Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
import type { WizardConfig, WizardStepId, CustomField, WizardFieldConfig } from '@/types/wizard-config'
|
2026-02-14 15:26:42 +01:00
|
|
|
|
|
|
|
|
/**
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
* Check if a field is visible based on the wizard configuration
|
2026-02-14 15:26:42 +01:00
|
|
|
*/
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
export function isFieldVisible(config: WizardConfig, fieldName: string): boolean {
|
|
|
|
|
const fieldConfig = config.fields?.[fieldName]
|
|
|
|
|
if (!fieldConfig) return true // Default visible if not configured
|
|
|
|
|
return fieldConfig.visible !== false
|
2026-02-14 15:26:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
* Check if a field is required based on the wizard configuration
|
2026-02-14 15:26:42 +01:00
|
|
|
*/
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
export function isFieldRequired(config: WizardConfig, fieldName: string): boolean {
|
|
|
|
|
const fieldConfig = config.fields?.[fieldName]
|
|
|
|
|
if (!fieldConfig) return false // Default not required if not configured
|
|
|
|
|
return fieldConfig.required === true
|
2026-02-14 15:26:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
* Get field configuration for a specific field
|
2026-02-14 15:26:42 +01:00
|
|
|
*/
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
export function getFieldConfig(config: WizardConfig, fieldName: string): WizardFieldConfig | undefined {
|
|
|
|
|
return config.fields?.[fieldName]
|
2026-02-14 15:26:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
* Get visible steps based on configuration and form values
|
2026-02-14 15:26:42 +01:00
|
|
|
*/
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
export function getVisibleSteps(config: WizardConfig, formValues: Record<string, unknown>) {
|
|
|
|
|
const steps = config.steps || []
|
2026-02-14 15:26:42 +01:00
|
|
|
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
return steps
|
|
|
|
|
.filter((step) => step.enabled !== false)
|
|
|
|
|
.filter((step) => {
|
|
|
|
|
// Check conditional visibility
|
|
|
|
|
if (!step.conditionalOn) return true
|
|
|
|
|
|
|
|
|
|
const { field, operator, value } = step.conditionalOn
|
|
|
|
|
const fieldValue = formValues[field]
|
|
|
|
|
|
|
|
|
|
switch (operator) {
|
|
|
|
|
case 'equals':
|
|
|
|
|
return fieldValue === value
|
|
|
|
|
case 'notEquals':
|
|
|
|
|
return fieldValue !== value
|
|
|
|
|
case 'in':
|
|
|
|
|
return Array.isArray(value) && value.includes(fieldValue as string)
|
|
|
|
|
case 'notIn':
|
|
|
|
|
return Array.isArray(value) && !value.includes(fieldValue as string)
|
|
|
|
|
default:
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.sort((a, b) => a.order - b.order)
|
2026-02-14 15:26:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
* Build steps array with field mappings for validation
|
2026-02-14 15:26:42 +01:00
|
|
|
*/
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
export function buildStepsArray(config: WizardConfig) {
|
|
|
|
|
const baseSteps = [
|
|
|
|
|
{ id: 'welcome', title: 'Category', fields: ['competitionCategory'] },
|
|
|
|
|
{ id: 'contact', title: 'Contact', fields: ['contactName', 'contactEmail', 'contactPhone', 'country', 'city'] },
|
|
|
|
|
{ id: 'project', title: 'Project', fields: ['projectName', 'teamName', 'description', 'oceanIssue'] },
|
|
|
|
|
{ id: 'team', title: 'Team', fields: ['teamMembers'] },
|
|
|
|
|
{ id: 'additional', title: 'Details', fields: ['institution', 'startupCreatedDate', 'wantsMentorship', 'referralSource'] },
|
|
|
|
|
{ id: 'review', title: 'Review', fields: ['gdprConsent'] },
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
// Apply config overrides
|
|
|
|
|
return baseSteps.map((step) => {
|
|
|
|
|
const configStep = config.steps?.find((s) => s.id === step.id)
|
|
|
|
|
return {
|
|
|
|
|
...step,
|
|
|
|
|
title: configStep?.title || step.title,
|
|
|
|
|
enabled: configStep?.enabled !== false,
|
|
|
|
|
}
|
|
|
|
|
})
|
2026-02-14 15:26:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
* Get custom fields for a specific step
|
2026-02-14 15:26:42 +01:00
|
|
|
*/
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
export function getCustomFieldsForStep(config: WizardConfig, stepId: WizardStepId): CustomField[] {
|
|
|
|
|
const customFields = config.customFields || []
|
|
|
|
|
return customFields
|
|
|
|
|
.filter((field) => field.stepId === stepId)
|
2026-02-14 15:26:42 +01:00
|
|
|
.sort((a, b) => a.order - b.order)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
* Parse wizard config from JSON (settingsJson) and merge with defaults
|
2026-02-14 15:26:42 +01:00
|
|
|
*/
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
export function parseWizardConfig(settingsJson: unknown): WizardConfig {
|
|
|
|
|
const DEFAULT_WIZARD_CONFIG: WizardConfig = {
|
|
|
|
|
steps: [
|
|
|
|
|
{ id: 'welcome', enabled: true, order: 0, title: 'Category' },
|
|
|
|
|
{ id: 'contact', enabled: true, order: 1, title: 'Contact' },
|
|
|
|
|
{ id: 'project', enabled: true, order: 2, title: 'Project' },
|
|
|
|
|
{ id: 'team', enabled: true, order: 3, title: 'Team' },
|
|
|
|
|
{ id: 'additional', enabled: true, order: 4, title: 'Details' },
|
|
|
|
|
{ id: 'review', enabled: true, order: 5, title: 'Review' },
|
|
|
|
|
],
|
|
|
|
|
fields: {},
|
|
|
|
|
competitionCategories: [],
|
|
|
|
|
oceanIssues: [],
|
|
|
|
|
features: {
|
|
|
|
|
enableWhatsApp: false,
|
|
|
|
|
enableMentorship: true,
|
|
|
|
|
enableTeamMembers: true,
|
|
|
|
|
requireInstitution: false,
|
|
|
|
|
},
|
|
|
|
|
customFields: [],
|
2026-02-14 15:26:42 +01:00
|
|
|
}
|
|
|
|
|
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
if (!settingsJson || typeof settingsJson !== 'object') {
|
|
|
|
|
return DEFAULT_WIZARD_CONFIG
|
2026-02-14 15:26:42 +01:00
|
|
|
}
|
|
|
|
|
|
Competition/Round architecture: full platform rewrite (Phases 1-9)
Replace Pipeline/Stage system with Competition/Round architecture.
New schema: Competition, Round (7 types), JuryGroup, AssignmentPolicy,
ProjectRoundState, DeliberationSession, ResultLock, SubmissionWindow.
New services: round-engine, round-assignment, deliberation, result-lock,
submission-manager, competition-context, ai-prompt-guard.
Full admin/jury/applicant/mentor UI rewrite. AI prompt hardening with
structured prompts, retry logic, and injection detection. All legacy
pipeline/stage code removed. 4 new migrations + seed aligned.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 23:04:15 +01:00
|
|
|
return {
|
|
|
|
|
...DEFAULT_WIZARD_CONFIG,
|
|
|
|
|
...(settingsJson as Partial<WizardConfig>),
|
|
|
|
|
}
|
2026-02-14 15:26:42 +01:00
|
|
|
}
|