@playcademy/vite-plugin 0.1.36 → 0.1.37
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.js +98 -41
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -41199,7 +41199,7 @@ var import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
|
41199
41199
|
// package.json
|
|
41200
41200
|
var package_default = {
|
|
41201
41201
|
name: "@playcademy/vite-plugin",
|
|
41202
|
-
version: "0.1.
|
|
41202
|
+
version: "0.1.36",
|
|
41203
41203
|
type: "module",
|
|
41204
41204
|
exports: {
|
|
41205
41205
|
".": {
|
|
@@ -189515,7 +189515,9 @@ var init_constants = __esm3(() => {
|
|
|
189515
189515
|
studentTTL: 600000,
|
|
189516
189516
|
studentMaxSize: 500,
|
|
189517
189517
|
assessmentTTL: 1800000,
|
|
189518
|
-
assessmentMaxSize: 200
|
|
189518
|
+
assessmentMaxSize: 200,
|
|
189519
|
+
enrollmentTTL: 5000,
|
|
189520
|
+
enrollmentMaxSize: 100
|
|
189519
189521
|
};
|
|
189520
189522
|
CONFIG_DEFAULTS = {
|
|
189521
189523
|
fileNames: ["timeback.config.js", "timeback.config.json"]
|
|
@@ -189733,6 +189735,25 @@ class ResourceNotFoundError extends TimebackError {
|
|
|
189733
189735
|
Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
|
|
189734
189736
|
}
|
|
189735
189737
|
}
|
|
189738
|
+
init_constants();
|
|
189739
|
+
var isObject2 = (value) => typeof value === "object" && value !== null;
|
|
189740
|
+
var SUBJECT_VALUES = TIMEBACK_SUBJECTS;
|
|
189741
|
+
var GRADE_VALUES = TIMEBACK_GRADE_LEVELS;
|
|
189742
|
+
function isPlaycademyResourceMetadata(value) {
|
|
189743
|
+
if (!isObject2(value)) {
|
|
189744
|
+
return false;
|
|
189745
|
+
}
|
|
189746
|
+
if (!("mastery" in value) || value.mastery === undefined) {
|
|
189747
|
+
return true;
|
|
189748
|
+
}
|
|
189749
|
+
return isObject2(value.mastery);
|
|
189750
|
+
}
|
|
189751
|
+
function isTimebackSubject(value) {
|
|
189752
|
+
return typeof value === "string" && SUBJECT_VALUES.includes(value);
|
|
189753
|
+
}
|
|
189754
|
+
function isTimebackGrade(value) {
|
|
189755
|
+
return typeof value === "number" && Number.isInteger(value) && GRADE_VALUES.includes(value);
|
|
189756
|
+
}
|
|
189736
189757
|
var isBrowser2 = () => {
|
|
189737
189758
|
const g52 = globalThis;
|
|
189738
189759
|
return typeof g52.window !== "undefined" && typeof g52.document !== "undefined";
|
|
@@ -190857,6 +190878,7 @@ class TimebackCacheManager {
|
|
|
190857
190878
|
studentCache;
|
|
190858
190879
|
assessmentLineItemCache;
|
|
190859
190880
|
resourceMasteryCache;
|
|
190881
|
+
enrollmentCache;
|
|
190860
190882
|
constructor() {
|
|
190861
190883
|
this.studentCache = new TimebackCache({
|
|
190862
190884
|
defaultTTL: CACHE_DEFAULTS.studentTTL,
|
|
@@ -190873,6 +190895,11 @@ class TimebackCacheManager {
|
|
|
190873
190895
|
maxSize: CACHE_DEFAULTS.assessmentMaxSize,
|
|
190874
190896
|
name: "ResourceMasteryCache"
|
|
190875
190897
|
});
|
|
190898
|
+
this.enrollmentCache = new TimebackCache({
|
|
190899
|
+
defaultTTL: CACHE_DEFAULTS.enrollmentTTL,
|
|
190900
|
+
maxSize: CACHE_DEFAULTS.enrollmentMaxSize,
|
|
190901
|
+
name: "EnrollmentCache"
|
|
190902
|
+
});
|
|
190876
190903
|
}
|
|
190877
190904
|
getStudent(key) {
|
|
190878
190905
|
return this.studentCache.get(key);
|
|
@@ -190892,37 +190919,36 @@ class TimebackCacheManager {
|
|
|
190892
190919
|
setResourceMasterableUnits(key, value) {
|
|
190893
190920
|
this.resourceMasteryCache.set(key, value);
|
|
190894
190921
|
}
|
|
190922
|
+
getEnrollments(studentId) {
|
|
190923
|
+
return this.enrollmentCache.get(studentId);
|
|
190924
|
+
}
|
|
190925
|
+
setEnrollments(studentId, enrollments) {
|
|
190926
|
+
this.enrollmentCache.set(studentId, enrollments);
|
|
190927
|
+
}
|
|
190895
190928
|
clearAll() {
|
|
190896
190929
|
this.studentCache.clear();
|
|
190897
190930
|
this.assessmentLineItemCache.clear();
|
|
190931
|
+
this.resourceMasteryCache.clear();
|
|
190932
|
+
this.enrollmentCache.clear();
|
|
190898
190933
|
log32.info("[TimebackCacheManager] All caches cleared");
|
|
190899
190934
|
}
|
|
190900
190935
|
getStats() {
|
|
190901
190936
|
return {
|
|
190902
190937
|
studentCache: this.studentCache.stats(),
|
|
190903
190938
|
assessmentLineItemCache: this.assessmentLineItemCache.stats(),
|
|
190904
|
-
resourceMasteryCache: this.resourceMasteryCache.stats()
|
|
190939
|
+
resourceMasteryCache: this.resourceMasteryCache.stats(),
|
|
190940
|
+
enrollmentCache: this.enrollmentCache.stats()
|
|
190905
190941
|
};
|
|
190906
190942
|
}
|
|
190907
190943
|
cleanup() {
|
|
190908
190944
|
this.studentCache.cleanup();
|
|
190909
190945
|
this.assessmentLineItemCache.cleanup();
|
|
190910
190946
|
this.resourceMasteryCache.cleanup();
|
|
190947
|
+
this.enrollmentCache.cleanup();
|
|
190911
190948
|
log32.debug("[TimebackCacheManager] Cache cleanup completed");
|
|
190912
190949
|
}
|
|
190913
190950
|
}
|
|
190914
190951
|
init_constants();
|
|
190915
|
-
init_constants();
|
|
190916
|
-
var isObject2 = (value) => typeof value === "object" && value !== null;
|
|
190917
|
-
function isPlaycademyResourceMetadata(value) {
|
|
190918
|
-
if (!isObject2(value)) {
|
|
190919
|
-
return false;
|
|
190920
|
-
}
|
|
190921
|
-
if (!("mastery" in value) || value.mastery === undefined) {
|
|
190922
|
-
return true;
|
|
190923
|
-
}
|
|
190924
|
-
return isObject2(value.mastery);
|
|
190925
|
-
}
|
|
190926
190952
|
|
|
190927
190953
|
class MasteryTracker {
|
|
190928
190954
|
cacheManager;
|
|
@@ -194030,9 +194056,9 @@ class ZodUnion2 extends ZodType2 {
|
|
|
194030
194056
|
return this._def.options;
|
|
194031
194057
|
}
|
|
194032
194058
|
}
|
|
194033
|
-
ZodUnion2.create = (
|
|
194059
|
+
ZodUnion2.create = (types22, params) => {
|
|
194034
194060
|
return new ZodUnion2({
|
|
194035
|
-
options:
|
|
194061
|
+
options: types22,
|
|
194036
194062
|
typeName: ZodFirstPartyTypeKind2.ZodUnion,
|
|
194037
194063
|
...processCreateParams2(params)
|
|
194038
194064
|
});
|
|
@@ -195536,18 +195562,27 @@ class TimebackClient {
|
|
|
195536
195562
|
await this._ensureAuthenticated();
|
|
195537
195563
|
return this.sessionRecorder.record(courseId, studentIdentifier, sessionData);
|
|
195538
195564
|
}
|
|
195539
|
-
async getEnrollments(studentId
|
|
195565
|
+
async getEnrollments(studentId) {
|
|
195566
|
+
const cached = this.cacheManager.getEnrollments(studentId);
|
|
195567
|
+
if (cached) {
|
|
195568
|
+
return cached;
|
|
195569
|
+
}
|
|
195540
195570
|
await this._ensureAuthenticated();
|
|
195541
|
-
const
|
|
195542
|
-
|
|
195543
|
-
|
|
195544
|
-
|
|
195545
|
-
|
|
195546
|
-
|
|
195547
|
-
|
|
195548
|
-
|
|
195549
|
-
|
|
195550
|
-
|
|
195571
|
+
const edubridgeEnrollments = await this.edubridge.enrollments.listByUser(studentId);
|
|
195572
|
+
const enrollments = edubridgeEnrollments.map((enrollment) => {
|
|
195573
|
+
const grades = enrollment.course.grades ? enrollment.course.grades.map((g52) => parseInt(g52, 10)).filter(isTimebackGrade) : null;
|
|
195574
|
+
const subjects = enrollment.course.subjects ? enrollment.course.subjects.filter(isTimebackSubject) : null;
|
|
195575
|
+
return {
|
|
195576
|
+
sourcedId: enrollment.id,
|
|
195577
|
+
title: enrollment.course.title,
|
|
195578
|
+
courseId: enrollment.course.id,
|
|
195579
|
+
status: "active",
|
|
195580
|
+
grades,
|
|
195581
|
+
subjects
|
|
195582
|
+
};
|
|
195583
|
+
});
|
|
195584
|
+
this.cacheManager.setEnrollments(studentId, enrollments);
|
|
195585
|
+
return enrollments;
|
|
195551
195586
|
}
|
|
195552
195587
|
clearCaches() {
|
|
195553
195588
|
this.cacheManager.clearAll();
|
|
@@ -195786,7 +195821,9 @@ var init_constants2 = __esm4(() => {
|
|
|
195786
195821
|
studentTTL: 600000,
|
|
195787
195822
|
studentMaxSize: 500,
|
|
195788
195823
|
assessmentTTL: 1800000,
|
|
195789
|
-
assessmentMaxSize: 200
|
|
195824
|
+
assessmentMaxSize: 200,
|
|
195825
|
+
enrollmentTTL: 5000,
|
|
195826
|
+
enrollmentMaxSize: 100
|
|
195790
195827
|
};
|
|
195791
195828
|
CONFIG_DEFAULTS2 = {
|
|
195792
195829
|
fileNames: ["timeback.config.js", "timeback.config.json"]
|
|
@@ -195854,8 +195891,8 @@ var init_constants2 = __esm4(() => {
|
|
|
195854
195891
|
});
|
|
195855
195892
|
init_constants2();
|
|
195856
195893
|
var isObject3 = (value) => typeof value === "object" && value !== null;
|
|
195857
|
-
var
|
|
195858
|
-
var
|
|
195894
|
+
var SUBJECT_VALUES2 = TIMEBACK_SUBJECTS2;
|
|
195895
|
+
var GRADE_VALUES2 = TIMEBACK_GRADE_LEVELS2;
|
|
195859
195896
|
function isCourseMetadata(value) {
|
|
195860
195897
|
return isObject3(value);
|
|
195861
195898
|
}
|
|
@@ -195871,11 +195908,11 @@ function isPlaycademyResourceMetadata2(value) {
|
|
|
195871
195908
|
}
|
|
195872
195909
|
return isObject3(value.mastery);
|
|
195873
195910
|
}
|
|
195874
|
-
function
|
|
195875
|
-
return typeof value === "string" &&
|
|
195911
|
+
function isTimebackSubject2(value) {
|
|
195912
|
+
return typeof value === "string" && SUBJECT_VALUES2.includes(value);
|
|
195876
195913
|
}
|
|
195877
|
-
function
|
|
195878
|
-
return typeof value === "number" && Number.isInteger(value) &&
|
|
195914
|
+
function isTimebackGrade2(value) {
|
|
195915
|
+
return typeof value === "number" && Number.isInteger(value) && GRADE_VALUES2.includes(value);
|
|
195879
195916
|
}
|
|
195880
195917
|
var UUID_REGEX = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
195881
195918
|
function isValidUUID(value) {
|
|
@@ -209999,11 +210036,11 @@ async function setupTimebackIntegration(ctx) {
|
|
|
209999
210036
|
totalXp: derivedTotalXp,
|
|
210000
210037
|
masterableUnits: derivedMasterableUnits
|
|
210001
210038
|
} = courseConfig;
|
|
210002
|
-
if (!
|
|
210039
|
+
if (!isTimebackSubject2(subject)) {
|
|
210003
210040
|
log2.error("[API] Invalid subject in TimeBack request", { subject });
|
|
210004
210041
|
throw ApiError.badRequest(`Invalid subject "${subject}" provided for course "${title}".`);
|
|
210005
210042
|
}
|
|
210006
|
-
if (!
|
|
210043
|
+
if (!isTimebackGrade2(grade)) {
|
|
210007
210044
|
log2.error("[API] Invalid grade in TimeBack request", { grade });
|
|
210008
210045
|
throw ApiError.badRequest(`Invalid grade "${grade}" provided for course "${title}".`);
|
|
210009
210046
|
}
|
|
@@ -210399,14 +210436,34 @@ async function getStudentEnrollments(ctx) {
|
|
|
210399
210436
|
if (!timebackId) {
|
|
210400
210437
|
throw ApiError.badRequest("Missing timebackId parameter");
|
|
210401
210438
|
}
|
|
210439
|
+
const db = getDatabase();
|
|
210440
|
+
const isLocal = process.env.PUBLIC_IS_LOCAL === "true";
|
|
210441
|
+
if (isLocal) {
|
|
210442
|
+
log2.debug("[API] Local mode: returning all integrations as mock enrollments", {
|
|
210443
|
+
userId: user.id,
|
|
210444
|
+
timebackId
|
|
210445
|
+
});
|
|
210446
|
+
const allIntegrations = await db.query.gameTimebackIntegrations.findMany();
|
|
210447
|
+
const enrollments2 = allIntegrations.map((integration) => ({
|
|
210448
|
+
gameId: integration.gameId,
|
|
210449
|
+
grade: integration.grade,
|
|
210450
|
+
subject: integration.subject,
|
|
210451
|
+
courseId: integration.courseId
|
|
210452
|
+
}));
|
|
210453
|
+
log2.info("[API] Retrieved mock enrollments (local mode)", {
|
|
210454
|
+
userId: user.id,
|
|
210455
|
+
timebackId,
|
|
210456
|
+
enrollmentCount: enrollments2.length
|
|
210457
|
+
});
|
|
210458
|
+
return { enrollments: enrollments2 };
|
|
210459
|
+
}
|
|
210402
210460
|
log2.debug("[API] Getting student enrollments", { userId: user.id, timebackId });
|
|
210403
210461
|
const client2 = await getTimebackClient();
|
|
210404
|
-
const classes = await client2.getEnrollments(timebackId
|
|
210462
|
+
const classes = await client2.getEnrollments(timebackId);
|
|
210405
210463
|
const courseIds = classes.map((cls) => cls.courseId).filter((id) => Boolean(id));
|
|
210406
210464
|
if (courseIds.length === 0) {
|
|
210407
210465
|
return { enrollments: [] };
|
|
210408
210466
|
}
|
|
210409
|
-
const db = getDatabase();
|
|
210410
210467
|
const integrations = await db.query.gameTimebackIntegrations.findMany({
|
|
210411
210468
|
where: inArray(gameTimebackIntegrations.courseId, courseIds)
|
|
210412
210469
|
});
|
|
@@ -210614,11 +210671,11 @@ timebackRouter.post("/end-activity", async (c3) => {
|
|
|
210614
210671
|
return c3.json(createUnknownErrorResponse(error2), 500);
|
|
210615
210672
|
}
|
|
210616
210673
|
});
|
|
210617
|
-
timebackRouter.get("/enrollments/:
|
|
210618
|
-
const
|
|
210674
|
+
timebackRouter.get("/enrollments/:timebackId", async (c3) => {
|
|
210675
|
+
const timebackId = c3.req.param("timebackId");
|
|
210619
210676
|
const ctx = {
|
|
210620
210677
|
user: c3.get("user"),
|
|
210621
|
-
params: {
|
|
210678
|
+
params: { timebackId },
|
|
210622
210679
|
url: new URL(c3.req.url),
|
|
210623
210680
|
request: c3.req.raw
|
|
210624
210681
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcademy/vite-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"archiver": "^7.0.1",
|
|
23
23
|
"picocolors": "^1.1.1",
|
|
24
|
-
"playcademy": "0.14.
|
|
24
|
+
"playcademy": "0.14.24"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@inquirer/prompts": "^7.8.6",
|