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.

Move workflow types into dedicated workflow type files

Kiran Ka690a086e526
diff --git a/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts b/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts
index a89c393493..f0e0d66e32 100644
--- a/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts
+++ b/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts
@@ -10,7 +10,7 @@ import { PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES } from "@/lib/bounty/api/performanc
import { validateBounty } from "@/lib/bounty/api/validate-bounty";
import { getPlanCapabilities } from "@/lib/plan-capabilities";
import { prisma } from "@/lib/prisma";
-import { WorkflowCondition } from "@/lib/types";
+import { WorkflowCondition } from "@/lib/api/workflows/types";
import { sendWorkspaceWebhook } from "@/lib/webhook/publish";
import {
BountySchema,
diff --git a/apps/web/app/(ee)/api/bounties/route.ts b/apps/web/app/(ee)/api/bounties/route.ts
index 873593f51f..9b58eb4518 100644
--- a/apps/web/app/(ee)/api/bounties/route.ts
+++ b/apps/web/app/(ee)/api/bounties/route.ts
@@ -11,7 +11,7 @@ import { validateBounty } from "@/lib/bounty/api/validate-bounty";
import { qstash } from "@/lib/cron";
import { getPlanCapabilities } from "@/lib/plan-capabilities";
import { prisma } from "@/lib/prisma";
-import { WorkflowAction } from "@/lib/types";
+import { WorkflowAction } from "@/lib/api/workflows/types";
import { sendWorkspaceWebhook } from "@/lib/webhook/publish";
import {
BountyListSchema,
diff --git a/apps/web/app/(ee)/api/campaigns/route.ts b/apps/web/app/(ee)/api/campaigns/route.ts
index 4d333158d9..3ae65f5a5a 100644
--- a/apps/web/app/(ee)/api/campaigns/route.ts
+++ b/apps/web/app/(ee)/api/campaigns/route.ts
@@ -4,7 +4,7 @@ import { getDefaultProgramIdOrThrow } from "@/lib/api/programs/get-default-progr
import { parseRequestBody } from "@/lib/api/utils";
import { withWorkspace } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
-import { WorkflowAction, WorkflowCondition } from "@/lib/types";
+import { WorkflowAction, WorkflowCondition } from "@/lib/api/workflows/types";
import {
CampaignSchema,
createCampaignSchema,
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/[campaignId]/utils.ts b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/[campaignId]/utils.ts
index 93e9f1dd76..e4babc6f80 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/[campaignId]/utils.ts
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/[campaignId]/utils.ts
@@ -1,7 +1,5 @@
-import {
- SEND_CAMPAIGN_ATTRIBUTE_CONFIG,
- SendCampaignCondition,
-} from "@/lib/api/workflows/send-campaign/schema";
+import { SEND_CAMPAIGN_ATTRIBUTE_CONFIG } from "@/lib/api/workflows/send-campaign/schema";
+import type { SendCampaignCondition } from "@/lib/api/workflows/send-campaign/types";
export function isValidTriggerCondition(
triggerCondition: SendCampaignCondition | null | undefined,
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-move-rules.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-move-rules.tsx
index d36ecd9e9c..63a45392fc 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-move-rules.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/settings/group-move-rules.tsx
@@ -3,11 +3,13 @@
import {
GROUP_MOVE_ATTRIBUTE_CONFIG,
GROUP_MOVE_ATTRIBUTES,
- type GroupMoveAttribute,
- type GroupMoveAttributeConfig,
- type GroupMoveCondition,
- type GroupMoveRules as GroupMoveRulesForm,
} from "@/lib/api/workflows/move-group/schema";
+import type {
+ GroupMoveAttribute,
+ GroupMoveAttributeConfig,
+ GroupMoveCondition,
+ GroupMoveRules as GroupMoveRulesForm,
+} from "@/lib/api/workflows/move-group/types";
import { getPlanCapabilities } from "@/lib/plan-capabilities";
import useGroup from "@/lib/swr/use-group";
import useWorkspace from "@/lib/swr/use-workspace";
diff --git a/apps/web/lib/api/groups/find-groups-with-matching-rules.ts b/apps/web/lib/api/groups/find-groups-with-matching-rules.ts
index a12a84aaf0..20c93e5c95 100644
--- a/apps/web/lib/api/groups/find-groups-with-matching-rules.ts
+++ b/apps/web/lib/api/groups/find-groups-with-matching-rules.ts
@@ -1,7 +1,7 @@
import type {
GroupMoveCondition,
GroupMoveRules,
-} from "@/lib/api/workflows/move-group/schema";
+} from "@/lib/api/workflows/move-group/types";
import { groupRulesSchema } from "@/lib/zod/schemas/groups";
import * as z from "zod/v4";
diff --git a/apps/web/lib/api/groups/upsert-group-move-rules.ts b/apps/web/lib/api/groups/upsert-group-move-rules.ts
index 7ec8033428..d4e1167c8f 100644
--- a/apps/web/lib/api/groups/upsert-group-move-rules.ts
+++ b/apps/web/lib/api/groups/upsert-group-move-rules.ts
@@ -1,7 +1,8 @@
-import type { GroupMoveRules } from "@/lib/api/workflows/move-group/schema";
+import type { GroupMoveRules } from "@/lib/api/workflows/move-group/types";
+import type { WorkflowAction } from "@/lib/api/workflows/types";
import { getPlanCapabilities } from "@/lib/plan-capabilities";
import { prisma } from "@/lib/prisma";
-import { WorkflowAction, WorkspaceProps } from "@/lib/types";
+import { WorkspaceProps } from "@/lib/types";
import { WORKFLOW_ACTION_TYPES } from "@/lib/zod/schemas/workflows";
import { pluralize } from "@dub/utils";
import { PartnerGroup, WorkflowTrigger } from "@prisma/client";
diff --git a/apps/web/lib/api/groups/validate-group-move-rules.ts b/apps/web/lib/api/groups/validate-group-move-rules.ts
index 1cb2b9f05c..27deb2200f 100644
--- a/apps/web/lib/api/groups/validate-group-move-rules.ts
+++ b/apps/web/lib/api/groups/validate-group-move-rules.ts
@@ -1,10 +1,12 @@
import {
GROUP_MOVE_ATTRIBUTE_CONFIG,
GROUP_MOVE_OPERATOR_LABELS,
- GroupMoveAttribute,
- type GroupMoveCondition,
- type GroupMoveRules,
} from "@/lib/api/workflows/move-group/schema";
+import type {
+ GroupMoveAttribute,
+ GroupMoveCondition,
+ GroupMoveRules,
+} from "@/lib/api/workflows/move-group/types";
import { COMPARISON_OPERATORS } from "@/lib/api/workflows/operators";
type GroupMoveAttributeValidator = (params: {
diff --git a/apps/web/lib/api/workflows/award-bounty/execute.ts b/apps/web/lib/api/workflows/award-bounty/execute.ts
index 6844349bc6..2d7d322b6c 100644
--- a/apps/web/lib/api/workflows/award-bounty/execute.ts
+++ b/apps/web/lib/api/workflows/award-bounty/execute.ts
@@ -1,6 +1,6 @@
import { evaluateWorkflowConditions } from "@/lib/api/workflows/evaluate-workflow-conditions";
import { prisma } from "@/lib/prisma";
-import { WorkflowConditionAttribute, WorkflowContext } from "@/lib/types";
+import { WorkflowConditionAttribute, WorkflowContext } from "@/lib/api/workflows/types";
import { WORKFLOW_ACTION_TYPES } from "@/lib/zod/schemas/workflows";
import { sendBatchEmail, sendEmail } from "@dub/email";
import BountyCompleted from "@dub/email/templates/bounty-completed";
diff --git a/apps/web/lib/api/workflows/award-bounty/schema.ts b/apps/web/lib/api/workflows/award-bounty/schema.ts
index 5dbf48a946..db76169222 100644
--- a/apps/web/lib/api/workflows/award-bounty/schema.ts
+++ b/apps/web/lib/api/workflows/award-bounty/schema.ts
@@ -9,6 +9,16 @@ export const AWARD_BOUNTY_ATTRIBUTES = [
export const AWARD_BOUNTY_OPERATORS = ["gte"] as const;
+type AwardBountyAttribute = (typeof AWARD_BOUNTY_ATTRIBUTES)[number];
+
+type AwardBountyOperator = (typeof AWARD_BOUNTY_OPERATORS)[number];
+
+type AwardBountyAttributeConfig = {
+ label: string;
+ inputType: "number" | "currency";
+ operators: readonly AwardBountyOperator[];
+};
+
export const AWARD_BOUNTY_ATTRIBUTE_CONFIG: Record<
AwardBountyAttribute,
AwardBountyAttributeConfig
@@ -45,15 +55,3 @@ export const awardBountyConditionSchema = z.object({
operator: z.enum(AWARD_BOUNTY_OPERATORS).default("gte"),
value: z.number(),
});
-
-export type AwardBountyCondition = z.infer<typeof awardBountyConditionSchema>;
-
-export type AwardBountyAttribute = (typeof AWARD_BOUNTY_ATTRIBUTES)[number];
-
-type AwardBountyOperator = (typeof AWARD_BOUNTY_OPERATORS)[number];
-
-export type AwardBountyAttributeConfig = {
- label: string;
- inputType: "number" | "currency";
- operators: readonly AwardBountyOperator[];
-};
diff --git a/apps/web/lib/api/workflows/award-bounty/types.ts b/apps/web/lib/api/workflows/award-bounty/types.ts
new file mode 100644
index 0000000000..0e19452781
--- /dev/null
+++ b/apps/web/lib/api/workflows/award-bounty/types.ts
@@ -0,0 +1,4 @@
+import type * as z from "zod/v4";
+import type { awardBountyConditionSchema } from "./schema";
+
+export type AwardBountyCondition = z.infer<typeof awardBountyConditionSchema>;
diff --git a/apps/web/lib/api/workflows/evaluate-workflow-conditions.ts b/apps/web/lib/api/workflows/evaluate-workflow-conditions.ts
index 299c81000a..ca2367ddbc 100644
--- a/apps/web/lib/api/workflows/evaluate-workflow-conditions.ts
+++ b/apps/web/lib/api/workflows/evaluate-workflow-conditions.ts
@@ -1,4 +1,4 @@
-import { WorkflowCondition, WorkflowConditionAttribute } from "@/lib/types";
+import { WorkflowCondition, WorkflowConditionAttribute } from "@/lib/api/workflows/types";
import { COMPARISON_OPERATORS } from "./operators";
export function evaluateWorkflowConditions({
diff --git a/apps/web/lib/api/workflows/execute-workflows.ts b/apps/web/lib/api/workflows/execute-workflows.ts
index 2b868ba15a..856f68d463 100644
--- a/apps/web/lib/api/workflows/execute-workflows.ts
+++ b/apps/web/lib/api/workflows/execute-workflows.ts
@@ -1,6 +1,6 @@
import { aggregatePartnerLinksStats } from "@/lib/partners/aggregate-partner-links-stats";
import { prisma } from "@/lib/prisma";
-import { WorkflowConditionAttribute, WorkflowContext } from "@/lib/types";
+import { WorkflowConditionAttribute, WorkflowContext } from "@/lib/api/workflows/types";
import { WORKFLOW_ACTION_TYPES } from "@/lib/zod/schemas/workflows";
import { Workflow } from "@prisma/client";
import { executeAwardBountyWorkflow } from "./award-bounty/execute";
diff --git a/apps/web/lib/api/workflows/move-group/execute.ts b/apps/web/lib/api/workflows/move-group/execute.ts
index ac392eadf7..1c56b0b42c 100644
--- a/apps/web/lib/api/workflows/move-group/execute.ts
+++ b/apps/web/lib/api/workflows/move-group/execute.ts
@@ -1,5 +1,5 @@
import { prisma } from "@/lib/prisma";
-import { WorkflowConditionAttribute, WorkflowContext } from "@/lib/types";
+import { WorkflowConditionAttribute, WorkflowContext } from "@/lib/api/workflows/types";
import { redis } from "@/lib/upstash/redis";
import { WORKFLOW_ACTION_TYPES } from "@/lib/zod/schemas/workflows";
import { Workflow } from "@prisma/client";
diff --git a/apps/web/lib/api/workflows/move-group/schema.ts b/apps/web/lib/api/workflows/move-group/schema.ts
index 12ec7c097b..b8aa462ef7 100644
--- a/apps/web/lib/api/workflows/move-group/schema.ts
+++ b/apps/web/lib/api/workflows/move-group/schema.ts
@@ -9,6 +9,16 @@ export const GROUP_MOVE_ATTRIBUTES = [
export const GROUP_MOVE_OPERATORS = ["gte", "between"] as const;
+type GroupMoveAttribute = (typeof GROUP_MOVE_ATTRIBUTES)[number];
+
+type GroupMoveOperator = (typeof GROUP_MOVE_OPERATORS)[number];
+
+type GroupMoveAttributeConfig = {
+ label: string;
+ inputType: "number" | "currency";
+ operators: readonly GroupMoveOperator[];
+};
+
export const GROUP_MOVE_ATTRIBUTE_CONFIG: Record<
GroupMoveAttribute,
GroupMoveAttributeConfig
@@ -53,17 +63,3 @@ export const groupMoveConditionSchema = z.object({
});
export const groupMoveRulesSchema = z.array(groupMoveConditionSchema);
-
-export type GroupMoveCondition = z.infer<typeof groupMoveConditionSchema>;
-
-export type GroupMoveRules = z.infer<typeof groupMoveRulesSchema>;
-
-export type GroupMoveAttribute = (typeof GROUP_MOVE_ATTRIBUTES)[number];
-
-type GroupMoveOperator = (typeof GROUP_MOVE_OPERATORS)[number];
-
-export type GroupMoveAttributeConfig = {
- label: string;
- inputType: "number" | "currency";
- operators: readonly GroupMoveOperator[];
-};
diff --git a/apps/web/lib/api/workflows/move-group/types.ts b/apps/web/lib/api/workflows/move-group/types.ts
new file mode 100644
index 0000000000..c0b4f6b932
--- /dev/null
+++ b/apps/web/lib/api/workflows/move-group/types.ts
@@ -0,0 +1,22 @@
+import type * as z from "zod/v4";
+
+import type {
+ GROUP_MOVE_ATTRIBUTES,
+ GROUP_MOVE_OPERATORS,
+ groupMoveConditionSchema,
+ groupMoveRulesSchema,
+} from "./schema";
+
+export type GroupMoveCondition = z.infer<typeof groupMoveConditionSchema>;
+
+export type GroupMoveRules = z.infer<typeof groupMoveRulesSchema>;
+
+export type GroupMoveAttribute = (typeof GROUP_MOVE_ATTRIBUTES)[number];
+
+type GroupMoveOperator = (typeof GROUP_MOVE_OPERATORS)[number];
+
+export type GroupMoveAttributeConfig = {
+ label: string;
+ inputType: "number" | "currency";
+ operators: readonly GroupMoveOperator[];
+};
diff --git a/apps/web/lib/api/workflows/operators.ts b/apps/web/lib/api/workflows/operators.ts
index 4113dbf725..dc350657d7 100644
--- a/apps/web/lib/api/workflows/operators.ts
+++ b/apps/web/lib/api/workflows/operators.ts
@@ -1,4 +1,4 @@
-import { WorkflowComparisonOperator } from "@/lib/types";
+import { WorkflowComparisonOperator } from "@/lib/api/workflows/types";
type ConditionValue = number | { min: number; max?: number };
diff --git a/apps/web/lib/api/workflows/send-campaign/execute.ts b/apps/web/lib/api/workflows/send-campaign/execute.ts
index 392fb38359..eb07f28ff3 100644
--- a/apps/web/lib/api/workflows/send-campaign/execute.ts
+++ b/apps/web/lib/api/workflows/send-campaign/execute.ts
@@ -1,12 +1,12 @@
import { evaluateWorkflowConditions } from "@/lib/api/workflows/evaluate-workflow-conditions";
-import { aggregatePartnerLinksStats } from "@/lib/partners/aggregate-partner-links-stats";
-import { constructPartnerLink } from "@/lib/partners/construct-partner-link";
-import { prisma } from "@/lib/prisma";
import {
- TiptapNode,
WorkflowConditionAttribute,
WorkflowContext,
-} from "@/lib/types";
+} from "@/lib/api/workflows/types";
+import { aggregatePartnerLinksStats } from "@/lib/partners/aggregate-partner-links-stats";
+import { constructPartnerLink } from "@/lib/partners/construct-partner-link";
+import { prisma } from "@/lib/prisma";
+import { TiptapNode } from "@/lib/types";
import { WORKFLOW_ACTION_TYPES } from "@/lib/zod/schemas/workflows";
import { sendBatchEmail } from "@dub/email";
import CampaignEmail from "@dub/email/templates/campaign-email";
@@ -17,7 +17,7 @@ import { renderCampaignEmailHTML } from "../../campaigns/render-campaign-email-h
import { validateCampaignFromAddress } from "../../campaigns/validate-campaign";
import { createId } from "../../create-id";
import { parseWorkflowConfig } from "../parse-workflow-config";
-import { SendCampaignCondition } from "./schema";
+import type { SendCampaignCondition } from "./types";
export const executeSendCampaignWorkflow = async ({
workflow,
diff --git a/apps/web/lib/api/workflows/send-campaign/schema.ts b/apps/web/lib/api/workflows/send-campaign/schema.ts
index 515a28969e..52d4804690 100644
--- a/apps/web/lib/api/workflows/send-campaign/schema.ts
+++ b/apps/web/lib/api/workflows/send-campaign/schema.ts
@@ -11,6 +11,17 @@ export const SEND_CAMPAIGN_ATTRIBUTES = [
export const SEND_CAMPAIGN_OPERATORS = ["gte"] as const;
+type SendCampaignAttribute = (typeof SEND_CAMPAIGN_ATTRIBUTES)[number];
+
+type SendCampaignOperator = (typeof SEND_CAMPAIGN_OPERATORS)[number];
+
+type SendCampaignAttributeConfig = {
+ label: string;
+ inputType: "number" | "currency" | "dropdown" | "none";
+ operators: readonly SendCampaignOperator[];
+ dropdownValues?: number[];
+};
+
export const SEND_CAMPAIGN_ATTRIBUTE_CONFIG: Record<
SendCampaignAttribute,
SendCampaignAttributeConfig
@@ -60,16 +71,3 @@ export const sendCampaignConditionSchema = z.object({
operator: z.enum(SEND_CAMPAIGN_OPERATORS).default("gte"),
value: z.number(),
});
-
-export type SendCampaignCondition = z.infer<typeof sendCampaignConditionSchema>;
-
-export type SendCampaignAttribute = (typeof SEND_CAMPAIGN_ATTRIBUTES)[number];
-
-type SendCampaignOperator = (typeof SEND_CAMPAIGN_OPERATORS)[number];
-
-export type SendCampaignAttributeConfig = {
- label: string;
- inputType: "number" | "currency" | "dropdown" | "none";
- operators: readonly SendCampaignOperator[];
- dropdownValues?: number[];
-};
diff --git a/apps/web/lib/api/workflows/send-campaign/types.ts b/apps/web/lib/api/workflows/send-campaign/types.ts
new file mode 100644
index 0000000000..c015901fff
--- /dev/null
+++ b/apps/web/lib/api/workflows/send-campaign/types.ts
@@ -0,0 +1,5 @@
+import type * as z from "zod/v4";
+
+import type { sendCampaignConditionSchema } from "./schema";
+
+export type SendCampaignCondition = z.infer<typeof sendCampaignConditionSchema>;
diff --git a/apps/web/lib/api/workflows/types.ts b/apps/web/lib/api/workflows/types.ts
new file mode 100644
index 0000000000..5de35cf82f
--- /dev/null
+++ b/apps/web/lib/api/workflows/types.ts
@@ -0,0 +1,43 @@
+import {
+ WORKFLOW_ATTRIBUTES,
+ WORKFLOW_COMPARISON_OPERATORS,
+ workflowActionSchema,
+ workflowConditionSchema,
+} from "@/lib/zod/schemas/workflows";
+import { WorkflowTrigger } from "@prisma/client";
+import type * as z from "zod/v4";
+
+export type WorkflowCondition = z.infer<typeof workflowConditionSchema>;
+
+export type WorkflowConditionAttribute = (typeof WORKFLOW_ATTRIBUTES)[number];
+
+export type WorkflowComparisonOperator =
+ (typeof WORKFLOW_COMPARISON_OPERATORS)[number];
+
+export type WorkflowAction = z.infer<typeof workflowActionSchema>;
+
+interface WorkflowIdentity {
+ workspaceId: string;
+ programId: string;
+ partnerId: string;
+ groupId?: string;
+ customerId?: string;
+ customerFirstSaleAt?: Date;
+}
+
+interface PartnerMetrics {
+ leads?: number;
+ conversions?: number;
+ saleAmount?: number;
+ commissions?: number;
+}
+
+export interface WorkflowContext {
+ trigger: WorkflowTrigger;
+ reason?: "lead" | "sale" | "commission";
+ identity: WorkflowIdentity;
+ metrics?: {
+ current?: PartnerMetrics;
+ aggregated?: PartnerMetrics;
+ };
+}
diff --git a/apps/web/lib/api/workflows/utils.ts b/apps/web/lib/api/workflows/utils.ts
index c9665f0384..6621df1fc1 100644
--- a/apps/web/lib/api/workflows/utils.ts
+++ b/apps/web/lib/api/workflows/utils.ts
@@ -1,4 +1,4 @@
-import { WorkflowConditionAttribute } from "@/lib/types";
+import { WorkflowConditionAttribute } from "@/lib/api/workflows/types";
import { SCHEDULED_WORKFLOW_TRIGGERS } from "@/lib/zod/schemas/workflows";
import { Workflow } from "@prisma/client";
import { parseWorkflowConfig } from "./parse-workflow-config";
diff --git a/apps/web/lib/bounty/api/generate-performance-bounty-name.ts b/apps/web/lib/bounty/api/generate-performance-bounty-name.ts
index aa899530e8..79c2596f9d 100644
--- a/apps/web/lib/bounty/api/generate-performance-bounty-name.ts
+++ b/apps/web/lib/bounty/api/generate-performance-bounty-name.ts
@@ -1,5 +1,5 @@
import { isCurrencyAttribute } from "@/lib/api/workflows/utils";
-import { AwardBountyCondition } from "@/lib/types";
+import { AwardBountyCondition } from "@/lib/api/workflows/award-bounty/types";
import { currencyFormatter, nFormatter } from "@dub/utils";
import { PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES } from "./performance-bounty-scope-attributes";
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index c6c7ef2c2a..8126bc8ef9 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -29,7 +29,6 @@ import {
User,
UtmTemplate,
Webhook,
- WorkflowTrigger,
WorkspaceRole,
} from "@prisma/client";
import * as z from "zod/v4";
@@ -200,12 +199,6 @@ import {
webhookEventSchemaTB,
WebhookSchema,
} from "./zod/schemas/webhooks";
-import {
- WORKFLOW_ATTRIBUTES,
- WORKFLOW_COMPARISON_OPERATORS,
- workflowActionSchema,
- workflowConditionSchema,
-} from "./zod/schemas/workflows";
import { workspacePreferencesSchema } from "./zod/schemas/workspace-preferences";
import { workspaceUserSchema } from "./zod/schemas/workspaces";
@@ -716,23 +709,10 @@ export type BountySubmissionRequirement =
export type SocialMetricsChannel =
(typeof BOUNTY_SOCIAL_PLATFORMS)[number]["value"];
-export type WorkflowCondition = z.infer<typeof workflowConditionSchema>;
-
-export type { AwardBountyCondition } from "./api/workflows/award-bounty/schema";
-
export type BountySocialMetricsIncrementalBonus = z.infer<
typeof bountySocialContentIncrementalBonusSchema
>;
-export type { SendCampaignCondition } from "./api/workflows/send-campaign/schema";
-
-export type WorkflowConditionAttribute = (typeof WORKFLOW_ATTRIBUTES)[number];
-
-export type WorkflowComparisonOperator =
- (typeof WORKFLOW_COMPARISON_OPERATORS)[number];
-
-export type WorkflowAction = z.infer<typeof workflowActionSchema>;
-
export type BountySubmissionsQueryFilters = z.infer<
typeof getBountySubmissionsQuerySchema
>;
@@ -764,8 +744,6 @@ export interface TiptapNode {
marks?: Array<{ type: string; attrs?: Record<string, any> }>;
}
-export type WorkflowAttribute = (typeof WORKFLOW_ATTRIBUTES)[number];
-
export type EmailDomainProps = z.infer<typeof EmailDomainSchema>;
export type FraudGroupProps = z.infer<typeof fraudGroupSchema>;
@@ -823,32 +801,6 @@ export type CreateFraudEventInput = Pick<
metadata?: Record<string, unknown> | null;
};
-interface WorkflowIdentity {
- workspaceId: string;
- programId: string;
- partnerId: string;
- groupId?: string;
- customerId?: string;
- customerFirstSaleAt?: Date;
-}
-
-interface PartnerMetrics {
- leads?: number;
- conversions?: number;
- saleAmount?: number;
- commissions?: number;
-}
-
-export interface WorkflowContext {
- trigger: WorkflowTrigger;
- reason?: "lead" | "sale" | "commission";
- identity: WorkflowIdentity;
- metrics?: {
- current?: PartnerMetrics;
- aggregated?: PartnerMetrics;
- };
-}
-
export type SubmittedLeadProps = z.infer<typeof submittedLeadSchema>;
export type SubmittedLeadFormDataField = z.infer<
diff --git a/apps/web/lib/zod/schemas/workflows.ts b/apps/web/lib/zod/schemas/workflows.ts
index 8db5a8f4c3..fe4a6201c5 100644
--- a/apps/web/lib/zod/schemas/workflows.ts
+++ b/apps/web/lib/zod/schemas/workflows.ts
@@ -1,4 +1,3 @@
-import { WorkflowConditionAttribute } from "@/lib/types";
import { WorkflowTrigger } from "@prisma/client";
import * as z from "zod/v4";
@@ -11,6 +10,8 @@ export const WORKFLOW_ATTRIBUTES = [
"partnerJoined",
] as const;
+type WorkflowConditionAttribute = (typeof WORKFLOW_ATTRIBUTES)[number];
+
export const WORKFLOW_ATTRIBUTE_TRIGGER: Record<
WorkflowConditionAttribute,
WorkflowTrigger