pagegraph 0.5.1 → 0.6.1

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/dist/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as SeoGraph } from "./graph-BlLoEOw2.js";
1
+ import { f as SeoGraph, t as CoverageRule } from "./checks-6noG_xTS.js";
2
2
  import { PluginOption } from "vite";
3
3
  //#region src/config/vite-graph-loader.d.ts
4
4
  /** A graph, plus the release of whatever producing it acquired. */
@@ -67,6 +67,12 @@ interface SeoCliConfig {
67
67
  * Runs for indexable and preview hosts.
68
68
  */
69
69
  readonly transform?: ((robots: string) => string) | undefined;
70
+ /**
71
+ * Contextual-link coverage policy for `pagegraph check`: every sitemap-eligible
72
+ * page matching a rule's `path` glob needs at least `minInbound` incoming
73
+ * `related` edges. A `--require-inbound` flag overrides this per invocation.
74
+ */
75
+ readonly coverage?: ReadonlyArray<CoverageRule> | undefined;
70
76
  /** How the CLI gets the graph. {@link viteGraphLoader} covers the Vite-app case. */
71
77
  readonly loadGraph: SeoGraphLoader;
72
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":[],"sources":["../src/config/vite-graph-loader.ts","../src/config/index.ts"],"sourcesContent":["/**\n * A graph loader that evaluates the host app's own graph module inside a\n * headless Vite server.\n *\n * The SEO graph is built *by the app*: its module reads the generated route\n * tree and whatever content collections it owns, so it pulls in the app's real\n * module graph — path aliases, virtual modules from content plugins, bare\n * imports that only exist inside a server runtime. A CLI cannot just `import()`\n * that from Node or Bun.\n *\n * So this boots a scoped, in-process Vite server (middleware mode, no HMR, no\n * watcher, no HTTP listener), `ssrLoadModule`s the app's graph module, and calls\n * its exported loader. The graph comes back as a live in-process object — there\n * is no serialization boundary for the commands to cross — and the server is\n * closed by {@link LoadedSeoGraph.dispose}.\n *\n * Everything host-shaped is an option: the app supplies its own {@link\n * ViteGraphLoaderOptions.plugins} (a content plugin, an MDX loader), {@link\n * ViteGraphLoaderOptions.stubs} for bare modules that only resolve inside its\n * server runtime, and {@link ViteGraphLoaderOptions.env} for variables its\n * modules parse at import. This file knows about none of them.\n */\n\nimport { createServer, type InlineConfig, type PluginOption } from \"vite\";\n\nimport type { SeoGraph } from \"../core/graph\";\n\n/** A graph, plus the release of whatever producing it acquired. */\nexport interface LoadedSeoGraph {\n readonly graph: SeoGraph;\n /** Called once the command is done with the graph, on success or failure. */\n readonly dispose: () => Promise<void>;\n}\n\n/**\n * Produces the SEO graph for the `pagegraph` CLI. A plain promise on purpose: a\n * config file must be writable without Effect, which the CLI keeps behind its\n * `bin` (an optional peer dependency).\n */\nexport type SeoGraphLoader = () => Promise<LoadedSeoGraph>;\n\nexport interface ViteGraphLoaderOptions {\n /** The app's Vite root — the directory its aliases and plugins resolve against. */\n readonly root: string;\n /** Module exporting the graph loader, root-relative (e.g. `/lib/seo/graph.ts`). */\n readonly entry: string;\n /** Named export on `entry` returning `Promise<SeoGraph>`. Defaults to `loadSeoGraph`. */\n readonly exportName?: string | undefined;\n /** Vite plugins the app's module graph needs — a content/MDX plugin, say. */\n readonly plugins?: ReadonlyArray<PluginOption> | undefined;\n /**\n * Bare or virtual module ids to replace with inert source, so a module that\n * only resolves inside the app's server runtime does not break the load.\n */\n readonly stubs?: Readonly<Record<string, string>> | undefined;\n /**\n * Variables to seed on `process.env` before the app's modules parse it. Vite\n * exposes prefixed values through `import.meta.env`, so this is how a module\n * that demands an env var at import time is satisfied. Existing values win —\n * a real `.env` is never clobbered.\n */\n readonly env?: Readonly<Record<string, string>> | undefined;\n}\n\nconst messageOf = (cause: unknown): string =>\n cause instanceof Error ? cause.message : String(cause);\n\n/**\n * Vite and its plugins write progress to stdout. The CLI reserves stdout for the\n * data plane, so redirect it to stderr for the duration of the load.\n *\n * Both the stream method and `console.log`/`info` are swapped: under Bun,\n * `console.log` writes to fd 1 natively rather than going through\n * `process.stdout.write`, so the stream swap alone would miss a plugin that\n * logs through the console.\n */\nconst withCleanStdout = async <A>(run: () => Promise<A>): Promise<A> => {\n const originalWrite = process.stdout.write.bind(process.stdout);\n const originalLog = console.log;\n const originalInfo = console.info;\n process.stdout.write = process.stderr.write.bind(process.stderr) as typeof process.stdout.write;\n console.log = (...args: Array<unknown>) => console.error(...args);\n console.info = (...args: Array<unknown>) => console.error(...args);\n try {\n return await run();\n } finally {\n process.stdout.write = originalWrite;\n console.log = originalLog;\n console.info = originalInfo;\n }\n};\n\n/** Turn `{ id: source }` into a Vite plugin that resolves and loads each id. */\nconst stubPlugin = (stubs: Readonly<Record<string, string>>): PluginOption => {\n const virtualIdOf = (id: string) => `\\0seo-cli-stub:${id}`;\n const sourceByVirtualId = new Map(\n Object.entries(stubs).map(([id, source]) => [virtualIdOf(id), source]),\n );\n return {\n name: \"seo:stubs\",\n resolveId: (id) => (id in stubs ? virtualIdOf(id) : null),\n load: (id) => sourceByVirtualId.get(id) ?? null,\n };\n};\n\nconst seedEnv = (env: Readonly<Record<string, string>>): void => {\n for (const [key, value] of Object.entries(env)) {\n // oxlint-disable-next-line node/no-process-env -- CLI boundary: seeds the raw env BEFORE the app's own env module parses it; that module is the consumer here, not an option\n process.env[key] ??= value;\n }\n};\n\nconst inlineConfigFor = (options: ViteGraphLoaderOptions): InlineConfig => ({\n configFile: false,\n root: options.root,\n mode: \"production\",\n logLevel: \"error\",\n appType: \"custom\",\n clearScreen: false,\n server: { middlewareMode: true, hmr: false, watch: null },\n resolve: { tsconfigPaths: true },\n plugins: [\n ...(options.stubs === undefined ? [] : [stubPlugin(options.stubs)]),\n ...(options.plugins ?? []),\n ],\n});\n\n/**\n * Build a {@link SeoGraphLoader} that evaluates `entry` in a headless Vite\n * server rooted at `root`, and returns what its `exportName` export resolves to.\n */\nexport const viteGraphLoader =\n (options: ViteGraphLoaderOptions): SeoGraphLoader =>\n async () => {\n const exportName = options.exportName ?? \"loadSeoGraph\";\n if (options.env) seedEnv(options.env);\n\n const server = await withCleanStdout(() => createServer(inlineConfigFor(options))).catch(\n (cause: unknown) => {\n throw new Error(`Could not start the Vite loader: ${messageOf(cause)}`);\n },\n );\n\n // The server is a resource from here on: a failed load must still close it,\n // and a successful one hands the close to the caller as `dispose`.\n const graph = await withCleanStdout(async () => {\n const module = (await server.ssrLoadModule(options.entry)) as Record<string, unknown>;\n const load = module[exportName];\n if (typeof load !== \"function\") {\n throw new Error(\n `${options.entry} has no \\`${exportName}\\` export (found: ${Object.keys(module).join(\", \") || \"nothing\"}).`,\n );\n }\n return (await load()) as SeoGraph;\n }).catch(async (cause: unknown) => {\n // Close on the way out, but never let a close failure bury the real\n // error: the reason the graph did not build is the useful one.\n await withCleanStdout(() => server.close()).catch(() => {});\n throw new Error(`Could not build the SEO graph: ${messageOf(cause)}`);\n });\n\n return { graph, dispose: () => withCleanStdout(() => server.close()) };\n };\n","/**\n * `pagegraph/config` — the `pagegraph` CLI's configuration surface.\n *\n * The CLI is a set of pure views over one graph, but *acquiring* that graph is\n * host knowledge: only the app knows where its graph module lives and what its\n * module needs to evaluate. So the app declares it once in a `seo.config.ts` at\n * its root, which the CLI discovers from the working directory:\n *\n * ```ts\n * // seo.config.ts\n * import { defineSeoConfig, viteGraphLoader } from \"pagegraph/config\";\n * import { routeConfig } from \"./lib/route-config\";\n *\n * export default defineSeoConfig({\n * origin: \"https://example.com\",\n * disallow: routeConfig.robotsExclusions,\n * contentSignal: \"search=yes, ai-input=yes, ai-train=yes\",\n * loadGraph: viteGraphLoader({ root: import.meta.dirname, entry: \"/lib/seo/graph.ts\" }),\n * });\n * ```\n *\n * Nothing here imports Effect. The CLI needs it (an optional peer dependency),\n * but a config file must not: it is the app's file, and the app may not be an\n * Effect app.\n */\n\nexport type { LoadedSeoGraph, SeoGraphLoader, ViteGraphLoaderOptions } from \"./vite-graph-loader\";\nexport { viteGraphLoader } from \"./vite-graph-loader\";\n\nimport type { SeoGraphLoader } from \"./vite-graph-loader\";\n\nexport interface SeoCliConfig {\n /**\n * Canonical origin the sitemap and robots projections render under, no\n * trailing slash. The `--origin` flag overrides it per invocation.\n */\n readonly origin: string;\n /**\n * Path prefixes disallowed in robots.txt. Feed it the generated\n * `routeConfig.robotsExclusions` if you run the `pagegraph/vite` plugin.\n */\n readonly disallow: ReadonlyArray<string>;\n /**\n * Origin-wide Content-Signal preferences, forwarded to `renderRobots`.\n * Omit for none. Preview (`--no-indexable`) never emits the line.\n */\n readonly contentSignal?: string | undefined;\n /**\n * Extra robots.txt group lines, forwarded to `renderRobots` as `directives`.\n */\n readonly directives?: ReadonlyArray<string> | undefined;\n /**\n * Last-mile robots.txt override, forwarded to `renderRobots` as `transform`.\n * Runs for indexable and preview hosts.\n */\n readonly transform?: ((robots: string) => string) | undefined;\n /** How the CLI gets the graph. {@link viteGraphLoader} covers the Vite-app case. */\n readonly loadGraph: SeoGraphLoader;\n}\n\n/** Identity — it exists for the type inference and the editor completions. */\nexport const defineSeoConfig = (config: SeoCliConfig): SeoCliConfig => config;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgEA,MAAM,aAAa,UACjB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;;;;;;;;;;AAWvD,MAAM,kBAAkB,OAAU,QAAsC;CACtE,MAAM,gBAAgB,QAAQ,OAAO,MAAM,KAAK,QAAQ,MAAM;CAC9D,MAAM,cAAc,QAAQ;CAC5B,MAAM,eAAe,QAAQ;CAC7B,QAAQ,OAAO,QAAQ,QAAQ,OAAO,MAAM,KAAK,QAAQ,MAAM;CAC/D,QAAQ,OAAO,GAAG,SAAyB,QAAQ,MAAM,GAAG,IAAI;CAChE,QAAQ,QAAQ,GAAG,SAAyB,QAAQ,MAAM,GAAG,IAAI;CACjE,IAAI;EACF,OAAO,MAAM,IAAI;CACnB,UAAU;EACR,QAAQ,OAAO,QAAQ;EACvB,QAAQ,MAAM;EACd,QAAQ,OAAO;CACjB;AACF;;AAGA,MAAM,cAAc,UAA0D;CAC5E,MAAM,eAAe,OAAe,kBAAkB;CACtD,MAAM,oBAAoB,IAAI,IAC5B,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,YAAY,EAAE,GAAG,MAAM,CAAC,CACvE;CACA,OAAO;EACL,MAAM;EACN,YAAY,OAAQ,MAAM,QAAQ,YAAY,EAAE,IAAI;EACpD,OAAO,OAAO,kBAAkB,IAAI,EAAE,KAAK;CAC7C;AACF;AAEA,MAAM,WAAW,QAAgD;CAC/D,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,GAAG,GAE3C,QAAQ,IAAI,SAAS;AAEzB;AAEA,MAAM,mBAAmB,aAAmD;CAC1E,YAAY;CACZ,MAAM,QAAQ;CACd,MAAM;CACN,UAAU;CACV,SAAS;CACT,aAAa;CACb,QAAQ;EAAE,gBAAgB;EAAM,KAAK;EAAO,OAAO;CAAK;CACxD,SAAS,EAAE,eAAe,KAAK;CAC/B,SAAS,CACP,GAAI,QAAQ,UAAU,KAAA,IAAY,CAAC,IAAI,CAAC,WAAW,QAAQ,KAAK,CAAC,GACjE,GAAI,QAAQ,WAAW,CAAC,CAC1B;AACF;;;;;AAMA,MAAa,mBACV,YACD,YAAY;CACV,MAAM,aAAa,QAAQ,cAAc;CACzC,IAAI,QAAQ,KAAK,QAAQ,QAAQ,GAAG;CAEpC,MAAM,SAAS,MAAM,sBAAsB,aAAa,gBAAgB,OAAO,CAAC,CAAC,CAAC,CAAC,OAChF,UAAmB;EAClB,MAAM,IAAI,MAAM,oCAAoC,UAAU,KAAK,GAAG;CACxE,CACF;CAoBA,OAAO;EAAE,OAAA,MAhBW,gBAAgB,YAAY;GAC9C,MAAM,SAAU,MAAM,OAAO,cAAc,QAAQ,KAAK;GACxD,MAAM,OAAO,OAAO;GACpB,IAAI,OAAO,SAAS,YAClB,MAAM,IAAI,MACR,GAAG,QAAQ,MAAM,YAAY,WAAW,oBAAoB,OAAO,KAAK,MAAM,CAAC,CAAC,KAAK,IAAI,KAAK,UAAU,GAC1G;GAEF,OAAQ,MAAM,KAAK;EACrB,CAAC,CAAC,CAAC,MAAM,OAAO,UAAmB;GAGjC,MAAM,sBAAsB,OAAO,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;GAC1D,MAAM,IAAI,MAAM,kCAAkC,UAAU,KAAK,GAAG;EACtE,CAAC;EAEe,eAAe,sBAAsB,OAAO,MAAM,CAAC;CAAE;AACvE;;;;ACrGF,MAAa,mBAAmB,WAAuC"}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../src/config/vite-graph-loader.ts","../src/config/index.ts"],"sourcesContent":["/**\n * A graph loader that evaluates the host app's own graph module inside a\n * headless Vite server.\n *\n * The SEO graph is built *by the app*: its module reads the generated route\n * tree and whatever content collections it owns, so it pulls in the app's real\n * module graph — path aliases, virtual modules from content plugins, bare\n * imports that only exist inside a server runtime. A CLI cannot just `import()`\n * that from Node or Bun.\n *\n * So this boots a scoped, in-process Vite server (middleware mode, no HMR, no\n * watcher, no HTTP listener), `ssrLoadModule`s the app's graph module, and calls\n * its exported loader. The graph comes back as a live in-process object — there\n * is no serialization boundary for the commands to cross — and the server is\n * closed by {@link LoadedSeoGraph.dispose}.\n *\n * Everything host-shaped is an option: the app supplies its own {@link\n * ViteGraphLoaderOptions.plugins} (a content plugin, an MDX loader), {@link\n * ViteGraphLoaderOptions.stubs} for bare modules that only resolve inside its\n * server runtime, and {@link ViteGraphLoaderOptions.env} for variables its\n * modules parse at import. This file knows about none of them.\n */\n\nimport { createServer, type InlineConfig, type PluginOption } from \"vite\";\n\nimport type { SeoGraph } from \"../core/graph\";\n\n/** A graph, plus the release of whatever producing it acquired. */\nexport interface LoadedSeoGraph {\n readonly graph: SeoGraph;\n /** Called once the command is done with the graph, on success or failure. */\n readonly dispose: () => Promise<void>;\n}\n\n/**\n * Produces the SEO graph for the `pagegraph` CLI. A plain promise on purpose: a\n * config file must be writable without Effect, which the CLI keeps behind its\n * `bin` (an optional peer dependency).\n */\nexport type SeoGraphLoader = () => Promise<LoadedSeoGraph>;\n\nexport interface ViteGraphLoaderOptions {\n /** The app's Vite root — the directory its aliases and plugins resolve against. */\n readonly root: string;\n /** Module exporting the graph loader, root-relative (e.g. `/lib/seo/graph.ts`). */\n readonly entry: string;\n /** Named export on `entry` returning `Promise<SeoGraph>`. Defaults to `loadSeoGraph`. */\n readonly exportName?: string | undefined;\n /** Vite plugins the app's module graph needs — a content/MDX plugin, say. */\n readonly plugins?: ReadonlyArray<PluginOption> | undefined;\n /**\n * Bare or virtual module ids to replace with inert source, so a module that\n * only resolves inside the app's server runtime does not break the load.\n */\n readonly stubs?: Readonly<Record<string, string>> | undefined;\n /**\n * Variables to seed on `process.env` before the app's modules parse it. Vite\n * exposes prefixed values through `import.meta.env`, so this is how a module\n * that demands an env var at import time is satisfied. Existing values win —\n * a real `.env` is never clobbered.\n */\n readonly env?: Readonly<Record<string, string>> | undefined;\n}\n\nconst messageOf = (cause: unknown): string =>\n cause instanceof Error ? cause.message : String(cause);\n\n/**\n * Vite and its plugins write progress to stdout. The CLI reserves stdout for the\n * data plane, so redirect it to stderr for the duration of the load.\n *\n * Both the stream method and `console.log`/`info` are swapped: under Bun,\n * `console.log` writes to fd 1 natively rather than going through\n * `process.stdout.write`, so the stream swap alone would miss a plugin that\n * logs through the console.\n */\nconst withCleanStdout = async <A>(run: () => Promise<A>): Promise<A> => {\n const originalWrite = process.stdout.write.bind(process.stdout);\n const originalLog = console.log;\n const originalInfo = console.info;\n process.stdout.write = process.stderr.write.bind(process.stderr) as typeof process.stdout.write;\n console.log = (...args: Array<unknown>) => console.error(...args);\n console.info = (...args: Array<unknown>) => console.error(...args);\n try {\n return await run();\n } finally {\n process.stdout.write = originalWrite;\n console.log = originalLog;\n console.info = originalInfo;\n }\n};\n\n/** Turn `{ id: source }` into a Vite plugin that resolves and loads each id. */\nconst stubPlugin = (stubs: Readonly<Record<string, string>>): PluginOption => {\n const virtualIdOf = (id: string) => `\\0seo-cli-stub:${id}`;\n const sourceByVirtualId = new Map(\n Object.entries(stubs).map(([id, source]) => [virtualIdOf(id), source]),\n );\n return {\n name: \"seo:stubs\",\n resolveId: (id) => (id in stubs ? virtualIdOf(id) : null),\n load: (id) => sourceByVirtualId.get(id) ?? null,\n };\n};\n\nconst seedEnv = (env: Readonly<Record<string, string>>): void => {\n for (const [key, value] of Object.entries(env)) {\n // oxlint-disable-next-line node/no-process-env -- CLI boundary: seeds the raw env BEFORE the app's own env module parses it; that module is the consumer here, not an option\n process.env[key] ??= value;\n }\n};\n\nconst inlineConfigFor = (options: ViteGraphLoaderOptions): InlineConfig => ({\n configFile: false,\n root: options.root,\n mode: \"production\",\n logLevel: \"error\",\n appType: \"custom\",\n clearScreen: false,\n server: { middlewareMode: true, hmr: false, watch: null },\n resolve: { tsconfigPaths: true },\n plugins: [\n ...(options.stubs === undefined ? [] : [stubPlugin(options.stubs)]),\n ...(options.plugins ?? []),\n ],\n});\n\n/**\n * Build a {@link SeoGraphLoader} that evaluates `entry` in a headless Vite\n * server rooted at `root`, and returns what its `exportName` export resolves to.\n */\nexport const viteGraphLoader =\n (options: ViteGraphLoaderOptions): SeoGraphLoader =>\n async () => {\n const exportName = options.exportName ?? \"loadSeoGraph\";\n if (options.env) seedEnv(options.env);\n\n const server = await withCleanStdout(() => createServer(inlineConfigFor(options))).catch(\n (cause: unknown) => {\n throw new Error(`Could not start the Vite loader: ${messageOf(cause)}`);\n },\n );\n\n // The server is a resource from here on: a failed load must still close it,\n // and a successful one hands the close to the caller as `dispose`.\n const graph = await withCleanStdout(async () => {\n const module = (await server.ssrLoadModule(options.entry)) as Record<string, unknown>;\n const load = module[exportName];\n if (typeof load !== \"function\") {\n throw new Error(\n `${options.entry} has no \\`${exportName}\\` export (found: ${Object.keys(module).join(\", \") || \"nothing\"}).`,\n );\n }\n return (await load()) as SeoGraph;\n }).catch(async (cause: unknown) => {\n // Close on the way out, but never let a close failure bury the real\n // error: the reason the graph did not build is the useful one.\n await withCleanStdout(() => server.close()).catch(() => {});\n throw new Error(`Could not build the SEO graph: ${messageOf(cause)}`);\n });\n\n return { graph, dispose: () => withCleanStdout(() => server.close()) };\n };\n","/**\n * `pagegraph/config` — the `pagegraph` CLI's configuration surface.\n *\n * The CLI is a set of pure views over one graph, but *acquiring* that graph is\n * host knowledge: only the app knows where its graph module lives and what its\n * module needs to evaluate. So the app declares it once in a `seo.config.ts` at\n * its root, which the CLI discovers from the working directory:\n *\n * ```ts\n * // seo.config.ts\n * import { defineSeoConfig, viteGraphLoader } from \"pagegraph/config\";\n * import { routeConfig } from \"./lib/route-config\";\n *\n * export default defineSeoConfig({\n * origin: \"https://example.com\",\n * disallow: routeConfig.robotsExclusions,\n * contentSignal: \"search=yes, ai-input=yes, ai-train=yes\",\n * loadGraph: viteGraphLoader({ root: import.meta.dirname, entry: \"/lib/seo/graph.ts\" }),\n * });\n * ```\n *\n * Nothing here imports Effect. The CLI needs it (an optional peer dependency),\n * but a config file must not: it is the app's file, and the app may not be an\n * Effect app.\n */\n\nexport type { LoadedSeoGraph, SeoGraphLoader, ViteGraphLoaderOptions } from \"./vite-graph-loader\";\nexport { viteGraphLoader } from \"./vite-graph-loader\";\n\nimport type { CoverageRule } from \"../core/checks\";\nimport type { SeoGraphLoader } from \"./vite-graph-loader\";\n\nexport interface SeoCliConfig {\n /**\n * Canonical origin the sitemap and robots projections render under, no\n * trailing slash. The `--origin` flag overrides it per invocation.\n */\n readonly origin: string;\n /**\n * Path prefixes disallowed in robots.txt. Feed it the generated\n * `routeConfig.robotsExclusions` if you run the `pagegraph/vite` plugin.\n */\n readonly disallow: ReadonlyArray<string>;\n /**\n * Origin-wide Content-Signal preferences, forwarded to `renderRobots`.\n * Omit for none. Preview (`--no-indexable`) never emits the line.\n */\n readonly contentSignal?: string | undefined;\n /**\n * Extra robots.txt group lines, forwarded to `renderRobots` as `directives`.\n */\n readonly directives?: ReadonlyArray<string> | undefined;\n /**\n * Last-mile robots.txt override, forwarded to `renderRobots` as `transform`.\n * Runs for indexable and preview hosts.\n */\n readonly transform?: ((robots: string) => string) | undefined;\n /**\n * Contextual-link coverage policy for `pagegraph check`: every sitemap-eligible\n * page matching a rule's `path` glob needs at least `minInbound` incoming\n * `related` edges. A `--require-inbound` flag overrides this per invocation.\n */\n readonly coverage?: ReadonlyArray<CoverageRule> | undefined;\n /** How the CLI gets the graph. {@link viteGraphLoader} covers the Vite-app case. */\n readonly loadGraph: SeoGraphLoader;\n}\n\n/** Identity — it exists for the type inference and the editor completions. */\nexport const defineSeoConfig = (config: SeoCliConfig): SeoCliConfig => config;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgEA,MAAM,aAAa,UACjB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;;;;;;;;;;AAWvD,MAAM,kBAAkB,OAAU,QAAsC;CACtE,MAAM,gBAAgB,QAAQ,OAAO,MAAM,KAAK,QAAQ,MAAM;CAC9D,MAAM,cAAc,QAAQ;CAC5B,MAAM,eAAe,QAAQ;CAC7B,QAAQ,OAAO,QAAQ,QAAQ,OAAO,MAAM,KAAK,QAAQ,MAAM;CAC/D,QAAQ,OAAO,GAAG,SAAyB,QAAQ,MAAM,GAAG,IAAI;CAChE,QAAQ,QAAQ,GAAG,SAAyB,QAAQ,MAAM,GAAG,IAAI;CACjE,IAAI;EACF,OAAO,MAAM,IAAI;CACnB,UAAU;EACR,QAAQ,OAAO,QAAQ;EACvB,QAAQ,MAAM;EACd,QAAQ,OAAO;CACjB;AACF;;AAGA,MAAM,cAAc,UAA0D;CAC5E,MAAM,eAAe,OAAe,kBAAkB;CACtD,MAAM,oBAAoB,IAAI,IAC5B,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,YAAY,EAAE,GAAG,MAAM,CAAC,CACvE;CACA,OAAO;EACL,MAAM;EACN,YAAY,OAAQ,MAAM,QAAQ,YAAY,EAAE,IAAI;EACpD,OAAO,OAAO,kBAAkB,IAAI,EAAE,KAAK;CAC7C;AACF;AAEA,MAAM,WAAW,QAAgD;CAC/D,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,GAAG,GAE3C,QAAQ,IAAI,SAAS;AAEzB;AAEA,MAAM,mBAAmB,aAAmD;CAC1E,YAAY;CACZ,MAAM,QAAQ;CACd,MAAM;CACN,UAAU;CACV,SAAS;CACT,aAAa;CACb,QAAQ;EAAE,gBAAgB;EAAM,KAAK;EAAO,OAAO;CAAK;CACxD,SAAS,EAAE,eAAe,KAAK;CAC/B,SAAS,CACP,GAAI,QAAQ,UAAU,KAAA,IAAY,CAAC,IAAI,CAAC,WAAW,QAAQ,KAAK,CAAC,GACjE,GAAI,QAAQ,WAAW,CAAC,CAC1B;AACF;;;;;AAMA,MAAa,mBACV,YACD,YAAY;CACV,MAAM,aAAa,QAAQ,cAAc;CACzC,IAAI,QAAQ,KAAK,QAAQ,QAAQ,GAAG;CAEpC,MAAM,SAAS,MAAM,sBAAsB,aAAa,gBAAgB,OAAO,CAAC,CAAC,CAAC,CAAC,OAChF,UAAmB;EAClB,MAAM,IAAI,MAAM,oCAAoC,UAAU,KAAK,GAAG;CACxE,CACF;CAoBA,OAAO;EAAE,OAAA,MAhBW,gBAAgB,YAAY;GAC9C,MAAM,SAAU,MAAM,OAAO,cAAc,QAAQ,KAAK;GACxD,MAAM,OAAO,OAAO;GACpB,IAAI,OAAO,SAAS,YAClB,MAAM,IAAI,MACR,GAAG,QAAQ,MAAM,YAAY,WAAW,oBAAoB,OAAO,KAAK,MAAM,CAAC,CAAC,KAAK,IAAI,KAAK,UAAU,GAC1G;GAEF,OAAQ,MAAM,KAAK;EACrB,CAAC,CAAC,CAAC,MAAM,OAAO,UAAmB;GAGjC,MAAM,sBAAsB,OAAO,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;GAC1D,MAAM,IAAI,MAAM,kCAAkC,UAAU,KAAK,GAAG;EACtE,CAAC;EAEe,eAAe,sBAAsB,OAAO,MAAM,CAAC;CAAE;AACvE;;;;AC9FF,MAAa,mBAAmB,WAAuC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as SeoGraph, c as SeoSource, d as Register, f as RouteSeo, i as SeoEdgeType, l as buildSeoGraph, m as SitemapPolicy, n as SeoCollection, o as SeoInstance, p as SeoKind, r as SeoEdge, s as SeoNode, t as BuildSeoGraphInput, u as PublicPath } from "./graph-BlLoEOw2.js";
1
+ import { A as RenderedGraph, C as AnchorRegion, D as RenderedEdgeArtifact, E as RENDERED_EDGE_ARTIFACT_SCHEMA_VERSION, F as diffLinkGraph, I as extractAnchors, L as normalizePath, M as SimpleEdge, N as buildRenderedGraph, O as RenderedEdgeArtifactCrawl, P as decodeRenderedEdgeArtifact, R as renderedGraphFromEdges, S as Anchor, T as LinkGraphDiff, _ as PublicPath, a as checkGraph, b as SeoKind, c as BuildSeoGraphInput, d as SeoEdgeType, f as SeoGraph, g as buildSeoGraph, h as SeoSource, i as checkCoverage, j as RenderedPage, k as RenderedEdgeFailure, l as SeoCollection, m as SeoNode, n as Severity, o as checkRenderedCoverage, p as SeoInstance, r as Violation, s as hasStructuralViolations, t as CoverageRule, u as SeoEdge, v as Register, w as LinkEdge, x as SitemapPolicy, y as RouteSeo } from "./checks-6noG_xTS.js";
2
2
  import { AnyRouter } from "@tanstack/react-router";
3
3
  //#region src/core/projections.d.ts
4
4
  interface ProjectionConfig {
@@ -35,6 +35,12 @@ interface NodeReport {
35
35
  incoming: Array<SeoEdge>;
36
36
  outgoing: Array<SeoEdge>;
37
37
  }
38
+ /**
39
+ * A node belongs in the sitemap when it declares a positive sitemap policy, is not
40
+ * a redirect, is not robots-noindexed, and is not a param template (a route whose
41
+ * path still contains a `$` segment — those exist only so their instances inherit).
42
+ */
43
+ declare function isSitemapEligible(node: SeoNode): boolean;
38
44
  /**
39
45
  * Render sitemap.xml from the graph. Structural route entries emit no `<lastmod>`
40
46
  * (a route has no publish date); content instances emit it from their frontmatter.
@@ -62,19 +68,57 @@ declare function renderRobots(_graph: SeoGraph, cfg: RobotsConfig): string;
62
68
  /** Inspect a single node: its declaration, sitemap eligibility, and edges. */
63
69
  declare function inspectNode(graph: SeoGraph, path: string): NodeReport | undefined;
64
70
  //#endregion
65
- //#region src/core/checks.d.ts
66
- type Severity = "structural" | "editorial";
67
- interface Violation {
68
- severity: Severity;
69
- rule: string;
70
- path?: string | undefined;
71
- message: string;
72
- fix?: string | undefined;
71
+ //#region src/core/link-candidates.d.ts
72
+ /** One proposed contextual link, in the direction the link would be authored. */
73
+ interface LinkCandidatePair {
74
+ readonly source: string;
75
+ readonly destination: string;
76
+ /** The cluster the pair shares: a top-level section, or `kind:<kind>`. */
77
+ readonly cluster: string;
78
+ /** Why the pair is plausible, e.g. `same top-level section "/blog"`. */
79
+ readonly reason: string;
80
+ }
81
+ interface LinkCandidateOptions {
82
+ /** Maximum candidates to return after ordering (default 50). */
83
+ readonly limit?: number;
84
+ /** Restrict to these clusters; a filter may be a section or a bare kind. */
85
+ readonly clusters?: ReadonlyArray<string>;
86
+ /** Anchors already served in HTML; their pairs are excluded when supplied. */
87
+ readonly renderedEdges?: ReadonlyArray<SimpleEdge>;
88
+ }
89
+ /** One cluster and how many candidate pairs it contributes (before `limit`). */
90
+ interface LinkClusterSummary {
91
+ readonly key: string;
92
+ readonly candidates: number;
93
+ }
94
+ interface LinkCandidateResult {
95
+ readonly candidates: ReadonlyArray<LinkCandidatePair>;
96
+ /** Candidate pairs before `limit` was applied (after cluster filters). */
97
+ readonly total: number;
98
+ readonly truncated: boolean;
99
+ readonly clusters: ReadonlyArray<LinkClusterSummary>;
73
100
  }
74
- /** Run every rule against the graph and return the flat list of violations. */
75
- declare function checkGraph(graph: SeoGraph): Array<Violation>;
76
- /** Structural violations fail `pagegraph check`; editorial-only stays green. */
77
- declare const hasStructuralViolations: (violations: ReadonlyArray<Violation>) => boolean;
101
+ /** Directionless pair key, so an edge in either direction means "connected". */
102
+ declare const undirectedEdgeKey: (from: string, to: string) => string;
103
+ /** A `--cluster` filter matches a section by name, or a kind via its bare label. */
104
+ declare const matchesClusterFilter: (cluster: string, filter: string) => boolean;
105
+ /** Human reason string for a candidate's source page, used when handing a plan to Jev. */
106
+ declare const candidateSourceText: (node: SeoNode) => string;
107
+ /**
108
+ * Enumerate reviewable contextual-link candidates from the declared graph.
109
+ *
110
+ * Excluded: self-pairs, pages that are not sitemap-eligible, pairs already
111
+ * declared as a `related` edge, and — when {@link LinkCandidateOptions.renderedEdges}
112
+ * is supplied — pairs already rendered as an anchor. Queries, hashes, and
113
+ * trailing slashes are normalized so both sides compare by the graph's path key.
114
+ */
115
+ declare const generateLinkCandidates: (graph: SeoGraph, options?: LinkCandidateOptions) => LinkCandidateResult;
116
+ /**
117
+ * Decode a rendered-edge dump supplied to the CLI: either a bare array of
118
+ * `{ from, to }` edges, or an object carrying `edges` (or `internalEdges`).
119
+ * Throws on any other shape — this is user input, not a provider payload.
120
+ */
121
+ declare const decodeRenderedEdges: (input: unknown) => ReadonlyArray<SimpleEdge>;
78
122
  //#endregion
79
123
  //#region src/core/inspect-html.d.ts
80
124
  /**
@@ -137,5 +181,5 @@ declare const hasBlockingIssues: (report: LiveHeadReport) => boolean;
137
181
  */
138
182
  declare function resolveRouteLink(router: AnyRouter, path: string): RouteSeo["link"];
139
183
  //#endregion
140
- export { type BuildSeoGraphInput, type JsonLdReport, type LiveHeadReport, type NodeReport, type ProjectionConfig, type PublicPath, type Register, type RobotsConfig, type RouteSeo, type SeoCollection, type SeoEdge, type SeoEdgeType, type SeoGraph, type SeoInstance, type SeoKind, type SeoNode, type SeoSource, type Severity, type SitemapPolicy, type Violation, buildSeoGraph, checkGraph, contentSignal, hasBlockingIssues, hasStructuralViolations, inspectHtml, inspectNode, renderRobots, renderSitemap, resolveRouteLink };
184
+ export { type Anchor, type AnchorRegion, type BuildSeoGraphInput, type CoverageRule, type JsonLdReport, type LinkCandidateOptions, type LinkCandidatePair, type LinkCandidateResult, type LinkClusterSummary, type LinkEdge, type LinkGraphDiff, type LiveHeadReport, type NodeReport, type ProjectionConfig, type PublicPath, RENDERED_EDGE_ARTIFACT_SCHEMA_VERSION, type Register, type RenderedEdgeArtifact, type RenderedEdgeArtifactCrawl, type RenderedEdgeFailure, type RenderedGraph, type RenderedPage, type RobotsConfig, type RouteSeo, type SeoCollection, type SeoEdge, type SeoEdgeType, type SeoGraph, type SeoInstance, type SeoKind, type SeoNode, type SeoSource, type Severity, type SimpleEdge, type SitemapPolicy, type Violation, buildRenderedGraph, buildSeoGraph, candidateSourceText, checkCoverage, checkGraph, checkRenderedCoverage, contentSignal, decodeRenderedEdgeArtifact, decodeRenderedEdges, diffLinkGraph, extractAnchors, generateLinkCandidates, hasBlockingIssues, hasStructuralViolations, inspectHtml, inspectNode, isSitemapEligible, matchesClusterFilter, normalizePath, renderRobots, renderSitemap, renderedGraphFromEdges, resolveRouteLink, undirectedEdgeKey };
141
185
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { a as extractAnchors, i as diffLinkGraph, n as buildRenderedGraph, o as normalizePath, r as decodeRenderedEdgeArtifact, s as renderedGraphFromEdges, t as RENDERED_EDGE_ARTIFACT_SCHEMA_VERSION } from "./links-BFJc-pJ9.js";
1
2
  //#region src/core/graph.ts
2
3
  /** Kind for instances whose collection route carries no declaration to inherit. */
3
4
  const FALLBACK_KIND = "page";
@@ -425,19 +426,220 @@ const CHECK_RULES = [
425
426
  })
426
427
  }
427
428
  ];
428
- /** Run every rule against the graph and return the flat list of violations. */
429
- function checkGraph(graph) {
430
- return CHECK_RULES.flatMap((rule) => rule.evaluate(graph).map((raw) => ({
429
+ /**
430
+ * Run every static rule against the graph, then any caller-supplied
431
+ * {@link CoverageRule}s, and return the flat list of violations. With no
432
+ * `coverage` option the result is exactly the static rule set.
433
+ */
434
+ function checkGraph(graph, options = {}) {
435
+ const violations = CHECK_RULES.flatMap((rule) => rule.evaluate(graph).map((raw) => ({
431
436
  severity: rule.severity,
432
437
  rule: rule.name,
433
438
  path: raw.path,
434
439
  message: raw.message,
435
440
  fix: raw.fix
436
441
  })));
442
+ const coverage = options.coverage;
443
+ if (coverage !== void 0 && coverage.length > 0) violations.push(...checkCoverage(graph, coverage));
444
+ return violations;
445
+ }
446
+ /** Escape a glob for `RegExp`, then expand `**`, `*`, and `?` to path-aware forms. */
447
+ const globToRegExp = (glob) => {
448
+ const source = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "\0").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(/\u0000/g, ".*");
449
+ return new RegExp(`^${source}$`);
450
+ };
451
+ /**
452
+ * Enforce contextual-link coverage rules over an explicit surface.
453
+ *
454
+ * A rule that matches no sitemap-eligible page is itself a violation: a typo or
455
+ * a rule aimed at a noindex page would otherwise pass silently forever.
456
+ */
457
+ const checkCoverageRules = (surface, rules) => {
458
+ const violations = [];
459
+ for (const rule of rules) {
460
+ const matcher = globToRegExp(rule.path);
461
+ const matched = surface.paths.filter((path) => matcher.test(path));
462
+ const eligible = surface.eligiblePaths.filter((path) => matcher.test(path));
463
+ if (eligible.length === 0) {
464
+ violations.push({
465
+ severity: "structural",
466
+ rule: "coverage-rule-unmatched",
467
+ message: matched.length === 0 ? `Coverage rule "${rule.path}" matches no page in the graph.` : `Coverage rule "${rule.path}" matches only pages that are not sitemap-eligible.`,
468
+ fix: "Point the rule at a sitemap-eligible path, or drop it."
469
+ });
470
+ continue;
471
+ }
472
+ for (const path of eligible) {
473
+ const inbound = surface.inbound(path);
474
+ if (inbound >= rule.minInbound) continue;
475
+ violations.push({
476
+ severity: "structural",
477
+ rule: "inbound-link-coverage",
478
+ path,
479
+ message: `"${path}" has ${inbound} incoming contextual link(s); the coverage rule requires ${rule.minInbound}.`,
480
+ fix: `Add ${rule.minInbound - inbound} contextual link(s) pointing at "${path}".`
481
+ });
482
+ }
483
+ }
484
+ return violations;
485
+ };
486
+ /** The sitemap-eligible path set of a declared graph, in graph insertion order. */
487
+ const eligiblePathsOf = (graph) => [...graph.nodes.values()].filter(isSitemapEligible).map((node) => node.path);
488
+ /**
489
+ * Enforce contextual-link coverage against the *declared* graph: only `related`
490
+ * edges count — breadcrumb ancestry is navigation, not context.
491
+ */
492
+ function checkCoverage(graph, rules) {
493
+ return checkCoverageRules({
494
+ paths: [...graph.nodes.keys()],
495
+ eligiblePaths: eligiblePathsOf(graph),
496
+ inbound: (path) => graph.edges.filter((edge) => edge.type === "related" && edge.to === path).length
497
+ }, rules);
498
+ }
499
+ /**
500
+ * Enforce contextual-link coverage against the *rendered* graph: only same-origin
501
+ * body-region anchors count. Nav, header, and footer anchors are site chrome, so
502
+ * a page linked solely from them has no contextual inbound link — the same
503
+ * distinction the declared pass draws by counting `related` edges alone.
504
+ *
505
+ * The target universe is the declared graph's sitemap-eligible pages: the globs
506
+ * in `seo.config.ts` are written against declared paths, and the crawl is what
507
+ * supplies the served edges. Pass the crawl's `internalEdges` (each edge carries
508
+ * its `region`).
509
+ */
510
+ function checkRenderedCoverage(graph, renderedEdges, rules) {
511
+ const inbound = /* @__PURE__ */ new Map();
512
+ for (const edge of renderedEdges) {
513
+ if (edge.region !== "body") continue;
514
+ inbound.set(edge.to, (inbound.get(edge.to) ?? 0) + 1);
515
+ }
516
+ return checkCoverageRules({
517
+ paths: [...graph.nodes.keys()],
518
+ eligiblePaths: eligiblePathsOf(graph),
519
+ inbound: (path) => inbound.get(path) ?? 0
520
+ }, rules);
437
521
  }
438
522
  /** Structural violations fail `pagegraph check`; editorial-only stays green. */
439
523
  const hasStructuralViolations = (violations) => violations.some((violation) => violation.severity === "structural");
440
524
  //#endregion
525
+ //#region src/core/link-candidates.ts
526
+ /**
527
+ * Canonical path key: query and hash stripped, trailing slashes removed, "/"
528
+ * preserved. This is the same path key the graph and the rendered-link core
529
+ * use, so a served anchor like `/blog/a?ref=nav` still matches the graph pair
530
+ * `/blog/a`.
531
+ */
532
+ const normalize = (path) => {
533
+ const trimmed = (path.split(/[?#]/, 1)[0] ?? "").replace(/\/+$/, "");
534
+ return trimmed === "" ? "/" : trimmed;
535
+ };
536
+ /** Directionless pair key, so an edge in either direction means "connected". */
537
+ const undirectedEdgeKey = (from, to) => {
538
+ const [a, b] = [normalize(from), normalize(to)].sort();
539
+ return `${a}\u0000${b}`;
540
+ };
541
+ /** First path segment, or undefined for the root page. */
542
+ const topSegment = (path) => {
543
+ const segment = path.split("/").filter(Boolean)[0];
544
+ return segment === void 0 || segment === "" ? void 0 : segment;
545
+ };
546
+ /** A page with no nested segment (`/`, `/pricing`, `/blog`) is root-level. */
547
+ const isRootLevel = (path) => path.split("/").filter(Boolean).length <= 1;
548
+ /**
549
+ * The cluster a pair shares, or undefined when they share none. Section-first:
550
+ * a shared top-level section wins. The kind fallback is local to root-level
551
+ * pages, so it never pairs two nested pages from different sections.
552
+ */
553
+ const clusterOf = (a, b) => {
554
+ const aSegment = topSegment(a.path);
555
+ const bSegment = topSegment(b.path);
556
+ if (aSegment !== void 0 && aSegment === bSegment) return {
557
+ key: aSegment,
558
+ reason: `same top-level section "/${aSegment}"`
559
+ };
560
+ if (isRootLevel(a.path) && isRootLevel(b.path) && a.kind === b.kind) return {
561
+ key: `kind:${a.kind}`,
562
+ reason: `same kind "${a.kind}"`
563
+ };
564
+ };
565
+ /** A `--cluster` filter matches a section by name, or a kind via its bare label. */
566
+ const matchesClusterFilter = (cluster, filter) => {
567
+ const normalized = filter.replace(/^\/+/, "").toLowerCase();
568
+ const key = cluster.toLowerCase();
569
+ return key === normalized || key === `kind:${normalized}`;
570
+ };
571
+ /** Human reason string for a candidate's source page, used when handing a plan to Jev. */
572
+ const candidateSourceText = (node) => node.instance?.description?.trim() || node.instance?.title?.trim() || node.policy.link?.description?.trim() || node.policy.link?.title?.trim() || node.path;
573
+ /**
574
+ * Enumerate reviewable contextual-link candidates from the declared graph.
575
+ *
576
+ * Excluded: self-pairs, pages that are not sitemap-eligible, pairs already
577
+ * declared as a `related` edge, and — when {@link LinkCandidateOptions.renderedEdges}
578
+ * is supplied — pairs already rendered as an anchor. Queries, hashes, and
579
+ * trailing slashes are normalized so both sides compare by the graph's path key.
580
+ */
581
+ const generateLinkCandidates = (graph, options = {}) => {
582
+ const limit = options.limit ?? 50;
583
+ const filters = options.clusters ?? [];
584
+ const rendered = new Set((options.renderedEdges ?? []).map((edge) => undirectedEdgeKey(edge.from, edge.to)));
585
+ const declared = new Set(graph.edges.filter((edge) => edge.type === "related").map((edge) => undirectedEdgeKey(edge.from, edge.to)));
586
+ const eligible = [...graph.nodes.values()].filter(isSitemapEligible);
587
+ const all = [];
588
+ for (let i = 0; i < eligible.length; i++) for (let j = i + 1; j < eligible.length; j++) {
589
+ const a = eligible[i];
590
+ const b = eligible[j];
591
+ const cluster = clusterOf(a, b);
592
+ if (cluster === void 0) continue;
593
+ if (filters.length > 0 && !filters.some((filter) => matchesClusterFilter(cluster.key, filter))) continue;
594
+ const key = undirectedEdgeKey(a.path, b.path);
595
+ if (declared.has(key) || rendered.has(key)) continue;
596
+ all.push({
597
+ source: a.path,
598
+ destination: b.path,
599
+ cluster: cluster.key,
600
+ reason: cluster.reason
601
+ });
602
+ all.push({
603
+ source: b.path,
604
+ destination: a.path,
605
+ cluster: cluster.key,
606
+ reason: cluster.reason
607
+ });
608
+ }
609
+ const compare = (x, y) => x.cluster < y.cluster ? -1 : x.cluster > y.cluster ? 1 : x.source < y.source ? -1 : x.source > y.source ? 1 : x.destination < y.destination ? -1 : x.destination > y.destination ? 1 : 0;
610
+ all.sort(compare);
611
+ const counts = /* @__PURE__ */ new Map();
612
+ for (const pair of all) counts.set(pair.cluster, (counts.get(pair.cluster) ?? 0) + 1);
613
+ const candidates = all.slice(0, limit);
614
+ return {
615
+ candidates,
616
+ total: all.length,
617
+ truncated: all.length > candidates.length,
618
+ clusters: [...counts.entries()].map(([key, count]) => ({
619
+ key,
620
+ candidates: count
621
+ }))
622
+ };
623
+ };
624
+ /**
625
+ * Decode a rendered-edge dump supplied to the CLI: either a bare array of
626
+ * `{ from, to }` edges, or an object carrying `edges` (or `internalEdges`).
627
+ * Throws on any other shape — this is user input, not a provider payload.
628
+ */
629
+ const decodeRenderedEdges = (input) => {
630
+ const array = Array.isArray(input) ? input : input !== null && typeof input === "object" && Array.isArray(input.edges) ? input.edges : input !== null && typeof input === "object" && Array.isArray(input.internalEdges) ? input.internalEdges : void 0;
631
+ if (array === void 0) throw new Error("expected an array of { from, to } edges, or an object with an `edges` array");
632
+ return array.map((item) => {
633
+ if (item === null || typeof item !== "object") throw new Error("each rendered edge must be an object with string `from` and `to`");
634
+ const { from, to } = item;
635
+ if (typeof from !== "string" || typeof to !== "string") throw new Error("each rendered edge must have string `from` and `to`");
636
+ return {
637
+ from,
638
+ to
639
+ };
640
+ });
641
+ };
642
+ //#endregion
441
643
  //#region src/core/inspect-html.ts
442
644
  const ENTITIES = {
443
645
  "&amp;": "&",
@@ -603,6 +805,6 @@ function resolveRouteLink(router, path) {
603
805
  return Object.values(routesById).find((route) => route.fullPath === path)?.options.staticData?.seo?.link;
604
806
  }
605
807
  //#endregion
606
- export { buildSeoGraph, checkGraph, contentSignal, hasBlockingIssues, hasStructuralViolations, inspectHtml, inspectNode, renderRobots, renderSitemap, resolveRouteLink };
808
+ export { RENDERED_EDGE_ARTIFACT_SCHEMA_VERSION, buildRenderedGraph, buildSeoGraph, candidateSourceText, checkCoverage, checkGraph, checkRenderedCoverage, contentSignal, decodeRenderedEdgeArtifact, decodeRenderedEdges, diffLinkGraph, extractAnchors, generateLinkCandidates, hasBlockingIssues, hasStructuralViolations, inspectHtml, inspectNode, isSitemapEligible, matchesClusterFilter, normalizePath, renderRobots, renderSitemap, renderedGraphFromEdges, resolveRouteLink, undirectedEdgeKey };
607
809
 
608
810
  //# sourceMappingURL=index.js.map