chore: update MCP package version to 0.0.7, add formatting script, and enhance README with architecture and principles
This commit is contained in:
@@ -1,8 +1,25 @@
|
||||
import type {
|
||||
TCourseImportCourseParam,
|
||||
TCourseImportDraftCreate,
|
||||
TCourseImportDraftCreateFromCourse,
|
||||
TCourseImportDraftPublish,
|
||||
TCourseImportDraftPublishToCourse,
|
||||
TCourseImportDraftUpdate
|
||||
} from '@cio/utils/validation/course-import';
|
||||
import type { TCourseLandingPageUpdate } from '@cio/utils/validation/course';
|
||||
import type {
|
||||
TExerciseCreate,
|
||||
TExerciseFromTemplate,
|
||||
TExerciseGetParam,
|
||||
TExerciseListQuery,
|
||||
TExerciseUpdate
|
||||
} from '@cio/utils/validation/exercise';
|
||||
import type { TGetOrganizationCoursesQuery } from '@cio/utils/validation/organization';
|
||||
import type {
|
||||
TAutomationCourseTagAssignment,
|
||||
TAutomationDraftTagAssignment,
|
||||
TAutomationDraftTagParam
|
||||
} from '@cio/utils/validation/tag';
|
||||
|
||||
import type { McpServerConfig } from './config.js';
|
||||
|
||||
@@ -41,12 +58,83 @@ export class ClassroomIoApiClient {
|
||||
});
|
||||
}
|
||||
|
||||
async createCourseDraftFromCourse(payload: TCourseImportDraftCreateFromCourse) {
|
||||
return this.request('/organization/course-import/drafts/from-course', {
|
||||
method: 'POST',
|
||||
body: payload
|
||||
});
|
||||
}
|
||||
|
||||
async getCourseStructure(courseId: TCourseImportCourseParam['courseId']) {
|
||||
return this.request(`/organization/course-import/courses/${courseId}/structure`, {
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
|
||||
async updateCourseLandingPage(courseId: TCourseImportCourseParam['courseId'], payload: TCourseLandingPageUpdate) {
|
||||
return this.request(`/course/${courseId}/landing-page`, {
|
||||
method: 'PUT',
|
||||
body: payload
|
||||
});
|
||||
}
|
||||
|
||||
async getCourseDraft(draftId: string) {
|
||||
return this.request(`/organization/course-import/drafts/${draftId}`, {
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
|
||||
async listOrganizationCourses(query: TGetOrganizationCoursesQuery = {}) {
|
||||
const searchParams = new URLSearchParams();
|
||||
if (query.tags) searchParams.set('tags', query.tags);
|
||||
|
||||
const querySuffix = searchParams.toString() ? `?${searchParams.toString()}` : '';
|
||||
return this.request(`/organization/courses${querySuffix}`, {
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
|
||||
async listCourseExercises(courseId: string, query: TExerciseListQuery = {}) {
|
||||
const searchParams = new URLSearchParams();
|
||||
if (query.lessonId) searchParams.set('lessonId', query.lessonId);
|
||||
if (query.sectionId) searchParams.set('sectionId', query.sectionId);
|
||||
|
||||
const querySuffix = searchParams.toString() ? `?${searchParams.toString()}` : '';
|
||||
return this.request(`/course/${courseId}/exercise${querySuffix}`, {
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
|
||||
async getCourseExercise(courseId: string, exerciseId: TExerciseGetParam['exerciseId']) {
|
||||
return this.request(`/course/${courseId}/exercise/${exerciseId}`, {
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
|
||||
async createCourseExercise(courseId: string, payload: Omit<TExerciseCreate, 'courseId'>) {
|
||||
return this.request(`/course/${courseId}/exercise`, {
|
||||
method: 'POST',
|
||||
body: {
|
||||
...payload,
|
||||
courseId
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async createCourseExerciseFromTemplate(courseId: string, payload: TExerciseFromTemplate) {
|
||||
return this.request(`/course/${courseId}/exercise/from-template`, {
|
||||
method: 'POST',
|
||||
body: payload
|
||||
});
|
||||
}
|
||||
|
||||
async updateCourseExercise(courseId: string, exerciseId: TExerciseGetParam['exerciseId'], payload: TExerciseUpdate) {
|
||||
return this.request(`/course/${courseId}/exercise/${exerciseId}`, {
|
||||
method: 'PUT',
|
||||
body: payload
|
||||
});
|
||||
}
|
||||
|
||||
async updateCourseDraft(draftId: string, payload: TCourseImportDraftUpdate) {
|
||||
return this.request(`/organization/course-import/drafts/${draftId}`, {
|
||||
method: 'PUT',
|
||||
@@ -54,6 +142,13 @@ export class ClassroomIoApiClient {
|
||||
});
|
||||
}
|
||||
|
||||
async tagCourseDraft(draftId: TAutomationDraftTagParam['draftId'], payload: TAutomationDraftTagAssignment) {
|
||||
return this.request(`/organization/course-import/drafts/${draftId}/tags`, {
|
||||
method: 'PUT',
|
||||
body: payload
|
||||
});
|
||||
}
|
||||
|
||||
async publishCourseDraft(draftId: string, payload: TCourseImportDraftPublish) {
|
||||
return this.request(`/organization/course-import/drafts/${draftId}/publish`, {
|
||||
method: 'POST',
|
||||
@@ -61,6 +156,22 @@ export class ClassroomIoApiClient {
|
||||
});
|
||||
}
|
||||
|
||||
async publishCourseDraftToExistingCourse(draftId: string, payload: TCourseImportDraftPublishToCourse) {
|
||||
return this.request(`/organization/course-import/drafts/${draftId}/publish-existing-course`, {
|
||||
method: 'POST',
|
||||
body: payload
|
||||
});
|
||||
}
|
||||
|
||||
async tagCourses(payload: TAutomationCourseTagAssignment) {
|
||||
return this.request<
|
||||
Array<{ courseId: string; tags: Array<{ id: string; name: string; slug: string; color: string }> }>
|
||||
>('/organization/tags/courses/assign', {
|
||||
method: 'PUT',
|
||||
body: payload
|
||||
});
|
||||
}
|
||||
|
||||
private async request<TResponse>(
|
||||
path: string,
|
||||
options: {
|
||||
|
||||
Reference in New Issue
Block a user