import { z } from 'zod'; import type { FieldDiff } from './field-diff'; import { createFieldDiffSchema } from './field-diff'; import type { IndexDiff } from './index-diff'; import { createIndexDiffSchema } from './index-diff'; import type { RelationshipDiff } from './relationship-diff'; import { createRelationshipDiffSchema } from './relationship-diff'; import type { TableDiff } from './table-diff'; import { createTableDiffSchema } from './table-diff'; import type { DBField, DBIndex, DBRelationship, DBTable } from '..'; export type ChartDBDiff< TTable = DBTable, TField = DBField, TIndex = DBIndex, TRelationship = DBRelationship, > = | TableDiff | FieldDiff | IndexDiff | RelationshipDiff; export const createChartDBDiffSchema = < TTable = DBTable, TField = DBField, TIndex = DBIndex, TRelationship = DBRelationship, >( tableSchema: z.ZodType, fieldSchema: z.ZodType, indexSchema: z.ZodType, relationshipSchema: z.ZodType ): z.ZodType> => { return z.union([ createTableDiffSchema(tableSchema), createFieldDiffSchema(fieldSchema), createIndexDiffSchema(indexSchema), createRelationshipDiffSchema(relationshipSchema), ]) as z.ZodType>; }; export type DiffMap< TTable = DBTable, TField = DBField, TIndex = DBIndex, TRelationship = DBRelationship, > = Map>; export type DiffObject< TTable = DBTable, TField = DBField, TIndex = DBIndex, TRelationship = DBRelationship, > = | TableDiff['object'] | FieldDiff['object'] | IndexDiff['object'] | RelationshipDiff['object'];