Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
52 lines
2.3 KiB
Plaintext
52 lines
2.3 KiB
Plaintext
/**
|
|
* @param {string | null | undefined} a
|
|
* @param {string | null | undefined} b
|
|
* @param {string=} digits
|
|
* @return {string}
|
|
*/
|
|
export function generateKeyBetween(a: string | null | undefined, b: string | null | undefined, digits?: string | undefined): string;
|
|
/**
|
|
* same preconditions as generateKeysBetween.
|
|
* n >= 0.
|
|
* Returns an array of n distinct keys in sorted order.
|
|
* If a and b are both null, returns [a0, a1, ...]
|
|
* If one or the other is null, returns consecutive "integer"
|
|
* keys. Otherwise, returns relatively short keys between
|
|
* a and b.
|
|
* @param {string | null | undefined} a
|
|
* @param {string | null | undefined} b
|
|
* @param {number} n
|
|
* @param {string} digits
|
|
* @return {string[]}
|
|
*/
|
|
export function generateNKeysBetween(a: string | null | undefined, b: string | null | undefined, n: number, digits?: string): string[];
|
|
/**
|
|
* THIS FILE IS BASED ON:
|
|
* https://github.com/rocicorp/fractional-indexing/blob/main/src/index.js
|
|
*
|
|
* MODIFIED FOR PAYLOAD CMS:
|
|
* - Changed the integer part encoding to use only digits for "small" keys and
|
|
* only lowercase letters for "large" keys, ensuring consistent ordering
|
|
* across databases with different collations.
|
|
*
|
|
* - Original algorithm used A-Z (uppercase) for "smaller" integers and a-z (lowercase)
|
|
* for "larger" integers, relying on ASCII ordering where 'Z' < 'a'.
|
|
*
|
|
* - Some databases (e.g., PostgreSQL with default collation) use case-insensitive
|
|
* comparison, treating 'Z' as 'z', which breaks the ordering.
|
|
*
|
|
* - New encoding:
|
|
* - Uses digits '0'-'9' for "small" integers (10 values, lengths 11 down to 2)
|
|
* - Uses lowercase 'a'-'z' for "large" integers (26 values, lengths 2 up to 27)
|
|
* - Digits ALWAYS sort before letters in both ASCII and case-insensitive orderings.
|
|
*
|
|
* - Ordering: '0...' < '1...' < ... < '9..' < 'a.' < 'b..' < ... < 'z...'
|
|
*
|
|
* BACKWARD COMPATIBILITY:
|
|
* - Existing keys starting with lowercase 'a'-'z' remain valid and work correctly.
|
|
* - Keys starting with uppercase 'A'-'Z' (from the old algorithm) will still be
|
|
* parsed for backward compatibility, but they may sort incorrectly in
|
|
* case-insensitive databases. Consider running a migration to convert them.
|
|
*/
|
|
export const BASE_36_DIGITS: "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
//# sourceMappingURL=fractional-indexing.d.ts.map |