@hasna/connectors 1.3.35 → 1.3.36

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/bin/index.js CHANGED
@@ -1909,7 +1909,7 @@ var package_default;
1909
1909
  var init_package = __esm(() => {
1910
1910
  package_default = {
1911
1911
  name: "@hasna/connectors",
1912
- version: "1.3.35",
1912
+ version: "1.3.36",
1913
1913
  description: "Open source connector library - Install API connectors with a single command",
1914
1914
  type: "module",
1915
1915
  bin: {
@@ -1965,7 +1965,7 @@ var init_package = __esm(() => {
1965
1965
  },
1966
1966
  dependencies: {
1967
1967
  "@hasna/cloud": "0.1.24",
1968
- "@hasna/events": "^0.1.3",
1968
+ "@hasna/events": "^0.1.7",
1969
1969
  "@modelcontextprotocol/sdk": "^1.26.0",
1970
1970
  chalk: "^5.3.0",
1971
1971
  commander: "^12.1.0",
@@ -49848,9 +49848,15 @@ function print(value, json, text) {
49848
49848
  else
49849
49849
  console.log(text);
49850
49850
  }
49851
+ function hasJsonOption(options) {
49852
+ return Boolean(options?.json || options?.opts?.().json || options?.optsWithGlobals?.().json || options?.parent?.opts?.().json || options?.parent?.optsWithGlobals?.().json);
49853
+ }
49854
+ function wantsJson(actionOptions, command) {
49855
+ return hasJsonOption(actionOptions) || hasJsonOption(command);
49856
+ }
49851
49857
  function registerWebhookCommands(program2, options) {
49852
49858
  const webhooks = program2.command(options.webhooksCommandName ?? "webhooks").description("Manage Hasna event webhook subscriptions");
49853
- 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) => {
49859
+ 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) => {
49854
49860
  const timestamp = new Date().toISOString();
49855
49861
  const channel = {
49856
49862
  id: actionOptions.id,
@@ -49871,11 +49877,11 @@ function registerWebhookCommands(program2, options) {
49871
49877
  throw new Error(`Transport ${actionOptions.transport} is reserved for future use and cannot be added yet`);
49872
49878
  }
49873
49879
  const saved = await createClient(options).addChannel(channel);
49874
- print(sanitizeChannelForOutput(saved), Boolean(actionOptions.json), `Added ${saved.transport} channel ${saved.id}`);
49880
+ print(sanitizeChannelForOutput(saved), wantsJson(actionOptions, command), `Added ${saved.transport} channel ${saved.id}`);
49875
49881
  });
49876
- webhooks.command("list").description("List configured subscriptions").option("-j, --json", "Print JSON output", false).action(async (actionOptions) => {
49882
+ webhooks.command("list").description("List configured subscriptions").option("-j, --json", "Print JSON output", false).action(async (actionOptions, command) => {
49877
49883
  const channels = await createClient(options).listChannels();
49878
- if (actionOptions.json) {
49884
+ if (wantsJson(actionOptions, command)) {
49879
49885
  console.log(JSON.stringify(sanitizeChannelsForOutput(channels), null, 2));
49880
49886
  return;
49881
49887
  }
@@ -49887,11 +49893,11 @@ function registerWebhookCommands(program2, options) {
49887
49893
  console.log(`${channel.id} ${channel.enabled ? "enabled" : "disabled"} ${channel.transport} ${channel.webhook?.url ?? channel.command?.command ?? channel.transport}`);
49888
49894
  }
49889
49895
  });
49890
- webhooks.command("remove").description("Remove a subscription").argument("<id>", "Subscription/channel identifier").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions) => {
49896
+ webhooks.command("remove").description("Remove a subscription").argument("<id>", "Subscription/channel identifier").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions, command) => {
49891
49897
  const removed = await createClient(options).removeChannel(id);
49892
- print({ removed }, Boolean(actionOptions.json), removed ? `Removed ${id}` : `Channel not found: ${id}`);
49898
+ print({ removed }, wantsJson(actionOptions, command), removed ? `Removed ${id}` : `Channel not found: ${id}`);
49893
49899
  });
49894
- 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) => {
49900
+ 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) => {
49895
49901
  const result = await createClient(options).testChannel(id, {
49896
49902
  source: options.source,
49897
49903
  type: actionOptions.type,
@@ -49899,13 +49905,13 @@ function registerWebhookCommands(program2, options) {
49899
49905
  message: actionOptions.message,
49900
49906
  data: parseJsonObject(actionOptions.data, { test: true })
49901
49907
  });
49902
- print(result, Boolean(actionOptions.json), `${result.status}: ${result.channelId}`);
49908
+ print(result, wantsJson(actionOptions, command), `${result.status}: ${result.channelId}`);
49903
49909
  });
49904
49910
  return webhooks;
49905
49911
  }
49906
49912
  function registerEventCommands(program2, options) {
49907
49913
  const events = program2.command(options.eventsCommandName ?? "events").description("Emit, list, and replay Hasna events");
49908
- 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) => {
49914
+ 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) => {
49909
49915
  const result = await createClient(options).emit({
49910
49916
  source: actionOptions.source ?? options.source,
49911
49917
  type,
@@ -49916,9 +49922,9 @@ function registerEventCommands(program2, options) {
49916
49922
  data: parseJsonObject(actionOptions.data, {}),
49917
49923
  metadata: parseJsonObject(actionOptions.metadata, {})
49918
49924
  }, { deliver: actionOptions.deliver, dedupe: actionOptions.dedupe });
49919
- print(result, Boolean(actionOptions.json), `${result.deduped ? "Deduped" : "Emitted"} ${result.event.id} to ${result.deliveries.length} channel(s)`);
49925
+ print(result, wantsJson(actionOptions, command), `${result.deduped ? "Deduped" : "Emitted"} ${result.event.id} to ${result.deliveries.length} channel(s)`);
49920
49926
  });
49921
- 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) => {
49927
+ 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) => {
49922
49928
  let rows = await createClient(options).listEvents();
49923
49929
  if (actionOptions.source)
49924
49930
  rows = rows.filter((event) => event.source === actionOptions.source);
@@ -49926,7 +49932,7 @@ function registerEventCommands(program2, options) {
49926
49932
  rows = rows.filter((event) => event.type === actionOptions.type);
49927
49933
  if (actionOptions.limit)
49928
49934
  rows = rows.slice(-actionOptions.limit);
49929
- if (actionOptions.json) {
49935
+ if (wantsJson(actionOptions, command)) {
49930
49936
  console.log(JSON.stringify(rows, null, 2));
49931
49937
  return;
49932
49938
  }
@@ -49937,14 +49943,14 @@ function registerEventCommands(program2, options) {
49937
49943
  for (const event of rows)
49938
49944
  console.log(`${event.time} ${event.id} ${event.source} ${event.type} ${event.severity}`);
49939
49945
  });
49940
- 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) => {
49946
+ 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) => {
49941
49947
  const result = await createClient(options).replay({
49942
49948
  eventId: actionOptions.id,
49943
49949
  source: actionOptions.source,
49944
49950
  type: actionOptions.type,
49945
49951
  dryRun: actionOptions.dryRun
49946
49952
  });
49947
- print(result, Boolean(actionOptions.json), `Replayed ${result.events.length} event(s), ${result.deliveries.length} delivery result(s)`);
49953
+ print(result, wantsJson(actionOptions, command), `Replayed ${result.events.length} event(s), ${result.deliveries.length} delivery result(s)`);
49948
49954
  });
49949
49955
  return events;
49950
49956
  }
package/bin/mcp.js CHANGED
@@ -5804,7 +5804,7 @@ var package_default;
5804
5804
  var init_package = __esm(() => {
5805
5805
  package_default = {
5806
5806
  name: "@hasna/connectors",
5807
- version: "1.3.35",
5807
+ version: "1.3.36",
5808
5808
  description: "Open source connector library - Install API connectors with a single command",
5809
5809
  type: "module",
5810
5810
  bin: {
@@ -5860,7 +5860,7 @@ var init_package = __esm(() => {
5860
5860
  },
5861
5861
  dependencies: {
5862
5862
  "@hasna/cloud": "0.1.24",
5863
- "@hasna/events": "^0.1.3",
5863
+ "@hasna/events": "^0.1.7",
5864
5864
  "@modelcontextprotocol/sdk": "^1.26.0",
5865
5865
  chalk: "^5.3.0",
5866
5866
  commander: "^12.1.0",
package/bin/serve.js CHANGED
@@ -16400,7 +16400,7 @@ var package_default;
16400
16400
  var init_package = __esm(() => {
16401
16401
  package_default = {
16402
16402
  name: "@hasna/connectors",
16403
- version: "1.3.35",
16403
+ version: "1.3.36",
16404
16404
  description: "Open source connector library - Install API connectors with a single command",
16405
16405
  type: "module",
16406
16406
  bin: {
@@ -16456,7 +16456,7 @@ var init_package = __esm(() => {
16456
16456
  },
16457
16457
  dependencies: {
16458
16458
  "@hasna/cloud": "0.1.24",
16459
- "@hasna/events": "^0.1.3",
16459
+ "@hasna/events": "^0.1.7",
16460
16460
  "@modelcontextprotocol/sdk": "^1.26.0",
16461
16461
  chalk: "^5.3.0",
16462
16462
  commander: "^12.1.0",
package/dist/index.js CHANGED
@@ -5764,7 +5764,7 @@ function extractGoogleError(body) {
5764
5764
  // package.json
5765
5765
  var package_default = {
5766
5766
  name: "@hasna/connectors",
5767
- version: "1.3.35",
5767
+ version: "1.3.36",
5768
5768
  description: "Open source connector library - Install API connectors with a single command",
5769
5769
  type: "module",
5770
5770
  bin: {
@@ -5820,7 +5820,7 @@ var package_default = {
5820
5820
  },
5821
5821
  dependencies: {
5822
5822
  "@hasna/cloud": "0.1.24",
5823
- "@hasna/events": "^0.1.3",
5823
+ "@hasna/events": "^0.1.7",
5824
5824
  "@modelcontextprotocol/sdk": "^1.26.0",
5825
5825
  chalk: "^5.3.0",
5826
5826
  commander: "^12.1.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/connectors",
3
- "version": "1.3.35",
3
+ "version": "1.3.36",
4
4
  "description": "Open source connector library - Install API connectors with a single command",
5
5
  "type": "module",
6
6
  "bin": {
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@hasna/cloud": "0.1.24",
59
- "@hasna/events": "^0.1.3",
59
+ "@hasna/events": "^0.1.7",
60
60
  "@modelcontextprotocol/sdk": "^1.26.0",
61
61
  "chalk": "^5.3.0",
62
62
  "commander": "^12.1.0",