@curviate/cli 0.11.0 → 0.13.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.
@@ -9,12 +9,12 @@ import {
9
9
  AttachError,
10
10
  readAttachment
11
11
  } from "./chunk-Q43HZUN3.js";
12
- import {
13
- streamAll
14
- } from "./chunk-GXTZION6.js";
15
12
  import {
16
13
  buildPreviewOutput
17
14
  } from "./chunk-R3VLWLVV.js";
15
+ import {
16
+ streamAll
17
+ } from "./chunk-GXTZION6.js";
18
18
  import {
19
19
  resolveIdentifier
20
20
  } from "./chunk-DMQZEPQE.js";
@@ -66,7 +66,7 @@ function normalizeAttachPaths(attach) {
66
66
  async function handleSdkError(err, outOpts, out) {
67
67
  const { CurviateError } = await import("@curviate/sdk");
68
68
  if (err instanceof CurviateError) {
69
- const { getExitCode } = await import("./exit-codes-2ASIFXGR.js");
69
+ const { getExitCode } = await import("./exit-codes-ZTY2NY3X.js");
70
70
  renderError(err, outOpts, out);
71
71
  process.exit(getExitCode(err.code));
72
72
  }
@@ -276,13 +276,13 @@ async function runSalesNavProfile(client, flags, out) {
276
276
  async function runSalesNavSaveLead(client, flags, out) {
277
277
  const accountId = requireAccount(flags.account, out);
278
278
  const userId = flags.userId ?? "";
279
+ const listId = flags.list ?? "";
279
280
  const outOpts = resolveOutputOpts(flags);
280
- const body = {};
281
- if (flags["list-id"]) body["list_id"] = flags["list-id"];
281
+ const body = { user_id: userId };
282
282
  if (flags.preview) {
283
283
  const preview = buildPreviewOutput({
284
284
  method: "salesNavigator.saveLead",
285
- args: { user_id: userId },
285
+ args: { list_id: listId, user_id: userId },
286
286
  body,
287
287
  account: accountId
288
288
  });
@@ -291,7 +291,153 @@ async function runSalesNavSaveLead(client, flags, out) {
291
291
  }
292
292
  const ns = client.account(accountId);
293
293
  try {
294
- const result = await ns.salesNavigator.saveLead(userId, body);
294
+ const result = await ns.salesNavigator.saveLead({ list_id: listId, user_id: userId });
295
+ renderSuccess(result, outOpts, out);
296
+ } catch (err) {
297
+ await handleSdkError(err, outOpts, out);
298
+ }
299
+ }
300
+ async function runSalesNavAccountLists(client, flags, out) {
301
+ rejectPreviewOnRead(flags.preview, out);
302
+ const accountId = requireAccount(flags.account, out);
303
+ const ns = client.account(accountId);
304
+ const outOpts = resolveOutputOpts(flags);
305
+ const all = flags.all ?? false;
306
+ const maxPages = flags["max-pages"] ? parseInt(flags["max-pages"], 10) : 100;
307
+ const params = {};
308
+ if (flags.limit) params["limit"] = parseInt(flags.limit, 10);
309
+ if (flags.cursor) params["cursor"] = flags.cursor;
310
+ try {
311
+ if (all) {
312
+ const fn = (p) => ns.salesNavigator.accountLists(p);
313
+ for await (const item of streamAll(fn, params, {
314
+ maxPages,
315
+ onTruncated: (n) => out.stderr.write(`Streaming truncated at ${n} page(s). Use --all --max-pages or --cursor for manual paging.
316
+ `)
317
+ })) {
318
+ out.stdout.write(JSON.stringify(item) + "\n");
319
+ }
320
+ return;
321
+ }
322
+ const result = await ns.salesNavigator.accountLists(Object.keys(params).length > 0 ? params : void 0);
323
+ renderSuccess(result, outOpts, out);
324
+ } catch (err) {
325
+ await handleSdkError(err, outOpts, out);
326
+ }
327
+ }
328
+ async function runSalesNavLeadLists(client, flags, out) {
329
+ rejectPreviewOnRead(flags.preview, out);
330
+ const accountId = requireAccount(flags.account, out);
331
+ const ns = client.account(accountId);
332
+ const outOpts = resolveOutputOpts(flags);
333
+ const all = flags.all ?? false;
334
+ const maxPages = flags["max-pages"] ? parseInt(flags["max-pages"], 10) : 100;
335
+ const params = {};
336
+ if (flags.limit) params["limit"] = parseInt(flags.limit, 10);
337
+ if (flags.cursor) params["cursor"] = flags.cursor;
338
+ try {
339
+ if (all) {
340
+ const fn = (p) => ns.salesNavigator.leadLists(p);
341
+ for await (const item of streamAll(fn, params, {
342
+ maxPages,
343
+ onTruncated: (n) => out.stderr.write(`Streaming truncated at ${n} page(s). Use --all --max-pages or --cursor for manual paging.
344
+ `)
345
+ })) {
346
+ out.stdout.write(JSON.stringify(item) + "\n");
347
+ }
348
+ return;
349
+ }
350
+ const result = await ns.salesNavigator.leadLists(Object.keys(params).length > 0 ? params : void 0);
351
+ renderSuccess(result, outOpts, out);
352
+ } catch (err) {
353
+ await handleSdkError(err, outOpts, out);
354
+ }
355
+ }
356
+ async function runSalesNavBrowseAccountList(client, flags, out) {
357
+ rejectPreviewOnRead(flags.preview, out);
358
+ const accountId = requireAccount(flags.account, out);
359
+ const listId = flags.listId ?? "";
360
+ const ns = client.account(accountId);
361
+ const outOpts = resolveOutputOpts(flags);
362
+ const all = flags.all ?? false;
363
+ const maxPages = flags["max-pages"] ? parseInt(flags["max-pages"], 10) : 100;
364
+ const body = {};
365
+ if (flags.filter) body["filter"] = flags.filter;
366
+ if (flags["sort-by"]) body["sort_by"] = flags["sort-by"];
367
+ if (flags["sort-order"]) body["sort_order"] = flags["sort-order"];
368
+ const params = {};
369
+ if (flags.limit) params["limit"] = parseInt(flags.limit, 10);
370
+ if (flags.cursor) params["cursor"] = flags.cursor;
371
+ try {
372
+ if (all) {
373
+ const fn = (p) => ns.salesNavigator.browseAccountList(listId, body, p);
374
+ for await (const item of streamAll(fn, params, {
375
+ maxPages,
376
+ onTruncated: (n) => out.stderr.write(`Streaming truncated at ${n} page(s). Use --all --max-pages or --cursor for manual paging.
377
+ `)
378
+ })) {
379
+ out.stdout.write(JSON.stringify(item) + "\n");
380
+ }
381
+ return;
382
+ }
383
+ const result = await ns.salesNavigator.browseAccountList(listId, body, Object.keys(params).length > 0 ? params : void 0);
384
+ renderSuccess(result, outOpts, out);
385
+ } catch (err) {
386
+ await handleSdkError(err, outOpts, out);
387
+ }
388
+ }
389
+ async function runSalesNavBrowseLeadList(client, flags, out) {
390
+ rejectPreviewOnRead(flags.preview, out);
391
+ const accountId = requireAccount(flags.account, out);
392
+ const listId = flags.listId ?? "";
393
+ const ns = client.account(accountId);
394
+ const outOpts = resolveOutputOpts(flags);
395
+ const all = flags.all ?? false;
396
+ const maxPages = flags["max-pages"] ? parseInt(flags["max-pages"], 10) : 100;
397
+ const body = {};
398
+ if (flags.spotlight) body["spotlight"] = flags.spotlight;
399
+ if (flags["sort-by"]) body["sort_by"] = flags["sort-by"];
400
+ if (flags["sort-order"]) body["sort_order"] = flags["sort-order"];
401
+ const params = {};
402
+ if (flags.limit) params["limit"] = parseInt(flags.limit, 10);
403
+ if (flags.cursor) params["cursor"] = flags.cursor;
404
+ try {
405
+ if (all) {
406
+ const fn = (p) => ns.salesNavigator.browseLeadList(listId, body, p);
407
+ for await (const item of streamAll(fn, params, {
408
+ maxPages,
409
+ onTruncated: (n) => out.stderr.write(`Streaming truncated at ${n} page(s). Use --all --max-pages or --cursor for manual paging.
410
+ `)
411
+ })) {
412
+ out.stdout.write(JSON.stringify(item) + "\n");
413
+ }
414
+ return;
415
+ }
416
+ const result = await ns.salesNavigator.browseLeadList(listId, body, Object.keys(params).length > 0 ? params : void 0);
417
+ renderSuccess(result, outOpts, out);
418
+ } catch (err) {
419
+ await handleSdkError(err, outOpts, out);
420
+ }
421
+ }
422
+ async function runSalesNavSaveAccount(client, flags, out) {
423
+ const accountId = requireAccount(flags.account, out);
424
+ const listId = flags.list ?? "";
425
+ const companyId = flags.companyId ?? "";
426
+ const outOpts = resolveOutputOpts(flags);
427
+ const body = { company_id: companyId };
428
+ if (flags.preview) {
429
+ const preview = buildPreviewOutput({
430
+ method: "salesNavigator.saveAccount",
431
+ args: { list_id: listId, company_id: companyId },
432
+ body,
433
+ account: accountId
434
+ });
435
+ out.stdout.write(JSON.stringify(preview) + "\n");
436
+ return;
437
+ }
438
+ const ns = client.account(accountId);
439
+ try {
440
+ const result = await ns.salesNavigator.saveAccount({ list_id: listId, company_id: companyId });
295
441
  renderSuccess(result, outOpts, out);
296
442
  } catch (err) {
297
443
  await handleSdkError(err, outOpts, out);
@@ -489,12 +635,12 @@ var salesNavProfileCommand = defineCommand({
489
635
  }
490
636
  });
491
637
  var salesNavSaveLeadCommand = defineCommand({
492
- meta: { name: "save-lead", description: "Save a Sales Navigator member as a lead." },
638
+ meta: { name: "save-lead", description: "Save a Sales Navigator member into a lead list." },
493
639
  args: {
494
640
  // Write command: WRITE_FLAGS omits pagination/projection flags
495
641
  ...WRITE_FLAGS,
496
642
  userId: { type: "positional", description: "Sales Navigator member ID (ACw\u2026 format)." },
497
- "list-id": { type: "string", description: "Lead list ID to save the lead into." }
643
+ list: { type: "string", description: "Lead list ID to save the member into (required \u2014 the v2 save always targets a specific list).", required: true }
498
644
  },
499
645
  async run({ args }) {
500
646
  const flags = args;
@@ -514,6 +660,128 @@ var salesNavSaveLeadCommand = defineCommand({
514
660
  await runSalesNavSaveLead(client, { ...flags, account: flags.account ?? cfg.account }, out);
515
661
  }
516
662
  });
663
+ var salesNavAccountListsCommand = defineCommand({
664
+ meta: { name: "account-lists", description: "List the saved-account (company) lists on the operator's Sales Navigator seat." },
665
+ args: { ...GLOBAL_FLAGS },
666
+ async run({ args }) {
667
+ const flags = args;
668
+ const cfg = await resolveEffectiveConfig({
669
+ apiKey: flags["api-key"],
670
+ baseUrl: flags["base-url"],
671
+ timeout: flags.timeout,
672
+ account: flags.account,
673
+ profile: flags.profile
674
+ });
675
+ if (!cfg.apiKey) {
676
+ process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
677
+ process.exit(3);
678
+ }
679
+ const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
680
+ const out = buildOutputStreams();
681
+ await runSalesNavAccountLists(client, { ...flags, account: flags.account ?? cfg.account }, out);
682
+ }
683
+ });
684
+ var salesNavLeadListsCommand = defineCommand({
685
+ meta: { name: "lead-lists", description: "List the saved-lead (member) lists on the operator's Sales Navigator seat." },
686
+ args: { ...GLOBAL_FLAGS },
687
+ async run({ args }) {
688
+ const flags = args;
689
+ const cfg = await resolveEffectiveConfig({
690
+ apiKey: flags["api-key"],
691
+ baseUrl: flags["base-url"],
692
+ timeout: flags.timeout,
693
+ account: flags.account,
694
+ profile: flags.profile
695
+ });
696
+ if (!cfg.apiKey) {
697
+ process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
698
+ process.exit(3);
699
+ }
700
+ const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
701
+ const out = buildOutputStreams();
702
+ await runSalesNavLeadLists(client, { ...flags, account: flags.account ?? cfg.account }, out);
703
+ }
704
+ });
705
+ var salesNavBrowseAccountListCommand = defineCommand({
706
+ meta: { name: "browse-account-list", description: "Browse the saved accounts (companies) in one account list." },
707
+ args: {
708
+ ...GLOBAL_FLAGS,
709
+ listId: { type: "positional", description: "The account-list id (from `sales-nav account-lists`)." },
710
+ filter: { type: "string", description: "Restrict to a saved-account subset: STARRED, GROWTH_ALERTS, or RISK_ALERTS." },
711
+ "sort-by": { type: "string", description: "Sort field: DATE_ADDED or NAME. Defaults to NAME." },
712
+ "sort-order": { type: "string", description: "Sort direction: ASCENDING or DESCENDING. Defaults to ASCENDING." }
713
+ },
714
+ async run({ args }) {
715
+ const flags = args;
716
+ const cfg = await resolveEffectiveConfig({
717
+ apiKey: flags["api-key"],
718
+ baseUrl: flags["base-url"],
719
+ timeout: flags.timeout,
720
+ account: flags.account,
721
+ profile: flags.profile
722
+ });
723
+ if (!cfg.apiKey) {
724
+ process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
725
+ process.exit(3);
726
+ }
727
+ const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
728
+ const out = buildOutputStreams();
729
+ await runSalesNavBrowseAccountList(client, { ...flags, account: flags.account ?? cfg.account }, out);
730
+ }
731
+ });
732
+ var salesNavBrowseLeadListCommand = defineCommand({
733
+ meta: { name: "browse-lead-list", description: "Browse the saved leads (members) in one lead list." },
734
+ args: {
735
+ ...GLOBAL_FLAGS,
736
+ listId: { type: "positional", description: "The lead-list id (from `sales-nav lead-lists`)." },
737
+ spotlight: { type: "string", description: "Restrict to a spotlighted lead subset: RECENT_POSITION_CHANGE, RECENTLY_POSTED_ON_LINKEDIN, FOLLOW_YOUR_COMPANY, or SHARE_EXPERIENCE." },
738
+ "sort-by": { type: "string", description: "Sort field: DATE_ADDED, ACCOUNT, NAME, or OUTREACH_ACTIVITY. Defaults to DATE_ADDED." },
739
+ "sort-order": { type: "string", description: "Sort direction: ASCENDING or DESCENDING. Defaults to DESCENDING." }
740
+ },
741
+ async run({ args }) {
742
+ const flags = args;
743
+ const cfg = await resolveEffectiveConfig({
744
+ apiKey: flags["api-key"],
745
+ baseUrl: flags["base-url"],
746
+ timeout: flags.timeout,
747
+ account: flags.account,
748
+ profile: flags.profile
749
+ });
750
+ if (!cfg.apiKey) {
751
+ process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
752
+ process.exit(3);
753
+ }
754
+ const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
755
+ const out = buildOutputStreams();
756
+ await runSalesNavBrowseLeadList(client, { ...flags, account: flags.account ?? cfg.account }, out);
757
+ }
758
+ });
759
+ var salesNavSaveAccountCommand = defineCommand({
760
+ meta: { name: "save-account", description: "Save a LinkedIn company into an account list." },
761
+ args: {
762
+ // Write command: WRITE_FLAGS omits pagination/projection flags
763
+ ...WRITE_FLAGS,
764
+ companyId: { type: "positional", description: "The LinkedIn company id to save into the account list." },
765
+ list: { type: "string", description: "The target account-list id to save the company into (required).", required: true }
766
+ },
767
+ async run({ args }) {
768
+ const flags = args;
769
+ const cfg = await resolveEffectiveConfig({
770
+ apiKey: flags["api-key"],
771
+ baseUrl: flags["base-url"],
772
+ timeout: flags.timeout,
773
+ account: flags.account,
774
+ profile: flags.profile
775
+ });
776
+ if (!cfg.apiKey) {
777
+ process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
778
+ process.exit(3);
779
+ }
780
+ const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
781
+ const out = buildOutputStreams();
782
+ await runSalesNavSaveAccount(client, { ...flags, account: flags.account ?? cfg.account }, out);
783
+ }
784
+ });
517
785
  var salesNavCommand = defineCommand({
518
786
  meta: { name: "sales-nav", description: "Sales Navigator operations (requires the Sales Navigator add-on)." },
519
787
  args: { ...GLOBAL_FLAGS },
@@ -522,18 +790,28 @@ var salesNavCommand = defineCommand({
522
790
  message: salesNavMessageCommand,
523
791
  search: salesNavSearchCommand,
524
792
  profile: salesNavProfileCommand,
525
- "save-lead": salesNavSaveLeadCommand
793
+ "save-lead": salesNavSaveLeadCommand,
794
+ "account-lists": salesNavAccountListsCommand,
795
+ "lead-lists": salesNavLeadListsCommand,
796
+ "browse-account-list": salesNavBrowseAccountListCommand,
797
+ "browse-lead-list": salesNavBrowseLeadListCommand,
798
+ "save-account": salesNavSaveAccountCommand
526
799
  },
527
800
  async run() {
528
801
  process.stderr.write(
529
- 'Usage: curviate sales-nav sync\n curviate sales-nav search people [--keywords <k>]\n curviate sales-nav search companies [--keywords <k>]\n curviate sales-nav search parameters --type <t>\n curviate sales-nav message new --to <id> "<text>"\n curviate sales-nav profile <identifier>\n curviate sales-nav save-lead <user_id> [--list-id <id>]\n'
802
+ 'Usage: curviate sales-nav sync\n curviate sales-nav search people [--keywords <k>]\n curviate sales-nav search companies [--keywords <k>]\n curviate sales-nav search parameters --type <t>\n curviate sales-nav message new --to <id> "<text>"\n curviate sales-nav profile <identifier>\n curviate sales-nav save-lead --list <id> <user_id>\n curviate sales-nav account-lists --account <id>\n curviate sales-nav lead-lists --account <id>\n curviate sales-nav browse-account-list <list_id> --account <id>\n curviate sales-nav browse-lead-list <list_id> --account <id>\n curviate sales-nav save-account --list <id> <company_id> --account <id>\n'
530
803
  );
531
804
  }
532
805
  });
533
806
  export {
807
+ runSalesNavAccountLists,
808
+ runSalesNavBrowseAccountList,
809
+ runSalesNavBrowseLeadList,
534
810
  runSalesNavGetParameters,
811
+ runSalesNavLeadLists,
535
812
  runSalesNavMessageNew,
536
813
  runSalesNavProfile,
814
+ runSalesNavSaveAccount,
537
815
  runSalesNavSaveLead,
538
816
  runSalesNavSearchCompanies,
539
817
  runSalesNavSearchPeople,
@@ -222,7 +222,7 @@ async function runSearchPeople(client, flags, out, readers = DEFAULT_FILTER_READ
222
222
  } catch (err) {
223
223
  const { CurviateError } = await import("@curviate/sdk");
224
224
  if (err instanceof CurviateError) {
225
- const { getExitCode } = await import("./exit-codes-2ASIFXGR.js");
225
+ const { getExitCode } = await import("./exit-codes-ZTY2NY3X.js");
226
226
  renderError(err, outOpts, out);
227
227
  process.exit(getExitCode(err.code));
228
228
  }
@@ -264,7 +264,7 @@ async function runSearchCompanies(client, flags, out, readers = DEFAULT_FILTER_R
264
264
  } catch (err) {
265
265
  const { CurviateError } = await import("@curviate/sdk");
266
266
  if (err instanceof CurviateError) {
267
- const { getExitCode } = await import("./exit-codes-2ASIFXGR.js");
267
+ const { getExitCode } = await import("./exit-codes-ZTY2NY3X.js");
268
268
  renderError(err, outOpts, out);
269
269
  process.exit(getExitCode(err.code));
270
270
  }
@@ -306,7 +306,7 @@ async function runSearchPosts(client, flags, out, readers = DEFAULT_FILTER_READE
306
306
  } catch (err) {
307
307
  const { CurviateError } = await import("@curviate/sdk");
308
308
  if (err instanceof CurviateError) {
309
- const { getExitCode } = await import("./exit-codes-2ASIFXGR.js");
309
+ const { getExitCode } = await import("./exit-codes-ZTY2NY3X.js");
310
310
  renderError(err, outOpts, out);
311
311
  process.exit(getExitCode(err.code));
312
312
  }
@@ -348,7 +348,7 @@ async function runSearchJobs(client, flags, out, readers = DEFAULT_FILTER_READER
348
348
  } catch (err) {
349
349
  const { CurviateError } = await import("@curviate/sdk");
350
350
  if (err instanceof CurviateError) {
351
- const { getExitCode } = await import("./exit-codes-2ASIFXGR.js");
351
+ const { getExitCode } = await import("./exit-codes-ZTY2NY3X.js");
352
352
  renderError(err, outOpts, out);
353
353
  process.exit(getExitCode(err.code));
354
354
  }
@@ -372,7 +372,7 @@ async function runSearchParameters(client, flags, out) {
372
372
  } catch (err) {
373
373
  const { CurviateError } = await import("@curviate/sdk");
374
374
  if (err instanceof CurviateError) {
375
- const { getExitCode } = await import("./exit-codes-2ASIFXGR.js");
375
+ const { getExitCode } = await import("./exit-codes-ZTY2NY3X.js");
376
376
  renderError(err, outOpts, out);
377
377
  process.exit(getExitCode(err.code));
378
378
  }
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- streamAll
4
- } from "./chunk-GXTZION6.js";
5
2
  import {
6
3
  buildPreviewOutput
7
4
  } from "./chunk-R3VLWLVV.js";
5
+ import {
6
+ streamAll
7
+ } from "./chunk-GXTZION6.js";
8
8
  import {
9
9
  createClient,
10
10
  renderError,
@@ -47,7 +47,7 @@ function resolveOutputOpts(flags) {
47
47
  async function handleError(err, outOpts, out) {
48
48
  const { CurviateError } = await import("@curviate/sdk");
49
49
  if (err instanceof CurviateError) {
50
- const { getExitCode } = await import("./exit-codes-2ASIFXGR.js");
50
+ const { getExitCode } = await import("./exit-codes-ZTY2NY3X.js");
51
51
  renderError(err, outOpts, out);
52
52
  process.exit(getExitCode(err.code));
53
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curviate/cli",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "private": false,
5
5
  "description": "Official command-line interface for the Curviate API.",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "clean": "rm -rf dist *.tsbuildinfo"
41
41
  },
42
42
  "dependencies": {
43
- "@curviate/sdk": "^0.11.0",
43
+ "@curviate/sdk": "^0.13.0",
44
44
  "citty": "^0.1.6",
45
45
  "open": "^10.1.0"
46
46
  },
@@ -1,92 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- slimCompany
4
- } from "./chunk-SSPILTKF.js";
5
- import {
6
- resolveIdentifier
7
- } from "./chunk-DMQZEPQE.js";
8
- import {
9
- createClient,
10
- renderError,
11
- renderSuccess,
12
- renderUnexpectedError,
13
- resolveEffectiveConfig
14
- } from "./chunk-JXF47TRY.js";
15
- import {
16
- GLOBAL_FLAGS
17
- } from "./chunk-4JHGVY7R.js";
18
-
19
- // src/commands/company.ts
20
- import { defineCommand } from "citty";
21
- function buildOutputStreams() {
22
- return {
23
- stdout: { write: (s) => process.stdout.write(s) },
24
- stderr: { write: (s) => process.stderr.write(s) }
25
- };
26
- }
27
- async function runCompanyGet(client, flags, out) {
28
- if (flags.preview) {
29
- out.stderr.write("error: --preview is only valid on write commands (mutations). Reads just run.\n");
30
- process.exit(2);
31
- }
32
- if (flags.all) {
33
- out.stderr.write("error: --all is not supported on non-paginated commands.\n");
34
- process.exit(2);
35
- }
36
- if (flags.sections !== void 0) {
37
- out.stderr.write("error: --sections is not supported on company commands.\n");
38
- process.exit(2);
39
- }
40
- const rawId = flags.id ?? "";
41
- const resolvedId = resolveIdentifier(rawId);
42
- const outOpts = {
43
- json: (flags.json ?? false) || !process.stdout.isTTY,
44
- isTTY: process.stdout.isTTY ?? false,
45
- fields: flags.fields,
46
- verbose: flags.verbose ?? false,
47
- slim: slimCompany
48
- };
49
- try {
50
- const getCompany = flags.account ? client.account(flags.account).profiles.getCompany.bind(client.account(flags.account).profiles) : client.profiles.getCompany.bind(client.profiles);
51
- const result = await getCompany(resolvedId);
52
- renderSuccess(result, outOpts, out);
53
- } catch (err) {
54
- const { CurviateError } = await import("@curviate/sdk");
55
- if (err instanceof CurviateError) {
56
- const { getExitCode } = await import("./exit-codes-2ASIFXGR.js");
57
- renderError(err, outOpts, out);
58
- process.exit(getExitCode(err.code));
59
- }
60
- renderUnexpectedError(err, out);
61
- process.exit(1);
62
- }
63
- }
64
- var companyCommand = defineCommand({
65
- meta: { name: "company", description: "Fetch a company profile by URL or slug." },
66
- args: {
67
- ...GLOBAL_FLAGS,
68
- id: { type: "positional", description: "Company identifier (URL, slug, or native id)." },
69
- sections: { type: "string", description: "Not supported on company commands \u2014 usage error (exit 2) if supplied." }
70
- },
71
- async run({ args }) {
72
- const flags = args;
73
- const cfg = await resolveEffectiveConfig({
74
- apiKey: flags["api-key"],
75
- baseUrl: flags["base-url"],
76
- timeout: flags.timeout,
77
- account: flags.account,
78
- profile: flags.profile
79
- });
80
- if (!cfg.apiKey) {
81
- process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
82
- process.exit(3);
83
- }
84
- const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
85
- const out = buildOutputStreams();
86
- await runCompanyGet(client, { ...flags, account: flags.account ?? cfg.account }, out);
87
- }
88
- });
89
- export {
90
- companyCommand,
91
- runCompanyGet
92
- };