@simpleapps-com/augur-server 2026.11.1 → 2026.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/EXPORTS.md +1 -1
  2. package/dist/actions/agr-info.d.ts +3 -2
  3. package/dist/actions/agr-info.d.ts.map +1 -1
  4. package/dist/actions/agr-site.d.ts +2 -1
  5. package/dist/actions/agr-site.d.ts.map +1 -1
  6. package/dist/actions/basecamp2.d.ts +3 -2
  7. package/dist/actions/basecamp2.d.ts.map +1 -1
  8. package/dist/actions/brand-folder.d.ts +2 -1
  9. package/dist/actions/brand-folder.d.ts.map +1 -1
  10. package/dist/actions/customers.d.ts +2 -1
  11. package/dist/actions/customers.d.ts.map +1 -1
  12. package/dist/actions/favorites.d.ts +2 -1
  13. package/dist/actions/favorites.d.ts.map +1 -1
  14. package/dist/actions/gregorovich.d.ts +2 -1
  15. package/dist/actions/gregorovich.d.ts.map +1 -1
  16. package/dist/actions/items.d.ts +3 -2
  17. package/dist/actions/items.d.ts.map +1 -1
  18. package/dist/actions/joomla.d.ts +2 -1
  19. package/dist/actions/joomla.d.ts.map +1 -1
  20. package/dist/actions/legacy.d.ts +3 -2
  21. package/dist/actions/legacy.d.ts.map +1 -1
  22. package/dist/actions/logistics.d.ts +3 -2
  23. package/dist/actions/logistics.d.ts.map +1 -1
  24. package/dist/actions/orders.d.ts +2 -1
  25. package/dist/actions/orders.d.ts.map +1 -1
  26. package/dist/actions/p21-apis.d.ts +2 -1
  27. package/dist/actions/p21-apis.d.ts.map +1 -1
  28. package/dist/actions/p21-core.d.ts +3 -2
  29. package/dist/actions/p21-core.d.ts.map +1 -1
  30. package/dist/actions/p21-pim.d.ts +2 -1
  31. package/dist/actions/p21-pim.d.ts.map +1 -1
  32. package/dist/actions/p21-sism.d.ts +2 -1
  33. package/dist/actions/p21-sism.d.ts.map +1 -1
  34. package/dist/actions/pricing.d.ts +3 -2
  35. package/dist/actions/pricing.d.ts.map +1 -1
  36. package/dist/actions/search.d.ts +2 -1
  37. package/dist/actions/search.d.ts.map +1 -1
  38. package/dist/actions/shipping.d.ts +2 -1
  39. package/dist/actions/shipping.d.ts.map +1 -1
  40. package/dist/actions/site.d.ts +6 -5
  41. package/dist/actions/site.d.ts.map +1 -1
  42. package/dist/actions/vmi.d.ts +3 -2
  43. package/dist/actions/vmi.d.ts.map +1 -1
  44. package/dist/actions/wishlists.d.ts +2 -1
  45. package/dist/actions/wishlists.d.ts.map +1 -1
  46. package/dist/api.js +3 -3
  47. package/dist/auth.js +2 -2
  48. package/dist/cache/redis-client.d.ts +4 -2
  49. package/dist/cache/redis-client.d.ts.map +1 -1
  50. package/dist/cache/with-cache.d.ts +9 -10
  51. package/dist/cache/with-cache.d.ts.map +1 -1
  52. package/dist/{chunk-U2BKHRJC.js → chunk-6CSVIBHQ.js} +6 -6
  53. package/dist/chunk-6CSVIBHQ.js.map +1 -0
  54. package/dist/{chunk-NTUPTNOI.js → chunk-A4IVBK6P.js} +2 -2
  55. package/dist/{chunk-SXXWBSTX.js → chunk-INVDQQ7T.js} +2 -2
  56. package/dist/{chunk-PFYEMJTQ.js → chunk-LX7SJJOU.js} +79 -43
  57. package/dist/chunk-LX7SJJOU.js.map +1 -0
  58. package/dist/{chunk-TVH5EONP.js → chunk-OBWQSGB6.js} +36 -9
  59. package/dist/chunk-OBWQSGB6.js.map +1 -0
  60. package/dist/{chunk-FWO6Q43T.js → chunk-UVGG74FO.js} +3 -3
  61. package/dist/duration.d.ts +16 -0
  62. package/dist/duration.d.ts.map +1 -0
  63. package/dist/hooks.js +3 -3
  64. package/dist/index.js +4 -4
  65. package/dist/query-action.js +3 -3
  66. package/dist/query-options-helper.d.ts +7 -6
  67. package/dist/query-options-helper.d.ts.map +1 -1
  68. package/dist/query.js +1 -1
  69. package/dist/rules.d.ts +17 -8
  70. package/dist/rules.d.ts.map +1 -1
  71. package/dist/server-site-registry.d.ts.map +1 -1
  72. package/dist/server-site.d.ts.map +1 -1
  73. package/dist/site.js +9 -8
  74. package/dist/site.js.map +1 -1
  75. package/dist/testing.js +3 -3
  76. package/llms.txt +1 -1
  77. package/package.json +7 -6
  78. package/dist/chunk-PFYEMJTQ.js.map +0 -1
  79. package/dist/chunk-TVH5EONP.js.map +0 -1
  80. package/dist/chunk-U2BKHRJC.js.map +0 -1
  81. /package/dist/{chunk-NTUPTNOI.js.map → chunk-A4IVBK6P.js.map} +0 -0
  82. /package/dist/{chunk-SXXWBSTX.js.map → chunk-INVDQQ7T.js.map} +0 -0
  83. /package/dist/{chunk-FWO6Q43T.js.map → chunk-UVGG74FO.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../utils/src/strings.ts","../src/rules.ts"],"sourcesContent":["//@ backend dafny\nimport {\n isAlnumChar,\n isBase64UrlChar,\n isDigit,\n isHexChar,\n isJsSpace,\n isLineTerminator,\n isLowerHexChar,\n isSnakeChar,\n isWordChar,\n lowerCode,\n} from \"./chars\";\n\n/* String scans and slices, verified with LemmaScript → Dafny (hand lemmas in strings.dfy;\n model: models/Utils.dfy; link: models/links/utils-strings.dfy). Recursive and\n expression-bodied so specs can use them, and each contract pins the result exactly, so\n an importer (which sees only the contract) knows what it returns. Two of them stand in\n for constructs lsc mistranslates: `prefix` for an unclamped `slice`, and the code-unit\n scans for \"\\r\" / \"\\n\" literals. */\n\n/**\n * The code unit at `i`, or -1 when `i` is outside `s`. JS `charCodeAt` gives NaN there,\n * which no code equals, so a scan's own bounds test would change no result and no test\n * could tell it from none (an equivalent mutant); with the bound here once, the boundary is\n * observable (tests pin -1) and the scans that use it carry no bound of their own. A code\n * unit is never negative, so -1 matches no `code` a caller passes (`requires code >= 0`).\n *\n * @ensures 0 ≤ i < |s| ⟹ result = s[i]; otherwise result = -1\n */\nexport function codeAt(s: string, i: number): number {\n //@ verify\n //@ ensures (i >= 0 && i < s.length) ==> \\result === s.charCodeAt(i)\n //@ ensures !(i >= 0 && i < s.length) ==> \\result === -1\n return i >= 0 && i < s.length ? s.charCodeAt(i) : -1;\n}\n\n/**\n * Every character of `s` from index `i` on is base64url.\n *\n * @ensures result ⟺ ∀ k ∈ [i, |s|). isBase64UrlChar(s[k])\n */\nexport function base64UrlFrom(s: string, i: number): boolean {\n //@ verify\n //@ type i nat\n //@ decreases s.length - i\n //@ ensures \\result <==> forall(k: nat, (i <= k && k < s.length) ==> isBase64UrlChar(s.charCodeAt(k)))\n return i >= s.length || (isBase64UrlChar(s.charCodeAt(i)) && base64UrlFrom(s, i + 1));\n}\n\n/**\n * The base64url digit for `v` (RFC 4648 §5): A-Z a-z 0-9 - _.\n *\n * @ensures exactly the model's Base64UrlDigit\n */\nexport function base64UrlDigit(v: number): string {\n //@ verify\n //@ type v nat\n //@ requires v >= 0 && v < 64\n //@ ensures \\result === \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\".slice(v, v + 1)\n return \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\".slice(v, v + 1);\n}\n\n/**\n * Bytes from `i` on as unpadded base64url: each three as four digits, a last one or two as two or\n * three (JS `btoa` with `+/` as `-_` and the `=` dropped). One frame per three bytes: a JWT part\n * is a few hundred.\n *\n * @ensures exactly the model's Base64UrlFrom (links/utils-strings.dfy)\n */\nexport function encodeBase64UrlFrom(b: number[], i: number): string {\n //@ verify\n //@ type i nat\n //@ requires i >= 0 && forall(k: nat, k < b.length ==> (b[k] >= 0 && b[k] < 256))\n //@ decreases b.length - i\n //@ ensures i >= b.length ==> \\result === \"\"\n if (i >= b.length) return \"\";\n const x = b[i] as number;\n const first = base64UrlDigit(Math.floor(x / 4));\n if (i + 1 === b.length) return first + base64UrlDigit((x % 4) * 16);\n const y = b[i + 1] as number;\n const second = base64UrlDigit((x % 4) * 16 + Math.floor(y / 16));\n if (i + 2 === b.length) return first + second + base64UrlDigit((y % 16) * 4);\n const z = b[i + 2] as number;\n return (\n first +\n second +\n base64UrlDigit((y % 16) * 4 + Math.floor(z / 64)) +\n base64UrlDigit(z % 64) +\n encodeBase64UrlFrom(b, i + 3)\n );\n}\n\n/**\n * Every character of `s` from index `i` on is lowercase hex.\n *\n * @ensures result ⟺ ∀ k ∈ [i, |s|). isLowerHexChar(s[k])\n */\nexport function lowerHexFrom(s: string, i: number): boolean {\n //@ verify\n //@ type i nat\n //@ decreases s.length - i\n //@ ensures \\result <==> forall(k: nat, (i <= k && k < s.length) ==> isLowerHexChar(s.charCodeAt(k)))\n return i >= s.length || (isLowerHexChar(s.charCodeAt(i)) && lowerHexFrom(s, i + 1));\n}\n\n/**\n * Every character of `s` from index `i` on is hex, either case.\n *\n * @ensures result ⟺ ∀ k ∈ [i, |s|). isHexChar(s[k])\n */\nexport function hexFrom(s: string, i: number): boolean {\n //@ verify\n //@ type i nat\n //@ decreases s.length - i\n //@ ensures \\result <==> forall(k: nat, (i <= k && k < s.length) ==> isHexChar(s.charCodeAt(k)))\n return i >= s.length || (isHexChar(s.charCodeAt(i)) && hexFrom(s, i + 1));\n}\n\n/**\n * Every character of `s` from index `i` on is an ASCII digit (`\\d` without the `u` flag).\n *\n * @ensures result ⟺ ∀ k ∈ [i, |s|). isDigit(s[k])\n */\nexport function digitsFrom(s: string, i: number): boolean {\n //@ verify\n //@ type i nat\n //@ decreases s.length - i\n //@ ensures \\result <==> forall(k: nat, (i <= k && k < s.length) ==> isDigit(s.charCodeAt(k)))\n return i >= s.length || (isDigit(s.charCodeAt(i)) && digitsFrom(s, i + 1));\n}\n\n/**\n * Every character of `s` from index `i` on is a word character (`\\w`: `[A-Za-z0-9_]`).\n *\n * @ensures result ⟺ ∀ k ∈ [i, |s|). isWordChar(s[k])\n */\nexport function wordCharsFrom(s: string, i: number): boolean {\n //@ verify\n //@ type i nat\n //@ decreases s.length - i\n //@ ensures \\result <==> forall(k: nat, (i <= k && k < s.length) ==> isWordChar(s.charCodeAt(k)))\n return i >= s.length || (isWordChar(s.charCodeAt(i)) && wordCharsFrom(s, i + 1));\n}\n\n/**\n * Every character of `s` from index `i` on is a snake_case character (`[a-z0-9_]`).\n *\n * @ensures result ⟺ ∀ k ∈ [i, |s|). isSnakeChar(s[k])\n */\nexport function snakeCharsFrom(s: string, i: number): boolean {\n //@ verify\n //@ type i nat\n //@ decreases s.length - i\n //@ ensures \\result <==> forall(k: nat, (i <= k && k < s.length) ==> isSnakeChar(s.charCodeAt(k)))\n return i >= s.length || (isSnakeChar(s.charCodeAt(i)) && snakeCharsFrom(s, i + 1));\n}\n\n/**\n * Every character of `s` from index `i` on is an ASCII letter or digit (`[A-Za-z0-9]`).\n *\n * @ensures result ⟺ ∀ k ∈ [i, |s|). isAlnumChar(s[k])\n */\nexport function alnumFrom(s: string, i: number): boolean {\n //@ verify\n //@ type i nat\n //@ decreases s.length - i\n //@ ensures \\result <==> forall(k: nat, (i <= k && k < s.length) ==> isAlnumChar(s.charCodeAt(k)))\n return i >= s.length || (isAlnumChar(s.charCodeAt(i)) && alnumFrom(s, i + 1));\n}\n\n/**\n * Every character of `s` from index `i` on is an ASCII letter, digit or `-` (`[A-Za-z0-9-]`):\n * a domain label's tail, a service name's tail.\n *\n * @ensures result ⟺ ∀ k ∈ [i, |s|). isAlnumChar(s[k]) ∨ s[k] = \"-\" — the model's AlnumDashFrom\n */\nexport function alnumDashFrom(s: string, i: number): boolean {\n //@ verify\n //@ type i nat\n //@ decreases s.length - i\n //@ ensures \\result <==> forall(k: nat, (i <= k && k < s.length) ==> (isAlnumChar(s.charCodeAt(k)) || s.charCodeAt(k) === 45))\n if (i >= s.length) return true;\n const c = s.charCodeAt(i);\n return (isAlnumChar(c) || c === 45) && alnumDashFrom(s, i + 1);\n}\n\n/**\n * The last index before `end` holding `code`, or -1 (JS `s.lastIndexOf(c)` at end = |s|).\n *\n * @ensures result = -1 ∨ (0 ≤ result < end ∧ s[result] = code ∧ no `code` in (result, end))\n */\nexport function lastIndexOfCode(s: string, code: number, end: number): number {\n //@ verify\n //@ type end nat\n //@ requires end <= s.length\n //@ decreases end\n //@ ensures \\result === -1 || (0 <= \\result && \\result < end)\n //@ ensures \\result >= 0 ==> s.charCodeAt(\\result) === code\n //@ ensures \\result >= 0 ==> forall(k: nat, (\\result < k && k < end) ==> s.charCodeAt(k) !== code)\n //@ ensures \\result === -1 ==> forall(k: nat, k < end ==> s.charCodeAt(k) !== code)\n if (end === 0) return -1;\n if (s.charCodeAt(end - 1) === code) return end - 1;\n return lastIndexOfCode(s, code, end - 1);\n}\n\n/**\n * No character of `s` from index `i` on is `code`.\n *\n * @ensures result ⟺ ∀ k ∈ [i, |s|). s[k] ≠ code\n */\nexport function lacksCode(s: string, code: number, i: number): boolean {\n //@ verify\n //@ type i nat\n //@ requires i <= s.length\n //@ decreases s.length - i\n //@ ensures \\result <==> forall(k: nat, (i <= k && k < s.length) ==> s.charCodeAt(k) !== code)\n // `===`, not `>=`: past the end a read is NaN !== code, so `>=` vs `>` would be equivalent\n return i === s.length || (s.charCodeAt(i) !== code && lacksCode(s, code, i + 1));\n}\n\n/**\n * The end of the run of `code` starting at `i`: the first index ≥ i that isn't `code`\n * (skip spaces: `codeRunEnd(header, 32, i)`).\n *\n * @requires i ≤ |s|\n * @ensures i ≤ result ≤ |s| ∧ ∀ k ∈ [i, result). s[k] = code ∧ (result < |s| ⟹ s[result] ≠ code)\n * — exactly the run's end\n */\nexport function codeRunEnd(s: string, code: number, i: number): number {\n //@ verify\n //@ type i nat\n //@ requires 0 <= i && i <= s.length\n //@ requires code >= 0\n //@ decreases s.length - i\n //@ ensures i <= \\result && \\result <= s.length\n //@ ensures forall(k: nat, (i <= k && k < \\result) ==> s.charCodeAt(k) === code)\n //@ ensures \\result < s.length ==> s.charCodeAt(\\result) !== code\n return codeAt(s, i) === code ? codeRunEnd(s, code, i + 1) : i;\n}\n\n/**\n * The first index ≥ `from` holding `code`, or -1 (`indexOf` for one code unit, so \"\\n\" is\n * passed as 10, never as a literal).\n *\n * @ensures result = -1 ∨ (from ≤ result < |s| ∧ s[result] = code), with no `code` in\n * [from, result) — the first one; result = -1 ⟹ none from `from` on\n */\nexport function indexOfCode(s: string, code: number, from: number): number {\n //@ verify\n //@ type from nat\n //@ requires code >= 0\n //@ decreases s.length - from\n //@ ensures \\result === -1 || (from <= \\result && \\result < s.length)\n //@ ensures \\result >= 0 ==> s.charCodeAt(\\result) === code\n //@ ensures \\result >= 0 ==> forall(k: nat, (from <= k && k < \\result) ==> s.charCodeAt(k) !== code)\n //@ ensures \\result === -1 ==> forall(k: nat, (from <= k && k < s.length) ==> s.charCodeAt(k) !== code)\n const c = codeAt(s, from);\n if (c === code) return from;\n if (c === -1) return -1;\n return indexOfCode(s, code, from + 1);\n}\n\n/**\n * The first index ≥ `i` holding `a` or `b`, or |s| (a run either code ends: a path segment's\n * run to \"/\" or \"?\"). One scan: the lesser of two `indexOfCode` ends is the same index, but\n * its two sides are equal only when both are |s|, a boundary no test can observe.\n *\n * @requires i ≤ |s|\n * @ensures i ≤ result ≤ |s| ∧ ∀ k ∈ [i, result). s[k] ∉ {a, b} ∧ (result < |s| ⟹ s[result] ∈ {a, b})\n * — exactly the first such index\n */\nexport function eitherCodeEnd(s: string, a: number, b: number, i: number): number {\n //@ verify\n //@ type i nat\n //@ requires 0 <= i && i <= s.length\n //@ requires a >= 0 && b >= 0\n //@ decreases s.length - i\n //@ ensures i <= \\result && \\result <= s.length\n //@ ensures forall(k: nat, (i <= k && k < \\result) ==> (s.charCodeAt(k) !== a && s.charCodeAt(k) !== b))\n //@ ensures \\result < s.length ==> (s.charCodeAt(\\result) === a || s.charCodeAt(\\result) === b)\n const c = codeAt(s, i);\n if (c === -1 || c === a || c === b) return i;\n return eitherCodeEnd(s, a, b, i + 1);\n}\n\n/**\n * `s` without one trailing `code` (\"\\r\" before a \"\\n\", say); unchanged otherwise.\n *\n * @ensures s ends with code ⟹ result = s[0, |s| − 1)\n * @ensures otherwise result = s\n */\nexport function dropLast(s: string, code: number): string {\n //@ verify\n //@ requires code >= 0\n //@ ensures (s.length > 0 && s.charCodeAt(s.length - 1) === code) ==> \\result === s.slice(0, s.length - 1)\n //@ ensures !(s.length > 0 && s.charCodeAt(s.length - 1) === code) ==> \\result === s\n return codeAt(s, s.length - 1) === code ? s.slice(0, s.length - 1) : s;\n}\n\n/**\n * `s` without its leading `code` units (every one of them).\n *\n * @ensures exactly the model's LStripCode\n */\nexport function lStripCode(s: string, code: number): string {\n //@ verify\n //@ requires code >= 0\n //@ decreases s.length\n //@ ensures \\result.length <= s.length\n if (codeAt(s, 0) === code) return lStripCode(s.slice(1), code);\n return s;\n}\n\n/**\n * `s` without its trailing `code` units (every one of them).\n *\n * @ensures exactly the model's RStripCode\n */\nexport function rStripCode(s: string, code: number): string {\n //@ verify\n //@ requires code >= 0\n //@ decreases s.length\n //@ ensures \\result.length <= s.length\n if (codeAt(s, s.length - 1) === code) {\n return rStripCode(s.slice(0, s.length - 1), code);\n }\n return s;\n}\n\n/**\n * `s` without its leading and trailing `code` units, the middle kept (`/a/b/` with `/` →\n * `a/b`).\n *\n * @ensures exactly the model's StripCode — neither end is `code` (StripCodeTrims)\n */\nexport function stripCode(s: string, code: number): string {\n //@ verify\n //@ requires code >= 0\n //@ ensures \\result === rStripCode(lStripCode(s, code), code)\n return rStripCode(lStripCode(s, code), code);\n}\n\n/**\n * JS `s.startsWith(x, pos)`, which lsc mistranslates (it drops `pos`). Like JS, a `pos`\n * past the end counts as the end, so the empty string matches anywhere.\n *\n * @ensures pos ≤ |s| ⟹ (result ⟺ pos + |x| ≤ |s| ∧ s[pos, pos + |x|) = x) — so a true\n * result also gives the bounds for slicing after the match\n * @ensures pos > |s| ⟹ (result ⟺ x = \"\")\n */\nexport function startsWithAt(s: string, x: string, pos: number): boolean {\n //@ verify\n //@ type pos nat\n //@ requires pos >= 0\n //@ ensures pos <= s.length ==> (\\result <==> (pos + x.length <= s.length && s.slice(pos, pos + x.length) === x))\n //@ ensures pos > s.length ==> (\\result <==> x.length === 0)\n // Math.min, not a ternary: at pos = |s| both branches agree, so `<` vs `<=` is equivalent\n const at = Math.min(pos, s.length);\n // The slice is clamped to the end, so a too-long x differs by length: no separate fit test\n // (JS slice clamps too, which made one unobservable)\n return s.slice(at, Math.min(at + x.length, s.length)) === x;\n}\n\n/**\n * `s` with A-Z lowercased and every other character kept: what lsc's proofs take\n * `toLowerCase()` to be. JS's `toLowerCase()` also maps non-ASCII letters, some onto ASCII\n * (the Kelvin sign K, U+212A, becomes \"k\") or onto two characters (İ, U+0130), so a proved\n * function that lowercases MUST use this, or the runtime does what the proof says it\n * doesn't.\n *\n * @ensures result = s with A-Z lowercased — same length, every other character unchanged\n */\nexport function lowerAscii(s: string): string {\n //@ verify\n //@ decreases s.length\n //@ ensures \\result === s.toLowerCase()\n if (s.length === 0) return \"\";\n const c = s.charCodeAt(0);\n const head =\n c >= 65 && c <= 90 ? \"abcdefghijklmnopqrstuvwxyz\".slice(c - 65, c - 64) : s.slice(0, 1);\n return head + lowerAscii(s.slice(1));\n}\n\n/**\n * `lowerAscii` as a loop: a constant stack depth (and linear time) on long text, where the\n * recursive spec takes a frame and a slice per character.\n *\n * @ensures result = lowerAscii(s)\n */\nexport function lowerAsciiText(s: string): string {\n //@ verify\n //@ ensures \\result === lowerAscii(s)\n let out = \"\";\n let i = 0;\n while (i !== s.length) {\n //@ invariant 0 <= i && i <= s.length\n //@ invariant out + lowerAscii(s.slice(i)) === lowerAscii(s)\n //@ decreases s.length - i\n const c = s.charCodeAt(i);\n out =\n out +\n (c >= 65 && c <= 90 ? \"abcdefghijklmnopqrstuvwxyz\".slice(c - 65, c - 64) : s.slice(i, i + 1));\n i = i + 1;\n }\n return out;\n}\n\n/**\n * Whether `x` from index `k` matches `s` from `pos + k`, code by code, ASCII-lowered. A code\n * past the end of `s` is -1 (`codeAt`), which no code of `x` is, so there is no bound to\n * check (a `pos + |x| ≤ |s|` guard before a slice never changed the answer at runtime, where\n * `slice` clamps: an equivalent mutant, 2026-11-02).\n *\n * @ensures exactly the model's CaselessFrom\n */\nexport function caselessFrom(s: string, x: string, pos: number, k: number): boolean {\n //@ verify\n //@ type pos nat\n //@ type k nat\n //@ requires pos >= 0 && k >= 0 && k <= x.length\n //@ decreases x.length - k\n //@ ensures k === x.length ==> \\result\n if (k === x.length) return true;\n return lowerCode(codeAt(s, pos + k)) === x.charCodeAt(k) && caselessFrom(s, x, pos, k + 1);\n}\n\n/**\n * Whether the text of `s` at `pos`, ASCII-lowered, is `x` (`x` given lowercase): a case-free\n * `startsWith`; callers carry no length guard of their own. Only `pos ≤ |s|` is checked: it\n * decides an empty `x` past the end, the one case the code-by-code test can't see.\n *\n * @ensures result ⟺ pos + |x| ≤ |s| ∧ lowerAscii(s[pos, pos + |x|)) = x — Utils.StartsWithCaseless\n */\nexport function startsWithCaseless(s: string, x: string, pos: number): boolean {\n //@ verify\n //@ type pos nat\n //@ requires pos >= 0\n //@ ensures \\result <==> (pos + x.length <= s.length && s.slice(pos, pos + x.length).toLowerCase() === x)\n return pos <= s.length && caselessFrom(s, x, pos, 0);\n}\n\n/**\n * Whether `s` ends with `suffix` (JS one-argument `endsWith`, which lsc reads as its\n * two-argument form; moved from the augur-api generator 2026-11-01).\n *\n * @ensures result ⟺ |s| ≥ |suffix| ∧ s[|s| − |suffix|, |s|) = suffix — exactly the model's EndsWith\n */\nexport function endsWith(s: string, suffix: string): boolean {\n //@ verify\n //@ ensures \\result <==> (s.length >= suffix.length && s.slice(s.length - suffix.length) === suffix)\n // No length test: from max(|s| − |suffix|, 0), a too-long suffix compares unequal by length\n return s.slice(Math.max(s.length - suffix.length, 0)) === suffix;\n}\n\n/**\n * The order of `a` and `b` by UTF-16 code unit from index `i`, as a recursive spec: -1, 0\n * or 1 (JS `<` on strings; a proper prefix comes first). Locale-free, unlike `localeCompare`.\n *\n * @ensures result ∈ {-1, 0, 1} — exactly the model's CompareFrom\n */\nexport function compareFrom(a: string, b: string, i: number): number {\n //@ verify\n //@ type i nat\n //@ requires i >= 0\n //@ decreases a.length - i\n //@ ensures \\result === -1 || \\result === 0 || \\result === 1\n if (i >= a.length) return i >= b.length ? 0 : -1;\n if (i >= b.length) return 1;\n const x = a.charCodeAt(i);\n const y = b.charCodeAt(i);\n if (x < y) return -1;\n if (x > y) return 1;\n return compareFrom(a, b, i + 1);\n}\n\n/**\n * The order of two strings by UTF-16 code unit, for `sort` (what the default `sort` uses on\n * strings), so sorted output never depends on locale.\n *\n * @ensures result = compareFrom(a, b, 0)\n */\nexport function compareCodeUnits(a: string, b: string): number {\n //@ verify\n //@ ensures \\result === compareFrom(a, b, 0)\n return compareFrom(a, b, 0);\n}\n\n/**\n * JS `s.slice(0, n)`: at most `n` characters, clamped to the length. lsc reads a bare\n * `slice(0, n)` without JS's clamp, so use this instead.\n *\n * @ensures result = s[0, min(n, |s|))\n */\nexport function prefix(s: string, n: number): string {\n //@ verify\n //@ type n nat\n //@ requires n >= 0\n //@ ensures n < s.length ==> \\result === s.slice(0, n)\n //@ ensures n >= s.length ==> \\result === s\n // Math.min, not a ternary: JS slice already clamps, so a ternary's branch is unobservable\n return s.slice(0, Math.min(n, s.length));\n}\n\n/**\n * The end of the JS-whitespace (`\\s`) run starting at `i`: the first index ≥ i that is not\n * whitespace, or |s|.\n *\n * @ensures i ≤ result ≤ |s| ∧ s[i, result) all whitespace ∧ (result = |s| ∨ ¬space(s[result]))\n */\nexport function spaceRunEnd(s: string, i: number): number {\n //@ verify\n //@ type i nat\n //@ requires 0 <= i && i <= s.length\n //@ decreases s.length - i\n //@ ensures i <= \\result && \\result <= s.length\n //@ ensures forall(k: nat, (i <= k && k < \\result) ==> isJsSpace(s.charCodeAt(k)))\n //@ ensures \\result < s.length ==> !isJsSpace(s.charCodeAt(\\result))\n // codeAt is -1 at the end, which is no space: the bound needs no test of its own here\n if (!isJsSpace(codeAt(s, i))) return i;\n return spaceRunEnd(s, i + 1);\n}\n\n/**\n * A natural number written canonically (`^(0|[1-9][0-9]*)$`): the keys JS objects move\n * first, ahead of their source order.\n *\n * @ensures exactly the model's CanonicalNat, stated over the codes themselves so an importer\n * can use it (a contract naming `digitsFrom` can't be resolved there, models/LSC-GAPS.md)\n */\nexport function isCanonicalNat(s: string): boolean {\n //@ verify\n //@ ensures \\result <==> (s === \"0\" || (s.length > 0 && s.charCodeAt(0) >= 49 && s.charCodeAt(0) <= 57 && forall(k: nat, (1 <= k && k < s.length) ==> (s.charCodeAt(k) >= 48 && s.charCodeAt(k) <= 57))))\n if (s === \"0\") return true;\n const first = codeAt(s, 0);\n return first >= 49 && first <= 57 && digitsFrom(s, 1);\n}\n\n/**\n * The value of a run of decimal digits, most significant first (\"\" is 0).\n *\n * @requires ∀ k ∈ [0, |s|). isDigit(s[k])\n * @ensures exactly the model's DigitsValue (proved in links/utils-strings.dfy)\n */\nexport function digitsValue(s: string): number {\n //@ verify\n //@ requires forall(k: nat, k < s.length ==> (s.charCodeAt(k) >= 48 && s.charCodeAt(k) <= 57))\n //@ decreases s.length\n //@ ensures \\result >= 0\n if (s.length === 0) return 0;\n return digitsValue(s.slice(0, s.length - 1)) * 10 + (s.charCodeAt(s.length - 1) - 48);\n}\n\n/**\n * What a number from the environment means (owner 2026-11-04: a bad one fails at start):\n * \"default\" when unset (\"\": the wrapper reads a missing variable as \"\"), \"value\" when it is\n * a canonical natural number at least `min` (its value is `digitsValue(raw)`), and \"bad\"\n * otherwise: a sign, a space, a fraction, an exponent, hex, text, or below `min`.\n *\n * @ensures exactly the model's EnvNumberOf (proved in links/utils-strings.dfy)\n */\nexport function envNumberKind(raw: string, min: number): string {\n //@ verify\n //@ type min nat\n //@ ensures raw === \"\" ==> \\result === \"default\"\n //@ ensures (raw !== \"\" && !isCanonicalNat(raw)) ==> \\result === \"bad\"\n if (raw === \"\") return \"default\";\n if (!isCanonicalNat(raw)) return \"bad\";\n return digitsValue(raw) < min ? \"bad\" : \"value\";\n}\n\n/**\n * The first index ≥ `i` holding a line terminator, or |s|: where a regex `.+` started at `i`\n * stops.\n *\n * @ensures i ≤ result ≤ |s| ∧ no terminator in s[i, result) ∧ (result = |s| ∨ terminator at result)\n */\nexport function lineEnd(s: string, i: number): number {\n //@ verify\n //@ type i nat\n //@ requires 0 <= i && i <= s.length\n //@ decreases s.length - i\n //@ ensures i <= \\result && \\result <= s.length\n //@ ensures forall(k: nat, (i <= k && k < \\result) ==> !isLineTerminator(s.charCodeAt(k)))\n //@ ensures \\result < s.length ==> isLineTerminator(s.charCodeAt(\\result))\n if (i === s.length || isLineTerminator(s.charCodeAt(i))) return i;\n return lineEnd(s, i + 1);\n}\n\n/**\n * The largest p with lo ≤ p < hi whose character is not a line terminator, or -1: where a\n * backtracking regex `.` can start.\n *\n * @ensures result = -1 ∨ (lo ≤ result < hi ∧ ¬terminator(s[result]) ∧ only terminators in (result, hi))\n */\nexport function lastLineCharBelow(s: string, hi: number, lo: number): number {\n //@ verify\n //@ type hi nat\n //@ type lo nat\n //@ requires 0 <= lo && 0 <= hi && hi <= s.length\n //@ decreases hi\n //@ ensures \\result === -1 || (lo <= \\result && \\result < hi)\n //@ ensures \\result >= 0 ==> !isLineTerminator(s.charCodeAt(\\result))\n //@ ensures \\result >= 0 ==> forall(k: nat, (\\result < k && k < hi) ==> isLineTerminator(s.charCodeAt(k)))\n //@ ensures \\result === -1 ==> forall(k: nat, (lo <= k && k < hi) ==> isLineTerminator(s.charCodeAt(k)))\n if (hi <= lo) return -1;\n if (!isLineTerminator(s.charCodeAt(hi - 1))) return hi - 1;\n return lastLineCharBelow(s, hi - 1, lo);\n}\n\n/**\n * Nothing but JS whitespace (`s.trim() === \"\"`).\n *\n * @ensures exactly the model's Blank\n */\nexport function isBlank(s: string): boolean {\n //@ verify\n //@ ensures \\result <==> s.trim() === \"\"\n return s.trim() === \"\";\n}\n\n/**\n * The first index ≥ `i` where `x` occurs in `s`, or -1 (JS `s.indexOf(x, i)` for i ≤ |s|).\n *\n * @ensures result = -1 ∨ (i ≤ result ∧ s[result, result + |x|) = x) — and the first such\n * index: links/utils-strings.dfy proves it is exactly the model's IndexOfFrom (lsc can't\n * give the \"no earlier match\" quantifier a trigger)\n */\nexport function indexOfFrom(s: string, x: string, i: number): number {\n //@ verify\n //@ type i nat\n //@ requires i >= 0 && i <= s.length\n //@ decreases s.length - i\n //@ ensures \\result === -1 || (i <= \\result && \\result + x.length <= s.length)\n //@ ensures \\result >= 0 ==> s.slice(\\result, \\result + x.length) === x\n // A match here, else the end, else the next index: stopping at `i === |s|` (not \"x no\n // longer fits\") leaves no bound whose slip a later, harmless step would hide\n if (startsWithAt(s, x, i)) return i;\n if (i === s.length) return -1;\n return indexOfFrom(s, x, i + 1);\n}\n\n/**\n * `indexOfFrom` as a loop: the same answer at a constant stack depth, for text long enough that\n * one frame per character would overflow the stack (a rendered page, 50–60 KB with its inlined\n * stylesheet). Specs and links use `indexOfFrom`; runtime scans over long text use this.\n *\n * @ensures result = indexOfFrom(s, x, i)\n */\nexport function findFrom(s: string, x: string, i: number): number {\n //@ verify\n //@ type i nat\n //@ requires i >= 0 && i <= s.length\n //@ ensures \\result === indexOfFrom(s, x, i)\n let k = i;\n while (k !== s.length) {\n //@ invariant i <= k && k <= s.length\n //@ invariant indexOfFrom(s, x, k) === indexOfFrom(s, x, i)\n //@ decreases s.length - k\n if (startsWithAt(s, x, k)) return k;\n k = k + 1;\n }\n return startsWithAt(s, x, k) ? k : -1;\n}\n\n/**\n * `indexOfCode` as a loop: the same answer at a constant stack depth (see `findFrom`).\n *\n * @ensures result = indexOfCode(s, code, from)\n */\nexport function findCodeFrom(s: string, code: number, from: number): number {\n //@ verify\n //@ type from nat\n //@ requires code >= 0 && from >= 0\n //@ ensures \\result === indexOfCode(s, code, from)\n let k = from;\n while (k < s.length) {\n //@ invariant from <= k\n //@ invariant indexOfCode(s, code, k) === indexOfCode(s, code, from)\n //@ decreases s.length - k\n if (s.charCodeAt(k) === code) return k;\n k = k + 1;\n }\n return -1;\n}\n\n/**\n * How many times `x` occurs in `s` from `i` on, left to right without overlaps (repeated JS\n * `s.indexOf(x, at + x.length)`).\n *\n * @requires |x| > 0\n * @ensures result ≥ 0 — exactly the model's CountFrom (links/utils-strings.dfy)\n */\nexport function countFrom(s: string, x: string, i: number): number {\n //@ verify\n //@ type i nat\n //@ requires x.length > 0 && i >= 0 && i <= s.length\n //@ decreases s.length - i\n //@ ensures \\result >= 0\n const at = indexOfFrom(s, x, i);\n if (at === -1) return 0;\n return 1 + countFrom(s, x, at + x.length);\n}\n\n/**\n * `countFrom(s, x, 0)` as a loop: a constant stack depth on long text (see `findFrom`).\n *\n * @requires |x| > 0\n * @ensures result = countFrom(s, x, 0)\n */\nexport function countOf(s: string, x: string): number {\n //@ verify\n //@ requires x.length > 0\n //@ ensures \\result === countFrom(s, x, 0)\n let n = 0;\n let i = 0;\n let at = findFrom(s, x, 0);\n while (at !== -1) {\n //@ invariant 0 <= i && i <= s.length\n //@ invariant at === indexOfFrom(s, x, i)\n //@ invariant n + countFrom(s, x, i) === countFrom(s, x, 0)\n //@ decreases s.length - i\n n = n + 1;\n i = at + x.length;\n at = findFrom(s, x, i);\n }\n return n;\n}\n\n/**\n * The text before the first `code`, or all of it when there is none (JS `s.split(c)[0]`).\n *\n * @ensures result = s[0, first code) when s holds one, else s — the model's UntilCode\n */\nexport function untilCode(s: string, code: number): string {\n //@ verify\n //@ requires code >= 0\n //@ ensures \\result === (indexOfCode(s, code, 0) >= 0 && indexOfCode(s, code, 0) <= s.length ? s.slice(0, indexOfCode(s, code, 0)) : s)\n const k = indexOfCode(s, code, 0);\n return k >= 0 ? s.slice(0, k) : s;\n}\n\n/**\n * `s` from `i` on split at every `code` (JS `s.split(c)` at i = 0, for a one-character\n * separator): always at least one part.\n *\n * @ensures |result| ≥ 1 — exactly the model's SplitCodeFrom (links/utils-strings.dfy)\n */\nexport function splitCodeFrom(s: string, code: number, i: number): string[] {\n //@ verify\n //@ type i nat\n //@ requires code >= 0 && i >= 0 && i <= s.length\n //@ decreases s.length - i\n //@ ensures \\result.length > 0\n const k = indexOfCode(s, code, i);\n if (k === -1) return [s.slice(i)];\n return [s.slice(i, k), ...splitCodeFrom(s, code, k + 1)];\n}\n\n/**\n * Every run of JS whitespace in `s` from `i` on as one space (JS `s.replace(/\\s+/g, \" \")` at\n * i = 0).\n *\n * @ensures |result| ≤ |s| − i — exactly the model's CollapseSpacesFrom (links/utils-strings.dfy)\n */\nexport function collapseSpacesFrom(s: string, i: number): string {\n //@ verify\n //@ type i nat\n //@ requires 0 <= i && i <= s.length\n //@ decreases s.length - i\n //@ ensures \\result.length <= s.length - i\n if (i === s.length) return \"\";\n if (isJsSpace(s.charCodeAt(i))) return \" \" + collapseSpacesFrom(s, spaceRunEnd(s, i));\n return s.slice(i, i + 1) + collapseSpacesFrom(s, i + 1);\n}\n\n/**\n * `collapseSpacesFrom(s, 0)` at a constant stack depth (a page's text is tens of KB).\n *\n * @ensures result = collapseSpacesFrom(s, 0)\n */\nexport function collapseSpaces(s: string): string {\n //@ verify\n //@ ensures \\result === collapseSpacesFrom(s, 0)\n let out = \"\";\n let i = 0;\n while (i < s.length) {\n //@ invariant 0 <= i && i <= s.length\n //@ invariant out + collapseSpacesFrom(s, i) === collapseSpacesFrom(s, 0)\n //@ decreases s.length - i\n if (isJsSpace(s.charCodeAt(i))) {\n out = out + \" \";\n i = spaceRunEnd(s, i);\n } else {\n out = out + s.slice(i, i + 1);\n i = i + 1;\n }\n }\n return out;\n}\n\n/**\n * `n` spaces.\n *\n * @ensures result = \" \" repeated n times — the model's Spaces\n */\nexport function spaces(n: number): string {\n //@ verify\n //@ type n nat\n //@ requires n >= 0\n //@ decreases n\n //@ ensures \\result.length === n\n //@ ensures forall(k: nat, k < n ==> \\result.charCodeAt(k) === 32)\n if (n === 0) return \"\";\n return \" \" + spaces(n - 1);\n}\n\n/**\n * A line feed, `\"\\n\"`, for proved text that spans lines: lsc emits a `\"\\n\"` escape raw, which\n * Dafny cannot parse (models/LSC-GAPS.md), so the contract pins it by code unit and the body is\n * a template literal holding the line break itself.\n *\n * @ensures result = \"\\n\" — one code unit, 10\n */\nexport function lineFeed(): string {\n //@ verify\n //@ ensures \\result.length === 1 && \\result.charCodeAt(0) === 10\n return `\n`;\n}\n\n/**\n * `s` padded on the left with spaces to `width` (JS `s.padStart(width)`).\n *\n * @ensures result = Spaces(width − |s|) + s when width > |s|, else s\n */\nexport function padLeft(s: string, width: number): string {\n //@ verify\n //@ ensures width <= s.length ==> \\result === s\n // width > |s| ⟹ spaces(width − |s|) + s: a hand ensures in strings.dfy, so importers'\n // axioms name no helper (models/LSC-GAPS.md). Math.max, not a ternary: at width = |s|\n // both branches agree (spaces(0) is \"\"), so `>` vs `>=` would be equivalent.\n return spaces(Math.max(width - s.length, 0)) + s;\n}\n\n/**\n * `s` padded on the right with spaces to `width` (JS `s.padEnd(width)`).\n *\n * @ensures result = s + Spaces(width − |s|) when width > |s|, else s\n */\nexport function padRight(s: string, width: number): string {\n //@ verify\n //@ ensures width <= s.length ==> \\result === s\n // width > |s| ⟹ s + spaces(width − |s|): a hand ensures in strings.dfy, as padLeft's.\n return s + spaces(Math.max(width - s.length, 0));\n}\n\n/**\n * An optional part of a key: `tag` then `text`, or nothing when `text` is empty, so an absent\n * part never leaves a bare tag.\n *\n * @ensures result = \"\" when text = \"\", else tag + text — exactly the model's KeyPart\n */\nexport function keyPart(tag: string, text: string): string {\n //@ verify\n //@ ensures \\result === (text === \"\" ? \"\" : tag + text)\n return text === \"\" ? \"\" : tag + text;\n}\n\n/**\n * Two texts joined by one space: the one rule behind a loader key's `<column> <direction>`, a\n * sync line's `METHOD /path` and a field's description then note.\n *\n * @ensures result = a + \" \" + b — exactly the model's SpaceJoined\n */\nexport function spaceJoined(a: string, b: string): string {\n //@ verify\n //@ ensures \\result === a + \" \" + b\n return a + \" \" + b;\n}\n\n/**\n * Whether `x` occurs in `s` at some index ≥ `i` (JS `s.includes(x, i)` for i ≤ |s|).\n *\n * @ensures result ⟺ ∃ k. i ≤ k ≤ |s| ∧ startsWithAt(s, x, k) — exactly the model's\n * IncludesFrom: a hand lemma in strings.dfy (`includesFrom_exists`), so importers' axioms\n * name no helper (models/LSC-GAPS.md)\n */\nexport function includesFrom(s: string, x: string, i: number): boolean {\n //@ verify\n //@ type i nat\n //@ requires i >= 0\n //@ decreases s.length + 1 - i\n if (i > s.length) return false;\n if (startsWithAt(s, x, i)) return true;\n return includesFrom(s, x, i + 1);\n}\n\n/**\n * `s` with a-z uppercased and every other character kept, the mirror of `lowerAscii`: JS's\n * `toUpperCase()` also maps non-ASCII letters (ß becomes \"SS\").\n *\n * @ensures result = s with a-z uppercased — same length, every other character unchanged\n */\nexport function upperAscii(s: string): string {\n //@ verify\n //@ decreases s.length\n //@ ensures \\result === s.toUpperCase()\n if (s.length === 0) return \"\";\n const c = s.charCodeAt(0);\n const head =\n c >= 97 && c <= 122 ? \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".slice(c - 97, c - 96) : s.slice(0, 1);\n return head + upperAscii(s.slice(1));\n}\n","//@ backend dafny\nimport { includesFrom, indexOfCode } from \"@atlas/utils/strings\";\n\n/* The server's decisions, as pure functions verified with LemmaScript → Dafny (model:\n models/AugurServer.dfy; link: models/links/augur-server-rules.dfy). Cookies, JWT decoding,\n fetch, Redis and process.env stay in the callers, which hand over plain values. */\n\n/**\n * The siteId of a bearer's client_id claim (`<n>|<siteId>`): the text after the first \"|\", when\n * there is one and it is non-empty. The prefix is not checked.\n *\n * @ensures exactly the model's ClientIdSiteId on a string claim\n */\nexport function clientIdSiteIdOf(clientId: string): string | null {\n //@ verify\n //@ ensures indexOfCode(clientId, 124, 0) < 0 ==> \\result === null\n //@ ensures indexOfCode(clientId, 124, 0) >= 0 && indexOfCode(clientId, 124, 0) + 1 >= clientId.length ==> \\result === null\n //@ ensures indexOfCode(clientId, 124, 0) >= 0 && indexOfCode(clientId, 124, 0) + 1 < clientId.length ==> \\result === clientId.slice(indexOfCode(clientId, 124, 0) + 1)\n const k = indexOfCode(clientId, 124, 0);\n if (k < 0) return null;\n if (k + 1 >= clientId.length) return null;\n return clientId.slice(k + 1);\n}\n\n/** A session's siteId and bearer token, as minted, or refused. */\nexport type Mint = { kind: \"minted\"; siteId: string; token: string } | { kind: \"refused\" };\n\n/**\n * getSessionCredentials' mint, once the secret and the decoded session are in hand: a valid\n * siteId (augur-api's `isSiteId`, checked by the caller), a non-empty token, and the bearer's\n * client_id siteId (`\"\"` for none: `clientIdSiteIdOf` never gives `\"\"`) equal to it.\n *\n * @ensures exactly the model's MintCredentials with a secret and a decoded session\n */\nexport function mintedCredentials(\n siteIdOk: boolean,\n targetSiteId: string,\n token: string,\n bearerSiteId: string,\n): Mint {\n //@ verify\n //@ ensures siteIdOk && token !== \"\" && bearerSiteId !== \"\" && bearerSiteId === targetSiteId ==> \\result.kind === \"minted\" && \\result.siteId === targetSiteId && \\result.token === token\n //@ ensures !(siteIdOk && token !== \"\" && bearerSiteId !== \"\" && bearerSiteId === targetSiteId) ==> \\result.kind === \"refused\"\n if (!siteIdOk || token === \"\" || bearerSiteId === \"\" || bearerSiteId !== targetSiteId) {\n return { kind: \"refused\" };\n }\n return { kind: \"minted\", siteId: targetSiteId, token };\n}\n\n/**\n * Whether there is another page: from the total when one is given, else a full page.\n *\n * @ensures exactly the model's HasMore\n */\nexport function hasMoreOf(\n page: number,\n limit: number,\n total: number | undefined,\n itemCount: number,\n): boolean {\n //@ verify\n //@ ensures total !== undefined ==> \\result === ((page + 1) * limit < total)\n //@ ensures total === undefined ==> \\result === (itemCount === limit)\n if (total !== undefined) return (page + 1) * limit < total;\n return itemCount === limit;\n}\n\n/**\n * The next page's cursor: page + 1 while there is more.\n *\n * @ensures exactly the model's NextCursor given HasMore\n */\nexport function nextCursorOf(hasMore: boolean, page: number): number | undefined {\n //@ verify\n //@ ensures hasMore ==> \\result === page + 1\n //@ ensures !hasMore ==> \\result === undefined\n if (hasMore) return page + 1;\n return undefined;\n}\n\n/** The deployment environment. */\nexport type Env = \"development\" | \"staging\" | \"production\";\n\n/**\n * DEPLOYMENT_ENV first; then the server's NODE_ENV; then the browser's host (substring). A missing\n * variable is \"\".\n *\n * @ensures exactly the model's EnvOf\n */\nexport function envOf(\n deploymentEnv: string,\n isServer: boolean,\n nodeEnv: string,\n host: string,\n): Env {\n //@ verify\n //@ ensures deploymentEnv === \"dev\" ==> \\result === \"staging\"\n //@ ensures deploymentEnv !== \"dev\" && deploymentEnv === \"live\" ==> \\result === \"production\"\n //@ ensures deploymentEnv !== \"dev\" && deploymentEnv !== \"live\" && isServer ==> \\result === serverEnvOf(nodeEnv)\n //@ ensures deploymentEnv !== \"dev\" && deploymentEnv !== \"live\" && !isServer ==> \\result === hostEnvOf(host)\n if (deploymentEnv === \"dev\") return \"staging\";\n if (deploymentEnv === \"live\") return \"production\";\n if (isServer) return serverEnvOf(nodeEnv);\n return hostEnvOf(host);\n}\n\n/**\n * On the server: development only for NODE_ENV \"development\".\n *\n * @ensures result = development ⟺ nodeEnv = \"development\", else production\n */\nexport function serverEnvOf(nodeEnv: string): Env {\n //@ verify\n //@ ensures nodeEnv === \"development\" ==> \\result === \"development\"\n //@ ensures nodeEnv !== \"development\" ==> \\result === \"production\"\n return nodeEnv === \"development\" ? \"development\" : \"production\";\n}\n\n/**\n * In the browser: localhost or 127.0.0.1 anywhere in the host is development, agr-hosting.dev\n * staging, anything else production.\n *\n * @ensures exactly the model's host rule\n */\nexport function hostEnvOf(host: string): Env {\n //@ verify\n //@ ensures (includesFrom(host, \"localhost\", 0) || includesFrom(host, \"127.0.0.1\", 0)) ==> \\result === \"development\"\n //@ ensures !(includesFrom(host, \"localhost\", 0) || includesFrom(host, \"127.0.0.1\", 0)) && includesFrom(host, \"agr-hosting.dev\", 0) ==> \\result === \"staging\"\n //@ ensures !(includesFrom(host, \"localhost\", 0) || includesFrom(host, \"127.0.0.1\", 0)) && !includesFrom(host, \"agr-hosting.dev\", 0) ==> \\result === \"production\"\n if (includesFrom(host, \"localhost\", 0) || includesFrom(host, \"127.0.0.1\", 0))\n return \"development\";\n if (includesFrom(host, \"agr-hosting.dev\", 0)) return \"staging\";\n return \"production\";\n}\n\n/** The API route's outcome for a request. */\nexport type ApiOutcome = \"forbidden\" | \"bad-json\" | \"bad-method-path\" | \"bad-args\" | \"run\";\n\n/**\n * A present, non-empty Sec-Fetch-Site other than same-origin is refused (a missing one, `\"\"`\n * from the caller, passes).\n *\n * @ensures result ⟺ fetchSite ∉ {\"\", \"same-origin\"}\n */\nexport function isCrossOrigin(fetchSite: string): boolean {\n //@ verify\n //@ ensures \\result === (fetchSite !== \"\" && fetchSite !== \"same-origin\")\n return fetchSite !== \"\" && fetchSite !== \"same-origin\";\n}\n\n/**\n * The body's outcome: JSON, then a non-empty methodPath string, then an args array.\n *\n * @ensures exactly the model's ApiOutcomeOf past the origin check\n */\nexport function bodyOutcomeOf(\n jsonOk: boolean,\n methodPathOk: boolean,\n argsIsArray: boolean,\n): ApiOutcome {\n //@ verify\n //@ ensures !jsonOk ==> \\result === \"bad-json\"\n //@ ensures jsonOk && !methodPathOk ==> \\result === \"bad-method-path\"\n //@ ensures jsonOk && methodPathOk && !argsIsArray ==> \\result === \"bad-args\"\n //@ ensures jsonOk && methodPathOk && argsIsArray ==> \\result === \"run\"\n if (!jsonOk) return \"bad-json\";\n if (!methodPathOk) return \"bad-method-path\";\n if (!argsIsArray) return \"bad-args\";\n return \"run\";\n}\n\n/**\n * An outcome's HTTP status: 403, 400 for a bad body, 200 to run.\n *\n * @ensures exactly the model's ApiStatus\n */\nexport function apiStatusOf(o: ApiOutcome): number {\n //@ verify\n //@ ensures o === \"forbidden\" ==> \\result === 403\n //@ ensures (o === \"bad-json\" || o === \"bad-method-path\" || o === \"bad-args\") ==> \\result === 400\n //@ ensures o === \"run\" ==> \\result === 200\n if (o === \"forbidden\") return 403;\n if (o === \"run\") return 200;\n return 400;\n}\n\n/**\n * A refusal's response text (\"\" to run).\n *\n * @ensures each refusal has its fixed text\n */\nexport function apiMessageOf(o: ApiOutcome): string {\n //@ verify\n //@ ensures o === \"forbidden\" ==> \\result === \"Forbidden: cross-origin requests not allowed\"\n //@ ensures o === \"bad-json\" ==> \\result === \"Invalid JSON body\"\n //@ ensures o === \"bad-method-path\" ==> \\result === \"Missing or invalid methodPath\"\n //@ ensures o === \"bad-args\" ==> \\result === \"Missing or invalid args array\"\n //@ ensures o === \"run\" ==> \\result === \"\"\n if (o === \"forbidden\") return \"Forbidden: cross-origin requests not allowed\";\n if (o === \"bad-json\") return \"Invalid JSON body\";\n if (o === \"bad-method-path\") return \"Missing or invalid methodPath\";\n if (o === \"bad-args\") return \"Missing or invalid args array\";\n return \"\";\n}\n\n/**\n * The Redis TTL for a cache tier: none for staleTime 0, the long TTL from an hour up, else the\n * standard one.\n *\n * @ensures exactly the model's TtlFor\n */\nexport function ttlFor(staleTimeMs: number, redisTtl: number, longRedisTtl: number): number | null {\n //@ verify\n //@ ensures staleTimeMs === 0 ==> \\result === null\n //@ ensures staleTimeMs !== 0 && staleTimeMs >= 3600000 ==> \\result === longRedisTtl\n //@ ensures staleTimeMs !== 0 && staleTimeMs < 3600000 ==> \\result === redisTtl\n if (staleTimeMs === 0) return null;\n if (staleTimeMs >= 3600000) return longRedisTtl;\n return redisTtl;\n}\n\n/** The Redis circuit breaker's state: consecutive failures, and when it closes (0 = closed). */\nexport interface Circuit {\n failures: number;\n openUntil: number;\n}\n\n/** The circuit's answer at a time: whether it is open, and its state after the check. */\nexport interface CircuitAnswer {\n open: boolean;\n next: Circuit;\n}\n\n/**\n * isCircuitOpen at `now`: closed at openUntil 0; past it, reset and closed; else open.\n *\n * @ensures exactly the model's CircuitCheck\n */\nexport function circuitCheck(c: Circuit, now: number): CircuitAnswer {\n //@ verify\n //@ ensures c.openUntil === 0 ==> !\\result.open && \\result.next === c\n //@ ensures c.openUntil !== 0 && now >= c.openUntil ==> !\\result.open && \\result.next.failures === 0 && \\result.next.openUntil === 0\n //@ ensures c.openUntil !== 0 && now < c.openUntil ==> \\result.open && \\result.next === c\n if (c.openUntil === 0) return { open: false, next: c };\n if (now >= c.openUntil) return { open: false, next: { failures: 0, openUntil: 0 } };\n return { open: true, next: c };\n}\n\n/**\n * Whether a failure count opens the circuit: five in a row.\n *\n * @ensures result ⟺ failures ≥ 5\n */\nexport function opensAt(failures: number): boolean {\n //@ verify\n //@ ensures \\result === (failures >= 5)\n return failures >= 5;\n}\n\n/**\n * A failure counts; from the threshold on the circuit opens for a minute from now.\n *\n * @ensures exactly the model's RecordFailure\n */\nexport function recordFailureOf(c: Circuit, now: number): Circuit {\n //@ verify\n //@ ensures \\result.failures === c.failures + 1\n //@ ensures opensAt(c.failures + 1) ==> \\result.openUntil === now + 60000\n //@ ensures !opensAt(c.failures + 1) ==> \\result.openUntil === c.openUntil\n const failures = c.failures + 1;\n if (opensAt(failures)) return { failures, openUntil: now + 60000 };\n return { failures, openUntil: c.openUntil };\n}\n\n/**\n * A success clears the failure count and leaves openUntil.\n *\n * @ensures exactly the model's RecordSuccess\n */\nexport function recordSuccessOf(c: Circuit): Circuit {\n //@ verify\n //@ ensures \\result.failures === 0 && \\result.openUntil === c.openUntil\n return { failures: 0, openUntil: c.openUntil };\n}\n\n/**\n * authorize's verified flag: exactly the text \"true\".\n *\n * @ensures result ⟺ s = \"true\"\n */\nexport function verifiedFlag(s: string): boolean {\n //@ verify\n //@ ensures \\result === (s === \"true\")\n return s === \"true\";\n}\n\n/**\n * reCAPTCHA passes only with a secret, an ok response and the reply's optional `success` exactly\n * true (the score is not read).\n *\n * @ensures exactly the model's RecaptchaOk, success read as `=== true`\n */\nexport function recaptchaOk(\n hasSecret: boolean,\n httpOk: boolean,\n success: boolean | undefined,\n): boolean {\n //@ verify\n //@ ensures \\result === (hasSecret && httpOk && success === true)\n return hasSecret && httpOk && success === true;\n}\n\n/**\n * A customer id is used only above 0; anything else (NaN included, at the caller) is 0.\n *\n * @ensures result = n when n > 0, else 0\n */\nexport function positiveOrZero(n: number): number {\n //@ verify\n //@ ensures n > 0 ==> \\result === n\n //@ ensures n <= 0 ==> \\result === 0\n return n > 0 ? n : 0;\n}\n\n/**\n * The category page size: 24 when none (or 0) is given.\n *\n * @ensures exactly the model's ItemsLimit, a missing limit as 0\n */\nexport function itemsLimitOf(limit: number | undefined): number {\n //@ verify\n //@ ensures (limit === undefined || limit === 0) ==> \\result === 24\n //@ ensures limit !== undefined && limit !== 0 ==> \\result === limit\n if (limit === undefined) return 24;\n if (limit === 0) return 24;\n return limit;\n}\n\n/** How queryAction resolves its client. */\nexport type Resolution = \"scoped\" | \"global\" | \"uninit\";\n\n/**\n * resolveClient: scoped when credentials minted and a scoped client was made; else the global\n * client when one is registered (also for a valid session without a factory); else none.\n *\n * @ensures exactly the model's ResolveClient\n */\nexport function resolutionOf(minted: boolean, scopedMade: boolean, hasGlobal: boolean): Resolution {\n //@ verify\n //@ ensures minted && scopedMade ==> \\result === \"scoped\"\n //@ ensures !(minted && scopedMade) && hasGlobal ==> \\result === \"global\"\n //@ ensures !(minted && scopedMade) && !hasGlobal ==> \\result === \"uninit\"\n if (minted && scopedMade) return \"scoped\";\n return hasGlobal ? \"global\" : \"uninit\";\n}\n\n/** The scoped-client slot's decision. */\nexport type SlotDecision = \"hit\" | \"mint\" | \"no-client\";\n\n/**\n * getOrCreateScopedClient's single slot: a hit when it holds this key; else a new client when a\n * factory is registered; else none. An empty slot is \"\" at the caller, which no key equals (a\n * key holds a NUL).\n *\n * @ensures exactly the model's SlotDecisionOf\n */\nexport function slotDecisionOf(slotKey: string, key: string, hasFactory: boolean): SlotDecision {\n //@ verify\n //@ ensures slotKey === key ==> \\result === \"hit\"\n //@ ensures slotKey !== key && hasFactory ==> \\result === \"mint\"\n //@ ensures slotKey !== key && !hasFactory ==> \\result === \"no-client\"\n if (slotKey === key) return \"hit\";\n return hasFactory ? \"mint\" : \"no-client\";\n}\n\n/**\n * parseMethodPath: a non-empty path, in the allowlist when one is registered (permissive by\n * default); `listed` is the caller's Set lookup.\n *\n * @ensures exactly the model's ApprovePath\n */\nexport function approvePath(path: string, hasAllowlist: boolean, listed: boolean): boolean {\n //@ verify\n //@ ensures \\result === (path !== \"\" && (!hasAllowlist || listed))\n return path !== \"\" && (!hasAllowlist || listed);\n}\n\n/**\n * queryAction caches a call only through a wrapper, and only for a read leaf (augur-core's\n * `isReadMethod`, checked by the caller).\n *\n * @ensures exactly the model's UsesCache\n */\nexport function usesCache(hasWrapper: boolean, isRead: boolean): boolean {\n //@ verify\n //@ ensures \\result === (hasWrapper && isRead)\n return hasWrapper && isRead;\n}\n\n/**\n * The scoped cache prefix: the session's siteId and \":\".\n *\n * @ensures exactly the model's ScopedPrefix\n */\nexport function scopedPrefix(siteId: string): string {\n //@ verify\n //@ ensures \\result === siteId + \":\"\n return siteId + \":\";\n}\n\n/**\n * withServerCache caches when the TTL is not 0 (missing or NaN is 0 at the caller; a negative\n * TTL caches too).\n *\n * @ensures exactly the model's ShouldCache\n */\nexport function shouldCache(ttl: number): boolean {\n //@ verify\n //@ ensures \\result === (ttl !== 0)\n return ttl !== 0;\n}\n\n/**\n * getInvMastDoc's positional uid: kept above 0, else none.\n *\n * @ensures result = uid when uid > 0, else undefined\n */\nexport function docUidOf(uid: number): number | undefined {\n //@ verify\n //@ ensures uid > 0 ==> \\result === uid\n //@ ensures uid <= 0 ==> \\result === undefined\n if (uid > 0) return uid;\n return undefined;\n}\n\n/**\n * The positional itemId is used only at uid 0 and when non-empty (\"\" for none, at the caller).\n *\n * @ensures result ⟺ uid = 0 ∧ itemId ≠ \"\"\n */\nexport function takesItemId(uid: number, itemId: string): boolean {\n //@ verify\n //@ ensures \\result === (uid === 0 && itemId !== \"\")\n return uid === 0 && itemId !== \"\";\n}\n\n/**\n * A doc call needs a uid (truthy at the caller) or a non-empty itemId.\n *\n * @ensures result ⟺ uidSet ∨ itemId ≠ \"\"\n */\nexport function hasDocKey(uidSet: boolean, itemId: string): boolean {\n //@ verify\n //@ ensures \\result === (uidSet || itemId !== \"\")\n return uidSet || itemId !== \"\";\n}\n\n/**\n * The configured payments mode, \"live\" by default.\n *\n * @ensures result = configured ?? \"live\"\n */\nexport function configuredModeOf(configured: string | undefined): string {\n //@ verify\n //@ ensures configured === undefined ==> \\result === \"live\"\n //@ ensures configured !== undefined ==> \\result === configured\n if (configured === undefined) return \"live\";\n return configured;\n}\n"],"mappings":"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","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/query-options-helper.ts"],"sourcesContent":["import type { UseQueryOptions, UseSuspenseQueryOptions } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG } from \"@simpleapps-com/augur-utils\";\nimport { resolveGcTime } from \"@simpleapps-com/augur-core\";\n\nexport interface QueryOptionsConfig<TParams, TData> {\n /** Base query key (e.g., \"customer-orders\") */\n baseKey: string;\n /** Parameters object */\n params: TParams;\n /** Function that returns the data */\n queryFn: (params: TParams) => Promise<TData>;\n /** Function to determine if query should be enabled */\n enabledFn?: (params: TParams) => boolean;\n /** Custom stale time in milliseconds (default: SEMI_STATIC) */\n staleTime?: number;\n /**\n * Custom garbage collection time in milliseconds (default: SEMI_STATIC).\n * Browser only: on the server the returned gcTime is always `Infinity`\n * (no GC timer), so the per-request cache is freed with the request (#481).\n */\n gcTime?: number;\n /** Key to exclude from query key generation */\n excludeFromKey?: keyof TParams;\n}\n\n/**\n * `[baseKey, \"key:value\", ...]` from the params, sorted, leaving out `excludeFromKey` and\n * any undefined, null or empty-string value.\n */\nfunction queryKeyFor<TParams extends Record<string, unknown>>(\n baseKey: string,\n params: TParams,\n excludeFromKey: keyof TParams | undefined,\n): string[] {\n const paramEntries = Object.entries(params)\n .filter(([key, value]) => {\n if (excludeFromKey && key === excludeFromKey) return false;\n return value !== undefined && value !== null && value !== \"\";\n })\n .map(([key, value]) => `${key}:${value}`)\n .sort();\n\n return [baseKey, ...paramEntries];\n}\n\n/**\n * Creates useQuery options with consistent key generation.\n * Filters out undefined/null/empty params from the query key.\n */\nexport const createQueryOptions = <TParams extends Record<string, unknown>, TData>({\n baseKey,\n params,\n queryFn,\n enabledFn,\n staleTime = CACHE_CONFIG.SEMI_STATIC.staleTime,\n gcTime = CACHE_CONFIG.SEMI_STATIC.gcTime,\n excludeFromKey,\n}: QueryOptionsConfig<TParams, TData>): UseQueryOptions<TData> => {\n return {\n queryKey: queryKeyFor(baseKey, params, excludeFromKey),\n queryFn: () => queryFn(params),\n enabled: enabledFn ? enabledFn(params) : true,\n staleTime,\n gcTime: resolveGcTime(gcTime),\n };\n};\n\n/**\n * Creates useSuspenseQuery options with consistent key generation.\n * Same as createQueryOptions but without enabledFn (suspense queries\n * cannot be disabled).\n */\nexport const createSuspenseQueryOptions = <TParams extends Record<string, unknown>, TData>({\n baseKey,\n params,\n queryFn,\n staleTime = CACHE_CONFIG.SEMI_STATIC.staleTime,\n gcTime = CACHE_CONFIG.SEMI_STATIC.gcTime,\n excludeFromKey,\n}: Omit<QueryOptionsConfig<TParams, TData>, \"enabledFn\">): UseSuspenseQueryOptions<TData> => {\n return {\n queryKey: queryKeyFor(baseKey, params, excludeFromKey),\n queryFn: () => queryFn(params),\n staleTime,\n gcTime: resolveGcTime(gcTime),\n };\n};\n"],"mappings":";AACA,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AA2B9B,SAAS,YACP,SACA,QACA,gBACU;AACV,QAAM,eAAe,OAAO,QAAQ,MAAM,EACvC,OAAO,CAAC,CAAC,KAAK,KAAK,MAAM;AACxB,QAAI,kBAAkB,QAAQ,eAAgB,QAAO;AACrD,WAAO,UAAU,UAAa,UAAU,QAAQ,UAAU;AAAA,EAC5D,CAAC,EACA,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,EACvC,KAAK;AAER,SAAO,CAAC,SAAS,GAAG,YAAY;AAClC;AAMO,IAAM,qBAAqB,CAAiD;AAAA,EACjF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,aAAa,YAAY;AAAA,EACrC,SAAS,aAAa,YAAY;AAAA,EAClC;AACF,MAAkE;AAChE,SAAO;AAAA,IACL,UAAU,YAAY,SAAS,QAAQ,cAAc;AAAA,IACrD,SAAS,MAAM,QAAQ,MAAM;AAAA,IAC7B,SAAS,YAAY,UAAU,MAAM,IAAI;AAAA,IACzC;AAAA,IACA,QAAQ,cAAc,MAAM;AAAA,EAC9B;AACF;AAOO,IAAM,6BAA6B,CAAiD;AAAA,EACzF;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,aAAa,YAAY;AAAA,EACrC,SAAS,aAAa,YAAY;AAAA,EAClC;AACF,MAA6F;AAC3F,SAAO;AAAA,IACL,UAAU,YAAY,SAAS,QAAQ,cAAc;AAAA,IACrD,SAAS,MAAM,QAAQ,MAAM;AAAA,IAC7B;AAAA,IACA,QAAQ,cAAc,MAAM;AAAA,EAC9B;AACF;","names":[]}