2023-06-27 18:06:54 +02:00

600 lines
16 KiB
TypeScript

import {
// Addresses,
// Contacts,
// Customers,
// DeedHasDocumentTypes,
// DeedTypeHasDocumentTypes,
// DeedTypes,
// Deeds,
// DocumentHistory,
// DocumentTypes,
// Documents,
// EDocumentStatus,
// EFolderStatus,
// EOfficeStatus,
// OfficeFolderHasCustomers,
// OfficeFolders,
// Offices,
// Users,
// ECivility,
// ECustomerStatus,
PrismaClient,
// Roles,
} from "@prisma/client";
(async () => {
const prisma = new PrismaClient();
console.log(prisma);
// 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 uidContact1: string = randomString();
// const uidContact2: string = randomString();
// const uidContact3: string = randomString();
// const uidContact4: string = randomString();
// const uidAddress1: string = randomString();
// const uidAddress2: string = randomString();
// const uidAddress3: string = randomString();
// const uidAddress4: string = randomString();
// const uidOffice1: string = randomString();
// const uidOffice2: string = randomString();
// const uidUser1: string = randomString();
// const uidUser2: string = randomString();
// const uidRole1: string = randomString();
// const uidRole2: string = randomString();
// const uidOfficeFolder1: string = randomString();
// const uidOfficeFolder2: string = randomString();
// const uidOfficeFolder3: string = randomString();
// const uidOfficeFolder4: string = randomString();
// const uidOfficeFolder5: string = randomString();
// const uidDeed1: string = randomString();
// const uidDeed2: string = randomString();
// const uidDeed3: string = randomString();
// const uidDeed4: string = randomString();
// const uidDeed5: string = randomString();
// const uidDeedType1: string = randomString();
// const uidDeedType2: string = randomString();
// 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();
// 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 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,
// 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,
// },
// ];
// const addresses: Addresses[] = [
// {
// uid: uidAddress1,
// address: "123 Main St",
// city: "Los Angeles",
// zip_code: 90001,
// created_at: new Date(),
// updated_at: new Date(),
// },
// {
// uid: uidAddress2,
// address: "Rue Pierre Emillion",
// city: "Paris",
// zip_code: 75003,
// created_at: new Date(),
// updated_at: new Date(),
// },
// {
// uid: uidAddress3,
// address: "Rue Pierre Charles",
// city: "Paris",
// zip_code: 75003,
// created_at: new Date(),
// updated_at: new Date(),
// },
// {
// uid: uidAddress4,
// address: "Rue Pierre Pologne",
// city: "Paris",
// zip_code: 75003,
// 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.Jack@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,
// },
// {
// uid: uidOffice2,
// idNot: randomString(),
// name: "NYC Office",
// crpcen: randomString(),
// address_uid: uidAddress2,
// created_at: new Date(),
// updated_at: new Date(),
// office_status: EOfficeStatus.DESACTIVATED,
// },
// ];
// const roles: Roles[] = [
// {
// uid: uidRole1,
// name: 'super-admin',
// created_at: new Date(),
// updated_at: new Date(),
// },
// {
// uid: uidRole2,
// name: 'admin',
// created_at: new Date(),
// updated_at: new Date(),
// }
// ];
// const users: Users[] = [
// {
// uid: uidUser1,
// created_at: new Date(),
// updated_at: new Date(),
// idNot: randomString(),
// contact_uid: uidContact1,
// office_uid: uidOffice1,
// roles_uid: uidRole1,
// },
// {
// uid: uidUser2,
// created_at: new Date(),
// updated_at: new Date(),
// idNot: randomString(),
// contact_uid: uidContact2,
// office_uid: uidOffice2,
// roles_uid: uidRole2,
// },
// ];
// 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: uidOffice2,
// 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: uidOffice2,
// 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: uidOffice2,
// 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: uidOffice2,
// 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(),
// },
// ];
// 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: uidOffice2,
// 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(),
// },
// {
// 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[] = [
// {
// 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(),
// },
// {
// 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(),
// 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 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 role of roles) {
// await prisma.roles.create({ data: role });
// }
// 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 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!");
})();