@salesforce/lds-runtime-aura 1.321.0 → 1.323.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/ldsEngineCreator.js +332 -28
- package/dist/types/jwt-authorized-fetch-service.d.ts +6 -0
- package/dist/types/main.d.ts +1 -0
- package/dist/types/predictive-loading/prefetcher/utils.d.ts +23 -0
- package/dist/types/predictive-loading/request-strategy/request-strategy.d.ts +11 -0
- package/package.json +26 -23
package/dist/ldsEngineCreator.js
CHANGED
|
@@ -73,7 +73,7 @@ class NetworkCommand extends BaseCommand {
|
|
|
73
73
|
return this.fetch();
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
function buildServiceDescriptor$
|
|
76
|
+
function buildServiceDescriptor$a() {
|
|
77
77
|
return {
|
|
78
78
|
type: 'networkCommandBaseClass',
|
|
79
79
|
version: '1.0',
|
|
@@ -88,6 +88,10 @@ function buildServiceDescriptor$9() {
|
|
|
88
88
|
*/
|
|
89
89
|
|
|
90
90
|
|
|
91
|
+
const { create: create$1, freeze, keys: keys$1 } = Object;
|
|
92
|
+
const { isArray: isArray$1 } = Array;
|
|
93
|
+
const { stringify: stringify$1 } = JSON;
|
|
94
|
+
|
|
91
95
|
const LogLevelMap$1 = {
|
|
92
96
|
TRACE: 4,
|
|
93
97
|
DEBUG: 3,
|
|
@@ -215,6 +219,61 @@ function rejectedPromiseLike(reason) {
|
|
|
215
219
|
function isPromiseLike(x) {
|
|
216
220
|
return typeof x === 'object' && typeof (x === null || x === void 0 ? void 0 : x.then) === 'function';
|
|
217
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
|
|
224
|
+
* This is needed because insertion order for JSON.stringify(object) affects output:
|
|
225
|
+
* JSON.stringify({a: 1, b: 2})
|
|
226
|
+
* "{"a":1,"b":2}"
|
|
227
|
+
* JSON.stringify({b: 2, a: 1})
|
|
228
|
+
* "{"b":2,"a":1}"
|
|
229
|
+
* @param data Data to be JSON-stringified.
|
|
230
|
+
* @returns JSON.stringified value with consistent ordering of keys.
|
|
231
|
+
*/
|
|
232
|
+
function stableJSONStringify$2(node) {
|
|
233
|
+
// This is for Date values.
|
|
234
|
+
if (node && node.toJSON && typeof node.toJSON === 'function') {
|
|
235
|
+
// eslint-disable-next-line no-param-reassign
|
|
236
|
+
node = node.toJSON();
|
|
237
|
+
}
|
|
238
|
+
if (node === undefined) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (typeof node === 'number') {
|
|
242
|
+
return isFinite(node) ? '' + node : 'null';
|
|
243
|
+
}
|
|
244
|
+
if (typeof node !== 'object') {
|
|
245
|
+
return stringify$1(node);
|
|
246
|
+
}
|
|
247
|
+
let i;
|
|
248
|
+
let out;
|
|
249
|
+
if (isArray$1(node)) {
|
|
250
|
+
out = '[';
|
|
251
|
+
for (i = 0; i < node.length; i++) {
|
|
252
|
+
if (i) {
|
|
253
|
+
out += ',';
|
|
254
|
+
}
|
|
255
|
+
out += stableJSONStringify$2(node[i]) || 'null';
|
|
256
|
+
}
|
|
257
|
+
return out + ']';
|
|
258
|
+
}
|
|
259
|
+
if (node === null) {
|
|
260
|
+
return 'null';
|
|
261
|
+
}
|
|
262
|
+
const objKeys = keys$1(node).sort();
|
|
263
|
+
out = '';
|
|
264
|
+
for (i = 0; i < objKeys.length; i++) {
|
|
265
|
+
const key = objKeys[i];
|
|
266
|
+
const value = stableJSONStringify$2(node[key]);
|
|
267
|
+
if (!value) {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (out) {
|
|
271
|
+
out += ',';
|
|
272
|
+
}
|
|
273
|
+
out += stringify$1(key) + ':' + value;
|
|
274
|
+
}
|
|
275
|
+
return '{' + out + '}';
|
|
276
|
+
}
|
|
218
277
|
/**
|
|
219
278
|
* Converts an arbitrary value to an Error.
|
|
220
279
|
*
|
|
@@ -271,7 +330,7 @@ class AuraNetworkCommand extends NetworkCommand {
|
|
|
271
330
|
}
|
|
272
331
|
}
|
|
273
332
|
|
|
274
|
-
function buildServiceDescriptor$
|
|
333
|
+
function buildServiceDescriptor$9() {
|
|
275
334
|
return {
|
|
276
335
|
type: 'auraNetworkCommandBaseClass',
|
|
277
336
|
version: '1.0',
|
|
@@ -286,6 +345,116 @@ function buildServiceDescriptor$8() {
|
|
|
286
345
|
*/
|
|
287
346
|
|
|
288
347
|
|
|
348
|
+
/**
|
|
349
|
+
* An implementation of BaseCommand that allows for extending abstract cache methods
|
|
350
|
+
*
|
|
351
|
+
* @typeParam Data cache result for read operations
|
|
352
|
+
* @typeParam NetworkResult cache result including network metadata
|
|
353
|
+
* @typeParam ExtraServices additional named services needed by a subclass
|
|
354
|
+
*/
|
|
355
|
+
class CacheControlCommand extends BaseCommand {
|
|
356
|
+
constructor(services) {
|
|
357
|
+
super();
|
|
358
|
+
this.services = services;
|
|
359
|
+
}
|
|
360
|
+
execute() {
|
|
361
|
+
return this.services.cacheController.execute(this.cacheControlStrategyConfig, (cache) => this.buildRequestRunner(cache));
|
|
362
|
+
}
|
|
363
|
+
buildRequestRunner(cache) {
|
|
364
|
+
return {
|
|
365
|
+
readFromCache: () => this.readFromCache(cache),
|
|
366
|
+
requestFromNetwork: () => this.requestFromNetwork(),
|
|
367
|
+
writeToCache: (networkResult) => this.writeToCache(cache, networkResult),
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
374
|
+
* All rights reserved.
|
|
375
|
+
* For full license text, see the LICENSE.txt file
|
|
376
|
+
*/
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* An implementation of BaseCommand that allows for extending abstract cache methods
|
|
381
|
+
*
|
|
382
|
+
* @typeParam Data cache result for read operations
|
|
383
|
+
* @typeParam NetworkResult cache result including network metadata
|
|
384
|
+
* @typeParam ExtraServices additional named services needed by a subclass
|
|
385
|
+
*/
|
|
386
|
+
class AuraResourceCacheControlCommand extends CacheControlCommand {
|
|
387
|
+
constructor(services) {
|
|
388
|
+
super(services);
|
|
389
|
+
this.services = services;
|
|
390
|
+
this.actionConfig = {
|
|
391
|
+
background: false,
|
|
392
|
+
hotspot: true,
|
|
393
|
+
longRunning: false,
|
|
394
|
+
storable: false,
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
execute() {
|
|
398
|
+
return super.execute();
|
|
399
|
+
}
|
|
400
|
+
readFromCache(cache) {
|
|
401
|
+
var _a;
|
|
402
|
+
return resolvedPromiseLike(ok((_a = cache.get(this.buildKey())) === null || _a === void 0 ? void 0 : _a.value));
|
|
403
|
+
}
|
|
404
|
+
requestFromNetwork() {
|
|
405
|
+
return this.convertAuraResponseToData(this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig));
|
|
406
|
+
}
|
|
407
|
+
convertAuraResponseToData(responsePromise) {
|
|
408
|
+
return responsePromise
|
|
409
|
+
.then((response) => {
|
|
410
|
+
return ok(response.getReturnValue());
|
|
411
|
+
})
|
|
412
|
+
.catch((error) => {
|
|
413
|
+
if (!error || !error.getError) {
|
|
414
|
+
return err(toError('Failed to get error from response'));
|
|
415
|
+
}
|
|
416
|
+
const actionErrors = error.getError();
|
|
417
|
+
if (actionErrors.length > 0) {
|
|
418
|
+
return err(new AuraError(actionErrors));
|
|
419
|
+
}
|
|
420
|
+
return err(toError('Error fetching component'));
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
writeToCache(cache, networkResult) {
|
|
424
|
+
if (networkResult.isOk()) {
|
|
425
|
+
cache.set(this.buildKey(), {
|
|
426
|
+
value: networkResult.value,
|
|
427
|
+
metadata: { cacheControl: this.buildCacheControlMetadata(networkResult.value) },
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
return resolvedPromiseLike(undefined);
|
|
431
|
+
}
|
|
432
|
+
buildKey() {
|
|
433
|
+
return `{"endpoint":${this.endpoint},"params":${stableJSONStringify$2(this.auraParams)}}`;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
class AuraError extends Error {
|
|
437
|
+
constructor(data) {
|
|
438
|
+
super();
|
|
439
|
+
this.data = data;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
function buildServiceDescriptor$8() {
|
|
444
|
+
return {
|
|
445
|
+
type: 'auraResourceCacheControlCommand',
|
|
446
|
+
version: '1.0',
|
|
447
|
+
service: AuraResourceCacheControlCommand,
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
453
|
+
* All rights reserved.
|
|
454
|
+
* For full license text, see the LICENSE.txt file
|
|
455
|
+
*/
|
|
456
|
+
|
|
457
|
+
|
|
289
458
|
/**
|
|
290
459
|
* An implementation of NetworkCommand that uses HTTP/fetch as the transport mechanism.
|
|
291
460
|
*/
|
|
@@ -1040,12 +1209,41 @@ class CacheController {
|
|
|
1040
1209
|
|
|
1041
1210
|
function buildServiceDescriptor$1(cache) {
|
|
1042
1211
|
return {
|
|
1043
|
-
type: '
|
|
1212
|
+
type: 'cacheController',
|
|
1044
1213
|
version: '1.0',
|
|
1045
1214
|
service: new CacheController({ cache }),
|
|
1046
1215
|
};
|
|
1047
1216
|
}
|
|
1048
1217
|
|
|
1218
|
+
/**
|
|
1219
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
1220
|
+
* All rights reserved.
|
|
1221
|
+
* For full license text, see the LICENSE.txt file
|
|
1222
|
+
*/
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* Most-recently set of published services.
|
|
1226
|
+
*/
|
|
1227
|
+
let servicesAvailable;
|
|
1228
|
+
new Promise((resolve) => (servicesAvailable = resolve));
|
|
1229
|
+
/**
|
|
1230
|
+
* Sets the services that will be used to satisfy calls to getServices().
|
|
1231
|
+
* Any previously registered services are replaced with the services provided.
|
|
1232
|
+
* Note overwriting services should be done with great care as previous callers
|
|
1233
|
+
* of getServices() will not be aware of the new services.
|
|
1234
|
+
*
|
|
1235
|
+
* The default implementation provided by this module only supports a single
|
|
1236
|
+
* set of active services. Runtime environments that require multiple sets of
|
|
1237
|
+
* active services will need to override this module with their own
|
|
1238
|
+
* implementation.
|
|
1239
|
+
|
|
1240
|
+
* @param services services to be used to satisfy future getServices() requests
|
|
1241
|
+
*/
|
|
1242
|
+
function setServices(services) {
|
|
1243
|
+
resolvedPromiseLike(services);
|
|
1244
|
+
servicesAvailable(services);
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1049
1247
|
/**
|
|
1050
1248
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
1051
1249
|
* All rights reserved.
|
|
@@ -1550,9 +1748,79 @@ const composedNetworkAdapter$1 = {
|
|
|
1550
1748
|
function e(e){this.message=e;}e.prototype=new Error,e.prototype.name="InvalidCharacterError";"undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(r){var t=String(r).replace(/=+$/,"");if(t.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,a=0,i=0,c="";o=t.charAt(i++);~o&&(n=a%4?64*n+o:o,a++%4)?c+=String.fromCharCode(255&n>>(-2*a&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return c};function n(e){this.message=e;}n.prototype=new Error,n.prototype.name="InvalidTokenError";
|
|
1551
1749
|
|
|
1552
1750
|
const SFAP_BASE_URL = 'api.salesforce.com';
|
|
1751
|
+
const sfapJwtRepository = new JwtRepository();
|
|
1752
|
+
const sfapJwtManager = new JwtManager(sfapJwtRepository, platformSfapJwtResolver);
|
|
1553
1753
|
function buildJwtAuthorizedSfapFetchServiceDescriptor(logger) {
|
|
1554
|
-
const
|
|
1555
|
-
|
|
1754
|
+
const jwtAuthorizedFetchService = buildServiceDescriptor({
|
|
1755
|
+
request: [buildJwtRequestInterceptor(logger)],
|
|
1756
|
+
});
|
|
1757
|
+
return {
|
|
1758
|
+
...jwtAuthorizedFetchService,
|
|
1759
|
+
tags: { authenticationScopes: 'sfap_api' },
|
|
1760
|
+
};
|
|
1761
|
+
}
|
|
1762
|
+
/**
|
|
1763
|
+
* Returns a service descriptor for a fetch service that includes one-off copilot
|
|
1764
|
+
* hacks. This fetch service is not intended for use by anything other than
|
|
1765
|
+
* copilot commands.
|
|
1766
|
+
*/
|
|
1767
|
+
function buildCopilotFetchServiceDescriptor(logger) {
|
|
1768
|
+
return {
|
|
1769
|
+
// Note that this layers the Interceptor below directly on top of fetch(). WHen
|
|
1770
|
+
// we switch to JWT authentication this will need to change to incorporate the
|
|
1771
|
+
// Interceptor here with the logic in buildJwtAuthorizedSfapFetchServiceDescriptor()
|
|
1772
|
+
// above.
|
|
1773
|
+
...buildServiceDescriptor({
|
|
1774
|
+
request: [
|
|
1775
|
+
// Note that this function is VERY closely tied to the fetchParams generated
|
|
1776
|
+
// by copilotStartSessionCommand. Any changes to those parameters will require
|
|
1777
|
+
// corresponding updates to the logic below.
|
|
1778
|
+
(args) => {
|
|
1779
|
+
const [url, requestInit] = args;
|
|
1780
|
+
// ignore anything other than a start session request
|
|
1781
|
+
if (typeof url !== 'string' ||
|
|
1782
|
+
!url.endsWith('/sessions') ||
|
|
1783
|
+
!requestInit ||
|
|
1784
|
+
requestInit.method !== 'POST' ||
|
|
1785
|
+
!requestInit.body ||
|
|
1786
|
+
typeof requestInit.body !== 'string') {
|
|
1787
|
+
return resolvedPromiseLike(args);
|
|
1788
|
+
}
|
|
1789
|
+
return resolvedPromiseLike(sfapJwtManager.getJwt()).then((token) => {
|
|
1790
|
+
// replace the body's instanceConfig.endpoint with the JWT's iss value
|
|
1791
|
+
const body = JSON.parse(requestInit.body);
|
|
1792
|
+
if (!body || !token.decodedInfo || !token.decodedInfo.iss) {
|
|
1793
|
+
logger.warn('skipping injection of endpoint into start session request');
|
|
1794
|
+
}
|
|
1795
|
+
else {
|
|
1796
|
+
if (!body.instanceConfig) {
|
|
1797
|
+
body.instanceConfig = {};
|
|
1798
|
+
}
|
|
1799
|
+
body.instanceConfig.endpoint = token.decodedInfo.iss;
|
|
1800
|
+
}
|
|
1801
|
+
return [
|
|
1802
|
+
args[0],
|
|
1803
|
+
{
|
|
1804
|
+
...args[1],
|
|
1805
|
+
body: JSON.stringify(body),
|
|
1806
|
+
},
|
|
1807
|
+
];
|
|
1808
|
+
});
|
|
1809
|
+
},
|
|
1810
|
+
buildJwtRequestInterceptor(logger),
|
|
1811
|
+
],
|
|
1812
|
+
}),
|
|
1813
|
+
tags: { specialHacksFor: 'copilot' },
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
function buildUnauthorizedFetchServiceDescriptor() {
|
|
1817
|
+
const fetchService = buildServiceDescriptor();
|
|
1818
|
+
return {
|
|
1819
|
+
...fetchService,
|
|
1820
|
+
tags: { authenticationScopes: '' },
|
|
1821
|
+
};
|
|
1822
|
+
}
|
|
1823
|
+
function buildJwtRequestInterceptor(logger) {
|
|
1556
1824
|
const jwtRequestModifier = ({ baseUri }, [resource, request]) => {
|
|
1557
1825
|
if (typeof resource !== 'string' && !(resource instanceof URL)) {
|
|
1558
1826
|
// istanbul ignore else: this will not be tested in NODE_ENV = production for test coverage
|
|
@@ -1571,21 +1839,8 @@ function buildJwtAuthorizedSfapFetchServiceDescriptor(logger) {
|
|
|
1571
1839
|
url.protocol = overrideUrl.protocol;
|
|
1572
1840
|
return [url, request];
|
|
1573
1841
|
};
|
|
1574
|
-
const jwtRequestHeaderInterceptor = buildJwtRequestHeaderInterceptor(
|
|
1575
|
-
|
|
1576
|
-
request: [jwtRequestHeaderInterceptor],
|
|
1577
|
-
});
|
|
1578
|
-
return {
|
|
1579
|
-
...jwtAuthorizedFetchService,
|
|
1580
|
-
tags: { authenticationScopes: 'sfap_api' },
|
|
1581
|
-
};
|
|
1582
|
-
}
|
|
1583
|
-
function buildUnauthorizedFetchServiceDescriptor() {
|
|
1584
|
-
const fetchService = buildServiceDescriptor();
|
|
1585
|
-
return {
|
|
1586
|
-
...fetchService,
|
|
1587
|
-
tags: { authenticationScopes: '' },
|
|
1588
|
-
};
|
|
1842
|
+
const jwtRequestHeaderInterceptor = buildJwtRequestHeaderInterceptor(sfapJwtManager, jwtRequestModifier);
|
|
1843
|
+
return jwtRequestHeaderInterceptor;
|
|
1589
1844
|
}
|
|
1590
1845
|
|
|
1591
1846
|
const PDL_EXECUTE_ASYNC_OPTIONS = {
|
|
@@ -1634,7 +1889,17 @@ const { create, keys, hasOwnProperty, entries } = Object;
|
|
|
1634
1889
|
const { isArray, from } = Array;
|
|
1635
1890
|
const { stringify } = JSON;
|
|
1636
1891
|
|
|
1892
|
+
// Note: exported enum for core usage.
|
|
1893
|
+
var PdlRequestPriority;
|
|
1894
|
+
(function (PdlRequestPriority) {
|
|
1895
|
+
PdlRequestPriority[PdlRequestPriority["LOW"] = 0] = "LOW";
|
|
1896
|
+
PdlRequestPriority[PdlRequestPriority["NORMAL"] = 1] = "NORMAL";
|
|
1897
|
+
PdlRequestPriority[PdlRequestPriority["HIGH"] = 2] = "HIGH";
|
|
1898
|
+
})(PdlRequestPriority || (PdlRequestPriority = {}));
|
|
1637
1899
|
class RequestStrategy {
|
|
1900
|
+
getRequestPriority(_request, _context) {
|
|
1901
|
+
return 1 /* RequestPriority.NORMAL */;
|
|
1902
|
+
}
|
|
1638
1903
|
/**
|
|
1639
1904
|
* Perform any transformations required to prepare the request for saving.
|
|
1640
1905
|
*
|
|
@@ -2943,6 +3208,7 @@ const RECORD_HOME_SUPPORTED_ADAPTERS = new Set([
|
|
|
2943
3208
|
GET_RELATED_LIST_RECORDS_BATCH_ADAPTER_NAME,
|
|
2944
3209
|
GET_RELATED_LIST_RECORDS_ADAPTER_NAME,
|
|
2945
3210
|
GET_RELATED_LISTS_ACTIONS_ADAPTER_NAME,
|
|
3211
|
+
'templateApi', // external - getTemplateDescriptorWithExpansionBundle
|
|
2946
3212
|
]);
|
|
2947
3213
|
class RecordHomePage extends LexDefaultPage {
|
|
2948
3214
|
constructor(context, requestStrategyManager, options) {
|
|
@@ -3845,6 +4111,39 @@ async function runRequestsWithLimit(requests, runner, concurrentRequestsLimit, p
|
|
|
3845
4111
|
// Wait for all initial requests to complete
|
|
3846
4112
|
await Promise.all(promises);
|
|
3847
4113
|
}
|
|
4114
|
+
/**
|
|
4115
|
+
* Compares two request entries based on their priority and, if the priorities are the same, their request times.
|
|
4116
|
+
* This function is typically used for sorting requests where priority takes precedence, and timing is used
|
|
4117
|
+
* as a secondary criterion. The function assumes that any necessary filtering of requests has already been done.
|
|
4118
|
+
*
|
|
4119
|
+
* @template Context - Extends `DefaultPageContext`, provides additional context for the request priority determination.
|
|
4120
|
+
*
|
|
4121
|
+
* @param {RequestEntry<LexRequest>} requestA - The first request entry containing the request and its metadata.
|
|
4122
|
+
* @param {RequestEntry<LexRequest>} requestB - The second request entry containing the request and its metadata.
|
|
4123
|
+
* @param {RequestStrategyManager} requestStrategyManager - Manager that provides access to request strategies based on adapter names.
|
|
4124
|
+
* @param {Context} context - The context in which the requests are being compared, used to determine request priority.
|
|
4125
|
+
*
|
|
4126
|
+
* @returns {number} A negative number if the first request should come before the second, a positive number if the
|
|
4127
|
+
* second should come before the first, or zero if they are considered equal for sorting purposes.
|
|
4128
|
+
* This is determined first by the priority (higher priority comes first) and then by the request
|
|
4129
|
+
* time (earlier request comes first) if priorities are the same. The priorities are fetched from
|
|
4130
|
+
* the `requestStrategyManager` for each request's `adapterName`. If a strategy is not found,
|
|
4131
|
+
* the priority defaults to `RequestPriority.LOW`.
|
|
4132
|
+
*/
|
|
4133
|
+
function compareByPriorityThenTime({ request: requestA, requestMetadata: requestMetadataA }, { request: requestB, requestMetadata: requestMetadataB }, requestStrategyManager, context) {
|
|
4134
|
+
const aPriority = requestStrategyManager.get(requestA.adapterName)?.getRequestPriority(requestA, context) ||
|
|
4135
|
+
0 /* RequestPriority.LOW */;
|
|
4136
|
+
const bPriority = requestStrategyManager.get(requestB.adapterName)?.getRequestPriority(requestB, context) ||
|
|
4137
|
+
0 /* RequestPriority.LOW */;
|
|
4138
|
+
if (aPriority === bPriority) {
|
|
4139
|
+
// when both requests have the same priority, use the request time in waterfall.
|
|
4140
|
+
return requestMetadataA.requestTime - requestMetadataB.requestTime;
|
|
4141
|
+
}
|
|
4142
|
+
else {
|
|
4143
|
+
// sort by priority, descending
|
|
4144
|
+
return bPriority - aPriority;
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
3848
4147
|
|
|
3849
4148
|
function isBoxcarableRequest({ request: { adapterName } }, requestStrategyManager) {
|
|
3850
4149
|
const strategy = requestStrategyManager.get(adapterName);
|
|
@@ -3897,20 +4196,22 @@ class LexPredictivePrefetcher extends ApplicationPredictivePrefetcher {
|
|
|
3897
4196
|
return [...exactPageRequests, ...similarPageRequests];
|
|
3898
4197
|
}
|
|
3899
4198
|
async predict() {
|
|
4199
|
+
// perf: caching access, to avoid this.prop in loops.
|
|
4200
|
+
const { requestStrategyManager, context } = this;
|
|
3900
4201
|
const alwaysRequests = this.page.getAlwaysRunRequests();
|
|
3901
4202
|
const pageRequests = this.getAllPageRequests();
|
|
3902
4203
|
// IMPORTANT: Because there's no way to differentiate a cmpDef prediction from the page
|
|
3903
4204
|
// requesting the cmpDef, we need to predict cmpDefs before we start watching
|
|
3904
4205
|
// for predictions in the page. Having this code after an
|
|
3905
4206
|
// await will make the predictions to be saved as predictions too.
|
|
3906
|
-
predictNonBoxcarableRequest(pageRequests.filter((r) => !isBoxcarableRequest(r,
|
|
4207
|
+
predictNonBoxcarableRequest(pageRequests.filter((r) => !isBoxcarableRequest(r, requestStrategyManager)), this.requestRunner);
|
|
3907
4208
|
const alwaysRequestEntries = alwaysRequests.map((request) => {
|
|
3908
4209
|
return {
|
|
3909
4210
|
request,
|
|
3910
4211
|
requestMetadata: { requestTime: 0 }, // ensures always requests are executed, and executed first.
|
|
3911
4212
|
};
|
|
3912
4213
|
});
|
|
3913
|
-
const boxcarablePredictions = pageRequests.filter((r) => isBoxcarableRequest(r,
|
|
4214
|
+
const boxcarablePredictions = pageRequests.filter((r) => isBoxcarableRequest(r, requestStrategyManager));
|
|
3914
4215
|
const reducedPredictions = this.page.shouldReduceAlwaysRequestsWithPredictions()
|
|
3915
4216
|
? this.requestRunner.reduceRequests([...boxcarablePredictions, ...alwaysRequestEntries])
|
|
3916
4217
|
: this.requestRunner.reduceRequests(boxcarablePredictions);
|
|
@@ -3918,7 +4219,7 @@ class LexPredictivePrefetcher extends ApplicationPredictivePrefetcher {
|
|
|
3918
4219
|
? [...alwaysRequestEntries, ...reducedPredictions]
|
|
3919
4220
|
: reducedPredictions)
|
|
3920
4221
|
// Sorting in order requested
|
|
3921
|
-
.sort((a, b) => a
|
|
4222
|
+
.sort((a, b) => compareByPriorityThenTime(a, b, requestStrategyManager, context));
|
|
3922
4223
|
this.totalRequestCount = predictedRequestsWithLimit.length;
|
|
3923
4224
|
await runRequestsWithLimit(predictedRequestsWithLimit, this.requestRunner, this.options.inflightRequestLimit,
|
|
3924
4225
|
// `this.repository.pageStartTime` would be the correct here,
|
|
@@ -4076,7 +4377,7 @@ function getEnvironmentSetting(name) {
|
|
|
4076
4377
|
}
|
|
4077
4378
|
return undefined;
|
|
4078
4379
|
}
|
|
4079
|
-
// version: 1.
|
|
4380
|
+
// version: 1.323.0-34d96539ec
|
|
4080
4381
|
|
|
4081
4382
|
const forceRecordTransactionsDisabled = getEnvironmentSetting(EnvironmentSettings.ForceRecordTransactionsDisabled);
|
|
4082
4383
|
//TODO: Some duplication here that can be most likely moved to a util class
|
|
@@ -4739,16 +5040,19 @@ function initializeOneStore() {
|
|
|
4739
5040
|
instrumentationServiceDescriptor,
|
|
4740
5041
|
buildUnauthorizedFetchServiceDescriptor(),
|
|
4741
5042
|
buildJwtAuthorizedSfapFetchServiceDescriptor(loggerService),
|
|
5043
|
+
buildCopilotFetchServiceDescriptor(loggerService),
|
|
4742
5044
|
buildAuraNetworkService(),
|
|
4743
5045
|
buildServiceDescriptor$4(instrumentationServiceDescriptor.service),
|
|
4744
5046
|
buildServiceDescriptor$1(cacheServiceDescriptor.service),
|
|
4745
|
-
buildServiceDescriptor$8(),
|
|
4746
|
-
buildServiceDescriptor$7(),
|
|
4747
5047
|
buildServiceDescriptor$9(),
|
|
5048
|
+
buildServiceDescriptor$7(),
|
|
5049
|
+
buildServiceDescriptor$a(),
|
|
4748
5050
|
buildServiceDescriptor$6(),
|
|
4749
5051
|
buildServiceDescriptor$5(),
|
|
5052
|
+
buildServiceDescriptor$8(),
|
|
4750
5053
|
];
|
|
4751
5054
|
serviceBroker.publish(services);
|
|
5055
|
+
setServices(services);
|
|
4752
5056
|
}
|
|
4753
5057
|
function initializeOnestoreUiApiAdapters() {
|
|
4754
5058
|
configuration.setGetObjectInfoAdapter(getObjectInfo);
|
|
@@ -4774,5 +5078,5 @@ function ldsEngineCreator() {
|
|
|
4774
5078
|
return { name: 'ldsEngineCreator' };
|
|
4775
5079
|
}
|
|
4776
5080
|
|
|
4777
|
-
export { LexRequestStrategy, buildPredictorForContext, ldsEngineCreator as default, initializeLDS, initializeOneStore, registerRequestStrategy, saveRequestAsPrediction, unregisterRequestStrategy, whenPredictionsReady };
|
|
4778
|
-
// version: 1.
|
|
5081
|
+
export { LexRequestStrategy, PdlRequestPriority, buildPredictorForContext, ldsEngineCreator as default, initializeLDS, initializeOneStore, registerRequestStrategy, saveRequestAsPrediction, unregisterRequestStrategy, whenPredictionsReady };
|
|
5082
|
+
// version: 1.323.0-ddaba12fc0
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { type FetchServiceDescriptor } from '@luvio/service-fetch-network/v1';
|
|
2
2
|
import { type LoggerService } from '@luvio/utils';
|
|
3
3
|
export declare function buildJwtAuthorizedSfapFetchServiceDescriptor(logger: LoggerService): FetchServiceDescriptor;
|
|
4
|
+
/**
|
|
5
|
+
* Returns a service descriptor for a fetch service that includes one-off copilot
|
|
6
|
+
* hacks. This fetch service is not intended for use by anything other than
|
|
7
|
+
* copilot commands.
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildCopilotFetchServiceDescriptor(logger: LoggerService): FetchServiceDescriptor;
|
|
4
10
|
export declare const lightningJwtResolver: {
|
|
5
11
|
getJwt(): Promise<any>;
|
|
6
12
|
};
|
package/dist/types/main.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type RecordHomePageContext } from './predictive-loading';
|
|
2
2
|
import type { LexRequestStrategy } from './predictive-loading/request-strategy/lex-request-strategy';
|
|
3
3
|
import { type LexRequest } from './predictive-loading/lex';
|
|
4
|
+
export { PdlRequestPriority } from './predictive-loading';
|
|
4
5
|
export { LexRequestStrategy } from './predictive-loading/request-strategy/lex-request-strategy';
|
|
5
6
|
/**
|
|
6
7
|
* Registers a request strategy to be utilized by PDL.
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { RequestRunner } from '../request-runner';
|
|
2
2
|
import type { RequestEntry } from '../common';
|
|
3
|
+
import type { LexRequest } from '../lex';
|
|
4
|
+
import type { RequestStrategyManager } from '../request-strategy-manager/request-strategy-manager';
|
|
5
|
+
import type { DefaultPageContext } from '../pages';
|
|
3
6
|
/**
|
|
4
7
|
* Runs a list of requests with a specified concurrency limit.
|
|
5
8
|
*
|
|
@@ -14,3 +17,23 @@ import type { RequestEntry } from '../common';
|
|
|
14
17
|
* Requests are only processed if their `requestTime` is less than the time elapsed since `pageStartTime`.
|
|
15
18
|
*/
|
|
16
19
|
export declare function runRequestsWithLimit<Request>(requests: RequestEntry<Request>[], runner: RequestRunner<Request>, concurrentRequestsLimit: number, pageStartTime: number): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Compares two request entries based on their priority and, if the priorities are the same, their request times.
|
|
22
|
+
* This function is typically used for sorting requests where priority takes precedence, and timing is used
|
|
23
|
+
* as a secondary criterion. The function assumes that any necessary filtering of requests has already been done.
|
|
24
|
+
*
|
|
25
|
+
* @template Context - Extends `DefaultPageContext`, provides additional context for the request priority determination.
|
|
26
|
+
*
|
|
27
|
+
* @param {RequestEntry<LexRequest>} requestA - The first request entry containing the request and its metadata.
|
|
28
|
+
* @param {RequestEntry<LexRequest>} requestB - The second request entry containing the request and its metadata.
|
|
29
|
+
* @param {RequestStrategyManager} requestStrategyManager - Manager that provides access to request strategies based on adapter names.
|
|
30
|
+
* @param {Context} context - The context in which the requests are being compared, used to determine request priority.
|
|
31
|
+
*
|
|
32
|
+
* @returns {number} A negative number if the first request should come before the second, a positive number if the
|
|
33
|
+
* second should come before the first, or zero if they are considered equal for sorting purposes.
|
|
34
|
+
* This is determined first by the priority (higher priority comes first) and then by the request
|
|
35
|
+
* time (earlier request comes first) if priorities are the same. The priorities are fetched from
|
|
36
|
+
* the `requestStrategyManager` for each request's `adapterName`. If a strategy is not found,
|
|
37
|
+
* the priority defaults to `RequestPriority.LOW`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function compareByPriorityThenTime<Context extends DefaultPageContext = DefaultPageContext>({ request: requestA, requestMetadata: requestMetadataA }: RequestEntry<LexRequest>, { request: requestB, requestMetadata: requestMetadataB }: RequestEntry<LexRequest>, requestStrategyManager: RequestStrategyManager, context: Context): number;
|
|
@@ -3,6 +3,16 @@ export type BaseAdapterRequest<Config = unknown> = {
|
|
|
3
3
|
adapterName: string;
|
|
4
4
|
config: Config;
|
|
5
5
|
};
|
|
6
|
+
export declare const enum RequestPriority {
|
|
7
|
+
LOW = 0,
|
|
8
|
+
NORMAL = 1,
|
|
9
|
+
HIGH = 2
|
|
10
|
+
}
|
|
11
|
+
export declare enum PdlRequestPriority {
|
|
12
|
+
LOW = 0,
|
|
13
|
+
NORMAL = 1,
|
|
14
|
+
HIGH = 2
|
|
15
|
+
}
|
|
6
16
|
export declare abstract class RequestStrategy<Config, Request extends BaseAdapterRequest<Config>, Context> {
|
|
7
17
|
/**
|
|
8
18
|
* Name of the adapter used in this strategy.
|
|
@@ -10,6 +20,7 @@ export declare abstract class RequestStrategy<Config, Request extends BaseAdapte
|
|
|
10
20
|
abstract adapterName: string;
|
|
11
21
|
abstract execute(config: Config): any;
|
|
12
22
|
abstract buildConcreteRequest(similarRequest: Request, context: Context): Request;
|
|
23
|
+
getRequestPriority(_request: Request, _context: Context): RequestPriority;
|
|
13
24
|
/**
|
|
14
25
|
* Perform any transformations required to prepare the request for saving.
|
|
15
26
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-runtime-aura",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.323.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "LDS engine for Aura runtime",
|
|
6
6
|
"main": "dist/ldsEngineCreator.js",
|
|
@@ -34,33 +34,36 @@
|
|
|
34
34
|
"release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-aura"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@luvio/service-broker": "5.
|
|
38
|
-
"@
|
|
39
|
-
"@salesforce/lds-adapters-
|
|
37
|
+
"@luvio/service-broker": "5.13.0",
|
|
38
|
+
"@luvio/service-provisioner": "5.13.0",
|
|
39
|
+
"@salesforce/lds-adapters-apex": "^1.323.0",
|
|
40
|
+
"@salesforce/lds-adapters-uiapi": "^1.323.0",
|
|
40
41
|
"@salesforce/lds-adapters-uiapi-lex": "^1.302.0",
|
|
41
|
-
"@salesforce/lds-ads-bridge": "^1.
|
|
42
|
-
"@salesforce/lds-aura-storage": "^1.
|
|
43
|
-
"@salesforce/lds-bindings": "^1.
|
|
44
|
-
"@salesforce/lds-instrumentation": "^1.
|
|
45
|
-
"@salesforce/lds-network-aura": "^1.
|
|
46
|
-
"@salesforce/lds-network-fetch-with-jwt": "^1.
|
|
42
|
+
"@salesforce/lds-ads-bridge": "^1.323.0",
|
|
43
|
+
"@salesforce/lds-aura-storage": "^1.323.0",
|
|
44
|
+
"@salesforce/lds-bindings": "^1.323.0",
|
|
45
|
+
"@salesforce/lds-instrumentation": "^1.323.0",
|
|
46
|
+
"@salesforce/lds-network-aura": "^1.323.0",
|
|
47
|
+
"@salesforce/lds-network-fetch-with-jwt": "^1.323.0",
|
|
48
|
+
"jwt-encode": "1.0.1"
|
|
47
49
|
},
|
|
48
50
|
"dependencies": {
|
|
49
|
-
"@luvio/command-aura-network": "5.
|
|
50
|
-
"@luvio/command-
|
|
51
|
-
"@luvio/command-network": "5.
|
|
52
|
-
"@luvio/command-
|
|
53
|
-
"@luvio/command-
|
|
51
|
+
"@luvio/command-aura-network": "5.13.0",
|
|
52
|
+
"@luvio/command-aura-resource-cache-control": "5.13.0",
|
|
53
|
+
"@luvio/command-fetch-network": "5.13.0",
|
|
54
|
+
"@luvio/command-network": "5.13.0",
|
|
55
|
+
"@luvio/command-sse": "5.13.0",
|
|
56
|
+
"@luvio/command-streaming": "5.13.0",
|
|
54
57
|
"@luvio/network-adapter-composable": "0.156.5",
|
|
55
58
|
"@luvio/network-adapter-fetch": "0.156.5",
|
|
56
|
-
"@luvio/service-aura-network": "5.
|
|
57
|
-
"@luvio/service-cache": "5.
|
|
58
|
-
"@luvio/service-cache-control": "5.
|
|
59
|
-
"@luvio/service-fetch-network": "5.
|
|
60
|
-
"@luvio/service-instrument-command": "5.
|
|
61
|
-
"@luvio/service-store": "5.
|
|
62
|
-
"@luvio/utils": "5.
|
|
63
|
-
"@salesforce/lds-adapters-uiapi-lex": "^1.
|
|
59
|
+
"@luvio/service-aura-network": "5.13.0",
|
|
60
|
+
"@luvio/service-cache": "5.13.0",
|
|
61
|
+
"@luvio/service-cache-control": "5.13.0",
|
|
62
|
+
"@luvio/service-fetch-network": "5.13.0",
|
|
63
|
+
"@luvio/service-instrument-command": "5.13.0",
|
|
64
|
+
"@luvio/service-store": "5.13.0",
|
|
65
|
+
"@luvio/utils": "5.13.0",
|
|
66
|
+
"@salesforce/lds-adapters-uiapi-lex": "^1.323.0"
|
|
64
67
|
},
|
|
65
68
|
"luvioBundlesize": [
|
|
66
69
|
{
|