@playcademy/sdk 0.24.1-beta.1 → 0.24.1-beta.2

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
@@ -297,8 +297,18 @@ interface ActivityData {
297
297
  subject: CaliperSubject;
298
298
  /** Activity display name (optional) */
299
299
  activityName?: string;
300
- /** Course identifier (auto-filled from config if not provided) */
300
+ /**
301
+ * Optional course to report against. When omitted, the SDK fills it from
302
+ * the student's enrollment for this grade/subject (preferring a
303
+ * hole-filling course). The platform uses it if it's the base course or one
304
+ * of that grade/subject's hole-filling courses, otherwise the base course.
305
+ */
301
306
  courseId?: string;
307
+ /**
308
+ * The student's enrollment in `courseId`. Filled by the SDK alongside an
309
+ * automatic `courseId`; recorded on hole-filling Caliper events.
310
+ */
311
+ enrollmentId?: string;
302
312
  /** Course display name (auto-filled from config if not provided) */
303
313
  courseName?: string;
304
314
  /** Student email address (optional) */
@@ -395,6 +405,8 @@ interface HeartbeatRequestBase {
395
405
  appName?: string;
396
406
  sensorUrl?: string;
397
407
  courseId?: string;
408
+ /** The student's enrollment in `courseId`, sent by the SDK with the course hint. */
409
+ enrollmentId?: string;
398
410
  courseName?: string;
399
411
  studentEmail?: string;
400
412
  };
@@ -448,6 +460,8 @@ interface EndActivityRequest {
448
460
  appName?: string;
449
461
  sensorUrl?: string;
450
462
  courseId?: string;
463
+ /** The student's enrollment in `courseId`, sent by the SDK with the course hint. */
464
+ enrollmentId?: string;
451
465
  courseName?: string;
452
466
  studentEmail?: string;
453
467
  };
@@ -477,7 +491,14 @@ interface TimebackPromotionResult {
477
491
  }
478
492
  interface EndActivityResponse {
479
493
  status: 'ok';
494
+ /** The course the activity was recorded against. */
480
495
  courseId: string;
496
+ /**
497
+ * `'hole_filling'` when the activity was recorded against a hole-filling
498
+ * course (the student is enrolled there, or the game passed its
499
+ * `courseId`); `'base'` otherwise.
500
+ */
501
+ courseKind?: GameTimebackIntegrationKind;
481
502
  xpAwarded: number;
482
503
  masteredUnits?: number;
483
504
  pctCompleteApp?: number;
@@ -3040,6 +3061,8 @@ interface EmbedTimebackRecording {
3040
3061
  subject: TimebackSubject;
3041
3062
  /** Course id hint, same semantics as `startActivity()`. */
3042
3063
  courseId?: string;
3064
+ /** The student's enrollment in `courseId`; filled with it automatically. */
3065
+ enrollmentId?: string;
3043
3066
  }
3044
3067
  /**
3045
3068
  * Everything a parent needs to resume an interrupted launch later. The
package/dist/index.js CHANGED
@@ -2289,6 +2289,23 @@ function createTimebackActivityTracker(client) {
2289
2289
  };
2290
2290
  }
2291
2291
 
2292
+ // src/core/timeback/course-hint.ts
2293
+ function withEnrollmentCourseHint(metadata, enrollments) {
2294
+ if (metadata.courseId !== undefined) {
2295
+ return metadata;
2296
+ }
2297
+ const matching = enrollments.filter((enrollment) => enrollment.grade === metadata.grade && enrollment.subject === metadata.subject);
2298
+ const enrollment = matching.find((candidate) => candidate.kind === "hole_filling") ?? matching[0];
2299
+ if (!enrollment) {
2300
+ return metadata;
2301
+ }
2302
+ return {
2303
+ ...metadata,
2304
+ courseId: enrollment.courseId,
2305
+ ...enrollment.id && { enrollmentId: enrollment.id }
2306
+ };
2307
+ }
2308
+
2292
2309
  // src/namespaces/game/embed.ts
2293
2310
  function createEmbedNamespace(client) {
2294
2311
  return {
@@ -2325,7 +2342,7 @@ function createEmbedNamespace(client) {
2325
2342
  const session = new ChildSession({
2326
2343
  slug: options.slug,
2327
2344
  container: options.container,
2328
- timeback: options.timeback,
2345
+ timeback: options.timeback && withEnrollmentCourseHint(options.timeback, client.timeback.user?.enrollments ?? []),
2329
2346
  resume: resume.envelope,
2330
2347
  resumeStore: resume.store,
2331
2348
  reporter: {
@@ -3023,7 +3040,7 @@ function createTimebackEngine(client) {
3023
3040
  activity: {
3024
3041
  currentRunId: activityTracker.currentRunId,
3025
3042
  isManuallyPaused: activityTracker.isActivityManuallyPaused,
3026
- start: activityTracker.startActivity,
3043
+ start: (metadata, options) => activityTracker.startActivity(withEnrollmentCourseHint(metadata, userStore.snapshot()?.enrollments ?? []), options),
3027
3044
  tryStartAssessment: activityTracker.tryStartAssessmentTracking,
3028
3045
  pause: activityTracker.pauseActivity,
3029
3046
  resume: activityTracker.resumeActivity,
@@ -3765,7 +3782,7 @@ async function request({
3765
3782
  return rawText && rawText.length > 0 ? rawText : undefined;
3766
3783
  }
3767
3784
  // src/version.ts
3768
- var SDK_VERSION = "0.24.1-beta.1";
3785
+ var SDK_VERSION = "0.24.1-beta.2";
3769
3786
 
3770
3787
  // src/clients/base.ts
3771
3788
  class PlaycademyBaseClient {
@@ -349,8 +349,18 @@ interface ActivityData {
349
349
  subject: CaliperSubject;
350
350
  /** Activity display name (optional) */
351
351
  activityName?: string;
352
- /** Course identifier (auto-filled from config if not provided) */
352
+ /**
353
+ * Optional course to report against. When omitted, the SDK fills it from
354
+ * the student's enrollment for this grade/subject (preferring a
355
+ * hole-filling course). The platform uses it if it's the base course or one
356
+ * of that grade/subject's hole-filling courses, otherwise the base course.
357
+ */
353
358
  courseId?: string;
359
+ /**
360
+ * The student's enrollment in `courseId`. Filled by the SDK alongside an
361
+ * automatic `courseId`; recorded on hole-filling Caliper events.
362
+ */
363
+ enrollmentId?: string;
354
364
  /** Course display name (auto-filled from config if not provided) */
355
365
  courseName?: string;
356
366
  /** Student email address (optional) */
@@ -909,6 +919,8 @@ interface HeartbeatRequestBase {
909
919
  appName?: string;
910
920
  sensorUrl?: string;
911
921
  courseId?: string;
922
+ /** The student's enrollment in `courseId`, sent by the SDK with the course hint. */
923
+ enrollmentId?: string;
912
924
  courseName?: string;
913
925
  studentEmail?: string;
914
926
  };
@@ -962,6 +974,8 @@ interface EndActivityRequest {
962
974
  appName?: string;
963
975
  sensorUrl?: string;
964
976
  courseId?: string;
977
+ /** The student's enrollment in `courseId`, sent by the SDK with the course hint. */
978
+ enrollmentId?: string;
965
979
  courseName?: string;
966
980
  studentEmail?: string;
967
981
  };
@@ -983,7 +997,14 @@ interface EndActivityRequest {
983
997
  }
984
998
  interface EndActivityResponse {
985
999
  status: 'ok';
1000
+ /** The course the activity was recorded against. */
986
1001
  courseId: string;
1002
+ /**
1003
+ * `'hole_filling'` when the activity was recorded against a hole-filling
1004
+ * course (the student is enrolled there, or the game passed its
1005
+ * `courseId`); `'base'` otherwise.
1006
+ */
1007
+ courseKind?: GameTimebackIntegrationKind;
987
1008
  xpAwarded: number;
988
1009
  masteredUnits?: number;
989
1010
  pctCompleteApp?: number;
@@ -6079,6 +6100,8 @@ interface EmbedTimebackRecording {
6079
6100
  subject: TimebackSubject;
6080
6101
  /** Course id hint, same semantics as `startActivity()`. */
6081
6102
  courseId?: string;
6103
+ /** The student's enrollment in `courseId`; filled with it automatically. */
6104
+ enrollmentId?: string;
6082
6105
  }
6083
6106
  /**
6084
6107
  * Everything a parent needs to resume an interrupted launch later. The
package/dist/internal.js CHANGED
@@ -2289,6 +2289,23 @@ function createTimebackActivityTracker(client) {
2289
2289
  };
2290
2290
  }
2291
2291
 
2292
+ // src/core/timeback/course-hint.ts
2293
+ function withEnrollmentCourseHint(metadata, enrollments) {
2294
+ if (metadata.courseId !== undefined) {
2295
+ return metadata;
2296
+ }
2297
+ const matching = enrollments.filter((enrollment) => enrollment.grade === metadata.grade && enrollment.subject === metadata.subject);
2298
+ const enrollment = matching.find((candidate) => candidate.kind === "hole_filling") ?? matching[0];
2299
+ if (!enrollment) {
2300
+ return metadata;
2301
+ }
2302
+ return {
2303
+ ...metadata,
2304
+ courseId: enrollment.courseId,
2305
+ ...enrollment.id && { enrollmentId: enrollment.id }
2306
+ };
2307
+ }
2308
+
2292
2309
  // src/namespaces/game/embed.ts
2293
2310
  function createEmbedNamespace(client) {
2294
2311
  return {
@@ -2325,7 +2342,7 @@ function createEmbedNamespace(client) {
2325
2342
  const session = new ChildSession({
2326
2343
  slug: options.slug,
2327
2344
  container: options.container,
2328
- timeback: options.timeback,
2345
+ timeback: options.timeback && withEnrollmentCourseHint(options.timeback, client.timeback.user?.enrollments ?? []),
2329
2346
  resume: resume.envelope,
2330
2347
  resumeStore: resume.store,
2331
2348
  reporter: {
@@ -3023,7 +3040,7 @@ function createTimebackEngine(client) {
3023
3040
  activity: {
3024
3041
  currentRunId: activityTracker.currentRunId,
3025
3042
  isManuallyPaused: activityTracker.isActivityManuallyPaused,
3026
- start: activityTracker.startActivity,
3043
+ start: (metadata, options) => activityTracker.startActivity(withEnrollmentCourseHint(metadata, userStore.snapshot()?.enrollments ?? []), options),
3027
3044
  tryStartAssessment: activityTracker.tryStartAssessmentTracking,
3028
3045
  pause: activityTracker.pauseActivity,
3029
3046
  resume: activityTracker.resumeActivity,
@@ -4685,7 +4702,7 @@ async function request({
4685
4702
  return rawText && rawText.length > 0 ? rawText : undefined;
4686
4703
  }
4687
4704
  // src/version.ts
4688
- var SDK_VERSION = "0.24.1-beta.1";
4705
+ var SDK_VERSION = "0.24.1-beta.2";
4689
4706
 
4690
4707
  // src/clients/base.ts
4691
4708
  class PlaycademyBaseClient {
@@ -319,8 +319,18 @@ interface ActivityData {
319
319
  subject: CaliperSubject;
320
320
  /** Activity display name (optional) */
321
321
  activityName?: string;
322
- /** Course identifier (auto-filled from config if not provided) */
322
+ /**
323
+ * Optional course to report against. When omitted, the SDK fills it from
324
+ * the student's enrollment for this grade/subject (preferring a
325
+ * hole-filling course). The platform uses it if it's the base course or one
326
+ * of that grade/subject's hole-filling courses, otherwise the base course.
327
+ */
323
328
  courseId?: string;
329
+ /**
330
+ * The student's enrollment in `courseId`. Filled by the SDK alongside an
331
+ * automatic `courseId`; recorded on hole-filling Caliper events.
332
+ */
333
+ enrollmentId?: string;
324
334
  /** Course display name (auto-filled from config if not provided) */
325
335
  courseName?: string;
326
336
  /** Student email address (optional) */
@@ -382,9 +392,22 @@ interface EndActivityPayload {
382
392
  * @module types/timeback/api
383
393
  */
384
394
 
395
+ /**
396
+ * `base` courses form a game's grade ladder (one active per grade and subject).
397
+ * `hole_filling` courses are remediation courses Timeback enrolls students into
398
+ * after a failed test; each sits beside a base course.
399
+ */
400
+ type GameTimebackIntegrationKind = 'base' | 'hole_filling';
385
401
  interface EndActivityResponse {
386
402
  status: 'ok';
403
+ /** The course the activity was recorded against. */
387
404
  courseId: string;
405
+ /**
406
+ * `'hole_filling'` when the activity was recorded against a hole-filling
407
+ * course (the student is enrolled there, or the game passed its
408
+ * `courseId`); `'base'` otherwise.
409
+ */
410
+ courseKind?: GameTimebackIntegrationKind;
388
411
  xpAwarded: number;
389
412
  masteredUnits?: number;
390
413
  pctCompleteApp?: number;
@@ -361,7 +361,7 @@ function extractApiErrorInfo(error) {
361
361
  }
362
362
 
363
363
  // src/version.ts
364
- var SDK_VERSION = "0.24.1-beta.1";
364
+ var SDK_VERSION = "0.24.1-beta.2";
365
365
 
366
366
  // src/server/request.ts
367
367
  async function makeApiRequest(opts) {
package/dist/server.d.ts CHANGED
@@ -319,8 +319,18 @@ interface ActivityData {
319
319
  subject: CaliperSubject;
320
320
  /** Activity display name (optional) */
321
321
  activityName?: string;
322
- /** Course identifier (auto-filled from config if not provided) */
322
+ /**
323
+ * Optional course to report against. When omitted, the SDK fills it from
324
+ * the student's enrollment for this grade/subject (preferring a
325
+ * hole-filling course). The platform uses it if it's the base course or one
326
+ * of that grade/subject's hole-filling courses, otherwise the base course.
327
+ */
323
328
  courseId?: string;
329
+ /**
330
+ * The student's enrollment in `courseId`. Filled by the SDK alongside an
331
+ * automatic `courseId`; recorded on hole-filling Caliper events.
332
+ */
333
+ enrollmentId?: string;
324
334
  /** Course display name (auto-filled from config if not provided) */
325
335
  courseName?: string;
326
336
  /** Student email address (optional) */
@@ -382,9 +392,22 @@ interface EndActivityPayload {
382
392
  * @module types/timeback/api
383
393
  */
384
394
 
395
+ /**
396
+ * `base` courses form a game's grade ladder (one active per grade and subject).
397
+ * `hole_filling` courses are remediation courses Timeback enrolls students into
398
+ * after a failed test; each sits beside a base course.
399
+ */
400
+ type GameTimebackIntegrationKind = 'base' | 'hole_filling';
385
401
  interface EndActivityResponse {
386
402
  status: 'ok';
403
+ /** The course the activity was recorded against. */
387
404
  courseId: string;
405
+ /**
406
+ * `'hole_filling'` when the activity was recorded against a hole-filling
407
+ * course (the student is enrolled there, or the game passed its
408
+ * `courseId`); `'base'` otherwise.
409
+ */
410
+ courseKind?: GameTimebackIntegrationKind;
388
411
  xpAwarded: number;
389
412
  masteredUnits?: number;
390
413
  pctCompleteApp?: number;
package/dist/server.js CHANGED
@@ -557,7 +557,7 @@ function extractApiErrorInfo(error) {
557
557
  }
558
558
 
559
559
  // src/version.ts
560
- var SDK_VERSION = "0.24.1-beta.1";
560
+ var SDK_VERSION = "0.24.1-beta.2";
561
561
 
562
562
  // src/server/request.ts
563
563
  async function makeApiRequest(opts) {
package/dist/types.d.ts CHANGED
@@ -356,8 +356,18 @@ interface ActivityData {
356
356
  subject: CaliperSubject;
357
357
  /** Activity display name (optional) */
358
358
  activityName?: string;
359
- /** Course identifier (auto-filled from config if not provided) */
359
+ /**
360
+ * Optional course to report against. When omitted, the SDK fills it from
361
+ * the student's enrollment for this grade/subject (preferring a
362
+ * hole-filling course). The platform uses it if it's the base course or one
363
+ * of that grade/subject's hole-filling courses, otherwise the base course.
364
+ */
360
365
  courseId?: string;
366
+ /**
367
+ * The student's enrollment in `courseId`. Filled by the SDK alongside an
368
+ * automatic `courseId`; recorded on hole-filling Caliper events.
369
+ */
370
+ enrollmentId?: string;
361
371
  /** Course display name (auto-filled from config if not provided) */
362
372
  courseName?: string;
363
373
  /** Student email address (optional) */
@@ -533,6 +543,8 @@ interface HeartbeatRequestBase {
533
543
  appName?: string;
534
544
  sensorUrl?: string;
535
545
  courseId?: string;
546
+ /** The student's enrollment in `courseId`, sent by the SDK with the course hint. */
547
+ enrollmentId?: string;
536
548
  courseName?: string;
537
549
  studentEmail?: string;
538
550
  };
@@ -586,6 +598,8 @@ interface EndActivityRequest {
586
598
  appName?: string;
587
599
  sensorUrl?: string;
588
600
  courseId?: string;
601
+ /** The student's enrollment in `courseId`, sent by the SDK with the course hint. */
602
+ enrollmentId?: string;
589
603
  courseName?: string;
590
604
  studentEmail?: string;
591
605
  };
@@ -615,7 +629,14 @@ interface TimebackPromotionResult {
615
629
  }
616
630
  interface EndActivityResponse {
617
631
  status: 'ok';
632
+ /** The course the activity was recorded against. */
618
633
  courseId: string;
634
+ /**
635
+ * `'hole_filling'` when the activity was recorded against a hole-filling
636
+ * course (the student is enrolled there, or the game passed its
637
+ * `courseId`); `'base'` otherwise.
638
+ */
639
+ courseKind?: GameTimebackIntegrationKind;
619
640
  xpAwarded: number;
620
641
  masteredUnits?: number;
621
642
  pctCompleteApp?: number;
@@ -4013,6 +4034,8 @@ interface EmbedTimebackRecording {
4013
4034
  subject: TimebackSubject;
4014
4035
  /** Course id hint, same semantics as `startActivity()`. */
4015
4036
  courseId?: string;
4037
+ /** The student's enrollment in `courseId`; filled with it automatically. */
4038
+ enrollmentId?: string;
4016
4039
  }
4017
4040
  /**
4018
4041
  * Everything a parent needs to resume an interrupted launch later. The
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/sdk",
3
- "version": "0.24.1-beta.1",
3
+ "version": "0.24.1-beta.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {