@dench.com/cli 3.11.59 → 3.11.60-staging.1143
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/email.ts +84 -5
- package/package.json +1 -1
package/email.ts
CHANGED
|
@@ -206,6 +206,85 @@ export async function collectPaginated(
|
|
|
206
206
|
return { rows, pagesFetched, isDone, continueCursor: cursor };
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
/**
|
|
210
|
+
* The `--status` filters the list commands accept. Each mirrors the server's
|
|
211
|
+
* argument validator (`rawMessageStatus`, `recipientStatus`, `campaignStatus`
|
|
212
|
+
* in convex/functions/emailCampaigns.ts, `enrollmentStatus` in
|
|
213
|
+
* emailSequences.ts); `email-status-flags.test.ts` fails if they drift.
|
|
214
|
+
* Checking here turns a guessed value into a usable error instead of a
|
|
215
|
+
* server-side ArgumentValidationError (issue #2729: `--status undeliverable`).
|
|
216
|
+
*/
|
|
217
|
+
export const MESSAGE_STATUSES = [
|
|
218
|
+
"queued",
|
|
219
|
+
"sent",
|
|
220
|
+
"failed",
|
|
221
|
+
"delivered",
|
|
222
|
+
"opened",
|
|
223
|
+
"clicked",
|
|
224
|
+
"bounced",
|
|
225
|
+
"complained",
|
|
226
|
+
] as const;
|
|
227
|
+
export const CAMPAIGN_STATUSES = [
|
|
228
|
+
"draft",
|
|
229
|
+
"pending_approval",
|
|
230
|
+
"scheduled",
|
|
231
|
+
"sending",
|
|
232
|
+
"paused",
|
|
233
|
+
"completed",
|
|
234
|
+
"cancelled",
|
|
235
|
+
"failed",
|
|
236
|
+
"archived",
|
|
237
|
+
] as const;
|
|
238
|
+
export const RECIPIENT_STATUSES = [
|
|
239
|
+
"queued",
|
|
240
|
+
"sending",
|
|
241
|
+
"sent",
|
|
242
|
+
"delivered",
|
|
243
|
+
"opened",
|
|
244
|
+
"clicked",
|
|
245
|
+
"bounced",
|
|
246
|
+
"complained",
|
|
247
|
+
"failed",
|
|
248
|
+
"suppressed",
|
|
249
|
+
"unsubscribed",
|
|
250
|
+
] as const;
|
|
251
|
+
export const ENROLLMENT_STATUSES = [
|
|
252
|
+
"active",
|
|
253
|
+
"paused",
|
|
254
|
+
"finished",
|
|
255
|
+
"stopped",
|
|
256
|
+
"replied",
|
|
257
|
+
"bounced",
|
|
258
|
+
"complained",
|
|
259
|
+
"unsubscribed",
|
|
260
|
+
"failed",
|
|
261
|
+
] as const;
|
|
262
|
+
|
|
263
|
+
/** Words people (and agents) reach for that name an existing status. */
|
|
264
|
+
const STATUS_SYNONYMS: Record<string, string> = {
|
|
265
|
+
undeliverable: "bounced",
|
|
266
|
+
undelivered: "bounced",
|
|
267
|
+
bounce: "bounced",
|
|
268
|
+
spam: "complained",
|
|
269
|
+
canceled: "cancelled",
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
function statusFlag(
|
|
273
|
+
args: string[],
|
|
274
|
+
allowed: readonly string[],
|
|
275
|
+
): string | undefined {
|
|
276
|
+
const raw = getFlag(args, "--status");
|
|
277
|
+
if (raw === undefined) return undefined;
|
|
278
|
+
const value = raw.trim().toLowerCase();
|
|
279
|
+
if (allowed.includes(value)) return value;
|
|
280
|
+
const synonym = STATUS_SYNONYMS[value];
|
|
281
|
+
const hint =
|
|
282
|
+
synonym && allowed.includes(synonym) ? ` Did you mean "${synonym}"?` : "";
|
|
283
|
+
throw new EmailCliError(
|
|
284
|
+
`--status must be one of ${allowed.join(", ")} (got "${raw}").${hint}`,
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
209
288
|
function maxPagesFlag(args: string[]): number {
|
|
210
289
|
const raw = getFlag(args, "--max-pages");
|
|
211
290
|
if (raw === undefined) return DEFAULT_MAX_PAGES;
|
|
@@ -411,7 +490,7 @@ ${EMAIL_INBOX_HELP}
|
|
|
411
490
|
dench email identity forward --identity <identityId|email> --off [--json] # turn forwarding off
|
|
412
491
|
dench email send --from founder@example.com --to "Ada <ada@x.com>,bob@y.com" --subject "Hi" (--html-file body.html | --text "...") [--cc ...] [--bcc ...] [--from-name "Ada"] [--reply-to support@x.com] [--reply-message-id <messageId|rfc-id>] [--json]
|
|
413
492
|
dench email message status --message <messageId> [--json]
|
|
414
|
-
dench email message list [--limit 25] [--status sent] [--cursor <nextCursor>] [--json]
|
|
493
|
+
dench email message list [--limit 25] [--status queued|sent|failed|delivered|opened|clicked|bounced|complained] [--cursor <nextCursor>] [--json]
|
|
415
494
|
dench email template create --name "Intro" --subject "Hi {{firstName}}" --html-file body.html [--text-file body.txt] [--json]
|
|
416
495
|
dench email template preview --template <id> --data '{"firstName":"Ada"}' [--json]
|
|
417
496
|
dench email campaign create --name "Q2 outreach" (--mailbox you@gmail.com | --identity <identityId|fromEmail>) --template <id> [--json]
|
|
@@ -923,7 +1002,7 @@ async function runMessage(ctx: EmailCliContext) {
|
|
|
923
1002
|
}
|
|
924
1003
|
if (sub === "list") {
|
|
925
1004
|
const limitRaw = getFlag(ctx.args, "--limit");
|
|
926
|
-
const status =
|
|
1005
|
+
const status = statusFlag(ctx.args, MESSAGE_STATUSES);
|
|
927
1006
|
const cursor = getFlag(ctx.args, "--cursor");
|
|
928
1007
|
const page = await readMessageLogPage(ctx, {
|
|
929
1008
|
limit: limitRaw ? Number(limitRaw) : undefined,
|
|
@@ -1347,7 +1426,7 @@ async function runCampaign(ctx: EmailCliContext) {
|
|
|
1347
1426
|
}
|
|
1348
1427
|
if (sub === "list") {
|
|
1349
1428
|
const limitRaw = getFlag(ctx.args, "--limit");
|
|
1350
|
-
const status =
|
|
1429
|
+
const status = statusFlag(ctx.args, CAMPAIGN_STATUSES);
|
|
1351
1430
|
const maxPages = maxPagesFlag(ctx.args);
|
|
1352
1431
|
const numItems = limitRaw ? Number(limitRaw) : 25;
|
|
1353
1432
|
const result = await collectPaginated(
|
|
@@ -1371,7 +1450,7 @@ async function runCampaign(ctx: EmailCliContext) {
|
|
|
1371
1450
|
const nested = ctx.args.shift();
|
|
1372
1451
|
if (nested === "list") {
|
|
1373
1452
|
const limitRaw = getFlag(ctx.args, "--limit");
|
|
1374
|
-
const status =
|
|
1453
|
+
const status = statusFlag(ctx.args, RECIPIENT_STATUSES);
|
|
1375
1454
|
const summary = hasFlag(ctx.args, "--summary");
|
|
1376
1455
|
const maxPages = maxPagesFlag(ctx.args);
|
|
1377
1456
|
const campaignId = await resolveCampaignRef(ctx);
|
|
@@ -1721,7 +1800,7 @@ async function runSequence(ctx: EmailCliContext) {
|
|
|
1721
1800
|
numItems: limitRaw ? Number(limitRaw) : 50,
|
|
1722
1801
|
cursor: null,
|
|
1723
1802
|
},
|
|
1724
|
-
status:
|
|
1803
|
+
status: statusFlag(ctx.args, ENROLLMENT_STATUSES),
|
|
1725
1804
|
},
|
|
1726
1805
|
);
|
|
1727
1806
|
out(ctx, payload, JSON.stringify(payload, null, 2));
|