nuxt-ai-ready 2.5.2 → 3.0.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.
- package/README.md +13 -12
- package/dist/chunks/agent-skills.mjs +35 -12
- package/dist/chunks/prerender.mjs +35 -24
- package/dist/cli.mjs +5 -2
- package/dist/module.d.mts +4 -0
- package/dist/module.json +2 -2
- package/dist/module.mjs +8 -4
- package/dist/runtime/app/index.d.ts +3 -0
- package/dist/runtime/app/index.js +2 -0
- package/dist/runtime/cache-control.d.ts +2 -0
- package/dist/runtime/cache-control.js +11 -0
- package/dist/runtime/llms-txt-utils.js +1 -1
- package/dist/runtime/server/db/context.d.ts +13 -0
- package/dist/runtime/server/db/drizzle/client.d.ts +6 -7
- package/dist/runtime/server/db/drizzle/client.js +13 -2
- package/dist/runtime/server/db/drizzle/providers/bun.d.ts +2 -2
- package/dist/runtime/server/db/drizzle/providers/bun.js +2 -2
- package/dist/runtime/server/db/drizzle/providers/d1.d.ts +2 -2
- package/dist/runtime/server/db/drizzle/providers/d1.js +3 -2
- package/dist/runtime/server/db/drizzle/providers/libsql.d.ts +2 -2
- package/dist/runtime/server/db/drizzle/providers/libsql.js +2 -2
- package/dist/runtime/server/db/drizzle/providers/neon.d.ts +2 -2
- package/dist/runtime/server/db/drizzle/providers/neon.js +2 -2
- package/dist/runtime/server/db/drizzle/providers/node-sqlite.d.ts +2 -2
- package/dist/runtime/server/db/drizzle/providers/node-sqlite.js +2 -2
- package/dist/runtime/server/db/drizzle/providers/postgres.d.ts +2 -2
- package/dist/runtime/server/db/drizzle/providers/postgres.js +2 -2
- package/dist/runtime/server/db/drizzle/queries.d.ts +27 -27
- package/dist/runtime/server/db/drizzle/queries.js +6 -5
- package/dist/runtime/server/db/drizzle/raw.d.ts +2 -6
- package/dist/runtime/server/db/index.d.ts +1 -1
- package/dist/runtime/server/db/index.js +1 -1
- package/dist/runtime/server/db/queries.d.ts +36 -36
- package/dist/runtime/server/db/queries.js +8 -9
- package/dist/runtime/server/db/seed.d.ts +2 -2
- package/dist/runtime/server/db/seed.js +4 -3
- package/dist/runtime/server/db/shared.d.ts +8 -0
- package/dist/runtime/server/db/shared.js +8 -2
- package/dist/runtime/server/index.d.ts +2 -0
- package/dist/runtime/server/index.js +17 -0
- package/dist/runtime/server/mcp/tools/get-page-markdown.js +1 -1
- package/dist/runtime/server/mcp/tools/list-pages.js +1 -1
- package/dist/runtime/server/mcp/tools/search-pages.js +1 -1
- package/dist/runtime/server/middleware/markdown.js +3 -3
- package/dist/runtime/server/middleware/markdown.prerender.js +1 -1
- package/dist/runtime/server/plugins/db-lifecycle-nitro3.d.ts +2 -0
- package/dist/runtime/server/plugins/db-lifecycle-nitro3.js +16 -0
- package/dist/runtime/server/plugins/html-capture.prerender.js +6 -4
- package/dist/runtime/server/plugins/link-header-nitro3.d.ts +2 -0
- package/dist/runtime/server/plugins/link-header-nitro3.js +20 -0
- package/dist/runtime/server/plugins/link-header.d.ts +6 -0
- package/dist/runtime/server/plugins/link-header.js +7 -11
- package/dist/runtime/server/plugins/markdown-negotiation.js +8 -1
- package/dist/runtime/server/plugins/sitemap-seeder.js +3 -3
- package/dist/runtime/server/routes/agent-skills-artifact.d.ts +1 -1
- package/dist/runtime/server/routes/agent-skills-artifact.js +10 -10
- package/dist/runtime/server/routes/agent-skills-index.d.ts +1 -1
- package/dist/runtime/server/routes/agent-skills-index.js +7 -6
- package/dist/runtime/server/routes/ai-catalog.d.ts +2 -1
- package/dist/runtime/server/routes/ai-catalog.js +7 -8
- package/dist/runtime/server/routes/api-catalog.d.ts +3 -1
- package/dist/runtime/server/routes/api-catalog.js +12 -12
- package/dist/runtime/server/routes/llms-full.txt.get.js +1 -1
- package/dist/runtime/server/routes/mcp-server-card.d.ts +1 -1
- package/dist/runtime/server/routes/mcp-server-card.js +7 -8
- package/dist/runtime/server/utils/checkStale.d.ts +2 -2
- package/dist/runtime/server/utils/cloudflare-prerendered.d.ts +3 -0
- package/dist/runtime/server/utils/cloudflare-prerendered.js +23 -0
- package/dist/runtime/server/utils/cloudflare.d.ts +5 -5
- package/dist/runtime/server/utils/cloudflare.js +31 -7
- package/dist/runtime/server/utils/content-negotiation.d.ts +5 -3
- package/dist/runtime/server/utils/content-negotiation.js +8 -7
- package/dist/runtime/server/utils/context.d.ts +3 -3
- package/dist/runtime/server/utils/context.js +1 -1
- package/dist/runtime/server/utils/discovery-response.d.ts +2 -0
- package/dist/runtime/server/utils/link-header.d.ts +5 -3
- package/dist/runtime/server/utils/link-header.js +26 -2
- package/dist/runtime/server/utils/markdown-request.d.ts +4 -3
- package/dist/runtime/server/utils/markdown-request.js +15 -13
- package/dist/runtime/server/utils/negotiation-decision.d.ts +4 -0
- package/dist/runtime/server/utils/negotiation-decision.js +6 -5
- package/dist/runtime/server/utils/negotiation-response.d.ts +1 -1
- package/dist/runtime/server/utils/negotiation-response.js +63 -23
- package/dist/runtime/server/utils/prerender-html.d.ts +2 -1
- package/dist/runtime/server/utils/prerender-html.js +3 -1
- package/dist/runtime/types.d.ts +15 -7
- package/dist/shared/nuxt-ai-ready.B3hAuOLQ.mjs +29 -0
- package/dist/shared/{nuxt-ai-ready.CLSWou20.mjs → nuxt-ai-ready.C34F0LJo.mjs} +560 -219
- package/package.json +85 -20
- package/skills/nuxt-ai-ready/SKILL.md +26 -12
- package/skills/nuxt-ai-ready/references/runtime-indexing.md +7 -6
- package/dist/runtime/server/db/drizzle/providers/sqlite.d.ts +0 -8
- package/dist/runtime/server/db/drizzle/providers/sqlite.js +0 -15
- package/node_modules/@mdream/js/LICENSE.md +0 -9
- package/node_modules/@mdream/js/README.md +0 -792
- package/node_modules/@mdream/js/bin/mdream.mjs +0 -2
- package/node_modules/@mdream/js/dist/_chunks/const.mjs +0 -134
- package/node_modules/@mdream/js/dist/_chunks/index.d.mts +0 -9
- package/node_modules/@mdream/js/dist/_chunks/markdown-processor.mjs +0 -1968
- package/node_modules/@mdream/js/dist/_chunks/minimal.d.mts +0 -6
- package/node_modules/@mdream/js/dist/_chunks/parse.mjs +0 -2756
- package/node_modules/@mdream/js/dist/_chunks/plugins.mjs +0 -725
- package/node_modules/@mdream/js/dist/_chunks/resolve-plugins.mjs +0 -44
- package/node_modules/@mdream/js/dist/_chunks/stream.mjs +0 -37
- package/node_modules/@mdream/js/dist/_chunks/types.d.mts +0 -473
- package/node_modules/@mdream/js/dist/cli.d.mts +0 -1
- package/node_modules/@mdream/js/dist/cli.mjs +0 -32
- package/node_modules/@mdream/js/dist/core.d.mts +0 -15
- package/node_modules/@mdream/js/dist/core.mjs +0 -28
- package/node_modules/@mdream/js/dist/index.d.mts +0 -4
- package/node_modules/@mdream/js/dist/index.mjs +0 -58
- package/node_modules/@mdream/js/dist/llms-txt.d.mts +0 -86
- package/node_modules/@mdream/js/dist/llms-txt.mjs +0 -308
- package/node_modules/@mdream/js/dist/negotiate.d.mts +0 -35
- package/node_modules/@mdream/js/dist/negotiate.mjs +0 -121
- package/node_modules/@mdream/js/dist/parse.d.mts +0 -90
- package/node_modules/@mdream/js/dist/parse.mjs +0 -2
- package/node_modules/@mdream/js/dist/plugins.d.mts +0 -85
- package/node_modules/@mdream/js/dist/plugins.mjs +0 -2
- package/node_modules/@mdream/js/dist/preset/minimal.d.mts +0 -2
- package/node_modules/@mdream/js/dist/preset/minimal.mjs +0 -33
- package/node_modules/@mdream/js/dist/splitter.d.mts +0 -18
- package/node_modules/@mdream/js/dist/splitter.mjs +0 -194
- package/node_modules/@mdream/js/package.json +0 -103
- package/node_modules/cac/LICENSE +0 -21
- package/node_modules/cac/README.md +0 -492
- package/node_modules/cac/dist/index.d.ts +0 -196
- package/node_modules/cac/dist/index.js +0 -638
- package/node_modules/cac/package.json +0 -72
- package/node_modules/mdream/LICENSE.md +0 -9
- package/node_modules/mdream/README.md +0 -1091
- package/node_modules/mdream/bin/mdream.mjs +0 -46
- package/node_modules/mdream/dist/browser.d.mts +0 -105
- package/node_modules/mdream/dist/browser.mjs +0 -262
- package/node_modules/mdream/dist/edge.d.mts +0 -100
- package/node_modules/mdream/dist/edge.mjs +0 -250
- package/node_modules/mdream/dist/iife.js +0 -605
- package/node_modules/mdream/dist/index.d.mts +0 -89
- package/node_modules/mdream/dist/index.mjs +0 -184
- package/node_modules/mdream/dist/wasm.d.mts +0 -100
- package/node_modules/mdream/dist/wasm.mjs +0 -140
- package/node_modules/mdream/dist/worker.d.mts +0 -101
- package/node_modules/mdream/dist/worker.mjs +0 -217
- package/node_modules/mdream/napi/index.d.mts +0 -127
- package/node_modules/mdream/napi/index.d.ts +0 -127
- package/node_modules/mdream/napi/index.mjs +0 -725
- 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 +0 -2144
- 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 +0 -21
- package/node_modules/mdream/node_modules/@emnapi/core/README.md +0 -1
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.d.ts +0 -392
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.d.ts +0 -392
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.js +0 -8351
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.js +0 -7268
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.d.ts +0 -5
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.js +0 -843
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.d.ts +0 -4
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.js +0 -3
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.d.ts +0 -5
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.js +0 -1010
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.d.ts +0 -5
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.js +0 -1446
- package/node_modules/mdream/node_modules/@emnapi/core/package.json +0 -39
- package/node_modules/mdream/node_modules/@emnapi/core/rollup.config.js +0 -60
- package/node_modules/mdream/node_modules/@emnapi/runtime/LICENSE +0 -21
- package/node_modules/mdream/node_modules/@emnapi/runtime/README.md +0 -1
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.d.ts +0 -833
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js +0 -2306
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js.map +0 -1
- package/node_modules/mdream/node_modules/@emnapi/runtime/index.cjs +0 -63
- package/node_modules/mdream/node_modules/@emnapi/runtime/package.json +0 -39
- package/node_modules/mdream/node_modules/@emnapi/runtime/rollup.config.js +0 -25
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/LICENSE +0 -21
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/README.md +0 -203
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +0 -236
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +0 -1086
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/package.json +0 -35
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/rollup.config.js +0 -6
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.cjs +0 -1472
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.js +0 -1470
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +0 -237
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs.js +0 -18260
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +0 -317
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/package.json +0 -67
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.cjs +0 -39
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.js +0 -36
- package/node_modules/mdream/node_modules/@tybys/wasm-util/LICENSE +0 -21
- package/node_modules/mdream/node_modules/@tybys/wasm-util/README.md +0 -193
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/tsdoc-metadata.json +0 -11
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +0 -423
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +0 -2932
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +0 -2932
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +0 -1
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.js +0 -2954
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +0 -1
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/asyncify.js +0 -158
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/index.js +0 -13
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/jspi.js +0 -46
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/load.js +0 -97
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/memory.js +0 -35
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/error.js +0 -103
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fd.js +0 -268
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fs.js +0 -3
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +0 -192
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +0 -316
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +0 -1599
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/rights.js +0 -141
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/types.js +0 -220
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/util.js +0 -128
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/webassembly.js +0 -13
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/asyncify.mjs +0 -153
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/index.mjs +0 -9
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/jspi.mjs +0 -39
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/load.mjs +0 -89
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/memory.mjs +0 -28
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/error.mjs +0 -97
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fd.mjs +0 -256
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fs.mjs +0 -1
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +0 -186
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +0 -310
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +0 -1593
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/rights.mjs +0 -135
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/types.mjs +0 -216
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/util.mjs +0 -113
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/webassembly.mjs +0 -9
- package/node_modules/mdream/node_modules/@tybys/wasm-util/package.json +0 -58
- package/node_modules/mdream/node_modules/tslib/CopyrightNotice.txt +0 -15
- package/node_modules/mdream/node_modules/tslib/LICENSE.txt +0 -12
- package/node_modules/mdream/node_modules/tslib/README.md +0 -164
- package/node_modules/mdream/node_modules/tslib/SECURITY.md +0 -41
- package/node_modules/mdream/node_modules/tslib/modules/index.d.ts +0 -38
- package/node_modules/mdream/node_modules/tslib/modules/index.js +0 -70
- package/node_modules/mdream/node_modules/tslib/modules/package.json +0 -3
- package/node_modules/mdream/node_modules/tslib/package.json +0 -47
- package/node_modules/mdream/node_modules/tslib/tslib.d.ts +0 -460
- package/node_modules/mdream/node_modules/tslib/tslib.es6.html +0 -1
- package/node_modules/mdream/node_modules/tslib/tslib.es6.js +0 -402
- package/node_modules/mdream/node_modules/tslib/tslib.es6.mjs +0 -401
- package/node_modules/mdream/node_modules/tslib/tslib.html +0 -1
- package/node_modules/mdream/node_modules/tslib/tslib.js +0 -484
- package/node_modules/mdream/package.json +0 -110
- package/node_modules/mdream/skills/mdream/SKILL.md +0 -124
- package/node_modules/mdream/skills/mdream/references/runtimes.md +0 -49
- package/node_modules/mdream/wasm/mdream_edge.d.ts +0 -90
- package/node_modules/mdream/wasm/mdream_edge.js +0 -517
- package/node_modules/mdream/wasm/mdream_edge_bg.wasm +0 -0
- package/node_modules/mdream/wasm/mdream_edge_bg.wasm.d.ts +0 -20
- package/node_modules/mdream/wasm/package.json +0 -17
- package/node_modules/mdream/wasm-bundler/mdream_edge.d.ts +0 -45
- package/node_modules/mdream/wasm-bundler/mdream_edge.js +0 -13
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.js +0 -413
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm +0 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm.d.ts +0 -20
- package/node_modules/mdream/wasm-bundler/package.json +0 -19
- package/node_modules/pathe/LICENSE +0 -70
- package/node_modules/pathe/README.md +0 -73
- package/node_modules/pathe/dist/index.cjs +0 -39
- package/node_modules/pathe/dist/index.d.cts +0 -47
- package/node_modules/pathe/dist/index.d.mts +0 -47
- package/node_modules/pathe/dist/index.d.ts +0 -47
- package/node_modules/pathe/dist/index.mjs +0 -19
- package/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs +0 -266
- package/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +0 -249
- package/node_modules/pathe/dist/utils.cjs +0 -82
- package/node_modules/pathe/dist/utils.d.cts +0 -32
- package/node_modules/pathe/dist/utils.d.mts +0 -32
- package/node_modules/pathe/dist/utils.d.ts +0 -32
- package/node_modules/pathe/dist/utils.mjs +0 -77
- package/node_modules/pathe/package.json +0 -61
- package/node_modules/pathe/utils.d.ts +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AiReadyDatabaseEvent } from '../../context.js';
|
|
2
2
|
import { DatabaseSync } from 'node:sqlite';
|
|
3
|
-
export declare function createClient(
|
|
3
|
+
export declare function createClient(_event?: AiReadyDatabaseEvent): Promise<{
|
|
4
4
|
dialect: "sqlite";
|
|
5
5
|
db: import("drizzle-orm/node-sqlite").NodeSQLiteDatabase<import("drizzle-orm").EmptyRelations> & {
|
|
6
6
|
$client: DatabaseSync;
|
|
@@ -4,8 +4,8 @@ import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
|
4
4
|
import { logger } from "../../../logger.js";
|
|
5
5
|
import { registerDriver } from "../raw.js";
|
|
6
6
|
import { resolveWritableDbPath } from "./dbPath.js";
|
|
7
|
-
export async function createClient(
|
|
8
|
-
const config = useRuntimeConfig(
|
|
7
|
+
export async function createClient(_event) {
|
|
8
|
+
const config = useRuntimeConfig()["nuxt-ai-ready"];
|
|
9
9
|
const dbPath = await resolveWritableDbPath(config.database.filename || ".data/ai-ready/pages.db");
|
|
10
10
|
logger.debug(`[drizzle] Opening native SQLite database: ${dbPath}`);
|
|
11
11
|
const sqlite = new DatabaseSync(dbPath);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AiReadyDatabaseEvent } from '../../context.js';
|
|
2
2
|
import postgres from 'postgres';
|
|
3
|
-
export declare function createClient(
|
|
3
|
+
export declare function createClient(_event?: AiReadyDatabaseEvent): Promise<{
|
|
4
4
|
dialect: "postgres";
|
|
5
5
|
db: import("drizzle-orm/postgres-js").PostgresJsDatabase<import("drizzle-orm").EmptyRelations> & {
|
|
6
6
|
$client: postgres.Sql<{}>;
|
|
@@ -3,8 +3,8 @@ import postgres from "postgres";
|
|
|
3
3
|
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
4
4
|
import { logger } from "../../../logger.js";
|
|
5
5
|
import { registerDriver } from "../raw.js";
|
|
6
|
-
export async function createClient(
|
|
7
|
-
const config = useRuntimeConfig(
|
|
6
|
+
export async function createClient(_event) {
|
|
7
|
+
const config = useRuntimeConfig()["nuxt-ai-ready"];
|
|
8
8
|
const connectionString = config.database.url || process.env.POSTGRES_URL || process.env.DATABASE_URL;
|
|
9
9
|
if (!connectionString) {
|
|
10
10
|
throw new Error("[ai-ready] Missing database URL. Set DATABASE_URL or configure database.url");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { H3Event } from '#nuxtseo/h3';
|
|
2
1
|
import type { SitemapCrawlState } from '../../utils/sitemap-crawl-state.js';
|
|
2
|
+
import type { AiReadyDatabaseEvent } from '../context.js';
|
|
3
3
|
import type { SeedRoutesOptions } from '../seed.js';
|
|
4
4
|
export interface PageInput {
|
|
5
5
|
route: string;
|
|
@@ -36,72 +36,72 @@ export interface PageMetaOutput {
|
|
|
36
36
|
/**
|
|
37
37
|
* Insert or update a page
|
|
38
38
|
*/
|
|
39
|
-
export declare function upsertPage(event:
|
|
39
|
+
export declare function upsertPage(event: AiReadyDatabaseEvent | undefined, page: PageInput): Promise<void>;
|
|
40
40
|
/**
|
|
41
41
|
* Get all pages
|
|
42
42
|
*/
|
|
43
|
-
export declare function getAllPages(event:
|
|
43
|
+
export declare function getAllPages(event: AiReadyDatabaseEvent | undefined, options?: {
|
|
44
44
|
includeErrors?: boolean;
|
|
45
45
|
excludeMarkdown?: boolean;
|
|
46
46
|
}): Promise<PageOutput[] | PageMetaOutput[]>;
|
|
47
47
|
/**
|
|
48
48
|
* Get a single page by route
|
|
49
49
|
*/
|
|
50
|
-
export declare function getPageByRoute(event:
|
|
50
|
+
export declare function getPageByRoute(event: AiReadyDatabaseEvent | undefined, route: string): Promise<PageOutput | undefined>;
|
|
51
51
|
/**
|
|
52
52
|
* Get lastmod (updatedAt) for all indexed pages
|
|
53
53
|
* Returns a Map for O(1) lookup when enriching sitemaps
|
|
54
54
|
*/
|
|
55
|
-
export declare function getPageLastmods(event:
|
|
55
|
+
export declare function getPageLastmods(event: AiReadyDatabaseEvent | undefined): Promise<Map<string, string>>;
|
|
56
56
|
/**
|
|
57
57
|
* Search pages (uses LIKE for both dialects, FTS5 fallback for SQLite)
|
|
58
58
|
*/
|
|
59
|
-
export declare function searchPages(event:
|
|
59
|
+
export declare function searchPages(event: AiReadyDatabaseEvent | undefined, query: string, options?: {
|
|
60
60
|
limit?: number;
|
|
61
61
|
}): Promise<PageMetaOutput[]>;
|
|
62
62
|
/**
|
|
63
63
|
* Count pages
|
|
64
64
|
*/
|
|
65
|
-
export declare function countPages(event:
|
|
65
|
+
export declare function countPages(event: AiReadyDatabaseEvent | undefined, options?: {
|
|
66
66
|
indexed?: boolean;
|
|
67
67
|
errors?: boolean;
|
|
68
68
|
}): Promise<number>;
|
|
69
69
|
/**
|
|
70
70
|
* Get pending pages (not yet indexed)
|
|
71
71
|
*/
|
|
72
|
-
export declare function getPendingPages(event:
|
|
72
|
+
export declare function getPendingPages(event: AiReadyDatabaseEvent | undefined, limit?: number): Promise<{
|
|
73
73
|
route: string;
|
|
74
74
|
}[]>;
|
|
75
75
|
/**
|
|
76
76
|
* Mark page as indexed
|
|
77
77
|
*/
|
|
78
|
-
export declare function markPageIndexed(event:
|
|
78
|
+
export declare function markPageIndexed(event: AiReadyDatabaseEvent | undefined, route: string): Promise<void>;
|
|
79
79
|
/**
|
|
80
80
|
* Mark multiple routes as pending (needing re-index)
|
|
81
81
|
*/
|
|
82
|
-
export declare function markRoutesPending(event:
|
|
82
|
+
export declare function markRoutesPending(event: AiReadyDatabaseEvent | undefined, routes: string[]): Promise<void>;
|
|
83
83
|
/**
|
|
84
84
|
* Get content hashes for all pages
|
|
85
85
|
*/
|
|
86
|
-
export declare function getContentHashes(event?:
|
|
86
|
+
export declare function getContentHashes(event?: AiReadyDatabaseEvent): Promise<Map<string, string | null>>;
|
|
87
87
|
/**
|
|
88
88
|
* Get a value from the info table
|
|
89
89
|
*/
|
|
90
|
-
export declare function getInfoValue(event:
|
|
90
|
+
export declare function getInfoValue(event: AiReadyDatabaseEvent | undefined, key: string): Promise<string | null>;
|
|
91
91
|
/**
|
|
92
92
|
* Set a value in the info table
|
|
93
93
|
*/
|
|
94
|
-
export declare function setInfoValue(event:
|
|
94
|
+
export declare function setInfoValue(event: AiReadyDatabaseEvent | undefined, key: string, value: string): Promise<void>;
|
|
95
95
|
/**
|
|
96
96
|
* Delete a value from the info table
|
|
97
97
|
*/
|
|
98
|
-
export declare function deleteInfoValue(event:
|
|
98
|
+
export declare function deleteInfoValue(event: AiReadyDatabaseEvent | undefined, key: string): Promise<void>;
|
|
99
99
|
/**
|
|
100
100
|
* Initialize database schema. Rebuilds on a schema version change or when the
|
|
101
101
|
* SQLite FTS5 tokenizer differs from the one baked into the existing virtual
|
|
102
102
|
* table (Postgres has no FTS5; tokenizer comparison is SQLite-only).
|
|
103
103
|
*/
|
|
104
|
-
export declare function initSchema(event?:
|
|
104
|
+
export declare function initSchema(event?: AiReadyDatabaseEvent): Promise<void>;
|
|
105
105
|
export interface CronRunOutput {
|
|
106
106
|
id: number;
|
|
107
107
|
startedAt: number;
|
|
@@ -115,11 +115,11 @@ export interface CronRunOutput {
|
|
|
115
115
|
/**
|
|
116
116
|
* Start a cron run
|
|
117
117
|
*/
|
|
118
|
-
export declare function startCronRun(event:
|
|
118
|
+
export declare function startCronRun(event: AiReadyDatabaseEvent | undefined): Promise<number | null>;
|
|
119
119
|
/**
|
|
120
120
|
* Complete a cron run
|
|
121
121
|
*/
|
|
122
|
-
export declare function completeCronRun(event:
|
|
122
|
+
export declare function completeCronRun(event: AiReadyDatabaseEvent | undefined, runId: number, result: {
|
|
123
123
|
pagesIndexed: number;
|
|
124
124
|
pagesRemaining: number;
|
|
125
125
|
errors: string[];
|
|
@@ -127,7 +127,7 @@ export declare function completeCronRun(event: H3Event | undefined, runId: numbe
|
|
|
127
127
|
/**
|
|
128
128
|
* Get recent cron runs
|
|
129
129
|
*/
|
|
130
|
-
export declare function getRecentCronRuns(event:
|
|
130
|
+
export declare function getRecentCronRuns(event: AiReadyDatabaseEvent | undefined, limit?: number): Promise<CronRunOutput[]>;
|
|
131
131
|
export interface SitemapOutput {
|
|
132
132
|
name: string;
|
|
133
133
|
route: string;
|
|
@@ -143,7 +143,7 @@ interface SitemapEntry extends Omit<SitemapOutput, 'continuing'> {
|
|
|
143
143
|
/**
|
|
144
144
|
* Sync sitemaps from config
|
|
145
145
|
*/
|
|
146
|
-
export declare function syncSitemaps(event:
|
|
146
|
+
export declare function syncSitemaps(event: AiReadyDatabaseEvent | undefined, sitemapList: Array<{
|
|
147
147
|
name: string;
|
|
148
148
|
route: string;
|
|
149
149
|
}>): Promise<{
|
|
@@ -153,27 +153,27 @@ export declare function syncSitemaps(event: H3Event | undefined, sitemapList: Ar
|
|
|
153
153
|
/**
|
|
154
154
|
* Get next sitemap to crawl
|
|
155
155
|
*/
|
|
156
|
-
export declare function getNextSitemapToCrawl(event:
|
|
156
|
+
export declare function getNextSitemapToCrawl(event: AiReadyDatabaseEvent | undefined, minIntervalMinutes?: number): Promise<SitemapEntry | null>;
|
|
157
157
|
/**
|
|
158
158
|
* Mark sitemap as crawled
|
|
159
159
|
*/
|
|
160
|
-
export declare function markSitemapCrawled(event:
|
|
160
|
+
export declare function markSitemapCrawled(event: AiReadyDatabaseEvent | undefined, name: string, urlCount: number): Promise<void>;
|
|
161
161
|
/** Record a deferred sitemap hook seed only when no crawl is in progress. */
|
|
162
|
-
export declare function markSitemapSeeded(event:
|
|
162
|
+
export declare function markSitemapSeeded(event: AiReadyDatabaseEvent | undefined, name: string, urlCount: number, expectedLastCrawledAt: number | null): Promise<void>;
|
|
163
163
|
/** Persist a resumable sitemap crawl without incrementing its error budget. */
|
|
164
|
-
export declare function markSitemapCrawlPartial(event:
|
|
164
|
+
export declare function markSitemapCrawlPartial(event: AiReadyDatabaseEvent | undefined, name: string, state: SitemapCrawlState): Promise<void>;
|
|
165
165
|
/**
|
|
166
166
|
* Mark sitemap error
|
|
167
167
|
*/
|
|
168
|
-
export declare function markSitemapError(event:
|
|
168
|
+
export declare function markSitemapError(event: AiReadyDatabaseEvent | undefined, name: string, error: string): Promise<void>;
|
|
169
169
|
/**
|
|
170
170
|
* Get all sitemaps status
|
|
171
171
|
*/
|
|
172
|
-
export declare function getSitemapStatus(event:
|
|
172
|
+
export declare function getSitemapStatus(event: AiReadyDatabaseEvent | undefined): Promise<SitemapOutput[]>;
|
|
173
173
|
/**
|
|
174
174
|
* Reset all sitemap errors (called on build_id change)
|
|
175
175
|
*/
|
|
176
|
-
export declare function resetSitemapErrors(event:
|
|
176
|
+
export declare function resetSitemapErrors(event: AiReadyDatabaseEvent | undefined): Promise<number>;
|
|
177
177
|
/**
|
|
178
178
|
* Seed routes from sitemap
|
|
179
179
|
*
|
|
@@ -182,7 +182,7 @@ export declare function resetSitemapErrors(event: H3Event | undefined): Promise<
|
|
|
182
182
|
* guard each run bumped `last_seen_at` on every row, which cost millions of
|
|
183
183
|
* D1 row writes a month. Keep the two layers in sync.
|
|
184
184
|
*/
|
|
185
|
-
export declare function seedRoutes(event:
|
|
185
|
+
export declare function seedRoutes(event: AiReadyDatabaseEvent | undefined, routes: Array<string | {
|
|
186
186
|
route: string;
|
|
187
187
|
locale?: string;
|
|
188
188
|
url?: string;
|
|
@@ -4,11 +4,11 @@ import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
|
4
4
|
import { parseSitemapCrawlState, serializeSitemapCrawlState } from "../../utils/sitemap-crawl-state.js";
|
|
5
5
|
import { resolveFtsTokenizer as validateFtsTokenizer } from "../schema-sql.js";
|
|
6
6
|
import { deriveLocale, SEED_REFRESH_WINDOW_MS } from "../seed.js";
|
|
7
|
-
import { LIKE_ESCAPE, likeSubstring, maxRowsPerInsert } from "../shared.js";
|
|
7
|
+
import { LIKE_ESCAPE, likeSubstring, maxRowsPerInsert, toFtsMatchQuery } from "../shared.js";
|
|
8
8
|
import { useDrizzle } from "./client.js";
|
|
9
9
|
import { getRawExecutor, useRawDb } from "./raw.js";
|
|
10
|
-
function resolveFtsTokenizer(
|
|
11
|
-
const cfg = useRuntimeConfig(
|
|
10
|
+
function resolveFtsTokenizer(_event) {
|
|
11
|
+
const cfg = useRuntimeConfig();
|
|
12
12
|
return validateFtsTokenizer(cfg["nuxt-ai-ready"]?.ftsTokenizer);
|
|
13
13
|
}
|
|
14
14
|
const RE_LEADING_SLASH = /^\//;
|
|
@@ -131,13 +131,14 @@ export async function searchPages(event, query, options) {
|
|
|
131
131
|
const limitNum = options?.limit || 20;
|
|
132
132
|
const searchTerm = likeSubstring(query);
|
|
133
133
|
const matches = (col) => sql`${col} LIKE ${searchTerm} ESCAPE ${LIKE_ESCAPE}`;
|
|
134
|
-
|
|
134
|
+
const ftsQuery = toFtsMatchQuery(query);
|
|
135
|
+
if (client.dialect === "sqlite" && ftsQuery) {
|
|
135
136
|
try {
|
|
136
137
|
const ftsResult = await client.db.all(sql`
|
|
137
138
|
SELECT p.route, p.title, p.description, p.headings, p.keywords, p.updated_at as "updatedAt", p.is_error as "isError"
|
|
138
139
|
FROM ai_ready_pages p
|
|
139
140
|
JOIN ai_ready_pages_fts fts ON p.id = fts.rowid
|
|
140
|
-
WHERE ai_ready_pages_fts MATCH ${
|
|
141
|
+
WHERE ai_ready_pages_fts MATCH ${ftsQuery} AND p.is_error = 0
|
|
141
142
|
LIMIT ${limitNum}
|
|
142
143
|
`);
|
|
143
144
|
if (ftsResult?.length) {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Raw SQL execution utilities for Drizzle
|
|
3
|
-
* Provides direct driver access for raw SQL queries
|
|
4
|
-
*/
|
|
5
|
-
import type { H3Event } from '#nuxtseo/h3';
|
|
1
|
+
import type { AiReadyDatabaseEvent } from '../context.js';
|
|
6
2
|
import type { DrizzleDatabase } from './client.js';
|
|
7
3
|
/**
|
|
8
4
|
* Register the underlying driver for raw SQL access
|
|
@@ -29,7 +25,7 @@ export type RawExecutor = ReturnType<typeof getRawExecutor>;
|
|
|
29
25
|
/**
|
|
30
26
|
* Get raw SQL executor from event context or create new one
|
|
31
27
|
*/
|
|
32
|
-
export declare function useRawDb(event?:
|
|
28
|
+
export declare function useRawDb(event?: AiReadyDatabaseEvent): Promise<RawExecutor>;
|
|
33
29
|
/**
|
|
34
30
|
* Close underlying database driver connection
|
|
35
31
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "#ai-ready-virtual/database-runtime.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { H3Event } from '#nuxtseo/h3';
|
|
2
1
|
import type { SitemapCrawlState } from '../utils/sitemap-crawl-state.js';
|
|
2
|
+
import type { AiReadyDatabaseEvent } from './context.js';
|
|
3
3
|
import type { SeedRoutesOptions } from './seed.js';
|
|
4
4
|
export type { SeedRoutesOptions };
|
|
5
5
|
export { resolveSeedRefreshWindowMs, SEED_REFRESH_WINDOW_MS } from './seed.js';
|
|
@@ -56,23 +56,23 @@ type DatabaseNumber = number | string | bigint;
|
|
|
56
56
|
* Get lastmod (updatedAt) for all indexed pages
|
|
57
57
|
* Returns a Map for O(1) lookup when enriching sitemaps
|
|
58
58
|
*/
|
|
59
|
-
export declare function getPageLastmods(event:
|
|
59
|
+
export declare function getPageLastmods(event: AiReadyDatabaseEvent | undefined): Promise<Map<string, string>>;
|
|
60
60
|
/**
|
|
61
61
|
* Unified page query function
|
|
62
62
|
* @param event - H3Event (optional, used for db context)
|
|
63
63
|
* @param options - Query options
|
|
64
64
|
*/
|
|
65
|
-
export declare function queryPages(event:
|
|
65
|
+
export declare function queryPages(event: AiReadyDatabaseEvent | undefined, options: QueryPagesOptions & {
|
|
66
66
|
route: string;
|
|
67
67
|
includeMarkdown: true;
|
|
68
68
|
}): Promise<PageData | undefined>;
|
|
69
|
-
export declare function queryPages(event:
|
|
69
|
+
export declare function queryPages(event: AiReadyDatabaseEvent | undefined, options: QueryPagesOptions & {
|
|
70
70
|
route: string;
|
|
71
71
|
}): Promise<PageEntry | PageData | undefined>;
|
|
72
|
-
export declare function queryPages(event:
|
|
72
|
+
export declare function queryPages(event: AiReadyDatabaseEvent | undefined, options: QueryPagesOptions & {
|
|
73
73
|
includeMarkdown: true;
|
|
74
74
|
}): Promise<PageData[]>;
|
|
75
|
-
export declare function queryPages(event?:
|
|
75
|
+
export declare function queryPages(event?: AiReadyDatabaseEvent, options?: QueryPagesOptions): Promise<PageEntry[] | PageData[]>;
|
|
76
76
|
export interface StreamPagesOptions {
|
|
77
77
|
batchSize?: number;
|
|
78
78
|
}
|
|
@@ -80,7 +80,7 @@ export interface StreamPagesOptions {
|
|
|
80
80
|
* Stream pages using cursor-based pagination
|
|
81
81
|
* Yields pages one batch at a time to avoid loading all into memory
|
|
82
82
|
*/
|
|
83
|
-
export declare function streamPages(event?:
|
|
83
|
+
export declare function streamPages(event?: AiReadyDatabaseEvent, options?: StreamPagesOptions): AsyncGenerator<PageData, void, unknown>;
|
|
84
84
|
export interface CountPagesOptions {
|
|
85
85
|
where?: {
|
|
86
86
|
pending?: boolean;
|
|
@@ -91,7 +91,7 @@ export interface CountPagesOptions {
|
|
|
91
91
|
/**
|
|
92
92
|
* Count pages matching criteria
|
|
93
93
|
*/
|
|
94
|
-
export declare function countPages(event?:
|
|
94
|
+
export declare function countPages(event?: AiReadyDatabaseEvent, options?: CountPagesOptions): Promise<number>;
|
|
95
95
|
export interface SearchPagesOptions {
|
|
96
96
|
limit?: number;
|
|
97
97
|
}
|
|
@@ -99,7 +99,7 @@ export interface SearchPagesOptions {
|
|
|
99
99
|
* Full-text search using FTS5 or PostgreSQL ILIKE
|
|
100
100
|
* Note: FTS is only available at runtime, not during prerender
|
|
101
101
|
*/
|
|
102
|
-
export declare function searchPages(event:
|
|
102
|
+
export declare function searchPages(event: AiReadyDatabaseEvent | undefined, query: string, options?: SearchPagesOptions): Promise<SearchResult[]>;
|
|
103
103
|
export interface UpsertPageInput {
|
|
104
104
|
route: string;
|
|
105
105
|
title: string;
|
|
@@ -116,11 +116,11 @@ export interface UpsertPageInput {
|
|
|
116
116
|
/**
|
|
117
117
|
* Insert or update a page
|
|
118
118
|
*/
|
|
119
|
-
export declare function upsertPage(event:
|
|
119
|
+
export declare function upsertPage(event: AiReadyDatabaseEvent | undefined, page: UpsertPageInput): Promise<void>;
|
|
120
120
|
/**
|
|
121
121
|
* Check if a page is fresh (within TTL)
|
|
122
122
|
*/
|
|
123
|
-
export declare function isPageFresh(event:
|
|
123
|
+
export declare function isPageFresh(event: AiReadyDatabaseEvent | undefined, route: string, ttlSeconds: number): Promise<boolean>;
|
|
124
124
|
export interface PageIndexState {
|
|
125
125
|
indexedAt: number;
|
|
126
126
|
contentHash: string | null;
|
|
@@ -133,22 +133,22 @@ export interface PageIndexState {
|
|
|
133
133
|
* hot path needs into a single indexed row read (avoids `SELECT *` and two
|
|
134
134
|
* extra round-trips per page).
|
|
135
135
|
*/
|
|
136
|
-
export declare function getPageIndexState(event:
|
|
136
|
+
export declare function getPageIndexState(event: AiReadyDatabaseEvent | undefined, route: string): Promise<PageIndexState | undefined>;
|
|
137
137
|
/**
|
|
138
138
|
* Get existing content hash for a page (for change detection)
|
|
139
139
|
* @internal
|
|
140
140
|
*/
|
|
141
|
-
export declare function getPageHash(event:
|
|
141
|
+
export declare function getPageHash(event: AiReadyDatabaseEvent | undefined, route: string): Promise<string | null>;
|
|
142
142
|
/**
|
|
143
143
|
* Seed routes from sitemap (insert with indexed=0 if not exists)
|
|
144
144
|
*/
|
|
145
|
-
export declare function seedRoutes(event:
|
|
145
|
+
export declare function seedRoutes(event: AiReadyDatabaseEvent | undefined, routes: Array<string | {
|
|
146
146
|
route: string;
|
|
147
147
|
locale?: string;
|
|
148
148
|
url?: string;
|
|
149
149
|
}>, options?: SeedRoutesOptions): Promise<number>;
|
|
150
150
|
/** Remove a page after its route returns HTTP 410. */
|
|
151
|
-
export declare function prunePage(event:
|
|
151
|
+
export declare function prunePage(event: AiReadyDatabaseEvent | undefined, route: string): Promise<void>;
|
|
152
152
|
/**
|
|
153
153
|
* Prune routes not seen in sitemap for longer than threshold
|
|
154
154
|
* Only prunes routes with source='runtime' (never prerendered pages)
|
|
@@ -157,11 +157,11 @@ export declare function prunePage(event: H3Event | undefined, route: string): Pr
|
|
|
157
157
|
* so the threshold moves back by that window. A live route is then never
|
|
158
158
|
* pruned. Pass the window the seeder used; the default is the largest one.
|
|
159
159
|
*/
|
|
160
|
-
export declare function pruneStaleRoutes(event:
|
|
160
|
+
export declare function pruneStaleRoutes(event: AiReadyDatabaseEvent | undefined, staleThresholdSeconds: number, protectedSince?: number, refreshWindowMs?: number): Promise<number>;
|
|
161
161
|
/**
|
|
162
162
|
* Get stale routes that would be pruned (for preview)
|
|
163
163
|
*/
|
|
164
|
-
export declare function getStaleRoutes(event:
|
|
164
|
+
export declare function getStaleRoutes(event: AiReadyDatabaseEvent | undefined, staleThresholdSeconds: number, refreshWindowMs?: number): Promise<string[]>;
|
|
165
165
|
export interface CronRunRow {
|
|
166
166
|
id: number;
|
|
167
167
|
started_at: DatabaseNumber;
|
|
@@ -185,11 +185,11 @@ export interface CronRun {
|
|
|
185
185
|
/**
|
|
186
186
|
* Start a cron run and return its ID
|
|
187
187
|
*/
|
|
188
|
-
export declare function startCronRun(event:
|
|
188
|
+
export declare function startCronRun(event: AiReadyDatabaseEvent | undefined): Promise<number | null>;
|
|
189
189
|
/**
|
|
190
190
|
* Complete a cron run with results
|
|
191
191
|
*/
|
|
192
|
-
export declare function completeCronRun(event:
|
|
192
|
+
export declare function completeCronRun(event: AiReadyDatabaseEvent | undefined, runId: number, result: {
|
|
193
193
|
pagesIndexed: number;
|
|
194
194
|
pagesRemaining: number;
|
|
195
195
|
errors: string[];
|
|
@@ -197,11 +197,11 @@ export declare function completeCronRun(event: H3Event | undefined, runId: numbe
|
|
|
197
197
|
/**
|
|
198
198
|
* Get recent cron runs
|
|
199
199
|
*/
|
|
200
|
-
export declare function getRecentCronRuns(event:
|
|
200
|
+
export declare function getRecentCronRuns(event: AiReadyDatabaseEvent | undefined, limit?: number): Promise<CronRun[]>;
|
|
201
201
|
/**
|
|
202
202
|
* Clean up cron runs older than specified age
|
|
203
203
|
*/
|
|
204
|
-
export declare function pruneCronRunsByAge(event:
|
|
204
|
+
export declare function pruneCronRunsByAge(event: AiReadyDatabaseEvent | undefined, maxAgeMs?: number): Promise<number>;
|
|
205
205
|
export interface CronFastPathStatus {
|
|
206
206
|
totalPages: number;
|
|
207
207
|
pendingPages: number;
|
|
@@ -213,7 +213,7 @@ export interface CronFastPathStatus {
|
|
|
213
213
|
* Get all cron status in a single query for fast-path checking
|
|
214
214
|
* Reduces 6+ sequential DB calls to 1
|
|
215
215
|
*/
|
|
216
|
-
export declare function getCronFastPathStatus(event:
|
|
216
|
+
export declare function getCronFastPathStatus(event: AiReadyDatabaseEvent | undefined, sitemapIntervalMinutes?: number): Promise<CronFastPathStatus | null>;
|
|
217
217
|
export type CronLockAcquire = {
|
|
218
218
|
_tag: 'acquired';
|
|
219
219
|
token: string;
|
|
@@ -229,12 +229,12 @@ export type CronLockAcquire = {
|
|
|
229
229
|
* two isolates that start in the same millisecond. A legacy value that
|
|
230
230
|
* predates tokens parses as no expiry, so it is treated as expired.
|
|
231
231
|
*/
|
|
232
|
-
export declare function tryAcquireCronLock(event:
|
|
232
|
+
export declare function tryAcquireCronLock(event: AiReadyDatabaseEvent | undefined): Promise<CronLockAcquire>;
|
|
233
233
|
/**
|
|
234
234
|
* Release cron lock. Only deletes the row when its token is ours, so a run
|
|
235
235
|
* that outlived the lock TTL cannot delete the new owner's lock.
|
|
236
236
|
*/
|
|
237
|
-
export declare function releaseCronLock(event:
|
|
237
|
+
export declare function releaseCronLock(event: AiReadyDatabaseEvent | undefined, token: string): Promise<void>;
|
|
238
238
|
export interface CronLockStatus {
|
|
239
239
|
held: boolean;
|
|
240
240
|
since: number | null;
|
|
@@ -244,7 +244,7 @@ export interface CronLockStatus {
|
|
|
244
244
|
/**
|
|
245
245
|
* Get cron lock status for status endpoint
|
|
246
246
|
*/
|
|
247
|
-
export declare function getCronLockStatus(event:
|
|
247
|
+
export declare function getCronLockStatus(event: AiReadyDatabaseEvent | undefined): Promise<CronLockStatus>;
|
|
248
248
|
export interface SitemapEntry {
|
|
249
249
|
name: string;
|
|
250
250
|
route: string;
|
|
@@ -261,7 +261,7 @@ export interface SitemapStatusEntry extends Omit<SitemapEntry, 'crawlState'> {
|
|
|
261
261
|
* Sync sitemap list from config to DB
|
|
262
262
|
* Inserts new sitemaps, removes stale ones
|
|
263
263
|
*/
|
|
264
|
-
export declare function syncSitemaps(event:
|
|
264
|
+
export declare function syncSitemaps(event: AiReadyDatabaseEvent | undefined, sitemaps: Array<{
|
|
265
265
|
name: string;
|
|
266
266
|
route: string;
|
|
267
267
|
}>): Promise<{
|
|
@@ -273,36 +273,36 @@ export declare function syncSitemaps(event: H3Event | undefined, sitemaps: Array
|
|
|
273
273
|
* Prioritizes: in-progress continuations, errors, then oldest crawled
|
|
274
274
|
* Skips sitemaps crawled within minIntervalMinutes (default 5 min)
|
|
275
275
|
*/
|
|
276
|
-
export declare function getNextSitemapToCrawl(event:
|
|
276
|
+
export declare function getNextSitemapToCrawl(event: AiReadyDatabaseEvent | undefined, minIntervalMinutes?: number): Promise<SitemapEntry | null>;
|
|
277
277
|
/**
|
|
278
278
|
* Get the last crawl timestamp for a single sitemap. Used to throttle runtime
|
|
279
279
|
* re-seeding (the sitemap:resolved hook fires on every sitemap request).
|
|
280
280
|
* Returns null when the sitemap row doesn't exist yet.
|
|
281
281
|
*/
|
|
282
|
-
export declare function getSitemapLastCrawledAt(event:
|
|
282
|
+
export declare function getSitemapLastCrawledAt(event: AiReadyDatabaseEvent | undefined, name: string): Promise<number | null>;
|
|
283
283
|
/**
|
|
284
284
|
* Mark sitemap as successfully crawled
|
|
285
285
|
*/
|
|
286
|
-
export declare function markSitemapCrawled(event:
|
|
286
|
+
export declare function markSitemapCrawled(event: AiReadyDatabaseEvent | undefined, name: string, urlCount: number): Promise<void>;
|
|
287
287
|
/**
|
|
288
288
|
* Record a sitemap:resolved hook seed only while no durable crawl is active.
|
|
289
289
|
* The hook may finish in waitUntil after cron has persisted a continuation.
|
|
290
290
|
*/
|
|
291
|
-
export declare function markSitemapSeeded(event:
|
|
291
|
+
export declare function markSitemapSeeded(event: AiReadyDatabaseEvent | undefined, name: string, urlCount: number, expectedLastCrawledAt: number | null): Promise<void>;
|
|
292
292
|
/** Persist a resumable sitemap crawl without incrementing its error budget. */
|
|
293
|
-
export declare function markSitemapCrawlPartial(event:
|
|
293
|
+
export declare function markSitemapCrawlPartial(event: AiReadyDatabaseEvent | undefined, name: string, state: SitemapCrawlState): Promise<void>;
|
|
294
294
|
/**
|
|
295
295
|
* Mark sitemap crawl as failed
|
|
296
296
|
*/
|
|
297
|
-
export declare function markSitemapError(event:
|
|
297
|
+
export declare function markSitemapError(event: AiReadyDatabaseEvent | undefined, name: string, error: string): Promise<void>;
|
|
298
298
|
/**
|
|
299
299
|
* Reset all sitemap errors (called on build_id change)
|
|
300
300
|
*/
|
|
301
|
-
export declare function resetSitemapErrors(event:
|
|
301
|
+
export declare function resetSitemapErrors(event: AiReadyDatabaseEvent | undefined): Promise<number>;
|
|
302
302
|
/**
|
|
303
303
|
* Get all sitemaps with their status
|
|
304
304
|
*/
|
|
305
|
-
export declare function getSitemapStatus(event:
|
|
305
|
+
export declare function getSitemapStatus(event: AiReadyDatabaseEvent | undefined): Promise<SitemapStatusEntry[]>;
|
|
306
306
|
export interface RecentPageActivity {
|
|
307
307
|
route: string;
|
|
308
308
|
title: string;
|
|
@@ -311,8 +311,8 @@ export interface RecentPageActivity {
|
|
|
311
311
|
/**
|
|
312
312
|
* Get recently indexed pages
|
|
313
313
|
*/
|
|
314
|
-
export declare function getRecentlyIndexedPages(event:
|
|
314
|
+
export declare function getRecentlyIndexedPages(event: AiReadyDatabaseEvent | undefined, limit?: number): Promise<RecentPageActivity[]>;
|
|
315
315
|
/**
|
|
316
316
|
* Count pages indexed in a time window
|
|
317
317
|
*/
|
|
318
|
-
export declare function countRecentlyIndexed(event:
|
|
318
|
+
export declare function countRecentlyIndexed(event: AiReadyDatabaseEvent | undefined, sinceMs: number): Promise<number>;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { initSchema, useRawDb } from "#ai-ready-virtual/database-runtime.mjs";
|
|
2
2
|
import { useEvent, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
3
|
import { logger } from "../logger.js";
|
|
4
4
|
import { checkAndHandleStale } from "../utils/checkStale.js";
|
|
5
5
|
import { parseSitemapCrawlState, serializeSitemapCrawlState } from "../utils/sitemap-crawl-state.js";
|
|
6
|
-
import { initSchema } from "./drizzle/queries.js";
|
|
7
|
-
import { useRawDb } from "./drizzle/raw.js";
|
|
8
6
|
import { deriveLocale, SEED_REFRESH_WINDOW_MS } from "./seed.js";
|
|
9
|
-
import { LIKE_ESCAPE, likeSubstring, maxRowsPerInsert, normalizeRoute, normalizeRouteKey } from "./shared.js";
|
|
7
|
+
import { LIKE_ESCAPE, likeSubstring, maxRowsPerInsert, normalizeRoute, normalizeRouteKey, toFtsMatchQuery } from "./shared.js";
|
|
10
8
|
export { resolveSeedRefreshWindowMs, SEED_REFRESH_WINDOW_MS } from "./seed.js";
|
|
11
9
|
function getEventFromContext(providedEvent) {
|
|
12
10
|
if (providedEvent)
|
|
@@ -38,7 +36,6 @@ function syncBuildDump(event) {
|
|
|
38
36
|
return promise;
|
|
39
37
|
}
|
|
40
38
|
const RE_FTS_CHARS = /[*:^"()]/g;
|
|
41
|
-
const RE_WHITESPACE = /\s+/;
|
|
42
39
|
async function getDb(event) {
|
|
43
40
|
if (import.meta.dev) {
|
|
44
41
|
if (!devNoticeShown) {
|
|
@@ -51,7 +48,7 @@ async function getDb(event) {
|
|
|
51
48
|
return getPrerenderDb();
|
|
52
49
|
}
|
|
53
50
|
const resolvedEvent = getEventFromContext(event);
|
|
54
|
-
const cfg = useRuntimeConfig(
|
|
51
|
+
const cfg = useRuntimeConfig();
|
|
55
52
|
const database = cfg["nuxt-ai-ready"]?.database?._tag;
|
|
56
53
|
if (database === "Disabled")
|
|
57
54
|
return null;
|
|
@@ -289,7 +286,9 @@ export async function searchPages(event, query, options = {}) {
|
|
|
289
286
|
LIMIT ?
|
|
290
287
|
`, [searchTerm, LIKE_ESCAPE, searchTerm, LIKE_ESCAPE, searchTerm, LIKE_ESCAPE, searchTerm, LIKE_ESCAPE, limit]);
|
|
291
288
|
}
|
|
292
|
-
const
|
|
289
|
+
const ftsQuery = toFtsMatchQuery(query);
|
|
290
|
+
if (!ftsQuery)
|
|
291
|
+
return [];
|
|
293
292
|
return db.all(`
|
|
294
293
|
SELECT p.route, p.title, p.description, bm25(ai_ready_pages_fts, 5.0, 3.0, 1.0, 0.5, 2.0, 2.0) as score
|
|
295
294
|
FROM ai_ready_pages_fts
|
|
@@ -297,7 +296,7 @@ export async function searchPages(event, query, options = {}) {
|
|
|
297
296
|
WHERE ai_ready_pages_fts MATCH ?
|
|
298
297
|
ORDER BY score
|
|
299
298
|
LIMIT ?
|
|
300
|
-
`, [
|
|
299
|
+
`, [ftsQuery, limit]);
|
|
301
300
|
}
|
|
302
301
|
export async function upsertPage(event, page) {
|
|
303
302
|
const db = await getDb(event);
|
|
@@ -542,7 +541,7 @@ function cronLockField(db, column, key) {
|
|
|
542
541
|
return `CASE WHEN jsonb_typeof(${jsonb}) = 'object' THEN (${jsonb} ->> '${key}') END`;
|
|
543
542
|
}
|
|
544
543
|
export async function tryAcquireCronLock(event) {
|
|
545
|
-
const token = randomUUID();
|
|
544
|
+
const token = crypto.randomUUID();
|
|
546
545
|
const db = await getDb(event);
|
|
547
546
|
if (!db)
|
|
548
547
|
return { _tag: "acquired", token };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AiReadyDatabaseEvent } from './context.js';
|
|
2
2
|
/**
|
|
3
3
|
* Resolve a route's locale, deferring to the explicit value when supplied.
|
|
4
4
|
* Falls back to the runtime i18n config (set when @nuxtjs/i18n is detected at
|
|
@@ -13,7 +13,7 @@ import type { H3Event } from '#nuxtseo/h3';
|
|
|
13
13
|
* page on multi-domain i18n sites
|
|
14
14
|
* 3. the site config host
|
|
15
15
|
*/
|
|
16
|
-
export declare function deriveLocale(event:
|
|
16
|
+
export declare function deriveLocale(event: AiReadyDatabaseEvent | undefined, route: string, explicit?: string, pageUrl?: string): string;
|
|
17
17
|
/** Longest time `seedRoutes` lets `last_seen_at` lag behind a sighting. */
|
|
18
18
|
export declare const SEED_REFRESH_WINDOW_MS: number;
|
|
19
19
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getRequestHost } from "#nuxtseo/h3";
|
|
2
1
|
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
2
|
import { createUniversalContext } from "../utils/context.js";
|
|
4
3
|
import { resolveI18nDomain, resolveLocaleFromRoute } from "../utils/i18n.js";
|
|
@@ -14,7 +13,7 @@ function hostFromUrl(url) {
|
|
|
14
13
|
export function deriveLocale(event, route, explicit, pageUrl) {
|
|
15
14
|
if (explicit !== void 0)
|
|
16
15
|
return explicit;
|
|
17
|
-
const cfg = useRuntimeConfig(
|
|
16
|
+
const cfg = useRuntimeConfig();
|
|
18
17
|
const i18n = cfg["nuxt-ai-ready"]?.i18n;
|
|
19
18
|
if (!i18n)
|
|
20
19
|
return "";
|
|
@@ -24,7 +23,9 @@ export function deriveLocale(event, route, explicit, pageUrl) {
|
|
|
24
23
|
let requestHost;
|
|
25
24
|
if (event) {
|
|
26
25
|
try {
|
|
27
|
-
|
|
26
|
+
const headers = event.req?.headers || event.node?.req.headers;
|
|
27
|
+
const host2 = headers instanceof Headers ? headers.get("x-forwarded-host") || headers.get("host") : headers?.["x-forwarded-host"] || headers?.host;
|
|
28
|
+
requestHost = (Array.isArray(host2) ? host2[0] : host2)?.split(",")[0]?.trim();
|
|
28
29
|
} catch {
|
|
29
30
|
requestHost = void 0;
|
|
30
31
|
}
|
|
@@ -57,6 +57,14 @@ export declare function escapeLikeTerm(term: string): string;
|
|
|
57
57
|
export declare function likeSubstring(term: string): string;
|
|
58
58
|
/** Escape character to bind next to `likeSubstring` patterns. */
|
|
59
59
|
export declare const LIKE_ESCAPE = "\\";
|
|
60
|
+
/**
|
|
61
|
+
* Turn free text into an FTS5 MATCH expression that cannot throw. Each term
|
|
62
|
+
* becomes a quoted FTS5 string, so `-`, `.`, `'`, `AND`, `NOT` and `col:`
|
|
63
|
+
* filters stay literal text. The trailing `*` keeps prefix matching for
|
|
64
|
+
* partial words. A term with no letter or digit holds no token, so it is
|
|
65
|
+
* dropped. Returns null when no term remains.
|
|
66
|
+
*/
|
|
67
|
+
export declare function toFtsMatchQuery(query: string): string | null;
|
|
60
68
|
/**
|
|
61
69
|
* Multi-row INSERT chunk size that keeps one statement within the 100-bind
|
|
62
70
|
* cap shared by SQLite and D1, derived from the row's bind count so an added
|