@salesforce/lds-runtime-aura 1.425.0 → 1.427.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.
@@ -40,7 +40,7 @@ import { instrument as instrument$5 } from '@lwc/state';
40
40
  import { withRegistration, register, setDefaultLuvio } from 'force/ldsEngine';
41
41
  import applyPredictionRequestLimit from '@salesforce/gate/lds.pdl.applyRequestLimit';
42
42
  import { pageScopedCache } from 'instrumentation/utility';
43
- import { createStorage, clearStorages, setDurableStorageImplementation } from 'force/ldsDurableStorage';
43
+ import { createStorage, clearStorages } from 'force/ldsDurableStorage';
44
44
  import lightningConnectEnabled from '@salesforce/gate/ui.services.LightningConnect.enabled';
45
45
  import bypassAppRestrictionEnabled from '@salesforce/gate/ui.services.LightningConnect.BypassAppRestriction.enabled';
46
46
  import csrfValidationEnabled from '@salesforce/gate/ui.services.LightningConnect.CsrfValidation.enabled';
@@ -49,7 +49,6 @@ import useHttpUiapiOneApp from '@salesforce/gate/lds.useHttpUiapiOneApp';
49
49
  import useHttpUiapiOneRuntime from '@salesforce/gate/lds.useHttpUiapiOneRuntime';
50
50
  import disableCreateContentDocumentAndVersionHTTPLexRuntime from '@salesforce/gate/lds.lex.http.disableCreateContentDocumentAndVersion';
51
51
  import useHotspotLimit from '@salesforce/gate/lds.pdl.useHotspotLimit';
52
- import { createStorage as createStorage$1, clearStorages as clearStorages$1 } from 'force/ldsStorage';
53
52
 
54
53
  /*!
55
54
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -814,14 +813,15 @@ class CacheControlCommand extends BaseCommand {
814
813
  return "query";
815
814
  }
816
815
  /**
817
- * Subscribes to cache update and invalidation events for reactive updates
816
+ * Subscribes to cache update, invalidation, and eviction events for reactive updates
818
817
  *
819
818
  * This method sets up subscriptions to listen for changes that affect the data returned
820
819
  * by this Command.
821
820
  *
822
- * By default, it subscribes to two types of events on the PubSub service:
821
+ * By default, it subscribes to three types of events on the PubSub service:
823
822
  * - 'cacheUpdate': Triggers a rebuild with the original instantiation time
824
- * - 'cacheInvalidation': Triggers a full refresh without time constraints
823
+ * - 'cacheInvalidation': Triggers a full refresh without time constraints (data marked stale)
824
+ * - 'cacheEviction': Triggers a full refresh without time constraints (data removed from cache)
825
825
  *
826
826
  * This method can be extended by subclasses to add additional subscriptions.
827
827
  *
@@ -846,7 +846,13 @@ class CacheControlCommand extends BaseCommand {
846
846
  callback: () => this.rerun().then(() => void 0),
847
847
  keys: this.keysUsed
848
848
  });
849
- this.unsubscribers.push(rebuildUnsubscribe, refreshUnsubscribe);
849
+ const evictionUnsubscribe = pubSub.subscribe({
850
+ type: "cacheEviction",
851
+ predicate: (event) => setOverlaps(event.data, this.keysUsed),
852
+ callback: () => this.rerun().then(() => void 0),
853
+ keys: this.keysUsed
854
+ });
855
+ this.unsubscribers.push(rebuildUnsubscribe, refreshUnsubscribe, evictionUnsubscribe);
850
856
  }
851
857
  /**
852
858
  * Unsubscribes from all stored subscriptions
@@ -2706,7 +2712,7 @@ function buildServiceDescriptor$d(luvio) {
2706
2712
  },
2707
2713
  };
2708
2714
  }
2709
- // version: 1.425.0-7665d4cffc
2715
+ // version: 1.427.0-d53a098e46
2710
2716
 
2711
2717
  /*!
2712
2718
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3059,7 +3065,7 @@ function buildServiceDescriptor$9(notifyRecordUpdateAvailable, getNormalizedLuvi
3059
3065
  },
3060
3066
  };
3061
3067
  }
3062
- // version: 1.425.0-7665d4cffc
3068
+ // version: 1.427.0-d53a098e46
3063
3069
 
3064
3070
  /*!
3065
3071
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -5695,7 +5701,7 @@ function getEnvironmentSetting(name) {
5695
5701
  }
5696
5702
  return undefined;
5697
5703
  }
5698
- // version: 1.425.0-7665d4cffc
5704
+ // version: 1.427.0-d53a098e46
5699
5705
 
5700
5706
  const environmentHasAura = typeof window !== 'undefined' && typeof window.$A !== 'undefined';
5701
5707
  const defaultConfig = {
@@ -9629,6 +9635,9 @@ function buildUpdate(update, existing) {
9629
9635
  );
9630
9636
  return updatedCacheControl !== void 0 ? { type: "metadata", metadata: updatedCacheControl } : { type: "no-op" };
9631
9637
  }
9638
+ case "evict": {
9639
+ return { type: "delete" };
9640
+ }
9632
9641
  default:
9633
9642
  throw new Error(`Invalid update operation: ${update.type}`);
9634
9643
  }
@@ -9701,6 +9710,13 @@ class InMemoryCacheInclusionPolicy extends CacheInclusionPolicyService {
9701
9710
  });
9702
9711
  yield key;
9703
9712
  break;
9713
+ case "delete":
9714
+ this.write({
9715
+ l1: cache,
9716
+ writeToL1: (l1) => resolvedPromiseLike(ok(l1.delete(key)))
9717
+ });
9718
+ yield key;
9719
+ break;
9704
9720
  }
9705
9721
  }
9706
9722
  }
@@ -9972,6 +9988,10 @@ class AuraDurableCacheInclusionPolicy extends DurableCacheInclusionPolicy {
9972
9988
  * Find and modify entries matching a query
9973
9989
  * @param query - Cache query to match entries
9974
9990
  * @param cacheUpdate - Update to apply to matching entries
9991
+ *
9992
+ * Note: This method does not publish cache events. Callers should publish
9993
+ * appropriate cache events (e.g., 'cacheEviction') after eviction operations
9994
+ * to notify subscribers.
9975
9995
  */
9976
9996
  async *findAndModify(query, cacheUpdate) {
9977
9997
  if (!this.storage) {
@@ -9982,28 +10002,51 @@ class AuraDurableCacheInclusionPolicy extends DurableCacheInclusionPolicy {
9982
10002
  // Cannot pass specific keys since we don't know which entries match the query
9983
10003
  const allStoredData = (await this.storage.getAll());
9984
10004
  const modifiedEntries = [];
9985
- // Find and modify matching entries
10005
+ const deletedEntries = [];
10006
+ // Find and process matching entries
9986
10007
  for (const [storageKey, storedEntry] of Object.entries(allStoredData)) {
9987
10008
  const entry = storedEntry;
9988
10009
  const key = storageKey;
9989
10010
  if (entry && this.matchesQuery(key, entry, query)) {
9990
10011
  // Apply the update to the entry
9991
10012
  const updatedEntry = this.applyUpdate(entry, cacheUpdate);
9992
- if (updatedEntry) {
9993
- modifiedEntries.push({ storageKey, entry: updatedEntry, modifiedKey: key });
10013
+ if (updatedEntry.status === 'modified') {
10014
+ modifiedEntries.push({
10015
+ storageKey,
10016
+ entry: updatedEntry.entry,
10017
+ modifiedKey: key,
10018
+ });
9994
10019
  }
10020
+ else if (updatedEntry.status === 'deleted') {
10021
+ deletedEntries.push({ storageKey, deletedKey: key });
10022
+ }
10023
+ // 'no-op' case: do nothing
9995
10024
  }
9996
10025
  }
10026
+ let promises = [];
9997
10027
  // Save all modified entries back to storage
9998
10028
  if (modifiedEntries.length > 0 && this.storage) {
9999
- const promises = modifiedEntries.map(({ storageKey, entry }) => this.storage.set(storageKey, entry).catch((error) => {
10029
+ promises = modifiedEntries.map(({ storageKey, entry }) => this.storage.set(storageKey, entry).catch((error) => {
10000
10030
  console.warn(`Failed to update cache entry: ${storageKey}`, error);
10001
10031
  }));
10002
- await Promise.all(promises);
10003
- // Yield all modified keys
10004
- for (const { modifiedKey } of modifiedEntries) {
10005
- yield modifiedKey;
10006
- }
10032
+ }
10033
+ // Handle deleted entries
10034
+ if (deletedEntries.length > 0 && this.storage) {
10035
+ const keysToDelete = deletedEntries.map(({ storageKey }) => storageKey);
10036
+ promises.push(this.storage.removeAll(keysToDelete)
10037
+ .catch((error) => {
10038
+ console.warn(`Failed to remove cache entries: ${keysToDelete.join(', ')}`, error);
10039
+ })
10040
+ .then(() => { }));
10041
+ }
10042
+ await Promise.all(promises);
10043
+ // Yield all modified keys
10044
+ for (const { modifiedKey } of modifiedEntries) {
10045
+ yield modifiedKey;
10046
+ }
10047
+ // Yield all deleted keys
10048
+ for (const { deletedKey } of deletedEntries) {
10049
+ yield deletedKey;
10007
10050
  }
10008
10051
  }
10009
10052
  catch (error) {
@@ -10018,7 +10061,7 @@ class AuraDurableCacheInclusionPolicy extends DurableCacheInclusionPolicy {
10018
10061
  * @returns true if the entry matches the query
10019
10062
  */
10020
10063
  matchesQuery(key, entry, query) {
10021
- if (!query)
10064
+ if (!query || Object.keys(query).length === 0)
10022
10065
  return true;
10023
10066
  // Handle logical operators
10024
10067
  if (this.isAndQuery(query)) {
@@ -10076,32 +10119,37 @@ class AuraDurableCacheInclusionPolicy extends DurableCacheInclusionPolicy {
10076
10119
  * Apply an update to a cache entry
10077
10120
  * @param entry - Original cache entry
10078
10121
  * @param update - Update to apply
10079
- * @returns Updated entry or null if no update needed
10122
+ * @returns Object indicating the result: modified entry, deleted marker, or no-op
10080
10123
  */
10081
10124
  applyUpdate(entry, update) {
10082
10125
  try {
10083
10126
  const updateResult = this.buildUpdate(update, entry);
10084
10127
  switch (updateResult.type) {
10085
10128
  case 'entry':
10086
- return updateResult.entry;
10129
+ return { status: 'modified', entry: updateResult.entry };
10087
10130
  case 'metadata':
10088
10131
  // Create a new entry with updated metadata
10089
10132
  return {
10090
- ...entry,
10091
- metadata: {
10092
- ...entry.metadata,
10093
- cacheControl: updateResult.metadata,
10133
+ status: 'modified',
10134
+ entry: {
10135
+ ...entry,
10136
+ metadata: {
10137
+ ...entry.metadata,
10138
+ cacheControl: updateResult.metadata,
10139
+ },
10094
10140
  },
10095
10141
  };
10142
+ case 'delete':
10143
+ return { status: 'deleted' };
10096
10144
  case 'no-op':
10097
- return null; // No changes needed
10145
+ return { status: 'no-op' };
10098
10146
  default:
10099
- return null;
10147
+ return { status: 'no-op' };
10100
10148
  }
10101
10149
  }
10102
10150
  catch (error) {
10103
10151
  console.warn('Failed to apply update to cache entry:', error);
10104
- return null;
10152
+ return { status: 'no-op' };
10105
10153
  }
10106
10154
  }
10107
10155
  /**
@@ -10117,6 +10165,9 @@ class AuraDurableCacheInclusionPolicy extends DurableCacheInclusionPolicy {
10117
10165
  return updatedCacheControl !== undefined
10118
10166
  ? { type: 'metadata', metadata: updatedCacheControl }
10119
10167
  : { type: 'no-op' };
10168
+ case 'evict':
10169
+ // Eviction removes the entry entirely from storage
10170
+ return { type: 'delete' };
10120
10171
  default:
10121
10172
  throw new Error(`Invalid update operation: ${update.type}`);
10122
10173
  }
@@ -10355,10 +10406,6 @@ function buildPredictorForContext(context) {
10355
10406
  };
10356
10407
  }
10357
10408
  function initializeLDS() {
10358
- setDurableStorageImplementation({
10359
- createStorage: createStorage$1,
10360
- clearStorages: clearStorages$1,
10361
- });
10362
10409
  const storeOptions = {
10363
10410
  scheduler: () => { },
10364
10411
  };
@@ -10485,4 +10532,4 @@ function ldsEngineCreator() {
10485
10532
  }
10486
10533
 
10487
10534
  export { LexRequestStrategy, PdlPrefetcherEventType, PdlRequestPriority, buildPredictorForContext, configService, ldsEngineCreator as default, initializeLDS, initializeOneStore, notifyUpdateAvailableFactory, registerRequestStrategy, saveRequestAsPrediction, subscribeToPrefetcherEvents, unregisterRequestStrategy, whenPredictionsReady };
10488
- // version: 1.425.0-c433405ee2
10535
+ // version: 1.427.0-281d684cba
@@ -0,0 +1,5 @@
1
+ /// <reference types="jest" />
2
+ export declare const createStorage: jest.Mock<any, any, any>;
3
+ export declare const clearStorages: jest.Mock<any, any, any>;
4
+ export declare const setDurableStorageImplementation: jest.Mock<any, any, any>;
5
+ export declare const getDurableStorageImplementation: jest.Mock<any, any, any>;
@@ -34,6 +34,10 @@ export declare class AuraDurableCacheInclusionPolicy extends DurableCacheInclusi
34
34
  * Find and modify entries matching a query
35
35
  * @param query - Cache query to match entries
36
36
  * @param cacheUpdate - Update to apply to matching entries
37
+ *
38
+ * Note: This method does not publish cache events. Callers should publish
39
+ * appropriate cache events (e.g., 'cacheEviction') after eviction operations
40
+ * to notify subscribers.
37
41
  */
38
42
  findAndModify(query: CacheQuery, cacheUpdate: CacheUpdate): AsyncGenerator<Key, void, unknown>;
39
43
  /**
@@ -53,7 +57,7 @@ export declare class AuraDurableCacheInclusionPolicy extends DurableCacheInclusi
53
57
  * Apply an update to a cache entry
54
58
  * @param entry - Original cache entry
55
59
  * @param update - Update to apply
56
- * @returns Updated entry or null if no update needed
60
+ * @returns Object indicating the result: modified entry, deleted marker, or no-op
57
61
  */
58
62
  private applyUpdate;
59
63
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-aura",
3
- "version": "1.425.0",
3
+ "version": "1.427.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS engine for Aura runtime",
6
6
  "main": "dist/ldsEngineCreator.js",
@@ -34,51 +34,51 @@
34
34
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-aura"
35
35
  },
36
36
  "devDependencies": {
37
- "@conduit-client/service-provisioner": "3.17.3",
38
- "@conduit-client/tools-core": "3.17.3",
39
- "@salesforce/lds-adapters-apex": "^1.425.0",
40
- "@salesforce/lds-adapters-uiapi": "^1.425.0",
41
- "@salesforce/lds-ads-bridge": "^1.425.0",
42
- "@salesforce/lds-aura-storage": "^1.425.0",
43
- "@salesforce/lds-bindings": "^1.425.0",
44
- "@salesforce/lds-instrumentation": "^1.425.0",
45
- "@salesforce/lds-network-aura": "^1.425.0",
46
- "@salesforce/lds-network-fetch": "^1.425.0",
37
+ "@conduit-client/service-provisioner": "3.18.0",
38
+ "@conduit-client/tools-core": "3.18.0",
39
+ "@salesforce/lds-adapters-apex": "^1.427.0",
40
+ "@salesforce/lds-adapters-uiapi": "^1.427.0",
41
+ "@salesforce/lds-ads-bridge": "^1.427.0",
42
+ "@salesforce/lds-aura-storage": "^1.427.0",
43
+ "@salesforce/lds-bindings": "^1.427.0",
44
+ "@salesforce/lds-instrumentation": "^1.427.0",
45
+ "@salesforce/lds-network-aura": "^1.427.0",
46
+ "@salesforce/lds-network-fetch": "^1.427.0",
47
47
  "jwt-encode": "1.0.1"
48
48
  },
49
49
  "dependencies": {
50
- "@conduit-client/command-aura-graphql-normalized-cache-control": "3.17.3",
51
- "@conduit-client/command-aura-network": "3.17.3",
52
- "@conduit-client/command-aura-normalized-cache-control": "3.17.3",
53
- "@conduit-client/command-aura-resource-cache-control": "3.17.3",
54
- "@conduit-client/command-fetch-network": "3.17.3",
55
- "@conduit-client/command-http-graphql-normalized-cache-control": "3.17.3",
56
- "@conduit-client/command-http-normalized-cache-control": "3.17.3",
57
- "@conduit-client/command-ndjson": "3.17.3",
58
- "@conduit-client/command-network": "3.17.3",
59
- "@conduit-client/command-sse": "3.17.3",
60
- "@conduit-client/command-streaming": "3.17.3",
61
- "@conduit-client/service-aura-network": "3.17.3",
62
- "@conduit-client/service-bindings-imperative": "3.17.3",
63
- "@conduit-client/service-bindings-lwc": "3.17.3",
64
- "@conduit-client/service-cache": "3.17.3",
65
- "@conduit-client/service-cache-control": "3.17.3",
66
- "@conduit-client/service-cache-inclusion-policy": "3.17.3",
67
- "@conduit-client/service-config": "3.17.3",
68
- "@conduit-client/service-feature-flags": "3.17.3",
69
- "@conduit-client/service-fetch-network": "3.17.3",
70
- "@conduit-client/service-instrument-command": "3.17.3",
71
- "@conduit-client/service-pubsub": "3.17.3",
72
- "@conduit-client/service-store": "3.17.3",
73
- "@conduit-client/utils": "3.17.3",
50
+ "@conduit-client/command-aura-graphql-normalized-cache-control": "3.18.0",
51
+ "@conduit-client/command-aura-network": "3.18.0",
52
+ "@conduit-client/command-aura-normalized-cache-control": "3.18.0",
53
+ "@conduit-client/command-aura-resource-cache-control": "3.18.0",
54
+ "@conduit-client/command-fetch-network": "3.18.0",
55
+ "@conduit-client/command-http-graphql-normalized-cache-control": "3.18.0",
56
+ "@conduit-client/command-http-normalized-cache-control": "3.18.0",
57
+ "@conduit-client/command-ndjson": "3.18.0",
58
+ "@conduit-client/command-network": "3.18.0",
59
+ "@conduit-client/command-sse": "3.18.0",
60
+ "@conduit-client/command-streaming": "3.18.0",
61
+ "@conduit-client/service-aura-network": "3.18.0",
62
+ "@conduit-client/service-bindings-imperative": "3.18.0",
63
+ "@conduit-client/service-bindings-lwc": "3.18.0",
64
+ "@conduit-client/service-cache": "3.18.0",
65
+ "@conduit-client/service-cache-control": "3.18.0",
66
+ "@conduit-client/service-cache-inclusion-policy": "3.18.0",
67
+ "@conduit-client/service-config": "3.18.0",
68
+ "@conduit-client/service-feature-flags": "3.18.0",
69
+ "@conduit-client/service-fetch-network": "3.18.0",
70
+ "@conduit-client/service-instrument-command": "3.18.0",
71
+ "@conduit-client/service-pubsub": "3.18.0",
72
+ "@conduit-client/service-store": "3.18.0",
73
+ "@conduit-client/utils": "3.18.0",
74
74
  "@luvio/network-adapter-composable": "0.160.3",
75
75
  "@luvio/network-adapter-fetch": "0.160.3",
76
76
  "@lwc/state": "^0.29.0",
77
- "@salesforce/lds-adapters-onestore-graphql": "^1.425.0",
77
+ "@salesforce/lds-adapters-onestore-graphql": "^1.427.0",
78
78
  "@salesforce/lds-adapters-uiapi-lex": "^1.415.0",
79
- "@salesforce/lds-durable-storage": "^1.425.0",
80
- "@salesforce/lds-luvio-service": "^1.425.0",
81
- "@salesforce/lds-luvio-uiapi-records-service": "^1.425.0"
79
+ "@salesforce/lds-durable-storage": "^1.427.0",
80
+ "@salesforce/lds-luvio-service": "^1.427.0",
81
+ "@salesforce/lds-luvio-uiapi-records-service": "^1.427.0"
82
82
  },
83
83
  "luvioBundlesize": [
84
84
  {
@@ -1,6 +0,0 @@
1
- export declare function clearStorages(): Promise<void>;
2
- export declare function createStorage(): {
3
- getAll: jest.Mock<any, any, any>;
4
- get: jest.Mock<any, any, any>;
5
- set: jest.Mock<any, any, any>;
6
- };