@@ -11,6 +11,7 @@ import type {
1111 CurveCubicBezier ,
1212 Colour ,
1313} from '../shared/api-entities' ;
14+ import { getQuestionID , makeUserAnswerID } from '../shared/health' ;
1415
1516type MaybeAsyncIterable < T > = Iterable < T > | AsyncIterable < T > ;
1617
@@ -34,6 +35,7 @@ export interface RetroItemJsonExport {
3435 created : string ;
3536 category : string ;
3637 group ?: string | undefined ;
38+ for ?: string | undefined ;
3739 message : string ;
3840 votes : number ;
3941 completed ?: string | undefined ;
@@ -141,14 +143,17 @@ function importRetroItemAttachment(
141143 }
142144}
143145
144- function exportRetroItem ( item : RetroItem ) : RetroItemJsonExport {
146+ function exportRetroItem ( item : RetroItem , format : string ) : RetroItemJsonExport {
145147 const result : RetroItemJsonExport = {
146148 created : exportTimestamp ( item . created ) ,
147149 category : item . category ,
148150 group : item . group ,
149151 message : item . message ,
150152 votes : item . votes ,
151153 } ;
154+ if ( format === 'health' ) {
155+ result . for = getQuestionID ( item ) ;
156+ }
152157 if ( item . doneTime > 0 ) {
153158 result . completed = exportTimestamp ( item . doneTime ) ;
154159 }
@@ -158,9 +163,12 @@ function exportRetroItem(item: RetroItem): RetroItemJsonExport {
158163 return result ;
159164}
160165
161- function importRetroItem ( item : RetroItemJsonExport ) : RetroItem {
166+ function importRetroItem ( item : RetroItemJsonExport , format : string ) : RetroItem {
162167 return {
163- id : randomUUID ( ) ,
168+ id :
169+ format === 'health' && item . for
170+ ? makeUserAnswerID ( item . for , randomUUID ( ) )
171+ : randomUUID ( ) ,
164172 created : importTimestamp ( item . created ) ,
165173 category : item . category ,
166174 group : item . group ,
@@ -193,21 +201,21 @@ function importRetroHistoryItem(
193201 } ;
194202}
195203
196- function exportRetroData ( archive : RetroData ) : RetroDataJsonExport {
204+ function exportRetroData ( retro : RetroData ) : RetroDataJsonExport {
197205 return {
198- format : archive . format ,
199- options : archive . options ,
200- items : archive . items . map ( exportRetroItem ) ,
201- history : archive . history . map ( exportRetroHistoryItem ) ,
206+ format : retro . format ,
207+ options : retro . options ,
208+ items : retro . items . map ( ( item ) => exportRetroItem ( item , retro . format ) ) ,
209+ history : retro . history . map ( exportRetroHistoryItem ) ,
202210 } ;
203211}
204212
205- export function importRetroDataJson ( archive : RetroDataJsonExport ) : RetroData {
213+ export function importRetroDataJson ( retro : RetroDataJsonExport ) : RetroData {
206214 return {
207- format : archive . format ,
208- options : archive . options ,
209- items : archive . items . map ( importRetroItem ) ,
210- history : archive . history ?. map ( importRetroHistoryItem ) ?? [ ] ,
215+ format : retro . format ,
216+ options : retro . options ,
217+ items : retro . items . map ( ( item ) => importRetroItem ( item , retro . format ) ) ,
218+ history : retro . history ?. map ( importRetroHistoryItem ) ?? [ ] ,
211219 } ;
212220}
213221
0 commit comments