@salesforce/lds-runtime-aura 1.237.0 → 1.239.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.
@@ -19,7 +19,7 @@ import { withRegistration, register, setDefaultLuvio } from 'force/ldsEngine';
19
19
  import { REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR, instrument as instrument$2 } from 'force/ldsBindings';
20
20
  import { counter, registerCacheStats, perfStart, perfEnd, registerPeriodicLogger, interaction, timer } from 'instrumentation/service';
21
21
  import { LRUCache, instrumentAdapter, instrumentLuvio, setupInstrumentation as setupInstrumentation$1, logObjectInfoChanged as logObjectInfoChanged$1, updatePercentileHistogramMetric, incrementCounterMetric, incrementGetRecordNotifyChangeAllowCount, incrementGetRecordNotifyChangeDropCount, incrementNotifyRecordUpdateAvailableAllowCount, incrementNotifyRecordUpdateAvailableDropCount, setLdsAdaptersUiapiInstrumentation, setLdsNetworkAdapterInstrumentation } from 'force/ldsInstrumentation';
22
- import networkAdapter, { instrument as instrument$1, forceRecordTransactionsDisabled, ldsNetworkAdapterInstrument, dispatchAuraAction, defaultActionConfig } from 'force/ldsNetwork';
22
+ import auraNetworkAdapter, { instrument as instrument$1, forceRecordTransactionsDisabled, ldsNetworkAdapterInstrument, dispatchAuraAction, defaultActionConfig } from 'force/ldsNetwork';
23
23
  import { instrument as instrument$3 } from 'force/adsBridge';
24
24
  import { buildJwtNetworkAdapter } from 'force/ldsNetworkFetchWithJwt';
25
25
  import { clearStorages } from 'force/ldsStorage';
@@ -598,29 +598,24 @@ function logCRUDLightningInteraction(eventSource, attributes) {
598
598
  }
599
599
  const instrumentation = new Instrumentation();
600
600
 
601
- const OBJECT_INFO_PREFIX = 'UiApi::ObjectInfoRepresentation:';
602
- /**
603
- * Watch a Luvio instance for metadata changes.
604
- */
605
- function setupMetadataWatcher(luvio) {
606
- // Watch for object info changes. Since we don't have enough information to understand to which
607
- // extent an object info change may impact the application the only thing we do is to clear all
608
- // the persistent storages.
609
- luvio.storeWatch(OBJECT_INFO_PREFIX, (entries) => {
610
- for (let i = 0, len = entries.length; i < len; i++) {
611
- const entry = entries[i];
612
- const isObjectInfoUpdated = entry.inserted === false;
613
- if (isObjectInfoUpdated) {
614
- logObjectInfoChanged();
615
- clearStorages().catch(() => {
616
- /* noop */
617
- });
618
- break;
619
- }
601
+ class NoComposedAdapterTypeError extends TypeError {
602
+ constructor(message, resourceRequest) {
603
+ super(message);
604
+ this.resourceRequest = resourceRequest;
605
+ }
606
+ }
607
+
608
+ function buildComposableNetworkAdapter(composedAdapters) {
609
+ return (resourceRequest, resourceRequestContext) => {
610
+ const composedAdapter = composedAdapters.find((adapter) => adapter.shouldHandleRequest(resourceRequest));
611
+ if (composedAdapter === undefined) {
612
+ throw new NoComposedAdapterTypeError('There are no network adapters that can process the request.', resourceRequest);
620
613
  }
621
- });
614
+ return composedAdapter.adapter(resourceRequest, resourceRequestContext);
615
+ };
622
616
  }
623
617
 
618
+ const SALESFORCE_API_BASE_URI_FLAG = 'api.salesforce.com';
624
619
  const SFAPController = 'SalesforceApiPlatformController';
625
620
  const SFAPJwtMethod = 'getSFAPLightningJwtService';
626
621
  /**
@@ -687,6 +682,47 @@ const modifySfapResourceRequest = function (resourceRequest, jwtToken) {
687
682
  baseUri,
688
683
  };
689
684
  };
685
+ const sfapNetworkAdapter = buildJwtNetworkAdapter(platformSfapJwtResolver, modifySfapResourceRequest);
686
+ const composedNetworkAdapter$1 = {
687
+ shouldHandleRequest(resourceRequest) {
688
+ return resourceRequest.baseUri === SALESFORCE_API_BASE_URI_FLAG;
689
+ },
690
+ adapter: sfapNetworkAdapter,
691
+ };
692
+
693
+ const composedNetworkAdapter = buildComposableNetworkAdapter([
694
+ composedNetworkAdapter$1,
695
+ // The aura network adapter must be the default.
696
+ {
697
+ shouldHandleRequest() {
698
+ return true;
699
+ },
700
+ adapter: auraNetworkAdapter,
701
+ },
702
+ ]);
703
+
704
+ const OBJECT_INFO_PREFIX = 'UiApi::ObjectInfoRepresentation:';
705
+ /**
706
+ * Watch a Luvio instance for metadata changes.
707
+ */
708
+ function setupMetadataWatcher(luvio) {
709
+ // Watch for object info changes. Since we don't have enough information to understand to which
710
+ // extent an object info change may impact the application the only thing we do is to clear all
711
+ // the persistent storages.
712
+ luvio.storeWatch(OBJECT_INFO_PREFIX, (entries) => {
713
+ for (let i = 0, len = entries.length; i < len; i++) {
714
+ const entry = entries[i];
715
+ const isObjectInfoUpdated = entry.inserted === false;
716
+ if (isObjectInfoUpdated) {
717
+ logObjectInfoChanged();
718
+ clearStorages().catch(() => {
719
+ /* noop */
720
+ });
721
+ break;
722
+ }
723
+ }
724
+ });
725
+ }
690
726
 
691
727
  // This code *should* be in lds-network-adapter, but when combined with the Aura
692
728
  // component test workaround in lds-default-luvio it creates a circular dependecy
@@ -714,15 +750,13 @@ function setupQueryEvaluators(luvio, store) {
714
750
  luvio.registerStoreQueryEvaluator(baseQueryEvaluator);
715
751
  luvio.registerTypeQueryEvaluator(UiApiNamespace, RecordRepresentationRepresentationType, recordRepresentationQueryEvaluator);
716
752
  }
717
- // Should be used by the Integration WI
718
- buildJwtNetworkAdapter(platformSfapJwtResolver, modifySfapResourceRequest);
719
753
  // LDS initialization logic, invoked directly by Aura component tests
720
754
  function initializeLDS() {
721
755
  const storeOptions = {
722
756
  scheduler: () => { },
723
757
  };
724
758
  const store = new InMemoryStore(storeOptions);
725
- const environment = new Environment(store, networkAdapter);
759
+ const environment = new Environment(store, composedNetworkAdapter);
726
760
  const luvio = new Luvio(environment, {
727
761
  instrument: instrumentation.instrumentLuvio.bind(instrumentation),
728
762
  });
@@ -739,4 +773,4 @@ function ldsEngineCreator() {
739
773
  }
740
774
 
741
775
  export { ldsEngineCreator as default, initializeLDS };
742
- // version: 1.237.0-5cc894ce9
776
+ // version: 1.239.0-6c531185a
@@ -0,0 +1,2 @@
1
+ declare const composedNetworkAdapter: import("@luvio/engine").NetworkAdapter;
2
+ export default composedNetworkAdapter;
@@ -1,3 +1,4 @@
1
+ import { type ResourceRequest } from '@luvio/engine';
1
2
  import type { JwtResolver } from '@luvio/jwt-manager';
2
3
  import type { ModifyResourceRequestHook } from '@salesforce/lds-network-fetch-with-jwt';
3
4
  export declare const SFAPController = "SalesforceApiPlatformController";
@@ -19,4 +20,8 @@ export declare const platformSfapJwtResolver: JwtResolver<ExtraInfo>;
19
20
  * @returns resourceRequest with updated baseUri
20
21
  */
21
22
  export declare const modifySfapResourceRequest: ModifyResourceRequestHook<unknown, ExtraInfo>;
22
- export {};
23
+ declare const composedNetworkAdapter: {
24
+ shouldHandleRequest(resourceRequest: ResourceRequest): boolean;
25
+ adapter: import("@luvio/engine").NetworkAdapter;
26
+ };
27
+ export default composedNetworkAdapter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-aura",
3
- "version": "1.237.0",
3
+ "version": "1.239.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS engine for Aura runtime",
6
6
  "main": "dist/ldsEngineCreator.js",
@@ -42,6 +42,9 @@
42
42
  "@salesforce/lds-network-aura": "*",
43
43
  "@salesforce/lds-network-fetch-with-jwt": "*"
44
44
  },
45
+ "dependencies": {
46
+ "@luvio/network-adapter-composable": "0.148.1"
47
+ },
45
48
  "luvioBundlesize": [
46
49
  {
47
50
  "path": "./dist/ldsEngineCreator.js",