Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: event scope #8

Merged
merged 11 commits into from
Sep 30, 2024
91 changes: 49 additions & 42 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Essas variáveis são usadas no arquivo [docker-compose.yml](./docker-compose.ym
> [!IMPORTANT]
> Primeiro preencha os valores para `DB_USER`, `DB_PASS`, `JWT_SECRET` no arquivo [.env](./.env), salve e só depois disso execute o docker.


```sh
docker compose up -d
```
Expand Down Expand Up @@ -63,7 +62,6 @@ Preparei alguns seeds pra você importar na base de dados, mas primeiro verifiqu
> [!NOTE]
> Ele é necessário apenas para importar dados iniciais não obrigatórios, como dados de login com permissões distintas e todas as cidades do brasil com latitude e longitude.


Para importar execute, não se esqueça de colocar seu usuário no `--username=seu-user` configurado no [`.env`](./.env). Ao executar, ele irá solicitar a senha que foi configurada no mesmo arquivo.

### Cidades
Expand All @@ -78,6 +76,19 @@ mongoimport --host=localhost --port=27017 --username= --authenticationDatabase=a
mongoimport --host=localhost --port=27017 --username= --authenticationDatabase=admin --db=devparana --collection=accountcollections --file=assets/seeds/account-collection.json
```

Usuários que serão cadastrados

| username | password | member | speaker | donor | leader | staff | fellow | manager | director |
| -------- | -------- | :----: | :-----: | :---: | :----: | :---: | :----: | :-----: | :------: |
| member | member | [x] | [ ] | [ ] | [ ] | [ ] | [ ] | [ ] | [ ] |
| speaker | speaker | [x] | [x] | [ ] | [ ] | [ ] | [ ] | [ ] | [ ] |
| donor | donor123 | [x] | [ ] | [x] | [ ] | [ ] | [ ] | [ ] | [ ] |
| leader | leader | [x] | [ ] | [ ] | [x] | [ ] | [ ] | [ ] | [ ] |
| staff | staff123 | [x] | [ ] | [ ] | [ ] | [x] | [ ] | [ ] | [ ] |
| fellow | fellow | [x] | [ ] | [ ] | [ ] | [ ] | [x] | [ ] | [ ] |
| manager | manager | [x] | [ ] | [ ] | [ ] | [ ] | [ ] | [x] | [ ] |
| director | director | [x] | [ ] | [ ] | [ ] | [ ] | [ ] | [ ] | [x] |

## Agora sim!

Agora tudo está configurado pra você executar em desenvolvimento, configurei a execução do back-end e front-end no mesmo comando a seguir.
Expand All @@ -96,14 +107,12 @@ Os commits podem ser feitos em português, mas use inglês para termos técnicos
> [!TIP]
> Use o comando `pnpm commit`, e apenas responda as perguntas, assim seu commit seguirá a convenção utilizada.


## Arquitetura

Trata-se de responsabilidade e relacionamentos, ou seja, qual a responsabilidade de cada camada e quais camadas podem depender diretamente uma das outras. Esta é uma convenção chamada [enforce module boundaries](https://nx.dev/features/enforce-module-boundaries#enforce-module-boundaries) e quem permite que as regras sejam aplicadas é o [nx](https://nx.dev).

### Responsabilidades e relacionamentos entre tipos de bibliotecas


A tabela a seguir representa a configuração no arquivo [`.eslintrc.json`](.eslintrc.json).

| | api | util | domain | data | ui | feature | resource | app |
Expand All @@ -119,45 +128,43 @@ A tabela a seguir representa a configuração no arquivo [`.eslintrc.json`](.esl

Caso tenha interesse em aprofundar neste assunto e descobrir os motivos, recomendo que leia um conteúdo que escrevi ano passado, você pode fazer download através do link [Arquitetura em camadas, uma abordagem sobre responsabilidades e relacionamentos](https://conteudode.dev/pdf/nx).


---


```
..........
..............
..................
........................
............................
................................
....................................
........................................
.................. ...................
............ ..... ...... ....................
............ ... ... ...... ......................
.............. .... ... .... ..............
........ ..... ..... ..... .... ...............
........ ...... ....... ..... . .... .........
......... .... ...... ....... ....... .... ... .........
............. ...... .... ........ ..... ... ............
................ ........... ........ ...... ...............
................ ................. ..... ........ ................
................ ................ ......... ................
................. .............. ............... ................
.................. .... ................. ...............
.................... ................. ............
........................... ............... ...........
............................ ....... ..........
.......................... . ............
........................ ....................
...................... ......................
................... ...................
................. .................
............... ...............
............. .............
........... ...........
:........ .........
...... ......
.... ....
.. ..
..........
..............
..................
........................
............................
................................
....................................
........................................
.................. ...................
............ ..... ...... ....................
............ ... ... ...... ......................
.............. .... ... .... ..............
........ ..... ..... ..... .... ...............
........ ...... ....... ..... . .... .........
......... .... ...... ....... ....... .... ... .........
............. ...... .... ........ ..... ... ............
................ ........... ........ ...... ...............
................ ................. ..... ........ ................
................ ................ ......... ................
................. .............. ............... ................
.................. .... ................. ...............
.................... ................. ............
........................... ............... ...........
............................ ....... ..........
.......................... . ............
........................ ....................
...................... ......................
................... ...................
................. .................
............... ...............
............. .............
........... ...........
:........ .........
...... ......
.... ....
.. ..
```
9 changes: 8 additions & 1 deletion apps/devmx/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { Route } from '@angular/router';

export const appRoutes: Route[] = [
{
path: 'events',
loadChildren: () =>
import('@devmx/event-feature-shell').then(
(m) => m.eventFeatureShellRoutes
),
},
{
path: 'presentations',
loadChildren: () =>
Expand All @@ -18,6 +25,6 @@ export const appRoutes: Route[] = [
{
path: '',
pathMatch: 'prefix',
redirectTo: 'presentations',
redirectTo: 'events',
},
];
6 changes: 4 additions & 2 deletions apps/server/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { SharedDatabaseModule, SharedResourceModule } from '@devmx/shared-resource';
import { PresentationResourceModule } from '@devmx/presentation-resource';
import { AccountResourceModule } from '@devmx/account-resource';
import { LocationResourceModule } from '@devmx/location-resource';
import { AccountResourceModule } from '@devmx/account-resource';
import { EventResourceModule } from '@devmx/event-resource';
import { ServeStaticModule } from '@nestjs/serve-static';
import { Module } from '@nestjs/common';
import { env } from './envs/env';
Expand All @@ -13,7 +14,8 @@ import { env } from './envs/env';
SharedDatabaseModule,
AccountResourceModule,
PresentationResourceModule,
LocationResourceModule
LocationResourceModule,
EventResourceModule
]
})
export class AppModule {}
12 changes: 6 additions & 6 deletions assets/seeds/account-collection.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{"_id":{"$oid":"66fa1598073adabd63af0680"},"name":{"first":"Member","last":"Paraná"},"username":"member","password":"$2b$10$Tm3kJfirm6dbmYgbUuAWmuzMTByp6163nqf8M0.r.GqOHwahHonNy","email":"member@devpr.org","roles":{"member":true,"speaker":false,"neighbor":false,"donor":false,"leader":false,"staff":false,"fellow":false,"manager":false,"director":false},"gender":"female","photo":"","minibio":"","birthday":"2002-10-10T03:00:00.000Z","active":true,"__v":0}
{"_id":{"$oid":"66fa1529073adabd63af0670"},"name":{"first":"Speaker","last":"Paraná"},"username":"speaker","password":"$2b$10$vIGAhmSHgawn2UCp2dvp8eEIg4ZqVN5psF0XltOv5Ok1AvVVVzECC","email":"speaker@devpr.org","roles":{"member":true,"speaker":true,"neighbor":false,"donor":false,"leader":false,"staff":false,"fellow":false,"manager":false,"director":false},"gender":"male","photo":"","minibio":"","birthday":"1986-12-29T02:00:00.000Z","active":true,"__v":0}
{"_id":{"$oid":"66fa15e5073adabd63af0688"},"name":{"first":"Donor","last":"Paraná"},"username":"donor","password":"$2b$10$gVTbLG4cAkRp2B//hI9G5OPKBazWLVpbTNLspomaJRwORrZ0ZbM8W","email":"donor@devpr.org","roles":{"member":true,"speaker":false,"neighbor":false,"donor":false,"leader":false,"staff":false,"fellow":false,"manager":false,"director":false},"gender":"non-binary","photo":"","minibio":"","birthday":"2004-06-16T03:00:00.000Z","active":true,"__v":0}
{"_id":{"$oid":"66fa1686073adabd63af0690"},"name":{"first":"Leader","last":"Paraná"},"username":"leader","password":"$2b$10$gCQcetNAbiWBzp2KnuQ/juo5wch10sNxHgjYy/ht5bEsvDD0LDL.i","email":"leader@devpr.org","roles":{"member":true,"speaker":false,"neighbor":false,"donor":false,"leader":false,"staff":false,"fellow":false,"manager":false,"director":false},"gender":"gender-fluid","photo":"","minibio":"","birthday":"1997-07-03T03:00:00.000Z","active":true,"__v":0}
{"_id":{"$oid":"66fa16b5073adabd63af0698"},"name":{"first":"Staff","last":"Paraná"},"username":"staff","password":"$2b$10$A0D6enykGCeyqDi20sde9epqfxJqAZGHGZjsqh1RU9BzAc5sOn/Pq","email":"staff@devpr.org","roles":{"member":true,"speaker":false,"neighbor":false,"donor":false,"leader":false,"staff":false,"fellow":false,"manager":false,"director":false},"gender":"agender","photo":"","minibio":"","birthday":"2004-02-18T03:00:00.000Z","active":true,"__v":0}
{"_id":{"$oid":"66fa16d8073adabd63af06a0"},"name":{"first":"Fellow","last":"Paraná"},"username":"fellow","password":"$2b$10$CeZ3Yn3n350lEWi8OoQvIeLXqJMcEHeiCmjalWiWN9quf2/hwEDUG","email":"fellow@devpr.org","roles":{"member":true,"speaker":false,"neighbor":false,"donor":false,"leader":false,"staff":false,"fellow":false,"manager":false,"director":false},"gender":"prefer-not-to-say","photo":"","minibio":"","birthday":"1993-02-09T03:00:00.000Z","active":true,"__v":0}
{"_id":{"$oid":"66fa170c073adabd63af06a8"},"name":{"first":"Manager","last":"Paraná"},"username":"manager","password":"$2b$10$X6ElrWZ5MuUE/RKCM0khaeYm5GSyMavBgDKeJ5xxzJa.Rmo07KVxO","email":"manager@devpr.org","roles":{"member":true,"speaker":false,"neighbor":false,"donor":false,"leader":false,"staff":false,"fellow":false,"manager":false,"director":false},"gender":"male","photo":"","minibio":"","birthday":"1990-09-20T03:00:00.000Z","active":true,"__v":0}
{"_id":{"$oid":"66fa172f073adabd63af06b0"},"name":{"first":"Director","last":"Paraná"},"username":"director","password":"$2b$10$3F83Wt12gNu2PwINiimv..0ao5r6L6WHUzor11cWM0I5hgggavCHy","email":"director@devpr.org","roles":{"member":true,"speaker":false,"neighbor":false,"donor":false,"leader":false,"staff":false,"fellow":false,"manager":false,"director":false},"gender":"male","photo":"","minibio":"","birthday":"1986-12-29T02:00:00.000Z","active":true,"__v":0}
{"_id":{"$oid":"66fa15e5073adabd63af0688"},"name":{"first":"Donor","last":"Paraná"},"username":"donor","password":"$2b$10$gVTbLG4cAkRp2B//hI9G5OPKBazWLVpbTNLspomaJRwORrZ0ZbM8W","email":"donor@devpr.org","roles":{"member":true,"speaker":false,"neighbor":false,"donor":true,"leader":false,"staff":false,"fellow":false,"manager":false,"director":false},"gender":"non-binary","photo":"","minibio":"","birthday":"2004-06-16T03:00:00.000Z","active":true,"__v":0}
{"_id":{"$oid":"66fa1686073adabd63af0690"},"name":{"first":"Leader","last":"Paraná"},"username":"leader","password":"$2b$10$gCQcetNAbiWBzp2KnuQ/juo5wch10sNxHgjYy/ht5bEsvDD0LDL.i","email":"leader@devpr.org","roles":{"member":true,"speaker":false,"neighbor":false,"donor":false,"leader":true,"staff":false,"fellow":false,"manager":false,"director":false},"gender":"gender-fluid","photo":"","minibio":"","birthday":"1997-07-03T03:00:00.000Z","active":true,"__v":0}
{"_id":{"$oid":"66fa16b5073adabd63af0698"},"name":{"first":"Staff","last":"Paraná"},"username":"staff","password":"$2b$10$A0D6enykGCeyqDi20sde9epqfxJqAZGHGZjsqh1RU9BzAc5sOn/Pq","email":"staff@devpr.org","roles":{"member":true,"speaker":false,"neighbor":false,"donor":false,"leader":false,"staff":true,"fellow":false,"manager":false,"director":false},"gender":"agender","photo":"","minibio":"","birthday":"2004-02-18T03:00:00.000Z","active":true,"__v":0}
{"_id":{"$oid":"66fa16d8073adabd63af06a0"},"name":{"first":"Fellow","last":"Paraná"},"username":"fellow","password":"$2b$10$CeZ3Yn3n350lEWi8OoQvIeLXqJMcEHeiCmjalWiWN9quf2/hwEDUG","email":"fellow@devpr.org","roles":{"member":true,"speaker":false,"neighbor":false,"donor":false,"leader":false,"staff":false,"fellow":true,"manager":false,"director":false},"gender":"prefer-not-to-say","photo":"","minibio":"","birthday":"1993-02-09T03:00:00.000Z","active":true,"__v":0}
{"_id":{"$oid":"66fa170c073adabd63af06a8"},"name":{"first":"Manager","last":"Paraná"},"username":"manager","password":"$2b$10$X6ElrWZ5MuUE/RKCM0khaeYm5GSyMavBgDKeJ5xxzJa.Rmo07KVxO","email":"manager@devpr.org","roles":{"member":true,"speaker":false,"neighbor":false,"donor":false,"leader":false,"staff":false,"fellow":false,"manager":true,"director":false},"gender":"male","photo":"","minibio":"","birthday":"1990-09-20T03:00:00.000Z","active":true,"__v":0}
{"_id":{"$oid":"66fa172f073adabd63af06b0"},"name":{"first":"Director","last":"Paraná"},"username":"director","password":"$2b$10$3F83Wt12gNu2PwINiimv..0ao5r6L6WHUzor11cWM0I5hgggavCHy","email":"director@devpr.org","roles":{"member":true,"speaker":false,"neighbor":false,"donor":false,"leader":false,"staff":false,"fellow":false,"manager":false,"director":true},"gender":"male","photo":"","minibio":"","birthday":"1986-12-29T02:00:00.000Z","active":true,"__v":0}
1 change: 1 addition & 0 deletions packages/account/data-access/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './lib/account.providers';
export * from './lib/interfaces';
export * from './lib/facades';
export * from './lib/dtos';

2 changes: 1 addition & 1 deletion packages/account/data-access/src/lib/facades/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class AccountFacade extends State<AccountState> {
changeRoles(data: ChangeRoles) {
const request$ = this.changeRolesUseCase.execute(data);

request$.pipe(take(1)).subscribe(() => this.loadOne(data.id));
request$.pipe(take(1)).subscribe(() => this.load());
}

uploadPhoto(photo: Blob) {
Expand Down
3 changes: 3 additions & 0 deletions packages/account/data-access/src/lib/interfaces/nav-item.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Role } from "@devmx/shared-api-interfaces";

export interface NavItem {
path: (string | number)[];
text: string;
roles: Role[]
icon?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const account = {
staff: false,
fellow: false,
manager: false,
director: true,
director: false,
},
gender: 'male',
photo: '9c14863726af550ff0666c128c32286a',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export class AccountsServiceMock implements AccountsService {
}

async findOne(id: string): Promise<Account | null> {
throw new Error('Method not implemented.');
const account = this.#accounts.find((a) => a.id === id);

return account ?? null;
}

async findOneBy(filter: FindFilter<Account>): Promise<Account | null> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Change Roles UseCase', () => {
});

it('member assign staff should throw access denied', async () => {
const assign = { id: '', roles: merge(accountRole, { staff: true }) };
const assign = { id: '66f706967d818c4004effb48', roles: merge(accountRole, { staff: true }) };

const assigner = merge(authUser, {
roles: merge(accountRole, { member: true }),
Expand All @@ -40,7 +40,7 @@ describe('Change Roles UseCase', () => {
});

it('staff assign manager should throw access denied', async () => {
const assign = { id: '', roles: merge(accountRole, { manager: true }) };
const assign = { id: '66f706967d818c4004effb48', roles: merge(accountRole, { manager: true }) };

const assigner = merge(authUser, {
roles: merge(accountRole, { staff: true }),
Expand All @@ -52,7 +52,7 @@ describe('Change Roles UseCase', () => {
});

it('manager assign staff should be ok', async () => {
const assign = { id: '', roles: merge(accountRole, { staff: true }) };
const assign = { id: '66f706967d818c4004effb48', roles: merge(accountRole, { staff: true }) };

const assigner = merge(authUser, {
roles: merge(accountRole, { manager: true }),
Expand Down
Loading