@salesforce/lds-network-nimbus 1.260.0 → 1.262.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.
package/dist/main.js CHANGED
@@ -488,11 +488,14 @@ function mergeBatchRecordsFields(first, second, collectionMergeFunc) {
488
488
  * @param endpoint Regular Expression to check the endpoint to aggregate
489
489
  * @returns undefined if we should not aggregate. object if we should.
490
490
  */
491
- function createAggregateBatchRequestInfo(resourceRequest, endpoint) {
491
+ function createAggregateBatchRequestInfo(resourceRequest, endpoint, instrumentationSink) {
492
492
  // only handle GETs on the given endpoint regex
493
493
  if (!isGetRequestForEndpoint(endpoint, resourceRequest)) {
494
494
  return undefined;
495
495
  }
496
+ if (instrumentationSink) {
497
+ instrumentationSink.reportChunkCandidateUrlLength(calculateEstimatedTotalUrlLength(resourceRequest));
498
+ }
496
499
  const { queryParams: { fields, optionalFields }, } = resourceRequest;
497
500
  // only handle requests with fields or optional fields
498
501
  if (fields === undefined && optionalFields === undefined) {
@@ -604,6 +607,21 @@ function getMaxLengthPerChunkAllowed(request) {
604
607
  // MAX_URL_LENGTH - full lenght without fields, optionalFields
605
608
  return MAX_URL_LENGTH - roughUrlLengthWithoutFieldsAndOptionFields;
606
609
  }
610
+ // we don't have access to the host so we cannot calculate the exact length of the url
611
+ // so we will estimate it
612
+ function calculateEstimatedTotalUrlLength(request) {
613
+ const { baseUri, basePath, queryParams } = request;
614
+ let url = `${baseUri}${basePath}`;
615
+ if (queryParams) {
616
+ const queryParamString = entries(queryParams)
617
+ .map(([key, value]) => `${key}=${value}`)
618
+ .join('&');
619
+ if (queryParamString) {
620
+ url += `?${queryParamString}`;
621
+ }
622
+ }
623
+ return url.length;
624
+ }
607
625
 
608
626
  const RECORD_ENDPOINT_REGEX = /^\/ui-api\/records\/?(([a-zA-Z0-9]+))?$/;
609
627
  const referenceId$3 = 'LDS_Records_AggregateUi';
@@ -628,9 +646,9 @@ function mergeGetRecordResult(first, second) {
628
646
  mergeRecordFields(first, second);
629
647
  return first;
630
648
  }
631
- function makeNetworkChunkFieldsGetRecord(networkAdapter) {
649
+ function makeNetworkChunkFieldsGetRecord(networkAdapter, instrumentationSink) {
632
650
  return (resourceRequest, resourceRequestContext) => {
633
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORD_ENDPOINT_REGEX);
651
+ const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORD_ENDPOINT_REGEX, instrumentationSink);
634
652
  if (batchRequestInfo === undefined) {
635
653
  return networkAdapter(resourceRequest, resourceRequestContext);
636
654
  }
@@ -644,9 +662,9 @@ function makeNetworkChunkFieldsGetRecord(networkAdapter) {
644
662
 
645
663
  const RECORDS_BATCH_ENDPOINT_REGEX = /^\/ui-api\/records\/batch\/?(([a-zA-Z0-9|,]+))?$/;
646
664
  const referenceId$2 = 'LDS_Records_Batch_AggregateUi';
647
- function makeNetworkChunkFieldsGetRecordsBatch(networkAdapter) {
665
+ function makeNetworkChunkFieldsGetRecordsBatch(networkAdapter, intrumentationSink) {
648
666
  return (resourceRequest, resourceRequestContext) => {
649
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORDS_BATCH_ENDPOINT_REGEX);
667
+ const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORDS_BATCH_ENDPOINT_REGEX, intrumentationSink);
650
668
  if (batchRequestInfo === undefined) {
651
669
  return networkAdapter(resourceRequest, resourceRequestContext);
652
670
  }
@@ -692,9 +710,9 @@ function mergeRelatedRecordsFields(first, second) {
692
710
  throw new Error('Aggregate UI response is invalid');
693
711
  }
694
712
  }
695
- function makeNetworkChunkFieldsGetRelatedListRecords(networkAdapter) {
713
+ function makeNetworkChunkFieldsGetRelatedListRecords(networkAdapter, instrumentationSink) {
696
714
  return (resourceRequest, resourceRequestContext) => {
697
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_ENDPOINT_REGEX);
715
+ const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_ENDPOINT_REGEX, instrumentationSink);
698
716
  if (batchRequestInfo === undefined) {
699
717
  return networkAdapter(resourceRequest, resourceRequestContext);
700
718
  }
@@ -770,9 +788,9 @@ function recordIdsAllMatch(first, second) {
770
788
 
771
789
  const RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX = /^\/ui-api\/related-list-records\/batch\/?(([a-zA-Z0-9]+))?\//;
772
790
  const referenceId = 'LDS_Related_List_Records_AggregateUi';
773
- function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter) {
791
+ function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter, instrumentationSink) {
774
792
  return (resourceRequest, resourceRequestContext) => {
775
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX);
793
+ const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX, instrumentationSink);
776
794
  if (batchRequestInfo === undefined) {
777
795
  return networkAdapter(resourceRequest, resourceRequestContext);
778
796
  }
@@ -795,7 +813,7 @@ function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter) {
795
813
  *
796
814
  * @param networkAdapter the network adapter to do the call.
797
815
  */
798
- function makeNetworkAdapterChunkRecordFields(networkAdapter) {
816
+ function makeNetworkAdapterChunkRecordFields(networkAdapter, instrumentationSink) {
799
817
  // endpoint handlers that support aggregate-ui field batching
800
818
  const batchHandlers = [
801
819
  makeNetworkChunkFieldsGetRecord,
@@ -804,7 +822,7 @@ function makeNetworkAdapterChunkRecordFields(networkAdapter) {
804
822
  makeNetworkChunkFieldsGetRelatedListRecordsBatch,
805
823
  ];
806
824
  return batchHandlers.reduce((network, handler) => {
807
- return handler(network);
825
+ return handler(network, instrumentationSink);
808
826
  }, networkAdapter);
809
827
  }
810
828
 
@@ -7,4 +7,5 @@ export declare function getInstrumentation(_name: string): {
7
7
  startActivity: (_name: string) => any;
8
8
  incrementCounter: (_operation: string, _increment?: number | undefined, _hasError?: boolean | undefined, _tags?: any) => void;
9
9
  trackValue: (_operation: string, _value: number, _hasError?: boolean | undefined, _tags?: any) => void;
10
+ bucketValue: (_operation: string, _value: number, _buckets: number[]) => void;
10
11
  };
@@ -3,12 +3,14 @@ declare function error(_err: Error, _userSchemaOrText?: string, _data?: any): vo
3
3
  declare function startActivity(_name: string): any;
4
4
  declare function incrementCounter(_operation: string, _increment?: number, _hasError?: boolean, _tags?: any): void;
5
5
  declare function trackValue(_operation: string, _value: number, _hasError?: boolean, _tags?: any): void;
6
+ declare function bucketValue(_operation: string, _value: number, _buckets: number[]): void;
6
7
  export declare const instrumentation: {
7
8
  log: typeof log;
8
9
  error: typeof error;
9
10
  startActivity: typeof startActivity;
10
11
  incrementCounter: typeof incrementCounter;
11
12
  trackValue: typeof trackValue;
13
+ bucketValue: typeof bucketValue;
12
14
  };
13
15
  export declare const METRIC_KEYS: {};
14
16
  export {};
@@ -6,4 +6,6 @@ import type { NetworkAdapter } from '@luvio/engine';
6
6
  *
7
7
  * @param networkAdapter the network adapter to do the call.
8
8
  */
9
- export declare function makeNetworkAdapterChunkRecordFields(networkAdapter: NetworkAdapter): NetworkAdapter;
9
+ export declare function makeNetworkAdapterChunkRecordFields(networkAdapter: NetworkAdapter, instrumentationSink: {
10
+ reportChunkCandidateUrlLength: (urlLength: number) => void;
11
+ }): NetworkAdapter;
@@ -1,6 +1,6 @@
1
1
  import type { NetworkAdapter, FetchResponse } from '@luvio/engine';
2
2
  import type { RecordRepresentation } from '@salesforce/lds-adapters-uiapi';
3
- import type { AggregateResponse, UiApiErrorResponse } from './utils';
3
+ import type { AggregateResponse, InstrumentationSink, UiApiErrorResponse } from './utils';
4
4
  export type GetRecordResult = RecordRepresentation | UiApiErrorResponse;
5
5
  export type GetRecordAggregateResponse = AggregateResponse<GetRecordResult>;
6
6
  export type GetRecordResponse = FetchResponse<GetRecordResult>;
@@ -12,4 +12,4 @@ export type GetRecordResponse = FetchResponse<GetRecordResult>;
12
12
  * fields sub node will be merged recursively
13
13
  */
14
14
  export declare function mergeGetRecordResult(first: GetRecordResult, second: GetRecordResult): GetRecordResult;
15
- export declare function makeNetworkChunkFieldsGetRecord(networkAdapter: NetworkAdapter): NetworkAdapter;
15
+ export declare function makeNetworkChunkFieldsGetRecord(networkAdapter: NetworkAdapter, instrumentationSink: InstrumentationSink): NetworkAdapter;
@@ -1,7 +1,7 @@
1
1
  import type { FetchResponse, NetworkAdapter } from '@luvio/engine';
2
2
  import type { BatchRepresentation } from '@salesforce/lds-adapters-uiapi';
3
- import type { AggregateResponse } from './utils';
3
+ import type { AggregateResponse, InstrumentationSink } from './utils';
4
4
  export declare const RECORDS_BATCH_ENDPOINT_REGEX: RegExp;
5
5
  export type GetRecordsBatchAggregateResponse = AggregateResponse<BatchRepresentation>;
6
6
  export type GetRecordsBatchResponse = FetchResponse<BatchRepresentation>;
7
- export declare function makeNetworkChunkFieldsGetRecordsBatch(networkAdapter: NetworkAdapter): NetworkAdapter;
7
+ export declare function makeNetworkChunkFieldsGetRecordsBatch(networkAdapter: NetworkAdapter, intrumentationSink: InstrumentationSink): NetworkAdapter;
@@ -1,5 +1,5 @@
1
1
  import type { NetworkAdapter } from '@luvio/engine';
2
- import type { AggregateResponse } from './utils';
2
+ import type { AggregateResponse, InstrumentationSink } from './utils';
3
3
  import type { RelatedListRecordCollectionRepresentation } from '@salesforce/lds-adapters-uiapi';
4
4
  export type RelatedListAggregateResponse = AggregateResponse<RelatedListRecordCollectionRepresentation>;
5
5
  /**
@@ -8,7 +8,7 @@ export type RelatedListAggregateResponse = AggregateResponse<RelatedListRecordCo
8
8
  * Exports it for unit tests
9
9
  */
10
10
  export declare function mergeRelatedRecordsFields(first: RelatedListRecordCollectionRepresentation, second: RelatedListRecordCollectionRepresentation): RelatedListRecordCollectionRepresentation;
11
- export declare function makeNetworkChunkFieldsGetRelatedListRecords(networkAdapter: NetworkAdapter): NetworkAdapter;
11
+ export declare function makeNetworkChunkFieldsGetRelatedListRecords(networkAdapter: NetworkAdapter, instrumentationSink: InstrumentationSink): NetworkAdapter;
12
12
  /**
13
13
  * merge to paging url with different set of fields or optional fields as combined one
14
14
  * the paging url is like
@@ -1,6 +1,6 @@
1
1
  import type { FetchResponse, NetworkAdapter } from '@luvio/engine';
2
- import type { AggregateResponse } from './utils';
2
+ import type { AggregateResponse, InstrumentationSink } from './utils';
3
3
  import type { RelatedListRecordCollectionBatchRepresentation } from '@salesforce/lds-adapters-uiapi';
4
4
  export type RelatedListBatchAggregateResponse = AggregateResponse<RelatedListRecordCollectionBatchRepresentation>;
5
5
  export type RelatedListBatchResponse = FetchResponse<RelatedListRecordCollectionBatchRepresentation>;
6
- export declare function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter: NetworkAdapter): NetworkAdapter;
6
+ export declare function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter: NetworkAdapter, instrumentationSink: InstrumentationSink): NetworkAdapter;
@@ -42,6 +42,9 @@ type SupportedBatchRepresentation = RelatedListRecordCollectionBatchRepresentati
42
42
  * Supported batch representation
43
43
  */
44
44
  type SupportedBatchCollectionRepresentation = RelatedListRecordCollectionRepresentation | RecordRepresentation;
45
+ export interface InstrumentationSink {
46
+ reportChunkCandidateUrlLength: (urlLength: number) => void;
47
+ }
45
48
  /**
46
49
  * merge the aggregate ui child responses into a single object representation
47
50
  * @param response
@@ -60,7 +63,7 @@ export declare function mergeBatchRecordsFields(first: SupportedBatchRepresentat
60
63
  * @param endpoint Regular Expression to check the endpoint to aggregate
61
64
  * @returns undefined if we should not aggregate. object if we should.
62
65
  */
63
- export declare function createAggregateBatchRequestInfo(resourceRequest: ResourceRequest, endpoint: RegExp): {
66
+ export declare function createAggregateBatchRequestInfo(resourceRequest: ResourceRequest, endpoint: RegExp, instrumentationSink?: InstrumentationSink): {
64
67
  fieldCollection: ScopedFieldsCollection[];
65
68
  optionalFieldCollection: ScopedFieldsCollection[];
66
69
  } | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-network-nimbus",
3
- "version": "1.260.0",
3
+ "version": "1.262.0",
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",
@@ -26,20 +26,20 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@luvio/engine": "0.154.4",
29
- "@salesforce/lds-instrumentation": "^1.260.0",
29
+ "@salesforce/lds-instrumentation": "^1.262.0",
30
30
  "o11y": "242.8.3"
31
31
  },
32
32
  "devDependencies": {
33
- "@salesforce/lds-adapters-uiapi": "^1.260.0",
34
- "@salesforce/nimbus-plugin-lds": "^1.260.0"
33
+ "@salesforce/lds-adapters-uiapi": "^1.262.0",
34
+ "@salesforce/nimbus-plugin-lds": "^1.262.0"
35
35
  },
36
36
  "luvioBundlesize": [
37
37
  {
38
38
  "path": "./dist/main.js",
39
39
  "maxSize": {
40
- "none": "32 kB",
41
- "min": "12.5 kB",
42
- "compressed": "6.5 kB"
40
+ "none": "33 kB",
41
+ "min": "13 kB",
42
+ "compressed": "7 kB"
43
43
  }
44
44
  }
45
45
  ]