From 6eb7a13770f056a38cdac6c039f7dcfb534a4310 Mon Sep 17 00:00:00 2001 From: John Brunton <1276413+jbrunton@users.noreply.github.com> Date: Mon, 23 Sep 2024 19:38:24 -0400 Subject: [PATCH] docs: architecture docs (#230) --- pnpm-lock.yaml | 19 ++++++ services/api/architecture.md | 60 +++++++++++++++++++ services/api/package.json | 1 + services/api/src/app/auth/auth.module.ts | 2 +- .../api/src/app/auth/casl.auth.service.ts | 2 +- .../src/app/auth/permissions/roles.spec.ts | 2 +- .../api/src/app/auth/permissions/roles.ts | 2 +- .../src/app/dispatcher/dispatcher.service.ts | 2 +- ...{command.service.ts => command-service.ts} | 0 .../api/src/app/messages/messages.module.ts | 2 +- .../src/app/messages/messages.service.spec.ts | 2 +- .../api/src/app/messages/messages.service.ts | 2 +- .../domain/entities/memberships/membership.ts | 4 -- ...h.service.spec.ts => auth-service.spec.ts} | 2 +- .../{auth.service.ts => auth-service.ts} | 0 .../usecases/commands/parse/parsed-command.ts | 2 +- .../memberships/approve-request.spec.ts | 2 +- .../usecases/memberships/approve-request.ts | 2 +- .../usecases/memberships/invite.spec.ts | 2 +- .../src/domain/usecases/memberships/invite.ts | 2 +- .../domain/usecases/memberships/join.spec.ts | 2 +- .../src/domain/usecases/memberships/join.ts | 2 +- .../domain/usecases/memberships/leave.spec.ts | 2 +- .../usecases/messages/get-messages.spec.ts | 2 +- .../domain/usecases/messages/get-messages.ts | 2 +- .../src/domain/usecases/messages/send.spec.ts | 2 +- .../api/src/domain/usecases/messages/send.ts | 2 +- .../domain/usecases/rooms/about-room.spec.ts | 2 +- .../src/domain/usecases/rooms/about-room.ts | 2 +- .../usecases/rooms/configure-room.spec.ts | 2 +- .../domain/usecases/rooms/configure-room.ts | 2 +- .../api/src/domain/usecases/rooms/get.spec.ts | 2 +- services/api/src/domain/usecases/rooms/get.ts | 2 +- .../src/domain/usecases/rooms/rename.spec.ts | 2 +- .../api/src/domain/usecases/rooms/rename.ts | 2 +- .../src/fixtures/auth/test-auth-service.ts | 2 +- services/api/tsdoc.json | 4 ++ services/api/typedoc.json | 11 +++- 38 files changed, 123 insertions(+), 36 deletions(-) create mode 100644 services/api/architecture.md rename services/api/src/app/messages/{command.service.ts => command-service.ts} (100%) rename services/api/src/domain/usecases/{auth.service.spec.ts => auth-service.spec.ts} (97%) rename services/api/src/domain/usecases/{auth.service.ts => auth-service.ts} (100%) create mode 100644 services/api/tsdoc.json diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 599fa5ce..7332cdd4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -417,6 +417,9 @@ importers: typedoc: specifier: 0.26.7 version: 0.26.7(typescript@5.6.2) + typedoc-plugin-mermaid: + specifier: 1.12.0 + version: 1.12.0(typedoc@0.26.7(typescript@5.6.2)) typescript: specifier: 5.6.2 version: 5.6.2 @@ -4633,6 +4636,9 @@ packages: html-escaper@2.0.2: resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} + html-escaper@3.0.3: + resolution: {integrity: sha512-RuMffC89BOWQoY0WKGpIhn5gX3iI54O6nRA0yC124NYVtzjmFWBIiFd8M0x+ZdX0P9R4lADg1mgP8C7PxGOWuQ==} + html-void-elements@3.0.0: resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==} @@ -7206,6 +7212,12 @@ packages: typedarray@0.0.6: resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} + typedoc-plugin-mermaid@1.12.0: + resolution: {integrity: sha512-CRjw29j0YbQEh4ygG7xeGjq8zKUikgd1BBBrW3ttzTeCPLrNKZopWFPd1/leSb9dUEJ3p9exOO84aP4CgjYp3g==} + engines: {node: '>=16.0.0'} + peerDependencies: + typedoc: '>=0.23.0 || 0.24.x || 0.25.x || 0.26.x' + typedoc@0.26.7: resolution: {integrity: sha512-gUeI/Wk99vjXXMi8kanwzyhmeFEGv1LTdTQsiyIsmSYsBebvFxhbcyAx7Zjo4cMbpLGxM4Uz3jVIjksu/I2v6Q==} engines: {node: '>= 18'} @@ -13414,6 +13426,8 @@ snapshots: html-escaper@2.0.2: {} + html-escaper@3.0.3: {} + html-void-elements@3.0.0: {} http-cache-semantics@4.1.1: {} @@ -16335,6 +16349,11 @@ snapshots: typedarray@0.0.6: {} + typedoc-plugin-mermaid@1.12.0(typedoc@0.26.7(typescript@5.6.2)): + dependencies: + html-escaper: 3.0.3 + typedoc: 0.26.7(typescript@5.6.2) + typedoc@0.26.7(typescript@5.6.2): dependencies: lunr: 2.3.9 diff --git a/services/api/architecture.md b/services/api/architecture.md new file mode 100644 index 00000000..4665f4db --- /dev/null +++ b/services/api/architecture.md @@ -0,0 +1,60 @@ +# Domain Architecture + +The domain is organised around these fundamental concepts: + +- {@link domain/entities/users/user | Users} represent authenticated users (or the {@link domain/entities/users/system-user | system user}). + +- {@link domain/entities/messages/message | Messages} refer to the messages sent by users and by the system. + +- {@link domain/entities/rooms/room | Rooms} are the message rooms users may join, to which messages are sent. + +- {@link domain/entities/memberships/membership | Memberships} represent the membership status history (`PendingApproval`, `Joined`, `Revoked`, etc.) of a user for a given room. This history is used to authorize users using an {@link domain/usecases/auth-service | AuthService}. + +## Messages + +The uniquely identifiable **entity** representing a message in the system is a {@link domain/entities/messages/message!SentMessage | SentMessage}. Before being sent, there are a few **value objects** which represent how messages are processed and dispatched: + +1. An {@link domain/entities/messages/message!IncomingMessage | IncomingMessage} represents a new message received by the system. At this point it has not been processed or stored. +2. A message prefixed with a forward slash (e.g. `/help`) is considered to be a command, represented by an {@link domain/entities/commands!IncomingCommand | IncomingCommand}. +3. A newly generated message which has not yet been dispatched is a {@link domain/entities/messages/message!DraftMessage | DraftMessage}. +4. A draft message is sent to the message {@link domain/entities/messages/message!Dispatcher | Dispatcher} which will sent the message to the appropriate room and store it in the room's history as a {@link domain/entities/messages/message!SentMessage | SentMessage}. + +The entrypoint to the messaging pipeline is the `MessagesService`. A simplified view of this service looks like this: + +```mermaid +stateDiagram + state MessagesService { + direction LR + state if_state <> + [*] --> if_state + if_state --> IncomingCommand: isCommand + if_state --> IncomingMessage: !isCommand + IncomingMessage --> Dispatcher + Dispatcher --> SentMessage + IncomingCommand --> CommandService + CommandService --> Dispatcher + } +``` + +## Commands + +A message identified as an `IncomingCommand` will be parsed and (if it is a valid command) executed. + +```mermaid +stateDiagram + state CommandService { + direction LR + [*] --> IncomingCommand + IncomingCommand --> TokenizedCommand : tokenize + TokenizedCommand --> ParsedCommand : parse + ParsedCommand --> Dispatcher : execute + Dispatcher + } +``` + +The {@link app/messages/command-service.CommandService | CommandService} applies the following steps to match parsed commands and execute them with the appropriate use case: + +- The {@link domain/usecases/commands/parse/tokenize-command.tokenizeCommand | tokenizeCommand} function perfoms a lexing role, tokenizing the incoming commmand based on whitespace and returning a {@link domain/usecases/commands/parse/tokenize-command.TokenizedCommand | TokenizedCommand} which allows for easy parsing. +- The {@link domain/usecases/commands/parse/parse-command.ParseCommandUseCase | ParseCommandUseCase} class parses tokenized commands, returning a {@link domain/usecases/commands/parse/parsed-command.ParsedCommand | ParsedCommand}, a type safe discriminated union of all possible commands. +- Once the command is parsed, the `CommandService` will match the parsed command and execute the corresponding use case. +- These use cases will update entities and send messages via the `Dispatcher` as appropriate. diff --git a/services/api/package.json b/services/api/package.json index ac2d67e8..58b2334c 100644 --- a/services/api/package.json +++ b/services/api/package.json @@ -105,6 +105,7 @@ "ts-node": "^10.0.0", "tsconfig-paths": "4.2.0", "typedoc": "0.26.7", + "typedoc-plugin-mermaid": "1.12.0", "typescript": "5.6.2" } } diff --git a/services/api/src/app/auth/auth.module.ts b/services/api/src/app/auth/auth.module.ts index 5dd03af7..05303ea2 100644 --- a/services/api/src/app/auth/auth.module.ts +++ b/services/api/src/app/auth/auth.module.ts @@ -1,5 +1,5 @@ import { Module } from '@nestjs/common'; -import { AuthService } from '@usecases/auth.service'; +import { AuthService } from '@usecases/auth-service'; import { CaslAuthService } from './casl.auth.service'; import { Auth0Module } from './auth0/auth0.module'; diff --git a/services/api/src/app/auth/casl.auth.service.ts b/services/api/src/app/auth/casl.auth.service.ts index 09f885fa..08b0ab6d 100644 --- a/services/api/src/app/auth/casl.auth.service.ts +++ b/services/api/src/app/auth/casl.auth.service.ts @@ -1,4 +1,4 @@ -import { AuthorizeParams, AuthService } from '@usecases/auth.service'; +import { AuthorizeParams, AuthService } from '@usecases/auth-service'; import { MembershipsRepository } from '@entities/memberships/memberships-repository'; import { ConsoleLogger, Injectable } from '@nestjs/common'; import { defineRolesForUser } from './permissions/roles'; diff --git a/services/api/src/app/auth/permissions/roles.spec.ts b/services/api/src/app/auth/permissions/roles.spec.ts index 30728ca5..06246749 100644 --- a/services/api/src/app/auth/permissions/roles.spec.ts +++ b/services/api/src/app/auth/permissions/roles.spec.ts @@ -3,7 +3,7 @@ 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'; -import { Role } from '@usecases/auth.service'; +import { Role } from '@usecases/auth-service'; describe('defineRolesForUser', () => { const user = UserFactory.build(); diff --git a/services/api/src/app/auth/permissions/roles.ts b/services/api/src/app/auth/permissions/roles.ts index 132735ad..c0df4e2c 100644 --- a/services/api/src/app/auth/permissions/roles.ts +++ b/services/api/src/app/auth/permissions/roles.ts @@ -6,7 +6,7 @@ import { } from '@entities/memberships/membership'; import { ContentPolicy, JoinPolicy } from '@entities/rooms/room'; import { User } from '@entities/users/user'; -import { Role } from '@usecases/auth.service'; +import { Role } from '@usecases/auth-service'; export const defineRolesForUser = (user: User, memberships: Membership[]) => { const { can, build } = new AbilityBuilder(createMongoAbility); diff --git a/services/api/src/app/dispatcher/dispatcher.service.ts b/services/api/src/app/dispatcher/dispatcher.service.ts index 6cb6c290..2ef3068e 100644 --- a/services/api/src/app/dispatcher/dispatcher.service.ts +++ b/services/api/src/app/dispatcher/dispatcher.service.ts @@ -7,7 +7,7 @@ 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 { AuthService, Role } from '@usecases/auth-service'; import { fromEvent, merge, Observable } from 'rxjs'; import { EventEmitter } from 'stream'; diff --git a/services/api/src/app/messages/command.service.ts b/services/api/src/app/messages/command-service.ts similarity index 100% rename from services/api/src/app/messages/command.service.ts rename to services/api/src/app/messages/command-service.ts diff --git a/services/api/src/app/messages/messages.module.ts b/services/api/src/app/messages/messages.module.ts index ee3280a4..e1a86266 100644 --- a/services/api/src/app/messages/messages.module.ts +++ b/services/api/src/app/messages/messages.module.ts @@ -5,7 +5,7 @@ import { AuthModule } from '@app/auth/auth.module'; import { SendMessageUseCase } from '@usecases/messages/send'; import { GetMessagesUseCase } from '@usecases/messages/get-messages'; import { ParseCommandUseCase } from '@usecases/commands/parse/parse-command'; -import { CommandService } from '@app/messages/command.service'; +import { CommandService } from '@app/messages/command-service'; import { RenameRoomUseCase } from '@usecases/rooms/rename'; import { RenameUserUseCase } from '@usecases/users/rename'; import { HelpCommandUseCase } from '@usecases/commands/help'; diff --git a/services/api/src/app/messages/messages.service.spec.ts b/services/api/src/app/messages/messages.service.spec.ts index 1a92e98d..3e10d365 100644 --- a/services/api/src/app/messages/messages.service.spec.ts +++ b/services/api/src/app/messages/messages.service.spec.ts @@ -5,7 +5,7 @@ import { RoomFactory } from '@fixtures/messages/room.factory'; 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 { CommandService } from './command-service'; import { UnauthorizedException } from '@nestjs/common'; import { systemUser } from '@entities/users/system-user'; import { IncomingCommand } from '@entities/commands'; diff --git a/services/api/src/app/messages/messages.service.ts b/services/api/src/app/messages/messages.service.ts index 3338632e..e5b9ad52 100644 --- a/services/api/src/app/messages/messages.service.ts +++ b/services/api/src/app/messages/messages.service.ts @@ -1,7 +1,7 @@ import { HttpException, Injectable } from '@nestjs/common'; import { CreateMessageDto } from './dto/messages'; import { SendMessageUseCase } from '@usecases/messages/send'; -import { CommandService } from '@app/messages/command.service'; +import { CommandService } from '@app/messages/command-service'; import { systemUser } from '@entities/users/system-user'; import { User } from '@entities/users/user'; import { IncomingMessage } from '@entities/messages/message'; diff --git a/services/api/src/domain/entities/memberships/membership.ts b/services/api/src/domain/entities/memberships/membership.ts index df1509d9..7d0aeed7 100644 --- a/services/api/src/domain/entities/memberships/membership.ts +++ b/services/api/src/domain/entities/memberships/membership.ts @@ -36,10 +36,6 @@ export enum MembershipStatus { * Record representing the membership status of a user in a room for a specific period. * * A user will have a history of zero or more non-overlapping `Membership` records for each room. - * - * There are a number of predicates available to assist with filtering: {@link isCurrent}, {@link isActive}, {@link forRoom}, etc. - * - * There are also convenience functions to determine the membership */ export type Membership = { /** diff --git a/services/api/src/domain/usecases/auth.service.spec.ts b/services/api/src/domain/usecases/auth-service.spec.ts similarity index 97% rename from services/api/src/domain/usecases/auth.service.spec.ts rename to services/api/src/domain/usecases/auth-service.spec.ts index a68cc2dc..86a9873c 100644 --- a/services/api/src/domain/usecases/auth.service.spec.ts +++ b/services/api/src/domain/usecases/auth-service.spec.ts @@ -1,6 +1,6 @@ import { AppLogger } from '@app/app.logger'; import { TestAuthService } from '@fixtures/auth/test-auth-service'; -import { Role } from './auth.service'; +import { Role } from './auth-service'; import { UserFactory } from '@fixtures/messages/user.factory'; import { RoomFactory } from '@fixtures/messages/room.factory'; import { UnauthorizedException } from '@nestjs/common'; diff --git a/services/api/src/domain/usecases/auth.service.ts b/services/api/src/domain/usecases/auth-service.ts similarity index 100% rename from services/api/src/domain/usecases/auth.service.ts rename to services/api/src/domain/usecases/auth-service.ts diff --git a/services/api/src/domain/usecases/commands/parse/parsed-command.ts b/services/api/src/domain/usecases/commands/parse/parsed-command.ts index 649d3c38..4e87f9fc 100644 --- a/services/api/src/domain/usecases/commands/parse/parsed-command.ts +++ b/services/api/src/domain/usecases/commands/parse/parsed-command.ts @@ -42,7 +42,7 @@ export type Command = { parse: CommandParser; }; -type CommandParserParams = { +export type CommandParserParams = { matchTokens: string[]; schema: CommandSchema; signature: string; diff --git a/services/api/src/domain/usecases/memberships/approve-request.spec.ts b/services/api/src/domain/usecases/memberships/approve-request.spec.ts index 427e05b6..b5215b66 100644 --- a/services/api/src/domain/usecases/memberships/approve-request.spec.ts +++ b/services/api/src/domain/usecases/memberships/approve-request.spec.ts @@ -6,7 +6,7 @@ import { RoomFactory } from '@fixtures/messages/room.factory'; import { UserFactory } from '@fixtures/messages/user.factory'; import { UnauthorizedException } from '@nestjs/common'; import { AppLogger } from '@app/app.logger'; -import { Role } from '@usecases/auth.service'; +import { Role } from '@usecases/auth-service'; import mock, { MockProxy } from 'jest-mock-extended/lib/Mock'; import { Dispatcher } from '@entities/messages/message'; import { TestUsersRepository } from '@data/repositories/test/test.users.repository'; diff --git a/services/api/src/domain/usecases/memberships/approve-request.ts b/services/api/src/domain/usecases/memberships/approve-request.ts index 8e558089..279a6311 100644 --- a/services/api/src/domain/usecases/memberships/approve-request.ts +++ b/services/api/src/domain/usecases/memberships/approve-request.ts @@ -8,7 +8,7 @@ import { RoomsRepository } from '@entities/rooms/rooms-repository'; import { User } from '@entities/users/user'; import { UsersRepository } from '@entities/users/users-repository'; import { Injectable } from '@nestjs/common'; -import { AuthService, Role } from '@usecases/auth.service'; +import { AuthService, Role } from '@usecases/auth-service'; export type ApproveRequestParams = { authenticatedUser: User; diff --git a/services/api/src/domain/usecases/memberships/invite.spec.ts b/services/api/src/domain/usecases/memberships/invite.spec.ts index 99155419..8a0ce92e 100644 --- a/services/api/src/domain/usecases/memberships/invite.spec.ts +++ b/services/api/src/domain/usecases/memberships/invite.spec.ts @@ -6,7 +6,7 @@ import { RoomFactory } from '@fixtures/messages/room.factory'; import { UserFactory } from '@fixtures/messages/user.factory'; import { UnauthorizedException } from '@nestjs/common'; import { AppLogger } from '@app/app.logger'; -import { Role } from '@usecases/auth.service'; +import { Role } from '@usecases/auth-service'; import mock, { MockProxy } from 'jest-mock-extended/lib/Mock'; import { Dispatcher } from '@entities/messages/message'; import { InviteUseCase } from './invite'; diff --git a/services/api/src/domain/usecases/memberships/invite.ts b/services/api/src/domain/usecases/memberships/invite.ts index 390c94e7..f64707d2 100644 --- a/services/api/src/domain/usecases/memberships/invite.ts +++ b/services/api/src/domain/usecases/memberships/invite.ts @@ -1,4 +1,4 @@ -import { AuthService, Role } from '@usecases/auth.service'; +import { AuthService, Role } from '@usecases/auth-service'; import { MembershipStatus, getMembershipStatus, diff --git a/services/api/src/domain/usecases/memberships/join.spec.ts b/services/api/src/domain/usecases/memberships/join.spec.ts index b076b7ff..b1862879 100644 --- a/services/api/src/domain/usecases/memberships/join.spec.ts +++ b/services/api/src/domain/usecases/memberships/join.spec.ts @@ -7,7 +7,7 @@ import { UserFactory } from '@fixtures/messages/user.factory'; import { UnauthorizedException } from '@nestjs/common'; import { JoinRoomUseCase } from './join'; import { AppLogger } from '@app/app.logger'; -import { Role } from '@usecases/auth.service'; +import { Role } from '@usecases/auth-service'; import mock, { MockProxy } from 'jest-mock-extended/lib/Mock'; import { Dispatcher } from '@entities/messages/message'; diff --git a/services/api/src/domain/usecases/memberships/join.ts b/services/api/src/domain/usecases/memberships/join.ts index eaadf838..e8d3e988 100644 --- a/services/api/src/domain/usecases/memberships/join.ts +++ b/services/api/src/domain/usecases/memberships/join.ts @@ -1,4 +1,4 @@ -import { AuthService, Role } from '@usecases/auth.service'; +import { AuthService, Role } from '@usecases/auth-service'; import { MembershipStatus } from '@entities/memberships/membership'; import { MembershipsRepository } from '@entities/memberships/memberships-repository'; import { RoomsRepository } from '@entities/rooms/rooms-repository'; diff --git a/services/api/src/domain/usecases/memberships/leave.spec.ts b/services/api/src/domain/usecases/memberships/leave.spec.ts index 6eb08676..41d316eb 100644 --- a/services/api/src/domain/usecases/memberships/leave.spec.ts +++ b/services/api/src/domain/usecases/memberships/leave.spec.ts @@ -5,7 +5,7 @@ import { TestRoomsRepository } from '@data/repositories/test/test.rooms.reposito import { RoomFactory } from '@fixtures/messages/room.factory'; import { UserFactory } from '@fixtures/messages/user.factory'; import { AppLogger } from '@app/app.logger'; -import { Role } from '@usecases/auth.service'; +import { Role } from '@usecases/auth-service'; import mock, { MockProxy } from 'jest-mock-extended/lib/Mock'; import { Dispatcher, UpdatedEntity } from '@entities/messages/message'; import { LeaveRoomUseCase } from './leave'; diff --git a/services/api/src/domain/usecases/messages/get-messages.spec.ts b/services/api/src/domain/usecases/messages/get-messages.spec.ts index f9653521..fc89cea2 100644 --- a/services/api/src/domain/usecases/messages/get-messages.spec.ts +++ b/services/api/src/domain/usecases/messages/get-messages.spec.ts @@ -7,7 +7,7 @@ import { TestAuthService } from '@fixtures/auth/test-auth-service'; import { MessageFactory } from '@fixtures/messages/message.factory'; import { UnauthorizedException } from '@nestjs/common'; import { AppLogger } from '@app/app.logger'; -import { Role } from '@usecases/auth.service'; +import { Role } from '@usecases/auth-service'; import { mock } from 'jest-mock-extended'; describe('GetMessagesUseCase', () => { diff --git a/services/api/src/domain/usecases/messages/get-messages.ts b/services/api/src/domain/usecases/messages/get-messages.ts index 44ed983a..b360deee 100644 --- a/services/api/src/domain/usecases/messages/get-messages.ts +++ b/services/api/src/domain/usecases/messages/get-messages.ts @@ -1,4 +1,4 @@ -import { Role, AuthService } from '@usecases/auth.service'; +import { Role, AuthService } from '@usecases/auth-service'; import { RoomsRepository } from '@entities/rooms/rooms-repository'; import { User } from '@entities/users/user'; import { Injectable } from '@nestjs/common'; diff --git a/services/api/src/domain/usecases/messages/send.spec.ts b/services/api/src/domain/usecases/messages/send.spec.ts index e9a63bf4..70ac284c 100644 --- a/services/api/src/domain/usecases/messages/send.spec.ts +++ b/services/api/src/domain/usecases/messages/send.spec.ts @@ -7,7 +7,7 @@ import { SendMessageUseCase } from './send'; import { Dispatcher, DraftMessage } from '@entities/messages/message'; import { mock, MockProxy } from 'jest-mock-extended'; import { AppLogger } from '@app/app.logger'; -import { Role } from '@usecases/auth.service'; +import { Role } from '@usecases/auth-service'; describe('SendMessageUseCase', () => { let sendMessage: SendMessageUseCase; diff --git a/services/api/src/domain/usecases/messages/send.ts b/services/api/src/domain/usecases/messages/send.ts index 70464344..16be830c 100644 --- a/services/api/src/domain/usecases/messages/send.ts +++ b/services/api/src/domain/usecases/messages/send.ts @@ -2,7 +2,7 @@ import { Dispatcher, DraftMessage } from '@entities/messages/message'; import { RoomsRepository } from '@entities/rooms/rooms-repository'; import { User } from '@entities/users/user'; import { Injectable } from '@nestjs/common'; -import { Role, AuthService } from '@usecases/auth.service'; +import { Role, AuthService } from '@usecases/auth-service'; @Injectable() export class SendMessageUseCase { diff --git a/services/api/src/domain/usecases/rooms/about-room.spec.ts b/services/api/src/domain/usecases/rooms/about-room.spec.ts index 8526a20e..ebf4c32a 100644 --- a/services/api/src/domain/usecases/rooms/about-room.spec.ts +++ b/services/api/src/domain/usecases/rooms/about-room.spec.ts @@ -4,7 +4,7 @@ import { RoomFactory } from '@fixtures/messages/room.factory'; import { UserFactory } from '@fixtures/messages/user.factory'; import { UnauthorizedException } from '@nestjs/common'; import { AppLogger } from '@app/app.logger'; -import { Role } from '@usecases/auth.service'; +import { Role } from '@usecases/auth-service'; import mock, { MockProxy } from 'jest-mock-extended/lib/Mock'; import { Dispatcher } from '@entities/messages/message'; import { AboutRoomUseCase } from './about-room'; diff --git a/services/api/src/domain/usecases/rooms/about-room.ts b/services/api/src/domain/usecases/rooms/about-room.ts index efb28dfa..e824bfa4 100644 --- a/services/api/src/domain/usecases/rooms/about-room.ts +++ b/services/api/src/domain/usecases/rooms/about-room.ts @@ -3,7 +3,7 @@ import { RoomsRepository } from '@entities/rooms/rooms-repository'; import { User } from '@entities/users/user'; import { UsersRepository } from '@entities/users/users-repository'; import { Injectable } from '@nestjs/common'; -import { AuthService, Role } from '@usecases/auth.service'; +import { AuthService, Role } from '@usecases/auth-service'; export type AboutRoomParams = { authenticatedUser: User; diff --git a/services/api/src/domain/usecases/rooms/configure-room.spec.ts b/services/api/src/domain/usecases/rooms/configure-room.spec.ts index 1b0f6094..a143a925 100644 --- a/services/api/src/domain/usecases/rooms/configure-room.spec.ts +++ b/services/api/src/domain/usecases/rooms/configure-room.spec.ts @@ -6,7 +6,7 @@ import { UserFactory } from '@fixtures/messages/user.factory'; import { UnauthorizedException } from '@nestjs/common'; import { Dispatcher } from '@entities/messages/message'; import { AppLogger } from '@app/app.logger'; -import { Role } from '@usecases/auth.service'; +import { Role } from '@usecases/auth-service'; import { ConfigureRoomUseCase } from './configure-room'; import { ContentPolicy, JoinPolicy } from '@entities/rooms/room'; diff --git a/services/api/src/domain/usecases/rooms/configure-room.ts b/services/api/src/domain/usecases/rooms/configure-room.ts index 479dae78..52f55339 100644 --- a/services/api/src/domain/usecases/rooms/configure-room.ts +++ b/services/api/src/domain/usecases/rooms/configure-room.ts @@ -7,7 +7,7 @@ import { ContentPolicy, JoinPolicy } from '@entities/rooms/room'; import { RoomsRepository } from '@entities/rooms/rooms-repository'; import { User } from '@entities/users/user'; import { Injectable } from '@nestjs/common'; -import { AuthService, Role } from '@usecases/auth.service'; +import { AuthService, Role } from '@usecases/auth-service'; export type ConfigureRoomParams = { roomId: string; diff --git a/services/api/src/domain/usecases/rooms/get.spec.ts b/services/api/src/domain/usecases/rooms/get.spec.ts index 5de54395..dcec660c 100644 --- a/services/api/src/domain/usecases/rooms/get.spec.ts +++ b/services/api/src/domain/usecases/rooms/get.spec.ts @@ -4,7 +4,7 @@ import { RoomFactory } from '@fixtures/messages/room.factory'; import { UserFactory } from '@fixtures/messages/user.factory'; import { GetRoomUseCase } from './get'; import { AppLogger } from '@app/app.logger'; -import { Role } from '@usecases/auth.service'; +import { Role } from '@usecases/auth-service'; import { TestMembershipsRepository } from '@data/repositories/test/test.memberships.repository'; import { MembershipStatus } from '@entities/memberships/membership'; diff --git a/services/api/src/domain/usecases/rooms/get.ts b/services/api/src/domain/usecases/rooms/get.ts index 93770d95..ef2b4e3c 100644 --- a/services/api/src/domain/usecases/rooms/get.ts +++ b/services/api/src/domain/usecases/rooms/get.ts @@ -1,4 +1,4 @@ -import { AuthService, Role } from '@usecases/auth.service'; +import { AuthService, Role } from '@usecases/auth-service'; import { Room } from '@entities/rooms/room'; import { RoomsRepository } from '@entities/rooms/rooms-repository'; import { User } from '@entities/users/user'; diff --git a/services/api/src/domain/usecases/rooms/rename.spec.ts b/services/api/src/domain/usecases/rooms/rename.spec.ts index 60514903..f04a0329 100644 --- a/services/api/src/domain/usecases/rooms/rename.spec.ts +++ b/services/api/src/domain/usecases/rooms/rename.spec.ts @@ -7,7 +7,7 @@ import { UserFactory } from '@fixtures/messages/user.factory'; import { UnauthorizedException } from '@nestjs/common'; import { Dispatcher } from '@entities/messages/message'; import { AppLogger } from '@app/app.logger'; -import { Role } from '@usecases/auth.service'; +import { Role } from '@usecases/auth-service'; describe('RenameRoomUseCase', () => { let rename: RenameRoomUseCase; diff --git a/services/api/src/domain/usecases/rooms/rename.ts b/services/api/src/domain/usecases/rooms/rename.ts index d6794987..7057bf38 100644 --- a/services/api/src/domain/usecases/rooms/rename.ts +++ b/services/api/src/domain/usecases/rooms/rename.ts @@ -1,4 +1,4 @@ -import { AuthService, Role } from '@usecases/auth.service'; +import { AuthService, Role } from '@usecases/auth-service'; import { RoomsRepository } from '@entities/rooms/rooms-repository'; import { User } from '@entities/users/user'; import { Injectable } from '@nestjs/common'; diff --git a/services/api/src/fixtures/auth/test-auth-service.ts b/services/api/src/fixtures/auth/test-auth-service.ts index 78351769..286f5828 100644 --- a/services/api/src/fixtures/auth/test-auth-service.ts +++ b/services/api/src/fixtures/auth/test-auth-service.ts @@ -1,4 +1,4 @@ -import { AuthService, AuthorizeParams } from '@usecases/auth.service'; +import { AuthService, AuthorizeParams } from '@usecases/auth-service'; import { equals } from 'rambda'; type Permission = Omit; diff --git a/services/api/tsdoc.json b/services/api/tsdoc.json new file mode 100644 index 00000000..a8053fc4 --- /dev/null +++ b/services/api/tsdoc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "extends": ["typedoc-plugin-mermaid/tsdoc.json"] +} diff --git a/services/api/typedoc.json b/services/api/typedoc.json index e05f41ad..963c27aa 100644 --- a/services/api/typedoc.json +++ b/services/api/typedoc.json @@ -1,7 +1,14 @@ { // Comments are supported, like tsconfig.json - "entryPoints": ["src/**"], - "exclude": ["src/**/*.spec.ts"], + "entryPoints": ["src/**/*.ts"], + "exclude": [ + "src/**/*.spec.ts", + "src/fixtures/**/*.ts", + "**/@types/passport-strategy/index.d.ts" + ], "entryPointStrategy": "resolve", + "projectDocuments": ["architecture.md"], + "plugin": ["typedoc-plugin-mermaid"], + "treatValidationWarningsAsErrors": true, "out": "docs" }