-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(frontend): remove useless package
- Loading branch information
Showing
58 changed files
with
2,386 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/backend/src/_migrations/1723547616571-create-structure-information-migration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { domifaConfig } from "../config"; | ||
|
||
export class CreateStructureInformationMigration1723547616571 | ||
implements MigrationInterface | ||
{ | ||
name = "CreateStructureInformationMigration1723547616571"; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
if ( | ||
domifaConfig().envId === "prod" || | ||
domifaConfig().envId === "preprod" || | ||
domifaConfig().envId === "local" | ||
) { | ||
await queryRunner.query( | ||
`CREATE TABLE "structure_information" ("uuid" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "version" integer NOT NULL, "title" character varying NOT NULL, "description" character varying, "startDate" TIMESTAMP NOT NULL, "endDate" TIMESTAMP, "type" character varying NOT NULL, "createdBy" jsonb, "structureId" integer NOT NULL, CONSTRAINT "PK_b51c75b37769abf1fdf28fc89ef" PRIMARY KEY ("uuid"))` | ||
); | ||
await queryRunner.query( | ||
`CREATE INDEX "IDX_17cd35c9fdcd9ab82015a46b22" ON "structure_information" ("structureId") ` | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "structure_information" ADD CONSTRAINT "FK_17cd35c9fdcd9ab82015a46b22c" FOREIGN KEY ("structureId") REFERENCES "structure"("id") ON DELETE CASCADE ON UPDATE NO ACTION` | ||
); | ||
} | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "structure_information" DROP CONSTRAINT "FK_17cd35c9fdcd9ab82015a46b22c"` | ||
); | ||
|
||
await queryRunner.query(`DROP TABLE "structure_information"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/backend/src/auth/decorators/current-structure-information.decorator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { createParamDecorator, ExecutionContext } from "@nestjs/common"; | ||
import { UserStructureAuthenticated } from "../../_common/model"; | ||
|
||
export const CurrentStructureInformation = createParamDecorator( | ||
(_data: unknown, ctx: ExecutionContext) => { | ||
const request = ctx.switchToHttp().getRequest(); | ||
return request.structureInformation as UserStructureAuthenticated; | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/backend/src/auth/guards/structure-information-access.guard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { | ||
CanActivate, | ||
ExecutionContext, | ||
HttpException, | ||
HttpStatus, | ||
Injectable, | ||
} from "@nestjs/common"; | ||
|
||
import { appLogger } from "../../util"; | ||
import { structureInformationRepository } from "../../database"; | ||
|
||
@Injectable() | ||
export class StructureInformationAccessGuard implements CanActivate { | ||
public async canActivate(context: ExecutionContext) { | ||
const r = context.switchToHttp().getRequest(); | ||
|
||
if ( | ||
typeof r.params.uuid === "undefined" || | ||
typeof r.user.structureId === "undefined" | ||
) { | ||
appLogger.error( | ||
`[StructureInformationAccessGuard] invalid uuid or structureId`, | ||
{ | ||
sentry: true, | ||
context: { | ||
usagerRef: r?.params?.uui, | ||
structureId: r?.user?.structureId, | ||
user: r?.user?._id, | ||
}, | ||
} | ||
); | ||
throw new HttpException( | ||
"STRUCTURE_INFORMATION_NOT_FOUND", | ||
HttpStatus.BAD_REQUEST | ||
); | ||
} | ||
|
||
const uuid = r.params.uuid; | ||
const structureId = parseInt(r.user.structureId, 10); | ||
|
||
try { | ||
const structureInformation = | ||
await structureInformationRepository.findOneOrFail({ | ||
where: { | ||
structureId, | ||
uuid, | ||
}, | ||
}); | ||
r.structureInformation = structureInformation; | ||
return r; | ||
} catch (e) { | ||
appLogger.error(`[UsagerAccessGuard] structureInformation not found`, { | ||
sentry: true, | ||
context: { | ||
uuid, | ||
structureId, | ||
user: r?.user?._id, | ||
role: r?.user?.role, | ||
}, | ||
}); | ||
throw new HttpException("USAGER_NOT_FOUND", HttpStatus.BAD_REQUEST); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
packages/backend/src/database/entities/structure/StructureInformationTable.typeorm.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
StructureInformation, | ||
StructureInformationType, | ||
UserStructureResume, | ||
} from "@domifa/common"; | ||
import { Entity, Column, Index, JoinColumn, ManyToOne } from "typeorm"; | ||
import { AppTypeormTable } from "../_core"; | ||
import { StructureTable } from "./StructureTable.typeorm"; | ||
|
||
@Entity({ name: "structure_information" }) | ||
export class StructureInformationTable | ||
extends AppTypeormTable<StructureInformationTable> | ||
implements StructureInformation | ||
{ | ||
@Column({ type: "varchar" }) | ||
title: string; | ||
|
||
@Column({ nullable: true }) | ||
description: string; | ||
|
||
@Column({ type: "timestamp" }) | ||
startDate: Date; | ||
|
||
@Column({ type: "timestamp", nullable: true }) | ||
endDate: Date | null; | ||
|
||
@Column({ type: "varchar" }) | ||
type: StructureInformationType; | ||
|
||
@Column({ type: "jsonb", nullable: true }) | ||
createdBy: UserStructureResume; | ||
|
||
@Index() | ||
@ManyToOne(() => StructureTable, (structure) => structure.id, { | ||
onDelete: "CASCADE", | ||
}) | ||
@Column({ type: "integer", nullable: false }) | ||
@JoinColumn({ name: "structureId", referencedColumnName: "id" }) | ||
public structureId: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// @index('./*', f => `export * from '${f.path}'`) | ||
export * from "./StructureInformationTable.typeorm"; | ||
export * from "./StructureStatsReportingQuestionsTable.typeorm"; | ||
export * from "./StructureTable.typeorm"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// @index('./*', f => `export * from '${f.path}'`) | ||
// @index('./*.service.ts', f => `export * from '${f.path}'`) | ||
export * from "./structureInformationRepository.service"; | ||
export * from "./structureRepository.service"; | ||
export * from "./structureStatsReportingQuestionsRepository.service"; |
6 changes: 6 additions & 0 deletions
6
packages/backend/src/database/services/structure/structureInformationRepository.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { StructureInformation } from "@domifa/common"; | ||
import { myDataSource } from "../_postgres"; | ||
import { StructureInformationTable } from "../../entities/structure/StructureInformationTable.typeorm"; | ||
|
||
export const structureInformationRepository = | ||
myDataSource.getRepository<StructureInformation>(StructureInformationTable); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
...ortail-usagers/controllers/structure-information/structure-information.controller.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Test, TestingModule } from "@nestjs/testing"; | ||
import { StructureInformationController } from "./structure-information.controller"; | ||
|
||
describe("StructureInformationController", () => { | ||
let controller: StructureInformationController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [StructureInformationController], | ||
}).compile(); | ||
|
||
controller = module.get<StructureInformationController>( | ||
StructureInformationController | ||
); | ||
}); | ||
|
||
it("should be defined", () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
Oops, something went wrong.