Skip to content

Commit afe0be3

Browse files
committed
fix: david errors
1 parent 1d51081 commit afe0be3

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { yearsPassed } from '@douglasneuroinformatics/libjs';
2+
import { reviver } from '@douglasneuroinformatics/libjs';
23
import { linearRegression } from '@douglasneuroinformatics/libstats';
34
import { Injectable, NotFoundException, UnprocessableEntityException } from '@nestjs/common';
45
import type { Json, ScalarInstrument } from '@opendatacapture/runtime-core';
@@ -25,7 +26,6 @@ import { SubjectsService } from '@/subjects/subjects.service';
2526
import { VirtualizationService } from '@/virtualization/virtualization.service';
2627

2728
import { InstrumentMeasuresService } from './instrument-measures.service';
28-
import { reviver } from '@douglasneuroinformatics/libjs';
2929

3030
@Injectable()
3131
export class InstrumentRecordsService {
@@ -287,7 +287,7 @@ export class InstrumentRecordsService {
287287

288288
const sessionId = session.id;
289289

290-
const revivedData: Json = JSON.parse(JSON.stringify(data), reviver);
290+
const revivedData = JSON.parse(JSON.stringify(data), reviver) as Json;
291291

292292
if (!instrument.validationSchema.safeParse(revivedData).success) {
293293
throw new UnprocessableEntityException(

apps/web/src/features/upload/hooks/useUploadInstrumentRecords.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
import { replacer } from '@douglasneuroinformatics/libjs';
12
import { useNotificationsStore } from '@douglasneuroinformatics/libui/hooks';
3+
import type { Json } from '@opendatacapture/runtime-core';
24
import type { UploadInstrumentRecordsData } from '@opendatacapture/schemas/instrument-records';
35
import { useMutation } from '@tanstack/react-query';
46
import axios from 'axios';
5-
import { replacer } from '@douglasneuroinformatics/libjs';
67

78
export function useUploadInstrumentRecords() {
89
const addNotification = useNotificationsStore((store) => store.addNotification);
910
return useMutation({
1011
mutationFn: async (data: UploadInstrumentRecordsData) => {
11-
const replacedData = JSON.parse(JSON.stringify(data, replacer));
12+
const replacedData = JSON.parse(JSON.stringify(data, replacer)) as Json;
1213
await axios.post('/v1/instrument-records/upload', replacedData);
1314
},
1415
onSuccess() {

apps/web/src/features/upload/utils.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable max-lines */
2+
13
import { isNumberLike, isPlainObject, parseNumber } from '@douglasneuroinformatics/libjs';
24
import type { AnyUnilingualFormInstrument, FormTypes, Json } from '@opendatacapture/runtime-core';
35
import type { Group } from '@opendatacapture/schemas/group';
@@ -366,7 +368,8 @@ export function createUploadTemplateCSV(instrument: AnyUnilingualFormInstrument)
366368
let shape: { [key: string]: z.ZodTypeAny } = {};
367369
// TODO - include ZodEffect as a typename like our other types
368370
if ((instrumentSchema._def.typeName as string) === 'ZodEffects') {
369-
// TODO - find a type safe way to call this
371+
// @ts-expect-error - TODO - find a type safe way to call this
372+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
370373
shape = instrumentSchema._def.schema._def.shape() as { [key: string]: z.ZodTypeAny };
371374
} else {
372375
shape = instrumentSchema.shape as { [key: string]: z.ZodTypeAny };
@@ -402,8 +405,8 @@ export async function processInstrumentCSV(
402405
let instrumentSchemaWithInternal: z.AnyZodObject;
403406

404407
if ((instrumentSchema._def.typeName as string) === 'ZodEffects') {
405-
// TODO - find a type safe way to call this
406-
408+
// @ts-expect-error - TODO - find a type safe way to call this
409+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
407410
instrumentSchemaWithInternal = instrumentSchema._def.schema.extend({
408411
date: z.coerce.date(),
409412
subjectID: z.string()

0 commit comments

Comments
 (0)