@hasna/domains 0.0.6 → 0.0.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAoc5D"}
1
+ {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8d5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8D9D"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuJ9D"}
package/dist/cli/index.js CHANGED
@@ -42527,7 +42527,7 @@ WHOIS for ${result.domain}:`);
42527
42527
  const output = exportPortfolio(opts.format);
42528
42528
  console.log(output);
42529
42529
  });
42530
- domain.command("check <domains...>").description("Check domain availability via configured registrar").option("--provider <name>", "Registrar provider to use").action(async (domains, opts) => {
42530
+ domain.command("check <domains...>").description("Check domain availability via configured registrar").option("--provider <name>", "Registrar provider to use").option("-j, --json", "Output JSON").action(async (domains, opts) => {
42531
42531
  const cfg = loadConfig3();
42532
42532
  const providerName = opts.provider ?? cfg.default_registrar ?? "route53";
42533
42533
  const results = await Promise.allSettled(domains.map(async (d3) => {
@@ -42535,17 +42535,33 @@ WHOIS for ${result.domain}:`);
42535
42535
  return provider.checkAvailability(d3);
42536
42536
  }));
42537
42537
  let anyError = false;
42538
+ const output = [];
42538
42539
  for (let i3 = 0;i3 < domains.length; i3++) {
42539
42540
  const r3 = results[i3];
42540
42541
  if (r3.status === "rejected") {
42541
42542
  const reason = r3.reason;
42542
- console.error(`\u2717 ${domains[i3]}: ${reason instanceof Error ? reason.message : String(reason)}`);
42543
+ const error = reason instanceof Error ? reason.message : String(reason);
42544
+ output.push({ domain: domains[i3], error });
42545
+ if (!opts.json) {
42546
+ console.error(`\u2717 ${domains[i3]}: ${error}`);
42547
+ }
42543
42548
  anyError = true;
42544
42549
  } else {
42545
42550
  const result = r3.value;
42546
- console.log(`${result.available ? "\u2713" : "\u2717"} ${result.domain} is ${result.available ? "available" : "not available"}`);
42551
+ output.push({ domain: result.domain, available: result.available });
42552
+ if (!opts.json) {
42553
+ console.log(`${result.available ? "\u2713" : "\u2717"} ${result.domain} is ${result.available ? "available" : "not available"}`);
42554
+ }
42547
42555
  }
42548
42556
  }
42557
+ if (opts.json) {
42558
+ console.log(JSON.stringify({
42559
+ provider: providerName,
42560
+ count: output.length,
42561
+ ok: !anyError,
42562
+ results: output
42563
+ }, null, 2));
42564
+ }
42549
42565
  if (anyError)
42550
42566
  process.exit(1);
42551
42567
  });
@@ -43176,7 +43192,7 @@ function registerMonitorCommand(program2) {
43176
43192
  // src/cli/commands/provider.ts
43177
43193
  function registerProviderCommand(program2) {
43178
43194
  const provider = program2.command("provider").description("Configure and test registrar/DNS providers");
43179
- provider.command("list").description("Show all providers and their configuration status").option("--json", "Output JSON").action((opts) => {
43195
+ provider.command("list").description("Show all providers and their configuration status").option("-j, --json", "Output JSON").action((opts) => {
43180
43196
  const providers = getAvailableProviders();
43181
43197
  if (opts.json) {
43182
43198
  console.log(JSON.stringify(providers, null, 2));
@@ -43194,37 +43210,95 @@ Registrar / DNS Providers:`);
43194
43210
  }
43195
43211
  console.log();
43196
43212
  });
43197
- provider.command("test <name>").description("Live-test a provider's credentials").action(async (name) => {
43213
+ provider.command("test <name>").description("Live-test a provider's credentials").option("-j, --json", "Output JSON").action(async (name, opts) => {
43198
43214
  const providers = getAvailableProviders();
43199
43215
  const info = providers.find((p3) => p3.name === name);
43200
43216
  if (!info) {
43201
- console.error(`Unknown provider: ${name}`);
43217
+ const error = `Unknown provider: ${name}`;
43218
+ if (opts.json) {
43219
+ console.log(JSON.stringify({ provider: name, ok: false, error }, null, 2));
43220
+ } else {
43221
+ console.error(error);
43222
+ }
43202
43223
  process.exit(1);
43203
43224
  }
43204
43225
  if (!info.configured) {
43205
- console.error(`\u2717 ${name} is not configured. Set: ${info.envVars.join(", ")}`);
43226
+ const error = `${name} is not configured. Set: ${info.envVars.join(", ")}`;
43227
+ if (opts.json) {
43228
+ console.log(JSON.stringify({
43229
+ provider: name,
43230
+ ok: false,
43231
+ configured: false,
43232
+ required_env: info.envVars,
43233
+ error
43234
+ }, null, 2));
43235
+ } else {
43236
+ console.error(`\u2717 ${error}`);
43237
+ }
43206
43238
  process.exit(1);
43207
43239
  }
43208
- console.log(`Testing ${name}...`);
43240
+ if (!opts.json) {
43241
+ console.log(`Testing ${name}...`);
43242
+ }
43243
+ let registrarOk = null;
43244
+ let dnsOk = null;
43209
43245
  try {
43210
43246
  if (info.type === "registrar" || info.type === "full") {
43211
43247
  const reg = getRegistrarProvider(name);
43212
43248
  await reg.listDomains();
43213
- console.log(`\u2713 Registrar connection OK`);
43249
+ registrarOk = true;
43250
+ if (!opts.json)
43251
+ console.log("\u2713 Registrar connection OK");
43214
43252
  }
43215
43253
  if (info.type === "dns" || info.type === "full") {
43216
43254
  const dns = getDnsProvider(name);
43217
43255
  await dns.getDnsRecords("__test_nonexistent_domain__.invalid");
43218
- console.log(`\u2713 DNS connection OK`);
43256
+ dnsOk = true;
43257
+ if (!opts.json)
43258
+ console.log("\u2713 DNS connection OK");
43259
+ }
43260
+ if (opts.json) {
43261
+ console.log(JSON.stringify({
43262
+ provider: name,
43263
+ ok: true,
43264
+ configured: true,
43265
+ type: info.type,
43266
+ registrar_ok: registrarOk,
43267
+ dns_ok: dnsOk
43268
+ }, null, 2));
43219
43269
  }
43220
43270
  } catch (e3) {
43221
43271
  const msg = e3 instanceof Error ? e3.message : String(e3);
43222
43272
  if (msg.includes("not found") || msg.includes("No hosted zone") || msg.includes("NXDOMAIN")) {
43223
- console.log(`\u2713 Connection OK (no domains yet)`);
43273
+ if (opts.json) {
43274
+ console.log(JSON.stringify({
43275
+ provider: name,
43276
+ ok: true,
43277
+ configured: true,
43278
+ type: info.type,
43279
+ registrar_ok: registrarOk,
43280
+ dns_ok: true,
43281
+ note: "connection-ok-no-domains-yet"
43282
+ }, null, 2));
43283
+ } else {
43284
+ console.log("\u2713 Connection OK (no domains yet)");
43285
+ }
43286
+ return;
43287
+ }
43288
+ if (opts.json) {
43289
+ console.log(JSON.stringify({
43290
+ provider: name,
43291
+ ok: false,
43292
+ configured: true,
43293
+ type: info.type,
43294
+ registrar_ok: registrarOk,
43295
+ dns_ok: dnsOk,
43296
+ error: msg
43297
+ }, null, 2));
43224
43298
  } else {
43225
43299
  console.error(`\u2717 ${name} test failed: ${msg}`);
43226
- process.exit(1);
43227
43300
  }
43301
+ process.exit(1);
43228
43302
  }
43229
43303
  });
43230
43304
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/domains",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Domain portfolio and DNS management for AI agents — CLI + MCP server with SQLite",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",