@salesforce/lds-runtime-mobile 1.394.0 → 1.396.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.
Files changed (3) hide show
  1. package/dist/main.js +175 -24
  2. package/package.json +32 -32
  3. package/sfdc/main.js +175 -24
package/dist/main.js CHANGED
@@ -56314,6 +56314,14 @@ class CacheControlRequestRunner {
56314
56314
  }
56315
56315
  }
56316
56316
  class CacheControlCommand extends BaseCommand {
56317
+ /**
56318
+ * Creates a new CacheControlCommand instance
56319
+ *
56320
+ * @param services - Required services including cache controller and optional pub/sub service
56321
+ * @param services.cacheController - The cache controller service for managing cache operations
56322
+ * @param services.pubSub - Optional pub/sub service for cache invalidation notifications
56323
+ * @param services - Additional services specific to the implementation
56324
+ */
56317
56325
  constructor(services) {
56318
56326
  super();
56319
56327
  this.services = services;
@@ -56321,16 +56329,31 @@ class CacheControlCommand extends BaseCommand {
56321
56329
  this.keysUpdated = void 0;
56322
56330
  this._isInternalExecution = false;
56323
56331
  this.lastResult = void 0;
56324
- this.unsubscribeFromKeysImpl = () => void 0;
56332
+ this.unsubscribers = [];
56325
56333
  this.subscriptions = [];
56326
56334
  this.instantiationTime = Date.now() / 1e3;
56327
56335
  }
56328
56336
  get isInternalExecution() {
56329
56337
  return this._isInternalExecution;
56330
56338
  }
56339
+ /**
56340
+ * Executes the cache control command with optional overrides
56341
+ *
56342
+ * This method orchestrates the cache control flow by:
56343
+ * 1. Clearing any existing subscriptions
56344
+ * 2. Merging configuration overrides with the base strategy config
56345
+ * 3. Building a request runner for cache operations
56346
+ * 4. Executing the cache controller with the request runner
56347
+ * 5. Handling the result and setting up subscriptions if needed
56348
+ *
56349
+ * @param overrides - Optional execution overrides including timestamp and cache control config
56350
+ * @param overrides.now - Override the current timestamp for cache control calculations
56351
+ * @param overrides.cacheControlConfig - Override cache control strategy configuration
56352
+ * @returns A subscribable result containing either the cached/network data or an error
56353
+ */
56331
56354
  execute(overrides) {
56332
56355
  this.keysUpdated = void 0;
56333
- this.unsubscribeFromKeys();
56356
+ this.unsubscribe();
56334
56357
  const mergedCacheControlConfig = mergeCacheControlConfigs(
56335
56358
  this.cacheControlStrategyConfig,
56336
56359
  overrides
@@ -56352,6 +56375,17 @@ class CacheControlCommand extends BaseCommand {
56352
56375
  });
56353
56376
  });
56354
56377
  }
56378
+ /**
56379
+ * Handles the result from the cache controller and builds the appropriate subscribable result
56380
+ *
56381
+ * This method processes the cache controller execution result and determines the appropriate
56382
+ * response based on network errors, cache errors, and available data. It handles graceful
56383
+ * degradation scenarios where network data is available even when cache operations fail.
56384
+ *
56385
+ * @param result - The result from the cache controller execution
56386
+ * @param requestRunner - The request runner containing network data and errors
56387
+ * @returns A subscribable result with the appropriate data or error
56388
+ */
56355
56389
  handleCacheControllerResult(result, requestRunner) {
56356
56390
  const { networkError, networkData, returnData } = requestRunner;
56357
56391
  return this.publishUpdatedKeys().then(() => {
@@ -56387,11 +56421,21 @@ class CacheControlCommand extends BaseCommand {
56387
56421
  );
56388
56422
  }
56389
56423
  if (this.subscriptions.length > 0) {
56390
- this.subscribeToKeysUsed();
56424
+ this.subscribe();
56391
56425
  }
56392
56426
  return returnData;
56393
56427
  });
56394
56428
  }
56429
+ /**
56430
+ * Builds a request runner that orchestrates cache read, network request, and cache write operations
56431
+ *
56432
+ * The request runner encapsulates the three main operations:
56433
+ * 1. Reading from cache with subscription setup
56434
+ * 2. Requesting data from the network
56435
+ * 3. Writing network results to cache and recording keys
56436
+ *
56437
+ * @returns A configured request runner for the cache controller
56438
+ */
56395
56439
  buildRequestRunner() {
56396
56440
  return new CacheControlRequestRunner(
56397
56441
  (cache) => this.buildResultWithSubscribe(cache),
@@ -56399,6 +56443,15 @@ class CacheControlCommand extends BaseCommand {
56399
56443
  (cache, networkResult) => this.writeToCacheAndRecordKeys(cache, networkResult)
56400
56444
  );
56401
56445
  }
56446
+ /**
56447
+ * Publishes cache update events for keys that were modified during the operation
56448
+ *
56449
+ * This method notifies other parts of the system about cache changes by publishing
56450
+ * a 'cacheUpdate' event with the set of keys that were updated. This enables
56451
+ * cache invalidation and reactive updates across the application.
56452
+ *
56453
+ * @returns A promise that resolves when the update event is published (or immediately if no pub/sub service)
56454
+ */
56402
56455
  publishUpdatedKeys() {
56403
56456
  if (this.services.pubSub) {
56404
56457
  if (this.keysUpdated !== void 0 && this.keysUpdated.size > 0) {
@@ -56413,11 +56466,25 @@ class CacheControlCommand extends BaseCommand {
56413
56466
  get operationType() {
56414
56467
  return "query";
56415
56468
  }
56416
- subscribeToKeysUsed() {
56417
- this.unsubscribeFromKeys();
56469
+ /**
56470
+ * Subscribes to cache update and invalidation events for reactive updates
56471
+ *
56472
+ * This method sets up subscriptions to listen for changes that affect the data returned
56473
+ * by this Command.
56474
+ *
56475
+ * By default, it subscribes to two types of events on the PubSub service:
56476
+ * - 'cacheUpdate': Triggers a rebuild with the original instantiation time
56477
+ * - 'cacheInvalidation': Triggers a full refresh without time constraints
56478
+ *
56479
+ * This method can be extended by subclasses to add additional subscriptions.
56480
+ *
56481
+ * Note: ALL subscriptions should push an unsubscribe function to the unsubscribers array,
56482
+ * for the lifecycle to work correctly and avoid memory leaks.
56483
+ */
56484
+ subscribe() {
56485
+ this.unsubscribe();
56418
56486
  const { pubSub } = this.services;
56419
56487
  if (!pubSub) {
56420
- this.unsubscribeFromKeysImpl = () => void 0;
56421
56488
  return;
56422
56489
  }
56423
56490
  const rebuildUnsubscribe = pubSub.subscribe({
@@ -56432,21 +56499,58 @@ class CacheControlCommand extends BaseCommand {
56432
56499
  callback: () => this.rerun().then(() => void 0),
56433
56500
  keys: this.keysUsed
56434
56501
  });
56435
- this.unsubscribeFromKeysImpl = () => {
56436
- rebuildUnsubscribe();
56437
- refreshUnsubscribe();
56438
- };
56439
- return;
56502
+ this.unsubscribers.push(rebuildUnsubscribe, refreshUnsubscribe);
56440
56503
  }
56441
- unsubscribeFromKeys() {
56442
- this.unsubscribeFromKeysImpl();
56504
+ /**
56505
+ * Unsubscribes from all stored subscriptions
56506
+ *
56507
+ * This method calls all stored unsubscribe functions to clean up event listeners
56508
+ * and prevent memory leaks. It should be called when the command is no longer
56509
+ * needed and is also called before setting up new subscriptions.
56510
+ */
56511
+ unsubscribe() {
56512
+ while (this.unsubscribers.length > 0) {
56513
+ const unsubscriber = this.unsubscribers.pop();
56514
+ unsubscriber == null ? void 0 : unsubscriber();
56515
+ }
56443
56516
  }
56444
- // TODO: This should likely be abstract in v2. For v1, provide default comparison logic.
56517
+ /**
56518
+ * Compares two result values for equality to determine if a cache update should trigger a rerun
56519
+ *
56520
+ * This method is used to prevent unnecessary reruns when the cached data hasn't actually changed.
56521
+ * The default implementation uses deep equality comparison, but subclasses can override this
56522
+ * to provide more efficient or domain-specific comparison logic.
56523
+ *
56524
+ * @param result1 - The first result to compare
56525
+ * @param result2 - The second result to compare
56526
+ * @returns True if the results are equal, false otherwise
56527
+ *
56528
+ * @todo This should likely be abstract in v2. For v1, provide default comparison logic.
56529
+ */
56445
56530
  equals(result1, result2) {
56446
56531
  return deepEquals(result1, result2);
56447
56532
  }
56533
+ /**
56534
+ * Hook method called after a network request completes
56535
+ *
56536
+ * This method provides a point for subclasses to perform post-request operations
56537
+ * such as logging, metrics collection, or cleanup. The default implementation
56538
+ * is empty and can be overridden by subclasses as needed.
56539
+ *
56540
+ * @param _options - Request completion options
56541
+ * @param _options.statusCode - HTTP status code from the network response
56542
+ */
56448
56543
  async afterRequestHooks(_options) {
56449
56544
  }
56545
+ /**
56546
+ * Forces a refresh of the cached data by bypassing cache and fetching from network
56547
+ *
56548
+ * This method executes the command with a "no-cache" configuration, ensuring that
56549
+ * fresh data is fetched from the network regardless of cache state. It's useful
56550
+ * for scenarios where you need to ensure the most up-to-date data.
56551
+ *
56552
+ * @returns A refresh result indicating success or failure of the refresh operation
56553
+ */
56450
56554
  refresh() {
56451
56555
  return this.rerun({ cacheControlConfig: { type: "no-cache" } }).then((result) => {
56452
56556
  if (result.isErr()) {
@@ -56455,6 +56559,17 @@ class CacheControlCommand extends BaseCommand {
56455
56559
  return ok(void 0);
56456
56560
  });
56457
56561
  }
56562
+ /**
56563
+ * Writes network result to cache and records the keys that were updated
56564
+ *
56565
+ * This method wraps the cache write operation with key tracking functionality.
56566
+ * It uses a recordable cache wrapper to capture which keys are modified during
56567
+ * the write operation, then updates the internal tracking of used and updated keys.
56568
+ *
56569
+ * @param cache - The cache instance to write to
56570
+ * @param networkResult - The network result containing data to write to cache
56571
+ * @returns A result indicating success or failure of the write operation
56572
+ */
56458
56573
  writeToCacheAndRecordKeys(cache, networkResult) {
56459
56574
  const recordableCache = cache.record();
56460
56575
  return this.writeToCache(recordableCache, networkResult).then((result) => {
@@ -56463,6 +56578,16 @@ class CacheControlCommand extends BaseCommand {
56463
56578
  return ok(result);
56464
56579
  });
56465
56580
  }
56581
+ /**
56582
+ * Builds a subscribable result by reading from cache and setting up subscriptions
56583
+ *
56584
+ * This method reads data from the cache and wraps the result in a subscribable
56585
+ * structure that allows consumers to subscribe to updates. It also tracks which
56586
+ * cache keys were read for future invalidation purposes.
56587
+ *
56588
+ * @param cache - The readonly cache to read from
56589
+ * @returns A subscribable result containing the cached data or error
56590
+ */
56466
56591
  buildResultWithSubscribe(cache) {
56467
56592
  const recordableCache = cache.record();
56468
56593
  const result = this.readFromCache(recordableCache);
@@ -56490,23 +56615,35 @@ class CacheControlCommand extends BaseCommand {
56490
56615
  * the last known value. If a change is detected, the provided
56491
56616
  * callback is invoked.
56492
56617
  *
56493
- * @param keysRead - keys of interest that were read during readFromCache
56494
56618
  * @returns an unsubscribe function to stop watching for updates
56495
56619
  */
56496
56620
  buildSubscribe() {
56497
56621
  return (consumerCallback) => {
56498
56622
  if (this.subscriptions.length === 0 && this.operationType === "query") {
56499
- this.subscribeToKeysUsed();
56623
+ this.subscribe();
56500
56624
  }
56501
56625
  this.subscriptions.push(consumerCallback);
56502
56626
  return () => {
56503
56627
  this.subscriptions = this.subscriptions.filter((cb) => cb !== consumerCallback);
56504
56628
  if (this.subscriptions.length === 0) {
56505
- this.unsubscribeFromKeys();
56629
+ this.unsubscribe();
56506
56630
  }
56507
56631
  };
56508
56632
  };
56509
56633
  }
56634
+ /**
56635
+ * Re-runs the command execution with optional overrides and notifies subscribers of changes
56636
+ *
56637
+ * This method is called internally when cache updates occur that affect the command's data.
56638
+ * It executes the command with the provided overrides and compares the result with the
56639
+ * last known result. If the data has changed, it notifies all subscribers with the new data.
56640
+ *
56641
+ * The method handles deduplication to prevent unnecessary notifications when the data
56642
+ * hasn't actually changed, and properly manages the internal execution state.
56643
+ *
56644
+ * @param overrides - Optional execution overrides for the rerun
56645
+ * @returns A promise that resolves to the execution result
56646
+ */
56510
56647
  rerun(overrides) {
56511
56648
  this._isInternalExecution = true;
56512
56649
  return this.execute(overrides).then((result) => {
@@ -56523,6 +56660,15 @@ class CacheControlCommand extends BaseCommand {
56523
56660
  return result;
56524
56661
  });
56525
56662
  }
56663
+ /**
56664
+ * Invokes all registered consumer callbacks with the provided data
56665
+ *
56666
+ * This private method safely calls all registered subscriber callbacks with the
56667
+ * provided result data. It includes error handling to prevent callback failures
56668
+ * from affecting other callbacks or the overall system.
56669
+ *
56670
+ * @param data - The result data to send to all subscribers
56671
+ */
56526
56672
  invokeConsumerCallbacks(data) {
56527
56673
  this.subscriptions.forEach((cb) => {
56528
56674
  try {
@@ -58066,7 +58212,7 @@ function buildServiceDescriptor$5(luvio) {
58066
58212
  },
58067
58213
  };
58068
58214
  }
58069
- // version: 1.394.0-db58817a4e
58215
+ // version: 1.396.0-216c6e4547
58070
58216
 
58071
58217
  /**
58072
58218
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -58092,7 +58238,7 @@ function buildServiceDescriptor$4(notifyRecordUpdateAvailable, getNormalizedLuvi
58092
58238
  },
58093
58239
  };
58094
58240
  }
58095
- // version: 1.394.0-db58817a4e
58241
+ // version: 1.396.0-216c6e4547
58096
58242
 
58097
58243
  /*!
58098
58244
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -59185,7 +59331,7 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
59185
59331
  return this.runOriginalRequest();
59186
59332
  }
59187
59333
  if (this.subscriptions.length > 0) {
59188
- this.subscribeToKeysUsed();
59334
+ this.subscribe();
59189
59335
  }
59190
59336
  return returnData;
59191
59337
  });
@@ -59303,7 +59449,7 @@ class HttpGraphQLNormalizedCacheControlCommand extends HttpNormalizedCacheContro
59303
59449
  return this.runOriginalRequest();
59304
59450
  }
59305
59451
  if (this.subscriptions.length > 0) {
59306
- this.subscribeToKeysUsed();
59452
+ this.subscribe();
59307
59453
  }
59308
59454
  return returnData;
59309
59455
  });
@@ -59322,7 +59468,7 @@ function buildServiceDescriptor$2() {
59322
59468
  * All rights reserved.
59323
59469
  * For full license text, see the LICENSE.txt file
59324
59470
  */
59325
- function buildServiceDescriptor$1(interceptors = { request: [], response: [] }) {
59471
+ function buildServiceDescriptor$1(interceptors = { request: [], response: [] }, retryService) {
59326
59472
  return {
59327
59473
  type: "fetch",
59328
59474
  version: "1.0",
@@ -59332,7 +59478,12 @@ function buildServiceDescriptor$1(interceptors = { request: [], response: [] })
59332
59478
  (previousPromise, interceptor) => previousPromise.then(interceptor),
59333
59479
  resolvedPromiseLike$3(args)
59334
59480
  );
59335
- return pending.then((args2) => fetch(...args2)).then((response) => {
59481
+ return pending.then((args2) => {
59482
+ if (retryService) {
59483
+ return retryService.applyRetry(() => fetch(...args2));
59484
+ }
59485
+ return fetch(...args2);
59486
+ }).then((response) => {
59336
59487
  return responseInterceptors.reduce(
59337
59488
  (previousPromise, interceptor) => previousPromise.then(interceptor),
59338
59489
  resolvedPromiseLike$3(response)
@@ -60316,4 +60467,4 @@ register({
60316
60467
  });
60317
60468
 
60318
60469
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, initializeOneStore, registerReportObserver, reportGraphqlQueryParseError };
60319
- // version: 1.394.0-9f5a21c62e
60470
+ // version: 1.396.0-08650966f4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.394.0",
3
+ "version": "1.396.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for mobile/hybrid environments.",
6
6
  "main": "dist/main.js",
@@ -32,42 +32,42 @@
32
32
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-mobile"
33
33
  },
34
34
  "dependencies": {
35
- "@luvio/service-provisioner": "5.64.2",
36
- "@salesforce/lds-adapters-uiapi": "^1.394.0",
37
- "@salesforce/lds-bindings": "^1.394.0",
38
- "@salesforce/lds-instrumentation": "^1.394.0",
39
- "@salesforce/lds-luvio-service": "^1.394.0",
40
- "@salesforce/lds-luvio-uiapi-records-service": "^1.394.0",
35
+ "@luvio/service-provisioner": "5.65.1",
36
+ "@salesforce/lds-adapters-uiapi": "^1.396.0",
37
+ "@salesforce/lds-bindings": "^1.396.0",
38
+ "@salesforce/lds-instrumentation": "^1.396.0",
39
+ "@salesforce/lds-luvio-service": "^1.396.0",
40
+ "@salesforce/lds-luvio-uiapi-records-service": "^1.396.0",
41
41
  "@salesforce/user": "0.0.21",
42
42
  "o11y": "250.7.0",
43
43
  "o11y_schema": "256.126.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@luvio/command-aura-network": "5.64.2",
47
- "@luvio/command-aura-normalized-cache-control": "5.64.2",
48
- "@luvio/command-aura-resource-cache-control": "5.64.2",
49
- "@luvio/command-fetch-network": "5.64.2",
50
- "@luvio/command-http-normalized-cache-control": "5.64.2",
51
- "@luvio/command-network": "5.64.2",
52
- "@luvio/service-cache": "5.64.2",
53
- "@luvio/service-cache-control": "5.64.2",
54
- "@luvio/service-cache-inclusion-policy": "5.64.2",
55
- "@luvio/service-fetch-network": "5.64.2",
56
- "@luvio/service-instrument-command": "5.64.2",
57
- "@luvio/service-instrumentation": "5.64.2",
58
- "@luvio/service-pubsub": "5.64.2",
59
- "@luvio/service-store": "5.64.2",
60
- "@luvio/utils": "5.64.2",
61
- "@salesforce/lds-adapters-graphql": "^1.394.0",
62
- "@salesforce/lds-drafts": "^1.394.0",
63
- "@salesforce/lds-durable-records": "^1.394.0",
64
- "@salesforce/lds-network-adapter": "^1.394.0",
65
- "@salesforce/lds-network-nimbus": "^1.394.0",
66
- "@salesforce/lds-store-binary": "^1.394.0",
67
- "@salesforce/lds-store-nimbus": "^1.394.0",
68
- "@salesforce/lds-store-sql": "^1.394.0",
69
- "@salesforce/lds-utils-adapters": "^1.394.0",
70
- "@salesforce/nimbus-plugin-lds": "^1.394.0",
46
+ "@luvio/command-aura-network": "5.65.1",
47
+ "@luvio/command-aura-normalized-cache-control": "5.65.1",
48
+ "@luvio/command-aura-resource-cache-control": "5.65.1",
49
+ "@luvio/command-fetch-network": "5.65.1",
50
+ "@luvio/command-http-normalized-cache-control": "5.65.1",
51
+ "@luvio/command-network": "5.65.1",
52
+ "@luvio/service-cache": "5.65.1",
53
+ "@luvio/service-cache-control": "5.65.1",
54
+ "@luvio/service-cache-inclusion-policy": "5.65.1",
55
+ "@luvio/service-fetch-network": "5.65.1",
56
+ "@luvio/service-instrument-command": "5.65.1",
57
+ "@luvio/service-instrumentation": "5.65.1",
58
+ "@luvio/service-pubsub": "5.65.1",
59
+ "@luvio/service-store": "5.65.1",
60
+ "@luvio/utils": "5.65.1",
61
+ "@salesforce/lds-adapters-graphql": "^1.396.0",
62
+ "@salesforce/lds-drafts": "^1.396.0",
63
+ "@salesforce/lds-durable-records": "^1.396.0",
64
+ "@salesforce/lds-network-adapter": "^1.396.0",
65
+ "@salesforce/lds-network-nimbus": "^1.396.0",
66
+ "@salesforce/lds-store-binary": "^1.396.0",
67
+ "@salesforce/lds-store-nimbus": "^1.396.0",
68
+ "@salesforce/lds-store-sql": "^1.396.0",
69
+ "@salesforce/lds-utils-adapters": "^1.396.0",
70
+ "@salesforce/nimbus-plugin-lds": "^1.396.0",
71
71
  "babel-plugin-dynamic-import-node": "^2.3.3",
72
72
  "wait-for-expect": "^3.0.2"
73
73
  },
package/sfdc/main.js CHANGED
@@ -56314,6 +56314,14 @@ class CacheControlRequestRunner {
56314
56314
  }
56315
56315
  }
56316
56316
  class CacheControlCommand extends BaseCommand {
56317
+ /**
56318
+ * Creates a new CacheControlCommand instance
56319
+ *
56320
+ * @param services - Required services including cache controller and optional pub/sub service
56321
+ * @param services.cacheController - The cache controller service for managing cache operations
56322
+ * @param services.pubSub - Optional pub/sub service for cache invalidation notifications
56323
+ * @param services - Additional services specific to the implementation
56324
+ */
56317
56325
  constructor(services) {
56318
56326
  super();
56319
56327
  this.services = services;
@@ -56321,16 +56329,31 @@ class CacheControlCommand extends BaseCommand {
56321
56329
  this.keysUpdated = void 0;
56322
56330
  this._isInternalExecution = false;
56323
56331
  this.lastResult = void 0;
56324
- this.unsubscribeFromKeysImpl = () => void 0;
56332
+ this.unsubscribers = [];
56325
56333
  this.subscriptions = [];
56326
56334
  this.instantiationTime = Date.now() / 1e3;
56327
56335
  }
56328
56336
  get isInternalExecution() {
56329
56337
  return this._isInternalExecution;
56330
56338
  }
56339
+ /**
56340
+ * Executes the cache control command with optional overrides
56341
+ *
56342
+ * This method orchestrates the cache control flow by:
56343
+ * 1. Clearing any existing subscriptions
56344
+ * 2. Merging configuration overrides with the base strategy config
56345
+ * 3. Building a request runner for cache operations
56346
+ * 4. Executing the cache controller with the request runner
56347
+ * 5. Handling the result and setting up subscriptions if needed
56348
+ *
56349
+ * @param overrides - Optional execution overrides including timestamp and cache control config
56350
+ * @param overrides.now - Override the current timestamp for cache control calculations
56351
+ * @param overrides.cacheControlConfig - Override cache control strategy configuration
56352
+ * @returns A subscribable result containing either the cached/network data or an error
56353
+ */
56331
56354
  execute(overrides) {
56332
56355
  this.keysUpdated = void 0;
56333
- this.unsubscribeFromKeys();
56356
+ this.unsubscribe();
56334
56357
  const mergedCacheControlConfig = mergeCacheControlConfigs(
56335
56358
  this.cacheControlStrategyConfig,
56336
56359
  overrides
@@ -56352,6 +56375,17 @@ class CacheControlCommand extends BaseCommand {
56352
56375
  });
56353
56376
  });
56354
56377
  }
56378
+ /**
56379
+ * Handles the result from the cache controller and builds the appropriate subscribable result
56380
+ *
56381
+ * This method processes the cache controller execution result and determines the appropriate
56382
+ * response based on network errors, cache errors, and available data. It handles graceful
56383
+ * degradation scenarios where network data is available even when cache operations fail.
56384
+ *
56385
+ * @param result - The result from the cache controller execution
56386
+ * @param requestRunner - The request runner containing network data and errors
56387
+ * @returns A subscribable result with the appropriate data or error
56388
+ */
56355
56389
  handleCacheControllerResult(result, requestRunner) {
56356
56390
  const { networkError, networkData, returnData } = requestRunner;
56357
56391
  return this.publishUpdatedKeys().then(() => {
@@ -56387,11 +56421,21 @@ class CacheControlCommand extends BaseCommand {
56387
56421
  );
56388
56422
  }
56389
56423
  if (this.subscriptions.length > 0) {
56390
- this.subscribeToKeysUsed();
56424
+ this.subscribe();
56391
56425
  }
56392
56426
  return returnData;
56393
56427
  });
56394
56428
  }
56429
+ /**
56430
+ * Builds a request runner that orchestrates cache read, network request, and cache write operations
56431
+ *
56432
+ * The request runner encapsulates the three main operations:
56433
+ * 1. Reading from cache with subscription setup
56434
+ * 2. Requesting data from the network
56435
+ * 3. Writing network results to cache and recording keys
56436
+ *
56437
+ * @returns A configured request runner for the cache controller
56438
+ */
56395
56439
  buildRequestRunner() {
56396
56440
  return new CacheControlRequestRunner(
56397
56441
  (cache) => this.buildResultWithSubscribe(cache),
@@ -56399,6 +56443,15 @@ class CacheControlCommand extends BaseCommand {
56399
56443
  (cache, networkResult) => this.writeToCacheAndRecordKeys(cache, networkResult)
56400
56444
  );
56401
56445
  }
56446
+ /**
56447
+ * Publishes cache update events for keys that were modified during the operation
56448
+ *
56449
+ * This method notifies other parts of the system about cache changes by publishing
56450
+ * a 'cacheUpdate' event with the set of keys that were updated. This enables
56451
+ * cache invalidation and reactive updates across the application.
56452
+ *
56453
+ * @returns A promise that resolves when the update event is published (or immediately if no pub/sub service)
56454
+ */
56402
56455
  publishUpdatedKeys() {
56403
56456
  if (this.services.pubSub) {
56404
56457
  if (this.keysUpdated !== void 0 && this.keysUpdated.size > 0) {
@@ -56413,11 +56466,25 @@ class CacheControlCommand extends BaseCommand {
56413
56466
  get operationType() {
56414
56467
  return "query";
56415
56468
  }
56416
- subscribeToKeysUsed() {
56417
- this.unsubscribeFromKeys();
56469
+ /**
56470
+ * Subscribes to cache update and invalidation events for reactive updates
56471
+ *
56472
+ * This method sets up subscriptions to listen for changes that affect the data returned
56473
+ * by this Command.
56474
+ *
56475
+ * By default, it subscribes to two types of events on the PubSub service:
56476
+ * - 'cacheUpdate': Triggers a rebuild with the original instantiation time
56477
+ * - 'cacheInvalidation': Triggers a full refresh without time constraints
56478
+ *
56479
+ * This method can be extended by subclasses to add additional subscriptions.
56480
+ *
56481
+ * Note: ALL subscriptions should push an unsubscribe function to the unsubscribers array,
56482
+ * for the lifecycle to work correctly and avoid memory leaks.
56483
+ */
56484
+ subscribe() {
56485
+ this.unsubscribe();
56418
56486
  const { pubSub } = this.services;
56419
56487
  if (!pubSub) {
56420
- this.unsubscribeFromKeysImpl = () => void 0;
56421
56488
  return;
56422
56489
  }
56423
56490
  const rebuildUnsubscribe = pubSub.subscribe({
@@ -56432,21 +56499,58 @@ class CacheControlCommand extends BaseCommand {
56432
56499
  callback: () => this.rerun().then(() => void 0),
56433
56500
  keys: this.keysUsed
56434
56501
  });
56435
- this.unsubscribeFromKeysImpl = () => {
56436
- rebuildUnsubscribe();
56437
- refreshUnsubscribe();
56438
- };
56439
- return;
56502
+ this.unsubscribers.push(rebuildUnsubscribe, refreshUnsubscribe);
56440
56503
  }
56441
- unsubscribeFromKeys() {
56442
- this.unsubscribeFromKeysImpl();
56504
+ /**
56505
+ * Unsubscribes from all stored subscriptions
56506
+ *
56507
+ * This method calls all stored unsubscribe functions to clean up event listeners
56508
+ * and prevent memory leaks. It should be called when the command is no longer
56509
+ * needed and is also called before setting up new subscriptions.
56510
+ */
56511
+ unsubscribe() {
56512
+ while (this.unsubscribers.length > 0) {
56513
+ const unsubscriber = this.unsubscribers.pop();
56514
+ unsubscriber == null ? void 0 : unsubscriber();
56515
+ }
56443
56516
  }
56444
- // TODO: This should likely be abstract in v2. For v1, provide default comparison logic.
56517
+ /**
56518
+ * Compares two result values for equality to determine if a cache update should trigger a rerun
56519
+ *
56520
+ * This method is used to prevent unnecessary reruns when the cached data hasn't actually changed.
56521
+ * The default implementation uses deep equality comparison, but subclasses can override this
56522
+ * to provide more efficient or domain-specific comparison logic.
56523
+ *
56524
+ * @param result1 - The first result to compare
56525
+ * @param result2 - The second result to compare
56526
+ * @returns True if the results are equal, false otherwise
56527
+ *
56528
+ * @todo This should likely be abstract in v2. For v1, provide default comparison logic.
56529
+ */
56445
56530
  equals(result1, result2) {
56446
56531
  return deepEquals(result1, result2);
56447
56532
  }
56533
+ /**
56534
+ * Hook method called after a network request completes
56535
+ *
56536
+ * This method provides a point for subclasses to perform post-request operations
56537
+ * such as logging, metrics collection, or cleanup. The default implementation
56538
+ * is empty and can be overridden by subclasses as needed.
56539
+ *
56540
+ * @param _options - Request completion options
56541
+ * @param _options.statusCode - HTTP status code from the network response
56542
+ */
56448
56543
  async afterRequestHooks(_options) {
56449
56544
  }
56545
+ /**
56546
+ * Forces a refresh of the cached data by bypassing cache and fetching from network
56547
+ *
56548
+ * This method executes the command with a "no-cache" configuration, ensuring that
56549
+ * fresh data is fetched from the network regardless of cache state. It's useful
56550
+ * for scenarios where you need to ensure the most up-to-date data.
56551
+ *
56552
+ * @returns A refresh result indicating success or failure of the refresh operation
56553
+ */
56450
56554
  refresh() {
56451
56555
  return this.rerun({ cacheControlConfig: { type: "no-cache" } }).then((result) => {
56452
56556
  if (result.isErr()) {
@@ -56455,6 +56559,17 @@ class CacheControlCommand extends BaseCommand {
56455
56559
  return ok(void 0);
56456
56560
  });
56457
56561
  }
56562
+ /**
56563
+ * Writes network result to cache and records the keys that were updated
56564
+ *
56565
+ * This method wraps the cache write operation with key tracking functionality.
56566
+ * It uses a recordable cache wrapper to capture which keys are modified during
56567
+ * the write operation, then updates the internal tracking of used and updated keys.
56568
+ *
56569
+ * @param cache - The cache instance to write to
56570
+ * @param networkResult - The network result containing data to write to cache
56571
+ * @returns A result indicating success or failure of the write operation
56572
+ */
56458
56573
  writeToCacheAndRecordKeys(cache, networkResult) {
56459
56574
  const recordableCache = cache.record();
56460
56575
  return this.writeToCache(recordableCache, networkResult).then((result) => {
@@ -56463,6 +56578,16 @@ class CacheControlCommand extends BaseCommand {
56463
56578
  return ok(result);
56464
56579
  });
56465
56580
  }
56581
+ /**
56582
+ * Builds a subscribable result by reading from cache and setting up subscriptions
56583
+ *
56584
+ * This method reads data from the cache and wraps the result in a subscribable
56585
+ * structure that allows consumers to subscribe to updates. It also tracks which
56586
+ * cache keys were read for future invalidation purposes.
56587
+ *
56588
+ * @param cache - The readonly cache to read from
56589
+ * @returns A subscribable result containing the cached data or error
56590
+ */
56466
56591
  buildResultWithSubscribe(cache) {
56467
56592
  const recordableCache = cache.record();
56468
56593
  const result = this.readFromCache(recordableCache);
@@ -56490,23 +56615,35 @@ class CacheControlCommand extends BaseCommand {
56490
56615
  * the last known value. If a change is detected, the provided
56491
56616
  * callback is invoked.
56492
56617
  *
56493
- * @param keysRead - keys of interest that were read during readFromCache
56494
56618
  * @returns an unsubscribe function to stop watching for updates
56495
56619
  */
56496
56620
  buildSubscribe() {
56497
56621
  return (consumerCallback) => {
56498
56622
  if (this.subscriptions.length === 0 && this.operationType === "query") {
56499
- this.subscribeToKeysUsed();
56623
+ this.subscribe();
56500
56624
  }
56501
56625
  this.subscriptions.push(consumerCallback);
56502
56626
  return () => {
56503
56627
  this.subscriptions = this.subscriptions.filter((cb) => cb !== consumerCallback);
56504
56628
  if (this.subscriptions.length === 0) {
56505
- this.unsubscribeFromKeys();
56629
+ this.unsubscribe();
56506
56630
  }
56507
56631
  };
56508
56632
  };
56509
56633
  }
56634
+ /**
56635
+ * Re-runs the command execution with optional overrides and notifies subscribers of changes
56636
+ *
56637
+ * This method is called internally when cache updates occur that affect the command's data.
56638
+ * It executes the command with the provided overrides and compares the result with the
56639
+ * last known result. If the data has changed, it notifies all subscribers with the new data.
56640
+ *
56641
+ * The method handles deduplication to prevent unnecessary notifications when the data
56642
+ * hasn't actually changed, and properly manages the internal execution state.
56643
+ *
56644
+ * @param overrides - Optional execution overrides for the rerun
56645
+ * @returns A promise that resolves to the execution result
56646
+ */
56510
56647
  rerun(overrides) {
56511
56648
  this._isInternalExecution = true;
56512
56649
  return this.execute(overrides).then((result) => {
@@ -56523,6 +56660,15 @@ class CacheControlCommand extends BaseCommand {
56523
56660
  return result;
56524
56661
  });
56525
56662
  }
56663
+ /**
56664
+ * Invokes all registered consumer callbacks with the provided data
56665
+ *
56666
+ * This private method safely calls all registered subscriber callbacks with the
56667
+ * provided result data. It includes error handling to prevent callback failures
56668
+ * from affecting other callbacks or the overall system.
56669
+ *
56670
+ * @param data - The result data to send to all subscribers
56671
+ */
56526
56672
  invokeConsumerCallbacks(data) {
56527
56673
  this.subscriptions.forEach((cb) => {
56528
56674
  try {
@@ -58066,7 +58212,7 @@ function buildServiceDescriptor$5(luvio) {
58066
58212
  },
58067
58213
  };
58068
58214
  }
58069
- // version: 1.394.0-db58817a4e
58215
+ // version: 1.396.0-216c6e4547
58070
58216
 
58071
58217
  /**
58072
58218
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -58092,7 +58238,7 @@ function buildServiceDescriptor$4(notifyRecordUpdateAvailable, getNormalizedLuvi
58092
58238
  },
58093
58239
  };
58094
58240
  }
58095
- // version: 1.394.0-db58817a4e
58241
+ // version: 1.396.0-216c6e4547
58096
58242
 
58097
58243
  /*!
58098
58244
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -59185,7 +59331,7 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
59185
59331
  return this.runOriginalRequest();
59186
59332
  }
59187
59333
  if (this.subscriptions.length > 0) {
59188
- this.subscribeToKeysUsed();
59334
+ this.subscribe();
59189
59335
  }
59190
59336
  return returnData;
59191
59337
  });
@@ -59303,7 +59449,7 @@ class HttpGraphQLNormalizedCacheControlCommand extends HttpNormalizedCacheContro
59303
59449
  return this.runOriginalRequest();
59304
59450
  }
59305
59451
  if (this.subscriptions.length > 0) {
59306
- this.subscribeToKeysUsed();
59452
+ this.subscribe();
59307
59453
  }
59308
59454
  return returnData;
59309
59455
  });
@@ -59322,7 +59468,7 @@ function buildServiceDescriptor$2() {
59322
59468
  * All rights reserved.
59323
59469
  * For full license text, see the LICENSE.txt file
59324
59470
  */
59325
- function buildServiceDescriptor$1(interceptors = { request: [], response: [] }) {
59471
+ function buildServiceDescriptor$1(interceptors = { request: [], response: [] }, retryService) {
59326
59472
  return {
59327
59473
  type: "fetch",
59328
59474
  version: "1.0",
@@ -59332,7 +59478,12 @@ function buildServiceDescriptor$1(interceptors = { request: [], response: [] })
59332
59478
  (previousPromise, interceptor) => previousPromise.then(interceptor),
59333
59479
  resolvedPromiseLike$3(args)
59334
59480
  );
59335
- return pending.then((args2) => fetch(...args2)).then((response) => {
59481
+ return pending.then((args2) => {
59482
+ if (retryService) {
59483
+ return retryService.applyRetry(() => fetch(...args2));
59484
+ }
59485
+ return fetch(...args2);
59486
+ }).then((response) => {
59336
59487
  return responseInterceptors.reduce(
59337
59488
  (previousPromise, interceptor) => previousPromise.then(interceptor),
59338
59489
  resolvedPromiseLike$3(response)
@@ -60316,4 +60467,4 @@ register({
60316
60467
  });
60317
60468
 
60318
60469
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, initializeOneStore, registerReportObserver, reportGraphqlQueryParseError };
60319
- // version: 1.394.0-9f5a21c62e
60470
+ // version: 1.396.0-08650966f4