Skip to content

Commit

Permalink
Upgrade runtime (#227)
Browse files Browse the repository at this point in the history
* chore: upgrade runtime

* chore: fix tests

* fix: npm i

* refactor: remove comment

* chore: upgrade backbone

* refactor: isDefault true

* fix: use syncUntil in test

* chore: bump runtime to real v5

* chore: undo unnecessary formatting change

* fix: update test

* refactor: rename ConnectorResponse to Response

* refactor: Response -> ConnectorHttpResponse

* refactor: update sdk types

* refactor: update tests

* chore: bump local backbone

* ci: audit exclude

* chore: rm comment

* fix: specify atTypes

* fix: do not use runtime in connector tests

* fix: more issues

* chore: remove relic

* fix: naming

* fix: make only optional where necessary

---------

Co-authored-by: Sebastian Mahr <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Julian König <[email protected]>
  • Loading branch information
4 people authored Aug 15, 2024
1 parent 3181bbc commit 1738600
Show file tree
Hide file tree
Showing 52 changed files with 372 additions and 288 deletions.
2 changes: 1 addition & 1 deletion .dev/compose.backbone.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BACKBONE_VERSION=6.2.0
BACKBONE_VERSION=6.5.1
2 changes: 1 addition & 1 deletion .dev/compose.backbone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ services:
image: postgres
environment:
- PGPASSWORD=Passw0rd
command: /bin/bash -c 'env && apt update -y && apt install -y wget && wget https://raw.githubusercontent.com/nmshd/backbone/${BACKBONE_VERSION}/setup-db/setup-postgres.sql -O /setup-postgres.sql && psql -h postgres -U postgres -d enmeshed -f /setup-postgres.sql'
command: /bin/bash -c 'env && apt update -y && apt install -y wget && wget https://raw.githubusercontent.com/nmshd/backbone/${BACKBONE_VERSION}/scripts/sql/postgres/setup.sql -O /setup-postgres.sql && psql -h postgres -U postgres -d enmeshed -f /setup-postgres.sql'
depends_on:
database:
condition: service_healthy
Expand Down
25 changes: 18 additions & 7 deletions .dev/scripts/establishRelationshipAndSpamMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ async function run() {
const { connector1Address, connector2Address } = await establishOrReturnRelationship(connector1, connector2);

while (true) {
await connector1.messages.sendMessage({ recipients: [connector2Address], content: {} });
await connector1.messages.sendMessage({ recipients: [connector2Address], content: { "@type": "ArbitraryMessageContent", value: {} } });
await sleep(2000);

await connector2.messages.sendMessage({ recipients: [connector1Address], content: {} });
await connector2.messages.sendMessage({ recipients: [connector1Address], content: { "@type": "ArbitraryMessageContent", value: {} } });
await sleep(2000);
}
}
Expand All @@ -29,8 +29,8 @@ async function establishOrReturnRelationship(connector1: ConnectorClient, connec
const relationships = (await connector1.relationships.getRelationships()).result;

if (relationships.length > 0) {
if (relationships[0].status === ConnectorRelationshipStatus.PENDING) {
await connector1.relationships.acceptRelationshipChange(relationships[0].id, relationships[0].changes[0].id);
if (relationships[0].status === ConnectorRelationshipStatus.Pending) {
await connector1.relationships.acceptRelationship(relationships[0].id);
}

return {
Expand All @@ -39,15 +39,26 @@ async function establishOrReturnRelationship(connector1: ConnectorClient, connec
};
}

const template = (await connector1.relationshipTemplates.createOwnRelationshipTemplate({ expiresAt: "2099", maxNumberOfAllocations: 1, content: {} })).result;
const template = (
await connector1.relationshipTemplates.createOwnRelationshipTemplate({
expiresAt: "2099",
maxNumberOfAllocations: 1,
content: { "@type": "ArbitraryRelationshipTemplateContent", value: {} }
})
).result;

await connector2.relationshipTemplates.loadPeerRelationshipTemplate({ reference: template.truncatedReference });

const relationship = (await connector2.relationships.createRelationship({ templateId: template.id, content: {} })).result;
const relationship = (
await connector2.relationships.createRelationship({
templateId: template.id,
creationContent: { "@type": "ArbitraryRelationshipCreationContent", value: {} }
})
).result;

await connector1.account.sync();

const accepted = (await connector1.relationships.acceptRelationshipChange(relationship.id, relationship.changes[0].id)).result;
const accepted = (await connector1.relationships.acceptRelationship(relationship.id)).result;
console.log(accepted);

await connector2.account.sync();
Expand Down
64 changes: 26 additions & 38 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 @@ -85,7 +85,7 @@
"@js-soft/node-logger": "1.2.0",
"@js-soft/ts-utils": "^2.3.3",
"@nmshd/iql": "^1.0.2",
"@nmshd/runtime": "5.0.0-alpha.9",
"@nmshd/runtime": "5.0.0",
"agentkeepalive": "4.5.0",
"amqplib": "^0.10.4",
"axios": "^1.7.4",
Expand Down
14 changes: 7 additions & 7 deletions packages/sdk/_examples/relationships.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ async function run() {

const createdRelationship = await client.relationships.createRelationship({
templateId: "RLT_________________",
content: {
prop1: "value",
prop2: 1
creationContent: {
"@type": "ArbitraryRelationshipCreationContent",
value: {
prop1: "value",
prop2: 1
}
}
});
console.log(createdRelationship);

const syncedRelationships = await client.account.sync();
const relationship = syncedRelationships.result!.relationships[0];

const acceptedRelationship = await client.relationships.acceptRelationshipChange(relationship.id, relationship.changes[0].id, { content: { a: "b" } });
const acceptedRelationship = await client.relationships.acceptRelationship("REL_________________");
console.log(acceptedRelationship);
}

Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/endpoints/AccountEndpoint.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { ConnectorResponse, ConnectorSyncInfo, IdentityInfo } from "../types";
import { ConnectorHttpResponse, ConnectorSyncInfo, IdentityInfo } from "../types";
import { Endpoint } from "./Endpoint";

export class AccountEndpoint extends Endpoint {
public async getIdentityInfo(): Promise<ConnectorResponse<IdentityInfo>> {
public async getIdentityInfo(): Promise<ConnectorHttpResponse<IdentityInfo>> {
return await this.get("/api/v2/Account/IdentityInfo");
}

public async sync(): Promise<ConnectorResponse<void>> {
public async sync(): Promise<ConnectorHttpResponse<void>> {
return await this.post("/api/v2/Account/Sync", undefined, 204);
}

public async getSyncInfo(): Promise<ConnectorResponse<ConnectorSyncInfo>> {
public async getSyncInfo(): Promise<ConnectorHttpResponse<ConnectorSyncInfo>> {
return await this.get("/api/v2/Account/SyncInfo");
}
}
Loading

0 comments on commit 1738600

Please sign in to comment.