@@ -22,7 +22,7 @@ import {
2222 BuilderContext ,
2323 BuildResult ,
2424 BuildResultDto ,
25- HTML_EXPORT_GROUP_FORMAT ,
25+ ExportDocument ,
2626 PackageComparison ,
2727 PackageComparisonOperations ,
2828 PackageComparisons ,
@@ -38,7 +38,6 @@ import { unknownApiBuilder } from '../apitypes'
3838import { BUILD_TYPE , MESSAGE_SEVERITY , PACKAGE } from '../consts'
3939import { takeIf , toPackageDocument } from '../utils'
4040import { toVersionsComparisonDto } from '../utils/transformToDto'
41- import { dumpRestDocument } from '../apitypes/rest/rest.document'
4241
4342export interface ZipTool {
4443 // todo method should only accept Blob content, transformation is not a responsibility of this method
@@ -47,25 +46,6 @@ export interface ZipTool {
4746 buildResult : ( options ?: JSZip . JSZipGeneratorOptions ) => Promise < any >
4847}
4948
50- export const createExportResult = async (
51- buildResult : BuildResult ,
52- zip : ZipTool ,
53- ctx : BuilderContext ,
54- options ?: JSZip . JSZipGeneratorOptions ,
55- ) : Promise < any > => {
56- const { config : { format } } = ctx
57-
58- for ( const document of [ ...buildResult . documents . values ( ) ] ) {
59- // const apiBuilder = apiBuilders.find(({ types }) => types.includes(document.type)) || unknownApiBuilder
60- // const data = apiBuilder.dumpDocument(document, format)
61- const data = dumpRestDocument ( document , format )
62-
63- await zip . file ( document . filename , data )
64- }
65-
66- return await zip . buildResult ( options )
67- }
68-
6949export const createVersionPackage = async (
7050 buildResult : BuildResult ,
7151 zip : ZipTool ,
@@ -90,9 +70,9 @@ export const createVersionPackage = async (
9070 case BUILD_TYPE . EXPORT_REST_DOCUMENT :
9171 case BUILD_TYPE . EXPORT_REST_OPERATIONS_GROUP :
9272 if ( buildResult . exportDocuments . length === 1 ) {
93- return Buffer . from ( await dumpRestDocument ( buildResultDto . exportDocuments [ 0 ] , ctx . config . format ) . arrayBuffer ( ) )
73+ return Buffer . from ( await buildResultDto . exportDocuments [ 0 ] . data . arrayBuffer ( ) )
9474 }
95- await createExportDocumentDataFiles ( zip , buildResultDto . exportDocuments , ctx )
75+ await createExportDocumentDataFiles ( zip , buildResultDto . exportDocuments )
9676 return await zip . buildResult ( options )
9777 }
9878
@@ -150,6 +130,7 @@ const writeDocumentsToZip = async (zip: ZipTool, documents: ZippableDocument[],
150130
151131 const apiBuilder =
152132 apiBuilders . find ( ( { types } ) => types . includes ( document . type ) ) || unknownApiBuilder
133+ // @ts -ignore todo
153134 const data = apiBuilder . dumpDocument ( document , format )
154135 await zip . file ( document . filename , data )
155136 }
@@ -160,8 +141,10 @@ const createDocumentDataFiles = async (zip: ZipTool, documents: VersionDocument[
160141 await writeDocumentsToZip ( documentsDir , documents , ctx )
161142}
162143
163- const createExportDocumentDataFiles = async ( zip : ZipTool , documents : ZippableDocument [ ] , ctx : BuilderContext ) : Promise < void > => {
164- await writeDocumentsToZip ( zip , documents , ctx )
144+ const createExportDocumentDataFiles = async ( zip : ZipTool , documents : ExportDocument [ ] ) : Promise < void > => {
145+ for ( const document of documents ) {
146+ await zip . file ( document . filename , document . data )
147+ }
165148}
166149
167150const createOperationsFile = ( zip : ZipTool , operations : Map < string , ApiOperation > ) : void => {
0 commit comments