Skip to content

Commit

Permalink
fix outstanding errors relating to protocol validation lib
Browse files Browse the repository at this point in the history
  • Loading branch information
jthrilly committed Dec 2, 2024
1 parent 29bf413 commit ae6953b
Show file tree
Hide file tree
Showing 25 changed files with 1,908 additions and 1,606 deletions.
4 changes: 2 additions & 2 deletions app/(interview)/interview/[interviewId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { notFound, redirect } from 'next/navigation';
import { syncInterview } from '~/actions/interviews';
import FeedbackBanner from '~/components/Feedback/FeedbackBanner';
import { getAppSetting } from '~/queries/appSettings';
import { getInterviewById } from '~/queries/interviews';
import { TESTING_getInterviewById } from '~/queries/interviews';
import { getServerSession } from '~/utils/auth';
import InterviewShell from '../_components/InterviewShell';

Expand All @@ -18,7 +18,7 @@ export default async function Page({
return 'No interview id found';
}

const interview = await getInterviewById(interviewId);
const interview = await TESTING_getInterviewById(interviewId);
const session = await getServerSession();

// If the interview is not found, redirect to the 404 page
Expand Down
11 changes: 10 additions & 1 deletion knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
"lib/interviewer/hooks/forceSimulation.worker.js",
"lib/ui/components/Sprites/ExportSprite.js",
"utils/auth.ts",
"load-test.js"
"load-test.js",
"lib/protocol-validation/schemas/compiled/index.js",
"lib/protocol-validation/schemas/compiled/1.js",
"lib/protocol-validation/schemas/compiled/2.js",
"lib/protocol-validation/schemas/compiled/3.js",
"lib/protocol-validation/schemas/compiled/4.js",
"lib/protocol-validation/schemas/compiled/5.js",
"lib/protocol-validation/schemas/compiled/6.js",
"lib/protocol-validation/schemas/compiled/7.js",
"lib/protocol-validation/schemas/compiled/8.js"
],
"ignoreDependencies": [
"server-only",
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol-validation/__tests__/test-protocols.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type Zip from 'jszip';
import JSZip from 'jszip';
import { join } from 'path';
import { describe, it } from 'vitest';
import { validateProtocol } from '~/lib/protocol-validation';
import { validateProtocol } from '../index';

// Utility functions for encryption handling
const decryptFile = async (
Expand Down
4 changes: 2 additions & 2 deletions lib/protocol-validation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type ValidationError = {
message: string;
};

export type ValidationResult = {
type ValidationResult = {
isValid: boolean;
schemaErrors: ValidationError[];
logicErrors: ValidationError[];
Expand Down Expand Up @@ -46,4 +46,4 @@ const validateProtocol = async (
}
};

export { validateLogic, validateProtocol, validateSchema };
export { validateProtocol, };
4 changes: 2 additions & 2 deletions lib/protocol-validation/migrations/canUpgrade.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import getMigrationPath from "./getMigrationPath";
import getMigrationPath from './getMigrationPath';

export const canUpgrade = (
const canUpgrade = (
sourceSchemaVersion: number,
targetSchemaVersion: number,
) => {
Expand Down
5 changes: 0 additions & 5 deletions lib/protocol-validation/migrations/migrateProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,3 @@ export const migrateProtocol = (
return resultProtocol;
};

export default {
migrateProtocol,
getMigrationNotes,
canUpgrade,
};
350 changes: 175 additions & 175 deletions lib/protocol-validation/schemas/compiled/1.js

Large diffs are not rendered by default.

354 changes: 177 additions & 177 deletions lib/protocol-validation/schemas/compiled/2.js

Large diffs are not rendered by default.

354 changes: 177 additions & 177 deletions lib/protocol-validation/schemas/compiled/3.js

Large diffs are not rendered by default.

360 changes: 180 additions & 180 deletions lib/protocol-validation/schemas/compiled/4.js

Large diffs are not rendered by default.

362 changes: 181 additions & 181 deletions lib/protocol-validation/schemas/compiled/5.js

Large diffs are not rendered by default.

372 changes: 186 additions & 186 deletions lib/protocol-validation/schemas/compiled/6.js

Large diffs are not rendered by default.

372 changes: 186 additions & 186 deletions lib/protocol-validation/schemas/compiled/7.js

Large diffs are not rendered by default.

384 changes: 192 additions & 192 deletions lib/protocol-validation/schemas/compiled/8.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions lib/protocol-validation/schemas/compiled/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import version_6 from './6.js';
import version_7 from './7.js';
import version_1 from './1.js';
import version_2 from './2.js';
import version_3 from './3.js';
import version_8 from './8.js';
import version_4 from './4.js';
import version_5 from './5.js';
import version_6 from './6.js';
import version_7 from './7.js';
import version_8 from './8.js';

const versions = [
{ version: 6, validator: version_6 },
{ version: 7, validator: version_7 },
{ version: 1, validator: version_1 },
{ version: 2, validator: version_2 },
{ version: 3, validator: version_3 },
{ version: 8, validator: version_8 },
{ version: 4, validator: version_4 },
{ version: 5, validator: version_5 },
{ version: 6, validator: version_6 },
{ version: 7, validator: version_7 },
{ version: 8, validator: version_8 },
];

export default versions;
Expand Down
158 changes: 89 additions & 69 deletions lib/protocol-validation/schemas/src/8.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ const variableSchema = z
validation: validationSchema.optional(),
})
.strict();
export type Variable = z.infer<typeof variableSchema>;
type Variable = z.infer<typeof variableSchema>;

const VariablesSchema = z.record(
z.string().regex(validVariableName),
variableSchema,
);
export type Variables = z.infer<typeof VariablesSchema>;
type Variables = z.infer<typeof VariablesSchema>;

// Node, Edge, and Ego Schemas
const nodeSchema = z
Expand Down Expand Up @@ -125,7 +125,6 @@ const codebookSchema = z
ego: egoSchema.optional(),
})
.strict();
export type Codebook = z.infer<typeof codebookSchema>;

// Filter and Sort Options Schemas
const filterRuleSchema = z
Expand Down Expand Up @@ -203,14 +202,13 @@ const promptSchema = z
})
.strict();

const subjectSchema = z
.object({
entity: z.enum(['edge', 'node', 'ego']),
type: z.string(),
})
.strict()
.optional();

const subjectSchema = z
.object({
entity: z.enum(['edge', 'node', 'ego']),
type: z.string(),
})
.strict()
.optional();

// Common schemas used across different stage types
const baseStageSchema = z.object({
Expand Down Expand Up @@ -326,67 +324,83 @@ const sociogramStage = baseStageSchema.extend({
const dyadCensusStage = baseStageSchema.extend({
type: z.literal('DyadCensus'),
subject: subjectSchema,
prompts: z.array(
promptSchema.extend({
createEdge: z.string(),
}),
).min(1),
prompts: z
.array(
promptSchema.extend({
createEdge: z.string(),
}),
)
.min(1),
});

const tieStrengthCensusStage = baseStageSchema.extend({
type: z.literal('TieStrengthCensus'),
subject: subjectSchema,
prompts: z.array(
promptSchema.extend({
createEdge: z.string(),
edgeVariable: z.string(),
negativeLabel: z.string(),
}),
).min(1),
prompts: z
.array(
promptSchema.extend({
createEdge: z.string(),
edgeVariable: z.string(),
negativeLabel: z.string(),
}),
)
.min(1),
});

const ordinalBinStage = baseStageSchema.extend({
type: z.literal('OrdinalBin'),
subject: subjectSchema,
prompts: z.array(promptSchema.extend({
variable: z.string(),
bucketSortOrder: sortOrderSchema.optional(),
binSortOrder: sortOrderSchema.optional(),
color: z.string().optional(),
})).min(1),
prompts: z
.array(
promptSchema.extend({
variable: z.string(),
bucketSortOrder: sortOrderSchema.optional(),
binSortOrder: sortOrderSchema.optional(),
color: z.string().optional(),
}),
)
.min(1),
});

const categoricalBinStage = baseStageSchema.extend({
type: z.literal('CategoricalBin'),
subject: subjectSchema,
prompts: z.array(promptSchema.extend({
variable: z.string(),
otherVariable: z.string().optional(),
otherVariablePrompt: z.string().optional(),
otherOptionLabel: z.string().optional(),
bucketSortOrder: sortOrderSchema.optional(),
binSortOrder: sortOrderSchema.optional(),
})).min(1),
prompts: z
.array(
promptSchema.extend({
variable: z.string(),
otherVariable: z.string().optional(),
otherVariablePrompt: z.string().optional(),
otherOptionLabel: z.string().optional(),
bucketSortOrder: sortOrderSchema.optional(),
binSortOrder: sortOrderSchema.optional(),
}),
)
.min(1),
});

const narrativeStage = baseStageSchema.extend({
type: z.literal('Narrative'),
subject: subjectSchema,
presets: z.array(
z.object({
id: z.string(),
label: z.string(),
layoutVariable: z.string(),
groupVariable: z.string().optional(),
edges: z
presets: z
.array(
z
.object({
display: z.array(z.string()).optional(),
id: z.string(),
label: z.string(),
layoutVariable: z.string(),
groupVariable: z.string().optional(),
edges: z
.object({
display: z.array(z.string()).optional(),
})
.strict()
.optional(),
highlight: z.array(z.string()).optional(),
})
.strict()
.optional(),
highlight: z.array(z.string()).optional(),
}).strict(),
).min(1),
.strict(),
)
.min(1),
background: z
.object({
concentricCircles: z.number().int().optional(),
Expand All @@ -407,37 +421,43 @@ const informationStage = baseStageSchema.extend({
type: z.literal('Information'),
title: z.string().optional(),
items: z.array(
z.object({
id: z.string(),
type: z.enum(['text', 'asset']),
content: z.string(),
description: z.string().optional(),
size: z.string().optional(),
loop: z.boolean().optional(),
}).strict(),
z
.object({
id: z.string(),
type: z.enum(['text', 'asset']),
content: z.string(),
description: z.string().optional(),
size: z.string().optional(),
loop: z.boolean().optional(),
})
.strict(),
),
});

const anonymisationStage = baseStageSchema.extend({
type: z.literal('Anonymisation'),
items: z.array(
z.object({
id: z.string(),
type: z.enum(['text', 'asset']),
content: z.string(),
size: z.string().optional(),
}).strict(),
z
.object({
id: z.string(),
type: z.enum(['text', 'asset']),
content: z.string(),
size: z.string().optional(),
})
.strict(),
),
});

const oneToManyDyadCensusStage = baseStageSchema.extend({
type: z.literal('OneToManyDyadCensus'),
subject: subjectSchema,
prompts: z.array(
promptSchema.extend({
createEdge: z.string(),
}),
).min(1),
prompts: z
.array(
promptSchema.extend({
createEdge: z.string(),
}),
)
.min(1),
});

const familyTreeCensusStage = baseStageSchema.extend({
Expand Down
Loading

0 comments on commit ae6953b

Please sign in to comment.