@farming-labs/theme 0.2.24 → 0.2.25
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 +4 -1
- package/dist/docs-api.mjs +43 -3
- package/package.json +2 -2
package/dist/docs-api.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangelogConfig, DocsAnalyticsConfig, DocsAskAIMcpConfig, DocsConfig, DocsI18nConfig, DocsMcpConfig, DocsObservabilityConfig, DocsRobotsConfig, DocsSearchConfig, DocsSitemapConfig, FeedbackConfig, LlmsTxtConfig, OrderingItem } from "@farming-labs/docs";
|
|
1
|
+
import { ChangelogConfig, DocsAnalyticsConfig, DocsAskAIMcpConfig, DocsConfig, DocsI18nConfig, DocsMcpConfig, DocsObservabilityConfig, DocsRobotsConfig, DocsSearchConfig, DocsSitemapConfig, DocsTelemetryConfig, FeedbackConfig, LlmsTxtConfig, OrderingItem } from "@farming-labs/docs";
|
|
2
2
|
|
|
3
3
|
//#region src/docs-api.d.ts
|
|
4
4
|
interface AIProviderConfig {
|
|
@@ -54,6 +54,8 @@ interface DocsAPIOptions {
|
|
|
54
54
|
search?: boolean | DocsSearchConfig;
|
|
55
55
|
/** Analytics configuration */
|
|
56
56
|
analytics?: boolean | DocsAnalyticsConfig;
|
|
57
|
+
/** Farming Labs maintainer telemetry configuration. */
|
|
58
|
+
telemetry?: boolean | DocsTelemetryConfig;
|
|
57
59
|
/** Observability configuration for logs, traces, and metrics callbacks. */
|
|
58
60
|
observability?: boolean | DocsObservabilityConfig;
|
|
59
61
|
/** Feedback configuration */
|
|
@@ -82,6 +84,7 @@ interface DocsMCPAPIOptions {
|
|
|
82
84
|
mcp?: boolean | DocsMcpConfig;
|
|
83
85
|
search?: boolean | DocsSearchConfig;
|
|
84
86
|
analytics?: boolean | DocsAnalyticsConfig;
|
|
87
|
+
telemetry?: boolean | DocsTelemetryConfig;
|
|
85
88
|
observability?: boolean | DocsObservabilityConfig;
|
|
86
89
|
}
|
|
87
90
|
type LlmsTxtOptions = LlmsTxtConfig;
|
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, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsRobotsResponse, createDocsSitemapResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, formatDocsAskAIPackageHints, getDocsLlmsTxtMaxCharsIssue, getDocsMarkdownVaryHeader, hasDocsMarkdownSignatureAgent, 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, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsRobotsResponse, createDocsSitemapResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, getDocsLlmsTxtMaxCharsIssue, getDocsMarkdownVaryHeader, hasDocsMarkdownSignatureAgent, inferDocsTelemetryAgentSurface, 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
|
|
@@ -2368,7 +2368,8 @@ function createDocsAPI(options) {
|
|
|
2368
2368
|
const contentDir = options?.contentDir ?? path.join(appDir, entry);
|
|
2369
2369
|
const changelogConfig = resolveChangelogConfig(options?.changelog);
|
|
2370
2370
|
const agentFeedbackConfig = resolveAgentFeedbackConfig(options?.feedback);
|
|
2371
|
-
const
|
|
2371
|
+
const i18nConfig = options?.i18n ?? readI18nConfig(root);
|
|
2372
|
+
const i18n = resolveDocsI18n(i18nConfig);
|
|
2372
2373
|
const aiConfig = options?.ai ?? readAIConfig(root);
|
|
2373
2374
|
const cloudConfig = options?.cloud ?? readCloudConfig(root);
|
|
2374
2375
|
const searchConfig = options?.search;
|
|
@@ -2390,7 +2391,42 @@ function createDocsAPI(options) {
|
|
|
2390
2391
|
apiReference: apiReferenceConfig
|
|
2391
2392
|
};
|
|
2392
2393
|
const openapiDiscovery = resolveApiReferenceOpenApiDiscovery(apiReferenceConfig);
|
|
2393
|
-
const
|
|
2394
|
+
const rawMcpConfig = options?.mcp ?? readMcpConfig(root);
|
|
2395
|
+
const mcpConfig = resolveDocsMcpConfig(rawMcpConfig, { defaultName: llmsConfig.siteTitle ?? "Documentation" });
|
|
2396
|
+
const telemetryConfig = {
|
|
2397
|
+
entry,
|
|
2398
|
+
docsPath,
|
|
2399
|
+
contentDir,
|
|
2400
|
+
telemetry: options?.telemetry,
|
|
2401
|
+
search: searchConfig,
|
|
2402
|
+
ai: aiConfig,
|
|
2403
|
+
cloud: cloudConfig,
|
|
2404
|
+
i18n: i18nConfig ?? void 0,
|
|
2405
|
+
feedback: options?.feedback,
|
|
2406
|
+
mcp: rawMcpConfig,
|
|
2407
|
+
llmsTxt: llmsConfig,
|
|
2408
|
+
sitemap: sitemapConfig,
|
|
2409
|
+
robots: robotsConfig,
|
|
2410
|
+
apiReference: apiReferenceConfig,
|
|
2411
|
+
metadata: options?.metadata
|
|
2412
|
+
};
|
|
2413
|
+
function trackTelemetryRequest(request) {
|
|
2414
|
+
emitDocsTelemetryProjectEvent(telemetryConfig, {
|
|
2415
|
+
framework: "next",
|
|
2416
|
+
request
|
|
2417
|
+
});
|
|
2418
|
+
const surface = inferDocsTelemetryAgentSurface(request, {
|
|
2419
|
+
entry,
|
|
2420
|
+
llmsTxt: llmsConfig,
|
|
2421
|
+
feedback: options?.feedback
|
|
2422
|
+
});
|
|
2423
|
+
if (!surface) return;
|
|
2424
|
+
emitDocsTelemetryAgentSurfaceEvent(telemetryConfig, {
|
|
2425
|
+
framework: "next",
|
|
2426
|
+
request,
|
|
2427
|
+
surface
|
|
2428
|
+
});
|
|
2429
|
+
}
|
|
2394
2430
|
function resolveDocsDirCandidates(locale) {
|
|
2395
2431
|
const relativeCandidates = /* @__PURE__ */ new Set();
|
|
2396
2432
|
if (path.isAbsolute(contentDir)) return [locale ? path.join(contentDir, locale) : contentDir];
|
|
@@ -2533,6 +2569,7 @@ function createDocsAPI(options) {
|
|
|
2533
2569
|
}
|
|
2534
2570
|
return {
|
|
2535
2571
|
async GET(request) {
|
|
2572
|
+
trackTelemetryRequest(request);
|
|
2536
2573
|
const ctx = resolveContextFromRequest(request);
|
|
2537
2574
|
const url = new URL(request.url);
|
|
2538
2575
|
const requestAnalyticsProperties = getRequestAnalyticsProperties(request);
|
|
@@ -2857,6 +2894,7 @@ function createDocsAPI(options) {
|
|
|
2857
2894
|
return new Response(JSON.stringify(results), { headers: { "Content-Type": "application/json" } });
|
|
2858
2895
|
},
|
|
2859
2896
|
async POST(request) {
|
|
2897
|
+
trackTelemetryRequest(request);
|
|
2860
2898
|
const url = new URL(request.url);
|
|
2861
2899
|
const requestAnalyticsProperties = getRequestAnalyticsProperties(request);
|
|
2862
2900
|
const agentFeedbackRequest = resolveAgentFeedbackRequest(url, agentFeedbackConfig);
|
|
@@ -2981,6 +3019,8 @@ function createDocsMCPAPI(options = {}) {
|
|
|
2981
3019
|
mcp: options.mcp ?? readMcpConfig(rootDir),
|
|
2982
3020
|
search: options.search,
|
|
2983
3021
|
analytics: options.analytics,
|
|
3022
|
+
telemetry: options.telemetry,
|
|
3023
|
+
telemetryFramework: "next",
|
|
2984
3024
|
observability: options.observability,
|
|
2985
3025
|
defaultName: navTitle
|
|
2986
3026
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.25",
|
|
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.25"
|
|
150
150
|
},
|
|
151
151
|
"peerDependencies": {
|
|
152
152
|
"@farming-labs/docs": ">=0.0.1",
|