-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove duplicate
UpsertSubscriptionsDto
entities and builders (#2212)
Removes duplicate entities and centralises the associated schema and builder for `UpsertSubscriptionsDto`: business logic on the domain layer and implemented entity on the route: - Move schema and inferred type from datasource to domain layer - Have route entity implement domain type - Update imports accordingly
- Loading branch information
Showing
17 changed files
with
45 additions
and
151 deletions.
There are no files selected for viewing
32 changes: 0 additions & 32 deletions
32
src/datasources/notifications/__tests__/upsert-subscriptions.dto.entity.builder.ts
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/datasources/notifications/entities/upsert-subscriptions.dto.entity.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
..._/upsert-subscriptions-dto.entity.spec.ts → ..._/upsert-subscriptions-dto.entity.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 26 additions & 14 deletions
40
src/domain/notifications/v2/entities/upsert-subscriptions.dto.entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
import type { DeviceType } from '@/domain/notifications/v2/entities/device-type.entity'; | ||
import type { NotificationType } from '@/domain/notifications/v2/entities/notification-type.entity'; | ||
import type { UUID } from 'crypto'; | ||
|
||
export type UpsertSubscriptionsDto = { | ||
cloudMessagingToken: string; | ||
safes: Array<{ | ||
chainId: string; | ||
address: `0x${string}`; | ||
notificationTypes: Array<NotificationType>; | ||
}>; | ||
deviceType: DeviceType; | ||
deviceUuid?: UUID; | ||
}; | ||
import { DeviceType } from '@/domain/notifications/v2/entities/device-type.entity'; | ||
import { NotificationType } from '@/domain/notifications/v2/entities/notification-type.entity'; | ||
import { AddressSchema } from '@/validation/entities/schemas/address.schema'; | ||
import { UuidSchema } from '@/validation/entities/schemas/uuid.schema'; | ||
import { z } from 'zod'; | ||
|
||
const UpsertSubscriptionsDtoSafesSchema = z.object({ | ||
chainId: z.string(), | ||
address: AddressSchema, | ||
notificationTypes: z.array(z.nativeEnum(NotificationType)), | ||
}); | ||
|
||
export const UpsertSubscriptionsDtoSchema = z.object({ | ||
cloudMessagingToken: z.string(), | ||
safes: z.array(UpsertSubscriptionsDtoSafesSchema), | ||
deviceType: z.nativeEnum(DeviceType), | ||
deviceUuid: UuidSchema.nullish().default(null), | ||
}); | ||
|
||
export type UpsertSubscriptionsSafesDto = z.infer< | ||
typeof UpsertSubscriptionsDtoSafesSchema | ||
>; | ||
|
||
export type UpsertSubscriptionsDto = z.infer< | ||
typeof UpsertSubscriptionsDtoSchema | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/domain/notifications/v2/notifications.repository.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
src/routes/notifications/v1/entities/__tests__/upsert-subscriptions.dto.entity.builder.ts
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
src/routes/notifications/v1/entities/upsert-subscriptions.dto.entity.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters