@instructure/platform-mock-canvas-api 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fixtures/courses.d.ts +0 -1
- package/dist/fixtures/courses.d.ts.map +1 -1
- package/dist/fixtures/stickerDescriptions.d.ts +0 -1
- package/dist/fixtures/stickerTranslations.d.ts +0 -1
- package/dist/fixtures/submissions.d.ts +4 -0
- package/dist/fixtures/submissions.d.ts.map +1 -0
- package/dist/fixtures.js +8 -1
- package/dist/handlers/courses.d.ts +3 -0
- package/dist/handlers/courses.d.ts.map +1 -0
- package/dist/handlers/index.d.ts +7 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/submissions.d.ts +3 -0
- package/dist/handlers/submissions.d.ts.map +1 -0
- package/dist/handlers/userColors.d.ts +7 -0
- package/dist/handlers/userColors.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -27
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"courses.d.ts","sourceRoot":"","sources":["../../src/fixtures/courses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC,eAAO,MAAM,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"courses.d.ts","sourceRoot":"","sources":["../../src/fixtures/courses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC,eAAO,MAAM,OAAO,EAAE,MAAM,EAyC3B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submissions.d.ts","sourceRoot":"","sources":["../../src/fixtures/submissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,eAAO,MAAM,WAAW,EAAE,UAAU,EAiDnC,CAAA;AAGD,eAAO,MAAM,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAEpD,CAAA"}
|
package/dist/fixtures.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const t = [
|
|
2
2
|
{
|
|
3
3
|
id: "1",
|
|
4
|
+
uuid: "WvAU2cWNVZjm0Dup4i36bSusZ4UReXfNVhBjxooC",
|
|
4
5
|
name: "Introduction to Computer Science",
|
|
5
6
|
course_code: "CS 101",
|
|
6
7
|
enrollment_term_id: "1",
|
|
@@ -8,6 +9,7 @@ const t = [
|
|
|
8
9
|
},
|
|
9
10
|
{
|
|
10
11
|
id: "2",
|
|
12
|
+
uuid: "r4Dm1bQ7uXKpLe2yTnW9oZcFgHvJ5sAxMbN3iPdQ",
|
|
11
13
|
name: "Advanced Mathematics",
|
|
12
14
|
course_code: "MATH 201",
|
|
13
15
|
enrollment_term_id: "1",
|
|
@@ -15,6 +17,7 @@ const t = [
|
|
|
15
17
|
},
|
|
16
18
|
{
|
|
17
19
|
id: "3",
|
|
20
|
+
uuid: "Kp9eR2tYuI6oWqAzXcVbN7mLkJhGfDsApO4iU3yT",
|
|
18
21
|
name: "English Literature",
|
|
19
22
|
course_code: "ENG 150",
|
|
20
23
|
enrollment_term_id: "1",
|
|
@@ -22,6 +25,7 @@ const t = [
|
|
|
22
25
|
},
|
|
23
26
|
{
|
|
24
27
|
id: "4",
|
|
28
|
+
uuid: "B5nM8cXvZ2lK9pQwErTyU3iO7aSdFgHjKlZxCvBn",
|
|
25
29
|
name: "Biology Fundamentals",
|
|
26
30
|
course_code: "BIO 110",
|
|
27
31
|
enrollment_term_id: "2",
|
|
@@ -29,6 +33,7 @@ const t = [
|
|
|
29
33
|
},
|
|
30
34
|
{
|
|
31
35
|
id: "5",
|
|
36
|
+
uuid: "H1sToRy7wQ9eRtYuI2oPaSdFgHjKlZxCvBnM4kL0",
|
|
32
37
|
name: "World History",
|
|
33
38
|
course_code: "HIST 100",
|
|
34
39
|
enrollment_term_id: "2",
|
|
@@ -141,7 +146,9 @@ const t = [
|
|
|
141
146
|
grade: "A+",
|
|
142
147
|
score: 98
|
|
143
148
|
}
|
|
144
|
-
], c = new Map(
|
|
149
|
+
], c = new Map(
|
|
150
|
+
i.map((e) => [e.id, { ...e }])
|
|
151
|
+
);
|
|
145
152
|
export {
|
|
146
153
|
t as courses,
|
|
147
154
|
a as stickerDescriptions,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"courses.d.ts","sourceRoot":"","sources":["../../src/handlers/courses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAIzC,eAAO,MAAM,cAAc,EAAE,cAAc,EAe1C,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestHandler } from 'msw';
|
|
2
|
+
import { courseHandlers } from './courses';
|
|
3
|
+
import { submissionHandlers } from './submissions';
|
|
4
|
+
import { userColorHandlers } from './userColors';
|
|
5
|
+
export declare const handlers: RequestHandler[];
|
|
6
|
+
export { courseHandlers, submissionHandlers, userColorHandlers };
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD,eAAO,MAAM,QAAQ,EAAE,cAAc,EAIpC,CAAA;AAED,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submissions.d.ts","sourceRoot":"","sources":["../../src/handlers/submissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAMzC,eAAO,MAAM,kBAAkB,EAAE,cAAc,EAsD9C,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestHandler } from 'msw';
|
|
2
|
+
/**
|
|
3
|
+
* Handlers for the user course-color and course-nickname endpoints used by the
|
|
4
|
+
* platform-color-picker. Echo the submitted values back, matching Canvas shape.
|
|
5
|
+
*/
|
|
6
|
+
export declare const userColorHandlers: RequestHandler[];
|
|
7
|
+
//# sourceMappingURL=userColors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userColors.d.ts","sourceRoot":"","sources":["../../src/handlers/userColors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAGzC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,cAAc,EAiB7C,CAAA"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC5F,mBAAmB,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,46 +1,64 @@
|
|
|
1
|
-
import { courses as
|
|
2
|
-
import { stickerDescriptions as
|
|
3
|
-
import { http as
|
|
4
|
-
const
|
|
1
|
+
import { courses as c, submissionsStore as u } from "./fixtures.js";
|
|
2
|
+
import { stickerDescriptions as k, stickerTranslations as v, submissions as h } from "./fixtures.js";
|
|
3
|
+
import { http as i, HttpResponse as e } from "msw";
|
|
4
|
+
const m = [
|
|
5
5
|
// GET /api/v1/courses
|
|
6
|
-
|
|
7
|
-
// GET /api/v1/courses/:courseId
|
|
8
|
-
|
|
9
|
-
const s =
|
|
10
|
-
return
|
|
6
|
+
i.get("/api/v1/courses", () => e.json(c)),
|
|
7
|
+
// GET /api/v1/courses/:courseId (courseId may be a numeric id or a `uuid:<uuid>` ref)
|
|
8
|
+
i.get("/api/v1/courses/:courseId", ({ params: n }) => {
|
|
9
|
+
const s = String(n.courseId).replace(/^uuid:/, ""), o = c.find((r) => r.id === s || r.uuid === s);
|
|
10
|
+
return o ? e.json(o) : e.json({ errors: [{ message: "Course not found" }] }, { status: 404 });
|
|
11
11
|
})
|
|
12
12
|
], d = 300, b = [
|
|
13
13
|
// GET submission
|
|
14
|
-
|
|
14
|
+
i.get(
|
|
15
15
|
"/api/v1/courses/:courseId/assignments/:assignmentId/submissions/:submissionId",
|
|
16
|
-
({ params:
|
|
17
|
-
const s = u.get(
|
|
18
|
-
return s ?
|
|
16
|
+
({ params: n }) => {
|
|
17
|
+
const s = u.get(n.submissionId);
|
|
18
|
+
return s ? e.json(s) : e.json({ errors: [{ message: "Submission not found" }] }, { status: 404 });
|
|
19
19
|
}
|
|
20
20
|
),
|
|
21
21
|
// PATCH submission (update sticker)
|
|
22
|
-
|
|
22
|
+
i.patch(
|
|
23
23
|
"/api/v1/courses/:courseId/assignments/:assignmentId/submissions/:submissionId",
|
|
24
|
-
async ({ params:
|
|
25
|
-
const { submissionId:
|
|
26
|
-
return t ? (r.submission && "sticker" in r.submission && r.submission.sticker !== void 0 && (t.sticker = r.submission.sticker, u.set(
|
|
24
|
+
async ({ params: n, request: s }) => {
|
|
25
|
+
const { submissionId: o } = n, r = await s.json(), t = u.get(o);
|
|
26
|
+
return t ? (r.submission && "sticker" in r.submission && r.submission.sticker !== void 0 && (t.sticker = r.submission.sticker, u.set(o, t)), await new Promise((a) => setTimeout(a, d)), e.json(t)) : e.json({ errors: [{ message: "Submission not found" }] }, { status: 404 });
|
|
27
27
|
}
|
|
28
28
|
),
|
|
29
29
|
// GET all submissions for an assignment
|
|
30
|
-
|
|
30
|
+
i.get("/api/v1/courses/:courseId/assignments/:assignmentId/submissions", ({ params: n }) => {
|
|
31
31
|
const s = Array.from(u.values()).filter(
|
|
32
|
-
(
|
|
32
|
+
(o) => o.course_id === n.courseId && o.assignment_id === n.assignmentId
|
|
33
33
|
);
|
|
34
|
-
return
|
|
34
|
+
return e.json(s);
|
|
35
35
|
})
|
|
36
|
-
],
|
|
36
|
+
], g = [
|
|
37
|
+
// PUT /api/v1/users/:userId/colors/:assetString -> persist a course color
|
|
38
|
+
i.put("/api/v1/users/:userId/colors/:assetString", async ({ request: n }) => {
|
|
39
|
+
const s = await n.json().catch(() => ({}));
|
|
40
|
+
return e.json({ hexcode: s.hexcode ?? "" });
|
|
41
|
+
}),
|
|
42
|
+
// PUT /api/v1/users/self/course_nicknames/:courseId -> set a nickname
|
|
43
|
+
i.put("/api/v1/users/self/course_nicknames/:courseId", async ({ request: n }) => {
|
|
44
|
+
const s = await n.json().catch(() => ({}));
|
|
45
|
+
return e.json({ nickname: s.nickname ?? "", name: s.nickname ?? "" });
|
|
46
|
+
}),
|
|
47
|
+
// DELETE /api/v1/users/self/course_nicknames/:courseId -> clear a nickname
|
|
48
|
+
i.delete("/api/v1/users/self/course_nicknames/:courseId", () => e.json({ nickname: null, name: "" }))
|
|
49
|
+
], f = [
|
|
50
|
+
...m,
|
|
51
|
+
...b,
|
|
52
|
+
...g
|
|
53
|
+
];
|
|
37
54
|
export {
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
m as courseHandlers,
|
|
56
|
+
c as courses,
|
|
40
57
|
f as handlers,
|
|
41
|
-
|
|
42
|
-
|
|
58
|
+
k as stickerDescriptions,
|
|
59
|
+
v as stickerTranslations,
|
|
43
60
|
b as submissionHandlers,
|
|
44
|
-
|
|
45
|
-
u as submissionsStore
|
|
61
|
+
h as submissions,
|
|
62
|
+
u as submissionsStore,
|
|
63
|
+
g as userColorHandlers
|
|
46
64
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;CACF;AAED,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,YAAY,GACZ,QAAQ,GACR,QAAQ,GACR,KAAK,GACL,UAAU,GACV,YAAY,GACZ,WAAW,GACX,QAAQ,GACR,MAAM,GACN,SAAS,GACT,YAAY,GACZ,KAAK,GACL,MAAM,GACN,oBAAoB,GACpB,UAAU,GACV,MAAM,GACN,MAAM,GACN,OAAO,GACP,OAAO,GACP,UAAU,GACV,QAAQ,GACR,YAAY,GACZ,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,WAAW,GACX,MAAM,GACN,KAAK,GACL,MAAM,GACN,OAAO,GACP,UAAU,GACV,WAAW,GACX,UAAU,GACV,OAAO,GACP,MAAM,GACN,KAAK,GACL,cAAc,GACd,QAAQ,CAAA;AAEZ,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MA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ACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,WAAW,GACX,MAAM,GACN,KAAK,GACL,MAAM,GACN,OAAO,GACP,UAAU,GACV,WAAW,GACX,UAAU,GACV,OAAO,GACP,MAAM,GACN,KAAK,GACL,cAAc,GACd,QAAQ,CAAA;AAEZ,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,YAAY,GAAG,IAAI,CAAA;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,mBAAmB,GAAG;KAC/B,GAAG,IAAI,YAAY,GAAG,SAAS,GAAG,MAAM;CAC1C,CAAA;AAED,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;CACd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/platform-mock-canvas-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@types/node": "^20.0.0",
|
|
26
26
|
"msw": "^2.0.0",
|
|
27
27
|
"typescript": "^5.3.0",
|
|
28
|
-
"vite": "^
|
|
29
|
-
"vite-plugin-dts": "^
|
|
28
|
+
"vite": "^6.0.0",
|
|
29
|
+
"vite-plugin-dts": "^4.0.0"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "vite build",
|