nuxt-ai-ready 3.6.1 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-skills-config-CmZq9uWW.mjs +18 -0
- package/dist/agent-skills-zGLgFB6H.mjs +468 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +656 -570
- package/dist/devtools/pages/ai-ready/debug.vue +9 -3
- package/dist/devtools/pages/ai-ready/index.vue +3 -1
- package/dist/devtools/pages/ai-ready/llms-txt.vue +15 -4
- package/dist/devtools/pages/ai-ready.vue +28 -4
- package/dist/module.d.mts +106 -112
- package/dist/module.json +3 -3
- package/dist/module.mjs +2732 -26
- package/dist/package-metadata-B1darl8W.mjs +28 -0
- package/dist/prerender-QMv07W4h.mjs +650 -0
- package/dist/runtime/app/composables/webmcp.js +90 -97
- package/dist/runtime/app/plugins/md-alternate.server.js +29 -26
- package/dist/runtime/app/plugins/md-hints.prerender.js +13 -15
- package/dist/runtime/app/plugins/webmcp.client.js +49 -53
- package/dist/runtime/app/webmcp-config.js +2 -2
- package/dist/runtime/cache-control.js +16 -10
- package/dist/runtime/i18n-url.js +6 -6
- package/dist/runtime/index.js +4 -12
- package/dist/runtime/llms-txt-directive.js +20 -13
- package/dist/runtime/llms-txt-files.js +188 -187
- package/dist/runtime/llms-txt-format.js +54 -55
- package/dist/runtime/llms-txt-i18n.js +22 -19
- package/dist/runtime/llms-txt-utils.js +140 -95
- package/dist/runtime/markdown-links.js +45 -39
- package/dist/runtime/markdown-path.js +29 -9
- package/dist/runtime/markdown-text.js +2 -1
- package/dist/runtime/mcp.js +5 -1
- package/dist/runtime/route-path.js +14 -8
- package/dist/runtime/server/db/drizzle/client.js +71 -75
- package/dist/runtime/server/db/drizzle/index.js +16 -28
- package/dist/runtime/server/db/drizzle/providers/bun.d.ts +2 -1
- package/dist/runtime/server/db/drizzle/providers/bun.js +10 -7
- package/dist/runtime/server/db/drizzle/providers/d1.js +16 -13
- package/dist/runtime/server/db/drizzle/providers/dbPath.js +60 -37
- package/dist/runtime/server/db/drizzle/providers/libsql.js +23 -11
- package/dist/runtime/server/db/drizzle/providers/neon.js +13 -10
- package/dist/runtime/server/db/drizzle/providers/node-sqlite.js +10 -7
- package/dist/runtime/server/db/drizzle/providers/postgres.js +13 -10
- package/dist/runtime/server/db/drizzle/queries.js +633 -532
- package/dist/runtime/server/db/drizzle/raw.js +200 -176
- package/dist/runtime/server/db/index.js +3 -0
- package/dist/runtime/server/db/queries.js +816 -607
- package/dist/runtime/server/db/schema/postgres.js +56 -50
- package/dist/runtime/server/db/schema/sqlite.js +56 -50
- package/dist/runtime/server/db/schema-sql.js +35 -38
- package/dist/runtime/server/db/seed.js +60 -45
- package/dist/runtime/server/db/shared.js +300 -213
- package/dist/runtime/server/index.js +1 -17
- package/dist/runtime/server/mcp/cache-key.js +5 -1
- package/dist/runtime/server/mcp/resources/pages.js +32 -33
- package/dist/runtime/server/mcp/tools/get-page-markdown.js +41 -27
- package/dist/runtime/server/mcp/tools/list-pages.js +40 -34
- package/dist/runtime/server/mcp/tools/search-pages.js +24 -16
- package/dist/runtime/server/middleware/markdown.d.ts +1 -1
- package/dist/runtime/server/middleware/markdown.js +15 -13
- package/dist/runtime/server/middleware/markdown.prerender.d.ts +1 -1
- package/dist/runtime/server/middleware/markdown.prerender.js +135 -119
- package/dist/runtime/server/middleware/render-markdown.d.ts +1 -1
- package/dist/runtime/server/middleware/render-markdown.js +164 -144
- package/dist/runtime/server/plugins/ai-terms.d.ts +1 -1
- package/dist/runtime/server/plugins/ai-terms.js +4 -8
- package/dist/runtime/server/plugins/content-signal-capture-nitro3.prerender.d.ts +1 -1
- package/dist/runtime/server/plugins/content-signal-capture-nitro3.prerender.js +7 -8
- package/dist/runtime/server/plugins/content-signal-capture.prerender.d.ts +1 -1
- package/dist/runtime/server/plugins/content-signal-capture.prerender.js +7 -7
- package/dist/runtime/server/plugins/db-lifecycle-nitro3.d.ts +1 -1
- package/dist/runtime/server/plugins/db-lifecycle-nitro3.js +13 -14
- package/dist/runtime/server/plugins/db-lifecycle.js +13 -11
- package/dist/runtime/server/plugins/html-capture.prerender.js +6 -6
- package/dist/runtime/server/plugins/link-header-nitro3.d.ts +1 -1
- package/dist/runtime/server/plugins/link-header-nitro3.js +23 -13
- package/dist/runtime/server/plugins/link-header.d.ts +1 -1
- package/dist/runtime/server/plugins/link-header.js +30 -30
- package/dist/runtime/server/plugins/llms-txt-directive-html.d.ts +1 -1
- package/dist/runtime/server/plugins/llms-txt-directive-html.js +4 -3
- package/dist/runtime/server/plugins/markdown-negotiation.d.ts +1 -1
- package/dist/runtime/server/plugins/markdown-negotiation.js +64 -45
- package/dist/runtime/server/plugins/sitemap-seeder.js +144 -112
- package/dist/runtime/server/routes/__ai-ready/cron.get.d.ts +1 -1
- package/dist/runtime/server/routes/__ai-ready/cron.get.js +17 -11
- package/dist/runtime/server/routes/__ai-ready/devtools.get.d.ts +1 -1
- package/dist/runtime/server/routes/__ai-ready/devtools.get.js +60 -45
- package/dist/runtime/server/routes/__ai-ready/pages.get.d.ts +36 -1
- package/dist/runtime/server/routes/__ai-ready/pages.get.js +44 -40
- package/dist/runtime/server/routes/__ai-ready/poll.post.d.ts +15 -1
- package/dist/runtime/server/routes/__ai-ready/poll.post.js +30 -30
- package/dist/runtime/server/routes/__ai-ready/prune.post.d.ts +13 -1
- package/dist/runtime/server/routes/__ai-ready/prune.post.js +29 -15
- package/dist/runtime/server/routes/__ai-ready/reindex.post.d.ts +22 -1
- package/dist/runtime/server/routes/__ai-ready/reindex.post.js +31 -21
- package/dist/runtime/server/routes/__ai-ready/restore.post.d.ts +4 -1
- package/dist/runtime/server/routes/__ai-ready/restore.post.js +28 -22
- package/dist/runtime/server/routes/__ai-ready/status.get.d.ts +1 -1
- package/dist/runtime/server/routes/__ai-ready/status.get.js +52 -53
- package/dist/runtime/server/routes/__ai-ready-debug.get.d.ts +83 -1
- package/dist/runtime/server/routes/__ai-ready-debug.get.js +209 -189
- package/dist/runtime/server/routes/agent-skills-artifact.d.ts +1 -1
- package/dist/runtime/server/routes/agent-skills-artifact.js +16 -14
- package/dist/runtime/server/routes/agent-skills-index.d.ts +1 -1
- package/dist/runtime/server/routes/agent-skills-index.js +8 -6
- package/dist/runtime/server/routes/ai-catalog.js +19 -19
- package/dist/runtime/server/routes/ai-terms.js +23 -19
- package/dist/runtime/server/routes/api-catalog.js +23 -23
- package/dist/runtime/server/routes/llms-full.txt.get.d.ts +1 -1
- package/dist/runtime/server/routes/llms-full.txt.get.js +42 -41
- package/dist/runtime/server/routes/llms.txt.get.d.ts +1 -1
- package/dist/runtime/server/routes/llms.txt.get.js +38 -33
- package/dist/runtime/server/routes/mcp-server-card.js +19 -19
- package/dist/runtime/server/routes/sitemap.md.get.d.ts +1 -1
- package/dist/runtime/server/routes/sitemap.md.get.js +38 -39
- package/dist/runtime/server/tasks/ai-ready-cron.d.ts +1 -1
- package/dist/runtime/server/tasks/ai-ready-cron.js +17 -14
- package/dist/runtime/server/utils/auth.js +76 -53
- package/dist/runtime/server/utils/batchIndex.js +72 -60
- package/dist/runtime/server/utils/checkStale.js +181 -134
- package/dist/runtime/server/utils/cloudflare-prerendered.js +23 -20
- package/dist/runtime/server/utils/cloudflare.js +69 -51
- package/dist/runtime/server/utils/content-negotiation.js +30 -18
- package/dist/runtime/server/utils/content.js +4 -1
- package/dist/runtime/server/utils/context.js +30 -19
- package/dist/runtime/server/utils/cron-plan.js +6 -6
- package/dist/runtime/server/utils/discovery-response.js +5 -6
- package/dist/runtime/server/utils/fetch.js +2 -1
- package/dist/runtime/server/utils/frontmatter.js +44 -57
- package/dist/runtime/server/utils/i18n.js +3 -8
- package/dist/runtime/server/utils/indexPage.js +152 -113
- package/dist/runtime/server/utils/keywords.js +278 -277
- package/dist/runtime/server/utils/link-header.js +67 -56
- package/dist/runtime/server/utils/llms-full.js +39 -49
- package/dist/runtime/server/utils/markdown-redirect.js +26 -14
- package/dist/runtime/server/utils/markdown-request.js +62 -47
- package/dist/runtime/server/utils/negotiation-decision.d.ts +8 -0
- package/dist/runtime/server/utils/negotiation-decision.js +106 -34
- package/dist/runtime/server/utils/negotiation-response.d.ts +1 -1
- package/dist/runtime/server/utils/negotiation-response.js +195 -144
- package/dist/runtime/server/utils/page-updated-at.js +23 -15
- package/dist/runtime/server/utils/prerender-html.js +31 -17
- package/dist/runtime/server/utils/runCron.js +263 -192
- package/dist/runtime/server/utils/sitemap-crawl-state.js +57 -39
- package/dist/runtime/server/utils/sitemap-lastmod.js +16 -14
- package/dist/runtime/server/utils/sitemap-md.js +39 -50
- package/dist/runtime/server/utils/sitemap-routes.js +7 -7
- package/dist/runtime/server/utils/sitemap.js +459 -414
- package/dist/runtime/server/utils.js +141 -122
- package/dist/runtime/site-tool-catalog.js +39 -43
- package/dist/runtime/site-tool-config.js +1 -0
- package/dist/runtime/sync-secret.js +11 -11
- package/dist/runtime/types.js +1 -0
- package/dist/runtime/webmcp-site-tools.js +278 -250
- package/dist/runtime/webmcp.js +53 -42
- package/dist/static-headers-G7hFL3wE.mjs +328 -0
- package/dist/types.d.mts +1 -9
- package/package.json +18 -22
- package/skills/nuxt-ai-ready/SKILL.md +8 -2
- package/dist/chunks/agent-skills.mjs +0 -383
- package/dist/chunks/prerender.mjs +0 -683
- package/dist/shared/nuxt-ai-ready.Bzx0dNWj.mjs +0 -3034
- package/dist/shared/nuxt-ai-ready.DCd-1s1G.mjs +0 -29
|
@@ -3,46 +3,50 @@ import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
|
3
3
|
import { countPages, queryPages, searchPages } from "../../db/queries.js";
|
|
4
4
|
const MAX_LIMIT = 50;
|
|
5
5
|
function toLimit(value, fallback) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return Math.min(limit, MAX_LIMIT);
|
|
6
|
+
const limit = Math.trunc(Number(value));
|
|
7
|
+
if (!Number.isFinite(limit) || limit < 1) return fallback;
|
|
8
|
+
return Math.min(limit, MAX_LIMIT);
|
|
10
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Public page index powering the WebMCP site tools. Read-only and returns the
|
|
12
|
+
* same content already published through llms.txt and the `.md` routes.
|
|
13
|
+
*/
|
|
11
14
|
export default eventHandler(async (event) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
15
|
+
const config = useRuntimeConfig(event)["nuxt-ai-ready"];
|
|
16
|
+
const query = getQuery(event);
|
|
17
|
+
const { maxAge, swr } = config.markdownCacheHeaders;
|
|
18
|
+
setHeader(event, "cache-control", swr ? `public, max-age=${maxAge}, stale-while-revalidate=${maxAge}` : `public, max-age=${maxAge}`);
|
|
19
|
+
const route = typeof query.route === "string" ? query.route.trim() : "";
|
|
20
|
+
if (route) {
|
|
21
|
+
const page = await queryPages(event, { route });
|
|
22
|
+
return { page: page && !page.isError ? {
|
|
23
|
+
route: page.route,
|
|
24
|
+
title: page.title || page.route,
|
|
25
|
+
description: page.description || ""
|
|
26
|
+
} : null };
|
|
27
|
+
}
|
|
28
|
+
const search = String(query.q || "").trim();
|
|
29
|
+
if (search) {
|
|
30
|
+
return {
|
|
31
|
+
query: search,
|
|
32
|
+
results: await searchPages(event, search, { limit: toLimit(query.limit, 10) })
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const limit = toLimit(query.limit, 20);
|
|
36
|
+
const offset = Math.max(0, Math.trunc(Number(query.offset)) || 0);
|
|
37
|
+
const [pages, total] = await Promise.all([queryPages(event, {
|
|
38
|
+
limit,
|
|
39
|
+
offset
|
|
40
|
+
}), countPages(event)]);
|
|
41
|
+
return {
|
|
42
|
+
pages: pages.map((p) => ({
|
|
43
|
+
route: p.route,
|
|
44
|
+
title: p.title || p.route,
|
|
45
|
+
description: p.description || ""
|
|
46
|
+
})),
|
|
47
|
+
total,
|
|
48
|
+
limit,
|
|
49
|
+
offset,
|
|
50
|
+
hasMore: offset + pages.length < total
|
|
51
|
+
};
|
|
48
52
|
});
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("#nuxtseo/h3").EventHandlerWithFetch<import("#nuxtseo/h3").EventHandlerRequest, Promise<{
|
|
2
|
+
locked: boolean;
|
|
3
|
+
indexed?: undefined;
|
|
4
|
+
remaining?: undefined;
|
|
5
|
+
errors?: undefined;
|
|
6
|
+
duration?: undefined;
|
|
7
|
+
complete?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
indexed: number;
|
|
10
|
+
remaining: number;
|
|
11
|
+
errors: string[] | undefined;
|
|
12
|
+
duration: number;
|
|
13
|
+
complete: boolean;
|
|
14
|
+
locked?: undefined;
|
|
15
|
+
}>>;
|
|
2
16
|
export default _default;
|
|
@@ -4,34 +4,34 @@ import { releaseCronLock, tryAcquireCronLock } from "../../db/queries.js";
|
|
|
4
4
|
import { logger } from "../../logger.js";
|
|
5
5
|
import { batchIndexPages } from "../../utils/batchIndex.js";
|
|
6
6
|
export default eventHandler(async (event) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
7
|
+
const { requireAuth } = await import("../../utils/auth.js");
|
|
8
|
+
await requireAuth(event);
|
|
9
|
+
const lock = await tryAcquireCronLock(event);
|
|
10
|
+
if (lock._tag === "held") {
|
|
11
|
+
setResponseStatus(event, 409);
|
|
12
|
+
return { locked: true };
|
|
13
|
+
}
|
|
14
|
+
const query = getQuery(event);
|
|
15
|
+
const config = useRuntimeConfig(event)["nuxt-ai-ready"];
|
|
16
|
+
const defaultLimit = Math.max(1, Math.trunc(Math.min(config.runtimeSync?.batchSize ?? 10, 50))) || 10;
|
|
17
|
+
const limit = query.limit ? Math.max(1, Math.min(50, Math.trunc(Number(query.limit)) || defaultLimit)) : defaultLimit;
|
|
18
|
+
const timeout = query.timeout ? Math.max(1e3, Math.trunc(Number(query.timeout)) || 3e4) : undefined;
|
|
19
|
+
try {
|
|
20
|
+
const result = await batchIndexPages(event, {
|
|
21
|
+
limit,
|
|
22
|
+
all: query.all === "true" || query.all === "1",
|
|
23
|
+
timeout
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
indexed: result.indexed,
|
|
27
|
+
remaining: result.remaining,
|
|
28
|
+
errors: result.errors.length > 0 ? result.errors : undefined,
|
|
29
|
+
duration: result.duration,
|
|
30
|
+
complete: result.complete
|
|
31
|
+
};
|
|
32
|
+
} finally {
|
|
33
|
+
await releaseCronLock(event, lock.token).catch((err) => {
|
|
34
|
+
logger.warn(`[poll] Failed to release lock: ${err?.message || err}`);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
37
|
});
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("#nuxtseo/h3").EventHandlerWithFetch<import("#nuxtseo/h3").EventHandlerRequest, Promise<{
|
|
2
|
+
routes: string[];
|
|
3
|
+
count: number;
|
|
4
|
+
ttl: number;
|
|
5
|
+
dry: boolean;
|
|
6
|
+
pruned?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
pruned: number;
|
|
9
|
+
ttl: number;
|
|
10
|
+
dry: boolean;
|
|
11
|
+
routes?: undefined;
|
|
12
|
+
count?: undefined;
|
|
13
|
+
}>>;
|
|
2
14
|
export default _default;
|
|
@@ -2,19 +2,33 @@ import { eventHandler, getQuery } from "#nuxtseo/h3";
|
|
|
2
2
|
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
3
|
import { getStaleRoutes, pruneStaleRoutes, resolveSeedRefreshWindowMs } from "../../db/queries.js";
|
|
4
4
|
export default eventHandler(async (event) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
const config = useRuntimeConfig()["nuxt-ai-ready"];
|
|
6
|
+
const query = getQuery(event);
|
|
7
|
+
const dry = query.dry === "true" || query.dry === "1";
|
|
8
|
+
// Require auth for non-dry runs
|
|
9
|
+
if (!dry) {
|
|
10
|
+
const { requireAuth } = await import("../../utils/auth.js");
|
|
11
|
+
await requireAuth(event);
|
|
12
|
+
}
|
|
13
|
+
const ttl = query.ttl ? Math.max(0, Math.trunc(Number(query.ttl)) || config.runtimeSync.pruneTtl) : config.runtimeSync.pruneTtl;
|
|
14
|
+
// The seeder resolves its window from the configured pruneTtl, never the
|
|
15
|
+
// ttl override, so pruning uses that same window.
|
|
16
|
+
const refreshWindowMs = resolveSeedRefreshWindowMs(config.runtimeSync.pruneTtl);
|
|
17
|
+
// Dry run: preview stale routes without deleting
|
|
18
|
+
if (dry) {
|
|
19
|
+
const routes = await getStaleRoutes(event, ttl, refreshWindowMs);
|
|
20
|
+
return {
|
|
21
|
+
routes,
|
|
22
|
+
count: routes.length,
|
|
23
|
+
ttl,
|
|
24
|
+
dry: true
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
// Execute prune
|
|
28
|
+
const pruned = await pruneStaleRoutes(event, ttl, undefined, refreshWindowMs);
|
|
29
|
+
return {
|
|
30
|
+
pruned,
|
|
31
|
+
ttl,
|
|
32
|
+
dry: false
|
|
33
|
+
};
|
|
20
34
|
});
|
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("#nuxtseo/h3").EventHandlerWithFetch<import("#nuxtseo/h3").EventHandlerRequest, Promise<{
|
|
2
|
+
route: string;
|
|
3
|
+
indexed: boolean;
|
|
4
|
+
gone: boolean;
|
|
5
|
+
error?: undefined;
|
|
6
|
+
skipped?: undefined;
|
|
7
|
+
contentChanged?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
route: string;
|
|
10
|
+
indexed: boolean;
|
|
11
|
+
error: string;
|
|
12
|
+
gone?: undefined;
|
|
13
|
+
skipped?: undefined;
|
|
14
|
+
contentChanged?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
route: string;
|
|
17
|
+
indexed: boolean;
|
|
18
|
+
skipped: true | undefined;
|
|
19
|
+
contentChanged: boolean | undefined;
|
|
20
|
+
gone?: undefined;
|
|
21
|
+
error?: undefined;
|
|
22
|
+
}>>;
|
|
2
23
|
export default _default;
|
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
import { createError, eventHandler, getQuery, setResponseStatus } from "#nuxtseo/h3";
|
|
2
2
|
import { indexPageByRoute } from "../../utils/indexPage.js";
|
|
3
3
|
export default eventHandler(async (event) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
const { requireAuth } = await import("../../utils/auth.js");
|
|
5
|
+
await requireAuth(event);
|
|
6
|
+
const query = getQuery(event);
|
|
7
|
+
const route = typeof query.route === "string" ? query.route.trim() : "";
|
|
8
|
+
if (!route.startsWith("/")) {
|
|
9
|
+
throw createError({
|
|
10
|
+
statusCode: 400,
|
|
11
|
+
message: "Invalid route. It must be an absolute path starting with \"/\", for example \"/about\"."
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
const force = query.force !== "false" && query.force !== "0";
|
|
15
|
+
const result = await indexPageByRoute(route, event, { force });
|
|
16
|
+
if (result.gone) return {
|
|
17
|
+
route,
|
|
18
|
+
indexed: false,
|
|
19
|
+
gone: true
|
|
20
|
+
};
|
|
21
|
+
if (!result.success) {
|
|
22
|
+
setResponseStatus(event, 502);
|
|
23
|
+
return {
|
|
24
|
+
route,
|
|
25
|
+
indexed: false,
|
|
26
|
+
error: result.error ?? `Failed to index ${route}`
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
route,
|
|
31
|
+
indexed: !result.skipped,
|
|
32
|
+
skipped: result.skipped || undefined,
|
|
33
|
+
contentChanged: result.contentChanged
|
|
34
|
+
};
|
|
25
35
|
});
|
|
@@ -5,26 +5,32 @@ import { logger } from "../../logger.js";
|
|
|
5
5
|
import { requireAuth } from "../../utils/auth.js";
|
|
6
6
|
import { fetchPublicAsset } from "../../utils/cloudflare.js";
|
|
7
7
|
export default eventHandler(async (event) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
await requireAuth(event);
|
|
9
|
+
const query = getQuery(event);
|
|
10
|
+
// Fetch dump file
|
|
11
|
+
logger.debug("[restore] Fetching dump...");
|
|
12
|
+
const dumpData = await fetchPublicAsset(event, "/__ai-ready/pages.dump", { responseType: "text" });
|
|
13
|
+
if (!dumpData) {
|
|
14
|
+
throw createError({
|
|
15
|
+
statusCode: 404,
|
|
16
|
+
message: "Dump file not found"
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
logger.debug(`[restore] Fetched dump (${dumpData.length} bytes)`);
|
|
20
|
+
const db = await useRawDb(event);
|
|
21
|
+
// Clear existing pages if requested (default: true for full restore)
|
|
22
|
+
const clear = query.clear !== "false" && query.clear !== "0";
|
|
23
|
+
if (clear) {
|
|
24
|
+
await db.exec("DELETE FROM ai_ready_pages");
|
|
25
|
+
}
|
|
26
|
+
// Decompress and import
|
|
27
|
+
logger.debug(`[restore] Decompressing dump (${dumpData.length} bytes)`);
|
|
28
|
+
const rows = await decompressFromBase64(dumpData);
|
|
29
|
+
logger.debug(`[restore] Importing ${rows.length} rows to database`);
|
|
30
|
+
await importDbDump(db, rows);
|
|
31
|
+
logger.debug(`[restore] Restored ${rows.length} pages`);
|
|
32
|
+
return {
|
|
33
|
+
restored: rows.length,
|
|
34
|
+
cleared: clear
|
|
35
|
+
};
|
|
30
36
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: import("#nuxtseo/h3").EventHandlerWithFetch<import("#nuxtseo/h3").EventHandlerRequest, Promise<Record<string, unknown>>>;
|
|
2
2
|
export default _default;
|
|
@@ -2,57 +2,56 @@ import { eventHandler } from "#nuxtseo/h3";
|
|
|
2
2
|
import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
3
3
|
import { countPages, countRecentlyIndexed, getCronLockStatus, getRecentCronRuns, getRecentlyIndexedPages, getSitemapStatus } from "../../db/queries.js";
|
|
4
4
|
export default eventHandler(async (event) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return result;
|
|
5
|
+
const config = useRuntimeConfig(event)["nuxt-ai-ready"];
|
|
6
|
+
const { requireAuth } = await import("../../utils/auth.js");
|
|
7
|
+
await requireAuth(event);
|
|
8
|
+
const [total, pending, recentlyIndexed24h, recentlyIndexed1h, recentPages] = await Promise.all([
|
|
9
|
+
countPages(event),
|
|
10
|
+
countPages(event, { where: { pending: true } }),
|
|
11
|
+
countRecentlyIndexed(event, 24 * 60 * 60 * 1e3),
|
|
12
|
+
countRecentlyIndexed(event, 60 * 60 * 1e3),
|
|
13
|
+
getRecentlyIndexedPages(event, 5)
|
|
14
|
+
]);
|
|
15
|
+
const result = {
|
|
16
|
+
total,
|
|
17
|
+
indexed: total - pending,
|
|
18
|
+
pending,
|
|
19
|
+
activity: {
|
|
20
|
+
last1h: recentlyIndexed1h,
|
|
21
|
+
last24h: recentlyIndexed24h,
|
|
22
|
+
recentPages
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
// Include cron and sitemap info if runtime sync is enabled
|
|
26
|
+
if (config.runtimeSync) {
|
|
27
|
+
const [cronRuns, sitemaps, cronLock] = await Promise.all([
|
|
28
|
+
getRecentCronRuns(event, 3),
|
|
29
|
+
getSitemapStatus(event),
|
|
30
|
+
getCronLockStatus(event)
|
|
31
|
+
]);
|
|
32
|
+
result.cron = {
|
|
33
|
+
lock: {
|
|
34
|
+
held: cronLock.held,
|
|
35
|
+
since: cronLock.since,
|
|
36
|
+
elapsedMs: cronLock.elapsedMs,
|
|
37
|
+
stale: cronLock.stale
|
|
38
|
+
},
|
|
39
|
+
recentRuns: cronRuns.map((r) => ({
|
|
40
|
+
startedAt: r.startedAt,
|
|
41
|
+
durationMs: r.durationMs,
|
|
42
|
+
pagesIndexed: r.pagesIndexed,
|
|
43
|
+
status: r.status
|
|
44
|
+
}))
|
|
45
|
+
};
|
|
46
|
+
if (sitemaps.length) {
|
|
47
|
+
result.sitemaps = sitemaps.map((s) => ({
|
|
48
|
+
name: s.name,
|
|
49
|
+
urlCount: s.urlCount,
|
|
50
|
+
lastCrawledAt: s.lastCrawledAt,
|
|
51
|
+
errorCount: s.errorCount,
|
|
52
|
+
continuing: s.continuing
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
58
57
|
});
|
|
@@ -1,2 +1,84 @@
|
|
|
1
|
-
|
|
1
|
+
interface CronRunInfo {
|
|
2
|
+
id: number;
|
|
3
|
+
startedAt: string;
|
|
4
|
+
finishedAt: string | null;
|
|
5
|
+
durationMs: number | null;
|
|
6
|
+
status: string;
|
|
7
|
+
pagesIndexed: number;
|
|
8
|
+
pagesRemaining: number;
|
|
9
|
+
errors: string[];
|
|
10
|
+
}
|
|
11
|
+
interface DebugInfo {
|
|
12
|
+
version: string;
|
|
13
|
+
environment: {
|
|
14
|
+
isDev: boolean;
|
|
15
|
+
isPrerender: boolean;
|
|
16
|
+
mode: 'development' | 'prerender' | 'production';
|
|
17
|
+
};
|
|
18
|
+
config: {
|
|
19
|
+
debug: boolean;
|
|
20
|
+
debugCron: boolean;
|
|
21
|
+
llmsTxtCacheSeconds: number;
|
|
22
|
+
mdreamOptions: unknown;
|
|
23
|
+
};
|
|
24
|
+
runtimeSync?: {
|
|
25
|
+
total: number;
|
|
26
|
+
indexed: number;
|
|
27
|
+
pending: number;
|
|
28
|
+
errors: number;
|
|
29
|
+
};
|
|
30
|
+
cronRuns?: CronRunInfo[];
|
|
31
|
+
pageData: {
|
|
32
|
+
source: string;
|
|
33
|
+
pageCount: number;
|
|
34
|
+
pages: Array<{
|
|
35
|
+
route: string;
|
|
36
|
+
title: string;
|
|
37
|
+
hasDescription: boolean;
|
|
38
|
+
hasHeadings: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
errorRoutes: string[];
|
|
41
|
+
};
|
|
42
|
+
jsonFile: {
|
|
43
|
+
available: boolean;
|
|
44
|
+
pageCount: number;
|
|
45
|
+
source: string;
|
|
46
|
+
};
|
|
47
|
+
buildInfo?: {
|
|
48
|
+
storedBuildId: string | null;
|
|
49
|
+
dumpBuildId: string | null;
|
|
50
|
+
dumpPageCount: number | null;
|
|
51
|
+
isStale: boolean;
|
|
52
|
+
dumpCreatedAt: string | null;
|
|
53
|
+
};
|
|
54
|
+
virtualModules: {
|
|
55
|
+
pageDataModule: {
|
|
56
|
+
available: boolean;
|
|
57
|
+
pagesCount: number;
|
|
58
|
+
errorRoutesCount: number;
|
|
59
|
+
};
|
|
60
|
+
readPageDataModule: {
|
|
61
|
+
available: boolean;
|
|
62
|
+
note: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
cloudflare?: {
|
|
66
|
+
hasContext: boolean;
|
|
67
|
+
hasCloudflare: boolean;
|
|
68
|
+
hasCloudflareEnv: boolean;
|
|
69
|
+
hasContextEnv: boolean;
|
|
70
|
+
contextKeys: string[];
|
|
71
|
+
cloudflareKeys: string[];
|
|
72
|
+
cloudflareEnvKeys: string[];
|
|
73
|
+
databaseConfig: {
|
|
74
|
+
type: string;
|
|
75
|
+
bindingName?: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
diagnostics: {
|
|
79
|
+
issues: string[];
|
|
80
|
+
suggestions: string[];
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
declare const _default: import("#nuxtseo/h3").EventHandlerWithFetch<import("#nuxtseo/h3").EventHandlerRequest, Promise<DebugInfo>>;
|
|
2
84
|
export default _default;
|