zynor 0.0.68 → 0.0.77

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/dist/index.d.ts CHANGED
@@ -2096,7 +2096,42 @@ declare const records: readonly [
2096
2096
  }
2097
2097
  ];
2098
2098
  type ProviderName$1 = typeof records[number]["name"] | ProviderNames;
2099
+ /**
2100
+ * Logger signature for debug output. Receives one preformatted line per event.
2101
+ */
2102
+ export type DebugLogger = (line: string) => void;
2103
+ /**
2104
+ * Verbosity level for debug logging.
2105
+ * - `info` — top-level checkpoints only: validate() enter/exit, MX result,
2106
+ * shallow/deep/Invalid outcome, deep-validation enter/exit,
2107
+ * validateBulk phase boundaries. Best for spotting *where* a hang
2108
+ * occurs without drowning in noise.
2109
+ * - `debug` — adds sub-operations: cache hits/misses, MX→record matches,
2110
+ * domain_check probes, dnsLookup per-IP iteration, IP-cascade
2111
+ * HTTP calls, per-EmailProviders match.
2112
+ * - `trace` — adds every event: inflight hit/cleared, per-mx loop iterations,
2113
+ * per-worker bulk progress, syntax/rejected/disposable early
2114
+ * returns. Use only when `debug` doesn't pinpoint the issue.
2115
+ */
2116
+ export type DebugLevel = "info" | "debug" | "trace";
2099
2117
  export interface ValidationConfig {
2118
+ /**
2119
+ * Structured debug logging for the validation flow. Off by default.
2120
+ *
2121
+ * - `false` / omitted — silent (no overhead)
2122
+ * - `true` — `info` level, logged to stderr via `console.error`
2123
+ * - `'info' | 'debug' | 'trace'` — that level on stderr
2124
+ * - `(line: string) => void` — `trace` level, each line passed to fn
2125
+ * - `{ level, log }` — both explicit
2126
+ *
2127
+ * Each line is `[zynor HH:MM:SS.mmm <LEVEL>] <scope>: <msg>`.
2128
+ *
2129
+ * @default false
2130
+ */
2131
+ debug?: boolean | DebugLevel | DebugLogger | {
2132
+ level?: DebugLevel;
2133
+ log?: DebugLogger;
2134
+ };
2100
2135
  /**
2101
2136
  * @description This will enable deep validation of the email. slower than normal email validator as it triggers multiple dns requests, or travel to the ip address to get the domain name.
2102
2137
  * This is per request option, passing true to the getProvider without turning this ON, it wont work and vice versa.
@@ -2162,6 +2197,9 @@ export declare class EmailValidator {
2162
2197
  private validateCache;
2163
2198
  private ipCache;
2164
2199
  private inflight;
2200
+ private _logFn;
2201
+ /** 0=silent, 1=info, 2=debug, 3=trace */
2202
+ private _logLevel;
2165
2203
  private validationConfig;
2166
2204
  constructor(config?: {
2167
2205
  options?: ValidationConfig;
@@ -2236,6 +2274,34 @@ export declare class EmailValidator {
2236
2274
  deep?: boolean;
2237
2275
  logo?: boolean;
2238
2276
  }): Promise<EmailResponse>;
2277
+ /**
2278
+ * Emit a log line if its level is at or below the configured threshold.
2279
+ * Format: `[zynor HH:MM:SS.mmm <LVL>] <scope>: <msg>`. Zero formatting
2280
+ * cost when level is filtered out.
2281
+ *
2282
+ * Use the typed wrappers (`_info`/`_debug`/`_trace`) — they make every
2283
+ * call site self-document its expected verbosity.
2284
+ */
2285
+ private _emit;
2286
+ /** Top-level checkpoint (validate enter/exit, MX result, terminal outcome). */
2287
+ private _info;
2288
+ /** Sub-operation (cache hit/miss, network call start/end, sub-loop boundary). */
2289
+ private _debug;
2290
+ /** Fine-grained event (singleflight cleanup, per-iteration loop, early returns). */
2291
+ private _trace;
2292
+ /**
2293
+ * Belt-and-suspenders timeout for DNS calls. Races the underlying
2294
+ * operation against a `setTimeout`-based watchdog so a hung c-ares
2295
+ * query (or a broken AbortSignal propagation) cannot pin the inflight
2296
+ * Map indefinitely. The leaked DNS promise continues running in the
2297
+ * background — c-ares eventually abandons it on its own — but the
2298
+ * wrapper rejects on time and the inflight key is always cleared.
2299
+ *
2300
+ * Logged at INFO so the watchdog firing is visible at default
2301
+ * `debug: true`; the `WATCHDOG fired` line tells you which domain is
2302
+ * misbehaving.
2303
+ */
2304
+ private _withWatchdog;
2239
2305
  /**
2240
2306
  * Build a Valid response with `websiteTitle` and optional `loginUrl`
2241
2307
  * populated from the provider maps in ./provider-webmail.