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

build(deps): bump edc from 0.3.1 to 0.4.1 in /connector #147

Merged
merged 2 commits into from
Nov 21, 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
2 changes: 1 addition & 1 deletion connector/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
format.version = "1.1"

[versions]
edc = "0.3.1"
edc = "0.4.1"
shadow = "8.1.1"

[libraries]
Expand Down
5 changes: 3 additions & 2 deletions src/entities/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { QuerySpec } from ".";
import { JsonLdId } from "./jsonld";

export interface CatalogRequest {
providerUrl: string;
counterPartyAddress: string;
querySpec?: QuerySpec;
}

Expand Down Expand Up @@ -33,6 +33,7 @@ export class Offer extends JsonLdId {
}

get target(): string {
return this.mandatoryValue('odrl', 'target');
const target = this.nestedOf(() => new JsonLdId(), 'odrl', 'target');
return target?.id!!;
}
}
9 changes: 2 additions & 7 deletions src/entities/contract-negotiation.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { JsonLdId, JsonLdObject } from "./jsonld";

export interface ContractNegotiationRequest {
connectorAddress: string;
connectorId: string;
counterPartyAddress: string;
providerId: string;
offer: {
offerId: string;
assetId: string;
policy: any;
};
policy: any;
}

export class ContractNegotiation extends JsonLdId {
Expand Down
2 changes: 1 addition & 1 deletion src/entities/transfer-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export enum TransferProcessStates {

export interface TransferProcessInput {
assetId: string;
connectorAddress: string;
counterPartyAddress: string;
connectorId: string;
contractId: string;
dataDestination: DataAddress;
Expand Down
16 changes: 6 additions & 10 deletions src/inner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,41 +70,37 @@ export class Inner {
return response;
}

const errorMessage = await response.text();

switch (response.status) {
case 400: {
const error = new EdcConnectorClientError(
EdcConnectorClientErrorType.BadRequest,
"request was malformed",
"request was malformed: " + errorMessage,
);

error.body = await response.text();

throw error;
}
case 404: {
const error = new EdcConnectorClientError(
EdcConnectorClientErrorType.NotFound,
"resource not found",
"resource not found: " + errorMessage,
);

error.body = await response.text();

throw error;
}
case 409: {
const error = new EdcConnectorClientError(
EdcConnectorClientErrorType.Duplicate,
"duplicated resource",
"duplicated resource: " + errorMessage,
);

error.body = await response.text();

throw error;
}
default: {
throw new EdcConnectorClientError(
EdcConnectorClientErrorType.Unknown,
await response.text(),
errorMessage,
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/controllers/management-tests/catalog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe("CatalogController", () => {
// when
const catalog = await consumerManagement.catalog.request(
{
providerUrl: providerProtocolUrl,
counterPartyAddress: providerProtocolUrl,
},
);

Expand Down Expand Up @@ -119,7 +119,7 @@ describe("CatalogController", () => {
);
const catalog = await consumerManagement.catalog.request(
{
providerUrl: providerProtocolUrl,
counterPartyAddress: providerProtocolUrl,
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe("TransferProcessController", () => {
{
assetId,
connectorId: "provider",
connectorAddress: provider.addresses.protocol!,
counterPartyAddress: provider.addresses.protocol!,
contractId: contractAgreement.id,
dataDestination: { type: "HttpProxy" },
},
Expand Down
2 changes: 1 addition & 1 deletion tests/controllers/public.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe("PublicController", () => {
{
assetId,
connectorId: "provider",
connectorAddress: provider.addresses.protocol!,
counterPartyAddress: provider.addresses.protocol!,
contractId: contractAgreement.id,
dataDestination: { type: "HttpProxy" },
},
Expand Down
11 changes: 3 additions & 8 deletions tests/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function createContractNegotiation(

// Retrieve catalog and select contract offer
const catalog = await consumer.management.catalog.request({
providerUrl: provider.addresses.protocol!,
counterPartyAddress: provider.addresses.protocol!,
});

const offer = catalog.datasets
Expand All @@ -112,14 +112,9 @@ export async function createContractNegotiation(
// Initiate contract negotiation on the consumer's side
const idResponse = await consumer.management.contractNegotiations.initiate(
{
connectorAddress: provider.addresses.protocol!,
connectorId: "provider",
counterPartyAddress: provider.addresses.protocol!,
providerId: "provider",
offer: {
offerId: offer.id,
assetId: assetId,
policy: offer,
},
policy: offer
},
);

Expand Down