From a6bbc9a029b3e2ff130f38abf03ffad901841356 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aaron=20D=C3=B6tsch?= <aaron@fsmpi.rwth-aachen.de>
Date: Sun, 6 Aug 2023 16:34:07 +0200
Subject: [PATCH] Refactor notification and channel types to TypeScript

---
 src/lib/notifications/notificationTypes.js    | 19 -------------------
 src/lib/notifications/notificationTypes.ts    | 11 +++++++++++
 .../{channelTypes.js => channelTypes.ts}      |  6 ------
 3 files changed, 11 insertions(+), 25 deletions(-)
 delete mode 100644 src/lib/notifications/notificationTypes.js
 create mode 100644 src/lib/notifications/notificationTypes.ts
 rename src/lib/server/notifications/{channelTypes.js => channelTypes.ts} (58%)

diff --git a/src/lib/notifications/notificationTypes.js b/src/lib/notifications/notificationTypes.js
deleted file mode 100644
index 399eab0..0000000
--- a/src/lib/notifications/notificationTypes.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/** @type {{
- * BUY: import("./types").NotificationType<"buy">,
- * REFUND: import("./types").NotificationType<"refund">,
- * DEPOSIT: import("./types").NotificationType<"deposit">,
- * WITHDRAW: import("./types").NotificationType<"withdraw">,
- * USE_VOUCHER: import("./types").NotificationType<"use-voucher">,
- * SEND_TRANSFER: import("./types").NotificationType<"send-transfer">,
- * RECEIVE_TRANSFER: import("./types").NotificationType<"receive-transfer">,
- * }}
- */
-export const NotificationType = {
-	BUY: {key: 1<<0, name: "buy"},
-	REFUND: {key: 1<<1, name: "refund"},
-	DEPOSIT: {key: 1<<2, name: "deposit"},
-	WITHDRAW: {key: 1<<3, name: "withdraw"},
-	USE_VOUCHER: {key: 1<<4, name: "use-voucher"},
-	SEND_TRANSFER: {key: 1<<5, name: "send-transfer"},
-	RECEIVE_TRANSFER: {key: 1<<6, name: "receive-transfer"},
-};
diff --git a/src/lib/notifications/notificationTypes.ts b/src/lib/notifications/notificationTypes.ts
new file mode 100644
index 0000000..56d95d9
--- /dev/null
+++ b/src/lib/notifications/notificationTypes.ts
@@ -0,0 +1,11 @@
+import type { NotificationType as Type } from "./types";
+
+export const NotificationType = {
+	BUY: {key: 1<<0, name: "buy"} as Type<"buy">,
+	REFUND: {key: 1<<1, name: "refund"} as Type<"refund">,
+	DEPOSIT: {key: 1<<2, name: "deposit"} as Type<"deposit">,
+	WITHDRAW: {key: 1<<3, name: "withdraw"} as Type<"withdraw">,
+	USE_VOUCHER: {key: 1<<4, name: "use-voucher"} as Type<"use-voucher">,
+	SEND_TRANSFER: {key: 1<<5, name: "send-transfer"} as Type<"send-transfer">,
+	RECEIVE_TRANSFER: {key: 1<<6, name: "receive-transfer"} as Type<"receive-transfer">,
+};
diff --git a/src/lib/server/notifications/channelTypes.js b/src/lib/server/notifications/channelTypes.ts
similarity index 58%
rename from src/lib/server/notifications/channelTypes.js
rename to src/lib/server/notifications/channelTypes.ts
index 90df94f..4b6c9bf 100644
--- a/src/lib/server/notifications/channelTypes.js
+++ b/src/lib/server/notifications/channelTypes.ts
@@ -1,12 +1,6 @@
 import { handleWebhook } from "./webhookHandler";
 import { handleEmail } from "./emailHandler";
 
-/**
- * @type {{
- *  WEBHOOK: import("../../notifications/types").ChannelType<?>,
- *  EMAIL: import("../../notifications/types").ChannelType<?>
- * }}
- */
 export const ChannelType = {
 	WEBHOOK: {key: 1<<0, handler: handleWebhook},
 	EMAIL: {key: 1<<1, handler: handleEmail},
-- 
GitLab