@playcademy/sdk 0.2.5 → 0.2.6

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/index.d.ts CHANGED
@@ -57,6 +57,7 @@ interface ErrorResponseBody {
57
57
  * ```
58
58
  */
59
59
  declare class ApiError extends Error {
60
+ /** HTTP status code */
60
61
  readonly status: number;
61
62
  /**
62
63
  * API error code (e.g., "NOT_FOUND", "VALIDATION_FAILED").
@@ -4519,6 +4519,7 @@ interface ErrorResponseBody {
4519
4519
  * ```
4520
4520
  */
4521
4521
  declare class ApiError extends Error {
4522
+ /** HTTP status code */
4522
4523
  readonly status: number;
4523
4524
  /**
4524
4525
  * API error code (e.g., "NOT_FOUND", "VALIDATION_FAILED").
package/dist/server.js CHANGED
@@ -1,3 +1,23 @@
1
+ // src/server/guards.ts
2
+ var VALID_GRADES = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
3
+ var VALID_SUBJECTS = [
4
+ "Reading",
5
+ "Language",
6
+ "Vocabulary",
7
+ "Social Studies",
8
+ "Writing",
9
+ "Science",
10
+ "FastMath",
11
+ "Math",
12
+ "None"
13
+ ];
14
+ function isValidGrade(value) {
15
+ return typeof value === "number" && Number.isInteger(value) && VALID_GRADES.includes(value);
16
+ }
17
+ function isValidSubject(value) {
18
+ return typeof value === "string" && VALID_SUBJECTS.includes(value);
19
+ }
20
+
1
21
  // src/server/namespaces/timeback.ts
2
22
  function createTimebackNamespace(client) {
3
23
  function enrichActivityData(data) {
@@ -8,11 +28,11 @@ function createTimebackNamespace(client) {
8
28
  }
9
29
  return {
10
30
  endActivity: async (studentId, payload) => {
11
- if (!payload.activityData.grade) {
12
- throw new Error("activityData.grade is required for TimeBack integration");
31
+ if (!isValidGrade(payload.activityData.grade)) {
32
+ throw new Error("activityData.grade must be a valid grade level (-1 to 13)");
13
33
  }
14
- if (!payload.activityData.subject) {
15
- throw new Error("activityData.subject is required for TimeBack integration");
34
+ if (!isValidSubject(payload.activityData.subject)) {
35
+ throw new Error("activityData.subject must be a valid subject");
16
36
  }
17
37
  const enrichedActivityData = enrichActivityData(payload.activityData);
18
38
  return client["request"]("/api/timeback/end-activity", "POST", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/sdk",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -49,7 +49,7 @@
49
49
  "@playcademy/timeback": "0.0.1",
50
50
  "@playcademy/utils": "0.0.1",
51
51
  "@types/bun": "latest",
52
- "playcademy": "0.15.0",
52
+ "playcademy": "0.15.5",
53
53
  "rollup": "^4.50.2",
54
54
  "rollup-plugin-dts": "^6.2.3",
55
55
  "typescript": "^5.7.2"