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.

Update workflows.ts

Kiran Kc6c4ec9e79ad
diff --git a/apps/web/lib/zod/schemas/workflows.ts b/apps/web/lib/zod/schemas/workflows.ts
index 0f28e1631d..6f13b9f7b7 100644
--- a/apps/web/lib/zod/schemas/workflows.ts
+++ b/apps/web/lib/zod/schemas/workflows.ts
@@ -24,12 +24,20 @@ export const WORKFLOW_ACTION_TYPES = [
"send_webhook",
] as const;
+// Individual condition
const workflowConditionSchema = z.object({
attribute: z.enum(WORKFLOW_CONDITION_ATTRIBUTES),
operator: z.enum(WORKFLOW_CONDITION_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"),
+ conditions: z.array(workflowConditionSchema).min(1),
+});
+
+// Individual action
const workflowActionSchema = z.discriminatedUnion("type", [
z.object({
type: z.literal("create_commission"),
@@ -46,8 +54,11 @@ const workflowActionSchema = z.discriminatedUnion("type", [
}),
]);
+// Array of actions (Only supports one action for now)
+export const workflowActionsSchema = z.array(workflowActionSchema);
+
export const createWorkflowSchema = z.object({
trigger: z.nativeEnum(WorkflowTrigger),
- triggerConditions: z.array(workflowConditionSchema),
- actions: z.array(workflowActionSchema),
+ triggerConditions: workflowConditionsSchema,
+ actions: workflowActionsSchema,
});