recess-cli 3.49.0 → 3.50.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.
package/dist/args.js CHANGED
@@ -58,7 +58,6 @@ export const BOOLEAN_FLAGS = new Set([
58
58
  "esa-award-unknown",
59
59
  "even-installments",
60
60
  "force",
61
- "force-direct",
62
61
  "full",
63
62
  "help",
64
63
  "immediate",
package/dist/cli.js CHANGED
@@ -25,6 +25,7 @@ import { runFamiliesCommand } from "./commands/families.js";
25
25
  import { runFamilyCommand, runKidCommand, runMeCommand, } from "./commands/family.js";
26
26
  import { runStudentsTextsCommand, runUsersPhoneCommand, runUsersTextCommand, runStudentsTextParentCommand, } from "./commands/phone-and-texts.js";
27
27
  import { hasCommunityHour, runUsersCommunityHourCommand, } from "./commands/community-hour.js";
28
+ import { runUsersBirthdayCommand } from "./commands/birthday.js";
28
29
  import { runTuitionPlansCommand } from "./commands/tuition-plans.js";
29
30
  import { runReportsCommand } from "./commands/reports.js";
30
31
  import { runMasteryCommand } from "./commands/mastery.js";
@@ -35,7 +36,7 @@ import { runFlagsCommand } from "./commands/flags.js";
35
36
  import { runRockyFreeCommand } from "./commands/rocky-free.js";
36
37
  import { runSchoolCommand } from "./commands/school.js";
37
38
  import { runVillageEventsCommand } from "./commands/village-events.js";
38
- import { assertChoice, flagIdList, positional, readJsonFile, readJsonValue, } from "./commands/shared.js";
39
+ import { assertChoice, flagDate, flagIdList, positional, readJsonFile, readJsonValue, } from "./commands/shared.js";
39
40
  import { CliError } from "./errors.js";
40
41
  import { listFeedback, submitFeedback } from "./feedback.js";
41
42
  import { HELP } from "./help.js";
@@ -2047,20 +2048,6 @@ function flagItemDateMs(parsed) {
2047
2048
  }
2048
2049
  return ms;
2049
2050
  }
2050
- function flagDateOnly(parsed, name) {
2051
- const raw = flagString(parsed, name);
2052
- if (raw === undefined)
2053
- return undefined;
2054
- const parsedDate = /^\d{4}-\d{2}-\d{2}$/.test(raw)
2055
- ? new Date(`${raw}T00:00:00.000Z`)
2056
- : null;
2057
- if (!parsedDate ||
2058
- Number.isNaN(parsedDate.getTime()) ||
2059
- parsedDate.toISOString().slice(0, 10) !== raw) {
2060
- throw new CliError("invalid_arguments", `--${name} must be a valid YYYY-MM-DD date.`);
2061
- }
2062
- return raw;
2063
- }
2064
2051
  const DAY_MS = 24 * 60 * 60 * 1000;
2065
2052
  async function waitForContentLibraryLive(api, gems, timeoutSeconds) {
2066
2053
  const pending = new Set(gems);
@@ -3270,6 +3257,9 @@ export async function executeRecessCommand(argv, options = {}) {
3270
3257
  if (noun === "users" && verb === "phone") {
3271
3258
  return runUsersPhoneCommand({ parsed, api, writeCommand });
3272
3259
  }
3260
+ if (noun === "users" && verb === "birthday") {
3261
+ return runUsersBirthdayCommand({ parsed, api, writeCommand });
3262
+ }
3273
3263
  if (noun === "users" && verb === "text") {
3274
3264
  return runUsersTextCommand({ parsed, api, writeCommand });
3275
3265
  }
@@ -6828,7 +6818,7 @@ export async function executeRecessCommand(argv, options = {}) {
6828
6818
  const todoId = positional(parsed, 2, "todo ID");
6829
6819
  const student = await studentFlag(api, parsed, { required: true });
6830
6820
  const studentId = student.id;
6831
- const targetDueDateISO = flagDateOnly(parsed, "due-date");
6821
+ const targetDueDateISO = flagDate(parsed, "due-date");
6832
6822
  const mode = flagString(parsed, "mode");
6833
6823
  if (mode !== undefined &&
6834
6824
  mode !== "game" &&
@@ -0,0 +1,81 @@
1
+ import { unwrap } from "../api.js";
2
+ import { CliError } from "../errors.js";
3
+ import { flagDate, positional } from "./shared.js";
4
+ /** apps/web-server/src/libs/birth-window.ts MIN_AGE/MAX_AGE: the school's kid ages. */
5
+ const KID_AGE_WINDOW = { min: 3, max: 21 };
6
+ /** Whole years from `birthdate` (YYYY-MM-DD) to `today`, as `users get` counts them. */
7
+ function ageOn(birthdate, today) {
8
+ const born = new Date(`${birthdate}T00:00:00.000Z`);
9
+ const hadBirthday = today.getUTCMonth() > born.getUTCMonth() ||
10
+ (today.getUTCMonth() === born.getUTCMonth() &&
11
+ today.getUTCDate() >= born.getUTCDate());
12
+ return today.getUTCFullYear() - born.getUTCFullYear() - (hadBirthday ? 0 : 1);
13
+ }
14
+ /**
15
+ * `users birthday set` — staff correction of a kid's birthday, typically a
16
+ * year typed in the wrong century (1911 for 2011, so Recess shows age 115).
17
+ * The parent's `kid set-profile` only reaches the caller's own kids; this
18
+ * writes the same kid-config field, which the server lets an admin set on any
19
+ * kid, so the change keeps its provenance and lands in the family change log.
20
+ */
21
+ export async function runUsersBirthdayCommand({ parsed, api, writeCommand, }) {
22
+ const action = positional(parsed, 2, "users birthday action");
23
+ if (action !== "set") {
24
+ throw new CliError("invalid_arguments", "Use users birthday set.");
25
+ }
26
+ const userId = positional(parsed, 3, "kid ID");
27
+ const birthdate = flagDate(parsed, "date", { required: true });
28
+ const age = ageOn(birthdate, new Date());
29
+ if (age < 0) {
30
+ throw new CliError("invalid_arguments", `--date ${birthdate} is in the future.`);
31
+ }
32
+ const { user } = unwrap(await api.client.GET("/admin/users/{userId}", {
33
+ params: { path: { userId } },
34
+ }));
35
+ const current = {
36
+ userId: user.id,
37
+ name: [user.firstName, user.lastName].filter(Boolean).join(" "),
38
+ role: user.role,
39
+ birthdate: user.birthdate?.slice(0, 10) ?? null,
40
+ age: user.age ?? null,
41
+ };
42
+ if (user.role !== "KID") {
43
+ throw new CliError("invalid_arguments", `${current.name || user.id} is a ${user.role}, not a KID. Only a kid's birthday is set here: pass the kid's user ID.`, 1, { current });
44
+ }
45
+ if (current.birthdate === birthdate) {
46
+ return { ...current, status: "unchanged" };
47
+ }
48
+ const warnings = age < KID_AGE_WINDOW.min || age > KID_AGE_WINDOW.max
49
+ ? [
50
+ `Age ${age} is outside the school's ${KID_AGE_WINDOW.min} to ${KID_AGE_WINDOW.max} window: check the year with the family before approving.`,
51
+ ]
52
+ : [];
53
+ return writeCommand(parsed, {
54
+ action: `change this kid's birthday from ${current.birthdate ?? "unset"} (age ${current.age ?? "unknown"}) to ${birthdate} (age ${age}); the family's change log shows it under your first name, and a guardian can undo it`,
55
+ target: { userId: user.id },
56
+ request: { path: "profile.birthdate", value: birthdate },
57
+ details: {
58
+ current,
59
+ after: { birthdate, age },
60
+ ...(warnings.length > 0 ? { warnings } : {}),
61
+ },
62
+ }, async () => {
63
+ const { result } = unwrap(await api.client.PATCH("/kid-config/kid/{kidId}/", {
64
+ params: { path: { kidId: user.id }, query: { surface: "admin" } },
65
+ body: { path: "profile.birthdate", value: birthdate },
66
+ }));
67
+ if (result.status === "unconfirmed") {
68
+ throw new CliError("write_unconfirmed", `The server accepted the change but still reads ${String(result.after)}. Re-read with users get ${user.id}.`);
69
+ }
70
+ // What the server read back, not what was sent: a concurrent edit wins.
71
+ const saved = typeof result.after === "string" ? result.after : null;
72
+ return {
73
+ ...current,
74
+ birthdate: saved,
75
+ age: saved === null ? null : ageOn(saved, new Date()),
76
+ status: result.status,
77
+ changeId: result.changeId,
78
+ };
79
+ });
80
+ }
81
+ //# sourceMappingURL=birthday.js.map
@@ -3,7 +3,7 @@ import { unwrap } from "../api.js";
3
3
  import { flagString, hasFlag } from "../args.js";
4
4
  import { apiError, CliError } from "../errors.js";
5
5
  import { resolveStudentReference } from "../goal-authoring.js";
6
- import { assertChoice, flagBooleanValue, flagIdList, flagInteger, } from "./shared.js";
6
+ import { assertChoice, flagBooleanValue, flagDate, flagIdList, flagInteger, } from "./shared.js";
7
7
  // packages/web-schema COMMUNITY_HOUR_COURSE_ID: the daily coworking pods are
8
8
  // this course's event series (apps/web `$lib/onboarding/cowork.ts`).
9
9
  const COWORK_COURSE_ID = "b96a9f7d-7851-4506-965e-2d9babd50b11";
@@ -12,7 +12,6 @@ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
12
12
  const DEFAULT_SUMMARY_SEND_HOUR = 18;
13
13
  // lesson-notes.ts LESSON_NOTE_MAX_CHARS: the server's goal-note cap.
14
14
  const GOAL_NOTE_MAX_CHARS = 2000;
15
- const DATE = /^\d{4}-\d{2}-\d{2}$/;
16
15
  const FEED_LOCK_MODES = [
17
16
  "ALL_DAILY_TODOS",
18
17
  "SELECTED_GOALS",
@@ -83,15 +82,6 @@ function redactedSecret(secret) {
83
82
  .slice(0, 12),
84
83
  };
85
84
  }
86
- function flagDate(parsed, name) {
87
- const value = flagString(parsed, name);
88
- if (value !== undefined &&
89
- (!DATE.test(value) ||
90
- new Date(`${value}T00:00:00.000Z`).toISOString().slice(0, 10) !== value)) {
91
- throw new CliError("invalid_arguments", `--${name} must be a valid YYYY-MM-DD date.`);
92
- }
93
- return value;
94
- }
95
85
  function flagUuid(parsed, name, options = {}) {
96
86
  const value = flagString(parsed, name, options);
97
87
  if (value !== undefined && !UUID.test(value)) {
@@ -865,6 +855,9 @@ export async function runFamilyCommand({ parsed, api, writeCommand, }) {
865
855
  const text = flagString(parsed, "text", { required: true }).trim();
866
856
  if (!text || text.length > 4000)
867
857
  throw new CliError("invalid_arguments", "--text must be 1-4000 characters.");
858
+ const ask = flagString(parsed, "ask")?.trim();
859
+ if (ask !== undefined && (!ask || ask.length > 500))
860
+ throw new CliError("invalid_arguments", "--ask must be 1-500 characters.");
868
861
  // Each kid has their own guide: name one unless there's only one.
869
862
  const kids = hasFlag(parsed, "student") ? [] : await listFamilyKids(api);
870
863
  if (!hasFlag(parsed, "student") && kids.length !== 1)
@@ -872,13 +865,13 @@ export async function runFamilyCommand({ parsed, api, writeCommand, }) {
872
865
  const kid = hasFlag(parsed, "student")
873
866
  ? await resolveFamilyKid(api, parsed)
874
867
  : kids[0];
875
- const body = { text, studentId: kid.id };
868
+ const body = { text, ...(ask ? { ask } : {}), studentId: kid.id };
876
869
  return writeCommand(parsed, {
877
870
  action: `message ${kidName(kid)}'s guide: "${text.slice(0, 120)}"`,
878
871
  target: { family: "@me", ...kidTarget(kid) },
879
872
  request: body,
880
873
  details: {
881
- consequence: "The guide gets it on Slack and in your chat with them in the Recess app, and answers there. It can't be unsent.",
874
+ consequence: "The guide gets a support ticket, plus a message on Slack and in your chat with them in the Recess app, and answers there. It can't be unsent.",
882
875
  },
883
876
  }, async () => unwrap(await api.client.POST("/parent-v2/message-guide/", { body })));
884
877
  }
@@ -69,6 +69,21 @@ export function flagIsoInstant(parsed, name, options = {}) {
69
69
  }
70
70
  return raw;
71
71
  }
72
+ /** A `YYYY-MM-DD` date that exists: 2015-02-31 and 2015-13-01 are refused. */
73
+ export function flagDate(parsed, name, options = {}) {
74
+ const raw = flagString(parsed, name, options);
75
+ if (raw === undefined)
76
+ return undefined;
77
+ const date = /^\d{4}-\d{2}-\d{2}$/.test(raw)
78
+ ? new Date(`${raw}T00:00:00.000Z`)
79
+ : null;
80
+ if (!date ||
81
+ Number.isNaN(date.getTime()) ||
82
+ date.toISOString().slice(0, 10) !== raw) {
83
+ throw new CliError("invalid_arguments", `--${name} must be a valid YYYY-MM-DD date.`);
84
+ }
85
+ return raw;
86
+ }
72
87
  export async function readJsonValue(filePath, label) {
73
88
  const absolutePath = path.resolve(filePath);
74
89
  let raw;
@@ -237,10 +237,6 @@ export function parseTuitionPlanSpecFlags(parsed, options) {
237
237
  throw new CliError("invalid_arguments", "--custom-only needs --custom-plan.");
238
238
  }
239
239
  const subsetQuery = {
240
- // Florida is refused as a direct enrollment without this.
241
- ...(hasFlag(parsed, "force-direct")
242
- ? { forceDirect: "true" }
243
- : {}),
244
240
  ...(esaUnknown ? { esaAwardUnknown: "true" } : {}),
245
241
  ...(esaScenarios ? { esaScenarios } : {}),
246
242
  ...(esaAward ? { esaAward: Number(esaAward) } : {}),
package/dist/help.js CHANGED
@@ -52,6 +52,7 @@ Usage:
52
52
  recess [--json] users phone get <user-id>
53
53
  recess [--json] users phone set <user-id> --phone <number> [--confirm]
54
54
  recess [--json] users phone clear <user-id> [--confirm]
55
+ recess [--json] users birthday set <kid-id> --date YYYY-MM-DD [--confirm]
55
56
  recess [--json] users text <user-id> --text TEXT [--confirm]
56
57
  recess [--json] users lock <user-id> [--confirm]
57
58
  recess [--json] users unlock <user-id> [--confirm]
@@ -240,7 +241,7 @@ Usage:
240
241
  recess [--json] family memory rewrite --in family|me --text TEXT [--confirm]
241
242
  recess [--json] family memory forget --in journal|family|me --line TEXT
242
243
  [--date YYYY-MM-DD] [--confirm]
243
- recess [--json] family message-guide --text TEXT [--student <kid>] [--confirm]
244
+ recess [--json] family message-guide --text TEXT [--ask TEXT] [--student <kid>] [--confirm]
244
245
  recess [--json] family report-bug --text TEXT [--summary TEXT] [--kind bug|request] [--student <kid>]
245
246
  [--todo <todo-id>] [--confirm]
246
247
  recess [--json] kid today --student <kid> [--date YYYY-MM-DD]
@@ -371,7 +372,7 @@ Usage:
371
372
  recess [--json] channels members remove <channel-id> <user-id...> [--confirm]
372
373
  recess [--json] tuition-plans generate --parent TEXT --student TEXT [--dob YYYY-MM-DD]
373
374
  --state XX --start YYYY-MM-DD --annual DOLLARS --enrollment direct|partner-school|program
374
- [--partner-school <slug|id>] [--force-direct] [--state-funding] [--elective-price DOLLARS]
375
+ [--partner-school <slug|id>] [--state-funding] [--elective-price DOLLARS]
375
376
  [--one-on-one-price DOLLARS] [--one-on-one-sessions N] [--end YYYY-MM-DD]
376
377
  [--terms full-year,school-year,custom] [--payments upfront,installments]
377
378
  [--note TEXT]... [--bill-date upfront|N=YYYY-MM-DD]... [--due-date upfront|N=YYYY-MM-DD]... [--amount N=DOLLARS]... [--even-installments]
@@ -386,7 +387,7 @@ Usage:
386
387
  [--tier complete] [--paywall DOLLARS|--paywall-offline] [--staff-note TEXT]... [--no-email]
387
388
  (--no-agreement | --start YYYY-MM-DD [--annual DOLLARS] [--override-aid-price]) [--state-funding] [--end YYYY-MM-DD]
388
389
  [--terms full-year,school-year,custom] [--payments upfront,installments] [--note TEXT]...
389
- [--bill-date upfront|N=YYYY-MM-DD]... [--due-date upfront|N=YYYY-MM-DD]... [--amount N=DOLLARS]... [--even-installments] [--force-direct]
390
+ [--bill-date upfront|N=YYYY-MM-DD]... [--due-date upfront|N=YYYY-MM-DD]... [--amount N=DOLLARS]... [--even-installments]
390
391
  [--esa-award DOLLARS | --esa-award-unknown [--esa-scenarios DOLLARS,...]] [--custom-plan JSON|@file] [--custom-only]
391
392
  [--elective-price DOLLARS]
392
393
  [--one-on-one-price DOLLARS] [--one-on-one-sessions N] [--confirm]
@@ -912,6 +913,11 @@ account — the confirmed write's own response is the record of what changed.
912
913
  without +country is read as US), rejects invalid or already-taken numbers, and
913
914
  marks the new number unverified until the user's next phone sign-in.
914
915
 
916
+ "users birthday set" corrects any kid's birthday, e.g. a wrong-century year that
917
+ makes "users get" show age 115 ("kid set-profile" reaches only your own kids).
918
+ The preview shows the age before and after, and warns outside ages 3 to 21. The
919
+ family's change log shows the change under your first name; a guardian can undo it.
920
+
915
921
  Parent SMS summary notes: "students texts get" shows the kid-level switch and
916
922
  end-of-day send hour (0-23 in the kid's timezone; unset = 18) plus every
917
923
  recipient's phone, texts on/off, frequency, and focus. "set" changes the
@@ -1080,8 +1086,8 @@ supported states and their year-end dates. --enrollment partner-school
1080
1086
  (with --partner-school, e.g. wonder-ed) names the partner as the school of record
1081
1087
  and says tuition payments go to it, on the tuition page and the signing page. --enrollment program
1082
1088
  is the online learning program (main or supplemental): the agreement says Recess is not the
1083
- school of record and satisfies no attendance or reporting requirement. Florida students enroll through a
1084
- partner institution or the program: a direct Florida plan is refused unless --force-direct. Add-on prices default to
1089
+ school of record and satisfies no attendance or reporting requirement. Direct enrollment is Arizona-only for now:
1090
+ a direct plan in any other state is refused (use --enrollment program or partner-school). Add-on prices default to
1085
1091
  $160/month per extra elective and $400 per 4 tutoring sessions; --elective-price,
1086
1092
  --one-on-one-price, and --one-on-one-sessions override them on this sheet.
1087
1093
  --end YYYY-MM-DD adds a custom term through that date (priced by school days).
@@ -1274,6 +1280,7 @@ export const COMMAND_SUMMARIES = {
1274
1280
  "users phone get": "Read a user's phone number and verification.",
1275
1281
  "users phone set": "Set a user's phone number (stored E.164, unverified).",
1276
1282
  "users phone clear": "Remove a user's phone number.",
1283
+ "users birthday set": "Correct any kid's birthday (shows the age it gives).",
1277
1284
  "users text": "Text a parent from Rocky's number, signed with your first name.",
1278
1285
  "users community-hour get": "Show whether a kid can join Community Hour.",
1279
1286
  "users community-hour unlock": "Let a kid join Community Hour and enter the Village.",
@@ -1404,7 +1411,7 @@ export const COMMAND_SUMMARIES = {
1404
1411
  "family memory save": "Save one line to Rocky's family notes, with your name (at once).",
1405
1412
  "family memory rewrite": "Replace family.md or your own notes whole, tidied (at once).",
1406
1413
  "family memory forget": "Forget one exact line of the family notes (at once).",
1407
- "family message-guide": "Message your kid's guide (Slack + the app chat); the person for anything.",
1414
+ "family message-guide": "Message your kid's guide (a support ticket, Slack + the app chat); the person for anything. --text is the note for the guide; --ask, your request in your own words, is what the app chat shows.",
1408
1415
  "family report-bug": "Report a bug, or a request (--kind request: something missing, or what you think of Rocky), to the Recess team (at once; not a change).",
1409
1416
  "family remind": "Have Rocky text you a reminder (applies at once).",
1410
1417
  "family reminders": "Your upcoming text-me reminders.",
@@ -1773,7 +1780,7 @@ export const NOUN_SUMMARIES = {
1773
1780
  jobs: "Local ledger of write operations by operation key.",
1774
1781
  feedback: "Send or list feedback about this CLI.",
1775
1782
  auth: "Sign in (browser or headless), session status, sign out.",
1776
- users: "Accounts: search/get, lock/unlock, community-hour, disable/restore, phone, tier, school status.",
1783
+ users: "Accounts: search/get, lock/unlock, community-hour, disable/restore, phone, birthday, tier, school status.",
1777
1784
  guides: "Create and invite guide accounts.",
1778
1785
  guardians: "Invite guardians into a family.",
1779
1786
  students: "Kids: roster, today, schedule, todos, analysis, XP, SMS summaries, notes.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recess-cli",
3
- "version": "3.49.0",
3
+ "version": "3.50.1",
4
4
  "description": "Safe Recess administration and family AI tools from the command line.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {