Skip to content

Commit

Permalink
feat: implement missing transfer process functionalities (#132)
Browse files Browse the repository at this point in the history
* feat: implement missing transfer process functionalities

* pass @vocab in the request @context
  • Loading branch information
ndr-brt authored Oct 24, 2023
1 parent 686bdc4 commit 3b0fbe4
Show file tree
Hide file tree
Showing 13 changed files with 242 additions and 164 deletions.
11 changes: 4 additions & 7 deletions src/controllers/management-controllers/asset-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ import {
AssetInput,
IdResponse,
QuerySpec,
EDC_CONTEXT,
JSON_LD_DEFAULT_CONTEXT,
} from "../../entities";
import { Inner } from "../../inner";

export class AssetController {
#inner: Inner;
#context?: EdcConnectorClientContext;
defaultContextValues = {
edc: EDC_CONTEXT,
};

constructor(inner: Inner, context?: EdcConnectorClientContext) {
this.#inner = inner;
Expand All @@ -35,7 +32,7 @@ export class AssetController {
apiToken: actualContext.apiToken,
body: {
...input,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
})
.then((body) => expand(body, () => new IdResponse()));
Expand Down Expand Up @@ -81,7 +78,7 @@ export class AssetController {
apiToken: actualContext.apiToken,
body: {
...input,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
});
}
Expand All @@ -102,7 +99,7 @@ export class AssetController {
? null
: {
...query,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
})
.then((body) => expandArray(body, () => new Asset()));
Expand Down
11 changes: 5 additions & 6 deletions src/controllers/management-controllers/catalog-controller.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { EdcConnectorClientContext } from "../../context";
import { EDC_CONTEXT, CatalogRequest, Catalog, expand, Dataset, DatasetRequest } from "../../entities";
import {
JSON_LD_DEFAULT_CONTEXT, CatalogRequest, Catalog, expand, Dataset, DatasetRequest
} from "../../entities";
import { Inner } from "../../inner";

export class CatalogController {
#inner: Inner;
#context: EdcConnectorClientContext | undefined;
protocol: String = "dataspace-protocol-http";
defaultContextValues = {
edc: EDC_CONTEXT,
};

constructor(inner: Inner, context?: EdcConnectorClientContext) {
this.#inner = inner;
Expand All @@ -27,7 +26,7 @@ export class CatalogController {
method: "POST",
apiToken: actualContext.apiToken,
body: {
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
protocol: this.protocol,
...input,
},
Expand All @@ -47,7 +46,7 @@ export class CatalogController {
method: "POST",
apiToken: actualContext.apiToken,
body: {
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
protocol: this.protocol,
...input,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ import {
ContractAgreement,
ContractNegotiation,
QuerySpec,
EDC_CONTEXT,
JSON_LD_DEFAULT_CONTEXT,
} from "../../entities";
import { Inner } from "../../inner";

export class ContractAgreementController {
#inner: Inner;
#context?: EdcConnectorClientContext;
defaultContextValues = {
edc: EDC_CONTEXT,
};

constructor(inner: Inner, context?: EdcConnectorClientContext) {
this.#inner = inner;
Expand All @@ -37,7 +34,7 @@ export class ContractAgreementController {
? null
: {
...query,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
})
.then((body) => expandArray(body, () => new ContractAgreement()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ import {
ContractDefinitionInput,
IdResponse,
QuerySpec,
EDC_CONTEXT,
JSON_LD_DEFAULT_CONTEXT,
} from "../../entities";
import { Inner } from "../../inner";

export class ContractDefinitionController {
#inner: Inner;
#context?: EdcConnectorClientContext;
defaultContextValues = {
edc: EDC_CONTEXT,
};

constructor(inner: Inner, context?: EdcConnectorClientContext) {
this.#inner = inner;
Expand All @@ -35,7 +32,7 @@ export class ContractDefinitionController {
apiToken: actualContext.apiToken,
body: {
...input,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
})
.then((body) => expand(body, () => new IdResponse()));
Expand Down Expand Up @@ -84,7 +81,7 @@ export class ContractDefinitionController {
? null
: {
...query,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
})
.then((body) => expandArray(body, () => new ContractDefinition()));
Expand All @@ -102,7 +99,7 @@ export class ContractDefinitionController {
apiToken: actualContext.apiToken,
body: {
...input,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ import {
ContractNegotiationState,
IdResponse,
QuerySpec,
EDC_CONTEXT,
JSON_LD_DEFAULT_CONTEXT,
} from "../../entities";
import { Inner } from "../../inner";

export class ContractNegotiationController {
#inner: Inner;
#context?: EdcConnectorClientContext;
protocol: String = "dataspace-protocol-http";
defaultContextValues = {
edc: EDC_CONTEXT,
};

constructor(inner: Inner, context?: EdcConnectorClientContext) {
this.#inner = inner;
Expand All @@ -38,7 +35,7 @@ export class ContractNegotiationController {
apiToken: actualContext.apiToken,
body: {
protocol: this.protocol,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
...input,
},
})
Expand All @@ -61,7 +58,7 @@ export class ContractNegotiationController {
? null
: {
...query,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
})
.then((body) => expandArray(body, () => new ContractNegotiation()));
Expand Down Expand Up @@ -111,7 +108,7 @@ export class ContractNegotiationController {
body: {
reason: reason,
"@id": negotiationId,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
});
}
Expand All @@ -121,7 +118,7 @@ export class ContractNegotiationController {
context?: EdcConnectorClientContext,
): Promise<ContractAgreement> {
const actualContext = context || this.#context!;

return this.#inner
.request(actualContext.management, {
path: `/v2/contractnegotiations/${negotiationId}/agreement`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ import {
DataplaneInput,
DataplaceSelectInput,
IdResponse,
EDC_CONTEXT,
JSON_LD_DEFAULT_CONTEXT,
} from "../../entities";
import { Inner } from "../../inner";

export class DataplaneController {
#inner: Inner;
#context?: EdcConnectorClientContext;
defaultContextValues = {
edc: EDC_CONTEXT,
};

constructor(inner: Inner, context?: EdcConnectorClientContext) {
this.#inner = inner;
Expand All @@ -34,7 +31,7 @@ export class DataplaneController {
apiToken: actualContext.apiToken,
body: {
...input,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
})
.then((body) => expand(body, () => new IdResponse()));
Expand Down Expand Up @@ -64,7 +61,7 @@ export class DataplaneController {
apiToken: actualContext.apiToken,
body: {
...input,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
})
.then((body) => expand(body, () => new Dataplane()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ import {
PolicyDefinition,
PolicyDefinitionInput,
QuerySpec,
EDC_CONTEXT,
JSON_LD_DEFAULT_CONTEXT,
} from "../../entities";
import { Inner } from "../../inner";

export class PolicyDefinitionController {
#inner: Inner;
#context?: EdcConnectorClientContext;
defaultContextValues = {
edc: EDC_CONTEXT,
};

constructor(inner: Inner, context?: EdcConnectorClientContext) {
this.#inner = inner;
Expand All @@ -35,7 +32,7 @@ export class PolicyDefinitionController {
apiToken: actualContext.apiToken,
body: {
...input,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
})
.then((body) => expand(body, () => new IdResponse()));
Expand All @@ -55,7 +52,7 @@ export class PolicyDefinitionController {
apiToken: actualContext.apiToken,
body: {
...input,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
})
}
Expand Down Expand Up @@ -104,7 +101,7 @@ export class PolicyDefinitionController {
? null
: {
...query,
"@context": this.defaultContextValues,
"@context": JSON_LD_DEFAULT_CONTEXT,
},
})
.then((body) => expandArray(body, () => new PolicyDefinition()));
Expand Down
Loading

0 comments on commit 3b0fbe4

Please sign in to comment.