recess-cli 3.41.0 → 3.43.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/cli.js +8 -2
- package/dist/command-schema.js +1 -0
- package/dist/commands/phone-and-texts.js +106 -0
- package/dist/help.js +5 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -22,7 +22,7 @@ import { runDmsCommand } from "./commands/dms.js";
|
|
|
22
22
|
import { runFeedCommand } from "./commands/feed.js";
|
|
23
23
|
import { runFamiliesCommand } from "./commands/families.js";
|
|
24
24
|
import { runFamilyCommand, runKidCommand, runMeCommand, } from "./commands/family.js";
|
|
25
|
-
import { runStudentsTextsCommand, runUsersPhoneCommand, } from "./commands/phone-and-texts.js";
|
|
25
|
+
import { runStudentsTextsCommand, runUsersPhoneCommand, runUsersTextCommand, runStudentsTextParentCommand, } from "./commands/phone-and-texts.js";
|
|
26
26
|
import { hasCommunityHour, runUsersCommunityHourCommand, } from "./commands/community-hour.js";
|
|
27
27
|
import { runTuitionPlansCommand } from "./commands/tuition-plans.js";
|
|
28
28
|
import { runReportsCommand } from "./commands/reports.js";
|
|
@@ -3237,6 +3237,9 @@ export async function executeRecessCommand(argv, options = {}) {
|
|
|
3237
3237
|
if (noun === "users" && verb === "phone") {
|
|
3238
3238
|
return runUsersPhoneCommand({ parsed, api, writeCommand });
|
|
3239
3239
|
}
|
|
3240
|
+
if (noun === "users" && verb === "text") {
|
|
3241
|
+
return runUsersTextCommand({ parsed, api, writeCommand });
|
|
3242
|
+
}
|
|
3240
3243
|
if (noun === "users" && verb === "community-hour") {
|
|
3241
3244
|
return runUsersCommunityHourCommand({ parsed, api, writeCommand });
|
|
3242
3245
|
}
|
|
@@ -3532,6 +3535,9 @@ export async function executeRecessCommand(argv, options = {}) {
|
|
|
3532
3535
|
return { studentId, added, removed: remove };
|
|
3533
3536
|
});
|
|
3534
3537
|
}
|
|
3538
|
+
if (noun === "students" && verb === "text-parent") {
|
|
3539
|
+
return runStudentsTextParentCommand({ parsed, api, writeCommand });
|
|
3540
|
+
}
|
|
3535
3541
|
if (noun === "students" && verb === "notes") {
|
|
3536
3542
|
if (parsed.positionals[2] !== "add") {
|
|
3537
3543
|
throw new CliError("invalid_arguments", "Use students notes add.");
|
|
@@ -5128,7 +5134,7 @@ export async function executeRecessCommand(argv, options = {}) {
|
|
|
5128
5134
|
: {}),
|
|
5129
5135
|
...(visibility
|
|
5130
5136
|
? {
|
|
5131
|
-
visibility: assertChoice(visibility, ["PUBLIC", "PRIVATE", "STAFF_ONLY"], "--visibility"),
|
|
5137
|
+
visibility: assertChoice(visibility, ["PUBLIC", "PRIVATE", "STAFF_ONLY", "UNLISTED"], "--visibility"),
|
|
5132
5138
|
}
|
|
5133
5139
|
: {}),
|
|
5134
5140
|
...(targetPlatform
|
package/dist/command-schema.js
CHANGED
|
@@ -6,6 +6,112 @@ const TEXT_FREQUENCIES = ["all", "daily", "important"];
|
|
|
6
6
|
function fullName(user) {
|
|
7
7
|
return [user.firstName, user.lastName].filter(Boolean).join(" ");
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* What the parent reads: the server leads the text with the sender's name so
|
|
11
|
+
* they can tell a person wrote it (`staffTextBody` in
|
|
12
|
+
* web-server `parent-agent/staff-text.ts`). Shown in the preview for approval.
|
|
13
|
+
*/
|
|
14
|
+
async function staffTextPreview(api, text) {
|
|
15
|
+
const session = unwrap(await api.client.GET("/auth/admin-cli/session/"));
|
|
16
|
+
const name = session.user.firstName?.trim();
|
|
17
|
+
return `${name ? `${name} from Recess` : "Recess team"}: ${text}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `users text <user-id> --text TEXT` — text a parent from Rocky's number, led
|
|
21
|
+
* by the sender's name. Their reply goes to Rocky, who sees the text in the
|
|
22
|
+
* thread.
|
|
23
|
+
*/
|
|
24
|
+
export async function runUsersTextCommand({ parsed, api, writeCommand, }) {
|
|
25
|
+
const userId = positional(parsed, 2, "user ID");
|
|
26
|
+
const text = flagString(parsed, "text", { required: true }).trim();
|
|
27
|
+
if (!text || text.length > 1000) {
|
|
28
|
+
throw new CliError("invalid_arguments", "--text must be 1 to 1000 characters.");
|
|
29
|
+
}
|
|
30
|
+
const { user } = unwrap(await api.client.GET("/admin/users/{userId}", {
|
|
31
|
+
params: { path: { userId } },
|
|
32
|
+
}));
|
|
33
|
+
if (user.role !== "GUARDIAN" && user.role !== "ADMIN") {
|
|
34
|
+
throw new CliError("invalid_arguments", `Only a parent can get a text from Rocky; this user is a ${user.role}.`);
|
|
35
|
+
}
|
|
36
|
+
if (!user.phoneNumber) {
|
|
37
|
+
throw new CliError("invalid_arguments", "This parent has no phone number.");
|
|
38
|
+
}
|
|
39
|
+
return writeCommand(parsed, {
|
|
40
|
+
action: "text this parent from Rocky's number, signed with your first name (it sends right away; their reply goes to Rocky)",
|
|
41
|
+
target: { userId: user.id },
|
|
42
|
+
request: { text },
|
|
43
|
+
details: {
|
|
44
|
+
recipient: {
|
|
45
|
+
name: fullName(user),
|
|
46
|
+
role: user.role,
|
|
47
|
+
phoneNumber: user.phoneNumber,
|
|
48
|
+
},
|
|
49
|
+
parentReads: await staffTextPreview(api, text),
|
|
50
|
+
},
|
|
51
|
+
}, async () => {
|
|
52
|
+
const result = unwrap(await api.client.POST("/admin/users/{userId}/rocky-text/", {
|
|
53
|
+
params: { path: { userId: user.id } },
|
|
54
|
+
body: { text },
|
|
55
|
+
}));
|
|
56
|
+
if (!result.sent) {
|
|
57
|
+
throw new CliError("text_not_sent", `The text was not sent: ${result.skippedReason ?? "unknown reason"}.`);
|
|
58
|
+
}
|
|
59
|
+
return { userId: user.id, name: fullName(user), ...result };
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* `students text-parent --student <kid-id> [--parent <id>] --text TEXT` — the
|
|
64
|
+
* same text, for a parent of a kid the caller manages (guides and admins).
|
|
65
|
+
* `--parent` is only needed when the kid has more than one parent who can get
|
|
66
|
+
* a text.
|
|
67
|
+
*/
|
|
68
|
+
export async function runStudentsTextParentCommand({ parsed, api, writeCommand, }) {
|
|
69
|
+
const studentId = flagString(parsed, "student", { required: true });
|
|
70
|
+
const parentFlag = flagString(parsed, "parent");
|
|
71
|
+
const text = flagString(parsed, "text", { required: true }).trim();
|
|
72
|
+
if (!text || text.length > 1000) {
|
|
73
|
+
throw new CliError("invalid_arguments", "--text must be 1 to 1000 characters.");
|
|
74
|
+
}
|
|
75
|
+
const { parents } = unwrap(await api.client.GET("/tutor/students/{studentId}/parents", {
|
|
76
|
+
params: { path: { studentId } },
|
|
77
|
+
}));
|
|
78
|
+
const reachable = parents.filter((p) => p.hasPhone && !p.textsOff);
|
|
79
|
+
const parent = parentFlag
|
|
80
|
+
? parents.find((p) => p.id === parentFlag)
|
|
81
|
+
: reachable.length === 1
|
|
82
|
+
? reachable[0]
|
|
83
|
+
: undefined;
|
|
84
|
+
if (!parent) {
|
|
85
|
+
throw new CliError("invalid_arguments", parentFlag
|
|
86
|
+
? "--parent is not a parent of this kid."
|
|
87
|
+
: reachable.length
|
|
88
|
+
? "This kid has more than one parent who can get a text: choose one with --parent."
|
|
89
|
+
: "This kid has no parent who can get a text.", 1, { parents });
|
|
90
|
+
}
|
|
91
|
+
if (!parent.hasPhone || parent.textsOff) {
|
|
92
|
+
throw new CliError("invalid_arguments", parent.textsOff
|
|
93
|
+
? "This parent replied STOP to Rocky's texts."
|
|
94
|
+
: "This parent has no phone number.");
|
|
95
|
+
}
|
|
96
|
+
return writeCommand(parsed, {
|
|
97
|
+
action: "text this parent from Rocky's number, signed with your first name (it sends right away; their reply goes to Rocky)",
|
|
98
|
+
target: { studentUserId: studentId, parentUserId: parent.id },
|
|
99
|
+
request: { text },
|
|
100
|
+
details: {
|
|
101
|
+
recipient: { name: parent.name },
|
|
102
|
+
parentReads: await staffTextPreview(api, text),
|
|
103
|
+
},
|
|
104
|
+
}, async () => {
|
|
105
|
+
const result = unwrap(await api.client.POST("/tutor/students/{studentId}/parents/{parentId}/text", {
|
|
106
|
+
params: { path: { studentId, parentId: parent.id } },
|
|
107
|
+
body: { text },
|
|
108
|
+
}));
|
|
109
|
+
if (!result.sent) {
|
|
110
|
+
throw new CliError("text_not_sent", `The text was not sent: ${result.skippedReason ?? "unknown reason"}.`);
|
|
111
|
+
}
|
|
112
|
+
return { parentId: parent.id, name: parent.name, ...result };
|
|
113
|
+
});
|
|
114
|
+
}
|
|
9
115
|
/**
|
|
10
116
|
* `users phone get|set|clear` — a user's SMS/login phone number. The server
|
|
11
117
|
* normalizes whatever is typed to E.164 (bare numbers read as US) and rejects
|
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 text <user-id> --text TEXT [--confirm]
|
|
55
56
|
recess [--json] users lock <user-id> [--confirm]
|
|
56
57
|
recess [--json] users unlock <user-id> [--confirm]
|
|
57
58
|
recess [--json] users community-hour get <kid-id>
|
|
@@ -84,6 +85,7 @@ Usage:
|
|
|
84
85
|
recess [--json] students web-todos --student <kid-id> [--on|--off] [--confirm]
|
|
85
86
|
recess [--json] students flashcards --student <kid-id> [--on|--off] [--confirm]
|
|
86
87
|
recess [--json] students notes add --student <kid-id> --text TEXT [--confirm]
|
|
88
|
+
recess [--json] students text-parent --student <kid-id> [--parent <parent-id>] --text TEXT [--confirm]
|
|
87
89
|
recess [--json] students interests --student <kid-id> [--add LABEL]...
|
|
88
90
|
[--remove <interest-id>]... [--confirm]
|
|
89
91
|
recess [--json] chat-logs list --student <user-id> [--limit 100] [--cursor <cursor>]
|
|
@@ -625,7 +627,7 @@ Usage:
|
|
|
625
627
|
[--image-url URL] [--coin-amount N] [--chat-title TEXT|none] [--sort-order N]
|
|
626
628
|
[--is-starter true|false] [--setup-audience KID_FRIENDLY|PARENT_SETUP]
|
|
627
629
|
[--kind SIMPLE|BLUEPRINT]
|
|
628
|
-
[--visibility PUBLIC|PRIVATE|STAFF_ONLY] [--target-platform ANY|MOBILE|DESKTOP]
|
|
630
|
+
[--visibility PUBLIC|PRIVATE|STAFF_ONLY|UNLISTED] [--target-platform ANY|MOBILE|DESKTOP]
|
|
629
631
|
[--page-ink true|false]
|
|
630
632
|
[--agent-instructions-file <path>] [--output-template-file <path>] [--confirm]
|
|
631
633
|
recess [--json] goal-templates delete <template-id> [--expected-version N] [--confirm]
|
|
@@ -1249,6 +1251,7 @@ export const COMMAND_SUMMARIES = {
|
|
|
1249
1251
|
"users phone get": "Read a user's phone number and verification.",
|
|
1250
1252
|
"users phone set": "Set a user's phone number (stored E.164, unverified).",
|
|
1251
1253
|
"users phone clear": "Remove a user's phone number.",
|
|
1254
|
+
"users text": "Text a parent from Rocky's number, signed with your first name.",
|
|
1252
1255
|
"users community-hour get": "Show whether a kid can join Community Hour.",
|
|
1253
1256
|
"users community-hour unlock": "Let a kid join Community Hour and enter the Village.",
|
|
1254
1257
|
"users community-hour lock": "Stop a kid joining Community Hour or the Village.",
|
|
@@ -1272,6 +1275,7 @@ export const COMMAND_SUMMARIES = {
|
|
|
1272
1275
|
"students web-todos": "Show or set whether a kid's todos run on web (off: they open in the desktop app).",
|
|
1273
1276
|
"students flashcards": "Show or set whether a kid gets a daily flashcard review todo.",
|
|
1274
1277
|
"students interests": "List, add, or remove a kid's interests (Rocky, the feed, and reading/writing passages use them).",
|
|
1278
|
+
"students text-parent": "Text a kid's parent from Rocky's number, signed with your first name; the reply goes to Rocky.",
|
|
1275
1279
|
"students notes add": "Add a staff-visible guide note to a kid's profile (Rocky reads it).",
|
|
1276
1280
|
"chat-logs list": "List a student's AI chat conversations.",
|
|
1277
1281
|
"chat-logs get": "Read one AI chat conversation.",
|