@@ -148,47 +148,6 @@ export class InstrumentRecordsService {
148148 async exportRecords ( { groupId } : { groupId ?: string } = { } , { ability } : Required < EntityOperationOptions > ) {
149149 const records = await this . queryRecordsRaw ( ability , groupId ) ;
150150
151- // console.log(records[0]
152- // records.forEach((record) => {
153- // for (const key in record) {
154- // try {
155- // structuredClone(record[key])
156- // } catch (err) {
157- // console.log(key, record[key], record)
158- // throw err
159- // }
160- // }
161- // })
162- // records.map((record) => {
163- // try{
164- // structuredClone(record)
165- // }
166- // catch {
167- // console.log(record)
168- // console.log(Object.getPrototypeOf(record) === Object.prototype)
169- // console.log(record.computedMeasures)
170- // throw new Error()
171- // }
172-
173- // for (let i = 0; i < records.length; i++) {
174- // const record = records[i];
175- // if (Object.getPrototypeOf(record) !== Object.prototype) {
176- // console.log(record);
177- // throw new Error('Bad prototype');
178- // }
179- // // for (const key in record) {
180- // // structuredClone(record[key])
181- // // }
182- // records[i] = {
183- // ...record
184- // };
185- // }
186-
187- // console.log(records[0]);
188-
189- // throw new Error("NULL")
190- // structuredClone(records);
191-
192151 const instrumentIds = [ ...new Set ( records . map ( ( r ) => r . instrumentId ) ) ] ;
193152
194153 const instrumentsArray = await Promise . all (
@@ -551,8 +510,15 @@ export class InstrumentRecordsService {
551510
552511 const records = ( await this . instrumentRecordModel . aggregateRaw ( { pipeline } ) ) as unknown as unknown [ ] ;
553512
513+ /**
514+ * We need to create a shallow copy of all records here, as the aggregateRaw method returns objects
515+ * with the Symbol(nodejs.util.inspect.custom) property defined, which is not serializable.
516+ */
517+
554518 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
555- return records . filter ( ( record ) => appAbility . can ( 'read' , record as any ) ) as RecordType [ ] ;
519+ return ( records . filter ( ( record ) => appAbility . can ( 'read' , record as any ) ) as RecordType [ ] ) . map ( ( record ) => ( {
520+ ...record
521+ } ) ) ;
556522 }
557523
558524 private serializeData ( data : unknown ) {
0 commit comments