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.

add workflow type

Kiran K0b35358679a3
diff --git a/apps/web/lib/zod/schemas/workflows.ts b/apps/web/lib/zod/schemas/workflows.ts
index 9aa980a153..bfaedbfccd 100644
--- a/apps/web/lib/zod/schemas/workflows.ts
+++ b/apps/web/lib/zod/schemas/workflows.ts
@@ -9,46 +9,56 @@ export const WORKFLOW_CONDITION_ATTRIBUTES = [
] as const;
export const WORKFLOW_ACTION_TYPES = [
- "sendEmail", // send an email to the partner
- "updateGroup", // move the partner to a group
- "createCommission", // create a commission for the partner via Bounty
+ "sendEmail",
+ "moveToGroup",
+ "awardBounty",
+ "triggerWebhook",
] as const;
-export const WORKFLOW_CONDITION_OPERATORS = ["gte"] as const;
+export const WORKFLOW_COMPARISON_OPERATORS = ["gte"] as const;
+
+export const WORKFLOW_LOGICAL_OPERATORS = ["AND"] as const;
// Individual condition
const workflowConditionSchema = z.object({
attribute: z.enum(WORKFLOW_CONDITION_ATTRIBUTES),
- operator: z.enum(WORKFLOW_CONDITION_OPERATORS),
+ operator: z.enum(WORKFLOW_COMPARISON_OPERATORS),
value: z.union([z.string(), z.number()]),
});
// Array of conditions with AND operator
export const workflowConditionsSchema = z.object({
- operator: z.enum(["AND"]).default("AND"),
+ operator: z.enum(WORKFLOW_LOGICAL_OPERATORS).default("AND"),
conditions: z.array(workflowConditionSchema).min(1),
});
// Individual action
const workflowActionSchema = z.discriminatedUnion("type", [
z.object({
- type: z.literal("createCommission"),
+ type: z.literal("sendEmail"),
data: z.object({
- bountyId: z.string(),
+ emailId: z.string(),
}),
}),
z.object({
- type: z.literal("sendEmail"),
+ type: z.literal("moveToGroup"),
data: z.object({
- emailId: z.string(),
+ groupId: z.string(),
}),
}),
z.object({
- type: z.literal("updateGroup"),
+ type: z.literal("awardBounty"),
data: z.object({
- groupId: z.string(),
+ bountyId: z.string(),
+ }),
+ }),
+
+ z.object({
+ type: z.literal("triggerWebhook"),
+ data: z.object({
+ webhookId: z.string(),
}),
}),
]);
diff --git a/packages/prisma/schema/workflow.prisma b/packages/prisma/schema/workflow.prisma
index 7ad06b70dd..88803985c9 100644
--- a/packages/prisma/schema/workflow.prisma
+++ b/packages/prisma/schema/workflow.prisma
@@ -3,21 +3,27 @@ enum WorkflowTrigger {
leadRecorded
saleRecorded
commissionEarned
+ partnerEnrolled
+}
+
+enum WorkflowTriggerType {
+ event
+ scheduled
}
model Workflow {
- id String @id @default(cuid())
+ id String @id @default(cuid())
programId String
name String?
trigger WorkflowTrigger
+ triggerType WorkflowTriggerType
triggerConditions Json?
actions Json?
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
program Program @relation(fields: [programId], references: [id], onDelete: Cascade)
bounty Bounty?
@@index([programId, trigger])
}
-