/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const PartnerEnrolledEventEvent = { PartnerEnrolled: "partner.enrolled", } as const; export type PartnerEnrolledEventEvent = ClosedEnum< typeof PartnerEnrolledEventEvent >; /** * The partner's default payout method. Connect: Bank account payouts via Stripe Connect; Stablecoin: USDC payouts directly to a crypto wallet; PayPal: Payouts via PayPal */ export const DefaultPayoutMethod = { Connect: "connect", Stablecoin: "stablecoin", Paypal: "paypal", } as const; /** * The partner's default payout method. Connect: Bank account payouts via Stripe Connect; Stablecoin: USDC payouts directly to a crypto wallet; PayPal: Payouts via PayPal */ export type DefaultPayoutMethod = ClosedEnum; /** * The status of the partner's enrollment in the program. */ export const Status = { Pending: "pending", Approved: "approved", Rejected: "rejected", Invited: "invited", Declined: "declined", Deactivated: "deactivated", Banned: "banned", Archived: "archived", } as const; /** * The status of the partner's enrollment in the program. */ export type Status = ClosedEnum; export type Links = { /** * The unique ID of the short link. */ id: string; /** * The domain of the short link. If not provided, the primary domain for the workspace will be used (or `dub.sh` if the workspace has no domains). */ domain: string; /** * The short link slug. If not provided, a random 7-character slug will be generated. */ key: string; /** * The full URL of the short link, including the https protocol (e.g. `https://dub.sh/try`). */ shortLink: string; /** * The destination URL of the short link. */ url: string; /** * The number of clicks on the short link. */ clicks?: number | undefined; /** * The number of leads the short link has generated. */ leads?: number | undefined; /** * The number of leads that converted to paying customers. */ conversions?: number | undefined; /** * The total number of sales (includes recurring sales) generated by the short link. */ sales?: number | undefined; /** * The total dollar value of sales (in cents) generated by the short link. */ saleAmount?: number | undefined; }; /** * If the partner was banned from the program, this is the reason for the ban. */ export const BannedReason = { TosViolation: "tos_violation", InappropriateContent: "inappropriate_content", FakeTraffic: "fake_traffic", Fraud: "fraud", Spam: "spam", BrandAbuse: "brand_abuse", } as const; /** * If the partner was banned from the program, this is the reason for the ban. */ export type BannedReason = ClosedEnum; export const PartnerEnrolledEventFieldsDataReferralFormData8Type = { Phone: "phone", } as const; export type PartnerEnrolledEventFieldsDataReferralFormData8Type = ClosedEnum< typeof PartnerEnrolledEventFieldsDataReferralFormData8Type >; export type Eight = { key: string; label: string; required: boolean; locked: boolean; position: number; type: PartnerEnrolledEventFieldsDataReferralFormData8Type; }; export const PartnerEnrolledEventFieldsDataReferralFormData7Type = { Number: "number", } as const; export type PartnerEnrolledEventFieldsDataReferralFormData7Type = ClosedEnum< typeof PartnerEnrolledEventFieldsDataReferralFormData7Type >; export type Seven = { key: string; label: string; required: boolean; locked: boolean; position: number; type: PartnerEnrolledEventFieldsDataReferralFormData7Type; }; export const PartnerEnrolledEventFieldsDataReferralFormData6Type = { MultiSelect: "multiSelect", } as const; export type PartnerEnrolledEventFieldsDataReferralFormData6Type = ClosedEnum< typeof PartnerEnrolledEventFieldsDataReferralFormData6Type >; export type FieldsOptions = { label: string; value: string; }; export type Six = { key: string; label: string; required: boolean; locked: boolean; position: number; type: PartnerEnrolledEventFieldsDataReferralFormData6Type; options: Array; }; export const PartnerEnrolledEventFieldsDataReferralFormData5Type = { Date: "date", } as const; export type PartnerEnrolledEventFieldsDataReferralFormData5Type = ClosedEnum< typeof PartnerEnrolledEventFieldsDataReferralFormData5Type >; export type Five = { key: string; label: string; required: boolean; locked: boolean; position: number; type: PartnerEnrolledEventFieldsDataReferralFormData5Type; }; export const PartnerEnrolledEventFieldsDataReferralFormDataType = { Country: "country", } as const; export type PartnerEnrolledEventFieldsDataReferralFormDataType = ClosedEnum< typeof PartnerEnrolledEventFieldsDataReferralFormDataType >; export type Four = { key: string; label: string; required: boolean; locked: boolean; position: number; type: PartnerEnrolledEventFieldsDataReferralFormDataType; }; export const PartnerEnrolledEventFieldsDataType = { Select: "select", } as const; export type PartnerEnrolledEventFieldsDataType = ClosedEnum< typeof PartnerEnrolledEventFieldsDataType >; export type Options = { label: string; value: string; }; export type Fields3 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: PartnerEnrolledEventFieldsDataType; options: Array; }; export const PartnerEnrolledEventFieldsType = { Textarea: "textarea", } as const; export type PartnerEnrolledEventFieldsType = ClosedEnum< typeof PartnerEnrolledEventFieldsType >; export type FieldsConstraints = { maxLength?: number | undefined; }; export type Fields2 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: PartnerEnrolledEventFieldsType; constraints?: FieldsConstraints | undefined; }; export const FieldsType = { Text: "text", } as const; export type FieldsType = ClosedEnum; export type Constraints = { maxLength?: number | undefined; pattern?: string | undefined; }; export type Fields1 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: FieldsType; constraints?: Constraints | undefined; }; export type Fields = | (Fields1 & { type: "text" }) | (Fields2 & { type: "textarea" }) | (Fields3 & { type: "select" }) | (Four & { type: "country" }) | (Five & { type: "date" }) | (Six & { type: "multiSelect" }) | (Seven & { type: "number" }) | (Eight & { type: "phone" }); export type ReferralFormData = { fields: Array< | (Fields1 & { type: "text" }) | (Fields2 & { type: "textarea" }) | (Fields3 & { type: "select" }) | (Four & { type: "country" }) | (Five & { type: "date" }) | (Six & { type: "multiSelect" }) | (Seven & { type: "number" }) | (Eight & { type: "phone" }) >; }; /** * Preset reason when the application was rejected. */ export const RejectionReason = { NeedsMoreDetail: "needsMoreDetail", DoesNotMeetRequirements: "doesNotMeetRequirements", NotTheRightFit: "notTheRightFit", Other: "other", } as const; /** * Preset reason when the application was rejected. */ export type RejectionReason = ClosedEnum; /** * Linked program application, including review outcome when applicable. */ export type Application = { /** * Preset reason when the application was rejected. */ rejectionReason: RejectionReason | null; /** * Free-form note when the application was rejected. */ rejectionNote: string | null; /** * When the application was approved or rejected. */ reviewedAt: string | null; }; export type PartnerEnrolledEventData = { /** * The partner's unique ID on Dub. */ id: string; /** * The partner's full legal name. */ name: string; /** * If the partner profile type is a company, this is the partner's legal company name. */ companyName: string | null; /** * The partner's email address. Should be a unique value across Dub. */ email: string | null; /** * The partner's avatar image. */ image: string | null; /** * A brief description of the partner and their background. */ description?: string | null | undefined; /** * The partner's country (required for tax purposes). */ country: string | null; /** * The partner's default payout method. Connect: Bank account payouts via Stripe Connect; Stablecoin: USDC payouts directly to a crypto wallet; PayPal: Payouts via PayPal */ defaultPayoutMethod: DefaultPayoutMethod | null; /** * The partner's PayPal email (for receiving payouts via PayPal). */ paypalEmail: string | null; /** * The partner's Stripe Connect ID (for receiving payouts via Stripe). */ stripeConnectId: string | null; /** * The date when the partner enabled payouts. */ payoutsEnabledAt: string | null; /** * The date when the partner received the trusted badge in the partner network. */ trustedAt: string | null; /** * The program's unique ID on Dub. */ programId: string; /** * The partner's group ID on Dub. */ groupId?: string | null | undefined; /** * The partner's unique ID on Dub. */ partnerId: string; /** * The partner's unique ID within your database. Can be useful for associating the partner with a user in your database and retrieving/update their data in the future. */ tenantId: string | null; createdAt: string; /** * The status of the partner's enrollment in the program. */ status: Status; /** * The partner's referral links in this program. */ links: Array | null; /** * The total commissions paid to the partner for their referrals */ totalCommissions?: number | undefined; clickRewardId?: string | null | undefined; leadRewardId?: string | null | undefined; saleRewardId?: string | null | undefined; discountId?: string | null | undefined; /** * If the partner submitted an application to join the program, this is the ID of the application. */ applicationId?: string | null | undefined; /** * If the partner was banned from the program, this is the date of the ban. */ bannedAt?: string | null | undefined; /** * If the partner was banned from the program, this is the reason for the ban. */ bannedReason?: BannedReason | null | undefined; referralFormData?: ReferralFormData | null | undefined; /** * Linked program application, including review outcome when applicable. */ application?: Application | null | undefined; /** * The total number of clicks on the partner's links */ totalClicks?: number | undefined; /** * The total number of leads generated by the partner's links */ totalLeads?: number | undefined; /** * The total number of leads that converted to paying customers */ totalConversions?: number | undefined; /** * The total number of sales generated by the partner's links (includes recurring sales) */ totalSales?: number | undefined; /** * Total revenue generated by the partner's links */ totalSaleAmount?: number | undefined; /** * Net revenue after commissions (`Total Revenue - Total Commissions`) */ netRevenue?: number | undefined; /** * Earnings Per Click (EPC) (`Total Revenue ÷ Total Clicks`) */ earningsPerClick?: number | null | undefined; /** * Average lifetime value for each paying customer (`Total Revenue ÷ Total Conversions`) */ averageLifetimeValue?: number | null | undefined; /** * Percentage of clicks that become leads (`Total Leads ÷ Total Clicks`) */ clickToLeadRate?: number | null | undefined; /** * Percentage of clicks that convert to paying customers (`Total Conversions ÷ Total Clicks`) */ clickToConversionRate?: number | null | undefined; /** * Percentage of leads that convert to paying customers (`Total Conversions ÷ Total Leads`) */ leadToConversionRate?: number | null | undefined; /** * Return On Ad Spend (ROAS) (`Total Revenue ÷ Total Commissions`) */ returnOnAdSpend?: number | null | undefined; /** * The partner's website URL (including the https protocol). */ website?: string | null | undefined; /** * The partner's YouTube channel username (e.g. `johndoe`). */ youtube?: string | null | undefined; /** * The partner's Twitter username (e.g. `johndoe`). */ twitter?: string | null | undefined; /** * The partner's LinkedIn username (e.g. `johndoe`). */ linkedin?: string | null | undefined; /** * The partner's Instagram username (e.g. `johndoe`). */ instagram?: string | null | undefined; /** * The partner's TikTok username (e.g. `johndoe`). */ tiktok?: string | null | undefined; }; /** * Triggered when a partner is enrolled. */ export type PartnerEnrolledEvent = { id: string; event: PartnerEnrolledEventEvent; createdAt: string; data: PartnerEnrolledEventData; }; /** @internal */ export const PartnerEnrolledEventEvent$inboundSchema: z.ZodNativeEnum< typeof PartnerEnrolledEventEvent > = z.nativeEnum(PartnerEnrolledEventEvent); /** @internal */ export const PartnerEnrolledEventEvent$outboundSchema: z.ZodNativeEnum< typeof PartnerEnrolledEventEvent > = PartnerEnrolledEventEvent$inboundSchema; /** @internal */ export const DefaultPayoutMethod$inboundSchema: z.ZodNativeEnum< typeof DefaultPayoutMethod > = z.nativeEnum(DefaultPayoutMethod); /** @internal */ export const DefaultPayoutMethod$outboundSchema: z.ZodNativeEnum< typeof DefaultPayoutMethod > = DefaultPayoutMethod$inboundSchema; /** @internal */ export const Status$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Status); /** @internal */ export const Status$outboundSchema: z.ZodNativeEnum = Status$inboundSchema; /** @internal */ export const Links$inboundSchema: z.ZodType = z .object({ id: z.string(), domain: z.string(), key: z.string(), shortLink: z.string(), url: z.string(), clicks: z.number().default(0), leads: z.number().default(0), conversions: z.number().default(0), sales: z.number().default(0), saleAmount: z.number().default(0), }); /** @internal */ export type Links$Outbound = { id: string; domain: string; key: string; shortLink: string; url: string; clicks: number; leads: number; conversions: number; sales: number; saleAmount: number; }; /** @internal */ export const Links$outboundSchema: z.ZodType< Links$Outbound, z.ZodTypeDef, Links > = z.object({ id: z.string(), domain: z.string(), key: z.string(), shortLink: z.string(), url: z.string(), clicks: z.number().default(0), leads: z.number().default(0), conversions: z.number().default(0), sales: z.number().default(0), saleAmount: z.number().default(0), }); export function linksToJSON(links: Links): string { return JSON.stringify(Links$outboundSchema.parse(links)); } export function linksFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Links$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Links' from JSON`, ); } /** @internal */ export const BannedReason$inboundSchema: z.ZodNativeEnum = z.nativeEnum(BannedReason); /** @internal */ export const BannedReason$outboundSchema: z.ZodNativeEnum = BannedReason$inboundSchema; /** @internal */ export const PartnerEnrolledEventFieldsDataReferralFormData8Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum(PartnerEnrolledEventFieldsDataReferralFormData8Type); /** @internal */ export const PartnerEnrolledEventFieldsDataReferralFormData8Type$outboundSchema: z.ZodNativeEnum = PartnerEnrolledEventFieldsDataReferralFormData8Type$inboundSchema; /** @internal */ export const Eight$inboundSchema: z.ZodType = z .object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsDataReferralFormData8Type$inboundSchema, }); /** @internal */ export type Eight$Outbound = { key: string; label: string; required: boolean; locked: boolean; position: number; type: string; }; /** @internal */ export const Eight$outboundSchema: z.ZodType< Eight$Outbound, z.ZodTypeDef, Eight > = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsDataReferralFormData8Type$outboundSchema, }); export function eightToJSON(eight: Eight): string { return JSON.stringify(Eight$outboundSchema.parse(eight)); } export function eightFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Eight$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Eight' from JSON`, ); } /** @internal */ export const PartnerEnrolledEventFieldsDataReferralFormData7Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum(PartnerEnrolledEventFieldsDataReferralFormData7Type); /** @internal */ export const PartnerEnrolledEventFieldsDataReferralFormData7Type$outboundSchema: z.ZodNativeEnum = PartnerEnrolledEventFieldsDataReferralFormData7Type$inboundSchema; /** @internal */ export const Seven$inboundSchema: z.ZodType = z .object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsDataReferralFormData7Type$inboundSchema, }); /** @internal */ export type Seven$Outbound = { key: string; label: string; required: boolean; locked: boolean; position: number; type: string; }; /** @internal */ export const Seven$outboundSchema: z.ZodType< Seven$Outbound, z.ZodTypeDef, Seven > = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsDataReferralFormData7Type$outboundSchema, }); export function sevenToJSON(seven: Seven): string { return JSON.stringify(Seven$outboundSchema.parse(seven)); } export function sevenFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Seven$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Seven' from JSON`, ); } /** @internal */ export const PartnerEnrolledEventFieldsDataReferralFormData6Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum(PartnerEnrolledEventFieldsDataReferralFormData6Type); /** @internal */ export const PartnerEnrolledEventFieldsDataReferralFormData6Type$outboundSchema: z.ZodNativeEnum = PartnerEnrolledEventFieldsDataReferralFormData6Type$inboundSchema; /** @internal */ export const FieldsOptions$inboundSchema: z.ZodType< FieldsOptions, z.ZodTypeDef, unknown > = z.object({ label: z.string(), value: z.string(), }); /** @internal */ export type FieldsOptions$Outbound = { label: string; value: string; }; /** @internal */ export const FieldsOptions$outboundSchema: z.ZodType< FieldsOptions$Outbound, z.ZodTypeDef, FieldsOptions > = z.object({ label: z.string(), value: z.string(), }); export function fieldsOptionsToJSON(fieldsOptions: FieldsOptions): string { return JSON.stringify(FieldsOptions$outboundSchema.parse(fieldsOptions)); } export function fieldsOptionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FieldsOptions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FieldsOptions' from JSON`, ); } /** @internal */ export const Six$inboundSchema: z.ZodType = z .object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsDataReferralFormData6Type$inboundSchema, options: z.array(z.lazy(() => FieldsOptions$inboundSchema)), }); /** @internal */ export type Six$Outbound = { key: string; label: string; required: boolean; locked: boolean; position: number; type: string; options: Array; }; /** @internal */ export const Six$outboundSchema: z.ZodType = z .object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsDataReferralFormData6Type$outboundSchema, options: z.array(z.lazy(() => FieldsOptions$outboundSchema)), }); export function sixToJSON(six: Six): string { return JSON.stringify(Six$outboundSchema.parse(six)); } export function sixFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Six$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Six' from JSON`, ); } /** @internal */ export const PartnerEnrolledEventFieldsDataReferralFormData5Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum(PartnerEnrolledEventFieldsDataReferralFormData5Type); /** @internal */ export const PartnerEnrolledEventFieldsDataReferralFormData5Type$outboundSchema: z.ZodNativeEnum = PartnerEnrolledEventFieldsDataReferralFormData5Type$inboundSchema; /** @internal */ export const Five$inboundSchema: z.ZodType = z .object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsDataReferralFormData5Type$inboundSchema, }); /** @internal */ export type Five$Outbound = { key: string; label: string; required: boolean; locked: boolean; position: number; type: string; }; /** @internal */ export const Five$outboundSchema: z.ZodType = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsDataReferralFormData5Type$outboundSchema, }); export function fiveToJSON(five: Five): string { return JSON.stringify(Five$outboundSchema.parse(five)); } export function fiveFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Five$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Five' from JSON`, ); } /** @internal */ export const PartnerEnrolledEventFieldsDataReferralFormDataType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(PartnerEnrolledEventFieldsDataReferralFormDataType); /** @internal */ export const PartnerEnrolledEventFieldsDataReferralFormDataType$outboundSchema: z.ZodNativeEnum = PartnerEnrolledEventFieldsDataReferralFormDataType$inboundSchema; /** @internal */ export const Four$inboundSchema: z.ZodType = z .object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsDataReferralFormDataType$inboundSchema, }); /** @internal */ export type Four$Outbound = { key: string; label: string; required: boolean; locked: boolean; position: number; type: string; }; /** @internal */ export const Four$outboundSchema: z.ZodType = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsDataReferralFormDataType$outboundSchema, }); export function fourToJSON(four: Four): string { return JSON.stringify(Four$outboundSchema.parse(four)); } export function fourFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Four$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Four' from JSON`, ); } /** @internal */ export const PartnerEnrolledEventFieldsDataType$inboundSchema: z.ZodNativeEnum< typeof PartnerEnrolledEventFieldsDataType > = z.nativeEnum(PartnerEnrolledEventFieldsDataType); /** @internal */ export const PartnerEnrolledEventFieldsDataType$outboundSchema: z.ZodNativeEnum< typeof PartnerEnrolledEventFieldsDataType > = PartnerEnrolledEventFieldsDataType$inboundSchema; /** @internal */ export const Options$inboundSchema: z.ZodType = z.object({ label: z.string(), value: z.string(), }); /** @internal */ export type Options$Outbound = { label: string; value: string; }; /** @internal */ export const Options$outboundSchema: z.ZodType< Options$Outbound, z.ZodTypeDef, Options > = z.object({ label: z.string(), value: z.string(), }); export function optionsToJSON(options: Options): string { return JSON.stringify(Options$outboundSchema.parse(options)); } export function optionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Options$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Options' from JSON`, ); } /** @internal */ export const Fields3$inboundSchema: z.ZodType = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsDataType$inboundSchema, options: z.array(z.lazy(() => Options$inboundSchema)), }); /** @internal */ export type Fields3$Outbound = { key: string; label: string; required: boolean; locked: boolean; position: number; type: string; options: Array; }; /** @internal */ export const Fields3$outboundSchema: z.ZodType< Fields3$Outbound, z.ZodTypeDef, Fields3 > = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsDataType$outboundSchema, options: z.array(z.lazy(() => Options$outboundSchema)), }); export function fields3ToJSON(fields3: Fields3): string { return JSON.stringify(Fields3$outboundSchema.parse(fields3)); } export function fields3FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields3$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields3' from JSON`, ); } /** @internal */ export const PartnerEnrolledEventFieldsType$inboundSchema: z.ZodNativeEnum< typeof PartnerEnrolledEventFieldsType > = z.nativeEnum(PartnerEnrolledEventFieldsType); /** @internal */ export const PartnerEnrolledEventFieldsType$outboundSchema: z.ZodNativeEnum< typeof PartnerEnrolledEventFieldsType > = PartnerEnrolledEventFieldsType$inboundSchema; /** @internal */ export const FieldsConstraints$inboundSchema: z.ZodType< FieldsConstraints, z.ZodTypeDef, unknown > = z.object({ maxLength: z.number().int().optional(), }); /** @internal */ export type FieldsConstraints$Outbound = { maxLength?: number | undefined; }; /** @internal */ export const FieldsConstraints$outboundSchema: z.ZodType< FieldsConstraints$Outbound, z.ZodTypeDef, FieldsConstraints > = z.object({ maxLength: z.number().int().optional(), }); export function fieldsConstraintsToJSON( fieldsConstraints: FieldsConstraints, ): string { return JSON.stringify( FieldsConstraints$outboundSchema.parse(fieldsConstraints), ); } export function fieldsConstraintsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FieldsConstraints$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FieldsConstraints' from JSON`, ); } /** @internal */ export const Fields2$inboundSchema: z.ZodType = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsType$inboundSchema, constraints: z.lazy(() => FieldsConstraints$inboundSchema).optional(), }); /** @internal */ export type Fields2$Outbound = { key: string; label: string; required: boolean; locked: boolean; position: number; type: string; constraints?: FieldsConstraints$Outbound | undefined; }; /** @internal */ export const Fields2$outboundSchema: z.ZodType< Fields2$Outbound, z.ZodTypeDef, Fields2 > = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: PartnerEnrolledEventFieldsType$outboundSchema, constraints: z.lazy(() => FieldsConstraints$outboundSchema).optional(), }); export function fields2ToJSON(fields2: Fields2): string { return JSON.stringify(Fields2$outboundSchema.parse(fields2)); } export function fields2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields2' from JSON`, ); } /** @internal */ export const FieldsType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(FieldsType); /** @internal */ export const FieldsType$outboundSchema: z.ZodNativeEnum = FieldsType$inboundSchema; /** @internal */ export const Constraints$inboundSchema: z.ZodType< Constraints, z.ZodTypeDef, unknown > = z.object({ maxLength: z.number().int().optional(), pattern: z.string().optional(), }); /** @internal */ export type Constraints$Outbound = { maxLength?: number | undefined; pattern?: string | undefined; }; /** @internal */ export const Constraints$outboundSchema: z.ZodType< Constraints$Outbound, z.ZodTypeDef, Constraints > = z.object({ maxLength: z.number().int().optional(), pattern: z.string().optional(), }); export function constraintsToJSON(constraints: Constraints): string { return JSON.stringify(Constraints$outboundSchema.parse(constraints)); } export function constraintsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Constraints$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Constraints' from JSON`, ); } /** @internal */ export const Fields1$inboundSchema: z.ZodType = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: FieldsType$inboundSchema, constraints: z.lazy(() => Constraints$inboundSchema).optional(), }); /** @internal */ export type Fields1$Outbound = { key: string; label: string; required: boolean; locked: boolean; position: number; type: string; constraints?: Constraints$Outbound | undefined; }; /** @internal */ export const Fields1$outboundSchema: z.ZodType< Fields1$Outbound, z.ZodTypeDef, Fields1 > = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: FieldsType$outboundSchema, constraints: z.lazy(() => Constraints$outboundSchema).optional(), }); export function fields1ToJSON(fields1: Fields1): string { return JSON.stringify(Fields1$outboundSchema.parse(fields1)); } export function fields1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields1' from JSON`, ); } /** @internal */ export const Fields$inboundSchema: z.ZodType = z .union([ z.lazy(() => Fields1$inboundSchema).and( z.object({ type: z.literal("text") }), ), z.lazy(() => Fields2$inboundSchema).and( z.object({ type: z.literal("textarea") }), ), z.lazy(() => Fields3$inboundSchema).and( z.object({ type: z.literal("select") }), ), z.lazy(() => Four$inboundSchema).and( z.object({ type: z.literal("country") }), ), z.lazy(() => Five$inboundSchema).and(z.object({ type: z.literal("date") })), z.lazy(() => Six$inboundSchema).and( z.object({ type: z.literal("multiSelect") }), ), z.lazy(() => Seven$inboundSchema).and( z.object({ type: z.literal("number") }), ), z.lazy(() => Eight$inboundSchema).and( z.object({ type: z.literal("phone") }), ), ]); /** @internal */ export type Fields$Outbound = | (Fields1$Outbound & { type: "text" }) | (Fields2$Outbound & { type: "textarea" }) | (Fields3$Outbound & { type: "select" }) | (Four$Outbound & { type: "country" }) | (Five$Outbound & { type: "date" }) | (Six$Outbound & { type: "multiSelect" }) | (Seven$Outbound & { type: "number" }) | (Eight$Outbound & { type: "phone" }); /** @internal */ export const Fields$outboundSchema: z.ZodType< Fields$Outbound, z.ZodTypeDef, Fields > = z.union([ z.lazy(() => Fields1$outboundSchema).and( z.object({ type: z.literal("text") }), ), z.lazy(() => Fields2$outboundSchema).and( z.object({ type: z.literal("textarea") }), ), z.lazy(() => Fields3$outboundSchema).and( z.object({ type: z.literal("select") }), ), z.lazy(() => Four$outboundSchema).and( z.object({ type: z.literal("country") }), ), z.lazy(() => Five$outboundSchema).and(z.object({ type: z.literal("date") })), z.lazy(() => Six$outboundSchema).and( z.object({ type: z.literal("multiSelect") }), ), z.lazy(() => Seven$outboundSchema).and( z.object({ type: z.literal("number") }), ), z.lazy(() => Eight$outboundSchema).and( z.object({ type: z.literal("phone") }), ), ]); export function fieldsToJSON(fields: Fields): string { return JSON.stringify(Fields$outboundSchema.parse(fields)); } export function fieldsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields' from JSON`, ); } /** @internal */ export const ReferralFormData$inboundSchema: z.ZodType< ReferralFormData, z.ZodTypeDef, unknown > = z.object({ fields: z.array( z.union([ z.lazy(() => Fields1$inboundSchema).and( z.object({ type: z.literal("text") }), ), z.lazy(() => Fields2$inboundSchema).and( z.object({ type: z.literal("textarea") }), ), z.lazy(() => Fields3$inboundSchema).and( z.object({ type: z.literal("select") }), ), z.lazy(() => Four$inboundSchema).and( z.object({ type: z.literal("country") }), ), z.lazy(() => Five$inboundSchema).and( z.object({ type: z.literal("date") }), ), z.lazy(() => Six$inboundSchema).and( z.object({ type: z.literal("multiSelect") }), ), z.lazy(() => Seven$inboundSchema).and( z.object({ type: z.literal("number") }), ), z.lazy(() => Eight$inboundSchema).and( z.object({ type: z.literal("phone") }), ), ]), ), }); /** @internal */ export type ReferralFormData$Outbound = { fields: Array< | (Fields1$Outbound & { type: "text" }) | (Fields2$Outbound & { type: "textarea" }) | (Fields3$Outbound & { type: "select" }) | (Four$Outbound & { type: "country" }) | (Five$Outbound & { type: "date" }) | (Six$Outbound & { type: "multiSelect" }) | (Seven$Outbound & { type: "number" }) | (Eight$Outbound & { type: "phone" }) >; }; /** @internal */ export const ReferralFormData$outboundSchema: z.ZodType< ReferralFormData$Outbound, z.ZodTypeDef, ReferralFormData > = z.object({ fields: z.array( z.union([ z.lazy(() => Fields1$outboundSchema).and( z.object({ type: z.literal("text") }), ), z.lazy(() => Fields2$outboundSchema).and( z.object({ type: z.literal("textarea") }), ), z.lazy(() => Fields3$outboundSchema).and( z.object({ type: z.literal("select") }), ), z.lazy(() => Four$outboundSchema).and( z.object({ type: z.literal("country") }), ), z.lazy(() => Five$outboundSchema).and( z.object({ type: z.literal("date") }), ), z.lazy(() => Six$outboundSchema).and( z.object({ type: z.literal("multiSelect") }), ), z.lazy(() => Seven$outboundSchema).and( z.object({ type: z.literal("number") }), ), z.lazy(() => Eight$outboundSchema).and( z.object({ type: z.literal("phone") }), ), ]), ), }); export function referralFormDataToJSON( referralFormData: ReferralFormData, ): string { return JSON.stringify( ReferralFormData$outboundSchema.parse(referralFormData), ); } export function referralFormDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ReferralFormData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ReferralFormData' from JSON`, ); } /** @internal */ export const RejectionReason$inboundSchema: z.ZodNativeEnum< typeof RejectionReason > = z.nativeEnum(RejectionReason); /** @internal */ export const RejectionReason$outboundSchema: z.ZodNativeEnum< typeof RejectionReason > = RejectionReason$inboundSchema; /** @internal */ export const Application$inboundSchema: z.ZodType< Application, z.ZodTypeDef, unknown > = z.object({ rejectionReason: z.nullable(RejectionReason$inboundSchema), rejectionNote: z.nullable(z.string()), reviewedAt: z.nullable(z.string()), }); /** @internal */ export type Application$Outbound = { rejectionReason: string | null; rejectionNote: string | null; reviewedAt: string | null; }; /** @internal */ export const Application$outboundSchema: z.ZodType< Application$Outbound, z.ZodTypeDef, Application > = z.object({ rejectionReason: z.nullable(RejectionReason$outboundSchema), rejectionNote: z.nullable(z.string()), reviewedAt: z.nullable(z.string()), }); export function applicationToJSON(application: Application): string { return JSON.stringify(Application$outboundSchema.parse(application)); } export function applicationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Application$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Application' from JSON`, ); } /** @internal */ export const PartnerEnrolledEventData$inboundSchema: z.ZodType< PartnerEnrolledEventData, z.ZodTypeDef, unknown > = z.object({ id: z.string(), name: z.string(), companyName: z.nullable(z.string()), email: z.nullable(z.string()), image: z.nullable(z.string()), description: z.nullable(z.string()).optional(), country: z.nullable(z.string()), defaultPayoutMethod: z.nullable(DefaultPayoutMethod$inboundSchema), paypalEmail: z.nullable(z.string()), stripeConnectId: z.nullable(z.string()), payoutsEnabledAt: z.nullable(z.string()), trustedAt: z.nullable(z.string()), programId: z.string(), groupId: z.nullable(z.string()).optional(), partnerId: z.string(), tenantId: z.nullable(z.string()), createdAt: z.string(), status: Status$inboundSchema, links: z.nullable(z.array(z.lazy(() => Links$inboundSchema))), totalCommissions: z.number().default(0), clickRewardId: z.nullable(z.string()).optional(), leadRewardId: z.nullable(z.string()).optional(), saleRewardId: z.nullable(z.string()).optional(), discountId: z.nullable(z.string()).optional(), applicationId: z.nullable(z.string()).optional(), bannedAt: z.nullable(z.string()).optional(), bannedReason: z.nullable(BannedReason$inboundSchema).optional(), referralFormData: z.nullable(z.lazy(() => ReferralFormData$inboundSchema)) .optional(), application: z.nullable(z.lazy(() => Application$inboundSchema)).optional(), totalClicks: z.number().default(0), totalLeads: z.number().default(0), totalConversions: z.number().default(0), totalSales: z.number().default(0), totalSaleAmount: z.number().default(0), netRevenue: z.number().default(0), earningsPerClick: z.nullable(z.number()).optional(), averageLifetimeValue: z.nullable(z.number()).optional(), clickToLeadRate: z.nullable(z.number()).optional(), clickToConversionRate: z.nullable(z.number()).optional(), leadToConversionRate: z.nullable(z.number()).optional(), returnOnAdSpend: z.nullable(z.number()).optional(), website: z.nullable(z.string()).optional(), youtube: z.nullable(z.string()).optional(), twitter: z.nullable(z.string()).optional(), linkedin: z.nullable(z.string()).optional(), instagram: z.nullable(z.string()).optional(), tiktok: z.nullable(z.string()).optional(), }); /** @internal */ export type PartnerEnrolledEventData$Outbound = { id: string; name: string; companyName: string | null; email: string | null; image: string | null; description?: string | null | undefined; country: string | null; defaultPayoutMethod: string | null; paypalEmail: string | null; stripeConnectId: string | null; payoutsEnabledAt: string | null; trustedAt: string | null; programId: string; groupId?: string | null | undefined; partnerId: string; tenantId: string | null; createdAt: string; status: string; links: Array | null; totalCommissions: number; clickRewardId?: string | null | undefined; leadRewardId?: string | null | undefined; saleRewardId?: string | null | undefined; discountId?: string | null | undefined; applicationId?: string | null | undefined; bannedAt?: string | null | undefined; bannedReason?: string | null | undefined; referralFormData?: ReferralFormData$Outbound | null | undefined; application?: Application$Outbound | null | undefined; totalClicks: number; totalLeads: number; totalConversions: number; totalSales: number; totalSaleAmount: number; netRevenue: number; earningsPerClick?: number | null | undefined; averageLifetimeValue?: number | null | undefined; clickToLeadRate?: number | null | undefined; clickToConversionRate?: number | null | undefined; leadToConversionRate?: number | null | undefined; returnOnAdSpend?: number | null | undefined; website?: string | null | undefined; youtube?: string | null | undefined; twitter?: string | null | undefined; linkedin?: string | null | undefined; instagram?: string | null | undefined; tiktok?: string | null | undefined; }; /** @internal */ export const PartnerEnrolledEventData$outboundSchema: z.ZodType< PartnerEnrolledEventData$Outbound, z.ZodTypeDef, PartnerEnrolledEventData > = z.object({ id: z.string(), name: z.string(), companyName: z.nullable(z.string()), email: z.nullable(z.string()), image: z.nullable(z.string()), description: z.nullable(z.string()).optional(), country: z.nullable(z.string()), defaultPayoutMethod: z.nullable(DefaultPayoutMethod$outboundSchema), paypalEmail: z.nullable(z.string()), stripeConnectId: z.nullable(z.string()), payoutsEnabledAt: z.nullable(z.string()), trustedAt: z.nullable(z.string()), programId: z.string(), groupId: z.nullable(z.string()).optional(), partnerId: z.string(), tenantId: z.nullable(z.string()), createdAt: z.string(), status: Status$outboundSchema, links: z.nullable(z.array(z.lazy(() => Links$outboundSchema))), totalCommissions: z.number().default(0), clickRewardId: z.nullable(z.string()).optional(), leadRewardId: z.nullable(z.string()).optional(), saleRewardId: z.nullable(z.string()).optional(), discountId: z.nullable(z.string()).optional(), applicationId: z.nullable(z.string()).optional(), bannedAt: z.nullable(z.string()).optional(), bannedReason: z.nullable(BannedReason$outboundSchema).optional(), referralFormData: z.nullable(z.lazy(() => ReferralFormData$outboundSchema)) .optional(), application: z.nullable(z.lazy(() => Application$outboundSchema)).optional(), totalClicks: z.number().default(0), totalLeads: z.number().default(0), totalConversions: z.number().default(0), totalSales: z.number().default(0), totalSaleAmount: z.number().default(0), netRevenue: z.number().default(0), earningsPerClick: z.nullable(z.number()).optional(), averageLifetimeValue: z.nullable(z.number()).optional(), clickToLeadRate: z.nullable(z.number()).optional(), clickToConversionRate: z.nullable(z.number()).optional(), leadToConversionRate: z.nullable(z.number()).optional(), returnOnAdSpend: z.nullable(z.number()).optional(), website: z.nullable(z.string()).optional(), youtube: z.nullable(z.string()).optional(), twitter: z.nullable(z.string()).optional(), linkedin: z.nullable(z.string()).optional(), instagram: z.nullable(z.string()).optional(), tiktok: z.nullable(z.string()).optional(), }); export function partnerEnrolledEventDataToJSON( partnerEnrolledEventData: PartnerEnrolledEventData, ): string { return JSON.stringify( PartnerEnrolledEventData$outboundSchema.parse(partnerEnrolledEventData), ); } export function partnerEnrolledEventDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PartnerEnrolledEventData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PartnerEnrolledEventData' from JSON`, ); } /** @internal */ export const PartnerEnrolledEvent$inboundSchema: z.ZodType< PartnerEnrolledEvent, z.ZodTypeDef, unknown > = z.object({ id: z.string(), event: PartnerEnrolledEventEvent$inboundSchema, createdAt: z.string(), data: z.lazy(() => PartnerEnrolledEventData$inboundSchema), }); /** @internal */ export type PartnerEnrolledEvent$Outbound = { id: string; event: string; createdAt: string; data: PartnerEnrolledEventData$Outbound; }; /** @internal */ export const PartnerEnrolledEvent$outboundSchema: z.ZodType< PartnerEnrolledEvent$Outbound, z.ZodTypeDef, PartnerEnrolledEvent > = z.object({ id: z.string(), event: PartnerEnrolledEventEvent$outboundSchema, createdAt: z.string(), data: z.lazy(() => PartnerEnrolledEventData$outboundSchema), }); export function partnerEnrolledEventToJSON( partnerEnrolledEvent: PartnerEnrolledEvent, ): string { return JSON.stringify( PartnerEnrolledEvent$outboundSchema.parse(partnerEnrolledEvent), ); } export function partnerEnrolledEventFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PartnerEnrolledEvent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PartnerEnrolledEvent' from JSON`, ); }