From 725ba86239c1c8a8c420fd9736161ae6003eafaa Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 1 May 2026 12:07:40 +1200 Subject: [PATCH] feat(notifications): add notifications schema and channel constants Adds the alerts collection used by the console channel, plus channel and provider type constants shared by the worker and adapters. --- app/config/collections/common.php | 126 ++++++++++++++++++++++++++++++ app/init/constants.php | 10 +++ 2 files changed, 136 insertions(+) diff --git a/app/config/collections/common.php b/app/config/collections/common.php index 80bb717423..aec4f393fc 100644 --- a/app/config/collections/common.php +++ b/app/config/collections/common.php @@ -1888,6 +1888,132 @@ return [ ], ], + 'alerts' => [ + '$collection' => ID::custom(Database::METADATA), + '$id' => ID::custom('alerts'), + 'name' => 'Alerts', + 'attributes' => [ + [ + '$id' => ID::custom('messageId'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('type'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 64, + 'signed' => true, + 'required' => false, + 'default' => 'info', + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('channel'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 64, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('userId'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('teamId'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('projectId'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('title'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 256, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('body'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ], + 'indexes' => [ + [ + '$id' => ID::custom('_key_messageId'), + 'type' => Database::INDEX_UNIQUE, + 'attributes' => ['messageId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_userId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['userId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_teamId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['teamId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_projectId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + ], + ], + 'messages' => [ '$collection' => ID::custom(DATABASE::METADATA), '$id' => ID::custom('messages'), diff --git a/app/init/constants.php b/app/init/constants.php index f27d0c7c70..d3bbdaef49 100644 --- a/app/init/constants.php +++ b/app/init/constants.php @@ -254,6 +254,16 @@ const FUNCTION_ALLOWLIST_HEADERS_RESPONSE = ['content-type', 'content-length']; const MESSAGE_TYPE_EMAIL = 'email'; const MESSAGE_TYPE_SMS = 'sms'; const MESSAGE_TYPE_PUSH = 'push'; +// Notification channels +const NOTIFICATION_CHANNEL_EMAIL = 'email'; +const NOTIFICATION_CHANNEL_SMS = 'sms'; +const NOTIFICATION_CHANNEL_PUSH = 'push'; +const NOTIFICATION_CHANNEL_CONSOLE = 'console'; +const NOTIFICATION_CHANNEL_WEBHOOK = 'webhook'; +// Notification provider types (custom — extend MESSAGE_TYPE_*) +const MESSAGE_TYPE_CONSOLE = 'console'; +const MESSAGE_TYPE_WEBHOOK = 'webhook'; +const RESOURCE_TYPE_ALERTS = 'alerts'; // API key types const API_KEY_STANDARD = 'standard'; const API_KEY_EPHEMERAL = 'ephemeral';