@salesforce/lds-network-nimbus 1.332.0-dev3 → 1.333.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
|
@@ -618,7 +618,7 @@ function calculateEstimatedTotalUrlLength(request) {
|
|
|
618
618
|
}
|
|
619
619
|
|
|
620
620
|
const RECORD_ENDPOINT_REGEX = /^\/ui-api\/records\/?(([a-zA-Z0-9]+))?$/;
|
|
621
|
-
const referenceId$
|
|
621
|
+
const referenceId$1 = 'LDS_Records_AggregateUi';
|
|
622
622
|
/**
|
|
623
623
|
* Export to facilitate unit tests
|
|
624
624
|
* Merge the second getRecord result into the first one.
|
|
@@ -646,7 +646,7 @@ function makeNetworkChunkFieldsGetRecord(networkAdapter, instrumentationSink) {
|
|
|
646
646
|
if (batchRequestInfo === undefined) {
|
|
647
647
|
return networkAdapter(resourceRequest, resourceRequestContext);
|
|
648
648
|
}
|
|
649
|
-
const compositeRequest = buildCompositeRequestByFields(referenceId$
|
|
649
|
+
const compositeRequest = buildCompositeRequestByFields(referenceId$1, resourceRequest, batchRequestInfo);
|
|
650
650
|
const aggregateRequest = createAggregateUiRequest(resourceRequest, compositeRequest);
|
|
651
651
|
return networkAdapter(aggregateRequest, resourceRequestContext).then((response) => {
|
|
652
652
|
return mergeAggregateUiResponse(response, mergeGetRecordResult);
|
|
@@ -655,145 +655,19 @@ function makeNetworkChunkFieldsGetRecord(networkAdapter, instrumentationSink) {
|
|
|
655
655
|
}
|
|
656
656
|
|
|
657
657
|
const RECORDS_BATCH_ENDPOINT_REGEX = /^\/ui-api\/records\/batch\/?(([a-zA-Z0-9|,]+))?$/;
|
|
658
|
-
const referenceId
|
|
658
|
+
const referenceId = 'LDS_Records_Batch_AggregateUi';
|
|
659
659
|
function makeNetworkChunkFieldsGetRecordsBatch(networkAdapter, intrumentationSink) {
|
|
660
660
|
return (resourceRequest, resourceRequestContext) => {
|
|
661
661
|
const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORDS_BATCH_ENDPOINT_REGEX, intrumentationSink);
|
|
662
662
|
if (batchRequestInfo === undefined) {
|
|
663
663
|
return networkAdapter(resourceRequest, resourceRequestContext);
|
|
664
664
|
}
|
|
665
|
-
const compositeRequest = buildCompositeRequestByFields(referenceId$2, resourceRequest, batchRequestInfo);
|
|
666
|
-
const aggregateRequest = createAggregateUiRequest(resourceRequest, compositeRequest);
|
|
667
|
-
return networkAdapter(aggregateRequest, resourceRequestContext).then((response) => {
|
|
668
|
-
return mergeAggregateUiResponse(response, (first, second) => {
|
|
669
|
-
return mergeBatchRecordsFields(first, second, (a, b) => {
|
|
670
|
-
return mergeRecordFields(a, b);
|
|
671
|
-
});
|
|
672
|
-
});
|
|
673
|
-
});
|
|
674
|
-
};
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
const RELATED_LIST_RECORDS_ENDPOINT_REGEX = /^\/ui-api\/related-list-records\/?(([a-zA-Z0-9]+))?\/?(([a-zA-Z0-9]+))?$/;
|
|
678
|
-
const referenceId$1 = 'LDS_Related_List_Records_AggregateUi';
|
|
679
|
-
const QUERY_KEY_FIELDS = 'fields';
|
|
680
|
-
const QUERY_KEY_OPTIONAL_FIELDS = 'optionalFields';
|
|
681
|
-
/**
|
|
682
|
-
* Merge the second related list record collection into first one and return it.
|
|
683
|
-
* It checks both collections should have exaction same records, otherwise error.
|
|
684
|
-
* Exports it for unit tests
|
|
685
|
-
*/
|
|
686
|
-
function mergeRelatedRecordsFields(first, second) {
|
|
687
|
-
const { records: targetRecords } = first;
|
|
688
|
-
const { records: sourceRecords } = second;
|
|
689
|
-
if (sourceRecords.length === targetRecords.length &&
|
|
690
|
-
recordIdsAllMatch(targetRecords, sourceRecords)) {
|
|
691
|
-
first.fields = first.fields.concat(second.fields);
|
|
692
|
-
first.optionalFields = first.optionalFields.concat(second.optionalFields);
|
|
693
|
-
for (let i = 0, len = sourceRecords.length; i < len; i += 1) {
|
|
694
|
-
const targetRecord = targetRecords[i];
|
|
695
|
-
const sourceRecord = sourceRecords[i];
|
|
696
|
-
mergeRecordFields(targetRecord, sourceRecord);
|
|
697
|
-
}
|
|
698
|
-
mergePageUrls(first, second);
|
|
699
|
-
return first;
|
|
700
|
-
}
|
|
701
|
-
else {
|
|
702
|
-
// Throw error due to two collection are about different set of records
|
|
703
|
-
// eslint-disable-next-line @salesforce/lds/no-error-in-production
|
|
704
|
-
throw new Error('Aggregate UI response is invalid');
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
function makeNetworkChunkFieldsGetRelatedListRecords(networkAdapter, instrumentationSink) {
|
|
708
|
-
return (resourceRequest, resourceRequestContext) => {
|
|
709
|
-
const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_ENDPOINT_REGEX, instrumentationSink);
|
|
710
|
-
if (batchRequestInfo === undefined) {
|
|
711
|
-
return networkAdapter(resourceRequest, resourceRequestContext);
|
|
712
|
-
}
|
|
713
|
-
const compositeRequest = buildCompositeRequestByFields(referenceId$1, resourceRequest, batchRequestInfo);
|
|
714
|
-
const aggregateRequest = createAggregateUiRequest(resourceRequest, compositeRequest);
|
|
715
|
-
return networkAdapter(aggregateRequest, resourceRequestContext).then((response) => {
|
|
716
|
-
return mergeAggregateUiResponse(response, mergeRelatedRecordsFields);
|
|
717
|
-
});
|
|
718
|
-
};
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* merge the second related list record collection into first one and return it
|
|
722
|
-
*/
|
|
723
|
-
function mergePageUrls(first, second) {
|
|
724
|
-
first.currentPageUrl = mergeUrl(first.currentPageUrl, second.currentPageUrl);
|
|
725
|
-
first.previousPageUrl = mergeUrl(first.previousPageUrl, second.previousPageUrl);
|
|
726
|
-
first.nextPageUrl = mergeUrl(first.nextPageUrl, second.nextPageUrl);
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* merge to paging url with different set of fields or optional fields as combined one
|
|
730
|
-
* the paging url is like
|
|
731
|
-
* /services/data/v63.0/ui-api/related-list-records/001R0000006l1xKIAQ/Contacts
|
|
732
|
-
* ?fields=Id%2CName&optionalFields=Contact.Id%2CContact.Name&pageSize=50&pageToken=0
|
|
733
|
-
* @param path1 url path and query parmeter without domain
|
|
734
|
-
* @param path2 url path and query parmeter without domain
|
|
735
|
-
*
|
|
736
|
-
* Export to unit test
|
|
737
|
-
*/
|
|
738
|
-
function mergeUrl(path1, path2) {
|
|
739
|
-
if (path1 === null)
|
|
740
|
-
return path2;
|
|
741
|
-
if (path2 === null)
|
|
742
|
-
return path1;
|
|
743
|
-
// new Url(...) need the path1, path2 to be prefix-ed with this fake domain
|
|
744
|
-
const domain = 'http://c.com';
|
|
745
|
-
const url1 = new URL(domain + path1);
|
|
746
|
-
const url2 = new URL(domain + path2);
|
|
747
|
-
const searchParams1 = url1.searchParams;
|
|
748
|
-
const fields = mergeFields(url1, url2, QUERY_KEY_FIELDS);
|
|
749
|
-
if (fields && searchParams1.get(QUERY_KEY_FIELDS) !== fields) {
|
|
750
|
-
searchParams1.set(QUERY_KEY_FIELDS, fields);
|
|
751
|
-
}
|
|
752
|
-
const optionalFields = mergeFields(url1, url2, QUERY_KEY_OPTIONAL_FIELDS);
|
|
753
|
-
if (optionalFields && searchParams1.get(QUERY_KEY_OPTIONAL_FIELDS) !== optionalFields) {
|
|
754
|
-
searchParams1.set(QUERY_KEY_OPTIONAL_FIELDS, optionalFields);
|
|
755
|
-
}
|
|
756
|
-
from(searchParams1.keys())
|
|
757
|
-
.sort()
|
|
758
|
-
.forEach((key) => {
|
|
759
|
-
const value = searchParams1.get(key);
|
|
760
|
-
searchParams1.delete(key);
|
|
761
|
-
searchParams1.append(key, value);
|
|
762
|
-
});
|
|
763
|
-
return url1.toString().substr(domain.length);
|
|
764
|
-
}
|
|
765
|
-
function mergeFields(url1, url2, name) {
|
|
766
|
-
const fields1 = ScopedFieldsCollection.fromQueryParameterValue(url1.searchParams.get(name));
|
|
767
|
-
const fields2 = ScopedFieldsCollection.fromQueryParameterValue(url2.searchParams.get(name));
|
|
768
|
-
fields1.merge(fields2);
|
|
769
|
-
return fields1.toQueryParameterValue();
|
|
770
|
-
}
|
|
771
|
-
/**
|
|
772
|
-
* Checks that all records ids exist in both arrays
|
|
773
|
-
* @param first batch of first array or records
|
|
774
|
-
* @param second batch of second array or records
|
|
775
|
-
* @returns
|
|
776
|
-
*/
|
|
777
|
-
function recordIdsAllMatch(first, second) {
|
|
778
|
-
const firstIds = first.map((record) => record.id);
|
|
779
|
-
const secondIds = second.map((record) => record.id);
|
|
780
|
-
return firstIds.every((id) => secondIds.includes(id));
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
const RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX = /^\/ui-api\/related-list-records\/batch\/?(([a-zA-Z0-9]+))?\//;
|
|
784
|
-
const referenceId = 'LDS_Related_List_Records_AggregateUi';
|
|
785
|
-
function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter, instrumentationSink) {
|
|
786
|
-
return (resourceRequest, resourceRequestContext) => {
|
|
787
|
-
const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX, instrumentationSink);
|
|
788
|
-
if (batchRequestInfo === undefined) {
|
|
789
|
-
return networkAdapter(resourceRequest, resourceRequestContext);
|
|
790
|
-
}
|
|
791
665
|
const compositeRequest = buildCompositeRequestByFields(referenceId, resourceRequest, batchRequestInfo);
|
|
792
666
|
const aggregateRequest = createAggregateUiRequest(resourceRequest, compositeRequest);
|
|
793
667
|
return networkAdapter(aggregateRequest, resourceRequestContext).then((response) => {
|
|
794
668
|
return mergeAggregateUiResponse(response, (first, second) => {
|
|
795
669
|
return mergeBatchRecordsFields(first, second, (a, b) => {
|
|
796
|
-
return
|
|
670
|
+
return mergeRecordFields(a, b);
|
|
797
671
|
});
|
|
798
672
|
});
|
|
799
673
|
});
|
|
@@ -809,12 +683,7 @@ function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter, instru
|
|
|
809
683
|
*/
|
|
810
684
|
function makeNetworkAdapterChunkRecordFields(networkAdapter, instrumentationSink) {
|
|
811
685
|
// endpoint handlers that support aggregate-ui field batching
|
|
812
|
-
const batchHandlers = [
|
|
813
|
-
makeNetworkChunkFieldsGetRecord,
|
|
814
|
-
makeNetworkChunkFieldsGetRecordsBatch,
|
|
815
|
-
makeNetworkChunkFieldsGetRelatedListRecords,
|
|
816
|
-
makeNetworkChunkFieldsGetRelatedListRecordsBatch,
|
|
817
|
-
];
|
|
686
|
+
const batchHandlers = [makeNetworkChunkFieldsGetRecord, makeNetworkChunkFieldsGetRecordsBatch];
|
|
818
687
|
return batchHandlers.reduce((network, handler) => {
|
|
819
688
|
return handler(network, instrumentationSink);
|
|
820
689
|
}, networkAdapter);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-network-nimbus",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.333.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,12 +26,12 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@luvio/engine": "0.156.5",
|
|
29
|
-
"@salesforce/lds-instrumentation": "^1.
|
|
29
|
+
"@salesforce/lds-instrumentation": "^1.333.0",
|
|
30
30
|
"o11y": "250.7.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@salesforce/lds-adapters-uiapi": "^1.
|
|
34
|
-
"@salesforce/nimbus-plugin-lds": "^1.
|
|
33
|
+
"@salesforce/lds-adapters-uiapi": "^1.333.0",
|
|
34
|
+
"@salesforce/nimbus-plugin-lds": "^1.333.0"
|
|
35
35
|
},
|
|
36
36
|
"luvioBundlesize": [
|
|
37
37
|
{
|
package/dist/types/network/record-field-batching/makeNetworkChunkFieldsGetRelatedListRecords.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { NetworkAdapter } from '@luvio/engine';
|
|
2
|
-
import type { AggregateResponse, InstrumentationSink } from './utils';
|
|
3
|
-
import type { RelatedListRecordCollectionRepresentation } from '@salesforce/lds-adapters-uiapi';
|
|
4
|
-
export type RelatedListAggregateResponse = AggregateResponse<RelatedListRecordCollectionRepresentation>;
|
|
5
|
-
/**
|
|
6
|
-
* Merge the second related list record collection into first one and return it.
|
|
7
|
-
* It checks both collections should have exaction same records, otherwise error.
|
|
8
|
-
* Exports it for unit tests
|
|
9
|
-
*/
|
|
10
|
-
export declare function mergeRelatedRecordsFields(first: RelatedListRecordCollectionRepresentation, second: RelatedListRecordCollectionRepresentation): RelatedListRecordCollectionRepresentation;
|
|
11
|
-
export declare function makeNetworkChunkFieldsGetRelatedListRecords(networkAdapter: NetworkAdapter, instrumentationSink: InstrumentationSink): NetworkAdapter;
|
|
12
|
-
/**
|
|
13
|
-
* merge to paging url with different set of fields or optional fields as combined one
|
|
14
|
-
* the paging url is like
|
|
15
|
-
* /services/data/v63.0/ui-api/related-list-records/001R0000006l1xKIAQ/Contacts
|
|
16
|
-
* ?fields=Id%2CName&optionalFields=Contact.Id%2CContact.Name&pageSize=50&pageToken=0
|
|
17
|
-
* @param path1 url path and query parmeter without domain
|
|
18
|
-
* @param path2 url path and query parmeter without domain
|
|
19
|
-
*
|
|
20
|
-
* Export to unit test
|
|
21
|
-
*/
|
|
22
|
-
export declare function mergeUrl(path1: string | null, path2: string | null): string | null;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { FetchResponse, NetworkAdapter } from '@luvio/engine';
|
|
2
|
-
import type { AggregateResponse, InstrumentationSink } from './utils';
|
|
3
|
-
import type { RelatedListRecordCollectionBatchRepresentation } from '@salesforce/lds-adapters-uiapi';
|
|
4
|
-
export type RelatedListBatchAggregateResponse = AggregateResponse<RelatedListRecordCollectionBatchRepresentation>;
|
|
5
|
-
export type RelatedListBatchResponse = FetchResponse<RelatedListRecordCollectionBatchRepresentation>;
|
|
6
|
-
export declare function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter: NetworkAdapter, instrumentationSink: InstrumentationSink): NetworkAdapter;
|