@redocly/redoc-reef 0.139.0-next.7 → 0.139.0-next.8
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 +27 -0
- package/dist/constants/l10n/langs/ar.js +1 -1
- package/dist/constants/l10n/langs/de.js +1 -1
- package/dist/constants/l10n/langs/en.js +1 -1
- package/dist/constants/l10n/langs/es.js +1 -1
- package/dist/constants/l10n/langs/fr.js +1 -1
- package/dist/constants/l10n/langs/hi.js +1 -1
- package/dist/constants/l10n/langs/it.js +1 -1
- package/dist/constants/l10n/langs/ja.js +1 -1
- package/dist/constants/l10n/langs/ko.js +1 -1
- package/dist/constants/l10n/langs/pl.js +1 -1
- package/dist/constants/l10n/langs/pt-BR.js +1 -1
- package/dist/constants/l10n/langs/pt.js +1 -1
- package/dist/constants/l10n/langs/ru.js +1 -1
- package/dist/constants/l10n/langs/uk.js +1 -1
- package/dist/constants/l10n/langs/zh.js +1 -1
- package/dist/markdoc/helpers/get-inner-text.d.ts +2 -0
- package/dist/markdoc/helpers/get-inner-text.js +2 -2
- package/dist/markdoc/helpers/remove-markdoc-tags.js +1 -1
- package/dist/server/plugins/api-docs/search/get-ai-search-documents.js +67 -67
- package/dist/server/plugins/arazzo-docs/arazzo-doc-loader.js +2 -2
- package/dist/server/plugins/arazzo-docs/index.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/openapi-entities-extractor.js +1 -1
- package/dist/server/plugins/markdown/index.js +1 -1
- package/dist/server/plugins/markdown/markdoc/plugins/utils.js +1 -1
- package/dist/server/plugins/markdown/search/search-resolver.js +1 -1
- package/dist/server/plugins/pages/index.js +1 -1
- package/dist/server/plugins/register-page-props.d.ts +1 -1
- package/dist/server/plugins/register-page-props.js +1 -1
- package/dist/server/plugins/sidebars/index.js +1 -1
- package/dist/server/plugins/sidebars/utils.js +1 -1
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isPrimitive as n}from"../../utils/guards/is-primitive.js";import{getNodeAttribute as o}from"./get-node-attribute.js";import{getVariable as
|
|
2
|
-
`),
|
|
1
|
+
import{isPrimitive as n}from"../../utils/guards/is-primitive.js";import{getNodeAttribute as o}from"./get-node-attribute.js";import{getVariable as l}from"./get-variable.js";import{isNode as p}from"./guards/is-node.js";import{isTag as a}from"./guards/is-tag.js";import{isCodeNode as d}from"./guards/is-code-node.js";import{isConditionalNode as c}from"./guards/is-conditional-node.js";import{isExampleNode as u}from"./guards/is-example-node.js";import{isFenceNode as h}from"./guards/is-fence-node.js";import{isTextNode as g}from"./guards/is-text-node.js";import{isFunction as N}from"./guards/is-function.js";import{isVariable as T}from"./guards/is-variable.js";import{isPromptNode as b}from"./guards/is-prompt-node.js";function t(f,r={}){const{isTrim:s=!0}=r,i=[];for(const e of f){if(n(e))i.push(String(e));else if(p(e)){if(b(e))continue;if(e.type==="tr"&&i.push(`
|
|
2
|
+
`),g(e)||d(e)||h(e))i.push(t([o(e,"content")],r));else if(u(e))i.push(t(e.children.map(m=>o(m,"content")),r));else{if(c(e)&&r.skipConditionals)continue;if(e.type==="tag"&&r.renderTag){const m=()=>t(e.children,r);i.push(r.renderTag(e,{getBody:m})??m())}else i.push(t(e.children,r))}}else a(e)?i.push(t(e.children,r)):N(e)&&i.push(t(Object.values(e.parameters),r));T(e)&&i.push(t([l(e,r.variables)],r))}return s?i.map(e=>e.trim()).join(" ").trim():i.join(" ")}export{t as getInnerText};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import n from"@markdoc/markdoc";import{skipAgentsOnlyContent as e}from"@redocly/theme/markdoc/tags/visibility";import{getInnerText as t}from"./get-inner-text.js";function a(r){if(!r)return r;const o=n.parse(r);return t([o],{renderTag:e})}export{a as removeMarkdocTags};
|
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
import
|
|
2
|
-
`+en,sn=G+z;O.push({title:E||"API Overview",description:q,content:on,slug:
|
|
1
|
+
import C from"node:path";import{REDOCLY_TEAMS_RBAC as x}from"@redocly/config";import{nodeTypes as m,contentType as g,isGraphqlFieldsNode as ln,resolveGraphqlItemFields as fn}from"@redocly/api-docs";import{normalizeApiVersion as an}from"../utils/normalize-api-version.js";import{replaceFileExtension as v}from"../utils/replace-file-extension.js";import{isResourcePubliclyAccessible as pn,canDownloadApiDefinition as un,extractTeamsFromScopeItems as dn}from"../../../utils/rbac.js";import{getLlmsTxtMdPathBySlug as H}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{PUBLIC_API_DEFINITIONS_FOLDER as Y}from"../../../constants/common.js";import{GRAPHQL_SPEC_SLUG as hn}from"../../../../constants/common.js";import{ANONYMOUS_AUTH_DETAILS as mn}from"../../../constants/rbac.js";import{toMarkdown as N}from"../../markdown/search/to-markdown.js";import{createRenderTagFn as $n}from"../../markdown/search/create-render-tag-fn.js";import{getLocaleFromRelativePath as yn}from"../../../fs/utils/get-locale-from-relative-path.js";import{getBuildTranslateContext as gn}from"../../../utils/l10n/get-build-translate-context.js";import{llmsTxtLink as w}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as bn}from"../../search/utils.js";import{extractDocumentSearchFacets as In}from"./search-facets.js";import{createApiDocsSearchIndexer as Pn,createLlmDescriptionFormatter as Sn}from"./create-indexer.js";function P(e,s){return s==="openapi"&&"openapi"in e}function K(e,s){return s==="asyncapi"&&"asyncapi"in e}function Xn({items:e,metadata:s,store:c,document:r,specType:n,excludeFromSearch:l,basePath:t,getSearchFacets:i,markdocTags:f}){return async(o,d,p,u)=>{if(l)return;const h={...u.markdocOptions?.tags,...f},{locale:$,translate:nn}=await gn(o.slug,u.getGlobalData?.().l10n),S=$n(h,$,nn),L=u.getConfig(),R=yn(o.fsPath),D=Sn(S),j=Pn(t,D,c?.schemaStore,r,c?.exampleStore,c?.graphqlMeta),V=b=>{for(const a of b)j.addItem(a),a.items?.length&&V(a.items)};V(e);const tn=j.getResult(),F=new Map;for(const b of tn)F.set(b.url,b);const E=typeof s.title=="string"?s.title:void 0,_=an(s.version),k=In(o.metadata||{},E,_,i),A=[],O=[],q=typeof s.description=="string"&&s.description?D(s.description):void 0,G=An(s,q,r,n,D),z=On(n,s,o.fsPath,L),en=Tn(e,L,S),on=G+z+`
|
|
2
|
+
`+en,sn=G+z;O.push({title:E||"API Overview",description:q,content:on,slug:t,fsPath:o.fsPath,includeInLLMsTxt:!0}),A.push({title:E||"API Overview",content:sn,url:t,fsPath:o.fsPath,locale:R,product:o.product?.name,facets:k});const rn=r&&P(r,n)?r.security:void 0,U=b=>{for(const a of b){if(!a.content||!a.link){a.items?.length&&U(a.items);continue}const cn=F.get(a.link),W=a.content.contentType,B=a[x],J=B?dn(B):void 0,Q=J?.length?J:void 0;if(W===g.ITEM){const y=Ln(a,r,n)??X(a,cn,n,_,rn,S,c);if(y){const I=a.label||"";O.push({title:I,description:void 0,content:y,slug:a.link,fsPath:o.fsPath,includeInLLMsTxt:!1}),A.push({title:I,content:y,url:a.link,fsPath:o.fsPath,locale:R,product:o.product?.name,facets:k,rbacTeams:Q})}}else if(W===g.GROUP){const y=Rn(a,L,n,S,c);if(y){const I=a.label||"";O.push({title:I,description:void 0,content:y.llmstxt,slug:a.link,fsPath:o.fsPath,includeInLLMsTxt:!1}),A.push({title:I,content:y.aiSearch,url:a.link,fsPath:o.fsPath,locale:R,product:o.product?.name,facets:k,rbacTeams:Q})}}a.items?.length&&U(a.items)}};return U(e),{async getLLMsTxts(){return O},async getSearchDocuments(){return A}}}}function An(e,s,c,r,n){const l=typeof e.title=="string"?e.title:"",t=typeof e.summary=="string"?e.summary:"",i=typeof e.version=="string"?e.version:"";let f=l?`# ${l}
|
|
3
3
|
|
|
4
|
-
`:"";if(f+=
|
|
4
|
+
`:"";if(f+=s?`${s}
|
|
5
5
|
|
|
6
|
-
`:"",f+=
|
|
6
|
+
`:"",f+=t?`${t}
|
|
7
7
|
|
|
8
|
-
`:"",f+=
|
|
9
|
-
`:"",
|
|
10
|
-
`);const d=
|
|
8
|
+
`:"",f+=i?`Version: ${i}
|
|
9
|
+
`:"",c){if(P(c,r)){const{info:o}=c;o?.license?.name&&(f+=`License: ${o.license.name}
|
|
10
|
+
`);const d=o["x-metadata"],p=bn(d);p&&(f+=`
|
|
11
11
|
Metadata:
|
|
12
12
|
${p}
|
|
13
|
-
`)}else if(K(
|
|
13
|
+
`)}else if(K(c,r)){const{info:o}=c;o?.license?.name&&(f+=`License: ${o.license.name}
|
|
14
14
|
`)}}return f+=`
|
|
15
|
-
`,f+=
|
|
15
|
+
`,f+=Cn(c,r,n),f+=xn(c,r,n),f}function On(e,s,c,r){if(!c)return"";let n,l,t;if(e==="openapi")n=C.posix.join(Y,v(c,".yaml")),l="## Download OpenAPI description",t="OpenAPI definition";else if(e==="asyncapi")n=C.posix.join(Y,v(c,".yaml")),l="## Download AsyncAPI description",t="AsyncAPI definition";else if(e==="graphql"){const o=C.posix.extname(c)||".graphql";n=C.posix.join(hn,v(c,o)),l="## Download GraphQL schema",t="GraphQL schema"}else return"";if(!un(n,r.access?.rbac??{},r.access?.requiresLogin??!1,mn))return"";const f=typeof s.title=="string"&&s.title||t;return`${l}
|
|
16
16
|
|
|
17
|
-
- ${w({title:f,description:void 0,slug:n,siteUrl:
|
|
17
|
+
- ${w({title:f,description:void 0,slug:n,siteUrl:r.seo?.siteUrl})}`}function Cn(e,s,c){if(!e)return"";if(P(e,s)){const{servers:r}=e;if(!r?.length)return"";let n=`## Servers
|
|
18
18
|
|
|
19
|
-
`;for(const
|
|
19
|
+
`;for(const l of r)if(l.description&&(n+=`${c(l.description)}
|
|
20
20
|
`),n+=`\`\`\`
|
|
21
|
-
${
|
|
21
|
+
${l.url}
|
|
22
22
|
\`\`\`
|
|
23
23
|
|
|
24
|
-
`,
|
|
25
|
-
`;for(const[i
|
|
26
|
-
`,
|
|
27
|
-
`),
|
|
24
|
+
`,l.variables){n+=`Variables:
|
|
25
|
+
`;for(const[t,i]of Object.entries(l.variables))n+=`- \`${t}\`${i.description?`: ${c(i.description).replace(/\s+/g," ")}`:""}
|
|
26
|
+
`,i.default&&(n+=` Default: ${JSON.stringify(i.default)}
|
|
27
|
+
`),i.enum&&(n+=` Enum: ${i.enum.map(f=>JSON.stringify(f)).join(", ")}
|
|
28
28
|
`);n+=`
|
|
29
|
-
`}return n}if(K(
|
|
29
|
+
`}return n}if(K(e,s)){const{servers:r}=e;if(!r||!Object.keys(r).length)return"";let n=`## Servers
|
|
30
30
|
|
|
31
|
-
`;for(const[
|
|
31
|
+
`;for(const[l,t]of Object.entries(r))n+=`### ${l}
|
|
32
32
|
|
|
33
|
-
`,
|
|
34
|
-
`),
|
|
35
|
-
`),
|
|
36
|
-
`),
|
|
37
|
-
`),
|
|
33
|
+
`,t.description&&(n+=`${c(t.description)}
|
|
34
|
+
`),t.host&&(n+=`Host: ${t.host}
|
|
35
|
+
`),t.protocol&&(n+=`Protocol: ${t.protocol}
|
|
36
|
+
`),t.protocolVersion&&(n+=`Protocol Version: ${t.protocolVersion}
|
|
37
|
+
`),t.pathname&&(n+=`Pathname: ${t.pathname}
|
|
38
38
|
`),n+=`
|
|
39
|
-
`;return n}return""}function
|
|
40
|
-
|
|
41
|
-
`;for(const[
|
|
42
|
-
|
|
43
|
-
`,
|
|
44
|
-
|
|
45
|
-
`),
|
|
46
|
-
`),
|
|
47
|
-
`),
|
|
48
|
-
`),
|
|
49
|
-
`),
|
|
50
|
-
`),
|
|
51
|
-
`);const f=
|
|
52
|
-
`),"tokenUrl"in
|
|
53
|
-
`),
|
|
54
|
-
`;for(const[d,p]of Object.entries(
|
|
39
|
+
`;return n}return""}function xn(e,s,c){if(!e||!P(e,s))return"";const r=e.components?.securitySchemes;if(!r)return"";let n=`## Security
|
|
40
|
+
|
|
41
|
+
`;for(const[l,t]of Object.entries(r)){if(!t||"$ref"in t)continue;const i=t;n+=`### ${l}
|
|
42
|
+
|
|
43
|
+
`,i.description&&(n+=`${c(i.description)}
|
|
44
|
+
|
|
45
|
+
`),i.type&&(n+=`Type: ${i.type}
|
|
46
|
+
`),i.in&&(n+=`In: ${i.in}
|
|
47
|
+
`),i.name&&(n+=`Name: ${i.name}
|
|
48
|
+
`),i.scheme&&(n+=`Scheme: ${i.scheme}
|
|
49
|
+
`),i.bearerFormat&&(n+=`Bearer Format: ${i.bearerFormat}
|
|
50
|
+
`),i.openIdConnectUrl&&(n+=`OpenID Connect URL: ${i.openIdConnectUrl}
|
|
51
|
+
`);const f=i.flows,o=f?.implicit||f?.password||f?.clientCredentials||f?.authorizationCode;if(o&&("authorizationUrl"in o&&o.authorizationUrl&&(n+=`Authorization URL: ${o.authorizationUrl}
|
|
52
|
+
`),"tokenUrl"in o&&o.tokenUrl&&(n+=`Token URL: ${o.tokenUrl}
|
|
53
|
+
`),o.scopes)){n+=`Scopes:
|
|
54
|
+
`;for(const[d,p]of Object.entries(o.scopes))n+=`- \`${d}\`: ${p}
|
|
55
55
|
`}n+=`
|
|
56
|
-
`}return n}function
|
|
56
|
+
`}return n}function Tn(e,s,c){let r="";const n=(l,t)=>{for(const i of l)if(i.link){if(i.content?.contentType===g.GROUP)r+=`${t} ${i.label||""}
|
|
57
57
|
|
|
58
|
-
`,
|
|
58
|
+
`,i.items?.length&&n(i.items,t+"#");else if(i.content?.contentType===g.ITEM){if(!M(i,s))continue;const f=i,o=f.httpVerb,d=f.httpPath,p=o&&d?`${o.toUpperCase()} ${d}`:i.label||"",u=i.content?T(i.content.children,c):void 0;r+=` - ${w({title:p,description:u?u.slice(0,200):void 0,slug:H(i.link),siteUrl:s.seo?.siteUrl})}`}}};return n(e,"##"),r}function X(e,s,c,r,n,l,t){if(!e.content)return;const i=e,f=e.label||"",o=T(e.content.children,l),d=e.content.meta?.deprecated;let p=`# ${f}${d?" (deprecated)":""}
|
|
59
59
|
|
|
60
|
-
`;if(
|
|
60
|
+
`;if(o&&(p+=`${o}
|
|
61
61
|
|
|
62
|
-
`),
|
|
62
|
+
`),c==="openapi"||c==="asyncapi"){const u=i.httpVerb,h=i.httpPath;u&&h?p+=`Endpoint: ${u.toUpperCase()} ${h}
|
|
63
63
|
`:u&&(p+=`Method: ${u.toUpperCase()}
|
|
64
|
-
`),
|
|
65
|
-
`);const $=Dn(
|
|
66
|
-
`)}return
|
|
67
|
-
`+En(
|
|
68
|
-
`),
|
|
64
|
+
`),r&&(p+=`Version: ${r}
|
|
65
|
+
`);const $=Dn(e.content.children,n);$&&(p+=`Security: ${$}
|
|
66
|
+
`)}return s?.parameters?.length&&c!=="graphql"&&(p+=`
|
|
67
|
+
`+En(s.parameters)+`
|
|
68
|
+
`),c==="graphql"&&(p+=kn(e.content.children,t,l)),p}function Ln(e,s,c){if(e.httpVerb!=="tool"||!s||!P(s,c))return;const r=e.content?.meta?.name,n=r?s["x-mcp"]?.tools?.find(t=>t.name===r):void 0;if(!n)return;let l=`# ${e.label||n.name}
|
|
69
69
|
|
|
70
|
-
`;return typeof n.description=="string"&&n.description&&(
|
|
70
|
+
`;return typeof n.description=="string"&&n.description&&(l+=`${n.description}
|
|
71
71
|
|
|
72
|
-
`),
|
|
72
|
+
`),l+=`## Input schema:
|
|
73
73
|
|
|
74
|
-
`,
|
|
74
|
+
`,l+=`\`\`\`json
|
|
75
75
|
${JSON.stringify(n.inputSchema,null,2)}
|
|
76
76
|
\`\`\`
|
|
77
77
|
|
|
78
|
-
`,n.outputSchema&&(
|
|
78
|
+
`,n.outputSchema&&(l+=`## Output schema:
|
|
79
79
|
|
|
80
|
-
`,
|
|
80
|
+
`,l+=`\`\`\`json
|
|
81
81
|
${JSON.stringify(n.outputSchema,null,2)}
|
|
82
82
|
\`\`\`
|
|
83
83
|
|
|
84
|
-
`),
|
|
84
|
+
`),l}function Rn(e,s,c,r,n){if(!e.content)return;const l=e.label||"",t=T(e.content.children,r);let i=`# ${l}
|
|
85
85
|
|
|
86
|
-
`;if(
|
|
86
|
+
`;if(t&&(i+=`${t}
|
|
87
87
|
|
|
88
|
-
`),
|
|
88
|
+
`),c==="graphql"){let o="";const d=p=>{for(const u of p??[])if(!(!u.content||!M(u,s)))if(u.content.contentType===g.ITEM){const h=X(u,void 0,c,void 0,void 0,r,n);h&&(o+=`${h}
|
|
89
89
|
|
|
90
90
|
---
|
|
91
91
|
|
|
92
|
-
`)}else u.content.contentType===g.GROUP&&d(u.items)};return d(
|
|
93
|
-
`;return f&&(
|
|
94
|
-
`),
|
|
95
|
-
`:
|
|
96
|
-
`),
|
|
92
|
+
`)}else u.content.contentType===g.GROUP&&d(u.items)};return d(e.items),{llmstxt:i+o,aiSearch:i}}let f="";if(e.items?.length)for(const o of e.items){if(!o.link||!o.content||o.content.contentType!==g.ITEM||!M(o,s))continue;const d=o,p=d.httpVerb,u=d.httpPath,h=p&&u?`${p.toUpperCase()} ${u}`:o.label||"",$=o.content?T(o.content.children,r):void 0;f+=` - ${w({title:h,description:$?$.slice(0,200):void 0,slug:H(o.link),siteUrl:s.seo?.siteUrl})}`}return{llmstxt:i+f,aiSearch:i}}function Dn(e,s){const c=[],r=n=>{for(const l of n)if(l.nodeType===m.SECURITY){const t=l;for(const i of t.requirements)for(const f of i.schemes)f[x]||f.name&&!c.includes(f.name)&&c.push(f.name)}else(l.nodeType===m.CONTAINER||l.nodeType===m.OVERVIEW_SECTION_WRAPPER)&&r(l.children)};if(r(e),c.length)return c.join(", ");if(s?.length){const n=s.flatMap(l=>Object.keys(l));if(n.length)return[...new Set(n)].join(", ")}}function En(e){const s={};for(const r of e){const n=`${r.place}${r.mediaType?` (${r.mediaType})`:""}`;s[n]||(s[n]=[]),s[n].push(r)}return Object.entries(s).map(([r,n])=>{const l=n.map(t=>{const i=[...t.path||[],t.name],f=Array.isArray(t.description)?t.description.join(" "):t.description;let o=` - \`${i.join(".")}\` (${t.type}${t.required?", required":""})
|
|
93
|
+
`;return f&&(o+=` ${f.trim()}
|
|
94
|
+
`),t.enum?o+=` Enum: ${t.enum.map(d=>JSON.stringify(d)).join(", ")}
|
|
95
|
+
`:t.example&&(o+=` Example: ${t.example}
|
|
96
|
+
`),o});return`## ${Z(r)}:
|
|
97
97
|
|
|
98
|
-
${
|
|
98
|
+
${l.join(`
|
|
99
99
|
`)}`}).join(`
|
|
100
|
-
`)}function kn(
|
|
101
|
-
## ${Z(
|
|
100
|
+
`)}function kn(e,s,c){let r="";const n=l=>{for(const t of l)if(t.nodeType===m.ITEM){const i=ln(t)?fn(t,s??{}):void 0;i&&(r+=Un(i,t.variant,c))}else(t.nodeType===m.CONTAINER||t.nodeType===m.OVERVIEW_SECTION_WRAPPER)&&n(t.children)};return n(e),r}function Un(e,s,c){let n=`
|
|
101
|
+
## ${Z(s==="return-type"?"Return type":s==="graphql-args"||s==="arguments"?"Arguments":s==="graphql-fields"?"Fields":s)}:
|
|
102
102
|
|
|
103
|
-
`;const
|
|
104
|
-
`};if(
|
|
105
|
-
`}else if(!
|
|
103
|
+
`;const l=t=>{const i=t.description?N(Array.isArray(t.description)?t.description:[t.description],{renderTag:c}).trim():"";return` - \`${t.name}\` (${t.type.display})${i?`: ${i}`:""}
|
|
104
|
+
`};if(e.type){const t=e.type.description?N(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+=l(t);return n}function T(e,s){const c=[],r=l=>{for(const t of l)if(t.nodeType===m.MARKDOC){const i=t.content,f=Array.isArray(i)?i:[i],o=N(f,{renderTag:s}).trim();o&&c.push(o)}else(t.nodeType===m.CONTAINER||t.nodeType===m.OVERVIEW_SECTION_WRAPPER)&&r(t.children)};return r(e),c.join(" ").trim()||void 0}function Z(e){return e.charAt(0).toUpperCase()+e.slice(1)}function M(e,s){return s.access?.requiresLogin?!0:pn({slug:e.link||"",[x]:e[x]},s)}export{Xn as getAiDocumentsStore};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import s from"node:path";import{bundle as R,createConfig as I,getTotals as B}from"@redocly/openapi-core";import{CONFIG_FILE_NAME as J}from"../../../constants/common.js";import{deepMerge as L}from"../../../utils/object/deep-merge.js";import{pluralize as $}from"../../../utils/string/pluralize.js";import{getAllApiConfigsByPath as M}from"../get-api-config.js";import{injectDecoratorIntoConfig as W}from"../api-docs/utils/decorators.js";import{ExternalResolver as _}from"../../fs/utils/external-ref-resolver.js";async function Y(o,{fs:n,logger:d,cache:u,getConfig:l,isPathIgnored:f}){let i;try{i=(await u.load(o,"yaml")).data}catch{return[]}if(!i?.arazzo)return d.verbose(`${o} file is not Arazzo document. Skipping`),[];const p=[],e=n.getFileInfo(o),t=await l(s.posix.dirname(o)),x=M(t?.apis,o,t.configPath),D=await f(o);for(const c of x){if(!c.output&&D)continue;const k=t.configPath?s.posix.dirname(t.configPath):".",a=c.output?s.posix.join(k,c.output):o;e&&c.output&&!
|
|
1
|
+
import s from"node:path";import{bundle as R,createConfig as I,getTotals as B}from"@redocly/openapi-core";import{CONFIG_FILE_NAME as J}from"../../../constants/common.js";import{deepMerge as L}from"../../../utils/object/deep-merge.js";import{pluralize as $}from"../../../utils/string/pluralize.js";import{getAllApiConfigsByPath as M}from"../get-api-config.js";import{injectDecoratorIntoConfig as W}from"../api-docs/utils/decorators.js";import{ExternalResolver as _}from"../../fs/utils/external-ref-resolver.js";async function Y(o,{fs:n,logger:d,cache:u,getConfig:l,isPathIgnored:f}){let i;try{i=(await u.load(o,"yaml")).data}catch{return[]}if(!i?.arazzo)return d.verbose(`${o} file is not Arazzo document. Skipping`),[];const p=[],e=n.getFileInfo(o),t=await l(s.posix.dirname(o)),x=M(t?.apis,o,t.configPath),D=await f(o);for(const c of x){if(!c.output&&D)continue;const k=t.configPath?s.posix.dirname(t.configPath):".",a=c.output?s.posix.join(k,c.output):o;e&&c.output&&!n.exists(a)&&n.addVirtualFile(a,e);const m=L(t,{rbac:void 0},c),v=s.resolve(n.cwd,t.realConfigPath||J),w=new _(n),O=await I(W(m,a,n.cwd),{configPath:v,externalRefResolver:w}),h=s.resolve(n.cwd,o),g={config:O,base:s.dirname(h),doc:{source:{absoluteRef:h},parsed:JSON.parse(JSON.stringify(i))}},{bundle:{parsed:N},problems:z,visitorsData:P}=await R({...g,dereference:!0,externalRefResolver:w}),{bundle:{parsed:S}}=await R({...g,doc:{...g.doc,parsed:JSON.parse(JSON.stringify(i))}}),V=P["markdown/markdown"]?.markdocChunks??[],r=B(z),b=[r.errors&&`${r.errors} ${$(r.errors,"error","errors")}`,r.warnings&&`${r.warnings} ${$(r.warnings,"warning","warnings")}`,r.ignored&&`${r.ignored} ignored`].filter(Boolean).join(", ");if(r.errors){const C=z.find(F=>F.severity==="error");throw new Error(`${b} while bundling ${a} definition.
|
|
2
2
|
|
|
3
3
|
${C?.message} at ${C?.location?.[0]?.pointer}
|
|
4
4
|
|
|
5
|
-
`)}r.warnings&&d.warn(`${b} while bundling %rp definition`,a);const j=y(N,t.metadata),A=y(S,t.metadata),E={document:j,documentWithReferences:A,config:m,relativePath:a,realRelativePath:e?.realRelativePath||a,customOutputRelativeFile:c.output&&a,markdocChunks:V,isVirtual:e?.isVirtual??!1};p.push(E)}return p}async function Z(o,n){const{fs:d,cache:u,getConfig:l}=n,f=[];for(const i of
|
|
5
|
+
`)}r.warnings&&d.warn(`${b} while bundling %rp definition`,a);const j=y(N,t.metadata),A=y(S,t.metadata),E={document:j,documentWithReferences:A,config:m,relativePath:a,realRelativePath:e?.realRelativePath||a,customOutputRelativeFile:c.output&&a,markdocChunks:V,isVirtual:e?.isVirtual??!1};p.push(E)}return p}async function Z(o,n){const{fs:d,cache:u,getConfig:l}=n,f=[];for(const i of d.scan(/(\.ya?ml|\.json)$/)){if(!await l(s.posix.dirname(i.relativePath)))continue;let e;try{e=await u.load(i.relativePath,"arazzo-doc")}catch{continue}e.data?.length&&f.push(...e.data.map(t=>({...t,isVirtual:i.isVirtual||t.isVirtual,hash:e.compoundHash})))}return f}function y(o,n){return n?{...o,info:{...o.info,...n}}:o}export{Y as arazzoDocLoader,Z as arazzoDocsLoader};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{simplifyAstStructure as h}from"@redocly/api-docs";import{storeDefinitionBundles as p}from"./store-definition-bundles.js";import{arazzoDocLoader as y,arazzoDocsLoader as D}from"./arazzo-doc-loader.js";import{telemetryTraceStep as P}from"../../../cli/telemetry/helpers/trace-step.js";const u="arazzo-docs-";async function $(k){let l=[];return{id:"arazzo",loaders:{"arazzo-doc":y,"arazzo-docs":D},processContent:async(e,o)=>{await P("com.redocly.build.plugin.arazzoDocs",async()=>{for(const t of
|
|
1
|
+
import{simplifyAstStructure as h}from"@redocly/api-docs";import{storeDefinitionBundles as p}from"./store-definition-bundles.js";import{arazzoDocLoader as y,arazzoDocsLoader as D}from"./arazzo-doc-loader.js";import{telemetryTraceStep as P}from"../../../cli/telemetry/helpers/trace-step.js";const u="arazzo-docs-";async function $(k){let l=[];return{id:"arazzo",loaders:{"arazzo-doc":y,"arazzo-docs":D},processContent:async(e,o)=>{await P("com.redocly.build.plugin.arazzoDocs",async()=>{for(const t of o.fs.scan(/(\.ya?ml|\.json)$/))if(!await o.isPathIgnored(t.relativePath))try{const{data:a,compoundHash:n}=await o.cache.load(t.realRelativePath,"arazzo-doc");if(!a?.length)continue;l=a.map(({markdocChunks:r,relativePath:c,isVirtual:s,customOutputRelativeFile:i,realRelativePath:d})=>({chunks:r,relativePath:c,realRelativePath:d,isVirtual:i!=null||t.isVirtual||s})),p(a,e.outdir,n);for(const r of a){const c=`${u}${r.relativePath}`;await e.createSharedData(c,{document:r.document})}}catch(a){console.error(a)}})},afterRoutesCreated:async(e,o)=>{for(const{chunks:t,relativePath:a,isVirtual:n,realRelativePath:r}of l)await o.cache.load(a,{loader:async function(){await o.cache.load(r,"arazzo-doc");for(const{node:s,markdown:i,pointer:d,key:z,relativePath:m}of t){const{ast:f}=await e.parseMarkdoc({input:{content:i,relativePath:d,isVirtual:n},context:o,deps:{sharedDataIds:[`${u}${m}`]}});s[`x-parsed-md-${z}`]={result:h(f)}}},name:"arazzo-markdoc-inline-parser"})}}}export{$ as arazzoDocsPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as g}from"@redocly/config";import{removeLeadingSlash as x}from"@redocly/theme/core/utils";import{toKebabCase as p}from"../../../../../../utils/string/to-kebab-case.js";import{promiseMapLimit as S}from"../../../../../utils/async/promise-map-limit.js";import{promiseMapLimitWithStatus as b}from"../../../../../utils/async/promise-map-limit-with-status.js";import{extractTeamsFromScopeItems as R}from"../../../../../utils/rbac.js";import{removeMarkdocTags as w}from"../../../../../../markdoc/helpers/remove-markdoc-tags.js";import{BaseApiEntitiesExtractor as N}from"./base.js";import{OpenapiSchemaResolver as d}from"../../../utils/openapi-schema-resolver.js";import{extractPartsFromComponentsRef as A}from"../../../utils/extract-parts-from-components-ref.js";import{isValidTagName as T}from"../../../utils/is-valid-tag-name.js";const k=["get","post","put","delete","patch"],v=15,O=15;class _ extends N{#e;constructor(e){super("openapi",e),this.#e=e.context.logger}async loadApiDescriptions(){return(await this.actions.loadApiDocuments(this.context)).filter(o=>o.type==="openapi").map(o=>({...o,isVirtual:o.isVirtual??!1}))}mapApiDescriptionToEntity(e,o){const n=x(e.realRelativePath),s=e.document.info.title,t=this.resolveEntityKey({realRelativePath:e.realRelativePath,customKey:e.document["x-redocly-catalog-key"]});return{type:this.type,key:t,title:s,summary:w(typeof e.document.info.description=="string"?e.document.info.description:void 0),tags:e.document.tags?.filter(a=>a.name&&T(a.name)).map(a=>a.name),metadata:{specType:this.specType,descriptionFile:n},version:o}}async processApiDescription(e,o,n,s){if(d.clearSchemaCache(),!e?.document)throw new Error("OpenAPI definition is missing a bundled document");const t=this.getRbacTeamsForDefinition(e.relativePath),a=this.mapApiDescriptionToEntity(e,n);await this.catalogEntitiesService.createEntity({entity:a,sourceFile:e.realRelativePath,fileHash:e.hash,source:"file",isRootEntity:!0,rbacTeams:t,revision:o}),s.delete(`${a.key}:${n}`),await this.#o(e,a.key,a.version,n,o,s,t);const r=this.#n(e.document.paths);if(r.length!==0){const i=(await b(r,v,async({operation:m,path:h,method:f})=>{if(!m.operationId)return;const l=await this.#c(m,h,f,e,a.key,a.version,o,t);s.delete(`${l}:${n}`)},this.#e)).count.failed;i>0&&this.#e.warn(`Extraction completed with ${i} failures out of ${r.length} operations for ${a.key}`)}}#n(e){return Object.entries(e??{}).flatMap(([o,n])=>k.filter(s=>n[s]).map(s=>{const t=n[s];if(!t)throw new Error(`Operation not found for method ${s} on path ${o}`);return{operation:t,path:o,method:s.toUpperCase()}}))}async#o(e,o,n,s,t,a,r){const c=e.document.components?.schemas;if(!c)return;const i=Object.entries(c);i.length!==0&&await S(i,O,async([m,h])=>{const f=`${o}-${p(m)}`,l=await this.#r({schemaName:m,schema:h,description:e,parentKey:o,parentVersion:n,parentRevision:t,rbacTeams:r});a.delete(`${f}:${s}`),l&&await this.catalogEntitiesService.createEntityRelation({sourceKey:o,sourceVersion:n,sourceRevision:t,type:"uses",targetKey:l.key,targetVersion:n,targetRevision:t,sourceFile:e.realRelativePath,fileHash:e.hash})})}async#r({schemaName:e,schema:o,description:n,parentKey:s,parentVersion:t,parentRevision:a,rbacTeams:r}){const c=d.resolveSchemaRefs(o,n.document),i=JSON.stringify(c),m=c[g]?R(c[g]):r,h=R(c["x-rbac"]),f={type:"data-schema",key:`${s}-${p(e)}`,title:e,summary:(typeof c.description=="string"?c.description:c.title)??null,tags:[],metadata:{specType:this.specType,schema:i},version:t};try{return await this.catalogEntitiesService.createEntity({entity:f,sourceFile:n.realRelativePath,fileHash:n.hash,rbacTeams:h.length?h:m,source:"file",revision:a})}catch(l){return this.#e.error(`Failed to create data schema entity for ${e}: ${l instanceof Error?l.message:"Unknown error"}`),null}}async#c(e,o,n,s,t,a,r,c){const i=`${t}-${p(`${e.operationId}`)}`,m=this.#h(e.requestBody??null,s),h=this.#l(e.responses??{},s),f=m.schemaNames,l=h.schemaNames;m.errors.length>0&&this.#e.warn(`Schema extraction errors for operation ${e.operationId}: ${m.errors.join(", ")}`),h.errors.length>0&&this.#e.warn(`Response schema extraction errors for operation ${e.operationId}: ${h.errors.join(", ")}`);const u=f.map(E=>`${t}-${p(E)}`),$=l.map(E=>`${t}-${p(E)}`),y=await this.#p({path:o,method:n,operation:e,requestBodySchemasKeys:u,responseSchemasKeys:$,description:s,parentKey:t,parentVersion:a,parentRevision:r,rbacTeams:c});return y&&await Promise.all([this.#i(f,e.operationId??"",s.realRelativePath,s.hash,t,a,r),this.#m(l,e.operationId??"",s.realRelativePath,s.hash,t,a,r),this.#y({apiOperationKey:y.key,operationRelations:e["x-catalogRelations"],descriptionUniqueKey:t,description:s,parentVersion:a,parentRevision:r})]),i}async#i(e,o,n,s,t,a,r){return e.length===0||!o?[]:await this.#s(e,o,n,s,t,a,r)}async#m(e,o,n,s,t,a,r){return e.length===0||!o?[]:await this.#s(e,o,n,s,t,a,r)}#h(e,o){const n=[],s=[];try{if(e&&"content"in e&&e.content)for(const t of Object.values(e.content)){const a=this.#a(t,o);if(!a)continue;const r=this.#t(a);r?.componentType==="schemas"&&r.componentName&&n.push(r.componentName)}if(e&&e.$ref){const t=this.#t(e.$ref);if(t?.componentType==="requestBodies"&&t.componentName){const a=o.document.components?.requestBodies?.[t.componentName];if(a&&"content"in a)for(const r of Object.values(a.content??{})){const c=this.#a(r,o);if(!c)continue;const i=this.#t(c);i?.componentType==="schemas"&&i.componentName&&n.push(i.componentName)}}}}catch(t){s.push(`Failed to extract request body schemas: ${t instanceof Error?t.message:"Unknown error"}`)}return{schemaNames:[...new Set(n)],errors:s}}#l(e,o){const n=[],s=[];try{for(const t of Object.values(e)){if(t&&"content"in t&&t.content)for(const a of Object.values(t.content)){const r=this.#a(a,o);if(!r)continue;const c=this.#t(r);c?.componentType==="schemas"&&c.componentName&&n.push(c.componentName)}if(t&&t.$ref){const a=this.#t(t.$ref);if(a?.componentType==="responses"&&a.componentName){const r=o.document.components?.responses?.[a.componentName];if(r&&"content"in r)for(const c of Object.values(r.content??{})){const i=this.#a(c,o);if(!i)continue;const m=this.#t(i);m?.componentType==="schemas"&&m.componentName&&n.push(m.componentName)}}}}}catch(t){s.push(`Failed to extract response schemas: ${t instanceof Error?t.message:"Unknown error"}`)}return{schemaNames:[...new Set(n)],errors:s}}#a(e,o){const n=new Set;let s=e;for(;s&&"$ref"in s;){const t=this.#t(s.$ref),a=t?.componentName;if(t?.componentType!=="mediaTypes"||!a||n.has(a))return;n.add(a),s=o.document.components?.mediaTypes?.[a]}return s?.schema?.$ref}#t(e){try{return A(e)}catch{return{componentType:"",componentName:null}}}async#s(e,o,n,s,t,a,r){return e.length===0?[]:await S(e,O,async c=>await this.#f({operationId:o,schemaName:c,descriptionSourceFile:n,descriptionHash:s,parentKey:t,parentVersion:a,parentRevision:r}))}async#f({operationId:e,schemaName:o,descriptionSourceFile:n,descriptionHash:s,parentKey:t,parentVersion:a,parentRevision:r}){const c=`${t}-${p(o)}`;try{return await this.catalogEntitiesService.createEntityRelation({sourceKey:`${t}-${p(e)}`,type:"uses",targetKey:c,sourceFile:n,fileHash:s,sourceVersion:a,targetVersion:a,sourceRevision:r,targetRevision:r}),c}catch(i){throw this.#e.error(`Failed to create relation between operation ${e} and schema ${o}: ${i instanceof Error?i.message:"Unknown error"}`),i}}async#p({path:e,method:o,operation:n,requestBodySchemasKeys:s,responseSchemasKeys:t,description:a,parentKey:r,parentVersion:c,parentRevision:i,rbacTeams:m}){const h=`${n.operationId}`,f=`${r}-${p(h)}`,l=n[g]?R(n[g]):m,u=R(n["x-rbac"]),$={type:"api-operation",key:f,title:h,summary:w(n.summary),tags:n.tags?.filter(y=>T(y)),metadata:{path:e,method:o,payload:s,responses:t},version:c};try{return await this.catalogEntitiesService.createEntity({entity:$,sourceFile:a.realRelativePath,fileHash:a.hash,rbacTeams:u.length>0?u:l,source:"file",revision:i})}catch(y){return this.#e.error(`Failed to create API operation entity for ${h}: ${y instanceof Error?y.message:"Unknown error"}`),null}}async#y({apiOperationKey:e,operationRelations:o,descriptionUniqueKey:n,description:s,parentVersion:t,parentRevision:a}){try{await this.catalogEntitiesService.createEntityRelation({sourceKey:e,type:"partOf",targetKey:n,sourceFile:s.realRelativePath,fileHash:s.hash,sourceVersion:t,targetVersion:t,sourceRevision:a,targetRevision:a}),await this.#u(e,s,o,t,a)}catch(r){this.#e.error(`Failed to create API operation relations for ${e}: ${r instanceof Error?r.message:"Unknown error"}`)}}async#u(e,o,n,s,t){n?.length&&await S(n,v,async a=>{try{this.validateEntityRelationFileSchema(a),await this.catalogEntitiesService.createEntityRelation({sourceKey:e,type:a.type,targetKey:a.key,sourceFile:o.realRelativePath,fileHash:o.hash,sourceVersion:s,targetVersion:"",sourceRevision:t,targetRevision:""})}catch(r){this.context.logger.warn(`Error creating entity relation for operation ${e} based on custom property: ${r instanceof Error?r.message:"Unknown error"}`)}})}}export{_ as OpenApiEntitiesExtractor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../constants/common.js";import{reporter as R}from"../../tools/notifiers/reporter.js";import{canAccessFeature as g}from"../../utils/entitlements/can-access-feature.js";import{extractMdFirstHeading as A,getAst as T}from"./compiler.js";import{getTemplatePath as w}from"./get-template-path.js";import{prepareMarkdocPartials as M}from"./markdoc/partials.js";import{searchResolver as C}from"./search/search-resolver.js";import{markdownStaticDataLoader as E}from"./markdown-static-data-loader.js";import{makeErrorRoute as I}from"../error-route.js";import{validateRbacConfig as O}from"../validate-rbac-config.js";import{findFrontmatterSlugs as _,getSidebarSharedDataId as G,resolveFrontmatterSlugs as L}from"../utils.js";import{isPartial as j}from"./is-partial.js";import{markdownFrontmatterLoader as B}from"./markdown-frontmatter-loader.js";import{resolveRawPartials as K}from"./markdoc/resolve-raw-partials.js";import{getAiDocumentsStore as N}from"./search/get-ai-search-documents.js";import{registerPageProps as Y}from"../register-page-props.js";import{resolveMarkdownTemplate as q}from"./utils/resolve-markdown-template.js";import{sanitizeMalformedMdContent as z}from"./utils/sanitize-malformed-md-content.js";import{telemetryTraceStep as H}from"../../../cli/telemetry/helpers/trace-step.js";async function ce(h){return{id:"markdoc",requiredEntitlements:["markdown"],loaders:{"markdown-frontmatter":B,"markdown-ast":async(e,t)=>{const i=await t.fs.read(e),m=await t.getConfig(),s=await K(i,e,m?.markdown?.partialsFolders,t),n=z(s);return T(e,n)}},processContent:async(e,t)=>{await H("com.redocly.build.plugin.markdown",async i=>{const{markdown:m}=await t.getConfig();i?.setAttribute("config",JSON.stringify(m||{}));const s=m?.partialsFolders??[],n=e.createTemplate("markdown","@redocly/theme/core/templates/Markdown"),S=e.registerServerPropsGetter("markdown",w("./get-server-props.js"));e.createTemplate("error",w("../../../client/app/Error/ErrorDetails.js"));for(const o of t.fs.scan(/\.md$/))if(!await t.isPathIgnored(o.relativePath)&&!j(o.relativePath,s))try{await k(o)}catch(a){e.addRoute(I(o.relativePath,a)),i?.error(a),await R.panicOnBuild("Failed to create route for markdown file: %s",a.message)}async function k(o){const{relativePath:a,realRelativePath:b}=o,{data:{frontmatter:r}}=await t.cache.load(a,"markdown-frontmatter"),P=r?.metadata||{},y=await _(a,"markdown-frontmatter",r,t),p=L(y,a);let d=null;r?.sidebar&&(d=await G(r.sidebar,a,t.fs));let u=n;const l=q({realRelativePath:b,frontmatter:r,markdown:m,contentDir:h.contentDir});l&&(u=e.createTemplate(l.templateRef,l.templatePath)),r?.rbac&&(g("rbac")?O({content:{[a]:r.rbac}}):r.rbac=void 0),g("banner")||(r.banner=void 0),
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../constants/common.js";import{reporter as R}from"../../tools/notifiers/reporter.js";import{canAccessFeature as g}from"../../utils/entitlements/can-access-feature.js";import{extractMdFirstHeading as A,getAst as T}from"./compiler.js";import{getTemplatePath as w}from"./get-template-path.js";import{prepareMarkdocPartials as M}from"./markdoc/partials.js";import{searchResolver as C}from"./search/search-resolver.js";import{markdownStaticDataLoader as E}from"./markdown-static-data-loader.js";import{makeErrorRoute as I}from"../error-route.js";import{validateRbacConfig as O}from"../validate-rbac-config.js";import{findFrontmatterSlugs as _,getSidebarSharedDataId as G,resolveFrontmatterSlugs as L}from"../utils.js";import{isPartial as j}from"./is-partial.js";import{markdownFrontmatterLoader as B}from"./markdown-frontmatter-loader.js";import{resolveRawPartials as K}from"./markdoc/resolve-raw-partials.js";import{getAiDocumentsStore as N}from"./search/get-ai-search-documents.js";import{registerPageProps as Y}from"../register-page-props.js";import{resolveMarkdownTemplate as q}from"./utils/resolve-markdown-template.js";import{sanitizeMalformedMdContent as z}from"./utils/sanitize-malformed-md-content.js";import{telemetryTraceStep as H}from"../../../cli/telemetry/helpers/trace-step.js";async function ce(h){return{id:"markdoc",requiredEntitlements:["markdown"],loaders:{"markdown-frontmatter":B,"markdown-ast":async(e,t)=>{const i=await t.fs.read(e),m=await t.getConfig(),s=await K(i,e,m?.markdown?.partialsFolders,t),n=z(s);return T(e,n)}},processContent:async(e,t)=>{await H("com.redocly.build.plugin.markdown",async i=>{const{markdown:m}=await t.getConfig();i?.setAttribute("config",JSON.stringify(m||{}));const s=m?.partialsFolders??[],n=e.createTemplate("markdown","@redocly/theme/core/templates/Markdown"),S=e.registerServerPropsGetter("markdown",w("./get-server-props.js"));e.createTemplate("error",w("../../../client/app/Error/ErrorDetails.js"));for(const o of t.fs.scan(/\.md$/))if(!await t.isPathIgnored(o.relativePath)&&!j(o.relativePath,s))try{await k(o)}catch(a){e.addRoute(I(o.relativePath,a)),i?.error(a),await R.panicOnBuild("Failed to create route for markdown file: %s",a.message)}async function k(o){const{relativePath:a,realRelativePath:b}=o,{data:{frontmatter:r}}=await t.cache.load(a,"markdown-frontmatter"),P=r?.metadata||{},y=await _(a,"markdown-frontmatter",r,t),p=L(y,a);let d=null;r?.sidebar&&(d=await G(r.sidebar,a,t.fs));let u=n;const l=q({realRelativePath:b,frontmatter:r,markdown:m,contentDir:h.contentDir});l&&(u=e.createTemplate(l.templateRef,l.templatePath)),r?.rbac&&(g("rbac")?O({content:{[a]:r.rbac}}):r.rbac=void 0),g("banner")||(r.banner=void 0),Y(o,t.fs,e),(p.length?p.reverse():[void 0]).forEach(F=>{e.addRoute({excludeFromSearch:r?.excludeFromSearch||!1,slug:F,fsPath:a,templateId:u,sharedData:d?[{id:d,key:"sidebar"}]:void 0,redirectFrom:Object.entries(r.redirects||{}).map(([c,{type:f}])=>({type:f||301,from:c})),[v]:r?.rbac,getNavText:async()=>(r?.seo?.title||await A(a,t)||"").toString(),metadata:{type:"markdown",...P},async getStaticData(c,f){return E(o,c,t,r,f)},getSearchDocuments:C(r,a,e.getSearchFacets,e.setSearchFacets),getAiDocumentsStore:N(e.getSearchFacets,r),serverPropsGetterIds:[S]})})}})},afterRoutesCreated:async(e,t)=>{const i=await M(t,e);e.setGlobalConfig({[D]:i})}}}export{ce as markdownPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isNode as p}from"../../../../../markdoc/helpers/guards/is-node.js";import{isStringNode as u}from"../../../../../markdoc/helpers/guards/is-string-node.js";import{getNodeAttribute as o}from"../../../../../markdoc/helpers/get-node-attribute.js";import{getInnerText as
|
|
1
|
+
import{isForAgentsOnly as m}from"@redocly/theme/markdoc/tags/visibility";import{isNode as p}from"../../../../../markdoc/helpers/guards/is-node.js";import{isStringNode as u}from"../../../../../markdoc/helpers/guards/is-string-node.js";import{getNodeAttribute as o}from"../../../../../markdoc/helpers/get-node-attribute.js";import{getInnerText as l}from"../../../../../markdoc/helpers/get-inner-text.js";import{isPromptNode as d}from"../../../../../markdoc/helpers/guards/is-prompt-node.js";function h(t){const r=o(t,"level");if(r)return{value:l(t.children),id:o(t,"id"),depth:r}}function N(t){const r=o(t,"headlineLevel"),e=o(t,"anchorId"),s=o(t,"headline");if(!(!r||!e||!Array.isArray(s)))return{value:l(s),id:e,depth:r}}function S(t){let r;return c(t,e=>{if(p(e)){if(d(e)||m(e))return a;if(e.type==="heading")return r=h(e)?.value,f}}),r}const f=Symbol("Exit visitor"),a=Symbol("Skip children");function c(t,r){if(!t)return;const e=r(t);if(e===f)return e;if(e===a)return;for(const i of t.children){if(!i||u(i))continue;const n=c(i,r);if(n===f)return n}const s=t.slots||{};for(const i of Object.values(s)){if(!i||u(i))continue;const n=c(i,r);if(n===f)return n}}export{f as EXIT,a as SKIP,S as extractFirstHeading,h as getHeadingData,N as getNumberedItemHeadingData,c as visit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import d from"@markdoc/markdoc";import{REDOCLY_ROUTE_RBAC as l,REDOCLY_TEAMS_RBAC as A}from"@redocly/config";import{getInnerText as T}from"../../../../markdoc/helpers/get-inner-text.js";import{skipAgentsOnlyContent as h}from"@redocly/theme/markdoc/tags/visibility";import{getSearchDocuments as g}from"./get-search-documents.js";import{AstToSearchNodeTransformer as C}from"./walk-sections.js";import{setDocumentSearchFacets as R,extractDocumentSearchFacets as S}from"./search-facets.js";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../../constants/common.js";import{normalizeFrontmatterKeywords as _}from"../../helpers/normalize-frontmatter-keywords.js";function Y(e,m,o,c){return async(t,r,a)=>{if(e?.excludeFromSearch)return[];const i=d.Ast.fromJSON(r.ast),f=new C({ast:i,getInnerContent:T,partials:a.getGlobalConfig(D)||{},renderTag:h,indexPromptTitles:!0}),p=t.metadata||{},n=S(p,o);R(n,o,c);const u=e?.seo?.title||m,{result:s}=_(e?.keywords);return g(f,t.slug,u,r[A],r[l],n,s||void 0)}}export{Y as searchResolver};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import g from"node:path";import{REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import{slash as S}from"../../../utils/path/slash.js";import{canAccessFeature as y}from"../../utils/entitlements/can-access-feature.js";import{staticDataLoader as b}from"./loaders/static-data-loader.js";import{findFrontmatterSlugs as F,getSidebarSharedDataId as P,resolveFrontmatterSlugs as
|
|
1
|
+
import g from"node:path";import{REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import{slash as S}from"../../../utils/path/slash.js";import{canAccessFeature as y}from"../../utils/entitlements/can-access-feature.js";import{staticDataLoader as b}from"./loaders/static-data-loader.js";import{findFrontmatterSlugs as F,getSidebarSharedDataId as P,resolveFrontmatterSlugs as v}from"../utils.js";import{reactFrontmatterLoader as w}from"./loaders/react-frontmatter-loader.js";import{registerPageProps as D}from"../register-page-props.js";import{telemetryTraceStep as R}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as E}from"./search/search-resolver.js";async function x(){return{loaders:{"react-frontmatter":w},id:"react-pages",requiredEntitlements:["reactPages"],processContent:async(r,a)=>{await R("com.redocly.build.plugin.pages",async()=>{const{fs:o,cache:f}=a;for(const n of o.scan(/\.page\.tsx?$/)){const{relativePath:e,realRelativePath:l}=n;if(await a.isPathIgnored(e))continue;const p=r.createTemplate(S(e),g.resolve(o.cwd,l));D(n,o,r);const{data:t}=await f.load(e,"react-frontmatter"),u=await F(e,"react-frontmatter",t,a),s=v(u,e);let c=null;t?.sidebar&&(c=await P(t.sidebar,e,a.fs)),(s.length?s.reverse():[void 0]).forEach(i=>{r.addRoute({excludeFromSearch:t?.excludeFromSearch||!1,slug:i,templateId:p,fsPath:e,sharedData:c?[{id:c,key:"sidebar"}]:void 0,[h]:y("rbac")?t?.rbac:void 0,getNavText:async()=>t?.seo?.title,getStaticData:async(m,d)=>({props:await b({frontmatter:t,relativePath:e},a,d)}),getSearchDocuments:E(t,e,r.getSearchFacets,r.setSearchFacets)})});for(const[i,{to:m,type:d}]of Object.entries(t?.redirects||{}))r.addRedirect(i,{to:m||s[0],type:d||301})}})}}}export{x as customPagesPlugin};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ContentFs } from '../fs/content-fs.js';
|
|
2
2
|
import type { FileInfo, ProcessContentActions } from '../types';
|
|
3
|
-
export declare function registerPageProps(file: FileInfo, fs: ContentFs, actions: ProcessContentActions):
|
|
3
|
+
export declare function registerPageProps(file: FileInfo, fs: ContentFs, actions: ProcessContentActions): void;
|
|
4
4
|
//# sourceMappingURL=register-page-props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import a from"path";function l(e,t,p){const{realRelativePath:r,relativePath:o}=e;let s;r.match(/\.md$/)&&(s=r.replace(/\.md$/,".props.ts")),r.match(/\.page\.tsx?$/)&&(s=r.replace(/\.page\.tsx?$/,".props.ts"));const i=s?n(s,t):void 0;i&&p.registerPagePropsGetter(o,i)}function n(e,t){return t.exists(e)?a.resolve(t.cwd,e):void 0}export{l as registerPageProps};
|
|
@@ -4,4 +4,4 @@ import{writeFileSync as at}from"node:fs";import*as g from"path";import{removeMar
|
|
|
4
4
|
- ${y.join(`
|
|
5
5
|
- `)}`,m);return}const{fromDir:k,resolveOptions:n}=V(m,f,p);return Ft(l,k,a,c,n)}))).flat().filter(M),e=vt(r),s=It(e);if(s.length){await I.panicOnBuildContentError(`Navigation tabs conflict in %rp. A route can belong to one tab only:
|
|
6
6
|
- ${s.map(({routeSlug:l,owners:f})=>`${l} is claimed by ${f.map(m=>`"${m}"`).join(" and ")}`).join(`
|
|
7
|
-
- `)}`,i);return}return{routeOwners:e,sharedData:{items:[],tabs:r},navItems:Ct(r)}}function V(t,i,o){return{fromDir:g.dirname(g.join(u,t)),resolveOptions:{locale:i,ignoredRoutes:o,navFile:t,excludedFromLinkCheckerPatterns:T}}}async function rt(t,{routeOwners:i,sharedData:o,navItems:r}){const e=Q(t),s=new Set;for(const{routeSlug:f,items:m}of i){const p=a.getRouteBySlug(f)?.fsPath??"",y=x[p];y&&(Array.from(s).find(n=>n.key===y.key&&n.version===y.version)||s.add(y)),a.addRouteSharedData(f,"sidebar",e),F.set(J(f),m)}const l=s.size===1?Array.from(s)[0]:void 0;return await a.createSharedData(e,{relatedNavbarItem:tt?.get(t),...o,catalogEntity:l?{key:l.key,version:l.version}:void 0}),{firstLink:B(r,f=>!!f.link),resolved:r}}async function K(t,i,o,r=!1){const e=structuredClone(i);o&&o!==E&&e.items.forEach(n=>{n.directory=g.posix.join(d.localizationFolder||"",o,n.directory||"")});const s=await q(e.items,u,a,c,{groupCustomSidebars:!0,locale:o,navFile:Y,excludedFromLinkCheckerPatterns:T});if(!s){await I.panicOnBuild(`Failed to resolve catalog configuration. Make sure catalog ${t} has valid config`);return}Bt(s);const l=o===E?"":"/"+o.toLowerCase(),f=o===E?"":`-${o}`,m=J(g.posix.join(l,e.slug));if(r)for(const n of s){const S=B(n.items||[],v=>!!v.routeSlug);if(!S?.routeSlug)continue;const b=F.get(S.routeSlug);if(!b)continue;const O=N(b,"routeSlug"),R="current-catalog-info-"+n.routeSlug+f,P={catalog:{label:e.title,titleTranslationKey:e.titleTranslationKey,link:m,icon:e?.icon},item:{label:n.metadata?.title,link:n.link,icon:n.icon}};await a.createSharedData(R,P);for(const v of O)a.addRouteSharedData(v,"current-catalog-info",R),C.add(v);const X=B(b,v=>!!v.link&&!v.external&&ut(v.link)&&(!n.version||v.version===n.version));X&&(n.sidebar=[{...X,items:void 0}])}const p={},y=new Set;for(const n of s){if(!(n.routeSlug||n.sidebar?.[0]?.routeSlug)||!n.fsPath||y.has(n.fsPath))continue;y.add(n.fsPath);const b=g.dirname(n.fsPath);p[b]=(p[b]||0)+1}if(r){const n=await a.createSharedData(pt(t,f),s.flatMap(S=>{const b=g.dirname(S.fsPath??""),O=p[b]===1,R=P=>({...P,fsPath:O?b:P.fsPath??""});return S.type==="group"&&S.items?.every(P=>P.type==="group")?(S.items||[]).map(R):R(S)}));a.addRouteSharedData(m,"catalog",n),Ot(o,s,j,p)}const k=N(s,"routeSlug");for(const n of k)C.add(n)}})}}}function Ot(u,a,c,h){if(u===E)for(const d of a){const D=d.routeSlug||d.sidebar?.[0]?.routeSlug;if(!D||!d.fsPath)continue;const F=g.dirname(d.fsPath),C=h[F]===1;c.set(D,{rootFileFsPath:d.fsPath,fsPath:C?F:d.fsPath,metadata:d.metadata||{},title:d.metadata?.title||d.label||"Untitled",version:d.version||"latest"})}}function Bt(u){const a=c=>{typeof c.metadata?.description=="string"&&(c.metadata={...c.metadata,description:nt(c.metadata.description)})};for(const c of u)if(c.routeSlug)a(c);else for(const h of c.items||[])a(h)}function Q(u){return st+dt(u)}async function fe(u,a,c){const h=g.posix.join(g.dirname(u),a);return
|
|
7
|
+
- `)}`,i);return}return{routeOwners:e,sharedData:{items:[],tabs:r},navItems:Ct(r)}}function V(t,i,o){return{fromDir:g.dirname(g.join(u,t)),resolveOptions:{locale:i,ignoredRoutes:o,navFile:t,excludedFromLinkCheckerPatterns:T}}}async function rt(t,{routeOwners:i,sharedData:o,navItems:r}){const e=Q(t),s=new Set;for(const{routeSlug:f,items:m}of i){const p=a.getRouteBySlug(f)?.fsPath??"",y=x[p];y&&(Array.from(s).find(n=>n.key===y.key&&n.version===y.version)||s.add(y)),a.addRouteSharedData(f,"sidebar",e),F.set(J(f),m)}const l=s.size===1?Array.from(s)[0]:void 0;return await a.createSharedData(e,{relatedNavbarItem:tt?.get(t),...o,catalogEntity:l?{key:l.key,version:l.version}:void 0}),{firstLink:B(r,f=>!!f.link),resolved:r}}async function K(t,i,o,r=!1){const e=structuredClone(i);o&&o!==E&&e.items.forEach(n=>{n.directory=g.posix.join(d.localizationFolder||"",o,n.directory||"")});const s=await q(e.items,u,a,c,{groupCustomSidebars:!0,locale:o,navFile:Y,excludedFromLinkCheckerPatterns:T});if(!s){await I.panicOnBuild(`Failed to resolve catalog configuration. Make sure catalog ${t} has valid config`);return}Bt(s);const l=o===E?"":"/"+o.toLowerCase(),f=o===E?"":`-${o}`,m=J(g.posix.join(l,e.slug));if(r)for(const n of s){const S=B(n.items||[],v=>!!v.routeSlug);if(!S?.routeSlug)continue;const b=F.get(S.routeSlug);if(!b)continue;const O=N(b,"routeSlug"),R="current-catalog-info-"+n.routeSlug+f,P={catalog:{label:e.title,titleTranslationKey:e.titleTranslationKey,link:m,icon:e?.icon},item:{label:n.metadata?.title,link:n.link,icon:n.icon}};await a.createSharedData(R,P);for(const v of O)a.addRouteSharedData(v,"current-catalog-info",R),C.add(v);const X=B(b,v=>!!v.link&&!v.external&&ut(v.link)&&(!n.version||v.version===n.version));X&&(n.sidebar=[{...X,items:void 0}])}const p={},y=new Set;for(const n of s){if(!(n.routeSlug||n.sidebar?.[0]?.routeSlug)||!n.fsPath||y.has(n.fsPath))continue;y.add(n.fsPath);const b=g.dirname(n.fsPath);p[b]=(p[b]||0)+1}if(r){const n=await a.createSharedData(pt(t,f),s.flatMap(S=>{const b=g.dirname(S.fsPath??""),O=p[b]===1,R=P=>({...P,fsPath:O?b:P.fsPath??""});return S.type==="group"&&S.items?.every(P=>P.type==="group")?(S.items||[]).map(R):R(S)}));a.addRouteSharedData(m,"catalog",n),Ot(o,s,j,p)}const k=N(s,"routeSlug");for(const n of k)C.add(n)}})}}}function Ot(u,a,c,h){if(u===E)for(const d of a){const D=d.routeSlug||d.sidebar?.[0]?.routeSlug;if(!D||!d.fsPath)continue;const F=g.dirname(d.fsPath),C=h[F]===1;c.set(D,{rootFileFsPath:d.fsPath,fsPath:C?F:d.fsPath,metadata:d.metadata||{},title:d.metadata?.title||d.label||"Untitled",version:d.version||"latest"})}}function Bt(u){const a=c=>{typeof c.metadata?.description=="string"&&(c.metadata={...c.metadata,description:nt(c.metadata.description)})};for(const c of u)if(c.routeSlug)a(c);else for(const h of c.items||[])a(h)}function Q(u){return st+dt(u)}async function fe(u,a,c){const h=g.posix.join(g.dirname(u),a);return c.exists(h)?Q(h):(await I.panicOnBuildContentErrorForRealFile("File %rp: Failed to create relative path for sidebars.yaml using %s",u,c,u,a),null)}function Mt(u){const a=u.replaceAll("/","_");if(a.length>Lt){const c=a.slice(0,Tt),h=gt(u).slice(0,_t).replaceAll("/","_");return c+h}else return a}export{fe as resolveSidebarId,ce as sidebarsPlugin,Bt as stripMarkdocFromDescriptions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import s from"path";import{collectPropValueDeep as g}from"../../../utils/tree/collect-prop-value-deep.js";import{removeTrailingSlash as f}from"../../../utils/url/remove-trailing-slash.js";import{slash as C}from"../../../utils/path/slash.js";import{removeLeadingSlash as u}from"../../../utils/url/remove-leading-slash.js";import{reporter as p}from"../../tools/notifiers/reporter.js";import{getCompleteCatalogConfig as h}from"../catalog-entities/get-complete-catalog-config.js";async function k({fs:r,cache:i},e,n){const a=new Map;for(const t of n){if(!
|
|
1
|
+
import s from"path";import{collectPropValueDeep as g}from"../../../utils/tree/collect-prop-value-deep.js";import{removeTrailingSlash as f}from"../../../utils/url/remove-trailing-slash.js";import{slash as C}from"../../../utils/path/slash.js";import{removeLeadingSlash as u}from"../../../utils/url/remove-leading-slash.js";import{reporter as p}from"../../tools/notifiers/reporter.js";import{getCompleteCatalogConfig as h}from"../catalog-entities/get-complete-catalog-config.js";async function k({fs:r,cache:i},e,n){const a=new Map;for(const t of n){if(!r.exists(t))continue;const o=s.dirname(s.join(e,t)),m=(await i.load(t,"yaml")).data;try{const c=g(m,"$ref");for(const d of c){const l=C(s.relative(e,s.join(o,d)));a.has(l)&&await p.panicOnBuildContentError(`Sidebar reference '${l}' was used multiple times.`),a.set(l,t)}}catch(c){if(c.message.includes("not iterable")){await p.panicOnBuildContentErrorForRealFile('Invalid sidebar format at %rp, "items" should be an array',t,r,t);continue}throw c}}return a}function v(r){function i(e,n){if(n.includes(e))return[...n,e];const a=r.get(e);if(a){const t=i(a,[...n,e]);if(t)return t}return!1}for(const e of r.keys()){const n=i(e,[]);if(n)return n}return!1}function P(r){const i=r.apiFunctions?.folders?.map(o=>new RegExp(`^/?(${u(f(o))})(/|$)`))||[],e=[new RegExp("^/?(api)(/|$)")],n=h(r.entitiesCatalog),t=Object.values(n?.catalogs||{}).map(o=>o?.slug?new RegExp(`^/?(catalogs\\/${u(f(o?.slug||""))})(/|$)`):null).filter(o=>o!==null);return{apiFunctions:[...i,...e],catalog:t}}export{P as getExcludedFromLinkCheckerPatterns,k as getSidebarReferences,v as hasCircularDependency};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/redoc-reef",
|
|
3
|
-
"version": "0.139.0-next.
|
|
3
|
+
"version": "0.139.0-next.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -33,13 +33,13 @@
|
|
|
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.4.0-next.
|
|
36
|
+
"@redocly/api-docs": "0.4.0-next.8",
|
|
37
37
|
"@redocly/config": "0.66.0",
|
|
38
38
|
"@redocly/openapi-core": "2.64.0",
|
|
39
39
|
"@redocly/portal-legacy-ui": "0.19.0",
|
|
40
40
|
"@redocly/portal-plugin-mock-server": "0.24.0-next.1",
|
|
41
|
-
"@redocly/realm-asyncapi-sdk": "0.
|
|
42
|
-
"@redocly/theme": "0.71.0-next.
|
|
41
|
+
"@redocly/realm-asyncapi-sdk": "0.17.0-next.0",
|
|
42
|
+
"@redocly/theme": "0.71.0-next.5",
|
|
43
43
|
"@shikijs/transformers": "3.21.0",
|
|
44
44
|
"@tanstack/react-query": "5.62.3",
|
|
45
45
|
"@tanstack/react-table": "8.21.3",
|