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
|
@@ -1,58 +1,64 @@
|
|
|
1
1
|
import { bigint, index, integer, pgTable, serial, text } from "drizzle-orm/pg-core";
|
|
2
|
+
// Main pages table
|
|
2
3
|
export const pages = pgTable("ai_ready_pages", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
id: serial("id").primaryKey(),
|
|
5
|
+
route: text("route").unique().notNull(),
|
|
6
|
+
routeKey: text("route_key").unique().notNull(),
|
|
7
|
+
title: text("title").notNull().default(""),
|
|
8
|
+
description: text("description").notNull().default(""),
|
|
9
|
+
markdown: text("markdown").notNull().default(""),
|
|
10
|
+
headings: text("headings").notNull().default("[]"),
|
|
11
|
+
keywords: text("keywords").notNull().default("[]"),
|
|
12
|
+
contentHash: text("content_hash"),
|
|
13
|
+
updatedAt: text("updated_at").notNull(),
|
|
14
|
+
sourceLastmod: text("source_lastmod"),
|
|
15
|
+
indexedAt: bigint("indexed_at", { mode: "number" }).notNull(),
|
|
16
|
+
isError: integer("is_error").notNull().default(0),
|
|
17
|
+
indexed: integer("indexed").notNull().default(0),
|
|
18
|
+
source: text("source").notNull().default("prerender"),
|
|
19
|
+
lastSeenAt: bigint("last_seen_at", { mode: "number" }),
|
|
20
|
+
locale: text("locale").notNull().default("")
|
|
20
21
|
}, (table) => [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
index("idx_ai_ready_pages_route").on(table.route),
|
|
23
|
+
index("idx_ai_ready_pages_is_error").on(table.isError),
|
|
24
|
+
index("idx_ai_ready_pages_indexed").on(table.indexed),
|
|
25
|
+
index("idx_ai_ready_pages_source").on(table.source),
|
|
26
|
+
index("idx_ai_ready_pages_last_seen").on(table.lastSeenAt),
|
|
27
|
+
index("idx_ai_ready_pages_locale").on(table.locale)
|
|
27
28
|
]);
|
|
29
|
+
// Schema version tracking
|
|
28
30
|
export const info = pgTable("_ai_ready_info", {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
id: text("id").primaryKey(),
|
|
32
|
+
value: text("value"),
|
|
33
|
+
version: text("version"),
|
|
34
|
+
checksum: text("checksum"),
|
|
35
|
+
ready: integer("ready").default(0)
|
|
34
36
|
});
|
|
37
|
+
// Cron run history
|
|
35
38
|
export const cronRuns = pgTable("ai_ready_cron_runs", {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}, (table) => [
|
|
45
|
-
|
|
46
|
-
]);
|
|
39
|
+
id: serial("id").primaryKey(),
|
|
40
|
+
startedAt: bigint("started_at", { mode: "number" }).notNull(),
|
|
41
|
+
finishedAt: bigint("finished_at", { mode: "number" }),
|
|
42
|
+
durationMs: integer("duration_ms"),
|
|
43
|
+
pagesIndexed: integer("pages_indexed").default(0),
|
|
44
|
+
pagesRemaining: integer("pages_remaining").default(0),
|
|
45
|
+
errors: text("errors").default("[]"),
|
|
46
|
+
status: text("status").default("running")
|
|
47
|
+
}, (table) => [index("idx_ai_ready_cron_runs_started").on(table.startedAt)]);
|
|
48
|
+
// Sitemap tracking
|
|
47
49
|
export const sitemaps = pgTable("ai_ready_sitemaps", {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}, (table) => [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
name: text("name").primaryKey(),
|
|
51
|
+
route: text("route").notNull(),
|
|
52
|
+
lastCrawledAt: bigint("last_crawled_at", { mode: "number" }),
|
|
53
|
+
urlCount: integer("url_count").default(0),
|
|
54
|
+
errorCount: integer("error_count").default(0),
|
|
55
|
+
lastError: text("last_error"),
|
|
56
|
+
crawlState: text("crawl_state")
|
|
57
|
+
}, (table) => [index("idx_ai_ready_sitemaps_crawled").on(table.lastCrawledAt)]);
|
|
58
|
+
// Export schema for migrations
|
|
59
|
+
export const schema = {
|
|
60
|
+
pages,
|
|
61
|
+
info,
|
|
62
|
+
cronRuns,
|
|
63
|
+
sitemaps
|
|
64
|
+
};
|
|
@@ -1,58 +1,64 @@
|
|
|
1
1
|
import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
|
2
|
+
// Main pages table
|
|
2
3
|
export const pages = sqliteTable("ai_ready_pages", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
5
|
+
route: text("route").unique().notNull(),
|
|
6
|
+
routeKey: text("route_key").unique().notNull(),
|
|
7
|
+
title: text("title").notNull().default(""),
|
|
8
|
+
description: text("description").notNull().default(""),
|
|
9
|
+
markdown: text("markdown").notNull().default(""),
|
|
10
|
+
headings: text("headings").notNull().default("[]"),
|
|
11
|
+
keywords: text("keywords").notNull().default("[]"),
|
|
12
|
+
contentHash: text("content_hash"),
|
|
13
|
+
updatedAt: text("updated_at").notNull(),
|
|
14
|
+
sourceLastmod: text("source_lastmod"),
|
|
15
|
+
indexedAt: integer("indexed_at").notNull(),
|
|
16
|
+
isError: integer("is_error").notNull().default(0),
|
|
17
|
+
indexed: integer("indexed").notNull().default(0),
|
|
18
|
+
source: text("source").notNull().default("prerender"),
|
|
19
|
+
lastSeenAt: integer("last_seen_at"),
|
|
20
|
+
locale: text("locale").notNull().default("")
|
|
20
21
|
}, (table) => [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
index("idx_ai_ready_pages_route").on(table.route),
|
|
23
|
+
index("idx_ai_ready_pages_is_error").on(table.isError),
|
|
24
|
+
index("idx_ai_ready_pages_indexed").on(table.indexed),
|
|
25
|
+
index("idx_ai_ready_pages_source").on(table.source),
|
|
26
|
+
index("idx_ai_ready_pages_last_seen").on(table.lastSeenAt),
|
|
27
|
+
index("idx_ai_ready_pages_locale").on(table.locale)
|
|
27
28
|
]);
|
|
29
|
+
// Schema version tracking
|
|
28
30
|
export const info = sqliteTable("_ai_ready_info", {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
id: text("id").primaryKey(),
|
|
32
|
+
value: text("value"),
|
|
33
|
+
version: text("version"),
|
|
34
|
+
checksum: text("checksum"),
|
|
35
|
+
ready: integer("ready").default(0)
|
|
34
36
|
});
|
|
37
|
+
// Cron run history
|
|
35
38
|
export const cronRuns = sqliteTable("ai_ready_cron_runs", {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}, (table) => [
|
|
45
|
-
|
|
46
|
-
]);
|
|
39
|
+
id: integer("id").primaryKey({ autoIncrement: true }),
|
|
40
|
+
startedAt: integer("started_at").notNull(),
|
|
41
|
+
finishedAt: integer("finished_at"),
|
|
42
|
+
durationMs: integer("duration_ms"),
|
|
43
|
+
pagesIndexed: integer("pages_indexed").default(0),
|
|
44
|
+
pagesRemaining: integer("pages_remaining").default(0),
|
|
45
|
+
errors: text("errors").default("[]"),
|
|
46
|
+
status: text("status").default("running")
|
|
47
|
+
}, (table) => [index("idx_ai_ready_cron_runs_started").on(table.startedAt)]);
|
|
48
|
+
// Sitemap tracking
|
|
47
49
|
export const sitemaps = sqliteTable("ai_ready_sitemaps", {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}, (table) => [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
name: text("name").primaryKey(),
|
|
51
|
+
route: text("route").notNull(),
|
|
52
|
+
lastCrawledAt: integer("last_crawled_at"),
|
|
53
|
+
urlCount: integer("url_count").default(0),
|
|
54
|
+
errorCount: integer("error_count").default(0),
|
|
55
|
+
lastError: text("last_error"),
|
|
56
|
+
crawlState: text("crawl_state")
|
|
57
|
+
}, (table) => [index("idx_ai_ready_sitemaps_crawled").on(table.lastCrawledAt)]);
|
|
58
|
+
// Export schema for migrations
|
|
59
|
+
export const schema = {
|
|
60
|
+
pages,
|
|
61
|
+
info,
|
|
62
|
+
cronRuns,
|
|
63
|
+
sitemaps
|
|
64
|
+
};
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite schema definitions for build-time prerendering
|
|
3
|
+
* Used by shared.ts during nuxi generate/build
|
|
4
|
+
*/
|
|
1
5
|
export const SCHEMA_VERSION = "v2.4.0";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Allowed FTS5 tokenizer values. The configured value gets interpolated into the
|
|
8
|
+
* `CREATE VIRTUAL TABLE … tokenize='…'` DDL, so we restrict it to a known-safe
|
|
9
|
+
* set instead of escaping. Adding a new tokenizer requires extending this list.
|
|
10
|
+
*/
|
|
11
|
+
export const SUPPORTED_FTS_TOKENIZERS = ["unicode61 remove_diacritics 2", "trigram"];
|
|
6
12
|
export const DEFAULT_FTS_TOKENIZER = "unicode61 remove_diacritics 2";
|
|
7
13
|
export function resolveFtsTokenizer(value) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return SUPPORTED_FTS_TOKENIZERS.includes(value) ? value : DEFAULT_FTS_TOKENIZER;
|
|
14
|
+
if (!value) return DEFAULT_FTS_TOKENIZER;
|
|
15
|
+
return SUPPORTED_FTS_TOKENIZERS.includes(value) ? value : DEFAULT_FTS_TOKENIZER;
|
|
11
16
|
}
|
|
12
17
|
export function buildSchemaSql(opts = {}) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
`CREATE TABLE IF NOT EXISTS ai_ready_pages (
|
|
18
|
+
const tokenizer = resolveFtsTokenizer(opts.ftsTokenizer);
|
|
19
|
+
return [
|
|
20
|
+
`CREATE TABLE IF NOT EXISTS ai_ready_pages (
|
|
17
21
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
18
22
|
route TEXT UNIQUE NOT NULL,
|
|
19
23
|
route_key TEXT UNIQUE NOT NULL,
|
|
@@ -32,16 +36,14 @@ export function buildSchemaSql(opts = {}) {
|
|
|
32
36
|
last_seen_at INTEGER,
|
|
33
37
|
locale TEXT NOT NULL DEFAULT ''
|
|
34
38
|
)`,
|
|
35
|
-
|
|
36
|
-
`CREATE TABLE IF NOT EXISTS _ai_ready_info (
|
|
39
|
+
`CREATE TABLE IF NOT EXISTS _ai_ready_info (
|
|
37
40
|
id TEXT PRIMARY KEY,
|
|
38
41
|
value TEXT,
|
|
39
42
|
version TEXT,
|
|
40
43
|
checksum TEXT,
|
|
41
44
|
ready INTEGER DEFAULT 0
|
|
42
45
|
)`,
|
|
43
|
-
|
|
44
|
-
`CREATE TABLE IF NOT EXISTS ai_ready_cron_runs (
|
|
46
|
+
`CREATE TABLE IF NOT EXISTS ai_ready_cron_runs (
|
|
45
47
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
46
48
|
started_at INTEGER NOT NULL,
|
|
47
49
|
finished_at INTEGER,
|
|
@@ -51,8 +53,7 @@ export function buildSchemaSql(opts = {}) {
|
|
|
51
53
|
errors TEXT DEFAULT '[]',
|
|
52
54
|
status TEXT DEFAULT 'running'
|
|
53
55
|
)`,
|
|
54
|
-
|
|
55
|
-
`CREATE TABLE IF NOT EXISTS ai_ready_sitemaps (
|
|
56
|
+
`CREATE TABLE IF NOT EXISTS ai_ready_sitemaps (
|
|
56
57
|
name TEXT PRIMARY KEY,
|
|
57
58
|
route TEXT NOT NULL,
|
|
58
59
|
last_crawled_at INTEGER,
|
|
@@ -61,28 +62,25 @@ export function buildSchemaSql(opts = {}) {
|
|
|
61
62
|
last_error TEXT,
|
|
62
63
|
crawl_state TEXT
|
|
63
64
|
)`,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// FTS5 virtual table
|
|
72
|
-
`CREATE VIRTUAL TABLE IF NOT EXISTS ai_ready_pages_fts USING fts5(
|
|
65
|
+
`CREATE INDEX IF NOT EXISTS idx_ai_ready_pages_route ON ai_ready_pages(route)`,
|
|
66
|
+
`CREATE INDEX IF NOT EXISTS idx_ai_ready_pages_is_error ON ai_ready_pages(is_error)`,
|
|
67
|
+
`CREATE INDEX IF NOT EXISTS idx_ai_ready_pages_indexed ON ai_ready_pages(indexed)`,
|
|
68
|
+
`CREATE INDEX IF NOT EXISTS idx_ai_ready_pages_source ON ai_ready_pages(source)`,
|
|
69
|
+
`CREATE INDEX IF NOT EXISTS idx_ai_ready_pages_last_seen ON ai_ready_pages(last_seen_at)`,
|
|
70
|
+
`CREATE INDEX IF NOT EXISTS idx_ai_ready_pages_locale ON ai_ready_pages(locale)`,
|
|
71
|
+
`CREATE VIRTUAL TABLE IF NOT EXISTS ai_ready_pages_fts USING fts5(
|
|
73
72
|
route, title, description, markdown, headings, keywords,
|
|
74
73
|
content=ai_ready_pages, content_rowid=id, tokenize='${tokenizer}'
|
|
75
74
|
)`,
|
|
76
|
-
|
|
77
|
-
`CREATE TRIGGER IF NOT EXISTS ai_ready_pages_ai AFTER INSERT ON ai_ready_pages BEGIN
|
|
75
|
+
`CREATE TRIGGER IF NOT EXISTS ai_ready_pages_ai AFTER INSERT ON ai_ready_pages BEGIN
|
|
78
76
|
INSERT INTO ai_ready_pages_fts(rowid, route, title, description, markdown, headings, keywords)
|
|
79
77
|
VALUES (new.id, new.route, new.title, new.description, new.markdown, new.headings, new.keywords);
|
|
80
78
|
END`,
|
|
81
|
-
|
|
79
|
+
`CREATE TRIGGER IF NOT EXISTS ai_ready_pages_ad AFTER DELETE ON ai_ready_pages BEGIN
|
|
82
80
|
INSERT INTO ai_ready_pages_fts(ai_ready_pages_fts, rowid, route, title, description, markdown, headings, keywords)
|
|
83
81
|
VALUES('delete', old.id, old.route, old.title, old.description, old.markdown, old.headings, old.keywords);
|
|
84
82
|
END`,
|
|
85
|
-
|
|
83
|
+
`CREATE TRIGGER IF NOT EXISTS ai_ready_pages_au AFTER UPDATE ON ai_ready_pages
|
|
86
84
|
WHEN old.route IS NOT new.route
|
|
87
85
|
OR old.title IS NOT new.title
|
|
88
86
|
OR old.description IS NOT new.description
|
|
@@ -95,14 +93,13 @@ export function buildSchemaSql(opts = {}) {
|
|
|
95
93
|
INSERT INTO ai_ready_pages_fts(rowid, route, title, description, markdown, headings, keywords)
|
|
96
94
|
VALUES (new.id, new.route, new.title, new.description, new.markdown, new.headings, new.keywords);
|
|
97
95
|
END`
|
|
98
|
-
|
|
96
|
+
];
|
|
99
97
|
}
|
|
100
98
|
export const DROP_TABLES_SQL = [
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
"DROP TABLE IF EXISTS ai_ready_sitemaps"
|
|
99
|
+
"DROP TABLE IF EXISTS ai_ready_pages_fts",
|
|
100
|
+
"DROP TABLE IF EXISTS ai_ready_pages",
|
|
101
|
+
"DROP TABLE IF EXISTS _ai_ready_info",
|
|
102
|
+
"DROP TABLE IF EXISTS ai_ready_cron_runs",
|
|
103
|
+
"DROP TABLE IF EXISTS ai_ready_indexnow_log",
|
|
104
|
+
"DROP TABLE IF EXISTS ai_ready_sitemaps"
|
|
108
105
|
];
|
|
@@ -2,56 +2,71 @@ import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
|
2
2
|
import { createUniversalContext } from "../utils/context.js";
|
|
3
3
|
import { resolveI18nDomain, resolveLocaleFromRoute } from "../utils/i18n.js";
|
|
4
4
|
function hostFromUrl(url) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
5
|
+
if (!url) return undefined;
|
|
6
|
+
try {
|
|
7
|
+
return new URL(url).host || undefined;
|
|
8
|
+
} catch {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
12
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a route's locale, deferring to the explicit value when supplied.
|
|
14
|
+
* Falls back to the runtime i18n config (set when @nuxtjs/i18n is detected at
|
|
15
|
+
* build time). Returns '' when no i18n is configured, matching the schema's
|
|
16
|
+
* default for non-i18n sites.
|
|
17
|
+
*
|
|
18
|
+
* The host comes from the page's own URL, in order of trust:
|
|
19
|
+
* 1. the sitemap entry URL, when the caller has one
|
|
20
|
+
* 2. the request host, but only when it is itself a configured locale domain:
|
|
21
|
+
* cron and poll requests can arrive on any domain (e.g. a workers.dev
|
|
22
|
+
* preview host), which would otherwise decide the locale of every indexed
|
|
23
|
+
* page on multi-domain i18n sites
|
|
24
|
+
* 3. the site config host
|
|
25
|
+
*/
|
|
13
26
|
export function deriveLocale(event, route, explicit, pageUrl) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return resolveLocaleFromRoute(route, i18n, host ? { host } : void 0).locale;
|
|
27
|
+
if (explicit !== undefined) return explicit;
|
|
28
|
+
const cfg = useRuntimeConfig();
|
|
29
|
+
const i18n = cfg["nuxt-ai-ready"]?.i18n;
|
|
30
|
+
if (!i18n) return "";
|
|
31
|
+
const entryHost = hostFromUrl(pageUrl);
|
|
32
|
+
if (entryHost) return resolveLocaleFromRoute(route, i18n, { host: entryHost }).locale;
|
|
33
|
+
let requestHost;
|
|
34
|
+
if (event) {
|
|
35
|
+
try {
|
|
36
|
+
const headers = event.req?.headers || event.node?.req.headers;
|
|
37
|
+
const host = headers instanceof Headers ? headers.get("x-forwarded-host") || headers.get("host") : headers?.["x-forwarded-host"] || headers?.host;
|
|
38
|
+
requestHost = (Array.isArray(host) ? host[0] : host)?.split(",")[0]?.trim();
|
|
39
|
+
} catch {
|
|
40
|
+
// An event without a readable request carries no host signal; fall
|
|
41
|
+
// through to the site config host.
|
|
42
|
+
requestHost = undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const host = requestHost && resolveI18nDomain(requestHost, i18n)._tag === "known" ? requestHost : hostFromUrl(createUniversalContext(event).siteUrl);
|
|
46
|
+
return resolveLocaleFromRoute(route, i18n, host ? { host } : undefined).locale;
|
|
35
47
|
}
|
|
48
|
+
/** Longest time `seedRoutes` lets `last_seen_at` lag behind a sighting. */
|
|
36
49
|
export const SEED_REFRESH_WINDOW_MS = 24 * 60 * 60 * 1e3;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve how long an unchanged seeded row may skip its `last_seen_at` write.
|
|
52
|
+
* With pruning on, the window stays at half of pruneTtl so the lag stays small
|
|
53
|
+
* against the TTL. Pass the same value to `pruneStaleRoutes`.
|
|
54
|
+
*/
|
|
37
55
|
export function resolveSeedRefreshWindowMs(pruneTtlSeconds) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return Math.min(SEED_REFRESH_WINDOW_MS, Math.floor(pruneTtlSeconds * 1e3 / 2));
|
|
56
|
+
if (!(pruneTtlSeconds > 0)) return SEED_REFRESH_WINDOW_MS;
|
|
57
|
+
return Math.min(SEED_REFRESH_WINDOW_MS, Math.floor(pruneTtlSeconds * 1e3 / 2));
|
|
41
58
|
}
|
|
59
|
+
/** Parse source dates once, so equivalent W3C date representations compare equal. */
|
|
42
60
|
export function parseSourceLastmod(input) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
return date.toISOString();
|
|
61
|
+
if (input === undefined) return null;
|
|
62
|
+
if (typeof input === "string" && (input.length > 64 || !/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2}))?$/.test(input))) return null;
|
|
63
|
+
const date = new Date(input);
|
|
64
|
+
if (!Number.isFinite(date.getTime())) return null;
|
|
65
|
+
// Date silently rolls invalid calendar dates into the next month.
|
|
66
|
+
if (typeof input === "string") {
|
|
67
|
+
const calendarDate = input.slice(0, 10);
|
|
68
|
+
const parsedCalendarDate = new Date(calendarDate);
|
|
69
|
+
if (!Number.isFinite(parsedCalendarDate.getTime()) || parsedCalendarDate.toISOString().slice(0, 10) !== calendarDate) return null;
|
|
70
|
+
}
|
|
71
|
+
return date.toISOString();
|
|
57
72
|
}
|