From b72698ccf1ef768dd366dfbb0ea7dad00d5b275f Mon Sep 17 00:00:00 2001
From: Berend Sliedrecht <berend@animo.id>
Date: Mon, 27 Nov 2023 13:26:53 +0100
Subject: [PATCH] feat(ssi): use the new event structure in the ssi-abstraction

Signed-off-by: Berend Sliedrecht <berend@animo.id>
---
 .../__tests__/connections.controller.spec.ts       |  4 +++-
 .../agent/connections/connections.controller.ts    |  7 +++++--
 apps/ssi-abstraction/test/connections.e2e-spec.ts  |  5 +++--
 pnpm-lock.yaml                                     | 14 +++++++-------
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/apps/ssi-abstraction/src/agent/connections/__tests__/connections.controller.spec.ts b/apps/ssi-abstraction/src/agent/connections/__tests__/connections.controller.spec.ts
index f516874..91d7dc8 100644
--- a/apps/ssi-abstraction/src/agent/connections/__tests__/connections.controller.spec.ts
+++ b/apps/ssi-abstraction/src/agent/connections/__tests__/connections.controller.spec.ts
@@ -29,7 +29,9 @@ describe('ConnectionsController', () => {
         .spyOn(connectionsService, 'getAll')
         .mockImplementation(() => Promise.resolve(result));
 
-      expect(await connectionsController.getAll()).toBe(result);
+      const connectionsEvent = await connectionsController.getAll();
+
+      expect(connectionsEvent.data).toStrictEqual({ connections: result });
     });
   });
 });
diff --git a/apps/ssi-abstraction/src/agent/connections/connections.controller.ts b/apps/ssi-abstraction/src/agent/connections/connections.controller.ts
index c2aa973..f9637e3 100644
--- a/apps/ssi-abstraction/src/agent/connections/connections.controller.ts
+++ b/apps/ssi-abstraction/src/agent/connections/connections.controller.ts
@@ -1,5 +1,6 @@
 import { Controller } from '@nestjs/common';
 import { MessagePattern } from '@nestjs/microservices';
+import { EventDidcommConnectionsGetAll } from '@ocm/shared';
 
 import { ConnectionsService } from './connections.service.js';
 
@@ -8,7 +9,9 @@ export class ConnectionsController {
   public constructor(private connectionsService: ConnectionsService) {}
 
   @MessagePattern('didcomm.connections.getAll')
-  public async getAll() {
-    return await this.connectionsService.getAll();
+  public async getAll(): Promise<EventDidcommConnectionsGetAll> {
+    return new EventDidcommConnectionsGetAll({
+      connections: await this.connectionsService.getAll(),
+    });
   }
 }
diff --git a/apps/ssi-abstraction/test/connections.e2e-spec.ts b/apps/ssi-abstraction/test/connections.e2e-spec.ts
index d749062..75e7762 100644
--- a/apps/ssi-abstraction/test/connections.e2e-spec.ts
+++ b/apps/ssi-abstraction/test/connections.e2e-spec.ts
@@ -1,5 +1,6 @@
 import type { INestApplication } from '@nestjs/common';
 import type { ClientProxy } from '@nestjs/microservices';
+import type { EventDidcommConnectionsGetAll } from '@ocm/shared';
 
 import { ClientsModule, Transport } from '@nestjs/microservices';
 import { Test } from '@nestjs/testing';
@@ -36,12 +37,12 @@ describe('Connections', () => {
   });
 
   it('didcomm.connections.getAll', async () => {
-    const response$: Observable<unknown> = client.send(
+    const response$: Observable<EventDidcommConnectionsGetAll> = client.send(
       'didcomm.connections.getAll',
       {},
     );
     const response = await firstValueFrom(response$);
-    expect(response).toMatchObject([]);
+    expect(response.data).toMatchObject({ connections: [] });
   });
 
   afterAll(async () => {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index c3d6966..24b76e3 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -36,8 +36,8 @@ importers:
         specifier: ^5.0.1
         version: 5.0.1(eslint-config-prettier@9.0.0)(eslint@8.54.0)(prettier@3.1.0)
       eslint-plugin-workspaces:
-        specifier: ^0.9.0
-        version: 0.9.0
+        specifier: ^0.10.0
+        version: 0.10.0
       husky:
         specifier: ^8.0.0
         version: 8.0.3
@@ -7869,10 +7869,10 @@ packages:
       synckit: 0.8.5
     dev: true
 
-  /eslint-plugin-workspaces@0.9.0:
-    resolution: {integrity: sha512-krMuZ+yZgzwv1oTBfz50oamNVPDIm7CDyot3i1GRKBqMD2oXAwnXHLQWH7ctpV8k6YVrkhcaZhuV9IJxD8OPAQ==}
+  /eslint-plugin-workspaces@0.10.0:
+    resolution: {integrity: sha512-H692yRZFczzzyde0Sq3nmRDlyywv6foYJnmsxO3slWImJdCf4g5D+gzdWeRpmfitgUsFZxXVJdvW4OS6yY4M9g==}
     dependencies:
-      find-workspaces: 0.2.0
+      find-workspaces: 0.3.0
     dev: true
 
   /eslint-scope@5.1.1:
@@ -8608,8 +8608,8 @@ packages:
       semver-regex: 4.0.5
     dev: true
 
-  /find-workspaces@0.2.0:
-    resolution: {integrity: sha512-OTHryv88yjzwvbXHGi0+XRFu7Jqe5pFuIR2mhqdatDJQOBJd7MFJOPFJv4EbNo8n1BNM/13Y2KcyDpFQYf0ETw==}
+  /find-workspaces@0.3.0:
+    resolution: {integrity: sha512-sHdt3vbddcDuN0CYnKoG/b77jrOkSYPlxoM7ve7/vEvAd29XC7u/qE2zavRzJv4eD1sbTvDnRNZskdy/e0v83A==}
     dependencies:
       fast-glob: 3.3.2
       pkg-types: 1.0.3
-- 
GitLab