import { ObjectType, Field, ArgsType } from 'type-graphql'; import { BaseGraphModel } from '@seed/graphql/BaseGraphModel'; import { Permission } from '@seed/interfaces/permission'; import { GetArgs, GetManyArgs } from '@seed/graphql/Request'; import { AccountTypeEnum } from '@src/accounts/account.components'; import { StreamOperationType, PostHookStatus } from './change-stream.components'; import GraphQLJSON from 'graphql-type-json'; const permissions: Permission = { c: [AccountTypeEnum.admin], r: [AccountTypeEnum.admin], w: [AccountTypeEnum.admin], d: [AccountTypeEnum.admin], }; @ObjectType() export default class ChangeStreamModel extends BaseGraphModel { public constructor() { super({ //!!\\ Hard coded, do not change ! collectionName: 'stream.changes', permissions: permissions, }); } @Field(() => StreamOperationType) operation: StreamOperationType; @Field() collection: string; @Field() documentKey: string; @Field(() => PostHookStatus) hookStatus: PostHookStatus; @Field({ nullable: true }) logMessage?: string; @Field(() => GraphQLJSON, { nullable: true }) insertedValues?: Partial; @Field(() => GraphQLJSON, { nullable: true }) updatedValues?: Partial; @Field(() => GraphQLJSON, { nullable: true }) beforeUpdateValues?: Partial; logInfo?: any; searchOptions(): string[] { return ['documentKey', 'hookStatus']; } filterOptions(): string[] { return ['documentKey', 'hookStatus']; } } @ArgsType() export class ChangeStreamArgs extends GetManyArgs { @Field({ nullable: true }) documentKey?: string; @Field({ nullable: true }) hookStatus?: string; }