From dcbcb42acdf6aa5d1cedc8253c5dd23059e01465 Mon Sep 17 00:00:00 2001 From: Kirill Date: Mon, 18 May 2026 11:22:17 +0500 Subject: [PATCH] feat: add notification event type constants --- shared/constants/notification-events.d.ts | 34 +++++++++++++++++++++++ shared/constants/notification-events.js | 25 +++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 shared/constants/notification-events.d.ts create mode 100644 shared/constants/notification-events.js diff --git a/shared/constants/notification-events.d.ts b/shared/constants/notification-events.d.ts new file mode 100644 index 0000000..1eba015 --- /dev/null +++ b/shared/constants/notification-events.d.ts @@ -0,0 +1,34 @@ +export type NotificationEventType = + | 'order:created' + | 'order:statusChanged' + | 'orderMessage:sent' + | 'orderMessage:adminReply' + | 'payment:statusChanged' + | 'auth:codeRequested' + +export type NotificationChannel = 'email' | 'telegram' + +export type NotificationStatus = 'pending' | 'sent' | 'failed' + +export const NOTIFICATION_EVENTS: { + ORDER_CREATED: NotificationEventType + ORDER_STATUS_CHANGED: NotificationEventType + ORDER_MESSAGE_SENT: NotificationEventType + ORDER_MESSAGE_ADMIN_REPLY: NotificationEventType + PAYMENT_STATUS_CHANGED: NotificationEventType + AUTH_CODE_REQUESTED: NotificationEventType +} + +export const NOTIFICATION_CHANNELS: { + EMAIL: NotificationChannel + TELEGRAM: NotificationChannel +} + +export const NOTIFICATION_STATUSES: { + PENDING: NotificationStatus + SENT: NotificationStatus + FAILED: NotificationStatus +} + +export const MAX_RETRY_ATTEMPTS: number +export const RETRY_DELAYS_MS: number[] diff --git a/shared/constants/notification-events.js b/shared/constants/notification-events.js new file mode 100644 index 0000000..82d5578 --- /dev/null +++ b/shared/constants/notification-events.js @@ -0,0 +1,25 @@ +/** @typedef {'order:created' | 'order:statusChanged' | 'orderMessage:sent' | 'orderMessage:adminReply' | 'payment:statusChanged' | 'auth:codeRequested'} NotificationEventType */ + +export const NOTIFICATION_EVENTS = { + ORDER_CREATED: 'order:created', + ORDER_STATUS_CHANGED: 'order:statusChanged', + ORDER_MESSAGE_SENT: 'orderMessage:sent', + ORDER_MESSAGE_ADMIN_REPLY: 'orderMessage:adminReply', + PAYMENT_STATUS_CHANGED: 'payment:statusChanged', + AUTH_CODE_REQUESTED: 'auth:codeRequested', +} + +export const NOTIFICATION_CHANNELS = { + EMAIL: 'email', + TELEGRAM: 'telegram', +} + +export const NOTIFICATION_STATUSES = { + PENDING: 'pending', + SENT: 'sent', + FAILED: 'failed', +} + +export const MAX_RETRY_ATTEMPTS = 3 + +export const RETRY_DELAYS_MS = [5_000, 30_000, 120_000]