@rebilder/render-md 0.1.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/money.ts","../src/jsonld.ts","../src/internal/budget.ts","../src/markdown.ts","../src/documents/facts.ts","../src/documents/markdown.ts"],"names":[],"mappings":";;;AAMA,IAAM,YAAA,uBAAmB,GAAA,CAAI;AAAA,EAC3B,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAC,CAAA;AAGD,IAAM,aAAA,mBAAgB,IAAI,GAAA,CAAI,CAAC,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,KAAK,CAAC,CAAA;AAO/E,IAAM,OAAA,GAAkC;AAAA,EACtC,GAAA,EAAK,GAAA;AAAA,EACL,GAAA,EAAK,QAAA;AAAA,EACL,GAAA,EAAK,MAAA;AAAA,EACL,GAAA,EAAK;AACP,CAAA;AAEA,SAAS,gBAAgB,IAAA,EAAsB;AAC7C,EAAA,IAAI,YAAA,CAAa,GAAA,CAAI,IAAI,CAAA,EAAG,OAAO,CAAA;AACnC,EAAA,IAAI,aAAA,CAAc,GAAA,CAAI,IAAI,CAAA,EAAG,OAAO,CAAA;AACpC,EAAA,OAAO,CAAA;AACT;AAEA,SAAS,YAAY,CAAA,EAAyD;AAC5E,EAAA,IAAI,CAAC,MAAA,CAAO,SAAA,CAAU,CAAA,CAAE,MAAM,CAAA,EAAG;AAE/B,IAAA,MAAM,IAAI,SAAA;AAAA,MACR,CAAA,4DAA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A;AACZ,MAAA;AAAA,IACF;AACA,IAAA,MAAM,IAAA,GAAO,YAAA,CAAa,IAAA,CAAK,GAAG,CAAA,GAC9B,YAAA,CAAa,IAAA,CAAK,KAAA,EAAO,IAAA,CAAK,GAAG,CAAA,GACjC,MAAA,CAAO,KAAK,KAAK,CAAA;AACrB,IAAA,MAAM,KAAA,GAAkB,CAAC,CAAA,EAAA,EAAK,IAAI,CAAA,CAAE,CAAA;AACpC,IAAA,IAAI,KAAK,OAAA,KAAY,MAAA,IAAa,IAAA,CAAK,OAAA,CAAQ,SAAS,CAAA,EAAG;AACzD,MAAA,KAAA,CAAM,KAAK,CAAA,IAAA,EAAO,MAAA,CAAO,IAAA,CAAK,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,IAC1C;AACA,IAAA,MAAM,IAAA,GAAO,CAAA,EAAG,GAAG,CAAA,EAAG,QAAA,KAAa,CAAA,GAAI,MAAA,GAAS,IAAI,CAAA,EAAG,KAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA;AACvE,IAAA,IAAI,UAAA,CAAW,IAAI,CAAA,GAAI,MAAA,EAAQ;AAC7B,MAAA,SAAA,GAAY,IAAA;AACZ,MAAA;AAAA,IACF;AACA,IAAA,GAAA,GAAM,IAAA;AACN,IAAA,QAAA,IAAY,CAAA;AAAA,EACd;AAEA,EAAA,OAAO,SAAA,GAAY,CAAA,EAAG,GAAG,CAAA,EAAG,UAAU,CAAA,CAAA,GAAK,GAAA;AAC7C","file":"index.cjs","sourcesContent":["import type { Money } from './types'\n\n/**\n * ISO 4217 currencies with no minor unit — `Money.amount` is already whole\n * currency units for these (e.g. JPY 4900 = ¥4,900).\n */\nconst ZERO_DECIMAL = new Set([\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'ISK',\n 'JPY',\n 'KMF',\n 'KRW',\n 'MGA',\n 'PYG',\n 'RWF',\n 'UGX',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n])\n\n/** ISO 4217 currencies with three-digit minor units. */\nconst THREE_DECIMAL = new Set(['BHD', 'IQD', 'JOD', 'KWD', 'LYD', 'OMR', 'TND'])\n\n/**\n * Unambiguous symbol prefixes. Deliberately conservative: currencies whose\n * common symbol is shared across currencies (e.g. \"$\" for CAD/AUD) fall back\n * to the explicit \"CODE 49.00\" form instead of guessing.\n */\nconst SYMBOLS: Record<string, string> = {\n USD: '$',\n EUR: '€',\n GBP: '£',\n JPY: '¥',\n}\n\nfunction minorUnitDigits(code: string): number {\n if (ZERO_DECIMAL.has(code)) return 0\n if (THREE_DECIMAL.has(code)) return 3\n return 2\n}\n\nfunction splitAmount(m: Money): { sign: string; major: string; frac: string } {\n if (!Number.isInteger(m.amount)) {\n // Fail closed: silently rounding would alter a price (Hard Rule 2).\n throw new TypeError(\n `Money.amount must be an integer number of minor units, got: ${String(m.amount)}`,\n )\n }\n const digits = minorUnitDigits(m.currency.toUpperCase())\n const sign = m.amount < 0 ? '-' : ''\n const abs = Math.abs(m.amount)\n const factor = 10 ** digits\n const major = Math.floor(abs / factor).toString()\n const frac = digits === 0 ? '' : `.${(abs % factor).toString().padStart(digits, '0')}`\n return { sign, major, frac }\n}\n\n/**\n * Decimal string for machine consumption (JSON-LD `price`): \"89.00\", \"4900\"\n * (zero-decimal), \"49.123\" (three-decimal). No grouping, no symbol.\n */\nexport function toDecimalString(m: Money): string {\n const { sign, major, frac } = splitAmount(m)\n return `${sign}${major}${frac}`\n}\n\n/**\n * Human-readable, deterministic money formatting: \"$49.00\", \"€49.00\",\n * \"¥4,900\", \"-£5.50\". Unknown/ambiguous currencies render as \"CAD 49.00\".\n * Pure function — no Intl, no locale, same input → same output everywhere.\n */\nexport function formatMoney(m: Money): string {\n const { sign, major, frac } = splitAmount(m)\n const code = m.currency.toUpperCase()\n const grouped = major.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')\n const symbol = SYMBOLS[code]\n return symbol !== undefined ? `${sign}${symbol}${grouped}${frac}` : `${sign}${code} ${grouped}${frac}`\n}\n","import type { Availability, Money, ProductSource } from './types'\nimport { toDecimalString } from './money'\n\n/** Availability enum → schema.org ItemAvailability URL. */\nconst SCHEMA_AVAILABILITY: Record<Availability, string> = {\n in_stock: 'https://schema.org/InStock',\n out_of_stock: 'https://schema.org/OutOfStock',\n preorder: 'https://schema.org/PreOrder',\n backorder: 'https://schema.org/BackOrder',\n}\n\nfunction offer(\n price: Money,\n availability: Availability,\n extra: { url?: string; sku?: string; name?: string },\n): Record<string, unknown> {\n const o: Record<string, unknown> = {\n '@type': 'Offer',\n price: toDecimalString(price),\n priceCurrency: price.currency,\n availability: SCHEMA_AVAILABILITY[availability],\n }\n if (extra.url !== undefined) o.url = extra.url\n if (extra.sku !== undefined) o.sku = extra.sku\n if (extra.name !== undefined) o.name = extra.name\n return o\n}\n\n/**\n * Render a schema.org Product JSON-LD object from the product source.\n * Injection-only: every value comes from `p`; only fields present in the\n * source appear in the output. Key order is fixed for snapshot stability.\n */\nexport function renderProductJsonLd(p: ProductSource): Record<string, unknown> {\n const out: Record<string, unknown> = {\n '@context': 'https://schema.org',\n '@type': 'Product',\n name: p.title,\n url: p.url,\n }\n if (p.brand !== undefined) out.brand = { '@type': 'Brand', name: p.brand }\n if (p.description !== undefined && p.description.length > 0) out.description = p.description\n if (p.images !== undefined && p.images.length > 0) out.image = p.images.map((img) => img.url)\n out.offers =\n p.variants !== undefined && p.variants.length > 0\n ? p.variants.map((v) => offer(v.price, v.availability, { sku: v.sku, name: v.title }))\n : offer(p.price, p.availability, { url: p.url })\n return out\n}\n","/**\n * Byte-budget, heading, and markdown-escaping primitives shared by every\n * renderer in this package.\n *\n * These helpers were extracted from `src/markdown.ts` verbatim when the\n * universal document renderers were added. The extraction is not cosmetic:\n * the commerce renderers and the document renderers must truncate by exactly\n * the same rule, and two copies of a truncation loop is two truncation\n * behaviours that will drift the first time one of them is \"improved\". The\n * code below is byte-for-byte the code that shipped inside `src/markdown.ts`;\n * `tests/commerce-frozen.test.ts` pins the commerce renderers' output with\n * inline string literals and is the proof that the move changed nothing.\n *\n * Package-internal. Nothing here is re-exported from `src/index.ts` — these\n * are implementation primitives, not part of the public contract.\n */\n\n/** Default output size budget in UTF-8 bytes, shared by every renderer. */\nexport const DEFAULT_MAX_BYTES = 5120\n\n/**\n * Fixed meta note appended when output is truncated to fit the size budget.\n * Pure rendering metadata — contains no prices, claims, or policy text.\n */\nexport const TRUNCATION_NOTE = '*Truncated to fit size budget; remaining content omitted.*'\n\nconst encoder = new TextEncoder()\n\nexport function byteLength(s: string): number {\n return encoder.encode(s).length\n}\n\nexport function clampHeadingLevel(level: number): number {\n return Math.min(Math.max(Math.trunc(level), 1), 6)\n}\n\nexport function heading(level: number, text: string): string {\n return `${'#'.repeat(clampHeadingLevel(level))} ${text}`\n}\n\n/**\n * Keep verbatim source text on a single markdown line (inline contexts only:\n * fact lines, table cells). Collapses newlines to spaces; block contexts\n * (description, policy bodies) stay byte-for-byte verbatim.\n */\nexport function inline(text: string): string {\n return text.replace(/\\s*\\r?\\n\\s*/g, ' ')\n}\n\n/** Escape characters that would break a markdown table cell. Otherwise verbatim. */\nexport function cell(text: string): string {\n return inline(text).replace(/\\|/g, '\\\\|')\n}\n\n/** A bottom-of-page section that may be truncated (whole lines only). */\nexport interface TailSection {\n headingLine: string\n items: string[]\n}\n\nfunction tailText(t: TailSection): string {\n return `${t.headingLine}\\n\\n${t.items.join('\\n')}`\n}\n\n/**\n * Join required blocks + tail sections, enforcing the byte budget.\n *\n * Truncation is strictly from the bottom: required blocks (the front-loaded\n * buying facts and the variants table) are never dropped, tail sections are\n * re-added top-down until the budget (minus the truncation note) is exhausted,\n * and a cut always ends the document — nothing renders after it. Items are\n * whole lines; nothing is ever cut mid-fact.\n *\n * If the required blocks alone exceed the budget, they are emitted anyway\n * (facts are never sacrificed to the byte budget) followed by the note.\n */\nexport function assembleWithBudget(\n requiredBlocks: string[],\n tail: TailSection[],\n maxBytes: number,\n): string {\n const full = [...requiredBlocks, ...tail.map(tailText)].join('\\n\\n')\n if (byteLength(full) <= maxBytes) return full\n\n const noteSuffix = `\\n\\n${TRUNCATION_NOTE}`\n const budget = maxBytes - byteLength(noteSuffix)\n let out = requiredBlocks.join('\\n\\n')\n for (const section of tail) {\n const whole = `${out}\\n\\n${tailText(section)}`\n if (byteLength(whole) <= budget) {\n out = whole\n continue\n }\n // Section does not fit whole: add as many complete lines as fit.\n let partial = `${out}\\n\\n${section.headingLine}`\n let added = 0\n for (const item of section.items) {\n const next = `${partial}${added === 0 ? '\\n\\n' : '\\n'}${item}`\n if (byteLength(next) > budget) break\n partial = next\n added += 1\n }\n if (added > 0) out = partial\n break // truncate strictly from the bottom — nothing may appear after the cut\n }\n return `${out}${noteSuffix}`\n}\n","import type {\n Availability,\n CatalogItemSource,\n PolicySource,\n ProductSource,\n ProductVariantSource,\n RenderOptions,\n} from './types'\nimport { formatMoney } from './money'\nimport type { TailSection } from './internal/budget'\nimport {\n assembleWithBudget,\n byteLength,\n cell,\n clampHeadingLevel,\n DEFAULT_MAX_BYTES,\n heading,\n inline,\n TRUNCATION_NOTE,\n} from './internal/budget'\n\n/** Deterministic human labels for the availability enum (format mapping, not content). */\nconst AVAILABILITY_LABELS: Record<Availability, string> = {\n in_stock: 'In stock',\n out_of_stock: 'Out of stock',\n preorder: 'Preorder',\n backorder: 'Backorder',\n}\n\nfunction etaText(eta: [number, number]): string {\n const [min, max] = eta\n return min === max ? `${min} days` : `${min}-${max} days`\n}\n\nfunction variantsTable(variants: ProductVariantSource[], level: number): string {\n const lines = [\n heading(level, 'Variants'),\n '',\n '| ID | Title | Options | Price | Availability |',\n '| --- | --- | --- | --- | --- |',\n ]\n for (const v of variants) {\n const options =\n v.options !== undefined\n ? Object.entries(v.options)\n .map(([key, value]) => `${cell(key)}: ${cell(value)}`)\n .join('; ')\n : ''\n lines.push(\n `| ${cell(v.id)} | ${cell(v.title)} | ${options} | ${formatMoney(v.price)} | ${AVAILABILITY_LABELS[v.availability]} |`,\n )\n }\n return lines.join('\\n')\n}\n\n/**\n * Render a product detail page as clean markdown. Buying facts come first:\n * title, price, availability, shipping, and returns all land in the opening\n * lines so an agent reading top-down never misses them. Every substantive\n * value is injected from `p` — nothing is invented or reworded.\n */\nexport function renderProductMarkdown(p: ProductSource, opts?: RenderOptions): string {\n const maxBytes = opts?.maxBytes ?? DEFAULT_MAX_BYTES\n const level = clampHeadingLevel(opts?.headingLevel ?? 1)\n const sub = clampHeadingLevel(level + 1)\n\n const facts: string[] = [heading(level, `[${inline(p.title)}](${p.url})`), '']\n if (p.brand !== undefined) facts.push(`- **Brand:** ${inline(p.brand)}`)\n const price = formatMoney(p.price)\n facts.push(\n p.compareAtPrice !== undefined\n ? `- **Price:** ~~${formatMoney(p.compareAtPrice)}~~ ${price}`\n : `- **Price:** ${price}`,\n )\n facts.push(`- **Availability:** ${AVAILABILITY_LABELS[p.availability]}`)\n if (p.shipping !== undefined) {\n facts.push(`- **Shipping:** ${inline(p.shipping.summary)}`)\n if (p.shipping.freeThreshold !== undefined) {\n facts.push(` - Free shipping threshold: ${formatMoney(p.shipping.freeThreshold)}`)\n }\n if (p.shipping.regions !== undefined && p.shipping.regions.length > 0) {\n facts.push(` - Ships to: ${p.shipping.regions.map(inline).join(', ')}`)\n }\n if (p.shipping.etaDays !== undefined) {\n facts.push(` - Delivery estimate: ${etaText(p.shipping.etaDays)}`)\n }\n }\n if (p.returns !== undefined) {\n facts.push(`- **Returns:** ${inline(p.returns.summary)}`)\n if (p.returns.windowDays !== undefined) {\n facts.push(` - Return window: ${p.returns.windowDays} days`)\n }\n if (p.returns.url !== undefined) {\n facts.push(` - Policy: ${p.returns.url}`)\n }\n }\n\n const requiredBlocks: string[] = [facts.join('\\n')]\n if (p.variants !== undefined && p.variants.length > 0) {\n requiredBlocks.push(variantsTable(p.variants, sub))\n }\n\n const tail: TailSection[] = []\n if (p.description !== undefined && p.description.length > 0) {\n tail.push({ headingLine: heading(sub, 'Description'), items: p.description.split('\\n') })\n }\n if (p.attributes !== undefined) {\n const items = Object.entries(p.attributes).map(\n ([key, value]) => `- **${inline(key)}:** ${inline(value)}`,\n )\n if (items.length > 0) tail.push({ headingLine: heading(sub, 'Details'), items })\n }\n if (p.images !== undefined && p.images.length > 0) {\n const items = p.images.map((img) => {\n const label = img.alt !== undefined && img.alt.length > 0 ? inline(img.alt) : img.url\n return `- [${label}](${img.url})`\n })\n tail.push({ headingLine: heading(sub, 'Images'), items })\n }\n\n return assembleWithBudget(requiredBlocks, tail, maxBytes)\n}\n\n/**\n * Render store policies as markdown. Each policy is a linked heading followed\n * by its body byte-for-byte verbatim. Under the byte budget, whole policies\n * are kept in order; a policy whose body does not fit degrades to its linked\n * title (policy text is never partially rendered), and the document ends with\n * the truncation note.\n */\nexport function renderPolicyMarkdown(policies: PolicySource[], opts?: RenderOptions): string {\n const maxBytes = opts?.maxBytes ?? DEFAULT_MAX_BYTES\n const level = clampHeadingLevel(opts?.headingLevel ?? 1)\n\n const titleLineFor = (pol: PolicySource): string =>\n heading(level, `[${inline(pol.title)}](${pol.url})`)\n const blocks = policies.map((pol) => `${titleLineFor(pol)}\\n\\n${pol.body}`)\n const full = blocks.join('\\n\\n')\n if (byteLength(full) <= maxBytes) return full\n\n const noteSuffix = `\\n\\n${TRUNCATION_NOTE}`\n const budget = maxBytes - byteLength(noteSuffix)\n let out = ''\n for (const pol of policies) {\n const titleLine = titleLineFor(pol)\n const block = `${titleLine}\\n\\n${pol.body}`\n const withBlock = out === '' ? block : `${out}\\n\\n${block}`\n if (byteLength(withBlock) <= budget) {\n out = withBlock\n continue\n }\n const withTitle = out === '' ? titleLine : `${out}\\n\\n${titleLine}`\n if (byteLength(withTitle) <= budget) out = withTitle\n break // truncate strictly from the bottom\n }\n return out === '' ? TRUNCATION_NOTE : `${out}${noteSuffix}`\n}\n\n/**\n * Render a catalog listing as a markdown table (title → link, price,\n * availability). Under the byte budget, whole rows are dropped from the\n * bottom and the truncation note is appended.\n */\nexport function renderCatalogMarkdown(items: CatalogItemSource[], opts?: RenderOptions): string {\n const maxBytes = opts?.maxBytes ?? DEFAULT_MAX_BYTES\n const level = clampHeadingLevel(opts?.headingLevel ?? 1)\n\n const head = [\n heading(level, 'Catalog'),\n '',\n '| Title | Price | Availability |',\n '| --- | --- | --- |',\n ].join('\\n')\n const rows = items.map(\n (item) =>\n `| [${cell(item.title)}](${item.url}) | ${formatMoney(item.price)} | ${AVAILABILITY_LABELS[item.availability]} |`,\n )\n const full = [head, ...rows].join('\\n')\n if (byteLength(full) <= maxBytes) return full\n\n const noteSuffix = `\\n\\n${TRUNCATION_NOTE}`\n const budget = maxBytes - byteLength(noteSuffix)\n let out = head\n for (const row of rows) {\n const next = `${out}\\n${row}`\n if (byteLength(next) > budget) break\n out = next\n }\n return `${out}${noteSuffix}`\n}\n","/**\n * Fact rendering: the deterministic `FactValue` → markdown mapping, the fixed\n * label maps, the URL scheme allowlist, and the escaping rules.\n *\n * This file is where the injection-only guarantee is actually enforced for the\n * universal path. Every rule below is mechanical rather than advisory, because\n * an advisory rule in a renderer is a rule that holds until the first hurried\n * patch:\n *\n * - Every renderer-authored string in this package is a named constant here.\n * The whitelist in README.md is the list of these constants, and\n * `tests/documents-integrity.test.ts` re-states that list as literals (not\n * by importing these constants) so that adding scaffolding cannot silently\n * whitelist itself.\n * - A malformed value is DROPPED, never repaired. Repairing a fact invents a\n * value the merchant never stated (Hard Rule 2); dropping it only loses\n * information, which the agent can still get from the canonical page.\n * - URLs are checked against a scheme allowlist. The commerce path only ever\n * emitted merchant-controlled product/policy URLs; the universal path emits\n * arbitrary merchant-supplied link targets, and `[Click here](javascript:…)`\n * handed to an agent under our formatting authority is a phishing primitive.\n * - Money throws rather than rounds or guesses, matching `formatMoney`. A\n * thrown render is caught by the gateway and falls through to HTML; a\n * silently wrong price is served forever.\n */\n\nimport { formatMoney } from '../money'\nimport { cell, heading, inline } from '../internal/budget'\nimport type {\n BillingPeriod,\n DocumentAccess,\n Fact,\n FactValue,\n HoursException,\n HoursInterval,\n HoursSpec,\n Weekday,\n} from './types'\n\n/* ------------------------------------------------------------------ *\n * Fixed label maps — the only renderer-authored vocabulary.\n * ------------------------------------------------------------------ */\n\n/** Fixed suffix per billing period. Format mapping of a closed enum, not content. */\nexport const PERIOD_SUFFIX: Record<BillingPeriod, string> = {\n one_time: 'one-time',\n hour: 'per hour',\n day: 'per day',\n week: 'per week',\n month: 'per month',\n quarter: 'per quarter',\n year: 'per year',\n}\n\n/** Fixed label map for booleans. */\nexport const BOOLEAN_LABELS: Record<'true' | 'false', string> = {\n true: 'Yes',\n false: 'No',\n}\n\n/** Fixed weekday labels. English only and deliberately not localised: the\n * output is a machine-readable format transformation, and a locale would make\n * the same source render differently for different requesters (Hard Rule 3). */\nexport const WEEKDAY_LABELS: Record<Weekday, string> = {\n monday: 'Monday',\n tuesday: 'Tuesday',\n wednesday: 'Wednesday',\n thursday: 'Thursday',\n friday: 'Friday',\n saturday: 'Saturday',\n sunday: 'Sunday',\n}\n\n/** Fixed weekday order. Every one of the seven renders, always. */\nexport const WEEKDAY_ORDER: readonly Weekday[] = [\n 'monday',\n 'tuesday',\n 'wednesday',\n 'thursday',\n 'friday',\n 'saturday',\n 'sunday',\n]\n\n/** `intervals: []` — the merchant stated the day and stated it is closed. */\nexport const CLOSED_LABEL = 'Closed'\n\n/** Weekday absent from `weekly` — a different fact from `Closed`. */\nexport const NOT_STATED_LABEL = 'Not stated'\n\n/** An `hours` fact is not a valid table cell; the row links out instead. */\nexport const SEE_PAGE_LABEL = 'See page'\n\n/** Fixed labels used for structural bullets and table headers. */\nexport const UPDATED_LABEL = 'Updated'\nexport const PHONE_LABEL = 'Phone'\nexport const EMAIL_LABEL = 'Email'\nexport const ADDRESS_LABEL = 'Address'\nexport const DAY_LABEL = 'Day'\nexport const DATE_LABEL = 'Date'\nexport const HOURS_LABEL = 'Hours'\nexport const NOTE_LABEL = 'Note'\nexport const TITLE_LABEL = 'Title'\n\n/** Fixed headings. */\nexport const EXCEPTIONS_HEADING = 'Exceptions'\nexport const CONTACT_HEADING = 'Contact'\nexport const ACTIONS_HEADING = 'Actions'\nexport const RELATED_HEADING = 'Related'\nexport const CONTENTS_HEADING = 'Contents'\n\n/** Fixed access-level words used inside the single access notice sentence. */\nexport const ACCESS_LABELS: Record<DocumentAccess, string> = {\n free: 'free',\n registered: 'registration required',\n metered: 'metered',\n subscriber: 'subscription required',\n}\n\n/**\n * The fixed access notice. Emitted in place of `sections` whenever access is\n * not 'free'. It states only that the prose was not served and at what access\n * level — it never paraphrases the withheld text.\n */\nexport function accessNotice(access: DocumentAccess): string {\n return `*Full text is not served to agents at this URL (access: ${ACCESS_LABELS[access]}).*`\n}\n\n/** The fixed timezone sentence rendered above every hours table. */\nexport function timeZoneSentence(timeZone: string): string {\n return `All times are local to ${inline(timeZone)}.`\n}\n\n/* ------------------------------------------------------------------ *\n * URL scheme allowlist and escaping.\n * ------------------------------------------------------------------ */\n\n/** The only schemes this package will put behind a markdown link. */\nexport const ALLOWED_URL_SCHEMES: readonly string[] = ['https:', 'http:', 'mailto:', 'tel:']\n\n/**\n * True when `raw` is an absolute URL with an allowlisted scheme. Relative URLs\n * are rejected: this package has no base URL to resolve them against, and\n * guessing one would emit a link the merchant never wrote.\n */\nexport function isAllowedUrl(raw: string): boolean {\n let parsed: URL\n try {\n parsed = new URL(raw)\n } catch {\n return false\n }\n return ALLOWED_URL_SCHEMES.includes(parsed.protocol)\n}\n\n/**\n * Escape a markdown link label. `]`, `(`, and `)` would otherwise let source\n * text break out of the label and forge a link target.\n */\nexport function linkLabel(text: string): string {\n return inline(text).replace(/[\\]()]/g, (c) => `\\\\${c}`)\n}\n\n/** `[label](url)` with the label escaped. Callers must allowlist `url` first. */\nexport function markdownLink(label: string, url: string): string {\n return `[${linkLabel(label)}](${url})`\n}\n\n/**\n * A markdown link safe to drop into a table cell. `cell()` cannot be used on a\n * finished link — it would escape nothing useful and `linkLabel` has already\n * run — so the `|` guard is applied on top instead.\n */\nexport function cellLink(label: string, url: string): string {\n return markdownLink(label, url).replace(/\\|/g, '\\\\|')\n}\n\n/* ------------------------------------------------------------------ *\n * Value validation.\n * ------------------------------------------------------------------ */\n\n/** ISO 8601 date or datetime. Structure first, then real-calendar check. */\nconst ISO_DATE = /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d{1,9})?)?(Z|[+-]\\d{2}:\\d{2})?)?$/\n\nexport function isIsoDate(value: string): boolean {\n return ISO_DATE.test(value) && !Number.isNaN(Date.parse(value))\n}\n\n/** 'YYYY-MM-DD' only — the form `HoursException.date` is specified in. */\nexport function isIsoDay(value: string): boolean {\n return /^\\d{4}-\\d{2}-\\d{2}$/.test(value) && !Number.isNaN(Date.parse(value))\n}\n\nconst HH_MM = /^([01]\\d|2[0-3]):[0-5]\\d$/\n\n/**\n * A single interval is valid only if both ends are 'HH:MM' and it does not\n * wrap. Overnight spans are expressed as two intervals on two days; accepting\n * `22:00`–`02:00` here would make the same string mean two different things.\n */\nfunction isValidInterval(i: HoursInterval): boolean {\n return HH_MM.test(i.opens) && HH_MM.test(i.closes) && i.closes > i.opens\n}\n\nfunction intervalsText(intervals: HoursInterval[]): string {\n return intervals.map((i) => `${i.opens}-${i.closes}`).join(', ')\n}\n\n/* ------------------------------------------------------------------ *\n * FactValue → text.\n * ------------------------------------------------------------------ */\n\nfunction numberText(value: number, unit?: string): string | null {\n if (!Number.isFinite(value)) return null\n const text = String(value)\n // Exponential form (\"1e+21\") is a number an agent will misparse and a human\n // never wrote. Drop rather than reformat: reformatting invents digits.\n if (text.includes('e') || text.includes('E')) return null\n return unit !== undefined ? `${text} ${inline(unit)}` : text\n}\n\nfunction moneyText(v: Extract<FactValue, { type: 'money' }>): string {\n let text = formatMoney(v.value)\n if (v.maxValue !== undefined) {\n if (v.maxValue.currency.toUpperCase() !== v.value.currency.toUpperCase()) {\n throw new TypeError(\n `Money range currencies must match, got: ${v.value.currency} and ${v.maxValue.currency}`,\n )\n }\n if (v.maxValue.amount < v.value.amount) {\n throw new TypeError(\n `Money range maxValue must not be below value, got: ${String(v.value.amount)} and ${String(v.maxValue.amount)}`,\n )\n }\n text = `${text}-${formatMoney(v.maxValue)}`\n }\n if (v.period !== undefined) text = `${text} ${PERIOD_SUFFIX[v.period]}`\n if (v.per !== undefined) text = `${text} ${inline(v.per)}`\n return text\n}\n\n/**\n * Render a scalar fact value to its single-line inline form, or `null` when\n * the value is malformed (dropped) or is an `hours` value (rendered as its own\n * block, not as a fact line).\n *\n * Throws only for money ranges that are internally contradictory — see the\n * file header.\n */\nexport function factValueText(value: FactValue): string | null {\n switch (value.type) {\n case 'text':\n return inline(value.value)\n case 'list':\n return value.value.length > 0 ? value.value.map(inline).join(', ') : null\n case 'number':\n return numberText(value.value, value.unit)\n case 'boolean':\n return BOOLEAN_LABELS[value.value ? 'true' : 'false']\n case 'money':\n return moneyText(value)\n case 'date':\n return isIsoDate(value.value) ? value.value : null\n case 'url':\n if (!isAllowedUrl(value.value)) return null\n return value.label !== undefined ? markdownLink(value.label, value.value) : value.value\n case 'hours':\n return null\n }\n}\n\n/**\n * Render one fact as `- **Label:** value`, plus an indented note line when the\n * fact carries one. Returns `null` when the value is dropped or is an `hours`\n * value.\n */\nexport function renderFactLine(fact: Fact): string | null {\n const text = factValueText(fact.value)\n if (text === null) return null\n const line = `- **${inline(fact.label)}:** ${text}`\n return fact.note !== undefined ? `${line}\\n - ${inline(fact.note)}` : line\n}\n\n/**\n * Render a fact value as a table cell. Two differences from a fact line: every\n * cell is `|`-escaped, and an `hours` value degrades to a link to the item's\n * own page rather than trying to flatten a table into a cell.\n */\nexport function factCellText(value: FactValue, itemUrl: string): string | null {\n if (value.type === 'hours') {\n return isAllowedUrl(itemUrl) ? cellLink(SEE_PAGE_LABEL, itemUrl) : SEE_PAGE_LABEL\n }\n if (value.type === 'url') {\n if (!isAllowedUrl(value.value)) return null\n // Already an escaped link; only the `|` guard still applies.\n return value.label !== undefined\n ? cellLink(value.label, value.value)\n : value.value.replace(/\\|/g, '\\\\|')\n }\n const text = factValueText(value)\n return text === null ? null : cell(text)\n}\n\n/* ------------------------------------------------------------------ *\n * Hours block.\n * ------------------------------------------------------------------ */\n\nfunction exceptionRow(e: HoursException): string | null {\n if (!isIsoDay(e.date)) return null\n let hours: string\n if (e.closed === true) {\n hours = CLOSED_LABEL\n } else if (e.intervals !== undefined && e.intervals.length > 0) {\n if (!e.intervals.every(isValidInterval)) return null\n hours = intervalsText(e.intervals)\n } else if (e.intervals !== undefined) {\n hours = CLOSED_LABEL\n } else {\n hours = NOT_STATED_LABEL\n }\n const note = e.note !== undefined ? cell(e.note) : ''\n return `| ${e.date} | ${hours} | ${note} |`\n}\n\n/**\n * Render one `hours` fact as its own block, headed by the fact's own label.\n *\n * The heading is `Fact.label`, not a fixed \"Hours\": a clinic with \"Office\n * hours\" and \"Lab hours\" must not emit two identically-titled tables that an\n * agent cannot tell apart.\n *\n * All seven weekdays always render. An absent weekday is `Not stated` and a\n * present-but-empty one is `Closed`; collapsing those two into one label would\n * assert a closure the merchant never stated. Nothing here computes whether\n * the place is open now — that requires a clock and a timezone database, and a\n * wrong answer to \"are they open\" is worse than no answer.\n *\n * Returns `null` when the spec is malformed (missing timezone, or any invalid\n * interval anywhere in `weekly`). Partial hours are dropped whole: a table\n * missing the one day that was malformed reads as authoritative and is not.\n */\nexport function renderHoursBlock(\n label: string,\n spec: HoursSpec,\n level: number,\n subLevel: number,\n): string | null {\n if (typeof spec.timeZone !== 'string' || spec.timeZone.trim() === '') return null\n\n const byDay = new Map<Weekday, HoursInterval[]>()\n for (const rule of spec.weekly) {\n if (!rule.intervals.every(isValidInterval)) return null\n byDay.set(rule.day, rule.intervals)\n }\n\n const lines: string[] = [\n heading(level, inline(label)),\n '',\n timeZoneSentence(spec.timeZone),\n '',\n `| ${DAY_LABEL} | ${HOURS_LABEL} |`,\n '| --- | --- |',\n ]\n for (const day of WEEKDAY_ORDER) {\n const intervals = byDay.get(day)\n const text =\n intervals === undefined\n ? NOT_STATED_LABEL\n : intervals.length === 0\n ? CLOSED_LABEL\n : intervalsText(intervals)\n lines.push(`| ${WEEKDAY_LABELS[day]} | ${text} |`)\n }\n\n if (spec.note !== undefined) {\n lines.push('', `- **${NOTE_LABEL}:** ${inline(spec.note)}`)\n }\n\n const exceptionRows = (spec.exceptions ?? [])\n .map(exceptionRow)\n .filter((row): row is string => row !== null)\n if (exceptionRows.length > 0) {\n lines.push(\n '',\n heading(subLevel, EXCEPTIONS_HEADING),\n '',\n `| ${DATE_LABEL} | ${HOURS_LABEL} | ${NOTE_LABEL} |`,\n '| --- | --- | --- |',\n ...exceptionRows,\n )\n }\n\n return lines.join('\\n')\n}\n","/**\n * The universal renderers: any page that is not a product, a policy set, or a\n * catalog. Same signature shape and the same `RenderOptions` as the three\n * commerce renderers, and the same guarantee — pure, deterministic, no clock,\n * no locale, no network, and every substantive value injected from the source\n * object.\n *\n * Block order and truncation are stated once, here and in README.md, and\n * nowhere else:\n *\n * 1. `# [title](url)` required\n * 2. `> summary` required\n * 3. `- **Updated:**` + scalar fact lines required\n * 4. `## <fact label>` hours table, one per hours fact required\n * 5. `## Contact` required\n * 6. `## Actions` required\n * 7. `## <section heading>` prose (only when free) truncatable\n * 8. `## Related` truncatable, first to go\n *\n * `assembleWithBudget` truncates strictly from the bottom, so putting\n * `related` last in the tail is what makes prose survive a tight budget and\n * cross-links drop. The order of that array is load-bearing, not cosmetic.\n *\n * Two ceilings, not one. `maxBytes` governs the truncatable tail as it does\n * for commerce. A second, absolute ceiling at `4 × maxBytes` governs the\n * required blocks, because \"facts are never sacrificed\" is a safe promise for\n * a PDP with a dozen fields and an unbounded one for a government service page\n * with six twenty-item lists — without the hard ceiling a merchant's own data\n * shape decides our response size.\n */\n\nimport type { RenderOptions } from '../types'\nimport type { TailSection } from '../internal/budget'\nimport {\n assembleWithBudget,\n byteLength,\n cell,\n clampHeadingLevel,\n DEFAULT_MAX_BYTES,\n heading,\n inline,\n TRUNCATION_NOTE,\n} from '../internal/budget'\nimport type {\n CollectionItemSource,\n CollectionSource,\n DocumentSectionSource,\n DocumentSource,\n} from './types'\nimport {\n ACTIONS_HEADING,\n ADDRESS_LABEL,\n CONTACT_HEADING,\n CONTENTS_HEADING,\n EMAIL_LABEL,\n NOTE_LABEL,\n PHONE_LABEL,\n RELATED_HEADING,\n TITLE_LABEL,\n UPDATED_LABEL,\n accessNotice,\n cellLink,\n factCellText,\n isAllowedUrl,\n isIsoDate,\n linkLabel,\n markdownLink,\n renderFactLine,\n renderHoursBlock,\n} from './facts'\n\n/** Hard ceilings. Merchant data shape must not decide our response size. */\nconst MAX_FACTS = 60\nconst MAX_ACTIONS = 20\nconst MAX_COLLECTION_ROWS = 500\nconst MAX_COLLECTION_COLUMNS = 12\nconst HARD_CEILING_MULTIPLE = 4\n\n/**\n * Absolute output cap. `assembleWithBudget` deliberately emits required blocks\n * even when they alone exceed `maxBytes`; this bounds that escape hatch. Cuts\n * are on whole lines, and the truncation note always ends the document.\n */\nfunction applyHardCeiling(out: string, maxBytes: number): string {\n const ceiling = maxBytes * HARD_CEILING_MULTIPLE\n if (byteLength(out) <= ceiling) return out\n\n const noteSuffix = `\\n\\n${TRUNCATION_NOTE}`\n const budget = ceiling - byteLength(noteSuffix)\n let kept = ''\n for (const line of out.split('\\n')) {\n const next = kept === '' ? line : `${kept}\\n${line}`\n if (byteLength(next) > budget) break\n kept = next\n }\n return kept === '' ? TRUNCATION_NOTE : `${kept}${noteSuffix}`\n}\n\n/** `> ` prefix on every line; blank lines stay blank inside the quote. */\nfunction blockquote(text: string): string[] {\n return text.split('\\n').map((line) => (line.length > 0 ? `> ${line}` : '>'))\n}\n\n/**\n * A prose section as a truncatable tail block.\n *\n * `assembleWithBudget` renders a tail block as `headingLine` + blank line +\n * items. A section with a heading maps onto that exactly. A section without\n * one has no heading to put there, so its first body line takes that slot and\n * the blank line the assembler inserts consumes the body's own paragraph\n * break. For prose — where paragraphs are already blank-line separated — this\n * is byte-for-byte verbatim; for a body with no blank line after its first\n * line it inserts one paragraph break. No characters are ever added, removed,\n * or reordered either way.\n */\nfunction sectionTail(section: DocumentSectionSource, level: number): TailSection {\n const lines = section.body.split('\\n')\n if (section.heading !== undefined && section.heading.length > 0) {\n return { headingLine: heading(level, inline(section.heading)), items: lines }\n }\n const rest = lines.slice(1)\n if (rest[0] === '') rest.shift()\n return { headingLine: lines[0] ?? '', items: rest }\n}\n\n/**\n * Render any non-commerce page as clean markdown. Facts come first: an agent\n * reading top-down gets the whole machine-readable payload before any prose,\n * and prose is the only thing the byte budget can take away.\n */\nexport function renderDocumentMarkdown(doc: DocumentSource, opts?: RenderOptions): string {\n const maxBytes = opts?.maxBytes ?? DEFAULT_MAX_BYTES\n const level = clampHeadingLevel(opts?.headingLevel ?? 1)\n const sub = clampHeadingLevel(level + 1)\n const subSub = clampHeadingLevel(sub + 1)\n const access = doc.access ?? 'free'\n\n // A document whose own canonical URL is not allowlisted still renders — an\n // agent losing the self-link is better than losing the facts — but it never\n // renders as a link.\n const titleText = isAllowedUrl(doc.url)\n ? markdownLink(doc.title, doc.url)\n : linkLabel(doc.title)\n\n const updated = doc.updated !== undefined && isIsoDate(doc.updated) ? doc.updated : undefined\n const facts = (doc.facts ?? []).slice(0, MAX_FACTS)\n\n const factLines: string[] = []\n if (updated !== undefined) factLines.push(`- **${UPDATED_LABEL}:** ${updated}`)\n for (const fact of facts) {\n // Dedup: a top-level `updated` wins over a fact that repeats it. Two\n // \"Updated\" lines disagreeing is worse than one that might be stale.\n if (updated !== undefined && fact.label.trim().toLowerCase() === UPDATED_LABEL.toLowerCase()) {\n continue\n }\n const line = renderFactLine(fact)\n if (line !== null) factLines.push(line)\n }\n\n const head: string[] = [heading(level, titleText)]\n if (doc.summary !== undefined && doc.summary.length > 0) {\n head.push('', ...blockquote(doc.summary))\n }\n if (factLines.length > 0) head.push('', ...factLines)\n\n const requiredBlocks: string[] = [head.join('\\n')]\n\n for (const fact of facts) {\n if (fact.value.type !== 'hours') continue\n const block = renderHoursBlock(fact.label, fact.value.value, sub, subSub)\n if (block !== null) requiredBlocks.push(block)\n }\n\n const contactLines: string[] = []\n const contact = doc.contact\n if (contact !== undefined) {\n if (contact.phone !== undefined) contactLines.push(`- **${PHONE_LABEL}:** ${inline(contact.phone)}`)\n if (contact.email !== undefined) contactLines.push(`- **${EMAIL_LABEL}:** ${inline(contact.email)}`)\n if (contact.address !== undefined && contact.address.length > 0) {\n contactLines.push(`- **${ADDRESS_LABEL}:** ${contact.address.map(inline).join(', ')}`)\n }\n // No label: there is no whitelisted word for \"the contact URL\", and\n // inventing one would put renderer prose in the output.\n if (contact.url !== undefined && isAllowedUrl(contact.url)) contactLines.push(`- ${contact.url}`)\n }\n if (contactLines.length > 0) {\n requiredBlocks.push([heading(sub, CONTACT_HEADING), '', ...contactLines].join('\\n'))\n }\n\n const actionLines: string[] = []\n for (const action of (doc.actions ?? []).slice(0, MAX_ACTIONS)) {\n if (!isAllowedUrl(action.url)) continue\n actionLines.push(`- ${markdownLink(action.label, action.url)}`)\n if (action.note !== undefined) actionLines.push(` - ${inline(action.note)}`)\n }\n if (actionLines.length > 0) {\n requiredBlocks.push([heading(sub, ACTIONS_HEADING), '', ...actionLines].join('\\n'))\n }\n\n if (access !== 'free') requiredBlocks.push(accessNotice(access))\n\n const tail: TailSection[] = []\n // Mechanical, not a prose rule: `sections` is only ever read on this branch,\n // so no renderer bug below can leak a paywalled body.\n if (access === 'free') {\n for (const section of doc.sections ?? []) tail.push(sectionTail(section, sub))\n }\n\n const relatedItems: string[] = []\n for (const link of doc.related ?? []) {\n if (!isAllowedUrl(link.url)) continue\n relatedItems.push(`- ${markdownLink(link.title, link.url)}`)\n if (link.note !== undefined) relatedItems.push(` - ${inline(link.note)}`)\n }\n if (relatedItems.length > 0) {\n tail.push({ headingLine: heading(sub, RELATED_HEADING), items: relatedItems })\n }\n\n return applyHardCeiling(assembleWithBudget(requiredBlocks, tail, maxBytes), maxBytes)\n}\n\n/* ------------------------------------------------------------------ *\n * Collections.\n * ------------------------------------------------------------------ */\n\n/**\n * Exact byte length of `| a | b | c |` given the byte lengths of the cells:\n * two spaces around each cell, one pipe between each pair, one at each end.\n */\nfunction rowBytes(cellByteSum: number, columnCount: number): number {\n return cellByteSum + 3 * columnCount + 1\n}\n\nfunction tableRow(cells: string[]): string {\n return `| ${cells.join(' | ')} |`\n}\n\n/** One item's cells, in the order their columns should first appear. */\nfunction itemCells(item: CollectionItemSource): { label: string; text: string }[] {\n const cells: { label: string; text: string }[] = []\n if (item.summary !== undefined && item.summary.length > 0) {\n cells.push({ label: NOTE_LABEL, text: cell(item.summary) })\n }\n for (const fact of item.facts ?? []) {\n const text = factCellText(fact.value, item.url)\n if (text === null) continue\n cells.push({ label: cell(fact.label), text })\n }\n return cells\n}\n\nfunction titleCell(item: CollectionItemSource): string {\n return isAllowedUrl(item.url) ? cellLink(item.title, item.url) : cell(item.title)\n}\n\n/**\n * Render a listing page. Two deterministic modes and no third: if no item\n * carries facts the output is a link list, otherwise it is a table.\n *\n * The table's columns are the ordered union of fact labels by first\n * appearance, accumulated in the SAME streaming pass that spends the byte\n * budget. That is the whole point: compute the union first and the header can\n * advertise columns belonging only to rows the budget then drops, which is a\n * table of empty cells describing data we did not send. Byte accounting is\n * exact rather than estimated (see `rowBytes`), so the pass never has to\n * re-render to find out whether it overshot.\n *\n * An item `summary` occupies a `Note` column, positioned by the same\n * first-appearance rule. A merchant fact literally labelled `Note` on an item\n * that also has a summary collides; the summary wins, because it was written\n * for the listing.\n */\nexport function renderCollectionMarkdown(\n collection: CollectionSource,\n opts?: RenderOptions,\n): string {\n const maxBytes = opts?.maxBytes ?? DEFAULT_MAX_BYTES\n const level = clampHeadingLevel(opts?.headingLevel ?? 1)\n\n const title = collection.title !== undefined ? collection.title : CONTENTS_HEADING\n const titleText = isAllowedUrl(collection.url)\n ? markdownLink(title, collection.url)\n : linkLabel(title)\n const head = heading(level, titleText)\n\n const items = collection.items\n if (items.length === 0) return head\n\n const noteSuffix = `\\n\\n${TRUNCATION_NOTE}`\n const budget = maxBytes - byteLength(noteSuffix)\n const anyFacts = items.some((item) => (item.facts ?? []).length > 0)\n\n if (!anyFacts) return linkList(head, items, budget)\n\n // Streaming pass: columns and rows grow together, bounded by `budget`.\n const columns: string[] = []\n const rows: Map<string, string>[] = []\n let headerCellBytes = byteLength(TITLE_LABEL)\n let bodyCellBytes = 0\n let truncated = false\n\n // head + '\\n\\n' + headerRow + '\\n' + separatorRow + ('\\n' + row) per row.\n // Separator cells are always '---', i.e. 3 bytes each.\n const base = byteLength(head) + 2\n const totalBytes = (columnCount: number, rowCount: number): number =>\n base +\n rowBytes(headerCellBytes, columnCount) +\n 1 +\n rowBytes(3 * columnCount, columnCount) +\n bodyCellBytes +\n rowCount * (3 * columnCount + 2)\n\n for (const item of items) {\n if (rows.length >= MAX_COLLECTION_ROWS) {\n truncated = true\n break\n }\n\n const cells = itemCells(item)\n const values = new Map<string, string>()\n const newColumns: string[] = []\n for (const { label, text } of cells) {\n if (values.has(label)) continue // first write wins within a row\n if (!columns.includes(label) && !newColumns.includes(label)) {\n if (columns.length + newColumns.length >= MAX_COLLECTION_COLUMNS) continue\n newColumns.push(label)\n }\n values.set(label, text)\n }\n values.set(TITLE_LABEL, titleCell(item))\n\n const nextColumnCount = 1 + columns.length + newColumns.length\n const addedHeaderBytes = newColumns.reduce((sum, label) => sum + byteLength(label), 0)\n const addedBodyBytes = [...values.values()].reduce((sum, text) => sum + byteLength(text), 0)\n\n const savedHeader = headerCellBytes\n const savedBody = bodyCellBytes\n headerCellBytes += addedHeaderBytes\n bodyCellBytes += addedBodyBytes\n if (totalBytes(nextColumnCount, rows.length + 1) > budget) {\n headerCellBytes = savedHeader\n bodyCellBytes = savedBody\n truncated = true\n break\n }\n\n columns.push(...newColumns)\n rows.push(values)\n }\n\n // No row fit. A bare header advertises columns nothing fills — exactly what\n // the streaming pass exists to prevent — so emit no table at all.\n if (rows.length === 0) return `${head}${noteSuffix}`\n\n const header = [TITLE_LABEL, ...columns]\n const lines = [\n head,\n '',\n tableRow(header),\n tableRow(header.map(() => '---')),\n ...rows.map((values) => tableRow(header.map((label) => values.get(label) ?? ''))),\n ]\n const out = lines.join('\\n')\n return truncated ? `${out}${noteSuffix}` : out\n}\n\n/** Link-list mode: whole entries only, dropped from the bottom. */\nfunction linkList(head: string, items: CollectionItemSource[], budget: number): string {\n const noteSuffix = `\\n\\n${TRUNCATION_NOTE}`\n let out = head\n let truncated = false\n let rendered = 0\n\n for (const item of items) {\n if (rendered >= MAX_COLLECTION_ROWS) {\n truncated = true\n break\n }\n const link = isAllowedUrl(item.url)\n ? markdownLink(item.title, item.url)\n : inline(item.title)\n const entry: string[] = [`- ${link}`]\n if (item.summary !== undefined && item.summary.length > 0) {\n entry.push(` - ${inline(item.summary)}`)\n }\n const next = `${out}${rendered === 0 ? '\\n\\n' : '\\n'}${entry.join('\\n')}`\n if (byteLength(next) > budget) {\n truncated = true\n break\n }\n out = next\n rendered += 1\n }\n\n return truncated ? `${out}${noteSuffix}` : out\n}\n"]}
@@ -0,0 +1,415 @@
1
+ /**
2
+ * Source-of-truth input types for @rebilder/render-md.
3
+ *
4
+ * Every field on these types is treated as authoritative merchant data. The
5
+ * renderers in this package only transform format — they never invent,
6
+ * estimate, or reword any value found here (CLAUDE.md Hard Rules 2 & 3).
7
+ */
8
+ /** Monetary value. `amount` is in minor units (e.g. cents for USD). */
9
+ interface Money {
10
+ amount: number;
11
+ currency: string;
12
+ }
13
+ /** Stock state, as reported by the merchant source of truth. */
14
+ type Availability = 'in_stock' | 'out_of_stock' | 'preorder' | 'backorder';
15
+ interface ProductVariantSource {
16
+ id: string;
17
+ title: string;
18
+ price: Money;
19
+ availability: Availability;
20
+ sku?: string;
21
+ options?: Record<string, string>;
22
+ }
23
+ interface ShippingSource {
24
+ /** Merchant-authored shipping summary. Rendered verbatim. */
25
+ summary: string;
26
+ freeThreshold?: Money;
27
+ regions?: string[];
28
+ /** [min, max] delivery estimate in days, from the merchant. */
29
+ etaDays?: [number, number];
30
+ }
31
+ interface ReturnsSource {
32
+ /** Merchant-authored returns summary. Rendered verbatim. */
33
+ summary: string;
34
+ windowDays?: number;
35
+ url?: string;
36
+ }
37
+ interface ProductSource {
38
+ url: string;
39
+ title: string;
40
+ brand?: string;
41
+ description?: string;
42
+ price: Money;
43
+ compareAtPrice?: Money;
44
+ availability: Availability;
45
+ variants?: ProductVariantSource[];
46
+ shipping?: ShippingSource;
47
+ returns?: ReturnsSource;
48
+ images?: {
49
+ url: string;
50
+ alt?: string;
51
+ }[];
52
+ /** Material, size chart facts, etc. — rendered verbatim. */
53
+ attributes?: Record<string, string>;
54
+ }
55
+ interface PolicySource {
56
+ title: string;
57
+ url: string;
58
+ /** Policy text. Rendered verbatim — never summarized or reworded. */
59
+ body: string;
60
+ }
61
+ interface CatalogItemSource {
62
+ url: string;
63
+ title: string;
64
+ price: Money;
65
+ availability: ProductSource['availability'];
66
+ }
67
+ interface RenderOptions {
68
+ /** Output size budget in UTF-8 bytes. Default 5120. */
69
+ maxBytes?: number;
70
+ /** Markdown heading level for the top-level heading (1–6). Default 1. */
71
+ headingLevel?: number;
72
+ }
73
+
74
+ /**
75
+ * Human-readable, deterministic money formatting: "$49.00", "€49.00",
76
+ * "¥4,900", "-£5.50". Unknown/ambiguous currencies render as "CAD 49.00".
77
+ * Pure function — no Intl, no locale, same input → same output everywhere.
78
+ */
79
+ declare function formatMoney(m: Money): string;
80
+
81
+ /**
82
+ * Render a schema.org Product JSON-LD object from the product source.
83
+ * Injection-only: every value comes from `p`; only fields present in the
84
+ * source appear in the output. Key order is fixed for snapshot stability.
85
+ */
86
+ declare function renderProductJsonLd(p: ProductSource): Record<string, unknown>;
87
+
88
+ /**
89
+ * Render a product detail page as clean markdown. Buying facts come first:
90
+ * title, price, availability, shipping, and returns all land in the opening
91
+ * lines so an agent reading top-down never misses them. Every substantive
92
+ * value is injected from `p` — nothing is invented or reworded.
93
+ */
94
+ declare function renderProductMarkdown(p: ProductSource, opts?: RenderOptions): string;
95
+ /**
96
+ * Render store policies as markdown. Each policy is a linked heading followed
97
+ * by its body byte-for-byte verbatim. Under the byte budget, whole policies
98
+ * are kept in order; a policy whose body does not fit degrades to its linked
99
+ * title (policy text is never partially rendered), and the document ends with
100
+ * the truncation note.
101
+ */
102
+ declare function renderPolicyMarkdown(policies: PolicySource[], opts?: RenderOptions): string;
103
+ /**
104
+ * Render a catalog listing as a markdown table (title → link, price,
105
+ * availability). Under the byte budget, whole rows are dropped from the
106
+ * bottom and the truncation note is appended.
107
+ */
108
+ declare function renderCatalogMarkdown(items: CatalogItemSource[], opts?: RenderOptions): string;
109
+
110
+ /**
111
+ * Universal source-of-truth input types: any page that is not a product,
112
+ * a policy set, or a catalog.
113
+ *
114
+ * `src/types.ts` is deliberately not edited. Commerce types stay byte-
115
+ * identical and the commerce renderers keep their exact output; this file is
116
+ * additive and re-exported through `src/index.ts`.
117
+ *
118
+ * The same guarantee as the commerce types applies to every field here: it is
119
+ * authoritative merchant data, and the renderers only transform format. They
120
+ * never invent, estimate, or reword a value found on these types (CLAUDE.md
121
+ * Hard Rules 2 & 3).
122
+ *
123
+ * Why two types (document + collection) and not one per vertical: see the
124
+ * promotion bar in README.md. Every vertical evaluated so far reduces to
125
+ * document-with-facts, and a vertical that ships as vocabulary rather than as
126
+ * a type is a vertical we can add without a release.
127
+ */
128
+
129
+ type BillingPeriod = 'one_time' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
130
+ type Weekday = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
131
+ /** 24-hour local times, 'HH:MM'. Validated; malformed → the fact is dropped. */
132
+ interface HoursInterval {
133
+ opens: string;
134
+ closes: string;
135
+ }
136
+ /**
137
+ * One weekday. `intervals: []` means CLOSED that day. A weekday absent from
138
+ * `weekly` renders as "Not stated" — a different fact from "Closed".
139
+ * Overnight spans are expressed as two intervals on two days; a single
140
+ * interval where closes <= opens is rejected as malformed.
141
+ */
142
+ interface HoursRule {
143
+ day: Weekday;
144
+ intervals: HoursInterval[];
145
+ }
146
+ interface HoursException {
147
+ /** 'YYYY-MM-DD', validated. */
148
+ date: string;
149
+ closed?: boolean;
150
+ intervals?: HoursInterval[];
151
+ /** Verbatim. */
152
+ note?: string;
153
+ }
154
+ interface HoursSpec {
155
+ weekly: HoursRule[];
156
+ exceptions?: HoursException[];
157
+ /** IANA zone. REQUIRED — hours without a zone are an ambiguous fact. */
158
+ timeZone: string;
159
+ /** Verbatim. */
160
+ note?: string;
161
+ }
162
+ /**
163
+ * The value of one fact. Closed union; every member has a deterministic,
164
+ * locale-free rendering.
165
+ */
166
+ type FactValue = {
167
+ type: 'text';
168
+ value: string;
169
+ } | {
170
+ type: 'list';
171
+ value: string[];
172
+ }
173
+ /** String(value). Rejects non-finite and exponential-form values. */
174
+ | {
175
+ type: 'number';
176
+ value: number;
177
+ unit?: string;
178
+ }
179
+ /** Fixed label map { true: 'Yes', false: 'No' }. */
180
+ | {
181
+ type: 'boolean';
182
+ value: boolean;
183
+ }
184
+ /**
185
+ * Through formatMoney (throws rather than rounds). maxValue renders a range;
186
+ * period appends a fixed suffix; per appends verbatim text.
187
+ * Throws if maxValue.currency !== value.currency or maxValue < value.
188
+ */
189
+ | {
190
+ type: 'money';
191
+ value: Money;
192
+ maxValue?: Money;
193
+ period?: BillingPeriod;
194
+ per?: string;
195
+ }
196
+ /** ISO 8601 date or datetime, validated. Emitted verbatim. */
197
+ | {
198
+ type: 'date';
199
+ value: string;
200
+ }
201
+ /** [label](value) or the bare URL. Scheme allowlist enforced. */
202
+ | {
203
+ type: 'url';
204
+ value: string;
205
+ label?: string;
206
+ }
207
+ /** Markdown table. Never computes "open now" — that is the agent's job. */
208
+ | {
209
+ type: 'hours';
210
+ value: HoursSpec;
211
+ };
212
+ interface Fact {
213
+ label: string;
214
+ value: FactValue;
215
+ note?: string;
216
+ }
217
+ /** Advisory routing/telemetry label. NEVER rendered into markdown. */
218
+ type DocumentKind = 'page' | 'service' | 'location' | 'plan' | 'article' | 'faq' | 'profile' | 'event' | 'listing' | 'job' | 'course' | (string & {});
219
+ /**
220
+ * Contact details as published on the canonical page. See the PII note in
221
+ * README.md: this type plus kind 'profile'/'job' makes it trivial to serve
222
+ * named individuals' contact details in bulk, and the merchant is the
223
+ * controller for that data.
224
+ */
225
+ interface ContactSource {
226
+ phone?: string;
227
+ email?: string;
228
+ url?: string;
229
+ /** Display order, verbatim. */
230
+ address?: string[];
231
+ }
232
+ /** Advisory only, exactly like `DocumentKind` — never rendered into markdown. */
233
+ type ActionKind = 'book' | 'apply' | 'contact' | 'purchase' | 'subscribe' | 'download' | 'quote' | 'other' | (string & {});
234
+ interface ActionSource {
235
+ /** Verbatim. */
236
+ label: string;
237
+ url: string;
238
+ /** Advisory only; not rendered. */
239
+ kind?: ActionKind;
240
+ note?: string;
241
+ }
242
+ interface DocumentSectionSource {
243
+ heading?: string;
244
+ body: string;
245
+ }
246
+ interface LinkSource {
247
+ title: string;
248
+ url: string;
249
+ note?: string;
250
+ }
251
+ /**
252
+ * Access level of this document's prose, as the merchant's own access control
253
+ * sees it. The renderer emits `sections` ONLY when access === 'free'.
254
+ * Anything else emits summary + facts + actions + an access notice.
255
+ * This is mechanical, not a prose rule: no renderer bug can leak a paywalled
256
+ * body, and the merchant cannot accidentally over-serve one.
257
+ */
258
+ type DocumentAccess = 'free' | 'registered' | 'metered' | 'subscriber';
259
+ interface DocumentSource {
260
+ url: string;
261
+ title: string;
262
+ /** Advisory only; not rendered. */
263
+ kind?: DocumentKind;
264
+ /** Verbatim, rendered as a blockquote. */
265
+ summary?: string;
266
+ /** ISO 8601, verbatim. */
267
+ updated?: string;
268
+ /** Default 'free'. */
269
+ access?: DocumentAccess;
270
+ /** THE front-loaded block. Order is authoritative. Capped at 60 facts. */
271
+ facts?: Fact[];
272
+ /** Capped at 20. Never truncated. */
273
+ actions?: ActionSource[];
274
+ contact?: ContactSource;
275
+ /** Prose. Emitted only when access === 'free'. Truncatable. */
276
+ sections?: DocumentSectionSource[];
277
+ /** Cross-links. Last in the tail; FIRST to be dropped. */
278
+ related?: LinkSource[];
279
+ /**
280
+ * Set by hosted extraction only. When present the gateway refuses to serve
281
+ * the document past `ttlSeconds` and falls through to HTML. A snapshot is
282
+ * not a source of truth: without this, a merchant changes their hours and
283
+ * agents keep receiving the approved bundle — different substance to agents
284
+ * and humans at the same URL, which is a Hard Rule 3 breach manufactured by
285
+ * our own pipeline. Enforced by the gateway, not by this package.
286
+ */
287
+ provenance?: {
288
+ capturedAt: string;
289
+ contentSha256: string;
290
+ ttlSeconds: number;
291
+ };
292
+ }
293
+ interface CollectionItemSource {
294
+ url: string;
295
+ title: string;
296
+ summary?: string;
297
+ /** Become table columns. */
298
+ facts?: Fact[];
299
+ }
300
+ interface CollectionSource {
301
+ /**
302
+ * Canonical URL of the listing itself. Required — an agent must be able to
303
+ * resolve which page it is reading, and llms.txt needs a target.
304
+ */
305
+ url: string;
306
+ /** Defaults to the fixed 'Contents' label. */
307
+ title?: string;
308
+ /** Capped at 500 rendered rows; column union capped at 12. */
309
+ items: CollectionItemSource[];
310
+ }
311
+
312
+ /**
313
+ * The universal renderers: any page that is not a product, a policy set, or a
314
+ * catalog. Same signature shape and the same `RenderOptions` as the three
315
+ * commerce renderers, and the same guarantee — pure, deterministic, no clock,
316
+ * no locale, no network, and every substantive value injected from the source
317
+ * object.
318
+ *
319
+ * Block order and truncation are stated once, here and in README.md, and
320
+ * nowhere else:
321
+ *
322
+ * 1. `# [title](url)` required
323
+ * 2. `> summary` required
324
+ * 3. `- **Updated:**` + scalar fact lines required
325
+ * 4. `## <fact label>` hours table, one per hours fact required
326
+ * 5. `## Contact` required
327
+ * 6. `## Actions` required
328
+ * 7. `## <section heading>` prose (only when free) truncatable
329
+ * 8. `## Related` truncatable, first to go
330
+ *
331
+ * `assembleWithBudget` truncates strictly from the bottom, so putting
332
+ * `related` last in the tail is what makes prose survive a tight budget and
333
+ * cross-links drop. The order of that array is load-bearing, not cosmetic.
334
+ *
335
+ * Two ceilings, not one. `maxBytes` governs the truncatable tail as it does
336
+ * for commerce. A second, absolute ceiling at `4 × maxBytes` governs the
337
+ * required blocks, because "facts are never sacrificed" is a safe promise for
338
+ * a PDP with a dozen fields and an unbounded one for a government service page
339
+ * with six twenty-item lists — without the hard ceiling a merchant's own data
340
+ * shape decides our response size.
341
+ */
342
+
343
+ /**
344
+ * Render any non-commerce page as clean markdown. Facts come first: an agent
345
+ * reading top-down gets the whole machine-readable payload before any prose,
346
+ * and prose is the only thing the byte budget can take away.
347
+ */
348
+ declare function renderDocumentMarkdown(doc: DocumentSource, opts?: RenderOptions): string;
349
+ /**
350
+ * Render a listing page. Two deterministic modes and no third: if no item
351
+ * carries facts the output is a link list, otherwise it is a table.
352
+ *
353
+ * The table's columns are the ordered union of fact labels by first
354
+ * appearance, accumulated in the SAME streaming pass that spends the byte
355
+ * budget. That is the whole point: compute the union first and the header can
356
+ * advertise columns belonging only to rows the budget then drops, which is a
357
+ * table of empty cells describing data we did not send. Byte accounting is
358
+ * exact rather than estimated (see `rowBytes`), so the pass never has to
359
+ * re-render to find out whether it overshot.
360
+ *
361
+ * An item `summary` occupies a `Note` column, positioned by the same
362
+ * first-appearance rule. A merchant fact literally labelled `Note` on an item
363
+ * that also has a summary collides; the summary wins, because it was written
364
+ * for the listing.
365
+ */
366
+ declare function renderCollectionMarkdown(collection: CollectionSource, opts?: RenderOptions): string;
367
+
368
+ /**
369
+ * Fact rendering: the deterministic `FactValue` → markdown mapping, the fixed
370
+ * label maps, the URL scheme allowlist, and the escaping rules.
371
+ *
372
+ * This file is where the injection-only guarantee is actually enforced for the
373
+ * universal path. Every rule below is mechanical rather than advisory, because
374
+ * an advisory rule in a renderer is a rule that holds until the first hurried
375
+ * patch:
376
+ *
377
+ * - Every renderer-authored string in this package is a named constant here.
378
+ * The whitelist in README.md is the list of these constants, and
379
+ * `tests/documents-integrity.test.ts` re-states that list as literals (not
380
+ * by importing these constants) so that adding scaffolding cannot silently
381
+ * whitelist itself.
382
+ * - A malformed value is DROPPED, never repaired. Repairing a fact invents a
383
+ * value the merchant never stated (Hard Rule 2); dropping it only loses
384
+ * information, which the agent can still get from the canonical page.
385
+ * - URLs are checked against a scheme allowlist. The commerce path only ever
386
+ * emitted merchant-controlled product/policy URLs; the universal path emits
387
+ * arbitrary merchant-supplied link targets, and `[Click here](javascript:…)`
388
+ * handed to an agent under our formatting authority is a phishing primitive.
389
+ * - Money throws rather than rounds or guesses, matching `formatMoney`. A
390
+ * thrown render is caught by the gateway and falls through to HTML; a
391
+ * silently wrong price is served forever.
392
+ */
393
+
394
+ /** Fixed suffix per billing period. Format mapping of a closed enum, not content. */
395
+ declare const PERIOD_SUFFIX: Record<BillingPeriod, string>;
396
+ /** Fixed label map for booleans. */
397
+ declare const BOOLEAN_LABELS: Record<'true' | 'false', string>;
398
+ /** Fixed weekday labels. English only and deliberately not localised: the
399
+ * output is a machine-readable format transformation, and a locale would make
400
+ * the same source render differently for different requesters (Hard Rule 3). */
401
+ declare const WEEKDAY_LABELS: Record<Weekday, string>;
402
+ /** Fixed weekday order. Every one of the seven renders, always. */
403
+ declare const WEEKDAY_ORDER: readonly Weekday[];
404
+ /** `intervals: []` — the merchant stated the day and stated it is closed. */
405
+ declare const CLOSED_LABEL = "Closed";
406
+ /** Weekday absent from `weekly` — a different fact from `Closed`. */
407
+ declare const NOT_STATED_LABEL = "Not stated";
408
+ /** An `hours` fact is not a valid table cell; the row links out instead. */
409
+ declare const SEE_PAGE_LABEL = "See page";
410
+ /** Fixed access-level words used inside the single access notice sentence. */
411
+ declare const ACCESS_LABELS: Record<DocumentAccess, string>;
412
+ /** The only schemes this package will put behind a markdown link. */
413
+ declare const ALLOWED_URL_SCHEMES: readonly string[];
414
+
415
+ export { ACCESS_LABELS, ALLOWED_URL_SCHEMES, type ActionKind, type ActionSource, type Availability, BOOLEAN_LABELS, type BillingPeriod, CLOSED_LABEL, type CatalogItemSource, type CollectionItemSource, type CollectionSource, type ContactSource, type DocumentAccess, type DocumentKind, type DocumentSectionSource, type DocumentSource, type Fact, type FactValue, type HoursException, type HoursInterval, type HoursRule, type HoursSpec, type LinkSource, type Money, NOT_STATED_LABEL, PERIOD_SUFFIX, type PolicySource, type ProductSource, type ProductVariantSource, type RenderOptions, type ReturnsSource, SEE_PAGE_LABEL, type ShippingSource, WEEKDAY_LABELS, WEEKDAY_ORDER, type Weekday, formatMoney, renderCatalogMarkdown, renderCollectionMarkdown, renderDocumentMarkdown, renderPolicyMarkdown, renderProductJsonLd, renderProductMarkdown };