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,31 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drizzle ORM database layer for nuxt-ai-ready
|
|
3
|
+
*/
|
|
4
|
+
// Re-export schema for direct table access (build-time aliased to sqlite or postgres)
|
|
1
5
|
export * from "#ai-ready-virtual/db-schema.mjs";
|
|
6
|
+
// Client
|
|
2
7
|
export { closeDrizzle, finishDrizzleResponse, trackDrizzleWork, useDrizzle } from "./client.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
getRecentCronRuns,
|
|
15
|
-
getSitemapStatus,
|
|
16
|
-
initSchema,
|
|
17
|
-
markPageIndexed,
|
|
18
|
-
markRoutesPending,
|
|
19
|
-
markSitemapCrawled,
|
|
20
|
-
markSitemapCrawlPartial,
|
|
21
|
-
markSitemapError,
|
|
22
|
-
markSitemapSeeded,
|
|
23
|
-
resetSitemapErrors,
|
|
24
|
-
searchPages,
|
|
25
|
-
seedRoutes,
|
|
26
|
-
setInfoValue,
|
|
27
|
-
startCronRun,
|
|
28
|
-
syncSitemaps,
|
|
29
|
-
upsertPage
|
|
30
|
-
} from "./queries.js";
|
|
8
|
+
// Queries
|
|
9
|
+
export {
|
|
10
|
+
// Cron queries
|
|
11
|
+
completeCronRun,
|
|
12
|
+
// Page queries
|
|
13
|
+
countPages,
|
|
14
|
+
// Info table queries
|
|
15
|
+
deleteInfoValue, getAllPages, getContentHashes, getInfoValue,
|
|
16
|
+
// Sitemap queries
|
|
17
|
+
getNextSitemapToCrawl, getPageByRoute, getPageLastmods, getPendingPages, getRecentCronRuns, getSitemapStatus, initSchema, markPageIndexed, markRoutesPending, markSitemapCrawled, markSitemapCrawlPartial, markSitemapError, markSitemapSeeded, resetSitemapErrors, searchPages, seedRoutes, setInfoValue, startCronRun, syncSitemaps, upsertPage } from "./queries.js";
|
|
18
|
+
// Raw SQL access
|
|
31
19
|
export { useRawDb } from "./raw.js";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AiReadyDatabaseEvent } from '../../context.js';
|
|
2
|
+
import { Database } from 'bun:sqlite';
|
|
2
3
|
export declare function createClient(_event?: AiReadyDatabaseEvent): Promise<{
|
|
3
4
|
dialect: "sqlite";
|
|
4
5
|
db: import("drizzle-orm/bun-sqlite").SQLiteBunDatabase<import("drizzle-orm").EmptyRelations> & {
|
|
5
|
-
$client:
|
|
6
|
+
$client: Database;
|
|
6
7
|
};
|
|
7
8
|
}>;
|
|
@@ -5,11 +5,14 @@ import { logger } from "../../../logger.js";
|
|
|
5
5
|
import { registerDriver } from "../raw.js";
|
|
6
6
|
import { resolveWritableDbPath } from "./dbPath.js";
|
|
7
7
|
export async function createClient(_event) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
const config = useRuntimeConfig()["nuxt-ai-ready"];
|
|
9
|
+
const dbPath = await resolveWritableDbPath(config.database.filename || ".data/ai-ready/pages.db");
|
|
10
|
+
logger.debug(`[drizzle] Opening Bun SQLite database: ${dbPath}`);
|
|
11
|
+
const sqlite = new Database(dbPath);
|
|
12
|
+
const db = drizzle({ client: sqlite });
|
|
13
|
+
registerDriver(db, "better-sqlite3", sqlite);
|
|
14
|
+
return {
|
|
15
|
+
dialect: "sqlite",
|
|
16
|
+
db
|
|
17
|
+
};
|
|
15
18
|
}
|
|
@@ -3,17 +3,20 @@ import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
|
3
3
|
import { logger } from "../../../logger.js";
|
|
4
4
|
import { registerDriver } from "../raw.js";
|
|
5
5
|
export async function createClient(event) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
const config = useRuntimeConfig()["nuxt-ai-ready"];
|
|
7
|
+
const bindingName = config.database.bindingName || "DB";
|
|
8
|
+
logger.debug(`[drizzle] Using D1 binding: ${bindingName}`);
|
|
9
|
+
const cloudflare = event?.context.cloudflare;
|
|
10
|
+
const cfEnv = cloudflare?.env;
|
|
11
|
+
const globalEnv = globalThis.__env__;
|
|
12
|
+
const d1 = cfEnv?.[bindingName] || globalEnv?.[bindingName];
|
|
13
|
+
if (!d1) {
|
|
14
|
+
throw new Error(`[ai-ready] D1 binding "${bindingName}" not found`);
|
|
15
|
+
}
|
|
16
|
+
const db = drizzle(d1);
|
|
17
|
+
registerDriver(db, "d1", d1);
|
|
18
|
+
return {
|
|
19
|
+
dialect: "sqlite",
|
|
20
|
+
db
|
|
21
|
+
};
|
|
19
22
|
}
|
|
@@ -3,46 +3,69 @@ import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { dirname, join, resolve } from "pathe";
|
|
5
5
|
import { logger } from "../../../logger.js";
|
|
6
|
-
|
|
6
|
+
// Resolution is stable for the lifetime of the process (the filesystem does not
|
|
7
|
+
// flip from writable to read-only mid-run), so memoise per configured path to
|
|
8
|
+
// avoid probing on every request.
|
|
9
|
+
const resolved = new Map();
|
|
10
|
+
/**
|
|
11
|
+
* Ensure a directory exists and is actually writable.
|
|
12
|
+
*
|
|
13
|
+
* A recursive `mkdir` succeeding does NOT prove writability: the directory may
|
|
14
|
+
* already exist inside a read-only bundle, in which case `mkdir` is a no-op but
|
|
15
|
+
* a later `new Database()` open-for-write still fails. So probe with a real
|
|
16
|
+
* write. Returns the failing error, or null when the directory is writable.
|
|
17
|
+
*/
|
|
7
18
|
async function ensureWritableDir(dir) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
const mkErr = await mkdir(dir, { recursive: true }).then(() => null).catch((e) => e);
|
|
20
|
+
if (mkErr) return mkErr;
|
|
21
|
+
const probe = join(dir, ".ai-ready-write-test");
|
|
22
|
+
const writeErr = await writeFile(probe, "").then(() => null).catch((e) => e);
|
|
23
|
+
if (writeErr) return writeErr;
|
|
24
|
+
// Best-effort cleanup; a failed probe-file removal does not change the fact
|
|
25
|
+
// that the directory is writable, which is all this check establishes.
|
|
26
|
+
await rm(probe, { force: true }).catch(() => {
|
|
27
|
+
// Probe cleanup does not affect the established directory writability.
|
|
28
|
+
});
|
|
29
|
+
return null;
|
|
18
30
|
}
|
|
19
31
|
function isRecoverable(err) {
|
|
20
|
-
|
|
32
|
+
// EROFS/EACCES: read-only or permission-denied filesystem.
|
|
33
|
+
// ENOENT/ENOTDIR: the configured path cannot exist at runtime — e.g. on Vercel
|
|
34
|
+
// serverless the build cwd (/vercel/path0) is gone, so a relative '.data/...'
|
|
35
|
+
// mkdir rejects with ENOENT even with recursive: true.
|
|
36
|
+
return err.code === "EROFS" || err.code === "EACCES" || err.code === "ENOENT" || err.code === "ENOTDIR";
|
|
21
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolve a writable path for a file-based SQLite database, returning the path
|
|
40
|
+
* to actually open.
|
|
41
|
+
*
|
|
42
|
+
* On a read-only filesystem (read-only Docker container, serverless bundle) the
|
|
43
|
+
* configured directory cannot be written. Rather than crash every request, fall
|
|
44
|
+
* back to a temp dir so runtime indexing keeps working. The fallback is
|
|
45
|
+
* namespaced by a hash of the absolute configured path so unrelated apps sharing
|
|
46
|
+
* the OS temp dir do not open the same SQLite file (the tables are package-global
|
|
47
|
+
* and not namespaced per site). The fallback database is ephemeral and reseeded
|
|
48
|
+
* from the prerendered dump / sitemap on cold start, so this is a safe
|
|
49
|
+
* degradation for the SSR indexing model.
|
|
50
|
+
*/
|
|
22
51
|
export async function resolveWritableDbPath(dbPath) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const fallback = join(fallbackDir, "pages.db");
|
|
43
|
-
logger.warn(
|
|
44
|
-
`[ai-ready] Database directory '${dir}' is not writable (${err.code}); falling back to '${fallback}'. This database is ephemeral and reseeded on cold start. Set database.filename to a writable persistent path (or a volume) to silence this warning.`
|
|
45
|
-
);
|
|
46
|
-
resolved.set(dbPath, fallback);
|
|
47
|
-
return fallback;
|
|
52
|
+
const cached = resolved.get(dbPath);
|
|
53
|
+
if (cached) return cached;
|
|
54
|
+
const dir = dirname(dbPath);
|
|
55
|
+
const err = await ensureWritableDir(dir);
|
|
56
|
+
if (!err) {
|
|
57
|
+
resolved.set(dbPath, dbPath);
|
|
58
|
+
return dbPath;
|
|
59
|
+
}
|
|
60
|
+
if (!isRecoverable(err)) throw err;
|
|
61
|
+
const key = createHash("sha256").update(resolve(dbPath)).digest("hex").slice(0, 16);
|
|
62
|
+
const fallbackDir = join(tmpdir(), `ai-ready-${key}`);
|
|
63
|
+
const fallbackErr = await ensureWritableDir(fallbackDir);
|
|
64
|
+
if (fallbackErr) {
|
|
65
|
+
throw new Error(`[ai-ready] Database directory '${dir}' is not writable (${err.code}) and the temp dir fallback ` + `('${fallbackDir}') also failed: ${fallbackErr.message}. Set database.filename to a ` + `writable path, or use a remote driver: database.type 'd1' (Cloudflare), ` + `'neon' (Vercel), 'postgres' (PostgreSQL), or 'libsql' (Turso).`);
|
|
66
|
+
}
|
|
67
|
+
const fallback = join(fallbackDir, "pages.db");
|
|
68
|
+
logger.warn(`[ai-ready] Database directory '${dir}' is not writable (${err.code}); falling back to '${fallback}'. ` + `This database is ephemeral and reseeded on cold start. Set database.filename to a ` + `writable persistent path (or a volume) to silence this warning.`);
|
|
69
|
+
resolved.set(dbPath, fallback);
|
|
70
|
+
return fallback;
|
|
48
71
|
}
|
|
@@ -5,15 +5,27 @@ import { logger } from "../../../logger.js";
|
|
|
5
5
|
import { registerDriver } from "../raw.js";
|
|
6
6
|
import { resolveWritableDbPath } from "./dbPath.js";
|
|
7
7
|
export async function createClient(_event) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
const config = useRuntimeConfig()["nuxt-ai-ready"];
|
|
9
|
+
let dbUrl = config.database.url || `file:${config.database.filename || ".data/ai-ready/pages.db"}`;
|
|
10
|
+
// A local file database (`file:<path>`) can land on a read-only deploy
|
|
11
|
+
// filesystem, where libsql would throw `ConnectionFailed(... : 14)` (CANTOPEN)
|
|
12
|
+
// with no recovery (nuxt/scripts#818). Mirror the sqlite provider: resolve to a
|
|
13
|
+
// writable path, falling back to a temp dir on a read-only dir. Remote libsql /
|
|
14
|
+
// turso URLs (libsql:, http:, https:, ws:, wss:) and URL-authority `file://`
|
|
15
|
+
// forms are left untouched.
|
|
16
|
+
if (dbUrl.startsWith("file:") && !dbUrl.startsWith("file://")) {
|
|
17
|
+
const resolved = await resolveWritableDbPath(dbUrl.slice("file:".length));
|
|
18
|
+
dbUrl = `file:${resolved}`;
|
|
19
|
+
}
|
|
20
|
+
logger.debug(`[drizzle] Connecting to LibSQL: ${dbUrl}`);
|
|
21
|
+
const client = createLibSQLClient({
|
|
22
|
+
url: dbUrl,
|
|
23
|
+
authToken: config.database.authToken
|
|
24
|
+
});
|
|
25
|
+
const db = drizzle({ client });
|
|
26
|
+
registerDriver(db, "libsql", client);
|
|
27
|
+
return {
|
|
28
|
+
dialect: "sqlite",
|
|
29
|
+
db
|
|
30
|
+
};
|
|
19
31
|
}
|
|
@@ -4,14 +4,17 @@ import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
|
4
4
|
import { logger } from "../../../logger.js";
|
|
5
5
|
import { registerDriver } from "../raw.js";
|
|
6
6
|
export async function createClient(_event) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
const config = useRuntimeConfig()["nuxt-ai-ready"];
|
|
8
|
+
const connectionString = config.database.url || process.env.POSTGRES_URL || process.env.DATABASE_URL;
|
|
9
|
+
if (!connectionString) {
|
|
10
|
+
throw new Error("[ai-ready] Missing database URL. Set POSTGRES_URL or configure database.url");
|
|
11
|
+
}
|
|
12
|
+
logger.debug(`[drizzle] Connecting to Neon Postgres`);
|
|
13
|
+
const sqlFn = neon(connectionString);
|
|
14
|
+
const db = drizzle({ client: sqlFn });
|
|
15
|
+
registerDriver(db, "neon", sqlFn);
|
|
16
|
+
return {
|
|
17
|
+
dialect: "postgres",
|
|
18
|
+
db
|
|
19
|
+
};
|
|
17
20
|
}
|
|
@@ -5,11 +5,14 @@ import { logger } from "../../../logger.js";
|
|
|
5
5
|
import { registerDriver } from "../raw.js";
|
|
6
6
|
import { resolveWritableDbPath } from "./dbPath.js";
|
|
7
7
|
export async function createClient(_event) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
const config = useRuntimeConfig()["nuxt-ai-ready"];
|
|
9
|
+
const dbPath = await resolveWritableDbPath(config.database.filename || ".data/ai-ready/pages.db");
|
|
10
|
+
logger.debug(`[drizzle] Opening native SQLite database: ${dbPath}`);
|
|
11
|
+
const sqlite = new DatabaseSync(dbPath);
|
|
12
|
+
const db = drizzle({ client: sqlite });
|
|
13
|
+
registerDriver(db, "node-sqlite", sqlite);
|
|
14
|
+
return {
|
|
15
|
+
dialect: "sqlite",
|
|
16
|
+
db
|
|
17
|
+
};
|
|
15
18
|
}
|
|
@@ -4,14 +4,17 @@ import { useRuntimeConfig } from "#nuxtseo/nitro";
|
|
|
4
4
|
import { logger } from "../../../logger.js";
|
|
5
5
|
import { registerDriver } from "../raw.js";
|
|
6
6
|
export async function createClient(_event) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
const config = useRuntimeConfig()["nuxt-ai-ready"];
|
|
8
|
+
const connectionString = config.database.url || process.env.POSTGRES_URL || process.env.DATABASE_URL;
|
|
9
|
+
if (!connectionString) {
|
|
10
|
+
throw new Error("[ai-ready] Missing database URL. Set DATABASE_URL or configure database.url");
|
|
11
|
+
}
|
|
12
|
+
logger.debug("[drizzle] Connecting to PostgreSQL");
|
|
13
|
+
const sqlClient = postgres(connectionString, { prepare: false });
|
|
14
|
+
const db = drizzle({ client: sqlClient });
|
|
15
|
+
registerDriver(db, "postgres", sqlClient);
|
|
16
|
+
return {
|
|
17
|
+
dialect: "postgres",
|
|
18
|
+
db
|
|
19
|
+
};
|
|
17
20
|
}
|