Skip to content

Commit 0fc9f3a

Browse files
committed
feat: implement zod v4 checks
1 parent 51cecfc commit 0fc9f3a

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

apps/api/src/instrument-records/instrument-records.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { replacer, reviver, yearsPassed } from '@douglasneuroinformatics/libjs';
1+
import { isZodType, replacer, reviver, yearsPassed } from '@douglasneuroinformatics/libjs';
22
import { accessibleQuery, InjectModel } from '@douglasneuroinformatics/libnest';
33
import type { Model } from '@douglasneuroinformatics/libnest';
44
import { linearRegression } from '@douglasneuroinformatics/libstats';
@@ -17,6 +17,7 @@ import { Prisma } from '@prisma/client';
1717
import type { $Enums, Session } from '@prisma/client';
1818
import { isNumber, mergeWith, pickBy } from 'lodash-es';
1919
import { err, ok } from 'neverthrow';
20+
import z from 'zod/v4';
2021

2122
import type { EntityOperationOptions } from '@/core/types';
2223
import { GroupsService } from '@/groups/groups.service';
@@ -131,7 +132,7 @@ export class InstrumentRecordsService {
131132
}
132133

133134
//TODO
134-
// Chech if instrument schema is zod4 version, if so use the toJSONSchema method to convert to json
135+
// Check if instrument schema is zod4 version, if so use the toJSONSchema method to convert to json
135136
// and expand the data from there
136137
async exportRecords({ groupId }: { groupId?: string } = {}, { ability }: EntityOperationOptions = {}) {
137138
const data: InstrumentRecordsExport = [];
@@ -169,6 +170,11 @@ export class InstrumentRecordsService {
169170
instruments.set(record.instrumentId, instrument);
170171
}
171172

173+
// if (isZodType(instrument.validationSchema, { version: 4})) {
174+
// const zodToJson = z.toJSONSchema(instrument.validationSchema)
175+
176+
// }
177+
172178
for (const [measureKey, measureValue] of Object.entries(record.computedMeasures)) {
173179
let list;
174180
try {

0 commit comments

Comments
 (0)