/** * Browser-compatible test detection utilities. * This module provides pure parsing functionality that works with strings/objects, * without dependencies on Node.js file system or path modules. */ import { FileType } from "./fileTypes.js"; /** * Creates a RegExp from a pattern string with safety checks against ReDoS. * Returns null if the pattern is invalid or potentially unsafe. Results are * memoized per `(pattern, flags)` for the lifetime of the process. * * These patterns come from trusted file type configuration rather than * arbitrary user input. */ export declare function safeRegExp(pattern: string, flags: string): RegExp | null; /** * Deterministic 8-hex-char content hash (FNV-1a, 32-bit). Used to derive * stable fallback IDs from a test's or step's authored definition so the same * content produces the same ID on every run — that's what makes run-over-run * result comparison possible. Pure JS (no node:crypto) so it stays * browser-compatible. */ export declare function contentHash(value: any): string; /** * Precomputes an array of line-start character offsets for the given content. * Each entry is the index of the first character on that line (0-indexed offsets, 1-indexed lines). */ export declare function getLineStarts(content: string): number[]; /** * Returns the 1-indexed line number for a given character index. * Uses binary search over precomputed line starts, or scans linearly if none provided. */ export declare function getLineNumber(content: string, index: number, lineStarts?: number[]): number; export { FileType } from "./fileTypes.js"; export interface DetectTestsConfig { detectSteps?: boolean; origin?: string; logLevel?: string; _herettoPathMapping?: Record; } export interface DetectedTest { testId?: string; detectSteps?: boolean; steps: Array>; [key: string]: any; } export interface DetectTestsInput { content: string; filePath?: string; fileType?: FileType; config?: DetectTestsConfig; /** * Base used for generated testIds (`~`). Callers * that know the spec's stable ID (e.g. core's path-derived specId) should * pass it here; defaults to the normalized filePath. */ testIdBase?: string; } /** * Browser-compatible test detection function. * Detects tests from content string using specified file type configuration. * * This is the main entry point for test detection in Common. * It works with content strings rather than file paths, making it browser-compatible. * * @param input - Detection input * @param input.content - Content string to parse for tests * @param input.filePath - File path (for metadata only, not file I/O) * @param input.fileType - File type configuration with parsing rules * @param input.config - Optional configuration * @returns Array of detected tests * * @example * ```typescript * const tests = await detectTests({ * content: markdownContent, * filePath: 'docs/test.md', * fileType: { extensions: ['md'], markup: [...] }, * config: { detectSteps: true } * }); * ``` */ export declare function detectTests(input: DetectTestsInput): Promise; /** * Parses XML-style attributes to an object. * Example: 'wait=500' becomes { wait: 500 } * Example: 'testId="myTestId" detectSteps=false' becomes { testId: "myTestId", detectSteps: false } * Example: 'httpRequest.url="https://example.com"' becomes { httpRequest: { url: "https://example.com" } } */ export declare function parseXmlAttributes({ stringifiedObject }: { stringifiedObject: string; }): Record | null; /** * Parses a JSON or YAML object from a string. */ export declare function parseObject({ stringifiedObject }: { stringifiedObject: string; }): Record | null; /** * Replaces numeric variables ($0, $1, etc.) in strings and objects with provided values. */ export declare function replaceNumericVariables(stringOrObjectSource: string | Record, values: Record): string | Record | null; /** * Parses raw test content into an array of structured test objects. * This is a browser-compatible function that works with strings and doesn't require file system access. * * @param options - Options for parsing * @param options.config - Test configuration object * @param options.content - Raw file content as a string * @param options.filePath - Path to the file being parsed (for metadata, not file I/O) * @param options.fileType - File type definition containing parsing rules * @returns Array of parsed and validated test objects */ export declare function parseContent({ config, content, filePath, fileType, testIdBase, }: { config?: DetectTestsConfig; content: string; filePath?: string; fileType?: FileType; testIdBase?: string; }): Promise; /** * Simple browser-compatible logging function. */ export declare function log(config: DetectTestsConfig, level: string, message: any): void; //# sourceMappingURL=detectTests.d.ts.map