playcademy 0.15.3 → 0.15.5

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/cli.js CHANGED
@@ -2965,7 +2965,7 @@ import { join as join13 } from "path";
2965
2965
  // package.json with { type: 'json' }
2966
2966
  var package_default2 = {
2967
2967
  name: "playcademy",
2968
- version: "0.15.2",
2968
+ version: "0.15.4",
2969
2969
  type: "module",
2970
2970
  exports: {
2971
2971
  ".": {
@@ -17,6 +17,17 @@ import type { HonoEnv } from '../../../types'
17
17
  * their own backend infrastructure. The SDK handles config enrichment and metadata.
18
18
  */
19
19
 
20
+ /** Valid grade levels: -1 (Pre-K), 0 (Kindergarten), 1-12 (Grades), 13 (AP) */
21
+ const VALID_GRADES = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] as const
22
+
23
+ function isValidGrade(value: unknown): value is (typeof VALID_GRADES)[number] {
24
+ return (
25
+ typeof value === 'number' &&
26
+ Number.isInteger(value) &&
27
+ VALID_GRADES.includes(value as (typeof VALID_GRADES)[number])
28
+ )
29
+ }
30
+
20
31
  function getConfig(c: Context<HonoEnv>): PlaycademyConfig {
21
32
  const config = c.get('config')
22
33
  const timebackConfig = config?.integrations?.timeback
@@ -33,8 +44,8 @@ function validateRequestBody(body: {
33
44
  if (!body.activityData?.activityId) {
34
45
  return { error: 'activityId is required' }
35
46
  }
36
- if (!body.activityData?.grade) {
37
- return { error: 'grade is required' }
47
+ if (!isValidGrade(body.activityData?.grade)) {
48
+ return { error: `grade must be a valid grade level (${VALID_GRADES.join(', ')})` }
38
49
  }
39
50
  if (!body.activityData?.subject) {
40
51
  return { error: 'subject is required' }
package/dist/index.js CHANGED
@@ -3610,17 +3610,15 @@ ${indent(level)}integrations: {`];
3610
3610
  function getSlugFromConfig(config) {
3611
3611
  return generateSlug(config.name);
3612
3612
  }
3613
+ async function getGameBySlug(client, slug) {
3614
+ const games2 = await client.games.list();
3615
+ return games2.find((g) => g.slug === slug) ?? null;
3616
+ }
3613
3617
  async function ensureGameExists(client, config) {
3614
3618
  const slug = getSlugFromConfig(config);
3615
3619
  let game = await runStep(
3616
3620
  `Checking for app "${slug}"`,
3617
- async () => {
3618
- try {
3619
- return await client.games.fetch(slug);
3620
- } catch {
3621
- return null;
3622
- }
3623
- },
3621
+ () => getGameBySlug(client, slug),
3624
3622
  (result) => result ? "Found existing app" : "App not found"
3625
3623
  );
3626
3624
  if (!game) {
@@ -3649,16 +3647,34 @@ async function getGameFromConfig(client) {
3649
3647
  const game = await runStep(
3650
3648
  `Finding app "${slug}"`,
3651
3649
  async () => {
3652
- try {
3653
- return await client.games.fetch(slug);
3654
- } catch {
3650
+ const found = await getGameBySlug(client, slug);
3651
+ if (!found) {
3655
3652
  throw new Error(`App "${slug}" not found`);
3656
3653
  }
3654
+ return found;
3657
3655
  },
3658
3656
  "App found"
3659
3657
  );
3660
3658
  return { game, config };
3661
3659
  }
3660
+ async function getGameById(client, gameId, options) {
3661
+ const games2 = await client.games.list();
3662
+ const game = games2.find((g) => g.id === gameId);
3663
+ if (!game) {
3664
+ if (options?.noExit) {
3665
+ return null;
3666
+ }
3667
+ if (!options?.silent) {
3668
+ logger.newLine();
3669
+ logger.admonition("warning", "Game Not Found", [
3670
+ `Could not find game with ID: ${gameId}`
3671
+ ]);
3672
+ logger.newLine();
3673
+ }
3674
+ process.exit(1);
3675
+ }
3676
+ return game;
3677
+ }
3662
3678
 
3663
3679
  // src/lib/core/gitignore.ts
3664
3680
  import { existsSync as existsSync6, readFileSync as readFileSync3 } from "fs";
@@ -3960,7 +3976,7 @@ import { join as join12 } from "path";
3960
3976
  // package.json with { type: 'json' }
3961
3977
  var package_default2 = {
3962
3978
  name: "playcademy",
3963
- version: "0.15.2",
3979
+ version: "0.15.4",
3964
3980
  type: "module",
3965
3981
  exports: {
3966
3982
  ".": {
@@ -10609,7 +10625,7 @@ var getStatusCommand = new Command13("status").description("Check your developer
10609
10625
  });
10610
10626
 
10611
10627
  // package.json
10612
- var version2 = "0.15.2";
10628
+ var version2 = "0.15.4";
10613
10629
 
10614
10630
  // src/commands/dev/server.ts
10615
10631
  function setupCleanupHandlers(workspace, getServer) {
@@ -11135,7 +11151,7 @@ async function runDbResetRemote(options) {
11135
11151
  logger.newLine();
11136
11152
  process.exit(1);
11137
11153
  }
11138
- const game = await client.games.fetch(deployedGame.gameId);
11154
+ const game = await getGameById(client, deployedGame.gameId);
11139
11155
  logger.newLine();
11140
11156
  logger.admonition("warning", "DESTRUCTIVE OPERATION", [
11141
11157
  `Are you sure you want to ${redBright4(underline3(bold13("DELETE ALL DATA")))} in your ${environment} database?`,
@@ -11346,7 +11362,7 @@ async function runDbSeedRemote(seedFile, options) {
11346
11362
  logger.newLine();
11347
11363
  process.exit(1);
11348
11364
  }
11349
- const game = await client.games.fetch(deployedGame.gameId);
11365
+ const game = await getGameById(client, deployedGame.gameId);
11350
11366
  const willReset = options.reset !== false;
11351
11367
  logger.newLine();
11352
11368
  if (willReset) {
@@ -12562,7 +12578,9 @@ async function runBucketBulkRemote(directory, options) {
12562
12578
  outputDryRunResults(files, totalSize, options.prefix, options.json, options.raw);
12563
12579
  return;
12564
12580
  }
12565
- const game = await client.games.fetch(deployedGame.gameId);
12581
+ const game = await getGameById(client, deployedGame.gameId, {
12582
+ silent: options.raw || options.json
12583
+ });
12566
12584
  const uploaded = await uploadFilesRemote(
12567
12585
  files,
12568
12586
  game.slug,
@@ -12691,7 +12709,9 @@ async function runBucketDeleteRemote(key, options) {
12691
12709
  }
12692
12710
  process.exit(1);
12693
12711
  }
12694
- const game = await client.games.fetch(deployedGame.gameId);
12712
+ const game = await getGameById(client, deployedGame.gameId, {
12713
+ silent: options.raw || options.json
12714
+ });
12695
12715
  await client.dev.games.bucket.delete(game.slug, key);
12696
12716
  if (options.json) {
12697
12717
  logger.json({
@@ -12810,7 +12830,9 @@ async function runBucketGetRemote(key, options) {
12810
12830
  }
12811
12831
  process.exit(1);
12812
12832
  }
12813
- const game = await client.games.fetch(deployedGame.gameId);
12833
+ const game = await getGameById(client, deployedGame.gameId, {
12834
+ silent: options.raw || options.json
12835
+ });
12814
12836
  let arrayBuffer;
12815
12837
  try {
12816
12838
  arrayBuffer = await client.dev.games.bucket.get(game.slug, key);
@@ -13060,7 +13082,9 @@ async function runBucketListRemote(options) {
13060
13082
  }
13061
13083
  process.exit(1);
13062
13084
  }
13063
- const game = await client.games.fetch(deployedGame.gameId);
13085
+ const game = await getGameById(client, deployedGame.gameId, {
13086
+ silent: options.raw || options.json
13087
+ });
13064
13088
  const files = await client.dev.games.bucket.list(game.slug, options.prefix);
13065
13089
  if (options.json) {
13066
13090
  logger.json(files);
@@ -13225,7 +13249,9 @@ async function runBucketPutRemote(key, filePath, options) {
13225
13249
  }
13226
13250
  process.exit(1);
13227
13251
  }
13228
- const game = await client.games.fetch(deployedGame.gameId);
13252
+ const game = await getGameById(client, deployedGame.gameId, {
13253
+ silent: options.raw || options.json
13254
+ });
13229
13255
  const contentType = getContentType(filePath);
13230
13256
  await client.dev.games.bucket.put(game.slug, key, fileBuffer, contentType);
13231
13257
  if (options.json) {
@@ -14470,6 +14496,7 @@ export {
14470
14496
  getEnvironment,
14471
14497
  getErrorMessage,
14472
14498
  getFrameworksForEngine,
14499
+ getGameById,
14473
14500
  getGameFromConfig,
14474
14501
  getGamesStorePath,
14475
14502
  getIntegrationKeys,
package/dist/utils.js CHANGED
@@ -2321,7 +2321,7 @@ import { join as join12 } from "path";
2321
2321
  // package.json with { type: 'json' }
2322
2322
  var package_default2 = {
2323
2323
  name: "playcademy",
2324
- version: "0.15.2",
2324
+ version: "0.15.4",
2325
2325
  type: "module",
2326
2326
  exports: {
2327
2327
  ".": {
package/dist/version.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // package.json with { type: 'json' }
2
2
  var package_default = {
3
3
  name: "playcademy",
4
- version: "0.15.2",
4
+ version: "0.15.4",
5
5
  type: "module",
6
6
  exports: {
7
7
  ".": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playcademy",
3
- "version": "0.15.3",
3
+ "version": "0.15.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {