Skip to content

Commit 2f1521d

Browse files
committed
refactor(api): rename notification response structs
1 parent 4bb9d8f commit 2f1521d

11 files changed

+98
-110
lines changed

backend/pkg/api/handlers/public.go

Lines changed: 34 additions & 34 deletions
Large diffs are not rendered by default.

backend/pkg/api/types/notifications.go

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ type NotificationOverviewData struct {
2727
ClientsSubscriptionCount uint64 `db:"clients_subscription_count" json:"clients_subscription_count"`
2828
NetworksSubscriptionCount uint64 `db:"networks_subscription_count" json:"networks_subscription_count"`
2929
}
30-
31-
type InternalGetUserNotificationsResponse ApiDataResponse[NotificationOverviewData]
30+
type GetUserNotificationsResponse ApiDataResponse[NotificationOverviewData]
3231

3332
// ------------------------------------------------------------
3433
// Dashboards Table
@@ -43,8 +42,7 @@ type NotificationDashboardsTableRow struct {
4342
EntityCount uint64 `db:"entity_count" json:"entity_count"`
4443
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"`
4544
}
46-
47-
type InternalGetUserNotificationDashboardsResponse ApiPagingResponse[NotificationDashboardsTableRow]
45+
type GetUserNotificationDashboardsResponse ApiPagingResponse[NotificationDashboardsTableRow]
4846

4947
// ------------------------------------------------------------
5048
// Validator Dashboard Notification Detail
@@ -53,13 +51,11 @@ type NotificationEventValidatorBackOnline struct {
5351
Index uint64 `json:"index"`
5452
EpochCount uint64 `json:"epoch_count"`
5553
}
56-
5754
type NotificationEventWithdrawal struct {
5855
Index uint64 `json:"index"`
5956
Amount decimal.Decimal `json:"amount"`
6057
Address Address `json:"address"`
6158
}
62-
6359
type NotificationValidatorDashboardDetail struct {
6460
DashboardName string `db:"dashboard_name" json:"dashboard_name"`
6561
GroupName string `db:"group_name" json:"group_name"`
@@ -77,25 +73,22 @@ type NotificationValidatorDashboardDetail struct {
7773
MinCollateral []Address `json:"min_collateral"` // node addresses
7874
MaxCollateral []Address `json:"max_collateral"` // node addresses
7975
}
80-
81-
type InternalGetUserNotificationsValidatorDashboardResponse ApiDataResponse[NotificationValidatorDashboardDetail]
76+
type GetUserNotificationsValidatorDashboardResponse ApiDataResponse[NotificationValidatorDashboardDetail]
8277

8378
type NotificationEventExecution struct {
8479
Address Address `json:"address"`
8580
Amount decimal.Decimal `json:"amount"`
8681
TransactionHash Hash `json:"transaction_hash"`
8782
TokenName string `json:"token_name"` // this field will prob change depending on how execution stuff is implemented
8883
}
89-
9084
type NotificationAccountDashboardDetail struct {
9185
IncomingTransactions []NotificationEventExecution `json:"incoming_transactions"`
9286
OutgoingTransactions []NotificationEventExecution `json:"outgoing_transactions"`
9387
ERC20TokenTransfers []NotificationEventExecution `json:"erc20_token_transfers"`
9488
ERC721TokenTransfers []NotificationEventExecution `json:"erc721_token_transfers"`
9589
ERC1155TokenTransfers []NotificationEventExecution `json:"erc1155_token_transfers"`
9690
}
97-
98-
type InternalGetUserNotificationsAccountDashboardResponse ApiDataResponse[NotificationAccountDashboardDetail]
91+
type GetUserNotificationsAccountDashboardResponse ApiDataResponse[NotificationAccountDashboardDetail]
9992

10093
// ------------------------------------------------------------
10194
// Machines Table
@@ -105,8 +98,7 @@ type NotificationMachinesTableRow struct {
10598
EventType string `json:"event_type" tstype:"'offline' | 'storage' | 'cpu' | 'memory'" faker:"oneof: offline, storage, cpu, memory"`
10699
Timestamp int64 `json:"timestamp"`
107100
}
108-
109-
type InternalGetUserNotificationMachinesResponse ApiPagingResponse[NotificationMachinesTableRow]
101+
type GetUserNotificationMachinesResponse ApiPagingResponse[NotificationMachinesTableRow]
110102

111103
// ------------------------------------------------------------
112104
// Clients Table
@@ -116,8 +108,7 @@ type NotificationClientsTableRow struct {
116108
Url string `json:"url"`
117109
Timestamp int64 `json:"timestamp"`
118110
}
119-
120-
type InternalGetUserNotificationClientsResponse ApiPagingResponse[NotificationClientsTableRow]
111+
type GetUserNotificationClientsResponse ApiPagingResponse[NotificationClientsTableRow]
121112

122113
// ------------------------------------------------------------
123114
// Networks Table
@@ -127,8 +118,7 @@ type NotificationNetworksTableRow struct {
127118
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"`
128119
Threshold decimal.Decimal `json:"threshold,omitempty"` // participation rate threshold should also be passed as decimal string
129120
}
130-
131-
type InternalGetUserNotificationNetworksResponse ApiPagingResponse[NotificationNetworksTableRow]
121+
type GetUserNotificationNetworksResponse ApiPagingResponse[NotificationNetworksTableRow]
132122

133123
// ------------------------------------------------------------
134124
// Notification Settings
@@ -145,24 +135,23 @@ type NotificationNetwork struct {
145135
ChainId uint64 `json:"chain_id"`
146136
Settings NotificationSettingsNetwork `json:"settings"`
147137
}
148-
type InternalPutUserNotificationSettingsNetworksResponse ApiDataResponse[NotificationNetwork]
138+
type PutUserNotificationSettingsNetworksResponse ApiDataResponse[NotificationNetwork]
149139

150140
type NotificationPairedDevice struct {
151141
Id uint64 `json:"id"`
152142
PairedTimestamp int64 `json:"paired_timestamp"`
153143
Name string `json:"name,omitempty"`
154144
IsNotificationsEnabled bool `json:"is_notifications_enabled"`
155145
}
156-
type InternalPutUserNotificationSettingsPairedDevicesResponse ApiDataResponse[NotificationPairedDevice]
146+
type PutUserNotificationSettingsPairedDevicesResponse ApiDataResponse[NotificationPairedDevice]
157147

158148
type NotificationSettingsClient struct {
159149
Id uint64 `json:"id"`
160150
Name string `json:"name"`
161151
Category string `json:"category" tstype:"'execution_layer' | 'consensus_layer' | 'other'" faker:"oneof: execution_layer, consensus_layer, other"`
162152
IsSubscribed bool `json:"is_subscribed"`
163153
}
164-
165-
type InternalPutUserNotificationSettingsClientResponse ApiDataResponse[NotificationSettingsClient]
154+
type PutUserNotificationSettingsClientResponse ApiDataResponse[NotificationSettingsClient]
166155

167156
type NotificationSettingsGeneral struct {
168157
DoNotDisturbTimestamp int64 `json:"do_not_disturb_timestamp"` // notifications are disabled until this timestamp
@@ -178,15 +167,16 @@ type NotificationSettingsGeneral struct {
178167
IsMachineMemoryUsageSubscribed bool `json:"is_machine_memory_usage_subscribed"`
179168
MachineMemoryUsageThreshold float64 `json:"machine_memory_usage_threshold" faker:"boundary_start=0, boundary_end=1"`
180169
}
181-
type InternalPutUserNotificationSettingsGeneralResponse ApiDataResponse[NotificationSettingsGeneral]
170+
type PutUserNotificationSettingsGeneralResponse ApiDataResponse[NotificationSettingsGeneral]
171+
182172
type NotificationSettings struct {
183173
GeneralSettings NotificationSettingsGeneral `json:"general_settings"`
184174
HasMachines bool `json:"has_machines"`
185175
Networks []NotificationNetwork `json:"networks"`
186176
PairedDevices []NotificationPairedDevice `json:"paired_devices"`
187177
Clients []NotificationSettingsClient `json:"clients" faker:"slice_len=10"`
188178
}
189-
type InternalGetUserNotificationSettingsResponse ApiDataResponse[NotificationSettings]
179+
type GetUserNotificationSettingsResponse ApiDataResponse[NotificationSettings]
190180

191181
type NotificationSettingsValidatorDashboard struct {
192182
WebhookUrl string `json:"webhook_url" faker:"url"`
@@ -207,8 +197,7 @@ type NotificationSettingsValidatorDashboard struct {
207197
IsMinCollateralSubscribed bool `json:"is_min_collateral_subscribed"`
208198
MinCollateralThreshold float64 `json:"min_collateral_threshold" faker:"boundary_start=0, boundary_end=1"`
209199
}
210-
211-
type InternalPutUserNotificationSettingsValidatorDashboardResponse ApiDataResponse[NotificationSettingsValidatorDashboard]
200+
type PutUserNotificationSettingsValidatorDashboardResponse ApiDataResponse[NotificationSettingsValidatorDashboard]
212201

213202
type NotificationSettingsAccountDashboard struct {
214203
WebhookUrl string `json:"webhook_url" faker:"url"`
@@ -223,7 +212,7 @@ type NotificationSettingsAccountDashboard struct {
223212
IsERC721TokenTransfersSubscribed bool `json:"is_erc721_token_transfers_subscribed"`
224213
IsERC1155TokenTransfersSubscribed bool `json:"is_erc1155_token_transfers_subscribed"`
225214
}
226-
type InternalPutUserNotificationSettingsAccountDashboardResponse ApiDataResponse[NotificationSettingsAccountDashboard]
215+
type PutUserNotificationSettingsAccountDashboardResponse ApiDataResponse[NotificationSettingsAccountDashboard]
227216

228217
type NotificationSettingsDashboardsTableRow struct {
229218
IsAccountDashboard bool `json:"is_account_dashboard"` // if false it's a validator dashboard
@@ -235,5 +224,4 @@ type NotificationSettingsDashboardsTableRow struct {
235224
Settings interface{} `json:"settings" tstype:"NotificationSettingsAccountDashboard | NotificationSettingsValidatorDashboard" faker:"-"`
236225
ChainIds []uint64 `json:"chain_ids" faker:"chain_ids"`
237226
}
238-
239-
type InternalGetUserNotificationSettingsDashboardsResponse ApiPagingResponse[NotificationSettingsDashboardsTableRow]
227+
type GetUserNotificationSettingsDashboardsResponse ApiPagingResponse[NotificationSettingsDashboardsTableRow]

frontend/composables/notifications/useNotificationsManagementDashboards.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { TableQueryParams } from '~/types/datatable'
22

33
import type {
4-
InternalGetUserNotificationSettingsDashboardsResponse,
5-
InternalPutUserNotificationSettingsAccountDashboardResponse,
6-
InternalPutUserNotificationSettingsValidatorDashboardResponse,
4+
GetUserNotificationSettingsDashboardsResponse,
5+
PutUserNotificationSettingsAccountDashboardResponse,
6+
PutUserNotificationSettingsValidatorDashboardResponse,
77
NotificationSettingsAccountDashboard,
88
NotificationSettingsDashboardsTableRow,
99
NotificationSettingsValidatorDashboard,
@@ -12,7 +12,7 @@ import type {
1212
export function useNotificationsManagementDashboards() {
1313
const { fetch } = useCustomFetch()
1414
const { refreshOverview } = useNotificationsDashboardOverviewStore()
15-
const data = ref<InternalGetUserNotificationSettingsDashboardsResponse>()
15+
const data = ref<GetUserNotificationSettingsDashboardsResponse>()
1616
const {
1717
cursor,
1818
isStoredQuery,
@@ -36,7 +36,7 @@ export function useNotificationsManagementDashboards() {
3636
isLoading.value = true
3737
setStoredQuery(q)
3838
const res
39-
= await fetch<InternalGetUserNotificationSettingsDashboardsResponse>(
39+
= await fetch<GetUserNotificationSettingsDashboardsResponse>(
4040
'GET_NOTIFICATIONS_SETTINGS_DASHBOARD',
4141
undefined,
4242
undefined,
@@ -117,7 +117,7 @@ export function useNotificationsManagementDashboards() {
117117
settings,
118118
})
119119
if (is_account_dashboard) {
120-
return await fetch<InternalPutUserNotificationSettingsAccountDashboardResponse>(
120+
return await fetch<PutUserNotificationSettingsAccountDashboardResponse>(
121121
'NOTIFICATIONS_MANAGEMENT_DASHBOARD_ACCOUNT_SET_NOTIFICATION',
122122
{
123123
body: settings,
@@ -128,7 +128,7 @@ export function useNotificationsManagementDashboards() {
128128
},
129129
)
130130
}
131-
return await fetch<InternalPutUserNotificationSettingsValidatorDashboardResponse>(
131+
return await fetch<PutUserNotificationSettingsValidatorDashboardResponse>(
132132
'NOTIFICATIONS_MANAGEMENT_DASHBOARD_VALIDATOR_SET_NOTIFICATION',
133133
{
134134
body: settings,
@@ -173,7 +173,7 @@ export function useNotificationsManagementDashboards() {
173173
settings: NotificationSettingsValidatorDashboard,
174174
},
175175
) {
176-
await fetch<InternalPutUserNotificationSettingsValidatorDashboardResponse>(
176+
await fetch<PutUserNotificationSettingsValidatorDashboardResponse>(
177177
'SAVE_VALIDATOR_DASHBOARDS_SETTINGS',
178178
{
179179
body: {

frontend/stores/notifications/useNotificationsClientsStore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { defineStore } from 'pinia'
2-
import type { InternalGetUserNotificationClientsResponse } from '~/types/api/notifications'
2+
import type { GetUserNotificationClientsResponse } from '~/types/api/notifications'
33

44
import type { TableQueryParams } from '~/types/datatable'
55

66
const notificationsClientStore = defineStore('notifications-clients-store', () => {
7-
const data = ref<InternalGetUserNotificationClientsResponse | undefined>()
7+
const data = ref<GetUserNotificationClientsResponse | undefined>()
88
return { data }
99
})
1010

@@ -24,7 +24,7 @@ export function useNotificationsClientStore() {
2424
isLoading.value = true
2525
setStoredQuery(q)
2626
try {
27-
const result = await fetch<InternalGetUserNotificationClientsResponse>(
27+
const result = await fetch<GetUserNotificationClientsResponse>(
2828
'NOTIFICATIONS_CLIENTS',
2929
undefined,
3030
undefined,

frontend/stores/notifications/useNotificationsDashboardDetailsStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {
2-
InternalGetUserNotificationsValidatorDashboardResponse,
2+
GetUserNotificationsValidatorDashboardResponse,
33
NotificationDashboardsTableRow, NotificationValidatorDashboardDetail,
44
} from '~/types/api/notifications'
55

@@ -18,7 +18,7 @@ export const useNotificationsDashboardDetailsStore = defineStore('notifications-
1818
search?: string,
1919
},
2020
) => {
21-
return fetch<InternalGetUserNotificationsValidatorDashboardResponse>(
21+
return fetch<GetUserNotificationsValidatorDashboardResponse>(
2222
'NOTIFICATIONS_DASHBOARDS_DETAILS_VALIDATOR',
2323
{
2424
query: {

frontend/stores/notifications/useNotificationsDashboardStore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { defineStore } from 'pinia'
2-
import type { InternalGetUserNotificationDashboardsResponse } from '~/types/api/notifications'
2+
import type { GetUserNotificationDashboardsResponse } from '~/types/api/notifications'
33

44
import type { TableQueryParams } from '~/types/datatable'
55
import type { ChainIDs } from '~/types/network'
66

77
const notificationsDashboardStore = defineStore(
88
'notifications-dashboard-store',
99
() => {
10-
const data = ref<InternalGetUserNotificationDashboardsResponse | undefined>()
10+
const data = ref<GetUserNotificationDashboardsResponse | undefined>()
1111
return { data }
1212
},
1313
)
@@ -38,7 +38,7 @@ export function useNotificationsDashboardStore(networkId: globalThis.Ref<ChainID
3838
isLoading.value = true
3939
setStoredQuery(q)
4040
try {
41-
const result = await fetch<InternalGetUserNotificationDashboardsResponse>(
41+
const result = await fetch<GetUserNotificationDashboardsResponse>(
4242
'NOTIFICATIONS_DASHBOARDS',
4343
{ query: { networks: networkId.value } },
4444
undefined,

frontend/stores/notifications/useNotificationsMachineStore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { defineStore } from 'pinia'
2-
import type { InternalGetUserNotificationMachinesResponse } from '~/types/api/notifications'
2+
import type { GetUserNotificationMachinesResponse } from '~/types/api/notifications'
33

44
import type { TableQueryParams } from '~/types/datatable'
55

66
const notificationsMachineStore = defineStore('notifications-network-store', () => {
7-
const data = ref<InternalGetUserNotificationMachinesResponse | undefined>()
7+
const data = ref<GetUserNotificationMachinesResponse | undefined>()
88
return { data }
99
})
1010

@@ -24,7 +24,7 @@ export function useNotificationsMachineStore() {
2424
isLoading.value = true
2525
setStoredQuery(q)
2626
try {
27-
const result = await fetch<InternalGetUserNotificationMachinesResponse>(
27+
const result = await fetch<GetUserNotificationMachinesResponse>(
2828
'NOTIFICATIONS_MACHINE',
2929
undefined,
3030
undefined,

frontend/stores/notifications/useNotificationsManagementStore.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type {
2-
InternalGetUserNotificationSettingsResponse,
3-
InternalPutUserNotificationSettingsGeneralResponse,
4-
InternalPutUserNotificationSettingsNetworksResponse,
5-
InternalPutUserNotificationSettingsPairedDevicesResponse,
2+
GetUserNotificationSettingsResponse,
63
NotificationSettings,
74
NotificationSettingsNetwork,
5+
PutUserNotificationSettingsGeneralResponse,
6+
PutUserNotificationSettingsNetworksResponse,
7+
PutUserNotificationSettingsPairedDevicesResponse,
88
} from '~/types/api/notifications'
99

1010
export const useNotificationsManagementStore = defineStore('notifications-management-store', () => {
@@ -33,14 +33,14 @@ export const useNotificationsManagementStore = defineStore('notifications-manage
3333
)
3434

3535
const saveSettings = async () => {
36-
await fetch<InternalPutUserNotificationSettingsGeneralResponse>(
36+
await fetch<PutUserNotificationSettingsGeneralResponse>(
3737
'NOTIFICATIONS_MANAGEMENT_SAVE', {
3838
body: settings.value.general_settings,
3939
method: 'PUT',
4040
})
4141
}
4242
const getSettings = () => {
43-
return fetch<InternalGetUserNotificationSettingsResponse>(
43+
return fetch<GetUserNotificationSettingsResponse>(
4444
'NOTIFICATIONS_MANAGEMENT_GENERAL',
4545
)
4646
}
@@ -65,7 +65,7 @@ export const useNotificationsManagementStore = defineStore('notifications-manage
6565
id: number,
6666
value: boolean,
6767
}) => {
68-
await fetch<InternalPutUserNotificationSettingsPairedDevicesResponse>(
68+
await fetch<PutUserNotificationSettingsPairedDevicesResponse>(
6969
'NOTIFICATIONS_MANAGEMENT_PAIRED_DEVICES_SET_NOTIFICATION',
7070
{
7171
body: {
@@ -85,7 +85,7 @@ export const useNotificationsManagementStore = defineStore('notifications-manage
8585
chain_id: string,
8686
settings: NotificationSettingsNetwork,
8787
}) => {
88-
await fetch<InternalPutUserNotificationSettingsNetworksResponse>(
88+
await fetch<PutUserNotificationSettingsNetworksResponse>(
8989
'NOTIFICATIONS_MANAGEMENT_NETWORK_SET_NOTIFICATION',
9090
{
9191
body: {
@@ -106,7 +106,7 @@ export const useNotificationsManagementStore = defineStore('notifications-manage
106106
client_id: number,
107107
is_subscribed: boolean,
108108
}) => {
109-
await fetch<InternalPutUserNotificationSettingsNetworksResponse>(
109+
await fetch<PutUserNotificationSettingsNetworksResponse>(
110110
'NOTIFICATIONS_MANAGEMENT_CLIENTS_SET_NOTIFICATION',
111111
{
112112
body: {

frontend/stores/notifications/useNotificationsNetworkStore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { defineStore } from 'pinia'
2-
import type { InternalGetUserNotificationNetworksResponse } from '~/types/api/notifications'
2+
import type { GetUserNotificationNetworksResponse } from '~/types/api/notifications'
33

44
import type { TableQueryParams } from '~/types/datatable'
55

66
const notificationsNetworkStore = defineStore('notifications-network-store', () => {
7-
const data = ref<InternalGetUserNotificationNetworksResponse | undefined>()
7+
const data = ref<GetUserNotificationNetworksResponse | undefined>()
88
return { data }
99
})
1010

@@ -24,7 +24,7 @@ export function useNotificationsNetworkStore() {
2424
isLoading.value = true
2525
setStoredQuery(q)
2626
try {
27-
const result = await fetch<InternalGetUserNotificationNetworksResponse>(
27+
const result = await fetch<GetUserNotificationNetworksResponse>(
2828
'NOTIFICATIONS_NETWORK',
2929
undefined,
3030
undefined,

0 commit comments

Comments
 (0)