Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typescript definitions #3

Open
BelfordZ opened this issue Mar 27, 2018 · 3 comments
Open

Add typescript definitions #3

BelfordZ opened this issue Mar 27, 2018 · 3 comments

Comments

@BelfordZ
Copy link

As the title suggests =P

@krei-se
Copy link

krei-se commented Aug 23, 2024

Plus one

@GregLtrnr
Copy link

GregLtrnr commented Oct 15, 2024

Here's an example for the lib declaration that I use, you can surely use it to include it to the project

declare module "node-dig-dns" {
  interface MXRecord {
    priority: number;
    server: string;
  }

  interface ParsedSection {
    domain: string;
    type: string;
    ttl: string | number;
    class: string;
    value: string | MXRecord;
  }

  interface ParsedResult {
    header?: ParsedSection[];
    question?: ParsedSection[];
    answer?: ParsedSection[];
    authority?: ParsedSection[];
    additional?: ParsedSection[];
    time: number;
    server: string;
    datetime: string;
    size: number;
  }

  interface DigOptions {
    /**
     * Get the raw output as a string. If `+short` option is passed in `args`, raw output is returned by default.
     */
    raw?: boolean;

    /**
     * Manually set the dig command (e.g., '/my/custom/path/to/dig').
     */
    dig?: string;
  }

  /**
   * Parses a DNS section based on its values.
   * @param values Array of section values.
   * @param section The section type (e.g., 'answer', 'additional').
   */
  function parseSection(values: any[], section: string): ParsedSection | any[];

  /**
   * Parses the output from the `dig` command.
   * @param output The raw output from the `dig` command.
   * @returns A parsed object containing DNS information.
   */
  function parse(output?: string): ParsedResult;

  /**
   * Runs the `dig` command with given arguments.
   * @param args Array of arguments for the `dig` command.
   * @param options Options for executing the `dig` command.
   * @returns A promise that resolves with the result of the `dig` command.
   */
  function dig(args?: string[], options?: DigOptions): Promise<ParsedResult | string>;

  export default dig;
}

@StephanGeorg
Copy link
Owner

Thank you @GregLtrnr. Could you pls add a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants