Add automated content planning and image overlays
This commit is contained in:
+89
-79
@@ -77,21 +77,21 @@ model User {
|
||||
mustChangePassword Boolean @default(false)
|
||||
lastLoginAt DateTime?
|
||||
|
||||
memberships PageMember[]
|
||||
postsCreated Post[] @relation("PostCreatedBy")
|
||||
postsEdited Post[] @relation("PostLastEditedBy")
|
||||
approvals PostApproval[]
|
||||
auditLogs AuditLog[]
|
||||
metaConnections MetaConnection[]
|
||||
analyses PageAnalysis[]
|
||||
identities UserIdentity[]
|
||||
postGenerationJobs PostGenerationJob[]
|
||||
ownedTeams Team[] @relation("TeamOwner")
|
||||
teamMemberships TeamMember[]
|
||||
teamInvitesSent TeamInvite[] @relation("TeamInviteSender")
|
||||
approvalAssignments ApprovalRequest[] @relation("ApprovalAssignee")
|
||||
approvalRequestsSent ApprovalRequest[] @relation("ApprovalRequester")
|
||||
contentAutomations PageContentAutomation[]
|
||||
memberships PageMember[]
|
||||
postsCreated Post[] @relation("PostCreatedBy")
|
||||
postsEdited Post[] @relation("PostLastEditedBy")
|
||||
approvals PostApproval[]
|
||||
auditLogs AuditLog[]
|
||||
metaConnections MetaConnection[]
|
||||
analyses PageAnalysis[]
|
||||
identities UserIdentity[]
|
||||
postGenerationJobs PostGenerationJob[]
|
||||
ownedTeams Team[] @relation("TeamOwner")
|
||||
teamMemberships TeamMember[]
|
||||
teamInvitesSent TeamInvite[] @relation("TeamInviteSender")
|
||||
approvalAssignments ApprovalRequest[] @relation("ApprovalAssignee")
|
||||
approvalRequestsSent ApprovalRequest[] @relation("ApprovalRequester")
|
||||
contentAutomations PageContentAutomation[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@ -158,17 +158,17 @@ model Page {
|
||||
webhookSubscribedAt DateTime?
|
||||
tokenCheckedAt DateTime?
|
||||
|
||||
members PageMember[]
|
||||
posts Post[]
|
||||
rules ReplyRule[]
|
||||
conversations Conversation[]
|
||||
insights PageInsightSnapshot[]
|
||||
auditLogs AuditLog[]
|
||||
analyses PageAnalysis[]
|
||||
profile PageProfile?
|
||||
aiUsage AiUsage[]
|
||||
generationJobs PostGenerationJob[]
|
||||
teamPage TeamPage?
|
||||
members PageMember[]
|
||||
posts Post[]
|
||||
rules ReplyRule[]
|
||||
conversations Conversation[]
|
||||
insights PageInsightSnapshot[]
|
||||
auditLogs AuditLog[]
|
||||
analyses PageAnalysis[]
|
||||
profile PageProfile?
|
||||
aiUsage AiUsage[]
|
||||
generationJobs PostGenerationJob[]
|
||||
teamPage TeamPage?
|
||||
contentAutomation PageContentAutomation?
|
||||
inboxAiAutomation PageInboxAiAutomation?
|
||||
|
||||
@@ -225,10 +225,10 @@ model Post {
|
||||
lastEditedBy User? @relation("PostLastEditedBy", fields: [lastEditedById], references: [id])
|
||||
lastEditedAt DateTime?
|
||||
|
||||
approvals PostApproval[]
|
||||
insights PostInsightSnapshot[]
|
||||
auditLogs AuditLog[]
|
||||
generationJob PostGenerationJob?
|
||||
approvals PostApproval[]
|
||||
insights PostInsightSnapshot[]
|
||||
auditLogs AuditLog[]
|
||||
generationJob PostGenerationJob?
|
||||
approvalRequest ApprovalRequest?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
@@ -239,15 +239,15 @@ model Post {
|
||||
}
|
||||
|
||||
model Team {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
ownerId String
|
||||
owner User @relation("TeamOwner", fields: [ownerId], references: [id], onDelete: Restrict)
|
||||
owner User @relation("TeamOwner", fields: [ownerId], references: [id], onDelete: Restrict)
|
||||
members TeamMember[]
|
||||
pages TeamPage[]
|
||||
invites TeamInvite[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model TeamMember {
|
||||
@@ -265,11 +265,11 @@ model TeamMember {
|
||||
|
||||
// A Page belongs to at most one team. PageMember remains the page permission source.
|
||||
model TeamPage {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
teamId String
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
pageId String @unique
|
||||
page Page @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
pageId String @unique
|
||||
page Page @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([teamId])
|
||||
@@ -365,28 +365,28 @@ model Conversation {
|
||||
// Per-page AI sales assistant. Message bodies remain live in Graph and are
|
||||
// never persisted here; only configuration and source-message dedupe are kept.
|
||||
model PageInboxAiAutomation {
|
||||
id String @id @default(cuid())
|
||||
pageId String @unique
|
||||
page Page @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
||||
enabled Boolean @default(false)
|
||||
personaName String @default("แอดมินพิม")
|
||||
salesGoal String @default("")
|
||||
instructions String @default("")
|
||||
updatedById String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
id String @id @default(cuid())
|
||||
pageId String @unique
|
||||
page Page @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
||||
enabled Boolean @default(false)
|
||||
personaName String @default("แอดมินพิม")
|
||||
salesGoal String @default("")
|
||||
instructions String @default("")
|
||||
updatedById String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
replies InboxAiReply[]
|
||||
}
|
||||
|
||||
model InboxAiReply {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
automationId String
|
||||
automation PageInboxAiAutomation @relation(fields: [automationId], references: [id], onDelete: Cascade)
|
||||
sourceId String @unique
|
||||
automation PageInboxAiAutomation @relation(fields: [automationId], references: [id], onDelete: Cascade)
|
||||
sourceId String @unique
|
||||
recipientId String
|
||||
outcome String
|
||||
createdAt DateTime @default(now())
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([automationId, createdAt])
|
||||
}
|
||||
@@ -485,18 +485,18 @@ model PageAnalysis {
|
||||
|
||||
// Shop facts and voice the AI assistant writes from. One per page.
|
||||
model PageProfile {
|
||||
id String @id @default(cuid())
|
||||
pageId String @unique
|
||||
page Page @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
||||
business String
|
||||
audience String @default("")
|
||||
tone String @default("")
|
||||
visualStyle String @default("")
|
||||
website String @default("")
|
||||
avoid String @default("")
|
||||
cta String @default("")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
id String @id @default(cuid())
|
||||
pageId String @unique
|
||||
page Page @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
||||
business String
|
||||
audience String @default("")
|
||||
tone String @default("")
|
||||
visualStyle String @default("")
|
||||
website String @default("")
|
||||
avoid String @default("")
|
||||
cta String @default("")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
// One row per successful AI call — the per-page daily limit counts these.
|
||||
@@ -523,25 +523,35 @@ enum PostGenerationStatus {
|
||||
|
||||
// Recurring draft creation. The existing queue owns content and image generation.
|
||||
model PageContentAutomation {
|
||||
id String @id @default(cuid())
|
||||
pageId String @unique
|
||||
page Page @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
||||
requestedById String
|
||||
requestedBy User @relation(fields: [requestedById], references: [id], onDelete: Restrict)
|
||||
enabled Boolean @default(false)
|
||||
weekdays Int[] @default([1, 2, 3, 4, 5])
|
||||
times String[] @default(["09:00"])
|
||||
brief String @default("")
|
||||
targets Platform[] @default([FACEBOOK])
|
||||
nextRunAt DateTime?
|
||||
lastQueuedAt DateTime?
|
||||
lastError String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
id String @id @default(cuid())
|
||||
pageId String @unique
|
||||
page Page @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
||||
requestedById String
|
||||
requestedBy User @relation(fields: [requestedById], references: [id], onDelete: Restrict)
|
||||
enabled Boolean @default(false)
|
||||
scheduleMode ContentScheduleMode @default(FIXED)
|
||||
weekdays Int[] @default([1, 2, 3, 4, 5])
|
||||
times String[] @default(["09:00"])
|
||||
randomPostsPerDay Int @default(1)
|
||||
articlePercent Int @default(40)
|
||||
knowledgePercent Int @default(40)
|
||||
salesPercent Int @default(20)
|
||||
brief String @default("")
|
||||
targets Platform[] @default([FACEBOOK])
|
||||
nextRunAt DateTime?
|
||||
lastQueuedAt DateTime?
|
||||
lastError String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([enabled, nextRunAt])
|
||||
}
|
||||
|
||||
enum ContentScheduleMode {
|
||||
FIXED
|
||||
RANDOM
|
||||
}
|
||||
|
||||
// Durable creation queue. The output is always a draft and never a published post.
|
||||
model PostGenerationJob {
|
||||
id String @id @default(cuid())
|
||||
|
||||
Reference in New Issue
Block a user