Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix parameterization scope not aligned with core edc #348

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions docs/getting-started/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ services:
- EDC_UI_CATALOG_URLS=http://edc:11003/api/v1/ids/data
edc:
image: ghcr.io/sovity/edc-dev:latest
depends_on:
- postgresql
environment:
MY_EDC_NAME_KEBAB_CASE: 'example-connector'
MY_EDC_TITLE: 'EDC Connector'
MY_EDC_DESCRIPTION: 'Community Edition EDC Connector by sovity'
MY_EDC_DESCRIPTION: 'sovity Community Edition EDC Connector'
MY_EDC_CURATOR_URL: 'https://example.com'
MY_EDC_CURATOR_NAME: 'Example GmbH'
MY_EDC_MAINTAINER_URL: 'https://sovity.de'
Expand All @@ -27,6 +29,10 @@ services:
MY_EDC_FQDN: 'edc'
MY_EDC_PROTOCOL: 'http://'
MY_EDC_IDS_BASE_URL: 'http://edc:11003' # adds missing port

MY_EDC_JDBC_URL: jdbc:postgresql://postgresql:5432/edc
MY_EDC_JDBC_USER: edc
MY_EDC_JDBC_PASSWORD: edc
EDC_WEB_REST_CORS_ENABLED: 'true'
EDC_WEB_REST_CORS_HEADERS: 'origin,content-type,accept,authorization,x-api-key'
EDC_WEB_REST_CORS_ORIGINS: '*'
Expand All @@ -36,5 +42,18 @@ services:
- '11003:11003'
- '11004:11004'
- '11005:5005'
postgresql:
image: docker.io/bitnami/postgresql:11
restart: always
environment:
POSTGRESQL_USERNAME: edc
POSTGRESQL_PASSWORD: edc
POSTGRESQL_DATABASE: edc
ports:
- '54321:5432'
volumes:
- ./secrets:/secrets
- 'postgresql:/bitnami/postgresql'

volumes:
postgresql:
driver: local
4 changes: 1 addition & 3 deletions fake-backend/json/contractAgreementPage.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@
"asset:prop:datasource:http:hints:proxyMethod": "true",
"asset:prop:datasource:http:hints:proxyPath": "true",
"asset:prop:datasource:http:hints:proxyQueryParams": "true",
"asset:prop:datasource:http:hints:proxyBody": "true",
"asset:prop:datasource:http:hints:defaultMethod": "GET",
"asset:prop:datasource:http:hints:defaultPath": "/"
"asset:prop:datasource:http:hints:proxyBody": "true"
}
},
"contractPolicy": {
Expand Down
8 changes: 4 additions & 4 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 @@ -28,7 +28,7 @@
"@ng-apimock/core": "^3.6.0",
"@ngxs/store": "^3.8.1",
"@sovity.de/broker-server-client": "0.20230703.152001-main-d1ec5276",
"@sovity.de/edc-client": "0.20230629.150330-main-aaa2fa41",
"@sovity.de/edc-client": "0.20230706.64046-main-d2fd35a8",
"clean-deep": "^3.4.0",
"date-fns": "^2.29.3",
"dotenv": "^16.0.3",
Expand Down
14 changes: 0 additions & 14 deletions src/app/core/services/asset-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,6 @@ export const AssetProperties = {
*/
httpProxyBody: 'asset:prop:datasource:http:hints:proxyBody',

/**
* If this asset supports HTTP Method parameterization, this is the default method
*
* Example values: "GET", "POST", "PUT", "DELETE"
*/
httpDefaultMethod: 'asset:prop:datasource:http:hints:defaultMethod',

/**
* If this asset supports HTTP Path parameterization, this is the default path (appended after base path)
*
* Example values: /my-endpoint
*/
httpDefaultPath: 'asset:prop:datasource:http:hints:defaultPath',

/**
* @deprecated use {@link AssetProperties.curatorOrganizationName} instead
*/
Expand Down
8 changes: 0 additions & 8 deletions src/app/core/services/asset-property-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ export class AssetPropertyMapper {
props[AssetProperties.httpProxyQueryParams],
),
httpProxyBody: this._parseBoolean(props[AssetProperties.httpProxyBody]),
httpDefaultPath: props[AssetProperties.httpDefaultPath],
httpDefaultMethod: props[AssetProperties.httpDefaultMethod],
additionalProperties,
};
}
Expand Down Expand Up @@ -158,12 +156,6 @@ export class AssetPropertyMapper {
props[AssetProperties.httpProxyBody] = this._encodeBoolean(
datasource?.httpProxyBody,
);
props[AssetProperties.httpDefaultMethod] = datasource?.httpProxyMethod
? datasource?.httpMethod ?? null
: null;
props[AssetProperties.httpDefaultPath] = datasource?.httpProxyPath
? datasource?.httpDefaultPath ?? null
: null;
}

return removeNullValues(props);
Expand Down
34 changes: 17 additions & 17 deletions src/app/core/services/http-params-mapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ export class HttpRequestParamsMapper {
value: ContractAgreementTransferDialogFormValue,
): Record<string, string> {
const method = value.httpProxiedMethod?.trim() ?? '';
const {baseUrl: pathSegments, queryParams} = this.getUrlAndQueryParams(
const {url: pathSegments, queryParams} = this.getUrlAndQueryParams(
value.httpProxiedPath,
value.httpProxiedQueryParams,
);
const body = value.httpProxiedBody?.trim() ?? '';
const contentType = value.httpProxiedBodyContentType?.trim() ?? '';
const body = value.httpProxiedBody?.trim() || null;
const contentType = value.httpProxiedBodyContentType?.trim() || null;

let proxyMethod =
value.showAllHttpParameterizationFields || asset.httpProxyMethod;
Expand Down Expand Up @@ -66,7 +66,6 @@ export class HttpRequestParamsMapper {
proxyQueryParams: httpRequestParams.proxyQueryParams ? 'true' : null,
proxyBody: httpRequestParams.proxyBody ? 'true' : null,
queryParams: httpRequestParams.queryParams,
path: httpRequestParams.defaultPath,
...Object.fromEntries(
Object.entries(httpRequestParams.headers).map(
([headerName, headerValue]) => [`header:${headerName}`, headerValue],
Expand All @@ -87,20 +86,18 @@ export class HttpRequestParamsMapper {
let {authHeaderName, authHeaderValue, authHeaderSecretName} =
this.getAuthFields(formValue);

let defaultPath: string | null = null;
if (proxyPath) {
defaultPath = formValue?.httpDefaultPath?.trim() || null;
let method = formValue?.httpMethod?.trim().toUpperCase() || null;
if (proxyMethod) {
method = null;
}

let method = formValue?.httpMethod?.trim().toUpperCase() ?? '';
let {baseUrl, queryParams} = this.getUrlAndQueryParams(
let {url: baseUrl, queryParams} = this.getUrlAndQueryParams(
formValue?.httpUrl,
formValue?.httpQueryParams,
);

return {
baseUrl,
defaultPath,
baseUrl: baseUrl!!,
method,
authHeaderName,
authHeaderValue,
Expand Down Expand Up @@ -141,21 +138,24 @@ export class HttpRequestParamsMapper {
rawUrl: string | null | undefined,
rawQueryParams: HttpDatasourceQueryParamFormValue[] | null | undefined,
): {
baseUrl: string;
queryParams: string;
url: string | null;
queryParams: string | null;
} {
let url = rawUrl?.trim() ?? '';
let rawUrlTrimmed = rawUrl?.trim() ?? '';

let baseUrl = everythingBefore('?', url);
let url = everythingBefore('?', rawUrlTrimmed);

let queryParamSegments = (rawQueryParams ?? []).map((param) =>
this.encodeQueryParam(param),
);
let queryParams = [everythingAfter('?', url), ...queryParamSegments]
let queryParams = [
everythingAfter('?', rawUrlTrimmed),
...queryParamSegments,
]
.filter((it) => !!it)
.join('&');

return {baseUrl, queryParams};
return {url: url || null, queryParams: queryParams || null};
}

private encodeQueryParam(param: HttpDatasourceQueryParamFormValue): string {
Expand Down
2 changes: 0 additions & 2 deletions src/app/core/services/models/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ export interface Asset {
httpProxyPath: boolean | null;
httpProxyQueryParams: boolean | null;
httpProxyBody: boolean | null;
httpDefaultPath: string | null;
httpDefaultMethod: string | null;

// Unhandled Additional Properties
additionalProperties: AdditionalAssetProperty[];
Expand Down
10 changes: 2 additions & 8 deletions src/app/core/services/models/http-request-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@ export interface HttpRequestParams {
*/
baseUrl: string;

/**
* If proxy path is set, this
*/

defaultPath: string | null;

/**
* Http-method
*/
method: string;
method: string | null;

/**
* Header-Name ("Authorization"), where the secrets are passed into
Expand All @@ -38,7 +32,7 @@ export interface HttpRequestParams {
/**
* Query Parameters
*/
queryParams: string;
queryParams: string | null;
proxyMethod: boolean;
proxyPath: boolean;
proxyQueryParams: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,25 +198,27 @@ <h1 mat-dialog-title>Create New Asset</h1>
</mat-form-field>

<ng-container *ngIf="form.dataAddressType === 'Http'">
<div class="form-section-title">
{{ form.proxyMethod ? 'Default' : '' }} Method
<div class="form-section-title">Method</div>

<div *ngIf="form.proxyMethod" class="mb-[10px] px-[3px] text-sm">
The consuming side <b>must</b> provide a Custom HTTP Method with
method parameterization enabled.
</div>

<!-- Method (Rest-Api) -->
<mat-form-field
*ngIf="form.datasource.controls.httpMethod; let ctrl">
<mat-label>
{{ form.proxyMethod ? 'Default' : '' }} Method
</mat-label>
<mat-select [formControl]="ctrl">
<mat-option *ngFor="let method of methods" [value]="method">{{
method
}}</mat-option>
</mat-select>
<mat-hint *ngIf="form.proxyMethod">
When no method override is set, this method will be used.
</mat-hint>
</mat-form-field>
<ng-container *ngIf="!form.proxyMethod">
<mat-form-field
*ngIf="form.datasource.controls.httpMethod; let ctrl">
<mat-label>
{{ form.proxyMethod ? 'Default' : '' }} Method
</mat-label>
<mat-select [formControl]="ctrl">
<mat-option *ngFor="let method of methods" [value]="method">{{
method
}}</mat-option>
</mat-select>
</mat-form-field>
</ng-container>

<!-- Toggle Proxy Method Button -->
<div
Expand All @@ -232,34 +234,24 @@ <h1 mat-dialog-title>Create New Asset</h1>

<div class="form-section-title">URL</div>

<div *ngIf="form.proxyPath" class="mb-[10px] px-[3px] text-sm">
The consuming side <b>must</b> provide a Custom HTTP Subpath with
method parameterization is enabled. The Custom HTTP Subpath will
be appended to the base path.
</div>

<!-- Base Path (Rest-Api) -->
<mat-form-field
*ngIf="form.datasource.controls.httpUrl; let ctrl"
class="grow">
<mat-label *ngIf="!form.proxyPath"> URL </mat-label>
<mat-label *ngIf="form.proxyPath"> Base URL </mat-label>
<mat-label *ngIf="!form.proxyPath">URL</mat-label>
<mat-label *ngIf="form.proxyPath">Base URL</mat-label>
<input matInput [formControl]="ctrl" [placeholder]="'https://'" />
<mat-error *ngIf="ctrl.invalid && ctrl.errors?.pattern">
{{ validationMessages.invalidUrlMessage }}
</mat-error>
</mat-form-field>

<!-- Default Path (Rest-Api) -->
<ng-container *ngIf="form.proxyPath">
<mat-form-field
*ngIf="form.datasource.controls.httpDefaultPath; let ctrl"
class="grow">
<mat-label>Default Path</mat-label>
<input
matInput
[formControl]="ctrl"
[placeholder]="'sub-path/endpoint'" />
<mat-hint
>When no path override is set, this path will be used.
</mat-hint>
</mat-form-field>
</ng-container>

<!-- Toggle Proxy Path Button -->
<div
*ngIf="form.datasource.controls.httpProxyPath; let ctrl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,7 @@ <h1 mat-dialog-title>Initiate Transfer</h1>
>{{ method }}</mat-option
>
</mat-select>
<mat-hint>
Default: {{ data.asset.httpDefaultMethod ?? 'Unknown' }}
</mat-hint>
<mat-hint> Requires "proxyMethod" to be "true". </mat-hint>
</mat-form-field>
</ng-container>

Expand All @@ -257,10 +255,7 @@ <h1 mat-dialog-title>Initiate Transfer</h1>
matInput
[formControl]="ctrl"
[placeholder]="'sub-path/endpoint'" />
<mat-hint>
Default:
{{ data.asset.httpDefaultPath ?? 'Unknown' }}
</mat-hint>
<mat-hint> Requires "proxyPath" to be "true". </mat-hint>
</mat-form-field>
</ng-container>
</div>
Expand All @@ -281,6 +276,7 @@ <h1 mat-dialog-title>Initiate Transfer</h1>
required
autocomplete="new-query-param-name"
[formControl]="header.controls.paramName" />
<mat-hint> Requires "proxyQueryParams" to be "true". </mat-hint>
</mat-form-field>

<!-- Query Param Value -->
Expand Down Expand Up @@ -323,6 +319,7 @@ <h1 mat-dialog-title>Initiate Transfer</h1>
autocomplete="new-content-type"
[formControl]="form.all.controls.httpProxiedBodyContentType"
[placeholder]="'application/json'" />
<mat-hint> Requires "proxyBody" to be "true". </mat-hint>
</mat-form-field>

<!-- Request Body -->
Expand All @@ -333,6 +330,7 @@ <h1 mat-dialog-title>Initiate Transfer</h1>
placeholder='{"some": "request-body"}'
autocomplete="new-request-body"
[formControl]="ctrl"></textarea>
<mat-hint> Requires "proxyBody" to be "true". </mat-hint>
</mat-form-field>
</ng-container>

Expand Down
Loading
Loading