Hiyve Components - v1.0.0
    Preparing search index...

    Where courses, enrollments and progress are kept.

    Each document has one writer. The provider who owns a course writes the course, its lessons, its private quiz answers and every enrollment in it; a client writes only their own progress. Save calls return the document as saved, with its revision increased and updatedAt set.

    Access follows the lesson rules: a client can read a course's outline once enrolled, a lesson's content only once it has been opened to them (grantLessonAccess), their own enrollment, and their own progress. The provider can read everything in their courses, including clients' progress.

    interface CourseStorage {
        userId: string;
        createCourse(course: Course): Promise<Course>;
        deleteCourse(courseId: string): Promise<void>;
        deleteLessonContent(courseId: string, lessonId: string): Promise<void>;
        enroll(courseId: string, client: ClientRef): Promise<Enrollment>;
        grantLessonAccess(
            enrollment: Enrollment,
            lessonIds: string[],
        ): Promise<void>;
        listCourses(): Promise<CourseSummary[]>;
        listEnrollmentOverviews(courseId: string): Promise<EnrollmentOverview[]>;
        listEnrollments(
            query?: { clientId?: string; courseId?: string },
        ): Promise<EnrollmentSummary[]>;
        listMyEnrollments(): Promise<EnrollmentSummary[]>;
        loadCourse(courseId: string): Promise<Course>;
        loadCourseKeys(courseId: string): Promise<CourseKeys | null>;
        loadEnrollment(enrollmentId: string): Promise<Enrollment>;
        loadLessonContent(
            courseId: string,
            lessonId: string,
        ): Promise<LessonContent | null>;
        loadProgress(enrollmentId: string): Promise<Progress | null>;
        loadProviderSettings(): Promise<ProviderSettings | null>;
        resolveMediaUrl(
            media: MediaRef,
            options?: { stream?: boolean },
        ): Promise<string>;
        revokeAccess(enrollment: Enrollment): Promise<void>;
        revokeLessonAccess(
            enrollment: Enrollment,
            lessonIds: string[],
        ): Promise<void>;
        saveCourse(course: Course): Promise<Course>;
        saveCourseKeys(keys: CourseKeys): Promise<CourseKeys>;
        saveEnrollment(enrollment: Enrollment): Promise<Enrollment>;
        saveLessonContent(content: LessonContent): Promise<LessonContent>;
        saveProgress(progress: Progress): Promise<Progress>;
        saveProviderSettings(settings: ProviderSettings): Promise<ProviderSettings>;
        subscribe?(listener: (change: CourseStorageChange) => void): () => void;
        uploadMedia(file: File): Promise<MediaRef>;
    }

    Hierarchy (View Summary)

    Index

    Properties

    userId: string

    The user this storage acts for.

    Methods

    • Delete a course with its lessons, private answers and enrollments, and the files its lessons use that no other course uses.

      Parameters

      • courseId: string

      Returns Promise<void>

    • Delete a lesson's content (for example, a lesson added for one client that is no longer wanted).

      Parameters

      • courseId: string
      • lessonId: string

      Returns Promise<void>

    • Enroll a client: create their enrollment and let them read the course outline. Opens no lessons (see syncAccess). Enrolling a client who was removed reactivates their enrollment and reopens the lessons they had; enrolling an active client returns their enrollment unchanged.

      Parameters

      Returns Promise<Enrollment>

    • Let the enrolled client read these lessons' content and the files they use. Backends that decide access on the server can treat this as a no-op.

      Parameters

      Returns Promise<void>

    • An overview of every enrollment in one of this user's courses, including which lessons each client has completed — enough for progress tables, review queues and deciding what to open, without loading each client's progress. Implement it cheaply: it is called often.

      Parameters

      • courseId: string

      Returns Promise<EnrollmentOverview[]>

    • A URL to load a stored file from. stream asks for a URL suited to playback.

      Parameters

      • media: MediaRef
      • Optionaloptions: { stream?: boolean }

      Returns Promise<string>

    • Take these lessons (and the files only they use) back from the client, for example when a rule closes again.

      Parameters

      Returns Promise<void>