@gg-world/deals
Version:
Zod schemas and TypeScript types for deal-related data structures
259 lines (258 loc) • 9.05 kB
JavaScript
"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.FundraisingInfoSchema = exports.BusinessMetricsSchema = exports.FounderInfoSchema = 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",
"google_docs",
"dropbox",
"vimeo",
"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({
name: zod_1.z.string().nullable().default(null).describe("The name of the company"),
description: zod_1.z
.string()
.nullable()
.default(null)
.describe("The description of the company"),
logo_url: zod_1.z
.string()
.url()
.nullable()
.default(null)
.describe("The URL of the company logo"),
investment_status: zod_1.z
.string()
.nullable()
.default(null)
.describe("The investment status of the company"),
country_id: zod_1.z
.string()
.nullable()
.default(null)
.describe("The country where the company is headquartered (abbreviated)"),
website: zod_1.z
.string()
.url()
.nullable()
.default(null)
.describe("The website of the company"),
linkedin_url: zod_1.z
.string()
.url()
.nullable()
.default(null)
.describe("The LinkedIn URL of the company"),
});
exports.FounderInfoSchema = zod_1.z.object({
first_name: zod_1.z
.string()
.nullable()
.default(null)
.describe("The first name of the primary founder"),
last_name: zod_1.z
.string()
.nullable()
.default(null)
.describe("The last name of the primary founder"),
position: zod_1.z
.string()
.nullable()
.default(null)
.describe("The position of the primary founder"),
bio: zod_1.z
.string()
.nullable()
.default(null)
.describe("The bio of the primary founder"),
linkedin_url: zod_1.z
.string()
.url()
.nullable()
.default(null)
.describe("The LinkedIn URL of the primary founder"),
});
exports.BusinessMetricsSchema = zod_1.z.object({
business_model: zod_1.z
.string()
.nullable()
.default(null)
.describe("The business model of the company (B2B, B2C, etc.)"),
verticals: zod_1.z
.array(zod_1.z.string())
.nullable()
.default([])
.describe("The verticals of the company"),
geography: zod_1.z
.array(zod_1.z.string())
.nullable()
.default([])
.describe("The primary operating geography(s) of the company, in standardized country/region names"),
stage: zod_1.z
.string()
.nullable()
.default(null)
.describe("The funding stage of the company"),
arr: zod_1.z
.number()
.nullable()
.default(null)
.describe("The annual recurring revenue of the company"),
mrr: zod_1.z
.number()
.nullable()
.default(null)
.describe("The monthly recurring revenue of the company"),
sales_geography: zod_1.z
.array(zod_1.z.string())
.nullable()
.default([])
.describe("The sales geography of the company, in standardized country/region names"),
focus_geography: zod_1.z
.array(zod_1.z.string())
.nullable()
.default([])
.describe("The focus geography of the company, in standardized country/region names"),
});
exports.FundraisingInfoSchema = zod_1.z.object({
round: zod_1.z.string().nullable().default(null).describe("Current funding round"),
target_amount: zod_1.z
.number()
.nullable()
.default(null)
.describe("Current fundraising target"),
raised_amount: zod_1.z
.number()
.nullable()
.default(null)
.describe("Amount raised so far"),
valuation: zod_1.z
.number()
.nullable()
.default(null)
.describe("The valuation of the company in USD"),
pitch_deck_url: zod_1.z
.string()
.url()
.nullable()
.default(null)
.describe("The link to the pitch deck of the company"),
pitch_video_url: zod_1.z
.string()
.url()
.nullable()
.default(null)
.describe("The link to the pitch video of the company"),
});
// Profile Schema - contains only valuable data for embeddings and scoring
exports.DealProfileSchema = zod_1.z.object({
external_id: zod_1.z.string().nullable().optional(),
company_info: exports.CompanyInfoSchema.nullable(),
founder_info: exports.FounderInfoSchema.nullable(),
business_metrics: exports.BusinessMetricsSchema.nullable(),
fundraising: exports.FundraisingInfoSchema.nullable(),
additional_details: zod_1.z.record(zod_1.z.any()).nullable(), // For flexible additional valuable data
});
// 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({
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.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([]),
}),
});
// 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(),
});
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,
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(),
});