@playcademy/sdk 0.24.0 → 0.24.1-beta.1

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.
@@ -81,1955 +81,1218 @@ declare const ASSESSMENT_PURPOSES: readonly ['end_of_course', 'diagnostic', 'rev
81
81
  declare const PLAYCADEMY_ASSESSMENT_CONTRACT_VERSION: 2;
82
82
 
83
83
  /**
84
- * User Types
84
+ * TimeBack Enums & Literal Types
85
85
  *
86
- * Enums, DTOs and API response types. Database row types are in @playcademy/data/types.
86
+ * Basic type definitions used throughout the TimeBack integration. Unions
87
+ * derive from the canonical value lists in @playcademy/constants (type-only
88
+ * imports, so this package ships no runtime code).
87
89
  *
88
- * @module types/user
90
+ * @module types/timeback/types
89
91
  */
90
92
 
91
- type UserRoleEnumType = UserRole;
92
- type DeveloperStatusEnumType = 'none' | 'pending' | 'approved';
93
- type DeveloperStatusValue = DeveloperStatusEnumType;
94
- type TimebackUserRole = 'administrator' | 'aide' | 'guardian' | 'parent' | 'proctor' | 'relative' | 'student' | 'teacher';
95
- type TimebackOrgType = 'department' | 'school' | 'district' | 'local' | 'state' | 'national';
96
- interface UserEnrollment {
97
- gameId?: string;
98
- courseId: string;
99
- id?: string;
100
- grade: number;
101
- subject: string;
102
- orgId?: string;
103
- }
104
- interface UserOrganization {
105
- id: string;
106
- name: string | null;
107
- type: TimebackOrgType | string;
108
- isPrimary: boolean;
109
- }
110
- interface TimebackStudentProfile {
111
- role: TimebackUserRole;
112
- organizations: UserOrganization[];
113
- }
114
93
  /**
115
- * Timeback identity on `/users/me`: who the student is, without enrollments.
116
- * Enrollments come from `/timeback/user` (or `client.timeback.user`).
94
+ * The TimeBack subject vocabulary. 'None' is canonical: TimeBack accepts it
95
+ * on courses and uses it as the fallback for unknown or missing subjects.
117
96
  */
118
- interface UserTimebackProfile extends TimebackStudentProfile {
119
- id: string;
120
- }
121
- interface UserTimebackData extends UserTimebackProfile {
122
- enrollments: UserEnrollment[];
123
- }
124
- type LocalDaySource = 'browser_last_seen' | 'platform_default';
125
- interface LocalDayContext {
126
- timeZone: string;
127
- source: LocalDaySource;
128
- /** ISO 8601 timestamp for the last persisted timezone observation. */
129
- observedAt: string | null;
130
- }
97
+ type TimebackSubject = (typeof TIMEBACK_SUBJECTS)[number];
131
98
  /**
132
- * OpenID Connect UserInfo claims (NOT a database row).
99
+ * Grade levels per AE OneRoster GradeEnum.
100
+ * -1 = Pre-K, 0 = Kindergarten, 1-12 = Grades 1-12, 13 = AP
133
101
  */
134
- interface UserInfo {
135
- sub: string;
136
- email: string;
137
- name: string | null;
138
- email_verified?: boolean;
139
- given_name?: string;
140
- family_name?: string;
141
- issuer?: string;
142
- lti_roles?: unknown;
143
- lti_context?: unknown;
144
- lti_resource_link?: unknown;
145
- timeback_id?: string;
146
- }
147
- interface DeveloperStatusResponse {
148
- status: DeveloperStatusEnumType;
149
- }
102
+ type TimebackGrade = (typeof TIMEBACK_GRADES)[number];
150
103
  /**
151
- * Authenticated user for API responses.
152
- * Differs from UserRow: omits timebackId, adds hasTimebackAccount and timeback.
104
+ * Platform pedagogy levels for a single lesson of instruction.
105
+ * E1 teaches, E2/E3 practice and remediate, E4 is the mastery check.
153
106
  */
154
- interface AuthenticatedUser {
155
- id: string;
156
- email: string;
157
- emailVerified: boolean;
158
- name: string | null;
159
- image: string | null;
160
- username: string | null;
161
- role: UserRoleEnumType;
162
- developerStatus: DeveloperStatusEnumType;
163
- createdAt: Date;
164
- updatedAt: Date;
165
- hasTimebackAccount: boolean;
166
- localDay: LocalDayContext;
167
- timeback?: UserTimebackProfile;
168
- }
169
- interface GameUser {
170
- id: string;
171
- name: string | null;
172
- role: UserRoleEnumType;
173
- username: string | null;
174
- email: string | null;
175
- localDay: LocalDayContext;
176
- timeback?: UserTimebackProfile;
177
- }
107
+ type ELevel = 'E1' | 'E2' | 'E3' | 'E4';
108
+ /**
109
+ * Valid Caliper subject values. The same vocabulary as OneRoster subjects.
110
+ */
111
+ type CaliperSubject = (typeof TIMEBACK_SUBJECTS)[number];
112
+ /**
113
+ * OneRoster organization types.
114
+ */
115
+ type OrganizationType = 'department' | 'school' | 'district' | 'local' | 'state' | 'national';
116
+ /**
117
+ * Lesson types for PowerPath integration.
118
+ */
119
+ type LessonType = 'powerpath-100' | 'quiz' | 'test-out' | 'placement' | 'unit-test' | 'alpha-read-article' | null;
178
120
 
179
121
  /**
180
- * Game Types
122
+ * TimeBack Configuration Types
181
123
  *
182
- * Literal types and API DTOs. Database row types are in @playcademy/data/types.
124
+ * Configuration interfaces for Organization, Course, Component,
125
+ * Resource, and complete TimeBack setup.
183
126
  *
184
- * @module types/game
127
+ * @module types/timeback/config
185
128
  */
186
129
 
187
- type GameType = 'hosted' | 'external';
188
- type GamePlatform = 'web' | 'godot' | (string & {});
189
130
  /**
190
- * Game manifest file format (manifest.json).
191
- * Note: createdAt is a string here because it's parsed from JSON file.
131
+ * Organization configuration for TimeBack (user input - optionals allowed)
192
132
  */
193
- interface ManifestV1 {
194
- version: '1';
195
- platform: string;
196
- createdAt: string;
197
- }
198
- interface ManifestVersions {
199
- vitePlugin?: string;
200
- sdk?: string;
201
- cli?: string;
202
- vite?: string;
203
- godotSdk?: string;
204
- godot?: string;
205
- }
206
- interface ManifestV2 {
207
- version: '2';
208
- platform: string;
209
- createdAt: string;
210
- gameVersion?: string;
211
- versions: ManifestVersions;
212
- }
213
- type GameManifest = ManifestV1 | ManifestV2;
214
- /** One migration in a migrate-mode deploy payload */
215
- interface DeployMigration {
216
- /** Journal tag, e.g. '0042_brave_hulk' */
217
- tag: string;
218
- /** Pre-split SQL statements (the CLI splits on drizzle statement-breakpoints) */
219
- statements: string[];
220
- /** sha-256 of the normalized migration SQL (sha256-v1) */
221
- checksum: string;
222
- }
223
- /** Push-mode database payload: diff-generated SQL guarded by a baseline CAS */
224
- interface DeployDatabasePush {
225
- mode: 'push';
226
- /** Diff-generated DDL to execute (semicolon-separated statements) */
227
- sql: string;
228
- /** Stored schemaHash the diff was computed against; null only for a first deploy */
229
- baselineHash: string | null;
230
- /** Drizzle snapshot JSON this deploy moves the schema to */
231
- nextSnapshot: unknown;
232
- /** Hash of nextSnapshot, stored as the new push baseline on success */
233
- nextHash: string;
234
- /** Explicit consent for destructive statements (DROP TABLE, dropped columns) */
235
- acceptDataLoss?: boolean;
236
- }
237
- /** Migrate-mode database payload: the client's complete migration journal */
238
- interface DeployDatabaseMigrate {
239
- mode: 'migrate';
240
- /** The full journal in order; the server applies whatever the ledger lacks */
241
- migrations: DeployMigration[];
133
+ interface OrganizationConfig {
134
+ /** Display name for your organization */
135
+ name?: string;
136
+ /** Organization type */
137
+ type?: OrganizationType;
138
+ /** Unique identifier (defaults to Playcademy's org) */
139
+ identifier?: string;
242
140
  }
243
141
  /**
244
- * Mode-aware database payload (PLA-217 D5). Replaces the legacy `schema`
245
- * field for adopted games; the server verifies state before executing.
142
+ * Course goals for daily student targets
246
143
  */
247
- type DeployDatabasePayload = DeployDatabasePush | DeployDatabaseMigrate;
248
- /** Journal entry in a baseline adoption block */
249
- interface DeployBaselineJournalEntry {
250
- tag: string;
251
- checksum: string;
144
+ interface CourseGoals {
145
+ /** Target XP students should earn per day */
146
+ dailyXp?: number;
147
+ /** Target lessons per day */
148
+ dailyLessons?: number;
149
+ /** Target active minutes per day */
150
+ dailyActiveMinutes?: number;
151
+ /** Target accuracy percentage */
152
+ dailyAccuracy?: number;
153
+ /** Target mastered units per day */
154
+ dailyMasteredUnits?: number;
252
155
  }
253
156
  /**
254
- * Baseline adoption block (PLA-217 D7 seed-on-deploy): the client's claimed
255
- * starting state for a game that predates server-side deployment state.
256
- * Consumed by the deploy itself — an unadopted game gets its claimed ledger
257
- * rows, snapshot/hash, and live fingerprint recorded before the database
258
- * step runs; adopted games skip the block.
157
+ * Course metrics and totals
259
158
  */
260
- interface DeployBaseline {
261
- lastAppliedMigrationTag?: string;
262
- journal?: DeployBaselineJournalEntry[];
263
- /**
264
- * Per-migration snapshot deltas for content validation (D7): the
265
- * seed claim is judged against the live database exactly like a
266
- * manual `db baseline` claim — the side door uses the front door's
267
- * checkpoint.
268
- */
269
- evidence?: BaselineMigrationEvidence[];
270
- schemaSnapshot?: unknown;
271
- schemaHash?: string;
272
- integrationsHash?: string;
273
- buildHash?: string;
159
+ interface CourseMetrics {
160
+ /** Total XP available in the course */
161
+ totalXp?: number;
162
+ /** Total lessons/activities in the course */
163
+ totalLessons?: number;
164
+ /** Total number of grade levels covered by this course */
165
+ totalGrades?: number;
166
+ /** The type of course (e.g. 'optional', 'hole-filling', 'base') */
167
+ courseType?: 'base' | 'hole-filling' | 'optional' | 'Base' | 'Hole-Filling' | 'Optional';
168
+ /** Indicates whether the course is supplemental content */
169
+ isSupplemental?: boolean;
274
170
  }
275
171
  /**
276
- * Git provenance of the working tree a deploy was run from (PLA-294).
277
- *
278
- * Captured by the CLI at deploy time and persisted verbatim on the deploy
279
- * job, so "which commit is running" is answerable from the platform record.
280
- * Every field is nullable: a tree with no git, no remote, or a detached HEAD
281
- * is recorded honestly rather than refused. Recorded per deploy, never
282
- * pinned to the game — a fork deployed under the same slug shows the fork.
172
+ * Complete course metadata structure
283
173
  */
284
- interface DeploySource {
285
- /** Normalized `https://github.com/<org>/<repo>`; null when no remote or unparseable */
286
- repository: string | null;
287
- /** Full 40-char SHA of HEAD; null when not in a git tree */
288
- commit: string | null;
289
- /** Current branch name; null on detached HEAD outside CI */
290
- branch: string | null;
291
- /** True when the tree had uncommitted changes — the SHA does not describe what shipped */
292
- dirty: boolean;
293
- /**
294
- * True when the uploaded build artifact lives outside the git tree the
295
- * other fields describe (`--build ~/Downloads/game.zip`). The commit is
296
- * still the deployer's tree, but it may not be what produced the artifact.
297
- */
298
- externalBuild: boolean;
299
- }
300
- type DeployJobStatus = 'pending' | 'running' | 'succeeded' | 'failed';
301
- /** Active game worker state served by the deployment-state endpoint */
302
- interface DeploymentStateGame {
303
- /** Backend bundle hash from the active deployment row */
304
- codeHash: string | null;
305
- /** Frontend zip hash from game_deployment_state (null when unseeded) */
306
- buildHash: string | null;
307
- url: string;
308
- deployedAt: string;
174
+ interface CourseMetadata {
175
+ /** Define the type of course and priority for the student */
176
+ courseType?: 'base' | 'hole-filling' | 'optional';
177
+ /** Boolean value to determine if a course is supplemental to a base course */
178
+ isSupplemental?: boolean;
179
+ /** Boolean value to determine if a course is custom to an individual student */
180
+ isCustom?: boolean;
181
+ /** Signals whether a course is in production with students */
182
+ publishStatus?: 'draft' | 'testing' | 'published' | 'deactivated';
183
+ /** Whether this course appears in the TimeBack catalog for teachers and parents */
184
+ timebackVisible?: boolean;
185
+ /** Who to contact when issues reported with questions */
186
+ contactEmail?: string;
187
+ /** Primary app identifier */
188
+ primaryApp?: string;
189
+ /** Learning goals for students */
190
+ goals?: CourseGoals;
191
+ /** Course metrics and totals */
192
+ metrics?: CourseMetrics;
193
+ /** Vendor-specific metadata (e.g., AlphaLearn) */
194
+ [key: string]: unknown;
309
195
  }
310
- /** Active dashboard worker state served by the deployment-state endpoint */
311
- interface DeploymentStateDashboard {
312
- url: string;
313
- deployedAt: string;
196
+ /**
197
+ * Course configuration for TimeBack (user input)
198
+ */
199
+ interface CourseConfig {
200
+ /** Allocated OneRoster sourcedId (set after creation) */
201
+ sourcedId?: string;
202
+ /** Course title (defaults to game name) */
203
+ title?: string;
204
+ /** Subjects (REQUIRED for TimeBack integration) */
205
+ subjects: TimebackSubject[];
206
+ /** Used when recording progress/sessions if not explicitly specified per event. */
207
+ defaultSubject?: TimebackSubject;
208
+ /** Grade levels (REQUIRED for TimeBack integration) */
209
+ grades: TimebackGrade[];
210
+ /** Short course code (optional, auto-generated) */
211
+ courseCode?: string;
212
+ /** Course level (auto-derived from grades) */
213
+ level?: 'Elementary' | 'Middle' | 'High' | 'AP' | string;
214
+ /** Grading system */
215
+ gradingScheme?: 'STANDARD';
216
+ /** Total XP available in this course (REQUIRED before setup) */
217
+ totalXp?: number | null;
218
+ /** Total masterable units in this course (REQUIRED before setup) */
219
+ masterableUnits?: number | null;
220
+ /** Custom Playcademy metadata */
221
+ metadata?: CourseMetadata;
314
222
  }
315
- /** Details of the last failed migration, from the failed deploy job */
316
- interface DeploymentStateDatabaseFailure {
317
- tag: string;
318
- error: string;
319
- /**
320
- * Set only when the failing statement is known exactly (the size
321
- * preflight names the statement it measured). Execution failures are
322
- * null: D1's byte offset has an unverified reference frame for the
323
- * batch array form, so it is never mapped to an index.
324
- */
325
- statementIndex: number | null;
326
- at: string;
223
+ /**
224
+ * Component configuration for TimeBack (user input)
225
+ */
226
+ interface ComponentConfig {
227
+ /** Component title (defaults to "{course.title} Activities") */
228
+ title?: string;
229
+ /** Display order */
230
+ sortOrder?: number;
231
+ /** Required prior components */
232
+ prerequisites?: string[];
233
+ /** How prerequisites work */
234
+ prerequisiteCriteria?: 'ALL' | 'ANY';
327
235
  }
328
- /** A ledger entry from the game database's applied-migrations ledger */
329
- interface DeploymentStateAppliedMigration {
330
- tag: string;
331
- /** Checksum recorded at apply time (normalized SQL, see checksumAlgo) */
332
- checksum: string;
333
- /** Hash algorithm the checksum was recorded under (e.g. 'sha256-v1') */
334
- checksumAlgo: string;
236
+ /**
237
+ * Playcademy-specific resource extensions
238
+ */
239
+ interface PlaycademyResourceMetadata {
240
+ /** Mastery configuration for tracking discrete learning units */
241
+ mastery?: {
242
+ /** Total number of masterable units in the resource */
243
+ masterableUnits: number;
244
+ /** Type of mastery unit for semantic clarity */
245
+ unitType?: 'level' | 'rank' | 'skill' | 'module';
246
+ };
335
247
  }
336
- /** Database schema state served by the deployment-state endpoint */
337
- interface DeploymentStateDatabase {
338
- /** Applied migrations from the live in-D1 ledger (null when the game has no database) */
339
- appliedMigrations: DeploymentStateAppliedMigration[] | null;
340
- lastFailure: DeploymentStateDatabaseFailure | null;
341
- /** Hash of the drizzle snapshot (push-mode baseline) */
342
- schemaHash: string | null;
343
- /** Hash of the normalized live sqlite_master */
344
- schemaFingerprint: string | null;
345
- /**
346
- * Stored drizzle snapshot (push-mode diffing only). Present only when
347
- * the request asked for it with `?include=schemaSnapshot` (D4).
348
- */
349
- schemaSnapshot?: unknown;
248
+ /**
249
+ * Resource configuration for TimeBack (user input)
250
+ */
251
+ interface ResourceConfig {
252
+ /** Resource title (defaults to "{course.title} Game") */
253
+ title?: string;
254
+ /** Internal resource ID (auto-generated from package.json) */
255
+ vendorResourceId?: string;
256
+ /** Vendor identifier */
257
+ vendorId?: string;
258
+ /** Application identifier */
259
+ applicationId?: string;
260
+ /** Resource roles */
261
+ roles?: ('primary' | 'secondary')[];
262
+ /** Resource importance */
263
+ importance?: 'primary' | 'secondary';
264
+ /** Interactive resource metadata */
265
+ metadata?: {
266
+ /** Resource type */
267
+ type?: 'interactive';
268
+ /** Launch URL (defaults to Playcademy game URL) */
269
+ launchUrl?: string;
270
+ /** Platform name */
271
+ toolProvider?: string;
272
+ /** Teaching method */
273
+ instructionalMethod?: 'exploratory' | 'direct-instruction';
274
+ /** Subject area */
275
+ subject?: TimebackSubject;
276
+ /** Target grades */
277
+ grades?: TimebackGrade[];
278
+ /** Content language */
279
+ language?: string;
280
+ /** Base XP for completion */
281
+ xp?: number;
282
+ /** Playcademy-specific extensions */
283
+ playcademy?: PlaycademyResourceMetadata;
284
+ };
350
285
  }
351
- /** Secret key names partitioned by ownership — names only, never hashes */
352
- interface DeploymentStateSecrets {
353
- /** Keys recorded in the server-side secrets manifest */
354
- managedKeys: string[];
355
- /**
356
- * Remote keys not in the manifest (set by SST, wrangler, or hand).
357
- * Null when the server has no Cloudflare provider to list remote keys.
358
- */
359
- unmanagedKeys: string[] | null;
286
+ /**
287
+ * Component Resource link configuration (user input)
288
+ */
289
+ interface ComponentResourceConfig {
290
+ /** Link title (defaults to "{resource.title} Activity") */
291
+ title?: string;
292
+ /** Display order */
293
+ sortOrder?: number;
294
+ /** Lesson type for PowerPath integration */
295
+ lessonType?: LessonType;
360
296
  }
361
- interface DeploymentStateLastDeploy {
362
- at: string;
363
- /** Who deployed: their email, or the raw user id when the account no longer resolves */
364
- by: string;
297
+ interface TimebackCourseConfig {
298
+ subject: string;
299
+ grade: number;
300
+ }
301
+ interface DerivedPlatformCourseConfig extends TimebackCourseConfig {
302
+ title: string;
303
+ courseCode: string;
304
+ level: string;
305
+ metadata?: Record<string, unknown>;
306
+ totalXp?: number | null;
307
+ masterableUnits?: number | null;
365
308
  }
309
+
366
310
  /**
367
- * Server-side deployment state for a game.
311
+ * TimeBack Client SDK DTOs
368
312
  *
369
- * Everything CLI deploy prep diffs against, fetched from
370
- * GET /api/games/:slug/deployment-state so deploys never depend on
371
- * local state for correctness.
313
+ * Data transfer objects for the TimeBack client SDK including
314
+ * progress tracking, session management, and activity completion.
315
+ *
316
+ * Note: TimebackClientConfig lives in @playcademy/timeback as it's
317
+ * SDK configuration, not a DTO.
318
+ *
319
+ * @module types/timeback/client
372
320
  */
373
- interface DeploymentStateResponse {
374
- gameId: string;
375
- /** True iff a game_deployment_state row exists for the game */
376
- seeded: boolean;
377
- game: DeploymentStateGame | null;
378
- dashboard: DeploymentStateDashboard | null;
379
- database: DeploymentStateDatabase;
380
- secrets: DeploymentStateSecrets;
381
- /** Hash of the declared integrations config (null when unseeded) */
382
- integrationsHash: string | null;
383
- /** Last deployed compatibility date (null when unseeded) */
384
- compatibilityDate: string | null;
385
- lastDeploy: DeploymentStateLastDeploy | null;
386
- }
321
+
387
322
  /**
388
- * Per-key verdict groups from the server-side secrets diff (D6).
389
- *
390
- * Key names only — HMAC digests never leave the server. `remoteOnlyManaged`
391
- * keys are the only legal prune candidates; `remoteOnlyUnmanaged` keys were
392
- * set outside the platform and are untouchable.
323
+ * Known extensions for TimeBack Activity Metrics Collection
393
324
  */
394
- interface SecretsDiffResponse {
395
- /** Local keys the manifest doesn't know yet */
396
- added: string[];
397
- /** Keys whose local value's HMAC differs from the manifest's */
398
- changed: string[];
399
- /** Keys whose local value's HMAC matches the manifest's */
400
- unchanged: string[];
401
- /** Manifest keys absent locally (prunable) */
402
- remoteOnlyManaged: string[];
403
- /** Worker keys absent from both the manifest and the local set */
404
- remoteOnlyUnmanaged: string[];
325
+ interface TimebackActivityExtensions {
326
+ /** Percentage complete (0-100) for the app course */
327
+ pctCompleteApp?: number;
328
+ /** Allow other arbitrary extensions */
329
+ [key: string]: unknown;
330
+ }
331
+ interface MasteryWriteWarning {
332
+ code: 'MASTERY_WRITE_CAPPED';
333
+ message: string;
334
+ currentMasteredUnits: number;
335
+ attemptedMasteredUnits: number;
336
+ appliedMasteredUnits: number;
337
+ storedMasteredUnits: number;
338
+ masterableUnits: number;
405
339
  }
406
340
  /**
407
- * Manual baseline adoption request (PLA-217 D7): the fresh-machine path for
408
- * a game that predates server-side deployment state. Carries the claimed
409
- * migrate-mode history (tag + journal), the push-mode snapshot, or both.
341
+ * Activity data for ending an activity
410
342
  */
411
- interface DeploymentStateBaselineRequest {
412
- lastAppliedMigrationTag?: string;
413
- journal?: DeployBaselineJournalEntry[];
414
- schemaSnapshot?: unknown;
415
- schemaHash?: string;
416
- /**
417
- * Per-migration schema-object evidence (creates AND drops) derived
418
- * from drizzle's snapshot files. The server replays it up to the
419
- * claimed tag into the expected schema and validates that against the
420
- * live database (D7): surviving claimed objects must exist,
421
- * beyond-claim objects must be absent unless claimed history already
422
- * explains them. Absent evidence downgrades every migration to
423
- * no-signal.
424
- */
425
- evidence?: BaselineMigrationEvidence[];
426
- /**
427
- * Waive refusals for no-signal migrations only (content contradictions
428
- * are never waivable). Recorded server-side for audit.
429
- */
430
- allowUnverified?: boolean;
343
+ interface ActivityData {
344
+ /** Unique activity identifier (required) */
345
+ activityId: string;
346
+ /** Grade level for this activity (required for multi-grade course routing) */
347
+ grade: number;
348
+ /** Subject area (required for multi-grade course routing) */
349
+ subject: CaliperSubject;
350
+ /** Activity display name (optional) */
351
+ activityName?: string;
352
+ /** Course identifier (auto-filled from config if not provided) */
353
+ courseId?: string;
354
+ /** Course display name (auto-filled from config if not provided) */
355
+ courseName?: string;
356
+ /** Student email address (optional) */
357
+ studentEmail?: string;
358
+ /** Application name for Caliper events (defaults to 'Game') */
359
+ appName?: string;
360
+ /** Sensor URL for Caliper events (defaults to baseUrl) */
361
+ sensorUrl?: string;
431
362
  }
432
363
  /**
433
- * Schema objects one journal migration introduced and removed (snapshot
434
- * delta). Drops are as load-bearing as creates: an object created by one
435
- * migration and dropped by a later one must not be demanded of the live
436
- * database, and its live presence beyond the claim must not convict a
437
- * migration whose object is already explained by claimed history.
364
+ * Score data for ending an activity
438
365
  */
439
- interface BaselineMigrationEvidence {
440
- tag: string;
441
- /** Journal generation timestamp (drizzle `when`), ISO 8601 */
442
- generatedAt: string;
443
- createsTables: {
444
- name: string;
445
- columns: string[];
446
- }[];
447
- addsColumns: {
448
- table: string;
449
- column: string;
450
- }[];
451
- createsIndexes: string[];
452
- createsViews: string[];
453
- dropsTables: string[];
454
- dropsColumns: {
455
- table: string;
456
- column: string;
457
- }[];
458
- dropsIndexes: string[];
459
- dropsViews: string[];
460
- }
461
- /** Outcome of the `db realign <tag>` checksum pardon */
462
- interface MigrationRealignResponse {
463
- tag: string;
464
- /** The re-recorded checksum */
465
- checksum: string;
466
- /** Algorithm stamped alongside it (e.g. 'sha256-v1') */
467
- checksumAlgo: string;
468
- }
469
- /** How a ledger escape-hatch resolution lands: record the row, or remove it */
470
- type MigrationResolution = 'applied' | 'rolled-back';
471
- /** Outcome of the `db resolve <tag>` ledger escape hatch */
472
- interface MigrationResolveResponse {
473
- tag: string;
474
- resolution: MigrationResolution;
366
+ interface EndActivityScoreData {
367
+ /** Number of questions answered correctly */
368
+ correctQuestions: number;
369
+ /** Total number of questions */
370
+ totalQuestions: number;
475
371
  /**
476
- * Live schema fingerprint captured by the resolve: the developer's
477
- * attestation that the current database state is intended, so the next
478
- * deploy verifies against it instead of the pre-repair record.
372
+ * XP earned for this activity.
373
+ *
374
+ * Required when the game reports directly (platform, demo, standalone).
375
+ * A child-launched game may omit it: narrow the client with the SDK's
376
+ * `isChildLaunched()` for the relaxed signature. The parent game
377
+ * decides the award, and a value provided here travels only as the
378
+ * `childXpSuggested` audit suggestion.
479
379
  */
480
- schemaFingerprint: string;
380
+ xpAwarded: number;
481
381
  /**
482
- * Whether the fingerprint was persisted to the game's deployment-state
483
- * row. False when the game has no such row (not yet adopted): the
484
- * ledger repair still succeeded, but nothing was recorded.
382
+ * Incremental learning units mastered this session.
383
+ *
384
+ * Cannot be used with masteredUnitsAbsolute. When a course has mastery
385
+ * tracking configured, the platform bounds submissions that would move
386
+ * the student below 0 or above the configured masterableUnits maximum and
387
+ * returns warning metadata.
485
388
  */
486
- fingerprintRecorded: boolean;
487
- }
488
- /** One deploy job in a game's execution history (PLA-217 D10) */
489
- interface GameDeployHistoryDeploy {
490
- kind: 'deploy';
491
- status: DeployJobStatus;
492
- /** When the deploy landed (creation time while pending/running), ISO 8601 */
493
- at: string;
494
- /** When the job finished (null while pending/running) */
495
- completedAt: string | null;
496
- /** Who deployed: their email, or DELETED_ACCOUNT_LABEL when the account is gone */
497
- by: string;
498
- /** Client idempotency key (null for legacy clients) */
499
- deployId: string | null;
500
- error: string | null;
501
- }
502
- /** A Time Travel restore in a game's execution history */
503
- interface GameDeployHistoryRestore {
504
- kind: 'restore';
505
- /** When the restore ran, ISO 8601 */
506
- at: string;
507
- /** Who restored: their email, or DELETED_ACCOUNT_LABEL when the account is gone */
508
- by: string;
509
- /** The moment the database was rewound to, ISO 8601 */
510
- restoredTo: string;
511
- }
512
- /** A client-gate refusal in a game's execution history */
513
- interface GameDeployHistoryBlocked {
514
- kind: 'blocked';
515
- /** When the gate refused, ISO 8601 */
516
- at: string;
517
- /** Whose deploy was refused: their email, or DELETED_ACCOUNT_LABEL */
518
- by: string;
519
- /** Stable `blocked:*` code the gate refused with */
520
- code: string;
521
- /** The gate's plain-text refusal reason */
522
- reason: string;
523
- }
524
- /**
525
- * One entry in a game's execution history: deploy jobs interleaved with
526
- * the platform-visible events the job system never sees (restores,
527
- * client-gate refusals), newest first.
528
- */
529
- type GameDeployHistoryEntry = GameDeployHistoryDeploy | GameDeployHistoryRestore | GameDeployHistoryBlocked;
530
- /** Deploy history served by GET /api/games/:slug/deployments */
531
- interface GameDeployHistoryResponse {
532
- deploys: GameDeployHistoryEntry[];
389
+ masteredUnits?: number;
390
+ /**
391
+ * Absolute total of mastered units.
392
+ *
393
+ * The platform computes the delta from the current value. Cannot be used
394
+ * with masteredUnits. When a course has mastery tracking configured, the
395
+ * platform bounds values outside 0..masterableUnits and returns warning
396
+ * metadata.
397
+ */
398
+ masteredUnitsAbsolute?: number;
399
+ /** Optional arbitrary extensions to include in the Caliper event */
400
+ extensions?: TimebackActivityExtensions;
533
401
  }
402
+
534
403
  /**
535
- * One successful deploy of a game's worker, as the open releases surface
536
- * describes it: what is running and which commit produced it.
404
+ * Caliper Protocol Types
537
405
  *
538
- * This shape is parsed by external automation. Every field is present on
539
- * every entry — nullable, never absent — and nothing from the deploy job
540
- * beyond its git provenance and completion time is exposed. No deployer
541
- * identity, no schema state, no secrets manifest.
406
+ * Types for the IMS Caliper Analytics standard used by TimeBack
407
+ * for learning activity tracking.
408
+ *
409
+ * @module types/timeback/caliper
542
410
  */
543
- interface Release {
544
- slug: string;
545
- /** Where the game is served; null when the platform has no URL for it */
546
- url: string | null;
547
- /**
548
- * Git provenance the deploying CLI captured. Null for deploys that
549
- * predate provenance capture, so the fleet list is complete on day one
550
- * and a consumer can tell "unknown" from "not in git".
551
- */
552
- source: DeploySource | null;
553
- /** When the deploy succeeded, ISO 8601 */
554
- deployedAt: string;
555
- }
556
- /** GET /api/releases — the current release of every game */
557
- interface ReleasesResponse {
558
- releases: Release[];
411
+
412
+ interface TimebackStoredCaliperMetric {
413
+ type: string;
414
+ value?: number;
415
+ subType?: string;
559
416
  }
560
- /** GET /api/releases/:slug — one game's current release and, on request, its recent history */
561
- interface GameReleaseResponse {
562
- /** The current release; null when the game has never deployed successfully */
563
- current: Release | null;
564
- /**
565
- * The last N successful deploys, newest first, current included. Only
566
- * present when `?history=N` was requested.
567
- */
568
- history?: Release[];
417
+ interface TimebackStoredCaliperEntity {
418
+ id?: string;
419
+ type?: string;
420
+ name?: string;
421
+ email?: string;
422
+ app?: {
423
+ id?: string;
424
+ name?: string;
425
+ };
426
+ activity?: {
427
+ id?: string;
428
+ name?: string;
429
+ extensions?: Record<string, unknown> | null;
430
+ };
431
+ course?: {
432
+ id?: string;
433
+ name?: string;
434
+ };
435
+ items?: TimebackStoredCaliperMetric[];
436
+ extensions?: Record<string, unknown> | null;
437
+ [key: string]: unknown;
569
438
  }
570
- /** Request body for POST /api/games/:slug/deployments/blocked */
571
- interface DeployBlockedReport {
572
- /** Stable `blocked:*` code the gate refused with */
573
- code: string;
574
- /** The gate's plain-text refusal reason */
575
- reason: string;
439
+ interface TimebackStoredCaliperEvent {
440
+ id: number;
441
+ externalId: string;
442
+ sensor: string;
443
+ type: string;
444
+ profile?: string;
445
+ action: string;
446
+ eventTime: string;
447
+ sendTime: string;
448
+ updated_at: string | null;
449
+ created_at: string;
450
+ deleted_at: string | null;
451
+ actor: TimebackStoredCaliperEntity;
452
+ object: TimebackStoredCaliperEntity;
453
+ generated?: TimebackStoredCaliperEntity | null;
454
+ target?: TimebackStoredCaliperEntity | null;
455
+ referrer?: TimebackStoredCaliperEntity | null;
456
+ edApp?: TimebackStoredCaliperEntity | null;
457
+ group?: TimebackStoredCaliperEntity | null;
458
+ membership?: TimebackStoredCaliperEntity | null;
459
+ session?: TimebackStoredCaliperEntity | null;
460
+ federatedSession?: TimebackStoredCaliperEntity | null;
461
+ extensions?: Record<string, unknown> | null;
462
+ clientAppId?: string | null;
576
463
  }
464
+
577
465
  /**
578
- * A restorable pre-deploy database state (D1 Time Travel bookmark).
466
+ * Game-side learning metrics for a single student.
579
467
  *
580
- * Each schema-bearing deploy captures a bookmark of the database as it was
581
- * the moment before that deploy's schema changes ran. Only bookmarks
582
- * belonging to the CURRENT database and within Time Travel's retention
583
- * window are served — a `db reset` creates a new database (bookmarks do
584
- * not cross that boundary), and Cloudflare expires bookmarks after the
585
- * account plan's retention period.
468
+ * Returned by opted-in game workers from their reserved
469
+ * `/__playcademy/metrics` route.
586
470
  */
587
- interface GameRestorePoint {
588
- /** Deployment row id — pass to the restore endpoint (or a unique prefix to the CLI) */
589
- id: string;
590
- /**
591
- * When the bookmark was captured (the exact state a restore rewinds
592
- * to), ISO 8601. Rows from before capture times were recorded fall
593
- * back to the deploy completion time.
594
- */
595
- capturedAt: string;
596
- /** Whether the capturing deployment is the currently active one */
597
- active: boolean;
598
- }
599
- /** Restore points served by GET /api/games/:slug/database/restore-points */
600
- interface GameRestorePointsResponse {
601
- restorePoints: GameRestorePoint[];
602
- /**
603
- * True for push-adopted games, whose recorded snapshot cannot rewind
604
- * with the data: restore is categorically refused, so the list is
605
- * served empty rather than offering points that can never restore.
606
- */
607
- restoreUnsupported: boolean;
608
- }
609
- /** Outcome of a Time Travel restore (PLA-217 D10) */
610
- interface DatabaseRestoreResponse {
611
- restorePointId: string;
612
- /** The moment the database was rewound to (the bookmark's capture time), ISO 8601 */
613
- restoredTo: string;
614
- /**
615
- * Live schema fingerprint captured after the restore: the developer's
616
- * audited attestation that the rewound state is intended, so the next
617
- * deploy verifies against it.
618
- */
619
- schemaFingerprint: string;
620
- /** False when the game has no deployment-state row to re-attest */
621
- fingerprintRecorded: boolean;
622
- /**
623
- * Bookmark of the database as it was just before this restore — the
624
- * undo handle. Null only if Cloudflare omits it from the response.
625
- */
626
- previousBookmark: string | null;
627
- }
628
- /** Push-mode reset payload: the full schema that rebuilds the fresh database */
629
- interface DatabaseResetPush {
630
- mode: 'push';
631
- /** Full schema DDL (semicolon-separated statements) */
632
- sql: string;
633
- /** Drizzle snapshot JSON, stored as the new push baseline */
634
- nextSnapshot: unknown;
635
- /** Hash of nextSnapshot, stored as the new schemaHash */
636
- nextHash: string;
637
- }
638
- /** Migrate-mode reset payload: the complete journal to replay on the fresh database */
639
- interface DatabaseResetMigrate {
640
- mode: 'migrate';
641
- /** The full journal in order; replayed one-by-one, rebuilding the ledger */
642
- migrations: DeployMigration[];
471
+ interface GameMetricsResponse {
472
+ /** Student identifier (Playcademy user ID). */
473
+ studentId: string;
474
+ /** Student email, when available to the game. */
475
+ email?: string;
476
+ /** Per-course metrics grouped by TimeBack grade and subject. */
477
+ courses: GameCourseMetrics[];
643
478
  }
644
- /**
645
- * Mode-aware reset payload (PLA-217 D2). Reset recreates the database, so
646
- * the ledger dies with it and there is no baseline to compare against —
647
- * adopted games must send how to rebuild.
648
- */
649
- type DatabaseResetDatabasePayload = DatabaseResetPush | DatabaseResetMigrate;
650
- interface DatabaseResetRequest {
651
- /**
652
- * Legacy schema info, accepted only while the game's schema state is
653
- * unadopted; adopted games must send `database` instead.
654
- */
655
- schema?: {
656
- /** SQL schema statements (DDL: CREATE, ALTER, etc.) */
657
- sql: string;
658
- /** Hash of the schema for change detection */
659
- hash: string;
660
- };
661
- /** Mode-aware rebuild payload (mandatory for adopted games) */
662
- database?: DatabaseResetDatabasePayload;
479
+ interface GameCourseMetrics {
480
+ /** Grade level matching the game's TimeBack integration. */
481
+ grade: TimebackGrade;
482
+ /** Subject matching the game's TimeBack integration. */
483
+ subject: TimebackSubject;
484
+ /** Total XP the game has recorded for this student in this course. */
485
+ totalXp?: number;
486
+ /** Mastered units the game has recorded for this course. */
487
+ masteredUnits?: number;
488
+ /** Total active time in seconds the game has recorded for this course. */
489
+ activeTimeSeconds?: number;
490
+ /** Optional per-run breakdown keyed by Timeback run ID. */
491
+ activities?: GameRunMetrics[];
663
492
  }
664
- /** Log entry captured from seed worker console output */
665
- interface SeedLogEntry {
666
- /** Log level (log, warn, error, info) */
667
- level: 'log' | 'warn' | 'error' | 'info';
668
- /** Log message content */
669
- message: string;
670
- /** Milliseconds since seed execution started */
671
- timestamp: number;
493
+ interface GameRunMetrics {
494
+ runId: string;
495
+ activityId: string;
496
+ activityName?: string;
497
+ totalXp?: number;
498
+ masteredUnits?: number;
499
+ activeTimeSeconds?: number;
500
+ score?: number;
672
501
  }
673
- /** Structured error details from D1/SQLite errors */
674
- interface SeedErrorDetails {
675
- /** Error category code */
676
- code?: 'CONSTRAINT_VIOLATION' | 'SQL_ERROR' | 'DATABASE_BUSY';
677
- /** Table name involved in the error */
678
- table?: string;
679
- /** Constraint name or column that caused the error */
680
- constraint?: string;
681
- /** Specific constraint type */
682
- constraintType?: 'UNIQUE' | 'FOREIGN_KEY' | 'NOT_NULL';
683
- /** Token near syntax error */
684
- nearToken?: string;
685
- /** Specific error type within category */
686
- errorType?: 'TABLE_NOT_FOUND' | 'SYNTAX_ERROR';
502
+ type GameMetricsUnsupportedReason = 'no_timeback_integration' | 'no_active_deployment' | 'route_not_implemented' | 'timeout' | 'fetch_failed' | 'invalid_response';
503
+ type GameMetricsProxyResponse = {
504
+ supported: true;
505
+ metrics: GameMetricsResponse;
506
+ } | {
507
+ supported: false;
508
+ reason: GameMetricsUnsupportedReason;
509
+ details?: string;
510
+ };
511
+ type GameMetricComparisonMetric = 'xp' | 'mastery' | 'time' | 'score';
512
+ type GameMetricComparisonKind = 'number' | 'time' | 'percent';
513
+ type GameMetricComparisonRowStatus = 'matched' | 'discrepant' | 'not_reported_by_game' | 'not_recorded_by_timeback';
514
+ interface GameMetricComparisonRow {
515
+ metric: GameMetricComparisonMetric;
516
+ kind: GameMetricComparisonKind;
517
+ status: GameMetricComparisonRowStatus;
518
+ timebackValue?: number;
519
+ gameValue?: number;
520
+ delta?: number;
687
521
  }
688
- /**
689
- * API response for seed operations (what the API returns to the CLI).
690
- *
691
- * Extends the worker response with deployment metadata.
692
- */
693
- interface SeedResponse {
694
- /** Whether the seed completed successfully */
695
- success: boolean;
696
- /** Unique identifier for the seed worker deployment */
697
- deploymentId: string;
698
- /** When the seed was executed (ISO 8601 string from JSON serialization) */
699
- executedAt: string;
700
- /** Captured console output from the seed script */
701
- logs?: SeedLogEntry[];
702
- /** Execution duration in milliseconds */
703
- duration?: number;
704
- /** Error message if seed failed */
705
- error?: string;
706
- /** Stack trace if seed failed */
707
- stack?: string;
708
- /** Structured error details if seed failed */
709
- details?: SeedErrorDetails;
522
+ type GameRunMetricsComparisonStatus = 'matched' | 'discrepant' | 'not_reported' | 'unavailable';
523
+ interface GameRunMetricsComparisonSummary {
524
+ runId: string;
525
+ status: GameRunMetricsComparisonStatus;
526
+ discrepancyCount: number;
527
+ reason?: GameMetricsUnsupportedReason;
710
528
  }
711
- interface DomainValidationRecords {
712
- ownership?: {
713
- name?: string;
714
- value?: string;
715
- type?: string;
716
- };
717
- ssl?: {
718
- txt_name?: string;
719
- txt_value?: string;
720
- }[];
529
+ interface GameRunMetricsComparison extends GameRunMetricsComparisonSummary {
530
+ rows: GameMetricComparisonRow[];
721
531
  }
722
532
 
723
533
  /**
724
- * Leaderboard Types
534
+ * QTI API Response Types
725
535
  *
726
- * @module types/leaderboard
536
+ * Types for the QTI assessment content service responses.
537
+ * These mirror the JSON structure returned by the QTI API
538
+ * (beyond-qti-2) for assessment tests and items.
539
+ *
540
+ * @module types/timeback/qti
727
541
  */
728
- type LeaderboardTimeframe = 'all_time' | 'monthly' | 'weekly' | 'daily';
729
- interface LeaderboardOptions {
730
- timeframe?: LeaderboardTimeframe;
731
- limit?: number;
732
- offset?: number;
733
- gameId?: string;
542
+ interface QtiItemRef {
543
+ identifier: string;
544
+ href: string;
545
+ sequence?: number;
734
546
  }
735
- interface LeaderboardEntry {
736
- rank: number;
737
- userId: string;
738
- username: string;
739
- userImage?: string | null;
740
- score: number;
741
- achievedAt: Date;
742
- metadata?: Record<string, unknown>;
743
- gameId?: string;
744
- gameTitle?: string;
745
- gameSlug?: string;
547
+ interface QtiAssessmentSection {
548
+ identifier: string;
549
+ title: string;
550
+ visible?: boolean;
551
+ required?: boolean;
552
+ fixed?: boolean;
553
+ sequence?: number;
554
+ 'qti-assessment-item-ref'?: QtiItemRef[];
746
555
  }
747
- interface UserRank {
748
- rank: number;
749
- totalPlayers: number;
750
- score: number;
751
- percentile: number;
556
+ interface QtiTestPart {
557
+ identifier: string;
558
+ navigationMode: 'linear' | 'nonlinear';
559
+ submissionMode: 'individual' | 'simultaneous';
560
+ 'qti-assessment-section': QtiAssessmentSection[];
752
561
  }
753
- interface UserRankResponse {
754
- rank: number;
755
- score: number;
756
- userId: string;
562
+ interface QtiOutcomeDeclaration {
563
+ identifier: string;
564
+ cardinality?: 'single' | 'multiple' | 'ordered' | 'record';
565
+ baseType: 'boolean' | 'directedPair' | 'duration' | 'file' | 'float' | 'identifier' | 'integer' | 'pair' | 'point' | 'string' | 'uri';
566
+ normalMaximum?: number;
567
+ normalMinimum?: number;
568
+ defaultValue?: {
569
+ value?: unknown;
570
+ };
757
571
  }
758
- interface UserScore {
759
- id: string;
760
- score: number;
761
- achievedAt: Date;
762
- metadata?: Record<string, unknown>;
763
- gameId: string;
764
- gameTitle: string;
765
- gameSlug: string;
572
+ interface QtiAssessmentTest {
573
+ identifier: string;
574
+ title: string;
575
+ qtiVersion?: string;
576
+ timeLimit?: number;
577
+ maxAttempts?: number;
578
+ toolsEnabled?: Record<string, boolean>;
579
+ 'qti-test-part': QtiTestPart[];
580
+ 'qti-outcome-declaration'?: QtiOutcomeDeclaration[];
581
+ metadata?: Record<string, unknown>;
582
+ rawXml?: string;
583
+ content?: Record<string, unknown>;
584
+ createdAt?: string;
585
+ updatedAt?: string;
766
586
  }
767
- /**
768
- * Leaderboard entry with required game context.
769
- * Used when fetching leaderboards for a specific game.
770
- */
771
- interface GameLeaderboardEntry {
772
- rank: number;
773
- userId: string;
774
- username: string;
775
- userImage?: string | null;
776
- score: number;
777
- achievedAt: Date;
587
+ interface QtiAssessmentTestListResponse {
588
+ items: QtiAssessmentTest[];
589
+ total: number;
590
+ page: number;
591
+ pages: number;
592
+ limit: number;
593
+ sort: string;
594
+ order: 'asc' | 'desc';
595
+ }
596
+ interface QtiResponseDeclaration {
597
+ identifier: string;
598
+ cardinality: 'single' | 'multiple' | 'ordered';
599
+ baseType: string;
600
+ correctResponse?: {
601
+ value: string[];
602
+ };
603
+ }
604
+ interface QtiAssessmentItem {
605
+ identifier: string;
606
+ title: string;
607
+ type?: string;
608
+ qtiVersion?: string;
609
+ timeDependent?: boolean;
610
+ adaptive?: boolean;
611
+ preInteraction?: string;
612
+ interaction?: Record<string, unknown>;
613
+ postInteraction?: string;
614
+ responseDeclarations?: QtiResponseDeclaration[];
615
+ outcomeDeclarations?: QtiOutcomeDeclaration[];
616
+ responseProcessing?: Record<string, unknown>;
778
617
  metadata?: Record<string, unknown>;
779
- gameId: string;
780
- gameTitle: string;
781
- gameSlug: string;
618
+ modalFeedback?: unknown[];
619
+ feedbackInline?: unknown[];
620
+ feedbackBlock?: unknown[];
621
+ rubrics?: unknown[];
622
+ stimulus?: unknown;
623
+ rawXml?: string;
624
+ content?: Record<string, unknown>;
625
+ createdAt?: string;
626
+ updatedAt?: string;
627
+ }
628
+ interface QtiAssessmentItemListResponse {
629
+ items: QtiAssessmentItem[];
630
+ total: number;
631
+ page: number;
632
+ pages: number;
633
+ limit: number;
634
+ sort: string;
635
+ order: 'asc' | 'desc';
636
+ }
637
+ /** Request an exact, independently owned copy through the normal question collection endpoint. */
638
+ interface QtiQuestionCopyCreateInput {
639
+ mode: 'copy';
640
+ sourceItemIdentifier: string;
641
+ }
642
+ type QtiQuestionCreateInput = QtiQuestionCopyCreateInput | Record<string, unknown>;
643
+ interface QtiTestQuestionRef {
644
+ ownership?: 'owned' | 'shared';
645
+ reference: {
646
+ identifier: string;
647
+ href: string;
648
+ testPart: string;
649
+ section: string;
650
+ };
651
+ question: QtiAssessmentItem;
652
+ }
653
+ interface QtiTestQuestionsResponse {
654
+ assessmentTest: string;
655
+ title: string;
656
+ totalQuestions: number;
657
+ questions: QtiTestQuestionRef[];
782
658
  }
783
659
 
784
660
  /**
785
- * Skill Status Types
661
+ * TimeBack API Request/Response Types
786
662
  *
787
- * Contract for cross-game skill status queries. An answering game exports
788
- * `getSkillStatus` from `server/lib/skills.ts`; the platform calls its
789
- * reserved `/__playcademy/skills/status` route on behalf of another game.
663
+ * Types for TimeBack API endpoints including XP tracking,
664
+ * setup, verification, and activity completion.
790
665
  *
791
- * @module types/skills
666
+ * @module types/timeback/api
792
667
  */
793
668
 
794
- /**
795
- * Current status of one skill for one student, as judged by the answering game.
796
- *
797
- * - `locked`: the student can't work on the skill yet in this game.
798
- * - `unlocked`: available to the student, but no progress yet.
799
- * - `in_progress`: started, not mastered.
800
- * - `mastered`: currently meets this game's mastery bar, including by placement.
801
- * - `unknown_skill`: the skill ID isn't recognized. Never report an unrecognized
802
- * skill as `locked`.
803
- */
804
- type SkillStatus = (typeof SKILL_STATUSES)[number];
805
- /** How a `mastered` status was reached. */
806
- type SkillMasterySource = (typeof SKILL_MASTERY_SOURCES)[number];
807
- interface SkillStatusResult {
808
- /** Skill ID, lowercase. */
809
- skill: string;
810
- /** Current status. */
811
- status: SkillStatus;
812
- /** How mastery was reached. Only allowed when `status` is `mastered`. */
813
- source?: SkillMasterySource;
814
- /** ISO 8601 time of the evidence behind this status. */
815
- asOf?: string;
669
+ interface PopulateStudentResponse {
670
+ status: string;
671
+ message?: string;
816
672
  }
817
- /** Response returned by an answering game's `getSkillStatus` handler. */
818
- interface SkillStatusResponse {
819
- /** Student identifier (Playcademy user ID). Must match the requested student. */
820
- studentId: string;
821
- /** One result per skill the handler was asked about. */
822
- results: SkillStatusResult[];
673
+ interface TimebackSetupRequest {
674
+ gameId: string;
675
+ config: {
676
+ organization: {
677
+ name: string;
678
+ type: string;
679
+ identifier: string;
680
+ };
681
+ course: {
682
+ /**
683
+ * Client-chosen OneRoster sourcedId for the course. Omit to let
684
+ * Timeback allocate one. Fixed once the course exists.
685
+ */
686
+ sourcedId?: string;
687
+ title: string;
688
+ subjects: string[];
689
+ grades: number[];
690
+ courseCode: string;
691
+ level: string;
692
+ gradingScheme: string;
693
+ metadata?: Record<string, unknown>;
694
+ };
695
+ component: {
696
+ title: string;
697
+ sortOrder: number;
698
+ prerequisites: string[];
699
+ prerequisiteCriteria: string;
700
+ };
701
+ resource: {
702
+ title: string;
703
+ vendorResourceId: string;
704
+ vendorId: string;
705
+ applicationId: string;
706
+ roles: string[];
707
+ importance: string;
708
+ metadata: {
709
+ type?: string;
710
+ launchUrl?: string;
711
+ toolProvider?: string;
712
+ instructionalMethod?: string;
713
+ subject?: string;
714
+ grades?: number[];
715
+ language?: string;
716
+ xp?: number;
717
+ [key: string]: unknown;
718
+ };
719
+ };
720
+ componentResource: {
721
+ title: string;
722
+ sortOrder: number;
723
+ lessonType: string | null;
724
+ };
725
+ };
726
+ verbose?: boolean;
823
727
  }
824
- /** The game asking for skill status, as identified by the platform. */
825
- interface SkillStatusRequestingGame {
826
- id: string;
827
- slug: string;
728
+ interface PlatformTimebackSetupRequest {
729
+ gameId: string;
730
+ courses: DerivedPlatformCourseConfig[];
731
+ baseConfig: {
732
+ organization: {
733
+ name: string;
734
+ type: string;
735
+ identifier: string;
736
+ };
737
+ component: {
738
+ title: string;
739
+ titleSuffix?: string;
740
+ sortOrder: number;
741
+ prerequisites: string[];
742
+ prerequisiteCriteria: string;
743
+ };
744
+ resource: {
745
+ title: string;
746
+ titleSuffix?: string;
747
+ vendorResourceId: string;
748
+ vendorId: string;
749
+ applicationId: string;
750
+ roles: string[];
751
+ importance: string;
752
+ metadata: {
753
+ type?: string;
754
+ launchUrl?: string;
755
+ toolProvider?: string;
756
+ instructionalMethod?: string;
757
+ language?: string;
758
+ [key: string]: unknown;
759
+ };
760
+ };
761
+ componentResource: {
762
+ title: string;
763
+ titleSuffix?: string;
764
+ sortOrder: number;
765
+ lessonType: string | null;
766
+ };
767
+ };
768
+ verbose?: boolean;
828
769
  }
829
- /** Body of `POST /api/skills/status`, sent by the asking game's worker. */
830
- interface SkillStatusRequest {
831
- /** Slug of the game to ask. */
832
- game: string;
833
- /** Playcademy user ID of the student. */
834
- studentId: string;
835
- /** Skill IDs to ask about. Normalized (trimmed, lowercased) and de-duplicated. */
836
- skills: string[];
770
+ interface PlatformTimebackSetupResponse {
771
+ integrations: GameTimebackIntegration[];
772
+ verbose?: {
773
+ integration: GameTimebackIntegration;
774
+ config: {
775
+ course: unknown;
776
+ component: unknown;
777
+ resource: unknown;
778
+ componentResource: unknown;
779
+ };
780
+ }[];
837
781
  }
838
- /** Why the answering game couldn't answer. */
839
- type SkillStatusUnsupportedReason = 'not_implemented' | 'no_active_deployment' | 'timeout' | 'fetch_failed' | 'invalid_response';
840
782
  /**
841
- * What the asking game gets back. When `supported` is false, fall back to
842
- * the game's own default (usually: treat the skills as not mastered).
783
+ * `base` courses form a game's grade ladder (one active per grade and subject).
784
+ * `hole_filling` courses are remediation courses Timeback enrolls students into
785
+ * after a failed test; each sits beside a base course.
843
786
  */
844
- type SkillStatusLookupResult = {
845
- supported: true;
846
- results: SkillStatusResult[];
847
- } | {
848
- supported: false;
849
- reason: SkillStatusUnsupportedReason;
850
- };
851
-
852
- /**
853
- * TimeBack Enums & Literal Types
854
- *
855
- * Basic type definitions used throughout the TimeBack integration. Unions
856
- * derive from the canonical value lists in @playcademy/constants (type-only
857
- * imports, so this package ships no runtime code).
858
- *
859
- * @module types/timeback/types
860
- */
861
-
862
- /**
863
- * The TimeBack subject vocabulary. 'None' is canonical: TimeBack accepts it
864
- * on courses and uses it as the fallback for unknown or missing subjects.
865
- */
866
- type TimebackSubject = (typeof TIMEBACK_SUBJECTS)[number];
867
- /**
868
- * Grade levels per AE OneRoster GradeEnum.
869
- * -1 = Pre-K, 0 = Kindergarten, 1-12 = Grades 1-12, 13 = AP
870
- */
871
- type TimebackGrade = (typeof TIMEBACK_GRADES)[number];
872
- /**
873
- * Platform pedagogy levels for a single lesson of instruction.
874
- * E1 teaches, E2/E3 practice and remediate, E4 is the mastery check.
875
- */
876
- type ELevel = 'E1' | 'E2' | 'E3' | 'E4';
877
- /**
878
- * Valid Caliper subject values. The same vocabulary as OneRoster subjects.
879
- */
880
- type CaliperSubject = (typeof TIMEBACK_SUBJECTS)[number];
881
- /**
882
- * OneRoster organization types.
883
- */
884
- type OrganizationType = 'department' | 'school' | 'district' | 'local' | 'state' | 'national';
885
- /**
886
- * Lesson types for PowerPath integration.
887
- */
888
- type LessonType = 'powerpath-100' | 'quiz' | 'test-out' | 'placement' | 'unit-test' | 'alpha-read-article' | null;
889
-
890
- /**
891
- * TimeBack Configuration Types
892
- *
893
- * Configuration interfaces for Organization, Course, Component,
894
- * Resource, and complete TimeBack setup.
895
- *
896
- * @module types/timeback/config
897
- */
898
-
899
- /**
900
- * Organization configuration for TimeBack (user input - optionals allowed)
901
- */
902
- interface OrganizationConfig {
903
- /** Display name for your organization */
904
- name?: string;
905
- /** Organization type */
906
- type?: OrganizationType;
907
- /** Unique identifier (defaults to Playcademy's org) */
908
- identifier?: string;
909
- }
910
- /**
911
- * Course goals for daily student targets
912
- */
913
- interface CourseGoals {
914
- /** Target XP students should earn per day */
915
- dailyXp?: number;
916
- /** Target lessons per day */
917
- dailyLessons?: number;
918
- /** Target active minutes per day */
919
- dailyActiveMinutes?: number;
920
- /** Target accuracy percentage */
921
- dailyAccuracy?: number;
922
- /** Target mastered units per day */
923
- dailyMasteredUnits?: number;
787
+ type GameTimebackIntegrationKind = 'base' | 'hole_filling';
788
+ interface GameTimebackIntegration {
789
+ id: string;
790
+ gameId: string;
791
+ courseId: string;
792
+ grade: number;
793
+ subject: string;
794
+ /** Defaults to `base` when absent (responses from older servers). */
795
+ kind?: GameTimebackIntegrationKind;
796
+ /** The base course a hole-filling course belongs to; null for base courses. */
797
+ baseIntegrationId?: string | null;
798
+ status?: 'active' | 'deactivated';
799
+ totalXp?: number | null;
800
+ lastVerifiedAt?: Date | null;
801
+ deactivatedAt?: Date | null;
802
+ reactivatedAt?: Date | null;
803
+ createdAt: Date;
804
+ updatedAt: Date;
924
805
  }
925
- /**
926
- * Course metrics and totals
927
- */
928
- interface CourseMetrics {
929
- /** Total XP available in the course */
930
- totalXp?: number;
931
- /** Total lessons/activities in the course */
932
- totalLessons?: number;
933
- /** Total number of grade levels covered by this course */
934
- totalGrades?: number;
935
- /** The type of course (e.g. 'optional', 'hole-filling', 'base') */
936
- courseType?: 'base' | 'hole-filling' | 'optional' | 'Base' | 'Hole-Filling' | 'Optional';
937
- /** Indicates whether the course is supplemental content */
938
- isSupplemental?: boolean;
806
+ interface RemovedGameTimebackIntegration {
807
+ integration: GameTimebackIntegration;
808
+ title: string;
809
+ courseCode: string;
810
+ subject: TimebackSubject;
811
+ grade: number;
812
+ totalXp?: number | null;
813
+ masterableUnits?: number | null;
814
+ removedAt?: Date | string | null;
815
+ metadata?: CourseMetadata | null;
939
816
  }
940
- /**
941
- * Complete course metadata structure
942
- */
943
- interface CourseMetadata {
944
- /** Define the type of course and priority for the student */
945
- courseType?: 'base' | 'hole-filling' | 'optional';
946
- /** Boolean value to determine if a course is supplemental to a base course */
947
- isSupplemental?: boolean;
948
- /** Boolean value to determine if a course is custom to an individual student */
949
- isCustom?: boolean;
950
- /** Signals whether a course is in production with students */
951
- publishStatus?: 'draft' | 'testing' | 'published' | 'deactivated';
952
- /** Whether this course appears in the TimeBack catalog for teachers and parents */
953
- timebackVisible?: boolean;
954
- /** Who to contact when issues reported with questions */
955
- contactEmail?: string;
956
- /** Primary app identifier */
957
- primaryApp?: string;
958
- /** Learning goals for students */
959
- goals?: CourseGoals;
960
- /** Course metrics and totals */
961
- metrics?: CourseMetrics;
962
- /** Vendor-specific metadata (e.g., AlphaLearn) */
963
- [key: string]: unknown;
817
+ interface GameTimebackIntegrationConfig {
818
+ integration: GameTimebackIntegration;
819
+ title: string;
820
+ courseCode: string;
821
+ subject: TimebackSubject;
822
+ totalXp?: number | null;
823
+ masterableUnits?: number | null;
824
+ metadata?: CourseMetadata | null;
964
825
  }
965
- /**
966
- * Course configuration for TimeBack (user input)
967
- */
968
- interface CourseConfig {
969
- /** Allocated OneRoster sourcedId (set after creation) */
970
- sourcedId?: string;
971
- /** Course title (defaults to game name) */
826
+ interface UpdateGameTimebackIntegrationRequest {
972
827
  title?: string;
973
- /** Subjects (REQUIRED for TimeBack integration) */
974
- subjects: TimebackSubject[];
975
- /** Used when recording progress/sessions if not explicitly specified per event. */
976
- defaultSubject?: TimebackSubject;
977
- /** Grade levels (REQUIRED for TimeBack integration) */
978
- grades: TimebackGrade[];
979
- /** Short course code (optional, auto-generated) */
980
828
  courseCode?: string;
981
- /** Course level (auto-derived from grades) */
982
- level?: 'Elementary' | 'Middle' | 'High' | 'AP' | string;
983
- /** Grading system */
984
- gradingScheme?: 'STANDARD';
985
- /** Total XP available in this course (REQUIRED before setup) */
829
+ subject?: TimebackSubject;
986
830
  totalXp?: number | null;
987
- /** Total masterable units in this course (REQUIRED before setup) */
988
831
  masterableUnits?: number | null;
989
- /** Custom Playcademy metadata */
990
- metadata?: CourseMetadata;
832
+ goals?: Partial<Record<keyof CourseGoals, number | null>> | null;
833
+ publishStatus?: string | null;
834
+ isSupplemental?: boolean;
835
+ timebackVisible?: boolean | null;
991
836
  }
992
- /**
993
- * Component configuration for TimeBack (user input)
994
- */
995
- interface ComponentConfig {
996
- /** Component title (defaults to "{course.title} Activities") */
997
- title?: string;
998
- /** Display order */
999
- sortOrder?: number;
1000
- /** Required prior components */
1001
- prerequisites?: string[];
1002
- /** How prerequisites work */
1003
- prerequisiteCriteria?: 'ALL' | 'ANY';
837
+ interface CreateGameTimebackIntegrationRequest {
838
+ title: string;
839
+ courseCode: string;
840
+ subject: TimebackSubject;
841
+ grade: TimebackGrade;
842
+ totalXp: number;
843
+ masterableUnits: number;
844
+ level?: string;
1004
845
  }
1005
846
  /**
1006
- * Playcademy-specific resource extensions
847
+ * Create a hole-filling course beside an existing base course. Subject and
848
+ * grade come from the base course; everything else defaults to a copy of it.
1007
849
  */
1008
- interface PlaycademyResourceMetadata {
1009
- /** Mastery configuration for tracking discrete learning units */
1010
- mastery?: {
1011
- /** Total number of masterable units in the resource */
1012
- masterableUnits: number;
1013
- /** Type of mastery unit for semantic clarity */
1014
- unitType?: 'level' | 'rank' | 'skill' | 'module';
1015
- };
850
+ interface CreateGameTimebackHoleFillingCourseRequest {
851
+ /** Course ID of the active base course this hole-filling course belongs to. */
852
+ baseCourseId: string;
853
+ title: string;
854
+ courseCode: string;
855
+ totalXp: number;
856
+ masterableUnits: number;
857
+ /**
858
+ * Optional OneRoster sourcedId for the new course. Fixed once created; when
859
+ * omitted Timeback allocates one. This is the ID handed to Timeback.
860
+ */
861
+ courseId?: string;
1016
862
  }
1017
- /**
1018
- * Resource configuration for TimeBack (user input)
1019
- */
1020
- interface ResourceConfig {
1021
- /** Resource title (defaults to "{course.title} Game") */
1022
- title?: string;
1023
- /** Internal resource ID (auto-generated from package.json) */
1024
- vendorResourceId?: string;
1025
- /** Vendor identifier */
1026
- vendorId?: string;
1027
- /** Application identifier */
1028
- applicationId?: string;
1029
- /** Resource roles */
1030
- roles?: ('primary' | 'secondary')[];
1031
- /** Resource importance */
1032
- importance?: 'primary' | 'secondary';
1033
- /** Interactive resource metadata */
1034
- metadata?: {
1035
- /** Resource type */
1036
- type?: 'interactive';
1037
- /** Launch URL (defaults to Playcademy game URL) */
1038
- launchUrl?: string;
1039
- /** Platform name */
1040
- toolProvider?: string;
1041
- /** Teaching method */
1042
- instructionalMethod?: 'exploratory' | 'direct-instruction';
1043
- /** Subject area */
1044
- subject?: TimebackSubject;
1045
- /** Target grades */
1046
- grades?: TimebackGrade[];
1047
- /** Content language */
1048
- language?: string;
1049
- /** Base XP for completion */
1050
- xp?: number;
1051
- /** Playcademy-specific extensions */
1052
- playcademy?: PlaycademyResourceMetadata;
863
+ interface TimebackVerificationResources {
864
+ course: {
865
+ found: boolean;
866
+ data?: unknown;
867
+ };
868
+ component: {
869
+ found: boolean;
870
+ data?: unknown;
871
+ };
872
+ resource: {
873
+ found: boolean;
874
+ data?: unknown;
875
+ };
876
+ componentResource: {
877
+ found: boolean;
878
+ data?: unknown;
1053
879
  };
1054
880
  }
1055
- /**
1056
- * Component Resource link configuration (user input)
1057
- */
1058
- interface ComponentResourceConfig {
1059
- /** Link title (defaults to "{resource.title} Activity") */
1060
- title?: string;
1061
- /** Display order */
1062
- sortOrder?: number;
1063
- /** Lesson type for PowerPath integration */
1064
- lessonType?: LessonType;
1065
- }
1066
- interface TimebackCourseConfig {
1067
- subject: string;
1068
- grade: number;
1069
- }
1070
- interface DerivedPlatformCourseConfig extends TimebackCourseConfig {
1071
- title: string;
1072
- courseCode: string;
1073
- level: string;
1074
- metadata?: Record<string, unknown>;
1075
- totalXp?: number | null;
1076
- masterableUnits?: number | null;
1077
- }
1078
-
1079
- /**
1080
- * TimeBack Client SDK DTOs
1081
- *
1082
- * Data transfer objects for the TimeBack client SDK including
1083
- * progress tracking, session management, and activity completion.
1084
- *
1085
- * Note: TimebackClientConfig lives in @playcademy/timeback as it's
1086
- * SDK configuration, not a DTO.
1087
- *
1088
- * @module types/timeback/client
1089
- */
1090
-
1091
- /**
1092
- * Known extensions for TimeBack Activity Metrics Collection
1093
- */
1094
- interface TimebackActivityExtensions {
1095
- /** Percentage complete (0-100) for the app course */
1096
- pctCompleteApp?: number;
1097
- /** Allow other arbitrary extensions */
1098
- [key: string]: unknown;
881
+ interface TimebackVerifyCourseResult {
882
+ integration: GameTimebackIntegration;
883
+ resources: TimebackVerificationResources;
884
+ status: 'success' | 'error';
885
+ errors?: string[];
1099
886
  }
1100
- interface MasteryWriteWarning {
1101
- code: 'MASTERY_WRITE_CAPPED';
1102
- message: string;
1103
- currentMasteredUnits: number;
1104
- attemptedMasteredUnits: number;
1105
- appliedMasteredUnits: number;
1106
- storedMasteredUnits: number;
1107
- masterableUnits: number;
887
+ interface TimebackVerifyAllResponse {
888
+ status: 'success' | 'error';
889
+ results: TimebackVerifyCourseResult[];
1108
890
  }
1109
- /**
1110
- * Activity data for ending an activity
1111
- */
1112
- interface ActivityData {
1113
- /** Unique activity identifier (required) */
1114
- activityId: string;
1115
- /** Grade level for this activity (required for multi-grade course routing) */
1116
- grade: number;
1117
- /** Subject area (required for multi-grade course routing) */
1118
- subject: CaliperSubject;
1119
- /** Activity display name (optional) */
1120
- activityName?: string;
1121
- /** Course identifier (auto-filled from config if not provided) */
1122
- courseId?: string;
1123
- /** Course display name (auto-filled from config if not provided) */
1124
- courseName?: string;
1125
- /** Student email address (optional) */
1126
- studentEmail?: string;
1127
- /** Application name for Caliper events (defaults to 'Game') */
1128
- appName?: string;
1129
- /** Sensor URL for Caliper events (defaults to baseUrl) */
1130
- sensorUrl?: string;
891
+ interface HeartbeatRequestBase {
892
+ gameId: string;
893
+ studentId: string;
894
+ runId: string;
895
+ /**
896
+ * Per-session identifier.
897
+ *
898
+ * LEGACY SDK COMPATIBILITY (PR #711): optional because games deployed
899
+ * against the pre-resumable-sessions SDK do not send one. The
900
+ * platform falls back to `runId` when absent. Make this required
901
+ * once legacy SDK support is dropped.
902
+ */
903
+ resumeId?: string;
904
+ activityData: {
905
+ activityId: string;
906
+ activityName?: string;
907
+ grade: TimebackGrade;
908
+ subject: TimebackSubject;
909
+ appName?: string;
910
+ sensorUrl?: string;
911
+ courseId?: string;
912
+ courseName?: string;
913
+ studentEmail?: string;
914
+ };
915
+ timingData: {
916
+ activeMs: number;
917
+ pausedMs: number;
918
+ };
919
+ isFinal?: boolean;
1131
920
  }
1132
- /**
1133
- * Score data for ending an activity
1134
- */
1135
- interface EndActivityScoreData {
1136
- /** Number of questions answered correctly */
1137
- correctQuestions: number;
1138
- /** Total number of questions */
1139
- totalQuestions: number;
921
+ type HeartbeatWindowKey = {
1140
922
  /**
1141
- * XP earned for this activity.
923
+ * Absolute start-of-window timestamp (epoch ms). Preferred dedupe key
924
+ * for the post-#711 SDK.
1142
925
  *
1143
- * Required when the game reports directly (platform, demo, standalone).
1144
- * A child-launched game may omit it: narrow the client with the SDK's
1145
- * `isChildLaunched()` for the relaxed signature. The parent game
1146
- * decides the award, and a value provided here travels only as the
1147
- * `childXpSuggested` audit suggestion.
926
+ * LEGACY SDK COMPATIBILITY (PR #711): callers must provide exactly
927
+ * one of this field or `windowSequence`. Make this the only allowed
928
+ * field once legacy SDK support is dropped.
1148
929
  */
1149
- xpAwarded: number;
930
+ windowStartedAtMs: number;
931
+ windowSequence?: never;
932
+ } | {
933
+ windowStartedAtMs?: never;
1150
934
  /**
1151
- * Incremental learning units mastered this session.
935
+ * LEGACY SDK COMPATIBILITY (PR #711).
1152
936
  *
1153
- * Cannot be used with masteredUnitsAbsolute. When a course has mastery
1154
- * tracking configured, the platform bounds submissions that would move
1155
- * the student below 0 or above the configured masterableUnits maximum and
1156
- * returns warning metadata.
937
+ * Monotonic window counter emitted by the pre-resumable-sessions
938
+ * SDK. Remove this field once every deployed game has redeployed
939
+ * against the post-#711 SDK + edge-play runtime.
1157
940
  */
1158
- masteredUnits?: number;
941
+ windowSequence: number;
942
+ };
943
+ type HeartbeatRequest = HeartbeatRequestBase & HeartbeatWindowKey;
944
+ interface EndActivityRequest {
945
+ gameId: string;
946
+ studentId: string;
947
+ runId?: string;
1159
948
  /**
1160
- * Absolute total of mastered units.
949
+ * Per-session identifier.
1161
950
  *
1162
- * The platform computes the delta from the current value. Cannot be used
1163
- * with masteredUnits. When a course has mastery tracking configured, the
1164
- * platform bounds values outside 0..masterableUnits and returns warning
1165
- * metadata.
951
+ * LEGACY SDK COMPATIBILITY (PR #711): optional because games deployed
952
+ * against the pre-resumable-sessions SDK do not send one. The
953
+ * platform falls back to `runId`, or mints a server-side UUID, when
954
+ * absent. Make this required once legacy SDK support is dropped.
1166
955
  */
956
+ resumeId?: string;
957
+ activityData: {
958
+ activityId: string;
959
+ activityName?: string;
960
+ grade: TimebackGrade;
961
+ subject: TimebackSubject;
962
+ appName?: string;
963
+ sensorUrl?: string;
964
+ courseId?: string;
965
+ courseName?: string;
966
+ studentEmail?: string;
967
+ };
968
+ scoreData: {
969
+ correctQuestions: number;
970
+ totalQuestions: number;
971
+ };
972
+ timingData: {
973
+ durationSeconds: number;
974
+ };
975
+ sessionTimingData?: {
976
+ activeSeconds: number;
977
+ inactiveSeconds?: number;
978
+ };
979
+ xpEarned: number;
980
+ masteredUnits?: number;
1167
981
  masteredUnitsAbsolute?: number;
1168
- /** Optional arbitrary extensions to include in the Caliper event */
1169
982
  extensions?: TimebackActivityExtensions;
1170
983
  }
1171
-
1172
- /**
1173
- * Caliper Protocol Types
1174
- *
1175
- * Types for the IMS Caliper Analytics standard used by TimeBack
1176
- * for learning activity tracking.
1177
- *
1178
- * @module types/timeback/caliper
1179
- */
1180
-
1181
- interface TimebackStoredCaliperMetric {
1182
- type: string;
1183
- value?: number;
1184
- subType?: string;
984
+ interface EndActivityResponse {
985
+ status: 'ok';
986
+ courseId: string;
987
+ xpAwarded: number;
988
+ masteredUnits?: number;
989
+ pctCompleteApp?: number;
990
+ warnings?: MasteryWriteWarning[];
991
+ /**
992
+ * Set when this submission was stopped because a completion for the same
993
+ * run (`runId`) and activity had already been recorded — the platform's
994
+ * idempotency guard blocked a duplicate emit (PLA-142). This call awarded
995
+ * nothing new, but the award may well have happened: if the original
996
+ * response was lost in transit (e.g. a gateway timeout followed by an SDK
997
+ * retry), this is the only response the caller ever sees for a run that
998
+ * fully succeeded. The response therefore echoes what the run earned —
999
+ * `xpAwarded`, `masteredUnits`, and `pctCompleteApp` are the values
1000
+ * recorded when the completion was confirmed (zeros, with no
1001
+ * `pctCompleteApp`, only for runs recorded before award echoing existed).
1002
+ * Treat it as "already recorded — here's what it earned", and do not
1003
+ * count the run again.
1004
+ */
1005
+ blockedByDedupeGuard?: boolean;
1185
1006
  }
1186
- interface TimebackStoredCaliperEntity {
1187
- id?: string;
1188
- type?: string;
1189
- name?: string;
1190
- email?: string;
1191
- app?: {
1192
- id?: string;
1193
- name?: string;
1007
+ interface StudentHighestGradeMasteredResponse {
1008
+ /** Subject used for the highest-grade-mastered lookup */
1009
+ subject: TimebackSubject;
1010
+ /** EduBridge highestGradeOverall normalized to Playcademy's numeric grade type */
1011
+ highestGradeMastered: TimebackGrade | null;
1012
+ /** Normalized source grades returned by EduBridge for the rollup. */
1013
+ grades: {
1014
+ ritGrade: TimebackGrade | null;
1015
+ edulasticGrade: TimebackGrade | null;
1016
+ placementGrade: TimebackGrade | null;
1017
+ testOutGrade: TimebackGrade | null;
1018
+ highestGradeOverall: TimebackGrade | null;
1194
1019
  };
1195
- activity?: {
1196
- id?: string;
1197
- name?: string;
1198
- extensions?: Record<string, unknown> | null;
1199
- };
1200
- course?: {
1201
- id?: string;
1202
- name?: string;
1203
- };
1204
- items?: TimebackStoredCaliperMetric[];
1205
- extensions?: Record<string, unknown> | null;
1206
- [key: string]: unknown;
1207
- }
1208
- interface TimebackStoredCaliperEvent {
1209
- id: number;
1210
- externalId: string;
1211
- sensor: string;
1212
- type: string;
1213
- profile?: string;
1214
- action: string;
1215
- eventTime: string;
1216
- sendTime: string;
1217
- updated_at: string | null;
1218
- created_at: string;
1219
- deleted_at: string | null;
1220
- actor: TimebackStoredCaliperEntity;
1221
- object: TimebackStoredCaliperEntity;
1222
- generated?: TimebackStoredCaliperEntity | null;
1223
- target?: TimebackStoredCaliperEntity | null;
1224
- referrer?: TimebackStoredCaliperEntity | null;
1225
- edApp?: TimebackStoredCaliperEntity | null;
1226
- group?: TimebackStoredCaliperEntity | null;
1227
- membership?: TimebackStoredCaliperEntity | null;
1228
- session?: TimebackStoredCaliperEntity | null;
1229
- federatedSession?: TimebackStoredCaliperEntity | null;
1230
- extensions?: Record<string, unknown> | null;
1231
- clientAppId?: string | null;
1232
1020
  }
1233
-
1234
1021
  /**
1235
- * Game-side learning metrics for a single student.
1236
- *
1237
- * Returned by opted-in game workers from their reserved
1238
- * `/__playcademy/metrics` route.
1022
+ * Highest-ranking OneRoster account role for a user shown in the admin
1023
+ * dashboard. Precedence: administrator > teacher > student. Accounts whose
1024
+ * roles fall outside those three (aide, guardian, …) resolve to `null`.
1239
1025
  */
1240
- interface GameMetricsResponse {
1241
- /** Student identifier (Playcademy user ID). */
1026
+ type TimebackAccountRole = 'administrator' | 'teacher' | 'student';
1027
+ interface TimebackRosterStudent {
1242
1028
  studentId: string;
1243
- /** Student email, when available to the game. */
1244
- email?: string;
1245
- /** Per-course metrics grouped by TimeBack grade and subject. */
1246
- courses: GameCourseMetrics[];
1247
- }
1248
- interface GameCourseMetrics {
1249
- /** Grade level matching the game's TimeBack integration. */
1250
- grade: TimebackGrade;
1251
- /** Subject matching the game's TimeBack integration. */
1252
- subject: TimebackSubject;
1253
- /** Total XP the game has recorded for this student in this course. */
1254
- totalXp?: number;
1255
- /** Mastered units the game has recorded for this course. */
1256
- masteredUnits?: number;
1257
- /** Total active time in seconds the game has recorded for this course. */
1258
- activeTimeSeconds?: number;
1259
- /** Optional per-run breakdown keyed by Timeback run ID. */
1260
- activities?: GameRunMetrics[];
1261
- }
1262
- interface GameRunMetrics {
1263
- runId: string;
1264
- activityId: string;
1265
- activityName?: string;
1266
- totalXp?: number;
1267
- masteredUnits?: number;
1268
- activeTimeSeconds?: number;
1269
- score?: number;
1270
- }
1271
- type GameMetricsUnsupportedReason = 'no_timeback_integration' | 'no_active_deployment' | 'route_not_implemented' | 'timeout' | 'fetch_failed' | 'invalid_response';
1272
- type GameMetricsProxyResponse = {
1273
- supported: true;
1274
- metrics: GameMetricsResponse;
1275
- } | {
1276
- supported: false;
1277
- reason: GameMetricsUnsupportedReason;
1278
- details?: string;
1279
- };
1280
- type GameMetricComparisonMetric = 'xp' | 'mastery' | 'time' | 'score';
1281
- type GameMetricComparisonKind = 'number' | 'time' | 'percent';
1282
- type GameMetricComparisonRowStatus = 'matched' | 'discrepant' | 'not_reported_by_game' | 'not_recorded_by_timeback';
1283
- interface GameMetricComparisonRow {
1284
- metric: GameMetricComparisonMetric;
1285
- kind: GameMetricComparisonKind;
1286
- status: GameMetricComparisonRowStatus;
1287
- timebackValue?: number;
1288
- gameValue?: number;
1289
- delta?: number;
1029
+ enrollmentId: string | null;
1030
+ classId: string | null;
1031
+ className: string | null;
1032
+ name: string;
1033
+ email: string | null;
1034
+ primaryRole: TimebackAccountRole | null;
1035
+ analyticsUnavailable: boolean;
1036
+ totalXp: number;
1037
+ todayXp: number;
1038
+ activeTimeSeconds: number;
1039
+ masteredUnits: number;
1040
+ masterableUnits?: number;
1041
+ pctCompleteApp?: number;
1042
+ inactive?: boolean;
1290
1043
  }
1291
- type GameRunMetricsComparisonStatus = 'matched' | 'discrepant' | 'not_reported' | 'unavailable';
1292
- interface GameRunMetricsComparisonSummary {
1293
- runId: string;
1294
- status: GameRunMetricsComparisonStatus;
1295
- discrepancyCount: number;
1296
- reason?: GameMetricsUnsupportedReason;
1044
+ interface TimebackRosterResponse {
1045
+ gameId: string;
1046
+ courseId: string;
1047
+ students: TimebackRosterStudent[];
1297
1048
  }
1298
- interface GameRunMetricsComparison extends GameRunMetricsComparisonSummary {
1299
- rows: GameMetricComparisonRow[];
1049
+ interface TimebackStudentHistoryPoint {
1050
+ date: string;
1051
+ xpEarned: number;
1052
+ activeTimeSeconds: number;
1053
+ masteredUnits: number;
1300
1054
  }
1301
-
1302
- /**
1303
- * QTI API Response Types
1304
- *
1305
- * Types for the QTI assessment content service responses.
1306
- * These mirror the JSON structure returned by the QTI API
1307
- * (beyond-qti-2) for assessment tests and items.
1308
- *
1309
- * @module types/timeback/qti
1310
- */
1311
- interface QtiItemRef {
1312
- identifier: string;
1313
- href: string;
1314
- sequence?: number;
1055
+ type CourseCompletionStatus = 'none' | 'complete' | 'incomplete';
1056
+ interface TimebackStudentEnrollmentSummary {
1057
+ enrollmentId: string;
1058
+ status: 'active' | 'tobedeleted';
1059
+ beginDate: string | null;
1060
+ endDate: string | null;
1061
+ analyticsUnavailable: boolean;
1062
+ totalXp: number;
1063
+ todayXp: number;
1064
+ activeTimeSeconds: number;
1065
+ masteredUnits: number;
1066
+ pctCompleteApp?: number;
1067
+ history: TimebackStudentHistoryPoint[];
1315
1068
  }
1316
- interface QtiAssessmentSection {
1317
- identifier: string;
1069
+ interface TimebackStudentCourseOverview {
1070
+ courseId: string;
1318
1071
  title: string;
1319
- visible?: boolean;
1320
- required?: boolean;
1321
- fixed?: boolean;
1322
- sequence?: number;
1323
- 'qti-assessment-item-ref'?: QtiItemRef[];
1072
+ grade: number;
1073
+ subject: string;
1074
+ enrollmentId: string | null;
1075
+ analyticsUnavailable: boolean;
1076
+ totalXp: number;
1077
+ todayXp: number;
1078
+ activeTimeSeconds: number;
1079
+ masteredUnits: number;
1080
+ masterableUnits?: number;
1081
+ pctCompleteApp?: number;
1082
+ completionStatus: CourseCompletionStatus;
1083
+ history: TimebackStudentHistoryPoint[];
1084
+ inactive?: boolean;
1085
+ /** All enrollment records for this course, sorted active-first then by most recent. */
1086
+ enrollments?: TimebackStudentEnrollmentSummary[];
1324
1087
  }
1325
- interface QtiTestPart {
1326
- identifier: string;
1327
- navigationMode: 'linear' | 'nonlinear';
1328
- submissionMode: 'individual' | 'simultaneous';
1329
- 'qti-assessment-section': QtiAssessmentSection[];
1088
+ type TimebackRecentActivityKind = 'activity' | 'activity-in-progress' | 'time-spent' | 'remediation-xp' | 'remediation-time' | 'remediation-mastery' | 'course-completed' | 'course-resumed';
1089
+ interface TimebackRecentActivity {
1090
+ id: string;
1091
+ kind: TimebackRecentActivityKind;
1092
+ occurredAt: string;
1093
+ courseId: string;
1094
+ title: string;
1095
+ activityId?: string;
1096
+ appName?: string;
1097
+ reason?: string;
1098
+ score?: number;
1099
+ xpDelta?: number;
1100
+ timeDeltaSeconds?: number;
1101
+ masteredUnitsDelta?: number;
1102
+ runId?: string;
1103
+ sessionCount?: number;
1104
+ gameMetricsComparison?: GameRunMetricsComparisonSummary;
1105
+ gameMetricsVerification?: TimebackMetricDiscrepancyVerification;
1330
1106
  }
1331
- interface QtiOutcomeDeclaration {
1332
- identifier: string;
1333
- cardinality?: 'single' | 'multiple' | 'ordered' | 'record';
1334
- baseType: 'boolean' | 'directedPair' | 'duration' | 'file' | 'float' | 'identifier' | 'integer' | 'pair' | 'point' | 'string' | 'uri';
1335
- normalMaximum?: number;
1336
- normalMinimum?: number;
1337
- defaultValue?: {
1338
- value?: unknown;
1107
+ interface TimebackStudentOverviewResponse {
1108
+ student: {
1109
+ studentId: string;
1110
+ name: string;
1111
+ email: string | null;
1339
1112
  };
1113
+ courses: TimebackStudentCourseOverview[];
1340
1114
  }
1341
- interface QtiAssessmentTest {
1342
- identifier: string;
1343
- title: string;
1344
- qtiVersion?: string;
1345
- timeLimit?: number;
1346
- maxAttempts?: number;
1347
- toolsEnabled?: Record<string, boolean>;
1348
- 'qti-test-part': QtiTestPart[];
1349
- 'qti-outcome-declaration'?: QtiOutcomeDeclaration[];
1350
- metadata?: Record<string, unknown>;
1351
- rawXml?: string;
1352
- content?: Record<string, unknown>;
1353
- createdAt?: string;
1354
- updatedAt?: string;
1115
+ interface TimebackStudentActivityResponse {
1116
+ activities: TimebackRecentActivity[];
1117
+ hasMore: boolean;
1355
1118
  }
1356
- interface QtiAssessmentTestListResponse {
1357
- items: QtiAssessmentTest[];
1358
- total: number;
1359
- page: number;
1360
- pages: number;
1361
- limit: number;
1362
- sort: string;
1363
- order: 'asc' | 'desc';
1119
+ interface TimebackActivityDetailResponse {
1120
+ activity: TimebackRecentActivity;
1121
+ rawEvents: TimebackStoredCaliperEvent[];
1122
+ gameMetricsComparison?: GameRunMetricsComparison;
1364
1123
  }
1365
- interface QtiResponseDeclaration {
1366
- identifier: string;
1367
- cardinality: 'single' | 'multiple' | 'ordered';
1368
- baseType: string;
1369
- correctResponse?: {
1370
- value: string[];
1371
- };
1124
+ interface TimebackGradeLevelTestStudent {
1125
+ studentId: string;
1126
+ name: string;
1127
+ email: string | null;
1372
1128
  }
1373
- interface QtiAssessmentItem {
1374
- identifier: string;
1375
- title: string;
1376
- type?: string;
1377
- qtiVersion?: string;
1378
- timeDependent?: boolean;
1379
- adaptive?: boolean;
1380
- preInteraction?: string;
1381
- interaction?: Record<string, unknown>;
1382
- postInteraction?: string;
1383
- responseDeclarations?: QtiResponseDeclaration[];
1384
- outcomeDeclarations?: QtiOutcomeDeclaration[];
1385
- responseProcessing?: Record<string, unknown>;
1386
- metadata?: Record<string, unknown>;
1387
- modalFeedback?: unknown[];
1388
- feedbackInline?: unknown[];
1389
- feedbackBlock?: unknown[];
1390
- rubrics?: unknown[];
1391
- stimulus?: unknown;
1392
- rawXml?: string;
1393
- content?: Record<string, unknown>;
1394
- createdAt?: string;
1395
- updatedAt?: string;
1396
- }
1397
- interface QtiAssessmentItemListResponse {
1398
- items: QtiAssessmentItem[];
1399
- total: number;
1400
- page: number;
1401
- pages: number;
1402
- limit: number;
1403
- sort: string;
1404
- order: 'asc' | 'desc';
1129
+ interface TimebackGradeLevelTestStandardRef {
1130
+ source: string;
1131
+ id: string;
1132
+ identifier?: string;
1133
+ name?: string;
1134
+ description?: string;
1135
+ domain?: string;
1405
1136
  }
1406
- /** Request an exact, independently owned copy through the normal question collection endpoint. */
1407
- interface QtiQuestionCopyCreateInput {
1408
- mode: 'copy';
1409
- sourceItemIdentifier: string;
1137
+ interface TimebackGradeLevelTestStandardSummary extends TimebackGradeLevelTestStandardRef {
1138
+ attempted: number;
1139
+ missed: number;
1410
1140
  }
1411
- type QtiQuestionCreateInput = QtiQuestionCopyCreateInput | Record<string, unknown>;
1412
- interface QtiTestQuestionRef {
1413
- ownership?: 'owned' | 'shared';
1414
- reference: {
1415
- identifier: string;
1416
- href: string;
1417
- testPart: string;
1418
- section: string;
1419
- };
1420
- question: QtiAssessmentItem;
1141
+ interface TimebackGradeLevelTestSummary {
1142
+ resultId: string;
1143
+ lineItemId: string;
1144
+ studentId: string;
1145
+ testName: string;
1146
+ testType: string;
1147
+ provider: string;
1148
+ subject: string;
1149
+ grade: number | null;
1150
+ score: number | null;
1151
+ scorePercentile: number | null;
1152
+ scoreStatus: string;
1153
+ scoreDate: string | null;
1154
+ assignmentId?: string;
1155
+ qtiTestId?: string;
1156
+ questionCount?: number;
1157
+ correctQuestionCount?: number;
1421
1158
  }
1422
- interface QtiTestQuestionsResponse {
1423
- assessmentTest: string;
1159
+ type TimebackGradeLevelQuestionCorrectness = 'correct' | 'incorrect' | 'partial' | 'unknown';
1160
+ interface TimebackGradeLevelTestQuestionResult {
1161
+ lineItemId: string;
1162
+ resultId: string | null;
1424
1163
  title: string;
1425
- totalQuestions: number;
1426
- questions: QtiTestQuestionRef[];
1427
- }
1428
-
1429
- /**
1430
- * TimeBack API Request/Response Types
1431
- *
1432
- * Types for TimeBack API endpoints including XP tracking,
1433
- * setup, verification, and activity completion.
1434
- *
1435
- * @module types/timeback/api
1436
- */
1437
-
1438
- interface PopulateStudentResponse {
1439
- status: string;
1440
- message?: string;
1164
+ description?: string;
1165
+ correctness: TimebackGradeLevelQuestionCorrectness;
1166
+ score: number | null;
1167
+ scorePercentile: number | null;
1168
+ scoreStatus: string | null;
1169
+ standards: TimebackGradeLevelTestStandardRef[];
1170
+ qtiQuestion?: QtiTestQuestionRef | null;
1171
+ feedback?: string | null;
1441
1172
  }
1442
- interface TimebackSetupRequest {
1173
+ interface TimebackGradeLevelTestResultsResponse {
1443
1174
  gameId: string;
1444
- config: {
1445
- organization: {
1446
- name: string;
1447
- type: string;
1448
- identifier: string;
1449
- };
1450
- course: {
1451
- title: string;
1452
- subjects: string[];
1453
- grades: number[];
1454
- courseCode: string;
1455
- level: string;
1456
- gradingScheme: string;
1457
- metadata?: Record<string, unknown>;
1458
- };
1459
- component: {
1460
- title: string;
1461
- sortOrder: number;
1462
- prerequisites: string[];
1463
- prerequisiteCriteria: string;
1464
- };
1465
- resource: {
1466
- title: string;
1467
- vendorResourceId: string;
1468
- vendorId: string;
1469
- applicationId: string;
1470
- roles: string[];
1471
- importance: string;
1472
- metadata: {
1473
- type?: string;
1474
- launchUrl?: string;
1475
- toolProvider?: string;
1476
- instructionalMethod?: string;
1477
- subject?: string;
1478
- grades?: number[];
1479
- language?: string;
1480
- xp?: number;
1481
- [key: string]: unknown;
1482
- };
1483
- };
1484
- componentResource: {
1485
- title: string;
1486
- sortOrder: number;
1487
- lessonType: string | null;
1488
- };
1489
- };
1490
- verbose?: boolean;
1175
+ courseId: string;
1176
+ subject: TimebackSubject;
1177
+ grade: TimebackGrade;
1178
+ student: TimebackGradeLevelTestStudent;
1179
+ highestGradeMastered: StudentHighestGradeMasteredResponse | null;
1180
+ results: TimebackGradeLevelTestSummary[];
1491
1181
  }
1492
- interface PlatformTimebackSetupRequest {
1493
- gameId: string;
1494
- courses: DerivedPlatformCourseConfig[];
1495
- baseConfig: {
1496
- organization: {
1497
- name: string;
1498
- type: string;
1499
- identifier: string;
1500
- };
1501
- component: {
1502
- title: string;
1503
- titleSuffix?: string;
1504
- sortOrder: number;
1505
- prerequisites: string[];
1506
- prerequisiteCriteria: string;
1507
- };
1508
- resource: {
1509
- title: string;
1510
- titleSuffix?: string;
1511
- vendorResourceId: string;
1512
- vendorId: string;
1513
- applicationId: string;
1514
- roles: string[];
1515
- importance: string;
1516
- metadata: {
1517
- type?: string;
1518
- launchUrl?: string;
1519
- toolProvider?: string;
1520
- instructionalMethod?: string;
1521
- language?: string;
1522
- [key: string]: unknown;
1523
- };
1524
- };
1525
- componentResource: {
1526
- title: string;
1527
- titleSuffix?: string;
1528
- sortOrder: number;
1529
- lessonType: string | null;
1530
- };
1531
- };
1532
- verbose?: boolean;
1182
+ interface TimebackGradeLevelTestReviewResponse {
1183
+ parentResultId: string;
1184
+ parentLineItemId: string;
1185
+ studentId: string;
1186
+ qtiQuestionCount: number;
1187
+ questions: TimebackGradeLevelTestQuestionResult[];
1188
+ standards: TimebackGradeLevelTestStandardSummary[];
1533
1189
  }
1534
- interface PlatformTimebackSetupResponse {
1535
- integrations: GameTimebackIntegration[];
1536
- verbose?: {
1537
- integration: GameTimebackIntegration;
1538
- config: {
1539
- course: unknown;
1540
- component: unknown;
1541
- resource: unknown;
1542
- componentResource: unknown;
1543
- };
1544
- }[];
1190
+ type TimebackDiscrepancyQueueWindow = 'all' | 'today' | 'yesterday' | 'this-week' | 'last-week' | 'custom';
1191
+ interface TimebackDiscrepancyQueueDateRange {
1192
+ startDate?: string;
1193
+ endDate?: string;
1545
1194
  }
1546
- interface GameTimebackIntegration {
1547
- id: string;
1195
+ interface TimebackMetricDiscrepancyVerification {
1548
1196
  gameId: string;
1549
1197
  courseId: string;
1550
- grade: number;
1551
- subject: string;
1552
- status?: 'active' | 'deactivated';
1553
- totalXp?: number | null;
1554
- lastVerifiedAt?: Date | null;
1555
- deactivatedAt?: Date | null;
1556
- reactivatedAt?: Date | null;
1557
- createdAt: Date;
1558
- updatedAt: Date;
1198
+ studentId: string;
1199
+ runId: string;
1200
+ activityId?: string | null;
1201
+ verifiedAt: string;
1202
+ verifiedByUserId?: string | null;
1559
1203
  }
1560
- interface RemovedGameTimebackIntegration {
1561
- integration: GameTimebackIntegration;
1562
- title: string;
1563
- courseCode: string;
1564
- subject: TimebackSubject;
1565
- grade: number;
1566
- totalXp?: number | null;
1567
- masterableUnits?: number | null;
1568
- removedAt?: Date | string | null;
1569
- metadata?: CourseMetadata | null;
1204
+ interface TimebackDiscrepancyQueueStudent {
1205
+ studentId: string;
1206
+ name: string;
1207
+ email: string | null;
1570
1208
  }
1571
- interface GameTimebackIntegrationConfig {
1572
- integration: GameTimebackIntegration;
1573
- title: string;
1574
- courseCode: string;
1575
- subject: TimebackSubject;
1576
- totalXp?: number | null;
1577
- masterableUnits?: number | null;
1578
- metadata?: CourseMetadata | null;
1209
+ interface TimebackDiscrepancyQueueEventPage {
1210
+ offset: number;
1211
+ limit: number;
1212
+ total: number;
1213
+ hasPrevious: boolean;
1214
+ hasNext: boolean;
1579
1215
  }
1580
- interface UpdateGameTimebackIntegrationRequest {
1581
- title?: string;
1582
- courseCode?: string;
1583
- subject?: TimebackSubject;
1584
- totalXp?: number | null;
1585
- masterableUnits?: number | null;
1586
- goals?: Partial<Record<keyof CourseGoals, number | null>> | null;
1587
- publishStatus?: string | null;
1588
- isSupplemental?: boolean;
1589
- timebackVisible?: boolean | null;
1216
+ interface TimebackMetricDiscrepancyQueueItem {
1217
+ student: TimebackDiscrepancyQueueStudent;
1218
+ activity: TimebackRecentActivity;
1219
+ gameMetricsComparison: GameRunMetricsComparison;
1220
+ verification?: TimebackMetricDiscrepancyVerification;
1221
+ comparisonSource?: 'hydrated' | 'preliminary';
1590
1222
  }
1591
- interface CreateGameTimebackIntegrationRequest {
1592
- title: string;
1593
- courseCode: string;
1594
- subject: TimebackSubject;
1595
- grade: TimebackGrade;
1596
- totalXp: number;
1597
- masterableUnits: number;
1598
- level?: string;
1223
+ interface TimebackMetricDiscrepancyQueueResponse {
1224
+ gameId: string;
1225
+ courseId: string;
1226
+ window: TimebackDiscrepancyQueueWindow;
1227
+ dateRange: TimebackDiscrepancyQueueDateRange;
1228
+ studentId?: string;
1229
+ students: TimebackDiscrepancyQueueStudent[];
1230
+ discrepancyMetricScopes: GameMetricComparisonMetric[];
1231
+ eventPage: TimebackDiscrepancyQueueEventPage;
1232
+ includeVerified: boolean;
1233
+ items: TimebackMetricDiscrepancyQueueItem[];
1599
1234
  }
1600
- interface TimebackVerificationResources {
1601
- course: {
1602
- found: boolean;
1603
- data?: unknown;
1604
- };
1605
- component: {
1606
- found: boolean;
1607
- data?: unknown;
1608
- };
1609
- resource: {
1610
- found: boolean;
1611
- data?: unknown;
1612
- };
1613
- componentResource: {
1614
- found: boolean;
1615
- data?: unknown;
1616
- };
1235
+ interface VerifyTimebackMetricDiscrepancyRequest {
1236
+ studentId: string;
1237
+ runId: string;
1238
+ activityId?: string;
1617
1239
  }
1618
- interface TimebackVerifyCourseResult {
1619
- integration: GameTimebackIntegration;
1620
- resources: TimebackVerificationResources;
1621
- status: 'success' | 'error';
1622
- errors?: string[];
1240
+ interface VerifyTimebackMetricDiscrepancyResponse {
1241
+ status: 'ok';
1242
+ verification: TimebackMetricDiscrepancyVerification;
1623
1243
  }
1624
- interface TimebackVerifyAllResponse {
1625
- status: 'success' | 'error';
1626
- results: TimebackVerifyCourseResult[];
1244
+ interface GrantTimebackXpRequest {
1245
+ gameId: string;
1246
+ courseId: string;
1247
+ studentId: string;
1248
+ xp: number;
1249
+ reason: string;
1250
+ date?: string;
1251
+ useCurrentTime?: boolean;
1627
1252
  }
1628
- interface HeartbeatRequestBase {
1253
+ interface AdjustTimebackTimeRequest {
1629
1254
  gameId: string;
1255
+ courseId: string;
1630
1256
  studentId: string;
1631
- runId: string;
1632
- /**
1633
- * Per-session identifier.
1634
- *
1635
- * LEGACY SDK COMPATIBILITY (PR #711): optional because games deployed
1636
- * against the pre-resumable-sessions SDK do not send one. The
1637
- * platform falls back to `runId` when absent. Make this required
1638
- * once legacy SDK support is dropped.
1639
- */
1640
- resumeId?: string;
1641
- activityData: {
1642
- activityId: string;
1643
- activityName?: string;
1644
- grade: TimebackGrade;
1645
- subject: TimebackSubject;
1646
- appName?: string;
1647
- sensorUrl?: string;
1648
- courseId?: string;
1649
- courseName?: string;
1650
- studentEmail?: string;
1651
- };
1652
- timingData: {
1653
- activeMs: number;
1654
- pausedMs: number;
1655
- };
1656
- isFinal?: boolean;
1257
+ seconds: number;
1258
+ reason: string;
1259
+ date?: string;
1260
+ /** See {@link GrantTimebackXpRequest.useCurrentTime}. */
1261
+ useCurrentTime?: boolean;
1657
1262
  }
1658
- type HeartbeatWindowKey = {
1659
- /**
1660
- * Absolute start-of-window timestamp (epoch ms). Preferred dedupe key
1661
- * for the post-#711 SDK.
1662
- *
1663
- * LEGACY SDK COMPATIBILITY (PR #711): callers must provide exactly
1664
- * one of this field or `windowSequence`. Make this the only allowed
1665
- * field once legacy SDK support is dropped.
1666
- */
1667
- windowStartedAtMs: number;
1668
- windowSequence?: never;
1669
- } | {
1670
- windowStartedAtMs?: never;
1671
- /**
1672
- * LEGACY SDK COMPATIBILITY (PR #711).
1673
- *
1674
- * Monotonic window counter emitted by the pre-resumable-sessions
1675
- * SDK. Remove this field once every deployed game has redeployed
1676
- * against the post-#711 SDK + edge-play runtime.
1677
- */
1678
- windowSequence: number;
1679
- };
1680
- type HeartbeatRequest = HeartbeatRequestBase & HeartbeatWindowKey;
1681
- interface EndActivityRequest {
1263
+ interface AdjustTimebackMasteryRequest {
1682
1264
  gameId: string;
1265
+ courseId: string;
1683
1266
  studentId: string;
1684
- runId?: string;
1685
- /**
1686
- * Per-session identifier.
1687
- *
1688
- * LEGACY SDK COMPATIBILITY (PR #711): optional because games deployed
1689
- * against the pre-resumable-sessions SDK do not send one. The
1690
- * platform falls back to `runId`, or mints a server-side UUID, when
1691
- * absent. Make this required once legacy SDK support is dropped.
1692
- */
1693
- resumeId?: string;
1694
- activityData: {
1695
- activityId: string;
1696
- activityName?: string;
1697
- grade: TimebackGrade;
1698
- subject: TimebackSubject;
1699
- appName?: string;
1700
- sensorUrl?: string;
1701
- courseId?: string;
1702
- courseName?: string;
1703
- studentEmail?: string;
1704
- };
1705
- scoreData: {
1706
- correctQuestions: number;
1707
- totalQuestions: number;
1708
- };
1709
- timingData: {
1710
- durationSeconds: number;
1711
- };
1712
- sessionTimingData?: {
1713
- activeSeconds: number;
1714
- inactiveSeconds?: number;
1715
- };
1716
- xpEarned: number;
1717
- masteredUnits?: number;
1718
- masteredUnitsAbsolute?: number;
1719
- extensions?: TimebackActivityExtensions;
1267
+ units: number;
1268
+ reason: string;
1269
+ date?: string;
1270
+ /** See {@link GrantTimebackXpRequest.useCurrentTime}. */
1271
+ useCurrentTime?: boolean;
1720
1272
  }
1721
- interface EndActivityResponse {
1722
- status: 'ok';
1273
+ interface EnrollStudentRequest {
1274
+ gameId: string;
1723
1275
  courseId: string;
1724
- xpAwarded: number;
1725
- masteredUnits?: number;
1726
- pctCompleteApp?: number;
1727
- warnings?: MasteryWriteWarning[];
1728
- /**
1729
- * Set when this submission was stopped because a completion for the same
1730
- * run (`runId`) and activity had already been recorded — the platform's
1731
- * idempotency guard blocked a duplicate emit (PLA-142). This call awarded
1732
- * nothing new, but the award may well have happened: if the original
1733
- * response was lost in transit (e.g. a gateway timeout followed by an SDK
1734
- * retry), this is the only response the caller ever sees for a run that
1735
- * fully succeeded. The response therefore echoes what the run earned —
1736
- * `xpAwarded`, `masteredUnits`, and `pctCompleteApp` are the values
1737
- * recorded when the completion was confirmed (zeros, with no
1738
- * `pctCompleteApp`, only for runs recorded before award echoing existed).
1739
- * Treat it as "already recorded — here's what it earned", and do not
1740
- * count the run again.
1741
- */
1742
- blockedByDedupeGuard?: boolean;
1276
+ studentIds: string[];
1743
1277
  }
1744
- interface StudentHighestGradeMasteredResponse {
1745
- /** Subject used for the highest-grade-mastered lookup */
1746
- subject: TimebackSubject;
1747
- /** EduBridge highestGradeOverall normalized to Playcademy's numeric grade type */
1748
- highestGradeMastered: TimebackGrade | null;
1749
- /** Normalized source grades returned by EduBridge for the rollup. */
1750
- grades: {
1751
- ritGrade: TimebackGrade | null;
1752
- edulasticGrade: TimebackGrade | null;
1753
- placementGrade: TimebackGrade | null;
1754
- testOutGrade: TimebackGrade | null;
1755
- highestGradeOverall: TimebackGrade | null;
1756
- };
1278
+ interface EnrollStudentResult {
1279
+ studentId: string;
1280
+ status: 'ok' | 'already-enrolled' | 'not-found' | 'error';
1281
+ error?: string;
1757
1282
  }
1758
- /**
1759
- * Highest-ranking OneRoster account role for a user shown in the admin
1760
- * dashboard. Precedence: administrator > teacher > student. Accounts whose
1761
- * roles fall outside those three (aide, guardian, …) resolve to `null`.
1762
- */
1763
- type TimebackAccountRole = 'administrator' | 'teacher' | 'student';
1764
- interface TimebackRosterStudent {
1283
+ interface EnrollStudentResponse {
1284
+ results: EnrollStudentResult[];
1285
+ }
1286
+ interface ReactivateEnrollmentRequest {
1287
+ gameId: string;
1288
+ courseId: string;
1765
1289
  studentId: string;
1766
- enrollmentId: string | null;
1767
- classId: string | null;
1768
- className: string | null;
1769
- name: string;
1770
- email: string | null;
1771
- primaryRole: TimebackAccountRole | null;
1772
- analyticsUnavailable: boolean;
1773
- totalXp: number;
1774
- todayXp: number;
1775
- activeTimeSeconds: number;
1776
- masteredUnits: number;
1777
- masterableUnits?: number;
1778
- pctCompleteApp?: number;
1779
- inactive?: boolean;
1290
+ enrollmentId: string;
1780
1291
  }
1781
- interface TimebackRosterResponse {
1292
+ interface UnenrollStudentRequest {
1782
1293
  gameId: string;
1783
1294
  courseId: string;
1784
- students: TimebackRosterStudent[];
1785
- }
1786
- interface TimebackStudentHistoryPoint {
1787
- date: string;
1788
- xpEarned: number;
1789
- activeTimeSeconds: number;
1790
- masteredUnits: number;
1791
- }
1792
- type CourseCompletionStatus = 'none' | 'complete' | 'incomplete';
1793
- interface TimebackStudentEnrollmentSummary {
1794
- enrollmentId: string;
1795
- status: 'active' | 'tobedeleted';
1796
- beginDate: string | null;
1797
- endDate: string | null;
1798
- analyticsUnavailable: boolean;
1799
- totalXp: number;
1800
- todayXp: number;
1801
- activeTimeSeconds: number;
1802
- masteredUnits: number;
1803
- pctCompleteApp?: number;
1804
- history: TimebackStudentHistoryPoint[];
1805
- }
1806
- interface TimebackStudentCourseOverview {
1807
- courseId: string;
1808
- title: string;
1809
- grade: number;
1810
- subject: string;
1811
- enrollmentId: string | null;
1812
- analyticsUnavailable: boolean;
1813
- totalXp: number;
1814
- todayXp: number;
1815
- activeTimeSeconds: number;
1816
- masteredUnits: number;
1817
- masterableUnits?: number;
1818
- pctCompleteApp?: number;
1819
- completionStatus: CourseCompletionStatus;
1820
- history: TimebackStudentHistoryPoint[];
1821
- inactive?: boolean;
1822
- /** All enrollment records for this course, sorted active-first then by most recent. */
1823
- enrollments?: TimebackStudentEnrollmentSummary[];
1824
- }
1825
- type TimebackRecentActivityKind = 'activity' | 'activity-in-progress' | 'time-spent' | 'remediation-xp' | 'remediation-time' | 'remediation-mastery' | 'course-completed' | 'course-resumed';
1826
- interface TimebackRecentActivity {
1827
- id: string;
1828
- kind: TimebackRecentActivityKind;
1829
- occurredAt: string;
1830
- courseId: string;
1831
- title: string;
1832
- activityId?: string;
1833
- appName?: string;
1834
- reason?: string;
1835
- score?: number;
1836
- xpDelta?: number;
1837
- timeDeltaSeconds?: number;
1838
- masteredUnitsDelta?: number;
1839
- runId?: string;
1840
- sessionCount?: number;
1841
- gameMetricsComparison?: GameRunMetricsComparisonSummary;
1842
- gameMetricsVerification?: TimebackMetricDiscrepancyVerification;
1843
- }
1844
- interface TimebackStudentOverviewResponse {
1845
- student: {
1846
- studentId: string;
1847
- name: string;
1848
- email: string | null;
1849
- };
1850
- courses: TimebackStudentCourseOverview[];
1851
- }
1852
- interface TimebackStudentActivityResponse {
1853
- activities: TimebackRecentActivity[];
1854
- hasMore: boolean;
1855
- }
1856
- interface TimebackActivityDetailResponse {
1857
- activity: TimebackRecentActivity;
1858
- rawEvents: TimebackStoredCaliperEvent[];
1859
- gameMetricsComparison?: GameRunMetricsComparison;
1860
- }
1861
- interface TimebackGradeLevelTestStudent {
1862
- studentId: string;
1863
- name: string;
1864
- email: string | null;
1865
- }
1866
- interface TimebackGradeLevelTestStandardRef {
1867
- source: string;
1868
- id: string;
1869
- identifier?: string;
1870
- name?: string;
1871
- description?: string;
1872
- domain?: string;
1873
- }
1874
- interface TimebackGradeLevelTestStandardSummary extends TimebackGradeLevelTestStandardRef {
1875
- attempted: number;
1876
- missed: number;
1877
- }
1878
- interface TimebackGradeLevelTestSummary {
1879
- resultId: string;
1880
- lineItemId: string;
1881
- studentId: string;
1882
- testName: string;
1883
- testType: string;
1884
- provider: string;
1885
- subject: string;
1886
- grade: number | null;
1887
- score: number | null;
1888
- scorePercentile: number | null;
1889
- scoreStatus: string;
1890
- scoreDate: string | null;
1891
- assignmentId?: string;
1892
- qtiTestId?: string;
1893
- questionCount?: number;
1894
- correctQuestionCount?: number;
1895
- }
1896
- type TimebackGradeLevelQuestionCorrectness = 'correct' | 'incorrect' | 'partial' | 'unknown';
1897
- interface TimebackGradeLevelTestQuestionResult {
1898
- lineItemId: string;
1899
- resultId: string | null;
1900
- title: string;
1901
- description?: string;
1902
- correctness: TimebackGradeLevelQuestionCorrectness;
1903
- score: number | null;
1904
- scorePercentile: number | null;
1905
- scoreStatus: string | null;
1906
- standards: TimebackGradeLevelTestStandardRef[];
1907
- qtiQuestion?: QtiTestQuestionRef | null;
1908
- feedback?: string | null;
1909
- }
1910
- interface TimebackGradeLevelTestResultsResponse {
1911
- gameId: string;
1912
- courseId: string;
1913
- subject: TimebackSubject;
1914
- grade: TimebackGrade;
1915
- student: TimebackGradeLevelTestStudent;
1916
- highestGradeMastered: StudentHighestGradeMasteredResponse | null;
1917
- results: TimebackGradeLevelTestSummary[];
1918
- }
1919
- interface TimebackGradeLevelTestReviewResponse {
1920
- parentResultId: string;
1921
- parentLineItemId: string;
1922
- studentId: string;
1923
- qtiQuestionCount: number;
1924
- questions: TimebackGradeLevelTestQuestionResult[];
1925
- standards: TimebackGradeLevelTestStandardSummary[];
1926
- }
1927
- type TimebackDiscrepancyQueueWindow = 'all' | 'today' | 'yesterday' | 'this-week' | 'last-week' | 'custom';
1928
- interface TimebackDiscrepancyQueueDateRange {
1929
- startDate?: string;
1930
- endDate?: string;
1931
- }
1932
- interface TimebackMetricDiscrepancyVerification {
1933
- gameId: string;
1934
- courseId: string;
1935
- studentId: string;
1936
- runId: string;
1937
- activityId?: string | null;
1938
- verifiedAt: string;
1939
- verifiedByUserId?: string | null;
1940
- }
1941
- interface TimebackDiscrepancyQueueStudent {
1942
- studentId: string;
1943
- name: string;
1944
- email: string | null;
1945
- }
1946
- interface TimebackDiscrepancyQueueEventPage {
1947
- offset: number;
1948
- limit: number;
1949
- total: number;
1950
- hasPrevious: boolean;
1951
- hasNext: boolean;
1952
- }
1953
- interface TimebackMetricDiscrepancyQueueItem {
1954
- student: TimebackDiscrepancyQueueStudent;
1955
- activity: TimebackRecentActivity;
1956
- gameMetricsComparison: GameRunMetricsComparison;
1957
- verification?: TimebackMetricDiscrepancyVerification;
1958
- comparisonSource?: 'hydrated' | 'preliminary';
1959
- }
1960
- interface TimebackMetricDiscrepancyQueueResponse {
1961
- gameId: string;
1962
- courseId: string;
1963
- window: TimebackDiscrepancyQueueWindow;
1964
- dateRange: TimebackDiscrepancyQueueDateRange;
1965
- studentId?: string;
1966
- students: TimebackDiscrepancyQueueStudent[];
1967
- discrepancyMetricScopes: GameMetricComparisonMetric[];
1968
- eventPage: TimebackDiscrepancyQueueEventPage;
1969
- includeVerified: boolean;
1970
- items: TimebackMetricDiscrepancyQueueItem[];
1971
- }
1972
- interface VerifyTimebackMetricDiscrepancyRequest {
1973
- studentId: string;
1974
- runId: string;
1975
- activityId?: string;
1976
- }
1977
- interface VerifyTimebackMetricDiscrepancyResponse {
1978
- status: 'ok';
1979
- verification: TimebackMetricDiscrepancyVerification;
1980
- }
1981
- interface GrantTimebackXpRequest {
1982
- gameId: string;
1983
- courseId: string;
1984
- studentId: string;
1985
- xp: number;
1986
- reason: string;
1987
- date?: string;
1988
- useCurrentTime?: boolean;
1989
- }
1990
- interface AdjustTimebackTimeRequest {
1991
- gameId: string;
1992
- courseId: string;
1993
- studentId: string;
1994
- seconds: number;
1995
- reason: string;
1996
- date?: string;
1997
- /** See {@link GrantTimebackXpRequest.useCurrentTime}. */
1998
- useCurrentTime?: boolean;
1999
- }
2000
- interface AdjustTimebackMasteryRequest {
2001
- gameId: string;
2002
- courseId: string;
2003
- studentId: string;
2004
- units: number;
2005
- reason: string;
2006
- date?: string;
2007
- /** See {@link GrantTimebackXpRequest.useCurrentTime}. */
2008
- useCurrentTime?: boolean;
2009
- }
2010
- interface EnrollStudentRequest {
2011
- gameId: string;
2012
- courseId: string;
2013
- studentIds: string[];
2014
- }
2015
- interface EnrollStudentResult {
2016
- studentId: string;
2017
- status: 'ok' | 'already-enrolled' | 'not-found' | 'error';
2018
- error?: string;
2019
- }
2020
- interface EnrollStudentResponse {
2021
- results: EnrollStudentResult[];
2022
- }
2023
- interface ReactivateEnrollmentRequest {
2024
- gameId: string;
2025
- courseId: string;
2026
- studentId: string;
2027
- enrollmentId: string;
2028
- }
2029
- interface UnenrollStudentRequest {
2030
- gameId: string;
2031
- courseId: string;
2032
- studentId: string;
1295
+ studentId: string;
2033
1296
  }
2034
1297
  interface SearchStudentPastEnrollment {
2035
1298
  enrollmentId: string;
@@ -2891,230 +2154,1013 @@ interface StartAssessmentInputBase {
2891
2154
  subject?: TimebackSubject;
2892
2155
  grade?: TimebackGrade;
2893
2156
  }
2894
- interface StartFixedAssessmentInput extends StartAssessmentInputBase {
2895
- purpose: Exclude<UnscopedFixedAssessmentPurpose, 'diagnostic'>;
2157
+ interface StartFixedAssessmentInput extends StartAssessmentInputBase {
2158
+ purpose: Exclude<UnscopedFixedAssessmentPurpose, 'diagnostic'>;
2159
+ }
2160
+ interface StartDiagnosticAssessmentInput extends StartAssessmentInputBase {
2161
+ purpose: 'diagnostic';
2162
+ /** Stable authored diagnostic identity, independent of the selected QTI test identifier. */
2163
+ diagnosticKey: string;
2164
+ }
2165
+ interface StartMasteryAssessmentInput extends StartAssessmentInputBase {
2166
+ purpose: 'mastery';
2167
+ standard: AssessmentStandardRef;
2168
+ }
2169
+ interface StartReviewAssessmentInput extends StartAssessmentInputBase {
2170
+ purpose: 'review';
2171
+ /** Serving order; duplicate canonical skills keep their first position. Pinned on start. */
2172
+ standards: AssessmentReviewStandard[];
2173
+ /** Candidate capacity per standard; preloaded candidates are not administered automatically. */
2174
+ candidateItemsPerStandard?: number;
2175
+ }
2176
+ type StartAssessmentInput = StartFixedAssessmentInput | StartDiagnosticAssessmentInput | StartMasteryAssessmentInput | StartReviewAssessmentInput;
2177
+ /** Transport metadata for attempting a prepared new-assessment start. */
2178
+ interface StartAssessmentOptions {
2179
+ preparationReceipt?: string;
2180
+ }
2181
+ /** Result of preparing the immediate next assessment request. */
2182
+ type AssessmentPreparationResult = {
2183
+ status: 'prepared';
2184
+ receipt: string;
2185
+ /** Receipt expiry as an ISO-8601 timestamp. */
2186
+ expiresAt: string;
2187
+ } | {
2188
+ status: 'unprepared';
2189
+ reason: 'artifact_unavailable' | 'prerequisite_unavailable' | 'local_runtime';
2190
+ };
2191
+ interface SaveAssessmentInput {
2192
+ expectedResponseVersion: number;
2193
+ /** Complete active draft; success acknowledges its durable parent checkpoint. */
2194
+ transcript: AssessmentTranscript;
2195
+ }
2196
+ /** Best-effort mastery progress, not an answer commitment or an explicit checkpoint. */
2197
+ interface RecordAssessmentProgressInput {
2198
+ assessmentToken: string;
2199
+ expectedResponseVersion: number;
2200
+ /** Current raw draft, including the editable administration being projected. */
2201
+ transcript: AssessmentTranscript;
2202
+ itemIdentifier: string;
2203
+ }
2204
+ interface SubmitAssessmentItemInputBase {
2205
+ assessmentToken: string;
2206
+ /** The raw prefix preceding this administration (or including it for an exact retry). */
2207
+ transcript: AssessmentTranscript;
2208
+ expectedResponseVersion: number;
2209
+ /** Stable across every retry of this exact item submission. */
2210
+ submissionId: string;
2211
+ itemIdentifier: string;
2212
+ responses: Record<string, AssessmentResponseValue | null>;
2213
+ }
2214
+ interface SubmitReviewAssessmentItemInput extends SubmitAssessmentItemInputBase {
2215
+ routingNodeKey?: never;
2216
+ }
2217
+ interface SubmitDiagnosticAssessmentItemInput extends SubmitAssessmentItemInputBase {
2218
+ /** Canonical routing-context identity returned in routing.next. */
2219
+ routingNodeKey: string;
2220
+ }
2221
+ type SubmitAssessmentItemInput = SubmitReviewAssessmentItemInput | SubmitDiagnosticAssessmentItemInput;
2222
+ interface SubmitReviewAssessmentItemResult {
2223
+ attemptId: string;
2224
+ responseVersion: number;
2225
+ status: 'in_progress';
2226
+ responses: AssessmentResponses;
2227
+ /** Canonical ledger after commit or replay; replace local state with it. */
2228
+ itemSubmissions: AssessmentItemSubmission[];
2229
+ submission: AssessmentItemSubmission;
2230
+ transcript: AssessmentTranscript;
2231
+ }
2232
+ /** Safe acknowledgement for one immutable diagnostic item commitment. */
2233
+ interface DiagnosticAssessmentItemReceipt {
2234
+ submissionId: string;
2235
+ routingNodeKey: string;
2236
+ itemIdentifier: string;
2237
+ submittedAt: string;
2238
+ responseVersion: number;
2239
+ answered: boolean;
2240
+ score: AssessmentScore;
2241
+ isCorrect: boolean;
2242
+ }
2243
+ /** Canonical post-commit routing state plus trusted feedback for this administration. */
2244
+ interface SubmitDiagnosticAssessmentItemResult {
2245
+ attemptId: string;
2246
+ responseVersion: number;
2247
+ status: 'in_progress';
2248
+ routing: DiagnosticRoutingSnapshot;
2249
+ submission: DiagnosticAssessmentItemReceipt;
2250
+ transcript: AssessmentTranscript;
2251
+ }
2252
+ type SubmitAssessmentItemResult = SubmitReviewAssessmentItemResult | SubmitDiagnosticAssessmentItemResult;
2253
+ interface SubmitAssessmentInput {
2254
+ expectedResponseVersion: number;
2255
+ submissionId: string;
2256
+ transcript: AssessmentTranscript;
2257
+ }
2258
+ /** The optional mastery portion of a finalize award; at most one field is set. */
2259
+ interface AssessmentMasteryAward {
2260
+ /**
2261
+ * Incremental learning units mastered by this attempt. Cannot be combined
2262
+ * with masteredUnitsAbsolute. The platform bounds the delta against the
2263
+ * course's configured masterableUnits and returns any warning.
2264
+ */
2265
+ masteredUnits?: number;
2266
+ /**
2267
+ * Absolute mastered-unit total after this attempt; the platform computes
2268
+ * the delta. Cannot be combined with masteredUnits.
2269
+ */
2270
+ masteredUnitsAbsolute?: number;
2271
+ }
2272
+ interface FinalizeAssessmentInput extends AssessmentMasteryAward {
2273
+ submissionId: string;
2274
+ /** Explicit zero is an award; omission is never interpreted as zero. */
2275
+ xpAwarded: number;
2276
+ }
2277
+ /**
2278
+ * The award a game supplied at finalization, retained verbatim so a retried
2279
+ * finalize can be told apart from a contradictory one even after bounding
2280
+ * changed what was actually applied.
2281
+ */
2282
+ interface AssessmentAwardRecord extends AssessmentMasteryAward {
2283
+ xpAwarded: number;
2284
+ /** The bounded mastery delta the platform recorded for this attempt. */
2285
+ masteredUnitsApplied: number;
2286
+ pctCompleteApp?: number;
2287
+ warnings?: MasteryWriteWarning[];
2288
+ }
2289
+ /** One scored region for host-only point-response fixture scoring. */
2290
+ interface AssessmentResponseArea {
2291
+ shape: PlayableAssessmentShape;
2292
+ coords: number[];
2293
+ /** The region's mapped point value (1 when omitted). */
2294
+ value?: number;
2295
+ }
2296
+ /** One host-only assessment entry exported for the local runtime provider. */
2297
+ interface AssessmentRuntimeFixtureTest {
2298
+ id: string;
2299
+ assessmentKey: string;
2300
+ qtiTestIdentifier: string;
2301
+ live: boolean;
2302
+ /** Canonical quiz-level alignment used by mastery selection. */
2303
+ standard: AssessmentStandardRef | null;
2304
+ assessment: PlayableAssessment;
2305
+ /** Private comparison rules retained for hosted-equivalent local scoring when available. */
2306
+ scoring?: AssessmentScoringArtifactV1;
2307
+ /** Correct responses are retained by the host and are never returned to the game. */
2308
+ correctResponses: AssessmentResponses;
2309
+ /**
2310
+ * Host-only scored regions for point responses (select-point, position-object),
2311
+ * keyed by item then response identifier. A point response is correct when every
2312
+ * point lands in a distinct scored region.
2313
+ */
2314
+ responseAreas?: Record<string, Record<string, AssessmentResponseArea[]>>;
2315
+ /** Host-only platform-routing sidecar for one immutable diagnostic bank revision. */
2316
+ diagnostic?: {
2317
+ diagnosticKey: string;
2318
+ /** Calculated from the canonical manifest when the fixture is built. */
2319
+ routingRevision: string;
2320
+ routingManifest: DiagnosticRoutingManifestV1;
2321
+ };
2322
+ /** Host-only standard index derived from this ordinary QTI test when used for review. */
2323
+ reviewBank?: {
2324
+ sourceContentRevision: string;
2325
+ bankRevision: string;
2326
+ items: {
2327
+ itemIdentifier: string;
2328
+ standards: AssessmentStandardRef[];
2329
+ }[];
2330
+ };
2331
+ }
2332
+ /** Ordered local catalog for one course integration and assessment purpose. */
2333
+ interface AssessmentRuntimeFixtureCatalog {
2334
+ id: string;
2335
+ integrationId: string;
2336
+ purpose: AssessmentPurpose;
2337
+ subject: TimebackSubject;
2338
+ grade: TimebackGrade;
2339
+ tests: AssessmentRuntimeFixtureTest[];
2340
+ }
2341
+ /**
2342
+ * Versioned host-only bundle consumed by the local assessment runtime.
2343
+ *
2344
+ * The version tracks this bundle's own shape, including the shape of the
2345
+ * assessments nested inside it — a bundle is rejected outright when either
2346
+ * differs, so a stale export is re-generated rather than half-read.
2347
+ */
2348
+ interface AssessmentRuntimeFixtureBundle {
2349
+ version: 8;
2350
+ gameId: string;
2351
+ /**
2352
+ * The project-config slug the CLI resolved the game by at export time.
2353
+ * Local dev matches on this (the platform gameId and the locally derived
2354
+ * id live in different namespaces, so they can never be compared).
2355
+ */
2356
+ gameSlug?: string;
2357
+ exportedAt: string;
2358
+ catalogs: AssessmentRuntimeFixtureCatalog[];
2359
+ }
2360
+
2361
+ /**
2362
+ * Must admit exactly the raster set in `QTI_RASTER_IMAGE_MIME_TYPES`
2363
+ * (`@playcademy/utils/timeback`), minus the legacy `image/jpg` spelling
2364
+ * the server never emits.
2365
+ */
2366
+ type AssessmentAssetMimeType = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp' | 'image/bmp';
2367
+ type AssessmentAssetUploadStatus = 'uploaded' | 'already_exists';
2368
+ /** Assessment assets are production-oriented content; local sandboxes never host them. */
2369
+ type AssessmentAssetEnvironment = 'production' | 'staging';
2370
+ interface AssessmentAssetUploadResponse {
2371
+ status: AssessmentAssetUploadStatus;
2372
+ environment: AssessmentAssetEnvironment;
2373
+ key: string;
2374
+ url: string;
2375
+ sha256: string;
2376
+ mimeType: AssessmentAssetMimeType;
2377
+ size: number;
2378
+ width: number;
2379
+ height: number;
2380
+ }
2381
+
2382
+ /**
2383
+ * User Types
2384
+ *
2385
+ * Enums, DTOs and API response types. Database row types are in @playcademy/data/types.
2386
+ *
2387
+ * @module types/user
2388
+ */
2389
+
2390
+ type UserRoleEnumType = UserRole;
2391
+ type DeveloperStatusEnumType = 'none' | 'pending' | 'approved';
2392
+ type DeveloperStatusValue = DeveloperStatusEnumType;
2393
+ type TimebackUserRole = 'administrator' | 'aide' | 'guardian' | 'parent' | 'proctor' | 'relative' | 'student' | 'teacher';
2394
+ type TimebackOrgType = 'department' | 'school' | 'district' | 'local' | 'state' | 'national';
2395
+ interface UserEnrollment {
2396
+ gameId?: string;
2397
+ courseId: string;
2398
+ id?: string;
2399
+ grade: number;
2400
+ subject: string;
2401
+ orgId?: string;
2402
+ /**
2403
+ * `base` for the game's grade courses, `hole_filling` for a remediation
2404
+ * course Timeback enrolled the student in. Absent means `base`.
2405
+ */
2406
+ kind?: GameTimebackIntegrationKind;
2407
+ /** For hole-filling enrollments: the course ID of the base course it belongs to. */
2408
+ baseCourseId?: string;
2409
+ /** For hole-filling enrollments: when the enrollment started (ISO 8601). */
2410
+ beginDate?: string | null;
2411
+ /**
2412
+ * For hole-filling enrollments: enrollment metadata as set by Timeback
2413
+ * (e.g. `assignmentId`, `testType`). Every field is optional.
2414
+ */
2415
+ enrollmentMetadata?: Record<string, unknown>;
2416
+ }
2417
+ interface UserOrganization {
2418
+ id: string;
2419
+ name: string | null;
2420
+ type: TimebackOrgType | string;
2421
+ isPrimary: boolean;
2422
+ }
2423
+ interface TimebackStudentProfile {
2424
+ role: TimebackUserRole;
2425
+ organizations: UserOrganization[];
2426
+ }
2427
+ /**
2428
+ * Timeback identity on `/users/me`: who the student is, without enrollments.
2429
+ * Enrollments come from `/timeback/user` (or `client.timeback.user`).
2430
+ */
2431
+ interface UserTimebackProfile extends TimebackStudentProfile {
2432
+ id: string;
2433
+ }
2434
+ interface UserTimebackData extends UserTimebackProfile {
2435
+ enrollments: UserEnrollment[];
2436
+ }
2437
+ type LocalDaySource = 'browser_last_seen' | 'platform_default';
2438
+ interface LocalDayContext {
2439
+ timeZone: string;
2440
+ source: LocalDaySource;
2441
+ /** ISO 8601 timestamp for the last persisted timezone observation. */
2442
+ observedAt: string | null;
2443
+ }
2444
+ /**
2445
+ * OpenID Connect UserInfo claims (NOT a database row).
2446
+ */
2447
+ interface UserInfo {
2448
+ sub: string;
2449
+ email: string;
2450
+ name: string | null;
2451
+ email_verified?: boolean;
2452
+ given_name?: string;
2453
+ family_name?: string;
2454
+ issuer?: string;
2455
+ lti_roles?: unknown;
2456
+ lti_context?: unknown;
2457
+ lti_resource_link?: unknown;
2458
+ timeback_id?: string;
2459
+ }
2460
+ interface DeveloperStatusResponse {
2461
+ status: DeveloperStatusEnumType;
2462
+ }
2463
+ /**
2464
+ * Authenticated user for API responses.
2465
+ * Differs from UserRow: omits timebackId, adds hasTimebackAccount and timeback.
2466
+ */
2467
+ interface AuthenticatedUser {
2468
+ id: string;
2469
+ email: string;
2470
+ emailVerified: boolean;
2471
+ name: string | null;
2472
+ image: string | null;
2473
+ username: string | null;
2474
+ role: UserRoleEnumType;
2475
+ developerStatus: DeveloperStatusEnumType;
2476
+ createdAt: Date;
2477
+ updatedAt: Date;
2478
+ hasTimebackAccount: boolean;
2479
+ localDay: LocalDayContext;
2480
+ timeback?: UserTimebackProfile;
2481
+ }
2482
+ interface GameUser {
2483
+ id: string;
2484
+ name: string | null;
2485
+ role: UserRoleEnumType;
2486
+ username: string | null;
2487
+ email: string | null;
2488
+ localDay: LocalDayContext;
2489
+ timeback?: UserTimebackProfile;
2490
+ }
2491
+
2492
+ /**
2493
+ * Game Types
2494
+ *
2495
+ * Literal types and API DTOs. Database row types are in @playcademy/data/types.
2496
+ *
2497
+ * @module types/game
2498
+ */
2499
+
2500
+ type GameType = 'hosted' | 'external';
2501
+ type GamePlatform = 'web' | 'godot' | (string & {});
2502
+ /**
2503
+ * Game manifest file format (manifest.json).
2504
+ * Note: createdAt is a string here because it's parsed from JSON file.
2505
+ */
2506
+ interface ManifestV1 {
2507
+ version: '1';
2508
+ platform: string;
2509
+ createdAt: string;
2510
+ }
2511
+ interface ManifestVersions {
2512
+ vitePlugin?: string;
2513
+ sdk?: string;
2514
+ cli?: string;
2515
+ vite?: string;
2516
+ godotSdk?: string;
2517
+ godot?: string;
2518
+ }
2519
+ interface ManifestV2 {
2520
+ version: '2';
2521
+ platform: string;
2522
+ createdAt: string;
2523
+ gameVersion?: string;
2524
+ versions: ManifestVersions;
2525
+ }
2526
+ type GameManifest = ManifestV1 | ManifestV2;
2527
+ /** One migration in a migrate-mode deploy payload */
2528
+ interface DeployMigration {
2529
+ /** Journal tag, e.g. '0042_brave_hulk' */
2530
+ tag: string;
2531
+ /** Pre-split SQL statements (the CLI splits on drizzle statement-breakpoints) */
2532
+ statements: string[];
2533
+ /** sha-256 of the normalized migration SQL (sha256-v1) */
2534
+ checksum: string;
2535
+ }
2536
+ /** Push-mode database payload: diff-generated SQL guarded by a baseline CAS */
2537
+ interface DeployDatabasePush {
2538
+ mode: 'push';
2539
+ /** Diff-generated DDL to execute (semicolon-separated statements) */
2540
+ sql: string;
2541
+ /** Stored schemaHash the diff was computed against; null only for a first deploy */
2542
+ baselineHash: string | null;
2543
+ /** Drizzle snapshot JSON this deploy moves the schema to */
2544
+ nextSnapshot: unknown;
2545
+ /** Hash of nextSnapshot, stored as the new push baseline on success */
2546
+ nextHash: string;
2547
+ /** Explicit consent for destructive statements (DROP TABLE, dropped columns) */
2548
+ acceptDataLoss?: boolean;
2549
+ }
2550
+ /** Migrate-mode database payload: the client's complete migration journal */
2551
+ interface DeployDatabaseMigrate {
2552
+ mode: 'migrate';
2553
+ /** The full journal in order; the server applies whatever the ledger lacks */
2554
+ migrations: DeployMigration[];
2555
+ }
2556
+ /**
2557
+ * Mode-aware database payload (PLA-217 D5). Replaces the legacy `schema`
2558
+ * field for adopted games; the server verifies state before executing.
2559
+ */
2560
+ type DeployDatabasePayload = DeployDatabasePush | DeployDatabaseMigrate;
2561
+ /** Journal entry in a baseline adoption block */
2562
+ interface DeployBaselineJournalEntry {
2563
+ tag: string;
2564
+ checksum: string;
2565
+ }
2566
+ /**
2567
+ * Baseline adoption block (PLA-217 D7 seed-on-deploy): the client's claimed
2568
+ * starting state for a game that predates server-side deployment state.
2569
+ * Consumed by the deploy itself — an unadopted game gets its claimed ledger
2570
+ * rows, snapshot/hash, and live fingerprint recorded before the database
2571
+ * step runs; adopted games skip the block.
2572
+ */
2573
+ interface DeployBaseline {
2574
+ lastAppliedMigrationTag?: string;
2575
+ journal?: DeployBaselineJournalEntry[];
2576
+ /**
2577
+ * Per-migration snapshot deltas for content validation (D7): the
2578
+ * seed claim is judged against the live database exactly like a
2579
+ * manual `db baseline` claim — the side door uses the front door's
2580
+ * checkpoint.
2581
+ */
2582
+ evidence?: BaselineMigrationEvidence[];
2583
+ schemaSnapshot?: unknown;
2584
+ schemaHash?: string;
2585
+ integrationsHash?: string;
2586
+ buildHash?: string;
2587
+ }
2588
+ /**
2589
+ * Git provenance of the working tree a deploy was run from (PLA-294).
2590
+ *
2591
+ * Captured by the CLI at deploy time and persisted verbatim on the deploy
2592
+ * job, so "which commit is running" is answerable from the platform record.
2593
+ * Every field is nullable: a tree with no git, no remote, or a detached HEAD
2594
+ * is recorded honestly rather than refused. Recorded per deploy, never
2595
+ * pinned to the game — a fork deployed under the same slug shows the fork.
2596
+ */
2597
+ interface DeploySource {
2598
+ /** Normalized `https://github.com/<org>/<repo>`; null when no remote or unparseable */
2599
+ repository: string | null;
2600
+ /** Full 40-char SHA of HEAD; null when not in a git tree */
2601
+ commit: string | null;
2602
+ /** Current branch name; null on detached HEAD outside CI */
2603
+ branch: string | null;
2604
+ /** True when the tree had uncommitted changes — the SHA does not describe what shipped */
2605
+ dirty: boolean;
2606
+ /**
2607
+ * True when the uploaded build artifact lives outside the git tree the
2608
+ * other fields describe (`--build ~/Downloads/game.zip`). The commit is
2609
+ * still the deployer's tree, but it may not be what produced the artifact.
2610
+ */
2611
+ externalBuild: boolean;
2612
+ }
2613
+ type DeployJobStatus = 'pending' | 'running' | 'succeeded' | 'failed';
2614
+ /** Active game worker state served by the deployment-state endpoint */
2615
+ interface DeploymentStateGame {
2616
+ /** Backend bundle hash from the active deployment row */
2617
+ codeHash: string | null;
2618
+ /** Frontend zip hash from game_deployment_state (null when unseeded) */
2619
+ buildHash: string | null;
2620
+ url: string;
2621
+ deployedAt: string;
2622
+ }
2623
+ /** Active dashboard worker state served by the deployment-state endpoint */
2624
+ interface DeploymentStateDashboard {
2625
+ url: string;
2626
+ deployedAt: string;
2627
+ }
2628
+ /** Details of the last failed migration, from the failed deploy job */
2629
+ interface DeploymentStateDatabaseFailure {
2630
+ tag: string;
2631
+ error: string;
2632
+ /**
2633
+ * Set only when the failing statement is known exactly (the size
2634
+ * preflight names the statement it measured). Execution failures are
2635
+ * null: D1's byte offset has an unverified reference frame for the
2636
+ * batch array form, so it is never mapped to an index.
2637
+ */
2638
+ statementIndex: number | null;
2639
+ at: string;
2640
+ }
2641
+ /** A ledger entry from the game database's applied-migrations ledger */
2642
+ interface DeploymentStateAppliedMigration {
2643
+ tag: string;
2644
+ /** Checksum recorded at apply time (normalized SQL, see checksumAlgo) */
2645
+ checksum: string;
2646
+ /** Hash algorithm the checksum was recorded under (e.g. 'sha256-v1') */
2647
+ checksumAlgo: string;
2648
+ }
2649
+ /** Database schema state served by the deployment-state endpoint */
2650
+ interface DeploymentStateDatabase {
2651
+ /** Applied migrations from the live in-D1 ledger (null when the game has no database) */
2652
+ appliedMigrations: DeploymentStateAppliedMigration[] | null;
2653
+ lastFailure: DeploymentStateDatabaseFailure | null;
2654
+ /** Hash of the drizzle snapshot (push-mode baseline) */
2655
+ schemaHash: string | null;
2656
+ /** Hash of the normalized live sqlite_master */
2657
+ schemaFingerprint: string | null;
2658
+ /**
2659
+ * Stored drizzle snapshot (push-mode diffing only). Present only when
2660
+ * the request asked for it with `?include=schemaSnapshot` (D4).
2661
+ */
2662
+ schemaSnapshot?: unknown;
2663
+ }
2664
+ /** Secret key names partitioned by ownership — names only, never hashes */
2665
+ interface DeploymentStateSecrets {
2666
+ /** Keys recorded in the server-side secrets manifest */
2667
+ managedKeys: string[];
2668
+ /**
2669
+ * Remote keys not in the manifest (set by SST, wrangler, or hand).
2670
+ * Null when the server has no Cloudflare provider to list remote keys.
2671
+ */
2672
+ unmanagedKeys: string[] | null;
2673
+ }
2674
+ interface DeploymentStateLastDeploy {
2675
+ at: string;
2676
+ /** Who deployed: their email, or the raw user id when the account no longer resolves */
2677
+ by: string;
2678
+ }
2679
+ /**
2680
+ * Server-side deployment state for a game.
2681
+ *
2682
+ * Everything CLI deploy prep diffs against, fetched from
2683
+ * GET /api/games/:slug/deployment-state so deploys never depend on
2684
+ * local state for correctness.
2685
+ */
2686
+ interface DeploymentStateResponse {
2687
+ gameId: string;
2688
+ /** True iff a game_deployment_state row exists for the game */
2689
+ seeded: boolean;
2690
+ game: DeploymentStateGame | null;
2691
+ dashboard: DeploymentStateDashboard | null;
2692
+ database: DeploymentStateDatabase;
2693
+ secrets: DeploymentStateSecrets;
2694
+ /** Hash of the declared integrations config (null when unseeded) */
2695
+ integrationsHash: string | null;
2696
+ /** Last deployed compatibility date (null when unseeded) */
2697
+ compatibilityDate: string | null;
2698
+ lastDeploy: DeploymentStateLastDeploy | null;
2699
+ }
2700
+ /**
2701
+ * Per-key verdict groups from the server-side secrets diff (D6).
2702
+ *
2703
+ * Key names only — HMAC digests never leave the server. `remoteOnlyManaged`
2704
+ * keys are the only legal prune candidates; `remoteOnlyUnmanaged` keys were
2705
+ * set outside the platform and are untouchable.
2706
+ */
2707
+ interface SecretsDiffResponse {
2708
+ /** Local keys the manifest doesn't know yet */
2709
+ added: string[];
2710
+ /** Keys whose local value's HMAC differs from the manifest's */
2711
+ changed: string[];
2712
+ /** Keys whose local value's HMAC matches the manifest's */
2713
+ unchanged: string[];
2714
+ /** Manifest keys absent locally (prunable) */
2715
+ remoteOnlyManaged: string[];
2716
+ /** Worker keys absent from both the manifest and the local set */
2717
+ remoteOnlyUnmanaged: string[];
2718
+ }
2719
+ /**
2720
+ * Manual baseline adoption request (PLA-217 D7): the fresh-machine path for
2721
+ * a game that predates server-side deployment state. Carries the claimed
2722
+ * migrate-mode history (tag + journal), the push-mode snapshot, or both.
2723
+ */
2724
+ interface DeploymentStateBaselineRequest {
2725
+ lastAppliedMigrationTag?: string;
2726
+ journal?: DeployBaselineJournalEntry[];
2727
+ schemaSnapshot?: unknown;
2728
+ schemaHash?: string;
2729
+ /**
2730
+ * Per-migration schema-object evidence (creates AND drops) derived
2731
+ * from drizzle's snapshot files. The server replays it up to the
2732
+ * claimed tag into the expected schema and validates that against the
2733
+ * live database (D7): surviving claimed objects must exist,
2734
+ * beyond-claim objects must be absent unless claimed history already
2735
+ * explains them. Absent evidence downgrades every migration to
2736
+ * no-signal.
2737
+ */
2738
+ evidence?: BaselineMigrationEvidence[];
2739
+ /**
2740
+ * Waive refusals for no-signal migrations only (content contradictions
2741
+ * are never waivable). Recorded server-side for audit.
2742
+ */
2743
+ allowUnverified?: boolean;
2744
+ }
2745
+ /**
2746
+ * Schema objects one journal migration introduced and removed (snapshot
2747
+ * delta). Drops are as load-bearing as creates: an object created by one
2748
+ * migration and dropped by a later one must not be demanded of the live
2749
+ * database, and its live presence beyond the claim must not convict a
2750
+ * migration whose object is already explained by claimed history.
2751
+ */
2752
+ interface BaselineMigrationEvidence {
2753
+ tag: string;
2754
+ /** Journal generation timestamp (drizzle `when`), ISO 8601 */
2755
+ generatedAt: string;
2756
+ createsTables: {
2757
+ name: string;
2758
+ columns: string[];
2759
+ }[];
2760
+ addsColumns: {
2761
+ table: string;
2762
+ column: string;
2763
+ }[];
2764
+ createsIndexes: string[];
2765
+ createsViews: string[];
2766
+ dropsTables: string[];
2767
+ dropsColumns: {
2768
+ table: string;
2769
+ column: string;
2770
+ }[];
2771
+ dropsIndexes: string[];
2772
+ dropsViews: string[];
2773
+ }
2774
+ /** Outcome of the `db realign <tag>` checksum pardon */
2775
+ interface MigrationRealignResponse {
2776
+ tag: string;
2777
+ /** The re-recorded checksum */
2778
+ checksum: string;
2779
+ /** Algorithm stamped alongside it (e.g. 'sha256-v1') */
2780
+ checksumAlgo: string;
2781
+ }
2782
+ /** How a ledger escape-hatch resolution lands: record the row, or remove it */
2783
+ type MigrationResolution = 'applied' | 'rolled-back';
2784
+ /** Outcome of the `db resolve <tag>` ledger escape hatch */
2785
+ interface MigrationResolveResponse {
2786
+ tag: string;
2787
+ resolution: MigrationResolution;
2788
+ /**
2789
+ * Live schema fingerprint captured by the resolve: the developer's
2790
+ * attestation that the current database state is intended, so the next
2791
+ * deploy verifies against it instead of the pre-repair record.
2792
+ */
2793
+ schemaFingerprint: string;
2794
+ /**
2795
+ * Whether the fingerprint was persisted to the game's deployment-state
2796
+ * row. False when the game has no such row (not yet adopted): the
2797
+ * ledger repair still succeeded, but nothing was recorded.
2798
+ */
2799
+ fingerprintRecorded: boolean;
2800
+ }
2801
+ /** One deploy job in a game's execution history (PLA-217 D10) */
2802
+ interface GameDeployHistoryDeploy {
2803
+ kind: 'deploy';
2804
+ status: DeployJobStatus;
2805
+ /** When the deploy landed (creation time while pending/running), ISO 8601 */
2806
+ at: string;
2807
+ /** When the job finished (null while pending/running) */
2808
+ completedAt: string | null;
2809
+ /** Who deployed: their email, or DELETED_ACCOUNT_LABEL when the account is gone */
2810
+ by: string;
2811
+ /** Client idempotency key (null for legacy clients) */
2812
+ deployId: string | null;
2813
+ error: string | null;
2814
+ }
2815
+ /** A Time Travel restore in a game's execution history */
2816
+ interface GameDeployHistoryRestore {
2817
+ kind: 'restore';
2818
+ /** When the restore ran, ISO 8601 */
2819
+ at: string;
2820
+ /** Who restored: their email, or DELETED_ACCOUNT_LABEL when the account is gone */
2821
+ by: string;
2822
+ /** The moment the database was rewound to, ISO 8601 */
2823
+ restoredTo: string;
2896
2824
  }
2897
- interface StartDiagnosticAssessmentInput extends StartAssessmentInputBase {
2898
- purpose: 'diagnostic';
2899
- /** Stable authored diagnostic identity, independent of the selected QTI test identifier. */
2900
- diagnosticKey: string;
2825
+ /** A client-gate refusal in a game's execution history */
2826
+ interface GameDeployHistoryBlocked {
2827
+ kind: 'blocked';
2828
+ /** When the gate refused, ISO 8601 */
2829
+ at: string;
2830
+ /** Whose deploy was refused: their email, or DELETED_ACCOUNT_LABEL */
2831
+ by: string;
2832
+ /** Stable `blocked:*` code the gate refused with */
2833
+ code: string;
2834
+ /** The gate's plain-text refusal reason */
2835
+ reason: string;
2901
2836
  }
2902
- interface StartMasteryAssessmentInput extends StartAssessmentInputBase {
2903
- purpose: 'mastery';
2904
- standard: AssessmentStandardRef;
2837
+ /**
2838
+ * One entry in a game's execution history: deploy jobs interleaved with
2839
+ * the platform-visible events the job system never sees (restores,
2840
+ * client-gate refusals), newest first.
2841
+ */
2842
+ type GameDeployHistoryEntry = GameDeployHistoryDeploy | GameDeployHistoryRestore | GameDeployHistoryBlocked;
2843
+ /** Deploy history served by GET /api/games/:slug/deployments */
2844
+ interface GameDeployHistoryResponse {
2845
+ deploys: GameDeployHistoryEntry[];
2905
2846
  }
2906
- interface StartReviewAssessmentInput extends StartAssessmentInputBase {
2907
- purpose: 'review';
2908
- /** Serving order; duplicate canonical skills keep their first position. Pinned on start. */
2909
- standards: AssessmentReviewStandard[];
2910
- /** Candidate capacity per standard; preloaded candidates are not administered automatically. */
2911
- candidateItemsPerStandard?: number;
2847
+ /**
2848
+ * One successful deploy of a game's worker, as the open releases surface
2849
+ * describes it: what is running and which commit produced it.
2850
+ *
2851
+ * This shape is parsed by external automation. Every field is present on
2852
+ * every entry — nullable, never absent — and nothing from the deploy job
2853
+ * beyond its git provenance and completion time is exposed. No deployer
2854
+ * identity, no schema state, no secrets manifest.
2855
+ */
2856
+ interface Release {
2857
+ slug: string;
2858
+ /** Where the game is served; null when the platform has no URL for it */
2859
+ url: string | null;
2860
+ /**
2861
+ * Git provenance the deploying CLI captured. Null for deploys that
2862
+ * predate provenance capture, so the fleet list is complete on day one
2863
+ * and a consumer can tell "unknown" from "not in git".
2864
+ */
2865
+ source: DeploySource | null;
2866
+ /** When the deploy succeeded, ISO 8601 */
2867
+ deployedAt: string;
2912
2868
  }
2913
- type StartAssessmentInput = StartFixedAssessmentInput | StartDiagnosticAssessmentInput | StartMasteryAssessmentInput | StartReviewAssessmentInput;
2914
- /** Transport metadata for attempting a prepared new-assessment start. */
2915
- interface StartAssessmentOptions {
2916
- preparationReceipt?: string;
2869
+ /** GET /api/releases — the current release of every game */
2870
+ interface ReleasesResponse {
2871
+ releases: Release[];
2917
2872
  }
2918
- /** Result of preparing the immediate next assessment request. */
2919
- type AssessmentPreparationResult = {
2920
- status: 'prepared';
2921
- receipt: string;
2922
- /** Receipt expiry as an ISO-8601 timestamp. */
2923
- expiresAt: string;
2924
- } | {
2925
- status: 'unprepared';
2926
- reason: 'artifact_unavailable' | 'prerequisite_unavailable' | 'local_runtime';
2927
- };
2928
- interface SaveAssessmentInput {
2929
- expectedResponseVersion: number;
2930
- /** Complete active draft; success acknowledges its durable parent checkpoint. */
2931
- transcript: AssessmentTranscript;
2873
+ /** GET /api/releases/:slug — one game's current release and, on request, its recent history */
2874
+ interface GameReleaseResponse {
2875
+ /** The current release; null when the game has never deployed successfully */
2876
+ current: Release | null;
2877
+ /**
2878
+ * The last N successful deploys, newest first, current included. Only
2879
+ * present when `?history=N` was requested.
2880
+ */
2881
+ history?: Release[];
2932
2882
  }
2933
- /** Best-effort mastery progress, not an answer commitment or an explicit checkpoint. */
2934
- interface RecordAssessmentProgressInput {
2935
- assessmentToken: string;
2936
- expectedResponseVersion: number;
2937
- /** Current raw draft, including the editable administration being projected. */
2938
- transcript: AssessmentTranscript;
2939
- itemIdentifier: string;
2883
+ /** Request body for POST /api/games/:slug/deployments/blocked */
2884
+ interface DeployBlockedReport {
2885
+ /** Stable `blocked:*` code the gate refused with */
2886
+ code: string;
2887
+ /** The gate's plain-text refusal reason */
2888
+ reason: string;
2940
2889
  }
2941
- interface SubmitAssessmentItemInputBase {
2942
- assessmentToken: string;
2943
- /** The raw prefix preceding this administration (or including it for an exact retry). */
2944
- transcript: AssessmentTranscript;
2945
- expectedResponseVersion: number;
2946
- /** Stable across every retry of this exact item submission. */
2947
- submissionId: string;
2948
- itemIdentifier: string;
2949
- responses: Record<string, AssessmentResponseValue | null>;
2890
+ /**
2891
+ * A restorable pre-deploy database state (D1 Time Travel bookmark).
2892
+ *
2893
+ * Each schema-bearing deploy captures a bookmark of the database as it was
2894
+ * the moment before that deploy's schema changes ran. Only bookmarks
2895
+ * belonging to the CURRENT database and within Time Travel's retention
2896
+ * window are served — a `db reset` creates a new database (bookmarks do
2897
+ * not cross that boundary), and Cloudflare expires bookmarks after the
2898
+ * account plan's retention period.
2899
+ */
2900
+ interface GameRestorePoint {
2901
+ /** Deployment row id — pass to the restore endpoint (or a unique prefix to the CLI) */
2902
+ id: string;
2903
+ /**
2904
+ * When the bookmark was captured (the exact state a restore rewinds
2905
+ * to), ISO 8601. Rows from before capture times were recorded fall
2906
+ * back to the deploy completion time.
2907
+ */
2908
+ capturedAt: string;
2909
+ /** Whether the capturing deployment is the currently active one */
2910
+ active: boolean;
2950
2911
  }
2951
- interface SubmitReviewAssessmentItemInput extends SubmitAssessmentItemInputBase {
2952
- routingNodeKey?: never;
2912
+ /** Restore points served by GET /api/games/:slug/database/restore-points */
2913
+ interface GameRestorePointsResponse {
2914
+ restorePoints: GameRestorePoint[];
2915
+ /**
2916
+ * True for push-adopted games, whose recorded snapshot cannot rewind
2917
+ * with the data: restore is categorically refused, so the list is
2918
+ * served empty rather than offering points that can never restore.
2919
+ */
2920
+ restoreUnsupported: boolean;
2953
2921
  }
2954
- interface SubmitDiagnosticAssessmentItemInput extends SubmitAssessmentItemInputBase {
2955
- /** Canonical routing-context identity returned in routing.next. */
2956
- routingNodeKey: string;
2922
+ /** Outcome of a Time Travel restore (PLA-217 D10) */
2923
+ interface DatabaseRestoreResponse {
2924
+ restorePointId: string;
2925
+ /** The moment the database was rewound to (the bookmark's capture time), ISO 8601 */
2926
+ restoredTo: string;
2927
+ /**
2928
+ * Live schema fingerprint captured after the restore: the developer's
2929
+ * audited attestation that the rewound state is intended, so the next
2930
+ * deploy verifies against it.
2931
+ */
2932
+ schemaFingerprint: string;
2933
+ /** False when the game has no deployment-state row to re-attest */
2934
+ fingerprintRecorded: boolean;
2935
+ /**
2936
+ * Bookmark of the database as it was just before this restore — the
2937
+ * undo handle. Null only if Cloudflare omits it from the response.
2938
+ */
2939
+ previousBookmark: string | null;
2957
2940
  }
2958
- type SubmitAssessmentItemInput = SubmitReviewAssessmentItemInput | SubmitDiagnosticAssessmentItemInput;
2959
- interface SubmitReviewAssessmentItemResult {
2960
- attemptId: string;
2961
- responseVersion: number;
2962
- status: 'in_progress';
2963
- responses: AssessmentResponses;
2964
- /** Canonical ledger after commit or replay; replace local state with it. */
2965
- itemSubmissions: AssessmentItemSubmission[];
2966
- submission: AssessmentItemSubmission;
2967
- transcript: AssessmentTranscript;
2941
+ /** Push-mode reset payload: the full schema that rebuilds the fresh database */
2942
+ interface DatabaseResetPush {
2943
+ mode: 'push';
2944
+ /** Full schema DDL (semicolon-separated statements) */
2945
+ sql: string;
2946
+ /** Drizzle snapshot JSON, stored as the new push baseline */
2947
+ nextSnapshot: unknown;
2948
+ /** Hash of nextSnapshot, stored as the new schemaHash */
2949
+ nextHash: string;
2968
2950
  }
2969
- /** Safe acknowledgement for one immutable diagnostic item commitment. */
2970
- interface DiagnosticAssessmentItemReceipt {
2971
- submissionId: string;
2972
- routingNodeKey: string;
2973
- itemIdentifier: string;
2974
- submittedAt: string;
2975
- responseVersion: number;
2976
- answered: boolean;
2977
- score: AssessmentScore;
2978
- isCorrect: boolean;
2951
+ /** Migrate-mode reset payload: the complete journal to replay on the fresh database */
2952
+ interface DatabaseResetMigrate {
2953
+ mode: 'migrate';
2954
+ /** The full journal in order; replayed one-by-one, rebuilding the ledger */
2955
+ migrations: DeployMigration[];
2979
2956
  }
2980
- /** Canonical post-commit routing state plus trusted feedback for this administration. */
2981
- interface SubmitDiagnosticAssessmentItemResult {
2982
- attemptId: string;
2983
- responseVersion: number;
2984
- status: 'in_progress';
2985
- routing: DiagnosticRoutingSnapshot;
2986
- submission: DiagnosticAssessmentItemReceipt;
2987
- transcript: AssessmentTranscript;
2957
+ /**
2958
+ * Mode-aware reset payload (PLA-217 D2). Reset recreates the database, so
2959
+ * the ledger dies with it and there is no baseline to compare against —
2960
+ * adopted games must send how to rebuild.
2961
+ */
2962
+ type DatabaseResetDatabasePayload = DatabaseResetPush | DatabaseResetMigrate;
2963
+ interface DatabaseResetRequest {
2964
+ /**
2965
+ * Legacy schema info, accepted only while the game's schema state is
2966
+ * unadopted; adopted games must send `database` instead.
2967
+ */
2968
+ schema?: {
2969
+ /** SQL schema statements (DDL: CREATE, ALTER, etc.) */
2970
+ sql: string;
2971
+ /** Hash of the schema for change detection */
2972
+ hash: string;
2973
+ };
2974
+ /** Mode-aware rebuild payload (mandatory for adopted games) */
2975
+ database?: DatabaseResetDatabasePayload;
2988
2976
  }
2989
- type SubmitAssessmentItemResult = SubmitReviewAssessmentItemResult | SubmitDiagnosticAssessmentItemResult;
2990
- interface SubmitAssessmentInput {
2991
- expectedResponseVersion: number;
2992
- submissionId: string;
2993
- transcript: AssessmentTranscript;
2977
+ /** Log entry captured from seed worker console output */
2978
+ interface SeedLogEntry {
2979
+ /** Log level (log, warn, error, info) */
2980
+ level: 'log' | 'warn' | 'error' | 'info';
2981
+ /** Log message content */
2982
+ message: string;
2983
+ /** Milliseconds since seed execution started */
2984
+ timestamp: number;
2985
+ }
2986
+ /** Structured error details from D1/SQLite errors */
2987
+ interface SeedErrorDetails {
2988
+ /** Error category code */
2989
+ code?: 'CONSTRAINT_VIOLATION' | 'SQL_ERROR' | 'DATABASE_BUSY';
2990
+ /** Table name involved in the error */
2991
+ table?: string;
2992
+ /** Constraint name or column that caused the error */
2993
+ constraint?: string;
2994
+ /** Specific constraint type */
2995
+ constraintType?: 'UNIQUE' | 'FOREIGN_KEY' | 'NOT_NULL';
2996
+ /** Token near syntax error */
2997
+ nearToken?: string;
2998
+ /** Specific error type within category */
2999
+ errorType?: 'TABLE_NOT_FOUND' | 'SYNTAX_ERROR';
2994
3000
  }
2995
- /** The optional mastery portion of a finalize award; at most one field is set. */
2996
- interface AssessmentMasteryAward {
2997
- /**
2998
- * Incremental learning units mastered by this attempt. Cannot be combined
2999
- * with masteredUnitsAbsolute. The platform bounds the delta against the
3000
- * course's configured masterableUnits and returns any warning.
3001
- */
3002
- masteredUnits?: number;
3003
- /**
3004
- * Absolute mastered-unit total after this attempt; the platform computes
3005
- * the delta. Cannot be combined with masteredUnits.
3006
- */
3007
- masteredUnitsAbsolute?: number;
3001
+ /**
3002
+ * API response for seed operations (what the API returns to the CLI).
3003
+ *
3004
+ * Extends the worker response with deployment metadata.
3005
+ */
3006
+ interface SeedResponse {
3007
+ /** Whether the seed completed successfully */
3008
+ success: boolean;
3009
+ /** Unique identifier for the seed worker deployment */
3010
+ deploymentId: string;
3011
+ /** When the seed was executed (ISO 8601 string from JSON serialization) */
3012
+ executedAt: string;
3013
+ /** Captured console output from the seed script */
3014
+ logs?: SeedLogEntry[];
3015
+ /** Execution duration in milliseconds */
3016
+ duration?: number;
3017
+ /** Error message if seed failed */
3018
+ error?: string;
3019
+ /** Stack trace if seed failed */
3020
+ stack?: string;
3021
+ /** Structured error details if seed failed */
3022
+ details?: SeedErrorDetails;
3008
3023
  }
3009
- interface FinalizeAssessmentInput extends AssessmentMasteryAward {
3010
- submissionId: string;
3011
- /** Explicit zero is an award; omission is never interpreted as zero. */
3012
- xpAwarded: number;
3024
+ interface DomainValidationRecords {
3025
+ ownership?: {
3026
+ name?: string;
3027
+ value?: string;
3028
+ type?: string;
3029
+ };
3030
+ ssl?: {
3031
+ txt_name?: string;
3032
+ txt_value?: string;
3033
+ }[];
3013
3034
  }
3035
+
3014
3036
  /**
3015
- * The award a game supplied at finalization, retained verbatim so a retried
3016
- * finalize can be told apart from a contradictory one even after bounding
3017
- * changed what was actually applied.
3037
+ * Leaderboard Types
3038
+ *
3039
+ * @module types/leaderboard
3018
3040
  */
3019
- interface AssessmentAwardRecord extends AssessmentMasteryAward {
3020
- xpAwarded: number;
3021
- /** The bounded mastery delta the platform recorded for this attempt. */
3022
- masteredUnitsApplied: number;
3023
- pctCompleteApp?: number;
3024
- warnings?: MasteryWriteWarning[];
3041
+ type LeaderboardTimeframe = 'all_time' | 'monthly' | 'weekly' | 'daily';
3042
+ interface LeaderboardOptions {
3043
+ timeframe?: LeaderboardTimeframe;
3044
+ limit?: number;
3045
+ offset?: number;
3046
+ gameId?: string;
3025
3047
  }
3026
- /** One scored region for host-only point-response fixture scoring. */
3027
- interface AssessmentResponseArea {
3028
- shape: PlayableAssessmentShape;
3029
- coords: number[];
3030
- /** The region's mapped point value (1 when omitted). */
3031
- value?: number;
3048
+ interface LeaderboardEntry {
3049
+ rank: number;
3050
+ userId: string;
3051
+ username: string;
3052
+ userImage?: string | null;
3053
+ score: number;
3054
+ achievedAt: Date;
3055
+ metadata?: Record<string, unknown>;
3056
+ gameId?: string;
3057
+ gameTitle?: string;
3058
+ gameSlug?: string;
3032
3059
  }
3033
- /** One host-only assessment entry exported for the local runtime provider. */
3034
- interface AssessmentRuntimeFixtureTest {
3035
- id: string;
3036
- assessmentKey: string;
3037
- qtiTestIdentifier: string;
3038
- live: boolean;
3039
- /** Canonical quiz-level alignment used by mastery selection. */
3040
- standard: AssessmentStandardRef | null;
3041
- assessment: PlayableAssessment;
3042
- /** Private comparison rules retained for hosted-equivalent local scoring when available. */
3043
- scoring?: AssessmentScoringArtifactV1;
3044
- /** Correct responses are retained by the host and are never returned to the game. */
3045
- correctResponses: AssessmentResponses;
3046
- /**
3047
- * Host-only scored regions for point responses (select-point, position-object),
3048
- * keyed by item then response identifier. A point response is correct when every
3049
- * point lands in a distinct scored region.
3050
- */
3051
- responseAreas?: Record<string, Record<string, AssessmentResponseArea[]>>;
3052
- /** Host-only platform-routing sidecar for one immutable diagnostic bank revision. */
3053
- diagnostic?: {
3054
- diagnosticKey: string;
3055
- /** Calculated from the canonical manifest when the fixture is built. */
3056
- routingRevision: string;
3057
- routingManifest: DiagnosticRoutingManifestV1;
3058
- };
3059
- /** Host-only standard index derived from this ordinary QTI test when used for review. */
3060
- reviewBank?: {
3061
- sourceContentRevision: string;
3062
- bankRevision: string;
3063
- items: {
3064
- itemIdentifier: string;
3065
- standards: AssessmentStandardRef[];
3066
- }[];
3067
- };
3060
+ interface UserRank {
3061
+ rank: number;
3062
+ totalPlayers: number;
3063
+ score: number;
3064
+ percentile: number;
3068
3065
  }
3069
- /** Ordered local catalog for one course integration and assessment purpose. */
3070
- interface AssessmentRuntimeFixtureCatalog {
3066
+ interface UserRankResponse {
3067
+ rank: number;
3068
+ score: number;
3069
+ userId: string;
3070
+ }
3071
+ interface UserScore {
3071
3072
  id: string;
3072
- integrationId: string;
3073
- purpose: AssessmentPurpose;
3074
- subject: TimebackSubject;
3075
- grade: TimebackGrade;
3076
- tests: AssessmentRuntimeFixtureTest[];
3073
+ score: number;
3074
+ achievedAt: Date;
3075
+ metadata?: Record<string, unknown>;
3076
+ gameId: string;
3077
+ gameTitle: string;
3078
+ gameSlug: string;
3077
3079
  }
3078
3080
  /**
3079
- * Versioned host-only bundle consumed by the local assessment runtime.
3080
- *
3081
- * The version tracks this bundle's own shape, including the shape of the
3082
- * assessments nested inside it — a bundle is rejected outright when either
3083
- * differs, so a stale export is re-generated rather than half-read.
3081
+ * Leaderboard entry with required game context.
3082
+ * Used when fetching leaderboards for a specific game.
3084
3083
  */
3085
- interface AssessmentRuntimeFixtureBundle {
3086
- version: 8;
3084
+ interface GameLeaderboardEntry {
3085
+ rank: number;
3086
+ userId: string;
3087
+ username: string;
3088
+ userImage?: string | null;
3089
+ score: number;
3090
+ achievedAt: Date;
3091
+ metadata?: Record<string, unknown>;
3087
3092
  gameId: string;
3088
- /**
3089
- * The project-config slug the CLI resolved the game by at export time.
3090
- * Local dev matches on this (the platform gameId and the locally derived
3091
- * id live in different namespaces, so they can never be compared).
3092
- */
3093
- gameSlug?: string;
3094
- exportedAt: string;
3095
- catalogs: AssessmentRuntimeFixtureCatalog[];
3093
+ gameTitle: string;
3094
+ gameSlug: string;
3096
3095
  }
3097
3096
 
3098
3097
  /**
3099
- * Must admit exactly the raster set in `QTI_RASTER_IMAGE_MIME_TYPES`
3100
- * (`@playcademy/utils/timeback`), minus the legacy `image/jpg` spelling
3101
- * the server never emits.
3098
+ * Skill Status Types
3099
+ *
3100
+ * Contract for cross-game skill status queries. An answering game exports
3101
+ * `getSkillStatus` from `server/lib/skills.ts`; the platform calls its
3102
+ * reserved `/__playcademy/skills/status` route on behalf of another game.
3103
+ *
3104
+ * @module types/skills
3102
3105
  */
3103
- type AssessmentAssetMimeType = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp' | 'image/bmp';
3104
- type AssessmentAssetUploadStatus = 'uploaded' | 'already_exists';
3105
- /** Assessment assets are production-oriented content; local sandboxes never host them. */
3106
- type AssessmentAssetEnvironment = 'production' | 'staging';
3107
- interface AssessmentAssetUploadResponse {
3108
- status: AssessmentAssetUploadStatus;
3109
- environment: AssessmentAssetEnvironment;
3110
- key: string;
3111
- url: string;
3112
- sha256: string;
3113
- mimeType: AssessmentAssetMimeType;
3114
- size: number;
3115
- width: number;
3116
- height: number;
3106
+
3107
+ /**
3108
+ * Current status of one skill for one student, as judged by the answering game.
3109
+ *
3110
+ * - `locked`: the student can't work on the skill yet in this game.
3111
+ * - `unlocked`: available to the student, but no progress yet.
3112
+ * - `in_progress`: started, not mastered.
3113
+ * - `mastered`: currently meets this game's mastery bar, including by placement.
3114
+ * - `unknown_skill`: the skill ID isn't recognized. Never report an unrecognized
3115
+ * skill as `locked`.
3116
+ */
3117
+ type SkillStatus = (typeof SKILL_STATUSES)[number];
3118
+ /** How a `mastered` status was reached. */
3119
+ type SkillMasterySource = (typeof SKILL_MASTERY_SOURCES)[number];
3120
+ interface SkillStatusResult {
3121
+ /** Skill ID, lowercase. */
3122
+ skill: string;
3123
+ /** Current status. */
3124
+ status: SkillStatus;
3125
+ /** How mastery was reached. Only allowed when `status` is `mastered`. */
3126
+ source?: SkillMasterySource;
3127
+ /** ISO 8601 time of the evidence behind this status. */
3128
+ asOf?: string;
3129
+ }
3130
+ /** Response returned by an answering game's `getSkillStatus` handler. */
3131
+ interface SkillStatusResponse {
3132
+ /** Student identifier (Playcademy user ID). Must match the requested student. */
3133
+ studentId: string;
3134
+ /** One result per skill the handler was asked about. */
3135
+ results: SkillStatusResult[];
3136
+ }
3137
+ /** The game asking for skill status, as identified by the platform. */
3138
+ interface SkillStatusRequestingGame {
3139
+ id: string;
3140
+ slug: string;
3141
+ }
3142
+ /** Body of `POST /api/skills/status`, sent by the asking game's worker. */
3143
+ interface SkillStatusRequest {
3144
+ /** Slug of the game to ask. */
3145
+ game: string;
3146
+ /** Playcademy user ID of the student. */
3147
+ studentId: string;
3148
+ /** Skill IDs to ask about. Normalized (trimmed, lowercased) and de-duplicated. */
3149
+ skills: string[];
3117
3150
  }
3151
+ /** Why the answering game couldn't answer. */
3152
+ type SkillStatusUnsupportedReason = 'not_implemented' | 'no_active_deployment' | 'timeout' | 'fetch_failed' | 'invalid_response';
3153
+ /**
3154
+ * What the asking game gets back. When `supported` is false, fall back to
3155
+ * the game's own default (usually: treat the skills as not mastered).
3156
+ */
3157
+ type SkillStatusLookupResult = {
3158
+ supported: true;
3159
+ results: SkillStatusResult[];
3160
+ } | {
3161
+ supported: false;
3162
+ reason: SkillStatusUnsupportedReason;
3163
+ };
3118
3164
 
3119
3165
  /** A game token for a launch. `POST /api/embed/launches/:launchId/token`. */
3120
3166
  interface EmbedGameToken {
@@ -7137,6 +7183,8 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
7137
7183
  get: (gameId: string) => Promise<GameTimebackIntegration[]>;
7138
7184
  getRemovedIntegrations: (gameId: string) => Promise<RemovedGameTimebackIntegration[]>;
7139
7185
  createIntegration: (gameId: string, request: CreateGameTimebackIntegrationRequest) => Promise<GameTimebackIntegration>;
7186
+ getHoleFillingCourses: (gameId: string) => Promise<GameTimebackIntegration[]>;
7187
+ createHoleFillingCourse: (gameId: string, request: CreateGameTimebackHoleFillingCourseRequest) => Promise<GameTimebackIntegration>;
7140
7188
  updateIntegration: (gameId: string, courseId: string, request: UpdateGameTimebackIntegrationRequest) => Promise<GameTimebackIntegration>;
7141
7189
  deactivateCourse: (gameId: string, courseId: string) => Promise<GameTimebackIntegration>;
7142
7190
  reactivateCourse: (gameId: string, courseId: string) => Promise<GameTimebackIntegration>;