@simpleapps-com/augur-server 2026.11.4 → 2026.11.6
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.
- package/EXPORTS.md +28 -1
- package/README.md +42 -14
- package/dist/actions/action-rules.d.ts +99 -0
- package/dist/actions/action-rules.d.ts.map +1 -0
- package/dist/actions/agr-site.d.ts +7 -15
- package/dist/actions/agr-site.d.ts.map +1 -1
- package/dist/actions/commerce.d.ts.map +1 -1
- package/dist/actions/customers.d.ts +12 -15
- package/dist/actions/customers.d.ts.map +1 -1
- package/dist/actions/favorites.d.ts +9 -12
- package/dist/actions/favorites.d.ts.map +1 -1
- package/dist/actions/gregorovich.d.ts +7 -15
- package/dist/actions/gregorovich.d.ts.map +1 -1
- package/dist/actions/items.d.ts +8 -20
- package/dist/actions/items.d.ts.map +1 -1
- package/dist/actions/joomla.d.ts +8 -14
- package/dist/actions/joomla.d.ts.map +1 -1
- package/dist/actions/legacy.d.ts +10 -20
- package/dist/actions/legacy.d.ts.map +1 -1
- package/dist/actions/orders.d.ts +7 -14
- package/dist/actions/orders.d.ts.map +1 -1
- package/dist/actions/read-specs.d.ts +119 -0
- package/dist/actions/read-specs.d.ts.map +1 -0
- package/dist/actions/site.d.ts.map +1 -1
- package/dist/actions/vmi.d.ts +10 -16
- package/dist/actions/vmi.d.ts.map +1 -1
- package/dist/actions/wishlists.d.ts +11 -13
- package/dist/actions/wishlists.d.ts.map +1 -1
- package/dist/api.js +3 -2
- package/dist/api.js.map +1 -1
- package/dist/auth.js +3 -2
- package/dist/cache/redis-client.d.ts.map +1 -1
- package/dist/cache/redis-rules.d.ts +21 -0
- package/dist/cache/redis-rules.d.ts.map +1 -0
- package/dist/cache/spec-read.d.ts +39 -0
- package/dist/cache/spec-read.d.ts.map +1 -0
- package/dist/cache/with-cache.d.ts +2 -2
- package/dist/cache/with-cache.d.ts.map +1 -1
- package/dist/{chunk-WR7WT2FI.js → chunk-2RAKVFB5.js} +30 -9
- package/dist/chunk-2RAKVFB5.js.map +1 -0
- package/dist/{chunk-F7QWHMHH.js → chunk-4JPJQHT6.js} +2 -2
- package/dist/chunk-JIYVQWXK.js +10 -0
- package/dist/chunk-JIYVQWXK.js.map +1 -0
- package/dist/{chunk-34NCJS52.js → chunk-SFXO74RC.js} +874 -719
- package/dist/chunk-SFXO74RC.js.map +1 -0
- package/dist/chunk-V76GZZF3.js +66 -0
- package/dist/chunk-V76GZZF3.js.map +1 -0
- package/dist/{chunk-B4MGIUCU.js → chunk-Z53NEFEQ.js} +17 -16
- package/dist/chunk-Z53NEFEQ.js.map +1 -0
- package/dist/hooks.js +3 -2
- package/dist/hooks.js.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/query-action.d.ts +24 -1
- package/dist/query-action.d.ts.map +1 -1
- package/dist/query-action.js +7 -2
- package/dist/read-rules.d.ts +45 -0
- package/dist/read-rules.d.ts.map +1 -0
- package/dist/rules.d.ts +16 -0
- package/dist/rules.d.ts.map +1 -1
- package/dist/server-site-registry.d.ts.map +1 -1
- package/dist/server-site.d.ts.map +1 -1
- package/dist/site.js +24 -14
- package/dist/site.js.map +1 -1
- package/dist/sitemap-rules.d.ts +154 -0
- package/dist/sitemap-rules.d.ts.map +1 -0
- package/dist/sitemap.d.ts +80 -0
- package/dist/sitemap.d.ts.map +1 -0
- package/dist/sitemap.js +242 -0
- package/dist/sitemap.js.map +1 -0
- package/dist/testing.js +4 -2
- package/dist/testing.js.map +1 -1
- package/dist/utils/read-all-pages.d.ts +17 -0
- package/dist/utils/read-all-pages.d.ts.map +1 -0
- package/llms.txt +54 -1
- package/package.json +9 -5
- package/dist/chunk-34NCJS52.js.map +0 -1
- package/dist/chunk-B4MGIUCU.js.map +0 -1
- package/dist/chunk-WR7WT2FI.js.map +0 -1
- /package/dist/{chunk-F7QWHMHH.js.map → chunk-4JPJQHT6.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../utils/src/replace.ts","../../utils/src/xml.ts","../../utils/src/sitemap.ts","../src/sitemap-rules.ts","../src/sitemap.ts"],"sourcesContent":["//@ backend dafny\nimport { codeAt, indexOfFrom } from \"./strings\";\n\n/* Whole-string rewrites, verified with LemmaScript → Dafny (model: models/Utils.dfy \"text\n replacement\"; link: models/links/utils-replace.dfy). Each has a recursive spec (for\n proofs and tests) and a loop proved to build exactly it (for callers: its depth doesn't\n grow with the input). The `\\result === spec(s)` clause of each loop is a hand `ensures`\n in replace.dfy, as utils `escapeHtml`'s is: lsc would put it in every importer's axiom,\n where this file's own spec isn't emitted. */\n\n// --- One substitution rule (model `Utils.Substituted`, 2026-11-03): each code unit found in a\n// table is replaced by its text, every other kept. replaceCode, pointerToken, escapeHtml and\n// the generator's look-alike fold are this rule, each with its own table.\n\n/**\n * The first index ≥ `i` holding `c` in `codes`, or -1.\n *\n * @ensures result = -1 ∨ (i ≤ result < |codes| ∧ codes[result] = c) — the model's CodeIndex\n */\nexport function codeIndex(codes: number[], c: number, i: number): number {\n //@ verify\n //@ type i nat\n //@ requires i <= codes.length\n //@ decreases codes.length - i\n //@ ensures \\result === -1 || (i <= \\result && \\result < codes.length && codes[\\result] === c)\n // `===`, not `>=`: past the end codes[i] is undefined, never c, so `>=` vs `>` is equivalent\n if (i === codes.length) return -1;\n return (codes[i] as number) === c ? i : codeIndex(codes, c, i + 1);\n}\n\n/** `s` with each code unit in `codes` replaced by its text, recursively: the spec `substitute` builds. */\nexport function substitutedText(s: string, codes: number[], texts: string[]): string {\n //@ verify\n //@ decreases s.length\n //@ ensures s.length === 0 ==> \\result === \"\"\n //@ ensures codes.length === 0 ==> \\result === s\n if (s.length === 0) return \"\";\n const k = codeIndex(codes, s.charCodeAt(0), 0);\n const head = k >= 0 && k < texts.length ? (texts[k] as string) : s.slice(0, 1);\n return head + substitutedText(s.slice(1), codes, texts);\n}\n\n/**\n * `s` with each code unit in `codes` replaced by the text at its first index there, every\n * other kept. A loop, so its depth doesn't grow with the input.\n *\n * @ensures result = substitutedText(s, codes, texts) — the model's Substituted (a hand\n * ensures in replace.dfy: importers can't resolve substitutedText)\n * @ensures |s| = 0 ⟹ result = \"\" ∧ |codes| = 0 ⟹ result = s — no table, no change\n */\nexport function substitute(s: string, codes: number[], texts: string[]): string {\n //@ verify\n //@ ensures s.length === 0 ==> \\result === \"\"\n //@ ensures codes.length === 0 ==> \\result === s\n let out = \"\";\n // `!==`, not `<`: one step past the end reads NaN and adds \"\", so `<=` would be equivalent\n for (let i = 0; i !== s.length; i++) {\n //@ invariant 0 <= i && i <= s.length\n //@ invariant out + substitutedText(s.slice(i), codes, texts) === substitutedText(s, codes, texts)\n //@ decreases s.length - i\n const k = codeIndex(codes, s.charCodeAt(i), 0);\n out = k >= 0 && k < texts.length ? out + (texts[k] as string) : out + s.slice(i, i + 1);\n }\n return out;\n}\n\n/**\n * `s` with every `from` code unit replaced by `to`, recursively: the one-entry table.\n *\n * @ensures no `from` survives when `to` holds none — exactly the model's ReplaceCode in the link\n */\nexport function replacedCode(s: string, from: number, to: string): string {\n //@ verify\n //@ ensures forall(j: nat, j < to.length ==> to.charCodeAt(j) !== from) ==> forall(k: nat, k < \\result.length ==> \\result.charCodeAt(k) !== from)\n return substitutedText(s, [from], [to]);\n}\n\n/**\n * `s` with every `from` code unit replaced by `to` (`replaceAll` of one character).\n *\n * @ensures no `from` survives when `to` holds none (ReplaceCodeRemoves) — = replacedCode(s,\n * from, to), the model's ReplaceCode, as a hand ensures in replace.dfy\n */\nexport function replaceCode(s: string, from: number, to: string): string {\n //@ verify\n //@ ensures forall(j: nat, j < to.length ==> to.charCodeAt(j) !== from) ==> forall(k: nat, k < \\result.length ==> \\result.charCodeAt(k) !== from)\n return substitute(s, [from], [to]);\n}\n\n/**\n * `s` with its first `find` replaced by `put`; no match leaves it: JS `s.replace(find, put)` for\n * a string `find`, when `put` holds no `$` (JS reads `$&`, `$1` there as a pattern).\n *\n * @ensures exactly the model's ReplaceFirst\n */\nexport function replaceFirst(s: string, find: string, put: string): string {\n //@ verify\n //@ ensures \\result === (indexOfFrom(s, find, 0) < 0 ? s : s.slice(0, indexOfFrom(s, find, 0)) + put + s.slice(indexOfFrom(s, find, 0) + find.length))\n const i = indexOfFrom(s, find, 0);\n if (i < 0) return s;\n return s.slice(0, i) + put + s.slice(i + find.length);\n}\n\n/**\n * `s` with every `find` replaced by `put`, left to right without overlaps: JS\n * `s.split(find).join(put)` for a non-empty `find` (tests pin the two). Recursive, with no\n * loop twin: its callers fill short templates (the SDK's registry paths), so the depth stays\n * small; a long-input caller would need one.\n *\n * @requires |find| > 0 — split(\"\") splits into characters, a different rule\n * @ensures text shorter than `find` is unchanged, and so is any text when `put` = `find` —\n * exactly the model's ReplaceText in the link\n */\nexport function replaceText(s: string, find: string, put: string): string {\n //@ verify\n //@ requires find.length > 0\n //@ decreases s.length\n //@ ensures s.length < find.length ==> \\result === s\n //@ ensures put === find ==> \\result === s\n if (s.length < find.length) return s;\n if (s.slice(0, find.length) === find) {\n return put + replaceText(s.slice(find.length), find, put);\n }\n return s.slice(0, 1) + replaceText(s.slice(1), find, put);\n}\n\n/**\n * A JSON Pointer token of `s`, recursively: `~` → `~0`, `/` → `~1`.\n *\n * @ensures never holds \"/\" — exactly the model's PointerToken in the link\n */\nexport function pointerTokenOf(s: string): string {\n //@ verify\n //@ ensures forall(k: nat, k < \\result.length ==> \\result.charCodeAt(k) !== 47)\n return substitutedText(s, [126, 47], [\"~0\", \"~1\"]);\n}\n\n/**\n * `s` as a JSON Pointer reference token (RFC 6901 §3): `~` as `~0`, `/` as `~1`.\n *\n * @ensures never holds \"/\" (PointerTokenHasNoSlash) — = pointerTokenOf(s), the model's\n * PointerToken, as a hand ensures in replace.dfy\n */\nexport function pointerToken(s: string): string {\n //@ verify\n //@ ensures forall(k: nat, k < \\result.length ==> \\result.charCodeAt(k) !== 47)\n return substitute(s, [126, 47], [\"~0\", \"~1\"]);\n}\n\n/**\n * The escape of `s`, recursively: each `&` `<` `>` `\"` `'` as its entity.\n *\n * @ensures no `<` `>` `\"` `'` in result — exactly the model's EscapeHtml in the link\n */\nexport function escapedText(s: string): string {\n //@ verify\n //@ ensures forall(k: nat, k < \\result.length ==> (\\result.charCodeAt(k) !== 60 && \\result.charCodeAt(k) !== 62 && \\result.charCodeAt(k) !== 34 && \\result.charCodeAt(k) !== 39))\n return substitutedText(s, [38, 60, 62, 34, 39], [\"&\", \"<\", \">\", \""\", \"'\"]);\n}\n\n/**\n * Escape text for an HTML body or a double-quoted attribute.\n *\n * @ensures result = escapedText(value) — exactly the model's EscapeHtml (a hand ensures in\n * replace.dfy, since importers can't see escapedText)\n * @ensures ∀ k < |result|. result[k] ∉ {\"<\", \">\", \"\\\"\", \"'\"} — nothing in the output can\n * open a tag or close the attribute; \"&\" appears only as the start of an entity\n */\nexport function escapeHtml(value: string): string {\n //@ verify\n //@ ensures forall(k: nat, k < \\result.length ==> (\\result.charCodeAt(k) !== 60 && \\result.charCodeAt(k) !== 62 && \\result.charCodeAt(k) !== 34 && \\result.charCodeAt(k) !== 39))\n return substitute(value, [38, 60, 62, 34, 39], [\"&\", \"<\", \">\", \""\", \"'\"]);\n}\n\n/**\n * The code units a JSON string escapes: `\"`, `\\`, then the control characters with short\n * escapes (\\b \\t \\n \\f \\r), then the other code units below 0x20.\n *\n * @ensures exactly the model's JsonCodes\n */\nexport function jsonCodes(): number[] {\n //@ verify\n //@ ensures \\result === [34, 92, 8, 9, 10, 12, 13, 0, 1, 2, 3, 4, 5, 6, 7, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]\n return [\n 34, 92, 8, 9, 10, 12, 13, 0, 1, 2, 3, 4, 5, 6, 7, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\n 24, 25, 26, 27, 28, 29, 30, 31,\n ];\n}\n\n/**\n * Each `jsonCodes` entry's escape (ECMA-262 QuoteJSONString; lowercase hex, as JSON.stringify).\n *\n * @ensures exactly the model's JsonTexts\n */\nexport function jsonTexts(): string[] {\n //@ verify\n //@ ensures \\result === [\"\\\\\\\"\", \"\\\\\\\\\", \"\\\\b\", \"\\\\t\", \"\\\\n\", \"\\\\f\", \"\\\\r\", \"\\\\u0000\", \"\\\\u0001\", \"\\\\u0002\", \"\\\\u0003\", \"\\\\u0004\", \"\\\\u0005\", \"\\\\u0006\", \"\\\\u0007\", \"\\\\u000b\", \"\\\\u000e\", \"\\\\u000f\", \"\\\\u0010\", \"\\\\u0011\", \"\\\\u0012\", \"\\\\u0013\", \"\\\\u0014\", \"\\\\u0015\", \"\\\\u0016\", \"\\\\u0017\", \"\\\\u0018\", \"\\\\u0019\", \"\\\\u001a\", \"\\\\u001b\", \"\\\\u001c\", \"\\\\u001d\", \"\\\\u001e\", \"\\\\u001f\"]\n return [\n '\\\\\"',\n \"\\\\\\\\\",\n \"\\\\b\",\n \"\\\\t\",\n \"\\\\n\",\n \"\\\\f\",\n \"\\\\r\",\n \"\\\\u0000\",\n \"\\\\u0001\",\n \"\\\\u0002\",\n \"\\\\u0003\",\n \"\\\\u0004\",\n \"\\\\u0005\",\n \"\\\\u0006\",\n \"\\\\u0007\",\n \"\\\\u000b\",\n \"\\\\u000e\",\n \"\\\\u000f\",\n \"\\\\u0010\",\n \"\\\\u0011\",\n \"\\\\u0012\",\n \"\\\\u0013\",\n \"\\\\u0014\",\n \"\\\\u0015\",\n \"\\\\u0016\",\n \"\\\\u0017\",\n \"\\\\u0018\",\n \"\\\\u0019\",\n \"\\\\u001a\",\n \"\\\\u001b\",\n \"\\\\u001c\",\n \"\\\\u001d\",\n \"\\\\u001e\",\n \"\\\\u001f\",\n ];\n}\n\n/**\n * A string as JSON text, as `JSON.stringify(s)` writes it for well-formed text: quoted, `\"`\n * and `\\` backslashed, control characters escaped. A lone surrogate is kept as it is\n * (JSON.stringify writes `\\udxxx`); callers pass well-formed text. Built by the `substitute`\n * loop, so its depth doesn't grow with the text (an FAQ answer can be long; Fable review\n * 2026-11-06); importers still see a function (its contract as an axiom), so their premise\n * `jsonString(s) == Utils.JsonString(s)` stands.\n *\n * @ensures result = `\"` + substitutedText(s, jsonCodes(), jsonTexts()) + `\"` — a hand ensures in\n * replace.dfy; the model's JsonString (proved in links/utils-replace.dfy)\n * @ensures result starts and ends with `\"`\n */\nexport function jsonString(s: string): string {\n //@ verify\n //@ ensures \\result.length >= 2 && \\result.charCodeAt(0) === 34 && \\result.charCodeAt(\\result.length - 1) === 34\n return '\"' + substitute(s, jsonCodes(), jsonTexts()) + '\"';\n}\n\n/**\n * `s` with every `*` `/` pair written `* /`, recursively: the spec `commentSafe` builds.\n *\n * @ensures no \"*\" \"/\" pair in result — exactly the model's CommentSafe in the link\n */\nexport function commentSafeOf(s: string): string {\n //@ verify\n //@ decreases s.length\n //@ ensures forall(k: nat, k + 1 < \\result.length ==> !(\\result.charCodeAt(k) === 42 && \\result.charCodeAt(k + 1) === 47))\n if (s.length === 0) return \"\";\n if (codeAt(s, 0) === 42 && codeAt(s, 1) === 47) {\n return \"* /\" + commentSafeOf(s.slice(2));\n }\n return s.slice(0, 1) + commentSafeOf(s.slice(1));\n}\n\n/**\n * Text safe inside a `/* … *\\/` comment: every `*` `/` pair written `* /`.\n *\n * @ensures no \"*\" \"/\" pair in result: nothing can close the comment — = commentSafeOf(s), the\n * model's CommentSafe, as a hand ensures in replace.dfy\n */\nexport function commentSafe(s: string): string {\n //@ verify\n //@ ensures forall(k: nat, k + 1 < \\result.length ==> !(\\result.charCodeAt(k) === 42 && \\result.charCodeAt(k + 1) === 47))\n let out = \"\";\n let i = 0;\n while (i !== s.length) {\n //@ invariant 0 <= i && i <= s.length\n //@ invariant out + commentSafeOf(s.slice(i)) === commentSafeOf(s)\n //@ decreases s.length - i\n if (codeAt(s, i) === 42 && codeAt(s, i + 1) === 47) {\n out = out + \"* /\";\n i = i + 2;\n } else {\n out = out + s.slice(i, i + 1);\n i = i + 1;\n }\n }\n return out;\n}\n","//@ backend dafny\n\n/* XML text escaping, verified with LemmaScript → Dafny (model: models/Sitemap.dfy XmlEscape;\n link: models/links/utils-xml.dfy). The sitemap protocol's list, exactly (sitemaps.org\n \"Entity escaping\", atlas#101): `&` `'` `\"` `>` `<` as `&` `'` `"` `>` `<`.\n Recursive, so proved text builders (utils `sitemap`) can call it inside an expression; its\n depth is the text's length (a URL, at most 2,048 characters by the protocol). */\n\n/**\n * The entity the sitemap protocol writes for code unit `c`, or \"\" when `c` is written as itself.\n *\n * @ensures exactly the model's XmlEntity\n */\nexport function xmlEntity(c: number): string {\n //@ verify\n //@ ensures \\result === (c === 38 ? \"&\" : c === 60 ? \"<\" : c === 62 ? \">\" : c === 34 ? \""\" : c === 39 ? \"'\" : \"\")\n if (c === 38) return \"&\";\n if (c === 60) return \"<\";\n if (c === 62) return \">\";\n if (c === 34) return \""\";\n if (c === 39) return \"'\";\n return \"\";\n}\n\n/**\n * `s` escaped for XML text or a quoted attribute: each of `&` `<` `>` `\"` `'` as its entity,\n * every other code unit kept.\n *\n * @ensures ∀ k < |result|. result[k] ∉ {\"<\", \">\", \"\\\"\", \"'\"} — nothing can end an element or a\n * quoted value; exactly the model's XmlEscape in the link (a recursive contract can't be\n * imported, models/LSC-GAPS.md)\n */\nexport function xmlEscaped(s: string): string {\n //@ verify\n //@ decreases s.length\n //@ ensures forall(k: nat, k < \\result.length ==> (\\result.charCodeAt(k) !== 60 && \\result.charCodeAt(k) !== 62 && \\result.charCodeAt(k) !== 34 && \\result.charCodeAt(k) !== 39))\n if (s.length === 0) return \"\";\n const entity = xmlEntity(s.charCodeAt(0));\n return (entity === \"\" ? s.slice(0, 1) : entity) + xmlEscaped(s.slice(1));\n}\n","//@ backend dafny\nimport { lineFeed } from \"./strings\";\nimport { xmlEscaped } from \"./xml\";\n\n/* The sitemap protocol's XML (sitemaps.org; atlas#101), built once for every site, verified with\n LemmaScript → Dafny (model: models/Sitemap.dfy; link: models/links/utils-sitemap.dfy). A\n caller writes a head, its blocks and the tail: a `<urlset>` of `urlBlock`s, or a\n `<sitemapindex>` of `sitemapBlock`s. Each element sits on its own line, indented two spaces per\n level (owner 2026-11-10: \"properly formatted\"), and each value is escaped with `xmlEscaped`.\n\n The contracts here are true but not exact: an exact one names `xmlEscaped` or `lineFeed`, which\n an importer that doesn't call them itself can't resolve (models/LSC-GAPS.md). The link proves\n each function is the model's, and importers' links take that as a premise. */\n\n/**\n * A `<urlset>` file's opening: the XML declaration, then the root element.\n *\n * @ensures starts with the XML declaration — exactly the model's UrlsetHead in the link\n */\nexport function urlsetHead(): string {\n //@ verify\n //@ ensures \\result.length > 38 && \\result.slice(0, 38) === '<?xml version=\"1.0\" encoding=\"UTF-8\"?>'\n return (\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>' +\n lineFeed() +\n '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">' +\n lineFeed()\n );\n}\n\n/**\n * A `<urlset>` file's closing tag and final line feed.\n *\n * @ensures |result| = 10 ∧ starts with \"</urlset>\" — exactly the model's UrlsetTail in the link\n */\nexport function urlsetTail(): string {\n //@ verify\n //@ ensures \\result.length === 10 && \\result.slice(0, 9) === \"</urlset>\"\n return \"</urlset>\" + lineFeed();\n}\n\n/**\n * A `<sitemapindex>` file's opening: the XML declaration, then the root element.\n *\n * @ensures starts with the XML declaration — exactly the model's IndexHead in the link\n */\nexport function sitemapIndexHead(): string {\n //@ verify\n //@ ensures \\result.length > 38 && \\result.slice(0, 38) === '<?xml version=\"1.0\" encoding=\"UTF-8\"?>'\n return (\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>' +\n lineFeed() +\n '<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">' +\n lineFeed()\n );\n}\n\n/**\n * A `<sitemapindex>` file's closing tag and final line feed.\n *\n * @ensures |result| = 16 ∧ starts with \"</sitemapindex>\" — exactly the model's IndexTail in the link\n */\nexport function sitemapIndexTail(): string {\n //@ verify\n //@ ensures \\result.length === 16 && \\result.slice(0, 15) === \"</sitemapindex>\"\n return \"</sitemapindex>\" + lineFeed();\n}\n\n/**\n * One page of a `<urlset>`: its `<loc>`, and its `<lastmod>` only when known (\"\" leaves it out),\n * each escaped and on its own line.\n *\n * @ensures starts with \" <url>\" — exactly the model's UrlBlock in the link\n */\nexport function urlBlock(loc: string, lastmod: string): string {\n //@ verify\n //@ ensures \\result.length > 7 && \\result.slice(0, 7) === \" <url>\"\n const date =\n lastmod === \"\" ? \"\" : \" <lastmod>\" + xmlEscaped(lastmod) + \"</lastmod>\" + lineFeed();\n return (\n \" <url>\" +\n lineFeed() +\n \" <loc>\" +\n xmlEscaped(loc) +\n \"</loc>\" +\n lineFeed() +\n date +\n \" </url>\" +\n lineFeed()\n );\n}\n\n/**\n * One child sitemap of a `<sitemapindex>`: its `<loc>`, escaped, on its own line.\n *\n * @ensures starts with \" <sitemap>\" — exactly the model's SitemapBlock in the link\n */\nexport function sitemapBlock(loc: string): string {\n //@ verify\n //@ ensures \\result.length > 11 && \\result.slice(0, 11) === \" <sitemap>\"\n return (\n \" <sitemap>\" +\n lineFeed() +\n \" <loc>\" +\n xmlEscaped(loc) +\n \"</loc>\" +\n lineFeed() +\n \" </sitemap>\" +\n lineFeed()\n );\n}\n","//@ backend dafny\nimport { decimal } from \"@atlas/foundation/decimal\";\nimport { substitutedText } from \"@atlas/utils/replace\";\nimport {\n sitemapBlock,\n sitemapIndexHead,\n sitemapIndexTail,\n urlBlock,\n urlsetHead,\n urlsetTail,\n} from \"@atlas/utils/sitemap\";\nimport {\n canonicalNatValue,\n endsWith,\n isCanonicalNat,\n rStripCode,\n startsWithAt,\n} from \"@atlas/utils/strings\";\n\n/* The item sitemaps' decisions (atlas#101), verified with LemmaScript → Dafny and linked to\n models/AugurServerSitemap.dfy (models/links/augur-server-sitemap-rules.dfy). `sitemap.ts` only\n awaits the SDK and maps these answers to a Response.\n\n Layout (owner 2026-11-10): the item index at `{base}sitemap.xml` and page n at\n `{base}sitemap-{n}.xml`, all in the items' own folder `base` (default \"/items/\"), so by the\n sitemap protocol's location rule they may list the item pages there. */\n\n/** One item for a `<urlset>`: its page URL and, when known, its last change (\"\" leaves it out). */\nexport interface SitemapRow {\n loc: string;\n lastmod: string;\n}\n\n/** What a sitemap request comes to: served, not a sitemap (404), or Augur failed (503). */\nexport type SitemapOutcome = \"ok\" | \"not-found\" | \"unavailable\";\n\n// ---------------------------------------------------------------- pages\n\n/**\n * The SDK's `total` as a count: itself when a whole number ≥ 0, else 0 (no item sitemaps rather\n * than a guess).\n *\n * @ensures exactly the model's UsableTotal\n */\nexport function usableTotal(isWhole: boolean, n: number): number {\n //@ verify\n //@ ensures \\result === (isWhole && n >= 0 ? n : 0)\n return isWhole && n >= 0 ? n : 0;\n}\n\n/**\n * How many 5,000-item sitemaps cover `total` items (the endpoint fixes a page at 5,000).\n *\n * @requires total ≥ 0\n * @ensures result = ⌈total / 5000⌉ — exactly the model's ItemSitemapCount\n */\nexport function itemSitemapCount(total: number): number {\n //@ verify\n //@ type total nat\n //@ requires total >= 0\n //@ ensures \\result === Math.floor((total + 4999) / 5000)\n return Math.floor((total + 4999) / 5000);\n}\n\n/**\n * The page a request names (the rewrite's bare `:page`): its value when it is a canonical\n * natural number, else 0, \"not a page\" (`0`, `01`, `1e3`, ` 1`, `-1` and text never name one).\n *\n * @ensures result = canonicalNatValue(page) for canonical text, else 0 — exactly the model's\n * ItemSitemapPage (the test is spelled out: canonicalNatValue's contract names\n * isCanonicalNat, which this file must call to resolve, models/LSC-GAPS.md)\n */\nexport function parseItemSitemapPage(page: string): number {\n //@ verify\n //@ ensures \\result === (isCanonicalNat(page) ? canonicalNatValue(page) : 0)\n return isCanonicalNat(page) ? canonicalNatValue(page) : 0;\n}\n\n// ---------------------------------------------------------------- outcomes\n\n/**\n * An item page's outcome: not a page, or an empty page past the first, is \"not-found\"; a failed\n * fetch is \"unavailable\"; anything else is served. `rows` counts what the endpoint returned,\n * before the scope filter.\n *\n * @ensures exactly the model's ItemOutcome\n */\nexport function itemSitemapOutcome(page: number, fetched: boolean, rows: number): SitemapOutcome {\n //@ verify\n //@ ensures page === 0 ==> \\result === \"not-found\"\n //@ ensures page !== 0 && !fetched ==> \\result === \"unavailable\"\n //@ ensures page !== 0 && fetched && rows === 0 && page > 1 ==> \\result === \"not-found\"\n //@ ensures page !== 0 && fetched && !(rows === 0 && page > 1) ==> \\result === \"ok\"\n if (page === 0) return \"not-found\";\n if (!fetched) return \"unavailable\";\n if (rows === 0 && page > 1) return \"not-found\";\n return \"ok\";\n}\n\n/**\n * The item index's outcome: served when the count was read, else \"unavailable\" (a 200 with no\n * sitemaps would tell a crawler the site has none).\n *\n * @ensures exactly the model's IndexOutcome\n */\nexport function sitemapIndexOutcome(fetched: boolean): SitemapOutcome {\n //@ verify\n //@ ensures \\result === (fetched ? \"ok\" : \"unavailable\")\n return fetched ? \"ok\" : \"unavailable\";\n}\n\n/**\n * The HTTP status of an outcome.\n *\n * @ensures exactly the model's StatusOf\n */\nexport function sitemapStatus(o: SitemapOutcome): number {\n //@ verify\n //@ ensures \\result === (o === \"ok\" ? 200 : o === \"not-found\" ? 404 : 503)\n if (o === \"ok\") return 200;\n return o === \"not-found\" ? 404 : 503;\n}\n\n/**\n * An outcome's `Cache-Control`: a served sitemap for a day at the CDN and an hour in browsers\n * (rebuilt at most daily); a 404 or a 503 never.\n *\n * @ensures exactly the model's CacheControlOf\n */\nexport function sitemapCacheControl(o: SitemapOutcome): string {\n //@ verify\n //@ ensures \\result === (o === \"ok\" ? \"public, max-age=3600, s-maxage=86400\" : \"no-store\")\n return o === \"ok\" ? \"public, max-age=3600, s-maxage=86400\" : \"no-store\";\n}\n\n/**\n * An outcome's `Retry-After` in seconds: an hour for a 503, else \"\" (no header).\n *\n * @ensures exactly the model's RetryAfterOf\n */\nexport function sitemapRetryAfter(o: SitemapOutcome): string {\n //@ verify\n //@ ensures \\result === (o === \"unavailable\" ? \"3600\" : \"\")\n return o === \"unavailable\" ? \"3600\" : \"\";\n}\n\n/**\n * Whether a request's page is worth asking Augur for: only a page (≥ 1); \"not a page\" is\n * answered without a call.\n *\n * @ensures exactly the model's FetchesPage\n */\nexport function fetchesPage(page: number): boolean {\n //@ verify\n //@ ensures \\result === (page >= 1)\n return page >= 1;\n}\n\n/**\n * A response's body: the XML when served, else a short plain-text reason.\n *\n * @ensures exactly the model's BodyOf\n */\nexport function sitemapBody(o: SitemapOutcome, xml: string): string {\n //@ verify\n //@ ensures \\result === (o === \"ok\" ? xml : o === \"not-found\" ? \"Not Found\" : \"Sitemap temporarily unavailable\")\n if (o === \"ok\") return xml;\n return o === \"not-found\" ? \"Not Found\" : \"Sitemap temporarily unavailable\";\n}\n\n/** One response header. */\nexport interface SitemapHeader {\n name: string;\n value: string;\n}\n\n/**\n * A response's headers: its type, its cache rule, and `Retry-After` on a 503 only.\n *\n * @ensures exactly the model's HeadersOf\n */\nexport function sitemapHeaders(o: SitemapOutcome): SitemapHeader[] {\n //@ verify\n //@ ensures \\result.length === (o === \"unavailable\" ? 3 : 2)\n const type: SitemapHeader = {\n name: \"Content-Type\",\n value: o === \"ok\" ? \"application/xml; charset=utf-8\" : \"text/plain; charset=utf-8\",\n };\n const cache: SitemapHeader = { name: \"Cache-Control\", value: sitemapCacheControl(o) };\n const retry: SitemapHeader = { name: \"Retry-After\", value: sitemapRetryAfter(o) };\n return o === \"unavailable\" ? [type, cache, retry] : [type, cache];\n}\n\n// ---------------------------------------------------------------- URLs\n\n/**\n * The items' folder as a path, with one leading and one trailing \"/\" (\"items\" → \"/items/\").\n *\n * @ensures exactly the model's SitemapBase\n */\nexport function sitemapBase(base: string): string {\n //@ verify\n //@ ensures \\result.length >= 1 && \\result.charCodeAt(0) === 47 && \\result.charCodeAt(\\result.length - 1) === 47\n const lead = base.length > 0 && base.charCodeAt(0) === 47 ? base : \"/\" + base;\n return lead.charCodeAt(lead.length - 1) === 47 ? lead : lead + \"/\";\n}\n\n/**\n * The folder every item sitemap, and every item it lists, sits in: the site's origin with no\n * trailing \"/\", then the base.\n *\n * @ensures result = rStripCode(siteUrl, \"/\") + sitemapBase(base) — exactly the model's ItemsPrefix\n */\nexport function itemsPrefix(siteUrl: string, base: string): string {\n //@ verify\n //@ ensures \\result === rStripCode(siteUrl, 47) + sitemapBase(base)\n return rStripCode(siteUrl, 47) + sitemapBase(base);\n}\n\n/**\n * Item sitemap n's URL: `{siteUrl}{base}sitemap-{n}.xml`.\n *\n * @ensures exactly the model's ItemSitemapUrl\n */\nexport function itemSitemapUrl(siteUrl: string, base: string, n: number): string {\n //@ verify\n //@ type n nat\n //@ requires n >= 0\n //@ ensures \\result === itemsPrefix(siteUrl, base) + \"sitemap-\" + decimal(n) + \".xml\"\n return itemsPrefix(siteUrl, base) + \"sitemap-\" + decimal(n) + \".xml\";\n}\n\n/**\n * Whether a link is under the items' folder (the location rule); an empty link never is.\n *\n * @ensures exactly the model's InScope\n */\nexport function inScope(prefix: string, loc: string): boolean {\n //@ verify\n //@ ensures \\result <==> (prefix.length <= loc.length && loc.slice(0, prefix.length) === prefix)\n return startsWithAt(loc, prefix, 0);\n}\n\n// ---------------------------------------------------------------- the two files\n\n/**\n * The index's `<sitemap>` blocks for pages lo+1 … hi, built by halves (depth log n).\n *\n * @ensures nothing for an empty range — exactly the model's blocks of ItemSitemapUrlsFrom in the link\n */\nfunction indexBlocksRange(siteUrl: string, base: string, lo: number, hi: number): string {\n //@ verify\n //@ type lo nat\n //@ type hi nat\n //@ requires 0 <= lo && lo <= hi\n //@ decreases hi - lo\n //@ ensures lo === hi ==> \\result === \"\"\n if (hi - lo === 0) return \"\";\n if (hi - lo === 1) return sitemapBlock(itemSitemapUrl(siteUrl, base, lo + 1));\n const mid = lo + Math.floor((hi - lo) / 2);\n return indexBlocksRange(siteUrl, base, lo, mid) + indexBlocksRange(siteUrl, base, mid, hi);\n}\n\n/**\n * The item index: a `<sitemapindex>` of `{base}sitemap-1.xml` … `{base}sitemap-{count}.xml`.\n *\n * @ensures exactly the model's ItemIndex\n */\nexport function buildSitemapIndexXml(siteUrl: string, base: string, count: number): string {\n //@ verify\n //@ type count nat\n //@ requires count >= 0\n //@ ensures \\result === sitemapIndexHead() + indexBlocksRange(siteUrl, base, 0, count) + sitemapIndexTail()\n return sitemapIndexHead() + indexBlocksRange(siteUrl, base, 0, count) + sitemapIndexTail();\n}\n\n/**\n * The `<url>` blocks for rows[lo..hi) under `prefix`, others left out, built by halves.\n *\n * @ensures nothing for an empty range — exactly the model's blocks of ScopedEntries in the link\n */\nfunction urlBlocksRange(rows: SitemapRow[], prefix: string, lo: number, hi: number): string {\n //@ verify\n //@ type lo nat\n //@ type hi nat\n //@ requires 0 <= lo && lo <= hi && hi <= rows.length\n //@ decreases hi - lo\n //@ ensures lo === hi ==> \\result === \"\"\n if (hi - lo === 0) return \"\";\n if (hi - lo === 1) {\n const row = rows[lo] as SitemapRow;\n return inScope(prefix, row.loc) ? urlBlock(row.loc, row.lastmod) : \"\";\n }\n const mid = lo + Math.floor((hi - lo) / 2);\n return urlBlocksRange(rows, prefix, lo, mid) + urlBlocksRange(rows, prefix, mid, hi);\n}\n\n/**\n * An item page: a `<urlset>` of the rows under the items' folder, in order.\n *\n * @ensures exactly the model's ItemUrlset\n */\nexport function buildUrlsetXml(rows: SitemapRow[], siteUrl: string, base: string): string {\n //@ verify\n //@ ensures \\result === urlsetHead() + urlBlocksRange(rows, itemsPrefix(siteUrl, base), 0, rows.length) + urlsetTail()\n return (\n urlsetHead() + urlBlocksRange(rows, itemsPrefix(siteUrl, base), 0, rows.length) + urlsetTail()\n );\n}\n\n// ---------------------------------------------------------------- Next.js and robots.txt\n\n/**\n * The Next.js rewrite `source` for the page files, `{base}sitemap-:page.xml`, with every\n * character Next reads as pattern syntax (`( ) { } [ ] | \\ ^ . : * + - ? $`) escaped by a \"\\\".\n *\n * @ensures exactly the model's RewriteSource\n */\nexport function rewriteSource(base: string): string {\n //@ verify\n //@ ensures \\result === substitutedText(sitemapBase(base), [40, 41, 123, 125, 91, 93, 124, 92, 94, 46, 58, 42, 43, 45, 63, 36], [\"\\\\(\", \"\\\\)\", \"\\\\{\", \"\\\\}\", \"\\\\[\", \"\\\\]\", \"\\\\|\", \"\\\\\\\\\", \"\\\\^\", \"\\\\.\", \"\\\\:\", \"\\\\*\", \"\\\\+\", \"\\\\-\", \"\\\\?\", \"\\\\$\"]) + \"sitemap\\\\-:page\\\\.xml\"\n return (\n substitutedText(\n sitemapBase(base),\n [40, 41, 123, 125, 91, 93, 124, 92, 94, 46, 58, 42, 43, 45, 63, 36],\n [\n \"\\\\(\",\n \"\\\\)\",\n \"\\\\{\",\n \"\\\\}\",\n \"\\\\[\",\n \"\\\\]\",\n \"\\\\|\",\n \"\\\\\\\\\",\n \"\\\\^\",\n \"\\\\.\",\n \"\\\\:\",\n \"\\\\*\",\n \"\\\\+\",\n \"\\\\-\",\n \"\\\\?\",\n \"\\\\$\",\n ],\n ) + \"sitemap\\\\-:page\\\\.xml\"\n );\n}\n\n/**\n * The rewrite's destination, the page handler's route `{base}sitemap.xml/:page`\n * (`app/<base>/sitemap.xml/[page]/route.ts`).\n *\n * @ensures exactly the model's RewriteDestination\n */\nexport function rewriteDestination(base: string): string {\n //@ verify\n //@ ensures \\result === sitemapBase(base) + \"sitemap.xml/:page\"\n return sitemapBase(base) + \"sitemap.xml/:page\";\n}\n\n/**\n * Whether a path is one of the item sitemaps (the index or a page file), which a site's proxy\n * MUST pass through before any item-URL redirect (the proxy runs before rewrites).\n *\n * @ensures exactly the model's IsSitemapPath\n */\nexport function isSitemapPath(pathname: string, base: string): boolean {\n //@ verify\n //@ ensures \\result === (startsWithAt(pathname, sitemapBase(base) + \"sitemap\", 0) && endsWith(pathname, \".xml\"))\n return startsWithAt(pathname, sitemapBase(base) + \"sitemap\", 0) && endsWith(pathname, \".xml\");\n}\n\n/**\n * robots.txt's sitemaps: the site's own root `/sitemap.xml` and the item index. Two lines, since\n * the specs name no index inside an index.\n *\n * @ensures exactly the model's RobotsSitemaps\n */\nexport function robotsSitemaps(siteUrl: string, base: string): string[] {\n //@ verify\n //@ ensures \\result.length === 2\n //@ ensures \\result[0] === rStripCode(siteUrl, 47) + \"/sitemap.xml\"\n //@ ensures \\result[1] === itemsPrefix(siteUrl, base) + \"sitemap.xml\"\n return [rStripCode(siteUrl, 47) + \"/sitemap.xml\", itemsPrefix(siteUrl, base) + \"sitemap.xml\"];\n}\n","/**\n * Item sitemaps for a Next.js site, built at request time from the Augur SDK's\n * `googMc.sitemaps.items.list` (atlas#101), so the number of files follows the catalog without a\n * deploy, whatever its size.\n *\n * Layout: the item index at `{base}sitemap.xml` and page n (5,000 items) at\n * `{base}sitemap-{n}.xml`, in the items' own folder (`base`, default \"/items/\"), so by the\n * sitemap protocol's location rule they may list the item pages there. The site's root\n * `/sitemap.xml` stays its own; robots.txt names both (`robotsSitemaps`).\n *\n * Every decision is a proved rule in `sitemap-rules.ts`; this file only awaits the SDK and maps\n * the rules' answers to a Response.\n */\n\nimport type { AugurAPI } from \"@simpleapps-com/augur-api\";\nimport {\n buildSitemapIndexXml,\n buildUrlsetXml,\n fetchesPage,\n itemSitemapCount,\n itemSitemapOutcome,\n parseItemSitemapPage,\n rewriteDestination,\n rewriteSource,\n sitemapBody,\n sitemapHeaders,\n sitemapIndexOutcome,\n sitemapStatus,\n usableTotal,\n type SitemapOutcome,\n type SitemapRow,\n} from \"./sitemap-rules\";\n\nexport {\n buildSitemapIndexXml,\n buildUrlsetXml,\n inScope,\n isSitemapPath,\n itemSitemapCount,\n itemSitemapUrl,\n parseItemSitemapPage,\n robotsSitemaps,\n sitemapBase,\n type SitemapOutcome,\n type SitemapRow,\n} from \"./sitemap-rules\";\n\n/** The items' folder when a site names none. */\nexport const DEFAULT_SITEMAP_BASE = \"/items/\";\n\n/**\n * How long one Augur call may take, in milliseconds: crawlers wait longer than page visitors, and\n * a call past it is a 503 the crawler retries.\n */\nexport const DEFAULT_SITEMAP_DEADLINE = 10_000;\n\n/** What the handlers need of a server site: its SDK client (`createServerSite`'s result fits). */\nexport interface SitemapSite {\n client: Pick<AugurAPI, \"withRequest\" | \"googMc\">;\n}\n\n/** Where the site lives and where its item sitemaps sit. */\nexport interface SitemapOptions {\n /** The site's origin, e.g. \"https://www.example.com\" (a trailing \"/\" is dropped). */\n siteUrl: string;\n /** The items' folder, matching the item links Augur returns; default \"/items/\". */\n base?: string;\n /** Milliseconds one Augur call may take; default 10,000. */\n deadline?: number;\n}\n\n/** A Next.js rewrite, as `next.config` `rewrites()` takes it. */\nexport interface SitemapRewrite {\n source: string;\n destination: string;\n}\n\n/** The Augur edge cache the reads ask for, in hours: a day's sitemap stays close to the catalog. */\nconst EDGE_CACHE_HOURS = 1;\n\nfunction respond(outcome: SitemapOutcome, xml: string): Response {\n const headers = new Headers(\n sitemapHeaders(outcome).map((h): [string, string] => [h.name, h.value]),\n );\n return new Response(sitemapBody(outcome, xml), { status: sitemapStatus(outcome), headers });\n}\n\n/** The catalog's total from a one-row read, or undefined when Augur failed. */\nasync function readTotal(site: SitemapSite, deadline: number): Promise<number | undefined> {\n try {\n const response = await site.client\n .withRequest({ deadline })\n .googMc.sitemaps.items.list({ limit: 1, edgeCache: EDGE_CACHE_HOURS });\n return usableTotal(Number.isInteger(response.total), response.total);\n } catch {\n return undefined;\n }\n}\n\n/** One page's rows, as the rules take them, or undefined when Augur failed. */\nasync function readPage(\n site: SitemapSite,\n page: number,\n deadline: number,\n): Promise<SitemapRow[] | undefined> {\n try {\n const response = await site.client\n .withRequest({ deadline })\n .googMc.sitemaps.items.list({ page, edgeCache: EDGE_CACHE_HOURS });\n return (response.data ?? []).map((row) => ({\n loc: row.link ?? \"\",\n lastmod: row.lastModified ?? \"\",\n }));\n } catch {\n return undefined;\n }\n}\n\n/**\n * The item index's Route Handler, for `app/items/sitemap.xml/route.ts` (or the folder `base`\n * names): a `<sitemapindex>` of every item page file, or a 503 when Augur can't be read.\n *\n * @example\n * ```ts\n * export const dynamic = \"force-dynamic\";\n * export const GET = createSitemapIndexHandler(site, { siteUrl: \"https://www.example.com\" });\n * ```\n */\nexport function createSitemapIndexHandler(site: SitemapSite, options: SitemapOptions) {\n const { siteUrl, base = DEFAULT_SITEMAP_BASE, deadline = DEFAULT_SITEMAP_DEADLINE } = options;\n return async (): Promise<Response> => {\n const total = await readTotal(site, deadline);\n const count = itemSitemapCount(total ?? 0);\n return respond(\n sitemapIndexOutcome(total !== undefined),\n buildSitemapIndexXml(siteUrl, base, count),\n );\n };\n}\n\n/**\n * An item page's Route Handler, for `app/items/sitemap.xml/[page]/route.ts`, which\n * `sitemapRewrite` maps `{base}sitemap-{n}.xml` onto: a `<urlset>` of page n's items under\n * `base`, a 404 for no such page, or a 503 when Augur can't be read.\n *\n * @example\n * ```ts\n * export const dynamic = \"force-dynamic\";\n * export const GET = createItemSitemapHandler(site, { siteUrl: \"https://www.example.com\" });\n * ```\n */\nexport function createItemSitemapHandler(site: SitemapSite, options: SitemapOptions) {\n const { siteUrl, base = DEFAULT_SITEMAP_BASE, deadline = DEFAULT_SITEMAP_DEADLINE } = options;\n return async (\n _request: Request,\n context: { params: Promise<{ page: string }> },\n ): Promise<Response> => {\n const page = parseItemSitemapPage((await context.params).page);\n const rows = fetchesPage(page) ? await readPage(site, page, deadline) : [];\n const outcome = itemSitemapOutcome(page, rows !== undefined, rows?.length ?? 0);\n return respond(outcome, buildUrlsetXml(rows ?? [], siteUrl, base));\n };\n}\n\n/**\n * The Next.js rewrite from `{base}sitemap-{n}.xml` to the item page handler's route; spread it\n * into `next.config`'s `rewrites()`.\n *\n * @example\n * ```ts\n * async rewrites() {\n * return [sitemapRewrite()];\n * }\n * ```\n */\nexport function sitemapRewrite(base: string = DEFAULT_SITEMAP_BASE): SitemapRewrite {\n return { source: rewriteSource(base), destination: rewriteDestination(base) };\n}\n"],"mappings":";;;;;;;;;;;;;AAmBO,SAAS,UAAU,OAAiB,GAAW,GAAmB;AAOvE,MAAI,MAAM,MAAM,OAAQ,QAAO;AAC/B,SAAQ,MAAM,CAAC,MAAiB,IAAI,IAAI,UAAU,OAAO,GAAG,IAAI,CAAC;AACnE;AA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C;AAAA,EACnE;AACF;AAaO,SAAS,eAAe,OAAe,sBAAsC;AAClF,SAAO,EAAE,QAAQ,cAAc,IAAI,GAAG,aAAa,mBAAmB,IAAI,EAAE;AAC9E;","names":[]}
|
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
clearSiteActions
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-SFXO74RC.js";
|
|
4
|
+
import "./chunk-JIYVQWXK.js";
|
|
5
|
+
import "./chunk-Z53NEFEQ.js";
|
|
6
|
+
import "./chunk-V76GZZF3.js";
|
|
5
7
|
|
|
6
8
|
// src/testing.ts
|
|
7
9
|
import { createMockClient } from "@simpleapps-com/augur-core/testing";
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["export { createMockClient } from \"@simpleapps-com/augur-core/testing\";\nexport { clearSiteActions } from \"./server-site-registry\";\nexport type { DeepMockClient, MockClientResult } from \"@simpleapps-com/augur-core/testing\";\n\nimport type { SiteActions } from \"./actions/site\";\n\n/**\n * A mock function type compatible with both Vitest and Jest.\n * Supports `.mockResolvedValue()`, `.mockRejectedValue()`, and call tracking.\n */\nexport interface MockFn {\n (...args: unknown[]): unknown;\n mockResolvedValue: (value: unknown) => MockFn;\n mockRejectedValue: (value: unknown) => MockFn;\n mockReturnValue: (value: unknown) => MockFn;\n mockImplementation: (fn: (...args: unknown[]) => unknown) => MockFn;\n mock: { calls: unknown[][] };\n}\n\n/** Mirror of SiteActions where every method is a MockFn. */\nexport type MockSiteActions = {\n [K in keyof SiteActions]: {\n [M in keyof SiteActions[K]]: MockFn;\n };\n};\n\n/** Return type of createMockSiteActions. */\nexport interface MockSiteActionsResult {\n /** Typed as SiteActions — pass this to your components/server actions. */\n actions: SiteActions;\n /** Same object typed with MockFn — use for assertions and mock setup. */\n mocks: MockSiteActions;\n}\n\n/** Shape definition: service name → method names. */\nconst SERVICE_METHODS: Record<string, string[]> = {\n pricing: [\"getItemPrice\", \"batchGetItemPrices\", \"getTaxEstimate\"],\n items: [\n \"itemCategoryLookup\",\n \"getItemCategory\",\n \"getCategoryItems\",\n \"getCategoryItemsInfinite\",\n \"getItemAttributes\",\n \"getInvMast\",\n \"getInvMastDoc\",\n \"getStock\",\n \"getStockCompanySummary\",\n \"getItemFaqs\",\n \"getItemSubstitutes\",\n \"getItemAccessories\",\n \"getSimilarItems\",\n \"batchGetInvMastDocs\",\n \"batchGetStockData\",\n ],\n commerce: [\n \"cartHdrLookup\",\n \"getCartLines\",\n \"addToCart\",\n \"updateCartLines\",\n \"deleteCartItems\",\n \"getCartAlsoBought\",\n \"checkoutOrder\",\n ],\n search: [\"getSearchAttributes\", \"getSearchSuggestions\", \"itemSearch\", \"itemSearchInfinite\"],\n orders: [\"getOrderDoc\"],\n shipping: [\"getShippingRates\"],\n joomla: [\n \"getJoomlaContent\",\n \"getJoomlaContentList\",\n \"getJoomlaMenu\",\n \"getJoomlaMenuDoc\",\n \"getUserProfile\",\n \"verifyPassword\",\n ],\n legacy: [\"getItemWebDesc\", \"getAlsoBoughtItems\", \"getItemTags\", \"getStates\"],\n customers: [\n \"customerLookup\",\n \"getCustomerDoc\",\n \"getCustomerOrders\",\n \"getCustomerOrderDetail\",\n \"getCustomerInvoices\",\n \"getCustomerInvoiceDetail\",\n \"getCustomerQuotes\",\n \"getCustomerQuoteDetail\",\n \"getShipToAddresses\",\n ],\n smartyStreets: [\"validateAddress\"],\n p21Pim: [\"getInvMastExt\", \"listInvMastExt\"],\n agrSite: [\"getSettings\", \"getRobots\"],\n avalara: [\"calculateTax\"],\n payments: [\n \"transactionSetup\",\n \"accountQuery\",\n \"getSurcharge\",\n \"cardInfo\",\n \"billingUpdate\",\n \"validatePayment\",\n ],\n logistics: [\"getFreightRates\", \"getShipVia\"],\n vmi: [\n \"getWarehouses\",\n \"getWarehouseAvailability\",\n \"getDistributors\",\n \"getProducts\",\n \"getInventoryProfiles\",\n \"getRestockHeaders\",\n \"getSections\",\n ],\n p21Core: [\n \"getAddresses\",\n \"getCompanies\",\n \"getCompany\",\n \"getLocations\",\n \"getPaymentTypes\",\n \"getCashDrawers\",\n \"getCodeP21\",\n ],\n p21Apis: [\"refreshContacts\", \"refreshCustomers\"],\n p21Sism: [\"getRecentImports\", \"getImport\", \"getScheduledImports\"],\n agrWork: [\"healthCheck\", \"ping\"],\n agrInfo: [\"getContext\", \"getRubrics\", \"getMicroservices\", \"generateAkasha\", \"generateJoomla\"],\n basecamp2: [\n \"getTodos\",\n \"getTodo\",\n \"getTodosSummary\",\n \"getComments\",\n \"getPeople\",\n \"getProjects\",\n \"getEvents\",\n \"getMetrics\",\n \"getTodolists\",\n ],\n brandFolder: [\"getCategories\", \"getCategory\", \"createFocus\"],\n gregorovich: [\"getDocuments\"],\n favorites: [\"getFavorites\", \"addFavorite\", \"removeFavorite\"],\n wishlists: [\n \"getWishlists\",\n \"createWishlist\",\n \"getWishlistDetail\",\n \"deleteWishlist\",\n \"addWishlistItems\",\n \"removeWishlistItem\",\n ],\n};\n\nfunction createStubFn(): MockFn {\n const calls: unknown[][] = [];\n\n const fn = ((...args: unknown[]) => {\n calls.push(args);\n const impl = (fn as MockFnInternal)._impl;\n return impl ? impl(...args) : undefined;\n }) as MockFn & MockFnInternal;\n\n fn._impl = undefined;\n fn.mock = { calls };\n\n fn.mockResolvedValue = (value: unknown) => {\n fn._impl = () => Promise.resolve(value);\n return fn;\n };\n\n fn.mockRejectedValue = (value: unknown) => {\n fn._impl = () => Promise.reject(value);\n return fn;\n };\n\n fn.mockReturnValue = (value: unknown) => {\n fn._impl = () => value;\n return fn;\n };\n\n fn.mockImplementation = (impl: (...args: unknown[]) => unknown) => {\n fn._impl = impl;\n return fn;\n };\n\n return fn;\n}\n\ninterface MockFnInternal {\n _impl: ((...args: unknown[]) => unknown) | undefined;\n}\n\n/**\n * Creates a fully-mocked SiteActions object for testing.\n *\n * Every method on every service is a stub function with call tracking\n * and `.mockResolvedValue()` / `.mockReturnValue()` support.\n * Works with both Vitest and Jest — no framework dependency.\n *\n * @example\n * ```ts\n * import { createMockSiteActions } from \"@simpleapps-com/augur-server/testing\";\n *\n * const { actions, mocks } = createMockSiteActions();\n *\n * // Setup return values\n * mocks.pricing.getItemPrice.mockResolvedValue({ price: 9.99 });\n *\n * // Pass actions to your component/server action\n * const price = await actions.pricing.getItemPrice(\"ITEM-1\");\n *\n * // Assert calls\n * expect(mocks.pricing.getItemPrice.mock.calls[0]).toEqual([\"ITEM-1\"]);\n * ```\n */\nexport function createMockSiteActions(): MockSiteActionsResult {\n const result: Record<string, Record<string, MockFn>> = {};\n\n for (const [service, methods] of Object.entries(SERVICE_METHODS)) {\n const serviceMock: Record<string, MockFn> = {};\n for (const method of methods) {\n serviceMock[method] = createStubFn();\n }\n result[service] = serviceMock;\n }\n\n return {\n actions: result as unknown as SiteActions,\n mocks: result as unknown as MockSiteActions,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["export { createMockClient } from \"@simpleapps-com/augur-core/testing\";\nexport { clearSiteActions } from \"./server-site-registry\";\nexport type { DeepMockClient, MockClientResult } from \"@simpleapps-com/augur-core/testing\";\n\nimport type { SiteActions } from \"./actions/site\";\n\n/**\n * A mock function type compatible with both Vitest and Jest.\n * Supports `.mockResolvedValue()`, `.mockRejectedValue()`, and call tracking.\n */\nexport interface MockFn {\n (...args: unknown[]): unknown;\n mockResolvedValue: (value: unknown) => MockFn;\n mockRejectedValue: (value: unknown) => MockFn;\n mockReturnValue: (value: unknown) => MockFn;\n mockImplementation: (fn: (...args: unknown[]) => unknown) => MockFn;\n mock: { calls: unknown[][] };\n}\n\n/** Mirror of SiteActions where every method is a MockFn. */\nexport type MockSiteActions = {\n [K in keyof SiteActions]: {\n [M in keyof SiteActions[K]]: MockFn;\n };\n};\n\n/** Return type of createMockSiteActions. */\nexport interface MockSiteActionsResult {\n /** Typed as SiteActions — pass this to your components/server actions. */\n actions: SiteActions;\n /** Same object typed with MockFn — use for assertions and mock setup. */\n mocks: MockSiteActions;\n}\n\n/** Shape definition: service name → method names. */\nconst SERVICE_METHODS: Record<string, string[]> = {\n pricing: [\"getItemPrice\", \"batchGetItemPrices\", \"getTaxEstimate\"],\n items: [\n \"itemCategoryLookup\",\n \"getItemCategory\",\n \"getCategoryItems\",\n \"getCategoryItemsInfinite\",\n \"getItemAttributes\",\n \"getInvMast\",\n \"getInvMastDoc\",\n \"getStock\",\n \"getStockCompanySummary\",\n \"getItemFaqs\",\n \"getItemSubstitutes\",\n \"getItemAccessories\",\n \"getSimilarItems\",\n \"batchGetInvMastDocs\",\n \"batchGetStockData\",\n ],\n commerce: [\n \"cartHdrLookup\",\n \"getCartLines\",\n \"addToCart\",\n \"updateCartLines\",\n \"deleteCartItems\",\n \"getCartAlsoBought\",\n \"checkoutOrder\",\n ],\n search: [\"getSearchAttributes\", \"getSearchSuggestions\", \"itemSearch\", \"itemSearchInfinite\"],\n orders: [\"getOrderDoc\"],\n shipping: [\"getShippingRates\"],\n joomla: [\n \"getJoomlaContent\",\n \"getJoomlaContentList\",\n \"getJoomlaMenu\",\n \"getJoomlaMenuDoc\",\n \"getUserProfile\",\n \"verifyPassword\",\n ],\n legacy: [\"getItemWebDesc\", \"getAlsoBoughtItems\", \"getItemTags\", \"getStates\"],\n customers: [\n \"customerLookup\",\n \"getCustomerDoc\",\n \"getCustomerOrders\",\n \"getCustomerOrderDetail\",\n \"getCustomerInvoices\",\n \"getCustomerInvoiceDetail\",\n \"getCustomerQuotes\",\n \"getCustomerQuoteDetail\",\n \"getShipToAddresses\",\n ],\n smartyStreets: [\"validateAddress\"],\n p21Pim: [\"getInvMastExt\", \"listInvMastExt\"],\n agrSite: [\"getSettings\", \"getRobots\"],\n avalara: [\"calculateTax\"],\n payments: [\n \"transactionSetup\",\n \"accountQuery\",\n \"getSurcharge\",\n \"cardInfo\",\n \"billingUpdate\",\n \"validatePayment\",\n ],\n logistics: [\"getFreightRates\", \"getShipVia\"],\n vmi: [\n \"getWarehouses\",\n \"getWarehouseAvailability\",\n \"getDistributors\",\n \"getProducts\",\n \"getInventoryProfiles\",\n \"getRestockHeaders\",\n \"getSections\",\n ],\n p21Core: [\n \"getAddresses\",\n \"getCompanies\",\n \"getCompany\",\n \"getLocations\",\n \"getPaymentTypes\",\n \"getCashDrawers\",\n \"getCodeP21\",\n ],\n p21Apis: [\"refreshContacts\", \"refreshCustomers\"],\n p21Sism: [\"getRecentImports\", \"getImport\", \"getScheduledImports\"],\n agrWork: [\"healthCheck\", \"ping\"],\n agrInfo: [\"getContext\", \"getRubrics\", \"getMicroservices\", \"generateAkasha\", \"generateJoomla\"],\n basecamp2: [\n \"getTodos\",\n \"getTodo\",\n \"getTodosSummary\",\n \"getComments\",\n \"getPeople\",\n \"getProjects\",\n \"getEvents\",\n \"getMetrics\",\n \"getTodolists\",\n ],\n brandFolder: [\"getCategories\", \"getCategory\", \"createFocus\"],\n gregorovich: [\"getDocuments\"],\n favorites: [\"getFavorites\", \"addFavorite\", \"removeFavorite\"],\n wishlists: [\n \"getWishlists\",\n \"createWishlist\",\n \"getWishlistDetail\",\n \"deleteWishlist\",\n \"addWishlistItems\",\n \"removeWishlistItem\",\n ],\n};\n\nfunction createStubFn(): MockFn {\n const calls: unknown[][] = [];\n\n const fn = ((...args: unknown[]) => {\n calls.push(args);\n const impl = (fn as MockFnInternal)._impl;\n return impl ? impl(...args) : undefined;\n }) as MockFn & MockFnInternal;\n\n fn._impl = undefined;\n fn.mock = { calls };\n\n fn.mockResolvedValue = (value: unknown) => {\n fn._impl = () => Promise.resolve(value);\n return fn;\n };\n\n fn.mockRejectedValue = (value: unknown) => {\n fn._impl = () => Promise.reject(value);\n return fn;\n };\n\n fn.mockReturnValue = (value: unknown) => {\n fn._impl = () => value;\n return fn;\n };\n\n fn.mockImplementation = (impl: (...args: unknown[]) => unknown) => {\n fn._impl = impl;\n return fn;\n };\n\n return fn;\n}\n\ninterface MockFnInternal {\n _impl: ((...args: unknown[]) => unknown) | undefined;\n}\n\n/**\n * Creates a fully-mocked SiteActions object for testing.\n *\n * Every method on every service is a stub function with call tracking\n * and `.mockResolvedValue()` / `.mockReturnValue()` support.\n * Works with both Vitest and Jest — no framework dependency.\n *\n * @example\n * ```ts\n * import { createMockSiteActions } from \"@simpleapps-com/augur-server/testing\";\n *\n * const { actions, mocks } = createMockSiteActions();\n *\n * // Setup return values\n * mocks.pricing.getItemPrice.mockResolvedValue({ price: 9.99 });\n *\n * // Pass actions to your component/server action\n * const price = await actions.pricing.getItemPrice(\"ITEM-1\");\n *\n * // Assert calls\n * expect(mocks.pricing.getItemPrice.mock.calls[0]).toEqual([\"ITEM-1\"]);\n * ```\n */\nexport function createMockSiteActions(): MockSiteActionsResult {\n const result: Record<string, Record<string, MockFn>> = {};\n\n for (const [service, methods] of Object.entries(SERVICE_METHODS)) {\n const serviceMock: Record<string, MockFn> = {};\n for (const method of methods) {\n serviceMock[method] = createStubFn();\n }\n result[service] = serviceMock;\n }\n\n return {\n actions: result as unknown as SiteActions,\n mocks: result as unknown as MockSiteActions,\n };\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,wBAAwB;AAmCjC,IAAM,kBAA4C;AAAA,EAChD,SAAS,CAAC,gBAAgB,sBAAsB,gBAAgB;AAAA,EAChE,OAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,UAAU;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,uBAAuB,wBAAwB,cAAc,oBAAoB;AAAA,EAC1F,QAAQ,CAAC,aAAa;AAAA,E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,WAAW;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,SAAS,eAAuB;AAC9B,QAAM,QAAqB,CAAC;AAE5B,QAAM,MAAM,IAAI,SAAoB;AAClC,UAAM,KAAK,IAAI;AACf,UAAM,OAAQ,GAAsB;AACpC,WAAO,OAAO,KAAK,GAAG,IAAI,IAAI;AAAA,EAChC;AAEA,KAAG,QAAQ;AACX,KAAG,OAAO,EAAE,MAAM;AAElB,KAAG,oBAAoB,CAAC,UAAmB;AACzC,OAAG,QAAQ,MAAM,QAAQ,QAAQ,KAAK;AACtC,WAAO;AAAA,EACT;AAEA,KAAG,oBAAoB,CAAC,UAAmB;AACzC,OAAG,QAAQ,MAAM,QAAQ,OAAO,KAAK;AACrC,WAAO;AAAA,EACT;AAEA,KAAG,kBAAkB,CAAC,UAAmB;AACvC,OAAG,QAAQ,MAAM;AACjB,WAAO;AAAA,EACT;AAEA,KAAG,qBAAqB,CAAC,SAA0C;AACjE,OAAG,QAAQ;AACX,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AA6BO,SAAS,wBAA+C;AAC7D,QAAM,SAAiD,CAAC;AAExD,aAAW,CAAC,SAAS,OAAO,KAAK,OAAO,QAAQ,eAAe,GAAG;AAChE,UAAM,cAAsC,CAAC;AAC7C,eAAW,UAAU,SAAS;AAC5B,kBAAY,MAAM,IAAI,aAAa;AAAA,IACrC;AACA,WAAO,OAAO,IAAI;AAAA,EACpB;AAEA,SAAO;AAAA,IACL,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Every row a list route holds, and whether the read stopped on the page cap. */
|
|
2
|
+
export interface AllPages<T> {
|
|
3
|
+
rows: T[];
|
|
4
|
+
/** True when the last allowed call still returned rows: the list may be incomplete. */
|
|
5
|
+
capReached: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Reads every row of a list route (atlas#102): pages of `size` until an empty page, at most `cap`
|
|
9
|
+
* calls, each next offset past the rows actually read. The decisions are the proved
|
|
10
|
+
* `read-rules.ts` (`continues`, `nextOffset`, `capReached`); this only awaits and gathers, as the
|
|
11
|
+
* model's `ReadLoop` (models/AugurServerReads.dfy) states: every row when the rows fit the cap's
|
|
12
|
+
* pages, never more than `cap` calls, never silently short.
|
|
13
|
+
*
|
|
14
|
+
* @param fetchPage One call to the route at `offset` asking for `limit` rows; resolves to its rows.
|
|
15
|
+
*/
|
|
16
|
+
export declare function readAllPages<T>(fetchPage: (offset: number, limit: number) => Promise<T[]>, size?: number, cap?: number): Promise<AllPages<T>>;
|
|
17
|
+
//# sourceMappingURL=read-all-pages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-all-pages.d.ts","sourceRoot":"","sources":["../../src/utils/read-all-pages.ts"],"names":[],"mappings":"AAEA,kFAAkF;AAClF,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,uFAAuF;IACvF,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAClC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1D,IAAI,GAAE,MAAmB,EACzB,GAAG,GAAE,MAAkB,GACtB,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAatB"}
|
package/llms.txt
CHANGED
|
@@ -45,7 +45,7 @@ The docs are at https://augur.build/docs/packages (the API reference lists every
|
|
|
45
45
|
- value: unwrap
|
|
46
46
|
- value: unwrapOr
|
|
47
47
|
- function: verifyRecaptcha - Server-side Google reCAPTCHA v3 verification. Used by API routes that accept public form submissions.
|
|
48
|
-
-
|
|
48
|
+
- const: withServerCache - Caches an action's shaped value.
|
|
49
49
|
- type: ActionResult
|
|
50
50
|
- type: EdgeCacheValue
|
|
51
51
|
- type: PaginatedResult
|
|
@@ -213,10 +213,20 @@ const addToCart = useMutation(q.commerce.cartLine.add.create());
|
|
|
213
213
|
- function: getSessionCredentials - Resolve session credentials from the Auth.js JWT cookie.
|
|
214
214
|
- function: queryAction - The SDK call `callSdk` makes (everything above), answered as its envelope's data.
|
|
215
215
|
- function: queryActionRaw - The same call as `queryAction` (allowlist, client, `edgeCache` strip, Redis), answered as the SDK returned it: augur-api's `BaseResponse<T>` envelope (every SDK method's result) with `data`, `total`, `totalResults` and `count`, so client code can page a list (atlas#107). A method path carries no type, so the caller names `T` (`queryActionRaw<Article[]>(…)`). A `queryAction` and a `queryActionRaw` of one call share one Redis entry.
|
|
216
|
+
- function: queryActionRawWith - `queryActionRaw`, bounded: the same options as {@link queryActionWith}.
|
|
217
|
+
- function: queryActionWith - `queryAction`, bounded (atlas#106): `options.deadline` caps the whole call in milliseconds (every retry and the waits between them), and `options.signal` lets the caller cancel it. At the deadline the call rejects with a `TimeoutError` (the request is cancelled, nothing more is retried, nothing is cached), so a server render can fall back to a client-side fetch.
|
|
216
218
|
- function: resetSessionImports - Reset lazy-loaded imports. Used in tests only. @internal
|
|
217
219
|
- function: resolveMethod - Resolve a dot-separated method path on an object, returning the leaf function.
|
|
218
220
|
- value: unwrapBaseResponse
|
|
219
221
|
|
|
222
|
+
### Examples
|
|
223
|
+
|
|
224
|
+
queryActionWith:
|
|
225
|
+
```ts
|
|
226
|
+
const items = await queryActionWith({ deadline: 5000 }, "items.categories.items.list", uid, params)
|
|
227
|
+
.catch(() => undefined); // past 5 s: render without them, fetch on the client
|
|
228
|
+
```
|
|
229
|
+
|
|
220
230
|
## @simpleapps-com/augur-server/api
|
|
221
231
|
|
|
222
232
|
- function: createAugurApiHandler - Creates a Next.js Route Handler that routes method calls through queryAction, or through queryActionRaw when the body has `raw: true` (augur-core's `createFetchQueryActionRaw`).
|
|
@@ -232,5 +242,48 @@ const handler = createAugurApiHandler();
|
|
|
232
242
|
export const POST = handler;
|
|
233
243
|
```
|
|
234
244
|
|
|
245
|
+
## @simpleapps-com/augur-server/sitemap
|
|
246
|
+
|
|
247
|
+
- function: buildSitemapIndexXml - The item index: a `<sitemapindex>` of `{base}sitemap-1.xml` … `{base}sitemap-{count}.xml`.
|
|
248
|
+
- function: buildUrlsetXml - An item page: a `<urlset>` of the rows under the items' folder, in order.
|
|
249
|
+
- function: createItemSitemapHandler - An item page's Route Handler, for `app/items/sitemap.xml/[page]/route.ts`, which `sitemapRewrite` maps `{base}sitemap-{n}.xml` onto: a `<urlset>` of page n's items under `base`, a 404 for no such page, or a 503 when Augur can't be read.
|
|
250
|
+
- function: createSitemapIndexHandler - The item index's Route Handler, for `app/items/sitemap.xml/route.ts` (or the folder `base` names): a `<sitemapindex>` of every item page file, or a 503 when Augur can't be read.
|
|
251
|
+
- const: DEFAULT_SITEMAP_BASE - The items' folder when a site names none.
|
|
252
|
+
- const: DEFAULT_SITEMAP_DEADLINE - How long one Augur call may take, in milliseconds: crawlers wait longer than page visitors, and a call past it is a 503 the crawler retries.
|
|
253
|
+
- function: inScope - Whether a link is under the items' folder (the location rule); an empty link never is.
|
|
254
|
+
- function: isSitemapPath - Whether a path is one of the item sitemaps (the index or a page file), which a site's proxy MUST pass through before any item-URL redirect (the proxy runs before rewrites).
|
|
255
|
+
- function: itemSitemapCount - How many 5,000-item sitemaps cover `total` items (the endpoint fixes a page at 5,000).
|
|
256
|
+
- function: itemSitemapUrl - Item sitemap n's URL: `{siteUrl}{base}sitemap-{n}.xml`.
|
|
257
|
+
- function: parseItemSitemapPage - The page a request names (the rewrite's bare `:page`): its value when it is a canonical natural number, else 0, "not a page" (`0`, `01`, `1e3`, ` 1`, `-1` and text never name one).
|
|
258
|
+
- function: robotsSitemaps - robots.txt's sitemaps: the site's own root `/sitemap.xml` and the item index. Two lines, since the specs name no index inside an index.
|
|
259
|
+
- function: sitemapBase - The items' folder as a path, with one leading and one trailing "/" ("items" → "/items/").
|
|
260
|
+
- function: sitemapRewrite - The Next.js rewrite from `{base}sitemap-{n}.xml` to the item page handler's route; spread it into `next.config`'s `rewrites()`.
|
|
261
|
+
- type: SitemapOptions
|
|
262
|
+
- type: SitemapOutcome
|
|
263
|
+
- type: SitemapRewrite
|
|
264
|
+
- type: SitemapRow
|
|
265
|
+
- type: SitemapSite
|
|
266
|
+
|
|
267
|
+
### Examples
|
|
268
|
+
|
|
269
|
+
createItemSitemapHandler:
|
|
270
|
+
```ts
|
|
271
|
+
export const dynamic = "force-dynamic";
|
|
272
|
+
export const GET = createItemSitemapHandler(site, { siteUrl: "https://www.example.com" });
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
createSitemapIndexHandler:
|
|
276
|
+
```ts
|
|
277
|
+
export const dynamic = "force-dynamic";
|
|
278
|
+
export const GET = createSitemapIndexHandler(site, { siteUrl: "https://www.example.com" });
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
sitemapRewrite:
|
|
282
|
+
```ts
|
|
283
|
+
async rewrites() {
|
|
284
|
+
return [sitemapRewrite()];
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
235
288
|
## @simpleapps-com/augur-server/next-auth
|
|
236
289
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleapps-com/augur-server",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.6",
|
|
4
4
|
"description": "Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
"types": "./dist/api.d.ts",
|
|
47
47
|
"import": "./dist/api.js"
|
|
48
48
|
},
|
|
49
|
+
"./sitemap": {
|
|
50
|
+
"types": "./dist/sitemap.d.ts",
|
|
51
|
+
"import": "./dist/sitemap.js"
|
|
52
|
+
},
|
|
49
53
|
"./next-auth": {
|
|
50
54
|
"types": "./next-auth.d.ts"
|
|
51
55
|
}
|
|
@@ -58,12 +62,12 @@
|
|
|
58
62
|
"llms.txt"
|
|
59
63
|
],
|
|
60
64
|
"dependencies": {
|
|
61
|
-
"@simpleapps-com/augur-core": "^2026.11.
|
|
62
|
-
"@simpleapps-com/augur-hooks": "^2026.11.
|
|
65
|
+
"@simpleapps-com/augur-core": "^2026.11.4",
|
|
66
|
+
"@simpleapps-com/augur-hooks": "^2026.11.3",
|
|
63
67
|
"@simpleapps-com/augur-utils": "^2026.11.3"
|
|
64
68
|
},
|
|
65
69
|
"peerDependencies": {
|
|
66
|
-
"@simpleapps-com/augur-api": "^2026.
|
|
70
|
+
"@simpleapps-com/augur-api": "^2026.11.4",
|
|
67
71
|
"@tanstack/react-query": "^5.80.0",
|
|
68
72
|
"ioredis": "^5.9.0",
|
|
69
73
|
"jose": "^5.0.0 || ^6.0.0",
|
|
@@ -101,7 +105,7 @@
|
|
|
101
105
|
"@atlas/foundation": "0.0.0",
|
|
102
106
|
"@atlas/utils": "0.0.0",
|
|
103
107
|
"@atlas/vitest-config": "0.0.0",
|
|
104
|
-
"@simpleapps-com/augur-api": "2026.11.
|
|
108
|
+
"@simpleapps-com/augur-api": "2026.11.4"
|
|
105
109
|
},
|
|
106
110
|
"engines": {
|
|
107
111
|
"node": ">=22.0.0"
|