import type { SQL } from 'drizzle-orm';
/**
 * ============================================================================
 * SEMANTIC VERSION SORTING IN SQLITE
 * ============================================================================
 *
 * SQLite lacks native semantic version comparison, so we convert versions
 * into sortable strings. The key insight is that string comparison uses
 * ASCII/Unicode ordering, so we can control sort order through prefixes
 * and zero-padding.
 *
 * ## Sort Strategy (for descending order)
 *
 * We transform versions into strings that sort correctly when compared lexicographically:
 *
 * | Version Type         | Transformation                      | Example Result          |
 * |----------------------|-------------------------------------|-------------------------|
 * | not_specified_version| Prefix with '!'                     | '!not_specified'        |
 * | null/empty           | Padded zeros                        | '0000000000.0000...'    |
 * | Numeric (1.2.3)      | Zero-padded to 10 digits per part   | '0000000001.0000000002.0000000003' |
 * | Text (latest)        | Prefix with 'Z'                     | 'ZZZZZZZZZZ.latest'     |
 *
 * ASCII ordering ensures: '!' < '0' < 'Z', giving us:
 *   latest > 10.0.0 > 3.1 > 1 > null > not_specified_version
 *
 * ## Why Zero-Padding?
 *
 * Without padding, string comparison fails for multi-digit numbers:
 *   '9' > '10' (wrong!)  vs  '0000000009' < '0000000010' (correct!)
 *
 * We use 10 digits to support versions up to 9,999,999,999 per component.
 */
/**
 * Builds SQL expression for semantic version sorting in SQLite.
 * Handles versions like: 1, 1.0, 1.0.0, 10.2.3, latest, etc.
 *
 * @param versionColumn - The column name or expression containing the version
 * @returns SQL expression that can be used in ORDER BY for descending version sort
 *
 * @example
 * ```sql
 * ORDER BY ${buildSemanticVersionSortExpr('version')} DESC
 * -- Sorts: latest, 10.0.0, 3.1, 3, 2.0.1, 1, not_specified_version
 * ```
 */
export declare function buildSemanticVersionSortExpr(versionColumn: string): SQL;
/**
 * ============================================================================
 * VERSION COMPARISON FILTER
 * ============================================================================
 */
/**
 * Builds a SQL condition that checks no higher semantic version exists
 * for the same key in either local or remote database.
 *
 * This is used to find the "current" version of an entity when multiple
 * versions exist across local and remote databases.
 *
 * ## Logic
 *
 * Returns TRUE if there is NO other entity with the same key that has:
 *   1. A higher semantic version, OR
 *   2. The same version but a higher revision number
 *
 * ## Example
 *
 * Given entities with key='my-api':
 *   - Local:  version='1.0.0', revision=1
 *   - Remote: version='1.0.0', revision=2  ← This one wins (same version, higher revision)
 *   - Remote: version='2.0.0', revision=1  ← This one wins (higher version)
 *
 * @param keyExpr - SQL expression for the entity's key (e.g., 'entities.key')
 * @param versionExpr - SQL expression for the entity's version (e.g., 'entities.version')
 * @param revisionExpr - SQL expression for the entity's revision (e.g., 'entities.revision')
 * @returns SQL expression that evaluates to TRUE if this is the highest version
 */
export declare function buildNoHigherVersionExistsFilter(keyExpr: string, versionExpr: string, revisionExpr: string): SQL;
//# sourceMappingURL=semantic-version-sort.d.ts.map