nuxt-ai-ready 2.5.3 → 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.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.js +47 -22
- 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/node_modules/@emnapi/wasi-threads/LICENSE +0 -21
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/README.md +0 -203
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +0 -236
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +0 -1086
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/package.json +0 -35
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/rollup.config.js +0 -6
- 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 -240
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +0 -1118
- 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 -17578
- 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,4 +1,3 @@
|
|
|
1
|
-
import { subtle } from "uncrypto";
|
|
2
1
|
import { isMap, isScalar, parseDocument } from "yaml";
|
|
3
2
|
import { buildSchemaSql, DROP_TABLES_SQL, resolveFtsTokenizer, SCHEMA_VERSION } from "./schema-sql.js";
|
|
4
3
|
const LEADING_BLOCK_RE = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;
|
|
@@ -16,7 +15,7 @@ function stripPageFrontmatter(markdown) {
|
|
|
16
15
|
export async function computeContentHash(markdown) {
|
|
17
16
|
const encoder = new TextEncoder();
|
|
18
17
|
const data = encoder.encode(stripPageFrontmatter(markdown).trim());
|
|
19
|
-
const hashBuffer = await subtle.digest("SHA-256", data);
|
|
18
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
20
19
|
const hashArray = [...new Uint8Array(hashBuffer)];
|
|
21
20
|
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
22
21
|
}
|
|
@@ -78,6 +77,13 @@ export function likeSubstring(term) {
|
|
|
78
77
|
return `%${escapeLikeTerm(term)}%`;
|
|
79
78
|
}
|
|
80
79
|
export const LIKE_ESCAPE = "\\";
|
|
80
|
+
const RE_FTS_TERM_SPLIT = /\s+/;
|
|
81
|
+
const RE_FTS_TOKEN_CHAR = /[\p{L}\p{N}]/u;
|
|
82
|
+
const RE_DOUBLE_QUOTE = /"/g;
|
|
83
|
+
export function toFtsMatchQuery(query) {
|
|
84
|
+
const terms = query.split(RE_FTS_TERM_SPLIT).filter((term) => RE_FTS_TOKEN_CHAR.test(term)).map((term) => `"${term.replace(RE_DOUBLE_QUOTE, '""')}"*`);
|
|
85
|
+
return terms.length ? terms.join(" ") : null;
|
|
86
|
+
}
|
|
81
87
|
const MAX_BIND_PARAMS_PER_STATEMENT = 100;
|
|
82
88
|
export function maxRowsPerInsert(paramsPerRow) {
|
|
83
89
|
return Math.max(1, Math.floor(MAX_BIND_PARAMS_PER_STATEMENT / paramsPerRow));
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { closeDrizzle, countPages, getPageLastmods, getStaleRoutes, indexPage, indexPageByRoute, isPageFresh, pruneStaleRoutes, queryPages, searchPages, seedRoutes, streamPages, upsertPage, useDrizzle, useRawDb, } from '../index.js';
|
|
2
|
+
export type { CountPagesOptions, DatabaseDialect, DrizzleDatabase, IndexPageOptions, IndexPageResult, MarkdownContext, PageData, PageEntry, PageIndexedContext, PageRow, QueryPagesOptions, RawExecutor, SearchPagesOptions, SearchResult, StreamPagesOptions, UpsertPageInput, } from '../index.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export {
|
|
2
|
+
closeDrizzle,
|
|
3
|
+
countPages,
|
|
4
|
+
getPageLastmods,
|
|
5
|
+
getStaleRoutes,
|
|
6
|
+
indexPage,
|
|
7
|
+
indexPageByRoute,
|
|
8
|
+
isPageFresh,
|
|
9
|
+
pruneStaleRoutes,
|
|
10
|
+
queryPages,
|
|
11
|
+
searchPages,
|
|
12
|
+
seedRoutes,
|
|
13
|
+
streamPages,
|
|
14
|
+
upsertPage,
|
|
15
|
+
useDrizzle,
|
|
16
|
+
useRawDb
|
|
17
|
+
} from "../index.js";
|
|
@@ -11,7 +11,7 @@ const tool = {
|
|
|
11
11
|
title: SITE_TOOL_CATALOG.get_page_markdown.title,
|
|
12
12
|
description: SITE_TOOL_CATALOG.get_page_markdown.description,
|
|
13
13
|
inputSchema,
|
|
14
|
-
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
14
|
+
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
|
|
15
15
|
enabled: () => siteTools.getPageMarkdown.mcp.enabled,
|
|
16
16
|
cache: "5m",
|
|
17
17
|
async handler({ route }) {
|
|
@@ -14,7 +14,7 @@ const tool = {
|
|
|
14
14
|
title: SITE_TOOL_CATALOG.list_pages.title,
|
|
15
15
|
description: SITE_TOOL_CATALOG.list_pages.description,
|
|
16
16
|
inputSchema,
|
|
17
|
-
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
17
|
+
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
|
|
18
18
|
enabled: () => siteTools.listPages.mcp.enabled,
|
|
19
19
|
cache: "1h",
|
|
20
20
|
async handler({ limit, offset }) {
|
|
@@ -14,7 +14,7 @@ const tool = {
|
|
|
14
14
|
title: SITE_TOOL_CATALOG.search_pages.title,
|
|
15
15
|
description: SITE_TOOL_CATALOG.search_pages.description,
|
|
16
16
|
inputSchema,
|
|
17
|
-
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
17
|
+
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
|
|
18
18
|
enabled: () => siteTools.searchPages.mcp.enabled,
|
|
19
19
|
cache: "5m",
|
|
20
20
|
async handler({ query, limit }) {
|
|
@@ -38,7 +38,7 @@ export default defineEventHandler(async (event) => {
|
|
|
38
38
|
const { path } = renderInfo;
|
|
39
39
|
const runtimeConfig = fullRuntimeConfig["nuxt-ai-ready"];
|
|
40
40
|
const deployedPath = toDeployedRoute(path, fullRuntimeConfig.app.baseURL);
|
|
41
|
-
const canonicalUrl = withSiteUrl(event, deployedPath);
|
|
41
|
+
const canonicalUrl = withSiteUrl(event, deployedPath, { withBase: true });
|
|
42
42
|
const contentPage = await tryGetContentMarkdown(event, path).catch((error) => {
|
|
43
43
|
logger.debug(`[markdown.prerender] Content lookup failed for ${path}`, error);
|
|
44
44
|
return null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineNitroPlugin } from "#nuxtseo/nitro";
|
|
2
|
+
import { DB_CONTEXT_KEY, DB_PROMISE_CONTEXT_KEY, DB_WORK_CONTEXT_KEY } from "../db/context.js";
|
|
3
|
+
export default defineNitroPlugin((nitroApp) => {
|
|
4
|
+
const hooks = nitroApp.hooks;
|
|
5
|
+
hooks.hook("response", async (_response, event) => {
|
|
6
|
+
if (!event.context?.[DB_CONTEXT_KEY] && !event.context?.[DB_PROMISE_CONTEXT_KEY] && !event.context?.[DB_WORK_CONTEXT_KEY]) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const { finishDrizzleResponse } = await import("../db/index.js");
|
|
10
|
+
await finishDrizzleResponse(event);
|
|
11
|
+
});
|
|
12
|
+
hooks.hook("close", async () => {
|
|
13
|
+
const { closeDrizzle } = await import("../db/index.js");
|
|
14
|
+
await closeDrizzle();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { getRequestURL } from "#nuxtseo/h3";
|
|
2
|
+
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
|
+
import { toLogicalRoute } from "../../route-path.js";
|
|
1
4
|
import { storePrerenderedHtml } from "../utils/prerender-html.js";
|
|
2
5
|
export default function htmlCapturePlugin(nitroApp) {
|
|
3
6
|
if (!import.meta.prerender)
|
|
4
7
|
return;
|
|
5
|
-
nitroApp.hooks.hook("render:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
storePrerenderedHtml(event.path, response.body);
|
|
8
|
+
nitroApp.hooks.hook("render:html", (html, { event }) => {
|
|
9
|
+
const baseURL = useRuntimeConfig(event).app.baseURL;
|
|
10
|
+
storePrerenderedHtml(toLogicalRoute(getRequestURL(event).pathname, baseURL), html);
|
|
9
11
|
});
|
|
10
12
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineNitroPlugin } from "#nuxtseo/nitro";
|
|
2
|
+
import { ERROR_LINK_HEADER, STATUS_AWARE_LINK_HEADER } from "./link-header.js";
|
|
3
|
+
function readHeader(event) {
|
|
4
|
+
return event.context[STATUS_AWARE_LINK_HEADER];
|
|
5
|
+
}
|
|
6
|
+
export default defineNitroPlugin((nitro) => {
|
|
7
|
+
const hooks = nitro.hooks;
|
|
8
|
+
hooks.hook("error", (_error, { event }) => {
|
|
9
|
+
if (!event)
|
|
10
|
+
return;
|
|
11
|
+
const header = readHeader(event);
|
|
12
|
+
if (header)
|
|
13
|
+
event.req.headers.set(ERROR_LINK_HEADER, header.error);
|
|
14
|
+
});
|
|
15
|
+
hooks.hook("response", (response, event) => {
|
|
16
|
+
const header = readHeader(event);
|
|
17
|
+
if (header)
|
|
18
|
+
response.headers.set("link", response.status >= 400 ? header.error : header.success);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { H3Event } from '#nuxtseo/h3';
|
|
2
|
+
export declare const STATUS_AWARE_LINK_HEADER = "nuxt-ai-ready:status-aware-link-header";
|
|
3
|
+
export declare const ERROR_LINK_HEADER = "x-nuxt-ai-ready-error-link";
|
|
4
|
+
export interface StatusAwareLinkHeader {
|
|
5
|
+
error: string;
|
|
6
|
+
success: string;
|
|
7
|
+
}
|
|
2
8
|
export declare function setStatusAwareLinkHeader(event: H3Event, safeHeader: string, successHeader?: string): void;
|
|
3
9
|
declare const _default: any;
|
|
4
10
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getHeader, getResponseStatus, setHeader } from "#nuxtseo/h3";
|
|
2
2
|
import { defineNitroPlugin } from "#nuxtseo/nitro";
|
|
3
|
-
const STATUS_AWARE_LINK_HEADER = "nuxt-ai-ready:status-aware-link-header";
|
|
4
|
-
const ERROR_LINK_HEADER = "x-nuxt-ai-ready-error-link";
|
|
3
|
+
export const STATUS_AWARE_LINK_HEADER = "nuxt-ai-ready:status-aware-link-header";
|
|
4
|
+
export const ERROR_LINK_HEADER = "x-nuxt-ai-ready-error-link";
|
|
5
5
|
export function setStatusAwareLinkHeader(event, safeHeader, successHeader) {
|
|
6
6
|
event.context[STATUS_AWARE_LINK_HEADER] = {
|
|
7
7
|
error: safeHeader,
|
|
@@ -23,18 +23,14 @@ export default defineNitroPlugin((nitro) => {
|
|
|
23
23
|
return;
|
|
24
24
|
setHeader(event, "link", getResponseStatus(event) >= 400 ? header.error : header.success);
|
|
25
25
|
});
|
|
26
|
-
nitro.hooks.hook("render:
|
|
26
|
+
nitro.hooks.hook("render:html", (_html, { event }) => {
|
|
27
27
|
const header = event.context[STATUS_AWARE_LINK_HEADER];
|
|
28
|
-
const errorHeader = event.path.startsWith("/__nuxt_error")
|
|
28
|
+
const errorHeader = event.path.startsWith("/__nuxt_error") ? getHeader(event, ERROR_LINK_HEADER) : void 0;
|
|
29
29
|
if (errorHeader) {
|
|
30
|
-
|
|
31
|
-
response.headers.link = errorHeader;
|
|
30
|
+
setHeader(event, "link", errorHeader);
|
|
32
31
|
return;
|
|
33
32
|
}
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
response.headers ||= {};
|
|
37
|
-
const statusCode = response.statusCode ?? getResponseStatus(event);
|
|
38
|
-
response.headers.link = statusCode >= 400 ? header.error : header.success;
|
|
33
|
+
if (header)
|
|
34
|
+
setHeader(event, "link", getResponseStatus(event) >= 400 ? header.error : header.success);
|
|
39
35
|
});
|
|
40
36
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineEventHandler } from "#nuxtseo/h3";
|
|
2
2
|
import { defineNitroPlugin, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
3
|
import { logger } from "../logger.js";
|
|
4
|
+
import { serveCloudflarePrerenderedPage } from "../utils/cloudflare-prerendered.js";
|
|
4
5
|
import { applyNegotiation, decideNegotiation } from "../utils/negotiation-response.js";
|
|
5
6
|
function isH3App(candidate) {
|
|
6
7
|
if (!candidate || typeof candidate !== "object")
|
|
@@ -21,7 +22,13 @@ function resolveH3Runtime(candidate) {
|
|
|
21
22
|
return { _tag: "h3-v2", app: nitro.h3 };
|
|
22
23
|
return { _tag: "unsupported" };
|
|
23
24
|
}
|
|
24
|
-
const negotiationHandler = defineEventHandler((event) =>
|
|
25
|
+
const negotiationHandler = defineEventHandler(async (event) => {
|
|
26
|
+
const decision = decideNegotiation(event, "early");
|
|
27
|
+
const response = await applyNegotiation(event, decision);
|
|
28
|
+
if (response !== void 0 || decision._tag !== "html")
|
|
29
|
+
return response;
|
|
30
|
+
return serveCloudflarePrerenderedPage(event);
|
|
31
|
+
});
|
|
25
32
|
export default defineNitroPlugin((nitro) => {
|
|
26
33
|
const runtime = resolveH3Runtime(nitro);
|
|
27
34
|
if (runtime._tag === "unsupported") {
|
|
@@ -4,8 +4,8 @@ import { getPageLastmods, getSitemapLastCrawledAt, markSitemapSeeded, resolveSee
|
|
|
4
4
|
import { logger } from "../logger.js";
|
|
5
5
|
import { mapSitemapRoutes } from "../utils/sitemap-routes.js";
|
|
6
6
|
const DIAGNOSTICS_KEY = "_aiReadySitemapDiagnostics";
|
|
7
|
-
function isDebug(
|
|
8
|
-
return !!useRuntimeConfig(
|
|
7
|
+
function isDebug(_event) {
|
|
8
|
+
return !!useRuntimeConfig()["nuxt-ai-ready"]?.debug;
|
|
9
9
|
}
|
|
10
10
|
function recordDiagnostic(event, message) {
|
|
11
11
|
const ctx = event.context;
|
|
@@ -96,7 +96,7 @@ export default function sitemapSeederPlugin(nitroApp) {
|
|
|
96
96
|
const urlCount = urls.length;
|
|
97
97
|
const seed = async () => {
|
|
98
98
|
const seedStart = Date.now();
|
|
99
|
-
const pruneTtl = useRuntimeConfig(
|
|
99
|
+
const pruneTtl = useRuntimeConfig()["nuxt-ai-ready"]?.runtimeSync?.pruneTtl ?? 0;
|
|
100
100
|
const seeded = await seedRoutes(event, routes, { refreshWindowMs: resolveSeedRefreshWindowMs(pruneTtl) }).catch((e) => {
|
|
101
101
|
logger.warn(`[sitemap-seeder] Failed to seed routes: ${e.message}`);
|
|
102
102
|
return 0;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: any
|
|
1
|
+
declare const _default: import("nuxt/server").EventHandler<any>;
|
|
2
2
|
export default _default;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
import { createError, defineEventHandler, getRequestURL, useRuntimeConfig } from "nuxt/server";
|
|
1
2
|
import { localAgentSkillArtifacts } from "#ai-ready-virtual/agent-skills.mjs";
|
|
2
|
-
import { assertMethod, createError, eventHandler, getRequestURL, setHeader } from "#nuxtseo/h3";
|
|
3
|
-
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
4
3
|
import { publicCacheControl } from "../../cache-control.js";
|
|
5
4
|
import { toLogicalRoute } from "../../route-path.js";
|
|
6
|
-
export default
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export default defineEventHandler((event) => {
|
|
6
|
+
if (!["GET", "HEAD"].includes(event.req.method))
|
|
7
|
+
throw createError({ status: 405, statusText: "Method Not Allowed" });
|
|
8
|
+
const path = toLogicalRoute(getRequestURL(event).pathname, useRuntimeConfig().app.baseURL);
|
|
9
9
|
const content = localAgentSkillArtifacts[path];
|
|
10
10
|
if (content === void 0) {
|
|
11
11
|
throw createError({
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
status: 404,
|
|
13
|
+
statusText: "Agent skill artifact not found"
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
event.res.headers.set("Content-Type", "text/markdown; charset=utf-8");
|
|
17
|
+
event.res.headers.set("Cache-Control", publicCacheControl(3600, 86400));
|
|
18
|
+
event.res.headers.set("Access-Control-Allow-Origin", "*");
|
|
19
19
|
return content;
|
|
20
20
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: any
|
|
1
|
+
declare const _default: import("nuxt/server").EventHandler<any>;
|
|
2
2
|
export default _default;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { createError, defineEventHandler } from "nuxt/server";
|
|
1
2
|
import { agentSkillsIndex } from "#ai-ready-virtual/agent-skills.mjs";
|
|
2
|
-
import { assertMethod, eventHandler, setHeader } from "#nuxtseo/h3";
|
|
3
3
|
import { publicCacheControl } from "../../cache-control.js";
|
|
4
|
-
export default
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export default defineEventHandler((event) => {
|
|
5
|
+
if (!["GET", "HEAD"].includes(event.req.method))
|
|
6
|
+
throw createError({ status: 405, statusText: "Method Not Allowed" });
|
|
7
|
+
event.res.headers.set("Content-Type", "application/json; charset=utf-8");
|
|
8
|
+
event.res.headers.set("Cache-Control", publicCacheControl(3600, 86400));
|
|
9
|
+
event.res.headers.set("Access-Control-Allow-Origin", "*");
|
|
9
10
|
return agentSkillsIndex;
|
|
10
11
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
1
|
+
import { defineEventHandler, getRequestHeader, setResponseStatus, useRuntimeConfig } from "nuxt/server";
|
|
3
2
|
import { AI_CATALOG_MEDIA_TYPE, matchesDiscoveryEtag } from "../utils/discovery-response.js";
|
|
4
|
-
export default
|
|
5
|
-
const config = useRuntimeConfig(
|
|
6
|
-
|
|
3
|
+
export default defineEventHandler((event) => {
|
|
4
|
+
const config = useRuntimeConfig()["nuxt-ai-ready"];
|
|
5
|
+
Object.entries({
|
|
7
6
|
"Access-Control-Allow-Headers": "Content-Type, If-None-Match",
|
|
8
7
|
"Access-Control-Allow-Methods": "GET, HEAD",
|
|
9
8
|
"Access-Control-Allow-Origin": "*",
|
|
@@ -11,12 +10,12 @@ export default eventHandler((event) => {
|
|
|
11
10
|
"Cache-Control": `public, max-age=${config.aiCatalog.cacheMaxAge}`,
|
|
12
11
|
"Content-Type": AI_CATALOG_MEDIA_TYPE,
|
|
13
12
|
"ETag": config.aiCatalog.etag
|
|
14
|
-
});
|
|
15
|
-
if (event.method === "OPTIONS") {
|
|
13
|
+
}).forEach(([name, value]) => event.res.headers.set(name, value));
|
|
14
|
+
if (event.req.method === "OPTIONS") {
|
|
16
15
|
setResponseStatus(event, 204);
|
|
17
16
|
return null;
|
|
18
17
|
}
|
|
19
|
-
if (matchesDiscoveryEtag(
|
|
18
|
+
if (matchesDiscoveryEtag(getRequestHeader(event, "if-none-match"), config.aiCatalog.etag)) {
|
|
20
19
|
setResponseStatus(event, 304);
|
|
21
20
|
return null;
|
|
22
21
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
1
|
+
import { createError, defineEventHandler, setResponseStatus, useRuntimeConfig } from "nuxt/server";
|
|
3
2
|
export default defineEventHandler((event) => {
|
|
4
|
-
|
|
5
|
-
if (event.method === "OPTIONS") {
|
|
6
|
-
|
|
3
|
+
event.res.headers.set("Access-Control-Allow-Origin", "*");
|
|
4
|
+
if (event.req.method === "OPTIONS") {
|
|
5
|
+
Object.entries({
|
|
7
6
|
"Access-Control-Allow-Headers": "Content-Type, If-None-Match",
|
|
8
7
|
"Access-Control-Allow-Methods": "GET, HEAD"
|
|
9
|
-
});
|
|
8
|
+
}).forEach(([name, value]) => event.res.headers.set(name, value));
|
|
10
9
|
setResponseStatus(event, 204);
|
|
11
10
|
return null;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
if (!["GET", "HEAD"].includes(event.req.method))
|
|
13
|
+
throw createError({ status: 405, statusText: "Method Not Allowed" });
|
|
14
|
+
const config = useRuntimeConfig()["nuxt-ai-ready"].apiCatalog;
|
|
15
15
|
if (!config)
|
|
16
|
-
throw createError({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (event.method === "HEAD")
|
|
16
|
+
throw createError({ status: 404, message: "API catalog is not configured" });
|
|
17
|
+
event.res.headers.set("content-type", config.mediaType);
|
|
18
|
+
event.res.headers.set("link", `<${config.href}>; rel="api-catalog"`);
|
|
19
|
+
if (event.req.method === "HEAD")
|
|
20
20
|
return;
|
|
21
21
|
return config.document;
|
|
22
22
|
});
|
|
@@ -15,7 +15,7 @@ export default eventHandler(async (event) => {
|
|
|
15
15
|
const config = runtimeConfig["nuxt-ai-ready"];
|
|
16
16
|
const siteConfig = getSiteConfig(event);
|
|
17
17
|
const baseURL = runtimeConfig.app.baseURL;
|
|
18
|
-
const canonicalSiteUrl = siteConfig.url ? withSiteUrl(event, toDeployedRoute("/", baseURL)) : void 0;
|
|
18
|
+
const canonicalSiteUrl = siteConfig.url ? withSiteUrl(event, toDeployedRoute("/", baseURL), { withBase: true }) : void 0;
|
|
19
19
|
const header = buildLlmsFullTxtHeader(
|
|
20
20
|
{
|
|
21
21
|
name: siteConfig.name,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("nuxt/server").EventHandler<Record<string, unknown> | null>;
|
|
2
2
|
export default _default;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
1
|
+
import { defineEventHandler, getRequestHeader, setResponseStatus, useRuntimeConfig } from "nuxt/server";
|
|
3
2
|
import { matchesDiscoveryEtag, MCP_SERVER_CARD_MEDIA_TYPE } from "../utils/discovery-response.js";
|
|
4
|
-
export default
|
|
5
|
-
const config = useRuntimeConfig(
|
|
6
|
-
|
|
3
|
+
export default defineEventHandler((event) => {
|
|
4
|
+
const config = useRuntimeConfig()["nuxt-ai-ready"];
|
|
5
|
+
Object.entries({
|
|
7
6
|
"Access-Control-Allow-Headers": "Content-Type, If-None-Match",
|
|
8
7
|
"Access-Control-Allow-Methods": "GET, HEAD",
|
|
9
8
|
"Access-Control-Allow-Origin": "*",
|
|
@@ -11,12 +10,12 @@ export default eventHandler((event) => {
|
|
|
11
10
|
"Cache-Control": `public, max-age=${config.mcpServerCard.cacheMaxAge}`,
|
|
12
11
|
"Content-Type": MCP_SERVER_CARD_MEDIA_TYPE,
|
|
13
12
|
"ETag": config.mcpServerCard.etag
|
|
14
|
-
});
|
|
15
|
-
if (event.method === "OPTIONS") {
|
|
13
|
+
}).forEach(([name, value]) => event.res.headers.set(name, value));
|
|
14
|
+
if (event.req.method === "OPTIONS") {
|
|
16
15
|
setResponseStatus(event, 204);
|
|
17
16
|
return null;
|
|
18
17
|
}
|
|
19
|
-
if (matchesDiscoveryEtag(
|
|
18
|
+
if (matchesDiscoveryEtag(getRequestHeader(event, "if-none-match"), config.mcpServerCard.etag)) {
|
|
20
19
|
setResponseStatus(event, 304);
|
|
21
20
|
return null;
|
|
22
21
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AiReadyDatabaseEvent } from '../db/context.js';
|
|
2
2
|
export interface BuildMeta {
|
|
3
3
|
buildId: string;
|
|
4
4
|
pageCount: number;
|
|
@@ -25,4 +25,4 @@ export declare const STALE_CHECK_INTERVAL_MS: number;
|
|
|
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
|
*/
|
|
28
|
-
export declare function checkAndHandleStale(event?:
|
|
28
|
+
export declare function checkAndHandleStale(event?: AiReadyDatabaseEvent): Promise<StaleCheckResult>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getRequestHeaders, getRequestURL, getResponseHeaders } from "#nuxtseo/h3";
|
|
2
|
+
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
|
+
import { mergeVaryHeader } from "../../cache-control.js";
|
|
4
|
+
export async function serveCloudflarePrerenderedPage(event) {
|
|
5
|
+
if (event.method !== "GET" && event.method !== "HEAD")
|
|
6
|
+
return;
|
|
7
|
+
const config = useRuntimeConfig(event)["nuxt-ai-ready"];
|
|
8
|
+
const url = getRequestURL(event);
|
|
9
|
+
if (!config.cloudflarePrerenderedPages?.includes(url.pathname))
|
|
10
|
+
return;
|
|
11
|
+
const assets = event.context.cloudflare?.env?.ASSETS;
|
|
12
|
+
if (!assets)
|
|
13
|
+
return;
|
|
14
|
+
const response = await assets.fetch(new Request(url, { method: event.method, headers: getRequestHeaders(event) }));
|
|
15
|
+
const headers = new Headers(response.headers);
|
|
16
|
+
for (const [name, value] of Object.entries(getResponseHeaders(event))) {
|
|
17
|
+
if (value === void 0)
|
|
18
|
+
continue;
|
|
19
|
+
const header = Array.isArray(value) ? value.join(", ") : String(value);
|
|
20
|
+
headers.set(name, name.toLowerCase() === "vary" ? mergeVaryHeader(headers.get(name) ?? void 0, header) : header);
|
|
21
|
+
}
|
|
22
|
+
return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
|
|
23
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AiReadyDatabaseEvent } from '../db/context.js';
|
|
2
2
|
export interface CloudflareEnv {
|
|
3
3
|
ASSETS?: {
|
|
4
4
|
fetch: (req: Request | string) => Promise<Response>;
|
|
@@ -7,15 +7,15 @@ export interface CloudflareEnv {
|
|
|
7
7
|
/**
|
|
8
8
|
* Get Cloudflare environment from event context or globalThis.__env__ (for scheduled tasks)
|
|
9
9
|
*/
|
|
10
|
-
export declare function getCfEnv(event?:
|
|
10
|
+
export declare function getCfEnv(event?: AiReadyDatabaseEvent): CloudflareEnv | undefined;
|
|
11
11
|
/**
|
|
12
12
|
* Check if Cloudflare ASSETS binding is available
|
|
13
13
|
*/
|
|
14
|
-
export declare function hasAssets(event?:
|
|
14
|
+
export declare function hasAssets(event?: AiReadyDatabaseEvent): boolean;
|
|
15
15
|
/**
|
|
16
16
|
* Fetch a public asset, preferring Cloudflare ASSETS binding when available.
|
|
17
|
-
* Falls back to
|
|
17
|
+
* Falls back to Nitro localFetch with a timeout for unavailable assets.
|
|
18
18
|
*/
|
|
19
|
-
export declare function fetchPublicAsset<T = unknown>(event:
|
|
19
|
+
export declare function fetchPublicAsset<T = unknown>(event: AiReadyDatabaseEvent | undefined, path: string, options?: {
|
|
20
20
|
responseType?: 'json' | 'text' | 'arrayBuffer' | 'stream';
|
|
21
21
|
}): Promise<T | null>;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { withBase } from "ufo";
|
|
2
|
-
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
2
|
+
import { localFetch, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
|
+
import { DB_CONTEXT_KEY, DB_PROMISE_CONTEXT_KEY, DB_WORK_CONTEXT_KEY } from "../db/context.js";
|
|
3
4
|
const FETCH_TIMEOUT = 5e3;
|
|
5
|
+
const RETRY_STATUSES = /* @__PURE__ */ new Set([408, 409, 425, 429, 500, 502, 503, 504]);
|
|
4
6
|
function unavailablePublicAsset(_error) {
|
|
5
7
|
return null;
|
|
6
8
|
}
|
|
7
9
|
export function getCfEnv(event) {
|
|
8
|
-
|
|
10
|
+
const cloudflare = event?.context.cloudflare;
|
|
11
|
+
return cloudflare?.env ?? globalThis.__env__;
|
|
9
12
|
}
|
|
10
13
|
export function hasAssets(event) {
|
|
11
14
|
return !!getCfEnv(event)?.ASSETS?.fetch;
|
|
@@ -31,9 +34,30 @@ export async function fetchPublicAsset(event, path, options) {
|
|
|
31
34
|
}
|
|
32
35
|
const controller = new AbortController();
|
|
33
36
|
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const assetContext = event && Object.fromEntries(
|
|
38
|
+
Object.entries(event.context).filter(([key]) => ![DB_CONTEXT_KEY, DB_PROMISE_CONTEXT_KEY, DB_WORK_CONTEXT_KEY].includes(key))
|
|
39
|
+
);
|
|
40
|
+
return (async () => {
|
|
41
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
42
|
+
const response = await localFetch(withBase(path, useRuntimeConfig().app.baseURL), {
|
|
43
|
+
signal: controller.signal
|
|
44
|
+
}, assetContext).catch(unavailablePublicAsset);
|
|
45
|
+
if (attempt === 0 && !controller.signal.aborted && (!response || RETRY_STATUSES.has(response.status))) {
|
|
46
|
+
await response?.body?.cancel().catch(unavailablePublicAsset);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (!response?.ok) {
|
|
50
|
+
await response?.body?.cancel().catch(unavailablePublicAsset);
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (responseType === "stream")
|
|
54
|
+
return response.body;
|
|
55
|
+
if (responseType === "text")
|
|
56
|
+
return response.text().catch(unavailablePublicAsset);
|
|
57
|
+
if (responseType === "arrayBuffer")
|
|
58
|
+
return response.arrayBuffer().catch(unavailablePublicAsset);
|
|
59
|
+
return response.json().catch(unavailablePublicAsset);
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
})().finally(() => clearTimeout(timeout));
|
|
39
63
|
}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import type { ContentNegotiationPolicy } from '../../types.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function getContentNegotiationVary(botNegotiation?: boolean): "Accept" | "Accept, Sec-Fetch-Dest, User-Agent";
|
|
3
3
|
export interface NegotiationRouteRule {
|
|
4
4
|
cache?: boolean | Record<string, unknown> & {
|
|
5
5
|
headersOnly?: boolean;
|
|
6
|
-
varies?: string[];
|
|
6
|
+
varies?: readonly string[];
|
|
7
7
|
};
|
|
8
8
|
isr?: boolean | number | {
|
|
9
|
-
expiration
|
|
9
|
+
expiration?: number | false;
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
export type ContentNegotiationResolution = {
|
|
13
13
|
_tag: 'enabled';
|
|
14
14
|
source: 'default' | 'explicit';
|
|
15
|
+
vary: ReturnType<typeof getContentNegotiationVary>;
|
|
15
16
|
} | {
|
|
16
17
|
_tag: 'disabled';
|
|
17
18
|
source: 'explicit' | 'isr' | 'route-cache';
|
|
18
19
|
};
|
|
19
20
|
export declare function resolveContentNegotiation(input: {
|
|
20
21
|
policy: ContentNegotiationPolicy;
|
|
22
|
+
botNegotiation?: boolean;
|
|
21
23
|
routeRule: NegotiationRouteRule;
|
|
22
24
|
}): ContentNegotiationResolution;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export function getContentNegotiationVary(botNegotiation = false) {
|
|
2
|
+
return botNegotiation ? "Accept, Sec-Fetch-Dest, User-Agent" : "Accept";
|
|
3
|
+
}
|
|
4
|
+
function cachesWithoutNegotiationVariation(cache, botNegotiation) {
|
|
4
5
|
if (!cache)
|
|
5
6
|
return false;
|
|
6
7
|
if (typeof cache !== "object")
|
|
@@ -8,16 +9,16 @@ function cachesWithoutNegotiationVariation(cache) {
|
|
|
8
9
|
if (cache.headersOnly)
|
|
9
10
|
return false;
|
|
10
11
|
const varies = new Set(cache.varies?.map((header) => header.toLowerCase()));
|
|
11
|
-
return
|
|
12
|
+
return getContentNegotiationVary(botNegotiation).split(",").some((header) => !varies.has(header.trim().toLowerCase()));
|
|
12
13
|
}
|
|
13
14
|
export function resolveContentNegotiation(input) {
|
|
14
15
|
if (input.policy === "enabled")
|
|
15
|
-
return { _tag: "enabled", source: "explicit" };
|
|
16
|
+
return { _tag: "enabled", source: "explicit", vary: getContentNegotiationVary(input.botNegotiation) };
|
|
16
17
|
if (input.policy === "disabled")
|
|
17
18
|
return { _tag: "disabled", source: "explicit" };
|
|
18
19
|
if (input.routeRule.isr)
|
|
19
20
|
return { _tag: "disabled", source: "isr" };
|
|
20
|
-
if (cachesWithoutNegotiationVariation(input.routeRule.cache))
|
|
21
|
+
if (cachesWithoutNegotiationVariation(input.routeRule.cache, input.botNegotiation === true))
|
|
21
22
|
return { _tag: "disabled", source: "route-cache" };
|
|
22
|
-
return { _tag: "enabled", source: "default" };
|
|
23
|
+
return { _tag: "enabled", source: "default", vary: getContentNegotiationVary(input.botNegotiation) };
|
|
23
24
|
}
|