@salesforce/lds-runtime-aura 1.321.0 → 1.322.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.
@@ -73,7 +73,7 @@ class NetworkCommand extends BaseCommand {
73
73
  return this.fetch();
74
74
  }
75
75
  }
76
- function buildServiceDescriptor$9() {
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$8() {
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,7 +1209,7 @@ class CacheController {
1040
1209
 
1041
1210
  function buildServiceDescriptor$1(cache) {
1042
1211
  return {
1043
- type: 'cacheControl',
1212
+ type: 'cacheController',
1044
1213
  version: '1.0',
1045
1214
  service: new CacheController({ cache }),
1046
1215
  };
@@ -1550,9 +1719,9 @@ const composedNetworkAdapter$1 = {
1550
1719
  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
1720
 
1552
1721
  const SFAP_BASE_URL = 'api.salesforce.com';
1722
+ const sfapJwtRepository = new JwtRepository();
1723
+ const sfapJwtManager = new JwtManager(sfapJwtRepository, platformSfapJwtResolver);
1553
1724
  function buildJwtAuthorizedSfapFetchServiceDescriptor(logger) {
1554
- const jwtRepository = new JwtRepository();
1555
- const jwtManager = new JwtManager(jwtRepository, platformSfapJwtResolver);
1556
1725
  const jwtRequestModifier = ({ baseUri }, [resource, request]) => {
1557
1726
  if (typeof resource !== 'string' && !(resource instanceof URL)) {
1558
1727
  // istanbul ignore else: this will not be tested in NODE_ENV = production for test coverage
@@ -1571,7 +1740,7 @@ function buildJwtAuthorizedSfapFetchServiceDescriptor(logger) {
1571
1740
  url.protocol = overrideUrl.protocol;
1572
1741
  return [url, request];
1573
1742
  };
1574
- const jwtRequestHeaderInterceptor = buildJwtRequestHeaderInterceptor(jwtManager, jwtRequestModifier);
1743
+ const jwtRequestHeaderInterceptor = buildJwtRequestHeaderInterceptor(sfapJwtManager, jwtRequestModifier);
1575
1744
  const jwtAuthorizedFetchService = buildServiceDescriptor({
1576
1745
  request: [jwtRequestHeaderInterceptor],
1577
1746
  });
@@ -1580,6 +1749,56 @@ function buildJwtAuthorizedSfapFetchServiceDescriptor(logger) {
1580
1749
  tags: { authenticationScopes: 'sfap_api' },
1581
1750
  };
1582
1751
  }
1752
+ /**
1753
+ * Returns a service descriptor for a fetch service that includes one-off copilot
1754
+ * hacks. This fetch service is not intended for use by anything other than
1755
+ * copilot commands.
1756
+ */
1757
+ function buildCopilotFetchServiceDescriptor(logger) {
1758
+ return {
1759
+ // Note that this layers the Interceptor below directly on top of fetch(). WHen
1760
+ // we switch to JWT authentication this will need to change to incorporate the
1761
+ // Interceptor here with the logic in buildJwtAuthorizedSfapFetchServiceDescriptor()
1762
+ // above.
1763
+ ...buildServiceDescriptor({
1764
+ request: [
1765
+ // Note that this function is VERY closely tied to the fetchParams generated
1766
+ // by copilotStartSessionCommand. Any changes to those parameters will require
1767
+ // corresponding updates to the logic below.
1768
+ (args) => {
1769
+ const [url, requestInit] = args;
1770
+ // ignore anything other than a start session request
1771
+ if (typeof url !== 'string' ||
1772
+ !url.endsWith('/sessions') ||
1773
+ !requestInit ||
1774
+ requestInit.method !== 'POST' ||
1775
+ !requestInit.body ||
1776
+ typeof requestInit.body !== 'string') {
1777
+ return resolvedPromiseLike(args);
1778
+ }
1779
+ return resolvedPromiseLike(sfapJwtManager.getJwt()).then((token) => {
1780
+ // replace the body's instanceConfig.endpoint with the JWT's iss value
1781
+ const body = JSON.parse(requestInit.body);
1782
+ if (!body || !body.instanceConfig || !token.decodedInfo.iss) {
1783
+ logger.warn('skipping injection of endpoint into start session request');
1784
+ }
1785
+ else {
1786
+ body.instanceConfig.endpoint = token.decodedInfo.iss;
1787
+ }
1788
+ return [
1789
+ args[0],
1790
+ {
1791
+ ...args[1],
1792
+ body: JSON.stringify(body),
1793
+ },
1794
+ ];
1795
+ });
1796
+ },
1797
+ ],
1798
+ }),
1799
+ tags: { specialHacksFor: 'copilot' },
1800
+ };
1801
+ }
1583
1802
  function buildUnauthorizedFetchServiceDescriptor() {
1584
1803
  const fetchService = buildServiceDescriptor();
1585
1804
  return {
@@ -2943,6 +3162,7 @@ const RECORD_HOME_SUPPORTED_ADAPTERS = new Set([
2943
3162
  GET_RELATED_LIST_RECORDS_BATCH_ADAPTER_NAME,
2944
3163
  GET_RELATED_LIST_RECORDS_ADAPTER_NAME,
2945
3164
  GET_RELATED_LISTS_ACTIONS_ADAPTER_NAME,
3165
+ 'templateApi', // external - getTemplateDescriptorWithExpansionBundle
2946
3166
  ]);
2947
3167
  class RecordHomePage extends LexDefaultPage {
2948
3168
  constructor(context, requestStrategyManager, options) {
@@ -4076,7 +4296,7 @@ function getEnvironmentSetting(name) {
4076
4296
  }
4077
4297
  return undefined;
4078
4298
  }
4079
- // version: 1.321.0-40847d67a8
4299
+ // version: 1.322.0-87f682c9f3
4080
4300
 
4081
4301
  const forceRecordTransactionsDisabled = getEnvironmentSetting(EnvironmentSettings.ForceRecordTransactionsDisabled);
4082
4302
  //TODO: Some duplication here that can be most likely moved to a util class
@@ -4739,14 +4959,16 @@ function initializeOneStore() {
4739
4959
  instrumentationServiceDescriptor,
4740
4960
  buildUnauthorizedFetchServiceDescriptor(),
4741
4961
  buildJwtAuthorizedSfapFetchServiceDescriptor(loggerService),
4962
+ buildCopilotFetchServiceDescriptor(loggerService),
4742
4963
  buildAuraNetworkService(),
4743
4964
  buildServiceDescriptor$4(instrumentationServiceDescriptor.service),
4744
4965
  buildServiceDescriptor$1(cacheServiceDescriptor.service),
4745
- buildServiceDescriptor$8(),
4746
- buildServiceDescriptor$7(),
4747
4966
  buildServiceDescriptor$9(),
4967
+ buildServiceDescriptor$7(),
4968
+ buildServiceDescriptor$a(),
4748
4969
  buildServiceDescriptor$6(),
4749
4970
  buildServiceDescriptor$5(),
4971
+ buildServiceDescriptor$8(),
4750
4972
  ];
4751
4973
  serviceBroker.publish(services);
4752
4974
  }
@@ -4775,4 +4997,4 @@ function ldsEngineCreator() {
4775
4997
  }
4776
4998
 
4777
4999
  export { LexRequestStrategy, buildPredictorForContext, ldsEngineCreator as default, initializeLDS, initializeOneStore, registerRequestStrategy, saveRequestAsPrediction, unregisterRequestStrategy, whenPredictionsReady };
4778
- // version: 1.321.0-1fd3fba1c4
5000
+ // version: 1.322.0-6aa042602a
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-aura",
3
- "version": "1.321.0",
3
+ "version": "1.322.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,34 @@
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.12.0",
38
- "@salesforce/lds-adapters-apex": "^1.321.0",
39
- "@salesforce/lds-adapters-uiapi": "^1.321.0",
37
+ "@luvio/service-broker": "5.13.0",
38
+ "@salesforce/lds-adapters-apex": "^1.322.0",
39
+ "@salesforce/lds-adapters-uiapi": "^1.322.0",
40
40
  "@salesforce/lds-adapters-uiapi-lex": "^1.302.0",
41
- "@salesforce/lds-ads-bridge": "^1.321.0",
42
- "@salesforce/lds-aura-storage": "^1.321.0",
43
- "@salesforce/lds-bindings": "^1.321.0",
44
- "@salesforce/lds-instrumentation": "^1.321.0",
45
- "@salesforce/lds-network-aura": "^1.321.0",
46
- "@salesforce/lds-network-fetch-with-jwt": "^1.321.0"
41
+ "@salesforce/lds-ads-bridge": "^1.322.0",
42
+ "@salesforce/lds-aura-storage": "^1.322.0",
43
+ "@salesforce/lds-bindings": "^1.322.0",
44
+ "@salesforce/lds-instrumentation": "^1.322.0",
45
+ "@salesforce/lds-network-aura": "^1.322.0",
46
+ "@salesforce/lds-network-fetch-with-jwt": "^1.322.0"
47
47
  },
48
48
  "dependencies": {
49
- "@luvio/command-aura-network": "5.12.0",
50
- "@luvio/command-fetch-network": "5.12.0",
51
- "@luvio/command-network": "5.12.0",
52
- "@luvio/command-sse": "5.12.0",
53
- "@luvio/command-streaming": "5.12.0",
49
+ "@luvio/command-aura-network": "5.13.0",
50
+ "@luvio/command-aura-resource-cache-control": "5.13.0",
51
+ "@luvio/command-fetch-network": "5.13.0",
52
+ "@luvio/command-network": "5.13.0",
53
+ "@luvio/command-sse": "5.13.0",
54
+ "@luvio/command-streaming": "5.13.0",
54
55
  "@luvio/network-adapter-composable": "0.156.5",
55
56
  "@luvio/network-adapter-fetch": "0.156.5",
56
- "@luvio/service-aura-network": "5.12.0",
57
- "@luvio/service-cache": "5.12.0",
58
- "@luvio/service-cache-control": "5.12.0",
59
- "@luvio/service-fetch-network": "5.12.0",
60
- "@luvio/service-instrument-command": "5.12.0",
61
- "@luvio/service-store": "5.12.0",
62
- "@luvio/utils": "5.12.0",
63
- "@salesforce/lds-adapters-uiapi-lex": "^1.321.0"
57
+ "@luvio/service-aura-network": "5.13.0",
58
+ "@luvio/service-cache": "5.13.0",
59
+ "@luvio/service-cache-control": "5.13.0",
60
+ "@luvio/service-fetch-network": "5.13.0",
61
+ "@luvio/service-instrument-command": "5.13.0",
62
+ "@luvio/service-store": "5.13.0",
63
+ "@luvio/utils": "5.13.0",
64
+ "@salesforce/lds-adapters-uiapi-lex": "^1.322.0"
64
65
  },
65
66
  "luvioBundlesize": [
66
67
  {