Start every Rule private, with a rotating link and files that follow its readers.

New Rules stay off lists until the person who holds the pen turns on a share link, or the team features one. Uploaded files are readable only by those readers, stripped of location metadata, and deleted with the Rule, draft, or account.
This commit is contained in:
adilallo committed 2026-11-09 19:54:04 -07:00
1 parent 642551064c
commit 5cbda35e32
50 files changed
+2429 -219

No files matched your search

+47 -1
View File
@@ -16,6 +16,7 @@ model User {
sessions Session[]
draft RuleDraft?
rules PublishedRule[]
uploads Upload[]
/// At most one pending verified email change (CR-103).
emailChangeToken EmailChangeToken?
/// Rules this user was invited to as a stakeholder (after accepting invite).
@@ -68,12 +69,19 @@ model RuleDraft {
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
payload Json
updatedAt DateTime @updatedAt
uploads Upload[]
}
enum RuleVisibility {
private
shared_by_link
public_and_featured
}
model PublishedRule {
id String @id @default(cuid())
userId String?
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
title String
summary String?
document Json
@@ -82,10 +90,48 @@ model PublishedRule {
/// Hashed one-time secret so the publishing browser can claim this row on sign-in.
/// Null for owned publishes and after a successful claim.
claimTokenHash String? @unique
/// Who can read this Rule. New rows start private.
visibility RuleVisibility @default(private)
/// Rotating public path `/r/{shareSlug}`. Null while private. Replaced when a link is turned back on.
shareSlug String? @unique
stakeholders RuleStakeholder[]
uploads Upload[]
@@index([userId])
@@index([visibility, updatedAt])
}
/// File written under UPLOAD_ROOT. Readers follow the linked Rule or draft.
model Upload {
id String @id
mimeType String
byteLength Int
purpose String
userId String?
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
draftId String?
draft RuleDraft? @relation(fields: [draftId], references: [id], onDelete: Cascade)
ruleId String?
rule PublishedRule? @relation(fields: [ruleId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
@@index([ruleId])
@@index([draftId])
@@index([userId])
}
/// Named-admin reads of Rules they do not already hold the pen for or belong to.
model AdminRuleReadLog {
id String @id @default(cuid())
ruleId String
adminEmail String
adminUserId String?
path String
createdAt DateTime @default(now())
@@index([ruleId, createdAt])
@@index([adminEmail, createdAt])
}
/// Invite + access for a published rule: email invite at publish; userId set after magic-link-style accept.