Skip to content

Commit

Permalink
feat: Eclipse EDC 0.7.2 migration (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtreier committed Oct 25, 2024
1 parent 7bd3648 commit 4ce4ee5
Show file tree
Hide file tree
Showing 23 changed files with 141 additions and 373 deletions.
2 changes: 1 addition & 1 deletion .env.local-dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ EDC_UI_ACTIVE_PROFILE=sovity-open-source
EDC_UI_USE_FAKE_BACKEND=true
EDC_UI_MANAGEMENT_API_URL=http://edc.fake-backend
EDC_UI_MANAGEMENT_API_KEY=no-api-key-required-in-local-dev
EDC_UI_CATALOG_URLS=http://existing-other-connector/api/dsp,http://does-not-exist-but-is-super-long-so-we-can-test/api/dsp, http://how-wrapping-works-in-subtext-of-catalog-url-select/api/dsp
EDC_UI_CATALOG_URLS="https://existing-other-connector/api/dsp?participantId=MDSL1234XX.C1234XX, https://does-not-exist-but-is-super-long-so-we-can-test/api/dsp?participantId=MDSL1234XX.C1235XX, https://how-wrapping-works-in-subtext-of-catalog-url-select/api/dsp?participantId=MDSL1234XX.C1237XX"
EDC_UI_LOGOUT_URL=https://example.com/logout
EDC_UI_CONNECTOR_ENDPOINT=http://localhost:3000/api/dsp
EDC_UI_MANAGEMENT_API_URL_SHOWN_IN_DASHBOARD=http://localhost:3000/api/control/management
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "^7.0.0",
"@ngxs/store": "^3.8.1",
"@sovity.de/edc-client": "10.4.0",
"@sovity.de/edc-client": "0.0.1-20241025-2408-alpha1",
"clean-deep": "^3.4.0",
"date-fns": "^2.30.0",
"date-fns-tz": "^2.0.1",
Expand Down
6 changes: 5 additions & 1 deletion src/app/core/services/api/edc-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,13 @@ export class EdcApiService {

getCatalogPageDataOffers(
connectorEndpoint: string,
participantId: string,
): Observable<UiDataOffer[]> {
return toObservable(() =>
this.edcClient.uiApi.getCatalogPageDataOffers({connectorEndpoint}),
this.edcClient.uiApi.getCatalogPageDataOffers({
connectorEndpoint,
participantId,
}),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {TestPolicies} from './data/test-policies';

let dataOffers: UiDataOffer[] = [
{
endpoint: 'http://existing-other-connector/api/dsp',
endpoint: 'https://existing-other-connector/api/dsp',
participantId: 'MDSL1234XX.C1234XX',
asset: TestAssets.full,
contractOffers: [
Expand All @@ -21,7 +21,7 @@ let dataOffers: UiDataOffer[] = [
],
},
{
endpoint: 'http://existing-other-connector/api/dsp',
endpoint: 'https://existing-other-connector/api/dsp',
participantId: 'MDSL1234XX.C1234XX',
asset: TestAssets.onRequestAsset,
contractOffers: [
Expand All @@ -32,7 +32,7 @@ let dataOffers: UiDataOffer[] = [
],
},
{
endpoint: 'http://existing-other-connector/api/dsp',
endpoint: 'https://existing-other-connector/api/dsp',
asset: TestAssets.boring,
participantId: 'MDSL1234XX.C1234XX',
contractOffers: [
Expand All @@ -43,7 +43,7 @@ let dataOffers: UiDataOffer[] = [
],
},
{
endpoint: 'http://existing-other-connector/api/dsp',
endpoint: 'https://existing-other-connector/api/dsp',
asset: TestAssets.short,
participantId: 'MDSL1234XX.C1234XX',
contractOffers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const initiateContractNegotiation = (
direction: 'CONSUMING',
counterPartyAddress: request.counterPartyAddress,
transferProcesses: [],
counterPartyId: request.counterPartyParticipantId,
counterPartyId: request.counterPartyId,
asset: getAssetById(request.assetId)!,
contractSigningDate: new Date(),
contractPolicy: getPolicyDefinitionByJsonLd(request.policyJsonLd)!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ export const dashboardPage = (): DashboardPage => ({
connectorCuratorName: 'Example GmbH',
connectorCuratorUrl: 'https://example.com',
connectorEndpoint: 'https://edc.fake-backend/api/dsp',
connectorMiwConfig: {
url: 'https://miw.fake-backend',
tokenUrl: 'https://miw.fake-backend/token',
authorityId: 'fake-miw',
connectorCxDidConfig: {
myDid: 'your-did-long-number:1234567890:idk',
bdrsUrl: 'https://bdrs.fake-backend',
dimUrl: 'https://dim.fake-backend',
trustedVcIssuer: 'https://trusted-vc-issuer.fake-backend',
walletTokenUrl: 'https://wallet-token.fake-backend',
},
connectorDapsConfig: {
tokenUrl: 'https://daps.fake-backend/token',
Expand Down
31 changes: 31 additions & 0 deletions src/app/core/services/connector-endpoint-url-mapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {Injectable} from '@angular/core';

@Injectable({providedIn: 'root'})
export class ConnectorEndpointUrlMapper {
/**
* Builds strings like "https://my-connector.com/api/dsp, participantId=CXL-1234567890".
*
* Connectors now require both the connector endpoint and the participant ID for catalog requests, but we
* still want to be able to offer the "copy + paste" User Experience
*/
separator = '?participantId=';

mergeConnectorEndpointAndParticipantId(
connectorEndpoint: string,
participantId: string,
): string {
return `${connectorEndpoint}${this.separator}${participantId}`;
}

extractConnectorEndpointAndParticipantId(combined: string): {
connectorEndpoint: string;
participantId: string;
} {
const parts = combined.split(this.separator);
if (parts.length !== 2) {
return {connectorEndpoint: combined, participantId: ''};
}

return {connectorEndpoint: parts[0], participantId: parts[1]};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,25 +214,39 @@ export class ConnectorInfoPropertyGridGroupBuilder {
);
}

if (data.connectorMiwConfig != null) {
if (data.connectorCxDidConfig != null) {
fields.push(
{
icon: 'category',
label: 'MIW Authority ID',
label: 'Your DID',
...this.propertyGridUtils.guessValue(data.connectorCxDidConfig.myDid),
},
{
icon: 'vpn_key',
label: 'Wallet Token URL',
...this.propertyGridUtils.guessValue(
data.connectorCxDidConfig.walletTokenUrl,
),
},
{
icon: 'category',
label: 'Trusted VC Issuer',
...this.propertyGridUtils.guessValue(
data.connectorMiwConfig.authorityId,
data.connectorCxDidConfig.trustedVcIssuer,
),
},
{
icon: 'link',
label: 'MIW URL',
...this.propertyGridUtils.guessValue(data.connectorMiwConfig.url),
label: 'BDRS URL',
...this.propertyGridUtils.guessValue(
data.connectorCxDidConfig.bdrsUrl,
),
},
{
icon: 'vpn_key',
label: 'MIW Token URL',
icon: 'link',
label: 'DIM URL',
...this.propertyGridUtils.guessValue(
data.connectorMiwConfig.tokenUrl,
data.connectorCxDidConfig.dimUrl,
),
},
);
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/contract-negotiation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class ContractNegotiationService {
negotiate(dataOffer: DataOffer, contractOffer: UiContractOffer) {
const contractOfferId = contractOffer.contractOfferId;
const initiateRequest: ContractNegotiationRequest = {
counterPartyParticipantId: dataOffer.participantId,
counterPartyId: dataOffer.participantId,
counterPartyAddress: dataOffer.endpoint!,
assetId: dataOffer.asset.assetId,
contractOfferId,
Expand Down
40 changes: 0 additions & 40 deletions src/app/core/services/transfer-data-sink-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {getAuthFields} from '../utils/form-value-utils';
import {mapKeys, removeNullValues} from '../utils/record-utils';
import {DataAddressProperty} from './models/data-address-properties';
import {HttpDataAddressParams} from './models/http-data-address-params';
import {UiAssetMapped} from './models/ui-asset-mapped';
import {QueryParamsMapper} from './query-params-mapper';

@Injectable({providedIn: 'root'})
Expand All @@ -18,45 +17,6 @@ export class TransferDataSinkMapper {
const params = this.buildHttpRequestParams(formValue);
return this.encodeHttpRequestParams(params);
}

encodeHttpProxyTransferRequestProperties(
asset: UiAssetMapped,
value: ContractAgreementTransferDialogFormValue,
): Record<string, string> {
const method = value.httpProxiedMethod?.trim() ?? '';
const pathSegments = this.queryParamsMapper.getBaseUrlWithoutQueryParams(
value.httpProxiedPath!!,
);
const queryParams = this.queryParamsMapper.getFullQueryString(
value.httpProxiedPath!!,
value.httpProxiedQueryParams ?? [],
);
const body = value.httpProxiedBody?.trim() || null;
const contentType = value.httpProxiedBodyContentType?.trim() || null;

const proxyMethod =
value.showAllHttpParameterizationFields ||
asset.httpDatasourceHintsProxyMethod;
const proxyPath =
value.showAllHttpParameterizationFields ||
asset.httpDatasourceHintsProxyPath;
const proxyQueryParams =
value.showAllHttpParameterizationFields ||
asset.httpDatasourceHintsProxyQueryParams;
const proxyBody =
value.showAllHttpParameterizationFields ||
asset.httpDatasourceHintsProxyBody;

return removeNullValues({
[DataAddressProperty.method]: proxyMethod && method ? method : null,
[DataAddressProperty.pathSegments]: proxyPath ? pathSegments : null,
[DataAddressProperty.queryParams]: proxyQueryParams ? queryParams : null,
[DataAddressProperty.body]: proxyBody ? body : null,
[DataAddressProperty.contentType]: proxyBody ? contentType : null,
[DataAddressProperty.mediaType]: proxyBody ? contentType : null,
});
}

encodeHttpRequestParams(
httpRequestParams: HttpDataAddressParams,
): Record<string, string> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Injectable} from '@angular/core';
import {Observable, combineLatest} from 'rxjs';
import {map, switchMap} from 'rxjs/operators';
import {EdcApiService} from '../../../../core/services/api/edc-api.service';
import {ConnectorEndpointUrlMapper} from '../../../../core/services/connector-endpoint-url-mapper';
import {DataOffer} from '../../../../core/services/models/data-offer';
import {Fetched} from '../../../../core/services/models/fetched';
import {MultiFetched} from '../../../../core/services/models/multi-fetched';
Expand All @@ -19,6 +20,7 @@ export class CatalogBrowserPageService {
private edcApiService: EdcApiService,
private catalogApiUrlService: CatalogApiUrlService,
private dataOfferBuilder: DataOfferBuilder,
private connectorEndpointUrlMapper: ConnectorEndpointUrlMapper,
) {}

contractOfferPageData$(
Expand Down Expand Up @@ -90,9 +92,14 @@ export class CatalogBrowserPageService {
);
}

private fetchDataOffers(endpoint: string) {
private fetchDataOffers(endpointAndParticipantId: string) {
const {connectorEndpoint, participantId} =
this.connectorEndpointUrlMapper.extractConnectorEndpointAndParticipantId(
endpointAndParticipantId,
);

return this.edcApiService
.getCatalogPageDataOffers(endpoint)
.getCatalogPageDataOffers(connectorEndpoint, participantId)
.pipe(
map((dataOffers) =>
dataOffers.map((dataOffer) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<mat-icon matPrefix>link</mat-icon>
<input
matInput
placeholder="https://other-connector.com/control/api/v1/ids/data, ..."
placeholder="https://counter-party/api/dsp?participantId=1234, ..."
[(ngModel)]="customProviders"
(input)="onCatalogUrlsChange()" />
<mat-hint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
FormGroup,
ɵFormGroupValue,
} from '@angular/forms';
import {HttpDatasourceQueryParamFormModel} from '../../../../shared/business/edit-asset-form/form/model/http-datasource-query-param-form-model';
import {DataAddressType} from '../../../../shared/form-elements/data-address-type-select/data-address-type';
import {HttpDatasinkAuthHeaderType} from './http-datasink-auth-header-type';
import {HttpDatasinkHeaderFormModel} from './http-datasink-header-form-model';
Expand All @@ -31,20 +30,9 @@ export interface ContractAgreementTransferDialogFormModel {
httpUrl: FormControl<string>;
httpMethod: FormControl<string>;

showAllHttpParameterizationFields: FormControl<boolean>;

httpAuthHeaderType: FormControl<HttpDatasinkAuthHeaderType>;
httpAuthHeaderName: FormControl<string>;
httpAuthHeaderValue: FormControl<string>;
httpAuthHeaderSecretName: FormControl<string>;
httpHeaders: FormArray<FormGroup<HttpDatasinkHeaderFormModel>>;

// Http Datasource Parameterization
httpProxiedPath: FormControl<string>;
httpProxiedMethod: FormControl<string>;
httpProxiedQueryParams: FormArray<
FormGroup<HttpDatasourceQueryParamFormModel>
>;
httpProxiedBody: FormControl<string>;
httpProxiedBodyContentType: FormControl<string>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ export class ContractAgreementTransferDialogForm {
httpHeaders: this.formBuilder.array(
new Array<FormGroup<HttpDatasinkHeaderFormModel>>(),
),

showAllHttpParameterizationFields: [false],

httpProxiedPath: [''],
httpProxiedMethod: ['', Validators.required],
httpProxiedQueryParams: this.formBuilder.array(
new Array<FormGroup<HttpDatasourceQueryParamFormModel>>(),
),
httpProxiedBody: [''],
httpProxiedBodyContentType: [''],
});

switchDisabledControls<ContractAgreementTransferDialogFormValue>(
Expand All @@ -80,8 +70,6 @@ export class ContractAgreementTransferDialogForm {
const httpAuthByValue = value.httpAuthHeaderType === 'Value';
const httpAuthByVault = value.httpAuthHeaderType === 'Vault-Secret';

const httpProxiedMethod = !!value.showAllHttpParameterizationFields;

return {
dataAddressType: true,

Expand All @@ -99,14 +87,6 @@ export class ContractAgreementTransferDialogForm {
httpAuthHeaderSecretName: http && httpAuthByVault,

httpHeaders: http,

showAllHttpParameterizationFields: !customTransferProcessRequest,

httpProxiedPath: !customTransferProcessRequest,
httpProxiedMethod: !customTransferProcessRequest && httpProxiedMethod,
httpProxiedQueryParams: !customTransferProcessRequest,
httpProxiedBody: !customTransferProcessRequest,
httpProxiedBodyContentType: !customTransferProcessRequest,
};
},
);
Expand Down Expand Up @@ -134,14 +114,4 @@ export class ContractAgreementTransferDialogForm {
onHttpHeadersRemoveClick(index: number) {
this.all.controls.httpHeaders.removeAt(index);
}

onHttpQueryParamsAddClick() {
this.all.controls.httpProxiedQueryParams.push(
this.buildQueryParamFormGroup(),
);
}

onHttpQueryParamsRemoveClick(index: number) {
this.all.controls.httpProxiedQueryParams.removeAt(index);
}
}
Loading

0 comments on commit 4ce4ee5

Please sign in to comment.