@salesforce/lds-runtime-mobile 1.162.1 → 1.163.1

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.
package/dist/main.js CHANGED
@@ -19,6 +19,7 @@ import { parseAndVisit, Kind, visit, execute, buildSchema, isObjectType, default
19
19
  import { getRecordId18, keyBuilderQuickActionExecutionRepresentation, ingestQuickActionExecutionRepresentation, keyBuilderContentDocumentCompositeRepresentation, getResponseCacheKeysContentDocumentCompositeRepresentation, keyBuilderFromTypeContentDocumentCompositeRepresentation, ingestContentDocumentCompositeRepresentation, keyBuilderRecord, getTypeCacheKeysRecord, keyBuilderFromTypeRecordRepresentation, ingestRecord, RecordRepresentationRepresentationType, ObjectInfoRepresentationType, getRecordAdapterFactory, getObjectInfoAdapterFactory, getObjectInfosAdapterFactory, UiApiNamespace, RecordRepresentationType, RecordRepresentationTTL, RecordRepresentationVersion } from '@salesforce/lds-adapters-uiapi';
20
20
  import caseSensitiveUserId from '@salesforce/user/Id';
21
21
  import { idleDetector, getInstrumentation } from 'o11y/client';
22
+ import ldsUseShortUrlGate from '@salesforce/gate/lds.useShortUrl';
22
23
  import { instrument as instrument$1 } from '@salesforce/lds-bindings';
23
24
  import LOCALE from '@salesforce/i18n/locale';
24
25
  import CURRENCY from '@salesforce/i18n/currency';
@@ -13701,6 +13702,10 @@ class ScopedFieldsCollection {
13701
13702
  }
13702
13703
 
13703
13704
  const MAX_STRING_LENGTH_PER_CHUNK = 10000;
13705
+ //Salesforce/Akamai cdn uri max size is 8898 bytes, short than normal. Per
13706
+ //https://help.salesforce.com/s/articleView?id=sf.community_builder_cdn_considerations.htm&type=5
13707
+ //Due to we don't know the domain ResourceRequest, here we give 8000
13708
+ const MAX_URL_LENGTH = 8000;
13704
13709
  const PARSE_ERROR = 'PARSE_AGGREGATE_UI_RESPONSE_ERROR';
13705
13710
  function isErrorResponse(response) {
13706
13711
  return response.httpStatusCode >= 400;
@@ -13779,8 +13784,8 @@ function buildAggregateUiUrl(params, resourceRequest) {
13779
13784
  }
13780
13785
  return `${resourceRequest.baseUri}${resourceRequest.basePath}?${join$1.call(queryString, '&')}`;
13781
13786
  }
13782
- function shouldUseAggregateUiForFields(fieldsArray, optionalFieldsArray) {
13783
- return fieldsArray.length + optionalFieldsArray.length >= MAX_STRING_LENGTH_PER_CHUNK;
13787
+ function shouldUseAggregateUiForFields(fieldsArray, optionalFieldsArray, maxLengthPerChunk) {
13788
+ return fieldsArray.length + optionalFieldsArray.length >= maxLengthPerChunk;
13784
13789
  }
13785
13790
  function isSpanningRecord(fieldValue) {
13786
13791
  return fieldValue !== null && typeof fieldValue === 'object';
@@ -13843,14 +13848,15 @@ function createAggregateBatchRequestInfo(resourceRequest, endpoint) {
13843
13848
  if (fieldsArray.length === 0 && optionalFieldsArray.length === 0) {
13844
13849
  return undefined;
13845
13850
  }
13851
+ const allowedMaxStringLengthPerChunk = getMaxLengthPerChunkAllowed(resourceRequest);
13846
13852
  const fieldsString = fieldsArray.join(',');
13847
13853
  const optionalFieldsString = optionalFieldsArray.join(',');
13848
- const shouldUseAggregate = shouldUseAggregateUiForFields(fieldsString, optionalFieldsString);
13854
+ const shouldUseAggregate = shouldUseAggregateUiForFields(fieldsString, optionalFieldsString, allowedMaxStringLengthPerChunk);
13849
13855
  if (!shouldUseAggregate) {
13850
13856
  return undefined;
13851
13857
  }
13852
- const fieldCollection = ScopedFieldsCollection.fromQueryParameterValue(fieldsString).split(MAX_STRING_LENGTH_PER_CHUNK);
13853
- const optionalFieldCollection = ScopedFieldsCollection.fromQueryParameterValue(optionalFieldsString).split(MAX_STRING_LENGTH_PER_CHUNK);
13858
+ const fieldCollection = ScopedFieldsCollection.fromQueryParameterValue(fieldsString).split(allowedMaxStringLengthPerChunk);
13859
+ const optionalFieldCollection = ScopedFieldsCollection.fromQueryParameterValue(optionalFieldsString).split(allowedMaxStringLengthPerChunk);
13854
13860
  return {
13855
13861
  fieldCollection,
13856
13862
  optionalFieldCollection,
@@ -13923,6 +13929,25 @@ function isGetRequestForEndpoint(endpoint, request) {
13923
13929
  function arrayOrEmpty(array) {
13924
13930
  return array !== undefined && isArray(array) ? array : [];
13925
13931
  }
13932
+ /**
13933
+ * Calculate the max lengh per chunk.
13934
+ * If useShortUrlGate is open, allow max chunk size is MAX_URL_LENGTH - the url without fields and optional fields in url.
13935
+ * Otherwise MAX_STRING_LENGTH_PER_CHUNK
13936
+ * @param resourceRequest
13937
+ * @returns
13938
+ */
13939
+ function getMaxLengthPerChunkAllowed(request) {
13940
+ if (!ldsUseShortUrlGate.isOpen({ fallback: false })) {
13941
+ return MAX_STRING_LENGTH_PER_CHUNK;
13942
+ }
13943
+ // Too much work to get exact length of the final url, so use stringified json to get the rough length.
13944
+ const roughUrlLengthWithoutFieldsAndOptionFields = request.basePath.length +
13945
+ request.baseUri.length +
13946
+ (request.urlParams ? stringify$1(request.urlParams).length : 0) +
13947
+ stringify$1({ ...request.queryParams, fields: {}, optionalFields: {} }).length;
13948
+ // MAX_URL_LENGTH - full lenght without fields, optionalFields
13949
+ return MAX_URL_LENGTH - roughUrlLengthWithoutFieldsAndOptionFields;
13950
+ }
13926
13951
 
13927
13952
  const RECORD_ENDPOINT_REGEX = /^\/ui-api\/records\/?(([a-zA-Z0-9]+))?$/;
13928
13953
  const referenceId$3 = 'LDS_Records_AggregateUi';
@@ -15234,10 +15259,11 @@ function makeEnvironmentGraphqlAware(environment) {
15234
15259
  if (eagerEvalStaleWhileRevalidate.isOpen({ fallback: false }) &&
15235
15260
  cachePolicy &&
15236
15261
  cachePolicy.type === 'stale-while-revalidate' &&
15237
- cachePolicy.staleDurationSeconds === Number.MAX_SAFE_INTEGER) {
15262
+ cachePolicy.staleDurationSeconds >= Number.MAX_SAFE_INTEGER) {
15238
15263
  localBuildCachedSnapshot = hoistUnfulfilledToStale;
15239
15264
  }
15240
- if (eagerEvalDefaultCachePolicy.isOpen({ fallback: false }) && cachePolicy === undefined) {
15265
+ if (eagerEvalDefaultCachePolicy.isOpen({ fallback: false }) &&
15266
+ (cachePolicy === undefined || cachePolicy === null)) {
15241
15267
  localBuildCachedSnapshot = hoistUnfulfilledToStale;
15242
15268
  }
15243
15269
  return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, localBuildCachedSnapshot, buildNetworkSnapshot);
@@ -16133,4 +16159,4 @@ register({
16133
16159
  });
16134
16160
 
16135
16161
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
16136
- // version: 1.162.1-f025549da
16162
+ // version: 1.163.1-a8f2dcd38
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.162.1",
3
+ "version": "1.163.1",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for mobile/hybrid environments.",
6
6
  "main": "dist/main.js",
package/sfdc/main.js CHANGED
@@ -19,6 +19,7 @@ import { parseAndVisit, Kind, visit, execute, buildSchema, isObjectType, default
19
19
  import { getRecordId18, keyBuilderQuickActionExecutionRepresentation, ingestQuickActionExecutionRepresentation, keyBuilderContentDocumentCompositeRepresentation, getResponseCacheKeysContentDocumentCompositeRepresentation, keyBuilderFromTypeContentDocumentCompositeRepresentation, ingestContentDocumentCompositeRepresentation, keyBuilderRecord, getTypeCacheKeysRecord, keyBuilderFromTypeRecordRepresentation, ingestRecord, RecordRepresentationRepresentationType, ObjectInfoRepresentationType, getRecordAdapterFactory, getObjectInfoAdapterFactory, getObjectInfosAdapterFactory, UiApiNamespace, RecordRepresentationType, RecordRepresentationTTL, RecordRepresentationVersion } from 'force/ldsAdaptersUiapi';
20
20
  import caseSensitiveUserId from '@salesforce/user/Id';
21
21
  import { idleDetector, getInstrumentation } from 'o11y/client';
22
+ import ldsUseShortUrlGate from '@salesforce/gate/lds.useShortUrl';
22
23
  import { instrument as instrument$1 } from 'force/ldsBindings';
23
24
  import LOCALE from '@salesforce/i18n/locale';
24
25
  import CURRENCY from '@salesforce/i18n/currency';
@@ -13701,6 +13702,10 @@ class ScopedFieldsCollection {
13701
13702
  }
13702
13703
 
13703
13704
  const MAX_STRING_LENGTH_PER_CHUNK = 10000;
13705
+ //Salesforce/Akamai cdn uri max size is 8898 bytes, short than normal. Per
13706
+ //https://help.salesforce.com/s/articleView?id=sf.community_builder_cdn_considerations.htm&type=5
13707
+ //Due to we don't know the domain ResourceRequest, here we give 8000
13708
+ const MAX_URL_LENGTH = 8000;
13704
13709
  const PARSE_ERROR = 'PARSE_AGGREGATE_UI_RESPONSE_ERROR';
13705
13710
  function isErrorResponse(response) {
13706
13711
  return response.httpStatusCode >= 400;
@@ -13779,8 +13784,8 @@ function buildAggregateUiUrl(params, resourceRequest) {
13779
13784
  }
13780
13785
  return `${resourceRequest.baseUri}${resourceRequest.basePath}?${join$1.call(queryString, '&')}`;
13781
13786
  }
13782
- function shouldUseAggregateUiForFields(fieldsArray, optionalFieldsArray) {
13783
- return fieldsArray.length + optionalFieldsArray.length >= MAX_STRING_LENGTH_PER_CHUNK;
13787
+ function shouldUseAggregateUiForFields(fieldsArray, optionalFieldsArray, maxLengthPerChunk) {
13788
+ return fieldsArray.length + optionalFieldsArray.length >= maxLengthPerChunk;
13784
13789
  }
13785
13790
  function isSpanningRecord(fieldValue) {
13786
13791
  return fieldValue !== null && typeof fieldValue === 'object';
@@ -13843,14 +13848,15 @@ function createAggregateBatchRequestInfo(resourceRequest, endpoint) {
13843
13848
  if (fieldsArray.length === 0 && optionalFieldsArray.length === 0) {
13844
13849
  return undefined;
13845
13850
  }
13851
+ const allowedMaxStringLengthPerChunk = getMaxLengthPerChunkAllowed(resourceRequest);
13846
13852
  const fieldsString = fieldsArray.join(',');
13847
13853
  const optionalFieldsString = optionalFieldsArray.join(',');
13848
- const shouldUseAggregate = shouldUseAggregateUiForFields(fieldsString, optionalFieldsString);
13854
+ const shouldUseAggregate = shouldUseAggregateUiForFields(fieldsString, optionalFieldsString, allowedMaxStringLengthPerChunk);
13849
13855
  if (!shouldUseAggregate) {
13850
13856
  return undefined;
13851
13857
  }
13852
- const fieldCollection = ScopedFieldsCollection.fromQueryParameterValue(fieldsString).split(MAX_STRING_LENGTH_PER_CHUNK);
13853
- const optionalFieldCollection = ScopedFieldsCollection.fromQueryParameterValue(optionalFieldsString).split(MAX_STRING_LENGTH_PER_CHUNK);
13858
+ const fieldCollection = ScopedFieldsCollection.fromQueryParameterValue(fieldsString).split(allowedMaxStringLengthPerChunk);
13859
+ const optionalFieldCollection = ScopedFieldsCollection.fromQueryParameterValue(optionalFieldsString).split(allowedMaxStringLengthPerChunk);
13854
13860
  return {
13855
13861
  fieldCollection,
13856
13862
  optionalFieldCollection,
@@ -13923,6 +13929,25 @@ function isGetRequestForEndpoint(endpoint, request) {
13923
13929
  function arrayOrEmpty(array) {
13924
13930
  return array !== undefined && isArray(array) ? array : [];
13925
13931
  }
13932
+ /**
13933
+ * Calculate the max lengh per chunk.
13934
+ * If useShortUrlGate is open, allow max chunk size is MAX_URL_LENGTH - the url without fields and optional fields in url.
13935
+ * Otherwise MAX_STRING_LENGTH_PER_CHUNK
13936
+ * @param resourceRequest
13937
+ * @returns
13938
+ */
13939
+ function getMaxLengthPerChunkAllowed(request) {
13940
+ if (!ldsUseShortUrlGate.isOpen({ fallback: false })) {
13941
+ return MAX_STRING_LENGTH_PER_CHUNK;
13942
+ }
13943
+ // Too much work to get exact length of the final url, so use stringified json to get the rough length.
13944
+ const roughUrlLengthWithoutFieldsAndOptionFields = request.basePath.length +
13945
+ request.baseUri.length +
13946
+ (request.urlParams ? stringify$1(request.urlParams).length : 0) +
13947
+ stringify$1({ ...request.queryParams, fields: {}, optionalFields: {} }).length;
13948
+ // MAX_URL_LENGTH - full lenght without fields, optionalFields
13949
+ return MAX_URL_LENGTH - roughUrlLengthWithoutFieldsAndOptionFields;
13950
+ }
13926
13951
 
13927
13952
  const RECORD_ENDPOINT_REGEX = /^\/ui-api\/records\/?(([a-zA-Z0-9]+))?$/;
13928
13953
  const referenceId$3 = 'LDS_Records_AggregateUi';
@@ -15234,10 +15259,11 @@ function makeEnvironmentGraphqlAware(environment) {
15234
15259
  if (eagerEvalStaleWhileRevalidate.isOpen({ fallback: false }) &&
15235
15260
  cachePolicy &&
15236
15261
  cachePolicy.type === 'stale-while-revalidate' &&
15237
- cachePolicy.staleDurationSeconds === Number.MAX_SAFE_INTEGER) {
15262
+ cachePolicy.staleDurationSeconds >= Number.MAX_SAFE_INTEGER) {
15238
15263
  localBuildCachedSnapshot = hoistUnfulfilledToStale;
15239
15264
  }
15240
- if (eagerEvalDefaultCachePolicy.isOpen({ fallback: false }) && cachePolicy === undefined) {
15265
+ if (eagerEvalDefaultCachePolicy.isOpen({ fallback: false }) &&
15266
+ (cachePolicy === undefined || cachePolicy === null)) {
15241
15267
  localBuildCachedSnapshot = hoistUnfulfilledToStale;
15242
15268
  }
15243
15269
  return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, localBuildCachedSnapshot, buildNetworkSnapshot);
@@ -16133,4 +16159,4 @@ register({
16133
16159
  });
16134
16160
 
16135
16161
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
16136
- // version: 1.162.1-f025549da
16162
+ // version: 1.163.1-a8f2dcd38