/** * This Source Code is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (c) Infonomic Company Limited * * Fractional-index keys for stable, drag-and-drop reordering without a * rebalancing pass. Keys are base-62 strings that sort lexicographically; * `generateKeyBetween(a, b)` produces a new key strictly between two * neighbors (or before/after a single neighbor when the other is null). * * Implementation follows David Greenspan's algorithm * (https://observablehq.com/@dgreensp/implementing-fractional-indexing). * Each key has two parts: a head character that encodes the integer-part * length, followed by the integer digits and an optional base-62 fraction. * Heads 'A'..'Z' carry positive integer-part lengths 2..27; heads 'a'..'z' * carry negative integer-part lengths 2..27. This allows unbounded * prepend/append without ever needing a rebalance. * * Used by `orderable: true` collections to drive the * `byline_documents.order_key` column. */ /** * Validate a complete order_key — head + integer + optional fraction. * Returns true if the key is well-formed; false otherwise. Does not throw. */ export declare function validateOrderKey(key: string): boolean; /** * Generate an order_key strictly between `a` and `b`. * * - `(null, null)` returns a midpoint near zero * - `(a, null)` returns a key greater than `a` * - `(null, b)` returns a key less than `b` * - `(a, b)` returns a key strictly between (requires `a < b`) * * Throws if `a >= b`, if either key is malformed, or if the integer * head is already at its extreme bound (effectively never under normal * use — would require ~10^40 unbounded prepends or appends). */ export declare function generateKeyBetween(a: string | null, b: string | null): string; /** * Generate `n` order_keys strictly between `a` and `b`, in ascending order. * Used when inserting a contiguous run of rows (bulk import, multi-select drop). */ export declare function generateNKeysBetween(a: string | null, b: string | null, n: number): string[];