@@ -26,7 +26,9 @@ import {
2626 EMPTY_CHANGE_SUMMARY ,
2727 FILE_FORMAT ,
2828 GRAPHQL_API_TYPE ,
29- graphqlApiBuilder , MESSAGE_SEVERITY ,
29+ graphqlApiBuilder ,
30+ KIND_PACKAGE ,
31+ MESSAGE_SEVERITY ,
3032 NotificationMessage ,
3133 OperationId ,
3234 OperationsApiType ,
@@ -67,7 +69,7 @@ import {
6769 saveNotifications ,
6870 saveOperationsArray ,
6971} from './utils'
70- import { getCompositeKey , getSplittedVersionKey , isNotEmpty , toBase64 } from '../../../src/utils'
72+ import { getCompositeKey , getSplittedVersionKey , isNotEmpty , takeIfDefined , toBase64 } from '../../../src/utils'
7173import { groupBy } from 'graphql/jsutils/groupBy'
7274import { IRegistry } from './types'
7375import { calculateTotalChangeSummary } from '../../../src/components/compare'
@@ -199,26 +201,37 @@ export class LocalRegistry implements IRegistry {
199201 const documentsFromVersion = Array . from ( documents ?. values ( ) ?? [ ] )
200202
201203 if ( isNotEmpty ( documentsFromVersion ) ) {
202- return { documents : this . resolveDocuments ( documentsFromVersion , this . filterOperationIdsByGroup ( filterByOperationGroup ) ) }
204+ return { documents : this . resolveDocuments ( documentsFromVersion , this . filterOperationIdsByGroup ( filterByOperationGroup ) ) , packages : { } }
203205 }
204206
205207 const documentsFromRefs = (
206208 await Promise . all ( refs . map ( async ( { refId, version } ) => {
207209 const versionCache = await this . getVersion ( refId , version )
208210 if ( ! versionCache ) return [ ]
209211 const { documents } = versionCache
210- return Array . from ( documents . values ( ) )
212+ return this . resolveDocuments ( Array . from ( documents . values ( ) ) , this . filterOperationIdsByGroup ( filterByOperationGroup ) , refId )
211213 } ) )
212214 ) . flat ( )
213215
214- return { documents : this . resolveDocuments ( documentsFromRefs , this . filterOperationIdsByGroup ( filterByOperationGroup ) ) }
216+ const packages = refs . reduce ( ( acc , ref ) => {
217+ acc [ ref . refId ] = {
218+ refId : ref . refId ,
219+ version : ref . version ,
220+ kind : KIND_PACKAGE ,
221+ name : ref . refId ,
222+ status : VERSION_STATUS . DRAFT ,
223+ }
224+ return acc
225+ } , { } as ResolvedReferenceMap )
226+
227+ return { documents : documentsFromRefs , packages : packages }
215228 }
216229
217230 private filterOperationIdsByGroup ( filterByOperationGroup : string ) : ( id : string ) => boolean {
218231 return ( id : string ) : boolean => this . groupToOperationIdsMap [ filterByOperationGroup ] ?. includes ( id )
219232 }
220233
221- private resolveDocuments ( documents : VersionDocument [ ] , filterOperationIdsByGroup : ( id : string ) => boolean ) : ResolvedDocument [ ] {
234+ private resolveDocuments ( documents : VersionDocument [ ] , filterOperationIdsByGroup : ( id : string ) => boolean , refId ?: string ) : ResolvedDocument [ ] {
222235 return documents
223236 . filter ( versionDocument => versionDocument . operationIds . some ( filterOperationIdsByGroup ) )
224237 . map ( document => ( {
@@ -232,6 +245,7 @@ export class LocalRegistry implements IRegistry {
232245 title : document . title ,
233246 includedOperationIds : document . operationIds . filter ( filterOperationIdsByGroup ) ,
234247 data : toBase64 ( JSON . stringify ( document . data ) ) ,
248+ ...takeIfDefined ( { packageRef : refId } ) ,
235249 } ) )
236250 }
237251
@@ -295,7 +309,9 @@ export class LocalRegistry implements IRegistry {
295309 packages [ packageRef ] = {
296310 refId : ref . refId ,
297311 version : ref . version ,
298- versionRevision : 0 ,
312+ kind : KIND_PACKAGE ,
313+ name : ref . refId ,
314+ status : VERSION_STATUS . DRAFT ,
299315 }
300316 references . push ( {
301317 packageRef : packageRef ,
0 commit comments