@@ -8,12 +8,8 @@ import { TocContext } from '../../../types/toc-context.js';
88import { FileService } from '../../../infrastructure/file-service.js' ;
99import { BuildContext } from '../../../types/build-context.js' ;
1010import {
11- extractCallbacksForToc ,
12- extractEndpointGroupsForToc ,
13- extractModelsForToc ,
14- extractWebhooksForToc ,
15- SdlTocComponents
16- } from '../../../types/sdl/sdl.js' ;
11+ TocComponents
12+ } from '../../../types/toc/toc-components.js' ;
1713import { withDirPath } from '../../../infrastructure/tmp-extensions.js' ;
1814import { TempContext } from '../../../types/temp-context.js' ;
1915import { PortalService } from '../../../infrastructure/services/portal-service.js' ;
@@ -67,27 +63,20 @@ export class PortalNewTocAction {
6763 return ActionResult . cancelled ( ) ;
6864 }
6965
70- const sdlTocComponents : SdlTocComponents = await ( async ( ) => {
71- const defaultComponents = {
72- endpointGroups : new Map ( ) ,
73- models : [ ] ,
74- webhookGroups : new Map ( ) ,
75- callbackGroups : new Map ( )
76- } ;
77-
66+ const tocComponents : TocComponents = await ( async ( ) => {
7867 const specDirectory = buildDirectory . join ( 'spec' ) ;
7968
8069 if ( ! ( await this . fileService . directoryExists ( specDirectory ) ) ) {
8170 this . prompts . fallingBackToDefault ( ) ;
82- return defaultComponents ;
71+ return TocComponents . empty ( ) ;
8372 }
8473
8574 return await withDirPath ( async ( tempDirectory ) => {
8675 const tempContext = new TempContext ( tempDirectory ) ;
8776 const specZipPath = await tempContext . zip ( specDirectory ) ;
8877 const specFileStream = await this . fileService . getStream ( specZipPath ) ;
89- const result = await this . prompts . extractComponents (
90- this . portalService . generateSdl ( specFileStream , this . configDirectory , this . commandMetadata ) ,
78+ const result = await this . prompts . extractTocData (
79+ this . portalService . generateTocData ( specFileStream , this . configDirectory , this . commandMetadata ) ,
9180 expandEndpoints ,
9281 expandModels ,
9382 expandWebhooks ,
@@ -96,15 +85,10 @@ export class PortalNewTocAction {
9685 specFileStream . close ( ) ;
9786 if ( result . isErr ( ) ) {
9887 this . prompts . fallingBackToDefault ( ) ;
99- return defaultComponents ;
88+ return TocComponents . empty ( ) ;
10089 }
10190
102- return {
103- endpointGroups : extractEndpointGroupsForToc ( result . value ) ,
104- models : extractModelsForToc ( result . value ) ,
105- webhookGroups : extractWebhooksForToc ( result . value ) ,
106- callbackGroups : extractCallbacksForToc ( result . value )
107- } ;
91+ return TocComponents . fromTocData ( result . value ) ;
10892 } ) ;
10993 } ) ( ) ;
11094 const contentContext = new ContentContext ( contentDirectory ) ;
@@ -119,10 +103,11 @@ export class PortalNewTocAction {
119103 }
120104
121105 const toc = this . tocGenerator . createTocStructure (
122- { data : sdlTocComponents . endpointGroups , expand : expandEndpoints } ,
123- { data : sdlTocComponents . models , expand : expandModels } ,
124- { data : sdlTocComponents . webhookGroups , expand : expandWebhooks } ,
125- { data : sdlTocComponents . callbackGroups , expand : expandCallbacks } ,
106+ tocComponents ,
107+ expandEndpoints ,
108+ expandModels ,
109+ expandWebhooks ,
110+ expandCallbacks ,
126111 contentGroups
127112 ) ;
128113 const yamlString = this . tocGenerator . transformToYaml ( toc ) ;
0 commit comments