@playcademy/sdk 0.17.0 → 0.17.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1564,6 +1564,7 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
1564
1564
  save: (attemptId: string, input: _playcademy_types.SaveAssessmentInput) => Promise<_playcademy_types.AssessmentSaveResult>;
1565
1565
  submitItem: (attemptId: string, input: _playcademy_types.SubmitAssessmentItemInput) => Promise<_playcademy_types.SubmitAssessmentItemResult>;
1566
1566
  submit: (attemptId: string, input: _playcademy_types.SubmitAssessmentInput) => Promise<_playcademy_types.AssessmentSubmitResult>;
1567
+ finalize: (attemptId: string, input: _playcademy_types.FinalizeAssessmentInput) => Promise<_playcademy_types.AssessmentFinalizeResult>;
1567
1568
  };
1568
1569
  readonly user: TimebackUser;
1569
1570
  readonly currentRunId: string | undefined;
package/dist/index.js CHANGED
@@ -3094,7 +3094,7 @@ function createTimebackNamespace(client) {
3094
3094
  if (pendingAssessmentSubmissions.has(snapshot.attemptId)) {
3095
3095
  return snapshot;
3096
3096
  }
3097
- if (snapshot.status === "completed") {
3097
+ if (snapshot.status !== "in_progress") {
3098
3098
  await engine.activity.finishAssessment(snapshot.attemptId);
3099
3099
  clearAssessmentTrackingWarnings(snapshot.attemptId);
3100
3100
  return snapshot;
@@ -3278,6 +3278,28 @@ function createTimebackNamespace(client) {
3278
3278
  }
3279
3279
  throw error;
3280
3280
  }
3281
+ },
3282
+ finalize: async (attemptId, input) => {
3283
+ assertPlatformMode(client, "timeback.assessments.finalize()");
3284
+ if (!attemptId?.trim()) {
3285
+ throw new Error("attemptId is required");
3286
+ }
3287
+ if (!input.submissionId?.trim()) {
3288
+ throw new Error("submissionId is required");
3289
+ }
3290
+ if (!Number.isFinite(input.xpAwarded) || input.xpAwarded < 0) {
3291
+ throw new Error("xpAwarded must be a finite, non-negative number");
3292
+ }
3293
+ if (input.masteredUnits !== undefined && input.masteredUnitsAbsolute !== undefined) {
3294
+ throw new Error("Provide either masteredUnits or masteredUnitsAbsolute, not both");
3295
+ }
3296
+ if (input.masteredUnits !== undefined && !Number.isFinite(input.masteredUnits)) {
3297
+ throw new Error("masteredUnits must be a finite number");
3298
+ }
3299
+ if (input.masteredUnitsAbsolute !== undefined && !Number.isInteger(input.masteredUnitsAbsolute)) {
3300
+ throw new Error("masteredUnitsAbsolute must be an integer");
3301
+ }
3302
+ return client["requestGameBackend"](`${ASSESSMENTS_ROUTE}/${encodeURIComponent(attemptId)}/finalize`, "POST", input, undefined, { retryPolicy: ASSESSMENT_SUBMIT_RETRY_POLICY });
3281
3303
  }
3282
3304
  },
3283
3305
  get user() {
@@ -3684,7 +3706,7 @@ async function request({
3684
3706
  return rawText && rawText.length > 0 ? rawText : undefined;
3685
3707
  }
3686
3708
  // src/version.ts
3687
- var SDK_VERSION = "0.17.0";
3709
+ var SDK_VERSION = "0.17.1-beta.2";
3688
3710
 
3689
3711
  // src/clients/base.ts
3690
3712
  class PlaycademyBaseClient {
@@ -1,7 +1,7 @@
1
1
  import { SchemaInfo } from '@playcademy/cloudflare';
2
2
  import { GamePermission, AUTH_PROVIDER_IDS } from '@playcademy/constants';
3
3
  import { TimebackGrade, TimebackSubject, ELevel, HeartbeatRequest, EndActivityRequest, EndActivityScoreData, EndActivityResponse, TimebackCourseConfig, CourseConfig, OrganizationConfig, ComponentConfig, ResourceConfig, ComponentResourceConfig } from '@playcademy/types/timeback';
4
- export { AssessmentAttemptSnapshot, AssessmentFlow, AssessmentItemSubmission, AssessmentResponseUpdate, AssessmentResponseValue, AssessmentResponses, AssessmentSaveResult, AssessmentScore, AssessmentStandardRef, AssessmentSubmitResult, ConventionalAssessmentAttemptSnapshot, ConventionalAssessmentSubmitResult, DiagnosticAssessmentItemReceipt, DiagnosticAssessmentSubmitResult, DiagnosticRoutingSnapshot, DiagnosticRoutingTrackSnapshot, ELevel, PlatformRoutedDiagnosticAttemptSnapshot, PlatformRoutedDiagnosticSelectionContext, PlayableAssessment, PlayableAssessmentChoice, PlayableAssessmentGraphic, PlayableAssessmentHotspot, PlayableAssessmentInteraction, PlayableAssessmentItem, PlayableContentNode, SaveAssessmentInput, StartAssessmentInput, StartDiagnosticAssessmentInput, SubmitAssessmentInput, SubmitAssessmentItemInput, SubmitAssessmentItemResult, SubmitDiagnosticAssessmentItemInput, SubmitDiagnosticAssessmentItemResult } from '@playcademy/types/timeback';
4
+ export { AssessmentAttemptSnapshot, AssessmentAwardRecord, AssessmentFinalizeResult, AssessmentFlow, AssessmentItemSubmission, AssessmentMasteryAward, AssessmentResponseUpdate, AssessmentResponseValue, AssessmentResponses, AssessmentSaveResult, AssessmentScore, AssessmentStandardRef, AssessmentSubmitResult, ConventionalAssessmentAttemptSnapshot, ConventionalAssessmentSubmitResult, DiagnosticAssessmentItemReceipt, DiagnosticAssessmentSubmitResult, DiagnosticRoutingSnapshot, DiagnosticRoutingTrackSnapshot, ELevel, FinalizeAssessmentInput, PlatformRoutedDiagnosticAttemptSnapshot, PlatformRoutedDiagnosticSelectionContext, PlayableAssessment, PlayableAssessmentAttemptSnapshot, PlayableAssessmentChoice, PlayableAssessmentGraphic, PlayableAssessmentHotspot, PlayableAssessmentInteraction, PlayableAssessmentItem, PlayableContentNode, SaveAssessmentInput, SettledAssessmentAttemptSnapshot, StartAssessmentInput, StartDiagnosticAssessmentInput, SubmitAssessmentInput, SubmitAssessmentItemInput, SubmitAssessmentItemResult, SubmitDiagnosticAssessmentItemInput, SubmitDiagnosticAssessmentItemResult } from '@playcademy/types/timeback';
5
5
  import * as _playcademy_types from '@playcademy/types';
6
6
  import { GameManifest, LocalDayContext } from '@playcademy/types';
7
7
  export { AuthenticatedUser, DeveloperStatusEnumType, DeveloperStatusResponse, DeveloperStatusValue, GameCourseMetrics, GameLeaderboardEntry, GameManifest, GameMetricComparisonKind, GameMetricComparisonMetric, GameMetricComparisonRow, GameMetricComparisonRowStatus, GameMetricsProxyResponse, GameMetricsResponse, GameMetricsUnsupportedReason, GamePlatform, GameRunMetrics, GameRunMetricsComparison, GameRunMetricsComparisonStatus, GameRunMetricsComparisonSummary, GameTimebackIntegration, GameType, GameUser, LeaderboardEntry, LeaderboardOptions, LeaderboardTimeframe, LocalDayContext, LocalDaySource, ManifestV1, ManifestV2, ManifestVersions, PopulateStudentResponse, UserEnrollment, UserInfo, UserOrganization, UserRank, UserRankResponse, UserRoleEnumType, UserScore, UserTimebackData } from '@playcademy/types';
@@ -3659,11 +3659,6 @@ interface QtiLibraryQueryOptions {
3659
3659
  page?: number;
3660
3660
  limit?: number;
3661
3661
  }
3662
- interface ReviewMappingUpdateResult {
3663
- itemCount: number;
3664
- standardCount: number;
3665
- sourceFingerprint: string;
3666
- }
3667
3662
 
3668
3663
  /**
3669
3664
  * Internal Playcademy SDK client with all namespaces.
@@ -4027,19 +4022,19 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
4027
4022
  create: (gameId: string, courseId: string, data: {
4028
4023
  assessmentKey: string;
4029
4024
  title: string;
4030
- purpose: Exclude<_playcademy_types.AssessmentPurpose, 'diagnostic'>;
4025
+ purpose: Exclude<_playcademy_types.AssessmentPurpose, 'diagnostic' | 'review'>;
4031
4026
  standard?: _playcademy_types.AssessmentStandardRef;
4032
4027
  }) => Promise<_playcademy_types.AssessmentRow>;
4033
4028
  attachExisting: (gameId: string, courseId: string, manifest: _playcademy_types.AssessmentAssociationImportManifest) => Promise<_playcademy_types.AssessmentAssociationImportResponse>;
4034
4029
  update: (gameId: string, courseId: string, testIdentifier: string, data: {
4035
4030
  title?: string;
4036
- purpose?: _playcademy_types.AssessmentPurpose;
4031
+ purpose?: Exclude<_playcademy_types.AssessmentPurpose, 'review'>;
4037
4032
  standard?: _playcademy_types.AssessmentStandardRef;
4038
4033
  diagnostic?: _playcademy_types.DiagnosticAssessmentDefinitionInput | null;
4039
4034
  status?: _playcademy_types.AssessmentStatus;
4040
4035
  }) => Promise<_playcademy_types.AssessmentRow>;
4041
- updateReviewMapping: (gameId: string, courseId: string, testIdentifier: string) => Promise<ReviewMappingUpdateResult>;
4042
- reorder: (gameId: string, courseId: string, purpose: _playcademy_types.AssessmentPurpose, testIdentifiers: string[]) => Promise<{
4036
+ syncReviewBank: (gameId: string, courseId: string) => Promise<_playcademy_types.ReviewBankSynchronizationResult>;
4037
+ reorder: (gameId: string, courseId: string, purpose: Exclude<_playcademy_types.AssessmentPurpose, 'review'>, testIdentifiers: string[]) => Promise<{
4043
4038
  success: boolean;
4044
4039
  }>;
4045
4040
  remove: (gameId: string, courseId: string, testIdentifier: string) => Promise<{
@@ -4049,7 +4044,7 @@ declare class PlaycademyInternalClient extends PlaycademyBaseClient {
4049
4044
  copy: (gameId: string, courseId: string, data: {
4050
4045
  testIdentifier: string;
4051
4046
  assessmentKey: string;
4052
- purpose: Exclude<_playcademy_types.AssessmentPurpose, 'diagnostic'>;
4047
+ purpose: Exclude<_playcademy_types.AssessmentPurpose, 'diagnostic' | 'review'>;
4053
4048
  standard?: _playcademy_types.AssessmentStandardRef;
4054
4049
  }) => Promise<_playcademy_types.AssessmentRow>;
4055
4050
  listQuestions: (gameId: string, courseId: string, testIdentifier: string) => Promise<_playcademy_types.QtiTestQuestionsResponse>;
package/dist/internal.js CHANGED
@@ -3094,7 +3094,7 @@ function createTimebackNamespace(client) {
3094
3094
  if (pendingAssessmentSubmissions.has(snapshot.attemptId)) {
3095
3095
  return snapshot;
3096
3096
  }
3097
- if (snapshot.status === "completed") {
3097
+ if (snapshot.status !== "in_progress") {
3098
3098
  await engine.activity.finishAssessment(snapshot.attemptId);
3099
3099
  clearAssessmentTrackingWarnings(snapshot.attemptId);
3100
3100
  return snapshot;
@@ -3278,6 +3278,28 @@ function createTimebackNamespace(client) {
3278
3278
  }
3279
3279
  throw error;
3280
3280
  }
3281
+ },
3282
+ finalize: async (attemptId, input) => {
3283
+ assertPlatformMode(client, "timeback.assessments.finalize()");
3284
+ if (!attemptId?.trim()) {
3285
+ throw new Error("attemptId is required");
3286
+ }
3287
+ if (!input.submissionId?.trim()) {
3288
+ throw new Error("submissionId is required");
3289
+ }
3290
+ if (!Number.isFinite(input.xpAwarded) || input.xpAwarded < 0) {
3291
+ throw new Error("xpAwarded must be a finite, non-negative number");
3292
+ }
3293
+ if (input.masteredUnits !== undefined && input.masteredUnitsAbsolute !== undefined) {
3294
+ throw new Error("Provide either masteredUnits or masteredUnitsAbsolute, not both");
3295
+ }
3296
+ if (input.masteredUnits !== undefined && !Number.isFinite(input.masteredUnits)) {
3297
+ throw new Error("masteredUnits must be a finite number");
3298
+ }
3299
+ if (input.masteredUnitsAbsolute !== undefined && !Number.isInteger(input.masteredUnitsAbsolute)) {
3300
+ throw new Error("masteredUnitsAbsolute must be an integer");
3301
+ }
3302
+ return client["requestGameBackend"](`${ASSESSMENTS_ROUTE}/${encodeURIComponent(attemptId)}/finalize`, "POST", input, undefined, { retryPolicy: ASSESSMENT_SUBMIT_RETRY_POLICY });
3281
3303
  }
3282
3304
  },
3283
3305
  get user() {
@@ -4139,7 +4161,7 @@ function createAssessmentNamespace(client) {
4139
4161
  update: (gameId, courseId, testIdentifier, data) => client["request"](assessmentPath(gameId, courseId, testIdentifier), "PATCH", {
4140
4162
  body: data
4141
4163
  }),
4142
- updateReviewMapping: (gameId, courseId, testIdentifier) => client["request"](assessmentPath(gameId, courseId, testIdentifier, "review-mapping"), "POST"),
4164
+ syncReviewBank: (gameId, courseId) => client["request"](assessmentPath(gameId, courseId, "review-bank"), "POST"),
4143
4165
  reorder: (gameId, courseId, purpose, testIdentifiers) => client["request"](assessmentPath(gameId, courseId, "order"), "PUT", {
4144
4166
  body: { purpose, testIdentifiers }
4145
4167
  }),
@@ -4579,7 +4601,7 @@ async function request({
4579
4601
  return rawText && rawText.length > 0 ? rawText : undefined;
4580
4602
  }
4581
4603
  // src/version.ts
4582
- var SDK_VERSION = "0.17.0";
4604
+ var SDK_VERSION = "0.17.1-beta.2";
4583
4605
 
4584
4606
  // src/clients/base.ts
4585
4607
  class PlaycademyBaseClient {
@@ -378,6 +378,9 @@ declare class PlaycademyClient {
378
378
  submit: (studentId: string, attemptId: string, input: _playcademy_types.SubmitAssessmentRequest, context: {
379
379
  sensorUrl: string;
380
380
  }) => Promise<_playcademy_types.AssessmentSubmitResult>;
381
+ finalize: (studentId: string, attemptId: string, input: _playcademy_types.FinalizeAssessmentInput, context: {
382
+ sensorUrl: string;
383
+ }) => Promise<_playcademy_types.AssessmentFinalizeResult>;
381
384
  };
382
385
  endActivity: (studentId: string, payload: _playcademy_types.EndActivityPayload) => Promise<_playcademy_types.EndActivityResponse>;
383
386
  getStudentXp: (studentId: string, options?: {
@@ -117,6 +117,13 @@ function createTimebackNamespace(client) {
117
117
  studentId,
118
118
  appName: client.config.name,
119
119
  sensorUrl: context.sensorUrl
120
+ }),
121
+ finalize: (studentId, attemptId, input, context) => client["request"](`/api/timeback/assessments/${encodeURIComponent(attemptId)}/finalize`, "POST", {
122
+ ...input,
123
+ gameId: client.gameId,
124
+ studentId,
125
+ appName: client.config.name,
126
+ sensorUrl: context.sensorUrl
120
127
  })
121
128
  },
122
129
  endActivity: async (studentId, payload) => {
@@ -315,7 +322,7 @@ function extractApiErrorInfo(error) {
315
322
  }
316
323
 
317
324
  // src/version.ts
318
- var SDK_VERSION = "0.17.0";
325
+ var SDK_VERSION = "0.17.1-beta.2";
319
326
 
320
327
  // src/server/request.ts
321
328
  async function makeApiRequest(opts) {
package/dist/server.d.ts CHANGED
@@ -378,6 +378,9 @@ declare class PlaycademyClient$1 {
378
378
  submit: (studentId: string, attemptId: string, input: _playcademy_types.SubmitAssessmentRequest, context: {
379
379
  sensorUrl: string;
380
380
  }) => Promise<_playcademy_types.AssessmentSubmitResult>;
381
+ finalize: (studentId: string, attemptId: string, input: _playcademy_types.FinalizeAssessmentInput, context: {
382
+ sensorUrl: string;
383
+ }) => Promise<_playcademy_types.AssessmentFinalizeResult>;
381
384
  };
382
385
  endActivity: (studentId: string, payload: _playcademy_types.EndActivityPayload) => Promise<_playcademy_types.EndActivityResponse>;
383
386
  getStudentXp: (studentId: string, options?: {
package/dist/server.js CHANGED
@@ -306,6 +306,13 @@ function createTimebackNamespace(client) {
306
306
  studentId,
307
307
  appName: client.config.name,
308
308
  sensorUrl: context.sensorUrl
309
+ }),
310
+ finalize: (studentId, attemptId, input, context) => client["request"](`/api/timeback/assessments/${encodeURIComponent(attemptId)}/finalize`, "POST", {
311
+ ...input,
312
+ gameId: client.gameId,
313
+ studentId,
314
+ appName: client.config.name,
315
+ sensorUrl: context.sensorUrl
309
316
  })
310
317
  },
311
318
  endActivity: async (studentId, payload) => {
@@ -504,7 +511,7 @@ function extractApiErrorInfo(error) {
504
511
  }
505
512
 
506
513
  // src/version.ts
507
- var SDK_VERSION = "0.17.0";
514
+ var SDK_VERSION = "0.17.1-beta.2";
508
515
 
509
516
  // src/server/request.ts
510
517
  async function makeApiRequest(opts) {
package/dist/types.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as _playcademy_types from '@playcademy/types';
2
2
  import { GameManifest, LocalDayContext } from '@playcademy/types';
3
3
  export { AuthenticatedUser, DeveloperStatusEnumType, DeveloperStatusResponse, DeveloperStatusValue, GameCourseMetrics, GameLeaderboardEntry, GameManifest, GameMetricComparisonKind, GameMetricComparisonMetric, GameMetricComparisonRow, GameMetricComparisonRowStatus, GameMetricsProxyResponse, GameMetricsResponse, GameMetricsUnsupportedReason, GamePlatform, GameRunMetrics, GameRunMetricsComparison, GameRunMetricsComparisonStatus, GameRunMetricsComparisonSummary, GameTimebackIntegration, GameType, GameUser, LeaderboardEntry, LeaderboardOptions, LeaderboardTimeframe, LocalDayContext, LocalDaySource, ManifestV1, ManifestV2, ManifestVersions, PopulateStudentResponse, UserEnrollment, UserInfo, UserOrganization, UserRank, UserRankResponse, UserRoleEnumType, UserScore, UserTimebackData } from '@playcademy/types';
4
4
  import { TimebackCourseConfig, CourseConfig, OrganizationConfig, ComponentConfig, ResourceConfig, ComponentResourceConfig, TimebackGrade, TimebackSubject, ELevel, EndActivityRequest, HeartbeatRequest, EndActivityScoreData, EndActivityResponse } from '@playcademy/types/timeback';
5
- export { AssessmentAttemptSnapshot, AssessmentFlow, AssessmentItemSubmission, AssessmentResponseUpdate, AssessmentResponseValue, AssessmentResponses, AssessmentSaveResult, AssessmentScore, AssessmentStandardRef, AssessmentSubmitResult, ConventionalAssessmentAttemptSnapshot, ConventionalAssessmentSubmitResult, DiagnosticAssessmentItemReceipt, DiagnosticAssessmentSubmitResult, DiagnosticRoutingSnapshot, DiagnosticRoutingTrackSnapshot, ELevel, PlatformRoutedDiagnosticAttemptSnapshot, PlatformRoutedDiagnosticSelectionContext, PlayableAssessment, PlayableAssessmentChoice, PlayableAssessmentGraphic, PlayableAssessmentHotspot, PlayableAssessmentInteraction, PlayableAssessmentItem, PlayableContentNode, SaveAssessmentInput, StartAssessmentInput, StartDiagnosticAssessmentInput, SubmitAssessmentInput, SubmitAssessmentItemInput, SubmitAssessmentItemResult, SubmitDiagnosticAssessmentItemInput, SubmitDiagnosticAssessmentItemResult } from '@playcademy/types/timeback';
5
+ export { AssessmentAttemptSnapshot, AssessmentAwardRecord, AssessmentFinalizeResult, AssessmentFlow, AssessmentItemSubmission, AssessmentMasteryAward, AssessmentResponseUpdate, AssessmentResponseValue, AssessmentResponses, AssessmentSaveResult, AssessmentScore, AssessmentStandardRef, AssessmentSubmitResult, ConventionalAssessmentAttemptSnapshot, ConventionalAssessmentSubmitResult, DiagnosticAssessmentItemReceipt, DiagnosticAssessmentSubmitResult, DiagnosticRoutingSnapshot, DiagnosticRoutingTrackSnapshot, ELevel, FinalizeAssessmentInput, PlatformRoutedDiagnosticAttemptSnapshot, PlatformRoutedDiagnosticSelectionContext, PlayableAssessment, PlayableAssessmentAttemptSnapshot, PlayableAssessmentChoice, PlayableAssessmentGraphic, PlayableAssessmentHotspot, PlayableAssessmentInteraction, PlayableAssessmentItem, PlayableContentNode, SaveAssessmentInput, SettledAssessmentAttemptSnapshot, StartAssessmentInput, StartDiagnosticAssessmentInput, SubmitAssessmentInput, SubmitAssessmentItemInput, SubmitAssessmentItemResult, SubmitDiagnosticAssessmentItemInput, SubmitDiagnosticAssessmentItemResult } from '@playcademy/types/timeback';
6
6
  import { TimebackUserRole, UserEnrollment, UserOrganization, UserInfo } from '@playcademy/types/user';
7
7
  import { GamePermission, AUTH_PROVIDER_IDS } from '@playcademy/constants';
8
8
  import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
@@ -2020,6 +2020,7 @@ declare class PlaycademyClient extends PlaycademyBaseClient {
2020
2020
  save: (attemptId: string, input: _playcademy_types.SaveAssessmentInput) => Promise<_playcademy_types.AssessmentSaveResult>;
2021
2021
  submitItem: (attemptId: string, input: _playcademy_types.SubmitAssessmentItemInput) => Promise<_playcademy_types.SubmitAssessmentItemResult>;
2022
2022
  submit: (attemptId: string, input: _playcademy_types.SubmitAssessmentInput) => Promise<_playcademy_types.AssessmentSubmitResult>;
2023
+ finalize: (attemptId: string, input: _playcademy_types.FinalizeAssessmentInput) => Promise<_playcademy_types.AssessmentFinalizeResult>;
2023
2024
  };
2024
2025
  readonly user: TimebackUser;
2025
2026
  readonly currentRunId: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/sdk",
3
- "version": "0.17.0",
3
+ "version": "0.17.1-beta.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {