nuxt-ai-ready 2.5.0 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/agent-skills.mjs +1 -1
- package/dist/chunks/prerender.mjs +1 -1
- package/dist/cli.mjs +2 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/server/db/drizzle/queries.js +0 -1
- package/dist/runtime/server/db/queries.d.ts +2 -0
- package/dist/runtime/server/db/queries.js +11 -5
- package/dist/runtime/server/db/seed.d.ts +2 -2
- package/dist/runtime/server/routes/__ai-ready/reindex.post.js +2 -0
- package/dist/runtime/server/utils/batchIndex.js +4 -2
- package/dist/runtime/server/utils/checkStale.d.ts +1 -1
- package/dist/runtime/server/utils/checkStale.js +1 -1
- package/dist/runtime/server/utils/indexPage.d.ts +8 -1
- package/dist/runtime/server/utils/indexPage.js +13 -5
- package/dist/shared/{nuxt-ai-ready.DsokNmXc.mjs → nuxt-ai-ready.CLSWou20.mjs} +2 -0
- package/node_modules/@mdream/js/LICENSE.md +9 -0
- package/node_modules/@mdream/js/README.md +792 -0
- package/node_modules/@mdream/js/bin/mdream.mjs +2 -0
- package/node_modules/@mdream/js/dist/_chunks/const.mjs +134 -0
- package/node_modules/@mdream/js/dist/_chunks/index.d.mts +9 -0
- package/node_modules/@mdream/js/dist/_chunks/markdown-processor.mjs +1968 -0
- package/node_modules/@mdream/js/dist/_chunks/minimal.d.mts +6 -0
- package/node_modules/@mdream/js/dist/_chunks/parse.mjs +2756 -0
- package/node_modules/@mdream/js/dist/_chunks/plugins.mjs +725 -0
- package/node_modules/@mdream/js/dist/_chunks/resolve-plugins.mjs +44 -0
- package/node_modules/@mdream/js/dist/_chunks/stream.mjs +37 -0
- package/node_modules/@mdream/js/dist/_chunks/types.d.mts +473 -0
- package/node_modules/@mdream/js/dist/cli.d.mts +1 -0
- package/node_modules/@mdream/js/dist/cli.mjs +32 -0
- package/node_modules/@mdream/js/dist/core.d.mts +15 -0
- package/node_modules/@mdream/js/dist/core.mjs +28 -0
- package/node_modules/@mdream/js/dist/index.d.mts +4 -0
- package/node_modules/@mdream/js/dist/index.mjs +58 -0
- package/node_modules/@mdream/js/dist/llms-txt.d.mts +86 -0
- package/node_modules/@mdream/js/dist/llms-txt.mjs +308 -0
- package/node_modules/@mdream/js/dist/negotiate.d.mts +35 -0
- package/node_modules/@mdream/js/dist/negotiate.mjs +121 -0
- package/node_modules/@mdream/js/dist/parse.d.mts +90 -0
- package/node_modules/@mdream/js/dist/parse.mjs +2 -0
- package/node_modules/@mdream/js/dist/plugins.d.mts +85 -0
- package/node_modules/@mdream/js/dist/plugins.mjs +2 -0
- package/node_modules/@mdream/js/dist/preset/minimal.d.mts +2 -0
- package/node_modules/@mdream/js/dist/preset/minimal.mjs +33 -0
- package/node_modules/@mdream/js/dist/splitter.d.mts +18 -0
- package/node_modules/@mdream/js/dist/splitter.mjs +194 -0
- package/node_modules/@mdream/js/package.json +103 -0
- package/node_modules/cac/LICENSE +21 -0
- package/node_modules/cac/README.md +492 -0
- package/node_modules/cac/dist/index.d.ts +196 -0
- package/node_modules/cac/dist/index.js +638 -0
- package/node_modules/cac/package.json +72 -0
- package/node_modules/mdream/LICENSE.md +9 -0
- package/node_modules/mdream/README.md +1091 -0
- package/node_modules/mdream/bin/mdream.mjs +46 -0
- package/node_modules/mdream/dist/browser.d.mts +105 -0
- package/node_modules/mdream/dist/browser.mjs +262 -0
- package/node_modules/mdream/dist/edge.d.mts +100 -0
- package/node_modules/mdream/dist/edge.mjs +250 -0
- package/node_modules/mdream/dist/iife.js +605 -0
- package/node_modules/mdream/dist/index.d.mts +89 -0
- package/node_modules/mdream/dist/index.mjs +184 -0
- package/node_modules/mdream/dist/wasm.d.mts +100 -0
- package/node_modules/mdream/dist/wasm.mjs +140 -0
- package/node_modules/mdream/dist/worker.d.mts +101 -0
- package/node_modules/mdream/dist/worker.mjs +217 -0
- package/node_modules/mdream/napi/index.d.mts +127 -0
- package/node_modules/mdream/napi/index.d.ts +127 -0
- package/node_modules/mdream/napi/index.mjs +725 -0
- package/node_modules/mdream/napi/rust.android-arm-eabi.node +0 -0
- package/node_modules/mdream/napi/rust.android-arm64.node +0 -0
- package/node_modules/mdream/napi/rust.darwin-arm64.node +0 -0
- package/node_modules/mdream/napi/rust.darwin-x64.node +0 -0
- package/node_modules/mdream/napi/rust.freebsd-x64.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm-gnueabihf.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm64-gnu.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm64-musl.node +0 -0
- package/node_modules/mdream/napi/rust.linux-x64-gnu.node +0 -0
- package/node_modules/mdream/napi/rust.linux-x64-musl.node +0 -0
- package/node_modules/mdream/napi/rust.wasi.cjs +2144 -0
- package/node_modules/mdream/napi/rust.wasm32-wasi.wasm +0 -0
- package/node_modules/mdream/napi/rust.win32-arm64-msvc.node +0 -0
- package/node_modules/mdream/napi/rust.win32-x64-msvc.node +0 -0
- package/node_modules/mdream/node_modules/@emnapi/core/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@emnapi/core/README.md +1 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.d.ts +392 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.d.ts +392 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.js +8351 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.js +7268 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.d.ts +5 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.js +843 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.d.ts +4 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.js +3 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.d.ts +5 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.js +1010 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.d.ts +5 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.js +1446 -0
- package/node_modules/mdream/node_modules/@emnapi/core/package.json +39 -0
- package/node_modules/mdream/node_modules/@emnapi/core/rollup.config.js +60 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/README.md +1 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.d.ts +833 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js +2306 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js.map +1 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/index.cjs +63 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/package.json +39 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/rollup.config.js +25 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/README.md +203 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +236 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +1086 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/package.json +35 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/rollup.config.js +6 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.cjs +1472 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.js +1470 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +237 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs.js +18260 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +317 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/package.json +67 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.cjs +39 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.js +36 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/README.md +193 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/tsdoc-metadata.json +11 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +423 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +2932 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +2932 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.js +2954 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/asyncify.js +158 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/index.js +13 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/jspi.js +46 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/load.js +97 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/memory.js +35 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/error.js +103 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fd.js +268 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fs.js +3 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +192 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +316 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +1599 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/rights.js +141 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/types.js +220 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/util.js +128 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/webassembly.js +13 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/asyncify.mjs +153 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/index.mjs +9 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/jspi.mjs +39 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/load.mjs +89 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/memory.mjs +28 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/error.mjs +97 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fd.mjs +256 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fs.mjs +1 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +186 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +310 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +1593 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/rights.mjs +135 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/types.mjs +216 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/util.mjs +113 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/webassembly.mjs +9 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/package.json +58 -0
- package/node_modules/mdream/node_modules/tslib/CopyrightNotice.txt +15 -0
- package/node_modules/mdream/node_modules/tslib/LICENSE.txt +12 -0
- package/node_modules/mdream/node_modules/tslib/README.md +164 -0
- package/node_modules/mdream/node_modules/tslib/SECURITY.md +41 -0
- package/node_modules/mdream/node_modules/tslib/modules/index.d.ts +38 -0
- package/node_modules/mdream/node_modules/tslib/modules/index.js +70 -0
- package/node_modules/mdream/node_modules/tslib/modules/package.json +3 -0
- package/node_modules/mdream/node_modules/tslib/package.json +47 -0
- package/node_modules/mdream/node_modules/tslib/tslib.d.ts +460 -0
- package/node_modules/mdream/node_modules/tslib/tslib.es6.html +1 -0
- package/node_modules/mdream/node_modules/tslib/tslib.es6.js +402 -0
- package/node_modules/mdream/node_modules/tslib/tslib.es6.mjs +401 -0
- package/node_modules/mdream/node_modules/tslib/tslib.html +1 -0
- package/node_modules/mdream/node_modules/tslib/tslib.js +484 -0
- package/node_modules/mdream/package.json +110 -0
- package/node_modules/mdream/skills/mdream/SKILL.md +124 -0
- package/node_modules/mdream/skills/mdream/references/runtimes.md +49 -0
- package/node_modules/mdream/wasm/mdream_edge.d.ts +90 -0
- package/node_modules/mdream/wasm/mdream_edge.js +517 -0
- package/node_modules/mdream/wasm/mdream_edge_bg.wasm +0 -0
- package/node_modules/mdream/wasm/mdream_edge_bg.wasm.d.ts +20 -0
- package/node_modules/mdream/wasm/package.json +17 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge.d.ts +45 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge.js +13 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.js +413 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm +0 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm.d.ts +20 -0
- package/node_modules/mdream/wasm-bundler/package.json +19 -0
- package/node_modules/pathe/LICENSE +70 -0
- package/node_modules/pathe/README.md +73 -0
- package/node_modules/pathe/dist/index.cjs +39 -0
- package/node_modules/pathe/dist/index.d.cts +47 -0
- package/node_modules/pathe/dist/index.d.mts +47 -0
- package/node_modules/pathe/dist/index.d.ts +47 -0
- package/node_modules/pathe/dist/index.mjs +19 -0
- package/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs +266 -0
- package/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +249 -0
- package/node_modules/pathe/dist/utils.cjs +82 -0
- package/node_modules/pathe/dist/utils.d.cts +32 -0
- package/node_modules/pathe/dist/utils.d.mts +32 -0
- package/node_modules/pathe/dist/utils.d.ts +32 -0
- package/node_modules/pathe/dist/utils.mjs +77 -0
- package/node_modules/pathe/package.json +61 -0
- package/node_modules/pathe/utils.d.ts +1 -0
- package/package.json +8 -64
|
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { realpath, readFile, readdir } from 'node:fs/promises';
|
|
3
3
|
import { resolve, isAbsolute, join, relative, sep } from 'node:path';
|
|
4
4
|
import { parseDocument } from 'yaml';
|
|
5
|
-
import { A as AGENT_SKILLS_SCHEMA } from '../shared/nuxt-ai-ready.
|
|
5
|
+
import { A as AGENT_SKILLS_SCHEMA } from '../shared/nuxt-ai-ready.CLSWou20.mjs';
|
|
6
6
|
import 'node:module';
|
|
7
7
|
import '@nuxt/kit';
|
|
8
8
|
import 'defu';
|
|
@@ -5,7 +5,7 @@ import { colorize } from 'consola/utils';
|
|
|
5
5
|
import { resolveLocaleFromRoute } from 'nuxtseo-shared/i18n-runtime';
|
|
6
6
|
import { collectSitemap } from 'sitemapd/parse';
|
|
7
7
|
import { withLeadingSlash, joinURL, withBase } from 'ufo';
|
|
8
|
-
import { l as logger, s as supportsNativeNodeSqlite, M as MARKDOWN_LINK_AVAILABILITY_FILE } from '../shared/nuxt-ai-ready.
|
|
8
|
+
import { l as logger, s as supportsNativeNodeSqlite, M as MARKDOWN_LINK_AVAILABILITY_FILE } from '../shared/nuxt-ai-ready.CLSWou20.mjs';
|
|
9
9
|
import { normalizePagePath, toMarkdownPath } from '../../dist/runtime/markdown-path.js';
|
|
10
10
|
import { toDeployedRoute, toLogicalRoute } from '../../dist/runtime/route-path.js';
|
|
11
11
|
import { initSchema, computeContentHash, insertPage, queryAllPages, exportDbDump } from '../../dist/runtime/server/db/shared.js';
|
package/dist/cli.mjs
CHANGED
|
@@ -320,6 +320,8 @@ const main = defineCommand({
|
|
|
320
320
|
}
|
|
321
321
|
} else if (res.skipped) {
|
|
322
322
|
consola.info(`Skipped: ${colors.yellow(res.route)} (still fresh)`);
|
|
323
|
+
} else if (res.gone) {
|
|
324
|
+
consola.success(`Removed: ${colors.green(res.route)} (HTTP 410)`);
|
|
323
325
|
} else {
|
|
324
326
|
throw new Error(`Failed to reindex ${res.route ?? args.route}${res.error ? `: ${res.error}` : ""}`);
|
|
325
327
|
}
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import 'defu';
|
|
|
7
7
|
import 'nuxt-site-config/kit';
|
|
8
8
|
import 'nuxtseo-shared/kit';
|
|
9
9
|
import 'pkg-types';
|
|
10
|
-
export { m as default } from './shared/nuxt-ai-ready.
|
|
10
|
+
export { m as default } from './shared/nuxt-ai-ready.CLSWou20.mjs';
|
|
11
11
|
import '../dist/runtime/markdown-path.js';
|
|
12
12
|
import '../dist/runtime/server/utils/sitemap-md.js';
|
|
13
13
|
import '../dist/runtime/server/utils/discovery-response.js';
|
|
@@ -706,7 +706,6 @@ export async function seedRoutes(event, routes, options = {}) {
|
|
|
706
706
|
indexed = CASE WHEN ai_ready_pages.is_error = 1 THEN 0 ELSE ai_ready_pages.indexed END
|
|
707
707
|
WHERE ai_ready_pages.last_seen_at IS NULL
|
|
708
708
|
OR ai_ready_pages.last_seen_at < excluded.last_seen_at - ${refreshWindowMs}
|
|
709
|
-
OR ai_ready_pages.is_error = 1
|
|
710
709
|
OR ai_ready_pages.locale IS DISTINCT FROM excluded.locale
|
|
711
710
|
`,
|
|
712
711
|
params
|
|
@@ -147,6 +147,8 @@ export declare function seedRoutes(event: H3Event | undefined, routes: Array<str
|
|
|
147
147
|
locale?: string;
|
|
148
148
|
url?: string;
|
|
149
149
|
}>, options?: SeedRoutesOptions): Promise<number>;
|
|
150
|
+
/** Remove a page after its route returns HTTP 410. */
|
|
151
|
+
export declare function prunePage(event: H3Event | undefined, route: string): Promise<void>;
|
|
150
152
|
/**
|
|
151
153
|
* Prune routes not seen in sitemap for longer than threshold
|
|
152
154
|
* Only prunes routes with source='runtime' (never prerendered pages)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "uncrypto";
|
|
2
2
|
import { useEvent, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
|
+
import { logger } from "../logger.js";
|
|
3
4
|
import { checkAndHandleStale } from "../utils/checkStale.js";
|
|
4
5
|
import { parseSitemapCrawlState, serializeSitemapCrawlState } from "../utils/sitemap-crawl-state.js";
|
|
5
6
|
import { initSchema } from "./drizzle/queries.js";
|
|
@@ -16,7 +17,7 @@ function getEventFromContext(providedEvent) {
|
|
|
16
17
|
return void 0;
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
|
-
let
|
|
20
|
+
let devNoticeShown = false;
|
|
20
21
|
let schemaInitializationState = { _tag: "Uninitialized" };
|
|
21
22
|
let dumpSyncState = { _tag: "Pending" };
|
|
22
23
|
function syncBuildDump(event) {
|
|
@@ -40,9 +41,9 @@ const RE_FTS_CHARS = /[*:^"()]/g;
|
|
|
40
41
|
const RE_WHITESPACE = /\s+/;
|
|
41
42
|
async function getDb(event) {
|
|
42
43
|
if (import.meta.dev) {
|
|
43
|
-
if (!
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
if (!devNoticeShown) {
|
|
45
|
+
logger.info("Page data unavailable in dev. Run `nuxi generate` for full metadata.");
|
|
46
|
+
devNoticeShown = true;
|
|
46
47
|
}
|
|
47
48
|
return null;
|
|
48
49
|
}
|
|
@@ -402,7 +403,6 @@ export async function seedRoutes(event, routes, options = {}) {
|
|
|
402
403
|
indexed = CASE WHEN ai_ready_pages.is_error = 1 THEN 0 ELSE ai_ready_pages.indexed END
|
|
403
404
|
WHERE ai_ready_pages.last_seen_at IS NULL
|
|
404
405
|
OR ai_ready_pages.last_seen_at < excluded.last_seen_at - ${refreshWindowMs}
|
|
405
|
-
OR ai_ready_pages.is_error = 1
|
|
406
406
|
OR ai_ready_pages.locale IS DISTINCT FROM excluded.locale
|
|
407
407
|
`,
|
|
408
408
|
params
|
|
@@ -411,6 +411,12 @@ export async function seedRoutes(event, routes, options = {}) {
|
|
|
411
411
|
await db.batch(stmts);
|
|
412
412
|
return byRoute.size;
|
|
413
413
|
}
|
|
414
|
+
export async function prunePage(event, route) {
|
|
415
|
+
const db = await getDb(event);
|
|
416
|
+
if (!db)
|
|
417
|
+
return;
|
|
418
|
+
await db.exec("DELETE FROM ai_ready_pages WHERE route = ?", [normalizeRoute(route)]);
|
|
419
|
+
}
|
|
414
420
|
export async function pruneStaleRoutes(event, staleThresholdSeconds, protectedSince, refreshWindowMs = SEED_REFRESH_WINDOW_MS) {
|
|
415
421
|
const db = await getDb(event);
|
|
416
422
|
if (!db)
|
|
@@ -24,8 +24,8 @@ export declare const SEED_REFRESH_WINDOW_MS: number;
|
|
|
24
24
|
export declare function resolveSeedRefreshWindowMs(pruneTtlSeconds: number): number;
|
|
25
25
|
export interface SeedRoutesOptions {
|
|
26
26
|
/**
|
|
27
|
-
* An existing row is rewritten
|
|
28
|
-
*
|
|
27
|
+
* An existing row is rewritten when its `last_seen_at` is older than this
|
|
28
|
+
* or its locale changed. Error rows retry after this interval.
|
|
29
29
|
* @default SEED_REFRESH_WINDOW_MS
|
|
30
30
|
*/
|
|
31
31
|
refreshWindowMs?: number;
|
|
@@ -10,6 +10,8 @@ export default eventHandler(async (event) => {
|
|
|
10
10
|
}
|
|
11
11
|
const force = query.force !== "false" && query.force !== "0";
|
|
12
12
|
const result = await indexPageByRoute(route, event, { force });
|
|
13
|
+
if (result.gone)
|
|
14
|
+
return { route, indexed: false, gone: true };
|
|
13
15
|
if (!result.success) {
|
|
14
16
|
setResponseStatus(event, 502);
|
|
15
17
|
return { route, indexed: false, error: result.error ?? `Failed to index ${route}` };
|
|
@@ -36,12 +36,14 @@ export async function batchIndexPages(event, options = {}) {
|
|
|
36
36
|
markFailedAsError: true,
|
|
37
37
|
force: true
|
|
38
38
|
});
|
|
39
|
-
return { route: page.route,
|
|
39
|
+
return { route: page.route, result };
|
|
40
40
|
})
|
|
41
41
|
);
|
|
42
42
|
for (const result of results) {
|
|
43
43
|
processed++;
|
|
44
|
-
if (result.
|
|
44
|
+
if (result.result.gone) {
|
|
45
|
+
logger.debug(`[batchIndex] Pruned gone route: ${result.route}`);
|
|
46
|
+
} else if (result.result.success) {
|
|
45
47
|
indexed++;
|
|
46
48
|
logger.debug(`[batchIndex] Indexed: ${result.route}`);
|
|
47
49
|
} else {
|
|
@@ -21,7 +21,7 @@ export declare const STALE_CHECK_INTERVAL_MS: number;
|
|
|
21
21
|
/**
|
|
22
22
|
* Check if data is stale and handle restore/mark-pending
|
|
23
23
|
* Called at start of cron - handles:
|
|
24
|
-
* 1. Empty DB → restore from dump
|
|
24
|
+
* 1. Empty DB with a different build ID → restore from dump
|
|
25
25
|
* 2. Build ID changed → compare hashes, only mark changed pages pending, add new pages from dump
|
|
26
26
|
* Skips HTTP fetch if checked within 5 minutes and DB is populated
|
|
27
27
|
*/
|
|
@@ -78,7 +78,7 @@ export async function checkAndHandleStale(event) {
|
|
|
78
78
|
logger.info("[stale-check] No build metadata found, skipping stale check");
|
|
79
79
|
return { action: "none", dbCount, reason: "no_dump_metadata" };
|
|
80
80
|
}
|
|
81
|
-
if (dbCount === 0) {
|
|
81
|
+
if (dbCount === 0 && storedBuildId !== meta.buildId) {
|
|
82
82
|
if (debug)
|
|
83
83
|
logger.info("[stale-check] DB empty, restoring from dump...");
|
|
84
84
|
const rows = await fetchDump(event);
|
|
@@ -9,7 +9,7 @@ export interface IndexPageOptions {
|
|
|
9
9
|
/** Mark failed fetches as errors in DB to prevent retry loops */
|
|
10
10
|
markFailedAsError?: boolean;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
interface IndexedPageResult {
|
|
13
13
|
success: boolean;
|
|
14
14
|
/** True if page was already fresh and skipped */
|
|
15
15
|
skipped?: boolean;
|
|
@@ -31,6 +31,12 @@ export interface IndexPageResult {
|
|
|
31
31
|
/** Error message if failed */
|
|
32
32
|
error?: string;
|
|
33
33
|
}
|
|
34
|
+
export type IndexPageResult = IndexedPageResult & ({
|
|
35
|
+
success: false;
|
|
36
|
+
gone: true;
|
|
37
|
+
} | {
|
|
38
|
+
gone?: never;
|
|
39
|
+
});
|
|
34
40
|
/**
|
|
35
41
|
* Manually index a page's HTML content into database
|
|
36
42
|
* Use this from custom plugins or API routes to trigger indexing
|
|
@@ -41,3 +47,4 @@ export declare function indexPage(route: string, html: string, options?: IndexPa
|
|
|
41
47
|
* Convenience wrapper around indexPage that handles fetching
|
|
42
48
|
*/
|
|
43
49
|
export declare function indexPageByRoute(route: string, event: H3Event | undefined, options?: IndexPageOptions): Promise<IndexPageResult>;
|
|
50
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fetchWithEvent, useNitroApp, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
2
|
-
import { getPageIndexState, upsertPage } from "../db/queries.js";
|
|
2
|
+
import { getPageIndexState, prunePage, upsertPage } from "../db/queries.js";
|
|
3
3
|
import { computeContentHash } from "../db/shared.js";
|
|
4
4
|
import { logger } from "../logger.js";
|
|
5
5
|
import { convertHtmlToMarkdown } from "../utils.js";
|
|
@@ -79,18 +79,26 @@ export async function indexPage(route, html, options = {}, event) {
|
|
|
79
79
|
}
|
|
80
80
|
export async function indexPageByRoute(route, event, options = {}) {
|
|
81
81
|
logger.debug(`[indexPageByRoute] Fetching HTML for ${route} (timeout: 10000ms)`);
|
|
82
|
-
const
|
|
82
|
+
const fetched = await (event ? fetchWithEvent(event, route, {
|
|
83
83
|
headers: { accept: "text/html", [INTERNAL_HEADER]: "1" },
|
|
84
84
|
timeout: 1e4
|
|
85
85
|
}) : globalThis.$fetch(route, {
|
|
86
86
|
headers: { accept: "text/html", [INTERNAL_HEADER]: "1" },
|
|
87
87
|
timeout: 1e4
|
|
88
88
|
// 10s timeout per page (must fit within CF worker limit)
|
|
89
|
-
})).catch((err) => {
|
|
89
|
+
})).then((html2) => ({ _tag: "Html", html: html2 })).catch((err) => {
|
|
90
|
+
const status = err.status ?? err.statusCode ?? err.response?.status;
|
|
91
|
+
if (status === 410)
|
|
92
|
+
return { _tag: "Gone" };
|
|
90
93
|
logger.warn(`[indexPageByRoute] Failed to fetch ${route}:`, err.message);
|
|
91
|
-
return
|
|
94
|
+
return { _tag: "Failed" };
|
|
92
95
|
});
|
|
93
|
-
if (
|
|
96
|
+
if (fetched._tag === "Gone") {
|
|
97
|
+
await prunePage(event, route);
|
|
98
|
+
return { success: false, gone: true };
|
|
99
|
+
}
|
|
100
|
+
const html = fetched._tag === "Html" ? fetched.html : null;
|
|
101
|
+
if (typeof html === "string" && html) {
|
|
94
102
|
logger.debug(`[indexPageByRoute] Fetched ${route} (${html.length} bytes)`);
|
|
95
103
|
}
|
|
96
104
|
if (!html || typeof html !== "string") {
|
|
@@ -1618,6 +1618,8 @@ ${details}`);
|
|
|
1618
1618
|
nitroConfig.experimental.asyncContext = true;
|
|
1619
1619
|
const preset = String(nitroConfig.preset || "");
|
|
1620
1620
|
const isEdgePreset = ["cloudflare", "vercel-edge", "netlify-edge", "deno"].some((p) => preset.startsWith(p));
|
|
1621
|
+
if (isEdgePreset)
|
|
1622
|
+
nitroConfig.experimental.wasm = true;
|
|
1621
1623
|
if (nitroCompatibility._tag === "nitro-v3") {
|
|
1622
1624
|
const nitro3Config = nitroConfig;
|
|
1623
1625
|
const noExternals = Array.isArray(nitro3Config.noExternals) ? nitro3Config.noExternals : [];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Harlan Wilton
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|