@curviate/cli 0.49.0 → 0.50.0-next.1

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 +26 -0
  2. package/README.md +12 -5
  3. package/dist/{account-2BH2Q6VG.js → account-U7UJIE3H.js} +784 -116
  4. package/dist/analytics-MZU2WKON.js +27 -0
  5. package/dist/beta-consent-67IDUV3K.js +81 -0
  6. package/dist/billing-QAW75YE7.js +124 -0
  7. package/dist/{chunk-RXWODUWA.js → chunk-2W4RN5ON.js} +18 -2
  8. package/dist/{chunk-MGB6FE4A.js → chunk-3Z6PXS6N.js} +6 -6
  9. package/dist/chunk-5S3MJVI5.js +22 -0
  10. package/dist/{chunk-V7FJWTZW.js → chunk-6LBOGIVE.js} +4 -4
  11. package/dist/{chunk-Z7OQSWBD.js → chunk-6PLDAEMO.js} +85 -10
  12. package/dist/chunk-73DJ3KNE.js +54 -0
  13. package/dist/{chunk-3RCW7URJ.js → chunk-A57ZILRU.js} +1 -1
  14. package/dist/chunk-AVI7J47S.js +52 -0
  15. package/dist/{chunk-JYKYD57J.js → chunk-CKVCBGQX.js} +1 -1
  16. package/dist/chunk-EIA66ESN.js +339 -0
  17. package/dist/{chunk-YLSJ4HKU.js → chunk-ENBIMEKS.js} +26 -1
  18. package/dist/{chunk-LCGXJGPB.js → chunk-GHMRPX5H.js} +7 -1
  19. package/dist/chunk-GOICALYQ.js +28 -0
  20. package/dist/{chunk-PQWDDSV7.js → chunk-L7JH3W56.js} +1 -1
  21. package/dist/chunk-LCPPXOPN.js +528 -0
  22. package/dist/chunk-LRMPS4UQ.js +144 -0
  23. package/dist/{chunk-5ZGTU4VD.js → chunk-LULN3II2.js} +78 -5
  24. package/dist/chunk-PPGKQJKU.js +38 -0
  25. package/dist/chunk-Q3ZPRFUX.js +20 -0
  26. package/dist/{chunk-SA2QHAXG.js → chunk-QM57YDJE.js} +13 -201
  27. package/dist/{chunk-Y7MZZRYR.js → chunk-RYWWSZUH.js} +14 -2
  28. package/dist/{chunk-TEAWYLPO.js → chunk-TYNVJDYK.js} +49 -18
  29. package/dist/cli.js +34 -18
  30. package/dist/{comment-MRDPDA33.js → comment-6NRZILAS.js} +90 -11
  31. package/dist/{company-2AEHSGHA.js → company-VXE7IEPT.js} +65 -15
  32. package/dist/{config-NRBKHXES.js → config-3WP7OD35.js} +53 -4
  33. package/dist/{connect-4XEBV5V3.js → connect-FBK6UWZP.js} +63 -18
  34. package/dist/contact-HFPZ3KGL.js +32 -0
  35. package/dist/contact-groups-AI4MLGQS.js +399 -0
  36. package/dist/contact-import-54Y7EMU2.js +336 -0
  37. package/dist/core-RLMWMQEI.js +46 -0
  38. package/dist/do-not-contact-LQ5V6SPE.js +200 -0
  39. package/dist/{doctor-BZ4DA7DV.js → doctor-KKRL7TEF.js} +65 -11
  40. package/dist/{document-RKHRWXNT.js → document-GFRWPQFV.js} +1 -1
  41. package/dist/{draft-C5N6EOO5.js → draft-VSWZOCDR.js} +60 -14
  42. package/dist/{enrollment-BNQOUKI7.js → enrollment-OACCSBM5.js} +31 -19
  43. package/dist/{examples-NIMSIXMV.js → examples-JJB4DZKK.js} +2 -2
  44. package/dist/{exit-codes-TLMKTLRI.js → exit-codes-7DBETBDT.js} +1 -1
  45. package/dist/export-AQHAFVAB.js +96 -0
  46. package/dist/{feed-DFUU7SUJ.js → feed-HY4HT75U.js} +13 -10
  47. package/dist/{group-CSD2OWOZ.js → group-A3SMBFU5.js} +18 -10
  48. package/dist/{inbox-SNSPWI7J.js → inbox-YHUO2RPI.js} +31 -12
  49. package/dist/{inboxes-RIRHPS4H.js → inboxes-GKLMHPDR.js} +14 -10
  50. package/dist/incoming-NHROOOIZ.js +218 -0
  51. package/dist/{job-6PNXXZNF.js → job-QBW3PGWL.js} +65 -13
  52. package/dist/{login-Y7JBAHCW.js → login-GWIYHKYO.js} +13 -4
  53. package/dist/{message-2IK4MBBG.js → message-BFLN2VHS.js} +9 -7
  54. package/dist/{motion-7ATUXO6R.js → motion-LTWU2GPC.js} +39 -117
  55. package/dist/network-CNSBX2SR.js +235 -0
  56. package/dist/{notification-VYK5NDEB.js → notification-DCCFJPXU.js} +38 -11
  57. package/dist/notifications-AQBXBK4K.js +231 -0
  58. package/dist/{post-AN6T2OJF.js → post-PINZHSPS.js} +92 -12
  59. package/dist/{profile-UQY64642.js → profile-MJQJSNYR.js} +76 -20
  60. package/dist/{recruiter-OY4RN5HH.js → recruiter-X6GX4A2G.js} +133 -22
  61. package/dist/{sales-nav-KLODLYMW.js → sales-nav-44GYWDYE.js} +74 -19
  62. package/dist/{search-NWP5S6CF.js → search-SULIN6TB.js} +55 -23
  63. package/dist/{setup-YPPFLH2N.js → setup-ZQRHMRMB.js} +69 -17
  64. package/dist/team-TM6LRUY5.js +450 -0
  65. package/dist/tier-Z3U6AT7H.js +61 -0
  66. package/dist/unibox-BIMI2KY5.js +402 -0
  67. package/dist/{webhook-OHKBL3YS.js → webhook-EHXRTHBG.js} +257 -27
  68. package/package.json +2 -2
  69. package/dist/chunk-D2S5OCYU.js +0 -38
  70. package/dist/core-RGU2SCBN.js +0 -46
@@ -0,0 +1,450 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ fail,
4
+ listFlag,
5
+ outputOpts,
6
+ rootClient,
7
+ usage
8
+ } from "./chunk-3Z6PXS6N.js";
9
+ import {
10
+ buildPreviewOutput
11
+ } from "./chunk-TCUYH5GO.js";
12
+ import {
13
+ intFlag
14
+ } from "./chunk-NNV2OYEF.js";
15
+ import {
16
+ pageDelayFromFlags,
17
+ readCursorFlag,
18
+ readMaxPagesFlag,
19
+ readableObject,
20
+ readablePage,
21
+ rejectPaginationModifiersWithoutAll,
22
+ streamAll
23
+ } from "./chunk-LRMPS4UQ.js";
24
+ import {
25
+ renderSuccess,
26
+ writeNdjsonItem
27
+ } from "./chunk-QM57YDJE.js";
28
+ import {
29
+ createClient,
30
+ readConfig,
31
+ resolveEffectiveConfig,
32
+ writeProfile
33
+ } from "./chunk-LULN3II2.js";
34
+ import {
35
+ GLOBAL_FLAGS,
36
+ READ_SINGLE_FLAGS,
37
+ WRITE_SINGLE_FLAGS,
38
+ readOnly
39
+ } from "./chunk-RYWWSZUH.js";
40
+ import {
41
+ DESCRIPTIONS
42
+ } from "./chunk-73DJ3KNE.js";
43
+ import "./chunk-ZYURL5VK.js";
44
+
45
+ // src/commands/team.ts
46
+ import { defineCommand } from "citty";
47
+ import { readFile } from "fs/promises";
48
+ var show = (result, f) => renderSuccess(result, outputOpts(f), process);
49
+ var call = (method, args, body, run) => async ({ args: raw }) => {
50
+ const f = raw;
51
+ const b = body(f);
52
+ if (f.preview) {
53
+ process.stdout.write(JSON.stringify(buildPreviewOutput({ method, args: args(f), body: b ?? {} })) + "\n");
54
+ return;
55
+ }
56
+ const c = await rootClient(f);
57
+ try {
58
+ show(readableObject(await run(c, f)), f);
59
+ } catch (err) {
60
+ await fail(err, f);
61
+ }
62
+ };
63
+ var list = (page, params = () => ({})) => async ({ args: raw }) => {
64
+ const f = raw;
65
+ rejectPaginationModifiersWithoutAll(f, process);
66
+ const p = params(f);
67
+ if (f.limit !== void 0) p["limit"] = intFlag("limit", f.limit, 1, 100);
68
+ const cursor = readCursorFlag(f, process);
69
+ if (cursor) p["cursor"] = cursor;
70
+ const c = await rootClient(f);
71
+ try {
72
+ if (f.all) {
73
+ const next = (q) => page(c, q);
74
+ for await (const item of streamAll(next, p, { maxPages: readMaxPagesFlag(f, process), out: process, pageDelayMs: pageDelayFromFlags(f) })) writeNdjsonItem(process, item, f.fields);
75
+ } else {
76
+ show(readablePage(await page(c, p)), f);
77
+ }
78
+ } catch (err) {
79
+ await fail(err, f);
80
+ }
81
+ };
82
+ var nonEmpty = (flag, v) => {
83
+ if (v === void 0 || v.trim() === "") usage(`${flag} is required and must not be empty.`);
84
+ return v.trim();
85
+ };
86
+ async function runSwitch({ args: raw }) {
87
+ const f = raw;
88
+ const wanted = nonEmpty("<team>", f.id);
89
+ const cfg = await resolveEffectiveConfig({ apiKey: f["api-key"], baseUrl: f["base-url"], timeout: f.timeout, profile: f.profile });
90
+ if (!cfg.apiKey) {
91
+ process.stderr.write("error: no API key, run `curviate setup` or pass --api-key.\n");
92
+ process.exit(3);
93
+ }
94
+ let rows;
95
+ try {
96
+ const page = readablePage(await createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout, team: null }).teams.list({ limit: 100 }));
97
+ rows = page.items ?? [];
98
+ } catch (err) {
99
+ return fail(err, f);
100
+ }
101
+ const byName = rows.filter((t) => t.name === wanted);
102
+ const row = rows.find((t) => t.team_id === wanted) ?? (byName.length === 1 ? byName[0] : void 0);
103
+ if (!row) {
104
+ usage(byName.length > 1 ? `${byName.length} of your Teams are named "${wanted}": pass the team id (\`curviate team list\`).` : `"${wanted}" is not one of your Teams (\`curviate team list\`). For a Team you were just added to, run \`curviate setup --team <team_id>\`.`);
105
+ }
106
+ if (!cfg.apiKey.startsWith("cvt_all_") && !row.is_current) {
107
+ process.stderr.write(`error: this key works only in its own Team. Run \`curviate setup --team ${row.team_id}\` for a key that reaches ${row.name ?? row.team_id}.
108
+ `);
109
+ process.exit(3);
110
+ }
111
+ const profile = f.profile ?? (await readConfig())?.active ?? "default";
112
+ await writeProfile(profile, { team: row.team_id });
113
+ show({ team_id: row.team_id, name: row.name, profile }, f);
114
+ }
115
+ var USER = { type: "positional", description: "The member's user id (usr_...)." };
116
+ var INVITE = { type: "positional", description: "Invite id (inv_...)." };
117
+ var OWNERS = { INSUFFICIENT_ROLE: "only an Owner of the Team can do this." };
118
+ var OWNERS_MANAGERS = { INSUFFICIENT_ROLE: "only an Owner or a Manager of the Team can do this." };
119
+ var INVITE_ROLES = { INSUFFICIENT_ROLE: "only an Owner or a Manager of the Team can do this, and a Manager acts on Member invites only." };
120
+ var PAGE_FLAGS = readOnly(GLOBAL_FLAGS);
121
+ var listCmd = defineCommand({
122
+ meta: {
123
+ name: "list",
124
+ description: "The Teams you are a member of, with your role; is_current marks the Team this call acts in. --counts adds each Team's Tier, trial, Accounts, active Motions and, where you are an Owner, seats.",
125
+ risk: "read",
126
+ examples: ["curviate team list", "curviate team list --counts --json"]
127
+ },
128
+ args: { ...PAGE_FLAGS, counts: { type: "boolean", description: "Add each Team's counts (on every row for a key that works in all your Teams, on its own row for a Team key)." } },
129
+ run: list((c, p) => c.teams.list(p), (f) => f.counts ? { include: "counts" } : {})
130
+ });
131
+ var getCmd = defineCommand({
132
+ meta: { name: "get", description: "The Team this call acts in: its name, your role, and the Owner who receives invoices.", risk: "read", examples: ["curviate team get", "curviate team get --team tnt_01HZY3K8Q2"] },
133
+ args: readOnly(READ_SINGLE_FLAGS),
134
+ run: call("teams.getCurrent", () => ({}), () => void 0, (c) => c.teams.getCurrent())
135
+ });
136
+ var updateCmd = defineCommand({
137
+ meta: {
138
+ name: "update",
139
+ description: "Rename the Team (Owners and Managers), or name the Owner whose email receives invoices (Owners only).",
140
+ risk: "write",
141
+ rules: {
142
+ changes: "Renames the Team, or names the Owner whose email receives invoices.",
143
+ visible_to: "Everyone in the Team; the billing Owner receives the invoices.",
144
+ budget_rows: [],
145
+ retry: "Safe: the same values written again leave the Team the same.",
146
+ undo: "Run it again with the previous values."
147
+ },
148
+ errors: { INSUFFICIENT_ROLE: "only an Owner or a Manager renames the Team; only an Owner sets --billing-owner.", BILLING_OWNER_REQUIRED: "--billing-owner must name an Owner of this Team." },
149
+ examples: ['curviate team update --name "Acme (client)"', "curviate team update --billing-owner usr_01HZY3K8Q2"]
150
+ },
151
+ args: {
152
+ ...WRITE_SINGLE_FLAGS,
153
+ name: { type: "string", description: "The Team's new name, 1 to 80 characters." },
154
+ "billing-owner": { type: "string", description: "An Owner of this Team (usr_...) who receives the invoices." }
155
+ },
156
+ run: call("teams.updateCurrent", () => ({}), (f) => updateBody(f), (c, f) => c.teams.updateCurrent(updateBody(f)))
157
+ });
158
+ function updateBody(f) {
159
+ if (f.name === void 0 && f["billing-owner"] === void 0) usage("pass --name, --billing-owner, or both.");
160
+ return { ...f.name !== void 0 ? { name: f.name } : {}, ...f["billing-owner"] !== void 0 ? { billing_owner_user_id: f["billing-owner"] } : {} };
161
+ }
162
+ var createCmd = defineCommand({
163
+ meta: {
164
+ name: "create",
165
+ description: "Create a Team with you as its Owner, with no subscription or seat. Prints the Team and next_step: the header to send with a key for all your Teams, else the setup command for a key in the new Team.",
166
+ risk: "write",
167
+ rules: {
168
+ changes: "Creates a Team with you as its Owner, with no subscription or seat.",
169
+ visible_to: "You alone, until you invite people (`curviate team invites create`).",
170
+ budget_rows: [],
171
+ retry: "Two identical calls create two Teams.",
172
+ undo: "The CLI cannot delete a Team: leave it with `curviate team leave --team <team_id>` once another Owner holds it."
173
+ },
174
+ errors: { INVALID_REQUEST: "the name is empty or longer than allowed." },
175
+ examples: ['curviate team create "Acme (client)"']
176
+ },
177
+ args: { ...WRITE_SINGLE_FLAGS, name: { type: "positional", description: "The Team's name, 1 to 80 characters." } },
178
+ run: call("teams.create", () => ({}), (f) => ({ name: f.name }), (c, f) => c.teams.create({ name: nonEmpty("<name>", f.name) }))
179
+ });
180
+ var switchCmd = defineCommand({
181
+ meta: {
182
+ name: "switch",
183
+ description: "Act in another of your Teams from now on: writes the Team to the profile (by id, or by its exact name). --team and CURVIATE_TEAM still override it per call.",
184
+ risk: "write",
185
+ rules: {
186
+ changes: "Writes the Team to the local profile; later calls act in it unless --team or CURVIATE_TEAM says otherwise.",
187
+ visible_to: "Nobody else: the profile stays on this machine.",
188
+ budget_rows: [],
189
+ retry: "Safe: the same result every time.",
190
+ undo: "Switch back with `curviate team switch <team>` and the previous Team."
191
+ },
192
+ errors: { TEAM_ACCESS_DENIED: "this key works only in its own Team: run `curviate setup --team <team_id>` for a key that reaches the other one.", INVALID_REQUEST: "the Team is not one of yours, or several share the name." },
193
+ examples: ["curviate team switch tnt_01HZY3K8Q2", 'curviate team switch "Acme (client)" --profile work']
194
+ },
195
+ args: { ...readOnly(READ_SINGLE_FLAGS), id: { type: "positional", description: "Team id (tnt_...) or its exact name." } },
196
+ run: runSwitch
197
+ });
198
+ var membersCmd = defineCommand({
199
+ meta: { name: "members", description: "Everyone in the Team, oldest membership first, with their role and name (their email when they set no name). Every role may read it.", risk: "read", examples: ["curviate team members", "curviate team members --all"] },
200
+ args: PAGE_FLAGS,
201
+ run: list((c, p) => c.teams.listMembers(p))
202
+ });
203
+ var roleCmd = defineCommand({
204
+ meta: {
205
+ name: "role",
206
+ description: "Set a member's role: owner, manager or member. The Team always keeps an Owner. Owners only.",
207
+ risk: "write",
208
+ rules: {
209
+ changes: "Sets the member's role in this Team.",
210
+ visible_to: "The member and the Team's Owners.",
211
+ budget_rows: [],
212
+ retry: "Safe: the same role written again changes nothing.",
213
+ undo: "Set the previous role."
214
+ },
215
+ errors: { ...OWNERS, LAST_OWNER: "the Team must keep one Owner.", BILLING_OWNER_REQUIRED: "name another Owner to receive invoices first (`curviate team update --billing-owner`)." },
216
+ examples: ["curviate team role usr_01HZY3K8Q2 manager"]
217
+ },
218
+ args: { ...WRITE_SINGLE_FLAGS, user: USER, role: { type: "positional", description: "owner, manager or member." } },
219
+ run: call("teams.updateMember", (f) => ({ user_id: f.user }), (f) => ({ role: f.role }), (c, f) => c.teams.updateMember(nonEmpty("<user>", f.user), { role: nonEmpty("<role>", f.role) }))
220
+ });
221
+ var removeCmd = defineCommand({
222
+ meta: {
223
+ name: "remove",
224
+ description: "Remove a member from the Team. Their Accounts here are disconnected and their key and connectors for this Team stop working at once. An Owner removes anyone; a Manager removes Members.",
225
+ risk: "high",
226
+ rules: {
227
+ changes: "The member leaves the Team; their Accounts here are disconnected and their key and connectors for it stop working.",
228
+ visible_to: "The member, who loses access at once.",
229
+ budget_rows: [],
230
+ retry: "Safe: a member already gone has nothing left to remove.",
231
+ undo: "Cannot be undone for their Accounts, which are disconnected; invite them again with `curviate team invites create`.",
232
+ blast_radius: "One member and every Account they connected to this Team."
233
+ },
234
+ errors: { INSUFFICIENT_ROLE: "only an Owner removes someone else; a Manager removes Members only.", LAST_OWNER: "the Team must keep one Owner.", DEFAULT_TEAM_PROTECTED: "nobody is removed from their own default Team." },
235
+ seeAlso: ["curviate team members", "curviate team invites create"],
236
+ examples: ["curviate team remove usr_01HZY3K8Q2"]
237
+ },
238
+ args: { ...WRITE_SINGLE_FLAGS, user: USER },
239
+ run: call("teams.removeMember", (f) => ({ user_id: f.user }), () => void 0, (c, f) => c.teams.removeMember(nonEmpty("<user>", f.user)))
240
+ });
241
+ var leaveCmd = defineCommand({
242
+ meta: {
243
+ name: "leave",
244
+ description: "Leave the Team this call acts in. Your Accounts here are disconnected; you can never leave your own default Team.",
245
+ risk: "high",
246
+ rules: {
247
+ changes: "You leave the Team; your Accounts here are disconnected and your key for it stops working.",
248
+ visible_to: "The Team's members, who no longer see you.",
249
+ budget_rows: [],
250
+ retry: "Safe: once you have left, a repeat is refused.",
251
+ undo: "Cannot be undone for your Accounts, which are disconnected; an Owner can invite you again.",
252
+ blast_radius: "You and every Account you connected to this Team."
253
+ },
254
+ errors: { DEFAULT_TEAM_PROTECTED: "you can never leave your own default Team.", LAST_OWNER: "the Team must keep one Owner." },
255
+ seeAlso: ["curviate team members"],
256
+ examples: ["curviate team leave --team tnt_01HZY3K8Q2"]
257
+ },
258
+ args: WRITE_SINGLE_FLAGS,
259
+ run: call("teams.removeMember", () => ({ user_id: "me" }), () => void 0, (c) => c.teams.removeMember("me"))
260
+ });
261
+ var invitesCmd = defineCommand({
262
+ meta: { name: "invites", description: "Invite people to the Team, list, resend or revoke invites. Owners and Managers (a Manager invites Members only)." },
263
+ subCommands: {
264
+ create: defineCommand({
265
+ meta: {
266
+ name: "create",
267
+ description: "Invite people by email, comma-separated, each with --role (default member). Owners and Managers (a Manager invites Members only).",
268
+ risk: "write",
269
+ rules: {
270
+ changes: "Emails an invite, with a link, to each address.",
271
+ visible_to: "Each invitee, by email.",
272
+ budget_rows: [],
273
+ retry: "A repeat for an invite still pending answers INVITE_ALREADY_PENDING and sends nothing new.",
274
+ undo: "`curviate team invites revoke <invite_id>` makes the link stop working."
275
+ },
276
+ errors: { ...INVITE_ROLES, ALREADY_MEMBER: "that person is already in the Team.", INVITE_ALREADY_PENDING: "that person has a pending invite.", INVITE_LIMIT_REACHED: "the Team has as many pending invites as it may." },
277
+ examples: ["curviate team invites create dana@example.com", "curviate team invites create dana@example.com,lee@example.com --role manager"]
278
+ },
279
+ args: { ...WRITE_SINGLE_FLAGS, emails: { type: "positional", description: "Email addresses, comma-separated." }, role: { type: "string", description: "owner, manager or member (default)." } },
280
+ run: call("teams.createInvites", () => ({}), (f) => inviteBody(f), (c, f) => c.teams.createInvites(inviteBody(f)))
281
+ }),
282
+ list: defineCommand({
283
+ meta: { name: "list", description: "The Team's invites, newest first; never the invite link. Owners and Managers.", risk: "read", examples: ["curviate team invites list", "curviate team invites list --status pending"] },
284
+ args: { ...PAGE_FLAGS, status: { type: "string", description: "pending, expired, accepted or revoked." } },
285
+ run: list((c, p) => c.teams.listInvites(p), (f) => f.status !== void 0 ? { status: nonEmpty("--status", f.status) } : {})
286
+ }),
287
+ resend: defineCommand({
288
+ meta: {
289
+ name: "resend",
290
+ description: "Send a pending invite's email again, with a fresh link. Owners, and Managers for Member invites.",
291
+ risk: "write",
292
+ rules: {
293
+ changes: "Sends the invite email again, with a fresh link that replaces the old one.",
294
+ visible_to: "The invitee, by email.",
295
+ budget_rows: [],
296
+ retry: "Each call sends another email.",
297
+ undo: "`curviate team invites revoke <invite_id>` makes the link stop working."
298
+ },
299
+ errors: { ...INVITE_ROLES, INVITE_NOT_PENDING: "the invite was accepted, revoked or has expired." },
300
+ examples: ["curviate team invites resend inv_01HZY3K8Q2"]
301
+ },
302
+ args: { ...WRITE_SINGLE_FLAGS, id: INVITE },
303
+ run: call("teams.resendInvite", (f) => ({ invite_id: f.id }), () => void 0, (c, f) => c.teams.resendInvite(nonEmpty("<invite_id>", f.id)))
304
+ }),
305
+ revoke: defineCommand({
306
+ meta: {
307
+ name: "revoke",
308
+ description: "Revoke a pending invite: its link stops working. Owners, and Managers for Member invites.",
309
+ risk: "write",
310
+ rules: {
311
+ changes: "The invite's link stops working.",
312
+ visible_to: "The invitee, whose link no longer opens.",
313
+ budget_rows: [],
314
+ retry: "A second call answers INVITE_NOT_PENDING and changes nothing.",
315
+ undo: "`curviate team invites create <email>` sends a new invite."
316
+ },
317
+ errors: { ...INVITE_ROLES, INVITE_NOT_PENDING: "the invite was accepted, revoked or has expired." },
318
+ examples: ["curviate team invites revoke inv_01HZY3K8Q2"]
319
+ },
320
+ args: { ...WRITE_SINGLE_FLAGS, id: INVITE },
321
+ run: call("teams.revokeInvite", (f) => ({ invite_id: f.id }), () => void 0, (c, f) => c.teams.revokeInvite(nonEmpty("<invite_id>", f.id)))
322
+ })
323
+ }
324
+ });
325
+ function inviteBody(f) {
326
+ const emails = listFlag("emails", nonEmpty("<emails>", f.emails));
327
+ return { invites: emails.map((email) => ({ email, ...f.role !== void 0 ? { role: f.role } : {} })) };
328
+ }
329
+ var logoCmd = defineCommand({
330
+ meta: { name: "logo", description: "Set or remove the Team's logo. Owners and Managers." },
331
+ subCommands: {
332
+ set: defineCommand({
333
+ meta: {
334
+ name: "set",
335
+ description: "Set the Team's logo from a PNG file; replaces the previous one. Owners and Managers.",
336
+ risk: "write",
337
+ rules: {
338
+ changes: "Replaces the Team's logo with the PNG.",
339
+ visible_to: "Everyone in the Team, in the dashboard.",
340
+ budget_rows: [],
341
+ retry: "Safe: the same file written again leaves the logo the same.",
342
+ undo: "`curviate team logo remove`; the previous logo is not kept."
343
+ },
344
+ errors: OWNERS_MANAGERS,
345
+ examples: ["curviate team logo set ./logo.png"]
346
+ },
347
+ args: { ...WRITE_SINGLE_FLAGS, file: { type: "positional", description: "Path to a PNG." } },
348
+ run: call("teams.setLogo", (f) => ({ file: f.file }), () => void 0, async (c, f) => {
349
+ const path = nonEmpty("<file>", f.file);
350
+ let png;
351
+ try {
352
+ png = new Uint8Array(await readFile(path));
353
+ } catch {
354
+ usage(`cannot read ${path}.`);
355
+ }
356
+ return c.teams.setLogo(png);
357
+ })
358
+ }),
359
+ remove: defineCommand({
360
+ meta: {
361
+ name: "remove",
362
+ description: "Remove the Team's logo. Removing a logo that is not set changes nothing. Owners and Managers.",
363
+ risk: "write",
364
+ rules: {
365
+ changes: "Removes the Team's logo.",
366
+ visible_to: "Everyone in the Team, in the dashboard.",
367
+ budget_rows: [],
368
+ retry: "Safe: removing a logo that is not set changes nothing.",
369
+ undo: "`curviate team logo set <file>` with the PNG; the removed logo is not kept."
370
+ },
371
+ errors: OWNERS_MANAGERS,
372
+ examples: ["curviate team logo remove"]
373
+ },
374
+ args: WRITE_SINGLE_FLAGS,
375
+ run: call("teams.removeLogo", () => ({}), () => void 0, (c) => c.teams.removeLogo())
376
+ })
377
+ }
378
+ });
379
+ var seatsCmd = defineCommand({
380
+ meta: { name: "seats", description: "Lend an unused paid seat to another of your Teams, or take it back." },
381
+ subCommands: {
382
+ lend: defineCommand({
383
+ meta: {
384
+ name: "lend",
385
+ description: "Move an unused paid seat of this Team to another of your Teams at no charge; it stays on this Team's invoice. Only the Owner who pays for both Teams may lend. Each call lends one more seat.",
386
+ risk: "write",
387
+ rules: {
388
+ changes: "One unused paid seat moves to the Team named by --to, at no charge; it stays on this Team's invoice.",
389
+ visible_to: "Both Teams: the receiving Team gains a seat to connect an Account to.",
390
+ budget_rows: [],
391
+ retry: "Each call lends one more seat.",
392
+ undo: "`curviate team seats return <seat_id>`."
393
+ },
394
+ errors: { BILLING_OWNER_REQUIRED: "only the Owner who pays for both Teams may lend.", SEAT_LENT: "that seat is already lent." },
395
+ examples: ["curviate team seats lend --to tnt_01HZY3K8Q2", "curviate team seats lend --to tnt_01HZY3K8Q2 --seat seat_01HZY3K8Q2"]
396
+ },
397
+ args: {
398
+ ...WRITE_SINGLE_FLAGS,
399
+ to: { type: "string", required: true, description: "The Team that receives the seat (tnt_...)." },
400
+ seat: { type: "string", description: "The seat to lend (seat_...); default any unused paid seat." }
401
+ },
402
+ run: call("billing.seats.lend", () => ({}), (f) => lendBody(f), (c, f) => c.billing.seats.lend(lendBody(f)))
403
+ }),
404
+ return: defineCommand({
405
+ meta: {
406
+ name: "return",
407
+ description: "End a seat loan while no Account uses the seat. Run it in either Team, with that Team's id for the seat.",
408
+ risk: "write",
409
+ rules: {
410
+ changes: "Ends the loan: the seat goes back to the Team that lent it.",
411
+ visible_to: "Both Teams.",
412
+ budget_rows: [],
413
+ retry: "A second call finds no loan to end.",
414
+ undo: "`curviate team seats lend --to <team_id> --seat <seat_id>` lends it again."
415
+ },
416
+ errors: { SEAT_NOT_FOUND: "no seat has this id.", SEAT_NOT_EMPTY: "an Account still uses the seat: disconnect it first." },
417
+ examples: ["curviate team seats return seat_01HZY3K8Q2"]
418
+ },
419
+ args: { ...WRITE_SINGLE_FLAGS, id: { type: "positional", description: "Seat id (seat_...)." } },
420
+ run: call("billing.seats.return", (f) => ({ seat_id: f.id }), () => void 0, (c, f) => c.billing.seats.return(nonEmpty("<seat_id>", f.id)))
421
+ })
422
+ }
423
+ });
424
+ function lendBody(f) {
425
+ return { team_id: nonEmpty("--to", f.to), ...f.seat !== void 0 ? { seat_id: nonEmpty("--seat", f.seat) } : {} };
426
+ }
427
+ var teamCommand = defineCommand({
428
+ meta: { name: "team", description: DESCRIPTIONS.team },
429
+ subCommands: {
430
+ list: listCmd,
431
+ get: getCmd,
432
+ switch: switchCmd,
433
+ create: createCmd,
434
+ update: updateCmd,
435
+ members: membersCmd,
436
+ role: roleCmd,
437
+ remove: removeCmd,
438
+ leave: leaveCmd,
439
+ invites: invitesCmd,
440
+ logo: logoCmd,
441
+ seats: seatsCmd
442
+ },
443
+ async run() {
444
+ const { showHelp } = await import("./examples-JJB4DZKK.js");
445
+ await showHelp(teamCommand, ["curviate", "team"]);
446
+ }
447
+ });
448
+ export {
449
+ teamCommand
450
+ };
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ fail,
4
+ outputOpts,
5
+ rootClient
6
+ } from "./chunk-3Z6PXS6N.js";
7
+ import {
8
+ readableObject
9
+ } from "./chunk-LRMPS4UQ.js";
10
+ import {
11
+ renderSuccess
12
+ } from "./chunk-QM57YDJE.js";
13
+ import "./chunk-LULN3II2.js";
14
+ import {
15
+ READ_SINGLE_FLAGS,
16
+ readOnly
17
+ } from "./chunk-RYWWSZUH.js";
18
+ import {
19
+ DESCRIPTIONS
20
+ } from "./chunk-73DJ3KNE.js";
21
+ import "./chunk-ZYURL5VK.js";
22
+
23
+ // src/commands/tier.ts
24
+ import { defineCommand } from "citty";
25
+ var at = (u, key) => u ? `${u.tier}${u[key] ? ` until ${u[key]}` : ""}` : "none";
26
+ function humanTier(t) {
27
+ return [
28
+ `tier ${t.tier ?? "none"}`,
29
+ `bought ${t.bought_tier ?? "none"}${t.period ? ` (${t.period})` : ""}`,
30
+ `trial ${at(t.trial, "expires_at")}`,
31
+ `override ${at(t.override, "expires_at")}`,
32
+ `pending ${t.pending ? `${t.pending.tier} from ${t.pending.effective_at}` : "none"}`,
33
+ `features ${t.features.length ? t.features.join(", ") : "none"}`,
34
+ `early access ${t.early_access.map((e) => `${e.tier} (${e.requested_at ? `requested ${e.requested_at}` : "not requested"})`).join(", ") || "none"}`
35
+ ].join("\n") + "\n";
36
+ }
37
+ var tierCommand = defineCommand({
38
+ meta: {
39
+ name: "tier",
40
+ description: DESCRIPTIONS.tier,
41
+ risk: "read",
42
+ examples: ["curviate tier", "curviate tier --json"]
43
+ },
44
+ args: readOnly(READ_SINGLE_FLAGS),
45
+ async run({ args }) {
46
+ const f = args;
47
+ const c = await rootClient(f);
48
+ try {
49
+ const t = readableObject(await c.tier.get());
50
+ const opts = outputOpts(f);
51
+ if (opts.json || f.fields) renderSuccess(t, opts, process);
52
+ else process.stdout.write(humanTier(t));
53
+ } catch (err) {
54
+ await fail(err, f);
55
+ }
56
+ }
57
+ });
58
+ export {
59
+ humanTier,
60
+ tierCommand
61
+ };