From 8e12be81754dd77e953272bd11318ff85a7115fa Mon Sep 17 00:00:00 2001
From: Konstantin Tsabolov <konstantin.tsabolov@spherity.com>
Date: Mon, 18 Dec 2023 16:02:55 +0100
Subject: [PATCH] feat(shared): add credential requests events

---
 .../src/events/credentialRequestEvents.ts     | 48 +++++++++++++++++++
 apps/shared/src/index.ts                      |  1 +
 2 files changed, 49 insertions(+)
 create mode 100644 apps/shared/src/events/credentialRequestEvents.ts

diff --git a/apps/shared/src/events/credentialRequestEvents.ts b/apps/shared/src/events/credentialRequestEvents.ts
new file mode 100644
index 0000000..213562f
--- /dev/null
+++ b/apps/shared/src/events/credentialRequestEvents.ts
@@ -0,0 +1,48 @@
+import type { BaseEventInput } from './baseEvents.js';
+import type { AnonCredsCredentialRequest } from '@aries-framework/anoncreds';
+
+import { BaseEvent } from './baseEvents.js';
+
+export type EventAnonCredsCredentialRequestGetAllInput = BaseEventInput;
+
+export class EventAnonCredsCredentialRequestGetAll extends BaseEvent<
+  Array<AnonCredsCredentialRequest>
+> {
+  public static token = 'anoncreds.credentialRequests.getAll';
+
+  public get instance() {
+    return this.data;
+  }
+
+  public static fromEvent(e: EventAnonCredsCredentialRequestGetAll) {
+    return new EventAnonCredsCredentialRequestGetAll(
+      e.data,
+      e.tenantId,
+      e.id,
+      e.type,
+      e.timestamp,
+    );
+  }
+}
+
+export type EventAnonCredsCredentialRequestGetByIdInput = BaseEventInput & {
+  credentialRequestId: string;
+};
+
+export class EventAnonCredsCredentialRequestGetById extends BaseEvent<AnonCredsCredentialRequest | null> {
+  public static token = 'anoncreds.credentialRequests.getById';
+
+  public get instance() {
+    return this.data;
+  }
+
+  public static fromEvent(e: EventAnonCredsCredentialRequestGetById) {
+    return new EventAnonCredsCredentialRequestGetById(
+      e.data,
+      e.tenantId,
+      e.id,
+      e.type,
+      e.timestamp,
+    );
+  }
+}
diff --git a/apps/shared/src/index.ts b/apps/shared/src/index.ts
index 7e5e282..20c9faf 100644
--- a/apps/shared/src/index.ts
+++ b/apps/shared/src/index.ts
@@ -11,6 +11,7 @@ export * from './events/schemaEvents.js';
 export * from './events/credentialDefinitionEvents.js';
 export * from './events/credentialEvents.js';
 export * from './events/credentialOfferEvents.js';
+export * from './events/credentialRequestEvents.js';
 
 export * from './dto/pagination-params.dto.js';
 export * from './dto/multitenancy-params.dto.js';
-- 
GitLab