Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

2.0 KB
Raw Blame
enum WebhookReceiver {
  user
  zapier
  make
  slack
  segment
}

enum LinkScope {
  workspace // All links in the workspace
  folders // Links inside specific folders
  links // Specific links
}

model Webhook {
  id                  String          @id
  projectId           String
  installationId      String? // indicates which integration installation added the webhook
  receiver            WebhookReceiver @default(user)
  name                String
  url                 String          @db.LongText
  secret              String
  triggers            Json
  linkScope           LinkScope? // Only set for webhooks with the link.clicked trigger
  consecutiveFailures Int             @default(0)
  lastFailedAt        DateTime?
  disabledAt          DateTime?
  createdAt           DateTime        @default(now())
  updatedAt           DateTime        @updatedAt

  project              Project               @relation(fields: [projectId], references: [id], onDelete: Cascade)
  installedIntegration InstalledIntegration? @relation(fields: [installationId], references: [id], onDelete: Cascade)
  links                LinkWebhook[]
  folders              FolderWebhook[]

  @@index(projectId)
  @@index(installationId)
}

model LinkWebhook {
  id        String   @id @default(cuid())
  linkId    String
  webhookId String
  createdAt DateTime @default(now())

  link    Link    @relation(fields: [linkId], references: [id], onUpdate: Cascade, onDelete: Cascade)
  webhook Webhook @relation(fields: [webhookId], references: [id], onUpdate: Cascade, onDelete: Cascade)

  @@unique([linkId, webhookId])
  @@index(webhookId)
}

model FolderWebhook {
  id        String   @id @default(cuid())
  folderId  String
  webhookId String
  createdAt DateTime @default(now())

  folder  Folder  @relation(fields: [folderId], references: [id], onUpdate: Cascade, onDelete: Cascade)
  webhook Webhook @relation(fields: [webhookId], references: [id], onUpdate: Cascade, onDelete: Cascade)

  @@unique([folderId, webhookId])
  @@index(webhookId)
}