diff --git a/backend/src/interfaces/learningPath.ts b/backend/src/interfaces/learningPath.ts new file mode 100644 index 00000000..3260c6ea --- /dev/null +++ b/backend/src/interfaces/learningPath.ts @@ -0,0 +1,46 @@ +export interface LearningPathResponse { + success: boolean; + source: string; + data: any[] | null; + message?: string; +} + +export interface LearningPath { + _id: string; + language: string; + hruid: string; + title: string; + description: string; + image?: string; // Image might be missing, so it's optional + num_nodes: number; + num_nodes_left: number; + nodes: LearningObjectNode[]; + keywords: string; + target_ages: number[]; + min_age: number; + max_age: number; + __order: number; +} + + +interface LearningObjectNode { + _id: string; + learningobject_hruid: string; + version: number; + language: string; + start_node?: boolean; + transitions: Transition[]; + created_at: string; + updatedAt: string; +} + +interface Transition { + default: boolean; + _id: string; + next: { + _id: string; + hruid: string; + version: number; + language: string; + }; +} diff --git a/backend/src/services/learningPaths.ts b/backend/src/services/learningPaths.ts index 6a3039f7..a5a84b1d 100644 --- a/backend/src/services/learningPaths.ts +++ b/backend/src/services/learningPaths.ts @@ -1,12 +1,6 @@ import { fetchWithLogging } from "../util/apiHelper.js"; import { DWENGO_API_BASE } from "../config/config.js"; - -interface LearningPathResponse { - success: boolean; - source: string; - data: any[] | null; - message?: string; -} +import {LearningPath, LearningPathResponse} from "../interfaces/learningPath.js"; export async function fetchLearningPaths( hruids: string[], @@ -25,7 +19,7 @@ export async function fetchLearningPaths( const apiUrl = `${DWENGO_API_BASE}/learningPath/getPathsFromIdList`; const params = { pathIdList: JSON.stringify({ hruids }), language }; - const learningPaths = await fetchWithLogging(apiUrl, `Learning paths for ${source}`, params); + const learningPaths = await fetchWithLogging(apiUrl, `Learning paths for ${source}`, params); if (!learningPaths || learningPaths.length === 0) { console.error(`⚠️ WARNING: No learning paths found for ${source}.`);