@salesforce/lds-runtime-aura 1.229.0-dev2 → 1.229.0-dev4
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
CHANGED
|
@@ -12,15 +12,16 @@
|
|
|
12
12
|
* *******************************************************************************************
|
|
13
13
|
*/
|
|
14
14
|
/* proxy-compat-disable */
|
|
15
|
-
import { InMemoryStore, Environment, Luvio, InMemoryStoreQueryEvaluator } from 'force/luvioEngine';
|
|
15
|
+
import { HttpStatusCode, InMemoryStore, Environment, Luvio, InMemoryStoreQueryEvaluator } from 'force/luvioEngine';
|
|
16
16
|
import ldsTrackedFieldsBehaviorGate from '@salesforce/gate/lds.useNewTrackedFieldBehavior';
|
|
17
17
|
import { instrument, configuration, InMemoryRecordRepresentationQueryEvaluator, UiApiNamespace, RecordRepresentationRepresentationType } from 'force/ldsAdaptersUiapi';
|
|
18
18
|
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
|
|
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
|
+
import { buildJwtNetworkAdapter } from 'force/ldsNetworkFetchWithJwt';
|
|
24
25
|
import { clearStorages } from 'force/ldsStorage';
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -597,6 +598,109 @@ function logCRUDLightningInteraction(eventSource, attributes) {
|
|
|
597
598
|
}
|
|
598
599
|
const instrumentation = new Instrumentation();
|
|
599
600
|
|
|
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);
|
|
613
|
+
}
|
|
614
|
+
return composedAdapter.adapter(resourceRequest, resourceRequestContext);
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
const SALESFORCE_API_BASE_URI_FLAG = 'api.salesforce.com';
|
|
619
|
+
const SFAPController = 'SalesforceApiPlatformController';
|
|
620
|
+
const SFAPJwtMethod = 'getSFAPLightningJwtService';
|
|
621
|
+
/**
|
|
622
|
+
* We expect jwt info and baseUri to be present in the response.
|
|
623
|
+
*
|
|
624
|
+
* @param body
|
|
625
|
+
*/
|
|
626
|
+
function validateResponse(body) {
|
|
627
|
+
if (!body || !body.jwt || !body.baseUri) {
|
|
628
|
+
// wrapped the invocation in env conditional
|
|
629
|
+
// eslint-disable-next-line @salesforce/lds/no-error-in-production
|
|
630
|
+
throw new Error(`Expected jwt info and baseUri to be present but instead got: ${JSON.stringify(body)}`);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Resolves Jwt token for SFAP by calling Aura action
|
|
635
|
+
* {@link JwtResolver} for platform SFAP
|
|
636
|
+
*/
|
|
637
|
+
const platformSfapJwtResolver = {
|
|
638
|
+
getJwt() {
|
|
639
|
+
return new Promise((resolve, reject) => {
|
|
640
|
+
dispatchAuraAction(`${SFAPController}.${SFAPJwtMethod}`, {}, defaultActionConfig)
|
|
641
|
+
.then((response) => {
|
|
642
|
+
const body = response.body;
|
|
643
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
644
|
+
validateResponse(body);
|
|
645
|
+
}
|
|
646
|
+
resolve({
|
|
647
|
+
jwt: body.jwt,
|
|
648
|
+
extraInfo: {
|
|
649
|
+
baseUri: body.baseUri,
|
|
650
|
+
},
|
|
651
|
+
});
|
|
652
|
+
})
|
|
653
|
+
.catch((error) => {
|
|
654
|
+
if (error instanceof Error) {
|
|
655
|
+
reject(error.message);
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
// AuraFetchResponse errors
|
|
659
|
+
const { status } = error;
|
|
660
|
+
if (status !== HttpStatusCode.ServerError) {
|
|
661
|
+
// ConnectInJavaError
|
|
662
|
+
reject(error.body.message);
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
reject(error.body.error);
|
|
666
|
+
});
|
|
667
|
+
});
|
|
668
|
+
},
|
|
669
|
+
};
|
|
670
|
+
/**
|
|
671
|
+
* This hook is used to modify the resource request before it is sent to the server.
|
|
672
|
+
* SFAP uses extraInfo assocaiated JwtToken to update the baseUri for the resource request.
|
|
673
|
+
*
|
|
674
|
+
* @param resourceRequest
|
|
675
|
+
* @param jwtToken
|
|
676
|
+
* @returns resourceRequest with updated baseUri
|
|
677
|
+
*/
|
|
678
|
+
const modifySfapResourceRequest = function (resourceRequest, jwtToken) {
|
|
679
|
+
const { baseUri } = jwtToken.extraInfo;
|
|
680
|
+
return {
|
|
681
|
+
...resourceRequest,
|
|
682
|
+
baseUri,
|
|
683
|
+
};
|
|
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
|
+
|
|
600
704
|
const OBJECT_INFO_PREFIX = 'UiApi::ObjectInfoRepresentation:';
|
|
601
705
|
/**
|
|
602
706
|
* Watch a Luvio instance for metadata changes.
|
|
@@ -652,7 +756,7 @@ function initializeLDS() {
|
|
|
652
756
|
scheduler: () => { },
|
|
653
757
|
};
|
|
654
758
|
const store = new InMemoryStore(storeOptions);
|
|
655
|
-
const environment = new Environment(store,
|
|
759
|
+
const environment = new Environment(store, composedNetworkAdapter);
|
|
656
760
|
const luvio = new Luvio(environment, {
|
|
657
761
|
instrument: instrumentation.instrumentLuvio.bind(instrumentation),
|
|
658
762
|
});
|
|
@@ -669,4 +773,4 @@ function ldsEngineCreator() {
|
|
|
669
773
|
}
|
|
670
774
|
|
|
671
775
|
export { ldsEngineCreator as default, initializeLDS };
|
|
672
|
-
// version: 1.229.0-
|
|
776
|
+
// version: 1.229.0-dev4-07d38781a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildJwtNetworkAdapter(): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ResourceRequest } from '@luvio/engine';
|
|
2
|
+
import type { JwtResolver } from '@luvio/jwt-manager';
|
|
3
|
+
import type { ModifyResourceRequestHook } from '@salesforce/lds-network-fetch-with-jwt';
|
|
4
|
+
export declare const SFAPController = "SalesforceApiPlatformController";
|
|
5
|
+
export declare const SFAPJwtMethod = "getSFAPLightningJwtService";
|
|
6
|
+
type ExtraInfo = {
|
|
7
|
+
baseUri: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Resolves Jwt token for SFAP by calling Aura action
|
|
11
|
+
* {@link JwtResolver} for platform SFAP
|
|
12
|
+
*/
|
|
13
|
+
export declare const platformSfapJwtResolver: JwtResolver<ExtraInfo>;
|
|
14
|
+
/**
|
|
15
|
+
* This hook is used to modify the resource request before it is sent to the server.
|
|
16
|
+
* SFAP uses extraInfo assocaiated JwtToken to update the baseUri for the resource request.
|
|
17
|
+
*
|
|
18
|
+
* @param resourceRequest
|
|
19
|
+
* @param jwtToken
|
|
20
|
+
* @returns resourceRequest with updated baseUri
|
|
21
|
+
*/
|
|
22
|
+
export declare const modifySfapResourceRequest: ModifyResourceRequestHook<unknown, ExtraInfo>;
|
|
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.229.0-
|
|
3
|
+
"version": "1.229.0-dev4",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "LDS engine for Aura runtime",
|
|
6
6
|
"main": "dist/ldsEngineCreator.js",
|
|
@@ -34,21 +34,23 @@
|
|
|
34
34
|
"release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-aura"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@salesforce/lds-
|
|
39
|
-
"@salesforce/lds-
|
|
40
|
-
"@salesforce/lds-
|
|
41
|
-
"@salesforce/lds-
|
|
42
|
-
"@salesforce/lds-
|
|
43
|
-
"@salesforce/lds-
|
|
37
|
+
"@luvio/network-adapter-composable": "0.146.0-dev3",
|
|
38
|
+
"@salesforce/lds-adapters-uiapi": "1.229.0-dev4",
|
|
39
|
+
"@salesforce/lds-ads-bridge": "1.229.0-dev4",
|
|
40
|
+
"@salesforce/lds-aura-storage": "1.229.0-dev4",
|
|
41
|
+
"@salesforce/lds-bindings": "1.229.0-dev4",
|
|
42
|
+
"@salesforce/lds-instrumentation": "1.229.0-dev4",
|
|
43
|
+
"@salesforce/lds-network-aura": "1.229.0-dev4",
|
|
44
|
+
"@salesforce/lds-network-fetch-with-jwt": "1.229.0-dev4",
|
|
45
|
+
"@salesforce/lds-runtime-web": "1.229.0-dev4"
|
|
44
46
|
},
|
|
45
47
|
"luvioBundlesize": [
|
|
46
48
|
{
|
|
47
49
|
"path": "./dist/ldsEngineCreator.js",
|
|
48
50
|
"maxSize": {
|
|
49
51
|
"none": "32 kB",
|
|
50
|
-
"min": "
|
|
51
|
-
"compressed": "
|
|
52
|
+
"min": "13 kB",
|
|
53
|
+
"compressed": "8 kB"
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
]
|