recess-cli 3.43.0 → 3.45.0

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/api.js CHANGED
@@ -233,6 +233,37 @@ export class RecessAdminApi {
233
233
  throw apiError(response.status, body);
234
234
  return body;
235
235
  }
236
+ /** File a full MAP report PDF (e.g. Learning Statements) for one season. */
237
+ async uploadMapTestReport(studentId, query, pdf, fileName) {
238
+ this.requireAuth();
239
+ const formData = new FormData();
240
+ const pdfBody = new Uint8Array(pdf.byteLength);
241
+ pdfBody.set(pdf);
242
+ formData.append("file", new Blob([pdfBody.buffer], { type: "application/pdf" }), fileName);
243
+ const headers = cliRequestHeaders({ cookie: this.config.sessionCookie }, this.reason, this.clientTag);
244
+ applyIdempotencyHeaders(headers);
245
+ const url = new URL(`/tutor/students/${encodeURIComponent(studentId)}/map-test-reports`, this.config.apiOrigin);
246
+ for (const [key, value] of Object.entries(query)) {
247
+ if (value !== undefined)
248
+ url.searchParams.set(key, String(value));
249
+ }
250
+ const response = await fetch(url, {
251
+ method: "POST",
252
+ headers,
253
+ body: formData,
254
+ });
255
+ const text = await response.text();
256
+ let body = text;
257
+ try {
258
+ body = text ? JSON.parse(text) : null;
259
+ }
260
+ catch {
261
+ // Preserve a non-JSON API response as text.
262
+ }
263
+ if (!response.ok)
264
+ throw apiError(response.status, body);
265
+ return body;
266
+ }
236
267
  /** The packet's tuition agreement as a PDF, to sign by hand. */
237
268
  async downloadAdmissionContract(packetId, optionId) {
238
269
  this.requireAuth();
package/dist/cli.js CHANGED
@@ -19,6 +19,7 @@ import { runChallengeOfTheWeekCommand } from "./commands/challenge-of-the-week.j
19
19
  import { runDbCommand } from "./commands/db.js";
20
20
  import { runRoomsCommand } from "./commands/rooms.js";
21
21
  import { runDmsCommand } from "./commands/dms.js";
22
+ import { runChangelogCommand } from "./commands/changelog.js";
22
23
  import { runFeedCommand } from "./commands/feed.js";
23
24
  import { runFamiliesCommand } from "./commands/families.js";
24
25
  import { runFamilyCommand, runKidCommand, runMeCommand, } from "./commands/family.js";
@@ -1290,6 +1291,8 @@ const SCHOOL_TIER_IDS = SCHOOL_TIER_OPTIONS.map((tier) => tier.id);
1290
1291
  // own paths. The server's POST /admin/users/change-role/ enforces the same set.
1291
1292
  const RESTORABLE_ROLES = ["KID", "GUARDIAN", "GUIDE", "PROGRAM"];
1292
1293
  const MAX_MAP_PDF_BYTES = 15 * 1024 * 1024;
1294
+ /** `students map-reports upload`: the report route + MAP_REPORT policy cap. */
1295
+ const MAX_MAP_REPORT_PDF_BYTES = 32 * 1024 * 1024;
1293
1296
  const GOAL_TEMPLATE_KINDS = ["SIMPLE", "BLUEPRINT"];
1294
1297
  const GOAL_TEMPLATE_SETUP_AUDIENCES = ["KID_FRIENDLY", "PARENT_SETUP"];
1295
1298
  const STORE_ITEM_STATUSES = ["ACTIVE", "INACTIVE", "COMING_SOON"];
@@ -1943,7 +1946,16 @@ async function resolveExpectedTemplateVersion(api, parsed, templateId, recovered
1943
1946
  return { expectedVersion: current.version, pinnedFrom: "current" };
1944
1947
  }
1945
1948
  const PINNED_VERSION_NOTE = "--expected-version was omitted, so the version read at preview is pinned: a template change before confirm changes this preview and the confirm is refused. Retrying after a landed write needs --expected-version <the previewed version>.";
1946
- async function readMapScorePdf(filePath) {
1949
+ const MAP_REPORT_SUBJECTS = [
1950
+ "MATH",
1951
+ "READING",
1952
+ "LANGUAGE_USAGE",
1953
+ "SCIENCE",
1954
+ "OTHER",
1955
+ ];
1956
+ const MAP_REPORT_SEASONS = ["FALL", "WINTER", "SPRING", "SUMMER"];
1957
+ const MAP_REPORT_KINDS = ["LEARNING_STATEMENTS", "OTHER"];
1958
+ async function readMapScorePdf(filePath, maxBytes = MAX_MAP_PDF_BYTES) {
1947
1959
  const absolutePath = path.resolve(filePath);
1948
1960
  if (path.extname(absolutePath).toLowerCase() !== ".pdf") {
1949
1961
  throw new CliError("invalid_arguments", "--file must point to a PDF report.");
@@ -1964,8 +1976,8 @@ async function readMapScorePdf(filePath) {
1964
1976
  if (stat.size === 0) {
1965
1977
  throw new CliError("invalid_arguments", "MAP score PDF is empty.");
1966
1978
  }
1967
- if (stat.size > MAX_MAP_PDF_BYTES) {
1968
- throw new CliError("invalid_arguments", "MAP score PDF exceeds the 15 MB upload limit.");
1979
+ if (stat.size > maxBytes) {
1980
+ throw new CliError("invalid_arguments", `MAP PDF exceeds the ${Math.round(maxBytes / 1024 / 1024)} MB upload limit.`);
1969
1981
  }
1970
1982
  const bytes = await fs.readFile(absolutePath);
1971
1983
  return {
@@ -3571,6 +3583,48 @@ export async function executeRecessCommand(argv, options = {}) {
3571
3583
  },
3572
3584
  }, () => api.uploadMapTestScores(studentId, pdf.bytes, pdf.fileName));
3573
3585
  }
3586
+ if (noun === "students" && verb === "map-reports") {
3587
+ const action = parsed.positionals[2];
3588
+ const studentId = flagString(parsed, "student", { required: true });
3589
+ if (action === "list") {
3590
+ return unwrap(await api.client.GET("/tutor/students/{studentId}/map-test-reports", {
3591
+ params: { path: { studentId } },
3592
+ }));
3593
+ }
3594
+ if (action === "upload") {
3595
+ const subject = assertChoice(flagString(parsed, "subject", { required: true }).toUpperCase(), MAP_REPORT_SUBJECTS, "--subject");
3596
+ const season = assertChoice(flagString(parsed, "season", { required: true }).toUpperCase(), MAP_REPORT_SEASONS, "--season");
3597
+ const schoolYear = flagString(parsed, "school-year", { required: true });
3598
+ if (!/^\d{4}-\d{4}$/.test(schoolYear)) {
3599
+ throw new CliError("invalid_arguments", '--school-year must look like "2025-2026".');
3600
+ }
3601
+ const kind = assertChoice((flagString(parsed, "kind") ?? "learning-statements")
3602
+ .toUpperCase()
3603
+ .replace(/-/g, "_"), MAP_REPORT_KINDS, "--kind");
3604
+ const pdf = await readMapScorePdf(flagString(parsed, "file", { required: true }), MAX_MAP_REPORT_PDF_BYTES);
3605
+ const query = { kind, subject, season, schoolYear };
3606
+ return writeCommand(parsed, {
3607
+ action: "file a full MAP report PDF beside this season's scores (parents, the kid, and their guides can open it; replaces any existing report for the same subject + season)",
3608
+ target: { studentId },
3609
+ request: {
3610
+ ...query,
3611
+ file: pdf.absolutePath,
3612
+ fileName: pdf.fileName,
3613
+ sizeBytes: pdf.bytes.byteLength,
3614
+ sha256: pdf.sha256,
3615
+ },
3616
+ }, () => api.uploadMapTestReport(studentId, query, pdf.bytes, pdf.fileName));
3617
+ }
3618
+ if (action === "delete") {
3619
+ const reportId = flagString(parsed, "report", { required: true });
3620
+ return writeCommand(parsed, {
3621
+ action: "remove a filed MAP report PDF from the kid's dashboard",
3622
+ target: { studentId, reportId },
3623
+ request: {},
3624
+ }, async () => unwrap(await api.client.DELETE("/tutor/students/{studentId}/map-test-reports/{reportId}", { params: { path: { studentId, reportId } } })));
3625
+ }
3626
+ throw new CliError("invalid_arguments", "Use students map-reports list|upload|delete.");
3627
+ }
3574
3628
  if (noun === "enrollments" && verb === "list") {
3575
3629
  const userId = flagString(parsed, "user", { required: true });
3576
3630
  const data = unwrap(await api.client.GET("/admin/users/operations-search", {
@@ -6277,6 +6331,9 @@ export async function executeRecessCommand(argv, options = {}) {
6277
6331
  if (noun === "feed") {
6278
6332
  return runFeedCommand({ parsed, api, writeCommand });
6279
6333
  }
6334
+ if (noun === "changelog") {
6335
+ return runChangelogCommand({ parsed, api, writeCommand });
6336
+ }
6280
6337
  if (noun === "dms") {
6281
6338
  return runDmsCommand({ parsed, api, writeCommand });
6282
6339
  }
@@ -6524,7 +6581,7 @@ export async function executeRecessCommand(argv, options = {}) {
6524
6581
  return { studentId, flashcardReviewEnabled: on };
6525
6582
  });
6526
6583
  }
6527
- throw new CliError("invalid_arguments", "Use students list|today|schedule|todos|analysis|xp-history|mastery|upload-map-scores|issue-email|goblins|web-todos|flashcards.");
6584
+ throw new CliError("invalid_arguments", "Use students list|today|schedule|todos|analysis|xp-history|mastery|upload-map-scores|map-reports|issue-email|goblins|web-todos|flashcards.");
6528
6585
  }
6529
6586
  if (noun === "todos") {
6530
6587
  if (verb === "create") {
@@ -585,6 +585,9 @@ const STAFF_COMMANDS = new Set([
585
585
  "school update",
586
586
  "store-items list",
587
587
  "students upload-map-scores",
588
+ "students map-reports list",
589
+ "students map-reports upload",
590
+ "students map-reports delete",
588
591
  "students issue-email",
589
592
  "students goblins",
590
593
  "students web-todos",
@@ -0,0 +1,41 @@
1
+ import { unwrap } from "../api.js";
2
+ import { CliError } from "../errors.js";
3
+ import { positional } from "./shared.js";
4
+ /**
5
+ * `changelog preview|send <slug>` — the same send as the post page's button. The
6
+ * server holds the copy and audience, so this only names the post. It sends once,
7
+ * and only when the post is live.
8
+ */
9
+ export async function runChangelogCommand({ parsed, api, writeCommand, }) {
10
+ const action = positional(parsed, 1, "changelog action");
11
+ if (action !== "preview" && action !== "send") {
12
+ throw new CliError("invalid_arguments", "Use changelog preview|send.");
13
+ }
14
+ const slug = positional(parsed, 2, "post slug");
15
+ const params = { path: { slug } };
16
+ const preview = unwrap(await api.client.GET("/admin/changelog-sends/{slug}/", { params }));
17
+ const reach = preview.audiences.map((a) => ({
18
+ audience: a.audience,
19
+ feed: a.feed?.count ?? 0,
20
+ email: a.email?.count ?? 0,
21
+ sms: a.sms?.count ?? 0,
22
+ }));
23
+ if (action === "preview")
24
+ return { ...preview, reach };
25
+ if (preview.record) {
26
+ throw new CliError("invalid_arguments", "This post was already sent.");
27
+ }
28
+ if (!preview.live) {
29
+ throw new CliError("invalid_arguments", "This post isn't live yet.");
30
+ }
31
+ if (preview.problems.length > 0) {
32
+ throw new CliError("invalid_arguments", preview.problems.join("; "));
33
+ }
34
+ return writeCommand(parsed, {
35
+ action: `send the "${slug}" changelog post to its audience${preview.dryRun ? " (test environment: nothing leaves)" : ""}. This can't be undone or sent twice.`,
36
+ target: { slug },
37
+ request: {},
38
+ details: { reach, audiences: preview.audiences },
39
+ }, async () => unwrap(await api.client.POST("/admin/changelog-sends/{slug}/send/", { params })));
40
+ }
41
+ //# sourceMappingURL=changelog.js.map
@@ -971,10 +971,6 @@ export async function runKidCommand({ parsed, api, writeCommand, }) {
971
971
  },
972
972
  wins: today.insights.wins,
973
973
  struggles: today.insights.struggles,
974
- // Adaptive coins: a required to-do pays 10 × its subject's multiplier.
975
- ...(today.coinMultipliers && {
976
- coinMultipliers: today.coinMultipliers,
977
- }),
978
974
  };
979
975
  }
980
976
  if (verb === "goals") {
@@ -1903,7 +1899,7 @@ export async function runKidCommand({ parsed, api, writeCommand, }) {
1903
1899
  target: { ...kidTarget(kid), goalId },
1904
1900
  request: { coins },
1905
1901
  details: {
1906
- consequence: "Its open and future to-dos pay this (default: required 20, optional 5; undo: family undo).",
1902
+ consequence: "Its open and future to-dos pay this (default: by subject, math 20, reading 10, else 5; undo: family undo).",
1907
1903
  },
1908
1904
  }, async () => {
1909
1905
  const result = unwrap(await api.client.PATCH("/parent-v2/kid/{kidId}/challenges/{goalId}/coins/", { params: { path: { kidId, goalId } }, body: { coins } }));
@@ -1945,7 +1941,7 @@ export async function runKidCommand({ parsed, api, writeCommand, }) {
1945
1941
  params: { path: { kidId } },
1946
1942
  }));
1947
1943
  return {
1948
- challenges: goals.map((goal) => `${goal.id} · ${goal.title} · ${goal.required ? "required" : "optional"} · ${goal.todoCoins ?? (goal.required ? 20 : 5)} coins/to-do · ${goal.status.toLowerCase()}`),
1944
+ challenges: goals.map((goal) => `${goal.id} · ${goal.title} · ${goal.required ? "required" : "optional"} · ${goal.todoCoins ?? "subject-priced"} coins/to-do · ${goal.status.toLowerCase()}`),
1949
1945
  page: `${api.config.webOrigin}/ai?kid=${encodeURIComponent(kidId)}&tab=challenges`,
1950
1946
  browse: `${api.config.webOrigin}/activity/challenges`,
1951
1947
  };
package/dist/help.js CHANGED
@@ -79,6 +79,13 @@ Usage:
79
79
  [--focus <text> | --clear-focus] [--confirm]
80
80
  recess [--json] students upload-map-scores --student <kid-id>
81
81
  --file </path/to/map-report.pdf> [--confirm]
82
+ recess [--json] students map-reports list --student <kid-id>
83
+ recess [--json] students map-reports upload --student <kid-id>
84
+ --file </path/to/report.pdf> --subject math|reading|language_usage|science|other
85
+ --season fall|winter|spring|summer --school-year <YYYY-YYYY>
86
+ [--kind learning-statements|other] [--confirm]
87
+ recess [--json] students map-reports delete --student <kid-id> --report <report-id>
88
+ [--confirm]
82
89
  recess [--json] students issue-email --student <kid-id> [--confirm]
83
90
  recess [--json] students goblins --student <kid-id> [--course <slug>] [--search TEXT]
84
91
  [--confirm]
@@ -411,6 +418,8 @@ Usage:
411
418
  recess [--json] cohorts email <cohort-id> --target ALL_PARENTS|ALL_PARENTS_GUIDES
412
419
  --content TEXT [--confirm]
413
420
  recess [--json] feed post --users <id,id,...> --text TEXT [--send-email] [--confirm]
421
+ recess [--json] changelog preview <slug>
422
+ recess [--json] changelog send <slug> [--confirm]
414
423
  recess [--json] dms send --users <id,id,...> --text TEXT [--confirm]
415
424
  recess [--json] events get <event-id>
416
425
  recess [--json] events list --date YYYY-MM-DD [--timezone <iana>] [--search TEXT]
@@ -1270,6 +1279,9 @@ export const COMMAND_SUMMARIES = {
1270
1279
  "students texts set": "Change a kid's SMS summary switch or send hour.",
1271
1280
  "students texts set-guardian": "Change one adult's SMS frequency, focus, or on/off.",
1272
1281
  "students upload-map-scores": "Upload a NWEA MAP score report PDF for a kid.",
1282
+ "students map-reports list": "List the full MAP report PDFs filed for a kid, by subject and season.",
1283
+ "students map-reports upload": "File a full MAP report PDF (e.g. Learning Statements) beside that season's scores for parents, the kid, and guides.",
1284
+ "students map-reports delete": "Remove a filed MAP report PDF.",
1273
1285
  "students issue-email": "Issue a Recess email address for a kid.",
1274
1286
  "students goblins": "Roster a kid into Goblins so their Goblins todos sign them straight in.",
1275
1287
  "students web-todos": "Show or set whether a kid's todos run on web (off: they open in the desktop app).",
@@ -1502,6 +1514,8 @@ export const COMMAND_SUMMARIES = {
1502
1514
  "cohorts resume-billing": "Resume billing for a cohort.",
1503
1515
  "cohorts email": "Email a cohort's parents (and guides).",
1504
1516
  "feed post": "Post a message to users' feeds (optionally email).",
1517
+ "changelog preview": "Show what a live changelog post would send, and to how many people.",
1518
+ "changelog send": "Send a live changelog post to its audience, once.",
1505
1519
  "dms send": "Send a Recess chat DM as yourself to each user (1:1).",
1506
1520
  "events get": "Read one class event.",
1507
1521
  "events list": "List class events on a date.",
@@ -1759,6 +1773,7 @@ export const NOUN_SUMMARIES = {
1759
1773
  "tuition-plans": "Compute tuition plan sheets (stores nothing).",
1760
1774
  placement: "Give placement quests, one kid's results, results vs MAP, question bank, mastery sync.",
1761
1775
  feed: "Post messages to users' feeds.",
1776
+ changelog: "Preview and send changelog posts.",
1762
1777
  dms: "Send Recess chat DMs as yourself.",
1763
1778
  events: "Class events: list, attendance, cancel, reschedule, add.",
1764
1779
  registrations: "Approve or deny cohort registrations.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recess-cli",
3
- "version": "3.43.0",
3
+ "version": "3.45.0",
4
4
  "description": "Safe Recess administration and family AI tools from the command line.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -30,7 +30,7 @@ recess --json skills guardian get recess-family
30
30
  recess --json skills guardian get recess-challenge-design
31
31
  # Research, author, or apply a goal or reusable goal template
32
32
  recess --json skills guardian get recess-goal-authoring
33
- # Guide (guide_students): your students, class ops, Math Academy linking and activity
33
+ # Guide (guide_students): your students, class ops, Math Academy, Goblins math practice
34
34
  recess --json skills guardian get recess-guide
35
35
  # Staff operations (full_admin), then the one playbook its table names
36
36
  recess --json skills admin get recess-admin