@salesforce/lds-network-nimbus 1.163.0 → 1.163.2
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
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { idleDetector } from 'o11y/client';
|
|
8
8
|
import { HttpStatusCode } from '@luvio/engine';
|
|
9
|
+
import ldsUseShortUrlGate from '@salesforce/gate/lds.useShortUrl';
|
|
9
10
|
|
|
10
11
|
const { keys, create, assign, entries } = Object;
|
|
11
12
|
const { stringify, parse } = JSON;
|
|
@@ -353,6 +354,10 @@ class ScopedFieldsCollection {
|
|
|
353
354
|
}
|
|
354
355
|
|
|
355
356
|
const MAX_STRING_LENGTH_PER_CHUNK = 10000;
|
|
357
|
+
//Salesforce/Akamai cdn uri max size is 8898 bytes, short than normal. Per
|
|
358
|
+
//https://help.salesforce.com/s/articleView?id=sf.community_builder_cdn_considerations.htm&type=5
|
|
359
|
+
//Due to we don't know the domain ResourceRequest, here we give 8000
|
|
360
|
+
const MAX_URL_LENGTH = 8000;
|
|
356
361
|
const PARSE_ERROR = 'PARSE_AGGREGATE_UI_RESPONSE_ERROR';
|
|
357
362
|
function isErrorResponse(response) {
|
|
358
363
|
return response.httpStatusCode >= 400;
|
|
@@ -431,8 +436,8 @@ function buildAggregateUiUrl(params, resourceRequest) {
|
|
|
431
436
|
}
|
|
432
437
|
return `${resourceRequest.baseUri}${resourceRequest.basePath}?${join.call(queryString, '&')}`;
|
|
433
438
|
}
|
|
434
|
-
function shouldUseAggregateUiForFields(fieldsArray, optionalFieldsArray) {
|
|
435
|
-
return fieldsArray.length + optionalFieldsArray.length >=
|
|
439
|
+
function shouldUseAggregateUiForFields(fieldsArray, optionalFieldsArray, maxLengthPerChunk) {
|
|
440
|
+
return fieldsArray.length + optionalFieldsArray.length >= maxLengthPerChunk;
|
|
436
441
|
}
|
|
437
442
|
function isSpanningRecord(fieldValue) {
|
|
438
443
|
return fieldValue !== null && typeof fieldValue === 'object';
|
|
@@ -495,14 +500,15 @@ function createAggregateBatchRequestInfo(resourceRequest, endpoint) {
|
|
|
495
500
|
if (fieldsArray.length === 0 && optionalFieldsArray.length === 0) {
|
|
496
501
|
return undefined;
|
|
497
502
|
}
|
|
503
|
+
const allowedMaxStringLengthPerChunk = getMaxLengthPerChunkAllowed(resourceRequest);
|
|
498
504
|
const fieldsString = fieldsArray.join(',');
|
|
499
505
|
const optionalFieldsString = optionalFieldsArray.join(',');
|
|
500
|
-
const shouldUseAggregate = shouldUseAggregateUiForFields(fieldsString, optionalFieldsString);
|
|
506
|
+
const shouldUseAggregate = shouldUseAggregateUiForFields(fieldsString, optionalFieldsString, allowedMaxStringLengthPerChunk);
|
|
501
507
|
if (!shouldUseAggregate) {
|
|
502
508
|
return undefined;
|
|
503
509
|
}
|
|
504
|
-
const fieldCollection = ScopedFieldsCollection.fromQueryParameterValue(fieldsString).split(
|
|
505
|
-
const optionalFieldCollection = ScopedFieldsCollection.fromQueryParameterValue(optionalFieldsString).split(
|
|
510
|
+
const fieldCollection = ScopedFieldsCollection.fromQueryParameterValue(fieldsString).split(allowedMaxStringLengthPerChunk);
|
|
511
|
+
const optionalFieldCollection = ScopedFieldsCollection.fromQueryParameterValue(optionalFieldsString).split(allowedMaxStringLengthPerChunk);
|
|
506
512
|
return {
|
|
507
513
|
fieldCollection,
|
|
508
514
|
optionalFieldCollection,
|
|
@@ -575,6 +581,25 @@ function isGetRequestForEndpoint(endpoint, request) {
|
|
|
575
581
|
function arrayOrEmpty(array) {
|
|
576
582
|
return array !== undefined && isArray(array) ? array : [];
|
|
577
583
|
}
|
|
584
|
+
/**
|
|
585
|
+
* Calculate the max lengh per chunk.
|
|
586
|
+
* If useShortUrlGate is open, allow max chunk size is MAX_URL_LENGTH - the url without fields and optional fields in url.
|
|
587
|
+
* Otherwise MAX_STRING_LENGTH_PER_CHUNK
|
|
588
|
+
* @param resourceRequest
|
|
589
|
+
* @returns
|
|
590
|
+
*/
|
|
591
|
+
function getMaxLengthPerChunkAllowed(request) {
|
|
592
|
+
if (!ldsUseShortUrlGate.isOpen({ fallback: false })) {
|
|
593
|
+
return MAX_STRING_LENGTH_PER_CHUNK;
|
|
594
|
+
}
|
|
595
|
+
// Too much work to get exact length of the final url, so use stringified json to get the rough length.
|
|
596
|
+
const roughUrlLengthWithoutFieldsAndOptionFields = request.basePath.length +
|
|
597
|
+
request.baseUri.length +
|
|
598
|
+
(request.urlParams ? stringify(request.urlParams).length : 0) +
|
|
599
|
+
stringify({ ...request.queryParams, fields: {}, optionalFields: {} }).length;
|
|
600
|
+
// MAX_URL_LENGTH - full lenght without fields, optionalFields
|
|
601
|
+
return MAX_URL_LENGTH - roughUrlLengthWithoutFieldsAndOptionFields;
|
|
602
|
+
}
|
|
578
603
|
|
|
579
604
|
const RECORD_ENDPOINT_REGEX = /^\/ui-api\/records\/?(([a-zA-Z0-9]+))?$/;
|
|
580
605
|
const referenceId$3 = 'LDS_Records_AggregateUi';
|
|
@@ -4,6 +4,7 @@ import type { RecordRepresentation, BatchRepresentation, RelatedListRecordCollec
|
|
|
4
4
|
import type { GetRecordResult } from './makeNetworkChunkFieldsGetRecord';
|
|
5
5
|
import { ScopedFieldsCollection } from './ScopedFields';
|
|
6
6
|
export declare const MAX_STRING_LENGTH_PER_CHUNK = 10000;
|
|
7
|
+
export declare const MAX_URL_LENGTH = 8000;
|
|
7
8
|
export interface CompositeRequest {
|
|
8
9
|
url: string;
|
|
9
10
|
referenceId: string;
|
|
@@ -49,7 +50,7 @@ type SupportedBatchCollectionRepresentation = RelatedListRecordCollectionReprese
|
|
|
49
50
|
*/
|
|
50
51
|
export declare function mergeAggregateUiResponse<T>(response: AggregateResponse<T>, mergeFunc: (first: T, second: T) => SupportedAggregateRepresentation<T>): FetchResponse<SupportedAggregateRepresentation<T> | UiApiErrorResponse>;
|
|
51
52
|
export declare function buildAggregateUiUrl(params: UiApiParams, resourceRequest: ResourceRequest): string;
|
|
52
|
-
export declare function shouldUseAggregateUiForFields(fieldsArray: string, optionalFieldsArray: string): boolean;
|
|
53
|
+
export declare function shouldUseAggregateUiForFields(fieldsArray: string, optionalFieldsArray: string, maxLengthPerChunk: number): boolean;
|
|
53
54
|
export declare function isSpanningRecord(fieldValue: null | string | number | boolean | RecordRepresentation): fieldValue is RecordRepresentation;
|
|
54
55
|
export declare function mergeRecordFields(first: RecordRepresentation, second: RecordRepresentation): RecordRepresentation;
|
|
55
56
|
export declare function mergeBatchRecordsFields(first: SupportedBatchRepresentation, second: SupportedBatchRepresentation, collectionMergeFunc: (first: SupportedBatchCollectionRepresentation, second: SupportedBatchCollectionRepresentation) => SupportedBatchCollectionRepresentation): SupportedBatchRepresentation;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-network-nimbus",
|
|
3
|
-
"version": "1.163.
|
|
3
|
+
"version": "1.163.2",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "A nimbus-plugin-based implementation of the Luvio NetworkAdapter.",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"maxSize": {
|
|
40
40
|
"none": "32 kB",
|
|
41
41
|
"min": "12.5 kB",
|
|
42
|
-
"compressed": "6 kB"
|
|
42
|
+
"compressed": "6.5 kB"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
]
|