Skip to content

Commit

Permalink
refactor(autorizacao): reorganize
Browse files Browse the repository at this point in the history
  • Loading branch information
guesant committed May 1, 2024
1 parent 0d6b1aa commit cf34754
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/autorizacao/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './regras';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IBaseAuthzFilterFn } from '../../domain';
import { BaseAuthzPolicy } from './BaseAuthzPolicy';
import { IBaseAuthzFilterFn } from '@/autorizacao/regras/types';

const filterAllowNotDeleted: IBaseAuthzFilterFn<any, any> = (_context, alias = 'row') => {
return (qb) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//

import * as Authz from './statements/IAuthzStatement';
import * as Authz from './types/IAuthzStatement';

type IAuthzPolicySetup = {
endereco: {
Expand Down
4 changes: 4 additions & 0 deletions src/autorizacao/regras/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './00-AuthzPolicyPublic';
export * from './01-AuthzPolicySuperUser';
export * from './BaseAuthzPolicy';
export * from './types';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Dto from '@sisgea/spec';
import { IBaseAuthzCheck, IBaseAuthzFilter } from '../../../domain';
import { IBaseAuthzFilter, IBaseAuthzCheck } from './IBaseAuthz';

// ===================================================================================

Expand Down Expand Up @@ -29,21 +29,36 @@ export type IAuthzStatementBlocoDelete = IBaseAuthzFilter<'bloco:delete', { dto:
export type IAuthzStatementAmbienteCreate = IBaseAuthzCheck<'ambiente:create', { dto: Dto.IAmbienteCreateDto }>;
export type IAuthzStatementAmbienteFind = IBaseAuthzFilter<'ambiente:find'>;
export type IAuthzStatementAmbienteUpdate = IBaseAuthzFilter<'ambiente:update', { dto: Dto.IAmbienteUpdateDto }>;
export type IAuthzStatementAmbienteDelete = IBaseAuthzFilter<'ambiente:delete', { dto: Dto.IAmbienteDeleteOneByIdInputDto }>;
export type IAuthzStatementAmbienteDelete = IBaseAuthzFilter<
'ambiente:delete',
{
dto: Dto.IAmbienteDeleteOneByIdInputDto;
}
>;

// =====================

export type IAuthzStatementUsuarioCreate = IBaseAuthzCheck<'usuario:create', { dto: Dto.IUsuarioCreateDto }>;
export type IAuthzStatementUsuarioFind = IBaseAuthzFilter<'usuario:find'>;
export type IAuthzStatementUsuarioUpdate = IBaseAuthzFilter<'usuario:update', { dto: Dto.IUsuarioUpdateDto }>;
export type IAuthzStatementUsuarioDelete = IBaseAuthzFilter<'usuario:delete', { dto: Dto.IUsuarioDeleteOneByIdInputDto }>;
export type IAuthzStatementUsuarioDelete = IBaseAuthzFilter<
'usuario:delete',
{
dto: Dto.IUsuarioDeleteOneByIdInputDto;
}
>;

// =====================

export type IAuthzStatementModalidadeCreate = IBaseAuthzCheck<'modalidade:create', { dto: Dto.IModalidadeCreateDto }>;
export type IAuthzStatementModalidadeFind = IBaseAuthzFilter<'modalidade:find'>;
export type IAuthzStatementModalidadeUpdate = IBaseAuthzFilter<'modalidade:update', { dto: Dto.IModalidadeUpdateDto }>;
export type IAuthzStatementModalidadeDelete = IBaseAuthzFilter<'modalidade:delete', { dto: Dto.IModalidadeDeleteOneByIdInputDto }>;
export type IAuthzStatementModalidadeDelete = IBaseAuthzFilter<
'modalidade:delete',
{
dto: Dto.IModalidadeDeleteOneByIdInputDto;
}
>;

// =====================

Expand All @@ -60,7 +75,12 @@ export type IAuthzStatementCursoFind = IBaseAuthzFilter<'curso:find'>;

export type IAuthzStatementDisciplinaCreate = IBaseAuthzCheck<'disciplina:create', { dto: Dto.IDisciplinaInputDto }>;
export type IAuthzStatementDisciplinaUpdate = IBaseAuthzFilter<'disciplina:update', { dto: Dto.IDisciplinaUpdateDto }>;
export type IAuthzStatementDisciplinaDelete = IBaseAuthzFilter<'disciplina:delete', { dto: Dto.IDisciplinaDeleteOneByIdInputDto }>;
export type IAuthzStatementDisciplinaDelete = IBaseAuthzFilter<
'disciplina:delete',
{
dto: Dto.IDisciplinaDeleteOneByIdInputDto;
}
>;
export type IAuthzStatementDisciplinaFind = IBaseAuthzFilter<'disciplina:find'>;

// =====================
Expand All @@ -81,21 +101,56 @@ export type IAuthzStatementDiarioFind = IBaseAuthzFilter<'diario:find'>;

export type IAuthzStatementReservaCreate = IBaseAuthzCheck<'reserva:create', { dto: Dto.IReservaInputDto }>;
export type IAuthzStatementReservaUpdate = IBaseAuthzFilter<'reserva:update', { dto: Dto.IReservaUpdateDto }>;
export type IAuthzStatementReservaDelete = IBaseAuthzFilter<'reserva:delete', { dto: Dto.IReservaDeleteOneByIdInputDto }>;
export type IAuthzStatementReservaDelete = IBaseAuthzFilter<
'reserva:delete',
{
dto: Dto.IReservaDeleteOneByIdInputDto;
}
>;
export type IAuthzStatementReservaFind = IBaseAuthzFilter<'reserva:find'>;

// =====================

export type IAuthzStatementCalendarioLetivoCreate = IBaseAuthzCheck<'calendario_letivo:create', { dto: Dto.ICalendarioLetivoCreateDto }>;
export type IAuthzStatementCalendarioLetivoUpdate = IBaseAuthzFilter<'calendario_letivo:update', { dto: Dto.ICalendarioLetivoUpdateDto }>;
export type IAuthzStatementCalendarioLetivoDelete = IBaseAuthzFilter<'calendario_letivo:delete', { dto: Dto.ICalendarioLetivoDeleteOneByIdInputDto }>;
export type IAuthzStatementCalendarioLetivoCreate = IBaseAuthzCheck<
'calendario_letivo:create',
{
dto: Dto.ICalendarioLetivoCreateDto;
}
>;
export type IAuthzStatementCalendarioLetivoUpdate = IBaseAuthzFilter<
'calendario_letivo:update',
{
dto: Dto.ICalendarioLetivoUpdateDto;
}
>;
export type IAuthzStatementCalendarioLetivoDelete = IBaseAuthzFilter<
'calendario_letivo:delete',
{
dto: Dto.ICalendarioLetivoDeleteOneByIdInputDto;
}
>;
export type IAuthzStatementCalendarioLetivoFind = IBaseAuthzFilter<'calendario_letivo:find'>;

export type IAuthzStatementDiarioProfessorCreate = IBaseAuthzCheck<'diario_professor:create', { dto: Dto.IDiarioProfessorInputDto }>;

export type IAuthzStatementDiarioProfessorUpdate = IBaseAuthzFilter<'diario_professor:update', { dto: Dto.IDiarioProfessorUpdateDto }>;

export type IAuthzStatementDiarioProfessorDelete = IBaseAuthzFilter<'diario_professor:delete', { dto: Dto.IDiarioProfessorDeleteOneByIdInputDto }>;
export type IAuthzStatementDiarioProfessorCreate = IBaseAuthzCheck<
'diario_professor:create',
{
dto: Dto.IDiarioProfessorInputDto;
}
>;

export type IAuthzStatementDiarioProfessorUpdate = IBaseAuthzFilter<
'diario_professor:update',
{
dto: Dto.IDiarioProfessorUpdateDto;
}
>;

export type IAuthzStatementDiarioProfessorDelete = IBaseAuthzFilter<
'diario_professor:delete',
{
dto: Dto.IDiarioProfessorDeleteOneByIdInputDto;
}
>;

export type IAuthzStatementDiarioProfessorFilter = IBaseAuthzFilter<'diario_professor:find'>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Promisable } from 'type-fest';
import { SelectQueryBuilder } from 'typeorm';
import type { IContextoDeAcesso } from '../contexto-de-acesso';
import type { IContextoDeAcesso } from '../../../contexto-de-acesso';

//

Expand Down
2 changes: 2 additions & 0 deletions src/autorizacao/regras/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './IBaseAuthz';
export * from './IAuthzStatement';
1 change: 0 additions & 1 deletion src/domain/authorization/index.ts

This file was deleted.

0 comments on commit cf34754

Please sign in to comment.