@hasna/microservices 0.0.4 → 0.0.5

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 (38) hide show
  1. package/microservices/microservice-ads/src/cli/index.ts +198 -0
  2. package/microservices/microservice-ads/src/db/campaigns.ts +304 -0
  3. package/microservices/microservice-ads/src/mcp/index.ts +160 -0
  4. package/microservices/microservice-contracts/src/cli/index.ts +410 -23
  5. package/microservices/microservice-contracts/src/db/contracts.ts +430 -1
  6. package/microservices/microservice-contracts/src/db/migrations.ts +83 -0
  7. package/microservices/microservice-contracts/src/mcp/index.ts +312 -3
  8. package/microservices/microservice-domains/src/cli/index.ts +253 -0
  9. package/microservices/microservice-domains/src/db/domains.ts +613 -0
  10. package/microservices/microservice-domains/src/index.ts +21 -0
  11. package/microservices/microservice-domains/src/mcp/index.ts +168 -0
  12. package/microservices/microservice-hiring/src/cli/index.ts +318 -8
  13. package/microservices/microservice-hiring/src/db/hiring.ts +503 -0
  14. package/microservices/microservice-hiring/src/db/migrations.ts +21 -0
  15. package/microservices/microservice-hiring/src/index.ts +29 -0
  16. package/microservices/microservice-hiring/src/lib/scoring.ts +206 -0
  17. package/microservices/microservice-hiring/src/mcp/index.ts +245 -0
  18. package/microservices/microservice-payments/src/cli/index.ts +255 -3
  19. package/microservices/microservice-payments/src/db/migrations.ts +18 -0
  20. package/microservices/microservice-payments/src/db/payments.ts +552 -0
  21. package/microservices/microservice-payments/src/mcp/index.ts +223 -0
  22. package/microservices/microservice-payroll/src/cli/index.ts +269 -0
  23. package/microservices/microservice-payroll/src/db/migrations.ts +26 -0
  24. package/microservices/microservice-payroll/src/db/payroll.ts +636 -0
  25. package/microservices/microservice-payroll/src/mcp/index.ts +246 -0
  26. package/microservices/microservice-shipping/src/cli/index.ts +211 -3
  27. package/microservices/microservice-shipping/src/db/migrations.ts +8 -0
  28. package/microservices/microservice-shipping/src/db/shipping.ts +453 -3
  29. package/microservices/microservice-shipping/src/mcp/index.ts +149 -1
  30. package/microservices/microservice-social/src/cli/index.ts +244 -2
  31. package/microservices/microservice-social/src/db/migrations.ts +33 -0
  32. package/microservices/microservice-social/src/db/social.ts +378 -4
  33. package/microservices/microservice-social/src/mcp/index.ts +221 -1
  34. package/microservices/microservice-subscriptions/src/cli/index.ts +315 -0
  35. package/microservices/microservice-subscriptions/src/db/migrations.ts +68 -0
  36. package/microservices/microservice-subscriptions/src/db/subscriptions.ts +567 -3
  37. package/microservices/microservice-subscriptions/src/mcp/index.ts +267 -1
  38. package/package.json +1 -1
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import { getDatabase } from "./database.js";
6
+ import { execSync } from "node:child_process";
6
7
 
7
8
  // --- Domain types ---
8
9
 
@@ -549,3 +550,615 @@ export function deleteAlert(id: string): boolean {
549
550
  const result = db.prepare("DELETE FROM alerts WHERE id = ?").run(id);
550
551
  return result.changes > 0;
551
552
  }
553
+
554
+ // ============================================================
555
+ // WHOIS Lookup
556
+ // ============================================================
557
+
558
+ export interface WhoisResult {
559
+ domain: string;
560
+ registrar: string | null;
561
+ expires_at: string | null;
562
+ nameservers: string[];
563
+ raw: string;
564
+ }
565
+
566
+ export function whoisLookup(domainName: string): WhoisResult {
567
+ let raw: string;
568
+ try {
569
+ raw = execSync(`whois ${domainName}`, { timeout: 15000, encoding: "utf-8" });
570
+ } catch (error: unknown) {
571
+ const err = error as { stdout?: string; stderr?: string };
572
+ raw = err.stdout || err.stderr || "";
573
+ if (!raw) throw new Error(`whois command failed for ${domainName}`);
574
+ }
575
+
576
+ const registrarMatch = raw.match(/Registrar:\s*(.+)/i) || raw.match(/registrar:\s*(.+)/i);
577
+ const registrar = registrarMatch ? registrarMatch[1].trim() : null;
578
+
579
+ const expiresMatch =
580
+ raw.match(/Registry Expiry Date:\s*(.+)/i) ||
581
+ raw.match(/Expir(?:y|ation) Date:\s*(.+)/i) ||
582
+ raw.match(/paid-till:\s*(.+)/i);
583
+ let expires_at: string | null = null;
584
+ if (expiresMatch) {
585
+ try {
586
+ expires_at = new Date(expiresMatch[1].trim()).toISOString();
587
+ } catch {
588
+ expires_at = expiresMatch[1].trim();
589
+ }
590
+ }
591
+
592
+ const nsMatches = raw.matchAll(/Name Server:\s*(.+)/gi);
593
+ const nameservers: string[] = [];
594
+ for (const m of nsMatches) {
595
+ const ns = m[1].trim().toLowerCase();
596
+ if (ns && !nameservers.includes(ns)) nameservers.push(ns);
597
+ }
598
+
599
+ // Update the DB record if a domain with this name exists
600
+ const db = getDatabase();
601
+ const row = db.prepare("SELECT id FROM domains WHERE name = ?").get(domainName) as { id: string } | null;
602
+ if (row) {
603
+ const updates: UpdateDomainInput = { whois: { raw } };
604
+ if (registrar) updates.registrar = registrar;
605
+ if (expires_at) updates.expires_at = expires_at;
606
+ if (nameservers.length > 0) updates.nameservers = nameservers;
607
+ updateDomain(row.id, updates);
608
+ }
609
+
610
+ return { domain: domainName, registrar, expires_at, nameservers, raw };
611
+ }
612
+
613
+ // ============================================================
614
+ // DNS Propagation Check
615
+ // ============================================================
616
+
617
+ const DNS_SERVERS = ["8.8.8.8", "1.1.1.1", "9.9.9.9", "208.67.222.222"];
618
+ const DNS_SERVER_NAMES: Record<string, string> = {
619
+ "8.8.8.8": "Google",
620
+ "1.1.1.1": "Cloudflare",
621
+ "9.9.9.9": "Quad9",
622
+ "208.67.222.222": "OpenDNS",
623
+ };
624
+
625
+ export interface DnsPropagationResult {
626
+ domain: string;
627
+ record_type: string;
628
+ servers: {
629
+ server: string;
630
+ name: string;
631
+ values: string[];
632
+ status: "ok" | "error";
633
+ error?: string;
634
+ }[];
635
+ consistent: boolean;
636
+ }
637
+
638
+ export function checkDnsPropagation(
639
+ domain: string,
640
+ recordType: string = "A"
641
+ ): DnsPropagationResult {
642
+ const servers: DnsPropagationResult["servers"] = [];
643
+
644
+ for (const server of DNS_SERVERS) {
645
+ try {
646
+ const output = execSync(
647
+ `dig @${server} ${domain} ${recordType} +short +time=5 +tries=1`,
648
+ { timeout: 10000, encoding: "utf-8" }
649
+ );
650
+ const values = output
651
+ .trim()
652
+ .split("\n")
653
+ .filter((l) => l.length > 0);
654
+ servers.push({
655
+ server,
656
+ name: DNS_SERVER_NAMES[server] || server,
657
+ values,
658
+ status: "ok",
659
+ });
660
+ } catch (error: unknown) {
661
+ servers.push({
662
+ server,
663
+ name: DNS_SERVER_NAMES[server] || server,
664
+ values: [],
665
+ status: "error",
666
+ error: error instanceof Error ? error.message : String(error),
667
+ });
668
+ }
669
+ }
670
+
671
+ // Check consistency: all servers with "ok" should have the same sorted values
672
+ const okServers = servers.filter((s) => s.status === "ok");
673
+ const consistent =
674
+ okServers.length > 0 &&
675
+ okServers.every(
676
+ (s) => JSON.stringify(s.values.sort()) === JSON.stringify(okServers[0].values.sort())
677
+ );
678
+
679
+ return { domain, record_type: recordType, servers, consistent };
680
+ }
681
+
682
+ // ============================================================
683
+ // SSL Certificate Check
684
+ // ============================================================
685
+
686
+ export interface SslCheckResult {
687
+ domain: string;
688
+ issuer: string | null;
689
+ expires_at: string | null;
690
+ subject: string | null;
691
+ error?: string;
692
+ }
693
+
694
+ export function checkSsl(domainName: string): SslCheckResult {
695
+ try {
696
+ const output = execSync(
697
+ `echo | openssl s_client -servername ${domainName} -connect ${domainName}:443 2>/dev/null | openssl x509 -noout -issuer -dates -subject 2>/dev/null`,
698
+ { timeout: 15000, encoding: "utf-8" }
699
+ );
700
+
701
+ const issuerMatch = output.match(/issuer\s*=\s*(.+)/i);
702
+ const notAfterMatch = output.match(/notAfter\s*=\s*(.+)/i);
703
+ const subjectMatch = output.match(/subject\s*=\s*(.+)/i);
704
+
705
+ const issuer = issuerMatch ? issuerMatch[1].trim() : null;
706
+ const subject = subjectMatch ? subjectMatch[1].trim() : null;
707
+ let expires_at: string | null = null;
708
+
709
+ if (notAfterMatch) {
710
+ try {
711
+ expires_at = new Date(notAfterMatch[1].trim()).toISOString();
712
+ } catch {
713
+ expires_at = notAfterMatch[1].trim();
714
+ }
715
+ }
716
+
717
+ // Update the DB record if exists
718
+ const db = getDatabase();
719
+ const row = db.prepare("SELECT id FROM domains WHERE name = ?").get(domainName) as { id: string } | null;
720
+ if (row) {
721
+ const updates: UpdateDomainInput = {};
722
+ if (expires_at) updates.ssl_expires_at = expires_at;
723
+ if (issuer) updates.ssl_issuer = issuer;
724
+ updateDomain(row.id, updates);
725
+ }
726
+
727
+ return { domain: domainName, issuer, expires_at, subject };
728
+ } catch (error: unknown) {
729
+ return {
730
+ domain: domainName,
731
+ issuer: null,
732
+ expires_at: null,
733
+ subject: null,
734
+ error: error instanceof Error ? error.message : String(error),
735
+ };
736
+ }
737
+ }
738
+
739
+ // ============================================================
740
+ // Zone File Export / Import
741
+ // ============================================================
742
+
743
+ export function exportZoneFile(domainId: string): string | null {
744
+ const domain = getDomain(domainId);
745
+ if (!domain) return null;
746
+
747
+ const records = listDnsRecords(domainId);
748
+ const lines: string[] = [];
749
+
750
+ lines.push(`; Zone file for ${domain.name}`);
751
+ lines.push(`; Exported at ${new Date().toISOString()}`);
752
+ lines.push(`$ORIGIN ${domain.name}.`);
753
+ lines.push(`$TTL 3600`);
754
+ lines.push("");
755
+
756
+ for (const r of records) {
757
+ const name = r.name === "@" ? domain.name + "." : r.name;
758
+ if (r.type === "MX" || r.type === "SRV") {
759
+ const priority = r.priority ?? 10;
760
+ lines.push(`${name}\t${r.ttl}\tIN\t${r.type}\t${priority}\t${r.value}`);
761
+ } else {
762
+ lines.push(`${name}\t${r.ttl}\tIN\t${r.type}\t${r.value}`);
763
+ }
764
+ }
765
+
766
+ return lines.join("\n") + "\n";
767
+ }
768
+
769
+ export interface ZoneImportResult {
770
+ imported: number;
771
+ skipped: number;
772
+ errors: string[];
773
+ records: DnsRecord[];
774
+ }
775
+
776
+ export function importZoneFile(domainId: string, content: string): ZoneImportResult | null {
777
+ const domain = getDomain(domainId);
778
+ if (!domain) return null;
779
+
780
+ const result: ZoneImportResult = { imported: 0, skipped: 0, errors: [], records: [] };
781
+ const lines = content.split("\n");
782
+ const validTypes = new Set(["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SRV"]);
783
+
784
+ for (const rawLine of lines) {
785
+ const line = rawLine.trim();
786
+ if (!line || line.startsWith(";") || line.startsWith("$")) {
787
+ continue;
788
+ }
789
+
790
+ // Parse zone file line: name ttl class type [priority] value
791
+ const parts = line.split(/\s+/);
792
+ if (parts.length < 4) {
793
+ result.errors.push(`Could not parse line: ${line}`);
794
+ result.skipped++;
795
+ continue;
796
+ }
797
+
798
+ let name = parts[0];
799
+ let idx = 1;
800
+
801
+ // Skip optional TTL (numeric)
802
+ let ttl = 3600;
803
+ if (/^\d+$/.test(parts[idx])) {
804
+ ttl = parseInt(parts[idx]);
805
+ idx++;
806
+ }
807
+
808
+ // Skip class (IN)
809
+ if (parts[idx] && parts[idx].toUpperCase() === "IN") {
810
+ idx++;
811
+ }
812
+
813
+ const type = parts[idx]?.toUpperCase();
814
+ idx++;
815
+
816
+ if (!type || !validTypes.has(type)) {
817
+ result.errors.push(`Unknown record type '${type}' in: ${line}`);
818
+ result.skipped++;
819
+ continue;
820
+ }
821
+
822
+ let priority: number | undefined;
823
+ if (type === "MX" || type === "SRV") {
824
+ if (parts[idx] && /^\d+$/.test(parts[idx])) {
825
+ priority = parseInt(parts[idx]);
826
+ idx++;
827
+ }
828
+ }
829
+
830
+ const value = parts.slice(idx).join(" ");
831
+ if (!value) {
832
+ result.errors.push(`Missing value in: ${line}`);
833
+ result.skipped++;
834
+ continue;
835
+ }
836
+
837
+ // Normalize name: remove trailing dot, replace domain name with @
838
+ if (name.endsWith(".")) name = name.slice(0, -1);
839
+ if (name === domain.name || name === "") name = "@";
840
+
841
+ try {
842
+ const record = createDnsRecord({
843
+ domain_id: domainId,
844
+ type: type as DnsRecord["type"],
845
+ name,
846
+ value,
847
+ ttl,
848
+ priority,
849
+ });
850
+ result.records.push(record);
851
+ result.imported++;
852
+ } catch (error: unknown) {
853
+ result.errors.push(
854
+ `Failed to create record: ${error instanceof Error ? error.message : String(error)}`
855
+ );
856
+ result.skipped++;
857
+ }
858
+ }
859
+
860
+ return result;
861
+ }
862
+
863
+ // ============================================================
864
+ // Subdomain Discovery (crt.sh)
865
+ // ============================================================
866
+
867
+ export interface SubdomainResult {
868
+ domain: string;
869
+ subdomains: string[];
870
+ source: string;
871
+ error?: string;
872
+ }
873
+
874
+ export async function discoverSubdomains(domain: string): Promise<SubdomainResult> {
875
+ try {
876
+ const url = `https://crt.sh/?q=%25.${encodeURIComponent(domain)}&output=json`;
877
+ const response = await fetch(url, {
878
+ signal: AbortSignal.timeout(15000),
879
+ headers: { "User-Agent": "microservice-domains/0.0.1" },
880
+ });
881
+
882
+ if (!response.ok) {
883
+ return {
884
+ domain,
885
+ subdomains: [],
886
+ source: "crt.sh",
887
+ error: `crt.sh returned ${response.status}`,
888
+ };
889
+ }
890
+
891
+ const data = (await response.json()) as { common_name?: string; name_value?: string }[];
892
+ const subdomainSet = new Set<string>();
893
+
894
+ for (const entry of data) {
895
+ for (const field of [entry.common_name, entry.name_value]) {
896
+ if (!field) continue;
897
+ for (const name of field.split("\n")) {
898
+ const cleaned = name.trim().toLowerCase().replace(/^\*\./, "");
899
+ if (cleaned.endsWith(domain.toLowerCase()) && cleaned !== domain.toLowerCase()) {
900
+ subdomainSet.add(cleaned);
901
+ }
902
+ }
903
+ }
904
+ }
905
+
906
+ const subdomains = [...subdomainSet].sort();
907
+ return { domain, subdomains, source: "crt.sh" };
908
+ } catch (error: unknown) {
909
+ return {
910
+ domain,
911
+ subdomains: [],
912
+ source: "crt.sh",
913
+ error: error instanceof Error ? error.message : String(error),
914
+ };
915
+ }
916
+ }
917
+
918
+ // ============================================================
919
+ // DNS Validation
920
+ // ============================================================
921
+
922
+ export interface DnsValidationIssue {
923
+ type: "error" | "warning";
924
+ record_id?: string;
925
+ message: string;
926
+ }
927
+
928
+ export interface DnsValidationResult {
929
+ domain_id: string;
930
+ domain_name: string;
931
+ issues: DnsValidationIssue[];
932
+ valid: boolean;
933
+ }
934
+
935
+ export function validateDns(domainId: string): DnsValidationResult | null {
936
+ const domain = getDomain(domainId);
937
+ if (!domain) return null;
938
+
939
+ const records = listDnsRecords(domainId);
940
+ const issues: DnsValidationIssue[] = [];
941
+
942
+ // Group records by name
943
+ const byName = new Map<string, DnsRecord[]>();
944
+ for (const r of records) {
945
+ const key = r.name.toLowerCase();
946
+ if (!byName.has(key)) byName.set(key, []);
947
+ byName.get(key)!.push(r);
948
+ }
949
+
950
+ // Check: CNAME should not coexist with A or MX at the same name
951
+ for (const [name, recs] of byName) {
952
+ const hasCname = recs.some((r) => r.type === "CNAME");
953
+ const hasA = recs.some((r) => r.type === "A" || r.type === "AAAA");
954
+ const hasMx = recs.some((r) => r.type === "MX");
955
+ const hasNs = recs.some((r) => r.type === "NS");
956
+
957
+ if (hasCname && hasA) {
958
+ issues.push({
959
+ type: "error",
960
+ message: `CNAME record at '${name}' conflicts with A/AAAA record — CNAME cannot coexist with other record types`,
961
+ });
962
+ }
963
+ if (hasCname && hasMx) {
964
+ issues.push({
965
+ type: "error",
966
+ message: `CNAME record at '${name}' conflicts with MX record — CNAME cannot coexist with other record types`,
967
+ });
968
+ }
969
+ if (hasCname && hasNs) {
970
+ issues.push({
971
+ type: "error",
972
+ message: `CNAME record at '${name}' conflicts with NS record — CNAME cannot coexist with other record types`,
973
+ });
974
+ }
975
+ if (hasCname && recs.filter((r) => r.type === "CNAME").length > 1) {
976
+ issues.push({
977
+ type: "error",
978
+ message: `Multiple CNAME records at '${name}' — only one CNAME is allowed per name`,
979
+ });
980
+ }
981
+ }
982
+
983
+ // Check: Missing MX records for root domain (warning)
984
+ const rootRecords = byName.get("@") || [];
985
+ const hasMxAtRoot = rootRecords.some((r) => r.type === "MX");
986
+ if (!hasMxAtRoot && records.length > 0) {
987
+ issues.push({
988
+ type: "warning",
989
+ message: `No MX record found at root (@) — email delivery may not work for ${domain.name}`,
990
+ });
991
+ }
992
+
993
+ // Check: Orphan records — records pointing to names with no A/AAAA resolution
994
+ for (const r of records) {
995
+ if (r.type === "CNAME") {
996
+ const target = r.value.toLowerCase().replace(/\.$/, "");
997
+ // Check if target is within this domain and has no records
998
+ if (target.endsWith(domain.name.toLowerCase())) {
999
+ const targetName = target === domain.name.toLowerCase() ? "@" : target.replace(`.${domain.name.toLowerCase()}`, "");
1000
+ const targetRecords = byName.get(targetName.toLowerCase());
1001
+ if (!targetRecords || targetRecords.length === 0) {
1002
+ issues.push({
1003
+ type: "warning",
1004
+ record_id: r.id,
1005
+ message: `CNAME '${r.name}' points to '${r.value}' which has no records in this zone`,
1006
+ });
1007
+ }
1008
+ }
1009
+ }
1010
+ }
1011
+
1012
+ // Check: MX records should have priority
1013
+ for (const r of records) {
1014
+ if (r.type === "MX" && r.priority === null) {
1015
+ issues.push({
1016
+ type: "warning",
1017
+ record_id: r.id,
1018
+ message: `MX record '${r.name}' -> '${r.value}' has no priority set`,
1019
+ });
1020
+ }
1021
+ }
1022
+
1023
+ return {
1024
+ domain_id: domainId,
1025
+ domain_name: domain.name,
1026
+ issues,
1027
+ valid: issues.filter((i) => i.type === "error").length === 0,
1028
+ };
1029
+ }
1030
+
1031
+ // ============================================================
1032
+ // Portfolio Export
1033
+ // ============================================================
1034
+
1035
+ export function exportPortfolio(format: "csv" | "json" = "json"): string {
1036
+ const domains = listDomains();
1037
+
1038
+ if (format === "json") {
1039
+ return JSON.stringify(
1040
+ domains.map((d) => ({
1041
+ name: d.name,
1042
+ registrar: d.registrar,
1043
+ status: d.status,
1044
+ registered_at: d.registered_at,
1045
+ expires_at: d.expires_at,
1046
+ auto_renew: d.auto_renew,
1047
+ nameservers: d.nameservers,
1048
+ ssl_expires_at: d.ssl_expires_at,
1049
+ ssl_issuer: d.ssl_issuer,
1050
+ notes: d.notes,
1051
+ })),
1052
+ null,
1053
+ 2
1054
+ );
1055
+ }
1056
+
1057
+ // CSV format
1058
+ const headers = [
1059
+ "name",
1060
+ "registrar",
1061
+ "status",
1062
+ "registered_at",
1063
+ "expires_at",
1064
+ "auto_renew",
1065
+ "nameservers",
1066
+ "ssl_expires_at",
1067
+ "ssl_issuer",
1068
+ "notes",
1069
+ ];
1070
+ const rows = domains.map((d) =>
1071
+ [
1072
+ csvEscape(d.name),
1073
+ csvEscape(d.registrar || ""),
1074
+ csvEscape(d.status),
1075
+ csvEscape(d.registered_at || ""),
1076
+ csvEscape(d.expires_at || ""),
1077
+ d.auto_renew ? "true" : "false",
1078
+ csvEscape(d.nameservers.join("; ")),
1079
+ csvEscape(d.ssl_expires_at || ""),
1080
+ csvEscape(d.ssl_issuer || ""),
1081
+ csvEscape(d.notes || ""),
1082
+ ].join(",")
1083
+ );
1084
+
1085
+ return [headers.join(","), ...rows].join("\n") + "\n";
1086
+ }
1087
+
1088
+ function csvEscape(value: string): string {
1089
+ if (value.includes(",") || value.includes('"') || value.includes("\n")) {
1090
+ return `"${value.replace(/"/g, '""')}"`;
1091
+ }
1092
+ return value;
1093
+ }
1094
+
1095
+ // ============================================================
1096
+ // Bulk Domain Check
1097
+ // ============================================================
1098
+
1099
+ export interface BulkCheckResult {
1100
+ domain: string;
1101
+ domain_id: string;
1102
+ whois?: { registrar: string | null; expires_at: string | null; error?: string };
1103
+ ssl?: { issuer: string | null; expires_at: string | null; error?: string };
1104
+ dns_validation?: { valid: boolean; issue_count: number; errors: string[] };
1105
+ }
1106
+
1107
+ export function checkAllDomains(): BulkCheckResult[] {
1108
+ const domains = listDomains();
1109
+ const results: BulkCheckResult[] = [];
1110
+
1111
+ for (const domain of domains) {
1112
+ const result: BulkCheckResult = {
1113
+ domain: domain.name,
1114
+ domain_id: domain.id,
1115
+ };
1116
+
1117
+ // WHOIS check
1118
+ try {
1119
+ const whois = whoisLookup(domain.name);
1120
+ result.whois = {
1121
+ registrar: whois.registrar,
1122
+ expires_at: whois.expires_at,
1123
+ };
1124
+ } catch (error: unknown) {
1125
+ result.whois = {
1126
+ registrar: null,
1127
+ expires_at: null,
1128
+ error: error instanceof Error ? error.message : String(error),
1129
+ };
1130
+ }
1131
+
1132
+ // SSL check
1133
+ const ssl = checkSsl(domain.name);
1134
+ result.ssl = {
1135
+ issuer: ssl.issuer,
1136
+ expires_at: ssl.expires_at,
1137
+ error: ssl.error,
1138
+ };
1139
+
1140
+ // DNS validation
1141
+ const validation = validateDns(domain.id);
1142
+ if (validation) {
1143
+ result.dns_validation = {
1144
+ valid: validation.valid,
1145
+ issue_count: validation.issues.length,
1146
+ errors: validation.issues.map((i) => `[${i.type}] ${i.message}`),
1147
+ };
1148
+ }
1149
+
1150
+ results.push(result);
1151
+ }
1152
+
1153
+ return results;
1154
+ }
1155
+
1156
+ // ============================================================
1157
+ // Helper: find domain by name (used by CLI to resolve names to IDs)
1158
+ // ============================================================
1159
+
1160
+ export function getDomainByName(name: string): Domain | null {
1161
+ const db = getDatabase();
1162
+ const row = db.prepare("SELECT * FROM domains WHERE name = ?").get(name) as DomainRow | null;
1163
+ return row ? rowToDomain(row) : null;
1164
+ }
@@ -14,6 +14,7 @@ export {
14
14
  listExpiring,
15
15
  listSslExpiring,
16
16
  getDomainStats,
17
+ getDomainByName,
17
18
  type Domain,
18
19
  type CreateDomainInput,
19
20
  type UpdateDomainInput,
@@ -41,4 +42,24 @@ export {
41
42
  type CreateAlertInput,
42
43
  } from "./db/domains.js";
43
44
 
45
+ export {
46
+ whoisLookup,
47
+ checkDnsPropagation,
48
+ checkSsl,
49
+ exportZoneFile,
50
+ importZoneFile,
51
+ discoverSubdomains,
52
+ validateDns,
53
+ exportPortfolio,
54
+ checkAllDomains,
55
+ type WhoisResult,
56
+ type DnsPropagationResult,
57
+ type SslCheckResult,
58
+ type ZoneImportResult,
59
+ type SubdomainResult,
60
+ type DnsValidationIssue,
61
+ type DnsValidationResult,
62
+ type BulkCheckResult,
63
+ } from "./db/domains.js";
64
+
44
65
  export { getDatabase, closeDatabase } from "./db/database.js";