@curviate/cli 0.56.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/README.md +9 -2
  3. package/dist/{account-ZF5NEMID.js → account-GSL6BCNX.js} +49 -13
  4. package/dist/{analytics-M7JWS67A.js → analytics-4FUMJSMC.js} +6 -6
  5. package/dist/{beta-consent-4Q2LZZQC.js → beta-consent-EC2QF6CM.js} +4 -4
  6. package/dist/billing-STRNXA4H.js +19 -0
  7. package/dist/{chunk-XP6S6E55.js → chunk-3IL3D5IZ.js} +2 -2
  8. package/dist/{chunk-UWRWZG4N.js → chunk-5OAJ4D65.js} +2 -2
  9. package/dist/{chunk-AMTKGO37.js → chunk-5Z3CCE5N.js} +1 -1
  10. package/dist/chunk-7F6B7P32.js +359 -0
  11. package/dist/{chunk-UOWOKEB2.js → chunk-CQHCPZ5I.js} +1 -1
  12. package/dist/{chunk-RDKTHFQ6.js → chunk-EWSOIFG2.js} +21 -0
  13. package/dist/{chunk-RKNW4UX4.js → chunk-JKOQX46J.js} +6 -0
  14. package/dist/{chunk-VHNF6OZD.js → chunk-JY26SUNH.js} +18 -2
  15. package/dist/{chunk-VEMK4MJM.js → chunk-KS4I4B3Z.js} +6 -6
  16. package/dist/{chunk-MIOEYSBQ.js → chunk-KUVJM5CP.js} +1 -1
  17. package/dist/{chunk-CRO7PJ4I.js → chunk-MLZSXQZC.js} +2 -2
  18. package/dist/{chunk-7PLTQHNO.js → chunk-PBJZQZPO.js} +1 -1
  19. package/dist/{chunk-J4SFOFMT.js → chunk-WGGZWJPO.js} +11 -11
  20. package/dist/{chunk-L3RJU7C3.js → chunk-WITIJCUU.js} +115 -14
  21. package/dist/{chunk-MWVTFTWV.js → chunk-XDPU2YAF.js} +8 -5
  22. package/dist/{chunk-EI64VFBE.js → chunk-XXB4MAX3.js} +121 -11
  23. package/dist/cli.js +30 -28
  24. package/dist/{comment-D6RSZTVK.js → comment-MUELYZYN.js} +8 -8
  25. package/dist/{company-3Z6PXGTW.js → company-5N7CXORR.js} +21 -10
  26. package/dist/company-record-HWLTP4TV.js +213 -0
  27. package/dist/{config-VY5MCJMN.js → config-PI7JMQ2L.js} +2 -2
  28. package/dist/{connect-G2RTLV7G.js → connect-NNZOOPWV.js} +11 -11
  29. package/dist/{contact-QSLJCBDE.js → contact-VNG7HRCN.js} +8 -8
  30. package/dist/{contact-groups-OITAD73K.js → contact-groups-6JF7VX6Q.js} +10 -10
  31. package/dist/{contact-import-LT7BKESC.js → contact-import-TMJWY2VD.js} +10 -10
  32. package/dist/core-ZRJY3HTF.js +46 -0
  33. package/dist/{do-not-contact-ZA7KS5WD.js → do-not-contact-GDVIUNMT.js} +19 -17
  34. package/dist/{doctor-JQT3DO6G.js → doctor-ZNAR5AZ2.js} +21 -4
  35. package/dist/{document-H65EXU4L.js → document-G6UND26L.js} +1 -1
  36. package/dist/{domain-7EX4E34B.js → domain-62YUYVDW.js} +8 -8
  37. package/dist/{draft-7U6H4BPF.js → draft-ED6RL67K.js} +5 -5
  38. package/dist/{enrollment-AZ6XGVVL.js → enrollment-LN3Z3RC5.js} +11 -7
  39. package/dist/{examples-IGQJCSNL.js → examples-5FJS47QF.js} +2 -2
  40. package/dist/{exit-codes-ZSOLAXQO.js → exit-codes-LQDMGDII.js} +1 -1
  41. package/dist/{export-OYMQXL62.js → export-S6D4FEAG.js} +4 -4
  42. package/dist/{feed-M5D4SJW7.js → feed-AC7HWUCD.js} +6 -6
  43. package/dist/{group-UTC3YBKE.js → group-6N37Q5ZS.js} +6 -6
  44. package/dist/{inbox-VSGNHSLG.js → inbox-JFRBROQ2.js} +6 -6
  45. package/dist/{inboxes-23C2MJK4.js → inboxes-IBZHZKSD.js} +6 -6
  46. package/dist/{incoming-QVPP32K7.js → incoming-YDRPPO24.js} +5 -5
  47. package/dist/{job-ZHVFFRWE.js → job-CSRHIFZM.js} +6 -6
  48. package/dist/{login-6OTNXEJZ.js → login-M7ZLOR2U.js} +2 -2
  49. package/dist/mailbox-E2K3I2VH.js +712 -0
  50. package/dist/{message-PIV77W47.js → message-SX6RDGWP.js} +7 -7
  51. package/dist/{motion-AHYF34DP.js → motion-4HH3OFI6.js} +118 -13
  52. package/dist/{network-RJHJFZEY.js → network-JQYLSQDH.js} +9 -9
  53. package/dist/{notification-XGR4NT3S.js → notification-ZAQM463D.js} +6 -6
  54. package/dist/{notifications-BHRWSHPR.js → notifications-N55F3DP3.js} +14 -9
  55. package/dist/{post-Z7AVDDKA.js → post-SIHHJX3P.js} +8 -8
  56. package/dist/{profile-YZNBX2RP.js → profile-VBHX3QGP.js} +12 -12
  57. package/dist/{recruiter-EXM4P7X7.js → recruiter-7AGFKQPI.js} +9 -9
  58. package/dist/{sales-nav-CKDSEXV2.js → sales-nav-ADVFBKWB.js} +9 -9
  59. package/dist/{search-B7FB6674.js → search-THJFPGOH.js} +16 -16
  60. package/dist/{setup-VZVPLJ4V.js → setup-D6D7SNND.js} +4 -4
  61. package/dist/signal-TGSF7WEP.js +438 -0
  62. package/dist/{team-PYABBUHO.js → team-MVNHCWJP.js} +59 -5
  63. package/dist/{tier-PRK4WQKR.js → tier-DAF7Y2HN.js} +6 -5
  64. package/dist/unibox-7B6B4SXB.js +741 -0
  65. package/dist/{webhook-V74EV4E2.js → webhook-NUVSTDXF.js} +9 -9
  66. package/package.json +3 -3
  67. package/dist/billing-LYPSX5SR.js +0 -196
  68. package/dist/core-RFTNNB6P.js +0 -46
  69. package/dist/mailbox-HD2UXZCA.js +0 -405
  70. package/dist/unibox-ZNKX2EKL.js +0 -410
@@ -0,0 +1,359 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ writeAtomic
4
+ } from "./chunk-GOICALYQ.js";
5
+ import {
6
+ fail,
7
+ outputOpts,
8
+ rootClient,
9
+ usage
10
+ } from "./chunk-5OAJ4D65.js";
11
+ import {
12
+ buildPreviewOutput
13
+ } from "./chunk-TCUYH5GO.js";
14
+ import {
15
+ intFlag
16
+ } from "./chunk-NNV2OYEF.js";
17
+ import {
18
+ pageDelayFromFlags,
19
+ readCursorFlag,
20
+ readMaxPagesFlag,
21
+ readablePage,
22
+ rejectPaginationModifiersWithoutAll,
23
+ streamAll
24
+ } from "./chunk-KUVJM5CP.js";
25
+ import {
26
+ renderSuccess,
27
+ writeNdjsonItem
28
+ } from "./chunk-QM57YDJE.js";
29
+ import {
30
+ downloadBinary
31
+ } from "./chunk-PBJZQZPO.js";
32
+ import {
33
+ GLOBAL_FLAGS,
34
+ READ_SINGLE_FLAGS,
35
+ WRITE_SINGLE_FLAGS,
36
+ readOnly
37
+ } from "./chunk-QLKGOIWS.js";
38
+ import {
39
+ DESCRIPTIONS
40
+ } from "./chunk-XDPU2YAF.js";
41
+
42
+ // src/commands/billing.ts
43
+ import { defineCommand } from "citty";
44
+ var online = (fn) => async ({ args }) => {
45
+ const f = args;
46
+ await fn(await rootClient(f), f);
47
+ };
48
+ async function runQuote(c, f) {
49
+ const seats = intFlag("seats", f.seats ?? usage("--seats is required: how many seats to price, 1 or more."), 1);
50
+ const period = f.period ?? "monthly";
51
+ if (period !== "monthly" && period !== "annual") usage("--period takes monthly or annual.");
52
+ try {
53
+ renderSuccess(await c.billing.quote({ seats: String(seats), period }), outputOpts(f), process);
54
+ } catch (err) {
55
+ await fail(err, f);
56
+ }
57
+ }
58
+ async function runCap(c, f) {
59
+ try {
60
+ renderSuccess(await c.billing.spendingCap(), outputOpts(f), process);
61
+ } catch (err) {
62
+ await fail(err, f);
63
+ }
64
+ }
65
+ async function runChanges(c, f) {
66
+ rejectPaginationModifiersWithoutAll(f, process);
67
+ const params = {};
68
+ if (f.limit !== void 0) params["limit"] = intFlag("limit", f.limit, 1, 100);
69
+ const cursor = readCursorFlag(f, process);
70
+ if (cursor) params["cursor"] = cursor;
71
+ try {
72
+ if (f.all) {
73
+ const page = (p) => c.billing.changes(p);
74
+ for await (const item of streamAll(page, params, { maxPages: readMaxPagesFlag(f, process), out: process, pageDelayMs: pageDelayFromFlags(f) })) writeNdjsonItem(process, item, f.fields);
75
+ } else {
76
+ renderSuccess(readablePage(await c.billing.changes(params)), outputOpts(f), process);
77
+ }
78
+ } catch (err) {
79
+ await fail(err, f);
80
+ }
81
+ }
82
+ async function runList(c, f) {
83
+ rejectPaginationModifiersWithoutAll(f, process);
84
+ const params = {};
85
+ if (f.limit !== void 0) params["limit"] = intFlag("limit", f.limit, 1, 100);
86
+ const cursor = readCursorFlag(f, process);
87
+ if (cursor) params["cursor"] = cursor;
88
+ try {
89
+ if (f.all) {
90
+ const page = (p) => c.billing.invoices.list(p);
91
+ for await (const item of streamAll(page, params, { maxPages: readMaxPagesFlag(f, process), out: process, pageDelayMs: pageDelayFromFlags(f) })) writeNdjsonItem(process, item, f.fields);
92
+ } else {
93
+ renderSuccess(readablePage(await c.billing.invoices.list(params)), outputOpts(f), process);
94
+ }
95
+ } catch (err) {
96
+ await fail(err, f);
97
+ }
98
+ }
99
+ async function runPdf(c, f) {
100
+ const number = String(f.number ?? "");
101
+ if (number.trim() === "") usage("the invoice number is empty. Take it from `curviate billing invoices`.");
102
+ if (f.output === void 0 || f.output.trim() === "") usage("-o <file> is required: the PDF is written there, or to stdout with -o - when stdout is not a terminal.");
103
+ if (f.output === "-" && process.stdout.isTTY) usage("-o - would write a PDF to the terminal. Pass a file name.");
104
+ let bytes;
105
+ try {
106
+ bytes = Buffer.from(await downloadBinary(() => c.billing.invoices.pdf(number)));
107
+ } catch (err) {
108
+ return fail(err, f);
109
+ }
110
+ if (f.output === "-") process.stdout.write(bytes);
111
+ else {
112
+ try {
113
+ writeAtomic(f.output, bytes);
114
+ } catch (err) {
115
+ usage(`-o: cannot write ${f.output}: ${err.code ?? "write error"}.`);
116
+ }
117
+ }
118
+ process.stderr.write(`Invoice ${number}: ${bytes.length} bytes${f.output === "-" ? "" : ` written to ${f.output}`}.
119
+ `);
120
+ }
121
+ async function confirmMoney(f, question, priceHint = "Read the price first with `curviate billing quote`.") {
122
+ if (f.yes) return true;
123
+ if (!process.stdin.isTTY) usage(`this charges money: pass --yes to confirm (no terminal to ask at). ${priceHint}`);
124
+ process.stderr.write(`${question} [y/N] `);
125
+ const answer = await new Promise((resolve) => {
126
+ process.stdin.setEncoding("utf8");
127
+ process.stdin.once("data", (chunk) => resolve(chunk.trim().toLowerCase()));
128
+ });
129
+ process.stdin.pause();
130
+ if (answer === "y" || answer === "yes") return true;
131
+ process.stderr.write("Aborted: nothing was charged.\n");
132
+ return false;
133
+ }
134
+ async function runMove(f) {
135
+ if (f.preview) return void process.stdout.write(JSON.stringify(buildPreviewOutput({ method: "billing.moveToCurrentPrice", args: {}, body: {} })) + "\n");
136
+ const c = await rootClient(f);
137
+ if (!await confirmMoney(f, "Move your subscription to the current price now? The unused time is credited and the current price charged for the rest of the period (yearly: today).")) return;
138
+ try {
139
+ renderSuccess(await c.billing.moveToCurrentPrice(), outputOpts(f), process);
140
+ } catch (err) {
141
+ await fail(err, f);
142
+ }
143
+ }
144
+ var moveCmd = defineCommand({
145
+ meta: {
146
+ name: "move",
147
+ description: "Move a subscription on a previous price (Build, Automate or Seat) to the current price now, same seats and billing period. This charges money: the unused time on the previous price is credited and the current price charged for the rest of the period, monthly on the next invoice, yearly today. Asks first at a terminal; elsewhere pass --yes. A Team already on the current price is refused and nothing is charged. Owners only.",
148
+ risk: "high",
149
+ rules: {
150
+ changes: "The subscription's price; a yearly move charges the difference today.",
151
+ visible_to: "Your Team's Owners, on the invoice.",
152
+ budget_rows: [],
153
+ retry: "A second call is refused (already on the current price); nothing is charged twice.",
154
+ undo: "None: there is no move back to a previous price.",
155
+ blast_radius: "The Team's whole subscription."
156
+ },
157
+ errors: { INVALID_REQUEST: "already on the current price, no subscription, or a previous price that cannot be moved in place; nothing was charged.", INSUFFICIENT_ROLE: "only an Owner moves the price." },
158
+ output: ["`moved`, `period`, `seats` and `charged_today` (cents, tax included; 0 for a monthly move)."],
159
+ seeAlso: ["curviate billing quote", "curviate tier"],
160
+ examples: ["curviate billing price move", "curviate billing price move --yes --json"]
161
+ },
162
+ args: { ...WRITE_SINGLE_FLAGS, yes: { type: "boolean", description: "Confirm the charge without a prompt (needed when no terminal can ask)." } },
163
+ run: async ({ args }) => runMove(args)
164
+ });
165
+ var priceCmd = defineCommand({
166
+ meta: { name: "price", description: "Your subscription's price: move one on a previous price to the current price." },
167
+ subCommands: { move: moveCmd }
168
+ });
169
+ var pdfCmd = defineCommand({
170
+ meta: {
171
+ name: "pdf",
172
+ description: "Download one invoice as a PDF, by its number from `curviate billing invoices`. Owners only. The file is written whole or not at all.",
173
+ risk: "read",
174
+ output: ["The PDF bytes, to -o <file> (replaced whole on success) or, with -o -, to stdout; a byte count on stderr."],
175
+ examples: ["curviate billing invoices pdf INV-0001 -o invoice.pdf"]
176
+ },
177
+ args: {
178
+ "api-key": GLOBAL_FLAGS["api-key"],
179
+ profile: GLOBAL_FLAGS.profile,
180
+ team: GLOBAL_FLAGS.team,
181
+ "base-url": GLOBAL_FLAGS["base-url"],
182
+ timeout: GLOBAL_FLAGS.timeout,
183
+ number: { type: "positional", description: "The invoice number, from the invoice list." },
184
+ output: { type: "string", alias: "o", required: true, description: "Write the PDF to this path, or - for stdout." }
185
+ },
186
+ run: online(runPdf)
187
+ });
188
+ var invoicesCmd = defineCommand({
189
+ meta: {
190
+ name: "invoices",
191
+ description: "List your Team's issued invoices, newest first: number, amount (in the currency's smallest unit), status and service period. No links: download a PDF by its number. Owners only.",
192
+ risk: "read",
193
+ output: ["`items` (number, created_at, period_start, period_end, total, currency, status) and a `cursor`; with --all, one invoice per line."],
194
+ examples: ["curviate billing invoices", "curviate billing invoices --json --limit 12"]
195
+ },
196
+ args: { ...readOnly(GLOBAL_FLAGS) },
197
+ subCommands: { pdf: pdfCmd },
198
+ run: online(runList)
199
+ });
200
+ var quoteCmd = defineCommand({
201
+ meta: {
202
+ name: "quote",
203
+ description: "Price a number of seats for one period, step by step: each seat costs the price of the step it falls in, so adding a seat never changes what the earlier ones cost. Amounts in cents. Computed from the price list; charges nothing. Owners only.",
204
+ risk: "read",
205
+ output: ["`total` and `steps[]` (from, up_to, unit_amount, seats, amount), in cents, with `currency` and `period`."],
206
+ examples: ["curviate billing quote --seats 25", "curviate billing quote --seats 25 --period annual"]
207
+ },
208
+ args: {
209
+ ...readOnly(READ_SINGLE_FLAGS),
210
+ seats: { type: "string", required: true, description: "How many seats to price, 1 or more." },
211
+ period: { type: "string", description: "monthly (default) or annual." }
212
+ },
213
+ run: online(runQuote)
214
+ });
215
+ var capCmd = defineCommand({
216
+ meta: {
217
+ name: "cap",
218
+ 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.",
219
+ risk: "read",
220
+ output: ["`cap_seats`, `is_default`, `seats`, `room_seats`, `monthly_amount` (cents), `currency`."],
221
+ examples: ["curviate billing cap"]
222
+ },
223
+ args: { ...readOnly(READ_SINGLE_FLAGS) },
224
+ run: online(runCap)
225
+ });
226
+ var changesCmd = defineCommand({
227
+ meta: {
228
+ name: "changes",
229
+ description: "Every seat added or removed and every spending cap change on your Team, newest first: who made it (a person or an API key), the way it came in, the seat counts before and after and what it adds to the monthly price. Owners only.",
230
+ risk: "read",
231
+ output: ["`items` and a `cursor`; with --all, one change per line."],
232
+ examples: ["curviate billing changes", "curviate billing changes --all"]
233
+ },
234
+ args: { ...readOnly(GLOBAL_FLAGS) },
235
+ run: online(runChanges)
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
+ });
347
+ var billingCommand = defineCommand({
348
+ meta: { name: "billing", description: DESCRIPTIONS.billing },
349
+ subCommands: { quote: quoteCmd, cap: capCmd, changes: changesCmd, invoices: invoicesCmd, price: priceCmd, seats: seatsCmd, period: periodCmd },
350
+ async run() {
351
+ const { showHelp } = await import("./examples-5FJS47QF.js");
352
+ await showHelp(billingCommand, ["curviate", "billing"]);
353
+ }
354
+ });
355
+
356
+ export {
357
+ confirmMoney,
358
+ billingCommand
359
+ };
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-UEAX6KUB.js";
5
5
  import {
6
6
  readableId
7
- } from "./chunk-MIOEYSBQ.js";
7
+ } from "./chunk-KUVJM5CP.js";
8
8
 
9
9
  // src/lib/member-id.ts
10
10
  var MEMBER_PROVIDER_ID_RE = /^A[CDE][A-Za-z0-9_-]{4,}$/;
@@ -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,
@@ -215,6 +229,9 @@ var EXIT_CODE_MAP = {
215
229
  RESOURCE_IN_USE: 2,
216
230
  LEAD_LIMIT_REACHED: 2,
217
231
  IMPORT_QUEUE_FULL: 6,
232
+ // Import control: the import's status forbids it, or a continue has nothing left; never succeeds as sent.
233
+ IMPORT_STATUS_CONFLICT: 2,
234
+ IMPORT_CANNOT_CONTINUE: 2,
218
235
  // Campaigns and Enrollments. Every refusal but one never succeeds as
219
236
  // sent (2): fix the document, merge the newer Sequence, or pick another
220
237
  // Enrollment or Account. STEP_IN_FLIGHT settles within a minute (7, the
@@ -231,6 +248,9 @@ var EXIT_CODE_MAP = {
231
248
  KNOWN_CHAT: 2,
232
249
  LEAD_NOT_ENROLLABLE: 2,
233
250
  CHAT_NOT_ONE_TO_ONE: 2,
251
+ REPLY_NOT_LABELLABLE: 2,
252
+ NOT_A_REFERRAL: 2,
253
+ EMAIL_UNAVAILABLE: 2,
234
254
  STEP_IN_FLIGHT: 7,
235
255
  // Voice clips: the file is empty, not audio, undecodable or outside 1 to 120 seconds; it never succeeds as sent.
236
256
  VOICE_CLIP_INVALID: 2,
@@ -239,6 +259,7 @@ var EXIT_CODE_MAP = {
239
259
  };
240
260
  function getExitCode(error) {
241
261
  if (typeof error === "string") return EXIT_CODE_MAP[error] ?? 1;
262
+ if (error.outcomeUnknown === true) return 1;
242
263
  if (error.code === "INTERNAL" && error.httpStatus === void 0 && error.retryLikelyToSucceed === true) return 7;
243
264
  return EXIT_CODE_MAP[error.code] ?? 1;
244
265
  }
@@ -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
  };
@@ -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-CRO7PJ4I.js";
24
+ } from "./chunk-MLZSXQZC.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-MIOEYSBQ.js";
31
+ } from "./chunk-KUVJM5CP.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-7PLTQHNO.js";
41
+ } from "./chunk-PBJZQZPO.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-MWVTFTWV.js";
49
+ } from "./chunk-XDPU2YAF.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-ZSOLAXQO.js");
156
+ const { getExitCode } = await import("./exit-codes-LQDMGDII.js");
157
157
  renderError(err, outOpts, out);
158
158
  process.exit(getExitCode(err));
159
159
  }
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-QM57YDJE.js";
6
6
  import {
7
7
  isPlainObject
8
- } from "./chunk-7PLTQHNO.js";
8
+ } from "./chunk-PBJZQZPO.js";
9
9
 
10
10
  // src/lib/paginate.ts
11
11
  import { CurviateError } from "@curviate/sdk";
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  readablePage
4
- } from "./chunk-MIOEYSBQ.js";
4
+ } from "./chunk-KUVJM5CP.js";
5
5
  import {
6
6
  assertNoStdinPlaceholder
7
7
  } from "./chunk-ZYURL5VK.js";
8
8
  import {
9
9
  getExitCode
10
- } from "./chunk-RDKTHFQ6.js";
10
+ } from "./chunk-EWSOIFG2.js";
11
11
 
12
12
  // src/lib/path-safety.ts
13
13
  var UNSAFE_CHARS = /[\u0000-\u0020\u007F/\\?#%]/;
@@ -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.56.0";
277
+ var version = "0.58.0";
278
278
 
279
279
  // src/lib/client.ts
280
280
  function headerStrings(headers) {
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  requireAccount
4
- } from "./chunk-CRO7PJ4I.js";
4
+ } from "./chunk-MLZSXQZC.js";
5
5
  import {
6
6
  writeAtomic
7
7
  } from "./chunk-GOICALYQ.js";
8
8
  import {
9
9
  sendInChunks
10
- } from "./chunk-XP6S6E55.js";
10
+ } from "./chunk-3IL3D5IZ.js";
11
11
  import {
12
12
  fail,
13
13
  listFlag,
14
14
  outputOpts,
15
15
  rootClient,
16
16
  usage
17
- } from "./chunk-UWRWZG4N.js";
17
+ } from "./chunk-5OAJ4D65.js";
18
18
  import {
19
19
  buildPreviewOutput
20
20
  } from "./chunk-TCUYH5GO.js";
@@ -29,14 +29,14 @@ import {
29
29
  readablePage,
30
30
  rejectPaginationModifiersWithoutAll,
31
31
  streamAll
32
- } from "./chunk-MIOEYSBQ.js";
32
+ } from "./chunk-KUVJM5CP.js";
33
33
  import {
34
34
  renderSuccess,
35
35
  writeNdjsonItem
36
36
  } from "./chunk-QM57YDJE.js";
37
37
  import {
38
38
  downloadBinary
39
- } from "./chunk-7PLTQHNO.js";
39
+ } from "./chunk-PBJZQZPO.js";
40
40
  import {
41
41
  GLOBAL_FLAGS,
42
42
  READ_SINGLE_FLAGS,
@@ -46,7 +46,7 @@ import {
46
46
  import {
47
47
  DESCRIPTIONS,
48
48
  lazy
49
- } from "./chunk-MWVTFTWV.js";
49
+ } from "./chunk-XDPU2YAF.js";
50
50
 
51
51
  // src/commands/contact.ts
52
52
  import { defineCommand } from "citty";
@@ -503,15 +503,15 @@ var contactCommand = defineCommand({
503
503
  create: createCmd,
504
504
  update: updateCmd,
505
505
  delete: deleteCmd,
506
- import: lazy("contactImport", () => import("./contact-import-LT7BKESC.js").then((m) => m.contactImportCommand)),
506
+ import: lazy("contactImport", () => import("./contact-import-TMJWY2VD.js").then((m) => m.contactImportCommand)),
507
507
  export: exportCmd,
508
508
  enrich: enrichCmd,
509
- lists: lazy("contactLists", () => import("./contact-groups-OITAD73K.js").then((m) => m.contactListsCommand)),
510
- tags: lazy("contactTags", () => import("./contact-groups-OITAD73K.js").then((m) => m.contactTagsCommand)),
511
- imports: lazy("contactImports", () => import("./contact-import-LT7BKESC.js").then((m) => m.contactImportsCommand))
509
+ lists: lazy("contactLists", () => import("./contact-groups-6JF7VX6Q.js").then((m) => m.contactListsCommand)),
510
+ tags: lazy("contactTags", () => import("./contact-groups-6JF7VX6Q.js").then((m) => m.contactTagsCommand)),
511
+ imports: lazy("contactImports", () => import("./contact-import-TMJWY2VD.js").then((m) => m.contactImportsCommand))
512
512
  },
513
513
  async run() {
514
- const { showHelp } = await import("./examples-IGQJCSNL.js");
514
+ const { showHelp } = await import("./examples-5FJS47QF.js");
515
515
  await showHelp(contactCommand, ["curviate", "lead"]);
516
516
  }
517
517
  });