/** * The default daily-record template applied to every new experiment. * * `fieldId` — stable UUID; used as the storage key in custom_fields. * Builtin fields have fixed canonical UUIDs so they are * recognised across all experiments. * `key` — human-readable slug (display / validation only) * `builtin` — true → value stored in the dedicated DB column * false → value stored in daily_statuses.custom_fields[fieldId] * `active` — false → hidden from forms (data preserved) * `tags` — quick-fill presets, stored per field per experiment */ const DEFAULT_TEMPLATE = [ { fieldId: '00000000-0000-0000-0000-000000000001', key: 'experiment_description', label: 'Experiment Description', type: 'textarea', builtin: true, active: true, tags: [] }, { fieldId: '00000000-0000-0000-0000-000000000002', key: 'vitals', label: 'Vitals', type: 'text', builtin: true, active: true, tags: [] }, { fieldId: '00000000-0000-0000-0000-000000000003', key: 'treatment', label: 'Treatment', type: 'text', builtin: true, active: true, tags: [] }, { fieldId: '00000000-0000-0000-0000-000000000004', key: 'notes', label: 'Notes', type: 'textarea', builtin: true, active: true, tags: [] }, ]; const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; function resolveTemplate(stored) { if (!Array.isArray(stored) || stored.length === 0) return DEFAULT_TEMPLATE; return stored; } module.exports = { DEFAULT_TEMPLATE, resolveTemplate, UUID_RE };