/* tslint:disable */
/* eslint-disable */

/* auto-generated by NAPI-RS */

/** MatchData struct represents a match found by a YARA rule. */
export interface MatchData {
  /** The offset of the match in the scanned data. */
  offset: number
  /** The length of the matched data. */
  length: number
  /** The matched data as a string. */
  data: string
  /** The identifier of the pattern that matched. */
  identifier: string
}
/**
 * RuleMatch struct represents a matching rule found during scanning.
 *
 * See [yara_::Match](https://docs.rs/yara-x/latest/yara_x/struct.Match.html) for more details.
 */
export interface RuleMatch {
  /** The identifier of the rule that matched. */
  ruleIdentifier: string
  /** The namespace of the rule that matched. */
  namespace: string
  /** The metadata associated with the rule that matched. */
  meta: object
  /** The tags associated with the rule that matched. */
  tags: Array<string>
  /** The matches found by the rule. */
  matches: Array<MatchData>
}
/**
 * CompilerOptions struct represents the options for the YARA compiler.
 *
 * See [yara_x::Compiler](https://docs.rs/yara-x/latest/yara_x/struct.Compiler.html) for more
 * details.
 */
export interface CompilerOptions {
  /** Defines global variables for the YARA rules. */
  defineVariables?: object
  /** A list of module names to ignore during compilation. */
  ignoreModules?: Array<string>
  /** A list of banned modules that cannot be used in the YARA rules. */
  bannedModules?: Array<BannedModule>
  /** A list of features to enable for the YARA rules. */
  features?: Array<string>
  /** Whether to use relaxed regular expression syntax. */
  relaxedReSyntax?: boolean
  /** Whether to optimize conditions in the YARA rules. */
  conditionOptimization?: boolean
  /** Whether to raise an error on slow patterns. */
  errorOnSlowPattern?: boolean
  /** Whether to raise an error on slow loops. */
  errorOnSlowLoop?: boolean
}
/** BannedModule struct represents a module that is banned from being used in YARA rules. */
export interface BannedModule {
  /** The name of the banned module. */
  name: string
  /** The title of the error message if the module is used. */
  errorTitle: string
  /** The error message if the module is used. */
  errorMessage: string
}
/**
 * CompilerWarning struct represents a warning generated by the YARA compiler.
 *
 * See [yara_x::CompilerWarning](https://docs.rs/yara-x/latest/yara_x/warnings/enum.Warning.html)
 * for more details.
 */
export interface CompilerWarning {
  /** The code of the warning. */
  code: string
  /** The message of the warning. */
  message: string
  /** The source of the warning, if available. */
  source?: string
  /** The line number where the warning occurred, if available. */
  line?: number
  /** The column number where the warning occurred, if available. */
  column?: number
}
/**
 * CompilerError struct represents an error generated by the YARA compiler.
 *
 * See
 * [yara_x::CompileError](https://docs.rs/yara-x/latest/yara_x/errors/enum.CompileError.html)
 * for more details.
 */
export interface CompilerError {
  /** The code of the error. */
  code: string
  /** The message of the error. */
  message: string
  /** The source of the error, if available. */
  source?: string
  /** The line number where the error occurred, if available. */
  line?: number
  /** The column number where the error occurred, if available. */
  column?: number
}
/**
 * CompileResult struct represents the result of compiling YARA rules.
 * It contains any warnings or errors generated during the compilation process.
 */
export interface CompileResult {
  /** Any warnings generated during the compilation process. */
  warnings: Array<CompilerWarning>
  /** Any errors generated during the compilation process. */
  errors: Array<CompilerError>
}
/**
 * Compiles a YARA rule source string and returns any warnings or errors generated during the
 * compilation process.
 *
 * Exported as `validate` in the NAPI interface.
 *
 * Example
 *
 * ```javascript
 * const { validate } = require('your_yara_module');
 * const result = validate('rule example { strings: $a = "example" condition: $a }');
 * ```
 */
export declare function validate(ruleSource: string, options?: CompilerOptions | undefined | null): CompileResult
/**
 * Compiles a YARA rule source string and returns a YaraX instance with the compiled rules.
 *
 * Exported as `compile` in the NAPI interface.
 *
 * Example
 *
 * ```javascript
 * const { compile } = require('your_yara_module');
 * const yarax = compile('rule example { strings: $a = "example" condition: $a }');
 * ```
 */
export declare function compile(ruleSource: string, options?: CompilerOptions | undefined | null): YaraX
/**
 * Creates a new YaraX instance with empty rules and no source code.
 *
 * Exported as `create` in the NAPI interface.
 *
 * Example
 *
 * ```javascript
 * const { create } = require('your_yara_module');
 * const yarax = create();
 *
 * // Now you can add rules or compile them later
 *
 * yarax.addRuleSource('rule example { strings: $a = "example" condition: $a }');
 * yarax.addRuleFile('path/to/rule_file.yar');
 * yarax.defineVariable('myVar', 'myValue');
 * ```
 */
export declare function create(): YaraX
/**
 * Creates a new YaraX instance from a file containing YARA rules.
 *
 * Exported as `fromFile` in the NAPI interface.
 *
 * Example
 *
 * ```javascript
 * const { fromFile } = require('your_yara_module');
 * const yarax = fromFile('path/to/rule_file.yar');
 * ```
 */
export declare function fromFile(rulePath: string, options?: CompilerOptions | undefined | null): YaraX
/**
 * Compiles a YARA rule source string to a WASM file.
 *
 * Exported as `compileToWasm` in the NAPI interface.
 *
 * Example
 *
 * ```javascript
 * const { compileToWasm } = require('your_yara_module');
 * compileToWasm('rule example { strings: $a = "example" condition: $a }', 'output.wasm');
 * ```
 */
export declare function compileToWasm(ruleSource: string, outputPath: string, options?: CompilerOptions | undefined | null): void
/**
 * Compiles a YARA rule file to a WASM file.
 *
 * Exported as `compileFileToWasm` in the NAPI interface.
 *
 * Example
 *
 * ```javascript
 * const { compileFileToWasm } = require('your_yara_module');
 * compileFileToWasm('path/to/rule_file.yar', 'output.wasm');
 * ```
 */
export declare function compileFileToWasm(rulePath: string, outputPath: string, options?: CompilerOptions | undefined | null): void
/**
 * YaraX struct represents the YARA rules and their associated data.
 * It contains the compiled rules, source code, warnings, and variables.
 *
 * See [yara_x::Rules](https://docs.rs/yara-x/latest/yara_x/struct.Rules.html) for more details.
 */
export declare class YaraX {
  getWarnings(): Array<CompilerWarning>
  /**
   * Scans the provided data using the compiled YARA rules.
   * This function takes the scanned data and an optional object of variables,
   * and returns a vector of RuleMatch representing the matching rules found during the scan.
   */
  scan(data: Buffer, variables?: Record<string, string | number>): Array<RuleMatch>
  /**
   * Scans a file using the compiled YARA rules.
   * This function takes the file path and an optional object of variables,
   * and returns a vector of RuleMatch representing the matching rules found during the scan.
   */
  scanFile(filePath: string, variables?: Record<string, string | number>): Array<RuleMatch>
  /**
   * Emits a WASM file from the compiled YARA rules.
   * This function takes the output path and writes the compiled rules to a WASM file.
   */
  emitWasmFile(outputPath: string): void
  /**
   * Scans the provided data asynchronously using the compiled YARA rules.
   * This function takes the scanned data and an optional object of variables,
   * and returns an AsyncTask that will resolve to a vector of RuleMatch representing the matching
   * rules found during the scan.
   *
   * This allows for non-blocking scanning of data, which can be useful for large datasets or
   * performance-critical applications.
   */
  scanAsync(data: Buffer, variables?: object | undefined | null): Promise<unknown>
  /**
   * Scans a file asynchronously using the compiled YARA rules.
   * This function takes the file path and an optional object of variables,
   * and returns an AsyncTask that will resolve to a vector of RuleMatch representing the matching
   * rules found during the scan.
   *
   * This allows for non-blocking scanning of files, which can be useful for large files or
   * performance-critical applications.
   */
  scanFileAsync(filePath: string, variables?: object | undefined | null): Promise<unknown>
  /**
   * Emits a WASM file asynchronously from the compiled YARA rules.
   * This function takes the output path
   * and returns an AsyncTask that will resolve when the WASM file is successfully emitted.
   */
  emitWasmFileAsync(outputPath: string): Promise<unknown>
  /**
   * Adds a rule source to the YARA compiler.
   * This function takes a rule source string,
   * compiles it, and updates the YaraX instance with the new rules.
   */
  addRuleSource(ruleSource: string): void
  /**
   * Adds a rule file to the YARA compiler.
   * This function takes a file path,
   * reads the file content, and adds it to the YaraX instance.
   */
  addRuleFile(filePath: string): void
  /**
   * Defines a variable for the YARA compiler.
   * This function takes a variable name and value,
   * and adds it to the YaraX instance.
   */
  defineVariable(name: string, value: string): void
}
