@farming-labs/theme 0.2.33 → 0.2.35
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/docs-api.d.mts +2 -0
- package/dist/docs-api.mjs +26 -4
- package/dist/docs-cloud-ai-client.mjs +8 -6
- package/package.json +2 -2
package/dist/docs-api.d.mts
CHANGED
|
@@ -40,6 +40,8 @@ interface DocsAPIOptions {
|
|
|
40
40
|
docsPath?: string;
|
|
41
41
|
/** Override the docs content directory when it does not live in app/<entry>. */
|
|
42
42
|
contentDir?: string;
|
|
43
|
+
/** Set when the docs site is built without runtime API routes. */
|
|
44
|
+
staticExport?: boolean;
|
|
43
45
|
/** Changelog configuration. */
|
|
44
46
|
changelog?: boolean | ChangelogConfig;
|
|
45
47
|
/** Search language (default: "english") */
|
package/dist/docs-api.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { getNextAppDir } from "./get-app-dir.mjs";
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import matter from "gray-matter";
|
|
6
|
-
import { DEFAULT_SITEMAP_MD_DOCS_ROUTE, buildDocsAskAIContext, buildDocsConfigMap, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsRobotsResponse, createDocsSitemapResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, getDocsLlmsTxtMaxCharsIssue, getDocsMarkdownVaryHeader, hasDocsMarkdownSignatureAgent, inferDocsTelemetryAgentSurface, isDocsConfigRequest, normalizeDocsRelated, performDocsSearch, renderDocsLlmsTxt, renderDocsMarkdownDocument, renderDocsMarkdownNotFound, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMarkdownRecovery, resolveDocsMetadataBaseUrl, resolveDocsSitemapConfig, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent } from "@farming-labs/docs";
|
|
6
|
+
import { DEFAULT_SITEMAP_MD_DOCS_ROUTE, buildDocsAskAIContext, buildDocsConfigMap, buildDocsDiagnostics, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsRobotsResponse, createDocsSitemapResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, getDocsLlmsTxtMaxCharsIssue, getDocsMarkdownVaryHeader, hasDocsMarkdownSignatureAgent, inferDocsTelemetryAgentSurface, isDocsConfigRequest, isDocsDiagnosticsRequest, normalizeDocsRelated, performDocsSearch, renderDocsLlmsTxt, renderDocsMarkdownDocument, renderDocsMarkdownNotFound, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMarkdownRecovery, resolveDocsMetadataBaseUrl, resolveDocsSitemapConfig, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent } from "@farming-labs/docs";
|
|
7
7
|
import { buildApiReferenceOpenApiDocumentAsync, createDocsMcpHttpHandler, createFilesystemDocsMcpSource, readDocsSitemapManifest, resolveApiReferenceConfig, resolveDocsMcpConfig } from "@farming-labs/docs/server";
|
|
8
8
|
|
|
9
9
|
//#region src/docs-api.ts
|
|
@@ -251,6 +251,7 @@ function buildAgentSpec({ origin, entry, i18n, search, mcp, feedback, llms, site
|
|
|
251
251
|
api: {
|
|
252
252
|
docs: DEFAULT_DOCS_API_ROUTE,
|
|
253
253
|
config: `${DEFAULT_DOCS_API_ROUTE}?format=config`,
|
|
254
|
+
diagnostics: `${DEFAULT_DOCS_API_ROUTE}?format=diagnostics`,
|
|
254
255
|
agentSpec: DEFAULT_AGENT_SPEC_ROUTE,
|
|
255
256
|
agentSpecDefault: DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE,
|
|
256
257
|
agentSpecFallback: DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE,
|
|
@@ -1355,10 +1356,10 @@ function readRuntimeEnv(name) {
|
|
|
1355
1356
|
return value ? value : void 0;
|
|
1356
1357
|
}
|
|
1357
1358
|
function resolveDocsCloudApiBaseUrl() {
|
|
1358
|
-
return (readRuntimeEnv("DOCS_CLOUD_API_URL") ?? readRuntimeEnv("NEXT_PUBLIC_DOCS_CLOUD_URL") ?? DEFAULT_DOCS_CLOUD_API_BASE_URL).replace(/\/+$/, "");
|
|
1359
|
+
return (readRuntimeEnv("DOCS_CLOUD_API_URL") ?? readRuntimeEnv("PUBLIC_DOCS_CLOUD_URL") ?? readRuntimeEnv("NEXT_PUBLIC_DOCS_CLOUD_URL") ?? DEFAULT_DOCS_CLOUD_API_BASE_URL).replace(/\/+$/, "");
|
|
1359
1360
|
}
|
|
1360
1361
|
function resolveDocsCloudProjectId() {
|
|
1361
|
-
return readRuntimeEnv("NEXT_PUBLIC_DOCS_CLOUD_PROJECT_ID") ?? readRuntimeEnv("DOCS_CLOUD_PROJECT_ID");
|
|
1362
|
+
return readRuntimeEnv("PUBLIC_DOCS_CLOUD_PROJECT_ID") ?? readRuntimeEnv("NEXT_PUBLIC_DOCS_CLOUD_PROJECT_ID") ?? readRuntimeEnv("DOCS_CLOUD_PROJECT_ID");
|
|
1362
1363
|
}
|
|
1363
1364
|
function resolveDocsCloudApiKey(cloudConfig) {
|
|
1364
1365
|
const envName = cloudConfig?.apiKey?.env?.trim() || DEFAULT_DOCS_CLOUD_API_KEY_ENV;
|
|
@@ -1647,7 +1648,7 @@ async function handleAskAI(request, indexes, aiConfig, cloudConfig, search, anal
|
|
|
1647
1648
|
model,
|
|
1648
1649
|
envName: !apiKey ? envName : void 0
|
|
1649
1650
|
});
|
|
1650
|
-
return Response.json({ error: !projectId ? "AI provider docs-cloud requires
|
|
1651
|
+
return Response.json({ error: !projectId ? "AI provider docs-cloud requires PUBLIC_DOCS_CLOUD_PROJECT_ID or DOCS_CLOUD_PROJECT_ID." : `AI provider docs-cloud requires ${envName} to be set on the server.` }, { status: 500 });
|
|
1651
1652
|
}
|
|
1652
1653
|
await emitDocsAnalyticsEvent(analytics, {
|
|
1653
1654
|
type: "api_ai_request",
|
|
@@ -2428,6 +2429,16 @@ function createDocsAPI(options) {
|
|
|
2428
2429
|
setConfigMapFallback("i18n", i18nConfig ?? void 0);
|
|
2429
2430
|
setConfigMapFallback("mcp", rawMcpConfig);
|
|
2430
2431
|
setConfigMapFallback("apiReference", apiReferenceConfig);
|
|
2432
|
+
const docsDiagnosticsInput = {
|
|
2433
|
+
...docsConfigMapInput,
|
|
2434
|
+
docsPath: docsConfigMapInput.docsPath ?? docsPath,
|
|
2435
|
+
contentDir: docsConfigMapInput.contentDir ?? contentDir,
|
|
2436
|
+
feedback: docsConfigMapInput.feedback ?? options?.feedback,
|
|
2437
|
+
llmsTxt: docsConfigMapInput.llmsTxt ?? llmsConfig,
|
|
2438
|
+
sitemap: docsConfigMapInput.sitemap ?? sitemapConfig,
|
|
2439
|
+
robots: docsConfigMapInput.robots ?? robotsConfig,
|
|
2440
|
+
staticExport: docsConfigMapInput.staticExport ?? options?.staticExport
|
|
2441
|
+
};
|
|
2431
2442
|
function trackTelemetryRequest(request) {
|
|
2432
2443
|
emitDocsTelemetryProjectEvent(telemetryConfig, {
|
|
2433
2444
|
framework: "next",
|
|
@@ -2595,6 +2606,17 @@ function createDocsAPI(options) {
|
|
|
2595
2606
|
"Cache-Control": "public, max-age=0, s-maxage=3600",
|
|
2596
2607
|
"X-Robots-Tag": "noindex"
|
|
2597
2608
|
} });
|
|
2609
|
+
if (isDocsDiagnosticsRequest(url)) return Response.json(buildDocsDiagnostics(docsDiagnosticsInput, {
|
|
2610
|
+
adapter: "next",
|
|
2611
|
+
entry,
|
|
2612
|
+
i18n,
|
|
2613
|
+
mcp: mcpConfig,
|
|
2614
|
+
feedback: agentFeedbackConfig,
|
|
2615
|
+
openapi: openapiDiscovery
|
|
2616
|
+
}), { headers: {
|
|
2617
|
+
"Cache-Control": "public, max-age=0, s-maxage=3600",
|
|
2618
|
+
"X-Robots-Tag": "noindex"
|
|
2619
|
+
} });
|
|
2598
2620
|
if (resolveAgentSpecRequest(url)) {
|
|
2599
2621
|
await emitDocsAnalyticsEvent(analytics, {
|
|
2600
2622
|
type: "agent_spec_request",
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
//#region src/docs-cloud-ai-client.ts
|
|
2
2
|
const DEFAULT_DOCS_API_ROUTE = "/api/docs";
|
|
3
3
|
const DEFAULT_DOCS_CLOUD_API_BASE_URL = "https://api.farming-labs.dev";
|
|
4
|
-
const DEFAULT_PUBLIC_DOCS_CLOUD_PROJECT_ID_ENV = "
|
|
5
|
-
const
|
|
4
|
+
const DEFAULT_PUBLIC_DOCS_CLOUD_PROJECT_ID_ENV = "PUBLIC_DOCS_CLOUD_PROJECT_ID";
|
|
5
|
+
const FALLBACK_PUBLIC_DOCS_CLOUD_PROJECT_ID_ENV = "NEXT_PUBLIC_DOCS_CLOUD_PROJECT_ID";
|
|
6
|
+
const DEFAULT_PUBLIC_DOCS_CLOUD_API_KEY_ENV = "PUBLIC_DOCS_CLOUD_API_KEY";
|
|
7
|
+
const FALLBACK_PUBLIC_DOCS_CLOUD_API_KEY_ENV = "NEXT_PUBLIC_DOCS_CLOUD_API_KEY";
|
|
6
8
|
function readRuntimeEnv(name) {
|
|
7
9
|
const value = process.env[name]?.trim();
|
|
8
10
|
return value ? value : void 0;
|
|
9
11
|
}
|
|
10
12
|
function resolveDocsCloudApiBaseUrl() {
|
|
11
|
-
return (readRuntimeEnv("NEXT_PUBLIC_DOCS_CLOUD_URL") ?? readRuntimeEnv("DOCS_CLOUD_API_URL") ?? DEFAULT_DOCS_CLOUD_API_BASE_URL).replace(/\/+$/, "");
|
|
13
|
+
return (readRuntimeEnv("PUBLIC_DOCS_CLOUD_URL") ?? readRuntimeEnv("NEXT_PUBLIC_DOCS_CLOUD_URL") ?? readRuntimeEnv("DOCS_CLOUD_API_URL") ?? DEFAULT_DOCS_CLOUD_API_BASE_URL).replace(/\/+$/, "");
|
|
12
14
|
}
|
|
13
15
|
function resolveDocsCloudProjectId() {
|
|
14
|
-
return readRuntimeEnv(DEFAULT_PUBLIC_DOCS_CLOUD_PROJECT_ID_ENV);
|
|
16
|
+
return readRuntimeEnv(DEFAULT_PUBLIC_DOCS_CLOUD_PROJECT_ID_ENV) ?? readRuntimeEnv(FALLBACK_PUBLIC_DOCS_CLOUD_PROJECT_ID_ENV);
|
|
15
17
|
}
|
|
16
18
|
function resolveDocsCloudApiKey(config) {
|
|
17
19
|
const configuredEnv = config.cloud?.apiKey?.env?.trim();
|
|
18
20
|
if (configuredEnv && isPublicRuntimeEnvName(configuredEnv)) return readRuntimeEnv(configuredEnv);
|
|
19
|
-
return readRuntimeEnv(DEFAULT_PUBLIC_DOCS_CLOUD_API_KEY_ENV);
|
|
21
|
+
return readRuntimeEnv(DEFAULT_PUBLIC_DOCS_CLOUD_API_KEY_ENV) ?? readRuntimeEnv(FALLBACK_PUBLIC_DOCS_CLOUD_API_KEY_ENV);
|
|
20
22
|
}
|
|
21
23
|
function isPublicRuntimeEnvName(name) {
|
|
22
|
-
return name.startsWith("NEXT_PUBLIC_");
|
|
24
|
+
return name.startsWith("PUBLIC_") || name.startsWith("NEXT_PUBLIC_");
|
|
23
25
|
}
|
|
24
26
|
function resolveDocsCloudAIStream(config) {
|
|
25
27
|
const aiConfig = config.ai;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.35",
|
|
4
4
|
"description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"tsdown": "^0.20.3",
|
|
147
147
|
"typescript": "^5.9.3",
|
|
148
148
|
"vitest": "^4.1.8",
|
|
149
|
-
"@farming-labs/docs": "0.2.
|
|
149
|
+
"@farming-labs/docs": "0.2.35"
|
|
150
150
|
},
|
|
151
151
|
"peerDependencies": {
|
|
152
152
|
"@farming-labs/docs": ">=0.0.1",
|