diff --git a/backend/pkg/api/handlers/public.go b/backend/pkg/api/handlers/public.go index a628bf26c..b20bad3e7 100644 --- a/backend/pkg/api/handlers/public.go +++ b/backend/pkg/api/handlers/public.go @@ -27,12 +27,12 @@ import ( // @BasePath /api/v2 -// @securitydefinitions.apikey ApiKeyInHeader +// @securityDefinitions.apikey ApiKeyInHeader // @in header // @name Authorization // @description Use your API key as a Bearer token, e.g. `Bearer ` -// @securitydefinitions.apikey ApiKeyInQuery +// @securityDefinitions.apikey ApiKeyInQuery // @in query // @name api_key @@ -757,7 +757,7 @@ func (h *HandlerService) PublicDeleteValidatorDashboardValidators(w http.Respons // PublicPostValidatorDashboardPublicIds godoc // -// @Description Create a new public ID for a specified dashboard. This can be used as an ID by other users for non-modyfing (i.e. GET) endpoints only. Currently limited to one per dashboard. +// @Description Create a new public ID for a specified dashboard. This can be used as an ID by other users for non-modifying (i.e. GET) endpoints only. Currently limited to one per dashboard. // @Security ApiKeyInHeader || ApiKeyInQuery // @Tags Validator Dashboard Management // @Accept json @@ -1877,7 +1877,7 @@ func (h *HandlerService) PublicGetValidatorDashboardRocketPoolMinipools(w http.R // @Security ApiKeyInHeader || ApiKeyInQuery // @Tags Notifications // @Produce json -// @Success 200 {object} types.InternalGetUserNotificationsResponse +// @Success 200 {object} types.GetUserNotificationsResponse // @Router /users/me/notifications [get] func (h *HandlerService) PublicGetUserNotifications(w http.ResponseWriter, r *http.Request) { userId, err := GetUserIdByContext(r) @@ -1890,7 +1890,7 @@ func (h *HandlerService) PublicGetUserNotifications(w http.ResponseWriter, r *ht handleErr(w, r, err) return } - response := types.InternalGetUserNotificationsResponse{ + response := types.GetUserNotificationsResponse{ Data: *data, } returnOk(w, r, response) @@ -1907,7 +1907,7 @@ func (h *HandlerService) PublicGetUserNotifications(w http.ResponseWriter, r *ht // @Param limit query integer false "The maximum number of results that may be returned." // @Param sort query string false "The field you want to sort by. Append with `:desc` for descending order." " Enums(chain_id, timestamp, dashboard_id) // @Param search query string false "Search for Dashboard, Group" -// @Success 200 {object} types.InternalGetUserNotificationDashboardsResponse +// @Success 200 {object} types.GetUserNotificationDashboardsResponse // @Failure 400 {object} types.ApiErrorResponse // @Router /users/me/notifications/dashboards [get] func (h *HandlerService) PublicGetUserNotificationDashboards(w http.ResponseWriter, r *http.Request) { @@ -1932,7 +1932,7 @@ func (h *HandlerService) PublicGetUserNotificationDashboards(w http.ResponseWrit return } mapDashboardNotificationEvents(data) - response := types.InternalGetUserNotificationDashboardsResponse{ + response := types.GetUserNotificationDashboardsResponse{ Data: data, Paging: *paging, } @@ -1949,7 +1949,7 @@ func (h *HandlerService) PublicGetUserNotificationDashboards(w http.ResponseWrit // @Param group_id path integer true "The ID of the group." // @Param epoch path integer true "The epoch of the notification." // @Param search query string false "Search for Index" -// @Success 200 {object} types.InternalGetUserNotificationsValidatorDashboardResponse +// @Success 200 {object} types.GetUserNotificationsValidatorDashboardResponse // @Failure 400 {object} types.ApiErrorResponse // @Router /users/me/notifications/validator-dashboards/{dashboard_id}/groups/{group_id}/epochs/{epoch} [get] func (h *HandlerService) PublicGetUserNotificationsValidatorDashboard(w http.ResponseWriter, r *http.Request) { @@ -1968,7 +1968,7 @@ func (h *HandlerService) PublicGetUserNotificationsValidatorDashboard(w http.Res handleErr(w, r, err) return } - response := types.InternalGetUserNotificationsValidatorDashboardResponse{ + response := types.GetUserNotificationsValidatorDashboardResponse{ Data: *data, } returnOk(w, r, response) @@ -1984,7 +1984,7 @@ func (h *HandlerService) PublicGetUserNotificationsValidatorDashboard(w http.Res // @Param group_id path integer true "The ID of the group." // @Param epoch path integer true "The epoch of the notification." // @Param search query string false "Search for Address, ENS" -// @Success 200 {object} types.InternalGetUserNotificationsAccountDashboardResponse +// @Success 200 {object} types.GetUserNotificationsAccountDashboardResponse // @Failure 400 {object} types.ApiErrorResponse // @Router /users/me/notifications/account-dashboards/{dashboard_id}/groups/{group_id}/epochs/{epoch} [get] func (h *HandlerService) PublicGetUserNotificationsAccountDashboard(w http.ResponseWriter, r *http.Request) { @@ -2003,7 +2003,7 @@ func (h *HandlerService) PublicGetUserNotificationsAccountDashboard(w http.Respo handleErr(w, r, err) return } - response := types.InternalGetUserNotificationsAccountDashboardResponse{ + response := types.GetUserNotificationsAccountDashboardResponse{ Data: *data, } returnOk(w, r, response) @@ -2019,7 +2019,7 @@ func (h *HandlerService) PublicGetUserNotificationsAccountDashboard(w http.Respo // @Param limit query integer false "The maximum number of results that may be returned." // @Param sort query string false "The field you want to sort by. Append with `:desc` for descending order." Enums(machine_name, threshold, event_type, timestamp) // @Param search query string false "Search for Machine" -// @Success 200 {object} types.InternalGetUserNotificationMachinesResponse +// @Success 200 {object} types.GetUserNotificationMachinesResponse // @Failure 400 {object} types.ApiErrorResponse // @Router /users/me/notifications/machines [get] func (h *HandlerService) PublicGetUserNotificationMachines(w http.ResponseWriter, r *http.Request) { @@ -2042,7 +2042,7 @@ func (h *HandlerService) PublicGetUserNotificationMachines(w http.ResponseWriter return } mapMachineNotificationEventNames(data) - response := types.InternalGetUserNotificationMachinesResponse{ + response := types.GetUserNotificationMachinesResponse{ Data: data, Paging: *paging, } @@ -2059,7 +2059,7 @@ func (h *HandlerService) PublicGetUserNotificationMachines(w http.ResponseWriter // @Param limit query integer false "The maximum number of results that may be returned." // @Param sort query string false "The field you want to sort by. Append with `:desc` for descending order." Enums(client_name, timestamp) // @Param search query string false "Search for Client" -// @Success 200 {object} types.InternalGetUserNotificationClientsResponse +// @Success 200 {object} types.GetUserNotificationClientsResponse // @Failure 400 {object} types.ApiErrorResponse // @Router /users/me/notifications/clients [get] func (h *HandlerService) PublicGetUserNotificationClients(w http.ResponseWriter, r *http.Request) { @@ -2081,7 +2081,7 @@ func (h *HandlerService) PublicGetUserNotificationClients(w http.ResponseWriter, handleErr(w, r, err) return } - response := types.InternalGetUserNotificationClientsResponse{ + response := types.GetUserNotificationClientsResponse{ Data: data, Paging: *paging, } @@ -2097,7 +2097,7 @@ func (h *HandlerService) PublicGetUserNotificationClients(w http.ResponseWriter, // @Param cursor query string false "Return data for the given cursor value. Pass the `paging.next_cursor`` value of the previous response to navigate to forward, or pass the `paging.prev_cursor`` value of the previous response to navigate to backward." // @Param limit query integer false "The maximum number of results that may be returned." // @Param sort query string false "The field you want to sort by. Append with `:desc` for descending order." Enums(timestamp, event_type) -// @Success 200 {object} types.InternalGetUserNotificationNetworksResponse +// @Success 200 {object} types.GetUserNotificationNetworksResponse // @Failure 400 {object} types.ApiErrorResponse // @Router /users/me/notifications/networks [get] func (h *HandlerService) PublicGetUserNotificationNetworks(w http.ResponseWriter, r *http.Request) { @@ -2120,7 +2120,7 @@ func (h *HandlerService) PublicGetUserNotificationNetworks(w http.ResponseWriter return } mapNetworkNotificationEventNames(data) - response := types.InternalGetUserNotificationNetworksResponse{ + response := types.GetUserNotificationNetworksResponse{ Data: data, Paging: *paging, } @@ -2135,7 +2135,7 @@ const diffTolerance = 0.0001 // @Security ApiKeyInHeader || ApiKeyInQuery // @Tags Notification Settings // @Produce json -// @Success 200 {object} types.InternalGetUserNotificationSettingsResponse +// @Success 200 {object} types.GetUserNotificationSettingsResponse // @Router /users/me/notifications/settings [get] func (h *HandlerService) PublicGetUserNotificationSettings(w http.ResponseWriter, r *http.Request) { userId, err := GetUserIdByContext(r) @@ -2180,7 +2180,7 @@ func (h *HandlerService) PublicGetUserNotificationSettings(w http.ResponseWriter data.GeneralSettings = userGeneralSettings } - response := types.InternalGetUserNotificationSettingsResponse{ + response := types.GetUserNotificationSettingsResponse{ Data: *data, } returnOk(w, r, response) @@ -2194,7 +2194,7 @@ func (h *HandlerService) PublicGetUserNotificationSettings(w http.ResponseWriter // @Accept json // @Produce json // @Param request body types.NotificationSettingsGeneral true "Description TODO" -// @Success 200 {object} types.InternalPutUserNotificationSettingsGeneralResponse +// @Success 200 {object} types.PutUserNotificationSettingsGeneralResponse // @Failure 400 {object} types.ApiErrorResponse // @Router /users/me/notifications/settings/general [put] func (h *HandlerService) PublicPutUserNotificationSettingsGeneral(w http.ResponseWriter, r *http.Request) { @@ -2230,7 +2230,7 @@ func (h *HandlerService) PublicPutUserNotificationSettingsGeneral(w http.Respons return } - // use tolarance for float comparison + // use tolerance for float comparison isCustomThresholdUsed := math.Abs(req.MachineStorageUsageThreshold-defaultSettings.MachineStorageUsageThreshold) > diffTolerance || math.Abs(req.MachineCpuUsageThreshold-defaultSettings.MachineCpuUsageThreshold) > diffTolerance || math.Abs(req.MachineMemoryUsageThreshold-defaultSettings.MachineMemoryUsageThreshold) > diffTolerance @@ -2245,7 +2245,7 @@ func (h *HandlerService) PublicPutUserNotificationSettingsGeneral(w http.Respons handleErr(w, r, err) return } - response := types.InternalPutUserNotificationSettingsGeneralResponse{ + response := types.PutUserNotificationSettingsGeneralResponse{ Data: req, } returnOk(w, r, response) @@ -2260,7 +2260,7 @@ func (h *HandlerService) PublicPutUserNotificationSettingsGeneral(w http.Respons // @Produce json // @Param network path string true "The networks name or chain ID." // @Param request body handlers.PublicPutUserNotificationSettingsNetworks.request true "Description Todo" -// @Success 200 {object} types.InternalPutUserNotificationSettingsNetworksResponse +// @Success 200 {object} types.PutUserNotificationSettingsNetworksResponse // @Failure 400 {object} types.ApiErrorResponse // @Router /users/me/notifications/settings/networks/{network} [put] func (h *HandlerService) PublicPutUserNotificationSettingsNetworks(w http.ResponseWriter, r *http.Request) { @@ -2310,7 +2310,7 @@ func (h *HandlerService) PublicPutUserNotificationSettingsNetworks(w http.Respon handleErr(w, r, err) return } - response := types.InternalPutUserNotificationSettingsNetworksResponse{ + response := types.PutUserNotificationSettingsNetworksResponse{ Data: types.NotificationNetwork{ ChainId: chainId, Settings: settings, @@ -2328,7 +2328,7 @@ func (h *HandlerService) PublicPutUserNotificationSettingsNetworks(w http.Respon // @Produce json // @Param paired_device_id path string true "The paired device ID." // @Param request body handlers.PublicPutUserNotificationSettingsPairedDevices.request true "Description TODO" -// @Success 200 {object} types.InternalPutUserNotificationSettingsPairedDevicesResponse +// @Success 200 {object} types.PutUserNotificationSettingsPairedDevicesResponse // @Failure 400 {object} types.ApiErrorResponse // @Router /users/me/notifications/settings/paired-devices/{paired_device_id} [put] func (h *HandlerService) PublicPutUserNotificationSettingsPairedDevices(w http.ResponseWriter, r *http.Request) { @@ -2369,7 +2369,7 @@ func (h *HandlerService) PublicPutUserNotificationSettingsPairedDevices(w http.R return } // TODO timestamp - response := types.InternalPutUserNotificationSettingsPairedDevicesResponse{ + response := types.PutUserNotificationSettingsPairedDevicesResponse{ Data: types.NotificationPairedDevice{ Id: pairedDeviceId, Name: req.Name, @@ -2428,7 +2428,7 @@ func (h *HandlerService) PublicDeleteUserNotificationSettingsPairedDevices(w htt // @Produce json // @Param client_id path integer true "The ID of the client." // @Param request body handlers.PublicPutUserNotificationSettingsClient.request true "`is_subscribed`: Set to `true` to subscribe to notifications; set to `false` to unsubscribe." -// @Success 200 {object} types.InternalPutUserNotificationSettingsClientResponse +// @Success 200 {object} types.PutUserNotificationSettingsClientResponse // @Failure 400 {object} types.ApiErrorResponse // @Router /users/me/notifications/settings/clients/{client_id} [put] func (h *HandlerService) PublicPutUserNotificationSettingsClient(w http.ResponseWriter, r *http.Request) { @@ -2456,7 +2456,7 @@ func (h *HandlerService) PublicPutUserNotificationSettingsClient(w http.Response handleErr(w, r, err) return } - response := types.InternalPutUserNotificationSettingsClientResponse{ + response := types.PutUserNotificationSettingsClientResponse{ Data: *data, } returnOk(w, r, response) @@ -2472,7 +2472,7 @@ func (h *HandlerService) PublicPutUserNotificationSettingsClient(w http.Response // @Param limit query integer false "The maximum number of results that may be returned." // @Param sort query string false "The field you want to sort by. Append with `:desc` for descending order." Enums (dashboard_id, group_name) // @Param search query string false "Search for Dashboard, Group" -// @Success 200 {object} types.InternalGetUserNotificationSettingsDashboardsResponse +// @Success 200 {object} types.GetUserNotificationSettingsDashboardsResponse // @Failure 400 {object} types.ApiErrorResponse // @Router /users/me/notifications/settings/dashboards [get] func (h *HandlerService) PublicGetUserNotificationSettingsDashboards(w http.ResponseWriter, r *http.Request) { @@ -2521,7 +2521,7 @@ func (h *HandlerService) PublicGetUserNotificationSettingsDashboards(w http.Resp } data[i].Settings = settings } - response := types.InternalGetUserNotificationSettingsDashboardsResponse{ + response := types.GetUserNotificationSettingsDashboardsResponse{ Data: data, Paging: *paging, } @@ -2538,7 +2538,7 @@ func (h *HandlerService) PublicGetUserNotificationSettingsDashboards(w http.Resp // @Param dashboard_id path string true "The ID of the dashboard." // @Param group_id path integer true "The ID of the group." // @Param request body types.NotificationSettingsValidatorDashboard true "Notification settings" -// @Success 200 {object} types.InternalPutUserNotificationSettingsValidatorDashboardResponse +// @Success 200 {object} types.PutUserNotificationSettingsValidatorDashboardResponse // @Failure 400 {object} types.ApiErrorResponse // @Router /users/me/notifications/settings/validator-dashboards/{dashboard_id}/groups/{group_id} [put] func (h *HandlerService) PublicPutUserNotificationSettingsValidatorDashboard(w http.ResponseWriter, r *http.Request) { @@ -2580,7 +2580,7 @@ func (h *HandlerService) PublicPutUserNotificationSettingsValidatorDashboard(w h handleErr(w, r, err) return } - response := types.InternalPutUserNotificationSettingsValidatorDashboardResponse{ + response := types.PutUserNotificationSettingsValidatorDashboardResponse{ Data: req, } returnOk(w, r, response) @@ -2596,7 +2596,7 @@ func (h *HandlerService) PublicPutUserNotificationSettingsValidatorDashboard(w h // @Param dashboard_id path string true "The ID of the dashboard." // @Param group_id path integer true "The ID of the group." // @Param request body handlers.PublicPutUserNotificationSettingsAccountDashboard.request true "Notification settings" -// @Success 200 {object} types.InternalPutUserNotificationSettingsAccountDashboardResponse +// @Success 200 {object} types.PutUserNotificationSettingsAccountDashboardResponse // @Failure 400 {object} types.ApiErrorResponse // @Router /users/me/notifications/settings/account-dashboards/{dashboard_id}/groups/{group_id} [put] func (h *HandlerService) PublicPutUserNotificationSettingsAccountDashboard(w http.ResponseWriter, r *http.Request) { @@ -2653,7 +2653,7 @@ func (h *HandlerService) PublicPutUserNotificationSettingsAccountDashboard(w htt handleErr(w, r, err) return } - response := types.InternalPutUserNotificationSettingsAccountDashboardResponse{ + response := types.PutUserNotificationSettingsAccountDashboardResponse{ Data: settings, } returnOk(w, r, response) diff --git a/backend/pkg/api/types/notifications.go b/backend/pkg/api/types/notifications.go index 23a3ea0e9..9e38715c1 100644 --- a/backend/pkg/api/types/notifications.go +++ b/backend/pkg/api/types/notifications.go @@ -27,8 +27,7 @@ type NotificationOverviewData struct { ClientsSubscriptionCount uint64 `db:"clients_subscription_count" json:"clients_subscription_count"` NetworksSubscriptionCount uint64 `db:"networks_subscription_count" json:"networks_subscription_count"` } - -type InternalGetUserNotificationsResponse ApiDataResponse[NotificationOverviewData] +type GetUserNotificationsResponse ApiDataResponse[NotificationOverviewData] // ------------------------------------------------------------ // Dashboards Table @@ -43,8 +42,7 @@ type NotificationDashboardsTableRow struct { EntityCount uint64 `db:"entity_count" json:"entity_count"` EventTypes pq.StringArray `db:"event_types" json:"event_types" tstype:"('validator_online' | 'validator_offline' | 'group_efficiency_below' | 'attestation_missed' | 'proposal_success' | 'proposal_missed' | 'proposal_upcoming' | 'max_collateral' | 'min_collateral' | 'sync' | 'withdrawal' | 'validator_got_slashed' | 'validator_has_slashed' | 'incoming_tx' | 'outgoing_tx' | 'transfer_erc20' | 'transfer_erc721' | 'transfer_erc1155')[]" faker:"slice_len=2, oneof: validator_online, validator_offline, group_efficiency_below, attestation_missed, proposal_success, proposal_missed, proposal_upcoming, max_collateral, min_collateral, sync, withdrawal, validator_got_slashed, validator_has_slashed, incoming_tx, outgoing_tx, transfer_erc20, transfer_erc721, transfer_erc1155"` } - -type InternalGetUserNotificationDashboardsResponse ApiPagingResponse[NotificationDashboardsTableRow] +type GetUserNotificationDashboardsResponse ApiPagingResponse[NotificationDashboardsTableRow] // ------------------------------------------------------------ // Validator Dashboard Notification Detail @@ -53,13 +51,11 @@ type NotificationEventValidatorBackOnline struct { Index uint64 `json:"index"` EpochCount uint64 `json:"epoch_count"` } - type NotificationEventWithdrawal struct { Index uint64 `json:"index"` Amount decimal.Decimal `json:"amount"` Address Address `json:"address"` } - type NotificationValidatorDashboardDetail struct { DashboardName string `db:"dashboard_name" json:"dashboard_name"` GroupName string `db:"group_name" json:"group_name"` @@ -77,8 +73,7 @@ type NotificationValidatorDashboardDetail struct { MinCollateral []Address `json:"min_collateral"` // node addresses MaxCollateral []Address `json:"max_collateral"` // node addresses } - -type InternalGetUserNotificationsValidatorDashboardResponse ApiDataResponse[NotificationValidatorDashboardDetail] +type GetUserNotificationsValidatorDashboardResponse ApiDataResponse[NotificationValidatorDashboardDetail] type NotificationEventExecution struct { Address Address `json:"address"` @@ -86,7 +81,6 @@ type NotificationEventExecution struct { TransactionHash Hash `json:"transaction_hash"` TokenName string `json:"token_name"` // this field will prob change depending on how execution stuff is implemented } - type NotificationAccountDashboardDetail struct { IncomingTransactions []NotificationEventExecution `json:"incoming_transactions"` OutgoingTransactions []NotificationEventExecution `json:"outgoing_transactions"` @@ -94,8 +88,7 @@ type NotificationAccountDashboardDetail struct { ERC721TokenTransfers []NotificationEventExecution `json:"erc721_token_transfers"` ERC1155TokenTransfers []NotificationEventExecution `json:"erc1155_token_transfers"` } - -type InternalGetUserNotificationsAccountDashboardResponse ApiDataResponse[NotificationAccountDashboardDetail] +type GetUserNotificationsAccountDashboardResponse ApiDataResponse[NotificationAccountDashboardDetail] // ------------------------------------------------------------ // Machines Table @@ -105,8 +98,7 @@ type NotificationMachinesTableRow struct { EventType string `json:"event_type" tstype:"'offline' | 'storage' | 'cpu' | 'memory'" faker:"oneof: offline, storage, cpu, memory"` Timestamp int64 `json:"timestamp"` } - -type InternalGetUserNotificationMachinesResponse ApiPagingResponse[NotificationMachinesTableRow] +type GetUserNotificationMachinesResponse ApiPagingResponse[NotificationMachinesTableRow] // ------------------------------------------------------------ // Clients Table @@ -116,8 +108,7 @@ type NotificationClientsTableRow struct { Url string `json:"url"` Timestamp int64 `json:"timestamp"` } - -type InternalGetUserNotificationClientsResponse ApiPagingResponse[NotificationClientsTableRow] +type GetUserNotificationClientsResponse ApiPagingResponse[NotificationClientsTableRow] // ------------------------------------------------------------ // Networks Table @@ -127,8 +118,7 @@ type NotificationNetworksTableRow struct { EventType string `json:"event_type" tstype:"'new_reward_round' | 'gas_above' | 'gas_below' | 'participation_rate'" faker:"oneof: new_reward_round, gas_above, gas_below, participation_rate"` Threshold decimal.Decimal `json:"threshold,omitempty"` // participation rate threshold should also be passed as decimal string } - -type InternalGetUserNotificationNetworksResponse ApiPagingResponse[NotificationNetworksTableRow] +type GetUserNotificationNetworksResponse ApiPagingResponse[NotificationNetworksTableRow] // ------------------------------------------------------------ // Notification Settings @@ -145,7 +135,7 @@ type NotificationNetwork struct { ChainId uint64 `json:"chain_id"` Settings NotificationSettingsNetwork `json:"settings"` } -type InternalPutUserNotificationSettingsNetworksResponse ApiDataResponse[NotificationNetwork] +type PutUserNotificationSettingsNetworksResponse ApiDataResponse[NotificationNetwork] type NotificationPairedDevice struct { Id uint64 `json:"id"` @@ -153,7 +143,7 @@ type NotificationPairedDevice struct { Name string `json:"name,omitempty"` IsNotificationsEnabled bool `json:"is_notifications_enabled"` } -type InternalPutUserNotificationSettingsPairedDevicesResponse ApiDataResponse[NotificationPairedDevice] +type PutUserNotificationSettingsPairedDevicesResponse ApiDataResponse[NotificationPairedDevice] type NotificationSettingsClient struct { Id uint64 `json:"id"` @@ -161,8 +151,7 @@ type NotificationSettingsClient struct { Category string `json:"category" tstype:"'execution_layer' | 'consensus_layer' | 'other'" faker:"oneof: execution_layer, consensus_layer, other"` IsSubscribed bool `json:"is_subscribed"` } - -type InternalPutUserNotificationSettingsClientResponse ApiDataResponse[NotificationSettingsClient] +type PutUserNotificationSettingsClientResponse ApiDataResponse[NotificationSettingsClient] type NotificationSettingsGeneral struct { DoNotDisturbTimestamp int64 `json:"do_not_disturb_timestamp"` // notifications are disabled until this timestamp @@ -178,7 +167,8 @@ type NotificationSettingsGeneral struct { IsMachineMemoryUsageSubscribed bool `json:"is_machine_memory_usage_subscribed"` MachineMemoryUsageThreshold float64 `json:"machine_memory_usage_threshold" faker:"boundary_start=0, boundary_end=1"` } -type InternalPutUserNotificationSettingsGeneralResponse ApiDataResponse[NotificationSettingsGeneral] +type PutUserNotificationSettingsGeneralResponse ApiDataResponse[NotificationSettingsGeneral] + type NotificationSettings struct { GeneralSettings NotificationSettingsGeneral `json:"general_settings"` HasMachines bool `json:"has_machines"` @@ -186,7 +176,7 @@ type NotificationSettings struct { PairedDevices []NotificationPairedDevice `json:"paired_devices"` Clients []NotificationSettingsClient `json:"clients" faker:"slice_len=10"` } -type InternalGetUserNotificationSettingsResponse ApiDataResponse[NotificationSettings] +type GetUserNotificationSettingsResponse ApiDataResponse[NotificationSettings] type NotificationSettingsValidatorDashboard struct { WebhookUrl string `json:"webhook_url" faker:"url"` @@ -207,8 +197,7 @@ type NotificationSettingsValidatorDashboard struct { IsMinCollateralSubscribed bool `json:"is_min_collateral_subscribed"` MinCollateralThreshold float64 `json:"min_collateral_threshold" faker:"boundary_start=0, boundary_end=1"` } - -type InternalPutUserNotificationSettingsValidatorDashboardResponse ApiDataResponse[NotificationSettingsValidatorDashboard] +type PutUserNotificationSettingsValidatorDashboardResponse ApiDataResponse[NotificationSettingsValidatorDashboard] type NotificationSettingsAccountDashboard struct { WebhookUrl string `json:"webhook_url" faker:"url"` @@ -223,7 +212,7 @@ type NotificationSettingsAccountDashboard struct { IsERC721TokenTransfersSubscribed bool `json:"is_erc721_token_transfers_subscribed"` IsERC1155TokenTransfersSubscribed bool `json:"is_erc1155_token_transfers_subscribed"` } -type InternalPutUserNotificationSettingsAccountDashboardResponse ApiDataResponse[NotificationSettingsAccountDashboard] +type PutUserNotificationSettingsAccountDashboardResponse ApiDataResponse[NotificationSettingsAccountDashboard] type NotificationSettingsDashboardsTableRow struct { IsAccountDashboard bool `json:"is_account_dashboard"` // if false it's a validator dashboard @@ -235,5 +224,4 @@ type NotificationSettingsDashboardsTableRow struct { Settings interface{} `json:"settings" tstype:"NotificationSettingsAccountDashboard | NotificationSettingsValidatorDashboard" faker:"-"` ChainIds []uint64 `json:"chain_ids" faker:"chain_ids"` } - -type InternalGetUserNotificationSettingsDashboardsResponse ApiPagingResponse[NotificationSettingsDashboardsTableRow] +type GetUserNotificationSettingsDashboardsResponse ApiPagingResponse[NotificationSettingsDashboardsTableRow] diff --git a/frontend/composables/notifications/useNotificationsManagementDashboards.ts b/frontend/composables/notifications/useNotificationsManagementDashboards.ts index ddb245d64..1b4d85399 100644 --- a/frontend/composables/notifications/useNotificationsManagementDashboards.ts +++ b/frontend/composables/notifications/useNotificationsManagementDashboards.ts @@ -1,18 +1,18 @@ import type { TableQueryParams } from '~/types/datatable' import type { - InternalGetUserNotificationSettingsDashboardsResponse, - InternalPutUserNotificationSettingsAccountDashboardResponse, - InternalPutUserNotificationSettingsValidatorDashboardResponse, + GetUserNotificationSettingsDashboardsResponse, NotificationSettingsAccountDashboard, NotificationSettingsDashboardsTableRow, NotificationSettingsValidatorDashboard, + PutUserNotificationSettingsAccountDashboardResponse, + PutUserNotificationSettingsValidatorDashboardResponse, } from '~/types/api/notifications' export function useNotificationsManagementDashboards() { const { fetch } = useCustomFetch() const { refreshOverview } = useNotificationsDashboardOverviewStore() - const data = ref() + const data = ref() const { cursor, isStoredQuery, @@ -36,7 +36,7 @@ export function useNotificationsManagementDashboards() { isLoading.value = true setStoredQuery(q) const res - = await fetch( + = await fetch( 'GET_NOTIFICATIONS_SETTINGS_DASHBOARD', undefined, undefined, @@ -72,30 +72,30 @@ export function useNotificationsManagementDashboards() { settings.webhook_url = '' settings.is_webhook_discord_enabled = false if (is_account_dashboard) { - const accountDashboarSettings = settings as NotificationSettingsAccountDashboard - accountDashboarSettings.erc20_token_transfers_value_threshold = 0 - accountDashboarSettings.is_erc1155_token_transfers_subscribed = false - accountDashboarSettings.is_erc20_token_transfers_subscribed = false - accountDashboarSettings.is_erc721_token_transfers_subscribed = false - accountDashboarSettings.is_ignore_spam_transactions_enabled = false - accountDashboarSettings.is_incoming_transactions_subscribed = false - accountDashboarSettings.is_outgoing_transactions_subscribed = false + const accountDashboardSettings = settings as NotificationSettingsAccountDashboard + accountDashboardSettings.erc20_token_transfers_value_threshold = 0 + accountDashboardSettings.is_erc1155_token_transfers_subscribed = false + accountDashboardSettings.is_erc20_token_transfers_subscribed = false + accountDashboardSettings.is_erc721_token_transfers_subscribed = false + accountDashboardSettings.is_ignore_spam_transactions_enabled = false + accountDashboardSettings.is_incoming_transactions_subscribed = false + accountDashboardSettings.is_outgoing_transactions_subscribed = false return } - const accountDashboarSettings = settings as NotificationSettingsValidatorDashboard - accountDashboarSettings.group_efficiency_below_threshold = 0 - accountDashboarSettings.is_attestations_missed_subscribed = false - accountDashboarSettings.is_block_proposal_subscribed = false - accountDashboarSettings.is_group_efficiency_below_subscribed = false - accountDashboarSettings.is_max_collateral_subscribed = false - accountDashboarSettings.is_min_collateral_subscribed = false - accountDashboarSettings.is_slashed_subscribed = false - accountDashboarSettings.is_sync_subscribed = false - accountDashboarSettings.is_upcoming_block_proposal_subscribed = false - accountDashboarSettings.is_validator_offline_subscribed = false - accountDashboarSettings.is_withdrawal_processed_subscribed = false - accountDashboarSettings.max_collateral_threshold = 0 - accountDashboarSettings.min_collateral_threshold = 0 + const accountDashboardSettings = settings as NotificationSettingsValidatorDashboard + accountDashboardSettings.group_efficiency_below_threshold = 0 + accountDashboardSettings.is_attestations_missed_subscribed = false + accountDashboardSettings.is_block_proposal_subscribed = false + accountDashboardSettings.is_group_efficiency_below_subscribed = false + accountDashboardSettings.is_max_collateral_subscribed = false + accountDashboardSettings.is_min_collateral_subscribed = false + accountDashboardSettings.is_slashed_subscribed = false + accountDashboardSettings.is_sync_subscribed = false + accountDashboardSettings.is_upcoming_block_proposal_subscribed = false + accountDashboardSettings.is_validator_offline_subscribed = false + accountDashboardSettings.is_withdrawal_processed_subscribed = false + accountDashboardSettings.max_collateral_threshold = 0 + accountDashboardSettings.min_collateral_threshold = 0 } const deleteDashboardNotifications = async ( { @@ -117,7 +117,7 @@ export function useNotificationsManagementDashboards() { settings, }) if (is_account_dashboard) { - return await fetch( + return await fetch( 'NOTIFICATIONS_MANAGEMENT_DASHBOARD_ACCOUNT_SET_NOTIFICATION', { body: settings, @@ -128,7 +128,7 @@ export function useNotificationsManagementDashboards() { }, ) } - return await fetch( + return await fetch( 'NOTIFICATIONS_MANAGEMENT_DASHBOARD_VALIDATOR_SET_NOTIFICATION', { body: settings, @@ -173,7 +173,7 @@ export function useNotificationsManagementDashboards() { settings: NotificationSettingsValidatorDashboard, }, ) { - await fetch( + await fetch( 'SAVE_VALIDATOR_DASHBOARDS_SETTINGS', { body: { diff --git a/frontend/stores/notifications/useNotificationsClientsStore.ts b/frontend/stores/notifications/useNotificationsClientsStore.ts index b4bac7e9f..498a6ec76 100644 --- a/frontend/stores/notifications/useNotificationsClientsStore.ts +++ b/frontend/stores/notifications/useNotificationsClientsStore.ts @@ -1,10 +1,10 @@ import { defineStore } from 'pinia' -import type { InternalGetUserNotificationClientsResponse } from '~/types/api/notifications' +import type { GetUserNotificationClientsResponse } from '~/types/api/notifications' import type { TableQueryParams } from '~/types/datatable' const notificationsClientStore = defineStore('notifications-clients-store', () => { - const data = ref() + const data = ref() return { data } }) @@ -24,7 +24,7 @@ export function useNotificationsClientStore() { isLoading.value = true setStoredQuery(q) try { - const result = await fetch( + const result = await fetch( 'NOTIFICATIONS_CLIENTS', undefined, undefined, diff --git a/frontend/stores/notifications/useNotificationsDashboardDetailsStore.ts b/frontend/stores/notifications/useNotificationsDashboardDetailsStore.ts index 37d561a9f..41f9af93d 100644 --- a/frontend/stores/notifications/useNotificationsDashboardDetailsStore.ts +++ b/frontend/stores/notifications/useNotificationsDashboardDetailsStore.ts @@ -1,5 +1,5 @@ import type { - InternalGetUserNotificationsValidatorDashboardResponse, + GetUserNotificationsValidatorDashboardResponse, NotificationDashboardsTableRow, NotificationValidatorDashboardDetail, } from '~/types/api/notifications' @@ -18,7 +18,7 @@ export const useNotificationsDashboardDetailsStore = defineStore('notifications- search?: string, }, ) => { - return fetch( + return fetch( 'NOTIFICATIONS_DASHBOARDS_DETAILS_VALIDATOR', { query: { diff --git a/frontend/stores/notifications/useNotificationsDashboardStore.ts b/frontend/stores/notifications/useNotificationsDashboardStore.ts index 048ba15e6..393c8357c 100644 --- a/frontend/stores/notifications/useNotificationsDashboardStore.ts +++ b/frontend/stores/notifications/useNotificationsDashboardStore.ts @@ -1,5 +1,5 @@ import { defineStore } from 'pinia' -import type { InternalGetUserNotificationDashboardsResponse } from '~/types/api/notifications' +import type { GetUserNotificationDashboardsResponse } from '~/types/api/notifications' import type { TableQueryParams } from '~/types/datatable' import type { ChainIDs } from '~/types/network' @@ -7,7 +7,7 @@ import type { ChainIDs } from '~/types/network' const notificationsDashboardStore = defineStore( 'notifications-dashboard-store', () => { - const data = ref() + const data = ref() return { data } }, ) @@ -38,7 +38,7 @@ export function useNotificationsDashboardStore(networkId: globalThis.Ref( + const result = await fetch( 'NOTIFICATIONS_DASHBOARDS', { query: { networks: networkId.value } }, undefined, diff --git a/frontend/stores/notifications/useNotificationsMachineStore.ts b/frontend/stores/notifications/useNotificationsMachineStore.ts index dda0914ee..57bd503ff 100644 --- a/frontend/stores/notifications/useNotificationsMachineStore.ts +++ b/frontend/stores/notifications/useNotificationsMachineStore.ts @@ -1,10 +1,10 @@ import { defineStore } from 'pinia' -import type { InternalGetUserNotificationMachinesResponse } from '~/types/api/notifications' +import type { GetUserNotificationMachinesResponse } from '~/types/api/notifications' import type { TableQueryParams } from '~/types/datatable' const notificationsMachineStore = defineStore('notifications-network-store', () => { - const data = ref() + const data = ref() return { data } }) @@ -24,7 +24,7 @@ export function useNotificationsMachineStore() { isLoading.value = true setStoredQuery(q) try { - const result = await fetch( + const result = await fetch( 'NOTIFICATIONS_MACHINE', undefined, undefined, diff --git a/frontend/stores/notifications/useNotificationsManagementStore.ts b/frontend/stores/notifications/useNotificationsManagementStore.ts index 52aee6dce..b7bfab6d2 100644 --- a/frontend/stores/notifications/useNotificationsManagementStore.ts +++ b/frontend/stores/notifications/useNotificationsManagementStore.ts @@ -1,10 +1,10 @@ import type { - InternalGetUserNotificationSettingsResponse, - InternalPutUserNotificationSettingsGeneralResponse, - InternalPutUserNotificationSettingsNetworksResponse, - InternalPutUserNotificationSettingsPairedDevicesResponse, + GetUserNotificationSettingsResponse, NotificationSettings, NotificationSettingsNetwork, + PutUserNotificationSettingsGeneralResponse, + PutUserNotificationSettingsNetworksResponse, + PutUserNotificationSettingsPairedDevicesResponse, } from '~/types/api/notifications' export const useNotificationsManagementStore = defineStore('notifications-management-store', () => { @@ -33,14 +33,14 @@ export const useNotificationsManagementStore = defineStore('notifications-manage ) const saveSettings = async () => { - await fetch( + await fetch( 'NOTIFICATIONS_MANAGEMENT_SAVE', { body: settings.value.general_settings, method: 'PUT', }) } const getSettings = () => { - return fetch( + return fetch( 'NOTIFICATIONS_MANAGEMENT_GENERAL', ) } @@ -65,7 +65,7 @@ export const useNotificationsManagementStore = defineStore('notifications-manage id: number, value: boolean, }) => { - await fetch( + await fetch( 'NOTIFICATIONS_MANAGEMENT_PAIRED_DEVICES_SET_NOTIFICATION', { body: { @@ -85,7 +85,7 @@ export const useNotificationsManagementStore = defineStore('notifications-manage chain_id: string, settings: NotificationSettingsNetwork, }) => { - await fetch( + await fetch( 'NOTIFICATIONS_MANAGEMENT_NETWORK_SET_NOTIFICATION', { body: { @@ -106,7 +106,7 @@ export const useNotificationsManagementStore = defineStore('notifications-manage client_id: number, is_subscribed: boolean, }) => { - await fetch( + await fetch( 'NOTIFICATIONS_MANAGEMENT_CLIENTS_SET_NOTIFICATION', { body: { diff --git a/frontend/stores/notifications/useNotificationsNetworkStore.ts b/frontend/stores/notifications/useNotificationsNetworkStore.ts index af630b7bf..abc302727 100644 --- a/frontend/stores/notifications/useNotificationsNetworkStore.ts +++ b/frontend/stores/notifications/useNotificationsNetworkStore.ts @@ -1,10 +1,10 @@ import { defineStore } from 'pinia' -import type { InternalGetUserNotificationNetworksResponse } from '~/types/api/notifications' +import type { GetUserNotificationNetworksResponse } from '~/types/api/notifications' import type { TableQueryParams } from '~/types/datatable' const notificationsNetworkStore = defineStore('notifications-network-store', () => { - const data = ref() + const data = ref() return { data } }) @@ -24,7 +24,7 @@ export function useNotificationsNetworkStore() { isLoading.value = true setStoredQuery(q) try { - const result = await fetch( + const result = await fetch( 'NOTIFICATIONS_NETWORK', undefined, undefined, diff --git a/frontend/stores/notifications/useNotificationsOverviewStore.ts b/frontend/stores/notifications/useNotificationsOverviewStore.ts index fca0d3c52..5ddf51f1a 100644 --- a/frontend/stores/notifications/useNotificationsOverviewStore.ts +++ b/frontend/stores/notifications/useNotificationsOverviewStore.ts @@ -1,7 +1,7 @@ import { defineStore } from 'pinia' import type { - InternalGetUserNotificationsResponse, NotificationOverviewData, + GetUserNotificationsResponse, NotificationOverviewData, } from '~/types/api/notifications' const notificationsOverviewStore = defineStore('notifications_overview_store', () => { @@ -15,7 +15,7 @@ export function useNotificationsDashboardOverviewStore() { async function refreshOverview() { try { - const res = await fetch( + const res = await fetch( 'NOTIFICATIONS_OVERVIEW', ) overview.value = res.data diff --git a/frontend/types/api/notifications.ts b/frontend/types/api/notifications.ts index 3cc00afa8..f8b8ec084 100644 --- a/frontend/types/api/notifications.ts +++ b/frontend/types/api/notifications.ts @@ -30,7 +30,7 @@ export interface NotificationOverviewData { clients_subscription_count: number /* uint64 */; networks_subscription_count: number /* uint64 */; } -export type InternalGetUserNotificationsResponse = ApiDataResponse; +export type GetUserNotificationsResponse = ApiDataResponse; /** * ------------------------------------------------------------ * Dashboards Table @@ -46,7 +46,7 @@ export interface NotificationDashboardsTableRow { entity_count: number /* uint64 */; event_types: ('validator_online' | 'validator_offline' | 'group_efficiency_below' | 'attestation_missed' | 'proposal_success' | 'proposal_missed' | 'proposal_upcoming' | 'max_collateral' | 'min_collateral' | 'sync' | 'withdrawal' | 'validator_got_slashed' | 'validator_has_slashed' | 'incoming_tx' | 'outgoing_tx' | 'transfer_erc20' | 'transfer_erc721' | 'transfer_erc1155')[]; } -export type InternalGetUserNotificationDashboardsResponse = ApiPagingResponse; +export type GetUserNotificationDashboardsResponse = ApiPagingResponse; export interface NotificationEventValidatorBackOnline { index: number /* uint64 */; epoch_count: number /* uint64 */; @@ -73,7 +73,7 @@ export interface NotificationValidatorDashboardDetail { min_collateral: Address[]; // node addresses max_collateral: Address[]; // node addresses } -export type InternalGetUserNotificationsValidatorDashboardResponse = ApiDataResponse; +export type GetUserNotificationsValidatorDashboardResponse = ApiDataResponse; export interface NotificationEventExecution { address: Address; amount: string /* decimal.Decimal */; @@ -87,7 +87,7 @@ export interface NotificationAccountDashboardDetail { erc721_token_transfers: NotificationEventExecution[]; erc1155_token_transfers: NotificationEventExecution[]; } -export type InternalGetUserNotificationsAccountDashboardResponse = ApiDataResponse; +export type GetUserNotificationsAccountDashboardResponse = ApiDataResponse; /** * ------------------------------------------------------------ * Machines Table @@ -98,7 +98,7 @@ export interface NotificationMachinesTableRow { event_type: 'offline' | 'storage' | 'cpu' | 'memory'; timestamp: number /* int64 */; } -export type InternalGetUserNotificationMachinesResponse = ApiPagingResponse; +export type GetUserNotificationMachinesResponse = ApiPagingResponse; /** * ------------------------------------------------------------ * Clients Table @@ -109,7 +109,7 @@ export interface NotificationClientsTableRow { url: string; timestamp: number /* int64 */; } -export type InternalGetUserNotificationClientsResponse = ApiPagingResponse; +export type GetUserNotificationClientsResponse = ApiPagingResponse; /** * ------------------------------------------------------------ * Networks Table @@ -120,7 +120,7 @@ export interface NotificationNetworksTableRow { event_type: 'new_reward_round' | 'gas_above' | 'gas_below' | 'participation_rate'; threshold?: string /* decimal.Decimal */; // participation rate threshold should also be passed as decimal string } -export type InternalGetUserNotificationNetworksResponse = ApiPagingResponse; +export type GetUserNotificationNetworksResponse = ApiPagingResponse; /** * ------------------------------------------------------------ * Notification Settings @@ -138,21 +138,21 @@ export interface NotificationNetwork { chain_id: number /* uint64 */; settings: NotificationSettingsNetwork; } -export type InternalPutUserNotificationSettingsNetworksResponse = ApiDataResponse; +export type PutUserNotificationSettingsNetworksResponse = ApiDataResponse; export interface NotificationPairedDevice { id: number /* uint64 */; paired_timestamp: number /* int64 */; name?: string; is_notifications_enabled: boolean; } -export type InternalPutUserNotificationSettingsPairedDevicesResponse = ApiDataResponse; +export type PutUserNotificationSettingsPairedDevicesResponse = ApiDataResponse; export interface NotificationSettingsClient { id: number /* uint64 */; name: string; category: 'execution_layer' | 'consensus_layer' | 'other'; is_subscribed: boolean; } -export type InternalPutUserNotificationSettingsClientResponse = ApiDataResponse; +export type PutUserNotificationSettingsClientResponse = ApiDataResponse; export interface NotificationSettingsGeneral { do_not_disturb_timestamp: number /* int64 */; // notifications are disabled until this timestamp is_email_notifications_enabled: boolean; @@ -166,7 +166,7 @@ export interface NotificationSettingsGeneral { is_machine_memory_usage_subscribed: boolean; machine_memory_usage_threshold: number /* float64 */; } -export type InternalPutUserNotificationSettingsGeneralResponse = ApiDataResponse; +export type PutUserNotificationSettingsGeneralResponse = ApiDataResponse; export interface NotificationSettings { general_settings: NotificationSettingsGeneral; has_machines: boolean; @@ -174,7 +174,7 @@ export interface NotificationSettings { paired_devices: NotificationPairedDevice[]; clients: NotificationSettingsClient[]; } -export type InternalGetUserNotificationSettingsResponse = ApiDataResponse; +export type GetUserNotificationSettingsResponse = ApiDataResponse; export interface NotificationSettingsValidatorDashboard { webhook_url: string; is_webhook_discord_enabled: boolean; @@ -192,7 +192,7 @@ export interface NotificationSettingsValidatorDashboard { is_min_collateral_subscribed: boolean; min_collateral_threshold: number /* float64 */; } -export type InternalPutUserNotificationSettingsValidatorDashboardResponse = ApiDataResponse; +export type PutUserNotificationSettingsValidatorDashboardResponse = ApiDataResponse; export interface NotificationSettingsAccountDashboard { webhook_url: string; is_webhook_discord_enabled: boolean; @@ -205,7 +205,7 @@ export interface NotificationSettingsAccountDashboard { is_erc721_token_transfers_subscribed: boolean; is_erc1155_token_transfers_subscribed: boolean; } -export type InternalPutUserNotificationSettingsAccountDashboardResponse = ApiDataResponse; +export type PutUserNotificationSettingsAccountDashboardResponse = ApiDataResponse; export interface NotificationSettingsDashboardsTableRow { is_account_dashboard: boolean; // if false it's a validator dashboard dashboard_id: number /* uint64 */; @@ -218,4 +218,4 @@ export interface NotificationSettingsDashboardsTableRow { settings: NotificationSettingsAccountDashboard | NotificationSettingsValidatorDashboard; chain_ids: number /* uint64 */[]; } -export type InternalGetUserNotificationSettingsDashboardsResponse = ApiPagingResponse; +export type GetUserNotificationSettingsDashboardsResponse = ApiPagingResponse;