@playcademy/sdk 0.20.1-beta.2 → 0.20.1-beta.3

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/types.d.ts CHANGED
@@ -1,12 +1,4 @@
1
- import * as _playcademy_types from '@playcademy/types';
2
- import { GameManifest, LocalDayContext } from '@playcademy/types';
3
- export { AuthenticatedUser, DeploySource, DeveloperStatusEnumType, DeveloperStatusResponse, DeveloperStatusValue, GameCourseMetrics, GameLeaderboardEntry, GameManifest, GameMetricComparisonKind, GameMetricComparisonMetric, GameMetricComparisonRow, GameMetricComparisonRowStatus, GameMetricsProxyResponse, GameMetricsResponse, GameMetricsUnsupportedReason, GamePlatform, GameReleaseResponse, GameRunMetrics, GameRunMetricsComparison, GameRunMetricsComparisonStatus, GameRunMetricsComparisonSummary, GameTimebackIntegration, GameType, GameUser, LeaderboardEntry, LeaderboardOptions, LeaderboardTimeframe, LocalDayContext, LocalDaySource, ManifestV1, ManifestV2, ManifestVersions, PopulateStudentResponse, Release, ReleasesResponse, SkillMasterySource, SkillStatus, SkillStatusLookupResult, SkillStatusRequest, SkillStatusRequestingGame, SkillStatusResponse, SkillStatusResult, SkillStatusUnsupportedReason, UserEnrollment, UserInfo, UserOrganization, UserRank, UserRankResponse, UserRoleEnumType, UserScore, UserTimebackData } from '@playcademy/types';
4
- import { TimebackCourseConfig, CourseConfig, OrganizationConfig, ComponentConfig, ResourceConfig, ComponentResourceConfig, TimebackGrade, TimebackSubject, ELevel, EndActivityRequest, HeartbeatRequest, EndActivityScoreData, EndActivityResponse } from '@playcademy/types/timeback';
5
- export { AssessmentAttemptSnapshot, AssessmentAwardRecord, AssessmentFinalizeResult, AssessmentFlow, AssessmentItemGrading, AssessmentItemOutcome, AssessmentItemSubmission, AssessmentMasteryAward, AssessmentPreparationResult, AssessmentResponseUpdate, AssessmentResponseValue, AssessmentResponses, AssessmentReviewStandard, AssessmentSaveResult, AssessmentScore, AssessmentStandardRef, AssessmentSubmitResult, AssessmentTranscript, ConventionalAssessmentAttemptSnapshot, ConventionalAssessmentSubmitResult, DiagnosticAssessmentItemReceipt, DiagnosticAssessmentSubmitResult, DiagnosticRoutingSnapshot, DiagnosticRoutingTrackSnapshot, ELevel, FinalizeAssessmentInput, MasteryAssessmentSubmitResult, PlatformRoutedDiagnosticAttemptSnapshot, PlatformRoutedDiagnosticSelectionContext, PlayableAssessment, PlayableAssessmentAttemptSnapshot, PlayableAssessmentChoice, PlayableAssessmentGraphic, PlayableAssessmentHotspot, PlayableAssessmentInteraction, PlayableAssessmentItem, PlayableChoiceInteraction, PlayableContentNode, PlayableGapMatchChoice, PlayableGapMatchInteraction, PlayableInlineChoiceInteraction, PlayableMatchChoice, PlayableMatchInteraction, PlayableOrderInteraction, RecordAssessmentProgressInput, ResumeAssessmentInput, SaveAssessmentInput, SettledAssessmentAttemptSnapshot, StandardsReviewSelectionContext, StartAssessmentInput, StartAssessmentOptions, StartDiagnosticAssessmentInput, SubmitAssessmentInput, SubmitAssessmentItemInput, SubmitAssessmentItemResult, SubmitDiagnosticAssessmentItemInput, SubmitDiagnosticAssessmentItemResult } from '@playcademy/types/timeback';
6
- import { TimebackUserRole, UserEnrollment, UserOrganization, UserInfo } from '@playcademy/types/user';
7
- import { GamePermission, AUTH_PROVIDER_IDS } from '@playcademy/constants';
8
1
  import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
9
- import { DomainValidationRecords } from '@playcademy/types/game';
10
2
  import { z } from 'zod';
11
3
 
12
4
  /**
@@ -31,6 +23,1712 @@ interface RetryPolicy {
31
23
  retryDelaysMs?: readonly number[];
32
24
  }
33
25
 
26
+ /**
27
+ * Authentication Constants
28
+ *
29
+ * Constants related to authentication providers.
30
+ */
31
+ /**
32
+ * Auth Provider Constants
33
+ */
34
+ declare const AUTH_PROVIDER_IDS: {
35
+ readonly TIMEBACK: 'timeback';
36
+ readonly TIMEBACK_LTI: 'timeback-lti';
37
+ readonly PLAYCADEMY: 'playcademy';
38
+ };
39
+ /**
40
+ * Platform user roles.
41
+ */
42
+ declare const USER_ROLES: {
43
+ readonly ADMIN: 'admin';
44
+ readonly PLAYER: 'player';
45
+ readonly DEVELOPER: 'developer';
46
+ readonly TEACHER: 'teacher';
47
+ };
48
+ type UserRole = (typeof USER_ROLES)[keyof typeof USER_ROLES];
49
+
50
+ /**
51
+ * Browser permissions a game may declare and the hub may delegate to its
52
+ * iframe. Opt-in per game because a delegated grant keys to the hub's
53
+ * top-level origin: one player grant would otherwise reach every embedded
54
+ * game. Baseline features (fullscreen, autoplay, gamepad) are delegated to
55
+ * all games and are not part of this set.
56
+ */
57
+ declare const GAME_PERMISSIONS: readonly ['microphone', 'camera'];
58
+ type GamePermission = (typeof GAME_PERMISSIONS)[number];
59
+
60
+ /** Every status an answering game may report for a skill. */
61
+ declare const SKILL_STATUSES: readonly ['locked', 'unlocked', 'in_progress', 'mastered', 'unknown_skill'];
62
+ /** Every way a `mastered` status may have been reached. */
63
+ declare const SKILL_MASTERY_SOURCES: readonly ['assessment', 'placement', 'test_out', 'manual'];
64
+
65
+ /**
66
+ * Valid grade levels per AE OneRoster GradeEnum.
67
+ * -1 = Pre-K, 0 = Kindergarten, 1-12 = Grades 1-12, 13 = AP
68
+ */
69
+ declare const TIMEBACK_GRADES: readonly [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
70
+ /**
71
+ * The TimeBack subject vocabulary, carried on courses, activity data, and
72
+ * Caliper events alike. 'None' is canonical: TimeBack accepts it as a course
73
+ * subject and uses it as the fallback for unknown or missing subjects.
74
+ */
75
+ declare const TIMEBACK_SUBJECTS: readonly ['Reading', 'Language', 'Vocabulary', 'Social Studies', 'Writing', 'Science', 'FastMath', 'Math', 'None'];
76
+ /**
77
+ * Playcademy's course-specific meaning for reusable QTI test content.
78
+ * Result writers translate this to OneRoster assessment-result
79
+ * `metadata.testType`; it intentionally does not become metadata on the QTI
80
+ * test itself.
81
+ */
82
+ declare const ASSESSMENT_PURPOSES: readonly ['end_of_course', 'diagnostic', 'review', 'mastery'];
83
+ /**
84
+ * Schema version of the playable assessment payload handed to a game.
85
+ *
86
+ * Distinct from an assessment's content revision: this identifies the shape of
87
+ * the contract, not the content inside it. Bumped when the payload gains a
88
+ * field or changes the meaning of one — never for content edits.
89
+ *
90
+ * Intended for diagnostics and for telling "this host does not support the
91
+ * field" apart from "this item does not use it". Games should branch on whether
92
+ * a field is present, not on this number: the content vocabularies are open by
93
+ * design, so feature detection keeps working across versions where a comparison
94
+ * does not.
95
+ */
96
+ declare const PLAYCADEMY_ASSESSMENT_CONTRACT_VERSION: 2;
97
+
98
+ /**
99
+ * User Types
100
+ *
101
+ * Enums, DTOs and API response types. Database row types are in @playcademy/data/types.
102
+ *
103
+ * @module types/user
104
+ */
105
+
106
+ type UserRoleEnumType = UserRole;
107
+ type DeveloperStatusEnumType = 'none' | 'pending' | 'approved';
108
+ type DeveloperStatusValue = DeveloperStatusEnumType;
109
+ type TimebackUserRole = 'administrator' | 'aide' | 'guardian' | 'parent' | 'proctor' | 'relative' | 'student' | 'teacher';
110
+ type TimebackOrgType = 'department' | 'school' | 'district' | 'local' | 'state' | 'national';
111
+ interface UserEnrollment {
112
+ gameId?: string;
113
+ courseId: string;
114
+ id?: string;
115
+ grade: number;
116
+ subject: string;
117
+ orgId?: string;
118
+ }
119
+ interface UserOrganization {
120
+ id: string;
121
+ name: string | null;
122
+ type: TimebackOrgType | string;
123
+ isPrimary: boolean;
124
+ }
125
+ interface TimebackStudentProfile {
126
+ role: TimebackUserRole;
127
+ organizations: UserOrganization[];
128
+ }
129
+ interface UserTimebackData extends TimebackStudentProfile {
130
+ id: string;
131
+ enrollments: UserEnrollment[];
132
+ }
133
+ type LocalDaySource = 'browser_last_seen' | 'platform_default';
134
+ interface LocalDayContext {
135
+ timeZone: string;
136
+ source: LocalDaySource;
137
+ /** ISO 8601 timestamp for the last persisted timezone observation. */
138
+ observedAt: string | null;
139
+ }
140
+ /**
141
+ * OpenID Connect UserInfo claims (NOT a database row).
142
+ */
143
+ interface UserInfo {
144
+ sub: string;
145
+ email: string;
146
+ name: string | null;
147
+ email_verified?: boolean;
148
+ given_name?: string;
149
+ family_name?: string;
150
+ issuer?: string;
151
+ lti_roles?: unknown;
152
+ lti_context?: unknown;
153
+ lti_resource_link?: unknown;
154
+ timeback_id?: string;
155
+ }
156
+ interface DeveloperStatusResponse {
157
+ status: DeveloperStatusEnumType;
158
+ }
159
+ interface DemoProfile {
160
+ displayName: string;
161
+ isDefault: boolean;
162
+ }
163
+ /**
164
+ * Update shape for `client.demo.profile.update(...)`.
165
+ *
166
+ * Kept as a named type so callers typed against it pick up new fields
167
+ * automatically, but `displayName` is the only updatable field today and
168
+ * the server's `DemoProfileSchema` requires it — a no-field payload would
169
+ * 400 at runtime, so we model that at the type level too. When additional
170
+ * fields land, make them required/optional individually based on server
171
+ * validation, rather than blanket-optional.
172
+ */
173
+ interface DemoProfileUpdate {
174
+ displayName: string;
175
+ }
176
+ /**
177
+ * Authenticated user for API responses.
178
+ * Differs from UserRow: omits timebackId, adds hasTimebackAccount and timeback.
179
+ */
180
+ interface AuthenticatedUser {
181
+ id: string;
182
+ email: string;
183
+ emailVerified: boolean;
184
+ name: string | null;
185
+ image: string | null;
186
+ username: string | null;
187
+ role: UserRoleEnumType;
188
+ developerStatus: DeveloperStatusEnumType;
189
+ createdAt: Date;
190
+ updatedAt: Date;
191
+ hasTimebackAccount: boolean;
192
+ localDay: LocalDayContext;
193
+ timeback?: UserTimebackData;
194
+ }
195
+ interface GameUser {
196
+ id: string;
197
+ name: string | null;
198
+ role: UserRoleEnumType;
199
+ username: string | null;
200
+ email: string | null;
201
+ localDay: LocalDayContext;
202
+ timeback?: UserTimebackData;
203
+ }
204
+
205
+ /**
206
+ * Game Types
207
+ *
208
+ * Literal types and API DTOs. Database row types are in @playcademy/data/types.
209
+ *
210
+ * @module types/game
211
+ */
212
+
213
+ type GameType = 'hosted' | 'external';
214
+ type GamePlatform = 'web' | 'godot' | (string & {});
215
+ /**
216
+ * Game manifest file format (manifest.json).
217
+ * Note: createdAt is a string here because it's parsed from JSON file.
218
+ */
219
+ interface ManifestV1 {
220
+ version: '1';
221
+ platform: string;
222
+ createdAt: string;
223
+ }
224
+ interface ManifestVersions {
225
+ vitePlugin?: string;
226
+ sdk?: string;
227
+ cli?: string;
228
+ vite?: string;
229
+ godotSdk?: string;
230
+ godot?: string;
231
+ }
232
+ interface ManifestV2 {
233
+ version: '2';
234
+ platform: string;
235
+ createdAt: string;
236
+ gameVersion?: string;
237
+ versions: ManifestVersions;
238
+ }
239
+ type GameManifest = ManifestV1 | ManifestV2;
240
+ /**
241
+ * Git provenance of the working tree a deploy was run from (PLA-294).
242
+ *
243
+ * Captured by the CLI at deploy time and persisted verbatim on the deploy
244
+ * job, so "which commit is running" is answerable from the platform record.
245
+ * Every field is nullable: a tree with no git, no remote, or a detached HEAD
246
+ * is recorded honestly rather than refused. Recorded per deploy, never
247
+ * pinned to the game — a fork deployed under the same slug shows the fork.
248
+ */
249
+ interface DeploySource {
250
+ /** Normalized `https://github.com/<org>/<repo>`; null when no remote or unparseable */
251
+ repository: string | null;
252
+ /** Full 40-char SHA of HEAD; null when not in a git tree */
253
+ commit: string | null;
254
+ /** Current branch name; null on detached HEAD outside CI */
255
+ branch: string | null;
256
+ /** True when the tree had uncommitted changes — the SHA does not describe what shipped */
257
+ dirty: boolean;
258
+ /**
259
+ * True when the uploaded build artifact lives outside the git tree the
260
+ * other fields describe (`--build ~/Downloads/game.zip`). The commit is
261
+ * still the deployer's tree, but it may not be what produced the artifact.
262
+ */
263
+ externalBuild: boolean;
264
+ }
265
+ /**
266
+ * One successful deploy of a game's worker, as the open releases surface
267
+ * describes it: what is running and which commit produced it.
268
+ *
269
+ * This shape is parsed by external automation. Every field is present on
270
+ * every entry — nullable, never absent — and nothing from the deploy job
271
+ * beyond its git provenance and completion time is exposed. No deployer
272
+ * identity, no schema state, no secrets manifest.
273
+ */
274
+ interface Release {
275
+ slug: string;
276
+ /** Where the game is served; null when the platform has no URL for it */
277
+ url: string | null;
278
+ /**
279
+ * Git provenance the deploying CLI captured. Null for deploys that
280
+ * predate provenance capture, so the fleet list is complete on day one
281
+ * and a consumer can tell "unknown" from "not in git".
282
+ */
283
+ source: DeploySource | null;
284
+ /** When the deploy succeeded, ISO 8601 */
285
+ deployedAt: string;
286
+ }
287
+ /** GET /api/releases — the current release of every game */
288
+ interface ReleasesResponse {
289
+ releases: Release[];
290
+ }
291
+ /** GET /api/releases/:slug — one game's current release and, on request, its recent history */
292
+ interface GameReleaseResponse {
293
+ /** The current release; null when the game has never deployed successfully */
294
+ current: Release | null;
295
+ /**
296
+ * The last N successful deploys, newest first, current included. Only
297
+ * present when `?history=N` was requested.
298
+ */
299
+ history?: Release[];
300
+ }
301
+ interface DomainValidationRecords {
302
+ ownership?: {
303
+ name?: string;
304
+ value?: string;
305
+ type?: string;
306
+ };
307
+ ssl?: {
308
+ txt_name?: string;
309
+ txt_value?: string;
310
+ }[];
311
+ }
312
+
313
+ /**
314
+ * Leaderboard Types
315
+ *
316
+ * @module types/leaderboard
317
+ */
318
+ type LeaderboardTimeframe = 'all_time' | 'monthly' | 'weekly' | 'daily';
319
+ interface LeaderboardOptions {
320
+ timeframe?: LeaderboardTimeframe;
321
+ limit?: number;
322
+ offset?: number;
323
+ gameId?: string;
324
+ }
325
+ interface LeaderboardEntry {
326
+ rank: number;
327
+ userId: string;
328
+ username: string;
329
+ userImage?: string | null;
330
+ score: number;
331
+ achievedAt: Date;
332
+ metadata?: Record<string, unknown>;
333
+ gameId?: string;
334
+ gameTitle?: string;
335
+ gameSlug?: string;
336
+ }
337
+ interface UserRank {
338
+ rank: number;
339
+ totalPlayers: number;
340
+ score: number;
341
+ percentile: number;
342
+ }
343
+ interface UserRankResponse {
344
+ rank: number;
345
+ score: number;
346
+ userId: string;
347
+ }
348
+ interface UserScore {
349
+ id: string;
350
+ score: number;
351
+ achievedAt: Date;
352
+ metadata?: Record<string, unknown>;
353
+ gameId: string;
354
+ gameTitle: string;
355
+ gameSlug: string;
356
+ }
357
+ /**
358
+ * Leaderboard entry with required game context.
359
+ * Used when fetching leaderboards for a specific game.
360
+ */
361
+ interface GameLeaderboardEntry {
362
+ rank: number;
363
+ userId: string;
364
+ username: string;
365
+ userImage?: string | null;
366
+ score: number;
367
+ achievedAt: Date;
368
+ metadata?: Record<string, unknown>;
369
+ gameId: string;
370
+ gameTitle: string;
371
+ gameSlug: string;
372
+ }
373
+
374
+ /**
375
+ * Skill Status Types
376
+ *
377
+ * Contract for cross-game skill status queries. An answering game exports
378
+ * `getSkillStatus` from `server/lib/skills.ts`; the platform calls its
379
+ * reserved `/__playcademy/skills/status` route on behalf of another game.
380
+ *
381
+ * @module types/skills
382
+ */
383
+
384
+ /**
385
+ * Current status of one skill for one student, as judged by the answering game.
386
+ *
387
+ * - `locked`: the student can't work on the skill yet in this game.
388
+ * - `unlocked`: available to the student, but no progress yet.
389
+ * - `in_progress`: started, not mastered.
390
+ * - `mastered`: currently meets this game's mastery bar, including by placement.
391
+ * - `unknown_skill`: the skill ID isn't recognized. Never report an unrecognized
392
+ * skill as `locked`.
393
+ */
394
+ type SkillStatus = (typeof SKILL_STATUSES)[number];
395
+ /** How a `mastered` status was reached. */
396
+ type SkillMasterySource = (typeof SKILL_MASTERY_SOURCES)[number];
397
+ interface SkillStatusResult {
398
+ /** Skill ID, lowercase. */
399
+ skill: string;
400
+ /** Current status. */
401
+ status: SkillStatus;
402
+ /** How mastery was reached. Only allowed when `status` is `mastered`. */
403
+ source?: SkillMasterySource;
404
+ /** ISO 8601 time of the evidence behind this status. */
405
+ asOf?: string;
406
+ }
407
+ /** Response returned by an answering game's `getSkillStatus` handler. */
408
+ interface SkillStatusResponse {
409
+ /** Student identifier (Playcademy user ID). Must match the requested student. */
410
+ studentId: string;
411
+ /** One result per skill the handler was asked about. */
412
+ results: SkillStatusResult[];
413
+ }
414
+ /** The game asking for skill status, as identified by the platform. */
415
+ interface SkillStatusRequestingGame {
416
+ id: string;
417
+ slug: string;
418
+ }
419
+ /** Body of `POST /api/skills/status`, sent by the asking game's worker. */
420
+ interface SkillStatusRequest {
421
+ /** Slug of the game to ask. */
422
+ game: string;
423
+ /** Playcademy user ID of the student. */
424
+ studentId: string;
425
+ /** Skill IDs to ask about. Normalized (trimmed, lowercased) and de-duplicated. */
426
+ skills: string[];
427
+ }
428
+ /** Why the answering game couldn't answer. */
429
+ type SkillStatusUnsupportedReason = 'not_implemented' | 'no_active_deployment' | 'timeout' | 'fetch_failed' | 'invalid_response';
430
+ /**
431
+ * What the asking game gets back. When `supported` is false, fall back to
432
+ * the game's own default (usually: treat the skills as not mastered).
433
+ */
434
+ type SkillStatusLookupResult = {
435
+ supported: true;
436
+ results: SkillStatusResult[];
437
+ } | {
438
+ supported: false;
439
+ reason: SkillStatusUnsupportedReason;
440
+ };
441
+
442
+ /**
443
+ * TimeBack Enums & Literal Types
444
+ *
445
+ * Basic type definitions used throughout the TimeBack integration. Unions
446
+ * derive from the canonical value lists in @playcademy/constants (type-only
447
+ * imports, so this package ships no runtime code).
448
+ *
449
+ * @module types/timeback/types
450
+ */
451
+
452
+ /**
453
+ * The TimeBack subject vocabulary. 'None' is canonical: TimeBack accepts it
454
+ * on courses and uses it as the fallback for unknown or missing subjects.
455
+ */
456
+ type TimebackSubject = (typeof TIMEBACK_SUBJECTS)[number];
457
+ /**
458
+ * Grade levels per AE OneRoster GradeEnum.
459
+ * -1 = Pre-K, 0 = Kindergarten, 1-12 = Grades 1-12, 13 = AP
460
+ */
461
+ type TimebackGrade = (typeof TIMEBACK_GRADES)[number];
462
+ /**
463
+ * Platform pedagogy levels for a single lesson of instruction.
464
+ * E1 teaches, E2/E3 practice and remediate, E4 is the mastery check.
465
+ */
466
+ type ELevel = 'E1' | 'E2' | 'E3' | 'E4';
467
+ /**
468
+ * Valid Caliper subject values. The same vocabulary as OneRoster subjects.
469
+ */
470
+ type CaliperSubject = (typeof TIMEBACK_SUBJECTS)[number];
471
+ /**
472
+ * OneRoster organization types.
473
+ */
474
+ type OrganizationType = 'department' | 'school' | 'district' | 'local' | 'state' | 'national';
475
+ /**
476
+ * Lesson types for PowerPath integration.
477
+ */
478
+ type LessonType = 'powerpath-100' | 'quiz' | 'test-out' | 'placement' | 'unit-test' | 'alpha-read-article' | null;
479
+
480
+ /**
481
+ * TimeBack Configuration Types
482
+ *
483
+ * Configuration interfaces for Organization, Course, Component,
484
+ * Resource, and complete TimeBack setup.
485
+ *
486
+ * @module types/timeback/config
487
+ */
488
+
489
+ /**
490
+ * Organization configuration for TimeBack (user input - optionals allowed)
491
+ */
492
+ interface OrganizationConfig {
493
+ /** Display name for your organization */
494
+ name?: string;
495
+ /** Organization type */
496
+ type?: OrganizationType;
497
+ /** Unique identifier (defaults to Playcademy's org) */
498
+ identifier?: string;
499
+ }
500
+ /**
501
+ * Course goals for daily student targets
502
+ */
503
+ interface CourseGoals {
504
+ /** Target XP students should earn per day */
505
+ dailyXp?: number;
506
+ /** Target lessons per day */
507
+ dailyLessons?: number;
508
+ /** Target active minutes per day */
509
+ dailyActiveMinutes?: number;
510
+ /** Target accuracy percentage */
511
+ dailyAccuracy?: number;
512
+ /** Target mastered units per day */
513
+ dailyMasteredUnits?: number;
514
+ }
515
+ /**
516
+ * Course metrics and totals
517
+ */
518
+ interface CourseMetrics {
519
+ /** Total XP available in the course */
520
+ totalXp?: number;
521
+ /** Total lessons/activities in the course */
522
+ totalLessons?: number;
523
+ /** Total number of grade levels covered by this course */
524
+ totalGrades?: number;
525
+ /** The type of course (e.g. 'optional', 'hole-filling', 'base') */
526
+ courseType?: 'base' | 'hole-filling' | 'optional' | 'Base' | 'Hole-Filling' | 'Optional';
527
+ /** Indicates whether the course is supplemental content */
528
+ isSupplemental?: boolean;
529
+ }
530
+ /**
531
+ * Complete course metadata structure
532
+ */
533
+ interface CourseMetadata {
534
+ /** Define the type of course and priority for the student */
535
+ courseType?: 'base' | 'hole-filling' | 'optional';
536
+ /** Boolean value to determine if a course is supplemental to a base course */
537
+ isSupplemental?: boolean;
538
+ /** Boolean value to determine if a course is custom to an individual student */
539
+ isCustom?: boolean;
540
+ /** Signals whether a course is in production with students */
541
+ publishStatus?: 'draft' | 'testing' | 'published' | 'deactivated';
542
+ /** Whether this course appears in the TimeBack catalog for teachers and parents */
543
+ timebackVisible?: boolean;
544
+ /** Who to contact when issues reported with questions */
545
+ contactEmail?: string;
546
+ /** Primary app identifier */
547
+ primaryApp?: string;
548
+ /** Learning goals for students */
549
+ goals?: CourseGoals;
550
+ /** Course metrics and totals */
551
+ metrics?: CourseMetrics;
552
+ /** Vendor-specific metadata (e.g., AlphaLearn) */
553
+ [key: string]: unknown;
554
+ }
555
+ /**
556
+ * Course configuration for TimeBack (user input)
557
+ */
558
+ interface CourseConfig {
559
+ /** Allocated OneRoster sourcedId (set after creation) */
560
+ sourcedId?: string;
561
+ /** Course title (defaults to game name) */
562
+ title?: string;
563
+ /** Subjects (REQUIRED for TimeBack integration) */
564
+ subjects: TimebackSubject[];
565
+ /** Used when recording progress/sessions if not explicitly specified per event. */
566
+ defaultSubject?: TimebackSubject;
567
+ /** Grade levels (REQUIRED for TimeBack integration) */
568
+ grades: TimebackGrade[];
569
+ /** Short course code (optional, auto-generated) */
570
+ courseCode?: string;
571
+ /** Course level (auto-derived from grades) */
572
+ level?: 'Elementary' | 'Middle' | 'High' | 'AP' | string;
573
+ /** Grading system */
574
+ gradingScheme?: 'STANDARD';
575
+ /** Total XP available in this course (REQUIRED before setup) */
576
+ totalXp?: number | null;
577
+ /** Total masterable units in this course (REQUIRED before setup) */
578
+ masterableUnits?: number | null;
579
+ /** Custom Playcademy metadata */
580
+ metadata?: CourseMetadata;
581
+ }
582
+ /**
583
+ * Component configuration for TimeBack (user input)
584
+ */
585
+ interface ComponentConfig {
586
+ /** Component title (defaults to "{course.title} Activities") */
587
+ title?: string;
588
+ /** Display order */
589
+ sortOrder?: number;
590
+ /** Required prior components */
591
+ prerequisites?: string[];
592
+ /** How prerequisites work */
593
+ prerequisiteCriteria?: 'ALL' | 'ANY';
594
+ }
595
+ /**
596
+ * Playcademy-specific resource extensions
597
+ */
598
+ interface PlaycademyResourceMetadata {
599
+ /** Mastery configuration for tracking discrete learning units */
600
+ mastery?: {
601
+ /** Total number of masterable units in the resource */
602
+ masterableUnits: number;
603
+ /** Type of mastery unit for semantic clarity */
604
+ unitType?: 'level' | 'rank' | 'skill' | 'module';
605
+ };
606
+ }
607
+ /**
608
+ * Resource configuration for TimeBack (user input)
609
+ */
610
+ interface ResourceConfig {
611
+ /** Resource title (defaults to "{course.title} Game") */
612
+ title?: string;
613
+ /** Internal resource ID (auto-generated from package.json) */
614
+ vendorResourceId?: string;
615
+ /** Vendor identifier */
616
+ vendorId?: string;
617
+ /** Application identifier */
618
+ applicationId?: string;
619
+ /** Resource roles */
620
+ roles?: ('primary' | 'secondary')[];
621
+ /** Resource importance */
622
+ importance?: 'primary' | 'secondary';
623
+ /** Interactive resource metadata */
624
+ metadata?: {
625
+ /** Resource type */
626
+ type?: 'interactive';
627
+ /** Launch URL (defaults to Playcademy game URL) */
628
+ launchUrl?: string;
629
+ /** Platform name */
630
+ toolProvider?: string;
631
+ /** Teaching method */
632
+ instructionalMethod?: 'exploratory' | 'direct-instruction';
633
+ /** Subject area */
634
+ subject?: TimebackSubject;
635
+ /** Target grades */
636
+ grades?: TimebackGrade[];
637
+ /** Content language */
638
+ language?: string;
639
+ /** Base XP for completion */
640
+ xp?: number;
641
+ /** Playcademy-specific extensions */
642
+ playcademy?: PlaycademyResourceMetadata;
643
+ };
644
+ }
645
+ /**
646
+ * Component Resource link configuration (user input)
647
+ */
648
+ interface ComponentResourceConfig {
649
+ /** Link title (defaults to "{resource.title} Activity") */
650
+ title?: string;
651
+ /** Display order */
652
+ sortOrder?: number;
653
+ /** Lesson type for PowerPath integration */
654
+ lessonType?: LessonType;
655
+ }
656
+ interface TimebackCourseConfig {
657
+ subject: string;
658
+ grade: number;
659
+ }
660
+
661
+ /**
662
+ * TimeBack Client SDK DTOs
663
+ *
664
+ * Data transfer objects for the TimeBack client SDK including
665
+ * progress tracking, session management, and activity completion.
666
+ *
667
+ * Note: TimebackClientConfig lives in @playcademy/timeback as it's
668
+ * SDK configuration, not a DTO.
669
+ *
670
+ * @module types/timeback/client
671
+ */
672
+
673
+ /**
674
+ * Known extensions for TimeBack Activity Metrics Collection
675
+ */
676
+ interface TimebackActivityExtensions {
677
+ /** Percentage complete (0-100) for the app course */
678
+ pctCompleteApp?: number;
679
+ /** Allow other arbitrary extensions */
680
+ [key: string]: unknown;
681
+ }
682
+ interface MasteryWriteWarning {
683
+ code: 'MASTERY_WRITE_CAPPED';
684
+ message: string;
685
+ currentMasteredUnits: number;
686
+ attemptedMasteredUnits: number;
687
+ appliedMasteredUnits: number;
688
+ storedMasteredUnits: number;
689
+ masterableUnits: number;
690
+ }
691
+ /**
692
+ * Activity data for ending an activity
693
+ */
694
+ interface ActivityData {
695
+ /** Unique activity identifier (required) */
696
+ activityId: string;
697
+ /** Grade level for this activity (required for multi-grade course routing) */
698
+ grade: number;
699
+ /** Subject area (required for multi-grade course routing) */
700
+ subject: CaliperSubject;
701
+ /** Activity display name (optional) */
702
+ activityName?: string;
703
+ /** Course identifier (auto-filled from config if not provided) */
704
+ courseId?: string;
705
+ /** Course display name (auto-filled from config if not provided) */
706
+ courseName?: string;
707
+ /** Student email address (optional) */
708
+ studentEmail?: string;
709
+ /** Application name for Caliper events (defaults to 'Game') */
710
+ appName?: string;
711
+ /** Sensor URL for Caliper events (defaults to baseUrl) */
712
+ sensorUrl?: string;
713
+ }
714
+ /**
715
+ * Score data for ending an activity
716
+ */
717
+ interface EndActivityScoreData {
718
+ /** Number of questions answered correctly */
719
+ correctQuestions: number;
720
+ /** Total number of questions */
721
+ totalQuestions: number;
722
+ /**
723
+ * XP earned for this activity.
724
+ *
725
+ * Required when the game reports directly (platform, demo, standalone).
726
+ * A child-launched game may omit it: narrow the client with the SDK's
727
+ * `isChildLaunched()` for the relaxed signature. The parent game
728
+ * decides the award, and a value provided here travels only as the
729
+ * `childXpSuggested` audit suggestion.
730
+ */
731
+ xpAwarded: number;
732
+ /**
733
+ * Incremental learning units mastered this session.
734
+ *
735
+ * Cannot be used with masteredUnitsAbsolute. When a course has mastery
736
+ * tracking configured, the platform bounds submissions that would move
737
+ * the student below 0 or above the configured masterableUnits maximum and
738
+ * returns warning metadata.
739
+ */
740
+ masteredUnits?: number;
741
+ /**
742
+ * Absolute total of mastered units.
743
+ *
744
+ * The platform computes the delta from the current value. Cannot be used
745
+ * with masteredUnits. When a course has mastery tracking configured, the
746
+ * platform bounds values outside 0..masterableUnits and returns warning
747
+ * metadata.
748
+ */
749
+ masteredUnitsAbsolute?: number;
750
+ /** Optional arbitrary extensions to include in the Caliper event */
751
+ extensions?: TimebackActivityExtensions;
752
+ }
753
+
754
+ /**
755
+ * Game-side learning metrics for a single student.
756
+ *
757
+ * Returned by opted-in game workers from their reserved
758
+ * `/__playcademy/metrics` route.
759
+ */
760
+ interface GameMetricsResponse {
761
+ /** Student identifier (Playcademy user ID). */
762
+ studentId: string;
763
+ /** Student email, when available to the game. */
764
+ email?: string;
765
+ /** Per-course metrics grouped by TimeBack grade and subject. */
766
+ courses: GameCourseMetrics[];
767
+ }
768
+ interface GameCourseMetrics {
769
+ /** Grade level matching the game's TimeBack integration. */
770
+ grade: TimebackGrade;
771
+ /** Subject matching the game's TimeBack integration. */
772
+ subject: TimebackSubject;
773
+ /** Total XP the game has recorded for this student in this course. */
774
+ totalXp?: number;
775
+ /** Mastered units the game has recorded for this course. */
776
+ masteredUnits?: number;
777
+ /** Total active time in seconds the game has recorded for this course. */
778
+ activeTimeSeconds?: number;
779
+ /** Optional per-run breakdown keyed by Timeback run ID. */
780
+ activities?: GameRunMetrics[];
781
+ }
782
+ interface GameRunMetrics {
783
+ runId: string;
784
+ activityId: string;
785
+ activityName?: string;
786
+ totalXp?: number;
787
+ masteredUnits?: number;
788
+ activeTimeSeconds?: number;
789
+ score?: number;
790
+ }
791
+ type GameMetricsUnsupportedReason = 'no_timeback_integration' | 'no_active_deployment' | 'route_not_implemented' | 'timeout' | 'fetch_failed' | 'invalid_response';
792
+ type GameMetricsProxyResponse = {
793
+ supported: true;
794
+ metrics: GameMetricsResponse;
795
+ } | {
796
+ supported: false;
797
+ reason: GameMetricsUnsupportedReason;
798
+ details?: string;
799
+ };
800
+ type GameMetricComparisonMetric = 'xp' | 'mastery' | 'time' | 'score';
801
+ type GameMetricComparisonKind = 'number' | 'time' | 'percent';
802
+ type GameMetricComparisonRowStatus = 'matched' | 'discrepant' | 'not_reported_by_game' | 'not_recorded_by_timeback';
803
+ interface GameMetricComparisonRow {
804
+ metric: GameMetricComparisonMetric;
805
+ kind: GameMetricComparisonKind;
806
+ status: GameMetricComparisonRowStatus;
807
+ timebackValue?: number;
808
+ gameValue?: number;
809
+ delta?: number;
810
+ }
811
+ type GameRunMetricsComparisonStatus = 'matched' | 'discrepant' | 'not_reported' | 'unavailable';
812
+ interface GameRunMetricsComparisonSummary {
813
+ runId: string;
814
+ status: GameRunMetricsComparisonStatus;
815
+ discrepancyCount: number;
816
+ reason?: GameMetricsUnsupportedReason;
817
+ }
818
+ interface GameRunMetricsComparison extends GameRunMetricsComparisonSummary {
819
+ rows: GameMetricComparisonRow[];
820
+ }
821
+
822
+ /**
823
+ * TimeBack API Request/Response Types
824
+ *
825
+ * Types for TimeBack API endpoints including XP tracking,
826
+ * setup, verification, and activity completion.
827
+ *
828
+ * @module types/timeback/api
829
+ */
830
+
831
+ interface PopulateStudentResponse {
832
+ status: string;
833
+ message?: string;
834
+ }
835
+ interface GameTimebackIntegration {
836
+ id: string;
837
+ gameId: string;
838
+ courseId: string;
839
+ grade: number;
840
+ subject: string;
841
+ status?: 'active' | 'deactivated';
842
+ totalXp?: number | null;
843
+ lastVerifiedAt?: Date | null;
844
+ deactivatedAt?: Date | null;
845
+ reactivatedAt?: Date | null;
846
+ createdAt: Date;
847
+ updatedAt: Date;
848
+ }
849
+ interface HeartbeatRequestBase {
850
+ gameId: string;
851
+ studentId: string;
852
+ runId: string;
853
+ /**
854
+ * Per-session identifier.
855
+ *
856
+ * LEGACY SDK COMPATIBILITY (PR #711): optional because games deployed
857
+ * against the pre-resumable-sessions SDK do not send one. The
858
+ * platform falls back to `runId` when absent. Make this required
859
+ * once legacy SDK support is dropped.
860
+ */
861
+ resumeId?: string;
862
+ activityData: {
863
+ activityId: string;
864
+ activityName?: string;
865
+ grade: TimebackGrade;
866
+ subject: TimebackSubject;
867
+ appName?: string;
868
+ sensorUrl?: string;
869
+ courseId?: string;
870
+ courseName?: string;
871
+ studentEmail?: string;
872
+ };
873
+ timingData: {
874
+ activeMs: number;
875
+ pausedMs: number;
876
+ };
877
+ isFinal?: boolean;
878
+ }
879
+ type HeartbeatWindowKey = {
880
+ /**
881
+ * Absolute start-of-window timestamp (epoch ms). Preferred dedupe key
882
+ * for the post-#711 SDK.
883
+ *
884
+ * LEGACY SDK COMPATIBILITY (PR #711): callers must provide exactly
885
+ * one of this field or `windowSequence`. Make this the only allowed
886
+ * field once legacy SDK support is dropped.
887
+ */
888
+ windowStartedAtMs: number;
889
+ windowSequence?: never;
890
+ } | {
891
+ windowStartedAtMs?: never;
892
+ /**
893
+ * LEGACY SDK COMPATIBILITY (PR #711).
894
+ *
895
+ * Monotonic window counter emitted by the pre-resumable-sessions
896
+ * SDK. Remove this field once every deployed game has redeployed
897
+ * against the post-#711 SDK + edge-play runtime.
898
+ */
899
+ windowSequence: number;
900
+ };
901
+ type HeartbeatRequest = HeartbeatRequestBase & HeartbeatWindowKey;
902
+ interface EndActivityRequest {
903
+ gameId: string;
904
+ studentId: string;
905
+ runId?: string;
906
+ /**
907
+ * Per-session identifier.
908
+ *
909
+ * LEGACY SDK COMPATIBILITY (PR #711): optional because games deployed
910
+ * against the pre-resumable-sessions SDK do not send one. The
911
+ * platform falls back to `runId`, or mints a server-side UUID, when
912
+ * absent. Make this required once legacy SDK support is dropped.
913
+ */
914
+ resumeId?: string;
915
+ activityData: {
916
+ activityId: string;
917
+ activityName?: string;
918
+ grade: TimebackGrade;
919
+ subject: TimebackSubject;
920
+ appName?: string;
921
+ sensorUrl?: string;
922
+ courseId?: string;
923
+ courseName?: string;
924
+ studentEmail?: string;
925
+ };
926
+ scoreData: {
927
+ correctQuestions: number;
928
+ totalQuestions: number;
929
+ };
930
+ timingData: {
931
+ durationSeconds: number;
932
+ };
933
+ sessionTimingData?: {
934
+ activeSeconds: number;
935
+ inactiveSeconds?: number;
936
+ };
937
+ xpEarned: number;
938
+ masteredUnits?: number;
939
+ masteredUnitsAbsolute?: number;
940
+ extensions?: TimebackActivityExtensions;
941
+ }
942
+ type TimebackPromotionStatus = 'promoted' | 'no-next-course' | 'already-promoted' | 'not-enrolled' | 'not-mastered';
943
+ interface TimebackPromotionResult {
944
+ status: TimebackPromotionStatus;
945
+ currentCourseId: string;
946
+ nextCourseId?: string;
947
+ masteredUnits?: number;
948
+ masterableUnits?: number;
949
+ }
950
+ interface EndActivityResponse {
951
+ status: 'ok';
952
+ courseId: string;
953
+ xpAwarded: number;
954
+ masteredUnits?: number;
955
+ pctCompleteApp?: number;
956
+ warnings?: MasteryWriteWarning[];
957
+ /**
958
+ * Set when this submission was stopped because a completion for the same
959
+ * run (`runId`) and activity had already been recorded — the platform's
960
+ * idempotency guard blocked a duplicate emit (PLA-142). This call awarded
961
+ * nothing new, but the award may well have happened: if the original
962
+ * response was lost in transit (e.g. a gateway timeout followed by an SDK
963
+ * retry), this is the only response the caller ever sees for a run that
964
+ * fully succeeded. The response therefore echoes what the run earned —
965
+ * `xpAwarded`, `masteredUnits`, and `pctCompleteApp` are the values
966
+ * recorded when the completion was confirmed (zeros, with no
967
+ * `pctCompleteApp`, only for runs recorded before award echoing existed).
968
+ * Treat it as "already recorded — here's what it earned", and do not
969
+ * count the run again.
970
+ */
971
+ blockedByDedupeGuard?: boolean;
972
+ }
973
+ interface AdvanceCourseResponse {
974
+ status: 'ok';
975
+ promotion: TimebackPromotionResult;
976
+ }
977
+ type TimebackUnenrollmentStatus = 'unenrolled' | 'not-mastered';
978
+ interface TimebackUnenrollmentResult {
979
+ status: TimebackUnenrollmentStatus;
980
+ currentCourseId: string;
981
+ masteredUnits?: number;
982
+ masterableUnits?: number;
983
+ forced?: boolean;
984
+ }
985
+ interface UnenrollCourseResponse {
986
+ status: 'ok';
987
+ unenrollment: TimebackUnenrollmentResult;
988
+ }
989
+
990
+ declare const DIAGNOSTIC_TRACK_OUTCOMES: readonly ['provisional', 'unresolved', 'route-to-instruction', 'not-assessed'];
991
+ type DiagnosticTrackOutcome = (typeof DIAGNOSTIC_TRACK_OUTCOMES)[number];
992
+ type DiagnosticRoutingTrackStatus = 'pending' | 'active' | 'completed' | 'skipped';
993
+ type DiagnosticRoutingStatus = 'in-progress' | 'ready-to-complete';
994
+ interface DiagnosticRoutingNextItem {
995
+ stageKey: string;
996
+ trackKey: string;
997
+ nodeKey: string;
998
+ itemIdentifier: string;
999
+ }
1000
+ /** Deliberately small semantic result exposed to normal game completion handlers. */
1001
+ interface DiagnosticTrackResult {
1002
+ trackKey: string;
1003
+ groupKey?: string;
1004
+ outcome: DiagnosticTrackOutcome;
1005
+ resultKey: string;
1006
+ }
1007
+
1008
+ /** Stable curriculum-standard identity used to align and select assessment content. */
1009
+ interface AssessmentStandardRef {
1010
+ framework: string;
1011
+ identifier: string;
1012
+ }
1013
+ /**
1014
+ * Playcademy's course-specific meaning for reusable QTI test content.
1015
+ * Result writers translate this to OneRoster assessment-result `metadata.testType`;
1016
+ * it intentionally does not become metadata on the QTI test itself.
1017
+ */
1018
+ type AssessmentPurpose = (typeof ASSESSMENT_PURPOSES)[number];
1019
+
1020
+ /** One answer value accepted by the supported QTI runtime interactions. */
1021
+ type AssessmentResponseValue = string | string[];
1022
+ /** Canonical response state persisted on an assessment attempt. */
1023
+ type AssessmentResponses = Record<string, Record<string, AssessmentResponseValue>>;
1024
+ /**
1025
+ * Partial update accepted by save(), merged into the stored responses at both
1026
+ * levels: an omitted question keeps its answers, and an omitted response keeps
1027
+ * its value. Null clears one response, and clearing the last response of a
1028
+ * question drops the question.
1029
+ *
1030
+ * Merging rather than replacing is what makes the obvious write safe. An item
1031
+ * may hold several interactions, so saving the one a student just answered —
1032
+ * `{ item: { RESPONSE_2: 'B' } }` — must not disturb its siblings. Under
1033
+ * replacement it silently discarded them, and nothing in the payload said so.
1034
+ */
1035
+ type AssessmentResponseUpdate = Record<string, Record<string, AssessmentResponseValue | null>>;
1036
+ /**
1037
+ * One node of the rich-content vocabulary, which is OPEN: kinds are added as
1038
+ * content that plain text would misrepresent appears, so a consumer must not
1039
+ * treat this union as exhaustive.
1040
+ *
1041
+ * Structured content is projected from sanitized QTI on the host — never raw
1042
+ * XML/HTML — and always travels alongside a flattened plain-text equivalent, so
1043
+ * simple clients can ignore it entirely.
1044
+ *
1045
+ * A node carries no field common to every kind, so there is nothing to
1046
+ * introspect on an unrecognized one. The supported fallback is one level up:
1047
+ * abandon the whole subtree and render the enclosing `prompt` / `content`
1048
+ * string, which is always present.
1049
+ *
1050
+ * Say so on screen when that happens. A question whose diagram or expression
1051
+ * carried what was being asked still reads as complete prose once the structure
1052
+ * is gone, so a silent fallback can leave a student an unanswerable question
1053
+ * with nothing to indicate why.
1054
+ */
1055
+ type PlayableContentNode = {
1056
+ kind: 'text';
1057
+ text: string;
1058
+ } | {
1059
+ kind: 'math';
1060
+ /** Sanitized MathML source for clients that can render it. */
1061
+ mathMl: string;
1062
+ /** Plain-text approximation for clients that cannot. */
1063
+ fallbackText: string;
1064
+ } | {
1065
+ kind: 'image';
1066
+ src: string;
1067
+ width?: number;
1068
+ height?: number;
1069
+ description?: string;
1070
+ } | {
1071
+ kind: 'paragraph';
1072
+ children: PlayableContentNode[];
1073
+ } | {
1074
+ kind: 'emphasis';
1075
+ children: PlayableContentNode[];
1076
+ } | {
1077
+ kind: 'strong';
1078
+ children: PlayableContentNode[];
1079
+ } | {
1080
+ kind: 'table';
1081
+ rows: {
1082
+ header: boolean;
1083
+ cells: PlayableContentNode[][];
1084
+ }[];
1085
+ }
1086
+ /**
1087
+ * A bulleted or numbered list. Modelled because flattening one to plain text
1088
+ * genuinely changes its meaning — "one two" is not a list — unlike inline
1089
+ * emphasis, which reads correctly either way and so is not carried.
1090
+ */
1091
+ | {
1092
+ kind: 'list';
1093
+ /** Numbered (`ol`) rather than bulleted (`ul`). */
1094
+ ordered: boolean;
1095
+ items: PlayableContentNode[][];
1096
+ }
1097
+ /**
1098
+ * Where one inline interaction belongs in the prose, naming the interaction
1099
+ * it stands for rather than relying on its position among sibling blanks.
1100
+ *
1101
+ * The identifier is what makes this robust: matching blanks to interactions
1102
+ * by order silently mispairs them when either sequence shifts, and a
1103
+ * mispaired dropdown produces a wrong answer rather than a visible error.
1104
+ */
1105
+ | {
1106
+ kind: 'blank';
1107
+ responseIdentifier: string;
1108
+ }
1109
+ /** One named target inside a gap-match passage. */
1110
+ | {
1111
+ kind: 'gap';
1112
+ identifier: string;
1113
+ };
1114
+ interface PlayableAssessmentChoice {
1115
+ identifier: string;
1116
+ content: string;
1117
+ /** Keep this choice in its authored slot when the interaction is shuffled. */
1118
+ fixed?: boolean;
1119
+ /** Rich content when the choice carries more than plain text. */
1120
+ contentNodes?: PlayableContentNode[];
1121
+ }
1122
+ /** A Match choice, which unlike an ordinary choice carries an association capacity. */
1123
+ interface PlayableMatchChoice extends PlayableAssessmentChoice {
1124
+ /** Associations this choice accepts (0 means unlimited). */
1125
+ matchMax: number;
1126
+ }
1127
+ interface PlayableAssessmentInteractionBase {
1128
+ responseIdentifier: string;
1129
+ /** Prompt declared inside the interaction (QTI qti-prompt), when present. */
1130
+ prompt?: string;
1131
+ }
1132
+ interface PlayableChoiceInteraction extends PlayableAssessmentInteractionBase {
1133
+ type: 'choice';
1134
+ choices: PlayableAssessmentChoice[];
1135
+ /** The host has already applied attempt-stable ordering; render the received array. */
1136
+ shuffle: boolean;
1137
+ minChoices: number;
1138
+ maxChoices: number;
1139
+ }
1140
+ interface PlayableInlineChoiceInteraction extends PlayableAssessmentInteractionBase {
1141
+ type: 'inline-choice';
1142
+ choices: PlayableAssessmentChoice[];
1143
+ /** The host has already applied attempt-stable ordering; render the received array. */
1144
+ shuffle: boolean;
1145
+ }
1146
+ interface PlayableTextEntryInteraction extends PlayableAssessmentInteractionBase {
1147
+ type: 'text-entry';
1148
+ expectedLength?: number;
1149
+ placeholder?: string;
1150
+ }
1151
+ interface PlayableOrderInteraction extends PlayableAssessmentInteractionBase {
1152
+ type: 'order';
1153
+ choices: PlayableAssessmentChoice[];
1154
+ /** Whether the host applies attempt-stable presentation ordering. */
1155
+ shuffle: boolean;
1156
+ }
1157
+ interface PlayableMatchInteraction extends PlayableAssessmentInteractionBase {
1158
+ type: 'match';
1159
+ sourceChoices: PlayableMatchChoice[];
1160
+ targetChoices: PlayableMatchChoice[];
1161
+ maxAssociations: number;
1162
+ /** Whether the host applies independent attempt-stable ordering to both choice sets. */
1163
+ shuffle: boolean;
1164
+ }
1165
+ interface PlayableHottextSegment {
1166
+ identifier?: string;
1167
+ content: string;
1168
+ selectable: boolean;
1169
+ }
1170
+ interface PlayableHottextInteraction extends PlayableAssessmentInteractionBase {
1171
+ type: 'hottext';
1172
+ segments: PlayableHottextSegment[];
1173
+ maxChoices: number;
1174
+ }
1175
+ /** A sanitized graphic reference rendered by graphic interactions. */
1176
+ interface PlayableAssessmentGraphic {
1177
+ src: string;
1178
+ width?: number;
1179
+ height?: number;
1180
+ /** Accessible description carried from the source QTI. */
1181
+ description?: string;
1182
+ }
1183
+ /** The QTI region shape vocabulary shared by hotspots and scored areas. */
1184
+ declare const PLAYABLE_ASSESSMENT_SHAPES: readonly ['circle', 'ellipse', 'rect', 'poly', 'default'];
1185
+ type PlayableAssessmentShape = (typeof PLAYABLE_ASSESSMENT_SHAPES)[number];
1186
+ /** A clickable or associable region positioned on a graphic. */
1187
+ interface PlayableAssessmentHotspot {
1188
+ identifier: string;
1189
+ shape: PlayableAssessmentShape;
1190
+ coords: number[];
1191
+ /** Maximum associations this region accepts (0 or absent means unlimited). */
1192
+ matchMax?: number;
1193
+ description?: string;
1194
+ }
1195
+ interface PlayableHotspotInteraction extends PlayableAssessmentInteractionBase {
1196
+ type: 'hotspot';
1197
+ image: PlayableAssessmentGraphic;
1198
+ hotspots: PlayableAssessmentHotspot[];
1199
+ minChoices: number;
1200
+ /** Always a concrete cap: an authored 0 (QTI: unlimited) resolves to the region count. */
1201
+ maxChoices: number;
1202
+ }
1203
+ interface PlayableGapMatchChoice {
1204
+ identifier: string;
1205
+ content: string;
1206
+ /** Keep this token in its authored bank slot, not a passage gap. */
1207
+ fixed?: boolean;
1208
+ /** Times this token may be placed (0 means unlimited). */
1209
+ matchMax: number;
1210
+ }
1211
+ interface PlayableGapMatchInteraction extends PlayableAssessmentInteractionBase {
1212
+ type: 'gap-match';
1213
+ /** Shuffle the token bank without moving passage gaps. */
1214
+ shuffle: boolean;
1215
+ /** Passage containing each gap as a `___` blank, in `gaps` order. */
1216
+ content: string;
1217
+ /** Structured passage retaining each named gap at its authored inline position. */
1218
+ contentNodes: PlayableContentNode[];
1219
+ gapTexts: PlayableGapMatchChoice[];
1220
+ /** Ordered gap identifiers matching the passage blanks. */
1221
+ gaps: string[];
1222
+ /** Overall pair limit (0 means unlimited). */
1223
+ maxAssociations: number;
1224
+ }
1225
+ interface PlayableGapImageChoice {
1226
+ identifier: string;
1227
+ image?: PlayableAssessmentGraphic;
1228
+ /** Times this token may be placed (0 means unlimited). */
1229
+ matchMax: number;
1230
+ description?: string;
1231
+ }
1232
+ interface PlayableGraphicGapMatchInteraction extends PlayableAssessmentInteractionBase {
1233
+ type: 'graphic-gap-match';
1234
+ image: PlayableAssessmentGraphic;
1235
+ gapImages: PlayableGapImageChoice[];
1236
+ hotspots: PlayableAssessmentHotspot[];
1237
+ /** Overall pair limit (0 means unlimited). */
1238
+ maxAssociations: number;
1239
+ }
1240
+ interface PlayableSelectPointInteraction extends PlayableAssessmentInteractionBase {
1241
+ type: 'select-point';
1242
+ image: PlayableAssessmentGraphic;
1243
+ minChoices: number;
1244
+ maxChoices: number;
1245
+ }
1246
+ interface PlayableGraphicAssociateInteraction extends PlayableAssessmentInteractionBase {
1247
+ type: 'graphic-associate';
1248
+ image: PlayableAssessmentGraphic;
1249
+ hotspots: PlayableAssessmentHotspot[];
1250
+ maxAssociations: number;
1251
+ }
1252
+ interface PlayablePositionObjectInteraction extends PlayableAssessmentInteractionBase {
1253
+ type: 'position-object';
1254
+ /** Background stage the object is placed onto. */
1255
+ stage: PlayableAssessmentGraphic;
1256
+ /** The movable object image. */
1257
+ object: PlayableAssessmentGraphic;
1258
+ /** Maximum number of placements. */
1259
+ maxPlacements: number;
1260
+ }
1261
+ type PlayableAssessmentInteraction = PlayableChoiceInteraction | PlayableInlineChoiceInteraction | PlayableTextEntryInteraction | PlayableOrderInteraction | PlayableMatchInteraction | PlayableHottextInteraction | PlayableHotspotInteraction | PlayableGapMatchInteraction | PlayableGraphicGapMatchInteraction | PlayableSelectPointInteraction | PlayableGraphicAssociateInteraction | PlayablePositionObjectInteraction;
1262
+ interface PlayableAssessmentItem {
1263
+ identifier: string;
1264
+ title: string;
1265
+ /**
1266
+ * Shared item stem, flattened to plain text. Inline interactions appear as
1267
+ * `___`, and block interactions belong after the prompt in `interactions`
1268
+ * order.
1269
+ *
1270
+ * The `___` marks that a blank is there, not which interaction fills it or
1271
+ * exactly where it sits: word offsets into this string are not part of the
1272
+ * contract. Prose is translated, re-wrapped, and tokenized differently by
1273
+ * language — a position counted in words does not survive any of that, and
1274
+ * languages that do not separate words with spaces have no such position to
1275
+ * count. Read `promptContent` to place blanks precisely; a client that
1276
+ * ignores it should render inline interactions after the prompt.
1277
+ */
1278
+ prompt: string;
1279
+ /**
1280
+ * Structured prompt content, present whenever the stem holds an inline
1281
+ * interaction or anything plain text would misrepresent — images, tables,
1282
+ * lists, MathML. Absent means `prompt` says everything.
1283
+ *
1284
+ * Inline interactions appear as `blank` nodes carrying the response
1285
+ * identifier they belong to.
1286
+ */
1287
+ promptContent?: PlayableContentNode[];
1288
+ /** Maximum points awarded by the item's declared outcome (1 when undeclared). */
1289
+ maxScore: number;
1290
+ /** Document-ordered interactions with item-unique response identifiers. */
1291
+ interactions: PlayableAssessmentInteraction[];
1292
+ }
1293
+ /** Sanitized assessment content safe to return to a sandboxed game. */
1294
+ interface PlayableAssessment {
1295
+ identifier: string;
1296
+ /**
1297
+ * Schema version of this payload's shape, never of its content.
1298
+ *
1299
+ * Present so a game can tell a field the host does not send from one this
1300
+ * item does not use, and so a mismatch is legible in a bug report. Branch on
1301
+ * whether a field is present rather than on this number — the content
1302
+ * vocabularies are deliberately open, so feature detection survives
1303
+ * versions that a comparison against a fixed number does not.
1304
+ */
1305
+ contractVersion: typeof PLAYCADEMY_ASSESSMENT_CONTRACT_VERSION;
1306
+ /**
1307
+ * Opaque revision of this assessment's content, used to ensure a resumed
1308
+ * attempt loads what it started with. Changes when an author edits the
1309
+ * assessment; unrelated to `contractVersion`.
1310
+ */
1311
+ contentRevision: string;
1312
+ title: string;
1313
+ items: PlayableAssessmentItem[];
1314
+ }
1315
+ interface AssessmentScore {
1316
+ earned: number;
1317
+ possible: number;
1318
+ /** Aggregate score normalized to the inclusive 0..1 range. */
1319
+ normalized: number;
1320
+ }
1321
+ type FixedAssessmentPurpose = Exclude<AssessmentPurpose, 'review'>;
1322
+ /** Fixed-test purposes that do not select their catalog by curriculum standard. */
1323
+ type UnscopedFixedAssessmentPurpose = Exclude<FixedAssessmentPurpose, 'mastery'>;
1324
+ /** One requested standard slot and the playable bank item selected for it. */
1325
+ interface AssessmentReviewItemSelection {
1326
+ standard: AssessmentStandardRef;
1327
+ itemIdentifier: string;
1328
+ }
1329
+ /** Why one requested standard could not be fully served by the current bank. */
1330
+ interface AssessmentReviewShortage {
1331
+ standard: AssessmentStandardRef;
1332
+ requested: number;
1333
+ selected: number;
1334
+ eligible: number;
1335
+ }
1336
+ /**
1337
+ * Explicit review-request fulfillment. A partial result still starts a normal
1338
+ * assessment attempt with every selectable item; no missing standard is
1339
+ * silently omitted.
1340
+ */
1341
+ type AssessmentReviewFulfillment = {
1342
+ status: 'complete';
1343
+ requestedItemCount: number;
1344
+ selectedItemCount: number;
1345
+ shortages: [];
1346
+ } | {
1347
+ status: 'partial';
1348
+ requestedItemCount: number;
1349
+ selectedItemCount: number;
1350
+ shortages: AssessmentReviewShortage[];
1351
+ };
1352
+ interface FixedAssessmentSelectionContext {
1353
+ kind: 'fixed-test';
1354
+ purpose: UnscopedFixedAssessmentPurpose;
1355
+ }
1356
+ /** A complete fixed quiz selected from the catalog for one canonical standard. */
1357
+ interface StandardQuizSelectionContext {
1358
+ kind: 'standard-quiz';
1359
+ purpose: 'mastery';
1360
+ standard: AssessmentStandardRef;
1361
+ }
1362
+ /** Administration policy for one requested review skill, separate from its identity. */
1363
+ interface AssessmentReviewStandard extends AssessmentStandardRef {
1364
+ /** Require this skill's second selected question, subject to the player's cap. */
1365
+ requireBothQuestions?: boolean;
1366
+ }
1367
+ interface StandardsReviewSelectionContext {
1368
+ kind: 'standards-review';
1369
+ purpose: 'review';
1370
+ standards: AssessmentReviewStandard[];
1371
+ candidateItemsPerStandard: number;
1372
+ selections: AssessmentReviewItemSelection[];
1373
+ fulfillment: AssessmentReviewFulfillment;
1374
+ }
1375
+ /** Immutable identity pinned when the host starts a platform-routed diagnostic. */
1376
+ interface PlatformRoutedDiagnosticSelectionContext {
1377
+ kind: 'platform-routed-diagnostic';
1378
+ purpose: 'diagnostic';
1379
+ definitionId: string;
1380
+ diagnosticKey: string;
1381
+ routingRevision: string;
1382
+ }
1383
+ /** How the host assembled the playable assessment returned for this attempt. */
1384
+ type AssessmentSelectionContext = FixedAssessmentSelectionContext | StandardQuizSelectionContext | StandardsReviewSelectionContext | PlatformRoutedDiagnosticSelectionContext;
1385
+ /** Server-derived assessment interaction model; callers select it only through purpose. */
1386
+ type AssessmentFlow = 'attempt-submit' | 'item-submit' | 'platform-routed-item-submit';
1387
+ /** Safe feedback persisted when one item is committed in an item-submit flow. */
1388
+ type AssessmentItemGrading = {
1389
+ source: 'timeback-qti';
1390
+ graderVersion: string;
1391
+ } | {
1392
+ source: 'platform-qti-adapter';
1393
+ graderVersion: string;
1394
+ qtiGraderVersion: string;
1395
+ } | {
1396
+ source: 'platform-artifact';
1397
+ artifactVersion: string;
1398
+ graderVersion: string;
1399
+ };
1400
+ interface AssessmentItemSubmission {
1401
+ /** Stable caller-generated key used to replay a lost success response. */
1402
+ submissionId: string;
1403
+ itemIdentifier: string;
1404
+ /** Stable administration timestamp used for exposure ordering and resume reconciliation. */
1405
+ submittedAt: string;
1406
+ /** One-based position in the validated administration sequence. */
1407
+ responseVersion: number;
1408
+ answered: boolean;
1409
+ score: AssessmentScore;
1410
+ isCorrect: boolean | null;
1411
+ /**
1412
+ * Trusted grading provenance pinned at grading time so child-result repair
1413
+ * reproduces the corresponding child projection. Absent only on attempts
1414
+ * committed before provenance was introduced.
1415
+ */
1416
+ grading?: AssessmentItemGrading;
1417
+ }
1418
+ /** Raw answers only. Array order is the administration sequence; no grades are trusted. */
1419
+ interface AssessmentTranscript {
1420
+ version: 1;
1421
+ attemptId: string;
1422
+ /** The selected source revision, not a review subset's presentation revision. */
1423
+ contentRevision: string;
1424
+ administrations: {
1425
+ submissionId: string;
1426
+ itemIdentifier: string;
1427
+ routingNodeKey?: string;
1428
+ /** An empty response is still an administered question. */
1429
+ responses: Record<string, AssessmentResponseValue>;
1430
+ }[];
1431
+ }
1432
+ interface ResumeAssessmentInput {
1433
+ /** Omit to recover the parent checkpoint, or best-effort child progress if none exists. */
1434
+ transcript?: AssessmentTranscript;
1435
+ }
1436
+ /**
1437
+ * Canonical activity context the SDK uses to track time for this attempt. A
1438
+ * narrowed `ActivityData`, so it can be handed straight to the shared clock:
1439
+ * the course routing fields are resolved rather than optional.
1440
+ */
1441
+ type AssessmentActivityData = Pick<ActivityData, 'activityId' | 'courseId'> & {
1442
+ activityName: string;
1443
+ grade: TimebackGrade;
1444
+ subject: TimebackSubject;
1445
+ };
1446
+ interface AssessmentAttemptSnapshotBase {
1447
+ attemptId: string;
1448
+ responseVersion: number;
1449
+ status: 'in_progress';
1450
+ /** Resolved server context for the shared activity-session clock, when valid. */
1451
+ activityData?: AssessmentActivityData;
1452
+ assessment: PlayableAssessment;
1453
+ /** Opaque, attempt-scoped authorization. Renew through start/resume, not per answer. */
1454
+ assessmentToken: string;
1455
+ transcript: AssessmentTranscript;
1456
+ }
1457
+ /** Existing fixed, mastery, and review attempt shape. */
1458
+ interface ConventionalAssessmentAttemptSnapshot extends AssessmentAttemptSnapshotBase {
1459
+ /** Historical fixed diagnostics remain attempt-submit and are never reinterpreted. */
1460
+ flow: Exclude<AssessmentFlow, 'platform-routed-item-submit'>;
1461
+ responses: AssessmentResponses;
1462
+ /** Ordered committed-item ledger. Empty for attempt-submit flows. */
1463
+ itemSubmissions: AssessmentItemSubmission[];
1464
+ score: AssessmentScore | null;
1465
+ selection: Exclude<AssessmentSelectionContext, PlatformRoutedDiagnosticSelectionContext>;
1466
+ }
1467
+ /** Safe public track progress; authored terminal semantics stay host-only until completion. */
1468
+ interface DiagnosticRoutingTrackSnapshot {
1469
+ trackKey: string;
1470
+ groupKey?: string;
1471
+ status: DiagnosticRoutingTrackStatus;
1472
+ administeredCount: number;
1473
+ }
1474
+ /** Safe canonical routing projection returned while a diagnostic is in progress. */
1475
+ interface DiagnosticRoutingSnapshot {
1476
+ kind: 'platform-routed-diagnostic';
1477
+ revision: string;
1478
+ status: DiagnosticRoutingStatus;
1479
+ next: DiagnosticRoutingNextItem | null;
1480
+ tracks: DiagnosticRoutingTrackSnapshot[];
1481
+ }
1482
+ /** Small semantic diagnostic result consumed by the game after finalization. */
1483
+ interface DiagnosticAssessmentSubmitResult {
1484
+ purpose: 'diagnostic';
1485
+ attemptId: string;
1486
+ submissionId: string;
1487
+ diagnosticKey: string;
1488
+ responseVersion: number;
1489
+ status: 'awaiting_award';
1490
+ tracks: DiagnosticTrackResult[];
1491
+ }
1492
+ /** Platform-routed diagnostics never expose grading, feedback, or their committed ledger. */
1493
+ interface PlatformRoutedDiagnosticAttemptSnapshot extends AssessmentAttemptSnapshotBase {
1494
+ flow: 'platform-routed-item-submit';
1495
+ selection: PlatformRoutedDiagnosticSelectionContext;
1496
+ routing: DiagnosticRoutingSnapshot;
1497
+ completion: null;
1498
+ }
1499
+ interface AssessmentSaveResult {
1500
+ attemptId: string;
1501
+ responseVersion: number;
1502
+ status: 'in_progress';
1503
+ responses: AssessmentResponses;
1504
+ transcript: AssessmentTranscript;
1505
+ }
1506
+ interface AssessmentSubmitResultBase {
1507
+ attemptId: string;
1508
+ submissionId: string;
1509
+ responseVersion: number;
1510
+ status: 'awaiting_award';
1511
+ responses: AssessmentResponses;
1512
+ score: AssessmentScore;
1513
+ }
1514
+ interface FixedAssessmentSubmitResult extends AssessmentSubmitResultBase {
1515
+ purpose: UnscopedFixedAssessmentPurpose;
1516
+ }
1517
+ /** Safe final item grade, exposed only after the assessment is submitted. */
1518
+ interface AssessmentItemOutcome {
1519
+ itemIdentifier: string;
1520
+ standard: AssessmentStandardRef;
1521
+ answered: boolean;
1522
+ score: AssessmentScore;
1523
+ isCorrect: boolean | null;
1524
+ }
1525
+ interface ReviewAssessmentSubmitResult extends AssessmentSubmitResultBase {
1526
+ purpose: 'review';
1527
+ /** Final outcomes in committed transcript order, excluding unused candidates. */
1528
+ itemOutcomes: AssessmentItemOutcome[];
1529
+ }
1530
+ interface MasteryAssessmentSubmitResult extends AssessmentSubmitResultBase {
1531
+ purpose: 'mastery';
1532
+ /** One final outcome per question in test order, including unanswered questions. */
1533
+ itemOutcomes: AssessmentItemOutcome[];
1534
+ }
1535
+ type ConventionalAssessmentSubmitResult = FixedAssessmentSubmitResult | ReviewAssessmentSubmitResult | MasteryAssessmentSubmitResult;
1536
+ type AssessmentSubmitResult = ConventionalAssessmentSubmitResult | DiagnosticAssessmentSubmitResult;
1537
+ type CompletedAssessmentResult<TResult extends AssessmentSubmitResult> = Omit<TResult, 'status'> & {
1538
+ status: 'completed';
1539
+ /** XP durably recorded on the authoritative OneRoster AssessmentResult. */
1540
+ xpAwarded: number;
1541
+ /**
1542
+ * The mastery delta durably recorded on the authoritative result after
1543
+ * platform bounding. Zero when the game awarded no mastery.
1544
+ */
1545
+ masteredUnitsApplied: number;
1546
+ /** Course completion percentage after this award, when mastery tracking is configured. */
1547
+ pctCompleteApp?: number;
1548
+ /** Non-fatal bounding warnings raised while applying the award. */
1549
+ warnings?: MasteryWriteWarning[];
1550
+ };
1551
+ /** Terminal result returned only after the game's award has been recorded. */
1552
+ type AssessmentFinalizeResult = CompletedAssessmentResult<FixedAssessmentSubmitResult> | CompletedAssessmentResult<ReviewAssessmentSubmitResult> | CompletedAssessmentResult<MasteryAssessmentSubmitResult> | CompletedAssessmentResult<DiagnosticAssessmentSubmitResult>;
1553
+ /** Minimal recovery snapshot; no QTI content load is required after answers are locked. */
1554
+ type SettledAssessmentAttemptSnapshot = {
1555
+ attemptId: string;
1556
+ responseVersion: number;
1557
+ status: 'awaiting_award';
1558
+ result: AssessmentSubmitResult;
1559
+ } | {
1560
+ attemptId: string;
1561
+ responseVersion: number;
1562
+ status: 'completed';
1563
+ result: AssessmentFinalizeResult;
1564
+ };
1565
+ /** Snapshot states that are still open for responses. */
1566
+ type PlayableAssessmentAttemptSnapshot = ConventionalAssessmentAttemptSnapshot | PlatformRoutedDiagnosticAttemptSnapshot;
1567
+ type AssessmentAttemptSnapshot = PlayableAssessmentAttemptSnapshot | SettledAssessmentAttemptSnapshot;
1568
+ interface GetLatestAssessmentOptionsBase {
1569
+ subject?: TimebackSubject;
1570
+ grade?: TimebackGrade;
1571
+ }
1572
+ /** Filters for finding the authenticated student's latest completed assessment. */
1573
+ type GetLatestAssessmentOptions = (GetLatestAssessmentOptionsBase & {
1574
+ purpose: Exclude<AssessmentPurpose, 'mastery'>;
1575
+ standard?: never;
1576
+ }) | (GetLatestAssessmentOptionsBase & {
1577
+ purpose: 'mastery';
1578
+ standard: AssessmentStandardRef;
1579
+ });
1580
+ /** Compact result returned by the latest-completed-assessment lookup. */
1581
+ interface LatestAssessmentResult {
1582
+ attemptId: string;
1583
+ purpose: AssessmentPurpose;
1584
+ activityId: string;
1585
+ subject: TimebackSubject;
1586
+ grade: TimebackGrade;
1587
+ testIdentifier: string;
1588
+ /** Canonical request identity for mastery results; null for other purposes. */
1589
+ standard: AssessmentStandardRef | null;
1590
+ completedAt: string;
1591
+ /** Persisted aggregate score normalized to the inclusive 0..1 range. */
1592
+ score: Pick<AssessmentScore, 'normalized'>;
1593
+ }
1594
+ interface StartAssessmentInputBase {
1595
+ activityId: string;
1596
+ subject?: TimebackSubject;
1597
+ grade?: TimebackGrade;
1598
+ }
1599
+ interface StartFixedAssessmentInput extends StartAssessmentInputBase {
1600
+ purpose: Exclude<UnscopedFixedAssessmentPurpose, 'diagnostic'>;
1601
+ }
1602
+ interface StartDiagnosticAssessmentInput extends StartAssessmentInputBase {
1603
+ purpose: 'diagnostic';
1604
+ /** Stable authored diagnostic identity, independent of the selected QTI test identifier. */
1605
+ diagnosticKey: string;
1606
+ }
1607
+ interface StartMasteryAssessmentInput extends StartAssessmentInputBase {
1608
+ purpose: 'mastery';
1609
+ standard: AssessmentStandardRef;
1610
+ }
1611
+ interface StartReviewAssessmentInput extends StartAssessmentInputBase {
1612
+ purpose: 'review';
1613
+ /** Serving order; duplicate canonical skills keep their first position. Pinned on start. */
1614
+ standards: AssessmentReviewStandard[];
1615
+ /** Candidate capacity per standard; preloaded candidates are not administered automatically. */
1616
+ candidateItemsPerStandard?: number;
1617
+ }
1618
+ type StartAssessmentInput = StartFixedAssessmentInput | StartDiagnosticAssessmentInput | StartMasteryAssessmentInput | StartReviewAssessmentInput;
1619
+ /** Transport metadata for attempting a prepared new-assessment start. */
1620
+ interface StartAssessmentOptions {
1621
+ preparationReceipt?: string;
1622
+ }
1623
+ /** Result of preparing the immediate next assessment request. */
1624
+ type AssessmentPreparationResult = {
1625
+ status: 'prepared';
1626
+ receipt: string;
1627
+ /** Receipt expiry as an ISO-8601 timestamp. */
1628
+ expiresAt: string;
1629
+ } | {
1630
+ status: 'unprepared';
1631
+ reason: 'artifact_unavailable' | 'prerequisite_unavailable' | 'local_runtime';
1632
+ };
1633
+ interface SaveAssessmentInput {
1634
+ expectedResponseVersion: number;
1635
+ /** Complete active draft; success acknowledges its durable parent checkpoint. */
1636
+ transcript: AssessmentTranscript;
1637
+ }
1638
+ /** Best-effort mastery progress, not an answer commitment or an explicit checkpoint. */
1639
+ interface RecordAssessmentProgressInput {
1640
+ assessmentToken: string;
1641
+ expectedResponseVersion: number;
1642
+ /** Current raw draft, including the editable administration being projected. */
1643
+ transcript: AssessmentTranscript;
1644
+ itemIdentifier: string;
1645
+ }
1646
+ interface SubmitAssessmentItemInputBase {
1647
+ assessmentToken: string;
1648
+ /** The raw prefix preceding this administration (or including it for an exact retry). */
1649
+ transcript: AssessmentTranscript;
1650
+ expectedResponseVersion: number;
1651
+ /** Stable across every retry of this exact item submission. */
1652
+ submissionId: string;
1653
+ itemIdentifier: string;
1654
+ responses: Record<string, AssessmentResponseValue | null>;
1655
+ }
1656
+ interface SubmitReviewAssessmentItemInput extends SubmitAssessmentItemInputBase {
1657
+ routingNodeKey?: never;
1658
+ }
1659
+ interface SubmitDiagnosticAssessmentItemInput extends SubmitAssessmentItemInputBase {
1660
+ /** Canonical routing-context identity returned in routing.next. */
1661
+ routingNodeKey: string;
1662
+ }
1663
+ type SubmitAssessmentItemInput = SubmitReviewAssessmentItemInput | SubmitDiagnosticAssessmentItemInput;
1664
+ interface SubmitReviewAssessmentItemResult {
1665
+ attemptId: string;
1666
+ responseVersion: number;
1667
+ status: 'in_progress';
1668
+ responses: AssessmentResponses;
1669
+ /** Canonical ledger after commit or replay; replace local state with it. */
1670
+ itemSubmissions: AssessmentItemSubmission[];
1671
+ submission: AssessmentItemSubmission;
1672
+ transcript: AssessmentTranscript;
1673
+ }
1674
+ /** Safe acknowledgement for one immutable diagnostic item commitment. */
1675
+ interface DiagnosticAssessmentItemReceipt {
1676
+ submissionId: string;
1677
+ routingNodeKey: string;
1678
+ itemIdentifier: string;
1679
+ submittedAt: string;
1680
+ responseVersion: number;
1681
+ answered: boolean;
1682
+ score: AssessmentScore;
1683
+ isCorrect: boolean;
1684
+ }
1685
+ /** Canonical post-commit routing state plus trusted feedback for this administration. */
1686
+ interface SubmitDiagnosticAssessmentItemResult {
1687
+ attemptId: string;
1688
+ responseVersion: number;
1689
+ status: 'in_progress';
1690
+ routing: DiagnosticRoutingSnapshot;
1691
+ submission: DiagnosticAssessmentItemReceipt;
1692
+ transcript: AssessmentTranscript;
1693
+ }
1694
+ type SubmitAssessmentItemResult = SubmitReviewAssessmentItemResult | SubmitDiagnosticAssessmentItemResult;
1695
+ interface SubmitAssessmentInput {
1696
+ expectedResponseVersion: number;
1697
+ submissionId: string;
1698
+ transcript: AssessmentTranscript;
1699
+ }
1700
+ /** The optional mastery portion of a finalize award; at most one field is set. */
1701
+ interface AssessmentMasteryAward {
1702
+ /**
1703
+ * Incremental learning units mastered by this attempt. Cannot be combined
1704
+ * with masteredUnitsAbsolute. The platform bounds the delta against the
1705
+ * course's configured masterableUnits and returns any warning.
1706
+ */
1707
+ masteredUnits?: number;
1708
+ /**
1709
+ * Absolute mastered-unit total after this attempt; the platform computes
1710
+ * the delta. Cannot be combined with masteredUnits.
1711
+ */
1712
+ masteredUnitsAbsolute?: number;
1713
+ }
1714
+ interface FinalizeAssessmentInput extends AssessmentMasteryAward {
1715
+ submissionId: string;
1716
+ /** Explicit zero is an award; omission is never interpreted as zero. */
1717
+ xpAwarded: number;
1718
+ }
1719
+ /**
1720
+ * The award a game supplied at finalization, retained verbatim so a retried
1721
+ * finalize can be told apart from a contradictory one even after bounding
1722
+ * changed what was actually applied.
1723
+ */
1724
+ interface AssessmentAwardRecord extends AssessmentMasteryAward {
1725
+ xpAwarded: number;
1726
+ /** The bounded mastery delta the platform recorded for this attempt. */
1727
+ masteredUnitsApplied: number;
1728
+ pctCompleteApp?: number;
1729
+ warnings?: MasteryWriteWarning[];
1730
+ }
1731
+
34
1732
  /**
35
1733
  * Base error class for Cademy SDK specific errors.
36
1734
  */
@@ -1388,7 +3086,7 @@ declare abstract class PlaycademyBaseClient {
1388
3086
  * - `me()` - Get authenticated user profile
1389
3087
  */
1390
3088
  users: {
1391
- me: () => Promise<_playcademy_types.AuthenticatedUser>;
3089
+ me: () => Promise<AuthenticatedUser>;
1392
3090
  };
1393
3091
  }
1394
3092
 
@@ -2011,36 +3709,36 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
2011
3709
  */
2012
3710
  timeback: {
2013
3711
  assessments: {
2014
- prepare: (input: _playcademy_types.StartAssessmentInput) => Promise<_playcademy_types.AssessmentPreparationResult>;
2015
- start: (input: _playcademy_types.StartAssessmentInput, options?: _playcademy_types.StartAssessmentOptions) => Promise<_playcademy_types.AssessmentAttemptSnapshot>;
2016
- latest: (options: _playcademy_types.GetLatestAssessmentOptions) => Promise<_playcademy_types.LatestAssessmentResult | null>;
2017
- get: (attemptId: string) => Promise<_playcademy_types.AssessmentAttemptSnapshot>;
3712
+ prepare: (input: StartAssessmentInput) => Promise<AssessmentPreparationResult>;
3713
+ start: (input: StartAssessmentInput, options?: StartAssessmentOptions) => Promise<AssessmentAttemptSnapshot>;
3714
+ latest: (options: GetLatestAssessmentOptions) => Promise<LatestAssessmentResult | null>;
3715
+ get: (attemptId: string) => Promise<AssessmentAttemptSnapshot>;
2018
3716
  stop: (attemptId: string) => Promise<{
2019
3717
  attemptId: string;
2020
3718
  }>;
2021
- resume: (attemptId: string, input?: _playcademy_types.ResumeAssessmentInput) => Promise<_playcademy_types.AssessmentAttemptSnapshot>;
2022
- save: (attemptId: string, input: _playcademy_types.SaveAssessmentInput) => Promise<_playcademy_types.AssessmentSaveResult>;
2023
- recordProgress: (attemptId: string, input: _playcademy_types.RecordAssessmentProgressInput) => Promise<{
3719
+ resume: (attemptId: string, input?: ResumeAssessmentInput) => Promise<AssessmentAttemptSnapshot>;
3720
+ save: (attemptId: string, input: SaveAssessmentInput) => Promise<AssessmentSaveResult>;
3721
+ recordProgress: (attemptId: string, input: RecordAssessmentProgressInput) => Promise<{
2024
3722
  attemptId: string;
2025
3723
  }>;
2026
- submitItem: (attemptId: string, input: _playcademy_types.SubmitAssessmentItemInput) => Promise<_playcademy_types.SubmitAssessmentItemResult>;
2027
- submit: (attemptId: string, input: _playcademy_types.SubmitAssessmentInput) => Promise<_playcademy_types.AssessmentSubmitResult>;
2028
- finalize: (attemptId: string, input: _playcademy_types.FinalizeAssessmentInput) => Promise<_playcademy_types.AssessmentFinalizeResult>;
3724
+ submitItem: (attemptId: string, input: SubmitAssessmentItemInput) => Promise<SubmitAssessmentItemResult>;
3725
+ submit: (attemptId: string, input: SubmitAssessmentInput) => Promise<AssessmentSubmitResult>;
3726
+ finalize: (attemptId: string, input: FinalizeAssessmentInput) => Promise<AssessmentFinalizeResult>;
2029
3727
  };
2030
3728
  readonly user: TimebackUser;
2031
3729
  readonly currentRunId: string | undefined;
2032
- startActivity: (metadata: _playcademy_types.ActivityData, options?: StartActivityOptions) => StartActivityResult;
3730
+ startActivity: (metadata: ActivityData, options?: StartActivityOptions) => StartActivityResult;
2033
3731
  pauseActivity: () => void;
2034
3732
  resumeActivity: () => void;
2035
- endActivity: (data: _playcademy_types.EndActivityScoreData) => Promise<_playcademy_types.EndActivityResponse | RelayedEndActivityResult>;
3733
+ endActivity: (data: EndActivityScoreData) => Promise<EndActivityResponse | RelayedEndActivityResult>;
2036
3734
  course: {
2037
3735
  advance: (options?: {
2038
- subject?: _playcademy_types.TimebackSubject;
2039
- }) => Promise<_playcademy_types.AdvanceCourseResponse>;
3736
+ subject?: TimebackSubject;
3737
+ }) => Promise<AdvanceCourseResponse>;
2040
3738
  unenroll: (options?: {
2041
- subject?: _playcademy_types.TimebackSubject;
3739
+ subject?: TimebackSubject;
2042
3740
  force?: boolean;
2043
- }) => Promise<_playcademy_types.UnenrollCourseResponse>;
3741
+ }) => Promise<UnenrollCourseResponse>;
2044
3742
  };
2045
3743
  };
2046
3744
  /**
@@ -2055,7 +3753,7 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
2055
3753
  * - `fetch(options?)` - Fetch leaderboard entries
2056
3754
  */
2057
3755
  leaderboard: {
2058
- fetch: (options?: _playcademy_types.LeaderboardOptions) => Promise<_playcademy_types.GameLeaderboardEntry[]>;
3756
+ fetch: (options?: LeaderboardOptions) => Promise<GameLeaderboardEntry[]>;
2059
3757
  };
2060
3758
  /**
2061
3759
  * Demo-mode helpers. Methods throw when called outside `client.mode === 'demo'`,
@@ -2066,8 +3764,8 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
2066
3764
  */
2067
3765
  demo: {
2068
3766
  profile: {
2069
- get: () => Promise<_playcademy_types.DemoProfile>;
2070
- update: (updates: _playcademy_types.DemoProfileUpdate) => Promise<_playcademy_types.DemoProfile>;
3767
+ get: () => Promise<DemoProfile>;
3768
+ update: (updates: DemoProfileUpdate) => Promise<DemoProfile>;
2071
3769
  };
2072
3770
  end: (score: number, options?: DemoEndOptions) => void;
2073
3771
  };
@@ -2741,4 +4439,4 @@ interface PlatformTimebackUser extends PlatformTimebackUserContext {
2741
4439
  }
2742
4440
 
2743
4441
  export { PlaycademyClient };
2744
- export type { AuthCallbackPayload, AuthOptions, AuthProviderType, AuthResult, AuthServerMessage, AuthStateChangePayload, AuthStateUpdate, BetterAuthApiKey, BetterAuthApiKeyResponse, BetterAuthSignInResponse, BucketFile, BucketFilePage, BucketListPageOptions, ChildCheckpointRelay, ClientConfig, ClientEvents, CourseMastery, CourseXp, DemoEndOptions, DemoEndPayload, DevUploadEvent, DevUploadHooks, EmbedActivity, EmbedActivityAbandoned, EmbedActivityCompleted, EmbedActivityFailed, EmbedLaunchOptions, EmbedResumeEnvelope, EmbedResumeStore, EmbedSession, EmbedSessionTiming, EmbedTimebackRecording, EventListeners, ExternalGame, FetchedGame, Game, GameContextPayload, GameCustomHostname, GameInitUser, GameRow as GameRecord, GameTokenResponse, GetHighestGradeMasteredOptions, GetMasteryOptions, GetXpOptions, HighestGradeMasteredResponse, HostedGame, InitErrorPayload, InitPayload, KVKeyEntry, KVKeyMetadata, KVSeedEntry, KVStatsResponse, KeyEventPayload, LaunchIntent, LoginResponse, MasteryResponse, ParentGameContext, ParentGameHandle, PlatformTimebackUser, PlatformTimebackUserContext, PlaycademyMode, PlaycademyServerClientConfig, PlaycademyServerClientState, ScoreSubmission, StartActivityOptions, StartActivityResult, TelemetryPayload, TimebackActivityEndRelay, TimebackActivityStartRelay, TimebackEnrollment, TimebackHeartbeatRelayRequest, TimebackInitContext, TimebackOrganization, TimebackUser, TimebackUserContext, TimebackUserHighestGradeMastered, TimebackUserMastery, TimebackUserRefreshField, TimebackUserRefreshOptions, TimebackUserXp, TokenRefreshPayload, TokenType, UpsertGameMetadataInput, UserRow as User, XpResponse };
4442
+ export type { AssessmentAttemptSnapshot, AssessmentAwardRecord, AssessmentFinalizeResult, AssessmentFlow, AssessmentItemGrading, AssessmentItemOutcome, AssessmentItemSubmission, AssessmentMasteryAward, AssessmentPreparationResult, AssessmentResponseUpdate, AssessmentResponseValue, AssessmentResponses, AssessmentReviewStandard, AssessmentSaveResult, AssessmentScore, AssessmentStandardRef, AssessmentSubmitResult, AssessmentTranscript, AuthCallbackPayload, AuthOptions, AuthProviderType, AuthResult, AuthServerMessage, AuthStateChangePayload, AuthStateUpdate, AuthenticatedUser, BetterAuthApiKey, BetterAuthApiKeyResponse, BetterAuthSignInResponse, BucketFile, BucketFilePage, BucketListPageOptions, ChildCheckpointRelay, ClientConfig, ClientEvents, ConventionalAssessmentAttemptSnapshot, ConventionalAssessmentSubmitResult, CourseMastery, CourseXp, DemoEndOptions, DemoEndPayload, DeploySource, DevUploadEvent, DevUploadHooks, DeveloperStatusEnumType, DeveloperStatusResponse, DeveloperStatusValue, DiagnosticAssessmentItemReceipt, DiagnosticAssessmentSubmitResult, DiagnosticRoutingSnapshot, DiagnosticRoutingTrackSnapshot, ELevel, EmbedActivity, EmbedActivityAbandoned, EmbedActivityCompleted, EmbedActivityFailed, EmbedLaunchOptions, EmbedResumeEnvelope, EmbedResumeStore, EmbedSession, EmbedSessionTiming, EmbedTimebackRecording, EventListeners, ExternalGame, FetchedGame, FinalizeAssessmentInput, Game, GameContextPayload, GameCourseMetrics, GameCustomHostname, GameInitUser, GameLeaderboardEntry, GameManifest, GameMetricComparisonKind, GameMetricComparisonMetric, GameMetricComparisonRow, GameMetricComparisonRowStatus, GameMetricsProxyResponse, GameMetricsResponse, GameMetricsUnsupportedReason, GamePlatform, GameRow as GameRecord, GameReleaseResponse, GameRunMetrics, GameRunMetricsComparison, GameRunMetricsComparisonStatus, GameRunMetricsComparisonSummary, GameTimebackIntegration, GameTokenResponse, GameType, GameUser, GetHighestGradeMasteredOptions, GetMasteryOptions, GetXpOptions, HighestGradeMasteredResponse, HostedGame, InitErrorPayload, InitPayload, KVKeyEntry, KVKeyMetadata, KVSeedEntry, KVStatsResponse, KeyEventPayload, LaunchIntent, LeaderboardEntry, LeaderboardOptions, LeaderboardTimeframe, LocalDayContext, LocalDaySource, LoginResponse, ManifestV1, ManifestV2, ManifestVersions, MasteryAssessmentSubmitResult, MasteryResponse, ParentGameContext, ParentGameHandle, PlatformRoutedDiagnosticAttemptSnapshot, PlatformRoutedDiagnosticSelectionContext, PlatformTimebackUser, PlatformTimebackUserContext, PlayableAssessment, PlayableAssessmentAttemptSnapshot, PlayableAssessmentChoice, PlayableAssessmentGraphic, PlayableAssessmentHotspot, PlayableAssessmentInteraction, PlayableAssessmentItem, PlayableChoiceInteraction, PlayableContentNode, PlayableGapMatchChoice, PlayableGapMatchInteraction, PlayableInlineChoiceInteraction, PlayableMatchChoice, PlayableMatchInteraction, PlayableOrderInteraction, PlaycademyMode, PlaycademyServerClientConfig, PlaycademyServerClientState, PopulateStudentResponse, RecordAssessmentProgressInput, Release, ReleasesResponse, ResumeAssessmentInput, SaveAssessmentInput, ScoreSubmission, SettledAssessmentAttemptSnapshot, SkillMasterySource, SkillStatus, SkillStatusLookupResult, SkillStatusRequest, SkillStatusRequestingGame, SkillStatusResponse, SkillStatusResult, SkillStatusUnsupportedReason, StandardsReviewSelectionContext, StartActivityOptions, StartActivityResult, StartAssessmentInput, StartAssessmentOptions, StartDiagnosticAssessmentInput, SubmitAssessmentInput, SubmitAssessmentItemInput, SubmitAssessmentItemResult, SubmitDiagnosticAssessmentItemInput, SubmitDiagnosticAssessmentItemResult, TelemetryPayload, TimebackActivityEndRelay, TimebackActivityStartRelay, TimebackEnrollment, TimebackHeartbeatRelayRequest, TimebackInitContext, TimebackOrganization, TimebackUser, TimebackUserContext, TimebackUserHighestGradeMastered, TimebackUserMastery, TimebackUserRefreshField, TimebackUserRefreshOptions, TimebackUserXp, TokenRefreshPayload, TokenType, UpsertGameMetadataInput, UserRow as User, UserEnrollment, UserInfo, UserOrganization, UserRank, UserRankResponse, UserRoleEnumType, UserScore, UserTimebackData, XpResponse };