@usethrottle/cli 1.0.1 → 1.0.3

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.
package/README.md CHANGED
@@ -1,3 +1,8 @@
1
+ <p align="left">
2
+ <img src="https://raw.githubusercontent.com/Epic-Design-Labs/app-throttle/main/packages/brand/assets/throttle-logo.png" alt="Throttle" height="56" />
3
+ </p>
4
+
5
+
1
6
  # @usethrottle/cli
2
7
 
3
8
  Command-line tool for the Throttle multi-tenant payments platform.
package/dist/cli.js CHANGED
@@ -7,23 +7,38 @@ import { Command } from "commander";
7
7
  import prompts from "prompts";
8
8
  import pc from "picocolors";
9
9
 
10
+ // ../errors/dist/index.js
11
+ var ThrottleError = class extends Error {
12
+ code;
13
+ statusCode;
14
+ details;
15
+ body;
16
+ constructor(args2) {
17
+ super(args2.message);
18
+ this.name = "ThrottleError";
19
+ this.code = args2.code;
20
+ this.statusCode = args2.statusCode;
21
+ this.details = args2.details;
22
+ this.body = args2.body;
23
+ Object.setPrototypeOf(this, new.target.prototype);
24
+ }
25
+ };
26
+
10
27
  // src/lib/throttle-api.ts
11
- var ThrottleApiError = class extends Error {
28
+ var ThrottleApiError = class extends ThrottleError {
12
29
  constructor(code, message, statusCode) {
13
- super(message);
14
- this.code = code;
15
- this.statusCode = statusCode;
30
+ super({ code, message, statusCode });
16
31
  this.name = "ThrottleApiError";
17
32
  }
18
33
  };
19
- async function callThrottle(opts, path, init = {}) {
34
+ async function callThrottle(opts, path, init2 = {}) {
20
35
  const url = `${opts.apiBaseUrl.replace(/\/$/, "")}${path}`;
21
36
  const headers = {
22
37
  "content-type": "application/json",
23
38
  "x-api-key": opts.apiKey,
24
- ...init.headers ?? {}
39
+ ...init2.headers ?? {}
25
40
  };
26
- const res = await fetch(url, { ...init, headers });
41
+ const res = await fetch(url, { ...init2, headers });
27
42
  const text = await res.text();
28
43
  let body = {};
29
44
  try {
@@ -203,15 +218,15 @@ async function resolveApiKey(provided) {
203
218
  return res.apiKey;
204
219
  }
205
220
  function printConfig(cfg) {
206
- console.log(pc3.dim(" allowed_origins:"));
207
- if (cfg.allowed_origins.length === 0) {
221
+ console.log(pc3.dim(" allowedOrigins:"));
222
+ if (cfg.allowedOrigins.length === 0) {
208
223
  console.log(pc3.dim(" (none \u2014 embeds are disabled until you add an origin)"));
209
224
  } else {
210
- for (const o of cfg.allowed_origins) console.log(pc3.dim(` ${o}`));
225
+ for (const o of cfg.allowedOrigins) console.log(pc3.dim(` ${o}`));
211
226
  }
212
- console.log(pc3.dim(` primary_color: ${cfg.primary_color ?? "(unset)"}`));
213
- console.log(pc3.dim(` logo_url: ${cfg.logo_url ?? "(unset)"}`));
214
- console.log(pc3.dim(` merchant_name: ${cfg.merchant_name ?? "(unset)"}`));
227
+ console.log(pc3.dim(` primaryColor: ${cfg.primaryColor ?? "(unset)"}`));
228
+ console.log(pc3.dim(` logoUrl: ${cfg.logoUrl ?? "(unset)"}`));
229
+ console.log(pc3.dim(` merchantName: ${cfg.merchantName ?? "(unset)"}`));
215
230
  }
216
231
  async function embedConfigShow(options) {
217
232
  const apiKey = await resolveApiKey(options.apiKey);
@@ -236,11 +251,11 @@ async function embedConfigSet(options) {
236
251
  const apiKey = await resolveApiKey(options.apiKey);
237
252
  const body = {};
238
253
  if (options.origins) {
239
- body.allowed_origins = options.origins.split(",").map((s) => s.trim()).filter(Boolean);
254
+ body.allowedOrigins = options.origins.split(",").map((s) => s.trim()).filter(Boolean);
240
255
  }
241
- if (options.primary) body.primary_color = options.primary;
242
- if (options.logo) body.logo_url = options.logo;
243
- if (options.merchantName) body.merchant_name = options.merchantName;
256
+ if (options.primary) body.primaryColor = options.primary;
257
+ if (options.logo) body.logoUrl = options.logo;
258
+ if (options.merchantName) body.merchantName = options.merchantName;
244
259
  if (Object.keys(body).length === 0) {
245
260
  console.error(
246
261
  pc3.red("\u2717") + " No fields provided. Pass --origins, --primary, --logo, or --merchant-name."
@@ -273,10 +288,137 @@ async function embedConfigSet(options) {
273
288
  }
274
289
  }
275
290
 
291
+ // src/sentry.ts
292
+ import { readFileSync } from "fs";
293
+ import { dirname, resolve } from "path";
294
+ import { fileURLToPath } from "url";
295
+ import * as Sentry from "@sentry/node";
296
+ function normalizeKey(key) {
297
+ return key.toLowerCase().replace(/[^a-z0-9]/g, "");
298
+ }
299
+ var DEFAULT_CLI_DSN = "https://519163f0134350c7b5845efee80f457c@o432365.ingest.us.sentry.io/4511401030516736";
300
+ var SENSITIVE_HEADER_KEYS = /* @__PURE__ */ new Set([
301
+ "authorization",
302
+ "cookie",
303
+ "setcookie",
304
+ "xapikey",
305
+ "xthrottleapikey"
306
+ ]);
307
+ var SENSITIVE_EXTRA_KEYS = /* @__PURE__ */ new Set([
308
+ "apikey",
309
+ "accesstoken",
310
+ "authorization",
311
+ "body",
312
+ "data",
313
+ "formdata",
314
+ "payload",
315
+ "rawbody",
316
+ "requestbody",
317
+ "token"
318
+ ]);
319
+ function removeSensitiveKeys(value, sensitiveKeys) {
320
+ if (!value) return value;
321
+ const keptEntries = Object.entries(value).filter(
322
+ ([key]) => !sensitiveKeys.has(normalizeKey(key))
323
+ );
324
+ return Object.fromEntries(keptEntries);
325
+ }
326
+ function isOptInValue(value) {
327
+ if (!value) return false;
328
+ return ["1", "true", "yes", "on"].includes(value.toLowerCase());
329
+ }
330
+ function readCliPackageRelease() {
331
+ try {
332
+ const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), "../package.json");
333
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
334
+ return packageJson.version ? `@usethrottle/cli@${packageJson.version}` : void 0;
335
+ } catch {
336
+ return void 0;
337
+ }
338
+ }
339
+ function isCliSentryEnabled(env = process.env) {
340
+ return isOptInValue(env.THROTTLE_CLI_TELEMETRY) || isOptInValue(env.THROTTLE_CLI_SENTRY_ENABLED);
341
+ }
342
+ function scrubCliSentryEvent(event) {
343
+ if (event.request) {
344
+ delete event.request.data;
345
+ delete event.request.cookies;
346
+ event.request.headers = removeSensitiveKeys(
347
+ event.request.headers,
348
+ SENSITIVE_HEADER_KEYS
349
+ );
350
+ }
351
+ if (event.extra) {
352
+ event.extra = removeSensitiveKeys(event.extra, SENSITIVE_EXTRA_KEYS);
353
+ }
354
+ if (event.user) {
355
+ event.user = event.user.id ? { id: event.user.id } : void 0;
356
+ }
357
+ return event;
358
+ }
359
+ function buildCliSentryOptions(env = process.env) {
360
+ const enabled = isCliSentryEnabled(env);
361
+ return {
362
+ dsn: enabled ? env.THROTTLE_CLI_SENTRY_DSN ?? env.SENTRY_DSN ?? DEFAULT_CLI_DSN : void 0,
363
+ enabled,
364
+ environment: env.SENTRY_ENVIRONMENT ?? env.NODE_ENV ?? "production",
365
+ release: env.SENTRY_RELEASE ?? env.THROTTLE_CLI_RELEASE ?? readCliPackageRelease(),
366
+ sendDefaultPii: false,
367
+ tracesSampleRate: 0,
368
+ beforeSend: scrubCliSentryEvent
369
+ };
370
+ }
371
+ function initCliSentry(env = process.env) {
372
+ if (!isCliSentryEnabled(env) || Sentry.isInitialized()) return;
373
+ Sentry.init(buildCliSentryOptions(env));
374
+ }
375
+ function captureCliException(error) {
376
+ if (!Sentry.isInitialized()) return;
377
+ Sentry.captureException(error);
378
+ }
379
+ async function flushCliSentry(timeout = 2e3) {
380
+ if (!Sentry.isInitialized()) return;
381
+ await Sentry.flush(timeout);
382
+ }
383
+
384
+ // src/banner.ts
385
+ var BRAND_BLUE = "\x1B[38;2;29;86;232m";
386
+ var RESET = "\x1B[0m";
387
+ var DIM = "\x1B[2m";
388
+ var ART = [
389
+ " \u2513 \u2513 \u2513 ",
390
+ " \u2513\u2523 \u2513\u250F\u2513\u254B\u254B\u2503\u250F\u2513 ",
391
+ " \u2517\u251B\u251B\u2517\u251B\u2517\u2517\u2517\u2517 "
392
+ ].join("\n");
393
+ function printBanner(opts) {
394
+ if (process.env.THROTTLE_CLI_NO_BANNER === "1") return;
395
+ if (!process.stdout.isTTY) return;
396
+ const v = opts?.version ? `v${opts.version}` : "";
397
+ process.stderr.write(`${BRAND_BLUE}${ART}${RESET}
398
+ `);
399
+ process.stderr.write(`${BRAND_BLUE}\u25B8${RESET} ${DIM}throttle CLI${v ? " " + v : ""} \xB7 docs https://docs.usethrottle.dev${RESET}
400
+
401
+ `);
402
+ }
403
+
404
+ // src/version.ts
405
+ import { readFileSync as readFileSync2 } from "fs";
406
+ import { fileURLToPath as fileURLToPath2 } from "url";
407
+ var pkg = JSON.parse(
408
+ readFileSync2(fileURLToPath2(new URL("../package.json", import.meta.url)), "utf8")
409
+ );
410
+ var CLI_VERSION = pkg.version;
411
+
276
412
  // src/index.ts
277
413
  var DEFAULT_API_URL = "https://api.usethrottle.dev";
414
+ initCliSentry();
415
+ var args = process.argv.slice(2);
416
+ var isHelpOrVersion = args.length === 0 || args.includes("--help") || args.includes("-h") || args.includes("--version") || args.includes("-V");
417
+ if (!isHelpOrVersion) {
418
+ printBanner({ version: CLI_VERSION });
419
+ }
278
420
  var program = new Command();
279
- program.name("throttle").description("Throttle command-line tool").version("0.2.0");
421
+ program.name("throttle").description("Throttle command-line tool").version(CLI_VERSION);
280
422
  program.command("bc-connect").description("Connect a BigCommerce store to throttle").option("--api <url>", "Throttle API base URL", process.env.THROTTLE_API_URL ?? DEFAULT_API_URL).option("--api-key <sk_*>", "Throttle API key (else $THROTTLE_API_KEY else interactive prompt)").option("--store-hash <hash>", "BigCommerce store hash").option("--access-token <token>", "BigCommerce API token").action(async (opts) => {
281
423
  await bcConnect({
282
424
  apiBaseUrl: opts.api,
@@ -310,8 +452,10 @@ embedConfig.command("set").description("Update the embed config (any combination
310
452
  merchantName: opts.merchantName
311
453
  });
312
454
  });
313
- program.parseAsync().catch((err) => {
455
+ program.parseAsync().catch(async (err) => {
456
+ captureCliException(err);
314
457
  console.error(err);
458
+ await flushCliSentry();
315
459
  process.exit(1);
316
460
  });
317
461
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/commands/bc-connect.ts","../src/lib/throttle-api.ts","../src/commands/bc-disconnect.ts","../src/commands/embed-config.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { bcConnect } from './commands/bc-connect.js';\nimport { bcDisconnect } from './commands/bc-disconnect.js';\nimport { embedConfigShow, embedConfigSet } from './commands/embed-config.js';\n\nconst DEFAULT_API_URL = 'https://api.usethrottle.dev';\n\nconst program = new Command();\n\nprogram.name('throttle').description('Throttle command-line tool').version('0.2.0');\n\nprogram\n .command('bc-connect')\n .description('Connect a BigCommerce store to throttle')\n .option('--api <url>', 'Throttle API base URL', process.env.THROTTLE_API_URL ?? DEFAULT_API_URL)\n .option('--api-key <sk_*>', 'Throttle API key (else $THROTTLE_API_KEY else interactive prompt)')\n .option('--store-hash <hash>', 'BigCommerce store hash')\n .option('--access-token <token>', 'BigCommerce API token')\n .action(async (opts) => {\n await bcConnect({\n apiBaseUrl: opts.api,\n apiKey: opts.apiKey,\n storeHash: opts.storeHash,\n accessToken: opts.accessToken,\n });\n });\n\nprogram\n .command('bc-disconnect [connectionId]')\n .description('Disconnect a BigCommerce store from throttle')\n .option('--api <url>', 'Throttle API base URL', process.env.THROTTLE_API_URL ?? DEFAULT_API_URL)\n .option('--api-key <sk_*>', 'Throttle API key (else $THROTTLE_API_KEY else interactive prompt)')\n .option('-y, --yes', 'Skip confirmation')\n .action(async (connectionId, opts) => {\n await bcDisconnect({\n apiBaseUrl: opts.api,\n apiKey: opts.apiKey,\n connectionId,\n yes: opts.yes,\n });\n });\n\nconst embedConfig = program\n .command('embed-config')\n .description('Manage embed allowlist + branding (origins permitted to host PaymentEmbed/CheckoutEmbed)');\n\nembedConfig\n .command('show')\n .description('Print the current embed config (allowlist + branding)')\n .option('--api <url>', 'Throttle API base URL', process.env.THROTTLE_API_URL ?? DEFAULT_API_URL)\n .option('--api-key <sk_*>', 'Throttle API key (else $THROTTLE_API_KEY else interactive prompt)')\n .action(async (opts) => {\n await embedConfigShow({ apiBaseUrl: opts.api, apiKey: opts.apiKey });\n });\n\nembedConfig\n .command('set')\n .description('Update the embed config (any combination of --origins, --primary, --logo, --merchant-name)')\n .option('--api <url>', 'Throttle API base URL', process.env.THROTTLE_API_URL ?? DEFAULT_API_URL)\n .option('--api-key <sk_*>', 'Throttle API key (else $THROTTLE_API_KEY else interactive prompt)')\n .option(\n '--origins <list>',\n 'Comma-separated parent origins (e.g. https://shop.example.com,https://staging.example.com). No paths, no trailing slash, no wildcards.',\n )\n .option('--primary <hex>', 'Primary brand color in #rrggbb form')\n .option('--logo <url>', 'Logo URL (https)')\n .option('--merchant-name <name>', 'Merchant display name')\n .action(async (opts) => {\n await embedConfigSet({\n apiBaseUrl: opts.api,\n apiKey: opts.apiKey,\n origins: opts.origins,\n primary: opts.primary,\n logo: opts.logo,\n merchantName: opts.merchantName,\n });\n });\n\nprogram.parseAsync().catch((err) => {\n console.error(err);\n process.exit(1);\n});\n","import prompts from 'prompts';\nimport pc from 'picocolors';\nimport { callThrottle, ThrottleApiError } from '../lib/throttle-api.js';\n\nexport interface BcConnectOptions {\n apiBaseUrl: string;\n apiKey?: string;\n storeHash?: string;\n accessToken?: string;\n yes?: boolean;\n}\n\ninterface ConnectResponse {\n connectionId: string;\n storeHash: string;\n webhookRegistrations: number;\n status: string;\n}\n\nexport async function bcConnect(options: BcConnectOptions): Promise<void> {\n const apiKey = options.apiKey ?? process.env.THROTTLE_API_KEY ?? (await promptApiKey());\n const storeHash = options.storeHash ?? (await promptStoreHash());\n const accessToken = options.accessToken ?? (await promptAccessToken());\n\n console.log();\n console.log(pc.dim('Connecting...'));\n\n try {\n const result = await callThrottle<ConnectResponse>(\n { apiBaseUrl: options.apiBaseUrl, apiKey },\n '/api/v1/bigcommerce/connect',\n {\n method: 'POST',\n body: JSON.stringify({ storeHash, accessToken }),\n },\n );\n\n console.log(pc.green('✓') + ` BigCommerce store ${pc.bold(storeHash)} connected`);\n console.log(pc.dim(` Connection id: ${result.connectionId}`));\n console.log(pc.dim(` Webhooks created: ${result.webhookRegistrations}`));\n console.log(pc.dim(` Status: ${result.status}`));\n console.log();\n console.log(pc.dim('Next steps:'));\n console.log(pc.dim(' • Test by placing a sandbox order — throttle should receive a webhook'));\n console.log(pc.dim(' • Run `throttle bc-disconnect` if you ever need to remove this connection'));\n } catch (err) {\n if (err instanceof ThrottleApiError) {\n console.error(pc.red('✗') + ` Failed (${err.code}): ${err.message}`);\n if (err.code === 'invalid_bc_credentials') {\n console.error(\n pc.dim(' Re-check your store hash and API token in your BigCommerce dashboard.'),\n );\n console.error(\n pc.dim(\n ' Store hash: settings → API accounts → store URL contains it (e.g. abc123 in stores/abc123/)',\n ),\n );\n console.error(\n pc.dim(\n ' API token: settings → advanced settings → API accounts → create V2/V3 API token',\n ),\n );\n }\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n}\n\nasync function promptApiKey(): Promise<string> {\n const res = await prompts(\n {\n type: 'password',\n name: 'apiKey',\n message: 'Throttle API key (sk_...)',\n validate: (v: string) =>\n v.startsWith('sk_') && v.length > 20\n ? true\n : 'Must look like sk_… (paste from https://checkout.usethrottle.dev/welcome)',\n },\n { onCancel: () => process.exit(1) },\n );\n return res.apiKey;\n}\n\nasync function promptStoreHash(): Promise<string> {\n const res = await prompts(\n {\n type: 'text',\n name: 'storeHash',\n message: 'BigCommerce store hash (e.g. abc123 from stores/abc123/...)',\n validate: (v: string) => (v.length >= 4 ? true : 'Must be at least 4 characters'),\n },\n { onCancel: () => process.exit(1) },\n );\n return res.storeHash.trim();\n}\n\nasync function promptAccessToken(): Promise<string> {\n console.log(\n pc.dim(\n ' Generate a token at: BigCommerce dashboard → Settings → API accounts → Create API account',\n ),\n );\n console.log(\n pc.dim(\n ' Required scopes: Orders, Customers, Carts, Webhooks (all \"Modify\"); Information & Products (Read-only)',\n ),\n );\n const res = await prompts(\n {\n type: 'password',\n name: 'accessToken',\n message: 'BigCommerce API token',\n validate: (v: string) =>\n v.length >= 10 ? true : 'Token looks too short — paste the full value',\n },\n { onCancel: () => process.exit(1) },\n );\n return res.accessToken;\n}\n","export interface ThrottleApiOptions {\n apiBaseUrl: string;\n apiKey: string;\n}\n\nexport class ThrottleApiError extends Error {\n constructor(\n public code: string,\n message: string,\n public statusCode: number,\n ) {\n super(message);\n this.name = 'ThrottleApiError';\n }\n}\n\ninterface ApiResponse<T> {\n data?: T;\n error?: { code: string; message: string };\n}\n\nexport async function callThrottle<T>(\n opts: ThrottleApiOptions,\n path: string,\n init: RequestInit = {},\n): Promise<T> {\n const url = `${opts.apiBaseUrl.replace(/\\/$/, '')}${path}`;\n const headers = {\n 'content-type': 'application/json',\n 'x-api-key': opts.apiKey,\n ...(init.headers ?? {}),\n };\n const res = await fetch(url, { ...init, headers });\n const text = await res.text();\n let body: ApiResponse<T> = {};\n try {\n body = text ? (JSON.parse(text) as ApiResponse<T>) : {};\n } catch {\n // non-JSON response (HTML error page, gateway timeout text, etc.)\n }\n\n if (!res.ok) {\n const code = body.error?.code ?? `http_${res.status}`;\n const message =\n body.error?.message ?? `Request failed (${res.status}): ${text.slice(0, 120)}`;\n throw new ThrottleApiError(code, message, res.status);\n }\n\n return (body.data ?? body) as T;\n}\n","import prompts from 'prompts';\nimport pc from 'picocolors';\nimport { callThrottle, ThrottleApiError } from '../lib/throttle-api.js';\n\nexport interface BcDisconnectOptions {\n apiBaseUrl: string;\n apiKey?: string;\n connectionId?: string;\n yes?: boolean;\n}\n\nexport async function bcDisconnect(options: BcDisconnectOptions): Promise<void> {\n const apiKey = options.apiKey ?? process.env.THROTTLE_API_KEY ?? (await promptApiKey());\n const connectionId = options.connectionId ?? (await promptConnectionId());\n\n if (!options.yes) {\n const confirm = await prompts(\n {\n type: 'confirm',\n name: 'ok',\n message: `Disconnect ${connectionId}? (will be hard-deleted in 90 days)`,\n initial: false,\n },\n { onCancel: () => process.exit(1) },\n );\n if (!confirm.ok) {\n console.log(pc.dim('Aborted.'));\n return;\n }\n }\n\n try {\n await callThrottle(\n { apiBaseUrl: options.apiBaseUrl, apiKey },\n `/api/v1/bigcommerce/connections/${encodeURIComponent(connectionId)}`,\n { method: 'DELETE' },\n );\n console.log(pc.green('✓') + ` Disconnected ${connectionId}`);\n } catch (err) {\n if (err instanceof ThrottleApiError) {\n console.error(pc.red('✗') + ` Failed (${err.code}): ${err.message}`);\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n}\n\nasync function promptApiKey(): Promise<string> {\n const res = await prompts(\n { type: 'password', name: 'apiKey', message: 'Throttle API key (sk_...)' },\n { onCancel: () => process.exit(1) },\n );\n return res.apiKey;\n}\n\nasync function promptConnectionId(): Promise<string> {\n const res = await prompts(\n { type: 'text', name: 'id', message: 'Connection id (conn_...)' },\n { onCancel: () => process.exit(1) },\n );\n return res.id.trim();\n}\n","import prompts from 'prompts';\nimport pc from 'picocolors';\nimport { callThrottle, ThrottleApiError } from '../lib/throttle-api.js';\n\nexport interface EmbedConfigCommonOptions {\n apiBaseUrl: string;\n apiKey?: string;\n}\n\nexport interface EmbedConfigSetOptions extends EmbedConfigCommonOptions {\n origins?: string;\n primary?: string;\n logo?: string;\n merchantName?: string;\n}\n\ninterface EmbedConfigData {\n allowed_origins: string[];\n primary_color: string | null;\n logo_url: string | null;\n merchant_name: string | null;\n}\n\nasync function resolveApiKey(provided?: string): Promise<string> {\n if (provided) return provided;\n if (process.env.THROTTLE_API_KEY) return process.env.THROTTLE_API_KEY;\n const res = await prompts(\n {\n type: 'password',\n name: 'apiKey',\n message: 'Throttle API key (sk_...)',\n validate: (v: string) =>\n v.startsWith('sk_') && v.length > 20 ? true : 'Must look like sk_… (paste from your dashboard)',\n },\n { onCancel: () => process.exit(1) },\n );\n return res.apiKey;\n}\n\nfunction printConfig(cfg: EmbedConfigData) {\n console.log(pc.dim(' allowed_origins:'));\n if (cfg.allowed_origins.length === 0) {\n console.log(pc.dim(' (none — embeds are disabled until you add an origin)'));\n } else {\n for (const o of cfg.allowed_origins) console.log(pc.dim(` ${o}`));\n }\n console.log(pc.dim(` primary_color: ${cfg.primary_color ?? '(unset)'}`));\n console.log(pc.dim(` logo_url: ${cfg.logo_url ?? '(unset)'}`));\n console.log(pc.dim(` merchant_name: ${cfg.merchant_name ?? '(unset)'}`));\n}\n\nexport async function embedConfigShow(options: EmbedConfigCommonOptions): Promise<void> {\n const apiKey = await resolveApiKey(options.apiKey);\n try {\n const data = await callThrottle<EmbedConfigData>(\n { apiBaseUrl: options.apiBaseUrl, apiKey },\n '/api/v1/embed-config',\n { method: 'GET' },\n );\n console.log(pc.green('✓') + ' Current embed config');\n printConfig(data);\n } catch (err) {\n if (err instanceof ThrottleApiError) {\n console.error(pc.red('✗') + ` Failed (${err.code}): ${err.message}`);\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n}\n\nexport async function embedConfigSet(options: EmbedConfigSetOptions): Promise<void> {\n const apiKey = await resolveApiKey(options.apiKey);\n\n const body: Record<string, unknown> = {};\n if (options.origins) {\n body.allowed_origins = options.origins\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n }\n if (options.primary) body.primary_color = options.primary;\n if (options.logo) body.logo_url = options.logo;\n if (options.merchantName) body.merchant_name = options.merchantName;\n\n if (Object.keys(body).length === 0) {\n console.error(\n pc.red('✗') + ' No fields provided. Pass --origins, --primary, --logo, or --merchant-name.',\n );\n process.exitCode = 1;\n return;\n }\n\n try {\n const data = await callThrottle<EmbedConfigData>(\n { apiBaseUrl: options.apiBaseUrl, apiKey },\n '/api/v1/embed-config',\n { method: 'PUT', body: JSON.stringify(body) },\n );\n console.log(pc.green('✓') + ' Embed config updated');\n printConfig(data);\n } catch (err) {\n if (err instanceof ThrottleApiError) {\n console.error(pc.red('✗') + ` Failed (${err.code}): ${err.message}`);\n if (err.code === 'invalid_origin') {\n console.error(\n pc.dim(\n ' Origins must be https://host[:port]. No paths, no trailing slash, no wildcards.',\n ),\n );\n }\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;;;ACAxB,OAAO,aAAa;AACpB,OAAO,QAAQ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CAA8C,EAC1D,OAAO,eAAe,yBAAyB,QAAQ,IAAI,oBAAoB,eAAe,EAC9F,OAAO,oBAAoB,mEAAmE,EAC9F,OAAO,aAAa,mBAAmB,EACvC,OAAO,OAAO,cAAc,SAAS;AACpC,QAAM,aAAa;AAAA,IACjB,YAAY,KAAK;AAAA,IACjB,QAAQ,KAAK;AAAA,IACb;AAAA,IACA,KAAK,KAAK;AAAA,EACZ,CAAC;AACH,CAAC;AAEH,IAAM,cAAc,QACjB,QAAQ,cAAc,EACtB,YAAY,0FAA0F;AAEzG,YACG,QAAQ,MAAM,EACd,YAAY,uDAAuD,EACnE,OAAO,eAAe,yBAAyB,QAAQ,IAAI,oBAAoB,eAAe,EAC9F,OAAO,oBAAoB,mEAAmE,EAC9F,OAAO,OAAO,SAAS;AACtB,QAAM,gBAAgB,EAAE,YAAY,KAAK,KAAK,QAAQ,KAAK,OAAO,CAAC;AACrE,CAAC;AAEH,YACG,QAAQ,KAAK,EACb,YAAY,4FAA4F,EACxG,OAAO,eAAe,yBAAyB,QAAQ,IAAI,oBAAoB,eAAe,EAC9F,OAAO,oBAAoB,mEAAmE,EAC9F;AAAA,EACC;AAAA,EACA;AACF,EACC,OAAO,mBAAmB,qCAAqC,EAC/D,OAAO,gBAAgB,kBAAkB,EACzC,OAAO,0BAA0B,uBAAuB,EACxD,OAAO,OAAO,SAAS;AACtB,QAAM,eAAe;AAAA,IACnB,YAAY,KAAK;AAAA,IACjB,QAAQ,KAAK;AAAA,IACb,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,IACd,MAAM,KAAK;AAAA,IACX,cAAc,KAAK;AAAA,EACrB,CAAC;AACH,CAAC;AAEH,QAAQ,WAAW,EAAE,MAAM,CAAC,QAAQ;AAClC,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["prompts","pc","promptApiKey","prompts","pc","prompts","pc","prompts","pc"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/commands/bc-connect.ts","../../errors/dist/index.js","../src/lib/throttle-api.ts","../src/commands/bc-disconnect.ts","../src/commands/embed-config.ts","../src/sentry.ts","../src/banner.ts","../src/version.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { bcConnect } from './commands/bc-connect.js';\nimport { bcDisconnect } from './commands/bc-disconnect.js';\nimport { embedConfigShow, embedConfigSet } from './commands/embed-config.js';\nimport { captureCliException, flushCliSentry, initCliSentry } from './sentry.js';\nimport { printBanner } from './banner.js';\nimport { CLI_VERSION } from './version.js';\n\nconst DEFAULT_API_URL = 'https://api.usethrottle.dev';\n\ninitCliSentry();\n\nconst args = process.argv.slice(2);\nconst isHelpOrVersion =\n args.length === 0 ||\n args.includes('--help') ||\n args.includes('-h') ||\n args.includes('--version') ||\n args.includes('-V');\n\nif (!isHelpOrVersion) {\n printBanner({ version: CLI_VERSION });\n}\n\nconst program = new Command();\n\nprogram.name('throttle').description('Throttle command-line tool').version(CLI_VERSION);\n\nprogram\n .command('bc-connect')\n .description('Connect a BigCommerce store to throttle')\n .option('--api <url>', 'Throttle API base URL', process.env.THROTTLE_API_URL ?? DEFAULT_API_URL)\n .option('--api-key <sk_*>', 'Throttle API key (else $THROTTLE_API_KEY else interactive prompt)')\n .option('--store-hash <hash>', 'BigCommerce store hash')\n .option('--access-token <token>', 'BigCommerce API token')\n .action(async (opts) => {\n await bcConnect({\n apiBaseUrl: opts.api,\n apiKey: opts.apiKey,\n storeHash: opts.storeHash,\n accessToken: opts.accessToken,\n });\n });\n\nprogram\n .command('bc-disconnect [connectionId]')\n .description('Disconnect a BigCommerce store from throttle')\n .option('--api <url>', 'Throttle API base URL', process.env.THROTTLE_API_URL ?? DEFAULT_API_URL)\n .option('--api-key <sk_*>', 'Throttle API key (else $THROTTLE_API_KEY else interactive prompt)')\n .option('-y, --yes', 'Skip confirmation')\n .action(async (connectionId, opts) => {\n await bcDisconnect({\n apiBaseUrl: opts.api,\n apiKey: opts.apiKey,\n connectionId,\n yes: opts.yes,\n });\n });\n\nconst embedConfig = program\n .command('embed-config')\n .description('Manage embed allowlist + branding (origins permitted to host PaymentEmbed/CheckoutEmbed)');\n\nembedConfig\n .command('show')\n .description('Print the current embed config (allowlist + branding)')\n .option('--api <url>', 'Throttle API base URL', process.env.THROTTLE_API_URL ?? DEFAULT_API_URL)\n .option('--api-key <sk_*>', 'Throttle API key (else $THROTTLE_API_KEY else interactive prompt)')\n .action(async (opts) => {\n await embedConfigShow({ apiBaseUrl: opts.api, apiKey: opts.apiKey });\n });\n\nembedConfig\n .command('set')\n .description('Update the embed config (any combination of --origins, --primary, --logo, --merchant-name)')\n .option('--api <url>', 'Throttle API base URL', process.env.THROTTLE_API_URL ?? DEFAULT_API_URL)\n .option('--api-key <sk_*>', 'Throttle API key (else $THROTTLE_API_KEY else interactive prompt)')\n .option(\n '--origins <list>',\n 'Comma-separated parent origins (e.g. https://shop.example.com,https://staging.example.com). No paths, no trailing slash, no wildcards.',\n )\n .option('--primary <hex>', 'Primary brand color in #rrggbb form')\n .option('--logo <url>', 'Logo URL (https)')\n .option('--merchant-name <name>', 'Merchant display name')\n .action(async (opts) => {\n await embedConfigSet({\n apiBaseUrl: opts.api,\n apiKey: opts.apiKey,\n origins: opts.origins,\n primary: opts.primary,\n logo: opts.logo,\n merchantName: opts.merchantName,\n });\n });\n\nprogram.parseAsync().catch(async (err) => {\n captureCliException(err);\n console.error(err);\n await flushCliSentry();\n process.exit(1);\n});\n","import prompts from 'prompts';\nimport pc from 'picocolors';\nimport { callThrottle, ThrottleApiError } from '../lib/throttle-api.js';\n\nexport interface BcConnectOptions {\n apiBaseUrl: string;\n apiKey?: string;\n storeHash?: string;\n accessToken?: string;\n yes?: boolean;\n}\n\ninterface ConnectResponse {\n connectionId: string;\n storeHash: string;\n webhookRegistrations: number;\n status: string;\n}\n\nexport async function bcConnect(options: BcConnectOptions): Promise<void> {\n const apiKey = options.apiKey ?? process.env.THROTTLE_API_KEY ?? (await promptApiKey());\n const storeHash = options.storeHash ?? (await promptStoreHash());\n const accessToken = options.accessToken ?? (await promptAccessToken());\n\n console.log();\n console.log(pc.dim('Connecting...'));\n\n try {\n const result = await callThrottle<ConnectResponse>(\n { apiBaseUrl: options.apiBaseUrl, apiKey },\n '/api/v1/bigcommerce/connect',\n {\n method: 'POST',\n body: JSON.stringify({ storeHash, accessToken }),\n },\n );\n\n console.log(pc.green('✓') + ` BigCommerce store ${pc.bold(storeHash)} connected`);\n console.log(pc.dim(` Connection id: ${result.connectionId}`));\n console.log(pc.dim(` Webhooks created: ${result.webhookRegistrations}`));\n console.log(pc.dim(` Status: ${result.status}`));\n console.log();\n console.log(pc.dim('Next steps:'));\n console.log(pc.dim(' • Test by placing a sandbox order — throttle should receive a webhook'));\n console.log(pc.dim(' • Run `throttle bc-disconnect` if you ever need to remove this connection'));\n } catch (err) {\n if (err instanceof ThrottleApiError) {\n console.error(pc.red('✗') + ` Failed (${err.code}): ${err.message}`);\n if (err.code === 'invalid_bc_credentials') {\n console.error(\n pc.dim(' Re-check your store hash and API token in your BigCommerce dashboard.'),\n );\n console.error(\n pc.dim(\n ' Store hash: settings → API accounts → store URL contains it (e.g. abc123 in stores/abc123/)',\n ),\n );\n console.error(\n pc.dim(\n ' API token: settings → advanced settings → API accounts → create V2/V3 API token',\n ),\n );\n }\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n}\n\nasync function promptApiKey(): Promise<string> {\n const res = await prompts(\n {\n type: 'password',\n name: 'apiKey',\n message: 'Throttle API key (sk_...)',\n validate: (v: string) =>\n v.startsWith('sk_') && v.length > 20\n ? true\n : 'Must look like sk_… (paste from https://checkout.usethrottle.dev/welcome)',\n },\n { onCancel: () => process.exit(1) },\n );\n return res.apiKey;\n}\n\nasync function promptStoreHash(): Promise<string> {\n const res = await prompts(\n {\n type: 'text',\n name: 'storeHash',\n message: 'BigCommerce store hash (e.g. abc123 from stores/abc123/...)',\n validate: (v: string) => (v.length >= 4 ? true : 'Must be at least 4 characters'),\n },\n { onCancel: () => process.exit(1) },\n );\n return res.storeHash.trim();\n}\n\nasync function promptAccessToken(): Promise<string> {\n console.log(\n pc.dim(\n ' Generate a token at: BigCommerce dashboard → Settings → API accounts → Create API account',\n ),\n );\n console.log(\n pc.dim(\n ' Required scopes: Orders, Customers, Carts, Webhooks (all \"Modify\"); Information & Products (Read-only)',\n ),\n );\n const res = await prompts(\n {\n type: 'password',\n name: 'accessToken',\n message: 'BigCommerce API token',\n validate: (v: string) =>\n v.length >= 10 ? true : 'Token looks too short — paste the full value',\n },\n { onCancel: () => process.exit(1) },\n );\n return res.accessToken;\n}\n","// src/index.ts\nvar ThrottleError = class extends Error {\n code;\n statusCode;\n details;\n body;\n constructor(args) {\n super(args.message);\n this.name = \"ThrottleError\";\n this.code = args.code;\n this.statusCode = args.statusCode;\n this.details = args.details;\n this.body = args.body;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n};\nfunction isThrottleError(value) {\n return value instanceof ThrottleError;\n}\nexport {\n ThrottleError,\n isThrottleError\n};\n","import { ThrottleError } from '@usethrottle/errors';\n\nexport interface ThrottleApiOptions {\n apiBaseUrl: string;\n apiKey: string;\n}\n\n/**\n * Thrown on a non-2xx response from the Throttle API.\n *\n * Extends the shared {@link ThrottleError} so it carries the same\n * `code` / `statusCode` shape as every other Throttle SDK.\n */\nexport class ThrottleApiError extends ThrottleError {\n constructor(code: string, message: string, statusCode: number) {\n super({ code, message, statusCode });\n this.name = 'ThrottleApiError';\n }\n}\n\nexport { ThrottleError, isThrottleError } from '@usethrottle/errors';\n\ninterface ApiResponse<T> {\n data?: T;\n error?: { code: string; message: string };\n}\n\nexport async function callThrottle<T>(\n opts: ThrottleApiOptions,\n path: string,\n init: RequestInit = {},\n): Promise<T> {\n const url = `${opts.apiBaseUrl.replace(/\\/$/, '')}${path}`;\n const headers = {\n 'content-type': 'application/json',\n 'x-api-key': opts.apiKey,\n ...(init.headers ?? {}),\n };\n const res = await fetch(url, { ...init, headers });\n const text = await res.text();\n let body: ApiResponse<T> = {};\n try {\n body = text ? (JSON.parse(text) as ApiResponse<T>) : {};\n } catch {\n // non-JSON response (HTML error page, gateway timeout text, etc.)\n }\n\n if (!res.ok) {\n const code = body.error?.code ?? `http_${res.status}`;\n const message =\n body.error?.message ?? `Request failed (${res.status}): ${text.slice(0, 120)}`;\n throw new ThrottleApiError(code, message, res.status);\n }\n\n return (body.data ?? body) as T;\n}\n","import prompts from 'prompts';\nimport pc from 'picocolors';\nimport { callThrottle, ThrottleApiError } from '../lib/throttle-api.js';\n\nexport interface BcDisconnectOptions {\n apiBaseUrl: string;\n apiKey?: string;\n connectionId?: string;\n yes?: boolean;\n}\n\nexport async function bcDisconnect(options: BcDisconnectOptions): Promise<void> {\n const apiKey = options.apiKey ?? process.env.THROTTLE_API_KEY ?? (await promptApiKey());\n const connectionId = options.connectionId ?? (await promptConnectionId());\n\n if (!options.yes) {\n const confirm = await prompts(\n {\n type: 'confirm',\n name: 'ok',\n message: `Disconnect ${connectionId}? (will be hard-deleted in 90 days)`,\n initial: false,\n },\n { onCancel: () => process.exit(1) },\n );\n if (!confirm.ok) {\n console.log(pc.dim('Aborted.'));\n return;\n }\n }\n\n try {\n await callThrottle(\n { apiBaseUrl: options.apiBaseUrl, apiKey },\n `/api/v1/bigcommerce/connections/${encodeURIComponent(connectionId)}`,\n { method: 'DELETE' },\n );\n console.log(pc.green('✓') + ` Disconnected ${connectionId}`);\n } catch (err) {\n if (err instanceof ThrottleApiError) {\n console.error(pc.red('✗') + ` Failed (${err.code}): ${err.message}`);\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n}\n\nasync function promptApiKey(): Promise<string> {\n const res = await prompts(\n { type: 'password', name: 'apiKey', message: 'Throttle API key (sk_...)' },\n { onCancel: () => process.exit(1) },\n );\n return res.apiKey;\n}\n\nasync function promptConnectionId(): Promise<string> {\n const res = await prompts(\n { type: 'text', name: 'id', message: 'Connection id (conn_...)' },\n { onCancel: () => process.exit(1) },\n );\n return res.id.trim();\n}\n","import prompts from 'prompts';\nimport pc from 'picocolors';\nimport { callThrottle, ThrottleApiError } from '../lib/throttle-api.js';\n\nexport interface EmbedConfigCommonOptions {\n apiBaseUrl: string;\n apiKey?: string;\n}\n\nexport interface EmbedConfigSetOptions extends EmbedConfigCommonOptions {\n origins?: string;\n primary?: string;\n logo?: string;\n merchantName?: string;\n}\n\ninterface EmbedConfigData {\n allowedOrigins: string[];\n primaryColor: string | null;\n logoUrl: string | null;\n merchantName: string | null;\n}\n\nasync function resolveApiKey(provided?: string): Promise<string> {\n if (provided) return provided;\n if (process.env.THROTTLE_API_KEY) return process.env.THROTTLE_API_KEY;\n const res = await prompts(\n {\n type: 'password',\n name: 'apiKey',\n message: 'Throttle API key (sk_...)',\n validate: (v: string) =>\n v.startsWith('sk_') && v.length > 20 ? true : 'Must look like sk_… (paste from your dashboard)',\n },\n { onCancel: () => process.exit(1) },\n );\n return res.apiKey;\n}\n\nfunction printConfig(cfg: EmbedConfigData) {\n console.log(pc.dim(' allowedOrigins:'));\n if (cfg.allowedOrigins.length === 0) {\n console.log(pc.dim(' (none — embeds are disabled until you add an origin)'));\n } else {\n for (const o of cfg.allowedOrigins) console.log(pc.dim(` ${o}`));\n }\n console.log(pc.dim(` primaryColor: ${cfg.primaryColor ?? '(unset)'}`));\n console.log(pc.dim(` logoUrl: ${cfg.logoUrl ?? '(unset)'}`));\n console.log(pc.dim(` merchantName: ${cfg.merchantName ?? '(unset)'}`));\n}\n\nexport async function embedConfigShow(options: EmbedConfigCommonOptions): Promise<void> {\n const apiKey = await resolveApiKey(options.apiKey);\n try {\n const data = await callThrottle<EmbedConfigData>(\n { apiBaseUrl: options.apiBaseUrl, apiKey },\n '/api/v1/embed-config',\n { method: 'GET' },\n );\n console.log(pc.green('✓') + ' Current embed config');\n printConfig(data);\n } catch (err) {\n if (err instanceof ThrottleApiError) {\n console.error(pc.red('✗') + ` Failed (${err.code}): ${err.message}`);\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n}\n\nexport async function embedConfigSet(options: EmbedConfigSetOptions): Promise<void> {\n const apiKey = await resolveApiKey(options.apiKey);\n\n const body: Record<string, unknown> = {};\n if (options.origins) {\n body.allowedOrigins = options.origins\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n }\n if (options.primary) body.primaryColor = options.primary;\n if (options.logo) body.logoUrl = options.logo;\n if (options.merchantName) body.merchantName = options.merchantName;\n\n if (Object.keys(body).length === 0) {\n console.error(\n pc.red('✗') + ' No fields provided. Pass --origins, --primary, --logo, or --merchant-name.',\n );\n process.exitCode = 1;\n return;\n }\n\n try {\n const data = await callThrottle<EmbedConfigData>(\n { apiBaseUrl: options.apiBaseUrl, apiKey },\n '/api/v1/embed-config',\n { method: 'PUT', body: JSON.stringify(body) },\n );\n console.log(pc.green('✓') + ' Embed config updated');\n printConfig(data);\n } catch (err) {\n if (err instanceof ThrottleApiError) {\n console.error(pc.red('✗') + ` Failed (${err.code}): ${err.message}`);\n if (err.code === 'invalid_origin') {\n console.error(\n pc.dim(\n ' Origins must be https://host[:port]. No paths, no trailing slash, no wildcards.',\n ),\n );\n }\n process.exitCode = 1;\n return;\n }\n throw err;\n }\n}\n","import { readFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport * as Sentry from '@sentry/node';\nimport type { Event, NodeOptions } from '@sentry/node';\n\ntype Env = Record<string, string | undefined>;\ntype EventHeaders = NonNullable<Event['request']>['headers'];\n\nfunction normalizeKey(key: string): string {\n return key.toLowerCase().replace(/[^a-z0-9]/g, '');\n}\n\nconst DEFAULT_CLI_DSN =\n 'https://519163f0134350c7b5845efee80f457c@o432365.ingest.us.sentry.io/4511401030516736';\n\nconst SENSITIVE_HEADER_KEYS = new Set([\n 'authorization',\n 'cookie',\n 'setcookie',\n 'xapikey',\n 'xthrottleapikey',\n]);\n\nconst SENSITIVE_EXTRA_KEYS = new Set([\n 'apikey',\n 'accesstoken',\n 'authorization',\n 'body',\n 'data',\n 'formdata',\n 'payload',\n 'rawbody',\n 'requestbody',\n 'token',\n]);\n\nfunction removeSensitiveKeys(\n value: Record<string, unknown> | undefined,\n sensitiveKeys: ReadonlySet<string>,\n): Record<string, unknown> | undefined {\n if (!value) return value;\n\n const keptEntries = Object.entries(value).filter(\n ([key]) => !sensitiveKeys.has(normalizeKey(key)),\n );\n return Object.fromEntries(keptEntries);\n}\n\nfunction isOptInValue(value: string | undefined): boolean {\n if (!value) return false;\n return ['1', 'true', 'yes', 'on'].includes(value.toLowerCase());\n}\n\nfunction readCliPackageRelease(): string | undefined {\n try {\n const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../package.json');\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as { version?: string };\n return packageJson.version ? `@usethrottle/cli@${packageJson.version}` : undefined;\n } catch {\n return undefined;\n }\n}\n\nexport function isCliSentryEnabled(env: Env = process.env): boolean {\n return isOptInValue(env.THROTTLE_CLI_TELEMETRY) || isOptInValue(env.THROTTLE_CLI_SENTRY_ENABLED);\n}\n\nexport function scrubCliSentryEvent<T extends Event>(event: T): T {\n if (event.request) {\n delete event.request.data;\n delete event.request.cookies;\n event.request.headers = removeSensitiveKeys(\n event.request.headers as Record<string, unknown> | undefined,\n SENSITIVE_HEADER_KEYS,\n ) as EventHeaders;\n }\n\n if (event.extra) {\n event.extra = removeSensitiveKeys(event.extra, SENSITIVE_EXTRA_KEYS);\n }\n\n if (event.user) {\n event.user = event.user.id ? { id: event.user.id } : undefined;\n }\n\n return event;\n}\n\nexport function buildCliSentryOptions(env: Env = process.env): NodeOptions {\n const enabled = isCliSentryEnabled(env);\n\n return {\n dsn: enabled ? (env.THROTTLE_CLI_SENTRY_DSN ?? env.SENTRY_DSN ?? DEFAULT_CLI_DSN) : undefined,\n enabled,\n environment: env.SENTRY_ENVIRONMENT ?? env.NODE_ENV ?? 'production',\n release: env.SENTRY_RELEASE ?? env.THROTTLE_CLI_RELEASE ?? readCliPackageRelease(),\n sendDefaultPii: false,\n tracesSampleRate: 0,\n beforeSend: scrubCliSentryEvent,\n };\n}\n\nexport function initCliSentry(env: Env = process.env): void {\n if (!isCliSentryEnabled(env) || Sentry.isInitialized()) return;\n\n Sentry.init(buildCliSentryOptions(env));\n}\n\nexport function captureCliException(error: unknown): void {\n if (!Sentry.isInitialized()) return;\n Sentry.captureException(error);\n}\n\nexport async function flushCliSentry(timeout = 2000): Promise<void> {\n if (!Sentry.isInitialized()) return;\n await Sentry.flush(timeout);\n}\n","const BRAND_BLUE = '\\x1b[38;2;29;86;232m';\nconst RESET = '\\x1b[0m';\nconst DIM = '\\x1b[2m';\n\nconst ART = [\n ' ┓ ┓ ┓ ',\n ' ┓┣ ┓┏┓╋╋┃┏┓ ',\n ' ┗┛┛┗┛┗┗┗┗ ',\n].join('\\n');\n\nexport function printBanner(opts?: { version?: string }): void {\n if (process.env.THROTTLE_CLI_NO_BANNER === '1') return;\n if (!process.stdout.isTTY) return;\n const v = opts?.version ? `v${opts.version}` : '';\n process.stderr.write(`${BRAND_BLUE}${ART}${RESET}\\n`);\n process.stderr.write(`${BRAND_BLUE}▸${RESET} ${DIM}throttle CLI${v ? ' ' + v : ''} · docs https://docs.usethrottle.dev${RESET}\\n\\n`);\n}\n","import { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\n\n// Read the version from package.json at runtime, resolved relative to this\n// module, so the binary's reported version always matches the published\n// package and can never drift from a hardcoded constant.\n// - bundled: dist/cli.js -> ../package.json = packages/cli/package.json\n// - vitest: src/version.ts -> ../package.json = packages/cli/package.json\nconst pkg = JSON.parse(\n readFileSync(fileURLToPath(new URL('../package.json', import.meta.url)), 'utf8'),\n) as { version: string };\n\nexport const CLI_VERSION: string = pkg.version;\n"],"mappings":";;;AAAA,SAAS,eAAe;;;ACAxB,OAAO,aAAa;AACpB,OAAO,QAAQ;;;ACAf,IAAI,gBAAgB,cAAc,MAAM;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAYA,OAAM;AAChB,UAAMA,MAAK,OAAO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MAAM,EACd,YAAY,uDAAuD,EACnE,OAAO,eAAe,yBAAyB,QAAQ,IAAI,oBAAoB,eAAe,EAC9F,OAAO,oBAAoB,mEAAmE,EAC9F,OAAO,OAAO,SAAS;AACtB,QAAM,gBAAgB,EAAE,YAAY,KAAK,KAAK,QAAQ,KAAK,OAAO,CAAC;AACrE,CAAC;AAEH,YACG,QAAQ,KAAK,EACb,YAAY,4FAA4F,EACxG,OAAO,eAAe,yBAAyB,QAAQ,IAAI,oBAAoB,eAAe,EAC9F,OAAO,oBAAoB,mEAAmE,EAC9F;AAAA,EACC;AAAA,EACA;AACF,EACC,OAAO,mBAAmB,qCAAqC,EAC/D,OAAO,gBAAgB,kBAAkB,EACzC,OAAO,0BAA0B,uBAAuB,EACxD,OAAO,OAAO,SAAS;AACtB,QAAM,eAAe;AAAA,IACnB,YAAY,KAAK;AAAA,IACjB,QAAQ,KAAK;AAAA,IACb,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,IACd,MAAM,KAAK;AAAA,IACX,cAAc,KAAK;AAAA,EACrB,CAAC;AACH,CAAC;AAEH,QAAQ,WAAW,EAAE,MAAM,OAAO,QAAQ;AACxC,sBAAoB,GAAG;AACvB,UAAQ,MAAM,GAAG;AACjB,QAAM,eAAe;AACrB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["args","init","prompts","pc","promptApiKey","prompts","pc","prompts","pc","prompts","pc","readFileSync","fileURLToPath"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usethrottle/cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Throttle command-line tool — connect your BigCommerce store, manage embed config, manage your account",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,6 +11,7 @@
11
11
  "README.md"
12
12
  ],
13
13
  "dependencies": {
14
+ "@sentry/node": "^10.53.1",
14
15
  "commander": "^12.1.0",
15
16
  "picocolors": "^1.1.0",
16
17
  "prompts": "^2.4.2"
@@ -20,7 +21,8 @@
20
21
  "@types/prompts": "^2.4.0",
21
22
  "tsup": "^8.0.0",
22
23
  "typescript": "^5.7.0",
23
- "vitest": "^2.1.9"
24
+ "vitest": "^2.1.9",
25
+ "@usethrottle/errors": "^1.0.0"
24
26
  },
25
27
  "publishConfig": {
26
28
  "access": "public"