@playcademy/vite-plugin 0.2.22 → 0.2.23-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.
Files changed (2) hide show
  1. package/dist/index.js +71 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -25334,7 +25334,7 @@ var package_default;
25334
25334
  var init_package = __esm(() => {
25335
25335
  package_default = {
25336
25336
  name: "@playcademy/sandbox",
25337
- version: "0.3.16",
25337
+ version: "0.3.17-beta.1",
25338
25338
  description: "Local development server for Playcademy game development",
25339
25339
  type: "module",
25340
25340
  exports: {
@@ -54372,6 +54372,27 @@ class TimebackAdminService {
54372
54372
  const rounded = Math.round(value * TimebackAdminService.XP_PRECISION_FACTOR) / TimebackAdminService.XP_PRECISION_FACTOR;
54373
54373
  return Object.is(rounded, -0) ? 0 : rounded;
54374
54374
  }
54375
+ static toAttributionEventTime(date3) {
54376
+ if (!date3) {
54377
+ return;
54378
+ }
54379
+ const match = date3.match(/^(\d{4})-(\d{2})-(\d{2})$/);
54380
+ if (!match) {
54381
+ throw new ValidationError("Date must be in YYYY-MM-DD format");
54382
+ }
54383
+ const [, yearStr, monthStr, dayStr] = match;
54384
+ const year = Number(yearStr);
54385
+ const month = Number(monthStr);
54386
+ const day = Number(dayStr);
54387
+ if (!Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day)) {
54388
+ throw new ValidationError("Date must be in YYYY-MM-DD format");
54389
+ }
54390
+ const eventTime = new Date(Date.UTC(year, month - 1, day, 12, 0, 0));
54391
+ if (eventTime.getUTCFullYear() !== year || eventTime.getUTCMonth() + 1 !== month || eventTime.getUTCDate() !== day) {
54392
+ throw new ValidationError("Date must be a valid calendar date");
54393
+ }
54394
+ return eventTime.toISOString();
54395
+ }
54375
54396
  requireClient() {
54376
54397
  if (!this.deps.timeback) {
54377
54398
  logger16.error("Timeback client not available in context");
@@ -54447,7 +54468,6 @@ class TimebackAdminService {
54447
54468
  masteredUnitsForDay += masteredUnitsFromFact;
54448
54469
  }
54449
54470
  }
54450
- const roundedXpForDay = TimebackAdminService.roundXpToTenths(xpForDay);
54451
54471
  totalXpRaw += xpForDay;
54452
54472
  activeTimeSeconds += activeSecondsForDay;
54453
54473
  masteredUnits += masteredUnitsForDay;
@@ -54456,7 +54476,7 @@ class TimebackAdminService {
54456
54476
  }
54457
54477
  history.push({
54458
54478
  date: date3,
54459
- xpEarned: roundedXpForDay,
54479
+ xpEarned: TimebackAdminService.roundXpToTenths(xpForDay),
54460
54480
  activeTimeSeconds: activeSecondsForDay,
54461
54481
  masteredUnits: masteredUnitsForDay
54462
54482
  });
@@ -54770,6 +54790,7 @@ class TimebackAdminService {
54770
54790
  courseId: data.courseId,
54771
54791
  studentId: data.studentId,
54772
54792
  xpEarned: data.xp,
54793
+ eventTime: TimebackAdminService.toAttributionEventTime(data.date),
54773
54794
  reason: data.reason,
54774
54795
  actor,
54775
54796
  appName,
@@ -54784,6 +54805,7 @@ class TimebackAdminService {
54784
54805
  courseId: data.courseId,
54785
54806
  studentId: data.studentId,
54786
54807
  activeTimeSeconds: data.seconds,
54808
+ eventTime: TimebackAdminService.toAttributionEventTime(data.date),
54787
54809
  reason: data.reason,
54788
54810
  actor,
54789
54811
  appName,
@@ -54798,6 +54820,7 @@ class TimebackAdminService {
54798
54820
  courseId: data.courseId,
54799
54821
  studentId: data.studentId,
54800
54822
  masteredUnits: data.units,
54823
+ eventTime: TimebackAdminService.toAttributionEventTime(data.date),
54801
54824
  reason: data.reason,
54802
54825
  actor,
54803
54826
  appName,
@@ -58683,7 +58706,7 @@ function createCaliperNamespace(client) {
58683
58706
  "@context": CALIPER_CONSTANTS4.context,
58684
58707
  id: `urn:uuid:${crypto.randomUUID()}`,
58685
58708
  type: TIMEBACK_EVENT_TYPES4.timeSpentEvent,
58686
- eventTime: new Date().toISOString(),
58709
+ eventTime: data.eventTime || new Date().toISOString(),
58687
58710
  profile: CALIPER_CONSTANTS4.profile,
58688
58711
  actor: {
58689
58712
  id: urls.user(data.studentId),
@@ -59184,6 +59207,7 @@ class AdminEventRecorder {
59184
59207
  courseId: data.courseId,
59185
59208
  courseName: ctx.courseContext.courseName,
59186
59209
  xpEarned: data.xpEarned,
59210
+ eventTime: data.eventTime,
59187
59211
  subject: ctx.courseContext.subject,
59188
59212
  appName: ctx.appName,
59189
59213
  sensorUrl: ctx.sensorUrl,
@@ -59209,6 +59233,7 @@ class AdminEventRecorder {
59209
59233
  courseId: data.courseId,
59210
59234
  courseName: ctx.courseContext.courseName,
59211
59235
  activeTimeSeconds: data.activeTimeSeconds,
59236
+ eventTime: data.eventTime,
59212
59237
  subject: ctx.courseContext.subject,
59213
59238
  appName: ctx.appName,
59214
59239
  sensorUrl: ctx.sensorUrl,
@@ -59229,6 +59254,7 @@ class AdminEventRecorder {
59229
59254
  courseId: data.courseId,
59230
59255
  courseName: ctx.courseContext.courseName,
59231
59256
  masteredUnits: data.masteredUnits,
59257
+ eventTime: data.eventTime,
59232
59258
  subject: ctx.courseContext.subject,
59233
59259
  appName: ctx.appName,
59234
59260
  sensorUrl: ctx.sensorUrl,
@@ -119906,6 +119932,18 @@ function isTimebackGrade3(value) {
119906
119932
  function isTimebackSubject3(value) {
119907
119933
  return TIMEBACK_SUBJECTS5.includes(value);
119908
119934
  }
119935
+ function isValidAdminAttributionDate(value) {
119936
+ const match3 = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
119937
+ if (!match3) {
119938
+ return false;
119939
+ }
119940
+ const [, yearStr, monthStr, dayStr] = match3;
119941
+ const year3 = Number(yearStr);
119942
+ const month = Number(monthStr);
119943
+ const day = Number(dayStr);
119944
+ const date4 = new Date(Date.UTC(year3, month - 1, day, 12, 0, 0));
119945
+ return date4.getUTCFullYear() === year3 && date4.getUTCMonth() + 1 === month && date4.getUTCDate() === day;
119946
+ }
119909
119947
  var TIMEBACK_GRADES;
119910
119948
  var TIMEBACK_SUBJECTS5;
119911
119949
  var TimebackGradeSchema;
@@ -119917,6 +119955,7 @@ var DerivedPlatformCourseConfigSchema;
119917
119955
  var TimebackBaseConfigSchema;
119918
119956
  var PlatformTimebackSetupRequestSchema;
119919
119957
  var AdminTimebackMutationBaseSchema;
119958
+ var AdminAttributionDateSchema;
119920
119959
  var GrantTimebackXpRequestSchema;
119921
119960
  var AdjustTimebackTimeRequestSchema;
119922
119961
  var AdjustTimebackMasteryRequestSchema;
@@ -120030,14 +120069,32 @@ var init_schemas11 = __esm(() => {
120030
120069
  studentId: exports_external.string().min(1),
120031
120070
  reason: exports_external.string().min(1)
120032
120071
  });
120072
+ AdminAttributionDateSchema = exports_external.string().superRefine((value, ctx) => {
120073
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
120074
+ ctx.addIssue({
120075
+ code: exports_external.ZodIssueCode.custom,
120076
+ message: "Date must be in YYYY-MM-DD format"
120077
+ });
120078
+ return;
120079
+ }
120080
+ if (!isValidAdminAttributionDate(value)) {
120081
+ ctx.addIssue({
120082
+ code: exports_external.ZodIssueCode.custom,
120083
+ message: "Date must be a valid calendar date"
120084
+ });
120085
+ }
120086
+ });
120033
120087
  GrantTimebackXpRequestSchema = AdminTimebackMutationBaseSchema.extend({
120034
- xp: exports_external.number().min(-100, "Amount must be between -100 and 100").max(100, "Amount must be between -100 and 100").refine((value) => value !== 0, { message: "Amount cannot be 0" })
120088
+ xp: exports_external.number().min(-100, "Amount must be between -100 and 100").max(100, "Amount must be between -100 and 100").refine((value) => value !== 0, { message: "Amount cannot be 0" }),
120089
+ date: AdminAttributionDateSchema.optional()
120035
120090
  });
120036
120091
  AdjustTimebackTimeRequestSchema = AdminTimebackMutationBaseSchema.extend({
120037
- seconds: exports_external.number().refine((value) => value !== 0, { message: "Time amount cannot be 0" })
120092
+ seconds: exports_external.number().refine((value) => value !== 0, { message: "Time amount cannot be 0" }),
120093
+ date: AdminAttributionDateSchema.optional()
120038
120094
  });
120039
120095
  AdjustTimebackMasteryRequestSchema = AdminTimebackMutationBaseSchema.extend({
120040
- units: exports_external.number().refine((value) => value !== 0, { message: "Units cannot be 0" })
120096
+ units: exports_external.number().refine((value) => value !== 0, { message: "Units cannot be 0" }),
120097
+ date: AdminAttributionDateSchema.optional()
120041
120098
  });
120042
120099
  ToggleCourseCompletionRequestSchema = exports_external.object({
120043
120100
  gameId: exports_external.string().uuid(),
@@ -122516,7 +122573,8 @@ var init_timeback_controller = __esm(() => {
122516
122573
  gameId: body2.gameId,
122517
122574
  courseId: body2.courseId,
122518
122575
  studentId: body2.studentId,
122519
- xp: body2.xp
122576
+ xp: body2.xp,
122577
+ date: body2.date
122520
122578
  });
122521
122579
  return ctx.services.timebackAdmin.grantManualXp(body2, ctx.user);
122522
122580
  });
@@ -122527,7 +122585,8 @@ var init_timeback_controller = __esm(() => {
122527
122585
  gameId: body2.gameId,
122528
122586
  courseId: body2.courseId,
122529
122587
  studentId: body2.studentId,
122530
- seconds: body2.seconds
122588
+ seconds: body2.seconds,
122589
+ date: body2.date
122531
122590
  });
122532
122591
  return ctx.services.timebackAdmin.adjustTimeSpent(body2, ctx.user);
122533
122592
  });
@@ -122538,7 +122597,8 @@ var init_timeback_controller = __esm(() => {
122538
122597
  gameId: body2.gameId,
122539
122598
  courseId: body2.courseId,
122540
122599
  studentId: body2.studentId,
122541
- units: body2.units
122600
+ units: body2.units,
122601
+ date: body2.date
122542
122602
  });
122543
122603
  return ctx.services.timebackAdmin.adjustMasteredUnits(body2, ctx.user);
122544
122604
  });
@@ -125136,7 +125196,7 @@ var import_picocolors12 = __toESM(require_picocolors(), 1);
125136
125196
  // package.json
125137
125197
  var package_default2 = {
125138
125198
  name: "@playcademy/vite-plugin",
125139
- version: "0.2.22",
125199
+ version: "0.2.23-beta.1",
125140
125200
  type: "module",
125141
125201
  exports: {
125142
125202
  ".": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/vite-plugin",
3
- "version": "0.2.22",
3
+ "version": "0.2.23-beta.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {