@@ -15,19 +15,6 @@ import {
1515} from '@xata.io/pgroll' ;
1616import chalk from 'chalk' ;
1717import enquirer from 'enquirer' ;
18- import {
19- AddColumnPayload ,
20- AddTablePayload ,
21- BranchSchemaFormatted ,
22- ColumnAdditions ,
23- ColumnEdits ,
24- DeleteColumnPayload ,
25- DeleteTablePayload ,
26- EditColumnPayload ,
27- EditTablePayload ,
28- SelectChoice ,
29- ValidationState
30- } from './types.js' ;
3118import {
3219 exhaustiveCheck ,
3320 generateLinkReference ,
@@ -42,6 +29,104 @@ import {
4229 xataColumnTypeToZeroValue
4330} from '../../migrations/pgroll.js' ;
4431
32+ export type BranchSchemaFormatted =
33+ | {
34+ schema : {
35+ tables : {
36+ name : string ;
37+ uniqueConstraints : Schemas . BranchSchema [ 'tables' ] [ number ] [ 'uniqueConstraints' ] ;
38+ checkConstraints : Schemas . BranchSchema [ 'tables' ] [ number ] [ 'checkConstraints' ] ;
39+ foreignKeys : Schemas . BranchSchema [ 'tables' ] [ number ] [ 'foreignKeys' ] ;
40+ columns : {
41+ name : string ;
42+ type : string ;
43+ unique : boolean ;
44+ notNull : boolean ;
45+ defaultValue : any ;
46+ comment : string ;
47+ } [ ] ;
48+ } [ ] ;
49+ } ;
50+ }
51+ | undefined ;
52+
53+ export type ColumnData = {
54+ name : string ;
55+ type : string ;
56+ unique : boolean ;
57+ nullable : boolean ;
58+ defaultValue ?: string ;
59+ vector ?: {
60+ dimension : number ;
61+ } ;
62+ originalName : string ;
63+ tableName : string ;
64+ link ?: {
65+ table : string ;
66+ } ;
67+ file ?: {
68+ defaultPublicAccess : boolean ;
69+ } ;
70+ 'file[]' ?: {
71+ defaultPublicAccess : boolean ;
72+ } ;
73+ } ;
74+
75+ export type AddTablePayload = {
76+ type : 'add-table' ;
77+ table : {
78+ name : string ;
79+ } ;
80+ } ;
81+
82+ export type EditTablePayload = {
83+ type : 'edit-table' ;
84+ table : {
85+ name : string ;
86+ newName : string ;
87+ } ;
88+ } ;
89+
90+ export type DeleteTablePayload = {
91+ name : string ;
92+ } ;
93+
94+ export type AddColumnPayload = {
95+ type : 'add-column' ;
96+ tableName : string ;
97+ column : ColumnData ;
98+ } ;
99+
100+ export type EditColumnPayload = {
101+ type : 'edit-column' ;
102+ column : ColumnData ;
103+ } ;
104+
105+ export type DeleteColumnPayload = { [ tableName : string ] : string [ ] } ;
106+
107+ export type FormatPayload = {
108+ type : 'space' | 'migrate' | 'schema' ;
109+ } ;
110+
111+ export type SelectChoice = {
112+ name : FormatPayload | AddTablePayload | EditTablePayload | AddColumnPayload | EditColumnPayload ;
113+ message : string ;
114+ role ?: string ;
115+ choices ?: SelectChoice [ ] ;
116+ disabled ?: boolean ;
117+ hint ?: string ;
118+ } ;
119+
120+ export type ValidationState = {
121+ values : { name : string } ;
122+ items : { name : string ; input : string } [ ] ;
123+ fields : { name : string ; initial : string } [ ] ;
124+ } ;
125+
126+ export type ColumnAdditions = { [ tableName : string ] : { [ columnName : string ] : AddColumnPayload [ 'column' ] } } ;
127+
128+ export type ColumnEdits = { [ tableName : string ] : { [ columnName : string ] : AddColumnPayload [ 'column' ] } } ;
129+
45130const { Select, Snippet, Confirm } = enquirer as any ;
46131
47132const xataTypes = [
0 commit comments