@salesforce/lds-runtime-webruntime 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.
@@ -16,7 +16,7 @@ import { getInstrumentation } from 'o11y/client';
16
16
  import { setServices } from 'force/luvioServiceProvisioner1';
17
17
  export { default, resolve, setServices } from 'force/luvioServiceProvisioner1';
18
18
  import { executeGlobalControllerRawResponse } from 'aura';
19
- import { HttpStatusCode as HttpStatusCode$2 } from 'force/luvioEngine';
19
+ import { getSfapJwt } from 'force/clwrSfapExchange';
20
20
 
21
21
  /**
22
22
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -417,10 +417,17 @@ class AuraNetworkCommand extends NetworkCommand {
417
417
  longRunning: false,
418
418
  storable: false,
419
419
  };
420
+ this.networkPreference = 'aura';
421
+ }
422
+ get fetchParams() {
423
+ throw new Error('Fetch parameters must be specified when using HTTP transport on an Aura adapter');
420
424
  }
421
425
  coerceAuraErrors(auraErrors) {
422
426
  return toError(auraErrors[0]); // Default Implmentation stringifies the response
423
427
  }
428
+ async coerceFetchErrors(errorResponse) {
429
+ return toError(errorResponse.statusText); // Default Behavior
430
+ }
424
431
  convertAuraResponseToData(responsePromise, coerceError) {
425
432
  return responsePromise
426
433
  .then((response) => {
@@ -446,8 +453,49 @@ class AuraNetworkCommand extends NetworkCommand {
446
453
  }
447
454
  });
448
455
  }
456
+ convertFetchResponseToData(response) {
457
+ return response.then((response) => {
458
+ if (response.ok) {
459
+ return response
460
+ .json()
461
+ .then((json) => ok(json), (reason) => err(toError(reason)))
462
+ .finally(() => {
463
+ try {
464
+ this.afterRequestHooks({ statusCode: response.status });
465
+ }
466
+ catch (e) { }
467
+ });
468
+ }
469
+ else {
470
+ return this.coerceFetchErrors(response)
471
+ .then((coercedError) => {
472
+ return err(coercedError);
473
+ })
474
+ .finally(() => {
475
+ try {
476
+ this.afterRequestHooks({ statusCode: response.status });
477
+ }
478
+ catch (e) { }
479
+ });
480
+ }
481
+ }, (reason) => err(toError(reason)));
482
+ }
483
+ shouldUseAuraNetwork() {
484
+ return (this.services.auraNetwork !== undefined &&
485
+ (this.networkPreference === 'aura' || !this.services.fetch));
486
+ }
487
+ shouldUseFetch() {
488
+ return (this.services.fetch !== undefined &&
489
+ (this.networkPreference === 'http' || !this.services.auraNetwork));
490
+ }
449
491
  fetch() {
450
- return this.convertAuraResponseToData(this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig), this.coerceAuraErrors);
492
+ if (this.shouldUseAuraNetwork()) {
493
+ return this.convertAuraResponseToData(this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig), this.coerceAuraErrors);
494
+ }
495
+ else if (this.shouldUseFetch()) {
496
+ return this.convertFetchResponseToData(this.services.fetch(...this.fetchParams));
497
+ }
498
+ return resolvedPromiseLike(err(toError('Aura/Fetch network services not found')));
451
499
  }
452
500
  }
453
501
 
@@ -723,6 +771,9 @@ function mergeCacheControlConfigs(baseConfig, overrides) {
723
771
  * @typeParam ExtraServices additional named services needed by a subclass
724
772
  */
725
773
  class AuraCacheControlCommand extends CacheControlCommand {
774
+ get fetchParams() {
775
+ throw new Error('Fetch parameters must be specified when using HTTP transport on an Aura adapter');
776
+ }
726
777
  constructor(services) {
727
778
  super(services);
728
779
  this.services = services;
@@ -732,13 +783,31 @@ class AuraCacheControlCommand extends CacheControlCommand {
732
783
  longRunning: false,
733
784
  storable: false,
734
785
  };
786
+ this.networkPreference = 'aura';
787
+ }
788
+ shouldUseAuraNetwork() {
789
+ return (this.services.auraNetwork !== undefined &&
790
+ (this.networkPreference === 'aura' || !this.services.fetch));
791
+ }
792
+ shouldUseFetch() {
793
+ return (this.services.fetch !== undefined &&
794
+ (this.networkPreference === 'http' || !this.services.auraNetwork));
735
795
  }
736
796
  requestFromNetwork() {
737
- return this.convertAuraResponseToData(this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig), (errs) => this.coerceError(errs));
797
+ if (this.shouldUseAuraNetwork()) {
798
+ return this.convertAuraResponseToData(this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig), (errs) => this.coerceError(errs));
799
+ }
800
+ else if (this.shouldUseFetch()) {
801
+ return this.convertFetchResponseToData(this.services.fetch(...this.fetchParams));
802
+ }
803
+ return resolvedPromiseLike(err(toError('Aura/Fetch network services not found')));
738
804
  }
739
805
  coerceError(auraErrors) {
740
806
  return toError(auraErrors[0]); // Default Implementation stringifies the response
741
807
  }
808
+ async coerceFetchError(errorResponse) {
809
+ return toError(errorResponse.statusText); // Default Behavior
810
+ }
742
811
  convertAuraResponseToData(responsePromise, coerceError) {
743
812
  return responsePromise
744
813
  .then((response) => {
@@ -764,6 +833,33 @@ class AuraCacheControlCommand extends CacheControlCommand {
764
833
  }
765
834
  });
766
835
  }
836
+ convertFetchResponseToData(response) {
837
+ return response.then((response) => {
838
+ if (response.ok) {
839
+ return response
840
+ .json()
841
+ .then((json) => ok(json), (reason) => err(toError(reason)))
842
+ .finally(() => {
843
+ try {
844
+ this.afterRequestHooks({ statusCode: response.status });
845
+ }
846
+ catch (e) { }
847
+ });
848
+ }
849
+ else {
850
+ return this.coerceFetchError(response)
851
+ .then((coercedError) => {
852
+ return err(coercedError);
853
+ })
854
+ .finally(() => {
855
+ try {
856
+ this.afterRequestHooks({ statusCode: response.status });
857
+ }
858
+ catch (e) { }
859
+ });
860
+ }
861
+ }, (reason) => err(toError(reason)));
862
+ }
767
863
  }
768
864
 
769
865
  /**
@@ -2628,14 +2724,18 @@ class JwtManager {
2628
2724
  */
2629
2725
 
2630
2726
 
2631
- function buildServiceDescriptor(interceptors = { request: [] }) {
2727
+ function buildServiceDescriptor(interceptors = { request: [], response: [] }) {
2632
2728
  return {
2633
2729
  type: 'fetch',
2634
2730
  version: '1.0',
2635
2731
  service: function (...args) {
2636
- const { request: requestInterceptors = [] } = interceptors;
2732
+ const { request: requestInterceptors = [], response: responseInterceptors = [] } = interceptors;
2637
2733
  const pending = requestInterceptors.reduce((previousPromise, interceptor) => previousPromise.then(interceptor), resolvedPromiseLike(args));
2638
- return pending.then((args) => fetch(...args));
2734
+ return pending
2735
+ .then((args) => fetch(...args))
2736
+ .then((response) => {
2737
+ return responseInterceptors.reduce((previousPromise, interceptor) => previousPromise.then(interceptor), resolvedPromiseLike(response));
2738
+ });
2639
2739
  },
2640
2740
  };
2641
2741
  }
@@ -2724,52 +2824,20 @@ function buildJwtRequestHeaderInterceptor(jwtManager, jwtRequestModifier = (_e,
2724
2824
  };
2725
2825
  }
2726
2826
 
2727
- const SFAP_EXCHANGE_PATH = '/webruntime/sfap-info';
2728
- /**
2729
- * We expect jwt info and baseUri to be present in the response.
2730
- *
2731
- * @param response
2732
- */
2733
- function validateResponse(response) {
2734
- if (!response || !response.jwt || !response.baseUri) {
2735
- // wrapped the invocation in env conditional
2736
- // eslint-disable-next-line @salesforce/lds/no-error-in-production
2737
- throw new Error(`Expected jwt info and baseUri to be present but instead got: ${JSON.stringify(response)}`);
2738
- }
2739
- }
2740
2827
  /**
2741
2828
  * Resolves Jwt token for SFAP by calling Aura action
2742
2829
  * {@link JwtResolver} for platform SFAP
2743
2830
  */
2744
2831
  const platformSfapJwtResolver = {
2745
2832
  getJwt() {
2746
- return new Promise((resolve, reject) => {
2747
- fetch(SFAP_EXCHANGE_PATH)
2748
- .then((res) => res.json())
2749
- .then((response) => {
2750
- if (process.env.NODE_ENV !== 'production') {
2751
- validateResponse(response);
2752
- }
2833
+ return new Promise((resolve) => {
2834
+ getSfapJwt().then((response) => {
2753
2835
  resolve({
2754
2836
  jwt: response.jwt,
2755
2837
  extraInfo: {
2756
2838
  baseUri: response.baseUri,
2757
2839
  },
2758
2840
  });
2759
- })
2760
- .catch((error) => {
2761
- if (error instanceof Error) {
2762
- reject(error.message);
2763
- return;
2764
- }
2765
- // AuraFetchResponse errors
2766
- const { status } = error;
2767
- if (status !== HttpStatusCode$2.ServerError) {
2768
- // ConnectInJavaError
2769
- reject(error.body.message);
2770
- return;
2771
- }
2772
- reject(error.body.error);
2773
2841
  });
2774
2842
  });
2775
2843
  },
@@ -2902,4 +2970,4 @@ const services = [
2902
2970
  buildServiceDescriptor$2(),
2903
2971
  ];
2904
2972
  setServices(services);
2905
- // version: 1.361.0-6a70680f2b
2973
+ // version: 1.363.0-99132bb508
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-webruntime",
3
- "version": "1.361.0",
3
+ "version": "1.363.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS engine for Webruntime runtime",
6
- "main": "dist/ldsWebruntimeOneRuntimeInit.js",
7
- "module": "dist/ldsWebruntimeOneRuntimeInit.js",
6
+ "main": "dist/ldsWebruntimeOneStoreInit.js",
7
+ "module": "dist/ldsWebruntimeOneStoreInit.js",
8
8
  "types": "dist/types/main.d.ts",
9
9
  "files": [
10
10
  "dist"
@@ -12,16 +12,16 @@
12
12
  "exports": {
13
13
  ".": {
14
14
  "types": "./dist/types/main.d.ts",
15
- "import": "./dist/ldsWebruntimeOneRuntimeInit.js",
16
- "default": "./dist/ldsWebruntimeOneRuntimeInit.js"
15
+ "import": "./dist/ldsWebruntimeOneStoreInit.js",
16
+ "default": "./dist/ldsWebruntimeOneStoreInit.js"
17
17
  }
18
18
  },
19
19
  "sfdc": {
20
- "path": "forcelds/ldsWebruntimeOneRuntimeInit/",
21
- "publishedFileName": "ldsWebruntimeOneRuntimeInit.js",
20
+ "path": "forcelds/ldsWebruntimeOneStoreInit/",
21
+ "publishedFileName": "ldsWebruntimeOneStoreInit.js",
22
22
  "overrides": {
23
23
  "artifactDirectory": "dist",
24
- "outputModuleName": "ldsWebruntimeOneRuntimeInit"
24
+ "outputModuleName": "ldsWebruntimeOneStoreInit"
25
25
  }
26
26
  },
27
27
  "scripts": {
@@ -32,40 +32,40 @@
32
32
  "test:debug": "node --inspect-brk ../../node_modules/.bin/jest --runInBand",
33
33
  "test:size": "luvioBundlesize",
34
34
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-webruntime",
35
- "ready": "yarn build && yarn test:unit && yarn test:size && yarn release:corejar"
35
+ "ready": "yarn build && jest --collectCoverage && yarn test:size && yarn release:corejar"
36
36
  },
37
37
  "devDependencies": {
38
- "@luvio/service-provisioner": "5.40.3",
39
- "@luvio/tools-core": "5.40.3",
38
+ "@luvio/service-provisioner": "5.41.0",
39
+ "@luvio/tools-core": "5.41.0",
40
40
  "jwt-encode": "1.0.1"
41
41
  },
42
42
  "dependencies": {
43
- "@luvio/command-aura-network": "5.40.3",
44
- "@luvio/command-aura-normalized-cache-control": "5.40.3",
45
- "@luvio/command-aura-resource-cache-control": "5.40.3",
46
- "@luvio/command-fetch-network": "5.40.3",
47
- "@luvio/command-http-normalized-cache-control": "5.40.3",
48
- "@luvio/command-ndjson": "5.40.3",
49
- "@luvio/command-network": "5.40.3",
50
- "@luvio/command-sse": "5.40.3",
51
- "@luvio/command-streaming": "5.40.3",
52
- "@luvio/jwt-manager": "5.40.3",
43
+ "@luvio/command-aura-network": "5.41.0",
44
+ "@luvio/command-aura-normalized-cache-control": "5.41.0",
45
+ "@luvio/command-aura-resource-cache-control": "5.41.0",
46
+ "@luvio/command-fetch-network": "5.41.0",
47
+ "@luvio/command-http-normalized-cache-control": "5.41.0",
48
+ "@luvio/command-ndjson": "5.41.0",
49
+ "@luvio/command-network": "5.41.0",
50
+ "@luvio/command-sse": "5.41.0",
51
+ "@luvio/command-streaming": "5.41.0",
52
+ "@luvio/jwt-manager": "5.41.0",
53
53
  "@luvio/network-adapter-composable": "0.158.1",
54
54
  "@luvio/network-adapter-fetch": "0.158.1",
55
- "@luvio/service-aura-network": "5.40.3",
56
- "@luvio/service-cache": "5.40.3",
57
- "@luvio/service-cache-control": "5.40.3",
58
- "@luvio/service-cache-inclusion-policy": "5.40.3",
59
- "@luvio/service-fetch-network": "5.40.3",
60
- "@luvio/service-instrument-command": "5.40.3",
61
- "@luvio/service-pubsub": "5.40.3",
62
- "@luvio/service-store": "5.40.3",
63
- "@luvio/utils": "5.40.3",
64
- "@salesforce/lds-adapters-uiapi-lex": "^1.361.0"
55
+ "@luvio/service-aura-network": "5.41.0",
56
+ "@luvio/service-cache": "5.41.0",
57
+ "@luvio/service-cache-control": "5.41.0",
58
+ "@luvio/service-cache-inclusion-policy": "5.41.0",
59
+ "@luvio/service-fetch-network": "5.41.0",
60
+ "@luvio/service-instrument-command": "5.41.0",
61
+ "@luvio/service-pubsub": "5.41.0",
62
+ "@luvio/service-store": "5.41.0",
63
+ "@luvio/utils": "5.41.0",
64
+ "@salesforce/lds-adapters-uiapi-lex": "^1.363.0"
65
65
  },
66
66
  "luvioBundlesize": [
67
67
  {
68
- "path": "./dist/ldsWebruntimeOneRuntimeInit.js",
68
+ "path": "./dist/ldsWebruntimeOneStoreInit.js",
69
69
  "maxSize": {
70
70
  "none": "120 kB",
71
71
  "min": "50 kB",