Files
klz-cables.com/.pnpm-store/v10/files/63/54ab8d5523b9e4b409ead9a25ea7243b826e212ee13a78ecae2ed631e122d4aecd1c9a60cef952ebcec0d7446c88d7a6639187902606a64d9deb6fdcb01f7c
Marc Mintel 5397309103
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
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

1 line
19 KiB
Plaintext

{"version":3,"sources":["../../../src/config/orderable/fractional-indexing.js"],"sourcesContent":["// @ts-no-check\n\n/**\n * THIS FILE IS BASED ON:\n * https://github.com/rocicorp/fractional-indexing/blob/main/src/index.js\n *\n * MODIFIED FOR PAYLOAD CMS:\n * - Changed the integer part encoding to use only digits for \"small\" keys and\n * only lowercase letters for \"large\" keys, ensuring consistent ordering\n * across databases with different collations.\n *\n * - Original algorithm used A-Z (uppercase) for \"smaller\" integers and a-z (lowercase)\n * for \"larger\" integers, relying on ASCII ordering where 'Z' < 'a'.\n *\n * - Some databases (e.g., PostgreSQL with default collation) use case-insensitive\n * comparison, treating 'Z' as 'z', which breaks the ordering.\n *\n * - New encoding:\n * - Uses digits '0'-'9' for \"small\" integers (10 values, lengths 11 down to 2)\n * - Uses lowercase 'a'-'z' for \"large\" integers (26 values, lengths 2 up to 27)\n * - Digits ALWAYS sort before letters in both ASCII and case-insensitive orderings.\n *\n * - Ordering: '0...' < '1...' < ... < '9..' < 'a.' < 'b..' < ... < 'z...'\n *\n * BACKWARD COMPATIBILITY:\n * - Existing keys starting with lowercase 'a'-'z' remain valid and work correctly.\n * - Keys starting with uppercase 'A'-'Z' (from the old algorithm) will still be\n * parsed for backward compatibility, but they may sort incorrectly in\n * case-insensitive databases. Consider running a migration to convert them.\n */\n\n// License: CC0 (no rights reserved).\n\n// This is based on https://observablehq.com/@dgreensp/implementing-fractional-indexing\n\nexport const BASE_36_DIGITS = '0123456789abcdefghijklmnopqrstuvwxyz'\n\n// `a` may be empty string, `b` is null or non-empty string.\n// `a < b` lexicographically if `b` is non-null.\n// no trailing zeros allowed.\n// digits is a string such as '0123456789' for base 10. Digits must be in\n// ascending character code order!\n/**\n * @param {string} a\n * @param {string | null | undefined} b\n * @param {string} digits\n * @returns {string}\n */\nfunction midpoint(a, b, digits) {\n const zero = digits[0]\n if (b != null && a >= b) {\n throw new Error(a + ' >= ' + b)\n }\n if (a.slice(-1) === zero || (b && b.slice(-1) === zero)) {\n throw new Error('trailing zero')\n }\n if (b) {\n // remove longest common prefix. pad `a` with 0s as we\n // go. note that we don't need to pad `b`, because it can't\n // end before `a` while traversing the common prefix.\n let n = 0\n while ((a[n] || zero) === b[n]) {\n n++\n }\n if (n > 0) {\n return b.slice(0, n) + midpoint(a.slice(n), b.slice(n), digits)\n }\n }\n // first digits (or lack of digit) are different\n const digitA = a ? digits.indexOf(a[0]) : 0\n const digitB = b != null ? digits.indexOf(b[0]) : digits.length\n if (digitB - digitA > 1) {\n const midDigit = Math.round(0.5 * (digitA + digitB))\n return digits[midDigit]\n } else {\n // first digits are consecutive\n if (b && b.length > 1) {\n return b.slice(0, 1)\n } else {\n // `b` is null or has length 1 (a single digit).\n // the first digit of `a` is the previous digit to `b`,\n // or 9 if `b` is null.\n // given, for example, midpoint('49', '5'), return\n // '4' + midpoint('9', null), which will become\n // '4' + '9' + midpoint('', null), which is '495'\n return digits[digitA] + midpoint(a.slice(1), null, digits)\n }\n }\n}\n\n/**\n * @param {string} int\n * @return {void}\n */\n\nfunction validateInteger(int) {\n if (int.length !== getIntegerLength(int[0])) {\n throw new Error('invalid integer part of order key: ' + int)\n }\n}\n\n/**\n * Returns the length of the integer part based on the head character.\n *\n * New encoding (case-insensitive safe):\n * - SMALL range (digits): '0' = 11 chars, '1' = 10 chars, ..., '9' = 2 chars\n * - LARGE range (lowercase): 'a' = 2 chars, 'b' = 3 chars, ..., 'z' = 27 chars\n *\n * Legacy encoding (for backward compatibility with existing keys):\n * - 'A'-'Z' uppercase: 'A' = 27 chars, 'B' = 26 chars, ..., 'Z' = 2 chars\n *\n * @param {string} head\n * @return {number}\n */\nfunction getIntegerLength(head) {\n if (head >= '0' && head <= '9') {\n return 11 - (head.charCodeAt(0) - '0'.charCodeAt(0))\n } else if (head >= 'a' && head <= 'z') {\n return head.charCodeAt(0) - 'a'.charCodeAt(0) + 2\n } else if (head >= 'A' && head <= 'Z') {\n // Legacy encoding\n return 'Z'.charCodeAt(0) - head.charCodeAt(0) + 2\n } else {\n throw new Error('invalid order key head: ' + head)\n }\n}\n\n/**\n * @param {string} key\n * @return {string}\n */\n\nfunction getIntegerPart(key) {\n const integerPartLength = getIntegerLength(key[0])\n if (integerPartLength > key.length) {\n throw new Error('invalid order key: ' + key)\n }\n return key.slice(0, integerPartLength)\n}\n\n/**\n * Smallest possible key (for validation)\n * '0' + 10 zeros = smallest valid key in new format\n */\nconst SMALLEST_KEY = '0' + BASE_36_DIGITS[0].repeat(10)\n\n/**\n * @param {string} key\n * @param {string} digits\n * @return {void}\n */\n\nfunction validateOrderKey(key, digits) {\n if (key === SMALLEST_KEY) {\n throw new Error('invalid order key: ' + key)\n }\n // Legacy check for old format\n if (key === 'A' + digits[0].repeat(26)) {\n throw new Error('invalid order key: ' + key)\n }\n // getIntegerPart will throw if the first character is bad,\n // or the key is too short. we'd call it to check these things\n // even if we didn't need the result\n const i = getIntegerPart(key)\n const f = key.slice(i.length)\n if (f.slice(-1) === digits[0]) {\n throw new Error('invalid order key: ' + key)\n }\n}\n\n// note that this may return null, as there is a largest integer\n/**\n * @param {string} x\n * @param {string} digits\n * @return {string | null}\n */\nfunction incrementInteger(x, digits) {\n validateInteger(x)\n const [head, ...digs] = x.split('')\n let carry = true\n for (let i = digs.length - 1; carry && i >= 0; i--) {\n const d = digits.indexOf(digs[i]) + 1\n if (d === digits.length) {\n digs[i] = digits[0]\n } else {\n digs[i] = digits[d]\n carry = false\n }\n }\n if (carry) {\n if (head === '9') {\n return 'a' + digits[0]\n }\n // Handle legacy uppercase transition\n if (head === 'Z') {\n return 'a' + digits[0]\n }\n if (head === 'z') {\n return null\n }\n\n let h\n if (head >= '0' && head <= '8') {\n h = String.fromCharCode(head.charCodeAt(0) + 1)\n digs.pop()\n } else if (head >= 'a' && head <= 'y') {\n h = String.fromCharCode(head.charCodeAt(0) + 1)\n digs.push(digits[0])\n } else if (head >= 'A' && head <= 'Y') {\n // Legacy uppercase\n h = String.fromCharCode(head.charCodeAt(0) + 1)\n digs.pop()\n } else {\n throw new Error('invalid head: ' + head)\n }\n return h + digs.join('')\n } else {\n return head + digs.join('')\n }\n}\n\n// note that this may return null, as there is a smallest integer\n/**\n * @param {string} x\n * @param {string} digits\n * @return {string | null}\n */\n\nfunction decrementInteger(x, digits) {\n validateInteger(x)\n const [head, ...digs] = x.split('')\n let borrow = true\n for (let i = digs.length - 1; borrow && i >= 0; i--) {\n const d = digits.indexOf(digs[i]) - 1\n if (d === -1) {\n digs[i] = digits.slice(-1)\n } else {\n digs[i] = digits[d]\n borrow = false\n }\n }\n if (borrow) {\n if (head === 'a') {\n return '9' + digits.slice(-1)\n }\n if (head === '0') {\n return null\n }\n\n let h\n if (head >= '1' && head <= '9') {\n h = String.fromCharCode(head.charCodeAt(0) - 1)\n digs.push(digits.slice(-1))\n } else if (head >= 'b' && head <= 'z') {\n h = String.fromCharCode(head.charCodeAt(0) - 1)\n digs.pop()\n } else if (head >= 'B' && head <= 'Z') {\n // Legacy uppercase\n h = String.fromCharCode(head.charCodeAt(0) - 1)\n digs.push(digits.slice(-1))\n } else if (head === 'A') {\n // Legacy uppercase\n return null\n } else {\n throw new Error('invalid head: ' + head)\n }\n return h + digs.join('')\n } else {\n return head + digs.join('')\n }\n}\n\n// `a` is an order key or null (START).\n// `b` is an order key or null (END).\n// `a < b` lexicographically if both are non-null.\n// digits is a string such as '0123456789' for base 10. Digits must be in\n// ascending character code order!\n/**\n * @param {string | null | undefined} a\n * @param {string | null | undefined} b\n * @param {string=} digits\n * @return {string}\n */\nexport function generateKeyBetween(a, b, digits = BASE_36_DIGITS) {\n if (a != null) {\n validateOrderKey(a, digits)\n }\n if (b != null) {\n validateOrderKey(b, digits)\n }\n if (a != null && b != null && a >= b) {\n throw new Error(a + ' >= ' + b)\n }\n if (a == null) {\n if (b == null) {\n return 'a' + digits[0]\n }\n\n const ib = getIntegerPart(b)\n const fb = b.slice(ib.length)\n if (ib === SMALLEST_KEY) {\n return ib + midpoint('', fb, digits)\n }\n // Legacy check\n if (ib === 'A' + digits[0].repeat(26)) {\n return ib + midpoint('', fb, digits)\n }\n if (ib < b) {\n return ib\n }\n const res = decrementInteger(ib, digits)\n if (res == null) {\n throw new Error('cannot decrement any more')\n }\n return res\n }\n\n if (b == null) {\n const ia = getIntegerPart(a)\n const fa = a.slice(ia.length)\n const i = incrementInteger(ia, digits)\n return i == null ? ia + midpoint(fa, null, digits) : i\n }\n\n const ia = getIntegerPart(a)\n const fa = a.slice(ia.length)\n const ib = getIntegerPart(b)\n const fb = b.slice(ib.length)\n if (ia === ib) {\n return ia + midpoint(fa, fb, digits)\n }\n const i = incrementInteger(ia, digits)\n if (i == null) {\n throw new Error('cannot increment any more')\n }\n if (i < b) {\n return i\n }\n return ia + midpoint(fa, null, digits)\n}\n\n/**\n * same preconditions as generateKeysBetween.\n * n >= 0.\n * Returns an array of n distinct keys in sorted order.\n * If a and b are both null, returns [a0, a1, ...]\n * If one or the other is null, returns consecutive \"integer\"\n * keys. Otherwise, returns relatively short keys between\n * a and b.\n * @param {string | null | undefined} a\n * @param {string | null | undefined} b\n * @param {number} n\n * @param {string} digits\n * @return {string[]}\n */\nexport function generateNKeysBetween(a, b, n, digits = BASE_36_DIGITS) {\n if (n === 0) {\n return []\n }\n if (n === 1) {\n return [generateKeyBetween(a, b, digits)]\n }\n if (b == null) {\n let c = generateKeyBetween(a, b, digits)\n const result = [c]\n for (let i = 0; i < n - 1; i++) {\n c = generateKeyBetween(c, b, digits)\n result.push(c)\n }\n return result\n }\n if (a == null) {\n let c = generateKeyBetween(a, b, digits)\n const result = [c]\n for (let i = 0; i < n - 1; i++) {\n c = generateKeyBetween(a, c, digits)\n result.push(c)\n }\n result.reverse()\n return result\n }\n const mid = Math.floor(n / 2)\n const c = generateKeyBetween(a, b, digits)\n return [\n ...generateNKeysBetween(a, c, mid, digits),\n c,\n ...generateNKeysBetween(c, b, n - mid - 1, digits),\n ]\n}\n"],"names":["BASE_36_DIGITS","midpoint","a","b","digits","zero","Error","slice","n","digitA","indexOf","digitB","length","midDigit","Math","round","validateInteger","int","getIntegerLength","head","charCodeAt","getIntegerPart","key","integerPartLength","SMALLEST_KEY","repeat","validateOrderKey","i","f","incrementInteger","x","digs","split","carry","d","h","String","fromCharCode","pop","push","join","decrementInteger","borrow","generateKeyBetween","ib","fb","res","ia","fa","generateNKeysBetween","c","result","reverse","mid","floor"],"mappings":"AAAA,eAAe;AAEf;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GAED,qCAAqC;AAErC,uFAAuF;AAEvF,OAAO,MAAMA,iBAAiB,uCAAsC;AAEpE,4DAA4D;AAC5D,gDAAgD;AAChD,6BAA6B;AAC7B,0EAA0E;AAC1E,kCAAkC;AAClC;;;;;CAKC,GACD,SAASC,SAASC,CAAC,EAAEC,CAAC,EAAEC,MAAM;IAC5B,MAAMC,OAAOD,MAAM,CAAC,EAAE;IACtB,IAAID,KAAK,QAAQD,KAAKC,GAAG;QACvB,MAAM,IAAIG,MAAMJ,IAAI,SAASC;IAC/B;IACA,IAAID,EAAEK,KAAK,CAAC,CAAC,OAAOF,QAASF,KAAKA,EAAEI,KAAK,CAAC,CAAC,OAAOF,MAAO;QACvD,MAAM,IAAIC,MAAM;IAClB;IACA,IAAIH,GAAG;QACL,uDAAuD;QACvD,4DAA4D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