The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Merge branch 'customers' into payouts
Steven Tey0837c43af101
diff --cc apps/web/lib/types.tsindex 60ee88b5df,94fcec6338..88b77afbad--- a/apps/web/lib/types.ts+++ b/apps/web/lib/types.ts@@@ -1,17 -1,12 +1,20 @@@import z from "@/lib/zod";import { metaTagsSchema } from "@/lib/zod/schemas/metatags";import { DirectorySyncProviders } from "@boxyhq/saml-jackson";-import { Link, Project, UtmTemplate, Webhook } from "@prisma/client";+import {+ Link,+ PayoutStatus,+ ProgramEnrollmentStatus,+ Project,+ SaleStatus,+ UtmTemplate,+ Webhook,+} from "@prisma/client";import { WEBHOOK_TRIGGER_DESCRIPTIONS } from "./webhook/constants";- import { trackCustomerResponseSchema } from "./zod/schemas/customers";+ import {+ CustomerSchema,+ trackCustomerResponseSchema,+ } from "./zod/schemas/customers";import { integrationSchema } from "./zod/schemas/integration";import { trackLeadResponseSchema } from "./zod/schemas/leads";import { createLinkBodySchema } from "./zod/schemas/links";@@@ -295,17 -278,11 +298,19 @@@ export type TrackLeadResponse = z.inferexport type TrackSaleResponse = z.infer<typeof trackSaleResponseSchema>;+ export type Customer = z.infer<typeof CustomerSchema>;+export type UsageResponse = z.infer<typeof usageResponse>;+export type PartnersCount = Record<ProgramEnrollmentStatus | "all", number>;++export type SaleProps = z.infer<typeof SaleSchema>;+export type SalesCount = Record<SaleStatus | "all", number>;++export type CustomerProps = z.infer<typeof CustomerSchema>;+export type PartnerProps = z.infer<typeof PartnerSchema>;+export type EnrolledPartnerProps = z.infer<typeof EnrolledPartnerSchema>;export type ProgramProps = z.infer<typeof ProgramSchema>;diff --cc apps/web/lib/zod/schemas/customers.tsindex da448d88de,1fd1087705..fac692cf5b--- a/apps/web/lib/zod/schemas/customers.ts+++ b/apps/web/lib/zod/schemas/customers.ts@@@ -1,6 -1,41 +1,42 @@@import z from "@/lib/zod";+import { getPaginationQuerySchema } from "./misc";+ export const createCustomerBodySchema = z.object({+ externalId: z+ .string()+ .describe("Unique identifier for the customer in the client's app."),+ email: z+ .string()+ .email()+ .nullish()+ .describe("Email of the customer in the client's app."),+ name: z+ .string()+ .nullish()+ .describe(+ "Name of the customer in the client's app. If not provided, a random name will be generated.",+ ),+ avatar: z+ .string()+ .url()+ .nullish()+ .describe("Avatar URL of the customer in the client's app."),+ });++ export const updateCustomerBodySchema = createCustomerBodySchema.partial();++ // customer object schema+ export const CustomerSchema = z.object({+ id: z.string().describe("The unique identifier of the customer in Dub."),+ externalId: z+ .string()+ .describe("Unique identifier for the customer in the client's app."),+ name: z.string().describe("Name of the customer."),+ email: z.string().nullish().describe("Email of the customer."),+ avatar: z.string().nullish().describe("Avatar URL of the customer."),+ createdAt: z.date().describe("The date the customer was created."),+ });+export const trackCustomerRequestSchema = z.object({// RequiredcustomerId: z@@@ -37,24 -72,3 +73,25 @@@ export const trackCustomerResponseSchemcustomerEmail: z.string().nullable(),customerAvatar: z.string().nullable(),});++// simple schema returned by /events API+export const customerSchema = z.object({+ id: z.string(),+ name: z.string(),+ email: z.string(),+ avatar: z.string(),++ externalId: z.string().optional(),+});++export const CUSTOMERS_MAX_PAGE_SIZE = 100;++export const customersQuerySchema = z+ .object({+ search: z.string().optional(),+ ids: z+ .union([z.string(), z.array(z.string())])+ .transform((v) => (Array.isArray(v) ? v : v.split(",")))+ .optional()+ .describe("IDs of customers to filter by."),+ })+ .merge(getPaginationQuerySchema({ pageSize: CUSTOMERS_MAX_PAGE_SIZE }));