@curviate/cli 0.57.0 → 0.59.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/README.md +9 -2
  3. package/dist/{account-IRIYB2SG.js → account-EUHYWIDH.js} +52 -16
  4. package/dist/{analytics-IRSCLVOL.js → analytics-SQQIMSLF.js} +6 -6
  5. package/dist/{beta-consent-NQVGFZL3.js → beta-consent-DFS7YMZR.js} +4 -4
  6. package/dist/billing-3FRIQFY3.js +19 -0
  7. package/dist/{chunk-OE4CY3ZL.js → chunk-5AJS2V4T.js} +1 -1
  8. package/dist/{chunk-AMTKGO37.js → chunk-5Z3CCE5N.js} +1 -1
  9. package/dist/{chunk-A6JGJGDF.js → chunk-72PYX57P.js} +16 -16
  10. package/dist/{billing-TCTP44ZB.js → chunk-7CSXYRSO.js} +125 -14
  11. package/dist/{chunk-SCUTAREU.js → chunk-EWSOIFG2.js} +17 -0
  12. package/dist/{chunk-3ZQNOKEK.js → chunk-F3FEY4D5.js} +2 -2
  13. package/dist/{chunk-F7CLAS5Y.js → chunk-HG2G5OAZ.js} +2 -2
  14. package/dist/{chunk-6OT6TS7N.js → chunk-HJ7YY4HE.js} +2 -2
  15. package/dist/{chunk-RKNW4UX4.js → chunk-JKOQX46J.js} +6 -0
  16. package/dist/{chunk-VHNF6OZD.js → chunk-JY26SUNH.js} +18 -2
  17. package/dist/{chunk-RXDG57B2.js → chunk-KD2XY7RS.js} +1 -1
  18. package/dist/{chunk-RTT75CXE.js → chunk-QRTMRTKA.js} +88 -15
  19. package/dist/{chunk-VPFV7YV3.js → chunk-R2MIDSMB.js} +6 -6
  20. package/dist/{chunk-AG6G3PRQ.js → chunk-TNLIV3SW.js} +17 -13
  21. package/dist/{chunk-3B5M2RUN.js → chunk-VKHAL6WT.js} +1 -1
  22. package/dist/{chunk-5LGKZBAY.js → chunk-ZC4S4B32.js} +4 -3
  23. package/dist/cli.js +33 -33
  24. package/dist/{comment-PNHEKGZX.js → comment-DA6XPY4F.js} +8 -8
  25. package/dist/{company-OUFF23SU.js → company-IWVNUBWS.js} +8 -8
  26. package/dist/{company-record-ULPDDB6L.js → company-record-ZJMW3NC6.js} +95 -10
  27. package/dist/{config-U6VDNL2P.js → config-P4HKPOCW.js} +2 -2
  28. package/dist/{connect-ICNXC37R.js → connect-AELFEVR7.js} +11 -11
  29. package/dist/{contact-K6RIVQWU.js → contact-FHN3A7MJ.js} +9 -9
  30. package/dist/{contact-groups-CNH2VB6A.js → contact-groups-HNZTN6I6.js} +11 -11
  31. package/dist/{contact-import-FK22UTN2.js → contact-import-PJFRLCHR.js} +11 -11
  32. package/dist/core-R7R44CVA.js +46 -0
  33. package/dist/{do-not-contact-BQHXNHTV.js → do-not-contact-KSH36NMT.js} +22 -20
  34. package/dist/{doctor-ZYPZF5BE.js → doctor-BEO4E227.js} +4 -4
  35. package/dist/{document-H65EXU4L.js → document-G6UND26L.js} +1 -1
  36. package/dist/{domain-HLOT6Y4A.js → domain-HF3WXWUT.js} +5 -5
  37. package/dist/{draft-JGQ36JSH.js → draft-2KBRHBBH.js} +5 -5
  38. package/dist/{enrollment-CF634DB4.js → enrollment-QPE54QQN.js} +14 -10
  39. package/dist/{examples-J4X5NEIE.js → examples-5FJS47QF.js} +2 -2
  40. package/dist/{exit-codes-P2FLCKM7.js → exit-codes-LQDMGDII.js} +1 -1
  41. package/dist/{export-ZQLDQYUZ.js → export-J4JQRE2A.js} +4 -4
  42. package/dist/{feed-RQHEDZVL.js → feed-PHF2ROIT.js} +6 -6
  43. package/dist/{group-LRMG76FN.js → group-SLXDOCHV.js} +6 -6
  44. package/dist/{inbox-5RGG5RQG.js → inbox-IDILZLPC.js} +6 -6
  45. package/dist/{inboxes-ZFY6ZP33.js → inboxes-QLP5PWTS.js} +6 -6
  46. package/dist/{incoming-3MJ4CP6H.js → incoming-XG6IBPU6.js} +8 -8
  47. package/dist/{job-QFIUTHHT.js → job-WUYHK6OX.js} +6 -6
  48. package/dist/{login-THXWX5HZ.js → login-3RIU257N.js} +2 -2
  49. package/dist/mailbox-CJRCYZGL.js +772 -0
  50. package/dist/{message-DM5OUKQS.js → message-EBVO4ZZI.js} +7 -7
  51. package/dist/{motion-NKOAK7NU.js → motion-7XQ3E4GI.js} +121 -16
  52. package/dist/{network-VKJUMZ2L.js → network-X5XL44GB.js} +12 -12
  53. package/dist/{notification-XW5J6KFA.js → notification-QNGHG5EO.js} +6 -6
  54. package/dist/{notifications-USYOV54R.js → notifications-MOLNELNE.js} +9 -9
  55. package/dist/{post-M2G3BK4A.js → post-XYSFN5OP.js} +8 -8
  56. package/dist/{profile-3SG64IEG.js → profile-7LJLU4Y5.js} +12 -12
  57. package/dist/{recruiter-7OUGZ776.js → recruiter-ALQNIRYR.js} +9 -9
  58. package/dist/{sales-nav-HHQLLM5C.js → sales-nav-HYZXNYCC.js} +9 -9
  59. package/dist/{search-5LMSLUH4.js → search-DNCPCFRR.js} +16 -16
  60. package/dist/{setup-6F4HYUSZ.js → setup-QI5FW6VD.js} +4 -4
  61. package/dist/{signal-LVODDBOY.js → signal-J2TLIT47.js} +126 -19
  62. package/dist/{team-MSOPELF6.js → team-PPPCJ5HT.js} +8 -8
  63. package/dist/{tier-RXHOAQ6L.js → tier-NFWWW34H.js} +4 -4
  64. package/dist/{unibox-UAA6WIGZ.js → unibox-52C7G5LK.js} +318 -16
  65. package/dist/{webhook-J2H7X766.js → webhook-J3JYMSY2.js} +12 -12
  66. package/package.json +3 -3
  67. package/dist/core-MPEBYNSL.js +0 -46
  68. package/dist/mailbox-54DPLNXA.js +0 -412
@@ -7,13 +7,13 @@ import {
7
7
  outputOpts,
8
8
  rootClient,
9
9
  usage
10
- } from "./chunk-3ZQNOKEK.js";
11
- import {
12
- intFlag
13
- } from "./chunk-NNV2OYEF.js";
10
+ } from "./chunk-F3FEY4D5.js";
14
11
  import {
15
12
  buildPreviewOutput
16
13
  } from "./chunk-TCUYH5GO.js";
14
+ import {
15
+ intFlag
16
+ } from "./chunk-NNV2OYEF.js";
17
17
  import {
18
18
  pageDelayFromFlags,
19
19
  readCursorFlag,
@@ -21,14 +21,14 @@ import {
21
21
  readablePage,
22
22
  rejectPaginationModifiersWithoutAll,
23
23
  streamAll
24
- } from "./chunk-OE4CY3ZL.js";
24
+ } from "./chunk-5AJS2V4T.js";
25
25
  import {
26
26
  renderSuccess,
27
27
  writeNdjsonItem
28
28
  } from "./chunk-QM57YDJE.js";
29
29
  import {
30
30
  downloadBinary
31
- } from "./chunk-RXDG57B2.js";
31
+ } from "./chunk-KD2XY7RS.js";
32
32
  import {
33
33
  GLOBAL_FLAGS,
34
34
  READ_SINGLE_FLAGS,
@@ -37,8 +37,7 @@ import {
37
37
  } from "./chunk-QLKGOIWS.js";
38
38
  import {
39
39
  DESCRIPTIONS
40
- } from "./chunk-5LGKZBAY.js";
41
- import "./chunk-ZYURL5VK.js";
40
+ } from "./chunk-ZC4S4B32.js";
42
41
 
43
42
  // src/commands/billing.ts
44
43
  import { defineCommand } from "citty";
@@ -119,9 +118,9 @@ async function runPdf(c, f) {
119
118
  process.stderr.write(`Invoice ${number}: ${bytes.length} bytes${f.output === "-" ? "" : ` written to ${f.output}`}.
120
119
  `);
121
120
  }
122
- async function confirmMoney(f, question) {
121
+ async function confirmMoney(f, question, priceHint = "Read the price first with `curviate billing quote`.") {
123
122
  if (f.yes) return true;
124
- if (!process.stdin.isTTY) usage("this charges money: pass --yes to confirm (no terminal to ask at). Read the price first with `curviate billing quote`.");
123
+ if (!process.stdin.isTTY) usage(`this charges money: pass --yes to confirm (no terminal to ask at). ${priceHint}`);
125
124
  process.stderr.write(`${question} [y/N] `);
126
125
  const answer = await new Promise((resolve) => {
127
126
  process.stdin.setEncoding("utf8");
@@ -216,9 +215,9 @@ var quoteCmd = defineCommand({
216
215
  var capCmd = defineCommand({
217
216
  meta: {
218
217
  name: "cap",
219
- description: "The spending cap: the most seats an agent may bring your Team to (100 until an Owner sets one), the seats now, the room left and what the cap's seats cost a month. Read only: an Owner changes it in the dashboard. Adding a seat past it is refused with SPENDING_CAP_REACHED. Owners only.",
218
+ description: "The spending cap: the most seats an agent may bring your Team to (`is_default` until an Owner sets one), the seats now, the room left and what the cap's seats cost a month. While Mailboxes from Curviate can be ordered it also carries `mailbox_cap`, the most of them an agent may bring your Team to: `cap`, `is_default`, `count` (held plus those in orders not yet created) and `room` (the cap minus the count). An order through an API key of more than `room` is refused with SPENDING_CAP_REACHED; no `mailbox_cap` means orders are closed now. Read only: an Owner changes either cap in the dashboard. Adding a seat past it is refused with SPENDING_CAP_REACHED. Owners only.",
220
219
  risk: "read",
221
- output: ["`cap_seats`, `is_default`, `seats`, `room_seats`, `monthly_amount` (cents), `currency`."],
220
+ output: ["`cap_seats`, `is_default`, `seats`, `room_seats`, `monthly_amount` (cents), `currency`; `mailbox_cap` { `cap`, `is_default`, `count`, `room` } while Mailboxes from Curviate can be ordered."],
222
221
  examples: ["curviate billing cap"]
223
222
  },
224
223
  args: { ...readOnly(READ_SINGLE_FLAGS) },
@@ -235,14 +234,126 @@ var changesCmd = defineCommand({
235
234
  args: { ...readOnly(GLOBAL_FLAGS) },
236
235
  run: online(runChanges)
237
236
  });
237
+ async function runSeatsAdd(f) {
238
+ const qty = intFlag("qty", f.qty ?? usage("how many seats? `curviate billing seats add <qty>`, 1 to 50."), 1, 50);
239
+ const body = { qty };
240
+ if (f.preview) return void process.stdout.write(JSON.stringify(buildPreviewOutput({ method: "accounts.addSeats", args: {}, body })) + "\n");
241
+ const c = await rootClient(f);
242
+ if (!await confirmMoney(f, `Buy ${qty} seat${qty === 1 ? "" : "s"} now? Each costs the price of its step (\`curviate billing quote\`); a yearly plan charges today.`)) return;
243
+ try {
244
+ renderSuccess(await c.accounts.addSeats(body), outputOpts(f), process);
245
+ } catch (err) {
246
+ await fail(err, f);
247
+ }
248
+ }
249
+ async function runSeatsRemove(f) {
250
+ const seatId = (f.seatId ?? "").trim() || usage("which seat? `curviate billing seats remove <seat_id>` (`curviate account seats` lists them).");
251
+ if (f.preview) return void process.stdout.write(JSON.stringify(buildPreviewOutput({ method: "accounts.cancelSeat", args: { seat_id: seatId }, body: {} })) + "\n");
252
+ const c = await rootClient(f);
253
+ if (!await confirmMoney(f, `Remove seat ${seatId} at the end of the current period? Its Account disconnects then.`)) return;
254
+ try {
255
+ renderSuccess(await c.accounts.cancelSeat(seatId), outputOpts(f), process);
256
+ } catch (err) {
257
+ await fail(err, f);
258
+ }
259
+ }
260
+ async function runPeriodSet(f) {
261
+ if (f.to !== "annual") usage("`curviate billing period set annual`: the one switch is monthly to yearly; there is no switch back.");
262
+ if (f.preview) return void process.stdout.write(JSON.stringify(buildPreviewOutput({ method: "billing.switchPeriod", args: {}, body: { to: "annual" } })) + "\n");
263
+ const c = await rootClient(f);
264
+ if (!await confirmMoney(f, "Switch to yearly billing at your next renewal? The renewal bills the whole year; there is no switch back to monthly.")) return;
265
+ try {
266
+ renderSuccess(await c.billing.switchPeriod(), outputOpts(f), process);
267
+ } catch (err) {
268
+ await fail(err, f);
269
+ }
270
+ }
271
+ var YES = { yes: { type: "boolean", description: "Confirm without a prompt (needed when no terminal can ask)." } };
272
+ var seatsAddCmd = defineCommand({
273
+ meta: {
274
+ name: "add",
275
+ description: "Buy seats now, inside your Team's spending cap: each seat costs the price of the step it falls in (`curviate billing quote`); a monthly plan prorates on the next invoice, a yearly plan charges today. This charges money: it asks first at a terminal; elsewhere pass --yes. An add past the spending cap is refused (SPENDING_CAP_REACHED) and buys nothing; from 80% of the cap the answer carries a SPENDING_CAP_NEAR notice. Only an Owner raises the cap, in the dashboard. Owners only.",
276
+ risk: "write",
277
+ rules: {
278
+ changes: "The subscription's seat count, and the bill.",
279
+ visible_to: "Your Team's Owners (the bill, the change log).",
280
+ budget_rows: [],
281
+ retry: "Never blind: every call buys the seats it asks for. After a timeout, read `curviate account seats` first.",
282
+ undo: "`curviate billing seats remove <seat_id>`, at the end of the period."
283
+ },
284
+ errors: {
285
+ SPENDING_CAP_REACHED: "the add would pass your Team's spending cap; nothing was bought. An Owner raises the cap in Settings, Billing.",
286
+ INSUFFICIENT_ROLE: "only an Owner buys seats."
287
+ },
288
+ seeAlso: ["curviate billing quote", "curviate billing cap", "curviate account seats"],
289
+ examples: ["curviate billing seats add 2", "curviate billing seats add 1 --yes --json"]
290
+ },
291
+ args: { ...WRITE_SINGLE_FLAGS, qty: { type: "positional", description: "How many seats to buy, 1 to 50." }, ...YES },
292
+ run: async ({ args }) => runSeatsAdd(args)
293
+ });
294
+ var seatsRemoveCmd = defineCommand({
295
+ meta: {
296
+ name: "remove",
297
+ description: "Remove one seat at the end of the current period, never checked against the spending cap. Asks first at a terminal; elsewhere pass --yes. Your Team's last paid seat is refused (CANCEL_IN_DASHBOARD): removing it cancels the subscription, which an Owner does in the dashboard. Owners only.",
298
+ risk: "write",
299
+ rules: {
300
+ changes: "The seat ends at the period end; the renewal bills one seat fewer.",
301
+ visible_to: "Your Team's Owners; the Account on the seat disconnects when it ends.",
302
+ budget_rows: [],
303
+ retry: "Safe: a seat already scheduled answers with its date.",
304
+ undo: "Keep the seat in the dashboard before the period ends."
305
+ },
306
+ errors: { CANCEL_IN_DASHBOARD: "the last paid seat: an Owner cancels in the dashboard.", INSUFFICIENT_ROLE: "only an Owner removes seats." },
307
+ seeAlso: ["curviate account seats", "curviate billing changes"],
308
+ examples: ["curviate billing seats remove seat_YOUR_SEAT_ID"]
309
+ },
310
+ args: { ...WRITE_SINGLE_FLAGS, seatId: { type: "positional", description: "The seat (seat_...), from `curviate account seats`." }, ...YES },
311
+ run: async ({ args }) => runSeatsRemove(args)
312
+ });
313
+ var seatsCmd = defineCommand({
314
+ meta: { name: "seats", description: "Buy seats inside the spending cap, or remove one at the end of the period. Cancelling the subscription is the dashboard's." },
315
+ subCommands: { add: seatsAddCmd, remove: seatsRemoveCmd },
316
+ async run() {
317
+ const { showHelp } = await import("./examples-5FJS47QF.js");
318
+ await showHelp(seatsCmd, ["curviate", "billing", "seats"]);
319
+ }
320
+ });
321
+ var periodSetCmd = defineCommand({
322
+ meta: {
323
+ name: "set",
324
+ description: "Switch a monthly subscription to yearly billing at its next renewal, for the same seats at the yearly price. Nothing is charged now; the renewal bills the full year. There is no switch back. Asks first at a terminal; elsewhere pass --yes. Owners only.",
325
+ risk: "write",
326
+ rules: {
327
+ changes: "The billing period, from the next renewal.",
328
+ visible_to: "Your Team's Owners.",
329
+ budget_rows: [],
330
+ retry: "Safe: a second call while the switch is pending changes nothing.",
331
+ undo: "None: there is no switch back to monthly."
332
+ },
333
+ errors: { INVALID_REQUEST: "already billed yearly.", INSUFFICIENT_ROLE: "only an Owner switches the period." },
334
+ examples: ["curviate billing period set annual"]
335
+ },
336
+ args: { ...WRITE_SINGLE_FLAGS, to: { type: "positional", description: "annual (the one switch)." }, ...YES },
337
+ run: async ({ args }) => runPeriodSet(args)
338
+ });
339
+ var periodCmd = defineCommand({
340
+ meta: { name: "period", description: "Your billing period: switch monthly to yearly." },
341
+ subCommands: { set: periodSetCmd },
342
+ async run() {
343
+ const { showHelp } = await import("./examples-5FJS47QF.js");
344
+ await showHelp(periodCmd, ["curviate", "billing", "period"]);
345
+ }
346
+ });
238
347
  var billingCommand = defineCommand({
239
348
  meta: { name: "billing", description: DESCRIPTIONS.billing },
240
- subCommands: { quote: quoteCmd, cap: capCmd, changes: changesCmd, invoices: invoicesCmd, price: priceCmd },
349
+ subCommands: { quote: quoteCmd, cap: capCmd, changes: changesCmd, invoices: invoicesCmd, price: priceCmd, seats: seatsCmd, period: periodCmd },
241
350
  async run() {
242
- const { showHelp } = await import("./examples-J4X5NEIE.js");
351
+ const { showHelp } = await import("./examples-5FJS47QF.js");
243
352
  await showHelp(billingCommand, ["curviate", "billing"]);
244
353
  }
245
354
  });
355
+
246
356
  export {
357
+ confirmMoney,
247
358
  billingCommand
248
359
  };
@@ -207,6 +207,20 @@ var EXIT_CODE_MAP = {
207
207
  MAILBOX_LIMIT_REACHED: 2,
208
208
  MAILBOX_APP_PASSWORD_REQUIRED: 2,
209
209
  MAILBOX_ADMIN_APPROVAL_REQUIRED: 5,
210
+ // Placement tests: the monthly allowance comes with paid seats (5, a seat or the new month lifts it, never a
211
+ // wait of minutes, so not 6); tests that cannot run at all today are "not available" (1, as PLATFORM_NOT_IMPLEMENTED).
212
+ PLACEMENT_TEST_ALLOWANCE_EXHAUSTED: 5,
213
+ PLACEMENT_TESTS_UNAVAILABLE: 1,
214
+ // Mailboxes from Curviate: a missing order is 4; a domain refused as named never succeeds as sent (2); an order
215
+ // already waiting on the domain is a state (8); a trial Team cannot order (11, billing); orders paused is "not
216
+ // available" (1).
217
+ MAILBOX_PURCHASE_NOT_FOUND: 4,
218
+ DOMAIN_IN_USE: 2,
219
+ DOMAIN_IS_COMPANY_EMAIL: 2,
220
+ MAILBOX_PURCHASE_PENDING: 8,
221
+ MAILBOX_PURCHASE_STATE_CONFLICT: 8,
222
+ MAILBOX_PURCHASE_TRIAL: 11,
223
+ MAILBOX_SALES_PAUSED: 1,
210
224
  // Seat calls: only an Owner raises the spending cap or cancels in the dashboard (5, someone else acts first).
211
225
  SPENDING_CAP_REACHED: 5,
212
226
  CANCEL_IN_DASHBOARD: 5,
@@ -235,6 +249,8 @@ var EXIT_CODE_MAP = {
235
249
  LEAD_NOT_ENROLLABLE: 2,
236
250
  CHAT_NOT_ONE_TO_ONE: 2,
237
251
  REPLY_NOT_LABELLABLE: 2,
252
+ NOT_A_REFERRAL: 2,
253
+ EMAIL_UNAVAILABLE: 2,
238
254
  STEP_IN_FLIGHT: 7,
239
255
  // Voice clips: the file is empty, not audio, undecodable or outside 1 to 120 seconds; it never succeeds as sent.
240
256
  VOICE_CLIP_INVALID: 2,
@@ -243,6 +259,7 @@ var EXIT_CODE_MAP = {
243
259
  };
244
260
  function getExitCode(error) {
245
261
  if (typeof error === "string") return EXIT_CODE_MAP[error] ?? 1;
262
+ if (error.outcomeUnknown === true) return 1;
246
263
  if (error.code === "INTERNAL" && error.httpStatus === void 0 && error.retryLikelyToSucceed === true) return 7;
247
264
  return EXIT_CODE_MAP[error.code] ?? 1;
248
265
  }
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  createClient,
8
8
  resolveEffectiveConfig
9
- } from "./chunk-RXDG57B2.js";
9
+ } from "./chunk-KD2XY7RS.js";
10
10
 
11
11
  // src/lib/root-command.ts
12
12
  var outputOpts = (f) => ({
@@ -35,7 +35,7 @@ async function rootClient(f) {
35
35
  async function fail(err, f) {
36
36
  const { CurviateError } = await import("@curviate/sdk");
37
37
  if (err instanceof CurviateError) {
38
- const { getExitCode } = await import("./exit-codes-P2FLCKM7.js");
38
+ const { getExitCode } = await import("./exit-codes-LQDMGDII.js");
39
39
  renderError(err, outputOpts(f), process);
40
40
  process.exit(getExitCode(err));
41
41
  }
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  readablePage
4
- } from "./chunk-OE4CY3ZL.js";
4
+ } from "./chunk-5AJS2V4T.js";
5
5
  import {
6
6
  assertNoStdinPlaceholder
7
7
  } from "./chunk-ZYURL5VK.js";
8
8
  import {
9
9
  getExitCode
10
- } from "./chunk-SCUTAREU.js";
10
+ } from "./chunk-EWSOIFG2.js";
11
11
 
12
12
  // src/lib/path-safety.ts
13
13
  var UNSAFE_CHARS = /[\u0000-\u0020\u007F/\\?#%]/;
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  fail,
4
4
  outputOpts
5
- } from "./chunk-3ZQNOKEK.js";
5
+ } from "./chunk-F3FEY4D5.js";
6
6
 
7
7
  // src/lib/chunks.ts
8
8
  async function sendInChunks(ids, size, send, f) {
@@ -32,7 +32,7 @@ async function sendChunked(chunks, send, f, unit) {
32
32
  `);
33
33
  return fail(err, f);
34
34
  }
35
- const { getExitCode } = await import("./exit-codes-P2FLCKM7.js");
35
+ const { getExitCode } = await import("./exit-codes-LQDMGDII.js");
36
36
  const e = err.toJSON();
37
37
  if (outputOpts(f).json) process.stdout.write(JSON.stringify({ error: e, progress }) + "\n");
38
38
  process.stderr.write(
@@ -1058,6 +1058,9 @@ var documents_default = {
1058
1058
  nullable: true
1059
1059
  }
1060
1060
  },
1061
+ one_lead_per_company: {
1062
+ type: "boolean"
1063
+ },
1061
1064
  reply_scope: {
1062
1065
  type: "string",
1063
1066
  enum: [
@@ -1276,6 +1279,9 @@ var documents_default = {
1276
1279
  nullable: true
1277
1280
  }
1278
1281
  },
1282
+ one_lead_per_company: {
1283
+ type: "boolean"
1284
+ },
1279
1285
  reply_scope: {
1280
1286
  type: "string",
1281
1287
  enum: [
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/lib/attach.ts
4
- import { readFile } from "fs/promises";
4
+ import * as fs from "fs";
5
+ import { readFile, stat } from "fs/promises";
5
6
  import { basename, extname } from "path";
6
7
  var AttachError = class extends Error {
7
8
  constructor(message) {
@@ -54,6 +55,20 @@ function toAttachmentPayload(filePath, buf, sendMode) {
54
55
  function isAudioFile(filePath) {
55
56
  return guessContentType(filePath).startsWith("audio/");
56
57
  }
58
+ async function openUpload(filePath, maxBytes) {
59
+ const filename = basename(filePath);
60
+ let size;
61
+ try {
62
+ const st = await stat(filePath);
63
+ if (!st.isFile()) throw new Error("not a file");
64
+ size = st.size;
65
+ } catch (err) {
66
+ throw new AttachError(`Cannot read attachment "${filename}": ${err instanceof Error ? err.message : "unknown error"}. Pass a valid file path.`);
67
+ }
68
+ if (size > maxBytes) throw new AttachError(`"${filename}" is ${size} bytes, over the ${maxBytes / (1024 * 1024)} MiB a file may be; nothing was sent. A link usually lands better than a file.`);
69
+ const open = fs.openAsBlob;
70
+ return { data: open ? await open(filePath) : await readAttachment(filePath), size };
71
+ }
57
72
 
58
73
  export {
59
74
  AttachError,
@@ -61,5 +76,6 @@ export {
61
76
  describeAttachment,
62
77
  guessContentType,
63
78
  toAttachmentPayload,
64
- isAudioFile
79
+ isAudioFile,
80
+ openUpload
65
81
  };
@@ -274,7 +274,7 @@ import { AsyncLocalStorage } from "async_hooks";
274
274
  import { Curviate, CurviateError as CurviateError2 } from "@curviate/sdk";
275
275
 
276
276
  // package.json
277
- var version = "0.57.0";
277
+ var version = "0.59.0";
278
278
 
279
279
  // src/lib/client.ts
280
280
  function headerStrings(headers) {
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ writeExport
4
+ } from "./chunk-PPGKQJKU.js";
2
5
  import {
3
6
  print,
4
7
  rate,
5
8
  table
6
9
  } from "./chunk-5S3MJVI5.js";
7
- import {
8
- writeExport
9
- } from "./chunk-PPGKQJKU.js";
10
10
  import {
11
11
  fail,
12
12
  listFlag,
13
13
  outputOpts,
14
14
  rootClient,
15
15
  usage
16
- } from "./chunk-3ZQNOKEK.js";
16
+ } from "./chunk-F3FEY4D5.js";
17
17
  import {
18
18
  intFlag
19
19
  } from "./chunk-NNV2OYEF.js";
@@ -24,14 +24,14 @@ import {
24
24
  readablePage,
25
25
  rejectPaginationModifiersWithoutAll,
26
26
  streamAll
27
- } from "./chunk-OE4CY3ZL.js";
27
+ } from "./chunk-5AJS2V4T.js";
28
28
  import {
29
29
  renderSuccess,
30
30
  writeNdjsonItem
31
31
  } from "./chunk-QM57YDJE.js";
32
32
  import {
33
33
  downloadBinary
34
- } from "./chunk-RXDG57B2.js";
34
+ } from "./chunk-KD2XY7RS.js";
35
35
  import {
36
36
  GLOBAL_FLAGS,
37
37
  READ_SINGLE_FLAGS,
@@ -39,7 +39,7 @@ import {
39
39
  } from "./chunk-QLKGOIWS.js";
40
40
  import {
41
41
  DESCRIPTIONS
42
- } from "./chunk-5LGKZBAY.js";
42
+ } from "./chunk-ZC4S4B32.js";
43
43
 
44
44
  // src/commands/analytics.ts
45
45
  import { defineCommand } from "citty";
@@ -189,10 +189,30 @@ var JOB_ENTITIES = ["campaign_activity", "account_activity", "account_metrics"];
189
189
  async function runExport(c, f) {
190
190
  if (f.json) usage("export commands take no --json: pass --format json.");
191
191
  const tables = f.table === void 0 ? [] : listFlag("table", f.table);
192
+ if (tables.includes("email")) {
193
+ if (tables.length > 1) usage("--table email is one table of its own: pass it alone.");
194
+ if (f.origin !== void 0) usage("--table email takes no --origin: it counts Campaign email only.");
195
+ const format2 = f.format ?? "csv";
196
+ const filters2 = { ...windowParams(f), ...filterParams(f, ["campaigns", "accounts"]) };
197
+ try {
198
+ if (f.job) {
199
+ const exp = await c.exports.create({ entity: "email_daily", format: format2, filters: filters2 });
200
+ renderSuccess(exp, outputOpts(f), process);
201
+ process.stderr.write(`Export ${exp["id"]} is ${exp["status"]}. Read it with \`curviate export get ${exp["id"]}\`, then \`curviate export download ${exp["id"]} -o <file>\` once ready.
202
+ `);
203
+ return;
204
+ }
205
+ const bytes = await downloadBinary(() => c.analytics.export({ ...filters2, format: format2, entity: "email_daily" }));
206
+ await writeExport(f.output, new Uint8Array(bytes));
207
+ } catch (err) {
208
+ await fail(err, f);
209
+ }
210
+ return;
211
+ }
192
212
  const entity = tables.length === 1 && JOB_ENTITIES.includes(tables[0]) ? tables[0] : "analytics";
193
213
  if (entity !== "analytics" && !f.job) usage(`--table ${entity} is built by a background job: add --job.`);
194
214
  const unknown = tables.find((t) => !ANALYTICS_TABLES.includes(t) && t !== entity);
195
- if (unknown !== void 0) usage(`--table takes ${ANALYTICS_TABLES.join(", ")}, or one of ${JOB_ENTITIES.join(", ")} with --job.`);
215
+ if (unknown !== void 0) usage(`--table takes ${ANALYTICS_TABLES.join(", ")} or email, or one of ${JOB_ENTITIES.join(", ")} with --job.`);
196
216
  const format = f.format ?? "csv";
197
217
  const filters = { ...windowParams(f), ...filterParams(f, ["campaigns", "accounts", "origin"]) };
198
218
  try {
@@ -306,7 +326,7 @@ var exportCmd = defineCommand({
306
326
  team: GLOBAL_FLAGS.team,
307
327
  "base-url": GLOBAL_FLAGS["base-url"],
308
328
  timeout: GLOBAL_FLAGS.timeout,
309
- table: { type: "string", description: "Comma list of daily, accounts, campaigns, enrollments (default all four); or, with --job, one of campaign_activity, account_activity, account_metrics." },
329
+ table: { type: "string", description: "Comma list of daily, accounts, campaigns, enrollments (default all four); or email alone: your Campaign email's daily counts per Mailbox, Account, Campaign, step, variant and receiving provider (at most 366 days); or, with --job, one of campaign_activity, account_activity, account_metrics." },
310
330
  format: { type: "string", description: "csv (default), json or ndjson (ndjson takes one table)." },
311
331
  output: { type: "string", alias: "o", description: "File to write (mode 0600), or - for stdout (default)." },
312
332
  job: { type: "boolean", description: "Build it in the background and print the export record instead of streaming it." },
@@ -321,13 +341,18 @@ var eventsCommand = defineCommand({
321
341
  meta: { name: "events", description: "The records behind the analytics numbers." },
322
342
  subCommands: { list: eventsListCmd },
323
343
  async run() {
324
- const { showHelp } = await import("./examples-J4X5NEIE.js");
344
+ const { showHelp } = await import("./examples-5FJS47QF.js");
325
345
  await showHelp(eventsCommand, ["curviate", "analytics", "events"]);
326
346
  }
327
347
  });
328
348
  async function runEmail(c, f) {
329
349
  const q = { ...windowParams(f), ...filterParams(f, ["campaigns", "accounts"]) };
330
- if (f.include !== void 0) q["include"] = listFlag("include", f.include);
350
+ const include = f.include === void 0 ? [] : listFlag("include", f.include);
351
+ const EMAIL_INCLUDES = ["weeks", "breakdowns", "mailboxes", "domains", "forecast"];
352
+ const bad = include.find((i) => !EMAIL_INCLUDES.includes(i));
353
+ if (bad !== void 0) usage(`--include takes ${EMAIL_INCLUDES.join(", ")} (got ${bad}).`);
354
+ if (f.forecast && !include.includes("forecast")) include.push("forecast");
355
+ if (include.length) q["include"] = include;
331
356
  try {
332
357
  const body = await c.analytics.email(q);
333
358
  if (outputOpts(f).json) return renderSuccess(body, outputOpts(f), process);
@@ -335,10 +360,55 @@ async function runEmail(c, f) {
335
360
  print(`sent ${String(body["sent"] ?? "-")} \xB7 reply ${rate(body["reply"], "replied", "first_emailed")} \xB7 open ${body["open"] == null ? "not tracked" : rate(body["open"], "opened", "tracked")} \xB7 bounce ${rate(body["bounce"], "bounced", "sent")} \xB7 opt-out ${rate(body["opt_out"], "opted_out", "first_emailed")}`);
336
361
  if (today) print(`today: ${String(today["sent"])} sent of a ${String(today["cap"])} daily cap`);
337
362
  if (body["tracking"] !== "set_up") print(`open tracking: ${String(body["tracking"])} (set it up on the Mailboxes for an open rate over every email)`);
363
+ for (const m of body["mailboxes"] ?? []) print(`mailbox ${String(m["address"])}: ${String(m["state"])}, sent ${String(m["sent"] ?? 0)}, cap ${String(m["cap_lowered_to"] ?? m["daily_cap"])}`);
364
+ for (const d of body["domains"] ?? []) {
365
+ const checks = d["checks"] ?? {};
366
+ print(`domain ${String(d["name"])}: ${Object.entries(checks).map(([k, v]) => `${k} ${String(v)}`).join(", ")}`);
367
+ }
368
+ const breakdowns = body["breakdowns"];
369
+ if (breakdowns) for (const [by, rows] of Object.entries(breakdowns)) print(`by ${by}: ${rows.length} row${rows.length === 1 ? "" : "s"} (--json for the figures)`);
370
+ const forecast = body["forecast"];
371
+ if (forecast) {
372
+ if (forecast["status"] === "computing") print("forecast: computing; read again in a few minutes");
373
+ else for (const day of forecast["daily"] ?? []) print(`forecast ${String(day["date"])}: ${String(day["emails_sent"])} emails`);
374
+ }
338
375
  } catch (err) {
339
376
  await fail(err, f);
340
377
  }
341
378
  }
379
+ async function runAttention(c, f) {
380
+ const q = {};
381
+ if (f.campaign !== void 0) q["campaign_id"] = f.campaign;
382
+ if (f["account-id"] !== void 0) q["account_id"] = f["account-id"];
383
+ try {
384
+ const body = await c.analytics.emailAttention(q);
385
+ if (outputOpts(f).json) return renderSuccess(body, outputOpts(f), process);
386
+ const items = body.items ?? [];
387
+ if (!items.length) return void print("Nothing needs a fix.");
388
+ print(table(["PROBLEM", "ON", "SINCE", "FIX"], items.map((i) => {
389
+ const on = i["subject"];
390
+ return [i["kind"], on ? `${String(on["type"])} ${String(on["id"])}` : "", i["since"], i["next"]];
391
+ })));
392
+ } catch (err) {
393
+ await fail(err, f);
394
+ }
395
+ }
396
+ var attentionCmd = defineCommand({
397
+ meta: {
398
+ name: "attention",
399
+ description: "Needs a fix: what to fix in your email sending now, one row per problem, what stops sending first: paused or disconnected Mailboxes, failing DMARC or DKIM, mail landing in spam, Accounts without a Mailbox, and advice. Each row names the call that leads to its fix; a row leaves once its problem ends. Read-only.",
400
+ risk: "read",
401
+ output: ["A table of problem (a Notification type), what it is on, since when, and the fix command; --json (or piped) prints the API body (`values` carries the problem's codes and numbers)."],
402
+ seeAlso: ["curviate analytics email", "curviate mailbox list", "curviate notification list --channel email"],
403
+ examples: ["curviate analytics attention", "curviate analytics attention --campaign mot_YOUR_CAMPAIGN_ID --json"]
404
+ },
405
+ args: {
406
+ ...readOnly(READ_SINGLE_FLAGS),
407
+ campaign: { type: "string", description: "Only problems that touch this Campaign (mot_...)." },
408
+ "account-id": { type: "string", description: "Only problems that touch this Account (acc_...)." }
409
+ },
410
+ run: online(runAttention)
411
+ });
342
412
  var emailCmd = defineCommand({
343
413
  meta: {
344
414
  name: "email",
@@ -348,17 +418,19 @@ var emailCmd = defineCommand({
348
418
  "reply: Leads first emailed in the window whose first reply, by email or on LinkedIn, came after that email, so far; an out-of-office reply is never a reply.",
349
419
  "open: opened over tracked emails; null when no Mailbox in scope tracks opens (`tracking`).",
350
420
  "bounce: bounced over sent. opt-out: Leads who opted out over Leads first emailed.",
351
- "--include weeks adds the reply rate by week of first email. A compact line by default; --json (or piped) prints the API body."
421
+ "--include weeks adds the reply rate by week of first email. A compact line by default; --json (or piped) prints the API body.",
422
+ "landing: where mail lands, as verdicts, each with a reason when there is nothing to read: warm_up.reason warm_up_off (warm-up is off), weekly_check.reason no_test_inboxes (not available), tests.reason no_test_inboxes or no_test_run (none run yet); a Mailbox's reputation_reason warm_up_off (no score while warm-up is off). Show them as served."
352
423
  ],
353
424
  seeAlso: ["curviate analytics get", "curviate mailbox list"],
354
- examples: ["curviate analytics email --range 30d", "curviate analytics email --campaigns mot_YOUR_CAMPAIGN_ID --include weeks --json"]
425
+ examples: ["curviate analytics email --range 30d", "curviate analytics email --campaigns mot_YOUR_CAMPAIGN_ID --include weeks --json", "curviate analytics email --include mailboxes,domains --forecast"]
355
426
  },
356
427
  args: {
357
428
  ...readOnly(READ_SINGLE_FLAGS),
358
429
  campaigns: { type: "string", description: "Only these Campaigns, comma list (mot_...)." },
359
430
  ...WINDOW_ARGS,
360
431
  accounts: FILTER_ARGS.accounts,
361
- include: { type: "string", description: "Sections to add: weeks (the reply rate by week of first email)." }
432
+ include: { type: "string", description: "Sections to add, comma list: weeks (the reply rate by week of first email), breakdowns (by Campaign, step, variant, receiving provider, thread setting, Mailbox and Account), mailboxes, domains (their checks), forecast." },
433
+ forecast: { type: "boolean", description: "Add the emails your Campaigns are expected to send each day from today (include=forecast): a simulation of their email steps, each Mailbox counting its daily cap." }
362
434
  },
363
435
  run: online(runEmail)
364
436
  });
@@ -367,11 +439,12 @@ var analyticsCommand = defineCommand({
367
439
  subCommands: {
368
440
  get: getCmd,
369
441
  email: emailCmd,
442
+ attention: attentionCmd,
370
443
  events: eventsCommand,
371
444
  export: exportCmd
372
445
  },
373
446
  async run() {
374
- const { showHelp } = await import("./examples-J4X5NEIE.js");
447
+ const { showHelp } = await import("./examples-5FJS47QF.js");
375
448
  await showHelp(analyticsCommand, ["curviate", "analytics"]);
376
449
  }
377
450
  });
@@ -18,17 +18,17 @@ import {
18
18
  isAudioFile,
19
19
  readAttachment,
20
20
  toAttachmentPayload
21
- } from "./chunk-VHNF6OZD.js";
21
+ } from "./chunk-JY26SUNH.js";
22
22
  import {
23
23
  requireAccount
24
- } from "./chunk-F7CLAS5Y.js";
24
+ } from "./chunk-HG2G5OAZ.js";
25
25
  import {
26
26
  buildPreviewOutput
27
27
  } from "./chunk-TCUYH5GO.js";
28
28
  import {
29
29
  readableId,
30
30
  readableObject
31
- } from "./chunk-OE4CY3ZL.js";
31
+ } from "./chunk-5AJS2V4T.js";
32
32
  import {
33
33
  renderError,
34
34
  renderSuccess,
@@ -38,7 +38,7 @@ import {
38
38
  createClient,
39
39
  downloadBinary,
40
40
  resolveEffectiveConfig
41
- } from "./chunk-RXDG57B2.js";
41
+ } from "./chunk-KD2XY7RS.js";
42
42
  import {
43
43
  READ_SINGLE_FLAGS,
44
44
  WRITE_FLAGS,
@@ -46,7 +46,7 @@ import {
46
46
  } from "./chunk-QLKGOIWS.js";
47
47
  import {
48
48
  DESCRIPTIONS
49
- } from "./chunk-5LGKZBAY.js";
49
+ } from "./chunk-ZC4S4B32.js";
50
50
  import {
51
51
  looksLikeCommandWord,
52
52
  nearestSubcommand
@@ -153,7 +153,7 @@ var MEMBER_PROVIDER_ID_RE = /^A[CDE][A-Za-z0-9_-]{4,}$/;
153
153
  async function handleSdkError(err, outOpts, out) {
154
154
  const { CurviateError } = await import("@curviate/sdk");
155
155
  if (err instanceof CurviateError) {
156
- const { getExitCode } = await import("./exit-codes-P2FLCKM7.js");
156
+ const { getExitCode } = await import("./exit-codes-LQDMGDII.js");
157
157
  renderError(err, outOpts, out);
158
158
  process.exit(getExitCode(err));
159
159
  }