Skip to content

Commit

Permalink
PR remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Jul 28, 2023
1 parent 4e6da0d commit 20220b6
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 899 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/pull-request-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ jobs:
with:
node-version: '18.x'

- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
node_modules
*/*/node_modules
key: yarn-deps-${{ hashFiles('**/yarn.lock') }}


- name: Install dependencies
run: |
yarn
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@think-it-labs/edc-connector-client",
"version": "0.0.1-milestone-8.beta-5",
"version": "0.1.2",
"description": "EDC Connector HTTP client",
"private": false,
"main": "dist/src/index.js",
Expand All @@ -20,8 +20,7 @@
"license": "MIT",
"dependencies": {
"@think-it-labs/typed-error": "^0.1.4",
"jsonld": "^8.2.0",
"schema-dts-gen": "^1.1.2"
"jsonld": "^8.2.0"
},
"devDependencies": {
"@commitlint/config-conventional": "^17.1.0",
Expand Down
31 changes: 17 additions & 14 deletions src/controllers/management-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ import {
QuerySpec,
TransferProcess,
TransferProcessInput,
defaultContextValues,
EDC_CONTEXT,
} from "../entities";
import { Inner } from "../inner";
import jsonld from "jsonld";

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

constructor(inner: Inner) {
this.#inner = inner;
Expand Down Expand Up @@ -65,7 +68,7 @@ export class ManagementController {
apiToken: context.apiToken,
body: {
...input,
"@context": defaultContextValues,
"@context": this.defaultContextValues,
},
})
.then((body) => jsonld.expand(body))
Expand Down Expand Up @@ -118,7 +121,7 @@ export class ManagementController {
? null
: {
...query,
"@context": defaultContextValues,
"@context": this.defaultContextValues,
},
});
}
Expand All @@ -134,7 +137,7 @@ export class ManagementController {
apiToken: context.apiToken,
body: {
...input,
"@context": defaultContextValues,
"@context": this.defaultContextValues,
},
})
.then((body) => jsonld.expand(body))
Expand Down Expand Up @@ -177,7 +180,7 @@ export class ManagementController {
? null
: {
...query,
"@context": defaultContextValues,
"@context": this.defaultContextValues,
},
})
.then((body) => jsonld.expand(body))
Expand All @@ -199,7 +202,7 @@ export class ManagementController {
apiToken: context.apiToken,
body: {
...input,
"@context": defaultContextValues,
"@context": this.defaultContextValues,
},
})
.then((body) => jsonld.expand(body))
Expand Down Expand Up @@ -242,7 +245,7 @@ export class ManagementController {
? null
: {
...query,
"@context": defaultContextValues,
"@context": this.defaultContextValues,
},
})
.then((body) => jsonld.expand(body))
Expand All @@ -263,7 +266,7 @@ export class ManagementController {
method: "POST",
apiToken: context.apiToken,
body: {
"@context": defaultContextValues,
"@context": this.defaultContextValues,
protocol: this.protocol,
...input,
},
Expand All @@ -283,7 +286,7 @@ export class ManagementController {
apiToken: context.apiToken,
body: {
protocol: this.protocol,
"@context": defaultContextValues,
"@context": this.defaultContextValues,
...input,
},
})
Expand All @@ -304,7 +307,7 @@ export class ManagementController {
? null
: {
...query,
"@context": defaultContextValues,
"@context": this.defaultContextValues,
},
});
}
Expand Down Expand Up @@ -391,7 +394,7 @@ export class ManagementController {
? null
: {
...query,
"@context": defaultContextValues,
"@context": this.defaultContextValues,
},
})
.then((body) => jsonld.expand(body))
Expand Down Expand Up @@ -426,7 +429,7 @@ export class ManagementController {
method: "POST",
apiToken: context.apiToken,
body: {
"@context": defaultContextValues,
"@context": this.defaultContextValues,
protocol: this.protocol,
...input,
},
Expand All @@ -444,9 +447,9 @@ export class ManagementController {
path: "/v2/transferprocesses/request",
method: "POST",
apiToken: context.apiToken,
body: Object.keys(query).length === 0 ? null : {
body: {
...query,
"@context": defaultContextValues,
"@context": this.defaultContextValues,
},
})
.then((body) => jsonld.expand(body))
Expand Down
5 changes: 0 additions & 5 deletions src/entities/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,3 @@ export interface ContextProperties {
}

export const EDC_CONTEXT = "https://w3id.org/edc/v0.0.1/ns/";

type DefaultContextValues = Pick<Context, "edc">;
export const defaultContextValues: DefaultContextValues = {
edc: EDC_CONTEXT,
};
2 changes: 1 addition & 1 deletion src/entities/data-address.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface BaseDataAddress {
[key: string]: string | undefined | any;
[key: string]: string | undefined;
type: string;
}

Expand Down
6 changes: 2 additions & 4 deletions tests/controllers/public.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ describe("PublicController", () => {
consumerContext,
);

const receiverCallback = receiverServer.waitForEvent('endpoint-data-reference');

await edcClient.management.initiateTransfer(
const idResponse = await edcClient.management.initiateTransfer(
consumerContext,
{
assetId,
Expand All @@ -97,7 +95,7 @@ describe("PublicController", () => {
},
);

const transferProcessResponse = await receiverCallback;
const transferProcessResponse = await receiverServer.waitForEvent(idResponse.id);

// when
const data = await edcClient.public.getTranferedData(consumerContext, {
Expand Down
4 changes: 3 additions & 1 deletion tests/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ export function createReceiverServer() {
},
);

emitter.emit("endpoint-data-reference", body);
if (body.id) {
emitter.emit(body.id, body);
}

res.statusCode = 204;
res.end();
Expand Down
Loading

0 comments on commit 20220b6

Please sign in to comment.