import {z} from 'zod' export type SearchTextContactFilter = {included?: Array | undefined, excluded?: Array | undefined}; export type SearchSeniorityContactFilter = {included?: ('Owner' | 'Partner' | 'Chief Officer' | 'VP' | 'Director' | 'Senior' | 'Manager' | 'Intern' | 'Unpaid') | undefined, excluded?: ('Owner' | 'Partner' | 'Chief Officer' | 'VP' | 'Director' | 'Senior' | 'Manager' | 'Intern' | 'Unpaid') | undefined}; export type SearchIndustryContactFilter = {included?: (Array<'Defense & Space' | 'Computer Networking' | 'Internet' | 'Computer Hardware' | 'Computer Software' | 'Law Practice' | 'Legal Services' | 'Management Consulting' | 'Biotechnology' | 'Medical Practice' | 'Hospital & Health Care' | 'Semiconductors' | 'Telecommunications' | 'Medical Devices' | 'Cosmetics' | 'Apparel & Fashion' | 'Sporting Goods' | 'Tobacco' | 'Supermarkets' | 'Food Production' | 'Consumer Electronics' | 'Consumer Goods' | 'Furniture' | 'Retail' | 'Entertainment' | 'Gambling & Casinos' | 'Pharmaceuticals' | 'Veterinary' | 'Restaurants' | 'Sports' | 'Food & Beverages' | 'Motion Pictures and Film' | 'Broadcast Media' | 'Museums and Institutions' | 'Fine Art' | 'Performing Arts' | 'Recreational Facilities and Services' | 'Banking' | 'Insurance' | 'Financial Services' | 'Real Estate' | 'Investment Banking' | 'Investment Management' | 'Accounting' | 'Construction' | 'Building Materials' | 'Architecture & Planning' | 'Leisure, Travel & Tourism' | 'Hospitality' | 'Automotive' | 'Chemicals' | 'Machinery' | 'Oil & Energy' | 'Shipbuilding' | 'Mining & Metals' | 'Utilities' | 'Textiles' | 'Paper & Forest Products' | 'Railroad Manufacture' | 'Farming' | 'Ranching' | 'Fishery' | 'Dairy' | 'Primary/Secondary Education' | 'Higher Education' | 'Education Management' | 'Research' | 'Military' | 'Legislative Office' | 'Judiciary' | 'Civil Engineering' | 'Aviation & Aerospace' | 'Law Enforcement' | 'Public Safety' | 'Executive Office' | 'Public Policy' | 'Marketing and Advertising' | 'Newspapers' | 'Publishing' | 'Printing' | 'Information Services' | 'Libraries' | 'Environmental Services' | 'Package/Freight Delivery' | 'Individual & Family Services' | 'Religious Institutions' | 'Civic & Social Organization' | 'Consumer Services' | 'Transportation/Trucking/Railroad' | 'Warehousing' | 'Airlines/Aviation' | 'Maritime' | 'Information Technology and Services' | 'Market Research' | 'Public Relations and Communications' | 'Design' | 'Nonprofit Organization Management' | 'Fund-Raising' | 'Writing and Editing' | 'Program Development' | 'Staffing and Recruiting' | 'Professional Training & Coaching' | 'International Affairs' | 'Government Administration' | 'Translation and Localization' | 'Computer Games' | 'Events Services' | 'Arts and Crafts' | 'Electrical/Electronic Manufacturing' | 'Nanotechnology' | 'Online Media' | 'Logistics and Supply Chain' | 'Music' | 'Plastics' | 'Computer & Network Security' | 'Wireless' | 'Alternative Dispute Resolution' | 'Security and Investigations' | 'Facilities Services' | 'Outsourcing/Offshoring' | 'Health, Wellness and Fitness' | 'Alternative Medicine' | 'Animation' | 'Media Production' | 'Commercial Real Estate' | 'Capital Markets' | 'Philanthropy' | 'Think Tanks' | 'E-Learning' | 'Wholesale' | 'Import and Export' | 'Mechanical or Industrial Engineering' | 'Photography' | 'Human Resources' | 'Business Supplies and Equipment' | 'Mental Health Care' | 'Graphic Design' | 'International Trade and Development' | 'Wine and Spirits' | 'Luxury Goods & Jewelry' | 'Renewables & Environment' | 'Political Organization' | 'Venture Capital & Private Equity' | 'Government Relations' | 'Industrial Automation' | 'Horticulture' | 'Mobile Games' | 'Packaging and Containers' | 'Glass, Ceramics & Concrete'>) | undefined, excluded?: (Array<'Defense & Space' | 'Computer Networking' | 'Internet' | 'Computer Hardware' | 'Computer Software' | 'Law Practice' | 'Legal Services' | 'Management Consulting' | 'Biotechnology' | 'Medical Practice' | 'Hospital & Health Care' | 'Semiconductors' | 'Telecommunications' | 'Medical Devices' | 'Cosmetics' | 'Apparel & Fashion' | 'Sporting Goods' | 'Tobacco' | 'Supermarkets' | 'Food Production' | 'Consumer Electronics' | 'Consumer Goods' | 'Furniture' | 'Retail' | 'Entertainment' | 'Gambling & Casinos' | 'Pharmaceuticals' | 'Veterinary' | 'Restaurants' | 'Sports' | 'Food & Beverages' | 'Motion Pictures and Film' | 'Broadcast Media' | 'Museums and Institutions' | 'Fine Art' | 'Performing Arts' | 'Recreational Facilities and Services' | 'Banking' | 'Insurance' | 'Financial Services' | 'Real Estate' | 'Investment Banking' | 'Investment Management' | 'Accounting' | 'Construction' | 'Building Materials' | 'Architecture & Planning' | 'Leisure, Travel & Tourism' | 'Hospitality' | 'Automotive' | 'Chemicals' | 'Machinery' | 'Oil & Energy' | 'Shipbuilding' | 'Mining & Metals' | 'Utilities' | 'Textiles' | 'Paper & Forest Products' | 'Railroad Manufacture' | 'Farming' | 'Ranching' | 'Fishery' | 'Dairy' | 'Primary/Secondary Education' | 'Higher Education' | 'Education Management' | 'Research' | 'Military' | 'Legislative Office' | 'Judiciary' | 'Civil Engineering' | 'Aviation & Aerospace' | 'Law Enforcement' | 'Public Safety' | 'Executive Office' | 'Public Policy' | 'Marketing and Advertising' | 'Newspapers' | 'Publishing' | 'Printing' | 'Information Services' | 'Libraries' | 'Environmental Services' | 'Package/Freight Delivery' | 'Individual & Family Services' | 'Religious Institutions' | 'Civic & Social Organization' | 'Consumer Services' | 'Transportation/Trucking/Railroad' | 'Warehousing' | 'Airlines/Aviation' | 'Maritime' | 'Information Technology and Services' | 'Market Research' | 'Public Relations and Communications' | 'Design' | 'Nonprofit Organization Management' | 'Fund-Raising' | 'Writing and Editing' | 'Program Development' | 'Staffing and Recruiting' | 'Professional Training & Coaching' | 'International Affairs' | 'Government Administration' | 'Translation and Localization' | 'Computer Games' | 'Events Services' | 'Arts and Crafts' | 'Electrical/Electronic Manufacturing' | 'Nanotechnology' | 'Online Media' | 'Logistics and Supply Chain' | 'Music' | 'Plastics' | 'Computer & Network Security' | 'Wireless' | 'Alternative Dispute Resolution' | 'Security and Investigations' | 'Facilities Services' | 'Outsourcing/Offshoring' | 'Health, Wellness and Fitness' | 'Alternative Medicine' | 'Animation' | 'Media Production' | 'Commercial Real Estate' | 'Capital Markets' | 'Philanthropy' | 'Think Tanks' | 'E-Learning' | 'Wholesale' | 'Import and Export' | 'Mechanical or Industrial Engineering' | 'Photography' | 'Human Resources' | 'Business Supplies and Equipment' | 'Mental Health Care' | 'Graphic Design' | 'International Trade and Development' | 'Wine and Spirits' | 'Luxury Goods & Jewelry' | 'Renewables & Environment' | 'Political Organization' | 'Venture Capital & Private Equity' | 'Government Relations' | 'Industrial Automation' | 'Horticulture' | 'Mobile Games' | 'Packaging and Containers' | 'Glass, Ceramics & Concrete'>) | undefined}; export type SearchCountContactFilter = {included?: ('1 - 10' | '11 - 20' | '21 - 50' | '51 - 100' | '101 - 200' | '201 - 500' | '501 - 1000' | '1001 - 2000' | '2001 - 5000' | '5001 - 10000' | '10000') | undefined}; export type InsightSearchContactsDto = {contactName?: SearchTextContactFilter | undefined, companyName?: SearchTextContactFilter | undefined, jobTitle?: SearchTextContactFilter | undefined, seniority?: SearchSeniorityContactFilter | undefined, domain?: SearchTextContactFilter | undefined, industry?: SearchIndustryContactFilter | undefined, location?: SearchTextContactFilter | undefined, keywords?: SearchTextContactFilter | undefined, headquarters?: SearchTextContactFilter | undefined, employees?: SearchCountContactFilter | undefined, lastUpdated?: unknown | undefined, email?: ('all' | 'all_contacts') | undefined}; export type CreateApiPublicV1InsightsContactsArgs = {pageSize?: number | undefined, pageNumber?: number | undefined, sort?: ('id' | 'firstName' | 'lastName' | 'contactInfo' | 'summary' | 'geolocation.region' | 'geolocation.timezone' | 'geolocation.location' | 'geolocation.countryCode') | undefined, order?: ('ASC' | 'DESC') | undefined, body: InsightSearchContactsDto}; export type CreateApiPublicV1InsightsContactsOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const email = z.object({status: z.enum(["valid", "not found", "not checked"]), value: z.string().optional(), lastCheckedAt: z.string().optional()}); export const company = z.object({getProspectId: z.string(), domain: z.string().optional(), name: z.string().optional()}); export const companyRelation = z.object({email: email.optional(), position: z.string(), company: company}); export const linkedinResponseDto = z.object({id: z.string(), type: z.string()}); export const geolocation = z.object({location: z.string(), countryCode: z.string(), region: z.string(), timezone: z.string()}); export const contactResponseDto = z.object({getProspectId: z.string(), firstName: z.string().optional(), lastName: z.string().optional(), contactInfo: z.string().optional(), summary: z.string().optional(), companies: z.array(companyRelation), lastUpdatedAt: z.string(), linkedin: z.array(linkedinResponseDto), geolocation: geolocation}); export const sort = z.object({column: z.string(), order: z.enum(["ASC", "DESC"])}); export const meta = z.object({totalPages: z.number(), totalItems: z.number(), savedItems: z.number(), pageSize: z.number(), page: z.number(), sort: sort, additionalInfo: z.object({})}); export const paginatedContactsData = z.object({data: z.array(contactResponseDto), meta: meta}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Search leads * * POST /public/v1/insights/contacts */ export const createApiPublicV1InsightsContacts = async (args: CreateApiPublicV1InsightsContactsArgs, options?: CreateApiPublicV1InsightsContactsOptions) => { const {baseUrl = "https://api.getprospect.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.pageSize != null) query.append("pageSize", String(args.pageSize)) if (args.pageNumber != null) query.append("pageNumber", String(args.pageNumber)) if (args.sort != null) query.append("sort", String(args.sort)) if (args.order != null) query.append("order", String(args.order)) if (apiKey !== undefined) headers.set("apiKey", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/public/v1/insights/contacts${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(paginatedContactsData, await res.json()) };