Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonF committed Oct 4, 2024
2 parents 10ad931 + 0a75101 commit d4da31f
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { FilmModule } from './components/film/film.module';
import { FundingAccountModule } from './components/funding-account/funding-account.module';
import { LanguageModule } from './components/language/language.module';
import { LocationModule } from './components/location/location.module';
import { NotificationModule } from './components/notifications/notification.module';
import { OrganizationModule } from './components/organization/organization.module';
import { PartnerModule } from './components/partner/partner.module';
import { PartnershipProducingMediumModule } from './components/partnership-producing-medium/partnership-producing-medium.module';
Expand Down Expand Up @@ -89,6 +90,7 @@ if (process.env.NODE_ENV !== 'production') {
ProgressReportModule,
PromptsModule,
PnpExtractionResultModule,
NotificationModule,
],
})
export class AppModule {}
Expand Down
3 changes: 3 additions & 0 deletions src/components/notifications/dto/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './notification.dto';
export * from './notification-list.input';
export * from './mark-notification-read.args';
11 changes: 11 additions & 0 deletions src/components/notifications/dto/mark-notification-read.args.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ArgsType, Field } from '@nestjs/graphql';
import { ID, IdField } from '~/common';

@ArgsType()
export abstract class MarkNotificationReadArgs {
@IdField()
readonly id: ID<'Notification'>;

@Field(() => Boolean, { nullable: true })
readonly unread = false;
}
26 changes: 26 additions & 0 deletions src/components/notifications/dto/notification-list.input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Field, InputType, Int, ObjectType } from '@nestjs/graphql';
import { FilterField, PaginatedList, PaginationInput } from '~/common';
import { Notification } from './notification.dto';

@InputType()
export abstract class NotificationFilters {
@Field(() => Boolean, {
description: 'Only read/unread notifications',
nullable: true,
})
readonly unread?: boolean;
}

@InputType()
export class NotificationListInput extends PaginationInput {
@FilterField(() => NotificationFilters)
readonly filter?: NotificationFilters;
}

@ObjectType()
export class NotificationList extends PaginatedList(Notification) {
@Field(() => Int, {
description: 'The total number of unread notifications',
})
readonly totalUnread: number;
}
35 changes: 35 additions & 0 deletions src/components/notifications/dto/notification.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Field, InterfaceType, ObjectType } from '@nestjs/graphql';
import { keys as keysOf } from 'ts-transformer-keys';
import { Resource, SecuredProps } from '~/common';
import { LinkTo, RegisterResource } from '~/core/resources';

@RegisterResource()
@InterfaceType({
implements: [Resource],
})
export class Notification extends Resource {
static readonly Props = keysOf<Notification>();
static readonly SecuredProps = keysOf<SecuredProps<Notification>>();

readonly owner: LinkTo<'User'>;

@Field(() => Boolean)
readonly unread: boolean;
}

@ObjectType({
implements: [Notification],
})
export class SimpleTextNotification extends Notification {
@Field(() => String)
readonly content: string;
}

declare module '~/core/resources/map' {
interface ResourceMap {
Notification: typeof Notification;
}
// interface ResourceDBMap {
// Notification: typeof e.Notification;
// }
}
7 changes: 7 additions & 0 deletions src/components/notifications/notification.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { NotificationResolver } from './notification.resolver';

@Module({
providers: [NotificationResolver],
})
export class NotificationModule {}
32 changes: 32 additions & 0 deletions src/components/notifications/notification.resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
import {
ListArg,
LoggedInSession,
NotImplementedException,
Session,
} from '~/common';
import {
MarkNotificationReadArgs,
Notification,
NotificationList,
NotificationListInput,
} from './dto';

@Resolver()
export class NotificationResolver {
@Query(() => NotificationList)
async notifications(
@LoggedInSession() session: Session,
@ListArg(NotificationListInput) input: NotificationListInput,
): Promise<NotificationList> {
throw new NotImplementedException().with(input, session);
}

@Mutation(() => Notification)
async readNotification(
@LoggedInSession() session: Session,
@Args() input: MarkNotificationReadArgs,
): Promise<Notification> {
throw new NotImplementedException().with(input, session);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export class ProgressReportRepository extends DtoRepository<
relation('in', '', 'engagement'),
node('project', 'Project'),
])
.logIt()
.match(requestingUser(session))
.apply(progressReportFilters(input.filter))
.apply(
Expand Down

0 comments on commit d4da31f

Please sign in to comment.