@farming-labs/svelte 0.2.77 → 0.2.78
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/server.js +40 -9
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
import fs from "node:fs";
|
|
31
31
|
import path from "node:path";
|
|
32
32
|
import matter from "gray-matter";
|
|
33
|
-
import { applySidebarFolderIndexBehavior, buildDocsAskAIContext, buildDocsAgentDiscoverySpec, buildDocsConfigMap, buildDocsDiagnostics, createDocsStandardsDiscoveryResponse, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, findDocsMarkdownPage, getDocsLlmsTxtMaxCharsIssue, getDocsAgentManifestLinkHeader, getDocsDiscoveryLinkHeader, isDocsAgentDiscoveryRequest, isDocsAgentsRequest, isDocsConfigRequest, isDocsDiagnosticsRequest, isDocsSkillRequest, normalizeDocsRelated, normalizePageAgentFrontmatter, parseDocsAgentFeedbackData, performDocsSearch, performDocsSearchWithMetadata, renderDocsMarkdownDocument, renderDocsLlmsTxt, renderDocsAgentsDocument, renderDocsSkillDocument, readDocsSitemapManifestFromContentMap, stripGeneratedAgentProvenance, resolveDocsAudienceMdxContent, resolveDocsAgentFeedbackConfig, resolveDocsAgentFeedbackRequest, resolvePageSidebarFolderIndexBehavior, resolveAskAISearchRequestConfig, resolveDocsSearchAudience, resolveDocsSearchError, resolveDocsSearchRequest, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsMetadataBaseUrl, resolveDocsRequestApiRoute, resolveDocsRetrievalLastModified, resolveDocsPublishedAgentSkill, resolveDocsStandardsDiscoveryRequest, resolveDocsPath, resolvePageReadingTime, resolveReadingTimeOptions, resolveDocsSitemapPageLastmod, resolveDocsAgentsFormat, resolveDocsSkillFormat, inferDocsTelemetryAgentSurface, renderDocsPageStructuredDataJson, selectDocsLlmsTxtContent, validateDocsAgentFeedbackPayload, } from "@farming-labs/docs";
|
|
33
|
+
import { applySidebarFolderIndexBehavior, buildDocsAskAIContext, buildDocsSearchFacets, buildDocsAgentDiscoverySpec, buildDocsConfigMap, buildDocsDiagnostics, createDocsContentChangeFeed, createDocsContentChangesHttpResponse, createDocsStandardsDiscoveryResponse, createDocsMarkdownResponse, createDocsRobotsResponse, createDocsSitemapResponse, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryProjectEvent, formatDocsAskAIPackageHints, findDocsMarkdownPage, getDocsLlmsTxtMaxCharsIssue, getDocsAgentManifestLinkHeader, getDocsDiscoveryLinkHeader, isDocsAgentDiscoveryRequest, isDocsContentChangesRequest, isDocsAgentsRequest, isDocsConfigRequest, isDocsDiagnosticsRequest, isDocsSkillRequest, normalizeDocsRelated, normalizePageAgentFrontmatter, parseDocsAgentFeedbackData, performDocsSearch, performDocsSearchWithMetadata, renderDocsMarkdownDocument, renderDocsLlmsTxt, renderDocsAgentsDocument, renderDocsSkillDocument, readDocsSitemapManifestFromContentMap, stripGeneratedAgentProvenance, resolveDocsAudienceMdxContent, resolveDocsAgentFeedbackConfig, resolveDocsAgentFeedbackRequest, resolvePageSidebarFolderIndexBehavior, resolveAskAISearchRequestConfig, resolveDocsSearchAudience, resolveDocsSearchError, resolveDocsSearchRequest, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsMetadataBaseUrl, resolveDocsContentChangesConfig, resolveDocsRequestApiRoute, resolveDocsRetrievalLastModified, resolveDocsPublishedAgentSkill, resolveDocsStandardsDiscoveryRequest, resolveDocsPath, resolvePageReadingTime, resolveReadingTimeOptions, resolveDocsSitemapPageLastmod, resolveDocsAgentsFormat, resolveDocsSkillFormat, inferDocsTelemetryAgentSurface, renderDocsPageStructuredDataJson, selectDocsLlmsTxtContent, validateDocsAgentFeedbackPayload, } from "@farming-labs/docs";
|
|
34
34
|
import { buildApiReferenceOpenApiDocumentAsync, createDocsCloudAskAIResponse, createDocsMcpHttpHandler, isDocsCloudAskAIProvider, readDocsSitemapManifest, resolveApiReferenceOpenApiDiscovery, resolveDocsMcpConfig, resolveConfiguredAgentSkills, serializeDocsIconRegistry, serializeOpenDocsProviders, } from "@farming-labs/docs/server";
|
|
35
35
|
import { loadDocsNavTree, loadDocsContent, flattenNavTree, normalizeDocsFrontmatterLastmod, } from "./content.js";
|
|
36
36
|
import { renderMarkdown } from "./markdown.js";
|
|
@@ -635,6 +635,10 @@ export function createDocsServer(config = {}) {
|
|
|
635
635
|
const llmsTxtConfig = config.llmsTxt;
|
|
636
636
|
const llmsBaseUrl = typeof llmsTxtConfig === "object" ? (llmsTxtConfig.baseUrl ?? "") : "";
|
|
637
637
|
const markdownMetadataBaseUrl = resolveDocsMetadataBaseUrl(config);
|
|
638
|
+
const contentChangesConfig = resolveDocsContentChangesConfig(config.agent?.contentChanges, {
|
|
639
|
+
staticExport: config.staticExport === true,
|
|
640
|
+
});
|
|
641
|
+
const contentChangeFeed = createDocsContentChangeFeed(config.agent?.contentChanges);
|
|
638
642
|
const llmsTitle = typeof llmsTxtConfig === "object" ? (llmsTxtConfig.siteTitle ?? llmsSiteTitle) : llmsSiteTitle;
|
|
639
643
|
const llmsDesc = typeof llmsTxtConfig === "object" ? llmsTxtConfig.siteDescription : undefined;
|
|
640
644
|
const llmsEnabled = llmsTxtConfig !== false &&
|
|
@@ -719,6 +723,7 @@ export function createDocsServer(config = {}) {
|
|
|
719
723
|
apiCatalog: apiCatalogEnabled,
|
|
720
724
|
i18n,
|
|
721
725
|
search: config.search,
|
|
726
|
+
contentChanges: contentChangesConfig.enabled,
|
|
722
727
|
mcp: mcpConfig,
|
|
723
728
|
feedback: agentFeedbackDiscovery,
|
|
724
729
|
llms: {
|
|
@@ -814,6 +819,22 @@ export function createDocsServer(config = {}) {
|
|
|
814
819
|
},
|
|
815
820
|
});
|
|
816
821
|
}
|
|
822
|
+
if (isDocsContentChangesRequest(event.url)) {
|
|
823
|
+
if (!contentChangesConfig.enabled) {
|
|
824
|
+
return new Response("Not Found", {
|
|
825
|
+
status: 404,
|
|
826
|
+
headers: { "Content-Type": "text/plain; charset=utf-8", "X-Robots-Tag": "noindex" },
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
return createDocsContentChangesHttpResponse({
|
|
830
|
+
request: event.request,
|
|
831
|
+
feed: contentChangeFeed,
|
|
832
|
+
pages: getSearchIndex(ctx),
|
|
833
|
+
search: config.search,
|
|
834
|
+
locale: ctx.locale,
|
|
835
|
+
baseUrl: markdownMetadataBaseUrl || event.url.origin,
|
|
836
|
+
});
|
|
837
|
+
}
|
|
817
838
|
if (isApiReferenceOpenApiRequest(event.url)) {
|
|
818
839
|
if (!openapiDiscovery.enabled) {
|
|
819
840
|
return new Response("Not Found", {
|
|
@@ -990,8 +1011,8 @@ export function createDocsServer(config = {}) {
|
|
|
990
1011
|
throw error;
|
|
991
1012
|
return Response.json({ error: searchError }, { status: 400 });
|
|
992
1013
|
}
|
|
993
|
-
const { filters, structured, cursor, limit } = searchRequest;
|
|
994
|
-
if (!query && !structured) {
|
|
1014
|
+
const { filters, structured, facets, facet, cursor, limit } = searchRequest;
|
|
1015
|
+
if (!query && !structured && !facets) {
|
|
995
1016
|
return new Response("[]", {
|
|
996
1017
|
headers: { "Content-Type": "application/json" },
|
|
997
1018
|
});
|
|
@@ -1007,17 +1028,20 @@ export function createDocsServer(config = {}) {
|
|
|
1007
1028
|
siteTitle: llmsTitle,
|
|
1008
1029
|
baseUrl: markdownMetadataBaseUrl || event.url.origin,
|
|
1009
1030
|
syncBaseUrl: markdownMetadataBaseUrl ?? null,
|
|
1031
|
+
facet,
|
|
1010
1032
|
cursor,
|
|
1011
1033
|
limit,
|
|
1012
1034
|
};
|
|
1013
1035
|
const searchStartedAt = Date.now();
|
|
1014
1036
|
let searchResponse;
|
|
1015
1037
|
try {
|
|
1016
|
-
searchResponse =
|
|
1017
|
-
? await
|
|
1018
|
-
:
|
|
1019
|
-
? await
|
|
1020
|
-
:
|
|
1038
|
+
searchResponse = facets
|
|
1039
|
+
? await buildDocsSearchFacets(searchOptions)
|
|
1040
|
+
: structured
|
|
1041
|
+
? await performDocsSearchWithMetadata(searchOptions)
|
|
1042
|
+
: query
|
|
1043
|
+
? await performDocsSearch(searchOptions)
|
|
1044
|
+
: [];
|
|
1021
1045
|
}
|
|
1022
1046
|
catch (error) {
|
|
1023
1047
|
const searchError = resolveDocsSearchError(error);
|
|
@@ -1025,12 +1049,19 @@ export function createDocsServer(config = {}) {
|
|
|
1025
1049
|
throw error;
|
|
1026
1050
|
return Response.json({ error: searchError }, { status: 400 });
|
|
1027
1051
|
}
|
|
1052
|
+
if (facets) {
|
|
1053
|
+
return Response.json(searchResponse, {
|
|
1054
|
+
headers: { "Cache-Control": "public, max-age=60, stale-while-revalidate=300" },
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1028
1057
|
if (!query) {
|
|
1029
1058
|
return Response.json(searchResponse);
|
|
1030
1059
|
}
|
|
1031
1060
|
const resultCount = Array.isArray(searchResponse)
|
|
1032
1061
|
? searchResponse.length
|
|
1033
|
-
: searchResponse
|
|
1062
|
+
: "resultCount" in searchResponse
|
|
1063
|
+
? searchResponse.resultCount
|
|
1064
|
+
: searchResponse.matchedPageCount;
|
|
1034
1065
|
await emitDocsAnalyticsEvent(analytics, {
|
|
1035
1066
|
type: "api_search",
|
|
1036
1067
|
source: "server",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/svelte",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.78",
|
|
4
4
|
"description": "SvelteKit adapter for @farming-labs/docs — content loading and navigation utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@types/node": "^22.10.0",
|
|
58
58
|
"typescript": "^5.9.3",
|
|
59
59
|
"vitest": "^4.1.8",
|
|
60
|
-
"@farming-labs/docs": "0.2.
|
|
60
|
+
"@farming-labs/docs": "0.2.78"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@farming-labs/docs": ">=0.2.73"
|