import { z } from 'zod';

/**
 * Base Entity Contracts
 *
 * Typed base interfaces for CRM, Lead-Gen (Acquisition), and Projects domains.
 * Each uses a `<TMeta>` generic parameter so client projects can narrow the
 * metadata type in their own `foundations/types/` directory.
 *
 * These are PARALLEL abstractions — they do NOT replace or modify the existing
 * row types (ProjectRow, AcqDealRow, etc.). Use these as the SDK-facing contract
 * layer; use the row types internally for direct Supabase access.
 *
 * Usage in a client project:
 *   import { BaseProject } from '@elevasis/core'
 *   type Project = BaseProject<{ budget: number; riskScore: 'low' | 'medium' | 'high' }>
 *
 * Extending a Zod schema in a client project:
 *   import { BaseProjectSchema } from '@elevasis/core'
 *   const ProjectMetaSchema = z.object({ budget: z.number(), riskScore: z.enum(['low','medium','high']) })
 *   const ProjectSchema = BaseProjectSchema.extend({ metadata: ProjectMetaSchema })
 */
/**
 * Common fields shared across all project implementations.
 * `TMeta` narrows the `metadata` JSONB column (prj_projects.metadata).
 */
interface BaseProject<TMeta = Record<string, unknown>> {
    id: string;
    organizationId: string;
    name: string;
    kind: string;
    status: string;
    description: string | null;
    metadata: TMeta;
    createdAt: string;
    updatedAt: string;
}
/**
 * Common fields shared across all milestone implementations.
 * `TMeta` narrows the `metadata` JSONB column (prj_milestones.metadata).
 */
interface BaseMilestone<TMeta = Record<string, unknown>> {
    id: string;
    organizationId: string;
    projectId: string;
    name: string;
    status: string;
    description: string | null;
    metadata: TMeta;
    createdAt: string;
    updatedAt: string;
}
/**
 * Common fields shared across all task implementations.
 * `TMeta` narrows the `metadata` JSONB column (prj_tasks.metadata).
 */
interface BaseTask<TMeta = Record<string, unknown>> {
    id: string;
    organizationId: string;
    projectId: string;
    name: string;
    status: string;
    type: string;
    description: string | null;
    metadata: TMeta;
    createdAt: string;
    updatedAt: string;
}
/**
 * Common fields shared across all deal implementations.
 * `TMeta` is an extension point for client-specific deal metadata.
 * Note: The underlying acq_deals table does not have a `metadata` column;
 * this field serves as a typed extension slot for SDK consumers.
 */
interface BaseDeal<TMeta = Record<string, unknown>> {
    id: string;
    organizationId: string;
    contactEmail: string;
    stage: string | null;
    metadata: TMeta;
    createdAt: string;
    updatedAt: string;
}
/**
 * Common fields shared across all company implementations.
 * `TMeta` is an extension point for client-specific company metadata.
 */
interface BaseCompany<TMeta = Record<string, unknown>> {
    id: string;
    organizationId: string;
    name: string;
    domain: string | null;
    status: string;
    metadata: TMeta;
    createdAt: string;
    updatedAt: string;
}
/**
 * Common fields shared across all contact implementations.
 * `TMeta` is an extension point for client-specific contact metadata.
 */
interface BaseContact<TMeta = Record<string, unknown>> {
    id: string;
    organizationId: string;
    email: string;
    firstName: string | null;
    lastName: string | null;
    status: string;
    metadata: TMeta;
    createdAt: string;
    updatedAt: string;
}
/**
 * Base Zod schema for a project record.
 * Extend with `BaseProjectSchema.extend({ metadata: ProjectMetaSchema })`.
 */
declare const BaseProjectSchema: z.ZodObject<{
    id: z.ZodString;
    organizationId: z.ZodString;
    name: z.ZodString;
    kind: z.ZodString;
    status: z.ZodString;
    description: z.ZodNullable<z.ZodString>;
    metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    createdAt: z.ZodString;
    updatedAt: z.ZodString;
}, z.core.$strip>;
/**
 * Base Zod schema for a milestone record.
 * Extend with `BaseMilestoneSchema.extend({ metadata: MilestoneMetaSchema })`.
 */
declare const BaseMilestoneSchema: z.ZodObject<{
    id: z.ZodString;
    organizationId: z.ZodString;
    projectId: z.ZodString;
    name: z.ZodString;
    status: z.ZodString;
    description: z.ZodNullable<z.ZodString>;
    metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    createdAt: z.ZodString;
    updatedAt: z.ZodString;
}, z.core.$strip>;
/**
 * Base Zod schema for a task record.
 * Extend with `BaseTaskSchema.extend({ metadata: TaskMetaSchema })`.
 */
declare const BaseTaskSchema: z.ZodObject<{
    id: z.ZodString;
    organizationId: z.ZodString;
    projectId: z.ZodString;
    name: z.ZodString;
    status: z.ZodString;
    type: z.ZodString;
    description: z.ZodNullable<z.ZodString>;
    metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    createdAt: z.ZodString;
    updatedAt: z.ZodString;
}, z.core.$strip>;
/**
 * Base Zod schema for a deal record.
 * Extend with `BaseDealSchema.extend({ metadata: DealMetaSchema })`.
 */
declare const BaseDealSchema: z.ZodObject<{
    id: z.ZodString;
    organizationId: z.ZodString;
    contactEmail: z.ZodString;
    stage: z.ZodNullable<z.ZodString>;
    metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    createdAt: z.ZodString;
    updatedAt: z.ZodString;
}, z.core.$strip>;
/**
 * Base Zod schema for a company record.
 * Extend with `BaseCompanySchema.extend({ metadata: CompanyMetaSchema })`.
 */
declare const BaseCompanySchema: z.ZodObject<{
    id: z.ZodString;
    organizationId: z.ZodString;
    name: z.ZodString;
    domain: z.ZodNullable<z.ZodString>;
    status: z.ZodString;
    metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    createdAt: z.ZodString;
    updatedAt: z.ZodString;
}, z.core.$strip>;
/**
 * Base Zod schema for a contact record.
 * Extend with `BaseContactSchema.extend({ metadata: ContactMetaSchema })`.
 */
declare const BaseContactSchema: z.ZodObject<{
    id: z.ZodString;
    organizationId: z.ZodString;
    email: z.ZodString;
    firstName: z.ZodNullable<z.ZodString>;
    lastName: z.ZodNullable<z.ZodString>;
    status: z.ZodString;
    metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    createdAt: z.ZodString;
    updatedAt: z.ZodString;
}, z.core.$strip>;
/** Default (unnarrowed) inferred type from BaseProjectSchema */
type BaseProjectInput = z.infer<typeof BaseProjectSchema>;
/** Default (unnarrowed) inferred type from BaseMilestoneSchema */
type BaseMilestoneInput = z.infer<typeof BaseMilestoneSchema>;
/** Default (unnarrowed) inferred type from BaseTaskSchema */
type BaseTaskInput = z.infer<typeof BaseTaskSchema>;
/** Default (unnarrowed) inferred type from BaseDealSchema */
type BaseDealInput = z.infer<typeof BaseDealSchema>;
/** Default (unnarrowed) inferred type from BaseCompanySchema */
type BaseCompanyInput = z.infer<typeof BaseCompanySchema>;
/** Default (unnarrowed) inferred type from BaseContactSchema */
type BaseContactInput = z.infer<typeof BaseContactSchema>;

export { BaseCompanySchema, BaseContactSchema, BaseDealSchema, BaseMilestoneSchema, BaseProjectSchema, BaseTaskSchema };
export type { BaseCompany, BaseCompanyInput, BaseContact, BaseContactInput, BaseDeal, BaseDealInput, BaseMilestone, BaseMilestoneInput, BaseProject, BaseProjectInput, BaseTask, BaseTaskInput };
