From 4f1c06418996992188c3c12c56bbef0807b5d115 Mon Sep 17 00:00:00 2001 From: OxSaitama Date: Wed, 10 May 2023 23:23:20 +0200 Subject: [PATCH 1/8] fix data encryption --- package.json | 7 +- src/app/api/super-admin/FilesController.ts | 22 ++++++- .../20230510204321_v4/migration.sql | 9 +++ src/common/databases/schema.prisma | 2 +- src/common/databases/seeders/seeder.ts | 17 ++--- src/common/repositories/FilesRepository.ts | 9 ++- .../CryptoService/CryptoService.ts | 66 +++++++------------ .../FilesService/FilesService.ts | 64 +++++++++++------- 8 files changed, 113 insertions(+), 83 deletions(-) create mode 100644 src/common/databases/migrations/20230510204321_v4/migration.sql diff --git a/package.json b/package.json index 14fa336e..7fe55c8c 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@Test": "./dist/test" }, "scripts": { - "build-db": "npx prisma migrate dev", + "build-db": "npx prisma migrate dev && node ./dist/common/databases/seeders/seeder.js", "build": "tsc", "start": "node ./dist/entries/App.js", "api:start": "npm run migrate && npm run start", @@ -48,7 +48,7 @@ "cors": "^2.8.5", "express": "^4.18.2", "jsonwebtoken": "^9.0.0", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.44", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.46", "module-alias": "^2.2.2", "multer": "^1.4.5-lts.1", "next": "^13.1.5", @@ -60,7 +60,8 @@ "tslib": "^2.4.1", "typedi": "^0.10.0", "typescript": "^4.9.4", - "uuid": "^9.0.0" + "uuid": "^9.0.0", + "uuidv4": "^6.2.13" }, "devDependencies": { "@types/cors": "^2.8.13", diff --git a/src/app/api/super-admin/FilesController.ts b/src/app/api/super-admin/FilesController.ts index ae38660a..68c2dfd1 100644 --- a/src/app/api/super-admin/FilesController.ts +++ b/src/app/api/super-admin/FilesController.ts @@ -39,6 +39,26 @@ export default class FilesController extends ApiController { } } + /** + * @description Get a specific File by uid + */ + @Get("/api/v1/super-admin/files/upload/:uid") + protected async getFileData(req: Request, response: Response) { + try { + const uid = req.params["uid"]; + if (!uid) { + throw new Error("No uid provided"); + } + + const file = await this.filesService.updload(uid); + + this.httpSuccess(response, file); + } catch (error) { + this.httpBadRequest(response, error); + return; + } + } + /** * @description Create a new File * @returns File created @@ -135,7 +155,7 @@ export default class FilesController extends ApiController { /** * @description Get a specific File by uid */ - @Get("/api/v1/super-admin/Files/:uid") + @Get("/api/v1/super-admin/files/:uid") protected async getOneByUid(req: Request, response: Response) { try { const uid = req.params["uid"]; diff --git a/src/common/databases/migrations/20230510204321_v4/migration.sql b/src/common/databases/migrations/20230510204321_v4/migration.sql new file mode 100644 index 00000000..463c9e19 --- /dev/null +++ b/src/common/databases/migrations/20230510204321_v4/migration.sql @@ -0,0 +1,9 @@ +/* + Warnings: + + - You are about to drop the column `iv` on the `files` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE "files" DROP COLUMN "iv", +ADD COLUMN "key" VARCHAR(255); diff --git a/src/common/databases/schema.prisma b/src/common/databases/schema.prisma index b1b04496..4261b9ea 100644 --- a/src/common/databases/schema.prisma +++ b/src/common/databases/schema.prisma @@ -204,7 +204,7 @@ model Files { document_uid String @db.VarChar(255) file_path String @unique @db.VarChar(255) file_name String @db.VarChar(255) - iv String @db.VarChar(255) + key String? @db.VarChar(255) created_at DateTime? @default(now()) updated_at DateTime? @updatedAt diff --git a/src/common/databases/seeders/seeder.ts b/src/common/databases/seeders/seeder.ts index 08b8869a..999503de 100644 --- a/src/common/databases/seeders/seeder.ts +++ b/src/common/databases/seeders/seeder.ts @@ -25,12 +25,6 @@ import { (async () => { const prisma = new PrismaClient(); - const existingData = await prisma.contacts.findFirst({ where: { email: "john.doe@example.com" } }); - if (existingData) { - console.log("Seed data already exists. Skipping seeding process."); - return; - } - const randomString = () => { const chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; let result = ""; @@ -92,6 +86,13 @@ import { const uidDocumentHistory1: string = randomString(); const uidDocumentHistory2: string = randomString(); + // const existingData = await prisma.contacts.findFirst({ where: { uid: uidContact4 } }); + // if (existingData) { + // console.log("Seed data already exists. Skipping seeding process."); + // return; + // } + + const customers: Customers[] = [ { uid: uidCustomer1, @@ -427,7 +428,7 @@ import { document_uid: uidDocument1, file_name: "fileName1", file_path: "https://www.google1.com", - iv: "randomIv1", + key: '', created_at: new Date(), updated_at: new Date(), }, @@ -436,7 +437,7 @@ import { document_uid: uidDocument1, file_name: "fileName2", file_path: "https://www.google2.com", - iv: "randomIv2", + key: '', created_at: new Date(), updated_at: new Date(), }, diff --git a/src/common/repositories/FilesRepository.ts b/src/common/repositories/FilesRepository.ts index af5b8044..d48fb7d5 100644 --- a/src/common/repositories/FilesRepository.ts +++ b/src/common/repositories/FilesRepository.ts @@ -27,7 +27,7 @@ export default class FilesRepository extends BaseRepository { /** * @description : Create a file linked to a document */ - public async create(file: File): Promise { + public async create(file: File, key: string): Promise { return this.model.create({ data: { document: { @@ -37,7 +37,7 @@ export default class FilesRepository extends BaseRepository { }, file_name: file.file_name, file_path: file.file_path, - iv: file.iv + key: key }, include: { document: true } }); @@ -61,10 +61,13 @@ export default class FilesRepository extends BaseRepository { * @description : Delete a file */ public async delete(uid: string): Promise { - return this.model.delete({ + return this.model.update({ where: { uid: uid, }, + data: { + key: null + } }); } diff --git a/src/services/private-services/CryptoService/CryptoService.ts b/src/services/private-services/CryptoService/CryptoService.ts index 548ed6b0..5ac62af1 100644 --- a/src/services/private-services/CryptoService/CryptoService.ts +++ b/src/services/private-services/CryptoService/CryptoService.ts @@ -5,62 +5,44 @@ import crypto from "crypto"; @Service() export default class CryptoService extends BaseService { - private jwkKey: JsonWebKey; - private subtle: SubtleCrypto = crypto.webcrypto.subtle + + private static readonly CRYPTO_ALGORITHM = "aes-256-ctr"; + constructor(protected variables: BackendVariables) { super(); - this.jwkKey = { - kty: "oct", - k: variables.KEY_DATA, - alg: "A256GCM", - ext: true, - }; } - private async getKey() { - return await this.subtle.importKey("jwk", this.jwkKey, {name: "AES-GCM"}, false, ["encrypt", "decrypt"]); + private getKey(key: string) { + return crypto.createHash('sha256').update(String(key)).digest('base64').slice(0, 32); } /** * @description : encrypt data * @throws {Error} If data cannot be encrypted */ - public async encrypt(data: string) { - const encodedData = Buffer.from(data); - const iv = crypto.webcrypto.getRandomValues(new Uint8Array(16)) - const key = await this.getKey(); - const cipherData = await this.subtle.encrypt( - { - name: "AES-GCM", - iv, - }, - key, - encodedData, - ); - - const cipherText = Buffer.from(cipherData).toString('base64'); - const ivStringified = Buffer.from(iv).toString('base64'); - - return { cipherText, ivStringified }; + public async encrypt(buffer: Buffer, key: string): Promise { + // Create an initialization vector + const iv = crypto.randomBytes(16); + // Create a new cipher using the algorithm, key, and iv + const cipher = crypto.createCipheriv(CryptoService.CRYPTO_ALGORITHM, this.getKey(key), iv); + // Create the new (encrypted) buffer + const result = Buffer.concat([iv, cipher.update(buffer), cipher.final()]); + return result; } - + /** * @description : decrypt data with an initialization vector * @throws {Error} If data cannot be decrypted */ - public async decrypt(cipherText: string, ivStringified: string): Promise { - const cipherData = Buffer.from(cipherText, 'base64'); - const iv = Buffer.from(ivStringified, 'base64'); - const key = await this.getKey(); - const decryptedData = await this.subtle.decrypt( - { - name: "AES-GCM", - iv, - }, - key, - cipherData, - ); - - return Buffer.from(decryptedData).toString('utf-8'); + public async decrypt(encrypted: Buffer, key: string): Promise { + // Get the iv: the first 16 bytes + const iv = encrypted.subarray(0, 16); + // Get the rest + encrypted = encrypted.subarray(16); + // Create a decipher + const decipher = crypto.createDecipheriv(CryptoService.CRYPTO_ALGORITHM, this.getKey(key), iv); + // Actually decrypt it + const result = Buffer.concat([decipher.update(encrypted), decipher.final()]); + return result; } } diff --git a/src/services/private-services/FilesService/FilesService.ts b/src/services/private-services/FilesService/FilesService.ts index 88b1d3b9..8affd988 100644 --- a/src/services/private-services/FilesService/FilesService.ts +++ b/src/services/private-services/FilesService/FilesService.ts @@ -1,16 +1,21 @@ import FilesRepository from "@Repositories/FilesRepository"; import BaseService from "@Services/BaseService"; import { Service } from "typedi"; -import { File } from "le-coffre-resources/dist/SuperAdmin" +import { File } from "le-coffre-resources/dist/SuperAdmin"; import CryptoService from "../CryptoService/CryptoService"; import IpfsService from "../IpfsService/IpfsService"; -//import fs from "fs"; import { BackendVariables } from "@Common/config/variables/Variables"; import { Readable } from "stream"; +import { uuid } from "uuidv4"; @Service() export default class FilesService extends BaseService { - constructor(private filesRepository: FilesRepository, private ipfsService: IpfsService, private variables: BackendVariables, private cryptoService: CryptoService) { + constructor( + private filesRepository: FilesRepository, + private ipfsService: IpfsService, + private variables: BackendVariables, + private cryptoService: CryptoService, + ) { super(); } @@ -22,17 +27,39 @@ export default class FilesService extends BaseService { return this.filesRepository.findMany(query); } + /** + * @description : Get a file by uid + * @throws {Error} If project cannot be created + */ + public async getByUid(uid: string) { + return this.filesRepository.findOneByUid(uid); + } + + /** + * @description : view a file + * @throws {Error} If file cannot be deleted + */ + public async updload(uid: string) { + const file = await this.filesRepository.findOneByUid(uid); + if (!file.key) throw new Error("file deleted"); + const fileResult = await fetch(file.file_path); + const fileContent = await fileResult.arrayBuffer(); + return await this.cryptoService.decrypt(Buffer.from(fileContent), file.key); + } + /** * @description : Create a new file * @throws {Error} If file cannot be created */ public async create(file: File, fileData: Express.Multer.File) { - const upload = await this.ipfsService.pinFile(Readable.from(fileData.buffer), fileData.originalname); - const encryptedPath = await this.cryptoService.encrypt(this.variables.PINATA_GATEWAY.concat(upload.IpfsHash)); - file.file_name = fileData.originalname; - file.file_path = encryptedPath.cipherText; - file.iv = encryptedPath.ivStringified; - return this.filesRepository.create(file); + const key = uuid(); //crypto.getRandomValues(new Uint8Array(16)); + const encryptedFile = await this.cryptoService.encrypt(fileData.buffer, key); + //const encryptedFileName = await this.cryptoService.encrypt(Buffer.from(fileData.originalname, 'utf-8'), key); + const upload = await this.ipfsService.pinFile(Readable.from(encryptedFile), fileData.originalname); + file.file_name = fileData.originalname; //encryptedFileName.toString('utf-8') + file.file_path = this.variables.PINATA_GATEWAY.concat(upload.IpfsHash); + + return this.filesRepository.create(file, key); } /** @@ -48,23 +75,10 @@ export default class FilesService extends BaseService { * @throws {Error} If file cannot be deleted */ public async delete(uid: string) { - try { - const fileToUnpin = await this.filesRepository.findOneByUid(uid); - const decryptedFilePath = await this.cryptoService.decrypt(fileToUnpin.file_path, fileToUnpin.iv); - const fileHash= decryptedFilePath.substring(this.variables.PINATA_GATEWAY.length); - await this.ipfsService.unpinFile(fileHash) - } catch (error) { - console.log(error); - } + const fileToUnpin = await this.filesRepository.findOneByUid(uid); + const fileHash = fileToUnpin.file_path.substring(this.variables.PINATA_GATEWAY.length); + await this.ipfsService.unpinFile(fileHash); return this.filesRepository.delete(uid); } - - /** - * @description : Get a file by uid - * @throws {Error} If project cannot be created - */ - public async getByUid(uid: string) { - return this.filesRepository.findOneByUid(uid); - } } From 6904d1be02ee53aa36371da0ecb5821741f37565 Mon Sep 17 00:00:00 2001 From: OxSaitama Date: Thu, 11 May 2023 08:54:08 +0200 Subject: [PATCH 2/8] remove deprecated method uuid() --- src/services/private-services/FilesService/FilesService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/private-services/FilesService/FilesService.ts b/src/services/private-services/FilesService/FilesService.ts index 8affd988..8c050c48 100644 --- a/src/services/private-services/FilesService/FilesService.ts +++ b/src/services/private-services/FilesService/FilesService.ts @@ -6,7 +6,7 @@ import CryptoService from "../CryptoService/CryptoService"; import IpfsService from "../IpfsService/IpfsService"; import { BackendVariables } from "@Common/config/variables/Variables"; import { Readable } from "stream"; -import { uuid } from "uuidv4"; +import { v4 } from "uuid"; @Service() export default class FilesService extends BaseService { @@ -52,7 +52,7 @@ export default class FilesService extends BaseService { * @throws {Error} If file cannot be created */ public async create(file: File, fileData: Express.Multer.File) { - const key = uuid(); //crypto.getRandomValues(new Uint8Array(16)); + const key = v4(); const encryptedFile = await this.cryptoService.encrypt(fileData.buffer, key); //const encryptedFileName = await this.cryptoService.encrypt(Buffer.from(fileData.originalname, 'utf-8'), key); const upload = await this.ipfsService.pinFile(Readable.from(encryptedFile), fileData.originalname); From 9c84f995981f54c4dee1c23effc1e57299f6e3c8 Mon Sep 17 00:00:00 2001 From: OxSaitama Date: Thu, 11 May 2023 11:07:59 +0200 Subject: [PATCH 3/8] add archived to files on delete --- package.json | 2 +- .../databases/migrations/20230511085908_v5/migration.sql | 2 ++ src/common/databases/schema.prisma | 3 ++- src/common/databases/seeders/seeder.ts | 2 ++ src/common/repositories/FilesRepository.ts | 3 ++- 5 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/common/databases/migrations/20230511085908_v5/migration.sql diff --git a/package.json b/package.json index 7fe55c8c..327677fa 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "cors": "^2.8.5", "express": "^4.18.2", "jsonwebtoken": "^9.0.0", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.46", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.47", "module-alias": "^2.2.2", "multer": "^1.4.5-lts.1", "next": "^13.1.5", diff --git a/src/common/databases/migrations/20230511085908_v5/migration.sql b/src/common/databases/migrations/20230511085908_v5/migration.sql new file mode 100644 index 00000000..a5b3abcb --- /dev/null +++ b/src/common/databases/migrations/20230511085908_v5/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "files" ADD COLUMN "archived_at" TIMESTAMP(3); diff --git a/src/common/databases/schema.prisma b/src/common/databases/schema.prisma index 4261b9ea..742b331b 100644 --- a/src/common/databases/schema.prisma +++ b/src/common/databases/schema.prisma @@ -39,7 +39,7 @@ model Contacts { cell_phone_number String @unique @db.VarChar(50) civility ECivility @default(MALE) address Addresses? @relation(fields: [address_uid], references: [uid], onDelete: Cascade) - address_uid String? @unique @db.VarChar(255) + address_uid String? @unique @db.VarChar(255) birthdate DateTime? created_at DateTime? @default(now()) updated_at DateTime? @updatedAt @@ -204,6 +204,7 @@ model Files { document_uid String @db.VarChar(255) file_path String @unique @db.VarChar(255) file_name String @db.VarChar(255) + archived_at DateTime? key String? @db.VarChar(255) created_at DateTime? @default(now()) updated_at DateTime? @updatedAt diff --git a/src/common/databases/seeders/seeder.ts b/src/common/databases/seeders/seeder.ts index 999503de..6a3eaf55 100644 --- a/src/common/databases/seeders/seeder.ts +++ b/src/common/databases/seeders/seeder.ts @@ -429,6 +429,7 @@ import { file_name: "fileName1", file_path: "https://www.google1.com", key: '', + archived_at: null, created_at: new Date(), updated_at: new Date(), }, @@ -438,6 +439,7 @@ import { file_name: "fileName2", file_path: "https://www.google2.com", key: '', + archived_at: null, created_at: new Date(), updated_at: new Date(), }, diff --git a/src/common/repositories/FilesRepository.ts b/src/common/repositories/FilesRepository.ts index d48fb7d5..34f2f89c 100644 --- a/src/common/repositories/FilesRepository.ts +++ b/src/common/repositories/FilesRepository.ts @@ -66,7 +66,8 @@ export default class FilesRepository extends BaseRepository { uid: uid, }, data: { - key: null + key: null, + archived_at: new Date(Date.now()) } }); } From d2d2263bd23fe4fc967f8599d37a5febb9621335 Mon Sep 17 00:00:00 2001 From: OxSaitama Date: Thu, 11 May 2023 11:12:58 +0200 Subject: [PATCH 4/8] add error catcher for ipfs --- src/services/private-services/FilesService/FilesService.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/services/private-services/FilesService/FilesService.ts b/src/services/private-services/FilesService/FilesService.ts index 8c050c48..88e5948b 100644 --- a/src/services/private-services/FilesService/FilesService.ts +++ b/src/services/private-services/FilesService/FilesService.ts @@ -75,9 +75,13 @@ export default class FilesService extends BaseService { * @throws {Error} If file cannot be deleted */ public async delete(uid: string) { - const fileToUnpin = await this.filesRepository.findOneByUid(uid); + try { + const fileToUnpin = await this.filesRepository.findOneByUid(uid); const fileHash = fileToUnpin.file_path.substring(this.variables.PINATA_GATEWAY.length); await this.ipfsService.unpinFile(fileHash); + } catch(error) { + console.error(error); + } return this.filesRepository.delete(uid); } From deeddd69446d5537c5779e71566a7c8ffe10950c Mon Sep 17 00:00:00 2001 From: Hugo Lextrait Date: Thu, 11 May 2023 12:35:08 +0200 Subject: [PATCH 5/8] patch seeder 1 --- src/common/databases/seeders/seeder.ts | 46 +++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/common/databases/seeders/seeder.ts b/src/common/databases/seeders/seeder.ts index 6a3eaf55..39f8f7cd 100644 --- a/src/common/databases/seeders/seeder.ts +++ b/src/common/databases/seeders/seeder.ts @@ -67,9 +67,13 @@ import { const uidDocument1: string = randomString(); const uidDocument2: string = randomString(); + const uidDocument3: string = randomString(); + const uidDocument4: string = randomString(); + const uidDocument5: string = randomString(); const uidDocumentType1: string = randomString(); const uidDocumentType2: string = randomString(); + const uidDocumentType3: string = randomString(); const uidOfficeFolderHasCustomer1: string = randomString(); const uidOfficeFolderHasCustomer2: string = randomString(); @@ -380,6 +384,36 @@ import { created_at: new Date(), updated_at: new Date(), }, + { + uid: uidDocument3, + blockchain_anchor_uid: null, + depositor_uid: uidCustomer1, + document_status: EDocumentStatus.ASKED, + folder_uid: uidOfficeFolder1, + document_type_uid: uidDocumentType3, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDocument4, + blockchain_anchor_uid: null, + depositor_uid: uidCustomer1, + document_status: EDocumentStatus.ASKED, + folder_uid: uidOfficeFolder1, + document_type_uid: uidDocumentType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDocument5, + blockchain_anchor_uid: null, + depositor_uid: uidCustomer1, + document_status: EDocumentStatus.ASKED, + folder_uid: uidOfficeFolder1, + document_type_uid: uidDocumentType1, + created_at: new Date(), + updated_at: new Date(), + }, ]; const documentTypes: DocumentTypes[] = [ @@ -397,7 +431,17 @@ import { uid: uidDocumentType2, archived_at: null, name: "Carte d'identité", - office_uid: uidOffice2, + office_uid: uidOffice1, + private_description: "Ce document est confidentiel, demander un recto-verso au client", + public_description: "Carte d'identité est un document officiel qui atteste de l'identité d'une personne", + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDocumentType3, + archived_at: null, + name: "Autres documents", + office_uid: uidOffice1, private_description: "Ce document est confidentiel, demander un recto-verso au client", public_description: "Carte d'identité est un document officiel qui atteste de l'identité d'une personne", created_at: new Date(), From fea447192306d35ae89002c5a13b514a9859cdb6 Mon Sep 17 00:00:00 2001 From: Vincent Alamelle Date: Thu, 11 May 2023 13:49:44 +0200 Subject: [PATCH 6/8] seeder v2 --- package-lock.json | 35 +- package.json | 2 +- src/common/databases/seeders/seeder2.ts | 1380 +++++++++++++++++++++++ 3 files changed, 1410 insertions(+), 7 deletions(-) create mode 100644 src/common/databases/seeders/seeder2.ts diff --git a/package-lock.json b/package-lock.json index 6e8150bc..2b3ba769 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "cors": "^2.8.5", "express": "^4.18.2", "jsonwebtoken": "^9.0.0", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.44", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.47", "module-alias": "^2.2.2", "multer": "^1.4.5-lts.1", "next": "^13.1.5", @@ -29,7 +29,8 @@ "tslib": "^2.4.1", "typedi": "^0.10.0", "typescript": "^4.9.4", - "uuid": "^9.0.0" + "uuid": "^9.0.0", + "uuidv4": "^6.2.13" }, "devDependencies": { "@types/cors": "^2.8.13", @@ -2371,9 +2372,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.389", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.389.tgz", - "integrity": "sha512-WDgWUOK8ROR7sDFyYmxCUOoDc50lPgYAHAHwnnD1iN3SKO/mpqftb9iIPiEkMKmqYdkrR0j3N/O+YB/U7lSxwg==", + "version": "1.4.391", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.391.tgz", + "integrity": "sha512-GqydVV1+kUWY5qlEzaw34/hyWTApuQrHiGrcGA2Kk/56nEK44i+YUW45VH43JuZT0Oo7uY8aVtpPhBBZXEWtSA==", "dev": true }, "node_modules/emittery": { @@ -3861,7 +3862,7 @@ } }, "node_modules/le-coffre-resources": { - "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#30c8ee50b872a8bc6bec0f5d8c4626d8f4490177", + "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#467b34a484adbd6dfa3fd6082bb7677f6178da51", "license": "MIT", "dependencies": { "class-transformer": "^0.5.1", @@ -5666,6 +5667,28 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/uuidv4": { + "version": "6.2.13", + "resolved": "https://registry.npmjs.org/uuidv4/-/uuidv4-6.2.13.tgz", + "integrity": "sha512-AXyzMjazYB3ovL3q051VLH06Ixj//Knx7QnUSi1T//Ie3io6CpsPu9nVMOx5MoLWh6xV0B9J0hIaxungxXUbPQ==", + "dependencies": { + "@types/uuid": "8.3.4", + "uuid": "8.3.2" + } + }, + "node_modules/uuidv4/node_modules/@types/uuid": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", + "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==" + }, + "node_modules/uuidv4/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", diff --git a/package.json b/package.json index 327677fa..9442b3d8 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,6 @@ }, "prisma": { "schema": "src/common/databases/schema.prisma", - "seed": "ts-node src/common/databases/seeders/seeder.ts" + "seed": "ts-node src/common/databases/seeders/seeder2.ts" } } diff --git a/src/common/databases/seeders/seeder2.ts b/src/common/databases/seeders/seeder2.ts new file mode 100644 index 00000000..53413da8 --- /dev/null +++ b/src/common/databases/seeders/seeder2.ts @@ -0,0 +1,1380 @@ +import { + Addresses, + Contacts, + Customers, + DeedHasDocumentTypes, + DeedTypeHasDocumentTypes, + DeedTypes, + Deeds, + DocumentHistory, + DocumentTypes, + Documents, + EDocumentStatus, + EFolderStatus, + EOfficeStatus, + Files, + OfficeFolderHasCustomers, + OfficeFolders, + Offices, + Users, + ECivility, + ECustomerStatus, + PrismaClient, +} from "@prisma/client"; + +(async () => { + const prisma = new PrismaClient(); + + const existingData = await prisma.contacts.findFirst({ where: { email: "john.doe@example.com" } }); + if (existingData) { + console.log("Seed data already exists. Skipping seeding process."); + return; + } + + const randomString = () => { + const chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + let result = ""; + for (let i = 10; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)]; + return result; + }; + const uidCustomer1: string = randomString(); + const uidCustomer2: string = randomString(); + const uidCustomer3: string = randomString(); + const uidCustomer4: string = randomString(); + const uidCustomer5: string = randomString(); + const uidCustomer6: string = randomString(); + const uidCustomer7: string = randomString(); + const uidCustomer8: string = randomString(); + const uidCustomer9: string = randomString(); + const uidCustomer10: string = randomString(); + const uidCustomer11: string = randomString(); + const uidCustomer12: string = randomString(); + const uidCustomer13: string = randomString(); + const uidCustomer14: string = randomString(); + const uidCustomer15: string = randomString(); + + const uidContact1: string = randomString(); + const uidContact2: string = randomString(); + const uidContact3: string = randomString(); + const uidContact4: string = randomString(); + const uidContact5: string = randomString(); + const uidContact6: string = randomString(); + const uidContact7: string = randomString(); + const uidContact8: string = randomString(); + const uidContact9: string = randomString(); + const uidContact10: string = randomString(); + const uidContact11: string = randomString(); + const uidContact12: string = randomString(); + const uidContact13: string = randomString(); + const uidContact14: string = randomString(); + const uidContact15: string = randomString(); + const uidContact16: string = randomString(); + const uidContact17: string = randomString(); + const uidContact18: string = randomString(); + const uidContact19: string = randomString(); + const uidContact20: string = randomString(); + + const uidAddress1: string = randomString(); + const uidAddress2: string = randomString(); + const uidAddress3: string = randomString(); + const uidAddress4: string = randomString(); + const uidAddress5: string = randomString(); + const uidAddress6: string = randomString(); + const uidAddress7: string = randomString(); + const uidAddress8: string = randomString(); + const uidAddress9: string = randomString(); + const uidAddress10: string = randomString(); + const uidAddress11: string = randomString(); + const uidAddress12: string = randomString(); + const uidAddress13: string = randomString(); + const uidAddress14: string = randomString(); + const uidAddress15: string = randomString(); + const uidAddress16: string = randomString(); + const uidAddress17: string = randomString(); + const uidAddress18: string = randomString(); + const uidAddress19: string = randomString(); + const uidAddress20: string = randomString(); + + const uidOffice1: string = randomString(); + + const uidUser1: string = randomString(); + const uidUser2: string = randomString(); + const uidUser3: string = randomString(); + const uidUser4: string = randomString(); + const uidUser5: string = randomString(); + + const uidOfficeFolder1: string = randomString(); + const uidOfficeFolder2: string = randomString(); + const uidOfficeFolder3: string = randomString(); + const uidOfficeFolder4: string = randomString(); + const uidOfficeFolder5: string = randomString(); + const uidOfficeFolder6: string = randomString(); + const uidOfficeFolder7: string = randomString(); + const uidOfficeFolder8: string = randomString(); + const uidOfficeFolder9: string = randomString(); + const uidOfficeFolder10: string = randomString(); + const uidOfficeFolder11: string = randomString(); + const uidOfficeFolder12: string = randomString(); + const uidOfficeFolder13: string = randomString(); + const uidOfficeFolder14: string = randomString(); + const uidOfficeFolder15: string = randomString(); + const uidOfficeFolder16: string = randomString(); + const uidOfficeFolder17: string = randomString(); + const uidOfficeFolder18: string = randomString(); + const uidOfficeFolder19: string = randomString(); + const uidOfficeFolder20: string = randomString(); + + const uidDeed1: string = randomString(); + const uidDeed2: string = randomString(); + const uidDeed3: string = randomString(); + const uidDeed4: string = randomString(); + const uidDeed5: string = randomString(); + const uidDeed6: string = randomString(); + const uidDeed7: string = randomString(); + const uidDeed8: string = randomString(); + const uidDeed9: string = randomString(); + const uidDeed10: string = randomString(); + const uidDeed11: string = randomString(); + const uidDeed12: string = randomString(); + const uidDeed13: string = randomString(); + const uidDeed14: string = randomString(); + const uidDeed15: string = randomString(); + const uidDeed16: string = randomString(); + const uidDeed17: string = randomString(); + const uidDeed18: string = randomString(); + const uidDeed19: string = randomString(); + const uidDeed20: string = randomString(); + + + const uidDeedType1: string = randomString(); + const uidDeedType2: string = randomString(); + const uidDeedType3: string = randomString(); + const uidDeedType4: string = randomString(); + const uidDeedType5: string = randomString(); + + const uidDocument1: string = randomString(); + const uidDocument2: string = randomString(); + + const uidDocumentType1: string = randomString(); + const uidDocumentType2: string = randomString(); + + const uidOfficeFolderHasCustomer1: string = randomString(); + const uidOfficeFolderHasCustomer2: string = randomString(); + + const uidFiles1: string = randomString(); + const uidFiles2: string = randomString(); + + const uidDeedHasDocumentType1: string = randomString(); + const uidDeedHasDocumentType2: string = randomString(); + + const uidDeedTypeHasDocumentType1: string = randomString(); + const uidDeedTypeHasDocumentType2: string = randomString(); + + const uidDocumentHistory1: string = randomString(); + const uidDocumentHistory2: string = randomString(); + + const customers: Customers[] = [ + { + uid: uidCustomer1, + contact_uid: uidContact1, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer2, + contact_uid: uidContact2, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer3, + contact_uid: uidContact3, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer4, + contact_uid: uidContact4, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer5, + contact_uid: uidContact5, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer6, + contact_uid: uidContact6, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer7, + contact_uid: uidContact7, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer8, + contact_uid: uidContact8, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer9, + contact_uid: uidContact9, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer10, + contact_uid: uidContact10, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer11, + contact_uid: uidContact11, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer12, + contact_uid: uidContact12, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer13, + contact_uid: uidContact13, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer14, + contact_uid: uidContact14, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + { + uid: uidCustomer15, + contact_uid: uidContact15, + created_at: new Date(), + updated_at: new Date(), + status: ECustomerStatus.PENDING, + }, + ]; + + const addresses: Addresses[] = [ + { + uid: uidAddress1, + address: "123 Main St", + city: "Los Angeles", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress2, + address: "Rue Pierre Emillion", + city: "Pacé", + zip_code: 35740, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress3, + address: "Rue Pierre Charles", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress4, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress5, + address: "Rue Pierre Marcel", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress6, + address: "Rue Pierre Jacques", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress7, + address: "Rue Pierre Pascal", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress8, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress9, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress10, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress11, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress12, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress13, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress14, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress15, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress16, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress17, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress18, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress19, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidAddress20, + address: "Rue Pierre Pologne", + city: "Rennes", + zip_code: 35000, + created_at: new Date(), + updated_at: new Date(), + }, + + ]; + + const contacts: Contacts[] = [ + { + uid: uidContact1, + address_uid: uidAddress1, + first_name: "John", + last_name: "Doe", + email: "john.doe@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.MALE, + }, + { + uid: uidContact2, + address_uid: uidAddress2, + first_name: "Jane", + last_name: "Doe", + email: "jane.doe@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact3, + address_uid: uidAddress3, + first_name: "Maitre Marcelino", + last_name: "Jack", + email: "Marcelino.Jack@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.MALE, + }, + { + uid: uidContact4, + address_uid: uidAddress4, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack19@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact5, + address_uid: uidAddress5, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack18@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact6, + address_uid: uidAddress6, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack2@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact7, + address_uid: uidAddress7, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack3@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact8, + address_uid: uidAddress8, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack4@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact9, + address_uid: uidAddress9, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack5@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact10, + address_uid: uidAddress10, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack6@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact11, + address_uid: uidAddress11, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack7@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact12, + address_uid: uidAddress12, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack8@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact13, + address_uid: uidAddress13, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack9@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact14, + address_uid: uidAddress14, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack10@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact15, + address_uid: uidAddress15, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack11@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact16, + address_uid: uidAddress16, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack12@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact17, + address_uid: uidAddress17, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack13@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact18, + address_uid: uidAddress18, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack14@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact19, + address_uid: uidAddress19, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack15@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + { + uid: uidContact20, + address_uid: uidAddress20, + first_name: "Maitre Massi", + last_name: "Jack", + email: "Massi.Jack16@example.com", + phone_number: randomString(), + cell_phone_number: randomString(), + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.FEMALE, + }, + ]; + + const offices: Offices[] = [ + { + uid: uidOffice1, + idNot: randomString(), + name: "LA Office", + crpcen: randomString(), + address_uid: uidAddress1, + created_at: new Date(), + updated_at: new Date(), + office_status: EOfficeStatus.ACTIVATED, + } + ]; + + const users: Users[] = [ + { + uid: uidUser1, + created_at: new Date(), + updated_at: new Date(), + idNot: randomString(), + contact_uid: uidContact16, + office_uid: uidOffice1, + }, + { + uid: uidUser2, + created_at: new Date(), + updated_at: new Date(), + idNot: randomString(), + contact_uid: uidContact17, + office_uid: uidOffice1, + }, + { + uid: uidUser3, + created_at: new Date(), + updated_at: new Date(), + idNot: randomString(), + contact_uid: uidContact18, + office_uid: uidOffice1, + }, + { + uid: uidUser4, + created_at: new Date(), + updated_at: new Date(), + idNot: randomString(), + contact_uid: uidContact19, + office_uid: uidOffice1, + }, + { + uid: uidUser5, + created_at: new Date(), + updated_at: new Date(), + idNot: randomString(), + contact_uid: uidContact20, + office_uid: uidOffice1, + }, + ]; + + const officeFolders: OfficeFolders[] = [ + { + uid: uidOfficeFolder1, + folder_number: "0001", + name: "Dossier", + deed_uid: uidDeed1, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder2, + folder_number: "0002", + name: "Dossier", + deed_uid: uidDeed2, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder3, + folder_number: "0003", + name: "Dossier", + deed_uid: uidDeed3, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder4, + folder_number: "0004", + name: "Dossier", + deed_uid: uidDeed4, + status: EFolderStatus.ARCHIVED, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder5, + folder_number: "0005", + name: "Dossier", + deed_uid: uidDeed5, + status: EFolderStatus.ARCHIVED, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder6, + folder_number: "0006", + name: "Dossier", + deed_uid: uidDeed6, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder7, + folder_number: "0007", + name: "Dossier", + deed_uid: uidDeed7, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder8, + folder_number: "0008", + name: "Dossier", + deed_uid: uidDeed8, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder9, + folder_number: "0009", + name: "Dossier", + deed_uid: uidDeed9, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder10, + folder_number: "00010", + name: "Dossier", + deed_uid: uidDeed10, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder11, + folder_number: "00011", + name: "Dossier", + deed_uid: uidDeed11, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder12, + folder_number: "00012", + name: "Dossier", + deed_uid: uidDeed12, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder13, + folder_number: "00013", + name: "Dossier", + deed_uid: uidDeed13, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder14, + folder_number: "00014", + name: "Dossier", + deed_uid: uidDeed14, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder15, + folder_number: "00015", + name: "Dossier", + deed_uid: uidDeed15, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder16, + folder_number: "00016", + name: "Dossier", + deed_uid: uidDeed16, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder17, + folder_number: "00017", + name: "Dossier", + deed_uid: uidDeed17, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder18, + folder_number: "00018", + name: "Dossier", + deed_uid: uidDeed18, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder19, + folder_number: "00019", + name: "Dossier", + deed_uid: uidDeed19, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + { + uid: uidOfficeFolder20, + folder_number: "00020", + name: "Dossier", + deed_uid: uidDeed20, + status: EFolderStatus.LIVE, + created_at: new Date(), + updated_at: new Date(), + office_uid: uidOffice1, + description: null, + archived_description: null, + }, + ]; + + const deeds: Deeds[] = [ + { + uid: uidDeed1, + deed_type_uid: uidDeedType1, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed2, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed3, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed4, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed5, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed6, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed7, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed8, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed9, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed10, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed11, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed12, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed13, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed14, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed15, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed16, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed17, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed18, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed19, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeed20, + deed_type_uid: uidDeedType2, + created_at: new Date(), + updated_at: new Date(), + }, + ]; + + const deedTypes: DeedTypes[] = [ + { + uid: uidDeedType1, + name: "Acte de mariage", + archived_at: null, + description: "Acte regroupant deux personnes en mariage", + office_uid: uidOffice1, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeedType2, + name: "Vente d'un bien immobilier", + archived_at: null, + description: "Permet de vendre un bien immobilier à une entité ou une personne physique", + office_uid: uidOffice1, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeedType3, + name: "Deed Type 3", + archived_at: null, + description: "Deed type 3", + office_uid: uidOffice1, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeedType4, + name: "Deed Type 4", + archived_at: null, + description: "Deed type 4", + office_uid: uidOffice1, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeedType5, + name: "Deed Type 5", + archived_at: null, + description: "Deed type 5", + office_uid: uidOffice1, + created_at: new Date(), + updated_at: new Date(), + }, + ]; + + const documents: Documents[] = [ + { + uid: uidDocument1, + blockchain_anchor_uid: null, + depositor_uid: uidCustomer1, + document_status: EDocumentStatus.DEPOSITED, + folder_uid: uidOfficeFolder1, + document_type_uid: uidDocumentType1, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDocument2, + blockchain_anchor_uid: null, + depositor_uid: uidCustomer2, + document_status: EDocumentStatus.ASKED, + folder_uid: uidOfficeFolder2, + document_type_uid: uidDocumentType2, + created_at: new Date(), + updated_at: new Date(), + }, + ]; + + const documentTypes: DocumentTypes[] = [ + { + uid: uidDocumentType1, + archived_at: null, + name: "Acte de naissance", + office_uid: uidOffice1, + private_description: "Ce document est confidentiel, et ne doit pas être divulgué", + public_description: "Acte de naissance est un document officiel qui atteste de la naissance d'une personne", + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDocumentType2, + archived_at: null, + name: "Carte d'identité", + office_uid: uidOffice1, + private_description: "Ce document est confidentiel, demander un recto-verso au client", + public_description: "Carte d'identité est un document officiel qui atteste de l'identité d'une personne", + created_at: new Date(), + updated_at: new Date(), + }, + ]; + + const officeFolderHasCustomers: OfficeFolderHasCustomers[] = [ + { + uid: uidOfficeFolderHasCustomer1, + customer_uid: uidCustomer1, + office_folder_uid: uidOfficeFolder1, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidOfficeFolderHasCustomer2, + customer_uid: uidCustomer2, + office_folder_uid: uidOfficeFolder2, + created_at: new Date(), + updated_at: new Date(), + }, + ]; + + const files: Files[] = [ + { + uid: uidFiles1, + document_uid: uidDocument1, + file_name: "fileName1", + file_path: "https://www.google1.com", + key: '', + archived_at: null, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidFiles2, + document_uid: uidDocument2, + file_name: "fileName1", + file_path: "https://www.google2.com", + key: '', + archived_at: null, + created_at: new Date(), + updated_at: new Date(), + }, + ]; + + const deedHasDocumentTypes: DeedHasDocumentTypes[] = [ + { + uid: uidDeedHasDocumentType1, + deed_uid: uidDeed1, + document_type_uid: uidDocumentType1, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeedHasDocumentType2, + deed_uid: uidDeed2, + document_type_uid: uidDocumentType2, + created_at: new Date(), + updated_at: new Date(), + }, + ]; + + const deedTypeHasDocumentTypes: DeedTypeHasDocumentTypes[] = [ + { + uid: uidDeedTypeHasDocumentType1, + deed_type_uid: uidDeedType1, + document_type_uid: uidDocumentType1, + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDeedTypeHasDocumentType2, + deed_type_uid: uidDeedType2, + document_type_uid: uidDocumentType2, + created_at: new Date(), + updated_at: new Date(), + }, + ]; + + const documentHistories: DocumentHistory[] = [ + { + uid: uidDocumentHistory1, + document_status: EDocumentStatus.ASKED, + document_uid: uidDocument1, + refused_reason: "", + created_at: new Date(), + updated_at: new Date(), + }, + { + uid: uidDocumentHistory2, + document_status: EDocumentStatus.DEPOSITED, + document_uid: uidDocument1, + refused_reason: "Le document n'est pas conforme", + created_at: new Date(), + updated_at: new Date(), + }, + ]; + + for (const address of addresses) { + await prisma.addresses.create({ data: address }); + } + + for (const contact of contacts) { + await prisma.contacts.create({ data: contact }); + } + + for (const office of offices) { + await prisma.offices.create({ data: office }); + } + + for (const user of users) { + await prisma.users.create({ data: user }); + } + + for (const customer of customers) { + await prisma.customers.create({ data: customer }); + } + + for (const deedType of deedTypes) { + await prisma.deedTypes.create({ data: deedType }); + } + + for (const deed of deeds) { + await prisma.deeds.create({ data: deed }); + } + for (const officeFolder of officeFolders) { + await prisma.officeFolders.create({ data: officeFolder }); + } + + for (const documentType of documentTypes) { + await prisma.documentTypes.create({ data: documentType }); + } + + for (const document of documents) { + await prisma.documents.create({ data: document }); + } + + for (const file of files) { + await prisma.files.create({ data: file }); + } + + for (const documentHistory of documentHistories) { + await prisma.documentHistory.create({ data: documentHistory }); + } + + for (const officeFolderHasCustomer of officeFolderHasCustomers) { + await prisma.officeFolderHasCustomers.create({ data: officeFolderHasCustomer }); + } + + for (const deedHasDocumentType of deedHasDocumentTypes) { + await prisma.deedHasDocumentTypes.create({ data: deedHasDocumentType }); + } + + for (const deedTypeHasDocumentType of deedTypeHasDocumentTypes) { + await prisma.deedTypeHasDocumentTypes.create({ data: deedTypeHasDocumentType }); + } + + console.log(">MOCK DATA - Seeding completed!"); +})(); From 23eb8aecc44a9d40122deb4a82036f541055861d Mon Sep 17 00:00:00 2001 From: Vincent Alamelle Date: Thu, 11 May 2023 14:16:16 +0200 Subject: [PATCH 7/8] Seeder v2 update --- package.json | 2 +- src/common/databases/seeders/seeder2.ts | 266 ++++++++++++------------ 2 files changed, 134 insertions(+), 134 deletions(-) diff --git a/package.json b/package.json index 9442b3d8..8f6c3f38 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@Test": "./dist/test" }, "scripts": { - "build-db": "npx prisma migrate dev && node ./dist/common/databases/seeders/seeder.js", + "build-db": "npx prisma migrate dev", "build": "tsc", "start": "node ./dist/entries/App.js", "api:start": "npm run migrate && npm run start", diff --git a/src/common/databases/seeders/seeder2.ts b/src/common/databases/seeders/seeder2.ts index 53413da8..3ad9520e 100644 --- a/src/common/databases/seeders/seeder2.ts +++ b/src/common/databases/seeders/seeder2.ts @@ -284,8 +284,8 @@ import { const addresses: Addresses[] = [ { uid: uidAddress1, - address: "123 Main St", - city: "Los Angeles", + address: "148 Avenue du bac", + city: "Rennes", zip_code: 35000, created_at: new Date(), updated_at: new Date(), @@ -340,7 +340,7 @@ import { }, { uid: uidAddress8, - address: "Rue Pierre Pologne", + address: "Rue Maxime Henry", city: "Rennes", zip_code: 35000, created_at: new Date(), @@ -348,7 +348,7 @@ import { }, { uid: uidAddress9, - address: "Rue Pierre Pologne", + address: "Rue Maxime Francis", city: "Rennes", zip_code: 35000, created_at: new Date(), @@ -356,7 +356,7 @@ import { }, { uid: uidAddress10, - address: "Rue Pierre Pologne", + address: "Avenue Paul Roger", city: "Rennes", zip_code: 35000, created_at: new Date(), @@ -364,7 +364,7 @@ import { }, { uid: uidAddress11, - address: "Rue Pierre Pologne", + address: "Avenue Paul Franck", city: "Rennes", zip_code: 35000, created_at: new Date(), @@ -372,7 +372,7 @@ import { }, { uid: uidAddress12, - address: "Rue Pierre Pologne", + address: "Avenue Paul Maréchal", city: "Rennes", zip_code: 35000, created_at: new Date(), @@ -380,7 +380,7 @@ import { }, { uid: uidAddress13, - address: "Rue Pierre Pologne", + address: "Avenue Marcel Denis", city: "Rennes", zip_code: 35000, created_at: new Date(), @@ -388,7 +388,7 @@ import { }, { uid: uidAddress14, - address: "Rue Pierre Pologne", + address: "Place Alexandre", city: "Rennes", zip_code: 35000, created_at: new Date(), @@ -396,7 +396,7 @@ import { }, { uid: uidAddress15, - address: "Rue Pierre Pologne", + address: "Place Alexandre Jacques", city: "Rennes", zip_code: 35000, created_at: new Date(), @@ -404,7 +404,7 @@ import { }, { uid: uidAddress16, - address: "Rue Pierre Pologne", + address: "Place Alexandre 2", city: "Rennes", zip_code: 35000, created_at: new Date(), @@ -412,7 +412,7 @@ import { }, { uid: uidAddress17, - address: "Rue Pierre Pologne", + address: "Rue du livre", city: "Rennes", zip_code: 35000, created_at: new Date(), @@ -420,7 +420,7 @@ import { }, { uid: uidAddress18, - address: "Rue Pierre Pologne", + address: "Place de la joie", city: "Rennes", zip_code: 35000, created_at: new Date(), @@ -428,7 +428,7 @@ import { }, { uid: uidAddress19, - address: "Rue Pierre Pologne", + address: "Rue Paul Henry", city: "Rennes", zip_code: 35000, created_at: new Date(), @@ -436,7 +436,7 @@ import { }, { uid: uidAddress20, - address: "Rue Pierre Pologne", + address: "Rue Marcelin", city: "Rennes", zip_code: 35000, created_at: new Date(), @@ -449,37 +449,37 @@ import { { uid: uidContact1, address_uid: uidAddress1, - first_name: "John", - last_name: "Doe", - email: "john.doe@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), - birthdate: null, - created_at: new Date(), - updated_at: new Date(), - civility: ECivility.MALE, - }, - { - uid: uidContact2, - address_uid: uidAddress2, - first_name: "Jane", - last_name: "Doe", - email: "jane.doe@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Manon", + last_name: "Simon", + email: "manon.simon@gmail.com", + phone_number: "06 12 34 56 78", + cell_phone_number: "06 12 34 56 78", birthdate: null, created_at: new Date(), updated_at: new Date(), civility: ECivility.FEMALE, }, + { + uid: uidContact2, + address_uid: uidAddress2, + first_name: "Kevin", + last_name: "Hautefaye", + email: "kevin.hautefaye@gmail.com", + phone_number: "06 23 45 67 89", + cell_phone_number: "06 23 45 67 89", + birthdate: null, + created_at: new Date(), + updated_at: new Date(), + civility: ECivility.MALE, + }, { uid: uidContact3, address_uid: uidAddress3, - first_name: "Maitre Marcelino", - last_name: "Jack", - email: "Marcelino.Jack@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Maxime", + last_name: "Lalo", + email: "maxime.lalo@gmail.com", + phone_number: "06 34 56 78 90", + cell_phone_number: "06 34 56 78 90", birthdate: null, created_at: new Date(), updated_at: new Date(), @@ -488,50 +488,50 @@ import { { uid: uidContact4, address_uid: uidAddress4, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack19@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Vincent", + last_name: "Brognard", + email: "vincent.brognard@gmail.com", + phone_number: "06 45 67 89 01", + cell_phone_number: "06 45 67 89 01", birthdate: null, created_at: new Date(), updated_at: new Date(), - civility: ECivility.FEMALE, + civility: ECivility.MALE, }, { uid: uidContact5, address_uid: uidAddress5, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack18@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Maxime", + last_name: "Leroy", + email: "maxime.leroy@hotmail.fr", + phone_number: "06 56 78 90 12", + cell_phone_number: "06 56 78 90 12", birthdate: null, created_at: new Date(), updated_at: new Date(), - civility: ECivility.FEMALE, + civility: ECivility.MALE, }, { uid: uidContact6, address_uid: uidAddress6, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack2@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Thibault", + last_name: "Dubois", + email: "thibault.dubois@outlook.com", + phone_number: "06 67 89 01 23", + cell_phone_number: "06 67 89 01 23", birthdate: null, created_at: new Date(), updated_at: new Date(), - civility: ECivility.FEMALE, + civility: ECivility.MALE, }, { uid: uidContact7, address_uid: uidAddress7, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack3@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Léa", + last_name: "Fontaine", + email: "lea.fontaine@gmail.com", + phone_number: "06 78 90 12 34", + cell_phone_number: "06 78 90 12 34", birthdate: null, created_at: new Date(), updated_at: new Date(), @@ -540,24 +540,24 @@ import { { uid: uidContact8, address_uid: uidAddress8, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack4@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Guillaume", + last_name: "Renaud", + email: "guillaume.renaud@gmail.com", + phone_number: "06 89 01 23 45", + cell_phone_number: "06 89 01 23 45", birthdate: null, created_at: new Date(), updated_at: new Date(), - civility: ECivility.FEMALE, + civility: ECivility.MALE, }, { uid: uidContact9, address_uid: uidAddress9, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack5@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Lucie", + last_name: "Chevalier", + email: "lucie.chevalier@outlook.com", + phone_number: "07 12 34 56 78", + cell_phone_number: "07 12 34 56 78", birthdate: null, created_at: new Date(), updated_at: new Date(), @@ -566,24 +566,24 @@ import { { uid: uidContact10, address_uid: uidAddress10, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack6@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Sébastien", + last_name: "Dubois", + email: "sebastien.dubois@gmail.com", + phone_number: "07 23 45 67 89", + cell_phone_number: "07 23 45 67 89", birthdate: null, created_at: new Date(), updated_at: new Date(), - civility: ECivility.FEMALE, + civility: ECivility.MALE, }, { uid: uidContact11, address_uid: uidAddress11, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack7@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Mathilde", + last_name: "Durand", + email: "mathilde.durand@gmail.com", + phone_number: "07 34 56 78 90", + cell_phone_number: "07 34 56 78 90", birthdate: null, created_at: new Date(), updated_at: new Date(), @@ -592,24 +592,24 @@ import { { uid: uidContact12, address_uid: uidAddress12, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack8@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Antoine", + last_name: "Bernard", + email: "antoine.bernard@outlook.com", + phone_number: "07 45 67 89 01", + cell_phone_number: "07 45 67 89 01", birthdate: null, created_at: new Date(), updated_at: new Date(), - civility: ECivility.FEMALE, + civility: ECivility.MALE, }, { uid: uidContact13, address_uid: uidAddress13, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack9@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Camille", + last_name: "Laurent", + email: "camille.laurent@gmail.com", + phone_number: "07 56 78 90 12", + cell_phone_number: "07 56 78 90 12", birthdate: null, created_at: new Date(), updated_at: new Date(), @@ -618,24 +618,24 @@ import { { uid: uidContact14, address_uid: uidAddress14, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack10@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Julien", + last_name: "Mercier", + email: "julien.mercier@hotmail.fr", + phone_number: "07 67 89 01 23", + cell_phone_number: "07 67 89 01 23", birthdate: null, created_at: new Date(), updated_at: new Date(), - civility: ECivility.FEMALE, + civility: ECivility.MALE, }, { uid: uidContact15, address_uid: uidAddress15, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack11@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Charlotte", + last_name: "Lefebvre", + email: "charlotte.lefebvre@gmail.com", + phone_number: "07 78 90 12 34", + cell_phone_number: "07 78 90 12 34", birthdate: null, created_at: new Date(), updated_at: new Date(), @@ -644,11 +644,11 @@ import { { uid: uidContact16, address_uid: uidAddress16, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack12@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Caroline", + last_name: "Pallut", + email: "caroline.pallut@gmail.com", + phone_number: "07 89 01 23 45", + cell_phone_number: "07 89 01 23 45", birthdate: null, created_at: new Date(), updated_at: new Date(), @@ -657,11 +657,11 @@ import { { uid: uidContact17, address_uid: uidAddress17, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack13@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Nadège", + last_name: "Gauchet", + email: "nedege.gauchet@outlook.com", + phone_number: "06 11 22 33 44", + cell_phone_number: "06 11 22 33 44", birthdate: null, created_at: new Date(), updated_at: new Date(), @@ -670,24 +670,24 @@ import { { uid: uidContact18, address_uid: uidAddress18, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack14@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Matthieu", + last_name: "Bougeard", + email: "matthieu.bougeard@gmail.com", + phone_number: "07 22 33 44 55", + cell_phone_number: "07 22 33 44 55", birthdate: null, created_at: new Date(), updated_at: new Date(), - civility: ECivility.FEMALE, + civility: ECivility.MALE, }, { uid: uidContact19, address_uid: uidAddress19, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack15@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Cécile", + last_name: "Celton", + email: "cecile.celton@outlook.com", + phone_number: "06 55 66 77 88", + cell_phone_number: "06 55 66 77 88", birthdate: null, created_at: new Date(), updated_at: new Date(), @@ -696,15 +696,15 @@ import { { uid: uidContact20, address_uid: uidAddress20, - first_name: "Maitre Massi", - last_name: "Jack", - email: "Massi.Jack16@example.com", - phone_number: randomString(), - cell_phone_number: randomString(), + first_name: "Gwendal", + last_name: "Texier", + email: "gwendal.texier@gmail.com", + phone_number: "07 88 99 00 11", + cell_phone_number: "07 88 99 00 11", birthdate: null, created_at: new Date(), updated_at: new Date(), - civility: ECivility.FEMALE, + civility: ECivility.MALE, }, ]; @@ -712,7 +712,7 @@ import { { uid: uidOffice1, idNot: randomString(), - name: "LA Office", + name: "Office Rennes", crpcen: randomString(), address_uid: uidAddress1, created_at: new Date(), From d4c8466f9d6e3454ef06eda78abedad2564ce273 Mon Sep 17 00:00:00 2001 From: Vincent Alamelle Date: Thu, 11 May 2023 14:29:39 +0200 Subject: [PATCH 8/8] Removed key data variables --- src/common/config/variables/Variables.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/common/config/variables/Variables.ts b/src/common/config/variables/Variables.ts index 43646886..bc20851c 100644 --- a/src/common/config/variables/Variables.ts +++ b/src/common/config/variables/Variables.ts @@ -54,9 +54,6 @@ export class BackendVariables { @IsNotEmpty() public readonly PINATA_GATEWAY!: string; - @IsNotEmpty() - public readonly KEY_DATA!: string; - public constructor() { dotenv.config(); this.DATABASE_PORT = process.env["DATABASE_PORT"]!; @@ -75,7 +72,6 @@ export class BackendVariables { this.PINATA_API_KEY = process.env["PINATA_API_KEY"]!; this.PINATA_API_SECRET = process.env["PINATA_API_SECRET"]!; this.PINATA_GATEWAY = process.env["PINATA_GATEWAY"]!; - this.KEY_DATA = process.env["KEY_DATA"]!; } public async validate() { await validateOrReject(this);