import type { XMLAdapter, Namespaces, ResolverContext, RegistrationHistory } from "../types/index.js"; type XPathTextGetter = (xpath: string) => string | null; type NamespaceResolver = (prefix: string | null) => string | null; /** * Creates a reusable namespace resolver function * * @param namespaces - Namespace mappings * @returns Resolver function for XPath namespace prefixes */ export declare function createNamespaceResolver(namespaces: Namespaces): NamespaceResolver; /** * Helper to get text content from a node * * @param node - XML node or null * @returns Trimmed text content or null */ export declare function getTextContent(node: Node | null): string | null; /** * Creates an XPath text getter bound to a specific context node * * This eliminates the need to create identical getText helper functions * in every determination parser. * * @param contextNode - Node to query from * @param adapter - XML adapter * @param namespaces - Namespace mappings * @returns Function that gets text from XPath expressions * * @example * ```typescript * const getText = createXPathTextGetter(detNode, adapter, namespaces); * const procedure = getText('./bhrgtcom:determinationProcedure'); * const method = getText('./bhrgtcom:determinationMethod'); * ``` */ export declare function createXPathTextGetter(contextNode: Node, adapter: XMLAdapter, namespaces: Namespaces): XPathTextGetter; /** * Find a child element using XPath * * @param parentNode - Parent node to search from * @param childPath - XPath to child element * @param adapter - XML adapter * @param namespaces - Namespace mappings * @returns Child node or null if not found */ export declare function findChildElement(parentNode: Node, childPath: string, adapter: XMLAdapter, namespaces: Namespaces): Node | null; /** * Extract an array of typed objects from XPath results * * @param contextNode - Node to query from * @param xpathPattern - XPath expression to find array elements * @param mapFn - Function to transform each node into typed object * @param adapter - XML adapter * @param namespaces - Namespace mappings * @returns Array of non-null results * * @example * ```typescript * const points = extractArray( * detNode, * './bhrgtcom:plasticityAtSpecificWaterContent', * (node, getText) => ({ * waterContent: parseFloat(getText('./bhrgtcom:waterContent')), * numberOfFalls: parseInt(getText('./bhrgtcom:numberOfFalls') ?? '0', 10) * }), * adapter, * namespaces * ); * ``` */ export declare function extractArray(contextNode: Node, xpathPattern: string, mapFn: (node: Node, getText: XPathTextGetter) => T | null, adapter: XMLAdapter, namespaces: Namespaces): Array; /** * Configuration for optional layer fields */ export interface OptionalLayerField { /** XPath to the field element */ xpath: string; /** Property name on the result object */ key: keyof T; /** Optional transform function (defaults to returning trimmed text or null) */ transform?: (text: string | null) => unknown; /** * If true, only set property when value is non-null/non-empty. * Used for truly optional properties like 'color' that should * not appear on the object if absent from XML. */ omitIfEmpty?: boolean; } /** * Configuration for layer parser factory */ interface LayerParserConfig { /** XPath to find layer elements */ layerXPath: string; /** Configuration for required fields */ requiredFields: { upperBoundary: string; lowerBoundary: string; soilName: string; soilNameKey: keyof T; }; /** Configuration for optional fields */ optionalFields: Array>; /** * Optional post-processing callback for each layer. * Called after basic fields are extracted, allows adding nested objects * or other complex fields that can't be expressed as simple XPath extractions. */ postProcess?: (layerNode: Node, layer: T, adapter: XMLAdapter, namespaces: Namespaces) => void; } /** * Factory function to create layer parsers * * @param config - Layer parser configuration * @returns Resolver function for parsing layers * * @example * ```typescript * const processBHRGTLayerData = createLayerParser({ * layerXPath: './/bhrgtcom:layer', * requiredFields: { * upperBoundary: './bhrgtcom:upperBoundary', * lowerBoundary: './bhrgtcom:lowerBoundary', * soilName: './bhrgtcom:soil/bhrgtcom:geotechnicalSoilName', * soilNameKey: 'geotechnicalSoilName' * }, * optionalFields: [ * { xpath: './bhrgtcom:soil/bhrgtcom:colour', key: 'color' }, * { xpath: './bhrgtcom:soil/bhrgtcom:dispersedInhomogeneity', key: 'dispersedInhomogeneity', transform: parseBoolean } * ] * }); * ``` */ export declare function createLayerParser(config: LayerParserConfig): (value: string | null, context: { node: Node; adapter: XMLAdapter; namespaces: Namespaces; }) => Array; /** * Extract a set of optional fields into a typed `Partial` the caller can * spread into a layer object (or Object.assign onto one). * * Shared by createLayerParser and bespoke layer parsers so the omitIfEmpty / * transform semantics stay identical everywhere. The only assertion is where a * field's `transform` (typed `=> unknown`) or the raw text is committed to its * declared property type - the inherent XML-to-typed-value boundary. */ export declare function extractOptionalFields(fields: Array>, layerNode: Node, adapter: XMLAdapter, namespaces: Namespaces): Partial; /** * Parse space-separated comma-delimited pairs from CSV text * * Handles the common pattern of "value1,value2 value3,value4" format * used in settlement characteristics and other time-series data. * * @param csvText - Space-separated "key,value" pairs * @param parsePair - Function to parse a single key,value pair * @returns Array of parsed objects * * @example * ```typescript * const timeHeightPairs = parseCSVPairs( * csvNode.textContent, * (timeStr, heightStr) => { * const time = parseFloat(timeStr); * const height = parseFloat(heightStr); * return !isNaN(time) && !isNaN(height) * ? { time, height } * : null; * } * ); * ``` */ export declare function parseCSVPairs(csvText: string | null | undefined, parsePair: (key: string, value: string) => T | null): Array; /** * Parse space-separated comma-delimited rows with multiple columns * * Handles CSV data with arbitrary number of columns per row. * Format: "col1,col2,col3,... col1,col2,col3,..." (space-separated rows) * * @param csvText - Space-separated CSV rows * @param parseRow - Function to parse a single row's columns into an object * @returns Array of parsed objects * * @example * ```typescript * const measurements = parseCSVRows( * csvNode.textContent, * (columns) => { * if (columns.length < 6) return null; * return { * time: parseFloat(columns[0]), * strain: parseFloat(columns[1]), * stress: parseFloat(columns[2]), * pressure: parseFloat(columns[3]), * porePressure: parseFloat(columns[4]) ?? null, * volumeChange: parseFloat(columns[5]) ?? null * }; * } * ); * ``` */ export declare function parseCSVRows(csvText: string | null | undefined, parseRow: (columns: Array) => T | null): Array; /** * Parse the BRO registration history. * * Shared by every registration type (CPT, BHR-GT, BHR-G): the `registrationHistory` * element is a direct child of the registration object and its children are all * `brocom:*`, identical across domains - only the container's ds-namespace differs, * which we sidestep with a namespace-agnostic local-name() match. */ export declare function processRegistrationHistory(_value: string | null, context: ResolverContext): RegistrationHistory | null; export {}; //# sourceMappingURL=bore-resolver-utils.d.ts.map