@curviate/cli 0.32.0 → 0.34.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 (41) hide show
  1. package/CHANGELOG.md +264 -1
  2. package/README.md +13 -1
  3. package/dist/{account-JDSZC633.js → account-463D5EVY.js} +90 -47
  4. package/dist/{chunk-JRKM4OV2.js → chunk-6W7364S3.js} +1 -1
  5. package/dist/{chunk-KQXYEQAD.js → chunk-7JU4IXXG.js} +172 -8
  6. package/dist/{chunk-5EJDQ47B.js → chunk-BN7L7WSY.js} +16 -16
  7. package/dist/chunk-DCZR4M7G.js +327 -0
  8. package/dist/{chunk-V3PB4HSF.js → chunk-MNDXMGPX.js} +68 -24
  9. package/dist/chunk-TCUYH5GO.js +34 -0
  10. package/dist/{chunk-SKJNLN37.js → chunk-XDQHNUEU.js} +86 -2
  11. package/dist/{chunk-LJR4LJG6.js → chunk-XP2LN6F6.js} +53 -0
  12. package/dist/{chunk-EIEF2KFH.js → chunk-XZJQQJBE.js} +6 -4
  13. package/dist/{chunk-6P52Q2GK.js → chunk-ZJ7D3NFS.js} +5 -4
  14. package/dist/cli.js +104 -37
  15. package/dist/{comment-YOFNFQUE.js → comment-G6RB2PBZ.js} +32 -26
  16. package/dist/{company-6PKHDK6L.js → company-OWND3W3L.js} +53 -35
  17. package/dist/{config-FUHT23SX.js → config-RUBXWFQ3.js} +74 -29
  18. package/dist/{connect-DG2AVGVL.js → connect-3E7EC5ZM.js} +35 -32
  19. package/dist/{doctor-FK7B6754.js → doctor-Z6OSCGKT.js} +22 -16
  20. package/dist/{exit-codes-AAFTOAXF.js → exit-codes-YSFFFWMS.js} +1 -1
  21. package/dist/{feed-HXBKXKAQ.js → feed-VDTFIMKN.js} +18 -17
  22. package/dist/{group-UYX3KTX3.js → group-KDJHY2IM.js} +21 -18
  23. package/dist/{inbox-EVE2ZTHC.js → inbox-DQLX2LR7.js} +39 -23
  24. package/dist/{inboxes-JBB34WMQ.js → inboxes-WMNHOPY7.js} +18 -17
  25. package/dist/{job-GXUZANYN.js → job-ESKS2LDJ.js} +44 -30
  26. package/dist/{login-3OAUY7TG.js → login-YTVPIN27.js} +15 -3
  27. package/dist/{message-34AGROW2.js → message-5W2R3YHS.js} +7 -9
  28. package/dist/{notification-SKKZS2C5.js → notification-IGNUH2GR.js} +20 -19
  29. package/dist/{post-FIW522Q6.js → post-NLI76K74.js} +34 -26
  30. package/dist/{profile-SX6JOYMD.js → profile-TBKKIICM.js} +71 -90
  31. package/dist/{recruiter-H7ROBEVC.js → recruiter-AEJRHIX5.js} +42 -29
  32. package/dist/{sales-nav-7KCK562X.js → sales-nav-SW6WJVMD.js} +43 -29
  33. package/dist/{search-PASMDQEH.js → search-CS6VN5AG.js} +58 -44
  34. package/dist/{setup-YV5PVIU5.js → setup-ANHJZJ2S.js} +12 -8
  35. package/dist/{webhook-GPLFPC6N.js → webhook-NGMRJMQ5.js} +25 -22
  36. package/package.json +2 -2
  37. package/dist/chunk-LKF5MZIP.js +0 -90
  38. package/dist/chunk-PKSKQ3LN.js +0 -68
  39. package/dist/chunk-R3VLWLVV.js +0 -23
  40. package/dist/chunk-TD2ZIXFR.js +0 -67
  41. package/dist/chunk-TQJ77SL4.js +0 -147
@@ -1,27 +1,27 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- pageDelayFromFlags,
4
- streamAll
5
- } from "./chunk-LKF5MZIP.js";
6
2
  import {
7
3
  buildPreviewOutput
8
- } from "./chunk-R3VLWLVV.js";
4
+ } from "./chunk-TCUYH5GO.js";
9
5
  import {
6
+ pageDelayFromFlags,
7
+ readablePage,
8
+ rejectPaginationModifiersWithoutAll,
10
9
  renderError,
11
10
  renderSuccess,
12
- renderUnexpectedError
13
- } from "./chunk-KQXYEQAD.js";
11
+ renderUnexpectedError,
12
+ resolveEffectiveConfig,
13
+ streamAll,
14
+ writeNdjsonItem
15
+ } from "./chunk-7JU4IXXG.js";
14
16
  import {
15
- createClient,
16
- resolveEffectiveConfig
17
- } from "./chunk-TD2ZIXFR.js";
18
- import "./chunk-PKSKQ3LN.js";
19
- import "./chunk-TQJ77SL4.js";
17
+ createClient
18
+ } from "./chunk-DCZR4M7G.js";
20
19
  import {
21
20
  GLOBAL_FLAGS,
21
+ NON_STREAM_FLAGS,
22
22
  defaultReadStdin,
23
23
  isStdinToken
24
- } from "./chunk-SKJNLN37.js";
24
+ } from "./chunk-XDQHNUEU.js";
25
25
 
26
26
  // src/commands/webhook.ts
27
27
  import { defineCommand } from "citty";
@@ -54,9 +54,9 @@ function resolveOutputOpts(flags) {
54
54
  async function handleError(err, outOpts, out) {
55
55
  const { CurviateError } = await import("@curviate/sdk");
56
56
  if (err instanceof CurviateError) {
57
- const { getExitCode } = await import("./exit-codes-AAFTOAXF.js");
57
+ const { getExitCode } = await import("./exit-codes-YSFFFWMS.js");
58
58
  renderError(err, outOpts, out);
59
- process.exit(getExitCode(err.code));
59
+ process.exit(getExitCode(err));
60
60
  }
61
61
  renderUnexpectedError(err, out);
62
62
  process.exit(1);
@@ -103,6 +103,7 @@ async function runWebhookCreate(client, flags, out) {
103
103
  }
104
104
  async function runWebhookList(client, flags, out) {
105
105
  rejectPreviewOnRead(flags.preview, out);
106
+ rejectPaginationModifiersWithoutAll(flags, out);
106
107
  const outOpts = resolveOutputOpts(flags);
107
108
  const all = flags.all ?? false;
108
109
  const maxPages = flags["max-pages"] ? parseInt(flags["max-pages"], 10) : 100;
@@ -119,10 +120,11 @@ async function runWebhookList(client, flags, out) {
119
120
  out,
120
121
  pageDelayMs: pageDelayFromFlags(flags)
121
122
  })) {
122
- out.stdout.write(JSON.stringify(item) + "\n");
123
+ writeNdjsonItem(out, item, outOpts.fields);
123
124
  }
124
125
  } else {
125
126
  const result = await client.webhooks.list(params);
127
+ readablePage(result);
126
128
  renderSuccess(result, outOpts, out);
127
129
  }
128
130
  } catch (err) {
@@ -269,7 +271,7 @@ async function runWebhookVerify(input, out) {
269
271
  var webhookCreateCommand = defineCommand({
270
272
  meta: { name: "create", description: "Register a new webhook endpoint." },
271
273
  args: {
272
- ...GLOBAL_FLAGS,
274
+ ...NON_STREAM_FLAGS,
273
275
  source: { type: "string", description: "Event source: messaging | user | account_status.", required: true },
274
276
  "request-url": { type: "string", description: "HTTPS URL to receive webhook deliveries.", required: true },
275
277
  "account-ids": { type: "string", description: "Comma-separated account ids to target (required).", required: true },
@@ -317,7 +319,7 @@ var webhookListCommand = defineCommand({
317
319
  });
318
320
  var webhookEventsCommand = defineCommand({
319
321
  meta: { name: "events", description: "List the canonical webhook event catalogue." },
320
- args: { ...GLOBAL_FLAGS },
322
+ args: { ...NON_STREAM_FLAGS },
321
323
  async run({ args }) {
322
324
  const flags = args;
323
325
  const cfg = await resolveEffectiveConfig({
@@ -338,7 +340,7 @@ var webhookEventsCommand = defineCommand({
338
340
  var webhookGetCommand = defineCommand({
339
341
  meta: { name: "get", description: "Get a single webhook owned by the calling tenant." },
340
342
  args: {
341
- ...GLOBAL_FLAGS,
343
+ ...NON_STREAM_FLAGS,
342
344
  id: { type: "positional", description: "Webhook id (wh_...)." }
343
345
  },
344
346
  async run({ args }) {
@@ -361,7 +363,7 @@ var webhookGetCommand = defineCommand({
361
363
  var webhookUpdateCommand = defineCommand({
362
364
  meta: { name: "update", description: "Update a webhook in place (source is immutable)." },
363
365
  args: {
364
- ...GLOBAL_FLAGS,
366
+ ...NON_STREAM_FLAGS,
365
367
  id: { type: "positional", description: "Webhook id (wh_...)." },
366
368
  "request-url": { type: "string", description: "Replace the delivery URL." },
367
369
  name: { type: "string", description: "Replace the name (or clear with empty string)." },
@@ -390,7 +392,7 @@ var webhookUpdateCommand = defineCommand({
390
392
  var webhookDeleteCommand = defineCommand({
391
393
  meta: { name: "delete", description: "Permanently remove a webhook subscription." },
392
394
  args: {
393
- ...GLOBAL_FLAGS,
395
+ ...NON_STREAM_FLAGS,
394
396
  id: { type: "positional", description: "Webhook id (wh_...)." }
395
397
  },
396
398
  async run({ args }) {
@@ -412,8 +414,9 @@ var webhookDeleteCommand = defineCommand({
412
414
  });
413
415
  var webhookVerifyCommand = defineCommand({
414
416
  meta: { name: "verify", description: "Verify a webhook signature offline (no network call)." },
417
+ // Offline: no profile, credential, transport or pagination flag applies.
415
418
  args: {
416
- ...GLOBAL_FLAGS,
419
+ json: GLOBAL_FLAGS.json,
417
420
  secret: {
418
421
  type: "string",
419
422
  description: "The webhook signing secret from your webhook registration.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curviate/cli",
3
- "version": "0.32.0",
3
+ "version": "0.34.0",
4
4
  "private": false,
5
5
  "description": "Official command-line interface for the Curviate API.",
6
6
  "license": "MIT",
@@ -46,7 +46,7 @@
46
46
  "clean": "rm -rf dist *.tsbuildinfo"
47
47
  },
48
48
  "dependencies": {
49
- "@curviate/sdk": "0.31.0",
49
+ "@curviate/sdk": "0.32.0",
50
50
  "citty": "^0.1.6",
51
51
  "open": "^10.1.0"
52
52
  },
@@ -1,90 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- renderNotices,
4
- renderProvenanceNote
5
- } from "./chunk-KQXYEQAD.js";
6
-
7
- // src/lib/paginate.ts
8
- var PaginateError = class extends Error {
9
- constructor(message) {
10
- super(message);
11
- this.exitCode = 2;
12
- this.name = "PaginateError";
13
- }
14
- };
15
- function truncationProseNote(pagesFetched) {
16
- return `Streaming truncated at ${pagesFetched} page(s). Use --all --max-pages or --cursor for manual paging.
17
- `;
18
- }
19
- function ndjsonModeNotice() {
20
- return "--all streams NDJSON: one object per line; the {items,cursor} envelope is not used\n";
21
- }
22
- var DEFAULT_PAGE_DELAY_MS = 400;
23
- function pageDelayFrom(raw) {
24
- if (raw === void 0 || raw === "") return void 0;
25
- const n = Number(raw);
26
- if (!Number.isInteger(n) || n < 0) return void 0;
27
- return n;
28
- }
29
- function pageDelayFromFlags(flags) {
30
- return pageDelayFrom(flags["page-delay"]);
31
- }
32
- var realSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
33
- function truncationSentinelLine(pagesFetched, hasMore) {
34
- return JSON.stringify({ object: "stream_truncated", pages_fetched: pagesFetched, has_more: hasMore }) + "\n";
35
- }
36
- async function* streamAll(fn, params, opts = {}) {
37
- const maxPages = opts.maxPages ?? 100;
38
- const pageDelayMs = opts.pageDelayMs ?? DEFAULT_PAGE_DELAY_MS;
39
- const sleep = opts.sleep ?? realSleep;
40
- let cursor = void 0;
41
- let pageCount = 0;
42
- let firstPage = true;
43
- while (true) {
44
- const pageParams = cursor !== void 0 && cursor !== null ? { ...params, cursor } : params;
45
- const page = await fn(pageParams);
46
- pageCount++;
47
- const items = page.items ?? page.data;
48
- if (firstPage && !Array.isArray(items)) {
49
- throw new PaginateError(
50
- "--all requires a paginated method (response must have `items` or `data` array). Remove --all for non-list commands."
51
- );
52
- }
53
- if (firstPage) {
54
- if (opts.out) opts.out.stderr.write(ndjsonModeNotice());
55
- firstPage = false;
56
- }
57
- if (opts.out) {
58
- const pageNotices = renderNotices(page.notices);
59
- if (pageNotices) opts.out.stderr.write(pageNotices + "\n");
60
- const pageProvenance = renderProvenanceNote(page);
61
- if (pageProvenance) opts.out.stderr.write(pageProvenance);
62
- }
63
- if (Array.isArray(items)) {
64
- for (const item of items) {
65
- yield item;
66
- }
67
- }
68
- cursor = page.cursor;
69
- if (!cursor) break;
70
- if (pageCount >= maxPages) {
71
- const hasMore = cursor !== null && cursor !== void 0;
72
- if (opts.out) {
73
- opts.out.stdout.write(truncationSentinelLine(pageCount, hasMore));
74
- opts.out.stderr.write(truncationProseNote(pageCount));
75
- }
76
- if (opts.onTruncated) {
77
- opts.onTruncated(pageCount, hasMore);
78
- }
79
- break;
80
- }
81
- if (pageDelayMs > 0) await sleep(pageDelayMs);
82
- }
83
- }
84
-
85
- export {
86
- ndjsonModeNotice,
87
- DEFAULT_PAGE_DELAY_MS,
88
- pageDelayFromFlags,
89
- streamAll
90
- };
@@ -1,68 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/lib/beta.ts
4
- var BETA_CONSENT_HEADER = "X-Curviate-Beta";
5
- var TRUE_TOKENS = /* @__PURE__ */ new Set(["true", "1", "on", "yes"]);
6
- var FALSE_TOKENS = /* @__PURE__ */ new Set(["false", "0", "off", "no"]);
7
- var BETA_ACCEPTED_VALUES = "true|false, 1|0, on|off, yes|no (case-insensitive)";
8
- function parseBetaFlag(rawArgs) {
9
- let value;
10
- const rest = [];
11
- let endOfFlags = false;
12
- for (const arg of rawArgs) {
13
- if (endOfFlags) {
14
- rest.push(arg);
15
- continue;
16
- }
17
- if (arg === "--") {
18
- endOfFlags = true;
19
- rest.push(arg);
20
- continue;
21
- }
22
- if (arg === "--beta") {
23
- value = true;
24
- continue;
25
- }
26
- if (arg === "--no-beta") {
27
- value = false;
28
- continue;
29
- }
30
- if (arg.startsWith("--no-beta=")) {
31
- return {
32
- ok: false,
33
- error: `--no-beta takes no value. Use --no-beta, or --beta=${BETA_ACCEPTED_VALUES.split(",")[0].split("|")[1]}.`
34
- };
35
- }
36
- if (arg.startsWith("--beta=")) {
37
- const raw = arg.slice("--beta=".length).trim().toLowerCase();
38
- if (TRUE_TOKENS.has(raw)) {
39
- value = true;
40
- continue;
41
- }
42
- if (FALSE_TOKENS.has(raw)) {
43
- value = false;
44
- continue;
45
- }
46
- return {
47
- ok: false,
48
- error: `--beta must be one of ${BETA_ACCEPTED_VALUES}. Got "${arg.slice("--beta=".length)}".`
49
- };
50
- }
51
- rest.push(arg);
52
- }
53
- return { ok: true, value, rest };
54
- }
55
- var override;
56
- function setBetaOverride(value) {
57
- override = value;
58
- }
59
- function betaOverrideHeader() {
60
- if (override === void 0) return {};
61
- return { [BETA_CONSENT_HEADER]: override ? "true" : "false" };
62
- }
63
-
64
- export {
65
- parseBetaFlag,
66
- setBetaOverride,
67
- betaOverrideHeader
68
- };
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/lib/preview.ts
4
- function buildPreviewOutput(req) {
5
- const result = {
6
- method: req.method,
7
- args: req.args,
8
- body: req.body
9
- };
10
- if (req.account !== void 0) {
11
- result.account = req.account;
12
- }
13
- if (req.attachments && req.attachments.length > 0) {
14
- result.attachments = req.attachments.map(
15
- (a) => `${a.name} (${a.buffer.byteLength} bytes)`
16
- );
17
- }
18
- return result;
19
- }
20
-
21
- export {
22
- buildPreviewOutput
23
- };
@@ -1,67 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- betaOverrideHeader
4
- } from "./chunk-PKSKQ3LN.js";
5
- import {
6
- readConfig
7
- } from "./chunk-TQJ77SL4.js";
8
- import {
9
- assertNoStdinPlaceholder
10
- } from "./chunk-SKJNLN37.js";
11
-
12
- // src/lib/client.ts
13
- import { Curviate } from "@curviate/sdk";
14
- function headerStrings(headers) {
15
- if (!headers) return [];
16
- if (headers instanceof Headers) {
17
- const out = [];
18
- headers.forEach((value, key) => out.push(key, value));
19
- return out;
20
- }
21
- if (Array.isArray(headers)) return headers.flat().map(String);
22
- return Object.entries(headers).flat().map(String);
23
- }
24
- var guardedFetch = (input, init) => {
25
- const beta = betaOverrideHeader();
26
- let merged = init;
27
- if (Object.keys(beta).length > 0) {
28
- const headers = new Headers(init?.headers);
29
- for (const [name, value] of Object.entries(beta)) headers.set(name, value);
30
- merged = { ...init, headers };
31
- }
32
- assertNoStdinPlaceholder("the request about to be sent", [
33
- String(input instanceof Request ? input.url : input),
34
- ...headerStrings(merged?.headers),
35
- typeof merged?.body === "string" ? merged.body : void 0
36
- ]);
37
- return fetch(input, merged);
38
- };
39
- function createClient(config) {
40
- return new Curviate({
41
- apiKey: config.apiKey.trim(),
42
- fetch: guardedFetch,
43
- ...config.baseUrl !== void 0 ? { baseUrl: config.baseUrl } : {},
44
- ...config.timeout !== void 0 ? { timeout: config.timeout } : {}
45
- });
46
- }
47
-
48
- // src/lib/resolve.ts
49
- var DEFAULT_BASE_URL = "https://api.curviate.com";
50
- var DEFAULT_TIMEOUT_MS = 3e4;
51
- async function resolveEffectiveConfig(flags) {
52
- const cfg = await readConfig();
53
- const profileName = flags.profile ?? (cfg?.active ?? "default");
54
- const profile = cfg?.profiles[profileName];
55
- const apiKey = flags.apiKey ?? process.env["CURVIATE_API_KEY"] ?? profile?.apiKey ?? void 0;
56
- const apiKeySource = flags.apiKey !== void 0 ? "flag" : process.env["CURVIATE_API_KEY"] !== void 0 ? "env" : profile?.apiKey !== void 0 ? "profile" : "none";
57
- const baseUrl = flags.baseUrl ?? process.env["CURVIATE_BASE_URL"] ?? profile?.baseUrl ?? DEFAULT_BASE_URL;
58
- const timeoutFlag = flags.timeout !== void 0 ? parseInt(flags.timeout, 10) : void 0;
59
- const timeout = timeoutFlag ?? profile?.timeout ?? DEFAULT_TIMEOUT_MS;
60
- const account = flags.account ?? process.env["CURVIATE_ACCOUNT"] ?? profile?.account ?? void 0;
61
- return { apiKey, baseUrl, timeout, account, apiKeySource };
62
- }
63
-
64
- export {
65
- createClient,
66
- resolveEffectiveConfig
67
- };
@@ -1,147 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- assertNoStdinPlaceholder
4
- } from "./chunk-SKJNLN37.js";
5
-
6
- // src/lib/config.ts
7
- import {
8
- readFile,
9
- writeFile,
10
- mkdir,
11
- rename,
12
- chmod,
13
- unlink
14
- } from "fs/promises";
15
- import { join, dirname } from "path";
16
- import { homedir, tmpdir } from "os";
17
- import { randomBytes } from "crypto";
18
- function nullProtoProfiles(profiles) {
19
- return Object.assign(/* @__PURE__ */ Object.create(null), profiles);
20
- }
21
- function getConfigPath() {
22
- const xdg = process.env["XDG_CONFIG_HOME"] ?? (process.env["APPDATA"] ?? join(homedir(), ".config"));
23
- return join(xdg, "curviate", "config.json");
24
- }
25
- async function readConfig() {
26
- const cfgPath = getConfigPath();
27
- let raw;
28
- try {
29
- raw = await readFile(cfgPath, "utf8");
30
- } catch (err) {
31
- const e = err;
32
- if (e.code === "ENOENT") return null;
33
- throw err;
34
- }
35
- const parsed = JSON.parse(raw);
36
- return { ...parsed, profiles: nullProtoProfiles(parsed.profiles ?? {}) };
37
- }
38
- async function writeConfig(cfg) {
39
- const cfgPath = getConfigPath();
40
- const cfgDir = dirname(cfgPath);
41
- await mkdir(cfgDir, { recursive: true, mode: 448 });
42
- try {
43
- await chmod(cfgDir, 448);
44
- } catch {
45
- }
46
- const content = JSON.stringify(cfg, null, 2) + "\n";
47
- assertNoStdinPlaceholder("the configuration about to be written", [content]);
48
- const tmpPath = join(
49
- tmpdir(),
50
- `curviate-cfg-${randomBytes(6).toString("hex")}.tmp`
51
- );
52
- try {
53
- await writeFile(tmpPath, content, { encoding: "utf8", mode: 384 });
54
- try {
55
- await chmod(tmpPath, 384);
56
- } catch {
57
- }
58
- await rename(tmpPath, cfgPath);
59
- try {
60
- await chmod(cfgPath, 384);
61
- } catch {
62
- }
63
- } catch (err) {
64
- try {
65
- await unlink(tmpPath);
66
- } catch {
67
- }
68
- throw err;
69
- }
70
- }
71
- async function writeProfile(profileName, entry) {
72
- const existing = await readConfig() ?? {
73
- active: profileName,
74
- profiles: nullProtoProfiles({})
75
- };
76
- const current = existing.profiles[profileName] ?? {};
77
- existing.profiles[profileName] = { ...current, ...entry };
78
- if (!existing.active) {
79
- existing.active = profileName;
80
- }
81
- await writeConfig(existing);
82
- }
83
- async function setActiveProfile(profileName) {
84
- const cfg = await readConfig();
85
- if (!cfg || !cfg.profiles[profileName]) {
86
- throw new Error(`Profile "${profileName}" not found.`);
87
- }
88
- cfg.active = profileName;
89
- await writeConfig(cfg);
90
- }
91
- async function renameProfile(oldName, newName) {
92
- const cfg = await readConfig();
93
- if (!cfg || !cfg.profiles[oldName]) {
94
- throw new Error(`Profile "${oldName}" not found.`);
95
- }
96
- if (cfg.profiles[newName]) {
97
- throw new Error(
98
- `Profile "${newName}" already exists. Remove it first or choose another name.`
99
- );
100
- }
101
- cfg.profiles[newName] = cfg.profiles[oldName];
102
- delete cfg.profiles[oldName];
103
- if (cfg.active === oldName) {
104
- cfg.active = newName;
105
- }
106
- await writeConfig(cfg);
107
- }
108
- async function removeProfile(profileName) {
109
- const cfg = await readConfig();
110
- if (!cfg) return;
111
- delete cfg.profiles[profileName];
112
- if (cfg.active === profileName) {
113
- cfg.active = "default";
114
- }
115
- await writeConfig(cfg);
116
- }
117
- async function updateProfileField(profileName, field, value) {
118
- const cfg = await readConfig();
119
- if (!cfg || !cfg.profiles[profileName]) {
120
- throw new Error(`Profile "${profileName}" not found.`);
121
- }
122
- const profile = cfg.profiles[profileName];
123
- if (profile) {
124
- if (field === "timeout") {
125
- profile.timeout = typeof value === "number" ? value : value !== void 0 ? Number(value) : void 0;
126
- } else if (field === "apiKey") {
127
- profile.apiKey = value !== void 0 ? String(value) : void 0;
128
- } else if (field === "account") {
129
- profile.account = value !== void 0 ? String(value) : void 0;
130
- } else if (field === "baseUrl") {
131
- profile.baseUrl = value !== void 0 ? String(value) : void 0;
132
- } else if (field === "tenant") {
133
- profile.tenant = value !== void 0 ? String(value) : void 0;
134
- }
135
- }
136
- await writeConfig(cfg);
137
- }
138
-
139
- export {
140
- getConfigPath,
141
- readConfig,
142
- writeProfile,
143
- setActiveProfile,
144
- renameProfile,
145
- removeProfile,
146
- updateProfileField
147
- };