@salesforce/lds-runtime-aura 1.361.0 → 1.363.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.
@@ -439,10 +439,17 @@ class AuraNetworkCommand extends NetworkCommand {
439
439
  longRunning: false,
440
440
  storable: false,
441
441
  };
442
+ this.networkPreference = 'aura';
443
+ }
444
+ get fetchParams() {
445
+ throw new Error('Fetch parameters must be specified when using HTTP transport on an Aura adapter');
442
446
  }
443
447
  coerceAuraErrors(auraErrors) {
444
448
  return toError(auraErrors[0]); // Default Implmentation stringifies the response
445
449
  }
450
+ async coerceFetchErrors(errorResponse) {
451
+ return toError(errorResponse.statusText); // Default Behavior
452
+ }
446
453
  convertAuraResponseToData(responsePromise, coerceError) {
447
454
  return responsePromise
448
455
  .then((response) => {
@@ -468,8 +475,49 @@ class AuraNetworkCommand extends NetworkCommand {
468
475
  }
469
476
  });
470
477
  }
478
+ convertFetchResponseToData(response) {
479
+ return response.then((response) => {
480
+ if (response.ok) {
481
+ return response
482
+ .json()
483
+ .then((json) => ok(json), (reason) => err(toError(reason)))
484
+ .finally(() => {
485
+ try {
486
+ this.afterRequestHooks({ statusCode: response.status });
487
+ }
488
+ catch (e) { }
489
+ });
490
+ }
491
+ else {
492
+ return this.coerceFetchErrors(response)
493
+ .then((coercedError) => {
494
+ return err(coercedError);
495
+ })
496
+ .finally(() => {
497
+ try {
498
+ this.afterRequestHooks({ statusCode: response.status });
499
+ }
500
+ catch (e) { }
501
+ });
502
+ }
503
+ }, (reason) => err(toError(reason)));
504
+ }
505
+ shouldUseAuraNetwork() {
506
+ return (this.services.auraNetwork !== undefined &&
507
+ (this.networkPreference === 'aura' || !this.services.fetch));
508
+ }
509
+ shouldUseFetch() {
510
+ return (this.services.fetch !== undefined &&
511
+ (this.networkPreference === 'http' || !this.services.auraNetwork));
512
+ }
471
513
  fetch() {
472
- return this.convertAuraResponseToData(this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig), this.coerceAuraErrors);
514
+ if (this.shouldUseAuraNetwork()) {
515
+ return this.convertAuraResponseToData(this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig), this.coerceAuraErrors);
516
+ }
517
+ else if (this.shouldUseFetch()) {
518
+ return this.convertFetchResponseToData(this.services.fetch(...this.fetchParams));
519
+ }
520
+ return resolvedPromiseLike(err(toError('Aura/Fetch network services not found')));
473
521
  }
474
522
  }
475
523
 
@@ -745,6 +793,9 @@ function mergeCacheControlConfigs(baseConfig, overrides) {
745
793
  * @typeParam ExtraServices additional named services needed by a subclass
746
794
  */
747
795
  class AuraCacheControlCommand extends CacheControlCommand {
796
+ get fetchParams() {
797
+ throw new Error('Fetch parameters must be specified when using HTTP transport on an Aura adapter');
798
+ }
748
799
  constructor(services) {
749
800
  super(services);
750
801
  this.services = services;
@@ -754,13 +805,31 @@ class AuraCacheControlCommand extends CacheControlCommand {
754
805
  longRunning: false,
755
806
  storable: false,
756
807
  };
808
+ this.networkPreference = 'aura';
809
+ }
810
+ shouldUseAuraNetwork() {
811
+ return (this.services.auraNetwork !== undefined &&
812
+ (this.networkPreference === 'aura' || !this.services.fetch));
813
+ }
814
+ shouldUseFetch() {
815
+ return (this.services.fetch !== undefined &&
816
+ (this.networkPreference === 'http' || !this.services.auraNetwork));
757
817
  }
758
818
  requestFromNetwork() {
759
- return this.convertAuraResponseToData(this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig), (errs) => this.coerceError(errs));
819
+ if (this.shouldUseAuraNetwork()) {
820
+ return this.convertAuraResponseToData(this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig), (errs) => this.coerceError(errs));
821
+ }
822
+ else if (this.shouldUseFetch()) {
823
+ return this.convertFetchResponseToData(this.services.fetch(...this.fetchParams));
824
+ }
825
+ return resolvedPromiseLike(err(toError('Aura/Fetch network services not found')));
760
826
  }
761
827
  coerceError(auraErrors) {
762
828
  return toError(auraErrors[0]); // Default Implementation stringifies the response
763
829
  }
830
+ async coerceFetchError(errorResponse) {
831
+ return toError(errorResponse.statusText); // Default Behavior
832
+ }
764
833
  convertAuraResponseToData(responsePromise, coerceError) {
765
834
  return responsePromise
766
835
  .then((response) => {
@@ -786,6 +855,33 @@ class AuraCacheControlCommand extends CacheControlCommand {
786
855
  }
787
856
  });
788
857
  }
858
+ convertFetchResponseToData(response) {
859
+ return response.then((response) => {
860
+ if (response.ok) {
861
+ return response
862
+ .json()
863
+ .then((json) => ok(json), (reason) => err(toError(reason)))
864
+ .finally(() => {
865
+ try {
866
+ this.afterRequestHooks({ statusCode: response.status });
867
+ }
868
+ catch (e) { }
869
+ });
870
+ }
871
+ else {
872
+ return this.coerceFetchError(response)
873
+ .then((coercedError) => {
874
+ return err(coercedError);
875
+ })
876
+ .finally(() => {
877
+ try {
878
+ this.afterRequestHooks({ statusCode: response.status });
879
+ }
880
+ catch (e) { }
881
+ });
882
+ }
883
+ }, (reason) => err(toError(reason)));
884
+ }
789
885
  }
790
886
 
791
887
  /**
@@ -2466,14 +2562,18 @@ class JwtManager {
2466
2562
  */
2467
2563
 
2468
2564
 
2469
- function buildServiceDescriptor(interceptors = { request: [] }) {
2565
+ function buildServiceDescriptor(interceptors = { request: [], response: [] }) {
2470
2566
  return {
2471
2567
  type: 'fetch',
2472
2568
  version: '1.0',
2473
2569
  service: function (...args) {
2474
- const { request: requestInterceptors = [] } = interceptors;
2570
+ const { request: requestInterceptors = [], response: responseInterceptors = [] } = interceptors;
2475
2571
  const pending = requestInterceptors.reduce((previousPromise, interceptor) => previousPromise.then(interceptor), resolvedPromiseLike(args));
2476
- return pending.then((args) => fetch(...args));
2572
+ return pending
2573
+ .then((args) => fetch(...args))
2574
+ .then((response) => {
2575
+ return responseInterceptors.reduce((previousPromise, interceptor) => previousPromise.then(interceptor), resolvedPromiseLike(response));
2576
+ });
2477
2577
  },
2478
2578
  };
2479
2579
  }
@@ -5657,7 +5757,7 @@ function getEnvironmentSetting(name) {
5657
5757
  }
5658
5758
  return undefined;
5659
5759
  }
5660
- // version: 1.361.0-eb406138cb
5760
+ // version: 1.363.0-112332910d
5661
5761
 
5662
5762
  const forceRecordTransactionsDisabled = getEnvironmentSetting(EnvironmentSettings.ForceRecordTransactionsDisabled);
5663
5763
  //TODO: Some duplication here that can be most likely moved to a util class
@@ -6535,4 +6635,4 @@ function ldsEngineCreator() {
6535
6635
  }
6536
6636
 
6537
6637
  export { LexRequestStrategy, PdlRequestPriority, buildPredictorForContext, ldsEngineCreator as default, initializeLDS, initializeOneStore, registerRequestStrategy, saveRequestAsPrediction, unregisterRequestStrategy, whenPredictionsReady };
6538
- // version: 1.361.0-6a70680f2b
6638
+ // version: 1.363.0-99132bb508
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-aura",
3
- "version": "1.361.0",
3
+ "version": "1.363.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS engine for Aura runtime",
6
6
  "main": "dist/ldsEngineCreator.js",
@@ -34,48 +34,48 @@
34
34
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-aura"
35
35
  },
36
36
  "devDependencies": {
37
- "@luvio/service-provisioner": "5.40.3",
38
- "@luvio/tools-core": "5.40.3",
39
- "@salesforce/lds-adapters-apex": "^1.361.0",
40
- "@salesforce/lds-adapters-uiapi": "^1.361.0",
37
+ "@luvio/service-provisioner": "5.41.0",
38
+ "@luvio/tools-core": "5.41.0",
39
+ "@salesforce/lds-adapters-apex": "^1.363.0",
40
+ "@salesforce/lds-adapters-uiapi": "^1.363.0",
41
41
  "@salesforce/lds-adapters-uiapi-lex": "^1.302.0",
42
- "@salesforce/lds-ads-bridge": "^1.361.0",
43
- "@salesforce/lds-aura-storage": "^1.361.0",
44
- "@salesforce/lds-bindings": "^1.361.0",
45
- "@salesforce/lds-instrumentation": "^1.361.0",
46
- "@salesforce/lds-network-aura": "^1.361.0",
47
- "@salesforce/lds-network-fetch": "^1.361.0",
42
+ "@salesforce/lds-ads-bridge": "^1.363.0",
43
+ "@salesforce/lds-aura-storage": "^1.363.0",
44
+ "@salesforce/lds-bindings": "^1.363.0",
45
+ "@salesforce/lds-instrumentation": "^1.363.0",
46
+ "@salesforce/lds-network-aura": "^1.363.0",
47
+ "@salesforce/lds-network-fetch": "^1.363.0",
48
48
  "jwt-encode": "1.0.1"
49
49
  },
50
50
  "dependencies": {
51
- "@luvio/command-aura-network": "5.40.3",
52
- "@luvio/command-aura-normalized-cache-control": "5.40.3",
53
- "@luvio/command-aura-resource-cache-control": "5.40.3",
54
- "@luvio/command-fetch-network": "5.40.3",
55
- "@luvio/command-http-normalized-cache-control": "5.40.3",
56
- "@luvio/command-ndjson": "5.40.3",
57
- "@luvio/command-network": "5.40.3",
58
- "@luvio/command-sse": "5.40.3",
59
- "@luvio/command-streaming": "5.40.3",
51
+ "@luvio/command-aura-network": "5.41.0",
52
+ "@luvio/command-aura-normalized-cache-control": "5.41.0",
53
+ "@luvio/command-aura-resource-cache-control": "5.41.0",
54
+ "@luvio/command-fetch-network": "5.41.0",
55
+ "@luvio/command-http-normalized-cache-control": "5.41.0",
56
+ "@luvio/command-ndjson": "5.41.0",
57
+ "@luvio/command-network": "5.41.0",
58
+ "@luvio/command-sse": "5.41.0",
59
+ "@luvio/command-streaming": "5.41.0",
60
60
  "@luvio/network-adapter-composable": "0.158.1",
61
61
  "@luvio/network-adapter-fetch": "0.158.1",
62
- "@luvio/service-aura-network": "5.40.3",
63
- "@luvio/service-cache": "5.40.3",
64
- "@luvio/service-cache-control": "5.40.3",
65
- "@luvio/service-cache-inclusion-policy": "5.40.3",
66
- "@luvio/service-fetch-network": "5.40.3",
67
- "@luvio/service-instrument-command": "5.40.3",
68
- "@luvio/service-pubsub": "5.40.3",
69
- "@luvio/service-store": "5.40.3",
70
- "@luvio/utils": "5.40.3",
71
- "@salesforce/lds-adapters-uiapi-lex": "^1.361.0"
62
+ "@luvio/service-aura-network": "5.41.0",
63
+ "@luvio/service-cache": "5.41.0",
64
+ "@luvio/service-cache-control": "5.41.0",
65
+ "@luvio/service-cache-inclusion-policy": "5.41.0",
66
+ "@luvio/service-fetch-network": "5.41.0",
67
+ "@luvio/service-instrument-command": "5.41.0",
68
+ "@luvio/service-pubsub": "5.41.0",
69
+ "@luvio/service-store": "5.41.0",
70
+ "@luvio/utils": "5.41.0",
71
+ "@salesforce/lds-adapters-uiapi-lex": "^1.363.0"
72
72
  },
73
73
  "luvioBundlesize": [
74
74
  {
75
75
  "path": "./dist/ldsEngineCreator.js",
76
76
  "maxSize": {
77
- "none": "245 kB",
78
- "min": "100 kB",
77
+ "none": "250 kB",
78
+ "min": "102 kB",
79
79
  "compressed": "45 kB"
80
80
  }
81
81
  }