/** * Timeback Config Types * * Types for timeback.config.json files. * * Note: Runtime validation is enforced by `@timeback/types/zod` (see * `packages/types/src/zod/config.ts`). These TS types are a convenience layer * and should not be treated as a replacement for Zod validation. */ import type { TimebackGrade, TimebackSubject } from './primitives'; /** * Environment-specific course IDs. * Populated by `timeback resources push` for each environment. */ export interface CourseIds { staging?: string; production?: string; } /** * Course classification type. */ export type CourseType = 'base' | 'hole-filling' | 'optional'; /** * Course publication status. */ export type PublishStatus = 'draft' | 'testing' | 'published' | 'deactivated'; /** * Daily learning goals for a course. */ export interface CourseGoals { /** Target XP to earn per day */ dailyXp?: number; /** Target lessons to complete per day */ dailyLessons?: number; /** Target active learning minutes per day */ dailyActiveMinutes?: number; /** Target accuracy percentage (0-100) */ dailyAccuracy?: number; /** Target units to master per day */ dailyMasteredUnits?: number; } /** * Aggregate metrics for a course. */ export interface CourseMetrics { /** Total XP available in the course */ totalXp?: number; /** Total number of lessons/activities */ totalLessons?: number; /** Total grade levels covered */ totalGrades?: number; } /** * Course metadata (matches API metadata object). */ export interface CourseMetadata { /** Course classification (base, hole-filling, optional) */ courseType?: CourseType; /** Whether this is supplemental to a base course */ isSupplemental?: boolean; /** Whether this is a custom course for an individual student */ isCustom?: boolean; /** Publication status */ publishStatus?: PublishStatus; /** Contact email for course issues */ contactEmail?: string; /** Primary application identifier */ primaryApp?: string; /** Daily learning goals */ goals?: CourseGoals; /** Aggregate metrics */ metrics?: CourseMetrics; } /** * Default properties that apply to all courses unless overridden. * Set these at the root level to avoid repetition. */ export interface CourseDefaults { /** Course code (e.g., "MATH101") */ courseCode?: string; /** Course level (e.g., "AP", "Honors") */ level?: string; /** Course metadata */ metadata?: CourseMetadata; } /** * Environment-specific course overrides. * * Non-identity fields that can differ per environment. * Excludes `subject`, `grade`, `courseCode` (identity) and `ids` (already env-scoped). */ export interface CourseEnvOverrides { /** Course level override for this environment */ level?: string; /** Caliper sensor URL override for this environment */ sensor?: string; /** Launch URL override for this environment (used in dashboard resource links) */ launchUrl?: string; /** Metadata override for this environment (merged with base metadata) */ metadata?: CourseMetadata; } /** * Per-environment course overrides. * * Allows staging and production to have different non-identity properties. */ export interface CourseOverrides { /** Overrides applied when syncing to staging */ staging?: CourseEnvOverrides; /** Overrides applied when syncing to production */ production?: CourseEnvOverrides; } /** * Configuration for a single course in a Timeback app. * * Course identity is determined by one of: * - **Grade-based**: `(subject, grade)` — traditional K-12 courses * - **Grade-less**: `courseCode` — apps without grade levels (e.g., CS platforms) * * At least one identity must be present: * - If `grade` is provided, the course is identified by `(subject, grade)`. * - If `grade` is omitted, `courseCode` is required as the identifier. * * Sensor resolution: * - Default sensor is derived from the origin of the effective `launchUrl`. * - Override precedence: env override > `course.sensor` > `config.sensor` > derived from launchUrl. * - If no sensor is set and no launchUrl is derivable, validation fails. * * Environment overrides: * - Use `overrides.staging` or `overrides.production` to vary non-identity fields per env. */ export interface CourseConfig extends CourseDefaults { /** Subject area (e.g., 'Math', 'Reading') */ subject: TimebackSubject; /** * Grade level (-1 = Pre-K, 0 = K, 1-12 = grades, 13 = AP). * Optional for grade-less apps; if omitted, `courseCode` is required. */ grade?: TimebackGrade; /** Timeback course IDs per environment (populated after sync) */ ids?: CourseIds | null; /** * Caliper sensor URL for this course. * Overrides the top-level `sensor` or derived sensor from launchUrl. */ sensor?: string; /** * Launch URL for this course (used in dashboard resource links). * Overrides the top-level `launchUrl` if set. */ launchUrl?: string; /** * Environment-specific overrides for non-identity fields. * Merged with base course config when syncing to a specific environment. */ overrides?: CourseOverrides; } /** * Root configuration for a Timeback app. * Define this in your timeback.config.json file. * * Sensor resolution: * - By default, sensor is derived from the origin of the effective `launchUrl`. * - Set `sensor` explicitly (top-level or per-course) to override the derived value. * - If no sensor is set and no launchUrl is derivable, validation fails. */ export interface TimebackConfig { /** Display name for your app */ name: string; /** Default properties applied to all courses */ defaults?: CourseDefaults; /** Courses available in this app */ courses: CourseConfig[]; /** * Default Caliper sensor URL for activity events. * Overrides the derived sensor from launchUrl. Can be overridden per course. */ sensor?: string; /** * Default launch URL for dashboard resource links. * Can be overridden per course with `courses[].launchUrl`. */ launchUrl?: string; /** Studio-specific configuration */ studio?: { /** * Enable anonymous usage telemetry for Studio. * Defaults to true. Set to false to opt out. */ telemetry?: boolean; }; } //# sourceMappingURL=config.d.ts.map