@salesforce/lds-runtime-mobile 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
@@ -14959,11 +14959,14 @@ function mergeBatchRecordsFields(first, second, collectionMergeFunc) {
14959
14959
  * @param endpoint Regular Expression to check the endpoint to aggregate
14960
14960
  * @returns undefined if we should not aggregate. object if we should.
14961
14961
  */
14962
- function createAggregateBatchRequestInfo(resourceRequest, endpoint) {
14962
+ function createAggregateBatchRequestInfo(resourceRequest, endpoint, instrumentationSink) {
14963
14963
  // only handle GETs on the given endpoint regex
14964
14964
  if (!isGetRequestForEndpoint(endpoint, resourceRequest)) {
14965
14965
  return undefined;
14966
14966
  }
14967
+ if (instrumentationSink) {
14968
+ instrumentationSink.reportChunkCandidateUrlLength(calculateEstimatedTotalUrlLength(resourceRequest));
14969
+ }
14967
14970
  const { queryParams: { fields, optionalFields }, } = resourceRequest;
14968
14971
  // only handle requests with fields or optional fields
14969
14972
  if (fields === undefined && optionalFields === undefined) {
@@ -15075,6 +15078,21 @@ function getMaxLengthPerChunkAllowed(request) {
15075
15078
  // MAX_URL_LENGTH - full lenght without fields, optionalFields
15076
15079
  return MAX_URL_LENGTH - roughUrlLengthWithoutFieldsAndOptionFields;
15077
15080
  }
15081
+ // we don't have access to the host so we cannot calculate the exact length of the url
15082
+ // so we will estimate it
15083
+ function calculateEstimatedTotalUrlLength(request) {
15084
+ const { baseUri, basePath, queryParams } = request;
15085
+ let url = `${baseUri}${basePath}`;
15086
+ if (queryParams) {
15087
+ const queryParamString = entries$2(queryParams)
15088
+ .map(([key, value]) => `${key}=${value}`)
15089
+ .join('&');
15090
+ if (queryParamString) {
15091
+ url += `?${queryParamString}`;
15092
+ }
15093
+ }
15094
+ return url.length;
15095
+ }
15078
15096
 
15079
15097
  const RECORD_ENDPOINT_REGEX = /^\/ui-api\/records\/?(([a-zA-Z0-9]+))?$/;
15080
15098
  const referenceId$3 = 'LDS_Records_AggregateUi';
@@ -15099,9 +15117,9 @@ function mergeGetRecordResult(first, second) {
15099
15117
  mergeRecordFields(first, second);
15100
15118
  return first;
15101
15119
  }
15102
- function makeNetworkChunkFieldsGetRecord(networkAdapter) {
15120
+ function makeNetworkChunkFieldsGetRecord(networkAdapter, instrumentationSink) {
15103
15121
  return (resourceRequest, resourceRequestContext) => {
15104
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORD_ENDPOINT_REGEX);
15122
+ const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORD_ENDPOINT_REGEX, instrumentationSink);
15105
15123
  if (batchRequestInfo === undefined) {
15106
15124
  return networkAdapter(resourceRequest, resourceRequestContext);
15107
15125
  }
@@ -15115,9 +15133,9 @@ function makeNetworkChunkFieldsGetRecord(networkAdapter) {
15115
15133
 
15116
15134
  const RECORDS_BATCH_ENDPOINT_REGEX = /^\/ui-api\/records\/batch\/?(([a-zA-Z0-9|,]+))?$/;
15117
15135
  const referenceId$2 = 'LDS_Records_Batch_AggregateUi';
15118
- function makeNetworkChunkFieldsGetRecordsBatch(networkAdapter) {
15136
+ function makeNetworkChunkFieldsGetRecordsBatch(networkAdapter, intrumentationSink) {
15119
15137
  return (resourceRequest, resourceRequestContext) => {
15120
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORDS_BATCH_ENDPOINT_REGEX);
15138
+ const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORDS_BATCH_ENDPOINT_REGEX, intrumentationSink);
15121
15139
  if (batchRequestInfo === undefined) {
15122
15140
  return networkAdapter(resourceRequest, resourceRequestContext);
15123
15141
  }
@@ -15163,9 +15181,9 @@ function mergeRelatedRecordsFields(first, second) {
15163
15181
  throw new Error('Aggregate UI response is invalid');
15164
15182
  }
15165
15183
  }
15166
- function makeNetworkChunkFieldsGetRelatedListRecords(networkAdapter) {
15184
+ function makeNetworkChunkFieldsGetRelatedListRecords(networkAdapter, instrumentationSink) {
15167
15185
  return (resourceRequest, resourceRequestContext) => {
15168
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_ENDPOINT_REGEX);
15186
+ const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_ENDPOINT_REGEX, instrumentationSink);
15169
15187
  if (batchRequestInfo === undefined) {
15170
15188
  return networkAdapter(resourceRequest, resourceRequestContext);
15171
15189
  }
@@ -15241,9 +15259,9 @@ function recordIdsAllMatch(first, second) {
15241
15259
 
15242
15260
  const RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX = /^\/ui-api\/related-list-records\/batch\/?(([a-zA-Z0-9]+))?\//;
15243
15261
  const referenceId = 'LDS_Related_List_Records_AggregateUi';
15244
- function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter) {
15262
+ function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter, instrumentationSink) {
15245
15263
  return (resourceRequest, resourceRequestContext) => {
15246
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX);
15264
+ const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX, instrumentationSink);
15247
15265
  if (batchRequestInfo === undefined) {
15248
15266
  return networkAdapter(resourceRequest, resourceRequestContext);
15249
15267
  }
@@ -15266,7 +15284,7 @@ function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter) {
15266
15284
  *
15267
15285
  * @param networkAdapter the network adapter to do the call.
15268
15286
  */
15269
- function makeNetworkAdapterChunkRecordFields(networkAdapter) {
15287
+ function makeNetworkAdapterChunkRecordFields(networkAdapter, instrumentationSink) {
15270
15288
  // endpoint handlers that support aggregate-ui field batching
15271
15289
  const batchHandlers = [
15272
15290
  makeNetworkChunkFieldsGetRecord,
@@ -15275,7 +15293,7 @@ function makeNetworkAdapterChunkRecordFields(networkAdapter) {
15275
15293
  makeNetworkChunkFieldsGetRelatedListRecordsBatch,
15276
15294
  ];
15277
15295
  return batchHandlers.reduce((network, handler) => {
15278
- return handler(network);
15296
+ return handler(network, instrumentationSink);
15279
15297
  }, networkAdapter);
15280
15298
  }
15281
15299
 
@@ -15552,6 +15570,11 @@ function reportPrimingConflict(resolutionType, recordCount) {
15552
15570
  resolutionType,
15553
15571
  });
15554
15572
  }
15573
+ /** Network */
15574
+ function reportChunkCandidateUrlLength(urlLength) {
15575
+ const buckets = [8000, 10000, 12000, 14000, 16000];
15576
+ ldsMobileInstrumentation.bucketValue('chunk-candidate-url-length-histogram', urlLength, buckets);
15577
+ }
15555
15578
 
15556
15579
  /**
15557
15580
  * HOF (high-order-function) that instruments any async operation. If the operation
@@ -17762,7 +17785,9 @@ function getRuntime() {
17762
17785
  const { newRecordId, isGenerated } = recordIdGenerator(userId);
17763
17786
  // non-draft-aware base services
17764
17787
  const store = new InMemoryStore();
17765
- lazyNetworkAdapter = platformNetworkAdapter(makeNetworkAdapterChunkRecordFields(NimbusNetworkAdapter));
17788
+ lazyNetworkAdapter = platformNetworkAdapter(makeNetworkAdapterChunkRecordFields(NimbusNetworkAdapter, {
17789
+ reportChunkCandidateUrlLength: reportChunkCandidateUrlLength,
17790
+ }));
17766
17791
  lazyBaseDurableStore = getNimbusDurableStore();
17767
17792
  // specific adapters
17768
17793
  const internalAdapterStore = new InMemoryStore();
@@ -17891,4 +17916,4 @@ register({
17891
17916
  });
17892
17917
 
17893
17918
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
17894
- // version: 1.260.0-95d02abca
17919
+ // version: 1.262.0-af6b3d211
@@ -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 {};
@@ -15,3 +15,5 @@ export declare function reportPrimingSessionCreated(): void;
15
15
  export declare function reportPrimingError(errorType: string, recordCount: number): void;
16
16
  export declare function reportPrimingSuccess(recordCount: number): void;
17
17
  export declare function reportPrimingConflict(resolutionType: string, recordCount: number): void;
18
+ /** Network */
19
+ export declare function reportChunkCandidateUrlLength(urlLength: number): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.260.0",
3
+ "version": "1.262.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for mobile/hybrid environments.",
6
6
  "main": "dist/main.js",
@@ -32,25 +32,25 @@
32
32
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-mobile"
33
33
  },
34
34
  "dependencies": {
35
- "@salesforce/lds-adapters-uiapi": "^1.260.0",
36
- "@salesforce/lds-bindings": "^1.260.0",
37
- "@salesforce/lds-instrumentation": "^1.260.0",
38
- "@salesforce/lds-priming": "^1.260.0",
35
+ "@salesforce/lds-adapters-uiapi": "^1.262.0",
36
+ "@salesforce/lds-bindings": "^1.262.0",
37
+ "@salesforce/lds-instrumentation": "^1.262.0",
38
+ "@salesforce/lds-priming": "^1.262.0",
39
39
  "@salesforce/user": "0.0.21",
40
40
  "o11y": "244.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@salesforce/lds-adapters-graphql": "^1.260.0",
44
- "@salesforce/lds-drafts": "^1.260.0",
45
- "@salesforce/lds-drafts-adapters-uiapi": "^1.260.0",
46
- "@salesforce/lds-graphql-eval": "^1.260.0",
47
- "@salesforce/lds-network-adapter": "^1.260.0",
48
- "@salesforce/lds-network-nimbus": "^1.260.0",
49
- "@salesforce/lds-store-binary": "^1.260.0",
50
- "@salesforce/lds-store-nimbus": "^1.260.0",
51
- "@salesforce/lds-store-sql": "^1.260.0",
52
- "@salesforce/lds-utils-adapters": "^1.260.0",
53
- "@salesforce/nimbus-plugin-lds": "^1.260.0",
43
+ "@salesforce/lds-adapters-graphql": "^1.262.0",
44
+ "@salesforce/lds-drafts": "^1.262.0",
45
+ "@salesforce/lds-drafts-adapters-uiapi": "^1.262.0",
46
+ "@salesforce/lds-graphql-eval": "^1.262.0",
47
+ "@salesforce/lds-network-adapter": "^1.262.0",
48
+ "@salesforce/lds-network-nimbus": "^1.262.0",
49
+ "@salesforce/lds-store-binary": "^1.262.0",
50
+ "@salesforce/lds-store-nimbus": "^1.262.0",
51
+ "@salesforce/lds-store-sql": "^1.262.0",
52
+ "@salesforce/lds-utils-adapters": "^1.262.0",
53
+ "@salesforce/nimbus-plugin-lds": "^1.262.0",
54
54
  "babel-plugin-dynamic-import-node": "^2.3.3",
55
55
  "wait-for-expect": "^3.0.2"
56
56
  },
package/sfdc/main.js CHANGED
@@ -14959,11 +14959,14 @@ function mergeBatchRecordsFields(first, second, collectionMergeFunc) {
14959
14959
  * @param endpoint Regular Expression to check the endpoint to aggregate
14960
14960
  * @returns undefined if we should not aggregate. object if we should.
14961
14961
  */
14962
- function createAggregateBatchRequestInfo(resourceRequest, endpoint) {
14962
+ function createAggregateBatchRequestInfo(resourceRequest, endpoint, instrumentationSink) {
14963
14963
  // only handle GETs on the given endpoint regex
14964
14964
  if (!isGetRequestForEndpoint(endpoint, resourceRequest)) {
14965
14965
  return undefined;
14966
14966
  }
14967
+ if (instrumentationSink) {
14968
+ instrumentationSink.reportChunkCandidateUrlLength(calculateEstimatedTotalUrlLength(resourceRequest));
14969
+ }
14967
14970
  const { queryParams: { fields, optionalFields }, } = resourceRequest;
14968
14971
  // only handle requests with fields or optional fields
14969
14972
  if (fields === undefined && optionalFields === undefined) {
@@ -15075,6 +15078,21 @@ function getMaxLengthPerChunkAllowed(request) {
15075
15078
  // MAX_URL_LENGTH - full lenght without fields, optionalFields
15076
15079
  return MAX_URL_LENGTH - roughUrlLengthWithoutFieldsAndOptionFields;
15077
15080
  }
15081
+ // we don't have access to the host so we cannot calculate the exact length of the url
15082
+ // so we will estimate it
15083
+ function calculateEstimatedTotalUrlLength(request) {
15084
+ const { baseUri, basePath, queryParams } = request;
15085
+ let url = `${baseUri}${basePath}`;
15086
+ if (queryParams) {
15087
+ const queryParamString = entries$2(queryParams)
15088
+ .map(([key, value]) => `${key}=${value}`)
15089
+ .join('&');
15090
+ if (queryParamString) {
15091
+ url += `?${queryParamString}`;
15092
+ }
15093
+ }
15094
+ return url.length;
15095
+ }
15078
15096
 
15079
15097
  const RECORD_ENDPOINT_REGEX = /^\/ui-api\/records\/?(([a-zA-Z0-9]+))?$/;
15080
15098
  const referenceId$3 = 'LDS_Records_AggregateUi';
@@ -15099,9 +15117,9 @@ function mergeGetRecordResult(first, second) {
15099
15117
  mergeRecordFields(first, second);
15100
15118
  return first;
15101
15119
  }
15102
- function makeNetworkChunkFieldsGetRecord(networkAdapter) {
15120
+ function makeNetworkChunkFieldsGetRecord(networkAdapter, instrumentationSink) {
15103
15121
  return (resourceRequest, resourceRequestContext) => {
15104
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORD_ENDPOINT_REGEX);
15122
+ const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORD_ENDPOINT_REGEX, instrumentationSink);
15105
15123
  if (batchRequestInfo === undefined) {
15106
15124
  return networkAdapter(resourceRequest, resourceRequestContext);
15107
15125
  }
@@ -15115,9 +15133,9 @@ function makeNetworkChunkFieldsGetRecord(networkAdapter) {
15115
15133
 
15116
15134
  const RECORDS_BATCH_ENDPOINT_REGEX = /^\/ui-api\/records\/batch\/?(([a-zA-Z0-9|,]+))?$/;
15117
15135
  const referenceId$2 = 'LDS_Records_Batch_AggregateUi';
15118
- function makeNetworkChunkFieldsGetRecordsBatch(networkAdapter) {
15136
+ function makeNetworkChunkFieldsGetRecordsBatch(networkAdapter, intrumentationSink) {
15119
15137
  return (resourceRequest, resourceRequestContext) => {
15120
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORDS_BATCH_ENDPOINT_REGEX);
15138
+ const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RECORDS_BATCH_ENDPOINT_REGEX, intrumentationSink);
15121
15139
  if (batchRequestInfo === undefined) {
15122
15140
  return networkAdapter(resourceRequest, resourceRequestContext);
15123
15141
  }
@@ -15163,9 +15181,9 @@ function mergeRelatedRecordsFields(first, second) {
15163
15181
  throw new Error('Aggregate UI response is invalid');
15164
15182
  }
15165
15183
  }
15166
- function makeNetworkChunkFieldsGetRelatedListRecords(networkAdapter) {
15184
+ function makeNetworkChunkFieldsGetRelatedListRecords(networkAdapter, instrumentationSink) {
15167
15185
  return (resourceRequest, resourceRequestContext) => {
15168
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_ENDPOINT_REGEX);
15186
+ const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_ENDPOINT_REGEX, instrumentationSink);
15169
15187
  if (batchRequestInfo === undefined) {
15170
15188
  return networkAdapter(resourceRequest, resourceRequestContext);
15171
15189
  }
@@ -15241,9 +15259,9 @@ function recordIdsAllMatch(first, second) {
15241
15259
 
15242
15260
  const RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX = /^\/ui-api\/related-list-records\/batch\/?(([a-zA-Z0-9]+))?\//;
15243
15261
  const referenceId = 'LDS_Related_List_Records_AggregateUi';
15244
- function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter) {
15262
+ function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter, instrumentationSink) {
15245
15263
  return (resourceRequest, resourceRequestContext) => {
15246
- const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX);
15264
+ const batchRequestInfo = createAggregateBatchRequestInfo(resourceRequest, RELATED_LIST_RECORDS_BATCH_ENDPOINT_REGEX, instrumentationSink);
15247
15265
  if (batchRequestInfo === undefined) {
15248
15266
  return networkAdapter(resourceRequest, resourceRequestContext);
15249
15267
  }
@@ -15266,7 +15284,7 @@ function makeNetworkChunkFieldsGetRelatedListRecordsBatch(networkAdapter) {
15266
15284
  *
15267
15285
  * @param networkAdapter the network adapter to do the call.
15268
15286
  */
15269
- function makeNetworkAdapterChunkRecordFields(networkAdapter) {
15287
+ function makeNetworkAdapterChunkRecordFields(networkAdapter, instrumentationSink) {
15270
15288
  // endpoint handlers that support aggregate-ui field batching
15271
15289
  const batchHandlers = [
15272
15290
  makeNetworkChunkFieldsGetRecord,
@@ -15275,7 +15293,7 @@ function makeNetworkAdapterChunkRecordFields(networkAdapter) {
15275
15293
  makeNetworkChunkFieldsGetRelatedListRecordsBatch,
15276
15294
  ];
15277
15295
  return batchHandlers.reduce((network, handler) => {
15278
- return handler(network);
15296
+ return handler(network, instrumentationSink);
15279
15297
  }, networkAdapter);
15280
15298
  }
15281
15299
 
@@ -15552,6 +15570,11 @@ function reportPrimingConflict(resolutionType, recordCount) {
15552
15570
  resolutionType,
15553
15571
  });
15554
15572
  }
15573
+ /** Network */
15574
+ function reportChunkCandidateUrlLength(urlLength) {
15575
+ const buckets = [8000, 10000, 12000, 14000, 16000];
15576
+ ldsMobileInstrumentation.bucketValue('chunk-candidate-url-length-histogram', urlLength, buckets);
15577
+ }
15555
15578
 
15556
15579
  /**
15557
15580
  * HOF (high-order-function) that instruments any async operation. If the operation
@@ -17762,7 +17785,9 @@ function getRuntime() {
17762
17785
  const { newRecordId, isGenerated } = recordIdGenerator(userId);
17763
17786
  // non-draft-aware base services
17764
17787
  const store = new InMemoryStore();
17765
- lazyNetworkAdapter = platformNetworkAdapter(makeNetworkAdapterChunkRecordFields(NimbusNetworkAdapter));
17788
+ lazyNetworkAdapter = platformNetworkAdapter(makeNetworkAdapterChunkRecordFields(NimbusNetworkAdapter, {
17789
+ reportChunkCandidateUrlLength: reportChunkCandidateUrlLength,
17790
+ }));
17766
17791
  lazyBaseDurableStore = getNimbusDurableStore();
17767
17792
  // specific adapters
17768
17793
  const internalAdapterStore = new InMemoryStore();
@@ -17891,4 +17916,4 @@ register({
17891
17916
  });
17892
17917
 
17893
17918
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
17894
- // version: 1.260.0-95d02abca
17919
+ // version: 1.262.0-af6b3d211
@@ -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 {};
@@ -15,3 +15,5 @@ export declare function reportPrimingSessionCreated(): void;
15
15
  export declare function reportPrimingError(errorType: string, recordCount: number): void;
16
16
  export declare function reportPrimingSuccess(recordCount: number): void;
17
17
  export declare function reportPrimingConflict(resolutionType: string, recordCount: number): void;
18
+ /** Network */
19
+ export declare function reportChunkCandidateUrlLength(urlLength: number): void;