@redocly/reef 0.140.0 → 0.141.0-next.0
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/CHANGELOG.md +11 -0
- package/dist/client/app/search/useFacets.d.ts +1 -1
- package/dist/client/app/search/useFacets.js +1 -1
- package/dist/client/app/search/useSearch.js +1 -1
- package/dist/server/plugins/api-docs/search/get-ai-search-documents.js +14 -14
- package/dist/server/plugins/markdown/search/create-render-tag-fn.d.ts +1 -1
- package/dist/server/plugins/markdown/search/create-render-tag-fn.js +1 -1
- package/dist/server/plugins/markdown/search/get-ai-search-documents.js +8 -8
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @redocly/reef
|
|
2
2
|
|
|
3
|
+
## 0.141.0-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6e38eefc93c: Fixed an issue where the `renderForLlms` of custom Markdoc tags received variable references instead of values for attributes set with `$frontmatter` or `$env`.
|
|
8
|
+
Attributes set with other variables or with functions still pass the reference.
|
|
9
|
+
- Updated dependencies [646e97c1085]
|
|
10
|
+
- Updated dependencies [80da2b54a6b]
|
|
11
|
+
- Updated dependencies [646e97c1085]
|
|
12
|
+
- @redocly/api-docs@0.6.0-next.0
|
|
13
|
+
|
|
3
14
|
## 0.140.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
|
@@ -4,7 +4,7 @@ export declare function useFacetQuery(field: string): {
|
|
|
4
4
|
setSearchFacet: import("react").Dispatch<import("react").SetStateAction<SearchFacet | null>>;
|
|
5
5
|
setSearchFacetQuery: import("react").Dispatch<import("react").SetStateAction<SearchFacetQuery | null>>;
|
|
6
6
|
};
|
|
7
|
-
export declare const useFacets: (facetCounts?: Record<string, SearchFacetCount[]
|
|
7
|
+
export declare const useFacets: (facetCounts?: Record<string, SearchFacetCount[]>, product?: string) => {
|
|
8
8
|
facets: SearchFacet[];
|
|
9
9
|
};
|
|
10
10
|
//# sourceMappingURL=useFacets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as
|
|
1
|
+
import{useCallback as S,useEffect as f,useMemo as b,useState as o}from"react";import{withPathPrefix as g}from"@redocly/theme/core/utils";import{ServerRoutes as C}from"../../../constants/api";import{SEARCH_PRODUCT_FIELD as E}from"../../../constants/common";import{useI18nConfig as L}from"../hooks";function F({field:e,product:a}){const[c,n]=o([]),[t,s]=o(null),[r,h]=o(null),[m,i]=o(!1),{currentLocale:l}=L();f(()=>{i(!0),p()},[r,a]);const p=S(async()=>{if(e&&r===null){i(!1);return}const y={locale:l,field:e,...r,...a&&{filter:[{field:E,values:[a]}]}},u=await(await fetch(g(C.SEARCH_FACETS),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(y)})).json();e?s(u):n(u),i(!1)},[l,r,e,a]);return{initialFacets:c,searchFacets:t,isFacetsLoading:m,setSearchFacetQuery:h}}function v(e){const[a,c]=o(null),{searchFacets:n,setSearchFacetQuery:t}=F({field:e});return f(()=>{const s=n?n.find(r=>r.field===e)??null:null;c(s)},[n,e]),{searchFacet:a,setSearchFacet:c,setSearchFacetQuery:t}}const w=(e,a)=>{const{initialFacets:c}=F({product:a});return{facets:b(()=>!e||!Object.keys(e).length?c.map(t=>({...t,values:t.values.map(s=>typeof s=="string"?s:{...s,isCounterVisible:!1})})):c.map(t=>({...t,values:e[t.field]?.map(s=>({...s,isCounterVisible:!0}))||[]})),[c,e])}};export{v as useFacetQuery,w as useFacets};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as v,useEffect as D,useMemo as L,useState as S,useRef as A}from"react";import{SEARCH_DEBOUNCE_TIME_MS as U}from"@redocly/theme/core/constants";import{getBaseDataAttributes as B,withPathPrefix as H}from"@redocly/theme/core/utils";import{ServerRoutes as T}from"../../../constants/api";import{SEARCH_GROUP_FACET_FIELD as j,SEARCH_PRODUCT_FIELD as J,SEARCH_VERSION_FIELD as K}from"../../../constants/common";import{debounce as $}from"../../../utils/time/debounce.js";import{useSearchSession as z}from"@redocly/theme/core/contexts";import{useGlobalData as k,useI18nConfig as x}from"../hooks";import{usePageVersions as W}from"../../providers/page-data/hooks";import{useFacets as X}from"./useFacets";import{telemetry as Y}from"../telemetry/index.js";const Z=(
|
|
1
|
+
import{useCallback as v,useEffect as D,useMemo as L,useState as S,useRef as A}from"react";import{SEARCH_DEBOUNCE_TIME_MS as U}from"@redocly/theme/core/constants";import{getBaseDataAttributes as B,withPathPrefix as H}from"@redocly/theme/core/utils";import{ServerRoutes as T}from"../../../constants/api";import{SEARCH_GROUP_FACET_FIELD as j,SEARCH_PRODUCT_FIELD as J,SEARCH_VERSION_FIELD as K}from"../../../constants/common";import{debounce as $}from"../../../utils/time/debounce.js";import{useSearchSession as z}from"@redocly/theme/core/contexts";import{useGlobalData as k,useI18nConfig as x}from"../hooks";import{usePageVersions as W}from"../../providers/page-data/hooks";import{useFacets as X}from"./useFacets";import{telemetry as Y}from"../telemetry/index.js";const Z=(r,u,s,l,R,n,F,i,o,d)=>{const{searchSessionId:g}=z(),{currentLocale:E}=x(),f=A(""),p=A(null),h=A(async(e,a)=>{try{F(null);const t=await fetch(H(T.SEARCH),a);if(!t.ok)throw new Error(t.statusText||`Search failed (${t.status})`);if(C(e)){const c=await t.json();l(c.facets),s(c.documents),R(c.groupCounts??{}),p.current=null,e.trim().length>1&&Y.sendSearchQueryMessage([{...B("searchQuery","search"),query:e,resultCount:Object.values(c.documents).flat().length.toString(),searchSessionId:g,...o&&{product:o}}]),n(!1)}}catch(t){if(!C(e))return;p.current={query:e,requestParams:a},s({}),n(!1),F(t instanceof Error?t.message:"An unknown error occurred")}}),C=e=>f.current===e,m=L(()=>$(async(e,a,t,c)=>{if(!e.trim().length&&!a.length){s({}),l({}),R({}),n(!1),F(null),p.current=null;return}const y={method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({query:e,filter:G(a,c,i),locale:t})};await h.current(e,y)},U),[i?.version,i?.folderId,o]);return D(()=>{d||(n(!0),m(r,u,E,o),f.current=r)},[d,u,E,o,r,m,n]),{retrySearch:v(async()=>{const e=p.current;e&&(n(!0),f.current=e.query,await h.current(e.query,e.requestParams))},[n])}},V=(r,u,s,l,R,n,F,i,o,d)=>{const{currentLocale:g}=x();D(()=>{E(s,r,u,g,l,R,o,d)},[l,o,d?.version,d?.folderId]);const E=v(async(f,p,h,C,m,b,e,a)=>{if(m){const{groupKey:t}=m;i(!0);const y={method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({query:p,filter:(()=>{const I=b.find(O=>O.field===j);let _=h;return I&&(h.find(q=>q.field===I.field)||(_=[...h,{field:I.field,values:[t]}])),G(_,e,a)})(),loadMore:m,locale:C})},w=await(await fetch(H(T.SEARCH),y)).json(),M=f[t]||[],N=w.documents[t]??[],Q={...f,[t]:[...M,...N]};n(Q),w.groupCounts&&F(I=>({...I,...w.groupCounts})),i(!1)}},[]);return{}};function fe(){const{searchFeatures:r}=k();return{askAi:r?.ai?.enabled}}function me(r,u){const{searchFeatures:s}=k(),[l,R]=S(""),[n,F]=S([]),[i,o]=S({}),[d,g]=S({}),[E,f]=S({}),[p,h]=S(),[C,m]=S(!1),[b,e]=S(null),{facets:a}=X(d,r),{versions:t=[]}=W()||{},c=t.find(P=>P?.active),{retrySearch:y}=Z(l,n,o,g,f,m,e,c,r,u);return V(l,n,i,p,a,o,f,m,r,c),{query:l,setQuery:R,filter:n,setFilter:F,items:i,isSearchLoading:C,searchError:b,facets:a,groupCounts:E,groupField:j,setLoadMore:h,retrySearch:y,advancedSearch:s?.advanced?.enabled,askAi:s?.ai?.enabled}}function G(r,u,s){return[...r,...u?[{field:J,values:[u]}]:[],...s?[{field:K,values:[...s.default?["default"]:[s.folderId,s.version]]}]:[]]}export{me as useSearch,fe as useSearchFeatures};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import C from"node:path";import{REDOCLY_TEAMS_RBAC as T}from"@redocly/config";import{nodeTypes as y,contentType as b,isGraphqlFieldsNode as pn,resolveGraphqlItemFields as un}from"@redocly/api-docs";import{normalizeApiVersion as dn}from"../utils/normalize-api-version.js";import{replaceFileExtension as N}from"../utils/replace-file-extension.js";import{isResourcePubliclyAccessible as mn,canDownloadApiDefinition as hn,extractTeamsFromScopeItems as yn}from"../../../utils/rbac.js";import{getLlmsTxtMdPathBySlug as K}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{PUBLIC_API_DEFINITIONS_FOLDER as X}from"../../../constants/common.js";import{GRAPHQL_SPEC_SLUG as $n}from"../../../../constants/common.js";import{isPlainObject as $}from"../../../../utils/guards/is-plain-object.js";import{ANONYMOUS_AUTH_DETAILS as gn}from"../../../constants/rbac.js";import{toMarkdown as j}from"../../markdown/search/to-markdown.js";import{createRenderTagFn as bn}from"../../markdown/search/create-render-tag-fn.js";import{getLocaleFromRelativePath as In}from"../../../fs/utils/get-locale-from-relative-path.js";import{getBuildTranslateContext as An}from"../../../utils/l10n/get-build-translate-context.js";import{llmsTxtLink as w}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as
|
|
2
|
-
`+sn,ln=W+B;x.push({title:
|
|
1
|
+
import C from"node:path";import{REDOCLY_TEAMS_RBAC as T}from"@redocly/config";import{nodeTypes as y,contentType as b,isGraphqlFieldsNode as pn,resolveGraphqlItemFields as un}from"@redocly/api-docs";import{normalizeApiVersion as dn}from"../utils/normalize-api-version.js";import{replaceFileExtension as N}from"../utils/replace-file-extension.js";import{isResourcePubliclyAccessible as mn,canDownloadApiDefinition as hn,extractTeamsFromScopeItems as yn}from"../../../utils/rbac.js";import{getLlmsTxtMdPathBySlug as K}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{PUBLIC_API_DEFINITIONS_FOLDER as X}from"../../../constants/common.js";import{GRAPHQL_SPEC_SLUG as $n}from"../../../../constants/common.js";import{isPlainObject as $}from"../../../../utils/guards/is-plain-object.js";import{ANONYMOUS_AUTH_DETAILS as gn}from"../../../constants/rbac.js";import{toMarkdown as j}from"../../markdown/search/to-markdown.js";import{createRenderTagFn as bn}from"../../markdown/search/create-render-tag-fn.js";import{getLocaleFromRelativePath as In}from"../../../fs/utils/get-locale-from-relative-path.js";import{getBuildTranslateContext as An}from"../../../utils/l10n/get-build-translate-context.js";import{getPublicEnvVariables as Pn}from"../../../utils/envs/get-public-env-variables.js";import{llmsTxtLink as w}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as On}from"../../search/utils.js";import{extractDocumentSearchFacets as Sn}from"./search-facets.js";import{createApiDocsSearchIndexer as xn,createLlmDescriptionFormatter as Cn}from"./create-indexer.js";function P(e,s){return s==="openapi"&&"openapi"in e}function Z(e,s){return s==="asyncapi"&&"asyncapi"in e}function rt({getBuild:e,metadata:s,document:c,specType:o,excludeFromSearch:n,basePath:r,getSearchFacets:t,markdocTags:i}){return async(l,f,d,p)=>{if(n)return;const{items:a,store:m}=e(),h={...p.markdocOptions?.tags,...i},{locale:en,translate:on}=await An(l.slug,p.getGlobalData?.().l10n),O=bn(h,en,on,{env:Pn()}),L=p.getConfig(),D=In(l.fsPath),E=Cn(O),V=xn(r,E,m?.schemaStore,c,m?.exampleStore,m?.graphqlMeta),F=I=>{for(const u of I)V.addItem(u),u.items?.length&&F(u.items)};F(a);const rn=V.getResult(),_=new Map;for(const I of rn)_.set(I.url,I);const R=typeof s.title=="string"?s.title:void 0,q=dn(s.version),k=Sn(l.metadata||{},R,q,t),S=[],x=[],G=Tn(c,s),z=G?E(G):void 0,W=vn(s,z,c,o,E),B=Ln(o,s,l.fsPath,L),sn=Rn(a,L,O),cn=W+B+`
|
|
2
|
+
`+sn,ln=W+B;x.push({title:R||"API Overview",description:z,content:cn,slug:r,fsPath:l.fsPath,includeInLLMsTxt:!0}),S.push({title:R||"API Overview",content:ln,url:r,fsPath:l.fsPath,locale:D,product:l.product?.name,facets:k});const fn=c&&P(c,o)?c.security:void 0,U=I=>{for(const u of I){if(!u.content||!u.link){u.items?.length&&U(u.items);continue}const an=_.get(u.link),J=u.content.contentType,Q=u[T],H=Q?yn(Q):void 0,Y=H?.length?H:void 0;if(J===b.ITEM){const g=kn(u,c,o)??nn(u,an,o,q,fn,O,m);if(g){const A=u.label||"";x.push({title:A,description:void 0,content:g,slug:u.link,fsPath:l.fsPath,includeInLLMsTxt:!1}),S.push({title:A,content:g,url:u.link,fsPath:l.fsPath,locale:D,product:l.product?.name,facets:k,rbacTeams:Y})}}else if(J===b.GROUP){const g=Un(u,L,o,O,m);if(g){const A=u.label||"";x.push({title:A,description:void 0,content:g.llmstxt,slug:u.link,fsPath:l.fsPath,includeInLLMsTxt:!1}),S.push({title:A,content:g.aiSearch,url:u.link,fsPath:l.fsPath,locale:D,product:l.product?.name,facets:k,rbacTeams:Y})}}u.items?.length&&U(u.items)}};return U(a),{async getLLMsTxts(){return x},async getSearchDocuments(){return S}}}}function Tn(e,s){const c=$(e?.info)?e.info:void 0,o=$(c?.["x-metadata"])?c["x-metadata"]:{},r=(typeof o.description=="string"?o.description:void 0)??c?.description??s.description;return typeof r=="string"?r||void 0:r&&typeof r=="object"?r:void 0}function vn(e,s,c,o,n){const r=typeof e.title=="string"?e.title:"",t=typeof e.summary=="string"?e.summary:"",i=typeof e.version=="string"?e.version:"";let l=r?`# ${r}
|
|
3
3
|
|
|
4
4
|
`:"";if(l+=s?`${s}
|
|
5
5
|
|
|
@@ -7,14 +7,14 @@ import C from"node:path";import{REDOCLY_TEAMS_RBAC as T}from"@redocly/config";im
|
|
|
7
7
|
|
|
8
8
|
`:"",l+=i?`Version: ${i}
|
|
9
9
|
`:"",c){if(P(c,o)){const{info:f}=c;f?.license?.name&&(l+=`License: ${f.license.name}
|
|
10
|
-
`);const d=f["x-metadata"],p=Object.entries($(d)?d:{}).filter(([m,h])=>m!=="description"||typeof h!="string"),a=
|
|
10
|
+
`);const d=f["x-metadata"],p=Object.entries($(d)?d:{}).filter(([m,h])=>m!=="description"||typeof h!="string"),a=On(Object.fromEntries(p));a&&(l+=`
|
|
11
11
|
Metadata:
|
|
12
12
|
${a}
|
|
13
13
|
`)}else if(Z(c,o)){const{info:f}=c;f?.license?.name&&(l+=`License: ${f.license.name}
|
|
14
14
|
`)}}return l+=`
|
|
15
|
-
`,l+=
|
|
15
|
+
`,l+=Dn(c,o,n),l+=En(c,o,n),l}function Ln(e,s,c,o){if(!c)return"";let n,r,t;if(e==="openapi")n=C.posix.join(X,N(c,".yaml")),r="## Download OpenAPI description",t="OpenAPI definition";else if(e==="asyncapi")n=C.posix.join(X,N(c,".yaml")),r="## Download AsyncAPI description",t="AsyncAPI definition";else if(e==="graphql"){const f=C.posix.extname(c)||".graphql";n=C.posix.join($n,N(c,f)),r="## Download GraphQL schema",t="GraphQL schema"}else return"";if(!hn(n,o.access?.rbac??{},o.access?.requiresLogin??!1,gn))return"";const l=typeof s.title=="string"&&s.title||t;return`${r}
|
|
16
16
|
|
|
17
|
-
- ${w({title:l,description:void 0,slug:n,siteUrl:o.seo?.siteUrl})}`}function
|
|
17
|
+
- ${w({title:l,description:void 0,slug:n,siteUrl:o.seo?.siteUrl})}`}function Dn(e,s,c){if(!e)return"";if(P(e,s)){const o=Array.isArray(e.servers)?e.servers.filter($):[];if(!o.length)return"";let n=`## Servers
|
|
18
18
|
|
|
19
19
|
`;for(const r of o){r.description&&(n+=`${c(r.description)}
|
|
20
20
|
`),n+=`\`\`\`
|
|
@@ -36,7 +36,7 @@ ${r.url}
|
|
|
36
36
|
`),t.protocolVersion&&(n+=`Protocol Version: ${t.protocolVersion}
|
|
37
37
|
`),t.pathname&&(n+=`Pathname: ${t.pathname}
|
|
38
38
|
`),n+=`
|
|
39
|
-
`;return n}return""}function
|
|
39
|
+
`;return n}return""}function En(e,s,c){if(!e||!P(e,s))return"";const o=e.components?.securitySchemes;if(!o)return"";let n=`## Security
|
|
40
40
|
|
|
41
41
|
`;for(const[r,t]of Object.entries(o)){if(!t||"$ref"in t)continue;const i=t;n+=`### ${r}
|
|
42
42
|
|
|
@@ -55,17 +55,17 @@ ${r.url}
|
|
|
55
55
|
`}n+=`
|
|
56
56
|
`}return n}function Rn(e,s,c){let o="";const n=(r,t)=>{for(const i of r)if(i.link){if(i.content?.contentType===b.GROUP)o+=`${t} ${i.label||""}
|
|
57
57
|
|
|
58
|
-
`,i.items?.length&&n(i.items,t+"#");else if(i.content?.contentType===b.ITEM){if(!M(i,s))continue;const l=i,f=l.httpVerb,d=l.httpPath,p=f&&d?`${f.toUpperCase()} ${d}`:i.label||"",a=i.content?
|
|
58
|
+
`,i.items?.length&&n(i.items,t+"#");else if(i.content?.contentType===b.ITEM){if(!M(i,s))continue;const l=i,f=l.httpVerb,d=l.httpPath,p=f&&d?`${f.toUpperCase()} ${d}`:i.label||"",a=i.content?v(i.content.children,c):void 0;o+=` - ${w({title:p,description:a?a.slice(0,200):void 0,slug:K(i.link),siteUrl:s.seo?.siteUrl})}`}}};return n(e,"##"),o}function nn(e,s,c,o,n,r,t){if(!e.content)return;const i=e,l=e.label||"",f=v(e.content.children,r),d=e.content.meta?.deprecated;let p=`# ${l}${d?" (deprecated)":""}
|
|
59
59
|
|
|
60
60
|
`;if(f&&(p+=`${f}
|
|
61
61
|
|
|
62
62
|
`),c==="openapi"||c==="asyncapi"){const a=i.httpVerb,m=i.httpPath;a&&m?p+=`Endpoint: ${a.toUpperCase()} ${m}
|
|
63
63
|
`:a&&(p+=`Method: ${a.toUpperCase()}
|
|
64
64
|
`),o&&(p+=`Version: ${o}
|
|
65
|
-
`);const h=
|
|
65
|
+
`);const h=Nn(e.content.children,n);h&&(p+=`Security: ${h}
|
|
66
66
|
`)}return s?.parameters?.length&&c!=="graphql"&&(p+=`
|
|
67
|
-
`+
|
|
68
|
-
`),c==="graphql"&&(p+=
|
|
67
|
+
`+jn(s.parameters)+`
|
|
68
|
+
`),c==="graphql"&&(p+=wn(e.content.children,t,r)),p}function kn(e,s,c){if(e.httpVerb!=="tool"||!s||!P(s,c))return;const o=e.content?.meta?.name,n=o?s["x-mcp"]?.tools?.find(t=>t.name===o):void 0;if(!n)return;let r=`# ${e.label||n.name}
|
|
69
69
|
|
|
70
70
|
`;return typeof n.description=="string"&&n.description&&(r+=`${n.description}
|
|
71
71
|
|
|
@@ -81,7 +81,7 @@ ${JSON.stringify(n.inputSchema,null,2)}
|
|
|
81
81
|
${JSON.stringify(n.outputSchema,null,2)}
|
|
82
82
|
\`\`\`
|
|
83
83
|
|
|
84
|
-
`),r}function
|
|
84
|
+
`),r}function Un(e,s,c,o,n){if(!e.content)return;const r=e.label||"",t=v(e.content.children,o);let i=`# ${r}
|
|
85
85
|
|
|
86
86
|
`;if(t&&(i+=`${t}
|
|
87
87
|
|
|
@@ -89,7 +89,7 @@ ${JSON.stringify(n.outputSchema,null,2)}
|
|
|
89
89
|
|
|
90
90
|
---
|
|
91
91
|
|
|
92
|
-
`)}else a.content.contentType===b.GROUP&&d(a.items)};return d(e.items),{llmstxt:i+f,aiSearch:i}}let l="";if(e.items?.length)for(const f of e.items){if(!f.link||!f.content||f.content.contentType!==b.ITEM||!M(f,s))continue;const d=f,p=d.httpVerb,a=d.httpPath,m=p&&a?`${p.toUpperCase()} ${a}`:f.label||"",h=f.content?
|
|
92
|
+
`)}else a.content.contentType===b.GROUP&&d(a.items)};return d(e.items),{llmstxt:i+f,aiSearch:i}}let l="";if(e.items?.length)for(const f of e.items){if(!f.link||!f.content||f.content.contentType!==b.ITEM||!M(f,s))continue;const d=f,p=d.httpVerb,a=d.httpPath,m=p&&a?`${p.toUpperCase()} ${a}`:f.label||"",h=f.content?v(f.content.children,o):void 0;l+=` - ${w({title:m,description:h?h.slice(0,200):void 0,slug:K(f.link),siteUrl:s.seo?.siteUrl})}`}return{llmstxt:i+l,aiSearch:i}}function Nn(e,s){const c=[],o=n=>{for(const r of n)if(r.nodeType===y.SECURITY){const t=r;for(const i of t.requirements)for(const l of i.schemes)l[T]||l.name&&!c.includes(l.name)&&c.push(l.name)}else(r.nodeType===y.CONTAINER||r.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&o(r.children)};if(o(e),c.length)return c.join(", ");if(s?.length){const n=s.flatMap(r=>Object.keys(r));if(n.length)return[...new Set(n)].join(", ")}}function jn(e){const s={};for(const o of e){const n=`${o.place}${o.mediaType?` (${o.mediaType})`:""}`;s[n]||(s[n]=[]),s[n].push(o)}return Object.entries(s).map(([o,n])=>{const r=n.map(t=>{const i=[...t.path||[],t.name],l=Array.isArray(t.description)?t.description.join(" "):t.description;let f=` - \`${i.join(".")}\` (${t.type}${t.required?", required":""})
|
|
93
93
|
`;return l&&(f+=` ${l.trim()}
|
|
94
94
|
`),t.enum?f+=` Enum: ${t.enum.map(d=>JSON.stringify(d)).join(", ")}
|
|
95
95
|
`:t.example&&(f+=` Example: ${t.example}
|
|
@@ -97,9 +97,9 @@ ${JSON.stringify(n.outputSchema,null,2)}
|
|
|
97
97
|
|
|
98
98
|
${r.join(`
|
|
99
99
|
`)}`}).join(`
|
|
100
|
-
`)}function
|
|
100
|
+
`)}function wn(e,s,c){let o="";const n=r=>{for(const t of r)if(t.nodeType===y.ITEM){const i=pn(t)?un(t,s??{}):void 0;i&&(o+=Mn(i,t.variant,c))}else(t.nodeType===y.CONTAINER||t.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&n(t.children)};return n(e),o}function Mn(e,s,c){let n=`
|
|
101
101
|
## ${tn(s==="return-type"?"Return type":s==="graphql-args"||s==="arguments"?"Arguments":s==="graphql-fields"?"Fields":s)}:
|
|
102
102
|
|
|
103
103
|
`;const r=t=>{const i=t.description?j(Array.isArray(t.description)?t.description:[t.description],{renderTag:c}).trim():"";return` - \`${t.name}\` (${t.type.display})${i?`: ${i}`:""}
|
|
104
104
|
`};if(e.type){const t=e.type.description?j(Array.isArray(e.type.description)?e.type.description:[e.type.description],{renderTag:c}).trim():"";n+=` Type: ${e.type.display}`,t&&(n+=` - ${t}`),n+=`
|
|
105
|
-
`}else if(!e.fields.length)return"";for(const t of e.fields)n+=r(t);return n}function
|
|
105
|
+
`}else if(!e.fields.length)return"";for(const t of e.fields)n+=r(t);return n}function v(e,s){const c=[],o=r=>{for(const t of r)if(t.nodeType===y.MARKDOC){const i=t.content,l=Array.isArray(i)?i:[i],f=j(l,{renderTag:s}).trim();f&&c.push(f)}else(t.nodeType===y.CONTAINER||t.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&o(t.children)};return o(e),c.join(" ").trim()||void 0}function tn(e){return e.charAt(0).toUpperCase()+e.slice(1)}function M(e,s){return s.access?.requiresLogin?!0:mn({slug:e.link||"",[T]:e[T]},s)}export{rt as getAiDocumentsStore};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MarkdocTagSchema } from '@redocly/theme/markdoc/tags/types';
|
|
2
2
|
import type { TFunction } from '@redocly/theme/core/types';
|
|
3
3
|
import type { RenderTagFn } from '../../../types/plugins/markdown';
|
|
4
|
-
export declare function createRenderTagFn(markdocTags: Record<string, MarkdocTagSchema> | undefined, locale: string, translate: TFunction): RenderTagFn;
|
|
4
|
+
export declare function createRenderTagFn(markdocTags: Record<string, MarkdocTagSchema> | undefined, locale: string, translate: TFunction, variables?: Record<string, unknown>): RenderTagFn;
|
|
5
5
|
//# sourceMappingURL=create-render-tag-fn.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import o from"@redocly/markdoc";function y(t,n,s,i={}){return(r,e)=>{if(!r.tag)return;const f=t?.[r.tag]?.renderForLlms;if(!f)return;const b=Object.assign(Object.create(Object.getPrototypeOf(r)),r,{attributes:c(r.attributes,i)});return f(b,{...e,locale:n,translate:s})}}function c(t,n){if(o.Ast.isVariable(t))return Object.hasOwn(n,String(t.path[0]))?new o.Ast.Variable(t.path).resolve({variables:n}):t;if(Array.isArray(t)){let i;for(let r=0;r<t.length;r++){const e=c(t[r],n);e!==t[r]&&((i??=t.slice())[r]=e)}return i??t}if(typeof t!="object"||t===null||o.Ast.isAst(t))return t;let s;for(const[i,r]of Object.entries(t)){const e=c(r,n);e!==r&&((s??={...t})[i]=e)}return s??t}export{y as createRenderTagFn};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import v from"@redocly/markdoc";import M from"node:path";import{AI_SEARCH_CHUNK_SIZE as R,AI_SEARCH_DOCUMENT_CHUNK_SIZE as D}from"../../../constants/plugins/search.js";import{slugger as I}from"../../../../utils/slugger.js";import{joinSectionContent as N}from"./join-section-content.js";import{toMarkdown as P}from"./to-markdown.js";import{AstToSearchNodeTransformer as b}from"./walk-sections.js";import{createRenderTagFn as w}from"./create-render-tag-fn.js";import{getPublicEnvVariables as x}from"../../../utils/envs/get-public-env-variables.js";import{getBuildTranslateContext as K}from"../../../utils/l10n/get-build-translate-context.js";import{getLocaleFromRelativePath as L}from"../../../fs/utils/get-locale-from-relative-path.js";import{HeadingNode as U}from"./nodes/heading-node.js";import{extractDocumentSearchFacets as y}from"./search-facets.js";import{formatDocumentMetadata as H}from"../../search/utils.js";import{TagNode as O}from"./nodes/tag-node.js";import{MARKDOC_PARTIALS_DATA_KEY as j}from"../../../constants/common.js";const F=Symbol(),mt=(n,r)=>async(e,o,i,c)=>{if(r?.excludeFromSearch)return;I.reset();const l=await e.getNavText?.()||M.basename(e.fsPath),f=v.Ast.fromJSON(o.ast),{locale:g,translate:A}=await K(e.slug,c.getGlobalData?.().l10n),s=new b({partials:c.getGlobalConfig(j)||{},renderTag:w(c.markdocOptions.tags,g,A,{frontmatter:o.frontmatter,env:x()}),getInnerContent:P,ast:f,skipConditionals:!0}),d=Array.from(s.transform());return{async getLLMsTxts(){const u=r?.seo,t=u&&typeof u=="object"&&"description"in u?String(u.description):void 0,a=N(d);return[{title:l,description:t,slug:e.slug,fsPath:e.fsPath,content:a,includeInLLMsTxt:!0}]},async getSearchDocuments(){return $(e,d,n,l)}}};function $(n,r,e,o){const i=n.slug,c=new Map,l=n.metadata||{},f=y(l,e),g=H(l),A=g?`Metadata:
|
|
2
2
|
${g}
|
|
3
|
-
`:"",s=[];for(const t of
|
|
4
|
-
`)};(t.attributes.level>1||h(t)!==
|
|
5
|
-
`:"",p.content+=t.content.trimEnd()),c.set(t.id,p),s.push({section:t,title:C,url:S})}else if(t instanceof
|
|
6
|
-
`)});else{const a=t.parentNode?.id??
|
|
7
|
-
`:"",m.content+=t.content.trimEnd(),c.set(a,m)}const d
|
|
8
|
-
`),fsPath:n.fsPath,locale:u,product:n.product?.name,facets:f}))}function _(n){return n.length/4}function
|
|
9
|
-
`+i.content:(
|
|
3
|
+
`:"",s=[];for(const t of r)if(t instanceof U){s.splice(t.attributes.level-1,6);const a=t.attributes.level>2,m=s[s.length-1]?.title,T=s[s.length-1]?.url,C=a&&m?m:B(o,t),S=a&&T?T:t.getUrl(i),p={title:C,content:"",url:S,level:t.attributes.level,toc:s.map(k=>h(k.section)).join(`
|
|
4
|
+
`)};(t.attributes.level>1||h(t)!==o)&&(p.content+=p.content?`
|
|
5
|
+
`:"",p.content+=t.content.trimEnd()),c.set(t.id,p),s.push({section:t,title:C,url:S})}else if(t instanceof O)c.set(t.id,{title:t.content,content:t.content,url:t.getUrl(i),level:t.attributes.level+1,toc:s.map(a=>h(a.section)).concat(t.content).join(`
|
|
6
|
+
`)});else{const a=t.parentNode?.id??F,m=c.get(a)??{title:o,content:"",url:i,level:1/0,toc:""};m.content+=m.content?`
|
|
7
|
+
`:"",m.content+=t.content.trimEnd(),c.set(a,m)}const d=G(Array.from(c.values())),u=L(n.fsPath);return d.filter(t=>t.content).map(t=>({title:t.title,url:t.url,content:[A,t.toc||`# ${o}`,t.content].filter(Boolean).join(`
|
|
8
|
+
`),fsPath:n.fsPath,locale:u,product:n.product?.name,facets:f}))}function _(n){return n.length/4}function G(n){if(n.length===0)return[];const r=[];let e=n[0];for(let o=1;o<n.length;o++){const i=n[o],c=_(e.content),l=_(i.content),f=o===n.length-1;l<R&&(c<D||f)&&i.level>e.level?e.content+=`
|
|
9
|
+
`+i.content:(r.push(e),e=i)}return r.push(e),r}const E=String.raw`\((?:[^()]|\([^()]*\))*\)`,z=new RegExp(String.raw`!\[[^\]]*\]`+E,"g"),W=new RegExp(String.raw`\[(?<!\[[^\]()]*?\[)([^\]]*)\]`+E,"g");function B(n,r){const e=h(r);return r.content===n||!e?n:`${n} \u2192 ${e}`}function h(n){return Y(n.content.replace(/^#+/,""))}function Y(n){return n.replace(z,"").replace(W,"$1").trim()}export{mt as getAiDocumentsStore};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/reef",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.141.0-next.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@opentelemetry/sdk-trace-web": "2.8.0",
|
|
34
34
|
"@opentelemetry/semantic-conventions": "1.40.0",
|
|
35
35
|
"@redocly/ajv": "8.18.0",
|
|
36
|
-
"@redocly/api-docs": "0.
|
|
36
|
+
"@redocly/api-docs": "0.6.0-next.0",
|
|
37
37
|
"@redocly/config": "0.72.0",
|
|
38
38
|
"@redocly/markdoc": "0.7.0-beta.2",
|
|
39
39
|
"@redocly/openapi-core": "2.73.0",
|