UNPKG

@gg-world/deals

Version:

Zod schemas and TypeScript types for deal-related data structures

376 lines (375 loc) 15.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StageSchema = exports.DealSchema = exports.DealTagSchema = exports.DealScoringSchema = exports.DealFactorSchema = exports.EnrichmentMetadataSchema = exports.RawInputSchema = exports.FileAttachmentSchema = exports.LinkParsingResultSchema = exports.DealProfileSchema = exports.InvestorQuestionsSchema = exports.AdditionalDetailsSchema = exports.CompleteTeamInfoSchema = exports.FounderDeepInfoWithLinkedInProfileSchema = exports.LinkedInProfileSchema = exports.FounderDeepInfoSchema = exports.TeamBasicInfoSchema = exports.BusinessMetricsSchema = exports.MarketInfoSchema = exports.TractionInfoSchema = exports.FundraisingInfoSchema = exports.LocationsInfoSchema = exports.VideosInfoSchema = exports.PitchDeckInfoSchema = exports.CompanyInfoSchema = exports.DealSourceEnum = exports.SourceTypeEnum = exports.LinkStatusEnum = exports.LinkParsingStatusEnum = exports.ProcessingStatusEnum = exports.DealStatusEnum = void 0; const zod_1 = require("zod"); exports.DealStatusEnum = zod_1.z.enum([ "default", "liked", "disliked", "deleted", "email", ]); exports.ProcessingStatusEnum = zod_1.z.enum(["pending", "completed", "failed"]); exports.LinkParsingStatusEnum = zod_1.z.enum(["pending", "completed"]); exports.LinkStatusEnum = zod_1.z.enum([ "parsing_pending", "parsed_success", "parsing_failed", ]); exports.SourceTypeEnum = zod_1.z.enum([ "personal_linkedin", "company_linkedin", "youtube", "docsend", "google_drive", "onedrive", "google_docs", "dropbox", "vimeo", "funden", "pitch", "canva", "calameo", "maildoc", "figma", "brieflink", "other", "file", ]); exports.DealSourceEnum = zod_1.z.enum(["email", "file", "upload"]); // Core profile schemas exports.CompanyInfoSchema = zod_1.z.object({ company_name: zod_1.z.string().describe("The name of the company"), short_description: zod_1.z.string().describe("A short description of the company"), website: zod_1.z.string().nullable().describe("The website of the company"), founding_date: zod_1.z .string() .nullable() .describe("The founding date of the company"), }); exports.PitchDeckInfoSchema = zod_1.z.object({ pitch_deck_link: zod_1.z.string().nullable().describe("The URL of the pitch deck"), }); exports.VideosInfoSchema = zod_1.z.object({ video_pitch: zod_1.z.string().nullable().describe("The URL of the video pitch"), demo_video: zod_1.z.string().nullable().describe("The URL of the demo video"), }); exports.LocationsInfoSchema = zod_1.z.object({ startup_headquarters: zod_1.z .array(zod_1.z.string()) .describe("The headquarters of the company"), incorporation: zod_1.z.object({ country: zod_1.z .string() .describe("The country where the company is incorporated") .nullable(), state: zod_1.z .string() .describe("The state or region where the company is incorporated") .nullable(), entity_type: zod_1.z .string() .describe("The legal entity type of the company") .nullable(), }), }); exports.FundraisingInfoSchema = zod_1.z.object({ investment_stage: zod_1.z .string() .nullable() .describe("Current investment stage of the company"), round_size: zod_1.z .number() .nullable() .describe("Total size of the current funding round (USD)"), minimum_investment: zod_1.z .number() .nullable() .describe("Minimum investment amount (USD)"), round_deadline: zod_1.z .string() .nullable() .describe("Deadline for closing the round"), round_progress: zod_1.z .number() .nullable() .describe("Funding already raised towards the current round"), lead_investor: zod_1.z.string().nullable().describe("Name of the lead investor"), valuation: zod_1.z.object({ pre_money_valuation: zod_1.z .number() .nullable() .describe("Pre‑money valuation (USD)"), post_money_valuation: zod_1.z .number() .nullable() .describe("Post‑money valuation (USD)"), }), previous_funding: zod_1.z.object({ total_raised: zod_1.z .number() .nullable() .describe("Total amount previously raised (USD)"), last_round: zod_1.z.object({ type: zod_1.z.string().nullable().describe("Type of the last funding round"), amount: zod_1.z .number() .nullable() .describe("Amount raised in the last round (USD)"), date: zod_1.z.string().nullable().describe("Date of the last funding round"), }), }), }); exports.TractionInfoSchema = zod_1.z.object({ revenue: zod_1.z.object({ amount: zod_1.z.number().describe("Revenue (USD)"), type: zod_1.z.enum(["monthly", "annual", "total"]), growth: zod_1.z.number().nullable().describe("Revenue growth (%)"), }), users: zod_1.z .object({ active: zod_1.z.number().nullable().describe("Number of active users"), total: zod_1.z.number().nullable().describe("Total number of users"), }) .nullable() .describe("Number of active and total users, if available"), key_metrics: zod_1.z .record(zod_1.z.string(), zod_1.z.string()) .nullable() .describe("Additional key metrics as needed"), }); exports.MarketInfoSchema = zod_1.z.object({ tam: zod_1.z.number().nullable().describe("Total Addressable Market (USD)"), sam: zod_1.z.number().nullable().describe("Serviceable Available Market (USD)"), som: zod_1.z.number().nullable().describe("Serviceable Obtainable Market (USD)"), }); exports.BusinessMetricsSchema = zod_1.z.object({ focus_geography_sales: zod_1.z .array(zod_1.z.string()) .nullable() .default([]) .describe("Primary geographic markets for sales operations"), business_model: zod_1.z .array(zod_1.z.string()) .describe("Monetization strategy and revenue streams"), verticals: zod_1.z .array(zod_1.z.string()) .describe("Target industries and market segments"), unique_selling_points: zod_1.z .array(zod_1.z.string()) .describe("Key competitive advantages and differentiation factors"), challenges: zod_1.z .array(zod_1.z.string()) .describe("Current operational and market challenges"), }); exports.TeamBasicInfoSchema = zod_1.z.object({ team_size: zod_1.z.number().nullable().describe("Total number of team members"), founder_names: zod_1.z .array(zod_1.z.string().describe("The full name of the founder")) .describe("List of founding team members"), minorities: zod_1.z .array(zod_1.z.string()) .nullable() .describe("Minority groups represented on the team"), skills_focus: zod_1.z .string() .nullable() .describe("Primary skill focus areas of the team"), }); exports.FounderDeepInfoSchema = zod_1.z.object({ name: zod_1.z.string().describe("The full name of the founder"), linkedin_url: zod_1.z .string() .nullable() .describe("The LinkedIn URL of the founder"), email: zod_1.z.string().nullable().describe("The email of the founder"), phone: zod_1.z.string().nullable().describe("The phone number of the founder"), title: zod_1.z .string() .nullable() .describe("The title or role of the founder (e.g. CEO, CTO, etc.)"), notableExperiences: zod_1.z .array(zod_1.z.string()) .nullable() .describe("A list of notable experiences of the founder"), background: zod_1.z .string() .nullable() .describe("A brief background description of the founder"), }); exports.LinkedInProfileSchema = zod_1.z.object({ id: zod_1.z.string().describe("The ID of the LinkedIn profile"), name: zod_1.z.string().describe("The name of the LinkedIn profile"), city: zod_1.z.string().describe("The city of the LinkedIn profile"), country_code: zod_1.z.string().describe("The country code of the LinkedIn profile"), position: zod_1.z.string().describe("The position of the LinkedIn profile"), about: zod_1.z.string().describe("The about of the LinkedIn profile"), current_company: zod_1.z.object({ name: zod_1.z.string().describe("The name of the current company"), link: zod_1.z.string().describe("The link of the current company"), title: zod_1.z.string().describe("The title of the current company"), }), experience: zod_1.z.array(zod_1.z.object({ title: zod_1.z.string().describe("The title of the experience"), location: zod_1.z.string().describe("The location of the experience"), duration: zod_1.z.string().describe("The duration of the experience"), company: zod_1.z.string().describe("The company of the experience"), url: zod_1.z.string().describe("The URL of the experience"), description: zod_1.z.string().describe("The description of the experience"), })), education: zod_1.z.array(zod_1.z.object({ title: zod_1.z.string().describe("The title of the education"), degree: zod_1.z.string().describe("The degree of the education"), field: zod_1.z.string().describe("The field of the education"), start_year: zod_1.z.string().describe("The start year of the education"), end_year: zod_1.z.string().describe("The end year of the education"), })), certifications: zod_1.z.array(zod_1.z.object({ title: zod_1.z.string().describe("The title of the certification"), subtitle: zod_1.z.string().describe("The subtitle of the certification"), meta: zod_1.z.string().describe("The meta of the certification"), credential_url: zod_1.z .string() .describe("The credential URL of the certification"), })), avatar: zod_1.z.string().describe("The avatar of the LinkedIn profile"), followers: zod_1.z .number() .describe("The number of followers of the LinkedIn profile"), connections: zod_1.z .number() .describe("The number of connections of the LinkedIn profile"), profile_url: zod_1.z.string().describe("The URL of the LinkedIn profile"), }); exports.FounderDeepInfoWithLinkedInProfileSchema = exports.FounderDeepInfoSchema.extend({ linkedin_profile: exports.LinkedInProfileSchema, }); exports.CompleteTeamInfoSchema = zod_1.z.object({ team: exports.TeamBasicInfoSchema, founders: zod_1.z.array(exports.FounderDeepInfoWithLinkedInProfileSchema), }); exports.AdditionalDetailsSchema = zod_1.z .record(zod_1.z.any()) .nullable() .default(null) .describe("Additional valuable information"); exports.InvestorQuestionsSchema = zod_1.z.object({ investor_questions: zod_1.z .array(zod_1.z.object({ question: zod_1.z.string(), answer: zod_1.z.string(), })) .nullable(), }); // Profile Schema - contains only valuable data for embeddings and scoring exports.DealProfileSchema = zod_1.z .object({ videos: exports.VideosInfoSchema, pitch_deck: exports.PitchDeckInfoSchema, traction: exports.TractionInfoSchema, market: exports.MarketInfoSchema, team: exports.CompleteTeamInfoSchema, additional_details: exports.AdditionalDetailsSchema, }) .extend(exports.CompanyInfoSchema.shape) .extend(exports.LocationsInfoSchema.shape) .extend(exports.FundraisingInfoSchema.shape) .extend(exports.BusinessMetricsSchema.shape) .extend(exports.InvestorQuestionsSchema.shape); // Metadata schemas for tracking sources and processing exports.LinkParsingResultSchema = zod_1.z.object({ url: zod_1.z.string().url(), status: exports.LinkStatusEnum, type: exports.SourceTypeEnum, parsed_at: zod_1.z.date().nullable(), error_message: zod_1.z.string().nullable(), retries: zod_1.z.number().default(0), }); // New schemas for raw input data exports.FileAttachmentSchema = zod_1.z.object({ file_url: zod_1.z.string(), // Reference to stored file filename: zod_1.z.string(), uploaded_at: zod_1.z.date(), }); exports.RawInputSchema = zod_1.z.object({ text: zod_1.z.string().default(""), attachments: zod_1.z.array(exports.FileAttachmentSchema).default([]), received_at: zod_1.z.date().default(new Date()), }); exports.EnrichmentMetadataSchema = zod_1.z.object({ events: zod_1.z .array(zod_1.z.object({ id: zod_1.z.string(), last_enrichment_date: zod_1.z.date().nullable(), raw_input: exports.RawInputSchema, source_data: zod_1.z .record(zod_1.z.object({ raw_data: zod_1.z.object({ content: zod_1.z.string(), metadata: zod_1.z.any(), }), processed_at: zod_1.z.date(), source_type: exports.SourceTypeEnum, })) .default({}), processing_status: zod_1.z.object({ link_parsing_status: exports.LinkParsingStatusEnum.default("pending"), raw_input_parsing_status: exports.LinkParsingStatusEnum.default("pending"), link_parsing_results: zod_1.z.array(exports.LinkParsingResultSchema).default([]), attachment_parsing_results: zod_1.z .array(exports.LinkParsingResultSchema) .default([]), }), })) .default([]), }); // Scoring schemas remain the same exports.DealFactorSchema = zod_1.z.object({ factor: zod_1.z.string(), explanation: zod_1.z.string(), impact: zod_1.z.number().min(0).max(1).optional(), weight: zod_1.z.number().default(1), deal_breaker: zod_1.z.boolean().default(false), }); exports.DealScoringSchema = zod_1.z.object({ score: zod_1.z.number().min(-2).max(1).default(-1), factors: zod_1.z.array(exports.DealFactorSchema).default([]), }); exports.DealTagSchema = zod_1.z.object({ id: zod_1.z.number(), name: zod_1.z.string().default(""), description: zod_1.z.string().default(""), color: zod_1.z.string().default("#000000"), }); // Main Deal Schema exports.DealSchema = zod_1.z.object({ investor_email: zod_1.z.string().nullable(), status: exports.DealStatusEnum.default("default"), new: zod_1.z.boolean().default(true), stage: zod_1.z.string().nullable().default(null), tags: zod_1.z.array(zod_1.z.number()).default([]), source: exports.DealSourceEnum.default("file"), profile: exports.DealProfileSchema, notes: zod_1.z .array(zod_1.z.object({ id: zod_1.z.string(), content: zod_1.z.string(), created_at: zod_1.z.date(), author: zod_1.z.string(), author_email: zod_1.z.string(), })) .default([]), enrichment_metadata: exports.EnrichmentMetadataSchema, scoring: exports.DealScoringSchema, processing_status: exports.ProcessingStatusEnum.default("pending"), created_at: zod_1.z.date().default(new Date()), updated_at: zod_1.z.date().default(new Date()).nullable(), }); exports.StageSchema = zod_1.z.object({ investor_email: zod_1.z.string(), name: zod_1.z.string(), order: zod_1.z.number(), color: zod_1.z.string(), created_at: zod_1.z.date().default(new Date()), updated_at: zod_1.z.date().default(new Date()).nullable(), });