-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): add preferences entity and schema (#6396)
- Loading branch information
1 parent
070fde1
commit 0269ddc
Showing
41 changed files
with
1,874 additions
and
54 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { ChannelTypeEnum } from '@novu/shared'; | ||
import { Type } from 'class-transformer'; | ||
import { IsBoolean, ValidateNested } from 'class-validator'; | ||
|
||
export class Preference { | ||
@IsBoolean() | ||
defaultValue: boolean; | ||
|
||
@IsBoolean() | ||
readOnly: boolean; | ||
} | ||
|
||
export class Channels { | ||
@ValidateNested({ each: true }) | ||
@Type(() => Preference) | ||
[ChannelTypeEnum.IN_APP]: Preference; | ||
|
||
@ValidateNested({ each: true }) | ||
@Type(() => Preference) | ||
[ChannelTypeEnum.EMAIL]: Preference; | ||
|
||
@ValidateNested({ each: true }) | ||
@Type(() => Preference) | ||
[ChannelTypeEnum.SMS]: Preference; | ||
|
||
@ValidateNested({ each: true }) | ||
@Type(() => Preference) | ||
[ChannelTypeEnum.CHAT]: Preference; | ||
|
||
@ValidateNested({ each: true }) | ||
@Type(() => Preference) | ||
[ChannelTypeEnum.PUSH]: Preference; | ||
} | ||
|
||
export class PreferencesDto { | ||
@ValidateNested({ each: true }) | ||
@Type(() => Preference) | ||
workflow: Preference; | ||
|
||
@ValidateNested({ each: true }) | ||
@Type(() => Channels) | ||
channels: Channels; | ||
} |
12 changes: 12 additions & 0 deletions
12
apps/api/src/app/preferences/dtos/upsert-preferences.dto.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Type } from 'class-transformer'; | ||
import { IsString, ValidateNested } from 'class-validator'; | ||
import { PreferencesDto } from './preferences.dto'; | ||
|
||
export class UpsertPreferencesDto { | ||
@IsString() | ||
workflowId: string; | ||
|
||
@ValidateNested({ each: true }) | ||
@Type(() => PreferencesDto) | ||
preferences: PreferencesDto; | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { PreferencesModule } from './preferences.module'; |
Oops, something went wrong.