@curviate/cli 0.57.0 → 0.58.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/CHANGELOG.md +93 -0
- package/README.md +9 -2
- package/dist/{account-IRIYB2SG.js → account-GSL6BCNX.js} +52 -16
- package/dist/{analytics-IRSCLVOL.js → analytics-4FUMJSMC.js} +6 -6
- package/dist/{beta-consent-NQVGFZL3.js → beta-consent-EC2QF6CM.js} +4 -4
- package/dist/billing-STRNXA4H.js +19 -0
- package/dist/{chunk-6OT6TS7N.js → chunk-3IL3D5IZ.js} +2 -2
- package/dist/{chunk-3ZQNOKEK.js → chunk-5OAJ4D65.js} +2 -2
- package/dist/{chunk-AMTKGO37.js → chunk-5Z3CCE5N.js} +1 -1
- package/dist/{billing-TCTP44ZB.js → chunk-7F6B7P32.js} +123 -12
- package/dist/{chunk-3B5M2RUN.js → chunk-CQHCPZ5I.js} +1 -1
- package/dist/{chunk-SCUTAREU.js → chunk-EWSOIFG2.js} +17 -0
- package/dist/{chunk-RKNW4UX4.js → chunk-JKOQX46J.js} +6 -0
- package/dist/{chunk-VHNF6OZD.js → chunk-JY26SUNH.js} +18 -2
- package/dist/{chunk-VPFV7YV3.js → chunk-KS4I4B3Z.js} +6 -6
- package/dist/{chunk-OE4CY3ZL.js → chunk-KUVJM5CP.js} +1 -1
- package/dist/{chunk-F7CLAS5Y.js → chunk-MLZSXQZC.js} +2 -2
- package/dist/{chunk-RXDG57B2.js → chunk-PBJZQZPO.js} +1 -1
- package/dist/{chunk-A6JGJGDF.js → chunk-WGGZWJPO.js} +16 -16
- package/dist/{chunk-AG6G3PRQ.js → chunk-WITIJCUU.js} +17 -13
- package/dist/{chunk-5LGKZBAY.js → chunk-XDPU2YAF.js} +4 -3
- package/dist/{chunk-RTT75CXE.js → chunk-XXB4MAX3.js} +86 -14
- package/dist/cli.js +33 -33
- package/dist/{comment-PNHEKGZX.js → comment-MUELYZYN.js} +8 -8
- package/dist/{company-OUFF23SU.js → company-5N7CXORR.js} +8 -8
- package/dist/{company-record-ULPDDB6L.js → company-record-HWLTP4TV.js} +95 -10
- package/dist/{config-U6VDNL2P.js → config-PI7JMQ2L.js} +2 -2
- package/dist/{connect-ICNXC37R.js → connect-NNZOOPWV.js} +11 -11
- package/dist/{contact-K6RIVQWU.js → contact-VNG7HRCN.js} +9 -9
- package/dist/{contact-groups-CNH2VB6A.js → contact-groups-6JF7VX6Q.js} +11 -11
- package/dist/{contact-import-FK22UTN2.js → contact-import-TMJWY2VD.js} +11 -11
- package/dist/core-ZRJY3HTF.js +46 -0
- package/dist/{do-not-contact-BQHXNHTV.js → do-not-contact-GDVIUNMT.js} +22 -20
- package/dist/{doctor-ZYPZF5BE.js → doctor-ZNAR5AZ2.js} +4 -4
- package/dist/{document-H65EXU4L.js → document-G6UND26L.js} +1 -1
- package/dist/{domain-HLOT6Y4A.js → domain-62YUYVDW.js} +5 -5
- package/dist/{draft-JGQ36JSH.js → draft-ED6RL67K.js} +5 -5
- package/dist/{enrollment-CF634DB4.js → enrollment-LN3Z3RC5.js} +14 -10
- package/dist/{examples-J4X5NEIE.js → examples-5FJS47QF.js} +2 -2
- package/dist/{exit-codes-P2FLCKM7.js → exit-codes-LQDMGDII.js} +1 -1
- package/dist/{export-ZQLDQYUZ.js → export-S6D4FEAG.js} +4 -4
- package/dist/{feed-RQHEDZVL.js → feed-AC7HWUCD.js} +6 -6
- package/dist/{group-LRMG76FN.js → group-6N37Q5ZS.js} +6 -6
- package/dist/{inbox-5RGG5RQG.js → inbox-JFRBROQ2.js} +6 -6
- package/dist/{inboxes-ZFY6ZP33.js → inboxes-IBZHZKSD.js} +6 -6
- package/dist/{incoming-3MJ4CP6H.js → incoming-YDRPPO24.js} +8 -8
- package/dist/{job-QFIUTHHT.js → job-CSRHIFZM.js} +6 -6
- package/dist/{login-THXWX5HZ.js → login-M7ZLOR2U.js} +2 -2
- package/dist/mailbox-E2K3I2VH.js +712 -0
- package/dist/{message-DM5OUKQS.js → message-SX6RDGWP.js} +7 -7
- package/dist/{motion-NKOAK7NU.js → motion-4HH3OFI6.js} +121 -16
- package/dist/{network-VKJUMZ2L.js → network-JQYLSQDH.js} +12 -12
- package/dist/{notification-XW5J6KFA.js → notification-ZAQM463D.js} +6 -6
- package/dist/{notifications-USYOV54R.js → notifications-N55F3DP3.js} +9 -9
- package/dist/{post-M2G3BK4A.js → post-SIHHJX3P.js} +8 -8
- package/dist/{profile-3SG64IEG.js → profile-VBHX3QGP.js} +12 -12
- package/dist/{recruiter-7OUGZ776.js → recruiter-7AGFKQPI.js} +9 -9
- package/dist/{sales-nav-HHQLLM5C.js → sales-nav-ADVFBKWB.js} +9 -9
- package/dist/{search-5LMSLUH4.js → search-THJFPGOH.js} +16 -16
- package/dist/{setup-6F4HYUSZ.js → setup-D6D7SNND.js} +4 -4
- package/dist/{signal-LVODDBOY.js → signal-TGSF7WEP.js} +126 -19
- package/dist/{team-MSOPELF6.js → team-MVNHCWJP.js} +8 -8
- package/dist/{tier-RXHOAQ6L.js → tier-DAF7Y2HN.js} +4 -4
- package/dist/{unibox-UAA6WIGZ.js → unibox-7B6B4SXB.js} +292 -14
- package/dist/{webhook-J2H7X766.js → webhook-NUVSTDXF.js} +12 -12
- package/package.json +3 -3
- package/dist/core-MPEBYNSL.js +0 -46
- package/dist/mailbox-54DPLNXA.js +0 -412
|
@@ -0,0 +1,712 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
confirmMoney
|
|
4
|
+
} from "./chunk-7F6B7P32.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveSecret
|
|
7
|
+
} from "./chunk-DENWYJK2.js";
|
|
8
|
+
import "./chunk-GOICALYQ.js";
|
|
9
|
+
import {
|
|
10
|
+
fail,
|
|
11
|
+
outputOpts,
|
|
12
|
+
rootClient,
|
|
13
|
+
usage
|
|
14
|
+
} from "./chunk-5OAJ4D65.js";
|
|
15
|
+
import {
|
|
16
|
+
buildPreviewOutput
|
|
17
|
+
} from "./chunk-TCUYH5GO.js";
|
|
18
|
+
import {
|
|
19
|
+
intFlag
|
|
20
|
+
} from "./chunk-NNV2OYEF.js";
|
|
21
|
+
import {
|
|
22
|
+
pageDelayFromFlags,
|
|
23
|
+
readCursorFlag,
|
|
24
|
+
readMaxPagesFlag,
|
|
25
|
+
readableObject,
|
|
26
|
+
readablePage,
|
|
27
|
+
rejectPaginationModifiersWithoutAll,
|
|
28
|
+
streamAll
|
|
29
|
+
} from "./chunk-KUVJM5CP.js";
|
|
30
|
+
import {
|
|
31
|
+
renderSuccess,
|
|
32
|
+
writeNdjsonItem
|
|
33
|
+
} from "./chunk-QM57YDJE.js";
|
|
34
|
+
import "./chunk-IB6ARI3R.js";
|
|
35
|
+
import "./chunk-PBJZQZPO.js";
|
|
36
|
+
import {
|
|
37
|
+
GLOBAL_FLAGS,
|
|
38
|
+
READ_SINGLE_FLAGS,
|
|
39
|
+
WRITE_SINGLE_FLAGS,
|
|
40
|
+
readOnly
|
|
41
|
+
} from "./chunk-QLKGOIWS.js";
|
|
42
|
+
import {
|
|
43
|
+
DESCRIPTIONS
|
|
44
|
+
} from "./chunk-XDPU2YAF.js";
|
|
45
|
+
import {
|
|
46
|
+
readFileFlag
|
|
47
|
+
} from "./chunk-JKOQX46J.js";
|
|
48
|
+
import "./chunk-FDJMAF7D.js";
|
|
49
|
+
import "./chunk-ZYURL5VK.js";
|
|
50
|
+
import {
|
|
51
|
+
getExitCode
|
|
52
|
+
} from "./chunk-EWSOIFG2.js";
|
|
53
|
+
|
|
54
|
+
// src/commands/mailbox.ts
|
|
55
|
+
import { defineCommand } from "citty";
|
|
56
|
+
var TEST_BODY_MAX_BYTES = 64 * 1024;
|
|
57
|
+
var PURCHASE_STATES = ["awaiting_dns", "provisioning", "active", "cancelled"];
|
|
58
|
+
var MAILBOX_PRICE_CENTS = 500;
|
|
59
|
+
var STATES = ["connected", "ramping", "paused", "paused_by_bounces", "paused_by_provider", "reconnect_needed"];
|
|
60
|
+
var SIGNATURE_MAX_BYTES = 64 * 1024;
|
|
61
|
+
var online = (fn) => async ({ args }) => {
|
|
62
|
+
const f = args;
|
|
63
|
+
await fn(await rootClient(f), f);
|
|
64
|
+
};
|
|
65
|
+
var preview = (method, args, body = {}) => void process.stdout.write(JSON.stringify(buildPreviewOutput({ method, args, body })) + "\n");
|
|
66
|
+
async function runList(c, f) {
|
|
67
|
+
rejectPaginationModifiersWithoutAll(f, process);
|
|
68
|
+
const params = {};
|
|
69
|
+
if (f.state !== void 0) {
|
|
70
|
+
if (!STATES.includes(f.state)) usage(`--state takes one of ${STATES.join(", ")}.`);
|
|
71
|
+
params["state"] = f.state;
|
|
72
|
+
}
|
|
73
|
+
for (const [flag, key] of [["sends-for", "sends_for"], ["domain", "domain"]]) {
|
|
74
|
+
const v = f[flag];
|
|
75
|
+
if (v === void 0) continue;
|
|
76
|
+
if (v.trim() === "") usage(`--${flag} was given an empty value.`);
|
|
77
|
+
params[key] = v;
|
|
78
|
+
}
|
|
79
|
+
if (f.limit !== void 0) params["limit"] = intFlag("limit", f.limit, 1, 100);
|
|
80
|
+
const cursor = readCursorFlag(f, process);
|
|
81
|
+
if (cursor) params["cursor"] = cursor;
|
|
82
|
+
try {
|
|
83
|
+
if (f.all) {
|
|
84
|
+
const page = (p) => c.mailboxes.list(p);
|
|
85
|
+
for await (const item of streamAll(page, params, { maxPages: readMaxPagesFlag(f, process), out: process, pageDelayMs: pageDelayFromFlags(f) })) writeNdjsonItem(process, item, f.fields);
|
|
86
|
+
} else {
|
|
87
|
+
renderSuccess(readablePage(await c.mailboxes.list(params)), outputOpts(f), process);
|
|
88
|
+
}
|
|
89
|
+
} catch (err) {
|
|
90
|
+
await fail(err, f);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function runGet(c, f) {
|
|
94
|
+
try {
|
|
95
|
+
renderSuccess(readableObject(await c.mailboxes.get(String(f.id ?? ""))), outputOpts(f), process);
|
|
96
|
+
} catch (err) {
|
|
97
|
+
await fail(err, f);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function runUpdate(c, f) {
|
|
101
|
+
const id = String(f.id ?? "");
|
|
102
|
+
const body = {};
|
|
103
|
+
const link = f["sends-for"];
|
|
104
|
+
if (link !== void 0) {
|
|
105
|
+
if (link.trim() === "") usage("--sends-for was given an empty value: an Account id (acc_...) or shared.");
|
|
106
|
+
body["sends_for"] = link === "shared" ? { kind: "shared" } : { kind: "account", account_id: link };
|
|
107
|
+
}
|
|
108
|
+
if (f["daily-cap"] !== void 0) body["daily_cap"] = intFlag("daily-cap", f["daily-cap"]);
|
|
109
|
+
if (f["signature-file"] !== void 0) body["signature"] = (await readFileFlag("signature-file", f["signature-file"], { maxBytes: SIGNATURE_MAX_BYTES, others: f })).trimEnd();
|
|
110
|
+
if (f["display-name"] !== void 0 && f["clear-display-name"]) usage("--display-name and --clear-display-name cannot be combined.");
|
|
111
|
+
if (f["display-name"] !== void 0) body["display_name"] = f["display-name"];
|
|
112
|
+
if (f["clear-display-name"]) body["display_name"] = null;
|
|
113
|
+
if (f["warm-up"] !== void 0 || f.days !== void 0) {
|
|
114
|
+
const on = f["warm-up"] === "on" ? true : f["warm-up"] === "off" ? false : f["warm-up"] === void 0 ? usage("--days goes with --warm-up on.") : usage("--warm-up takes on or off.");
|
|
115
|
+
if (on && f.days === void 0) usage("--warm-up on needs --days: 10, 14, 21 or 28.");
|
|
116
|
+
if (!on && f.days !== void 0) usage("--days goes with --warm-up on.");
|
|
117
|
+
const days = f.days === void 0 ? void 0 : intFlag("days", f.days);
|
|
118
|
+
if (days !== void 0 && ![10, 14, 21, 28].includes(days)) usage("--days takes 10, 14, 21 or 28.");
|
|
119
|
+
body["warm_up"] = on ? { enabled: true, days } : { enabled: false };
|
|
120
|
+
}
|
|
121
|
+
if (Object.keys(body).length === 0) usage("pass at least one of --sends-for, --daily-cap, --signature-file, --display-name, --clear-display-name, --warm-up.");
|
|
122
|
+
if (f.preview) return preview("mailboxes.update", { id }, body);
|
|
123
|
+
try {
|
|
124
|
+
renderSuccess(readableObject(await c.mailboxes.update(id, body)), outputOpts(f), process);
|
|
125
|
+
} catch (err) {
|
|
126
|
+
await fail(err, f);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function runTest(c, f) {
|
|
130
|
+
const id = String(f.id ?? "");
|
|
131
|
+
if (f.subject === void 0 || f.subject.trim() === "") usage("--subject is required: the subject exactly as your Campaign sends it.");
|
|
132
|
+
if (f["body-file"] === void 0) usage("--body-file is required: a plain-text file with the body exactly as your Campaign sends it, or - for stdin.");
|
|
133
|
+
const body = { subject: f.subject, body: (await readFileFlag("body-file", f["body-file"], { maxBytes: TEST_BODY_MAX_BYTES, others: f })).trimEnd() };
|
|
134
|
+
if (f.preview) return preview("mailboxes.placementTests.run", { id }, body);
|
|
135
|
+
try {
|
|
136
|
+
renderSuccess(readableObject(await c.mailboxes.placementTests.run(id, body)), outputOpts(f), process);
|
|
137
|
+
} catch (err) {
|
|
138
|
+
await fail(err, f);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async function runTests(c, f) {
|
|
142
|
+
const id = String(f.id ?? "");
|
|
143
|
+
try {
|
|
144
|
+
if (f.testId !== void 0) return renderSuccess(readableObject(await c.mailboxes.placementTests.get(id, f.testId)), outputOpts(f), process);
|
|
145
|
+
const params = {};
|
|
146
|
+
if (f.limit !== void 0) params["limit"] = intFlag("limit", f.limit, 1, 100);
|
|
147
|
+
const cursor = readCursorFlag(f, process);
|
|
148
|
+
if (cursor) params["cursor"] = cursor;
|
|
149
|
+
renderSuccess(readablePage(await c.mailboxes.placementTests.list(id, params)), outputOpts(f), process);
|
|
150
|
+
} catch (err) {
|
|
151
|
+
await fail(err, f);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function parseMailboxSpec(raw) {
|
|
155
|
+
const at = raw.indexOf(":");
|
|
156
|
+
if (at <= 0 || raw.slice(at + 1).trim() === "") usage(`--mailbox ${JSON.stringify(raw)}: write it as local:"Name", optionally :acc_... or :shared at the end.`);
|
|
157
|
+
let name = raw.slice(at + 1);
|
|
158
|
+
let sendsFor;
|
|
159
|
+
const last = name.lastIndexOf(":");
|
|
160
|
+
const tail = last >= 0 ? name.slice(last + 1) : "";
|
|
161
|
+
if (tail === "shared" || /^acc_\S+$/.test(tail)) {
|
|
162
|
+
sendsFor = tail === "shared" ? { kind: "shared" } : { kind: "account", account_id: tail };
|
|
163
|
+
name = name.slice(0, last);
|
|
164
|
+
}
|
|
165
|
+
return { local_part: raw.slice(0, at), display_name: name, ...sendsFor ? { sends_for: sendsFor } : {} };
|
|
166
|
+
}
|
|
167
|
+
var BUY_PAST_CAP = "This order would take your Team past its cap on Mailboxes from Curviate. Nothing was ordered. Only a Team Owner raises the cap, in the dashboard.";
|
|
168
|
+
async function runBuy(c, f) {
|
|
169
|
+
const domain = f.domain ?? "";
|
|
170
|
+
if (domain.trim() === "") usage("--domain is required: the domain the Mailboxes send from, one your Team owns.");
|
|
171
|
+
const specs = f.mailbox === void 0 ? [] : [].concat(f.mailbox);
|
|
172
|
+
if (specs.length === 0) usage('pass at least one --mailbox local:"Name", up to 50.');
|
|
173
|
+
if (specs.length > 50) usage("at most 50 --mailbox in one order.");
|
|
174
|
+
const body = { domain, mailboxes: specs.map(parseMailboxSpec) };
|
|
175
|
+
if (f.preview) return preview("mailboxes.purchases.create", {}, body);
|
|
176
|
+
const n = specs.length;
|
|
177
|
+
const monthly = `$${(n * MAILBOX_PRICE_CENTS / 100).toFixed(2)}`;
|
|
178
|
+
if (!await confirmMoney(f, `Order ${n} Mailbox${n === 1 ? "" : "es"} on ${domain} at ${monthly} a month? Nothing is charged until the records are found at your domain.`, "Each Mailbox costs $5 a month.")) return;
|
|
179
|
+
try {
|
|
180
|
+
renderSuccess(readableObject(await c.mailboxes.purchases.create(body)), outputOpts(f), process);
|
|
181
|
+
} catch (err) {
|
|
182
|
+
const { CurviateError } = await import("@curviate/sdk");
|
|
183
|
+
if (err instanceof CurviateError && err.code === "SPENDING_CAP_REACHED") {
|
|
184
|
+
process.stderr.write(`error [SPENDING_CAP_REACHED] ${BUY_PAST_CAP}
|
|
185
|
+
`);
|
|
186
|
+
process.exit(getExitCode(err));
|
|
187
|
+
}
|
|
188
|
+
await fail(err, f);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function purchaseNote(order) {
|
|
192
|
+
if (order.state === "provisioning") return `The Mailboxes are being set up. If that fails, the charge is undone in full and the order ends cancelled (host_failed). Read it again later: curviate mailbox purchase get ${String(order.id ?? "<id>")}. Do not order again meanwhile.`;
|
|
193
|
+
if (order.state === "cancelled" && order.reason === "host_failed") return "Setting up these Mailboxes failed, so the charge was undone in full. Nothing to retry.";
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
var printPurchase = (order, f) => {
|
|
197
|
+
renderSuccess(readableObject(order), outputOpts(f), process);
|
|
198
|
+
const note = purchaseNote(order);
|
|
199
|
+
if (note) process.stderr.write(note + "\n");
|
|
200
|
+
};
|
|
201
|
+
async function runPurchaseList(c, f) {
|
|
202
|
+
const params = {};
|
|
203
|
+
if (f.state !== void 0) {
|
|
204
|
+
if (!PURCHASE_STATES.includes(f.state)) usage(`--state takes one of ${PURCHASE_STATES.join(", ")}.`);
|
|
205
|
+
params["state"] = f.state;
|
|
206
|
+
}
|
|
207
|
+
if (f.limit !== void 0) params["limit"] = intFlag("limit", f.limit, 1, 100);
|
|
208
|
+
const cursor = readCursorFlag(f, process);
|
|
209
|
+
if (cursor) params["cursor"] = cursor;
|
|
210
|
+
try {
|
|
211
|
+
renderSuccess(await c.mailboxes.purchases.list(params), outputOpts(f), process);
|
|
212
|
+
} catch (err) {
|
|
213
|
+
await fail(err, f);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
async function runPurchaseCheck(c, f) {
|
|
217
|
+
try {
|
|
218
|
+
printPurchase(await c.mailboxes.purchases.check(String(f.id ?? "")), f);
|
|
219
|
+
} catch (err) {
|
|
220
|
+
await fail(err, f);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async function runPurchaseGet(c, f) {
|
|
224
|
+
try {
|
|
225
|
+
printPurchase(await c.mailboxes.purchases.get(String(f.id ?? "")), f);
|
|
226
|
+
} catch (err) {
|
|
227
|
+
await fail(err, f);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
var act = (verb) => async (c, f) => {
|
|
231
|
+
const id = String(f.id ?? "");
|
|
232
|
+
if (f.preview) return preview(`mailboxes.${verb}`, { id });
|
|
233
|
+
try {
|
|
234
|
+
renderSuccess(readableObject(await c.mailboxes[verb](id)), outputOpts(f), process);
|
|
235
|
+
} catch (err) {
|
|
236
|
+
await fail(err, f);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
var CONNECTIONS = ["google_app_password", "google_sign_in", "microsoft_sign_in", "imap_smtp"];
|
|
240
|
+
var PASSWORD_CONNECTIONS = ["google_app_password", "imap_smtp"];
|
|
241
|
+
var SERVER_FLAGS = ["imap-host", "imap-port", "imap-security", "smtp-host", "smtp-port", "smtp-security"];
|
|
242
|
+
var MAILBOX_REQUEST_INSTRUCTION = "Ask your user to open this link in the browser where they're signed in to Curviate. It expires in 15 minutes. Never ask them for their email password, in chat or anywhere else: a password never passes through you. They enter it on the link's page.";
|
|
243
|
+
async function runDiscover(c, f) {
|
|
244
|
+
const address = String(f.address ?? "");
|
|
245
|
+
if (address.trim() === "") usage("the address is empty. Pass the email address to look up.");
|
|
246
|
+
try {
|
|
247
|
+
renderSuccess(readableObject(await c.mailboxes.discover(address)), outputOpts(f), process);
|
|
248
|
+
} catch (err) {
|
|
249
|
+
await fail(err, f);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
async function readPassword(f) {
|
|
253
|
+
if (!f["password-stdin"]) return void 0;
|
|
254
|
+
if (f.preview) return "";
|
|
255
|
+
return resolveSecret({
|
|
256
|
+
stdinRequested: true,
|
|
257
|
+
isTTY: process.stdin.isTTY ?? false,
|
|
258
|
+
required: true,
|
|
259
|
+
failMessage: "--password-stdin read an empty password; nothing was sent. Leave the flag out: the command prints a Connect request link, and the person enters the password on its page.",
|
|
260
|
+
out: process
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
var requestLines = (req) => req.status === "completed" ? [`Mailbox: ${req.mailbox_id ?? ""}`, `Request: ${req.id ?? ""}`] : [`Link: ${req.url ?? ""}`, `Expires: ${req.expires_at ?? ""}`, `Request: ${req.id ?? ""}`, ...req.admin_consent_url ? [`Administrator link: ${req.admin_consent_url}`] : []];
|
|
264
|
+
async function sendRequest(c, f, body) {
|
|
265
|
+
try {
|
|
266
|
+
const req = await c.connectRequests.create(body);
|
|
267
|
+
const opts = outputOpts(f);
|
|
268
|
+
if (opts.json) renderSuccess(req, opts, process);
|
|
269
|
+
if (req.error_code) {
|
|
270
|
+
process.stderr.write(`error [${req.error_code}] the request ${req.id ?? ""} is ${req.status ?? "open"}. Read it: curviate account connect-request get ${req.id ?? "<request_id>"}
|
|
271
|
+
`);
|
|
272
|
+
process.exit(getExitCode(req.error_code));
|
|
273
|
+
}
|
|
274
|
+
if (!opts.json) process.stdout.write(requestLines(req).join("\n") + "\n");
|
|
275
|
+
if (req.status !== "completed") process.stderr.write(`${MAILBOX_REQUEST_INSTRUCTION}
|
|
276
|
+
Check on it: curviate account connect-request get ${req.id ?? "<request_id>"}
|
|
277
|
+
`);
|
|
278
|
+
} catch (err) {
|
|
279
|
+
await fail(err, f);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
var withPassword = (body, password) => password === void 0 ? body : { ...body, credentials: { password } };
|
|
283
|
+
async function runConnect(c, f) {
|
|
284
|
+
const address = String(f.address ?? "");
|
|
285
|
+
if (address.trim() === "") usage("the address is empty. Pass the email address to connect.");
|
|
286
|
+
const connection = f.connection ?? "";
|
|
287
|
+
if (!CONNECTIONS.includes(connection)) usage(`--connection takes one of ${CONNECTIONS.join(", ")}.`);
|
|
288
|
+
if (f["password-stdin"] && !PASSWORD_CONNECTIONS.includes(connection)) usage(`--password-stdin does not apply to ${connection}: the person signs in on the provider's page. It takes ${PASSWORD_CONNECTIONS.join(" or ")}.`);
|
|
289
|
+
const mailbox = { connection, address };
|
|
290
|
+
if (f["display-name"] !== void 0) mailbox["display_name"] = f["display-name"];
|
|
291
|
+
if (connection === "imap_smtp") {
|
|
292
|
+
const missing = SERVER_FLAGS.filter((k) => f[k] === void 0 || f[k].trim() === "");
|
|
293
|
+
if (missing.length > 0) usage(`--connection imap_smtp needs ${missing.map((k) => `--${k}`).join(", ")} (the settings from \`curviate mailbox discover\`, as the person confirmed them).`);
|
|
294
|
+
for (const side of ["imap", "smtp"]) {
|
|
295
|
+
const security = f[`${side}-security`];
|
|
296
|
+
if (security !== "tls" && security !== "starttls") usage(`--${side}-security takes tls or starttls, never cleartext.`);
|
|
297
|
+
mailbox[side] = { host: f[`${side}-host`], port: intFlag(`${side}-port`, f[`${side}-port`], 1, 65535), security };
|
|
298
|
+
}
|
|
299
|
+
} else {
|
|
300
|
+
const given = SERVER_FLAGS.filter((k) => f[k] !== void 0);
|
|
301
|
+
if (given.length > 0) usage(`${given.map((k) => `--${k}`).join(", ")} apply to --connection imap_smtp only.`);
|
|
302
|
+
}
|
|
303
|
+
const body = withPassword({ mailbox }, await readPassword(f));
|
|
304
|
+
if (f.preview) return preview("connectRequests.create", {}, body);
|
|
305
|
+
await sendRequest(c, f, body);
|
|
306
|
+
}
|
|
307
|
+
async function runReconnect(c, f) {
|
|
308
|
+
const id = String(f.id ?? "");
|
|
309
|
+
if (id.trim() === "") usage("the Mailbox id is empty. Pass the mbx_... id from `curviate mailbox list`.");
|
|
310
|
+
const body = withPassword({ mailbox_id: id }, await readPassword(f));
|
|
311
|
+
if (f.preview) return preview("connectRequests.create", {}, body);
|
|
312
|
+
await sendRequest(c, f, body);
|
|
313
|
+
}
|
|
314
|
+
var ID = { type: "positional", description: "The Mailbox (mbx_...), from `curviate mailbox list`." };
|
|
315
|
+
var NOT_FOUND = { MAILBOX_NOT_FOUND: "no Mailbox of your Team has this id (another Team's id answers the same)." };
|
|
316
|
+
var listCmd = defineCommand({
|
|
317
|
+
meta: {
|
|
318
|
+
name: "list",
|
|
319
|
+
description: "List your Team's Mailboxes, newest first: state, Sends for, daily cap, sent today, bounces over 7 days, paused until. Every role reads. A Mailbox in `ramping` works up to its cap; the steps are never shown. No secret is ever in the answer.",
|
|
320
|
+
risk: "read",
|
|
321
|
+
seeAlso: ["curviate mailbox get", "curviate domain check"],
|
|
322
|
+
examples: ["curviate mailbox list", "curviate mailbox list --state paused --domain acme.example", "curviate mailbox list --sends-for none"]
|
|
323
|
+
},
|
|
324
|
+
args: {
|
|
325
|
+
...readOnly(GLOBAL_FLAGS),
|
|
326
|
+
limit: { ...GLOBAL_FLAGS.limit, description: "Mailboxes per page (1 to 100)." },
|
|
327
|
+
state: { type: "string", description: `Only Mailboxes in this state: ${STATES.join(" | ")}.` },
|
|
328
|
+
"sends-for": { type: "string", description: "Only Mailboxes linked to this Account (acc_...), or shared (any Account may send), or none (linked to nothing, sends nothing)." },
|
|
329
|
+
domain: { type: "string", description: "Only Mailboxes on this domain." }
|
|
330
|
+
},
|
|
331
|
+
run: online(runList)
|
|
332
|
+
});
|
|
333
|
+
var getCmd = defineCommand({
|
|
334
|
+
meta: {
|
|
335
|
+
name: "get",
|
|
336
|
+
description: "One Mailbox: address, state, Sends for and its suggestion, daily cap (and cap_lowered_to when a spam reading lowered it), sent today, bounces over 7 days, signature, which Accounts and Campaigns used it, warm_up (state, day, reason: paused_by_curviate, reconnect_needed, trial, app_password, warm_up_app, allowance, address_check: the address is being confirmed, nothing to do, or address_unconfirmed: check the connection settings, Curviate tries again), reputation (0 to 100, or null while there is not enough to say: gathering, never 0), and landing: where its own warm-up mail lands per receiving provider over 7 days (google, microsoft, other: inbox, partly_spam, spam, or gathering while there is not enough to say). Every role reads.",
|
|
337
|
+
risk: "read",
|
|
338
|
+
errors: NOT_FOUND,
|
|
339
|
+
seeAlso: ["curviate mailbox list", "curviate mailbox update"],
|
|
340
|
+
examples: ["curviate mailbox get mbx_YOUR_MAILBOX_ID"]
|
|
341
|
+
},
|
|
342
|
+
args: { ...readOnly(READ_SINGLE_FLAGS), id: ID },
|
|
343
|
+
run: online(runGet)
|
|
344
|
+
});
|
|
345
|
+
var updateCmd = defineCommand({
|
|
346
|
+
meta: {
|
|
347
|
+
name: "update",
|
|
348
|
+
description: "Change one Mailbox: who it sends for (--sends-for an Account id, or shared), its daily cap (--daily-cap, 1 to 50, one cap across every Campaign and Account, a hard maximum for every caller) its signature (--signature-file, plain text, up to 2,000 characters, available as {{mailbox.signature}}; nothing adds it to an email by itself) its From name (--display-name, one line, up to 100 characters; --clear-display-name sends with the name of the Account it sends for) and Mailbox warm-up (--warm-up on --days 10|14|21|28: short everyday emails exchanged with other Teams' Mailboxes, filed in their own folder, so the Mailbox builds a sending history, included in the plan; --warm-up off stops it; `mailbox get` shows warm_up with its state and day). Flags you leave out stay as they are. A Mailbox linked to no Account sends nothing. Owners and Managers change any Mailbox; a Member only the ones they connected.",
|
|
349
|
+
risk: "write",
|
|
350
|
+
rules: {
|
|
351
|
+
changes: "The Mailbox's link, daily cap, signature, From name or warm-up, from the next email on. Open threads stay on it.",
|
|
352
|
+
visible_to: "Your Team; the signature reaches recipients where a step uses {{mailbox.signature}}.",
|
|
353
|
+
budget_rows: [],
|
|
354
|
+
retry: "Safe: the same flags leave the same Mailbox.",
|
|
355
|
+
undo: "Update again with the previous values.",
|
|
356
|
+
blast_radius: "One Mailbox's sending, in every Campaign that uses it."
|
|
357
|
+
},
|
|
358
|
+
errors: { ...NOT_FOUND, ACCOUNT_NOT_FOUND: "--sends-for names an Account outside your Team.", INVALID_REQUEST: "a value is out of range (a cap above 50, a signature over 2,000 characters); the message names the limit.", INSUFFICIENT_ROLE: "a Member changes only the Mailboxes they connected." },
|
|
359
|
+
seeAlso: ["curviate mailbox get", "curviate mailbox pause"],
|
|
360
|
+
examples: [
|
|
361
|
+
"curviate mailbox update mbx_YOUR_MAILBOX_ID --sends-for acc_YOUR_ACCOUNT_ID",
|
|
362
|
+
"curviate mailbox update mbx_YOUR_MAILBOX_ID --sends-for shared --daily-cap 40",
|
|
363
|
+
"curviate mailbox update mbx_YOUR_MAILBOX_ID --warm-up on --days 14"
|
|
364
|
+
],
|
|
365
|
+
requires: ["at least one of --sends-for, --daily-cap, --signature-file, --display-name, --clear-display-name, --warm-up."]
|
|
366
|
+
},
|
|
367
|
+
args: {
|
|
368
|
+
...WRITE_SINGLE_FLAGS,
|
|
369
|
+
id: ID,
|
|
370
|
+
"sends-for": { type: "string", description: "An Account id (acc_..., it then sends only for that Account) or shared (any Account of your Team may send from it)." },
|
|
371
|
+
"daily-cap": { type: "string", description: "Emails a day across every Campaign and Account, 1 to 50. The API refuses a higher value (exit 2, the message names 50)." },
|
|
372
|
+
"signature-file": { type: "string", stdinArg: true, description: "A plain-text file with the sign-off: a path, or - to read it from stdin. Up to 2,000 characters." },
|
|
373
|
+
"display-name": { type: "string", description: "The name recipients see in From, one line, up to 100 characters." },
|
|
374
|
+
"clear-display-name": { type: "boolean", description: "Clear the From name: the Mailbox sends with the name of the Account it sends for." },
|
|
375
|
+
"warm-up": { type: "string", description: "on (Recommended) or off: Mailbox warm-up." },
|
|
376
|
+
days: { type: "string", description: "With --warm-up on: how many days warm-up runs before the Mailbox can be ready, 10, 14, 21 or 28." }
|
|
377
|
+
},
|
|
378
|
+
run: online(runUpdate)
|
|
379
|
+
});
|
|
380
|
+
var pauseCmd = defineCommand({
|
|
381
|
+
meta: {
|
|
382
|
+
name: "pause",
|
|
383
|
+
description: "Stop a Mailbox sending until you resume it. Emails due from it wait; nothing is sent from it meanwhile.",
|
|
384
|
+
risk: "write",
|
|
385
|
+
rules: {
|
|
386
|
+
changes: "The Mailbox's state becomes paused; no email leaves it.",
|
|
387
|
+
visible_to: "Your Team.",
|
|
388
|
+
budget_rows: [],
|
|
389
|
+
retry: "Safe to repeat.",
|
|
390
|
+
undo: "`curviate mailbox resume <id>`.",
|
|
391
|
+
blast_radius: "One Mailbox's sending."
|
|
392
|
+
},
|
|
393
|
+
errors: { ...NOT_FOUND, MAILBOX_STATE_CONFLICT: "the Mailbox is not in a state that can be paused." },
|
|
394
|
+
seeAlso: ["curviate mailbox resume"],
|
|
395
|
+
examples: ["curviate mailbox pause mbx_YOUR_MAILBOX_ID"]
|
|
396
|
+
},
|
|
397
|
+
args: { ...WRITE_SINGLE_FLAGS, id: ID },
|
|
398
|
+
run: online(act("pause"))
|
|
399
|
+
});
|
|
400
|
+
var resumeCmd = defineCommand({
|
|
401
|
+
meta: {
|
|
402
|
+
name: "resume",
|
|
403
|
+
description: "Let a paused Mailbox send again. A Mailbox that is not paused, or one paused by bounces or by its provider with no date, is refused with MAILBOX_STATE_CONFLICT and stays as it was.",
|
|
404
|
+
risk: "write",
|
|
405
|
+
rules: {
|
|
406
|
+
changes: "The Mailbox sends again, under its daily cap.",
|
|
407
|
+
visible_to: "Your Team; recipients of what it then sends.",
|
|
408
|
+
budget_rows: [],
|
|
409
|
+
retry: "Safe: a second call on a Mailbox that already sends answers MAILBOX_STATE_CONFLICT.",
|
|
410
|
+
undo: "`curviate mailbox pause <id>`.",
|
|
411
|
+
blast_radius: "One Mailbox's sending."
|
|
412
|
+
},
|
|
413
|
+
errors: { ...NOT_FOUND, MAILBOX_STATE_CONFLICT: "the Mailbox is not paused by a person, or its pause is not yours to lift." },
|
|
414
|
+
seeAlso: ["curviate mailbox pause"],
|
|
415
|
+
examples: ["curviate mailbox resume mbx_YOUR_MAILBOX_ID"]
|
|
416
|
+
},
|
|
417
|
+
args: { ...WRITE_SINGLE_FLAGS, id: ID },
|
|
418
|
+
run: online(act("resume"))
|
|
419
|
+
});
|
|
420
|
+
var removeCmd = defineCommand({
|
|
421
|
+
meta: {
|
|
422
|
+
name: "remove",
|
|
423
|
+
description: `Remove a Mailbox and delete its stored credentials in one step. Changes no seat count. Connect it again to use the address afterwards. A Mailbox from Curviate is an Owner's to remove: it is deleted with its mail, and its $5 a month stops at the end of the billing period. MAILBOX_STATE_CONFLICT (exit 8) "Too many Mailbox changes are still settling with billing" changed nothing: try again later, never in a loop.`,
|
|
424
|
+
risk: "high",
|
|
425
|
+
rules: {
|
|
426
|
+
changes: "The Mailbox and its credentials are deleted; emails due from it are not sent. A Mailbox from Curviate is deleted with its mail; its charge ends at the period's end.",
|
|
427
|
+
visible_to: "Your Team.",
|
|
428
|
+
budget_rows: [],
|
|
429
|
+
retry: "Safe: a second call answers MAILBOX_NOT_FOUND.",
|
|
430
|
+
undo: "None: connect the address again.",
|
|
431
|
+
blast_radius: "One Mailbox and every Campaign that sends from it."
|
|
432
|
+
},
|
|
433
|
+
errors: { ...NOT_FOUND, INSUFFICIENT_ROLE: "a Member removes only a Mailbox they connected; a Mailbox from Curviate is an Owner's.", MAILBOX_STATE_CONFLICT: "changes are still settling with billing; nothing was changed. Try again later, never in a loop." },
|
|
434
|
+
seeAlso: ["curviate mailbox list", "curviate mailbox pause"],
|
|
435
|
+
examples: ["curviate mailbox remove mbx_YOUR_MAILBOX_ID"]
|
|
436
|
+
},
|
|
437
|
+
args: { ...WRITE_SINGLE_FLAGS, id: ID },
|
|
438
|
+
run: online(act("remove"))
|
|
439
|
+
});
|
|
440
|
+
var ADDRESS = { type: "positional", description: "The email address." };
|
|
441
|
+
var PASSWORD_STDIN = {
|
|
442
|
+
type: "boolean",
|
|
443
|
+
description: "Check and keep a password the person gave you: one line from stdin, never echoed, sent only in the request body and never printed. No flag takes the password as a value: it would show in `ps` and in shell history.",
|
|
444
|
+
default: false
|
|
445
|
+
};
|
|
446
|
+
var discoverCmd = defineCommand({
|
|
447
|
+
meta: {
|
|
448
|
+
name: "discover",
|
|
449
|
+
description: "Find the IMAP and SMTP settings for an email address, to show the person and confirm before connecting. An address on Google or Microsoft answers with its connection. confirm_required marks settings that arrived unencrypted or are a guess; a domain with nothing usable answers source none with no settings. Takes no password and the answer holds none.",
|
|
450
|
+
risk: "read",
|
|
451
|
+
seeAlso: ["curviate mailbox connect"],
|
|
452
|
+
examples: ["curviate mailbox discover anna@acme.example"]
|
|
453
|
+
},
|
|
454
|
+
args: { ...readOnly(READ_SINGLE_FLAGS), address: ADDRESS },
|
|
455
|
+
run: online(runDiscover)
|
|
456
|
+
});
|
|
457
|
+
var connectCmd = defineCommand({
|
|
458
|
+
meta: {
|
|
459
|
+
name: "connect",
|
|
460
|
+
description: "Connect a new Mailbox: creates a Connect request and prints its link for the person, who finishes in their Curviate dashboard. --connection google_sign_in (a Google Workspace whose administrator trusts Curviate) and microsoft_sign_in print the sign-in link and, where the provider needs one, the administrator link. A password never passes through an agent: give the person the link. A person at their own terminal may instead connect google_app_password or imap_smtp in one call with --password-stdin (read from standard input, never echoed); Curviate checks it before answering. imap_smtp needs the six server flags (the settings from `curviate mailbox discover`, as the person confirmed them). One API call.",
|
|
461
|
+
risk: "write",
|
|
462
|
+
rules: {
|
|
463
|
+
changes: "Creates a Connect request. With --password-stdin on google_app_password or imap_smtp, the password is checked and, if it works, the Mailbox is connected and the password is stored sealed (never returned).",
|
|
464
|
+
visible_to: "Your Team: the request is listed under Accounts for the person it is for.",
|
|
465
|
+
budget_rows: [],
|
|
466
|
+
retry: "Not safe: a repeated call creates a second request. Read `curviate account connect-request get <request_id>` first.",
|
|
467
|
+
undo: "`curviate account connect-request cancel <request_id>` before it completes; `curviate mailbox remove <id>` after."
|
|
468
|
+
},
|
|
469
|
+
errors: {
|
|
470
|
+
MAILBOX_ALREADY_CONNECTED: "this address is already a Mailbox of your Team.",
|
|
471
|
+
MAILBOX_APP_PASSWORD_REQUIRED: "a private Gmail address connects with an app password, not google_sign_in; or the password is Google's own, not an app password.",
|
|
472
|
+
MAILBOX_CREDENTIAL_REJECTED: "the host refused the password (exit 8); the request stays open for another try.",
|
|
473
|
+
MAILBOX_TLS_FAILED: "the host does not offer the encryption the settings name (exit 8).",
|
|
474
|
+
MAILBOX_LIMIT_REACHED: "your Team is past its Mailbox allowance (exit 2)."
|
|
475
|
+
},
|
|
476
|
+
seeAlso: ["curviate mailbox discover", "curviate mailbox reconnect", "curviate account connect-request get"],
|
|
477
|
+
examples: [
|
|
478
|
+
"curviate mailbox connect anna@acme.example --connection google_sign_in",
|
|
479
|
+
"curviate mailbox connect anna@gmail.com --connection google_app_password --password-stdin < app-password.txt",
|
|
480
|
+
"curviate mailbox connect anna@acme.example --connection imap_smtp --imap-host imap.acme.example --imap-port 993 --imap-security tls --smtp-host smtp.acme.example --smtp-port 465 --smtp-security tls --password-stdin < mail-password.txt"
|
|
481
|
+
],
|
|
482
|
+
requires: ["--connection: google_app_password, google_sign_in, microsoft_sign_in or imap_smtp.", "--connection imap_smtp: --imap-host, --imap-port, --imap-security, --smtp-host, --smtp-port, --smtp-security."]
|
|
483
|
+
},
|
|
484
|
+
args: {
|
|
485
|
+
...WRITE_SINGLE_FLAGS,
|
|
486
|
+
address: ADDRESS,
|
|
487
|
+
connection: { type: "string", description: `How the Mailbox connects: ${CONNECTIONS.join(" | ")}.` },
|
|
488
|
+
"password-stdin": PASSWORD_STDIN,
|
|
489
|
+
"display-name": { type: "string", description: 'The name recipients see in From ("Name" <address>), one line, up to 100 characters. Default: the name of the Account the Mailbox sends for, else the bare address.' },
|
|
490
|
+
"imap-host": { type: "string", description: "imap_smtp only: the IMAP host." },
|
|
491
|
+
"imap-port": { type: "string", description: "imap_smtp only: the IMAP port (usually 993 with tls, 143 with starttls)." },
|
|
492
|
+
"imap-security": { type: "string", description: "imap_smtp only: tls (TLS from the first byte) or starttls. Never cleartext." },
|
|
493
|
+
"smtp-host": { type: "string", description: "imap_smtp only: the SMTP submission host." },
|
|
494
|
+
"smtp-port": { type: "string", description: "imap_smtp only: the SMTP submission port (usually 465 with tls, 587 with starttls)." },
|
|
495
|
+
"smtp-security": { type: "string", description: "imap_smtp only: tls or starttls. Never cleartext." }
|
|
496
|
+
},
|
|
497
|
+
run: online(runConnect)
|
|
498
|
+
});
|
|
499
|
+
var reconnectCmd = defineCommand({
|
|
500
|
+
meta: {
|
|
501
|
+
name: "reconnect",
|
|
502
|
+
description: "Reconnect a Mailbox of your Team (state reconnect_needed, or any other): creates a Connect request and prints its link for the person. With --password-stdin on a google_app_password or imap_smtp Mailbox, the new password is checked and replaces the old one in this one call. On a google_sign_in Mailbox, --password-stdin adds an app password beside the sign-in, for warm-up; sending and reply checks stay on the sign-in. A microsoft_sign_in Mailbox takes no password. One API call.",
|
|
503
|
+
risk: "write",
|
|
504
|
+
rules: {
|
|
505
|
+
changes: "Creates a Connect request. With --password-stdin, the password is checked and stored sealed in place of the old one (never returned).",
|
|
506
|
+
visible_to: "Your Team.",
|
|
507
|
+
budget_rows: [],
|
|
508
|
+
retry: "Not safe: a repeated call creates a second request. Read `curviate account connect-request get <request_id>` first.",
|
|
509
|
+
undo: "`curviate account connect-request cancel <request_id>` before it completes."
|
|
510
|
+
},
|
|
511
|
+
errors: { ...NOT_FOUND, MAILBOX_CREDENTIAL_REJECTED: "the host refused the password (exit 8); the request stays open for another try.", MAILBOX_ADDRESS_MISMATCH: "the sign-in was for another address; nothing changed." },
|
|
512
|
+
seeAlso: ["curviate mailbox connect", "curviate account connect-request get"],
|
|
513
|
+
examples: ["curviate mailbox reconnect mbx_YOUR_MAILBOX_ID", "curviate mailbox reconnect mbx_YOUR_MAILBOX_ID --password-stdin < app-password.txt"]
|
|
514
|
+
},
|
|
515
|
+
args: { ...WRITE_SINGLE_FLAGS, id: ID, "password-stdin": PASSWORD_STDIN },
|
|
516
|
+
run: online(runReconnect)
|
|
517
|
+
});
|
|
518
|
+
var testCmd = defineCommand({
|
|
519
|
+
meta: {
|
|
520
|
+
name: "test",
|
|
521
|
+
description: "Run a placement test: your exact subject and body go from this Mailbox to 12 test inboxes, 3 at each of Google Workspace, Microsoft 365, Gmail and Outlook.com, and each copy's landing is read; results within an hour (`curviate mailbox tests <id> <test_id>`). The 12 copies count against the Mailbox's daily cap, so it needs room for 12 today. Each test draws one from the Team's allowance: 10 per paid seat a month, pooled across the Team (a trial has none). Owners and Managers test any Mailbox; a Member only the ones they connected. One API call, never retried.",
|
|
522
|
+
risk: "write",
|
|
523
|
+
rules: {
|
|
524
|
+
changes: "12 emails leave the Mailbox today, under its daily cap; the Team's allowance goes down by one.",
|
|
525
|
+
visible_to: "Your Team; the copies go to test inboxes only.",
|
|
526
|
+
budget_rows: [],
|
|
527
|
+
retry: "Not safe: a second run is a second test, 12 more emails and one more from the allowance. Read `mailbox tests` first.",
|
|
528
|
+
undo: "None: the copies are sent.",
|
|
529
|
+
blast_radius: "One Mailbox's daily cap and one test of the Team's month."
|
|
530
|
+
},
|
|
531
|
+
errors: {
|
|
532
|
+
...NOT_FOUND,
|
|
533
|
+
PLACEMENT_TEST_ALLOWANCE_EXHAUSTED: "this month's tests are used, or the Team has no paid seat yet; the message says when it resets. Nothing was sent. Waiting minutes does not help: a paid seat or the new month does.",
|
|
534
|
+
PLACEMENT_TESTS_UNAVAILABLE: "placement tests cannot run right now. Nothing was sent, nothing drawn.",
|
|
535
|
+
MAILBOX_STATE_CONFLICT: "the Mailbox cannot send now (paused, reconnect needed). Nothing was sent.",
|
|
536
|
+
INVALID_REQUEST: "the Mailbox has no room for 12 more emails today, or the subject or body is empty, too long or malformed. Nothing was sent."
|
|
537
|
+
},
|
|
538
|
+
output: ["The test: id, status (running), verdicts per provider (null while running), allowance { used, total, resets_at }."],
|
|
539
|
+
seeAlso: ["curviate mailbox tests", "curviate campaign placement"],
|
|
540
|
+
examples: [
|
|
541
|
+
'curviate mailbox test mbx_YOUR_MAILBOX_ID --subject "Quick question" --body-file body.txt'
|
|
542
|
+
],
|
|
543
|
+
requires: ["--subject and --body-file."]
|
|
544
|
+
},
|
|
545
|
+
args: {
|
|
546
|
+
...WRITE_SINGLE_FLAGS,
|
|
547
|
+
id: ID,
|
|
548
|
+
subject: { type: "string", description: "The subject exactly as your Campaign sends it: one line, up to 998 characters." },
|
|
549
|
+
"body-file": { type: "string", stdinArg: true, description: "A plain-text file with the body exactly as your Campaign sends it: a path, or - to read it from stdin. Up to 10,000 characters." }
|
|
550
|
+
},
|
|
551
|
+
run: online(runTest)
|
|
552
|
+
});
|
|
553
|
+
var testsCmd = defineCommand({
|
|
554
|
+
meta: {
|
|
555
|
+
name: "tests",
|
|
556
|
+
description: "This Mailbox's placement tests, newest first, with the Team's allowance { used, total, resets_at }; with a test id, that one test. A test is running or complete, with a verdict per provider: inbox (all 3 copies in the inbox), partly_spam or spam (none in the inbox). Every role reads. One API call.",
|
|
557
|
+
risk: "read",
|
|
558
|
+
errors: NOT_FOUND,
|
|
559
|
+
output: ["items[] (id, status, created_at, completed_at, verdicts), cursor, allowance; or one test."],
|
|
560
|
+
seeAlso: ["curviate mailbox test"],
|
|
561
|
+
examples: ["curviate mailbox tests mbx_YOUR_MAILBOX_ID", "curviate mailbox tests mbx_YOUR_MAILBOX_ID plt_YOUR_TEST_ID"]
|
|
562
|
+
},
|
|
563
|
+
args: {
|
|
564
|
+
...readOnly(READ_SINGLE_FLAGS),
|
|
565
|
+
id: ID,
|
|
566
|
+
testId: { type: "positional", required: false, description: "One test (plt_...), from the list." },
|
|
567
|
+
limit: { type: "string", description: "Tests per page (1 to 100)." },
|
|
568
|
+
cursor: GLOBAL_FLAGS.cursor
|
|
569
|
+
},
|
|
570
|
+
run: online(runTests)
|
|
571
|
+
});
|
|
572
|
+
var buyCmd = defineCommand({
|
|
573
|
+
meta: {
|
|
574
|
+
name: "buy",
|
|
575
|
+
description: "Order 1 to 50 Mailboxes from Curviate on one domain your Team owns, $5 a month each, warm-up included. The order waits in awaiting_dns until the records it lists (mx, spf, dkim, dmarc, and tracking, which is optional) are found at your domain; nothing is charged before, and an order still waiting after 14 days is cancelled. Team Owners only. An order through an API key counts under the Team's cap on Mailboxes from Curviate (`curviate billing cap` shows mailbox_cap), which only an Owner raises, in the dashboard: from 80% of it the order carries a SPENDING_CAP_NEAR notice, past it the order is refused (exit 5) and nothing is ordered. Read orders with `curviate mailbox purchase list`.",
|
|
576
|
+
risk: "high",
|
|
577
|
+
rules: {
|
|
578
|
+
changes: "An order in awaiting_dns; once its records are found, the Mailboxes are created and $5 a month each is charged.",
|
|
579
|
+
visible_to: "Your Team.",
|
|
580
|
+
budget_rows: [],
|
|
581
|
+
retry: "Never retried. A second order for the same domain while one waits is refused (MAILBOX_PURCHASE_PENDING).",
|
|
582
|
+
undo: "An order still waiting for its records lapses after 14 days, uncharged.",
|
|
583
|
+
blast_radius: "One domain's mail: the MX record it asks for routes the domain's mail to the new Mailboxes."
|
|
584
|
+
},
|
|
585
|
+
errors: {
|
|
586
|
+
SPENDING_CAP_REACHED: "the order would pass the Team's cap on Mailboxes from Curviate; only an Owner raises it, in the dashboard. Nothing was ordered.",
|
|
587
|
+
INSUFFICIENT_ROLE: "only a Team Owner orders.",
|
|
588
|
+
MAILBOX_PURCHASE_TRIAL: "a Team on a trial cannot order.",
|
|
589
|
+
MAILBOX_PURCHASE_PENDING: "this domain already has an order waiting for its records.",
|
|
590
|
+
DOMAIN_IN_USE: "the domain already has Mailboxes from Curviate or an order; name another domain.",
|
|
591
|
+
DOMAIN_IS_COMPANY_EMAIL: "the domain your company email runs on; use a separate domain.",
|
|
592
|
+
MAILBOX_SALES_PAUSED: "orders cannot be placed at the moment."
|
|
593
|
+
},
|
|
594
|
+
output: ["The order: id, domain, state (awaiting_dns), mailboxes[], records[] (mx, spf, dkim, dmarc, tracking), amount_monthly, expires_at."],
|
|
595
|
+
seeAlso: ["curviate mailbox purchase list", "curviate domain check"],
|
|
596
|
+
examples: [
|
|
597
|
+
"curviate mailbox buy --domain acme-mail.example --mailbox 'anna:Anna Weber:shared' --yes",
|
|
598
|
+
"curviate mailbox buy --domain acme-mail.example --mailbox 'anna:Anna Weber:acc_YOUR_ACCOUNT_ID' --mailbox 'max:Max Weber' --yes"
|
|
599
|
+
],
|
|
600
|
+
requires: ["--domain and at least one --mailbox."]
|
|
601
|
+
},
|
|
602
|
+
args: {
|
|
603
|
+
...WRITE_SINGLE_FLAGS,
|
|
604
|
+
domain: { type: "string", description: "The domain the Mailboxes send from, one your Team owns and not the one your company email runs on." },
|
|
605
|
+
mailbox: { type: "string", description: "One Mailbox, repeatable up to 50: local:Name, the part before the @ and the name recipients see; add :acc_... (the Account it sends for) or :shared at the end." },
|
|
606
|
+
yes: { type: "boolean", description: "Confirm the order without a prompt (needed when no terminal can ask)." }
|
|
607
|
+
},
|
|
608
|
+
run: online(runBuy)
|
|
609
|
+
});
|
|
610
|
+
var purchaseListCmd = defineCommand({
|
|
611
|
+
meta: {
|
|
612
|
+
name: "list",
|
|
613
|
+
description: "Your Team's orders of Mailboxes from Curviate, newest first: state (awaiting_dns, provisioning, active, cancelled), the records to add and which are found. Every role reads. One API call per page.",
|
|
614
|
+
risk: "read",
|
|
615
|
+
seeAlso: ["curviate mailbox purchase get"],
|
|
616
|
+
examples: ["curviate mailbox purchase list", "curviate mailbox purchase list --state awaiting_dns"]
|
|
617
|
+
},
|
|
618
|
+
args: {
|
|
619
|
+
...readOnly(READ_SINGLE_FLAGS),
|
|
620
|
+
state: { type: "string", description: `Only orders in this state: ${PURCHASE_STATES.join(" | ")}.` },
|
|
621
|
+
limit: { type: "string", description: "Orders per page (1 to 100)." },
|
|
622
|
+
cursor: GLOBAL_FLAGS.cursor
|
|
623
|
+
},
|
|
624
|
+
run: online(runPurchaseList)
|
|
625
|
+
});
|
|
626
|
+
var purchaseGetCmd = defineCommand({
|
|
627
|
+
meta: {
|
|
628
|
+
name: "get",
|
|
629
|
+
description: "One order of Mailboxes from Curviate: its state, the five records to add at your domain (mx, spf, dkim, dmarc, tracking; tracking is optional) and which are found, and its Mailboxes once active. awaiting_dns waits for the records; provisioning means charged and being set up; active is done; cancelled carries its reason (requested, expired, host_failed: setting up failed and the charge was undone in full). Every role reads. One API call.",
|
|
630
|
+
risk: "read",
|
|
631
|
+
errors: { MAILBOX_PURCHASE_NOT_FOUND: "no order of your Team has this id (another Team's id answers the same)." },
|
|
632
|
+
seeAlso: ["curviate mailbox purchase list", "curviate mailbox list"],
|
|
633
|
+
examples: ["curviate mailbox purchase get mpu_YOUR_PURCHASE_ID"]
|
|
634
|
+
},
|
|
635
|
+
args: { ...readOnly(READ_SINGLE_FLAGS), id: { type: "positional", description: "The order (mpu_...), from `curviate mailbox purchase list`." } },
|
|
636
|
+
run: online(runPurchaseGet)
|
|
637
|
+
});
|
|
638
|
+
var purchaseCheckCmd = defineCommand({
|
|
639
|
+
meta: {
|
|
640
|
+
name: "check",
|
|
641
|
+
description: "Look up an order's records now instead of waiting for Curviate's own checks (every 15 minutes for 2 hours after the order, then hourly); answers the order with each row's found. Once a minute per order: sooner is refused (exit 6) with the time to wait. Owners only. One API call.",
|
|
642
|
+
risk: "read",
|
|
643
|
+
errors: { MAILBOX_PURCHASE_NOT_FOUND: "no order of your Team has this id (another Team's id answers the same).", PLATFORM_RATE_LIMIT: "this order was checked less than a minute ago." },
|
|
644
|
+
seeAlso: ["curviate mailbox purchase get"],
|
|
645
|
+
examples: ["curviate mailbox purchase check mpu_YOUR_PURCHASE_ID"]
|
|
646
|
+
},
|
|
647
|
+
args: { ...readOnly(READ_SINGLE_FLAGS), id: { type: "positional", description: "The order (mpu_...), from `curviate mailbox purchase list`." } },
|
|
648
|
+
run: online(runPurchaseCheck)
|
|
649
|
+
});
|
|
650
|
+
async function runPurchaseCancel(c, f) {
|
|
651
|
+
const id = String(f.id ?? "");
|
|
652
|
+
if (id.trim() === "") usage("the order id is empty. Pass the mpu_... id from `curviate mailbox purchase list`.");
|
|
653
|
+
if (f.preview) return preview("mailboxes.purchases.cancel", { id });
|
|
654
|
+
try {
|
|
655
|
+
renderSuccess(readableObject(await c.mailboxes.purchases.cancel(id)), outputOpts(f), process);
|
|
656
|
+
} catch (err) {
|
|
657
|
+
const { CurviateError } = await import("@curviate/sdk");
|
|
658
|
+
if (err instanceof CurviateError && err.code === "MAILBOX_PURCHASE_STATE_CONFLICT") {
|
|
659
|
+
process.stderr.write(`error [MAILBOX_PURCHASE_STATE_CONFLICT] ${err.message} Nothing was changed; do not retry. Read it with: curviate mailbox purchase get ${id}
|
|
660
|
+
`);
|
|
661
|
+
process.exit(getExitCode(err));
|
|
662
|
+
}
|
|
663
|
+
await fail(err, f);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
var purchaseCancelCmd = defineCommand({
|
|
667
|
+
meta: {
|
|
668
|
+
name: "cancel",
|
|
669
|
+
description: "Cancel an order of Mailboxes from Curviate still waiting for its records: nothing was charged, so nothing is refunded. An order being charged, being set up, active or cancelled is refused (exit 8) and stays as it is; while a charge is under way, read the order again in a few minutes. Owners only. One API call, never retried.",
|
|
670
|
+
risk: "high",
|
|
671
|
+
rules: {
|
|
672
|
+
changes: "The order ends cancelled; its domain's records are no longer looked for. No Mailbox is created and nothing is charged.",
|
|
673
|
+
visible_to: "Your Team.",
|
|
674
|
+
budget_rows: [],
|
|
675
|
+
retry: "Not needed: a second cancel answers MAILBOX_PURCHASE_STATE_CONFLICT (already cancelled).",
|
|
676
|
+
undo: "Order again with `curviate mailbox buy`.",
|
|
677
|
+
blast_radius: "One order."
|
|
678
|
+
},
|
|
679
|
+
errors: {
|
|
680
|
+
MAILBOX_PURCHASE_NOT_FOUND: "no order of your Team has this id (another Team's id answers the same).",
|
|
681
|
+
MAILBOX_PURCHASE_STATE_CONFLICT: "the order is not waiting for its records (being charged, being set up, active or cancelled); the message names its state. Read it again later; never retry."
|
|
682
|
+
},
|
|
683
|
+
seeAlso: ["curviate mailbox purchase get", "curviate mailbox purchase list"],
|
|
684
|
+
examples: ["curviate mailbox purchase cancel mpu_YOUR_PURCHASE_ID"]
|
|
685
|
+
},
|
|
686
|
+
args: { ...WRITE_SINGLE_FLAGS, id: { type: "positional", description: "The order (mpu_...), from `curviate mailbox purchase list`." } },
|
|
687
|
+
run: online(runPurchaseCancel)
|
|
688
|
+
});
|
|
689
|
+
var purchaseCmd = defineCommand({
|
|
690
|
+
meta: { name: "purchase", description: "Your Team's orders of Mailboxes from Curviate: list, get, check (look the records up now), cancel (an order still waiting for its records)." },
|
|
691
|
+
subCommands: { list: purchaseListCmd, get: purchaseGetCmd, check: purchaseCheckCmd, cancel: purchaseCancelCmd },
|
|
692
|
+
async run() {
|
|
693
|
+
const { showHelp } = await import("./examples-5FJS47QF.js");
|
|
694
|
+
await showHelp(purchaseCmd, ["curviate", "mailbox", "purchase"]);
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
var mailboxCommand = defineCommand({
|
|
698
|
+
meta: { name: "mailbox", description: DESCRIPTIONS["mailbox"] },
|
|
699
|
+
subCommands: { list: listCmd, get: getCmd, update: updateCmd, pause: pauseCmd, resume: resumeCmd, remove: removeCmd, discover: discoverCmd, connect: connectCmd, reconnect: reconnectCmd, test: testCmd, tests: testsCmd, buy: buyCmd, purchase: purchaseCmd },
|
|
700
|
+
async run() {
|
|
701
|
+
const { showHelp } = await import("./examples-5FJS47QF.js");
|
|
702
|
+
await showHelp(mailboxCommand, ["curviate", "mailbox"]);
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
export {
|
|
706
|
+
BUY_PAST_CAP,
|
|
707
|
+
MAILBOX_REQUEST_INSTRUCTION,
|
|
708
|
+
mailboxCommand,
|
|
709
|
+
parseMailboxSpec,
|
|
710
|
+
purchaseNote,
|
|
711
|
+
requestLines
|
|
712
|
+
};
|