@@ -43,17 +43,34 @@ export class CubeToMetaTransformer {
4343
4444 const isCubeVisible = this . isVisible ( cube , true ) ;
4545
46- const processFolderMember = ( member ) => {
47- if ( member . type === 'folder' ) {
48- return {
49- name : member . name ,
50- members : member . includes . map ( processFolderMember ) ,
51- } ;
52- }
53-
54- return `${ cube . name } .${ member . name } ` ;
46+ const flatFolderSeparator = '/' ;
47+ const flatFolders = [ ] ;
48+
49+ const processFolder = ( folder , path = [ ] ) => {
50+ const flatMembers = [ ] ;
51+ const nestedMembers = folder . includes . map ( member => {
52+ if ( member . type === 'folder' ) {
53+ return processFolder ( member , [ ...path , folder . name ] ) ;
54+ }
55+ const memberName = `${ cube . name } .${ member . name } ` ;
56+ flatMembers . push ( memberName ) ;
57+
58+ return `${ cube . name } .${ member . name } ` ;
59+ } ) ;
60+
61+ flatFolders . push ( {
62+ name : [ ...path , folder . name ] . join ( flatFolderSeparator ) ,
63+ members : flatMembers ,
64+ } ) ;
65+
66+ return {
67+ name : folder . name ,
68+ members : nestedMembers ,
69+ } ;
5570 } ;
5671
72+ const nestedFolders = ( cube . folders || [ ] ) . map ( f => processFolder ( f ) ) ;
73+
5774 return {
5875 config : {
5976 name : cube . name ,
@@ -124,10 +141,8 @@ export class CubeToMetaTransformer {
124141 public : it . public ?? true ,
125142 name : `${ cube . name } .${ it . name } ` ,
126143 } ) ) ,
127- folders : ( cube . folders || [ ] ) . map ( ( it ) => ( {
128- name : it . name ,
129- members : it . includes . map ( processFolderMember ) ,
130- } ) ) ,
144+ folders : flatFolders ,
145+ nestedFolders,
131146 } ,
132147 } ;
133148 }
0 commit comments