elliottchong

Untitled

Mar 13th, 2024
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.02 KB | None | 0 0
  1. generator client {
  2. provider = "prisma-client-js"
  3. previewFeatures = ["views"]
  4. }
  5.  
  6. datasource db {
  7. provider = "postgresql"
  8. url = env("DATABASE_URL")
  9. directUrl = env("DIRECT_URL")
  10. }
  11.  
  12. model User {
  13. id String @id
  14. email String @unique
  15. firstName String
  16. lastName String
  17. role UserRole @default(applicant)
  18. createdAt DateTime @default(now())
  19. updatedAt DateTime @default(now()) @updatedAt
  20. devId String? @unique
  21. hashedPassword String?
  22. emailVerified DateTime?
  23. Account Account[]
  24. applications Application[] @relation("ApplicationToUser")
  25. conversations Conversation[]
  26. conversationSessionLog ConversationSessionLog[]
  27. ConversationsToUsers ConversationsToUsers[]
  28. messages Message[]
  29. Session Session[]
  30. WorkflowSchema WorkflowSchema[]
  31. WorkflowSubmission WorkflowSubmission[]
  32. authorizedOrganizationsStatuses OrganizationStatus[] @relation("AuthorizedUsers")
  33. Chore Chore[] @relation("ChoreToUser")
  34. ChoreTrigger ChoreTrigger[] @relation("ChoreTriggerToUser")
  35. organizations Organization[] @relation("OrganizationToUser")
  36. comments ConversationComment[]
  37. UserAllowedOrganizations UserAllowedOrganizations[]
  38. }
  39.  
  40. model UserAllowedOrganizations {
  41. id String @id @default(cuid())
  42. createdAt DateTime @default(now())
  43. updatedAt DateTime @default(now()) @updatedAt
  44. userId String
  45. organizationId String
  46. user User @relation(fields: [userId], references: [id])
  47. organization Organization @relation(fields: [organizationId], references: [id])
  48. }
  49.  
  50. model TempUserHashPassword {
  51. id String @id @default(cuid())
  52. createdAt DateTime @default(now())
  53. updatedAt DateTime @default(now())
  54. hashedPassword String
  55. userId String
  56. }
  57.  
  58. model Integration {
  59. id String @id @default(cuid())
  60. createdAt DateTime @default(now())
  61. updatedAt DateTime @default(now()) @updatedAt
  62. name String
  63. description String?
  64. logoUrl String?
  65. integrationProducts IntegrationProduct[]
  66. }
  67.  
  68. model IntegrationProduct {
  69. id String @id @default(cuid())
  70. createdAt DateTime @default(now())
  71. updatedAt DateTime @default(now()) @updatedAt
  72. integrationId String
  73. productId String
  74. integration Integration @relation(fields: [integrationId], references: [id])
  75. product Product @relation(fields: [productId], references: [id])
  76. }
  77.  
  78. model Endpoint {
  79. id String @id @default(cuid())
  80. description String
  81.  
  82. // inputEntities EntityView[]
  83. // outputEntities EntityField[]
  84.  
  85. rpcEndpoint String
  86. }
  87.  
  88. model Message {
  89. id String @id @default(cuid())
  90. text String
  91. timestamp DateTime @default(now())
  92. messageType MessageType
  93. aiThoughtProcess String?
  94. approvedById String?
  95. approvedAt DateTime?
  96. conversationId String
  97. uploadRequired Boolean @default(false)
  98. systemMessage String?
  99. subject String? @default("")
  100. attachments String[] @default([])
  101. source Company?
  102. sourceId String?
  103. contactId String?
  104. sourceMetadata Json?
  105. approvedBy User? @relation(fields: [approvedById], references: [id])
  106. contact Contact? @relation(fields: [contactId], references: [id])
  107. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  108. messageAttachments MessageAttachment[]
  109. }
  110.  
  111. model MessageAttachment {
  112. id String @id @default(cuid())
  113. createdAt DateTime @default(now())
  114. updatedAt DateTime @default(now()) @updatedAt
  115. messageId String
  116. conversationId String
  117. url String
  118. name String
  119. message Message @relation(fields: [messageId], references: [id], onDelete: Cascade)
  120. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  121.  
  122. @@index([messageId])
  123. @@index([conversationId])
  124. }
  125.  
  126. model ClientFile {
  127. id String @id @default(cuid())
  128. createdAt DateTime @default(now())
  129. updatedAt DateTime @default(now()) @updatedAt
  130. requiredName String
  131. uploadedName String?
  132. conversationId String
  133. url String?
  134. previewUrl String?
  135. status ClientFileStatus @default(pending)
  136. Description String?
  137. RejectionReasoning String?
  138. Visibility Visibility @default(private)
  139. fileType String?
  140. statusId String?
  141. documentType DocumentType @default(OTHER)
  142. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  143. extractedValues ExtractedValue[]
  144. triggerId String?
  145. trigger FileStatusTrigger? @relation(fields: [triggerId], references: [id])
  146. }
  147.  
  148. model ExtractedValue {
  149. id String @id @default(cuid())
  150. name String
  151. createdAt DateTime @default(now())
  152. updatedAt DateTime @default(now()) @updatedAt
  153. value String
  154. clientFileId String
  155. displayName String
  156. clientFile ClientFile @relation(fields: [clientFileId], references: [id], onDelete: Cascade)
  157. }
  158.  
  159. model Client {
  160. id String @id @default(cuid())
  161. createdAt DateTime @default(now())
  162. updatedAt DateTime @default(now()) @updatedAt
  163. firstName String?
  164. lastName String?
  165. name String?
  166. organizationId String
  167. activeContactId String?
  168. caseId String?
  169. Case Case?
  170. organization Organization @relation(fields: [organizationId], references: [id])
  171. contacts Contact[]
  172. conversations Conversation[] @relation("conversationToClient")
  173. }
  174.  
  175. model Contact {
  176. id String @id @default(cuid())
  177. createdAt DateTime @default(now())
  178. updatedAt DateTime @default(now()) @updatedAt
  179. detail String
  180. mode CommunicationMedium
  181. clientId String
  182. creationId String?
  183. Client Client @relation(fields: [clientId], references: [id], onDelete: Cascade)
  184. messages Message[]
  185. }
  186.  
  187. model Account {
  188. id String @id
  189. userId String
  190. type String
  191. provider String
  192. providerAccountId String
  193. refresh_token String?
  194. access_token String?
  195. expires_at Int
  196. token_type String?
  197. scope String?
  198. id_token String?
  199. session_state String?
  200. User User @relation(fields: [userId], references: [id], onDelete: Cascade)
  201.  
  202. @@unique([provider, providerAccountId])
  203. }
  204.  
  205. model LandingContactForm {
  206. id String @id @default(cuid())
  207. createdAt DateTime @default(now())
  208. updatedAt DateTime @default(now())
  209. email String
  210. name String?
  211. company String?
  212. message String?
  213. }
  214.  
  215. model EmailVerification {
  216. id String @id
  217. expires DateTime
  218. code String @unique
  219. userId String @unique
  220. }
  221.  
  222. model Session {
  223. id String @id
  224. sessionToken String @unique
  225. userId String
  226. expires DateTime
  227. User User @relation(fields: [userId], references: [id], onDelete: Cascade)
  228. }
  229.  
  230. model Case {
  231. id String @id @default(cuid())
  232. createdAt DateTime @default(now())
  233. updatedAt DateTime @default(now()) @updatedAt
  234. organizationId String
  235. aiTimestampLock DateTime @default(now())
  236. creationId String?
  237. activeConversationId String?
  238. clientId String? @unique
  239. role UserRole @default(lead)
  240. client Client? @relation(fields: [clientId], references: [id])
  241. organization Organization @relation(fields: [organizationId], references: [id])
  242. FunctionTask FunctionTask[]
  243. Memory Memory[]
  244. conversations Conversation[] @relation("CaseToConversation")
  245. }
  246.  
  247. model Conversation {
  248. id String @id @default(cuid())
  249. createdAt DateTime @default(now())
  250. updatedAt DateTime @default(now()) @updatedAt
  251. purpose String @default("")
  252. organizationId String
  253. humanOperatorId String?
  254. productId String
  255. initial_delay Int @default(30)
  256. actionStatus ActionStatus @default(PROCESSING)
  257. conversationStatusUpdatedAt DateTime?
  258. organizationStatusId String?
  259. productStatusId String?
  260. applicationId String?
  261. aiTimestampLock DateTime @default(now())
  262. conversationStateId String?
  263. metadata Json?
  264. rating Int?
  265. application Application?
  266. attributeValues AttributeValue[]
  267. chores Chore[]
  268. ClientFact ClientFact[]
  269. clientFiles ClientFile[]
  270. humanOperator User? @relation(fields: [humanOperatorId], references: [id])
  271. organization Organization @relation(fields: [organizationId], references: [id])
  272. organizationStatus OrganizationStatus? @relation(fields: [organizationStatusId], references: [id])
  273. product Product @relation(fields: [productId], references: [id])
  274. ProductStatus ProductStatus? @relation(fields: [productStatusId], references: [id])
  275. ConversationCheck ConversationCheck[]
  276. classifications ConversationClassfication[]
  277. ConversationDisplay ConversationDisplay[]
  278. conversationSessionLog ConversationSessionLog[]
  279. ConversationsToUsers ConversationsToUsers[]
  280. FunctionTask FunctionTask[]
  281. Memory Memory[]
  282. messages Message[]
  283. Reminders Reminders[]
  284. workflowFieldValues WorkflowFieldValues[]
  285. workflowSubmissions WorkflowSubmission[]
  286. cases Case[] @relation("CaseToConversation")
  287. clients Client[] @relation("conversationToClient")
  288. comments ConversationComment[]
  289. ipInfo String?
  290. ipAddress String?
  291. unstructuredMessages UnstructuredMessage[]
  292. messageAttachments MessageAttachment[]
  293. viewEntities EntityView[]
  294.  
  295. businessAddressInfo Json?
  296. }
  297.  
  298. model ConversationSessionLog {
  299. id String @id @default(cuid())
  300. createdAt DateTime @default(now())
  301. updatedAt DateTime @default(now()) @updatedAt
  302. userId String
  303. conversationId String
  304. active Boolean @default(true)
  305. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  306. user User @relation(fields: [userId], references: [id])
  307. }
  308.  
  309. model ConversationsToUsers {
  310. id String @id @default(cuid())
  311. createdAt DateTime @default(now())
  312. updatedAt DateTime @default(now()) @updatedAt
  313. conversationId String
  314. userId String
  315. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  316. user User @relation(fields: [userId], references: [id], onDelete: Cascade)
  317.  
  318. @@unique([conversationId, userId])
  319. }
  320.  
  321. model ConversationCheck {
  322. id String @id @default(cuid())
  323. createdAt DateTime @default(now())
  324. updatedAt DateTime @default(now()) @updatedAt
  325. conversationId String
  326. value String?
  327. status ConversationCheckStatus @default(PENDING)
  328. description String?
  329. fieldName String
  330. formType OrganizationCheckFormType @default(TEXTAREA)
  331. options String?
  332. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  333. triggerId String?
  334. trigger CheckStatusTrigger? @relation(fields: [triggerId], references: [id])
  335.  
  336. @@unique([conversationId, fieldName])
  337. }
  338.  
  339. model OrganizationDisplay {
  340. id String @id @default(cuid())
  341. createdAt DateTime @default(now())
  342. updatedAt DateTime @default(now()) @updatedAt
  343. organizationId String
  344. fieldName String
  345. description String?
  346. ConversationDisplay ConversationDisplay[]
  347. organization Organization @relation(fields: [organizationId], references: [id])
  348. }
  349.  
  350. model ConversationDisplay {
  351. id String @id @default(cuid())
  352. createdAt DateTime @default(now())
  353. updatedAt DateTime @default(now()) @updatedAt
  354. conversationId String
  355. organizationDisplayId String
  356. value String?
  357. status displayStatus @default(unknown)
  358. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  359. organizationDisplay OrganizationDisplay @relation(fields: [organizationDisplayId], references: [id], onDelete: Cascade)
  360. }
  361.  
  362. model Organization {
  363. id String @id @default(cuid())
  364. name String
  365. apiKey String
  366. createdAt DateTime @default(now())
  367. updatedAt DateTime @default(now()) @updatedAt
  368. organizationEmail String?
  369. organizationEmailToken Json?
  370. organizationHistoryId String?
  371. description String?
  372. accentColor String?
  373. bigLogoUrl String?
  374. mainColor String?
  375. smallLogoUrl String?
  376. websiteUrl String?
  377. defaultProductId String? @unique
  378. applications Application[] @relation("OrganizationToApplication")
  379. Case Case[]
  380. Chore Chore[]
  381. Client Client[]
  382. conversations Conversation[]
  383. Document Document[]
  384. MetaDocument MetaDocument[]
  385. defaultProduct Product? @relation("DefaultProduct", fields: [defaultProductId], references: [id])
  386. OrganizationDisplay OrganizationDisplay[]
  387. organizationStatuses OrganizationStatus[]
  388. products Product[] @relation("OrganizationProducts")
  389. users User[] @relation("OrganizationToUser")
  390. unstructuredMessages UnstructuredMessage[]
  391. incomingMailIntegrations OrganizationIncomingMailIntegration[]
  392. publicLogoUrl String?
  393. baseUrl String?
  394. newlineAddress String?
  395. UserAllowedOrganizations UserAllowedOrganizations[]
  396. }
  397.  
  398. model OrganizationIncomingMailIntegration {
  399. id String @id @default(cuid())
  400. createdAt DateTime @default(now())
  401. updatedAt DateTime @default(now()) @updatedAt
  402. organizationId String
  403. integrationId String
  404. integrationType IncomingMailIntegrationType
  405. organization Organization @relation(fields: [organizationId], references: [id])
  406.  
  407. @@unique([organizationId, integrationId])
  408. }
  409.  
  410. model Product {
  411. organizationId String
  412. id String @id @default(cuid())
  413. name String
  414. description String
  415. agentId String
  416. createdAt DateTime @default(now())
  417. updatedAt DateTime? @updatedAt
  418. Attribute Attribute[]
  419. conversations Conversation[]
  420. Organization Organization? @relation("DefaultProduct")
  421. agent Agent @relation(fields: [agentId], references: [id])
  422. organization Organization @relation("OrganizationProducts", fields: [organizationId], references: [id])
  423. classicications ProductClassification[]
  424. productStatuses ProductStatus[]
  425. WorkflowSchema WorkflowSchema[]
  426. entities Entity[] @relation("EntityToProduct")
  427. metaDocuments MetaDocument[]
  428. reactions SystemOneReaction[]
  429. customTables CustomTable[]
  430. integrationsProducts IntegrationProduct[]
  431. }
  432.  
  433. model OrganizationStatus {
  434. id String @id @default(cuid())
  435. createdAt DateTime @default(now())
  436. updatedAt DateTime @default(now()) @updatedAt
  437. name String
  438. description String?
  439. organizationId String
  440. isPublic Boolean @default(false)
  441. order Int @default(0)
  442. publicDescription String?
  443. Conversation Conversation[]
  444. organization Organization @relation(fields: [organizationId], references: [id])
  445. authorizedUsers User[] @relation("AuthorizedUsers")
  446. }
  447.  
  448. model FileStatusTrigger {
  449. id String @id @default(cuid())
  450. createdAt DateTime @default(now())
  451. requiredFileName String
  452. description String?
  453. requiredFileVisibility Visibility
  454. productStatusId String
  455. documentType DocumentType @default(OTHER)
  456. productStatus ProductStatus @relation(fields: [productStatusId], references: [id])
  457. files ClientFile[]
  458. }
  459.  
  460. model WorkflowTrigger {
  461. id String @id @default(cuid())
  462. createdAt DateTime @default(now())
  463. updatedAt DateTime @default(now()) @updatedAt
  464. workflowId String
  465. productStatusId String
  466. productStatus ProductStatus @relation(fields: [productStatusId], references: [id])
  467. workflow WorkflowSchema @relation(fields: [workflowId], references: [id])
  468. }
  469.  
  470. model CheckStatusTrigger {
  471. id String @id @default(cuid())
  472. createdAt DateTime @default(now())
  473. fieldName String
  474. description String?
  475. formType OrganizationCheckFormType
  476. options String?
  477. productStatusId String
  478. productStatus ProductStatus @relation(fields: [productStatusId], references: [id])
  479. conversationChecks ConversationCheck[]
  480. }
  481.  
  482. model ProductClassification {
  483. id String @id @default(cuid())
  484. createdAt DateTime @default(now())
  485. updatedAt DateTime @default(now()) @updatedAt
  486. name String
  487. description String?
  488. condition String?
  489. productId String
  490. color String @default("#3b82f7")
  491. icon String?
  492. conversationClassifications ConversationClassfication[]
  493. product Product @relation(fields: [productId], references: [id])
  494. }
  495.  
  496. model ConversationClassfication {
  497. id String @id @default(cuid())
  498. createdAt DateTime @default(now())
  499. updatedAt DateTime @default(now()) @updatedAt
  500. conversationId String
  501. classficationId String
  502. classfication ProductClassification @relation(fields: [classficationId], references: [id], onDelete: Cascade)
  503. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  504. }
  505.  
  506. model ProductStatus {
  507. id String @id @default(cuid())
  508. createdAt DateTime @default(now())
  509. updatedAt DateTime @updatedAt
  510. name String
  511. description String?
  512. isPublic Boolean @default(false)
  513. order Int @default(0)
  514. publicDescription String?
  515. productId String
  516. aiInstructions String? @default("")
  517. initial Boolean @default(false)
  518. CheckStatusTrigger CheckStatusTrigger[]
  519. ChoreTrigger ChoreTrigger[]
  520. factStatusTriggers ClientFactTrigger[]
  521. Conversation Conversation[]
  522. fileStatusTriggers FileStatusTrigger[]
  523. Product Product @relation(fields: [productId], references: [id])
  524. workflowTriggers WorkflowTrigger[]
  525. workflowSchemas WorkflowSchema[] @relation("ProductStatusToWorkflowSchema")
  526. workflowSchemaId String?
  527. }
  528.  
  529. model Agent {
  530. id String @id @default(cuid())
  531. name String
  532. agentType AgentType
  533. agentVersion String
  534. description String
  535. createdAt DateTime @default(now())
  536. updatedAt DateTime @default(now()) @updatedAt
  537. imageUrl String?
  538. products Product[]
  539. }
  540.  
  541. model SystemOneReaction {
  542. id String @id @default(cuid())
  543. createdAt DateTime @default(now())
  544. updatedAt DateTime @default(now()) @updatedAt
  545. trigger Json
  546. name String @default("")
  547. response SystemOneResponse?
  548. productId String
  549. product Product @relation(fields: [productId], references: [id])
  550. active Boolean @default(false)
  551. deleted DateTime?
  552. systemOneReactionLogItems SystemOneReactionLogItem[]
  553.  
  554. @@index([trigger(ops: JsonbPathOps)], type: Gin)
  555. }
  556.  
  557. model SystemOneReactionLogItem {
  558. id String @id @default(cuid())
  559. createdAt DateTime @default(now())
  560. updatedAt DateTime @default(now()) @updatedAt
  561. reactionId String
  562. reaction SystemOneReaction @relation(fields: [reactionId], references: [id])
  563. organizationId String
  564. reactionJson Json
  565. stateJson Json
  566. }
  567.  
  568. model SystemOneResponse {
  569. id String @id @default(cuid())
  570. name String
  571. createdAt DateTime @default(now())
  572. updatedAt DateTime @default(now()) @updatedAt
  573. reactionId String @unique
  574. reaction SystemOneReaction @relation(fields: [reactionId], references: [id])
  575. actions SystemOneAction[]
  576. }
  577.  
  578. model SystemOneAction {
  579. id String @id
  580. createdAt DateTime @default(now())
  581. updatedAt DateTime @default(now()) @updatedAt
  582. systemOneResponseId String
  583. systemOneResponse SystemOneResponse @relation(fields: [systemOneResponseId], references: [id])
  584. arguments SystemOneFunctionArgumentValue[]
  585. functionId String
  586. function Function @relation(fields: [functionId], references: [id], onDelete: Cascade)
  587. }
  588.  
  589. model SystemOneFunctionArgumentValue {
  590. id String @id
  591. createdAt DateTime @default(now())
  592. updatedAt DateTime @default(now()) @updatedAt
  593. value String?
  594. argumentId String
  595. actionId String
  596. action SystemOneAction @relation(fields: [actionId], references: [id])
  597. argument FunctionArgument @relation(fields: [argumentId], references: [id])
  598. }
  599.  
  600. model Application {
  601. id String @id @default(cuid())
  602. createdAt DateTime @default(now())
  603. updatedAt DateTime @default(now()) @updatedAt
  604. businessName String
  605. industry String
  606. creditAmount Float
  607. loanPurpose String
  608. businessAddress String
  609. businessCity String?
  610. businessState String?
  611. businessZipCode String?
  612. ownerMaritalStatus String?
  613. ssn String
  614. phoneNo String
  615. ownershipPercentage Float
  616. numberOfOwners Int?
  617. ownerAddress String
  618. ownerCity String?
  619. ownerState String?
  620. ownerZipCode String?
  621. organizationId String?
  622. userId String?
  623. businessWebsite String?
  624. ownerIsActiveInMilitary Boolean?
  625. taxPayerIdentificationNumber String?
  626. conversationId String? @unique
  627. emailAddress String?
  628. fullYearsIncorporated Int @default(0)
  629. lastYearRevenue Float @default(0)
  630. ownerFirstName String
  631. ownerLastName String
  632. pastBankruptcy Boolean?
  633. womenOwned Boolean?
  634. yearBeforeRevenue Float @default(0)
  635. incorporationDate DateTime?
  636. businessType String?
  637. conversation Conversation? @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  638. organization Organization? @relation("OrganizationToApplication", fields: [organizationId], references: [id])
  639. user User? @relation("ApplicationToUser", fields: [userId], references: [id])
  640. }
  641.  
  642. model Reminders {
  643. id String @id
  644. createdAt DateTime @default(now())
  645. updatedAt DateTime? @default(now()) @updatedAt
  646. conversationId String
  647. duration Int @default(0)
  648. lastLeadEventDate DateTime @default(now())
  649. triggerDate DateTime
  650. type ReminderType @default(automatic)
  651. Conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  652. }
  653.  
  654. model FunctionReminder {
  655. id String @id
  656. triggerDate DateTime
  657. }
  658.  
  659. model ClientFact {
  660. id String @id @default(cuid())
  661. createdAt DateTime @default(now())
  662. updatedAt DateTime @default(now()) @updatedAt
  663. question String
  664. conversationId String
  665. RejectionReasoning String?
  666. Description String?
  667. fact String?
  668. statusId String?
  669. clientFactStatus ClientFileStatus @default(pending)
  670. Conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  671. triggerId String?
  672. trigger ClientFactTrigger? @relation(fields: [triggerId], references: [id])
  673. }
  674.  
  675. model ClientFactTrigger {
  676. id String @id @default(cuid())
  677. createdAt DateTime @default(now())
  678. updatedAt DateTime @default(now()) @updatedAt
  679. question String
  680. description String @default("")
  681. productStatusId String
  682. productStatus ProductStatus @relation(fields: [productStatusId], references: [id])
  683. clientFacts ClientFact[]
  684. }
  685.  
  686. model WorkflowFields {
  687. id String @id(map: "WWorkflowField_pkey") @default(cuid())
  688. createdAt DateTime @default(now())
  689. updatedAt DateTime @default(now()) @updatedAt
  690. name String
  691. description String?
  692. order Int
  693. dataType FormFieldType
  694. required Boolean @default(true)
  695. isInput Boolean @default(false)
  696. workflowSchemaId String
  697. options String?
  698. codeName String?
  699. entityFieldId String?
  700. defaultValue String?
  701. workflowCardId String?
  702. orderWithinCard Int @default(0)
  703. caseInitiation Boolean @default(false)
  704. validation String?
  705. values WorkflowFieldValues[]
  706. tenantEntityField EntityField? @relation(fields: [entityFieldId], references: [id], map: "WWorkflowField_entityFieldId_fkey")
  707. workflowCard WorkflowCard? @relation(fields: [workflowCardId], references: [id], map: "WWorkflowField_workflowCardId_fkey")
  708. workflowSchema WorkflowSchema @relation(fields: [workflowSchemaId], references: [id], onDelete: Cascade, map: "WWorkflowField_workflowSchemaId_fkey")
  709. metadata String?
  710.  
  711. @@unique([workflowSchemaId, codeName], map: "WWorkflowField_workflowSchemaId_codeName_key")
  712. }
  713.  
  714. model WorkflowFieldValues {
  715. id String @id @default(cuid())
  716. createdAt DateTime @default(now())
  717. updatedAt DateTime @default(now()) @updatedAt
  718. value String?
  719. workflowFieldId String
  720. conversationId String
  721. pinned Boolean @default(false)
  722. status displayStatus @default(unknown)
  723. Conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  724. WorkflowField WorkflowFields @relation(fields: [workflowFieldId], references: [id], onDelete: Cascade)
  725. }
  726.  
  727. model Attribute {
  728. id String @id @default(uuid())
  729. createdAt DateTime @default(now())
  730. updatedAt DateTime @default(now()) @updatedAt
  731. name String
  732. type String
  733. description String?
  734. enumOptions String[]
  735. dataType String
  736. optional Boolean @default(false)
  737. placeholder String?
  738. displayName String?
  739. productId String?
  740. product Product? @relation(fields: [productId], references: [id])
  741. values AttributeValue[]
  742. }
  743.  
  744. model AttributeValue {
  745. id String @id @default(uuid())
  746. createdAt DateTime @default(now())
  747. updatedAt DateTime @default(now()) @updatedAt
  748. value String?
  749. attributeId String
  750. conversationId String
  751. status displayStatus @default(unknown)
  752. pinned Boolean @default(false)
  753. attribute Attribute @relation(fields: [attributeId], references: [id])
  754. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  755.  
  756. @@unique([attributeId, conversationId])
  757. }
  758.  
  759. model Function {
  760. id String @id @default(cuid())
  761. createdAt DateTime @default(now())
  762. updatedAt DateTime @default(now()) @updatedAt
  763. name String
  764. description String
  765. type FunctionType @default(query)
  766. ActiveFunction ActiveFunction[]
  767. arguments FunctionArgument[]
  768. FunctionAction FunctionAction[] @relation("PossibleFollowingFunctions")
  769. systemOneAction SystemOneAction[]
  770. }
  771.  
  772. model FunctionArgument {
  773. id String @id @default(cuid())
  774. createdAt DateTime @default(now())
  775. updatedAt DateTime @default(now()) @updatedAt
  776. name String
  777. description String
  778. dataType String
  779. optional Boolean @default(false)
  780. enumOptions String[] @default([])
  781. functionId String
  782. Function Function @relation(fields: [functionId], references: [id], onDelete: Cascade)
  783. FunctionArgumentValue FunctionArgumentValue[]
  784. systemOneFunctionArgumentValue SystemOneFunctionArgumentValue[]
  785. }
  786.  
  787. model ActiveFunction {
  788. id String @id @default(cuid())
  789. createdAt DateTime @default(now())
  790. updatedAt DateTime @default(now())
  791. functionId String
  792. Function Function @relation(fields: [functionId], references: [id])
  793. FunctionAction FunctionAction[]
  794. }
  795.  
  796. model FunctionAction {
  797. id String @id @default(cuid())
  798. createdAt DateTime @default(now())
  799. updatedAt DateTime @default(now())
  800. thought String @default("")
  801. HILDecision HILDecision @default(PENDING)
  802. order Int @default(0)
  803. taskId String
  804. activeFunctionId String
  805. systemMessage String @default("")
  806. status FunctionActionStatus @default(pending)
  807. metadata Json?
  808. ActiveFunction ActiveFunction @relation(fields: [activeFunctionId], references: [id])
  809. FunctionTask FunctionTask @relation(fields: [taskId], references: [id])
  810. FunctionArgumentValue FunctionArgumentValue[]
  811. possibleFollowingFunctions Function[] @relation("PossibleFollowingFunctions")
  812. }
  813.  
  814. model FunctionArgumentValue {
  815. id String @id @default(cuid())
  816. createdAt DateTime @default(now())
  817. updatedAt DateTime @default(now())
  818. value String?
  819. actionId String
  820. argumentId String
  821. FunctionAction FunctionAction @relation(fields: [actionId], references: [id], onDelete: Cascade)
  822. FunctionArgument FunctionArgument @relation(fields: [argumentId], references: [id])
  823.  
  824. @@unique([actionId, argumentId])
  825. }
  826.  
  827. model FunctionTask {
  828. id String @id @default(cuid())
  829. createdAt DateTime @default(now())
  830. updatedAt DateTime @default(now())
  831. completed Boolean @default(false)
  832. conversationId String?
  833. caseId String?
  834. typeMetadata Json?
  835. type TaskType @default(action)
  836. FunctionAction FunctionAction[]
  837. Case Case? @relation(fields: [caseId], references: [id])
  838. Conversation Conversation? @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  839. memories Memory[] @relation("FunctionTaskToMemory")
  840. }
  841.  
  842. model Memory {
  843. id String @id @default(cuid())
  844. createdAt DateTime @default(now())
  845. updatedAt DateTime @default(now())
  846. type MemoryType
  847. value String
  848. conversationId String?
  849. hierarchy Hierarchy
  850. role UserRole @default(lead)
  851. caseId String?
  852. Case Case? @relation(fields: [caseId], references: [id])
  853. Conversation Conversation? @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  854. tasks FunctionTask[] @relation("FunctionTaskToMemory")
  855. }
  856.  
  857. model Log {
  858. id String @id @default(cuid())
  859. createdAt DateTime @default(now())
  860. updatedAt DateTime @default(now())
  861. message String
  862. }
  863.  
  864. model Chore {
  865. id String @id @default(cuid())
  866. createdAt DateTime @default(now())
  867. updatedAt DateTime @default(now())
  868. description String
  869. organizationId String
  870. conversationId String
  871. isComplete Boolean @default(false)
  872. completedAt DateTime?
  873. triggerId String?
  874. trigger ChoreTrigger? @relation(fields: [triggerId], references: [id])
  875. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  876. Organization Organization @relation(fields: [organizationId], references: [id])
  877. users User[] @relation("ChoreToUser")
  878.  
  879. @@index([isComplete, conversationId])
  880. }
  881.  
  882. model MetaDocument {
  883. id Int @id @default(autoincrement())
  884. updatedAt DateTime @default(now())
  885. organizationId String
  886. title String
  887. status DocumentStatus @default(DRAFT)
  888. createdAt DateTime @default(now())
  889. s3url String
  890. Organization Organization @relation(fields: [organizationId], references: [id])
  891. MetaField MetaField[]
  892. MetaRecipient MetaRecipient[]
  893. productId String?
  894. product Product? @relation(fields: [productId], references: [id])
  895. entityFields EntityField[] @relation("MetaDocumentToEntityField")
  896. }
  897.  
  898. model MetaField {
  899. id Int @id @default(autoincrement())
  900. type FieldType
  901. page Int
  902. positionX Decimal @default(0)
  903. positionY Decimal @default(0)
  904. width Decimal @default(-1)
  905. height Decimal @default(-1)
  906. customText String?
  907. metaDocumentId Int
  908. MetaDocument MetaDocument @relation(fields: [metaDocumentId], references: [id], onDelete: Cascade)
  909.  
  910. @@index([metaDocumentId])
  911. }
  912.  
  913. model Document {
  914. id Int @id @default(autoincrement())
  915. updatedAt DateTime @default(now())
  916. organizationId String
  917. title String
  918. status DocumentStatus @default(DRAFT)
  919. createdAt DateTime @default(now())
  920. s3url String
  921. completedAt DateTime?
  922. deletedAt DateTime?
  923. Organization Organization @relation(fields: [organizationId], references: [id])
  924. Field Field[]
  925. Recipient Recipient[]
  926. }
  927.  
  928. model Field {
  929. id Int @id @default(autoincrement())
  930. documentId Int?
  931. type FieldType
  932. page Int
  933. positionX Decimal @default(0)
  934. positionY Decimal @default(0)
  935. width Decimal @default(-1)
  936. height Decimal @default(-1)
  937. customText String?
  938. recipientId Int?
  939. inserted Boolean
  940. Document Document? @relation(fields: [documentId], references: [id], onDelete: Cascade)
  941. Signature Signature?
  942. Recipient Recipient? @relation(fields: [recipientId], references: [id])
  943.  
  944. @@index([documentId])
  945. }
  946.  
  947. model ChoreTrigger {
  948. id String @id(map: "choretrigger_pk") @default(cuid())
  949. createdAt DateTime @default(now())
  950. productStatusId String
  951. description String
  952. triggerId String?
  953. productStatus ProductStatus @relation(fields: [productStatusId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "choretrigger_productstatus_id_fk")
  954. users User[] @relation("ChoreTriggerToUser")
  955. chores Chore[]
  956. }
  957.  
  958. model WorkflowCard {
  959. id String @id @default(cuid())
  960. createdAt DateTime @default(now())
  961. updatedAt DateTime @default(now())
  962. order Int @default(0)
  963. workflowSchemaId String
  964. name String
  965. getNextCard String?
  966. codeName String?
  967. isFirstCard Boolean @default(false)
  968. workflowContainerId String?
  969. workflowContainer WorkflowContainer? @relation(fields: [workflowContainerId], references: [id])
  970. workflowSchema WorkflowSchema @relation(fields: [workflowSchemaId], references: [id], onDelete: Cascade)
  971. workflowFields WorkflowFields[]
  972.  
  973. @@unique([workflowSchemaId, codeName])
  974. }
  975.  
  976. model WorkflowContainer {
  977. id String @id @default(cuid())
  978. createdAt DateTime @default(now())
  979. updatedAt DateTime @default(now())
  980. order Int @default(0)
  981. workflowSchemaId String
  982. name String
  983. codeName String?
  984. workflowCards WorkflowCard[]
  985. workflowSchema WorkflowSchema @relation(fields: [workflowSchemaId], references: [id], onDelete: Cascade)
  986. }
  987.  
  988. model WorkflowSchema {
  989. id String @id @default(cuid())
  990. createdAt DateTime @default(now())
  991. updatedAt DateTime @default(now())
  992. description String?
  993. url String?
  994. internal Boolean @default(false)
  995. name String
  996. productId String
  997. slug String?
  998. type WorkflowType
  999. createdById String
  1000. published Boolean @default(false)
  1001. workflowCards WorkflowCard[]
  1002. workflowContainers WorkflowContainer[]
  1003. workflowFields WorkflowFields[]
  1004. user User @relation(fields: [createdById], references: [id])
  1005. product Product @relation(fields: [productId], references: [id])
  1006. workflowSubmissions WorkflowSubmission[]
  1007. workflowTriggers WorkflowTrigger[]
  1008. statuses ProductStatus[] @relation("ProductStatusToWorkflowSchema")
  1009. }
  1010.  
  1011. model WorkflowSubmission {
  1012. id String @id @default(cuid())
  1013. createdAt DateTime @default(now())
  1014. updatedAt DateTime @default(now())
  1015. workflowSchemaId String
  1016. conversationId String
  1017. payload Json
  1018. userId String?
  1019. Conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  1020. User User? @relation(fields: [userId], references: [id])
  1021. workflowSchema WorkflowSchema @relation(fields: [workflowSchemaId], references: [id])
  1022. }
  1023.  
  1024. model Entity {
  1025. id String @id @default(cuid())
  1026. createdAt DateTime @default(now())
  1027. updatedAt DateTime @default(now())
  1028. name String
  1029. displayName String?
  1030. description String?
  1031. entityFields EntityField[]
  1032. products Product[] @relation("EntityToProduct")
  1033. }
  1034.  
  1035. model EntityField {
  1036. id String @id @default(cuid())
  1037. name String
  1038. type FieldTypes
  1039. recordHistory Boolean @default(false)
  1040. displayName String?
  1041. exampleValue String?
  1042. description String?
  1043. required Boolean @default(false)
  1044. defaultValue String?
  1045. createdAt DateTime @default(now())
  1046. updatedAt DateTime @default(now())
  1047. entityId String
  1048.  
  1049. entity Entity @relation(fields: [entityId], references: [id], onDelete: Cascade)
  1050.  
  1051. values EntityFieldValue[]
  1052. WorkflowFields WorkflowFields[]
  1053. metaDocuments MetaDocument[] @relation("MetaDocumentToEntityField")
  1054. automation Automation[]
  1055.  
  1056. @@unique([entityId, name], name: "entityId_name")
  1057. }
  1058.  
  1059. model EntityFieldValue {
  1060. id String @id @default(cuid())
  1061. createdAt DateTime @default(now())
  1062. updatedAt DateTime @default(now())
  1063. value String?
  1064. entityFieldId String
  1065. conversationId String?
  1066. organizationId String?
  1067. entityField EntityField @relation(fields: [entityFieldId], references: [id])
  1068. history FieldHistory[]
  1069.  
  1070. @@unique([entityFieldId, conversationId])
  1071. }
  1072.  
  1073. model FieldHistory {
  1074. id String @id @default(cuid())
  1075. createdAt DateTime @default(now())
  1076. oldValue String
  1077. newValue String
  1078. entityFieldValueId String
  1079. cause String?
  1080. entityFieldValue EntityFieldValue @relation(fields: [entityFieldValueId], references: [id])
  1081. }
  1082.  
  1083. model Action {
  1084. id String @id @default(cuid())
  1085. createdAt DateTime @default(now())
  1086. updatedAt DateTime @default(now())
  1087. description String?
  1088. ctxExecution String?
  1089. }
  1090.  
  1091. model Recipient {
  1092. id Int @id @default(autoincrement())
  1093. createdAt DateTime @default(now())
  1094. updatedAt DateTime @default(now())
  1095. documentId Int?
  1096. templateId Int?
  1097. email String @db.VarChar(255)
  1098. name String @default("") @db.VarChar(255)
  1099. token String
  1100. expired DateTime?
  1101. signedAt DateTime?
  1102. readStatus ReadStatus @default(NOT_OPENED)
  1103. signingStatus SigningStatus @default(NOT_SIGNED)
  1104. sendStatus SendStatus @default(NOT_SENT)
  1105. Field Field[]
  1106. Document Document? @relation(fields: [documentId], references: [id], onDelete: Cascade)
  1107. Signature Signature[]
  1108.  
  1109. @@unique([documentId, email])
  1110. @@unique([templateId, email])
  1111. @@index([documentId])
  1112. @@index([templateId])
  1113. @@index([token])
  1114. }
  1115.  
  1116. model MetaRecipient {
  1117. id Int @id @default(autoincrement())
  1118. createdAt DateTime @default(now())
  1119. updatedAt DateTime @default(now())
  1120. metaDocumentId Int
  1121. email String @default("john.doe@example.com") @db.VarChar(255)
  1122. name String @default("John Doe") @db.VarChar(255)
  1123. token String @default("0000")
  1124. expired DateTime?
  1125. signedAt DateTime?
  1126. readStatus ReadStatus @default(NOT_OPENED)
  1127. signingStatus SigningStatus @default(NOT_SIGNED)
  1128. sendStatus SendStatus @default(NOT_SENT)
  1129. metaDocument MetaDocument @relation(fields: [metaDocumentId], references: [id], onDelete: Cascade)
  1130.  
  1131. @@index([metaDocumentId])
  1132. }
  1133.  
  1134. model Signature {
  1135. id Int @id @default(autoincrement())
  1136. created DateTime @default(now())
  1137. recipientId Int
  1138. fieldId Int @unique
  1139. signatureImageAsBase64 String?
  1140. typedSignature String?
  1141.  
  1142. Recipient Recipient @relation(fields: [recipientId], references: [id], onDelete: Cascade)
  1143. Field Field @relation(fields: [fieldId], references: [id], onDelete: Restrict)
  1144.  
  1145. @@index([recipientId])
  1146. }
  1147.  
  1148. model Automation {
  1149. id String @id @default(cuid())
  1150. createdAt DateTime @default(now())
  1151. updatedAt DateTime @default(now())
  1152. name String?
  1153. description String?
  1154. active Boolean @default(true)
  1155. code String
  1156. objects Object[]
  1157. entityField EntityField @relation(fields: [entityFieldId], references: [id], onDelete: Cascade)
  1158. entityFieldId String
  1159. }
  1160.  
  1161. model Object {
  1162. id String @id
  1163. sourceId String
  1164. type ObjectType
  1165. role ObjectRole
  1166. automationId String
  1167. name String?
  1168. key String?
  1169. automation Automation @relation(fields: [automationId], references: [id], onDelete: Cascade)
  1170.  
  1171. @@index([automationId])
  1172. }
  1173.  
  1174. model CustomColumn {
  1175. id String @id @default(cuid())
  1176. createdAt DateTime @default(now())
  1177. updatedAt DateTime @default(now())
  1178. sortable Boolean @default(false)
  1179. sortOn String?
  1180. name String
  1181.  
  1182. hidden Boolean @default(false)
  1183. order Int @default(0)
  1184.  
  1185. tableId String
  1186. table CustomTable @relation(fields: [tableId], references: [id])
  1187.  
  1188. content String @db.Text
  1189. }
  1190.  
  1191. model CustomTable {
  1192. id String @id @default(cuid())
  1193. createdAt DateTime @default(now())
  1194. updatedAt DateTime @default(now())
  1195. name String
  1196. productId String
  1197. product Product @relation(fields: [productId], references: [id])
  1198. content String @db.Text
  1199. columns CustomColumn[]
  1200.  
  1201. classificationEnabled Boolean @default(false)
  1202. statusEnabled Boolean @default(false)
  1203. }
  1204.  
  1205. enum ObjectType {
  1206. Check
  1207. Fact
  1208. ClientFile
  1209. Workflow
  1210. Entity
  1211. Conversation
  1212. Organization
  1213. User
  1214. }
  1215.  
  1216. enum ObjectRole {
  1217. SOURCE
  1218. TARGET
  1219. }
  1220.  
  1221. enum ReadStatus {
  1222. NOT_OPENED
  1223. OPENED
  1224. }
  1225.  
  1226. enum SendStatus {
  1227. NOT_SENT
  1228. SENT
  1229. }
  1230.  
  1231. enum SigningStatus {
  1232. NOT_SIGNED
  1233. SIGNED
  1234. }
  1235.  
  1236. model ConversationComment {
  1237. id String @id @default(cuid())
  1238. createdAt DateTime @default(now())
  1239. updatedAt DateTime @default(now())
  1240. message String
  1241. userId String
  1242. conversationId String
  1243. isDeleted Boolean @default(false)
  1244. isEdited Boolean @default(false)
  1245. Conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  1246. User User @relation(fields: [userId], references: [id], onDelete: Cascade)
  1247. }
  1248.  
  1249. model UnstructuredMessage {
  1250. id String @id @default(cuid())
  1251. createdAt DateTime @default(now())
  1252. updatedAt DateTime @default(now())
  1253.  
  1254. organizationId String?
  1255. conversationId String?
  1256.  
  1257. organization Organization? @relation(fields: [organizationId], references: [id])
  1258. conversation Conversation? @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  1259.  
  1260. JSON String?
  1261. }
  1262.  
  1263. view EntityView {
  1264. id String @id
  1265. createdAt DateTime
  1266. updatedAt DateTime
  1267. field String
  1268. value String
  1269. conversationId String
  1270. status displayStatus
  1271. conversation Conversation @relation(fields: [conversationId], references: [id])
  1272. }
  1273.  
  1274. enum FormFieldType {
  1275. TEXT
  1276. TEXTAREA
  1277. SELECT
  1278. BIG_SELECT
  1279. HEADING
  1280. PARAGRAPH
  1281. SPACER
  1282. CHECKBOX
  1283. NUMBER
  1284. PERCENTAGE
  1285. ZIPCODE
  1286. PHONE_NUMBER
  1287. SSN
  1288. DATE
  1289. CURRENCY
  1290. TIN
  1291. LOCATION
  1292. }
  1293.  
  1294. enum FieldTypes {
  1295. string
  1296. number
  1297. boolean
  1298. date
  1299. time
  1300. dateTime
  1301. email
  1302. phone
  1303. url
  1304. image
  1305. color
  1306. password
  1307. currency
  1308. geolocation
  1309. address
  1310. }
  1311.  
  1312. enum FunctionType {
  1313. query
  1314. mutation
  1315. }
  1316.  
  1317. enum FunctionActionStatus {
  1318. executed
  1319. approved
  1320. rejected
  1321. pending
  1322. executing
  1323. }
  1324.  
  1325. enum HILDecision {
  1326. APPROVED
  1327. REJECTED
  1328. PENDING
  1329. EXECUTED
  1330. }
  1331.  
  1332. enum MemoryType {
  1333. observation
  1334. reflection
  1335. }
  1336.  
  1337. enum Hierarchy {
  1338. local
  1339. global
  1340. }
  1341.  
  1342. enum WorkflowType {
  1343. applicationForm
  1344. }
  1345.  
  1346. enum MessageType {
  1347. client
  1348. agent
  1349. }
  1350.  
  1351. enum ClientFileStatus {
  1352. pending
  1353. processing
  1354. approved
  1355. rejected
  1356. private
  1357. }
  1358.  
  1359. enum Visibility {
  1360. private
  1361. public
  1362. }
  1363.  
  1364. enum CommunicationMedium {
  1365. EMAIL
  1366. PHONE
  1367. SMS
  1368. WHATSAPP
  1369. }
  1370.  
  1371. enum displayStatus {
  1372. confirmed
  1373. mismatch
  1374. unknown
  1375. }
  1376.  
  1377. enum UserRole {
  1378. organizationAdmin
  1379. humanOperator
  1380. admin
  1381. applicant
  1382. lead
  1383. You
  1384. reminder
  1385. systemOne
  1386. }
  1387.  
  1388. enum AgentType {
  1389. LOAN
  1390. CREDIT_CARD
  1391. }
  1392.  
  1393. enum ActionStatus {
  1394. REVIEW_REQUIRED
  1395. PROCESSING
  1396. APPROVED
  1397. ORGANIZATION_REVIEW_REQUIRED
  1398. REMINDER_REVIEW_REQUIRE
  1399. }
  1400.  
  1401. enum OrganizationCheckFormType {
  1402. TEXTAREA
  1403. TEXT
  1404. SELECT
  1405. MULTI_SELECT
  1406. }
  1407.  
  1408. enum DocumentType {
  1409. BANK_STATEMENT
  1410. PERSONAL_TAX_RETURN
  1411. BUSINESS_TAX_RETURN
  1412. W2_TAX_FORM
  1413. INCOME_STATEMENT
  1414. OTHER
  1415. }
  1416.  
  1417. enum ConversationCheckStatus {
  1418. APPROVED
  1419. REJECTED
  1420. PENDING
  1421. }
  1422.  
  1423. enum Company {
  1424. Microsoft
  1425. Google
  1426. }
  1427.  
  1428. enum TaskType {
  1429. action
  1430. reminder
  1431. }
  1432.  
  1433. enum ReminderType {
  1434. automatic
  1435. heartbeat
  1436. }
  1437.  
  1438. enum DocumentStatus {
  1439. DRAFT
  1440. PENDING
  1441. COMPLETED
  1442. }
  1443.  
  1444. enum FieldType {
  1445. SIGNATURE
  1446. FREE_SIGNATURE
  1447. NAME
  1448. EMAIL
  1449. DATE
  1450. TEXT
  1451. }
  1452.  
  1453. enum IncomingMailIntegrationType {
  1454. GMAIL
  1455. OUTLOOK
  1456. }
  1457.  
Add Comment
Please, Sign In to add comment