recess-cli 3.55.0 → 3.57.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/args.js CHANGED
@@ -7,6 +7,7 @@ import { CliError } from "./errors.js";
7
7
  export const REPEATABLE_FLAGS = new Set([
8
8
  "amount",
9
9
  "bill-date",
10
+ "installment",
10
11
  "due-date",
11
12
  "existing-kid",
12
13
  "kid",
package/dist/cli.js CHANGED
@@ -26,6 +26,7 @@ import { runFamilyCommand, runKidCommand, runMeCommand, } from "./commands/famil
26
26
  import { runStudentsTextsCommand, runUsersPhoneCommand, runUsersTextCommand, runStudentsTextParentCommand, } from "./commands/phone-and-texts.js";
27
27
  import { hasCommunityHour, runUsersCommunityHourCommand, } from "./commands/community-hour.js";
28
28
  import { runUsersBirthdayCommand } from "./commands/birthday.js";
29
+ import { runUsersHostMultipleCommand } from "./commands/host-multiple.js";
29
30
  import { runTuitionPlansCommand } from "./commands/tuition-plans.js";
30
31
  import { runTuitionCommand } from "./commands/tuition.js";
31
32
  import { runReportsCommand } from "./commands/reports.js";
@@ -3527,6 +3528,9 @@ export async function executeRecessCommand(argv, options = {}) {
3527
3528
  if (noun === "users" && verb === "community-hour") {
3528
3529
  return runUsersCommunityHourCommand({ parsed, api, writeCommand });
3529
3530
  }
3531
+ if (noun === "users" && verb === "host-multiple") {
3532
+ return runUsersHostMultipleCommand({ parsed, api, writeCommand });
3533
+ }
3530
3534
  if (noun === "users" && verb === "get") {
3531
3535
  const userId = positional(parsed, 2, "user ID");
3532
3536
  return unwrap(await api.client.GET("/admin/users/{userId}", {
@@ -0,0 +1,43 @@
1
+ import { unwrap } from "../api.js";
2
+ import { CliError } from "../errors.js";
3
+ import { positional } from "./shared.js";
4
+ const HOST_MULTIPLE_ROLE = "recess:host-multiple";
5
+ /**
6
+ * `users host-multiple get|grant|revoke` — whether someone may host more than
7
+ * one group at a time (the `recess:host-multiple` access role). One person per
8
+ * run; the server's PATCH is a set-to, so a rerun is harmless.
9
+ */
10
+ export async function runUsersHostMultipleCommand({ parsed, api, writeCommand, }) {
11
+ const action = positional(parsed, 2, "users host-multiple action");
12
+ if (!["get", "grant", "revoke"].includes(action)) {
13
+ throw new CliError("invalid_arguments", "Use users host-multiple get|grant|revoke.");
14
+ }
15
+ const userId = positional(parsed, 3, "user ID");
16
+ const { user } = unwrap(await api.client.GET("/admin/users/{userId}", {
17
+ params: { path: { userId } },
18
+ }));
19
+ const current = {
20
+ userId: user.id,
21
+ name: [user.firstName, user.lastName].filter(Boolean).join(" "),
22
+ role: user.role,
23
+ canHostMultiple: (user.accessRoles ?? []).some((role) => role.name === HOST_MULTIPLE_ROLE),
24
+ };
25
+ if (action === "get")
26
+ return current;
27
+ const enabled = action === "grant";
28
+ return writeCommand(parsed, {
29
+ action: enabled
30
+ ? "let this person host more than one group at a time on Events. Their other access and restrictions are unchanged"
31
+ : "put this person back on the one-group-at-a-time limit on Events. Groups they already posted stay up; their other access and restrictions are unchanged",
32
+ target: { userId: user.id },
33
+ request: { enabled },
34
+ details: { current, canHostMultipleAfter: enabled },
35
+ }, async () => {
36
+ unwrap(await api.client.PATCH("/admin/users/{userId}/host-multiple", {
37
+ params: { path: { userId: user.id } },
38
+ body: { enabled },
39
+ }));
40
+ return { ...current, canHostMultiple: enabled };
41
+ });
42
+ }
43
+ //# sourceMappingURL=host-multiple.js.map
@@ -1,5 +1,5 @@
1
1
  import { unwrap } from "../api.js";
2
- import { flagString, hasFlag } from "../args.js";
2
+ import { flagList, flagString, hasFlag } from "../args.js";
3
3
  import { CliError } from "../errors.js";
4
4
  import { assertChoice, positional, renderColumns, } from "./shared.js";
5
5
  const STATUSES = [
@@ -50,7 +50,7 @@ function renderSchedule({ schedule, signed, events, revisions, }) {
50
50
  ...schedule.installments.map((row) => [
51
51
  String(row.sequence),
52
52
  row.status,
53
- `${dollars(row.amountCents)}${row.creditedCents ? ` (${dollars(row.amountCents - row.creditedCents)} after credit)` : ""}${row.refundedCents ? ` (${dollars(row.refundedCents)} refunded)` : ""}`,
53
+ `${dollars(row.amountCents)}${row.creditedCents ? ` (${dollars(row.amountCents - row.creditedCents)} after credit)` : ""}${row.refundedCents ? ` (${dollars(row.refundedCents)} refunded)` : ""}${row.feeCents ? ` (${dollars(row.feeCents)} fee withheld)` : ""}`,
54
54
  row.invoiceDate,
55
55
  row.dueDate,
56
56
  row.collection,
@@ -276,6 +276,83 @@ export async function runTuitionCommand({ parsed, api, writeCommand, }) {
276
276
  request: body,
277
277
  }, async () => shown(unwrap(await api.client.PATCH("/admin/tuition-billing/installments/{installmentId}", { params: { path: { installmentId } }, body })).schedule));
278
278
  }
279
+ if (verb === "create") {
280
+ const kidUserId = textFlag(parsed, "student", true);
281
+ if (!UUID.test(kidUserId)) {
282
+ throw new CliError("invalid_arguments", "--student must be a kid ID.");
283
+ }
284
+ const stateCode = textFlag(parsed, "state", true).toUpperCase();
285
+ if (!/^[A-Z]{2}$/.test(stateCode)) {
286
+ throw new CliError("invalid_arguments", "--state is a two-letter code.");
287
+ }
288
+ const enrollmentType = choiceFlag(parsed, "enrollment", {
289
+ direct: "DIRECT",
290
+ "partner-school": "PARTNER_SCHOOL",
291
+ program: "PROGRAM",
292
+ });
293
+ if (!enrollmentType) {
294
+ throw new CliError("invalid_arguments", "Missing required --enrollment direct|partner-school|program.");
295
+ }
296
+ const partnerSchoolSlug = textFlag(parsed, "partner-school");
297
+ if (enrollmentType === "PARTNER_SCHOOL" && !partnerSchoolSlug) {
298
+ throw new CliError("invalid_arguments", "--enrollment partner-school needs --partner-school <slug>.");
299
+ }
300
+ const partner = enrollmentType === "PARTNER_SCHOOL";
301
+ const payer = choiceFlag(parsed, "payer", PAYERS) ??
302
+ (partner ? "PARTNER_SCHOOL" : "FAMILY");
303
+ const defaultCollection = choiceFlag(parsed, "collection", COLLECTIONS) ??
304
+ (partner ? "OUT_OF_BAND" : "EMAIL_INVOICE");
305
+ const specs = flagList(parsed, "installment");
306
+ if (!specs.length) {
307
+ throw new CliError("invalid_arguments", 'Add at least one --installment "LABEL|DOLLARS|INVOICE-DATE|DUE-DATE[|SERVICE-START|SERVICE-END]".');
308
+ }
309
+ const installments = specs.map((spec) => {
310
+ const [label, amount, invoiceDate, dueDate, serviceStart, serviceEnd] = spec.split("|").map((part) => part.trim());
311
+ const raw = amount?.replace(/^\$/, "").replaceAll(",", "");
312
+ const dates = [invoiceDate, dueDate, serviceStart, serviceEnd].filter((d) => d !== undefined && d !== "");
313
+ if (!label ||
314
+ !raw ||
315
+ !/^\d+(\.\d{1,2})?$/.test(raw) ||
316
+ Number(raw) <= 0 ||
317
+ !invoiceDate ||
318
+ !dueDate ||
319
+ dates.some((d) => !ISO_DATE.test(d))) {
320
+ throw new CliError("invalid_arguments", `Bad --installment "${spec}": use "LABEL|DOLLARS|INVOICE-DATE|DUE-DATE[|SERVICE-START|SERVICE-END]".`);
321
+ }
322
+ return {
323
+ label,
324
+ amountCents: Math.round(Number(raw) * 100),
325
+ invoiceDate,
326
+ dueDate,
327
+ ...(serviceStart ? { serviceStart } : {}),
328
+ ...(serviceEnd ? { serviceEnd } : {}),
329
+ };
330
+ });
331
+ const note = textFlag(parsed, "note");
332
+ const body = {
333
+ kidUserId,
334
+ institutionSlug: textFlag(parsed, "school") ?? "recess-academy",
335
+ enrollmentType,
336
+ ...(partnerSchoolSlug ? { partnerSchoolSlug } : {}),
337
+ stateCode,
338
+ payer,
339
+ defaultCollection,
340
+ installments,
341
+ ...(note ? { note } : {}),
342
+ };
343
+ const { preview } = unwrap(await api.client.POST("/admin/tuition-billing/", {
344
+ body: { ...body, dryRun: true },
345
+ }));
346
+ return writeCommand(parsed, {
347
+ action: `record a ${dollars(preview.totalCents)} tuition schedule (${installments.length} installment(s), payer ${payer}, ${defaultCollection}) for ${preview.kidName} with no signed packet. Nothing is emailed; automatic invoicing stays off`,
348
+ target: { kidUserId },
349
+ request: body,
350
+ details: preview,
351
+ }, async () => {
352
+ const { schedule } = unwrap(await api.client.POST("/admin/tuition-billing/", { body }));
353
+ return shown(schedule);
354
+ });
355
+ }
279
356
  if (verb === "add") {
280
357
  const scheduleId = positional(parsed, 2, "schedule ID");
281
358
  const amountCents = centsFlag(parsed, "amount");
@@ -335,14 +412,16 @@ export async function runTuitionCommand({ parsed, api, writeCommand, }) {
335
412
  if (verb === "mark-paid") {
336
413
  const installmentId = positional(parsed, 2, "installment ID");
337
414
  const paidCents = centsFlag(parsed, "paid");
415
+ const feeCents = centsFlag(parsed, "fee");
338
416
  const paidOn = dateFlag(parsed, "paid-on");
339
417
  const body = {
340
418
  note: textFlag(parsed, "note", true),
341
419
  ...(paidCents !== undefined ? { paidCents } : {}),
420
+ ...(feeCents !== undefined ? { feeCents } : {}),
342
421
  ...(paidOn ? { paidOn } : {}),
343
422
  };
344
423
  return writeCommand(parsed, {
345
- action: `mark tuition installment ${installmentId} as paid outside Recess`,
424
+ action: `mark tuition installment ${installmentId} as paid outside Recess${feeCents ? ` (${dollars(feeCents)} withheld as a fee before it reached us)` : ""}`,
346
425
  target: { installmentId },
347
426
  request: body,
348
427
  }, async () => shown(unwrap(await api.client.POST("/admin/tuition-billing/installments/{installmentId}/mark-paid", { params: { path: { installmentId } }, body })).schedule));
@@ -512,6 +591,6 @@ export async function runTuitionCommand({ parsed, api, writeCommand, }) {
512
591
  request: body,
513
592
  }, async () => unwrap(await api.client.POST("/admin/tuition-billing/auto-invoice", { body })));
514
593
  }
515
- throw new CliError("invalid_arguments", "Usage: recess tuition summary|list|show|edit|add|release|void|reopen|mark-paid|draft|send|pull-back|email|resend-approval|record-consent|withdraw|retry-change|auto-invoice|pause|resume|set. See `recess help`.");
594
+ throw new CliError("invalid_arguments", "Usage: recess tuition summary|list|show|create|edit|add|release|void|reopen|mark-paid|draft|send|pull-back|email|resend-approval|record-consent|withdraw|retry-change|auto-invoice|pause|resume|set. See `recess help`.");
516
595
  }
517
596
  //# sourceMappingURL=tuition.js.map
package/dist/help.js CHANGED
@@ -61,6 +61,9 @@ Usage:
61
61
  recess [--json] users community-hour get <kid-id>
62
62
  recess [--json] users community-hour unlock <kid-id> [--confirm]
63
63
  recess [--json] users community-hour lock <kid-id> [--confirm]
64
+ recess [--json] users host-multiple get <user-id>
65
+ recess [--json] users host-multiple grant <user-id> [--confirm]
66
+ recess [--json] users host-multiple revoke <user-id> [--confirm]
64
67
  recess [--json] users disable <user-id> [--whole-family] [--allow-billing] [--confirm]
65
68
  recess [--json] users restore <user-id> --role kid|guardian|guide|program [--confirm]
66
69
  recess [--json] users tier list-tiers
@@ -391,11 +394,12 @@ Usage:
391
394
  recess [--json] tuition list [--status NEEDS_REVIEW|SCHEDULED|DRAFTED|SENT|PAID|PAID_OUT_OF_BAND|VOID] [--family <family-id>] [--packet <packet-id>] [--q TEXT] [--limit N]
392
395
  recess [--json] tuition show <schedule-id>
393
396
  recess [--json] tuition edit <installment-id> [--amount DOLLARS] [--invoice-date YYYY-MM-DD] [--due-date YYYY-MM-DD] [--label TEXT] [--collection invoice|auto-charge|out-of-band|default] [--note TEXT] [--ask-family [--family-note TEXT]] [--confirm]
397
+ recess [--json] tuition create --student <kid-id> --state XX --enrollment direct|partner-school|program [--partner-school <slug>] [--school <institution-slug>] [--payer family|az-esa|fl-scholarship|partner-school] [--collection invoice|auto-charge|out-of-band] --installment "LABEL|DOLLARS|INVOICE-DATE|DUE-DATE[|SERVICE-START|SERVICE-END]"... [--note TEXT] [--confirm]
394
398
  recess [--json] tuition add <schedule-id> --label TEXT --amount DOLLARS --invoice-date YYYY-MM-DD --due-date YYYY-MM-DD [--collection invoice|auto-charge|out-of-band] [--note TEXT] [--ask-family [--family-note TEXT]] [--confirm]
395
399
  recess [--json] tuition release <installment-id> [--note TEXT] [--confirm]
396
400
  recess [--json] tuition void <installment-id> --reason TEXT [--ask-family [--family-note TEXT]] [--confirm]
397
401
  recess [--json] tuition reopen <installment-id> --reason TEXT [--confirm]
398
- recess [--json] tuition mark-paid <installment-id> --note TEXT [--paid DOLLARS] [--paid-on YYYY-MM-DD] [--confirm]
402
+ recess [--json] tuition mark-paid <installment-id> --note TEXT [--paid DOLLARS] [--fee DOLLARS] [--paid-on YYYY-MM-DD] [--confirm]
399
403
  recess [--json] tuition draft <installment-id> [--confirm]
400
404
  recess [--json] tuition send <installment-id> [--confirm]
401
405
  recess [--json] tuition pull-back <installment-id> --reason TEXT [--confirm]
@@ -936,6 +940,11 @@ room; the Village picks the change up within about 30 seconds. "users unlock"
936
940
  does not grant it and "users lock" removes it. "users community-hour get" (or
937
941
  "users get": accessRoles contains recess:participant) is the read.
938
942
 
943
+ "users host-multiple grant|revoke" sets whether one person may host more than
944
+ one group at a time on Events (the recess:host-multiple access role). Without
945
+ it a kid or parent hosts one group until it ends; staff and Sparks are never
946
+ limited. One person per run. "users host-multiple get" is the read.
947
+
939
948
  "users disable" is the harder stop, and a different mechanism: it sets
940
949
  User.role to DISABLED, so the account stops resolving in every dashboard,
941
950
  search, chat, and todo query at the database layer, and its coherent-feed
@@ -1352,6 +1361,9 @@ export const COMMAND_SUMMARIES = {
1352
1361
  "users community-hour get": "Show whether a kid can join Community Hour.",
1353
1362
  "users community-hour unlock": "Let a kid join Community Hour and enter the Village.",
1354
1363
  "users community-hour lock": "Stop a kid joining Community Hour or the Village.",
1364
+ "users host-multiple get": "Show whether someone may host more than one group at a time.",
1365
+ "users host-multiple grant": "Let someone host more than one group at a time.",
1366
+ "users host-multiple revoke": "Put someone back on one group at a time.",
1355
1367
  "users lock": "Lock a kid's account with their guardians (removes Community Hour).",
1356
1368
  "users unlock": "Unlock a kid's account with guardians (not Community Hour); rerun = refresh.",
1357
1369
  "users disable": "Soft-disable an account or whole family (reversible; refuses live billing).",
@@ -1596,6 +1608,7 @@ export const COMMAND_SUMMARIES = {
1596
1608
  "tuition list": "List tuition schedules built from signed admission packets.",
1597
1609
  "tuition show": "One tuition schedule: its installments, the signed plan, the history.",
1598
1610
  "tuition edit": "Change an installment now (invoiced: void and reissue), or --ask-family first.",
1611
+ "tuition create": "Record a tuition schedule for a kid with no signed packet (sends nothing).",
1599
1612
  "tuition add": "Add an installment that was not on the signed plan.",
1600
1613
  "tuition release": "Release a past-dated installment from review.",
1601
1614
  "tuition void": "Void an installment (a Stripe draft is deleted, a sent invoice voided).",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recess-cli",
3
- "version": "3.55.0",
3
+ "version": "3.57.0",
4
4
  "description": "Safe Recess administration and family AI tools from the command line.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {