83 lines
1.9 KiB
TypeScript
83 lines
1.9 KiB
TypeScript
import { NotificationEnum } from '@config/config';
|
|
import { IEngineSchema, MetaBy, MetaPermissions } from '@seed/engine/EngineSchema';
|
|
import { AvailableTranslation } from '@src/__components/components';
|
|
import { GraphQLJSONObject } from 'graphql-type-json';
|
|
import { InputType, ObjectType, Field, Int, registerEnumType } from 'type-graphql';
|
|
|
|
export enum NotificationType {
|
|
'mail' = 'mail',
|
|
'push' = 'push',
|
|
'sms' = 'sms',
|
|
}
|
|
|
|
registerEnumType(NotificationType, {
|
|
name: 'NotificationType',
|
|
});
|
|
|
|
export enum NotificationStatus {
|
|
'toSend' = 'toSend',
|
|
'sent' = 'sent',
|
|
'error' = 'error',
|
|
}
|
|
|
|
registerEnumType(NotificationStatus, {
|
|
name: 'NotificationStatus',
|
|
});
|
|
|
|
@ObjectType()
|
|
@InputType()
|
|
export class ReceiverData {
|
|
@Field()
|
|
value: string;
|
|
|
|
@Field(() => AvailableTranslation)
|
|
language: AvailableTranslation;
|
|
}
|
|
|
|
@ObjectType()
|
|
@InputType()
|
|
export class NotificationBaseSchema {
|
|
@Field()
|
|
ressourceId: string;
|
|
|
|
@Field(() => [String])
|
|
accountIds?: string[];
|
|
|
|
data: any;
|
|
|
|
@Field(() => NotificationEnum)
|
|
key: NotificationEnum;
|
|
|
|
@Field(() => [ReceiverData], { nullable: true })
|
|
emails?: ReceiverData[];
|
|
@Field(() => [ReceiverData], { nullable: true })
|
|
pushTokens?: ReceiverData[];
|
|
@Field(() => [ReceiverData], { nullable: true })
|
|
sms?: ReceiverData[];
|
|
|
|
@Field({ nullable: true })
|
|
slack?: boolean;
|
|
|
|
@Field(() => NotificationType)
|
|
status: NotificationStatus;
|
|
|
|
@Field({ nullable: true })
|
|
sentAt?: Date;
|
|
}
|
|
|
|
@ObjectType()
|
|
export class NotificationDBInterfaceSchema extends NotificationBaseSchema {}
|
|
|
|
@ObjectType()
|
|
export class NotificationDBSchema extends NotificationDBInterfaceSchema {}
|
|
|
|
@ObjectType({ implements: IEngineSchema })
|
|
export class NotificationSchema extends NotificationDBSchema implements IEngineSchema {
|
|
_id: string;
|
|
organisationId?: string | undefined;
|
|
by?: MetaBy | undefined;
|
|
permissions: MetaPermissions;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
}
|