@curviate/cli 0.49.0 → 0.50.0-next.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 +15 -0
  2. package/README.md +12 -5
  3. package/dist/{account-2BH2Q6VG.js → account-KGCGUYKF.js} +668 -116
  4. package/dist/analytics-HRAD4ABO.js +27 -0
  5. package/dist/beta-consent-364JI6IL.js +81 -0
  6. package/dist/billing-3SSVRS2Y.js +124 -0
  7. package/dist/{chunk-V7FJWTZW.js → chunk-25MO7BYN.js} +4 -4
  8. package/dist/{chunk-RXWODUWA.js → chunk-2W4RN5ON.js} +18 -2
  9. package/dist/chunk-5S3MJVI5.js +22 -0
  10. package/dist/chunk-67S4JHZZ.js +339 -0
  11. package/dist/chunk-73DJ3KNE.js +54 -0
  12. package/dist/chunk-CQGDMARG.js +525 -0
  13. package/dist/{chunk-JYKYD57J.js → chunk-DOHBOYXN.js} +1 -1
  14. package/dist/{chunk-3RCW7URJ.js → chunk-DSGKYZDK.js} +1 -1
  15. package/dist/{chunk-YLSJ4HKU.js → chunk-ENBIMEKS.js} +26 -1
  16. package/dist/{chunk-LCGXJGPB.js → chunk-GHMRPX5H.js} +7 -1
  17. package/dist/chunk-GOICALYQ.js +28 -0
  18. package/dist/chunk-L4CIJT6F.js +144 -0
  19. package/dist/{chunk-PQWDDSV7.js → chunk-L7JH3W56.js} +1 -1
  20. package/dist/{chunk-Z7OQSWBD.js → chunk-OE6YFYUM.js} +85 -10
  21. package/dist/chunk-PPGKQJKU.js +38 -0
  22. package/dist/{chunk-SA2QHAXG.js → chunk-QM57YDJE.js} +13 -201
  23. package/dist/{chunk-Y7MZZRYR.js → chunk-RYWWSZUH.js} +14 -2
  24. package/dist/{chunk-MGB6FE4A.js → chunk-T6GBS5SS.js} +6 -6
  25. package/dist/{chunk-TEAWYLPO.js → chunk-TE3WBPW6.js} +43 -17
  26. package/dist/chunk-UL53T4O6.js +52 -0
  27. package/dist/chunk-UWQPX4AE.js +20 -0
  28. package/dist/{chunk-5ZGTU4VD.js → chunk-YXVF5UST.js} +77 -4
  29. package/dist/cli.js +34 -18
  30. package/dist/{comment-MRDPDA33.js → comment-5JKGNYOY.js} +90 -11
  31. package/dist/{company-2AEHSGHA.js → company-TXST2VXW.js} +65 -15
  32. package/dist/{config-NRBKHXES.js → config-TVIQUVNK.js} +53 -4
  33. package/dist/{connect-4XEBV5V3.js → connect-RBL6U4KV.js} +63 -18
  34. package/dist/contact-YAHC5QFX.js +32 -0
  35. package/dist/contact-groups-DKOIBC57.js +399 -0
  36. package/dist/contact-import-ITSJQV7K.js +336 -0
  37. package/dist/core-PWMJPPRG.js +46 -0
  38. package/dist/do-not-contact-WDYIBWYA.js +200 -0
  39. package/dist/{doctor-BZ4DA7DV.js → doctor-F7JLPTED.js} +65 -11
  40. package/dist/{document-RKHRWXNT.js → document-BHYAUJ6F.js} +1 -1
  41. package/dist/{draft-C5N6EOO5.js → draft-TDJJUXLH.js} +60 -14
  42. package/dist/{enrollment-BNQOUKI7.js → enrollment-Q6UOKHPY.js} +31 -19
  43. package/dist/{examples-NIMSIXMV.js → examples-DQSVIIXZ.js} +2 -2
  44. package/dist/{exit-codes-TLMKTLRI.js → exit-codes-7DBETBDT.js} +1 -1
  45. package/dist/export-HIJSCJS6.js +96 -0
  46. package/dist/{feed-DFUU7SUJ.js → feed-W56ZTA4Z.js} +13 -10
  47. package/dist/{group-CSD2OWOZ.js → group-AUALYK5H.js} +18 -10
  48. package/dist/{inbox-SNSPWI7J.js → inbox-HLZR2ZPV.js} +31 -12
  49. package/dist/{inboxes-RIRHPS4H.js → inboxes-IZTRD6FE.js} +14 -10
  50. package/dist/incoming-ULB2RNV4.js +218 -0
  51. package/dist/{job-6PNXXZNF.js → job-55IKS6LP.js} +65 -13
  52. package/dist/{login-Y7JBAHCW.js → login-DPZ6CXNO.js} +13 -4
  53. package/dist/{message-2IK4MBBG.js → message-J44YKRDS.js} +9 -7
  54. package/dist/{motion-7ATUXO6R.js → motion-SQI5F2EK.js} +39 -117
  55. package/dist/network-K4QD7APQ.js +235 -0
  56. package/dist/{notification-VYK5NDEB.js → notification-SEDXZHXO.js} +38 -11
  57. package/dist/notifications-HGIBRUNQ.js +231 -0
  58. package/dist/{post-AN6T2OJF.js → post-L467SKIG.js} +92 -12
  59. package/dist/{profile-UQY64642.js → profile-A2N6RMR2.js} +76 -20
  60. package/dist/{recruiter-OY4RN5HH.js → recruiter-AR75RHBO.js} +133 -22
  61. package/dist/{sales-nav-KLODLYMW.js → sales-nav-C2AYFXPV.js} +74 -19
  62. package/dist/{search-NWP5S6CF.js → search-Z4DZIG4X.js} +55 -23
  63. package/dist/{setup-YPPFLH2N.js → setup-45BEVX6B.js} +69 -17
  64. package/dist/team-6QWY4IFP.js +450 -0
  65. package/dist/tier-2HS3BXDF.js +61 -0
  66. package/dist/unibox-DHUKG65Z.js +402 -0
  67. package/dist/{webhook-OHKBL3YS.js → webhook-Q53WUAI2.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
@@ -15,6 +15,10 @@ var GLOBAL_FLAGS = {
15
15
  type: "string",
16
16
  description: "Account id for account-scoped commands. Optional when exactly one account is connected, and required with --preview."
17
17
  },
18
+ team: {
19
+ type: "string",
20
+ description: "Team to act in (tnt_...), sent with every request. Overrides CURVIATE_TEAM and the profile's team. Needed with a key that works in all your Teams; a Team key acts only in its own Team."
21
+ },
18
22
  "base-url": {
19
23
  type: "string",
20
24
  description: "Override the API base URL."
@@ -70,13 +74,14 @@ var GLOBAL_FLAGS = {
70
74
  // cannot express an optional-valued boolean without silently opting in).
71
75
  beta: {
72
76
  type: "boolean",
73
- description: "Allow beta operations for THIS call only (--beta, --beta=false). A gated operation refuses BETA_NOT_ENABLED (exit 5) until a human enables beta in Settings, or you pass --beta for this call. Persists nothing."
77
+ description: "Allow beta operations for THIS call only (--beta, --beta=false). A gated operation refuses BETA_NOT_ENABLED (exit 5) until beta is enabled for the Team (`curviate beta update --enabled true`, an Owner; `PATCH /v1/tenant/beta`), or you pass --beta for this call. Persists nothing."
74
78
  }
75
79
  };
76
80
  var NON_STREAM_FLAGS = {
77
81
  "api-key": GLOBAL_FLAGS["api-key"],
78
82
  profile: GLOBAL_FLAGS.profile,
79
83
  account: GLOBAL_FLAGS.account,
84
+ team: GLOBAL_FLAGS.team,
80
85
  "base-url": GLOBAL_FLAGS["base-url"],
81
86
  timeout: GLOBAL_FLAGS.timeout,
82
87
  json: GLOBAL_FLAGS.json,
@@ -91,6 +96,7 @@ var WRITE_FLAGS = {
91
96
  "api-key": GLOBAL_FLAGS["api-key"],
92
97
  profile: GLOBAL_FLAGS.profile,
93
98
  account: GLOBAL_FLAGS.account,
99
+ team: GLOBAL_FLAGS.team,
94
100
  "base-url": GLOBAL_FLAGS["base-url"],
95
101
  timeout: GLOBAL_FLAGS.timeout,
96
102
  json: GLOBAL_FLAGS.json,
@@ -102,6 +108,7 @@ var READ_SINGLE_FLAGS = {
102
108
  "api-key": GLOBAL_FLAGS["api-key"],
103
109
  profile: GLOBAL_FLAGS.profile,
104
110
  account: GLOBAL_FLAGS.account,
111
+ team: GLOBAL_FLAGS.team,
105
112
  "base-url": GLOBAL_FLAGS["base-url"],
106
113
  timeout: GLOBAL_FLAGS.timeout,
107
114
  json: GLOBAL_FLAGS.json,
@@ -131,6 +138,9 @@ var STATE_WRITES = {
131
138
  // Its answer says whether the Step was resumed, and what to wait for.
132
139
  "curviate enrollment retry": "curviate enrollment get <enrollment_id>"
133
140
  };
141
+ var teamFlag;
142
+ var setTeamFlag = (v) => void (teamFlag = typeof v === "string" ? v : void 0);
143
+ var getTeamFlag = () => teamFlag;
134
144
 
135
145
  // src/lib/beta.ts
136
146
  var BETA_CONSENT_HEADER = "X-Curviate-Beta";
@@ -212,5 +222,7 @@ export {
212
222
  isPoll,
213
223
  getWriteKind,
214
224
  getRecheck,
215
- STATE_WRITES
225
+ STATE_WRITES,
226
+ setTeamFlag,
227
+ getTeamFlag
216
228
  };
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  renderError,
4
- renderUnexpectedError,
5
- resolveEffectiveConfig
6
- } from "./chunk-SA2QHAXG.js";
4
+ renderUnexpectedError
5
+ } from "./chunk-QM57YDJE.js";
7
6
  import {
8
- createClient
9
- } from "./chunk-5ZGTU4VD.js";
7
+ createClient,
8
+ resolveEffectiveConfig
9
+ } from "./chunk-YXVF5UST.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-TLMKTLRI.js");
38
+ const { getExitCode } = await import("./exit-codes-7DBETBDT.js");
39
39
  renderError(err, outputOpts(f), process);
40
40
  process.exit(getExitCode(err));
41
41
  }
@@ -1035,6 +1035,19 @@ var documents_default = {
1035
1035
  nullable: true
1036
1036
  }
1037
1037
  },
1038
+ on_reply_elsewhere: {
1039
+ type: "string",
1040
+ enum: [
1041
+ "stop",
1042
+ "continue"
1043
+ ]
1044
+ },
1045
+ withdraw_on_reply_elsewhere: {
1046
+ type: "boolean"
1047
+ },
1048
+ account_gap: {
1049
+ type: "string"
1050
+ },
1038
1051
  stop_on_engagement: {
1039
1052
  type: "boolean"
1040
1053
  }
@@ -1066,8 +1079,7 @@ var documents_default = {
1066
1079
  "updated_at",
1067
1080
  "started_at",
1068
1081
  "completed_at",
1069
- "archived_at",
1070
- "safety_warning"
1082
+ "archived_at"
1071
1083
  ]
1072
1084
  },
1073
1085
  "motion update": {
@@ -1210,6 +1222,19 @@ var documents_default = {
1210
1222
  nullable: true
1211
1223
  }
1212
1224
  },
1225
+ on_reply_elsewhere: {
1226
+ type: "string",
1227
+ enum: [
1228
+ "stop",
1229
+ "continue"
1230
+ ]
1231
+ },
1232
+ withdraw_on_reply_elsewhere: {
1233
+ type: "boolean"
1234
+ },
1235
+ account_gap: {
1236
+ type: "string"
1237
+ },
1213
1238
  stop_on_engagement: {
1214
1239
  type: "boolean"
1215
1240
  }
@@ -1242,8 +1267,7 @@ var documents_default = {
1242
1267
  "updated_at",
1243
1268
  "started_at",
1244
1269
  "completed_at",
1245
- "archived_at",
1246
- "safety_warning"
1270
+ "archived_at"
1247
1271
  ]
1248
1272
  }
1249
1273
  };
@@ -1257,8 +1281,8 @@ function documentSchema(key) {
1257
1281
  return s;
1258
1282
  }
1259
1283
  var MAX_DOCUMENT_BYTES = 5 * 1024 * 1024;
1260
- var TOO_LARGE = (flag) => `--${flag}: larger than ${MAX_DOCUMENT_BYTES / 1024 / 1024} MiB, the most a document may be.`;
1261
- function readCapped(fd) {
1284
+ var TOO_LARGE = (flag, max = MAX_DOCUMENT_BYTES) => `--${flag}: larger than ${max / 1024 / 1024} MiB, the most a document may be.`;
1285
+ function readCapped(fd, max = MAX_DOCUMENT_BYTES) {
1262
1286
  const chunks = [];
1263
1287
  let total = 0;
1264
1288
  const buf = Buffer.alloc(64 * 1024);
@@ -1273,24 +1297,26 @@ function readCapped(fd) {
1273
1297
  }
1274
1298
  if (n === 0) break;
1275
1299
  total += n;
1276
- if (total > MAX_DOCUMENT_BYTES) return null;
1300
+ if (total > max) return null;
1277
1301
  chunks.push(Buffer.from(buf.subarray(0, n)));
1278
1302
  }
1279
1303
  return Buffer.concat(chunks);
1280
1304
  }
1281
- async function readStdinCapped(flag = "file") {
1305
+ async function readStdinCapped(flag = "file", allowBom = false, max = MAX_DOCUMENT_BYTES) {
1282
1306
  const chunks = [];
1283
1307
  let total = 0;
1284
1308
  for await (const chunk of process.stdin) {
1285
1309
  const b = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
1286
1310
  total += b.length;
1287
- if (total > MAX_DOCUMENT_BYTES) usage(TOO_LARGE(flag));
1311
+ if (total > max) usage(TOO_LARGE(flag, max));
1288
1312
  chunks.push(b);
1289
1313
  }
1290
- return decode(flag, Buffer.concat(chunks)).replace(/\n+$/, "");
1314
+ return decode(flag, Buffer.concat(chunks), allowBom).replace(/\n+$/, "");
1291
1315
  }
1292
- function decode(flag, bytes) {
1293
- if (bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191) usage(`--${flag}: starts with a byte order mark (BOM). Save it as UTF-8 without a BOM.`);
1316
+ function decode(flag, bytes, allowBom = false) {
1317
+ const bom = bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191;
1318
+ if (bom && allowBom) bytes = bytes.subarray(3);
1319
+ else if (bom) usage(`--${flag}: starts with a byte order mark (BOM). Save it as UTF-8 without a BOM.`);
1294
1320
  try {
1295
1321
  return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
1296
1322
  } catch {
@@ -1312,8 +1338,8 @@ async function readFileFlag(flag, value, io = {}) {
1312
1338
  const second = Object.entries(io.others ?? {}).find(([k, o]) => k !== flag && k !== "_" && isStdinToken(o));
1313
1339
  if (second) usage(`--${flag} - and --${second[0]} - both read stdin. Only one input can come from stdin.`);
1314
1340
  if (io.stdinIsTTY ?? process.stdin.isTTY) usage(`--${flag} -: stdin is a terminal. Pipe the document in or use a heredoc: --${flag} - <<'EOF' ... EOF`);
1315
- text = await (io.readStdin ?? (() => readStdinCapped(flag)))();
1316
- if (Buffer.byteLength(text) > MAX_DOCUMENT_BYTES) usage(TOO_LARGE(flag));
1341
+ text = await (io.readStdin ?? (() => readStdinCapped(flag, io.allowBom, io.maxBytes)))();
1342
+ if (Buffer.byteLength(text) > (io.maxBytes ?? MAX_DOCUMENT_BYTES)) usage(TOO_LARGE(flag, io.maxBytes));
1317
1343
  } else {
1318
1344
  let isDir = false;
1319
1345
  try {
@@ -1326,15 +1352,15 @@ async function readFileFlag(flag, value, io = {}) {
1326
1352
  try {
1327
1353
  const fd = openSync(value, "r");
1328
1354
  try {
1329
- bytes = readCapped(fd);
1355
+ bytes = readCapped(fd, io.maxBytes);
1330
1356
  } finally {
1331
1357
  closeSync(fd);
1332
1358
  }
1333
1359
  } catch (err) {
1334
1360
  usage(`--${flag}: cannot read ${value}: ${err.code ?? "read error"}.`);
1335
1361
  }
1336
- if (bytes === null) usage(TOO_LARGE(flag));
1337
- text = decode(flag, bytes);
1362
+ if (bytes === null) usage(TOO_LARGE(flag, io.maxBytes));
1363
+ text = decode(flag, bytes, io.allowBom);
1338
1364
  }
1339
1365
  if (text.trim() === "") usage(`--${flag}: empty input.`);
1340
1366
  return text;
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ fail,
4
+ outputOpts
5
+ } from "./chunk-T6GBS5SS.js";
6
+
7
+ // src/lib/chunks.ts
8
+ async function sendInChunks(ids, size, send, f) {
9
+ const chunks = [];
10
+ for (let k = 0; k < ids.length; k += size) chunks.push(ids.slice(k, k + size));
11
+ return sendChunked(chunks, send, f, "ids");
12
+ }
13
+ async function sendChunked(chunks, send, f, unit) {
14
+ const total = chunks.length;
15
+ const all = chunks.reduce((n, c) => n + c.length, 0);
16
+ const done = [];
17
+ let accepted = 0;
18
+ for (let k = 0; k < total; k++) {
19
+ const chunk = chunks[k];
20
+ try {
21
+ done.push(await send(chunk));
22
+ accepted += chunk.length;
23
+ } catch (err) {
24
+ const { CurviateError } = await import("@curviate/sdk");
25
+ const progress = {
26
+ chunks: { sent: k, total },
27
+ items: { accepted, total: all },
28
+ failed_chunk: { index: k + 1, first_row: accepted + 1, last_row: accepted + chunk.length }
29
+ };
30
+ if (!(err instanceof CurviateError)) {
31
+ process.stderr.write(`Chunk ${k + 1} of ${total} failed; ${accepted} of ${all} ${unit} were sent before it. Nothing after it was sent.
32
+ `);
33
+ return fail(err, f);
34
+ }
35
+ const { getExitCode } = await import("./exit-codes-7DBETBDT.js");
36
+ const e = err.toJSON();
37
+ if (outputOpts(f).json) process.stdout.write(JSON.stringify({ error: e, progress }) + "\n");
38
+ process.stderr.write(
39
+ `error [${e.code}] ${e.message}
40
+ Chunk ${k + 1} of ${total} failed (${unit} ${progress.failed_chunk.first_row} to ${progress.failed_chunk.last_row}); ${accepted} of ${all} ${unit} were sent before it. Nothing after it was sent.
41
+ `
42
+ );
43
+ process.exit(getExitCode(err));
44
+ }
45
+ }
46
+ return done;
47
+ }
48
+
49
+ export {
50
+ sendInChunks,
51
+ sendChunked
52
+ };
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/lib/help-errors.ts
4
+ var AS_ACCOUNT = {
5
+ ACCOUNT_NOT_FOUND: "the Account is not in your Team.",
6
+ LINKEDIN_AUTH_FAILED: "LinkedIn no longer accepts the Account's sign-in: reconnect it.",
7
+ ACCOUNT_RESTRICTED: "LinkedIn restricts the Account from this action."
8
+ };
9
+ var BUDGET = {
10
+ BUDGET_EXHAUSTED: "the Account's limit for this action is used up; nothing reached LinkedIn. `curviate account get <account_id>` shows when it resets."
11
+ };
12
+ var TARGET = {
13
+ RESOURCE_NOT_FOUND: "the target does not exist, or the Account cannot see it."
14
+ };
15
+
16
+ export {
17
+ AS_ACCOUNT,
18
+ BUDGET,
19
+ TARGET
20
+ };
@@ -2,11 +2,13 @@
2
2
  import {
3
3
  betaOverrideHeader,
4
4
  getRecheck,
5
+ getTeamFlag,
5
6
  getWriteKind,
6
7
  isPoll
7
- } from "./chunk-Y7MZZRYR.js";
8
+ } from "./chunk-RYWWSZUH.js";
8
9
  import {
9
- assertNoStdinPlaceholder
10
+ assertNoStdinPlaceholder,
11
+ isStdinToken
10
12
  } from "./chunk-ZYURL5VK.js";
11
13
 
12
14
  // src/lib/config.ts
@@ -30,6 +32,7 @@ var PROFILE_FIELD_TYPES = {
30
32
  account: "string",
31
33
  baseUrl: "string",
32
34
  tenant: "string",
35
+ team: "string",
33
36
  timeout: "number"
34
37
  };
35
38
  function isPlainObject(value) {
@@ -193,13 +196,79 @@ async function updateProfileField(profileName, field, value) {
193
196
  profile.baseUrl = value !== void 0 ? String(value) : void 0;
194
197
  } else if (field === "tenant") {
195
198
  profile.tenant = value !== void 0 ? String(value) : void 0;
199
+ } else if (field === "team") {
200
+ profile.team = value !== void 0 ? String(value) : void 0;
196
201
  }
197
202
  await writeConfig(cfg);
198
203
  }
199
204
 
205
+ // src/lib/resolve.ts
206
+ var lastTeam = () => void 0;
207
+ var resolvedTeam = () => lastTeam();
208
+ var DEFAULT_BASE_URL = "https://api.curviate.com";
209
+ var DEFAULT_TIMEOUT_MS = 3e4;
210
+ async function resolveEffectiveConfig(flags) {
211
+ const file = await readConfigFile();
212
+ const fromProfile = (field) => profileValue(file, flags.profile, field);
213
+ if (isStdinToken(flags.apiKey)) {
214
+ process.stderr.write("error: --api-key - reads stdin only on `curviate login`. Set CURVIATE_API_KEY, or save the key with `curviate login --api-key -`.\n");
215
+ process.exit(2);
216
+ }
217
+ const profileKey = flags.apiKey === void 0 && process.env["CURVIATE_API_KEY"] === void 0 ? fromProfile("apiKey") : void 0;
218
+ const apiKey = flags.apiKey ?? process.env["CURVIATE_API_KEY"] ?? profileKey;
219
+ const apiKeySource = flags.apiKey !== void 0 ? "flag" : process.env["CURVIATE_API_KEY"] !== void 0 ? "env" : profileKey !== void 0 ? "profile" : "none";
220
+ const baseUrl = flags.baseUrl ?? process.env["CURVIATE_BASE_URL"] ?? fromProfile("baseUrl") ?? DEFAULT_BASE_URL;
221
+ const timeoutFlag = flags.timeout === void 0 ? void 0 : /^[1-9]\d*$/.test(flags.timeout) ? Number(flags.timeout) : NaN;
222
+ const keyAndUrlBypassProfile = apiKeySource !== "profile" && apiKeySource !== "none" && (flags.baseUrl ?? process.env["CURVIATE_BASE_URL"]) !== void 0;
223
+ const profileTimeout = () => {
224
+ try {
225
+ return fromProfile("timeout");
226
+ } catch (err) {
227
+ if (keyAndUrlBypassProfile) return void 0;
228
+ throw err;
229
+ }
230
+ };
231
+ const timeout = timeoutFlag ?? profileTimeout() ?? DEFAULT_TIMEOUT_MS;
232
+ const flagTeam = getTeamFlag();
233
+ if (flagTeam !== void 0 && flagTeam.trim() === "") {
234
+ process.stderr.write("error: --team was given an empty value. Pass a Team id (tnt_...), or leave it out.\n");
235
+ process.exit(2);
236
+ }
237
+ const envTeam = process.env["CURVIATE_TEAM"] || void 0;
238
+ const effective = {
239
+ apiKey,
240
+ baseUrl,
241
+ timeout,
242
+ apiKeySource,
243
+ // Account: flag > env > profile. Read on access: a root-scoped command never
244
+ // takes it, so a broken profile account must not refuse that command.
245
+ get account() {
246
+ return flags.account ?? process.env["CURVIATE_ACCOUNT"] ?? fromProfile("account");
247
+ },
248
+ // Tenant: only meaningful when the key itself came from the profile.
249
+ get tenant() {
250
+ return apiKeySource === "profile" ? fromProfile("tenant") : void 0;
251
+ },
252
+ // Read on access, like `account`: a command that sends nothing never reads it.
253
+ get team() {
254
+ return flagTeam?.trim() ?? envTeam ?? fromProfile("team");
255
+ },
256
+ get teamSource() {
257
+ return flagTeam !== void 0 ? "flag" : envTeam !== void 0 ? "env" : fromProfile("team") !== void 0 ? "profile" : "none";
258
+ }
259
+ };
260
+ lastTeam = () => effective.team;
261
+ return effective;
262
+ }
263
+
200
264
  // src/lib/client.ts
201
265
  import { AsyncLocalStorage } from "async_hooks";
202
266
  import { Curviate, CurviateError as CurviateError2 } from "@curviate/sdk";
267
+
268
+ // package.json
269
+ var version = "0.50.0-next.0";
270
+
271
+ // src/lib/client.ts
203
272
  function headerStrings(headers) {
204
273
  if (!headers) return [];
205
274
  if (headers instanceof Headers) {
@@ -335,17 +404,20 @@ function createClient(config) {
335
404
  return new Curviate({
336
405
  apiKey: config.apiKey.trim(),
337
406
  fetch: guardedFetch,
407
+ // Replaces the SDK's own `sdk/<version>`: exactly one Curviate-Client header per request.
408
+ client: `cli/${version}`,
338
409
  ...config.baseUrl !== void 0 ? { baseUrl: config.baseUrl } : {},
339
- ...config.timeout !== void 0 ? { timeout: config.timeout } : {}
410
+ ...config.timeout !== void 0 ? { timeout: config.timeout } : {},
411
+ ...teamOption(config.team === void 0 ? resolvedTeam() : config.team)
340
412
  });
341
413
  }
414
+ var teamOption = (team) => team ? { team } : {};
342
415
 
343
416
  export {
344
417
  PROFILE_FIELD_TYPES,
345
418
  isPlainObject,
346
419
  assertStructure,
347
420
  readConfigFile,
348
- profileValue,
349
421
  getConfigPath,
350
422
  readConfig,
351
423
  writeProfile,
@@ -353,6 +425,7 @@ export {
353
425
  renameProfile,
354
426
  removeProfile,
355
427
  updateProfileField,
428
+ resolveEffectiveConfig,
356
429
  downloadBinary,
357
430
  baseUrlProblem,
358
431
  withoutUserinfo,
package/dist/cli.js CHANGED
@@ -1,20 +1,21 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- intFlag
4
- } from "./chunk-NNV2OYEF.js";
5
2
  import {
6
3
  SECRET_FLAGS
7
4
  } from "./chunk-TCUYH5GO.js";
5
+ import {
6
+ intFlag
7
+ } from "./chunk-NNV2OYEF.js";
8
8
  import {
9
9
  GLOBAL_FLAGS,
10
10
  STATE_WRITES,
11
11
  parseBetaFlag,
12
12
  setBetaOverride,
13
+ setTeamFlag,
13
14
  setWriteKind
14
- } from "./chunk-Y7MZZRYR.js";
15
+ } from "./chunk-RYWWSZUH.js";
15
16
  import {
16
17
  lazy
17
- } from "./chunk-D2S5OCYU.js";
18
+ } from "./chunk-73DJ3KNE.js";
18
19
  import {
19
20
  editDistance
20
21
  } from "./chunk-FDJMAF7D.js";
@@ -44,21 +45,33 @@ var main = defineCommand({
44
45
  // Subcommand registry, names and descriptions are static for help rendering;
45
46
  // the handler implementation is loaded lazily on first invocation.
46
47
  subCommands: {
47
- setup: lazy("setup", () => import("./setup-YPPFLH2N.js").then((m) => m.setupCommand)),
48
- doctor: lazy("doctor", () => import("./doctor-BZ4DA7DV.js").then((m) => m.doctorCommand)),
49
- login: lazy("login", () => import("./login-Y7JBAHCW.js").then((m) => m.loginCommand)),
50
- config: lazy("config", () => import("./config-NRBKHXES.js").then((m) => m.configCommand)),
51
- account: lazy("account", () => import("./account-2BH2Q6VG.js").then((m) => m.accountCommand)),
52
- motion: lazy("motion", () => import("./motion-7ATUXO6R.js").then((m) => m.motionCommand)),
53
- enrollment: lazy("enrollment", () => import("./enrollment-BNQOUKI7.js").then((m) => m.enrollmentCommand)),
54
- webhook: lazy("webhook", () => import("./webhook-OHKBL3YS.js").then((m) => m.webhookCommand)),
48
+ setup: lazy("setup", () => import("./setup-45BEVX6B.js").then((m) => m.setupCommand)),
49
+ doctor: lazy("doctor", () => import("./doctor-F7JLPTED.js").then((m) => m.doctorCommand)),
50
+ login: lazy("login", () => import("./login-DPZ6CXNO.js").then((m) => m.loginCommand)),
51
+ config: lazy("config", () => import("./config-TVIQUVNK.js").then((m) => m.configCommand)),
52
+ account: lazy("account", () => import("./account-KGCGUYKF.js").then((m) => m.accountCommand)),
53
+ motion: lazy("motion", () => import("./motion-SQI5F2EK.js").then((m) => m.motionCommand)),
54
+ enrollment: lazy("enrollment", () => import("./enrollment-Q6UOKHPY.js").then((m) => m.enrollmentCommand)),
55
+ contact: lazy("contact", () => import("./contact-YAHC5QFX.js").then((m) => m.contactCommand)),
56
+ "do-not-contact": lazy("do-not-contact", () => import("./do-not-contact-WDYIBWYA.js").then((m) => m.doNotContactCommand)),
57
+ unibox: lazy("unibox", () => import("./unibox-DHUKG65Z.js").then((m) => m.uniboxCommand)),
58
+ network: lazy("network", () => import("./network-K4QD7APQ.js").then((m) => m.networkCommand)),
59
+ analytics: lazy("analytics", () => import("./analytics-HRAD4ABO.js").then((m) => m.analyticsCommand)),
60
+ notification: lazy("notification", () => import("./notifications-HGIBRUNQ.js").then((m) => m.notificationsCommand)),
61
+ export: lazy("export", () => import("./export-HIJSCJS6.js").then((m) => m.exportCommand)),
62
+ billing: lazy("billing", () => import("./billing-3SSVRS2Y.js").then((m) => m.billingCommand)),
63
+ tier: lazy("tier", () => import("./tier-2HS3BXDF.js").then((m) => m.tierCommand)),
64
+ team: lazy("team", () => import("./team-6QWY4IFP.js").then((m) => m.teamCommand)),
65
+ incoming: lazy("incoming", () => import("./incoming-ULB2RNV4.js").then((m) => m.incomingCommand)),
66
+ beta: lazy("beta", () => import("./beta-consent-364JI6IL.js").then((m) => m.betaCommand)),
67
+ webhook: lazy("webhook", () => import("./webhook-Q53WUAI2.js").then((m) => m.webhookCommand)),
55
68
  // The LinkedIn building blocks. Reserved product groups
56
- // (contact, unibox, network, analytics, notification, team) land
69
+ // (unibox, network, analytics, team) land
57
70
  // between `enrollment` and `webhook` with their owning specs.
58
- core: lazy("core", () => import("./core-RGU2SCBN.js").then((m) => m.coreCommand))
71
+ core: lazy("core", () => import("./core-PWMJPPRG.js").then((m) => m.coreCommand))
59
72
  },
60
73
  async run() {
61
- const { showHelp } = await import("./examples-NIMSIXMV.js");
74
+ const { showHelp } = await import("./examples-DQSVIIXZ.js");
62
75
  await showHelp(main, ["curviate"]);
63
76
  }
64
77
  });
@@ -203,6 +216,8 @@ function arityPhrase(count) {
203
216
  return `${count} positional arguments`;
204
217
  }
205
218
  async function extraPositionals(cmd, rawArgs) {
219
+ const argsDef = await resolveValue(cmd.args ?? {});
220
+ if (Object.values(argsDef).some((def) => def?.type === "positional" && def.variadic)) return [];
206
221
  const booleanFlags = await routingBooleanFlagNames(cmd);
207
222
  const declaredFlags = await routingDeclaredFlagNames(cmd);
208
223
  const { positionals } = walkTokens(rawArgs, booleanFlags, declaredFlags);
@@ -348,7 +363,7 @@ async function dispatch(root, rawArgs) {
348
363
  helpFor = "curviate";
349
364
  if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
350
365
  const { leaf, path } = await resolveLeaf(root, rawArgs.filter((a) => a !== "--help" && a !== "-h"));
351
- const { showHelp } = await import("./examples-NIMSIXMV.js");
366
+ const { showHelp } = await import("./examples-DQSVIIXZ.js");
352
367
  await showHelp(leaf, path);
353
368
  await new Promise((done) => process.stdout.write("", () => done()));
354
369
  process.exit(0);
@@ -409,6 +424,7 @@ async function dispatch(root, rawArgs) {
409
424
  );
410
425
  const limit = ctx.args["limit"];
411
426
  if (typeof limit === "string") intFlag("limit", limit);
427
+ setTeamFlag(ctx.args["team"]);
412
428
  return originalRun(ctx);
413
429
  }
414
430
  } : {}
@@ -429,7 +445,7 @@ async function dispatch(root, rawArgs) {
429
445
  if (code === "EARG") process.stderr.write(helpPointer());
430
446
  const { CurviateError } = await import("@curviate/sdk");
431
447
  if (err instanceof CurviateError) {
432
- const { getExitCode } = await import("./exit-codes-TLMKTLRI.js");
448
+ const { getExitCode } = await import("./exit-codes-7DBETBDT.js");
433
449
  process.exit(getExitCode(err));
434
450
  }
435
451
  process.exit(code === "EARG" ? 2 : 1);