From fea447192306d35ae89002c5a13b514a9859cdb6 Mon Sep 17 00:00:00 2001 From: Vincent Alamelle Date: Thu, 11 May 2023 13:49:44 +0200 Subject: [PATCH] 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!"); +})();