22
33export interface DbConfig {
44 databases : DbConfigDatabases ;
5+ expanded : ExpandedDbItem [ ] ;
56 selected ?: SelectedDbItem ;
67}
78
@@ -87,6 +88,37 @@ export interface LocalDatabase {
8788 storagePath : string ;
8889}
8990
91+ export type ExpandedDbItem =
92+ | RootLocalExpandedDbItem
93+ | LocalUserDefinedListExpandedDbItem
94+ | RootRemoteExpandedDbItem
95+ | RemoteUserDefinedListExpandedDbItem ;
96+
97+ export enum ExpandedDbItemKind {
98+ RootLocal = "rootLocal" ,
99+ LocalUserDefinedList = "localUserDefinedList" ,
100+ RootRemote = "rootRemote" ,
101+ RemoteUserDefinedList = "remoteUserDefinedList" ,
102+ }
103+
104+ export interface RootLocalExpandedDbItem {
105+ kind : ExpandedDbItemKind . RootLocal ;
106+ }
107+
108+ export interface LocalUserDefinedListExpandedDbItem {
109+ kind : ExpandedDbItemKind . LocalUserDefinedList ;
110+ listName : string ;
111+ }
112+
113+ export interface RootRemoteExpandedDbItem {
114+ kind : ExpandedDbItemKind . RootRemote ;
115+ }
116+
117+ export interface RemoteUserDefinedListExpandedDbItem {
118+ kind : ExpandedDbItemKind . RemoteUserDefinedList ;
119+ listName : string ;
120+ }
121+
90122export function cloneDbConfig ( config : DbConfig ) : DbConfig {
91123 return {
92124 databases : {
@@ -108,6 +140,7 @@ export function cloneDbConfig(config: DbConfig): DbConfig {
108140 databases : config . databases . local . databases . map ( ( db ) => ( { ...db } ) ) ,
109141 } ,
110142 } ,
143+ expanded : config . expanded . map ( cloneDbConfigExpandedItem ) ,
111144 selected : config . selected
112145 ? cloneDbConfigSelectedItem ( config . selected )
113146 : undefined ,
@@ -150,3 +183,17 @@ function cloneDbConfigSelectedItem(selected: SelectedDbItem): SelectedDbItem {
150183 } ;
151184 }
152185}
186+
187+ function cloneDbConfigExpandedItem ( item : ExpandedDbItem ) : ExpandedDbItem {
188+ switch ( item . kind ) {
189+ case ExpandedDbItemKind . RootLocal :
190+ case ExpandedDbItemKind . RootRemote :
191+ return { kind : item . kind } ;
192+ case ExpandedDbItemKind . LocalUserDefinedList :
193+ case ExpandedDbItemKind . RemoteUserDefinedList :
194+ return {
195+ kind : item . kind ,
196+ listName : item . listName ,
197+ } ;
198+ }
199+ }
0 commit comments