@hasna/accounts 0.1.9 → 0.1.10

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 (2) hide show
  1. package/dist/cli.js +21 -15
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -12259,7 +12259,7 @@ var require_es5 = __commonJS((exports, module) => {
12259
12259
 
12260
12260
  // node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js
12261
12261
  var require_client2 = __commonJS((exports) => {
12262
- var __dirname = "/tmp/open-accounts-events-release-384975/node_modules/@aws-sdk/core/dist-cjs/submodules/client";
12262
+ var __dirname = "/tmp/hasna-events-refresh-1781608411540/open-accounts/node_modules/@aws-sdk/core/dist-cjs/submodules/client";
12263
12263
  var retry = require_retry();
12264
12264
  var protocols = require_protocols();
12265
12265
  var lambdaInvokeStore = require_invoke_store();
@@ -37381,9 +37381,15 @@ function print(value, json, text) {
37381
37381
  else
37382
37382
  console.log(text);
37383
37383
  }
37384
+ function hasJsonOption(options) {
37385
+ return Boolean(options?.json || options?.opts?.().json || options?.optsWithGlobals?.().json || options?.parent?.opts?.().json || options?.parent?.optsWithGlobals?.().json);
37386
+ }
37387
+ function wantsJson(actionOptions, command) {
37388
+ return hasJsonOption(actionOptions) || hasJsonOption(command);
37389
+ }
37384
37390
  function registerWebhookCommands(program2, options) {
37385
37391
  const webhooks = program2.command(options.webhooksCommandName ?? "webhooks").description("Manage Hasna event webhook subscriptions");
37386
- webhooks.command("add").description("Add or replace a webhook or command subscription").argument("<target>", "Webhook URL or command binary").requiredOption("--id <id>", "Subscription/channel identifier").option("--transport <kind>", "Transport kind: webhook or command", "webhook").option("--name <name>", "Display name").option("--type <pattern>", "Event type filter, e.g. todos.task.*").option("--source <pattern>", "Event source filter").option("--subject <pattern>", "Event subject filter").option("--severity <pattern>", "Event severity filter").option("--secret <secret>", "Webhook HMAC secret").option("--header <name=value...>", "Webhook header", collectValues, []).option("--arg <arg...>", "Command argument", collectValues, []).option("--timeout-ms <ms>", "Transport timeout in milliseconds", parseNumber).option("--retry-attempts <n>", "Maximum delivery attempts", parseNumber).option("--retry-backoff-ms <ms>", "Initial retry backoff in milliseconds", parseNumber).option("--redact <path...>", "Event field path to redact before delivery", collectValues, []).option("--disabled", "Create channel disabled", false).option("-j, --json", "Print JSON output", false).action(async (target, actionOptions) => {
37392
+ webhooks.command("add").description("Add or replace a webhook or command subscription").argument("<target>", "Webhook URL or command binary").requiredOption("--id <id>", "Subscription/channel identifier").option("--transport <kind>", "Transport kind: webhook or command", "webhook").option("--name <name>", "Display name").option("--type <pattern>", "Event type filter, e.g. todos.task.*").option("--source <pattern>", "Event source filter").option("--subject <pattern>", "Event subject filter").option("--severity <pattern>", "Event severity filter").option("--secret <secret>", "Webhook HMAC secret").option("--header <name=value...>", "Webhook header", collectValues, []).option("--arg <arg...>", "Command argument", collectValues, []).option("--timeout-ms <ms>", "Transport timeout in milliseconds", parseNumber).option("--retry-attempts <n>", "Maximum delivery attempts", parseNumber).option("--retry-backoff-ms <ms>", "Initial retry backoff in milliseconds", parseNumber).option("--redact <path...>", "Event field path to redact before delivery", collectValues, []).option("--disabled", "Create channel disabled", false).option("-j, --json", "Print JSON output", false).action(async (target, actionOptions, command) => {
37387
37393
  const timestamp = new Date().toISOString();
37388
37394
  const channel = {
37389
37395
  id: actionOptions.id,
@@ -37404,11 +37410,11 @@ function registerWebhookCommands(program2, options) {
37404
37410
  throw new Error(`Transport ${actionOptions.transport} is reserved for future use and cannot be added yet`);
37405
37411
  }
37406
37412
  const saved = await createClient(options).addChannel(channel);
37407
- print(sanitizeChannelForOutput(saved), Boolean(actionOptions.json), `Added ${saved.transport} channel ${saved.id}`);
37413
+ print(sanitizeChannelForOutput(saved), wantsJson(actionOptions, command), `Added ${saved.transport} channel ${saved.id}`);
37408
37414
  });
37409
- webhooks.command("list").description("List configured subscriptions").option("-j, --json", "Print JSON output", false).action(async (actionOptions) => {
37415
+ webhooks.command("list").description("List configured subscriptions").option("-j, --json", "Print JSON output", false).action(async (actionOptions, command) => {
37410
37416
  const channels = await createClient(options).listChannels();
37411
- if (actionOptions.json) {
37417
+ if (wantsJson(actionOptions, command)) {
37412
37418
  console.log(JSON.stringify(sanitizeChannelsForOutput(channels), null, 2));
37413
37419
  return;
37414
37420
  }
@@ -37420,11 +37426,11 @@ function registerWebhookCommands(program2, options) {
37420
37426
  console.log(`${channel.id} ${channel.enabled ? "enabled" : "disabled"} ${channel.transport} ${channel.webhook?.url ?? channel.command?.command ?? channel.transport}`);
37421
37427
  }
37422
37428
  });
37423
- webhooks.command("remove").description("Remove a subscription").argument("<id>", "Subscription/channel identifier").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions) => {
37429
+ webhooks.command("remove").description("Remove a subscription").argument("<id>", "Subscription/channel identifier").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions, command) => {
37424
37430
  const removed = await createClient(options).removeChannel(id);
37425
- print({ removed }, Boolean(actionOptions.json), removed ? `Removed ${id}` : `Channel not found: ${id}`);
37431
+ print({ removed }, wantsJson(actionOptions, command), removed ? `Removed ${id}` : `Channel not found: ${id}`);
37426
37432
  });
37427
- webhooks.command("test").description("Send a test event to one subscription").argument("<id>", "Subscription/channel identifier").option("--type <type>", "Event type", "events.test").option("--subject <subject>", "Event subject").option("--message <message>", "Event message", "Hasna events test delivery").option("--data <json>", "Event data JSON object").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions) => {
37433
+ webhooks.command("test").description("Send a test event to one subscription").argument("<id>", "Subscription/channel identifier").option("--type <type>", "Event type", "events.test").option("--subject <subject>", "Event subject").option("--message <message>", "Event message", "Hasna events test delivery").option("--data <json>", "Event data JSON object").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions, command) => {
37428
37434
  const result = await createClient(options).testChannel(id, {
37429
37435
  source: options.source,
37430
37436
  type: actionOptions.type,
@@ -37432,13 +37438,13 @@ function registerWebhookCommands(program2, options) {
37432
37438
  message: actionOptions.message,
37433
37439
  data: parseJsonObject(actionOptions.data, { test: true })
37434
37440
  });
37435
- print(result, Boolean(actionOptions.json), `${result.status}: ${result.channelId}`);
37441
+ print(result, wantsJson(actionOptions, command), `${result.status}: ${result.channelId}`);
37436
37442
  });
37437
37443
  return webhooks;
37438
37444
  }
37439
37445
  function registerEventCommands(program2, options) {
37440
37446
  const events = program2.command(options.eventsCommandName ?? "events").description("Emit, list, and replay Hasna events");
37441
- events.command("emit").description("Emit an event from this app").argument("<type>", "Event type").option("--source <source>", "Event source override").option("--subject <subject>", "Event subject").option("--severity <severity>", "Event severity", "info").option("--message <message>", "Event message").option("--dedupe-key <key>", "Dedupe key").option("--data <json>", "Event data JSON object").option("--metadata <json>", "Event metadata JSON object").option("--no-deliver", "Record without delivering").option("--no-dedupe", "Allow duplicate id/dedupeKey events").option("-j, --json", "Print JSON output", false).action(async (type, actionOptions) => {
37447
+ events.command("emit").description("Emit an event from this app").argument("<type>", "Event type").option("--source <source>", "Event source override").option("--subject <subject>", "Event subject").option("--severity <severity>", "Event severity", "info").option("--message <message>", "Event message").option("--dedupe-key <key>", "Dedupe key").option("--data <json>", "Event data JSON object").option("--metadata <json>", "Event metadata JSON object").option("--no-deliver", "Record without delivering").option("--no-dedupe", "Allow duplicate id/dedupeKey events").option("-j, --json", "Print JSON output", false).action(async (type, actionOptions, command) => {
37442
37448
  const result = await createClient(options).emit({
37443
37449
  source: actionOptions.source ?? options.source,
37444
37450
  type,
@@ -37449,9 +37455,9 @@ function registerEventCommands(program2, options) {
37449
37455
  data: parseJsonObject(actionOptions.data, {}),
37450
37456
  metadata: parseJsonObject(actionOptions.metadata, {})
37451
37457
  }, { deliver: actionOptions.deliver, dedupe: actionOptions.dedupe });
37452
- print(result, Boolean(actionOptions.json), `${result.deduped ? "Deduped" : "Emitted"} ${result.event.id} to ${result.deliveries.length} channel(s)`);
37458
+ print(result, wantsJson(actionOptions, command), `${result.deduped ? "Deduped" : "Emitted"} ${result.event.id} to ${result.deliveries.length} channel(s)`);
37453
37459
  });
37454
- events.command("list").description("List recorded events").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--limit <n>", "Limit results", parseNumber).option("-j, --json", "Print JSON output", false).action(async (actionOptions) => {
37460
+ events.command("list").description("List recorded events").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--limit <n>", "Limit results", parseNumber).option("-j, --json", "Print JSON output", false).action(async (actionOptions, command) => {
37455
37461
  let rows = await createClient(options).listEvents();
37456
37462
  if (actionOptions.source)
37457
37463
  rows = rows.filter((event) => event.source === actionOptions.source);
@@ -37459,7 +37465,7 @@ function registerEventCommands(program2, options) {
37459
37465
  rows = rows.filter((event) => event.type === actionOptions.type);
37460
37466
  if (actionOptions.limit)
37461
37467
  rows = rows.slice(-actionOptions.limit);
37462
- if (actionOptions.json) {
37468
+ if (wantsJson(actionOptions, command)) {
37463
37469
  console.log(JSON.stringify(rows, null, 2));
37464
37470
  return;
37465
37471
  }
@@ -37470,14 +37476,14 @@ function registerEventCommands(program2, options) {
37470
37476
  for (const event of rows)
37471
37477
  console.log(`${event.time} ${event.id} ${event.source} ${event.type} ${event.severity}`);
37472
37478
  });
37473
- events.command("replay").description("Replay recorded events").option("--id <id>", "Replay one event id").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--dry-run", "Preview without delivery", false).option("-j, --json", "Print JSON output", false).action(async (actionOptions) => {
37479
+ events.command("replay").description("Replay recorded events").option("--id <id>", "Replay one event id").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--dry-run", "Preview without delivery", false).option("-j, --json", "Print JSON output", false).action(async (actionOptions, command) => {
37474
37480
  const result = await createClient(options).replay({
37475
37481
  eventId: actionOptions.id,
37476
37482
  source: actionOptions.source,
37477
37483
  type: actionOptions.type,
37478
37484
  dryRun: actionOptions.dryRun
37479
37485
  });
37480
- print(result, Boolean(actionOptions.json), `Replayed ${result.events.length} event(s), ${result.deliveries.length} delivery result(s)`);
37486
+ print(result, wantsJson(actionOptions, command), `Replayed ${result.events.length} event(s), ${result.deliveries.length} delivery result(s)`);
37481
37487
  });
37482
37488
  return events;
37483
37489
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/accounts",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Manage and switch between multiple Claude Code (and other AI coding tool) profiles/accounts locally — isolated config dirs, per-account email, one-command switching.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -70,7 +70,7 @@
70
70
  "license": "Apache-2.0",
71
71
  "dependencies": {
72
72
  "@aws-sdk/client-s3": "^3.985.0",
73
- "@hasna/events": "^0.1.3",
73
+ "@hasna/events": "^0.1.7",
74
74
  "@modelcontextprotocol/sdk": "^1.27.1",
75
75
  "chalk": "^5.4.1",
76
76
  "commander": "^13.1.0",