@salesforce/lds-runtime-aura 1.404.0 → 1.409.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.
@@ -22,8 +22,9 @@ import useCmpDefPredictions from '@salesforce/gate/lds.pdl.useCmpDefPredictions'
22
22
  import applyPredictionRequestLimit from '@salesforce/gate/lds.pdl.applyRequestLimit';
23
23
  import useLocalStorage from '@salesforce/gate/lds.pdl.useLocalStorage';
24
24
  import useOneStoreGraphql from '@salesforce/gate/lds.oneStoreGraphqlEnabled.ltng';
25
+ import canCombineRecordLayoutRequests from '@salesforce/gate/lds.pdl.canCombineRecordLayoutRequests';
25
26
  import { GetApexWireAdapterFactory, registerPrefetcher as registerPrefetcher$1 } from 'force/ldsAdaptersApex';
26
- import { instrument, getRecordAvatarsAdapterFactory, getRecordAdapterFactory, coerceFieldIdArray, getRecordsAdapterFactory, getRecordActionsAdapterFactory, getObjectInfosAdapterFactory, coerceObjectIdArray, getObjectInfoAdapterFactory, coerceObjectId, getRelatedListsActionsAdapterFactory, getRelatedListInfoBatchAdapterFactory, getRelatedListInfoAdapterFactory, getRelatedListRecordsBatchAdapterFactory, getRelatedListRecordsAdapterFactory, getListInfoByNameAdapterFactory, getListInfosByObjectNameAdapterFactory, getListRecordsByNameAdapterFactory, getListObjectInfoAdapterFactory, getRelatedListsInfoAdapterFactory, getRelatedListActionsAdapterFactory, getRecordId18Array, buildRecordRepKeyFromId, configuration, InMemoryRecordRepresentationQueryEvaluator, UiApiNamespace, RecordRepresentationRepresentationType, registerPrefetcher, RecordRepresentationVersion } from 'force/ldsAdaptersUiapi';
27
+ import { instrument, getRecordAvatarsAdapterFactory, getRecordAdapterFactory, coerceFieldIdArray, coerceLayoutTypeArray, coerceLayoutModeArray, getRecordsAdapterFactory, getRecordActionsAdapterFactory, getObjectInfosAdapterFactory, coerceObjectIdArray, getObjectInfoAdapterFactory, coerceObjectId, getRelatedListsActionsAdapterFactory, getRelatedListInfoBatchAdapterFactory, getRelatedListInfoAdapterFactory, getRelatedListRecordsBatchAdapterFactory, getRelatedListRecordsAdapterFactory, getListInfoByNameAdapterFactory, getListInfosByObjectNameAdapterFactory, getListRecordsByNameAdapterFactory, getListObjectInfoAdapterFactory, getRelatedListsInfoAdapterFactory, getRelatedListActionsAdapterFactory, getRecordId18Array, buildRecordRepKeyFromId, configuration, InMemoryRecordRepresentationQueryEvaluator, UiApiNamespace, RecordRepresentationRepresentationType, registerPrefetcher, RecordRepresentationVersion } from 'force/ldsAdaptersUiapi';
27
28
  import { getInstrumentation } from 'o11y/client';
28
29
  import { findExecutableOperation, buildGraphQLInputExtension, addTypenameToDocument } from 'force/luvioGraphqlNormalization';
29
30
  import { print, wrapConfigAndVerify, resolveAst, validateGraphQLOperations } from 'force/luvioOnestoreGraphqlParser';
@@ -41,9 +42,14 @@ import { instrument as instrument$5 } from '@lwc/state';
41
42
  import { withRegistration, register, setDefaultLuvio } from 'force/ldsEngine';
42
43
  import { pageScopedCache } from 'instrumentation/utility';
43
44
  import { createStorage, clearStorages } from 'force/ldsStorage';
44
- import useHotspotLimit from '@salesforce/gate/lds.pdl.useHotspotLimit';
45
+ import lightningConnectEnabled from '@salesforce/gate/ui.services.LightningConnect.enabled';
46
+ import bypassAppRestrictionEnabled from '@salesforce/gate/ui.services.LightningConnect.BypassAppRestriction.enabled';
47
+ import csrfValidationEnabled from '@salesforce/gate/ui.services.LightningConnect.CsrfValidation.enabled';
48
+ import sessionApiEnabled from '@salesforce/gate/ui.uisdk.session.api.enabled';
45
49
  import useHttpUiapiOneApp from '@salesforce/gate/lds.useHttpUiapiOneApp';
46
50
  import useHttpUiapiOneRuntime from '@salesforce/gate/lds.useHttpUiapiOneRuntime';
51
+ import disableCreateContentDocumentAndVersionHTTPLexRuntime from '@salesforce/gate/lds.lex.http.disableCreateContentDocumentAndVersion';
52
+ import useHotspotLimit from '@salesforce/gate/lds.pdl.useHotspotLimit';
47
53
 
48
54
  /*!
49
55
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -2666,7 +2672,7 @@ function buildServiceDescriptor$d(luvio) {
2666
2672
  },
2667
2673
  };
2668
2674
  }
2669
- // version: 1.404.0-d0f3b5bc15
2675
+ // version: 1.409.0-355a528ce3
2670
2676
 
2671
2677
  /*!
2672
2678
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3004,7 +3010,7 @@ function buildServiceDescriptor$9(notifyRecordUpdateAvailable, getNormalizedLuvi
3004
3010
  },
3005
3011
  };
3006
3012
  }
3007
- // version: 1.404.0-d0f3b5bc15
3013
+ // version: 1.409.0-355a528ce3
3008
3014
 
3009
3015
  /*!
3010
3016
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -4707,7 +4713,7 @@ function getEnvironmentSetting(name) {
4707
4713
  }
4708
4714
  return undefined;
4709
4715
  }
4710
- // version: 1.404.0-d0f3b5bc15
4716
+ // version: 1.409.0-355a528ce3
4711
4717
 
4712
4718
  /**
4713
4719
  * Observability / Critical Availability Program (230+)
@@ -5715,19 +5721,240 @@ function buildLexRuntimeLuvio5xxStatusResponseInterceptor() {
5715
5721
  };
5716
5722
  }
5717
5723
 
5718
- const API_PATHS = [
5719
- // getLookupActions
5720
- // '/ui-api/actions/lookup/{objectApiNames}',
5721
- // getRecordActions
5722
- // '/ui-api/actions/record/{recordIds}',
5723
- // getRelatedListActions
5724
- // '/ui-api/actions/record/{recordIds}/related-list/{relatedListId}',
5725
- // getDuplicateConfiguration
5726
- // '/ui-api/duplicates/{objectApiName}',
5727
- // getListInfosByObjectName
5728
- // '/ui-api/list-info/{objectApiName}',
5729
- // getLookupRecords
5730
- // '/ui-api/lookups/{objectApiName}/{fieldApiName}',
5724
+ const CSRF_TOKEN_KEY = 'salesforce_csrf_token';
5725
+ const CSRF_STORAGE_NAME = 'ldsCSRFToken';
5726
+ const BASE_URI = '/services/data/v66.0';
5727
+ const UI_API_BASE_URI = `${BASE_URI}/ui-api`;
5728
+ const CSRF_TOKEN_ENDPOINT = `${UI_API_BASE_URI}/session/csrf`;
5729
+ const CSRF_STORAGE_CONFIG = {
5730
+ name: CSRF_STORAGE_NAME,
5731
+ persistent: true,
5732
+ secure: true,
5733
+ maxSize: 1024,
5734
+ expiration: 24 * 60 * 60,
5735
+ clearOnInit: false,
5736
+ debugLogging: false,
5737
+ };
5738
+ /**
5739
+ * Manages CSRF token fetching and caching for secure requests.
5740
+ * Implements a singleton pattern to ensure consistent token management across the application.
5741
+ */
5742
+ class CsrfTokenManager {
5743
+ constructor() {
5744
+ this.tokenPromise = null;
5745
+ // Initialize AuraStorage
5746
+ this.storage = createStorage(CSRF_STORAGE_CONFIG);
5747
+ }
5748
+ static getInstance() {
5749
+ if (!CsrfTokenManager.instance) {
5750
+ CsrfTokenManager.instance = new CsrfTokenManager();
5751
+ }
5752
+ return CsrfTokenManager.instance;
5753
+ }
5754
+ /**
5755
+ * Obtain a CSRF token, either from AuraStorage or by fetching a fresh one.
5756
+ *
5757
+ * @private
5758
+ */
5759
+ async loadOrFetchToken() {
5760
+ // First try to get token from AuraStorage
5761
+ if (this.storage) {
5762
+ try {
5763
+ const cachedToken = await this.storage.get(CSRF_TOKEN_KEY);
5764
+ if (typeof cachedToken === 'string' && cachedToken) {
5765
+ return cachedToken;
5766
+ }
5767
+ }
5768
+ catch {
5769
+ // If storage read fails, continue to fetch
5770
+ }
5771
+ }
5772
+ // No cached token, fetch from server
5773
+ return this.fetchFreshToken();
5774
+ }
5775
+ /**
5776
+ * Call API endpoint to acquire a CSRF token and cache it.
5777
+ *
5778
+ * @private
5779
+ */
5780
+ async fetchFreshToken() {
5781
+ try {
5782
+ const response = await fetch(CSRF_TOKEN_ENDPOINT, {
5783
+ method: 'GET',
5784
+ credentials: 'same-origin',
5785
+ });
5786
+ if (!response.ok) {
5787
+ return undefined;
5788
+ }
5789
+ const data = await response.json();
5790
+ const token = data.csrfToken;
5791
+ if (token && this.storage) {
5792
+ // Cache the token in AuraStorage
5793
+ try {
5794
+ await this.storage.set(CSRF_TOKEN_KEY, token);
5795
+ }
5796
+ catch {
5797
+ // Non-fatal: token is still available even if caching fails
5798
+ }
5799
+ }
5800
+ return token;
5801
+ }
5802
+ catch {
5803
+ return undefined;
5804
+ }
5805
+ }
5806
+ /**
5807
+ * Returns the current token value as a Promise.
5808
+ * Lazy-loads the token on first call (from cache or by fetching).
5809
+ */
5810
+ async getToken() {
5811
+ // Lazy initialization: only fetch token when actually needed
5812
+ if (!this.tokenPromise) {
5813
+ this.tokenPromise = this.loadOrFetchToken();
5814
+ }
5815
+ return this.tokenPromise;
5816
+ }
5817
+ /**
5818
+ * Obtains and returns a new token value as a promise.
5819
+ * This will clear the cached token and fetch a fresh one.
5820
+ */
5821
+ async refreshToken() {
5822
+ // Clear cached token
5823
+ if (this.storage) {
5824
+ try {
5825
+ await this.storage.remove(CSRF_TOKEN_KEY);
5826
+ }
5827
+ catch {
5828
+ // Non-fatal: continue with refresh even if clear fails
5829
+ }
5830
+ }
5831
+ // Fetch (and cache) fresh token
5832
+ this.tokenPromise = this.fetchFreshToken();
5833
+ return this.tokenPromise;
5834
+ }
5835
+ /**
5836
+ * Reset the singleton instance (useful for testing).
5837
+ * @internal
5838
+ */
5839
+ static resetInstance() {
5840
+ CsrfTokenManager.instance = null;
5841
+ }
5842
+ }
5843
+ CsrfTokenManager.instance = null;
5844
+
5845
+ const CSRF_TOKEN_HEADER = 'X-CSRF-Token';
5846
+ /**
5847
+ * Checks if all required gates are enabled for CSRF token interceptor.
5848
+ *
5849
+ * @returns true if all gates are enabled, false otherwise
5850
+ */
5851
+ function areCsrfGatesEnabled() {
5852
+ try {
5853
+ return (lightningConnectEnabled.isOpen({ fallback: false }) &&
5854
+ bypassAppRestrictionEnabled.isOpen({ fallback: false }) &&
5855
+ csrfValidationEnabled.isOpen({ fallback: false }) &&
5856
+ sessionApiEnabled.isOpen({ fallback: false }));
5857
+ }
5858
+ catch (error) {
5859
+ // If any gate check fails, disable CSRF interceptor
5860
+ return false;
5861
+ }
5862
+ }
5863
+ /**
5864
+ * Determines if the HTTP method requires CSRF protection.
5865
+ * Only mutating operations (POST, PUT, PATCH, DELETE) require CSRF tokens.
5866
+ *
5867
+ * @param method - The HTTP method to check
5868
+ * @returns true if the method requires CSRF protection
5869
+ */
5870
+ function isCsrfMethod(method) {
5871
+ if (!method) {
5872
+ return false;
5873
+ }
5874
+ const normalizedMethod = method.toLowerCase();
5875
+ return (normalizedMethod === 'post' ||
5876
+ normalizedMethod === 'put' ||
5877
+ normalizedMethod === 'patch' ||
5878
+ normalizedMethod === 'delete');
5879
+ }
5880
+ /**
5881
+ * Builds a request interceptor that adds CSRF token headers to mutating requests.
5882
+ * The CSRF token is fetched once and cached for subsequent requests.
5883
+ * Only POST, PUT, PATCH, and DELETE requests will have the CSRF token added.
5884
+ *
5885
+ * @returns A RequestInterceptor function for FetchParameters
5886
+ */
5887
+ function buildCsrfTokenInterceptor() {
5888
+ const csrfTokenManager = CsrfTokenManager.getInstance();
5889
+ return async (fetchArgs) => {
5890
+ // Check if all required gates are enabled before running
5891
+ if (!areCsrfGatesEnabled()) {
5892
+ return resolvedPromiseLike$2(fetchArgs);
5893
+ }
5894
+ const [urlOrRequest, options] = fetchArgs;
5895
+ // Determine the method from either Request object or options
5896
+ let method;
5897
+ if (typeof urlOrRequest !== 'string' && 'method' in urlOrRequest) {
5898
+ method = urlOrRequest.method;
5899
+ }
5900
+ else if (options && 'method' in options) {
5901
+ method = options.method;
5902
+ }
5903
+ // Only add CSRF token for mutating operations
5904
+ if (isCsrfMethod(method)) {
5905
+ const token = await csrfTokenManager.getToken();
5906
+ if (token) {
5907
+ fetchArgs = setHeader(CSRF_TOKEN_HEADER, token, fetchArgs);
5908
+ }
5909
+ }
5910
+ return resolvedPromiseLike$2(fetchArgs);
5911
+ };
5912
+ }
5913
+ /**
5914
+ * Builds a Luvio request interceptor that adds CSRF token headers to mutating requests.
5915
+ * The CSRF token is fetched once and cached for subsequent requests.
5916
+ * Only POST, PUT, PATCH, and DELETE requests will have the CSRF token added.
5917
+ *
5918
+ * @returns A request interceptor function for Luvio ResourceRequest objects
5919
+ */
5920
+ function buildLuvioCsrfTokenInterceptor() {
5921
+ const csrfTokenManager = CsrfTokenManager.getInstance();
5922
+ return async (resourceRequest) => {
5923
+ // Check if all required gates are enabled before running
5924
+ if (!areCsrfGatesEnabled()) {
5925
+ return resolvedPromiseLike$2(resourceRequest);
5926
+ }
5927
+ // Ensure headers object exists
5928
+ if (!resourceRequest.headers) {
5929
+ resourceRequest.headers = {};
5930
+ }
5931
+ // Only add CSRF token for mutating operations
5932
+ if (isCsrfMethod(resourceRequest.method)) {
5933
+ // Don't overwrite existing CSRF token header if it already exists
5934
+ if (!resourceRequest.headers[CSRF_TOKEN_HEADER]) {
5935
+ const token = await csrfTokenManager.getToken();
5936
+ if (token) {
5937
+ resourceRequest.headers[CSRF_TOKEN_HEADER] = token;
5938
+ }
5939
+ }
5940
+ }
5941
+ return resolvedPromiseLike$2(resourceRequest);
5942
+ };
5943
+ }
5944
+
5945
+ function isOneRuntime() {
5946
+ return !!globalThis.LWR;
5947
+ }
5948
+ /**
5949
+ * Base set of url paths that this adapter can serve via HTTP when enabled.
5950
+ * Extend this list to support additional endpoints (see predicate wiring below).
5951
+ *
5952
+ * Examples:
5953
+ * - Add another endpoint pattern:
5954
+ * "/ui-api/records/{recordId}"
5955
+ * - Keep placeholders for variable segments wrapped in "{}".
5956
+ */
5957
+ const UIAPI_PATHS = [
5731
5958
  // getObjectInfo
5732
5959
  '/ui-api/object-info/{objectApiName}',
5733
5960
  // getObjectInfos
@@ -5745,10 +5972,68 @@ const API_PATHS = [
5745
5972
  // getRelatedListRecords
5746
5973
  // '/ui-api/related-list-records/{parentRecordId}/{relatedListId}',
5747
5974
  ];
5748
- const API_PATH_MATCHERS = API_PATHS.map((path) => {
5749
- const regexString = path.replace(/\{.+?\}/g, '[^/]+');
5750
- return new RegExp(`^${regexString}$`);
5751
- });
5975
+ /**
5976
+ * Single content documents version URL enabled/disabled by killswitch.
5977
+ * Exported for reuse in tests.
5978
+ */
5979
+ const CONTENT_DOCUMENTS_VERSIONS_PATH = '/ui-api/records/content-documents/content-versions';
5980
+ /**
5981
+ * Configure which path sets are enabled under which conditions.
5982
+ *
5983
+ * To add a new condition:
5984
+ * - Define a new `predicate` function that returns true when your feature gate
5985
+ * or runtime environment should enable HTTP for its path set.
5986
+ * - Provide the list of `paths`
5987
+ *
5988
+ * Example:
5989
+ * {
5990
+ * predicate: () => myNewGate.isOpen({ fallback: false }),
5991
+ * paths: ['/ui-api/some-endpoint/{id}'],
5992
+ * }
5993
+ */
5994
+ const PREDICATE_PATH_SETS = [
5995
+ // One Runtime gate
5996
+ {
5997
+ predicate: () => isOneRuntime() && useHttpUiapiOneRuntime.isOpen({ fallback: false }),
5998
+ paths: UIAPI_PATHS,
5999
+ },
6000
+ // one.app gate
6001
+ {
6002
+ predicate: () => !isOneRuntime() && useHttpUiapiOneApp.isOpen({ fallback: false }),
6003
+ paths: UIAPI_PATHS,
6004
+ },
6005
+ // disableCreateContentDocumentAndVersionHTTPLexRuntime killswitch
6006
+ {
6007
+ predicate: () => !disableCreateContentDocumentAndVersionHTTPLexRuntime.isOpen({ fallback: false }),
6008
+ paths: [CONTENT_DOCUMENTS_VERSIONS_PATH],
6009
+ },
6010
+ ];
6011
+ function getEnabledPaths() {
6012
+ const enabled = new Set();
6013
+ for (const { predicate, paths } of PREDICATE_PATH_SETS) {
6014
+ if (predicate()) {
6015
+ for (const p of paths) {
6016
+ enabled.add(p);
6017
+ }
6018
+ }
6019
+ }
6020
+ return Array.from(enabled);
6021
+ }
6022
+ function buildMatchers(paths) {
6023
+ return paths.map((path) => {
6024
+ const regexString = path.replace(/\{.+?\}/g, '[^/]+');
6025
+ return new RegExp(`^${regexString}$`);
6026
+ });
6027
+ }
6028
+ // Precompute enabled path matchers at module load to avoid per-request rebuild
6029
+ const ENABLED_PATH_MATCHERS = buildMatchers(getEnabledPaths());
6030
+ /**
6031
+ * Indicates whether any predicate-enabled path sets are active.
6032
+ * Used by adapter composition to decide whether to include the fetch adapter.
6033
+ */
6034
+ function isFetchAdapterEnabled() {
6035
+ return getEnabledPaths().length > 0;
6036
+ }
5752
6037
  const requestTracker = {
5753
6038
  hasTracker: () => ThirdPartyTracker !== undefined,
5754
6039
  registerHandler: (request, name, loadedCheck) => {
@@ -5768,15 +6053,19 @@ const requestLogger = {
5768
6053
  },
5769
6054
  };
5770
6055
  const composedFetchNetworkAdapter = {
6056
+ /**
6057
+ * Handles only the enabled paths. The incoming path is normalized
6058
+ * (trailing slash removed) before matching against the precomputed matchers.
6059
+ */
5771
6060
  shouldHandleRequest(resourceRequest) {
5772
6061
  let path = resourceRequest.basePath.trim();
5773
6062
  if (path.endsWith('/')) {
5774
6063
  path = path.substring(0, path.length - 1);
5775
6064
  }
5776
- return API_PATH_MATCHERS.some((matcher) => matcher.test(path));
6065
+ return ENABLED_PATH_MATCHERS.some((matcher) => matcher.test(path));
5777
6066
  },
5778
6067
  adapter: setupLexNetworkAdapter(requestTracker, requestLogger, {
5779
- request: [buildLuvioPageScopedCacheRequestInterceptor()],
6068
+ request: [buildLuvioPageScopedCacheRequestInterceptor(), buildLuvioCsrfTokenInterceptor()],
5780
6069
  response: [
5781
6070
  buildLexRuntimeLuvio5xxStatusResponseInterceptor(),
5782
6071
  buildLexRuntimeLuvioAuthExpirationRedirectResponseInterceptor(),
@@ -5855,120 +6144,6 @@ function buildTransportMarksReceiveInterceptor() {
5855
6144
  };
5856
6145
  }
5857
6146
 
5858
- const CSRF_TOKEN_KEY = 'salesforce_csrf_token';
5859
- const CSRF_STORAGE_NAME = 'ldsCSRFToken';
5860
- const CSRF_STORAGE_CONFIG = {
5861
- name: CSRF_STORAGE_NAME,
5862
- persistent: true,
5863
- secure: true,
5864
- maxSize: 1024,
5865
- expiration: 24 * 60 * 60,
5866
- clearOnInit: false,
5867
- debugLogging: false,
5868
- };
5869
- /**
5870
- * Manages CSRF token fetching and caching for secure requests.
5871
- * Implements a singleton pattern to ensure consistent token management across the application.
5872
- */
5873
- class CsrfTokenManager {
5874
- constructor() {
5875
- // Initialize AuraStorage
5876
- this.storage = createStorage(CSRF_STORAGE_CONFIG);
5877
- // Try to load token from AuraStorage on initialization
5878
- this.tokenPromise = this.loadOrFetchToken();
5879
- }
5880
- static getInstance() {
5881
- if (!CsrfTokenManager.instance) {
5882
- CsrfTokenManager.instance = new CsrfTokenManager();
5883
- }
5884
- return CsrfTokenManager.instance;
5885
- }
5886
- /**
5887
- * Obtain a CSRF token, either from AuraStorage or by fetching a fresh one.
5888
- *
5889
- * @private
5890
- */
5891
- async loadOrFetchToken() {
5892
- // First try to get token from AuraStorage
5893
- if (this.storage) {
5894
- try {
5895
- const cachedToken = await this.storage.get(CSRF_TOKEN_KEY);
5896
- if (typeof cachedToken === 'string' && cachedToken) {
5897
- return cachedToken;
5898
- }
5899
- }
5900
- catch {
5901
- // If storage read fails, continue to fetch
5902
- }
5903
- }
5904
- // No cached token, fetch from server
5905
- return this.fetchFreshToken();
5906
- }
5907
- /**
5908
- * Call API endpoint to acquire a CSRF token and cache it.
5909
- *
5910
- * @private
5911
- */
5912
- async fetchFreshToken() {
5913
- try {
5914
- const response = await fetch('/session/csrf', {
5915
- method: 'GET',
5916
- credentials: 'same-origin',
5917
- });
5918
- if (!response.ok) {
5919
- return undefined;
5920
- }
5921
- const data = await response.json();
5922
- const token = data.csrfToken;
5923
- if (token && this.storage) {
5924
- // Cache the token in AuraStorage
5925
- try {
5926
- await this.storage.set(CSRF_TOKEN_KEY, token);
5927
- }
5928
- catch {
5929
- // Non-fatal: token is still available even if caching fails
5930
- }
5931
- }
5932
- return token;
5933
- }
5934
- catch {
5935
- return undefined;
5936
- }
5937
- }
5938
- /**
5939
- * Returns the current token value as a Promise.
5940
- */
5941
- async getToken() {
5942
- return this.tokenPromise;
5943
- }
5944
- /**
5945
- * Obtains and returns a new token value as a promise.
5946
- * This will clear the cached token and fetch a fresh one.
5947
- */
5948
- async refreshToken() {
5949
- // Clear cached token
5950
- if (this.storage) {
5951
- try {
5952
- await this.storage.remove(CSRF_TOKEN_KEY);
5953
- }
5954
- catch {
5955
- // Non-fatal: continue with refresh even if clear fails
5956
- }
5957
- }
5958
- // Fetch (and cache) fresh token
5959
- this.tokenPromise = this.fetchFreshToken();
5960
- return this.tokenPromise;
5961
- }
5962
- /**
5963
- * Reset the singleton instance (useful for testing).
5964
- * @internal
5965
- */
5966
- static resetInstance() {
5967
- CsrfTokenManager.instance = null;
5968
- }
5969
- }
5970
- CsrfTokenManager.instance = null;
5971
-
5972
6147
  const DEFAULT_CONFIG$1 = {
5973
6148
  maxRetries: 1, // Only retry once after token refresh
5974
6149
  };
@@ -6077,6 +6252,7 @@ function buildLexRuntimeDefaultFetchServiceDescriptor(logger, retryService) {
6077
6252
  buildThirdPartyTrackerRegisterInterceptor(),
6078
6253
  buildPageScopedCacheRequestInterceptor(),
6079
6254
  buildTransportMarksSendInterceptor(),
6255
+ buildCsrfTokenInterceptor(),
6080
6256
  ],
6081
6257
  response: [
6082
6258
  buildLexRuntime5xxStatusResponseInterceptor(logger),
@@ -6098,6 +6274,7 @@ function buildLexRuntimeAllow5xxFetchServiceDescriptor(logger, retryService) {
6098
6274
  buildThirdPartyTrackerRegisterInterceptor(),
6099
6275
  buildPageScopedCacheRequestInterceptor(),
6100
6276
  buildTransportMarksSendInterceptor(),
6277
+ buildCsrfTokenInterceptor(),
6101
6278
  ],
6102
6279
  response: [buildLexRuntimeAuthExpirationRedirectResponseInterceptor(logger)],
6103
6280
  finally: [
@@ -6691,9 +6868,31 @@ function isFieldsRequest(config) {
6691
6868
  config.modes === undefined &&
6692
6869
  (config.fields !== undefined || config.optionalFields !== undefined));
6693
6870
  }
6871
+ function isCombinableLayoutRequest(config) {
6872
+ // We will only consider a layout request combinable if it is a single layout type request
6873
+ // and the only request parameters are:
6874
+ // - layoutTypes
6875
+ // - optionalFields
6876
+ // - modes
6877
+ const hasExtraParams = config.childRelationships !== undefined ||
6878
+ config.pageSize !== undefined ||
6879
+ config.updateMru !== undefined;
6880
+ return config.layoutTypes !== undefined && !hasExtraParams;
6881
+ }
6882
+ function areCombinableLayoutRequests(reqA, reqB) {
6883
+ const normilizedLayoutTypesA = coerceLayoutTypeArray(reqA.layoutTypes) || [];
6884
+ const normilizedLayoutTypesB = coerceLayoutTypeArray(reqB.layoutTypes) || [];
6885
+ // Let's only combine when the layoutTypes are the same
6886
+ return (isCombinableLayoutRequest(reqA) &&
6887
+ isCombinableLayoutRequest(reqB) &&
6888
+ reqA.recordId === reqB.recordId &&
6889
+ normilizedLayoutTypesA.length === normilizedLayoutTypesB.length &&
6890
+ normilizedLayoutTypesA.every((type, index) => type === normilizedLayoutTypesB[index]));
6891
+ }
6694
6892
  class GetRecordRequestStrategy extends LuvioAdapterRequestStrategy {
6695
- constructor() {
6696
- super(...arguments);
6893
+ constructor(luvio, canCombineRecordLayoutRequests = false) {
6894
+ super(luvio);
6895
+ this.canCombineRecordLayoutRequests = canCombineRecordLayoutRequests;
6697
6896
  this.adapterName = GET_RECORD_ADAPTER_NAME;
6698
6897
  this.adapterFactory = getRecordAdapterFactory;
6699
6898
  }
@@ -6722,10 +6921,41 @@ class GetRecordRequestStrategy extends LuvioAdapterRequestStrategy {
6722
6921
  };
6723
6922
  }
6724
6923
  canCombine(reqA, reqB) {
6725
- // must be same record and
6726
- return reqA.recordId === reqB.recordId && isFieldsRequest(reqA) && isFieldsRequest(reqB);
6924
+ // must be same record and either both are fields requests or both are combinable layout requests
6925
+ return (reqA.recordId === reqB.recordId &&
6926
+ ((isFieldsRequest(reqA) && isFieldsRequest(reqB)) ||
6927
+ (this.canCombineRecordLayoutRequests && areCombinableLayoutRequests(reqA, reqB))));
6727
6928
  }
6728
6929
  combineRequests(reqA, reqB) {
6930
+ if (isFieldsRequest(reqA)) {
6931
+ return this.combineFieldsRequests(reqA, reqB);
6932
+ }
6933
+ else {
6934
+ return this.combineLayoutRequests(reqA, reqB);
6935
+ }
6936
+ }
6937
+ combineLayoutRequests(reqA, reqB) {
6938
+ const combined = {
6939
+ recordId: reqA.recordId,
6940
+ layoutTypes: coerceLayoutTypeArray(reqA.layoutTypes),
6941
+ };
6942
+ // combine Modes.
6943
+ // Note: the || ['View'] is important; it is to cover the case in which it needs to
6944
+ // combine mode: undefined (defaults to View) with mode: ['something else than View']
6945
+ const modeA = coerceLayoutModeArray(reqA.modes) || ['View'];
6946
+ const modeB = coerceLayoutModeArray(reqB.modes) || ['View'];
6947
+ if (reqA.modes !== undefined || reqB.modes !== undefined) {
6948
+ combined.modes = Array.from(new Set([...modeA, ...modeB]));
6949
+ }
6950
+ // combine Optional Fields.
6951
+ const optionalFieldsA = coerceFieldIdArray(reqA.optionalFields, COERCE_FIELD_ID_ARRAY_OPTIONS) || [];
6952
+ const optionalFieldsB = coerceFieldIdArray(reqB.optionalFields, COERCE_FIELD_ID_ARRAY_OPTIONS) || [];
6953
+ if (optionalFieldsA !== undefined || optionalFieldsB !== undefined) {
6954
+ combined.optionalFields = Array.from(new Set([...optionalFieldsA, ...optionalFieldsB]));
6955
+ }
6956
+ return combined;
6957
+ }
6958
+ combineFieldsRequests(reqA, reqB) {
6729
6959
  const fields = new Set();
6730
6960
  const optionalFields = new Set();
6731
6961
  if (reqA.fields !== undefined) {
@@ -8334,24 +8564,12 @@ function buildComposableNetworkAdapter(composedAdapters) {
8334
8564
  };
8335
8565
  }
8336
8566
 
8337
- function shouldUseHttp() {
8338
- // Check if we're in One Runtime (has LWR set)
8339
- const isOneRuntime = !!globalThis.LWR;
8340
- // If we're in One Runtime and the One Runtime gate is open, use HTTP
8341
- if (isOneRuntime && useHttpUiapiOneRuntime.isOpen({ fallback: false })) {
8342
- return true;
8343
- }
8344
- // If we're in one.app and the one.app gate is open, use HTTP
8345
- if (!isOneRuntime && useHttpUiapiOneApp.isOpen({ fallback: false })) {
8346
- return true;
8347
- }
8348
- return false;
8349
- }
8350
8567
  function getComposedAdapters() {
8351
8568
  const composedAdapters = [
8352
8569
  composedNetworkAdapter$1, // SFAP adapter
8353
8570
  ];
8354
- if (shouldUseHttp()) {
8571
+ // Add the UIAPI Fetch adapter if any of its API paths are enabled
8572
+ if (isFetchAdapterEnabled()) {
8355
8573
  composedAdapters.push(composedFetchNetworkAdapter); // UIAPI Fetch adapter
8356
8574
  }
8357
8575
  return composedAdapters;
@@ -9411,7 +9629,7 @@ function whenPredictionsReady(callback) {
9411
9629
  }
9412
9630
  function setupPredictivePrefetcher(luvio) {
9413
9631
  const allStrategies = [
9414
- new GetRecordRequestStrategy(luvio),
9632
+ new GetRecordRequestStrategy(luvio, canCombineRecordLayoutRequests.isOpen({ fallback: false })),
9415
9633
  new GetRecordsRequestStrategy(luvio),
9416
9634
  new GetRecordActionsRequestStrategy(luvio),
9417
9635
  new GetRecordAvatarsRequestStrategy(luvio),
@@ -9704,4 +9922,4 @@ function ldsEngineCreator() {
9704
9922
  }
9705
9923
 
9706
9924
  export { LexRequestStrategy, PdlRequestPriority, buildPredictorForContext, ldsEngineCreator as default, initializeLDS, initializeOneStore, notifyUpdateAvailableFactory, registerRequestStrategy, saveRequestAsPrediction, unregisterRequestStrategy, whenPredictionsReady };
9707
- // version: 1.404.0-fa9e7b68e4
9925
+ // version: 1.409.0-19a3d9bdf5
@@ -1,8 +1,32 @@
1
1
  import { type ResourceRequest } from '@luvio/engine';
2
2
  import type { RequestLogger, RequestTracker } from '@salesforce/lds-network-fetch';
3
+ /**
4
+ * Base set of url paths that this adapter can serve via HTTP when enabled.
5
+ * Extend this list to support additional endpoints (see predicate wiring below).
6
+ *
7
+ * Examples:
8
+ * - Add another endpoint pattern:
9
+ * "/ui-api/records/{recordId}"
10
+ * - Keep placeholders for variable segments wrapped in "{}".
11
+ */
12
+ export declare const UIAPI_PATHS: string[];
13
+ /**
14
+ * Single content documents version URL enabled/disabled by killswitch.
15
+ * Exported for reuse in tests.
16
+ */
17
+ export declare const CONTENT_DOCUMENTS_VERSIONS_PATH = "/ui-api/records/content-documents/content-versions";
18
+ /**
19
+ * Indicates whether any predicate-enabled path sets are active.
20
+ * Used by adapter composition to decide whether to include the fetch adapter.
21
+ */
22
+ export declare function isFetchAdapterEnabled(): boolean;
3
23
  export declare const instrumentationTracker: RequestTracker;
4
24
  export declare const requestLogger: RequestLogger;
5
25
  export declare const composedFetchNetworkAdapter: {
26
+ /**
27
+ * Handles only the enabled paths. The incoming path is normalized
28
+ * (trailing slash removed) before matching against the precomputed matchers.
29
+ */
6
30
  shouldHandleRequest(resourceRequest: ResourceRequest): boolean;
7
31
  adapter: import("@luvio/engine").NetworkAdapter;
8
32
  };
@@ -1,3 +1,4 @@
1
+ import type { Luvio } from '@luvio/engine';
1
2
  import type { GetRecordConfig } from '@salesforce/lds-adapters-uiapi';
2
3
  import { LuvioAdapterRequestStrategy } from './luvio-adapter-request-strategy';
3
4
  export type GetRecordRequest = {
@@ -9,12 +10,16 @@ type GetRecordContext = {
9
10
  };
10
11
  export declare const GET_RECORD_ADAPTER_NAME = "getRecord";
11
12
  export declare class GetRecordRequestStrategy extends LuvioAdapterRequestStrategy<GetRecordConfig, GetRecordRequest, GetRecordContext> {
13
+ private readonly canCombineRecordLayoutRequests;
12
14
  adapterName: string;
13
15
  adapterFactory: import("@luvio/engine").AdapterFactory<GetRecordConfig, import("@salesforce/lds-adapters-uiapi").RecordRepresentation>;
16
+ constructor(luvio: Luvio, canCombineRecordLayoutRequests?: boolean);
14
17
  buildConcreteRequest(similarRequest: GetRecordRequest, context: GetRecordContext): GetRecordRequest;
15
18
  transformForSave(request: GetRecordRequest): GetRecordRequest;
16
19
  canCombine(reqA: GetRecordConfig, reqB: GetRecordConfig): boolean;
17
20
  combineRequests(reqA: GetRecordConfig, reqB: GetRecordConfig): GetRecordConfig;
21
+ combineLayoutRequests(reqA: GetRecordConfig, reqB: GetRecordConfig): GetRecordConfig;
22
+ combineFieldsRequests(reqA: GetRecordConfig, reqB: GetRecordConfig): GetRecordConfig;
18
23
  isContextDependent(context: GetRecordContext, request: GetRecordRequest): boolean;
19
24
  transformForSaveSimilarRequest(request: GetRecordRequest): GetRecordRequest;
20
25
  }
@@ -22,6 +22,7 @@ declare class CsrfTokenManager {
22
22
  private fetchFreshToken;
23
23
  /**
24
24
  * Returns the current token value as a Promise.
25
+ * Lazy-loads the token on first call (from cache or by fetching).
25
26
  */
26
27
  getToken(): Promise<string | undefined>;
27
28
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-aura",
3
- "version": "1.404.0",
3
+ "version": "1.409.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS engine for Aura runtime",
6
6
  "main": "dist/ldsEngineCreator.js",
@@ -36,14 +36,14 @@
36
36
  "devDependencies": {
37
37
  "@conduit-client/service-provisioner": "3.2.0",
38
38
  "@conduit-client/tools-core": "3.2.0",
39
- "@salesforce/lds-adapters-apex": "^1.404.0",
40
- "@salesforce/lds-adapters-uiapi": "^1.404.0",
41
- "@salesforce/lds-ads-bridge": "^1.404.0",
42
- "@salesforce/lds-aura-storage": "^1.404.0",
43
- "@salesforce/lds-bindings": "^1.404.0",
44
- "@salesforce/lds-instrumentation": "^1.404.0",
45
- "@salesforce/lds-network-aura": "^1.404.0",
46
- "@salesforce/lds-network-fetch": "^1.404.0",
39
+ "@salesforce/lds-adapters-apex": "^1.409.0",
40
+ "@salesforce/lds-adapters-uiapi": "^1.409.0",
41
+ "@salesforce/lds-ads-bridge": "^1.409.0",
42
+ "@salesforce/lds-aura-storage": "^1.409.0",
43
+ "@salesforce/lds-bindings": "^1.409.0",
44
+ "@salesforce/lds-instrumentation": "^1.409.0",
45
+ "@salesforce/lds-network-aura": "^1.409.0",
46
+ "@salesforce/lds-network-fetch": "^1.409.0",
47
47
  "jwt-encode": "1.0.1"
48
48
  },
49
49
  "dependencies": {
@@ -59,6 +59,8 @@
59
59
  "@conduit-client/command-sse": "3.2.0",
60
60
  "@conduit-client/command-streaming": "3.2.0",
61
61
  "@conduit-client/service-aura-network": "3.2.0",
62
+ "@conduit-client/service-bindings-imperative": "3.2.0",
63
+ "@conduit-client/service-bindings-lwc": "3.2.0",
62
64
  "@conduit-client/service-cache": "3.2.0",
63
65
  "@conduit-client/service-cache-control": "3.2.0",
64
66
  "@conduit-client/service-cache-inclusion-policy": "3.2.0",
@@ -71,10 +73,10 @@
71
73
  "@luvio/network-adapter-composable": "0.158.7",
72
74
  "@luvio/network-adapter-fetch": "0.158.7",
73
75
  "@lwc/state": "^0.23.0",
74
- "@salesforce/lds-adapters-onestore-graphql": "^1.404.0",
75
- "@salesforce/lds-adapters-uiapi-lex": "^1.404.0",
76
- "@salesforce/lds-luvio-service": "^1.404.0",
77
- "@salesforce/lds-luvio-uiapi-records-service": "^1.404.0"
76
+ "@salesforce/lds-adapters-onestore-graphql": "^1.409.0",
77
+ "@salesforce/lds-adapters-uiapi-lex": "^1.409.0",
78
+ "@salesforce/lds-luvio-service": "^1.409.0",
79
+ "@salesforce/lds-luvio-uiapi-records-service": "^1.409.0"
78
80
  },
79
81
  "luvioBundlesize": [
80
82
  {
@@ -82,7 +84,7 @@
82
84
  "maxSize": {
83
85
  "none": "350 kB",
84
86
  "min": "190 kB",
85
- "compressed": "56 kB"
87
+ "compressed": "57 kB"
86
88
  }
87
89
  }
88
90
  ],