Skip to content

Commit

Permalink
Merge pull request #227 from jbrunton/refactor-entities
Browse files Browse the repository at this point in the history
refactor: entity file names
  • Loading branch information
jbrunton authored Sep 21, 2024
2 parents 5ece6f8 + 90ef5f8 commit 6e3c725
Show file tree
Hide file tree
Showing 78 changed files with 189 additions and 148 deletions.
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/chat-demo.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/api/src/app/auth/auth0/identify.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import { User } from '@entities/users/user.entity';
import { User } from '@entities/users/user';

export const Identify = createParamDecorator(
async (_data: unknown, ctx: ExecutionContext): Promise<User> => {
Expand Down
4 changes: 2 additions & 2 deletions services/api/src/app/auth/auth0/identify.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { User } from '@entities/users/user.entity';
import { User } from '@entities/users/user';
import {
ConsoleLogger,
Injectable,
Expand All @@ -11,7 +11,7 @@ import { Auth0Client } from '../auth0/auth0.client';
import {
UsersRepository,
userParamsFromAuth,
} from '@entities/users/users.repository';
} from '@entities/users/users-repository';

const extractAccessToken = ExtractJwt.fromAuthHeaderAsBearerToken();

Expand Down
2 changes: 1 addition & 1 deletion services/api/src/app/auth/auth0/jwt.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ExtractJwt, Strategy } from 'passport-jwt';
import { passportJwtSecret } from 'jwks-rsa';
import { config } from './auth0.config';
import { Request } from 'express';
import { User } from '@entities/users/user.entity';
import { User } from '@entities/users/user';
import { IdentifyService } from './identify.service';

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/app/auth/casl.auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AuthorizeParams, AuthService } from '@usecases/auth.service';
import { MembershipsRepository } from '@entities/memberships.repository';
import { MembershipsRepository } from '@entities/memberships/memberships-repository';
import { ConsoleLogger, Injectable } from '@nestjs/common';
import { defineRolesForUser } from './permissions/roles';

Expand Down
4 changes: 2 additions & 2 deletions services/api/src/app/auth/permissions/roles.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Membership, MembershipStatus } from '@entities/membership.entity';
import { ContentPolicy, JoinPolicy } from '@entities/room.entity';
import { Membership, MembershipStatus } from '@entities/memberships/membership';
import { ContentPolicy, JoinPolicy } from '@entities/rooms/room';
import { RoomFactory } from '@fixtures/messages/room.factory';
import { UserFactory } from '@fixtures/messages/user.factory';
import { defineRolesForUser } from './roles';
Expand Down
6 changes: 3 additions & 3 deletions services/api/src/app/auth/permissions/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
Membership,
MembershipStatus,
getRoomsWithStatus,
} from '@entities/membership.entity';
import { ContentPolicy, JoinPolicy } from '@entities/room.entity';
import { User } from '@entities/users/user.entity';
} from '@entities/memberships/membership';
import { ContentPolicy, JoinPolicy } from '@entities/rooms/room';
import { User } from '@entities/users/user';
import { Role } from '@usecases/auth.service';

export const defineRolesForUser = (user: User, memberships: Membership[]) => {
Expand Down
6 changes: 3 additions & 3 deletions services/api/src/app/dispatcher/dispatcher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
DraftMessage,
isPrivate,
} from '@entities/messages/message';
import { MessagesRepository } from '@entities/messages/messages.repository';
import { RoomsRepository } from '@entities/rooms.repository';
import { User } from '@entities/users/user.entity';
import { MessagesRepository } from '@entities/messages/messages-repository';
import { RoomsRepository } from '@entities/rooms/rooms-repository';
import { User } from '@entities/users/user';
import { ConsoleLogger, Injectable } from '@nestjs/common';
import { AuthService, Role } from '@usecases/auth.service';
import { fromEvent, merge, Observable } from 'rxjs';
Expand Down
4 changes: 2 additions & 2 deletions services/api/src/app/messages/command.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command } from '@entities/command.entity';
import { User } from '@entities/users/user.entity';
import { Command } from '@entities/command';
import { User } from '@entities/users/user';
import { Injectable } from '@nestjs/common';
import { HelpCommandUseCase } from '@usecases/commands/help';
import { RenameRoomUseCase } from '@usecases/rooms/rename';
Expand Down
12 changes: 6 additions & 6 deletions services/api/src/app/messages/messages.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import {
resetFakeAuthUsers,
} from '@fixtures/auth/FakeAuth';
import { MessageFactory } from '@fixtures/messages/message.factory';
import { UsersRepository } from '@entities/users/users.repository';
import { MessagesRepository } from '@entities/messages/messages.repository';
import { UsersRepository } from '@entities/users/users-repository';
import { MessagesRepository } from '@entities/messages/messages-repository';
import { TestUsersRepository } from '@data/repositories/test/test.users.repository';
import { TestMessagesRepository } from '@data/repositories/test/test.messages.repository';
import { Room } from '@entities/room.entity';
import { RoomsRepository } from '@entities/rooms.repository';
import { Room } from '@entities/rooms/room';
import { RoomsRepository } from '@entities/rooms/rooms-repository';
import { TestRoomsRepository } from '@data/repositories/test/test.rooms.repository';
import { RoomFactory } from '@fixtures/messages/room.factory';
import { CreateMessageDto } from './dto/messages';
import { TestMembershipsRepository } from '@data/repositories/test/test.memberships.repository';
import { MembershipsRepository } from '@entities/memberships.repository';
import { MembershipStatus } from '@entities/membership.entity';
import { MembershipsRepository } from '@entities/memberships/memberships-repository';
import { MembershipStatus } from '@entities/memberships/membership';
import { MessagesModule } from './messages.module';
import { Auth0Client } from '@app/auth/auth0/auth0.client';
import { MockLoggerModule } from '@fixtures/MockLoggerModule';
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/app/messages/messages.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MessagesService } from './messages.service';
import { CreateMessageDto, SentMessageDto } from './dto/messages';
import { Auth } from '@app/auth/auth.decorator';
import { Identify } from '@app/auth/auth0/identify.decorator';
import { User } from '@entities/users/user.entity';
import { User } from '@entities/users/user';
import { Dispatcher } from '@entities/messages/message';
import { GetMessagesUseCase } from '@usecases/messages/get-messages';
import { ApiBearerAuth, ApiOperation, ApiResponse } from '@nestjs/swagger';
Expand Down
6 changes: 3 additions & 3 deletions services/api/src/app/messages/messages.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { MessagesService } from './messages.service';
import { CreateMessageDto } from './dto/messages';
import { UserFactory } from '@fixtures/messages/user.factory';
import { RoomFactory } from '@fixtures/messages/room.factory';
import { User } from '@entities/users/user.entity';
import { User } from '@entities/users/user';
import { mock, MockProxy } from 'jest-mock-extended';
import { SendMessageUseCase } from '@usecases/messages/send';
import { CommandService } from './command.service';
import { Command } from '@entities/command.entity';
import { Command } from '@entities/command';
import { UnauthorizedException } from '@nestjs/common';
import { systemUser } from '@entities/users/system';
import { systemUser } from '@entities/users/system-user';

describe('MessagesService', () => {
let service: MessagesService;
Expand Down
4 changes: 2 additions & 2 deletions services/api/src/app/messages/messages.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { CreateMessageDto } from './dto/messages';
import { SendMessageUseCase } from '@usecases/messages/send';
import { CommandService } from '@app/messages/command.service';
import { isCommand, parseMessage } from '@usecases/messages/parse-message';
import { systemUser } from '@entities/users/system';
import { User } from '@entities/users/user.entity';
import { systemUser } from '@entities/users/system-user';
import { User } from '@entities/users/user';

@Injectable()
export class MessagesService {
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/app/rooms/rooms.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Auth } from '@app/auth/auth.decorator';
import { Identify } from '@app/auth/auth0/identify.decorator';
import { ConsoleLogger, Controller, Get, Param, Post } from '@nestjs/common';
import { User } from '@entities/users/user.entity';
import { User } from '@entities/users/user';
import { CreateRoomUseCase } from '@usecases/rooms/create';
import { GetRoomUseCase } from '@usecases/rooms/get';
import { JoinRoomUseCase } from '@usecases/memberships/join';
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/app/users/users.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Auth } from '@app/auth/auth.decorator';
import { Identify } from '@app/auth/auth0/identify.decorator';
import { User } from '@entities/users/user.entity';
import { User } from '@entities/users/user';
import { Controller, Get, Param } from '@nestjs/common';
import { UsersService } from './users.service';

Expand Down
14 changes: 7 additions & 7 deletions services/api/src/app/users/users.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getActiveRooms } from '@entities/membership.entity';
import { MembershipsRepository } from '@entities/memberships.repository';
import { Room } from '@entities/room.entity';
import { RoomsRepository } from '@entities/rooms.repository';
import { systemUser } from '@entities/users/system';
import { User } from '@entities/users/user.entity';
import { UsersRepository } from '@entities/users/users.repository';
import { getActiveRooms } from '@entities/memberships/membership';
import { MembershipsRepository } from '@entities/memberships/memberships-repository';
import { Room } from '@entities/rooms/room';
import { RoomsRepository } from '@entities/rooms/rooms-repository';
import { systemUser } from '@entities/users/system-user';
import { User } from '@entities/users/user';
import { UsersRepository } from '@entities/users/users-repository';
import { Injectable } from '@nestjs/common';

@Injectable()
Expand Down
4 changes: 2 additions & 2 deletions services/api/src/data/adapters/dynamodb/schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MembershipStatus } from '@entities/membership.entity';
import { ContentPolicy, JoinPolicy } from '@entities/room.entity';
import { MembershipStatus } from '@entities/memberships/membership';
import { ContentPolicy, JoinPolicy } from '@entities/rooms/room';
import { Entity } from 'dynamodb-onetable';

export const DbSchema = {
Expand Down
8 changes: 4 additions & 4 deletions services/api/src/data/data.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Global, Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import databaseConfig from '@config/database.config';
import { DynamoDBMessagesRepository } from './repositories/dynamodb/dynamodb.messages.repository';
import { RoomsRepository } from '@entities/rooms.repository';
import { RoomsRepository } from '@entities/rooms/rooms-repository';
import { DynamoDBUsersRepository } from './repositories/dynamodb/dynamodb.users.repository';
import { DynamoDBAdapter } from './adapters/dynamodb/dynamodb.adapter';
import { DynamoDBRoomsRepository } from './repositories/dynamodb/dynamodb.rooms.repository';
import { MembershipsRepository } from '@entities/memberships.repository';
import { MembershipsRepository } from '@entities/memberships/memberships-repository';
import { DynamoDBMembershipsRepository } from './repositories/dynamodb/dynamodb.memberships.repository';
import { MessagesRepository } from '@entities/messages/messages.repository';
import { UsersRepository } from '@entities/users/users.repository';
import { MessagesRepository } from '@entities/messages/messages-repository';
import { UsersRepository } from '@entities/users/users-repository';

export const DatabaseConfigModule = ConfigModule.forFeature(databaseConfig);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MembershipStatus } from '@entities/membership.entity';
import { CreateMembershipParams } from '@entities/memberships.repository';
import { MembershipStatus } from '@entities/memberships/membership';
import { CreateMembershipParams } from '@entities/memberships/memberships-repository';
import { TestMembershipsRepository } from '@data/repositories/test/test.memberships.repository';
import { RoomFactory } from '@fixtures/messages/room.factory';
import { UserFactory } from '@fixtures/messages/user.factory';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DynamoDBRoomsRepository } from '@data/repositories/dynamodb/dynamodb.rooms.repository';
import { ContentPolicy, JoinPolicy } from '@entities/room.entity';
import { CreateRoomParams } from '@entities/rooms.repository';
import { ContentPolicy, JoinPolicy } from '@entities/rooms/room';
import { CreateRoomParams } from '@entities/rooms/rooms-repository';
import { TestRoomsRepository } from '@data/repositories/test/test.rooms.repository';
import { Test } from '@nestjs/testing';
import { DataModule } from '../data.module';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DataModule } from '../data.module';
import { MockLoggerModule } from '@fixtures/MockLoggerModule';
import { AuthInfoFactory } from '@fixtures/auth/auth-info.factory';
import { omit } from 'remeda';
import { userParamsFromAuth } from '@entities/users/users.repository';
import { userParamsFromAuth } from '@entities/users/users-repository';

type TestCase = {
name: 'DynamoDBUsersRepository' | 'TestUsersRepository';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Membership } from '@entities/membership.entity';
import { Membership } from '@entities/memberships/membership';
import {
CreateMembershipParams,
MembershipsRepository,
} from '@entities/memberships.repository';
} from '@entities/memberships/memberships-repository';
import { Injectable } from '@nestjs/common';
import { pick } from 'rambda';
import { DynamoDBAdapter } from '../../adapters/dynamodb/dynamodb.adapter';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { pick } from 'rambda';
import { DynamoDBAdapter } from '../../adapters/dynamodb/dynamodb.adapter';
import { DbMessage } from '../../adapters/dynamodb/schema';
import { DraftMessage, SentMessage } from '@entities/messages/message';
import { MessagesRepository } from '@entities/messages/messages.repository';
import { MessagesRepository } from '@entities/messages/messages-repository';

@Injectable()
export class DynamoDBMessagesRepository extends MessagesRepository {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { subject } from '@casl/ability';
import { Room } from '@entities/room.entity';
import { Room } from '@entities/rooms/room';
import {
CreateRoomParams,
RoomsRepository,
UpdateRoomParams,
} from '@entities/rooms.repository';
} from '@entities/rooms/rooms-repository';
import { Injectable, NotFoundException } from '@nestjs/common';
import { pick } from 'rambda';
import { DynamoDBAdapter } from '../../adapters/dynamodb/dynamodb.adapter';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
UsersRepository,
SaveUserParams,
UpdateUserParams,
} from '@entities/users/users.repository';
import { User } from '@entities/users/user.entity';
} from '@entities/users/users-repository';
import { User } from '@entities/users/user';

@Injectable()
export class DynamoDBUsersRepository extends UsersRepository {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
CreateMembershipParams,
MembershipsRepository,
} from '@entities/memberships.repository';
import { Membership } from '@entities/membership.entity';
} from '@entities/memberships/memberships-repository';
import { Membership } from '@entities/memberships/membership';

export class TestMembershipsRepository extends MembershipsRepository {
private memberships: Membership[] = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SentMessage, DraftMessage } from '@entities/messages/message';
import { MessagesRepository } from '@entities/messages/messages.repository';
import { MessagesRepository } from '@entities/messages/messages-repository';
import * as R from 'rambda';

export class TestMessagesRepository extends MessagesRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
CreateRoomParams,
RoomsRepository,
UpdateRoomParams,
} from '@entities/rooms.repository';
import { Room } from '@entities/room.entity';
} from '@entities/rooms/rooms-repository';
import { Room } from '@entities/rooms/room';
import { faker } from '@faker-js/faker';
import { subject } from '@casl/ability';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { NotFoundException } from '@nestjs/common';
import {
UsersRepository,
UpdateUserParams,
} from '@entities/users/users.repository';
import { User } from '@entities/users/user.entity';
} from '@entities/users/users-repository';
import { User } from '@entities/users/user';

export class TestUsersRepository extends UsersRepository {
private users: User[] = [];
Expand Down
12 changes: 6 additions & 6 deletions services/api/src/domain/entities/auth.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export interface AuthInfo {
sub: string;
name?: string;
given_name?: string;
family_name?: string;
nickname?: string;
// given_name?: string;
// family_name?: string;
// nickname?: string;
picture?: string;
locale?: string;
updated_at?: number | string;
// locale?: string;
// updated_at?: number | string;
email?: string;
email_verified?: boolean;
// email_verified?: boolean;
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Membership, MembershipStatus } from './membership.entity';
import { Membership, MembershipStatus } from './membership';

export type CreateMembershipParams = Pick<
Membership,
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/domain/entities/messages/message.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Observable } from 'rxjs';
import { User } from '../users/user.entity';
import { User } from '../users/user';

export enum UpdatedEntity {
Room = 'room',
Expand Down
Loading

0 comments on commit 6e3c725

Please sign in to comment.