@redocly/reef 0.132.0-next.0 → 0.132.0-next.2

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.
Files changed (121) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/dist/client/App.js +1 -1
  3. package/dist/client/TestProvider.js +1 -1
  4. package/dist/client/app/hooks/catalog/useCatalogSort.d.ts +3 -4
  5. package/dist/client/app/hooks/catalog/useFetchCatalogEntities.js +1 -1
  6. package/dist/client/app/hooks/catalog/useFetchCatalogEntitiesRelations.js +1 -1
  7. package/dist/client/app/hooks/index.d.ts +1 -0
  8. package/dist/client/app/hooks/index.js +1 -1
  9. package/dist/client/app/hooks/markdown/useMarkdocRenderer.d.ts +3 -0
  10. package/dist/client/app/hooks/markdown/useMarkdocRenderer.js +1 -0
  11. package/dist/client/app/hooks/useBanner.d.ts +3 -5
  12. package/dist/client/app/hooks/useBanner.js +1 -1
  13. package/dist/client/app/hooks/utils/match-banner-target.d.ts +2 -2
  14. package/dist/client/app/hooks/utils/match-banner-target.js +1 -1
  15. package/dist/client/app/l10n/hooks/useTranslate.js +1 -1
  16. package/dist/client/app/markdoc/custom-components/ExcalidrawRenderer.d.ts +8 -0
  17. package/dist/client/app/markdoc/custom-components/ExcalidrawRenderer.js +14 -0
  18. package/dist/client/app/markdoc/custom-components/index.d.ts +1 -0
  19. package/dist/client/app/markdoc/custom-components/index.js +1 -1
  20. package/dist/client/app/utils/loadAndNavigate.js +1 -1
  21. package/dist/client/app/utils/scroll-to-anchor.d.ts +3 -0
  22. package/dist/client/app/utils/scroll-to-anchor.js +1 -0
  23. package/dist/client/providers/theme/ThemeDataProvider.js +1 -1
  24. package/dist/constants/common.js +1 -1
  25. package/dist/markdoc/nodes/fence/index.js +1 -1
  26. package/dist/markdoc/tags/excalidraw.d.ts +3 -0
  27. package/dist/markdoc/tags/excalidraw.js +1 -0
  28. package/dist/markdoc/tags/index.d.ts +4 -0
  29. package/dist/markdoc/tags/index.js +1 -1
  30. package/dist/server/config/env-schema.d.ts +3 -0
  31. package/dist/server/config/env-schemas/auth.d.ts +3 -0
  32. package/dist/server/config/env-schemas/auth.js +1 -1
  33. package/dist/server/fs/fast-mtime.js +3 -3
  34. package/dist/server/plugins/api-functions/helpers/parse-route-fs-path-for-hono.js +1 -1
  35. package/dist/server/plugins/api-functions/index.js +1 -1
  36. package/dist/server/plugins/arazzo-docs/index.js +1 -1
  37. package/dist/server/plugins/asyncapi-docs/get-server-props.js +1 -1
  38. package/dist/server/plugins/asyncapi-docs/index.js +1 -1
  39. package/dist/server/plugins/asyncapi-docs/search/get-ai-search-documents.js +3 -3
  40. package/dist/server/plugins/catalog-entities/database/mappers/create-bff-related-entity.js +1 -1
  41. package/dist/server/plugins/catalog-entities/database/mappers/field-transformations.d.ts +2 -2
  42. package/dist/server/plugins/catalog-entities/database/mappers/field-transformations.js +1 -1
  43. package/dist/server/plugins/catalog-entities/database/repositories/utils/create-merged-entity-fields-for-select.d.ts +1 -0
  44. package/dist/server/plugins/catalog-entities/database/repositories/utils/create-merged-entity-fields-for-select.js +8 -8
  45. package/dist/server/plugins/catalog-entities/database/repositories/utils.d.ts +4 -0
  46. package/dist/server/plugins/catalog-entities/database/repositories/utils.js +1 -1
  47. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/arazzo-entities-extractor.js +1 -1
  48. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/asyncapi-entities-extractor.js +1 -1
  49. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/base.d.ts +13 -1
  50. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/base.js +1 -1
  51. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/graphql-entities-extractor.js +2 -2
  52. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/openapi-entities-extractor.js +1 -1
  53. package/dist/server/plugins/catalog-entities/get-server-props.js +1 -1
  54. package/dist/server/plugins/catalog-entities/plugin.js +1 -1
  55. package/dist/server/plugins/catalog-entities/schemas/database-schemas.d.ts +6 -6
  56. package/dist/server/plugins/catalog-entities/schemas/database-schemas.js +1 -1
  57. package/dist/server/plugins/config-parser/index.js +1 -1
  58. package/dist/server/plugins/config-parser/loaders/redocly-config-loader.js +1 -1
  59. package/dist/server/plugins/config-parser/loaders/utils/read-and-validate-config.d.ts +1 -0
  60. package/dist/server/plugins/config-parser/loaders/utils/read-and-validate-config.js +1 -1
  61. package/dist/server/plugins/default-theme/index.js +1 -1
  62. package/dist/server/plugins/dev-onboarding/index.js +1 -1
  63. package/dist/server/plugins/enforce-login/index.d.ts +3 -0
  64. package/dist/server/plugins/enforce-login/index.js +1 -0
  65. package/dist/server/plugins/graphql-docs/spec-download.api.js +1 -1
  66. package/dist/server/plugins/lifecycle.js +2 -2
  67. package/dist/server/plugins/markdown/compiler.d.ts +1 -1
  68. package/dist/server/plugins/markdown/compiler.js +1 -1
  69. package/dist/server/plugins/markdown/get-server-props.js +1 -1
  70. package/dist/server/plugins/markdown/index.js +1 -1
  71. package/dist/server/plugins/markdown/markdoc/partials.js +1 -1
  72. package/dist/server/plugins/markdown/markdown-static-data-loader.js +1 -1
  73. package/dist/server/plugins/markdown/search/get-ai-search-documents.js +10 -10
  74. package/dist/server/plugins/mcp/handlers/docs-mcp-handler.js +1 -1
  75. package/dist/server/plugins/openapi-docs/get-server-props.js +1 -1
  76. package/dist/server/plugins/openapi-docs/index.js +1 -1
  77. package/dist/server/plugins/openapi-docs/load-definition.js +3 -3
  78. package/dist/server/plugins/openapi-docs/search/get-ai-search-documents.js +32 -32
  79. package/dist/server/plugins/openapi-docs/spec-download.api.js +1 -1
  80. package/dist/server/plugins/scorecard-classic/compute-scorecard.js +4 -4
  81. package/dist/server/plugins/scorecard-classic/loaders/scorecard-config.js +1 -1
  82. package/dist/server/plugins/scorecard-classic/loaders/scorecard.js +1 -1
  83. package/dist/server/plugins/search/ai-indexer/prepare-semantic-documents.js +1 -1
  84. package/dist/server/plugins/search/documents/search-documents.js +1 -1
  85. package/dist/server/plugins/search/engines/flexsearch/search-index.js +1 -1
  86. package/dist/server/plugins/search/index.js +1 -1
  87. package/dist/server/plugins/search/llmstxt/index.d.ts +0 -1
  88. package/dist/server/plugins/search/llmstxt/index.js +4 -4
  89. package/dist/server/plugins/sso/index.js +1 -1
  90. package/dist/server/plugins/utils.d.ts +4 -0
  91. package/dist/server/plugins/utils.js +1 -1
  92. package/dist/server/ssr/index.js +1 -1
  93. package/dist/server/store.d.ts +2 -3
  94. package/dist/server/store.js +1 -1
  95. package/dist/server/tools/notifiers/terminal-manager.js +5 -5
  96. package/dist/server/types/plugins/common.d.ts +4 -4
  97. package/dist/server/types/plugins/markdown.d.ts +7 -1
  98. package/dist/server/utils/llmstxt/get-llms-txt-md-path-by-slug.d.ts +19 -0
  99. package/dist/server/utils/llmstxt/get-llms-txt-md-path-by-slug.js +1 -0
  100. package/dist/server/utils/rbac/is-rbac-scope-items.d.ts +3 -0
  101. package/dist/server/utils/rbac/is-rbac-scope-items.js +1 -0
  102. package/dist/server/utils/rbac.js +1 -1
  103. package/dist/server/utils/search/highlight-text-for-search.d.ts +2 -0
  104. package/dist/server/utils/search/highlight-text-for-search.js +1 -0
  105. package/dist/server/web-server/routes/api-routes/api-routes.js +1 -1
  106. package/dist/server/web-server/routes/app-data.js +1 -1
  107. package/dist/server/web-server/routes/ask-ai.js +1 -1
  108. package/dist/server/web-server/routes/auth.d.ts +2 -1
  109. package/dist/server/web-server/routes/auth.js +1 -1
  110. package/dist/server/web-server/routes/catalog/bff-catalog-related-entities.js +1 -1
  111. package/dist/server/web-server/routes/catalog/bff-catalog.js +1 -1
  112. package/dist/server/web-server/routes/catalog/helpers/has-access-to-entity.js +1 -1
  113. package/dist/server/web-server/routes/dynamic-route.js +1 -1
  114. package/dist/server/web-server/routes/feedback.js +1 -1
  115. package/dist/server/web-server/routes/helpers/get-rbac-restrictions-data-for-catalog.js +1 -1
  116. package/dist/server/web-server/routes/page-data.js +1 -1
  117. package/dist/server/web-server/routes/search.js +1 -1
  118. package/dist/server/web-server/routes/static-content.js +1 -1
  119. package/package.json +11 -10
  120. package/dist/server/web-server/routes/helpers/get-md-asset-pathname.d.ts +0 -2
  121. package/dist/server/web-server/routes/helpers/get-md-asset-pathname.js +0 -1
@@ -1 +1 @@
1
- import P from"path";import{lintConfig as C,loadConfig as T,createConfigTypes as A}from"@redocly/openapi-core";import{deepMerge as U}from"../../../../../utils/object/deep-merge.js";import{logger as l}from"../../../../tools/notifiers/logger.js";import{BRANCH_ENV_PREFIX as $}from"../../../../../constants/common.js";import{sanitizeBranchName as L}from"../../../../utils/envs/sanitize-branch-name.js";import{safeParsePartial as E}from"../../safe-parse.js";import{formatConfigProblem as q}from"../../format-error.js";import{ExternalResolver as x}from"../../../../fs/utils/external-ref-resolver.js";import{resolveMutuallyExclusiveProps as B}from"../../resolve-mutual-exclusion.js";function g(o,e,t,r){e in o&&o[e]&&typeof o[e]=="string"&&(/^https?:\/\/.*/.test(o[e])||r(new Error(`Invalid ${t} URL: "${o[e]}". ${t} must start with "http://" or "https://".`)))}function j(o,e){if("access"in o&&o.access&&typeof o.access=="object"){const t=o.access;g(t,"logoutReturnUrl","access.logoutReturnUrl",e),g(t,"residency","access.residency",e);const r=["requiresLogin","logoutReturnUrl","residency","sso","rbac"];for(const n of r)n in t&&t[n]!==void 0&&n in o&&o[n]!==void 0&&e(new Error(`Property '${n}' is defined both at root level and in 'access' object. Please use 'access.${n}' to define this configuration.`))}}async function X(o,e,t,r){const h=e.getFileInfo(o)?.realRelativePath||o;async function d(){const a=new x(e),u=P.join(e.cwd,h),i=await T({configPath:u,externalRefResolver:a}),p=await r(i.resolvedConfig);if(p===void 0)return i.resolvedConfig;const m=[...i.document?.source?await C({config:i,externalConfigTypes:A(p,i)}):[],...i.document?.source?B(i.resolvedConfig,i.document?.source):[]];if(m.length>0)for(const b of m)t(new Error(q(b,e.cwd)));return i.resolvedConfig}const c=await e.exists(o)?await d():{},R=M(c),w=await r(c);g(c,"residency","Residency",t),g(c,"logoutReturnUrl","Logout return URL",t),j(c,t);let f=w?E(w,c):c;const{env:y}=f;if(y){const{envConfig:a}=await import("../../../../config/env-config.js"),u=a.redoclyEnv,i=y[u]||{},p=a.PUBLIC_REDOCLY_BRANCH_NAME||"",v=p?L(p):"",m=v&&y[`${$}${v}`]||{};f=U(f,m,i)}const s=N(f,R);if(s.imports&&s.imports.length>0){l.warn("The 'imports' property is deprecated. Please use 'plugins' property instead.");const a=new Set([...s.plugins||[],...s.imports.map(u=>P.posix.join(u,"plugin.js"))]);s.plugins=Array.from(a),delete s.imports}if(s.catalog&&(l.warn("The 'catalog' property is deprecated. Please use 'catalogClassic' property instead."),s.catalogClassic={...s.catalog},delete s.catalog),s.scorecard&&(l.warn("The 'scorecard' property is deprecated. Please use 'scorecardClassic' property instead."),s.scorecardClassic=s.scorecard,delete s.scorecard),s.search?.ai){l.warn("The 'search.ai' property is deprecated. Please use 'aiAssistant' property instead.");const a={...s.search?.ai,...s.aiAssistant,suggestions:s.aiAssistant?.suggestions?.length?s.aiAssistant.suggestions:s.search?.ai.suggestions||[]};s.aiAssistant=a,delete s.search.ai}return I(s)}function I(o){const e="access"in o?o.access:void 0;if(!e||typeof e!="object")return o;const t={...o},r=[{name:"requiresLogin",type:"boolean"},{name:"logoutReturnUrl",type:"string"},{name:"residency",type:"string"},{name:"sso",type:"string | string[]"},{name:"rbac",type:"object"}],n=[];for(const h of r){const d=h.name;d in t&&t[d]!==void 0&&!(d in e)&&n.push(d)}return n.length>0&&l.warn(`The following properties at root level are deprecated: ${n.join(", ")}. Please move them to the 'access' object.`),"requiresLogin"in e&&e.requiresLogin!==void 0&&(t.requiresLogin=e.requiresLogin),"logoutReturnUrl"in e&&e.logoutReturnUrl!==void 0&&(t.logoutReturnUrl=e.logoutReturnUrl),"residency"in e&&e.residency!==void 0&&(t.residency=e.residency),"sso"in e&&e.sso!==void 0&&(t.sso=e.sso),"rbac"in e&&e.rbac!==void 0&&(t.rbac=e.rbac),delete t.access,t}function M(o){if(!o.theme)return[];l.warn("The 'theme' property in redocly.yaml is deprecated. Please move all of the properties from 'theme' to the root of the config.");const e=[];for(const t of Object.keys(o.theme))o[t]==null?e.push(t):l.warn(`Detected both '${t}' and 'theme.${t}' properties in redocly.yaml. The 'theme.${t}' property will be ignored and needs to be removed or merged into the '${t}'.`);return e}function N(o,e){if(!o.theme||e.length===0)return o;const t={...o};for(const r of e)t[r]=o.theme[r];return delete t.theme,t}export{X as readAndValidateConfig};
1
+ import P from"path";import{lintConfig as b,loadConfig as A,createConfigTypes as T}from"@redocly/openapi-core";import{deepMerge as U}from"../../../../../utils/object/deep-merge.js";import{logger as d}from"../../../../tools/notifiers/logger.js";import{BRANCH_ENV_PREFIX as $}from"../../../../../constants/common.js";import{sanitizeBranchName as x}from"../../../../utils/envs/sanitize-branch-name.js";import{safeParsePartial as L}from"../../safe-parse.js";import{formatConfigProblem as E}from"../../format-error.js";import{ExternalResolver as B}from"../../../../fs/utils/external-ref-resolver.js";import{resolveMutuallyExclusiveProps as j}from"../../resolve-mutual-exclusion.js";function h(e,t,s,n){t in e&&e[t]&&typeof e[t]=="string"&&(/^https?:\/\/.*/.test(e[t])||n(new Error(`Invalid ${s} URL: "${e[t]}". ${s} must start with "http://" or "https://".`)))}function q(e,t){if("access"in e&&e.access&&typeof e.access=="object"){const s=e.access;h(s,"logoutReturnUrl","access.logoutReturnUrl",t),h(s,"residency","access.residency",t);const n=["requiresLogin","logoutReturnUrl","residency","sso","rbac"];for(const c of n)c in s&&s[c]!==void 0&&c in e&&e[c]!==void 0&&t(new Error(`Property '${c}' is defined both at root level and in 'access' object. Please use 'access.${c}' to define this configuration.`))}}async function X(e,t,s,n){const u=t.getFileInfo(e)?.realRelativePath||e;async function a(){const l=new B(t),p=P.join(t.cwd,u),i=await A({configPath:p,externalRefResolver:l}),f=await n(i.resolvedConfig);if(f===void 0)return i.resolvedConfig;const g=[...i.document?.source?await b({config:i,externalConfigTypes:T(f,i)}):[],...i.document?.source?j(i.resolvedConfig,i.document?.source):[]];if(g.length>0)for(const R of g)s(new Error(E(R,t.cwd)));return i.resolvedConfig}const r=await t.exists(e)?await a():{},C=I(r),w=await n(r);h(r,"residency","Residency",s),h(r,"logoutReturnUrl","Logout return URL",s),q(r,s);let m=w?L(w,r):r;const{env:y}=m;if(y){const{envConfig:l}=await import("../../../../config/env-config.js"),p=l.redoclyEnv,i=y[p]||{},f=l.PUBLIC_REDOCLY_BRANCH_NAME||"",v=f?x(f):"",g=v&&y[`${$}${v}`]||{};m=U(m,g,i)}const o=M(m,C);if(o.imports&&o.imports.length>0){d.warn("The 'imports' property is deprecated. Please use 'plugins' property instead.");const l=new Set([...o.plugins||[],...o.imports.map(p=>P.posix.join(p,"plugin.js"))]);o.plugins=Array.from(l),delete o.imports}if(o.catalog&&(d.warn("The 'catalog' property is deprecated. Please use 'catalogClassic' property instead."),o.catalogClassic={...o.catalog},delete o.catalog),o.scorecard&&(d.warn("The 'scorecard' property is deprecated. Please use 'scorecardClassic' property instead."),o.scorecardClassic=o.scorecard,delete o.scorecard),o.search?.ai){d.warn("The 'search.ai' property is deprecated. Please use 'aiAssistant' property instead.");const l={...o.search?.ai,...o.aiAssistant,suggestions:o.aiAssistant?.suggestions?.length?o.aiAssistant.suggestions:o.search?.ai.suggestions||[]};o.aiAssistant=l,delete o.search.ai}return k(o)}function k(e){const t={...e},n={..."access"in e&&e.access&&typeof e.access=="object"?e.access:{}},c=["requiresLogin","logoutReturnUrl","residency","sso","rbac"],u=[];for(const a of c){const r=t[a];r!==void 0&&(u.push(a),a==="requiresLogin"&&n.requiresLogin===void 0&&(n.requiresLogin=r),a==="logoutReturnUrl"&&n.logoutReturnUrl===void 0&&(n.logoutReturnUrl=r),a==="residency"&&n.residency===void 0&&(n.residency=r),a==="sso"&&n.sso===void 0&&(n.sso=r),a==="rbac"&&n.rbac===void 0&&(n.rbac=r),delete t[a])}return u.length>0&&d.warn(`The following properties at root level are deprecated: ${u.join(", ")}. Please move them to the 'access' object.`),Object.keys(n).length>0&&(t.access=n),t}function I(e){if(!e.theme)return[];d.warn("The 'theme' property in redocly.yaml is deprecated. Please move all of the properties from 'theme' to the root of the config.");const t=[];for(const s of Object.keys(e.theme))e[s]==null?t.push(s):d.warn(`Detected both '${s}' and 'theme.${s}' properties in redocly.yaml. The 'theme.${s}' property will be ignored and needs to be removed or merged into the '${s}'.`);return t}function M(e,t){if(!e.theme||t.length===0)return e;const s={...e};for(const n of t)s[n]=e.theme[n];return delete s.theme,s}export{k as ensureAccessBackwardsCompatibility,X as readAndValidateConfig};
@@ -1 +1 @@
1
- import{REDOCLY_TEAMS_RBAC as c}from"@redocly/config";import{DEV_LOGIN_SLUG as g,INVITE_SLUG as h,PUBLIC_RBAC_SCOPE_ITEM as m,UI_ACCESSIBLE_CONFIG_PROPS as P,CONFIG_FILE_NAME as n,DEFAULT_SSO_IDP_TITLE as _}from"../../../constants/common.js";import{envConfig as T}from"../../config/env-config.js";import{getTemplatePath as s}from"./get-template-path.js";import{resolveLinksFromConfig as p}from"../nav-utils.js";import{resolveLogoConfig as F}from"./resolve-logo.js";import{extractTeamNames as E}from"./extract-team-names.js";import{resolveProductsConfig as O}from"./resolve-products-config.js";import{getExcludedFromLinkCheckerPatterns as y}from"../sidebars/utils.js";import{resolveEntitiesCatalogConfig as A}from"./resolve-catalog-entities.js";import{telemetryTraceStep as j}from"../../../cli/telemetry/helpers/trace-step.js";async function q(r){return{id:"Default Theme",async processContent(e){await j("build.plugin.default_theme",async()=>{const t=v(e),o=Object.keys(e.getConfig()?.ssoDirect||{}).length>0,a=e.createTemplate("invite",s("../../../../dist/client/app/pages/Invite/Invite.js"));if(e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,excludeFromSearch:!0,slug:h,[c]:m,fsPath:h,templateId:a}),r.devLogin&&o){const i={frontmatter:{},seo:{title:"Login page"},authIdps:S(t),rbac:{teams:E(e.getConfig().rbac)}},l=e.createTemplate("dev-login",s("../../../../dist/client/app/pages/DevLogin/DevLogin.js"));e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,excludeFromSearch:!0,slug:g,[c]:m,fsPath:g,templateId:l,getStaticData:async()=>({props:i})})}else if(t.length>1){const i={frontmatter:{},seo:{title:"Login page"},authIdps:S(t)},l=e.createTemplate("login",s("../../../../dist/client/app/pages/Login/Login.js"));e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,slug:g,[c]:m,fsPath:g,templateId:l,getStaticData:async()=>({props:i})})}e.createTemplate("404",s("../../../../dist/client/app/pages/404/404.js")),e.createTemplate("403",s("../../../../dist/client/app/pages/403/403.js")),e.createTemplate("403OIDC",s("../../../../dist/client/app/pages/403/403OIDC.js")),T.isDevelopMode&&e.createTemplate("compilation-error",s("../../../../dist/client/app/pages/CompilationError/CompilationError.js"))})},async afterRoutesCreated(e,t){const{contentDir:o,outdir:a}=e,i=e.getConfig(),{navbar:l,footer:D,userMenu:u,search:f,breadcrumbs:I,products:b}=i,C=Object.keys(i?.ssoDirect||{}).length>0,d=y(i),L={navFile:n,excludedFromLinkCheckerPatterns:d};e.setGlobalData({...k(i),navbar:await p(l,o,e,t,L),footer:await p(D,o,e,t,L),breadcrumbs:{...I,prefixItems:await p(I?.prefixItems||[],o,e,t,{navFile:n,excludedFromLinkCheckerPatterns:d})},userMenu:{...u,hide:u?.hide??!C,menu:await p(u?.items,o,e,t,{navFile:n,excludedFromLinkCheckerPatterns:d})},logo:await F(i.logo,n,a,t.fs),auth:{idpsInfo:v(e),devLogin:r.devLogin&&C},products:await O(b,e,t),search:{...f,suggestedPages:await p(f?.suggestedPages,o,e,t,{navFile:n,excludedFromLinkCheckerPatterns:d})},entitiesCatalog:await A(i.entitiesCatalog,n,a,t.fs),headScriptTags:void 0,linkTags:void 0,postBodyScriptTags:void 0,preBodyScriptTags:void 0})}}}function v(r){const e=r.getConfig().ssoDirect;return Object.entries(e||{}).map(([o,a])=>({idpId:o,type:a.type,title:a.title}))}function S(r){return T.LOCALHOST_LOGIN==="true"?r:r.filter(t=>t.title!==_)}function k(r){const e={};for(const t of P)r[t]&&(e[t]=r[t]);return e}export{q as defaultThemePlugin,k as pickUiAccessibleConfig};
1
+ import{REDOCLY_TEAMS_RBAC as c}from"@redocly/config";import{DEV_LOGIN_SLUG as g,INVITE_SLUG as h,PUBLIC_RBAC_SCOPE_ITEM as m,UI_ACCESSIBLE_CONFIG_PROPS as P,CONFIG_FILE_NAME as n,DEFAULT_SSO_IDP_TITLE as _}from"../../../constants/common.js";import{envConfig as T}from"../../config/env-config.js";import{getTemplatePath as s}from"./get-template-path.js";import{resolveLinksFromConfig as p}from"../nav-utils.js";import{resolveLogoConfig as F}from"./resolve-logo.js";import{extractTeamNames as E}from"./extract-team-names.js";import{resolveProductsConfig as O}from"./resolve-products-config.js";import{getExcludedFromLinkCheckerPatterns as y}from"../sidebars/utils.js";import{resolveEntitiesCatalogConfig as A}from"./resolve-catalog-entities.js";import{telemetryTraceStep as j}from"../../../cli/telemetry/helpers/trace-step.js";async function q(r){return{id:"Default Theme",async processContent(e){await j("build.plugin.default_theme",async()=>{const t=v(e),i=Object.keys(e.getConfig()?.ssoDirect||{}).length>0,o=e.createTemplate("invite",s("../../../../dist/client/app/pages/Invite/Invite.js"));if(e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,excludeFromSearch:!0,slug:h,[c]:m,fsPath:h,templateId:o}),r.devLogin&&i){const a={frontmatter:{},seo:{title:"Login page"},authIdps:S(t),rbac:{teams:E(e.getConfig().access?.rbac)}},l=e.createTemplate("dev-login",s("../../../../dist/client/app/pages/DevLogin/DevLogin.js"));e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,excludeFromSearch:!0,slug:g,[c]:m,fsPath:g,templateId:l,getStaticData:async()=>({props:a})})}else if(t.length>1){const a={frontmatter:{},seo:{title:"Login page"},authIdps:S(t)},l=e.createTemplate("login",s("../../../../dist/client/app/pages/Login/Login.js"));e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,slug:g,[c]:m,fsPath:g,templateId:l,getStaticData:async()=>({props:a})})}e.createTemplate("404",s("../../../../dist/client/app/pages/404/404.js")),e.createTemplate("403",s("../../../../dist/client/app/pages/403/403.js")),e.createTemplate("403OIDC",s("../../../../dist/client/app/pages/403/403OIDC.js")),T.isDevelopMode&&e.createTemplate("compilation-error",s("../../../../dist/client/app/pages/CompilationError/CompilationError.js"))})},async afterRoutesCreated(e,t){const{contentDir:i,outdir:o}=e,a=e.getConfig(),{navbar:l,footer:D,userMenu:u,search:f,breadcrumbs:I,products:b}=a,C=Object.keys(a?.ssoDirect||{}).length>0,d=y(a),L={navFile:n,excludedFromLinkCheckerPatterns:d};e.setGlobalData({...k(a),navbar:await p(l,i,e,t,L),footer:await p(D,i,e,t,L),breadcrumbs:{...I,prefixItems:await p(I?.prefixItems||[],i,e,t,{navFile:n,excludedFromLinkCheckerPatterns:d})},userMenu:{...u,hide:u?.hide??!C,menu:await p(u?.items,i,e,t,{navFile:n,excludedFromLinkCheckerPatterns:d})},logo:await F(a.logo,n,o,t.fs),auth:{idpsInfo:v(e),devLogin:r.devLogin&&C},products:await O(b,e,t),search:{...f,suggestedPages:await p(f?.suggestedPages,i,e,t,{navFile:n,excludedFromLinkCheckerPatterns:d})},entitiesCatalog:await A(a.entitiesCatalog,n,o,t.fs),headScriptTags:void 0,linkTags:void 0,postBodyScriptTags:void 0,preBodyScriptTags:void 0})}}}function v(r){const e=r.getConfig().ssoDirect;return Object.entries(e||{}).map(([i,o])=>({idpId:i,type:o.type,title:o.title}))}function S(r){return T.LOCALHOST_LOGIN==="true"?r:r.filter(t=>t.title!==_)}function k(r){const e={};for(const t of P)r[t]&&(e[t]=r[t]);return e}export{q as defaultThemePlugin,k as pickUiAccessibleConfig};
@@ -1 +1 @@
1
- import{REDOCLY_TEAMS_RBAC as r}from"@redocly/config";import{getTemplatePath as l}from"./get-template-path.js";import{getDevOnboardingRbacConfig as o}from"./utils.js";import{telemetryTraceStep as u}from"../../../cli/telemetry/helpers/trace-step.js";const c="apigee-";async function f({contentDir:d}){return{id:"Developer Onboarding",requiredEntitlements:["devOnboarding"],async processContent(e,{getConfig:t}){await u("build.plugin.dev_onboarding",async()=>{const a=await t();if(!a.developerOnboarding)return;const n=e.createTemplate(c,l("./template/index.js"));e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,slug:"/apps/",fsPath:"",templateId:n,hasClientRoutes:!0,[r]:a?.rbac&&o(a?.rbac),getNavText:()=>Promise.resolve("My Apps"),getStaticData:async()=>({props:{proxyUrl:"https://api.enterprise.apigee.com/v1/organizations/ORGNAME/apis",seo:{title:"My Apps"}}})})})},async afterRoutesCreated(e){const t=e.getConfig();if(!t.developerOnboarding)return;const n=e.getGlobalData().userMenu||{},i={type:"link",link:"/apps/",label:"My Apps",[r]:t?.rbac&&o(t?.rbac),labelTranslationKey:"userMenu.devOnboardingLabel"},s=n?.menu||[],p={...n,menu:[...s,i]};e.setGlobalData({userMenu:p})}}}export{f as apiKeyMgmtPlugin};
1
+ import{REDOCLY_TEAMS_RBAC as o}from"@redocly/config";import{getTemplatePath as c}from"./get-template-path.js";import{getDevOnboardingRbacConfig as s}from"./utils.js";import{telemetryTraceStep as u}from"../../../cli/telemetry/helpers/trace-step.js";const d="apigee-";async function y({contentDir:g}){return{id:"Developer Onboarding",requiredEntitlements:["devOnboarding"],async processContent(e,{getConfig:n}){await u("build.plugin.dev_onboarding",async()=>{const t=await n();if(!t.developerOnboarding)return;const r=t.access?.rbac,a=e.createTemplate(d,c("./template/index.js"));e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,slug:"/apps/",fsPath:"",templateId:a,hasClientRoutes:!0,[o]:r?s(r):void 0,getNavText:()=>Promise.resolve("My Apps"),getStaticData:async()=>({props:{proxyUrl:"https://api.enterprise.apigee.com/v1/organizations/ORGNAME/apis",seo:{title:"My Apps"}}})})})},async afterRoutesCreated(e){const n=e.getConfig();if(!n.developerOnboarding)return;const t=n.access?.rbac,a=e.getGlobalData().userMenu||{},i={type:"link",link:"/apps/",label:"My Apps",[o]:t?s(t):void 0,labelTranslationKey:"userMenu.devOnboardingLabel"},p=a?.menu||[],l={...a,menu:[...p,i]};e.setGlobalData({userMenu:l})}}}export{y as apiKeyMgmtPlugin};
@@ -0,0 +1,3 @@
1
+ import type { LifecyclePluginInstance, PluginOptions } from '../../types';
2
+ export declare function enforceLoginPlugin(_opts: PluginOptions): Promise<LifecyclePluginInstance>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ import{envConfig as o}from"../../config/env-config.js";async function i(r){return{id:"enforce-login",async processContent(n){if(o.REDOCLY_ENFORCE_LOGIN!=="true")return;const e=n.getConfig();n.setGlobalConfig({access:{...e.access,requiresLogin:!0,rbac:{}}})}}}export{i as enforceLoginPlugin};
@@ -1 +1 @@
1
- import l from"node:path";import{readFile as u,existsSync as d}from"node:fs";import{promisify as h}from"node:util";import{PUBLIC_API_DEFINITIONS_FOLDER as A}from"../../constants/common.js";import{GRAPHQL_SPEC_SLUG as R}from"../../../constants/common";import{canDownloadApiDefinition as w}from"../../utils/rbac.js";const F=h(u);async function D(s,e,r){const{isAuthenticated:n,teams:i,claims:{email:a}}=e.user,o=new URL(s.url),c=decodeURIComponent(o.pathname.replace(R,"")),{rbac:p={},requiresLogin:m=!1}=e.config;if(!w(o.pathname,p,m,{isAuthenticated:n,email:a,teams:i}))return new Response("Unauthorized",{status:n?403:401});const t=l.join(r.props?.outdir??"",A,c);if(!d(t))return new Response("Not found",{status:404});const f=await F(t,"utf-8");return new Response(f,{headers:{"Content-Type":"application/graphql"}})}export{D as default};
1
+ import l from"node:path";import{readFile as d,existsSync as h}from"node:fs";import{promisify as A}from"node:util";import{PUBLIC_API_DEFINITIONS_FOLDER as L}from"../../constants/common.js";import{GRAPHQL_SPEC_SLUG as R}from"../../../constants/common";import{canDownloadApiDefinition as w}from"../../utils/rbac.js";const F=A(d);async function q(r,e,i){const{isAuthenticated:n,teams:a,claims:{email:c}}=e.user,o=new URL(r.url),p=decodeURIComponent(o.pathname.replace(R,"")),s=e.config.access??{},m=s.rbac??{},f=s.requiresLogin??!1;if(!w(o.pathname,m,f,{isAuthenticated:n,email:c,teams:a}))return new Response("Unauthorized",{status:n?403:401});const t=l.join(i.props?.outdir??"",L,p);if(!h(t))return new Response("Not found",{status:404});const u=await F(t,"utf-8");return new Response(u,{headers:{"Content-Type":"application/graphql"}})}export{q as default};
@@ -1,2 +1,2 @@
1
- import x from"@redocly/portal-plugin-mock-server";import B from"path";import{REDOCLY_ROUTE_RBAC as O}from"@redocly/config";import{combineUrls as v,withPathPrefix as N}from"@redocly/theme/core/utils";import{VERSION_SEPARATOR as L}from"../constants/common.js";import{removeTrailingSlash as F}from"../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as V}from"../../utils/url/remove-leading-slash.js";import{isTruthy as j}from"../../utils/guards/is-truthy.js";import{normalizeRouteSlug as T}from"../../utils/path/normalize-route-slug.js";import{slash as k}from"../../utils/path/slash.js";import{parsePathVersions as $}from"../../utils/path/parse-path-versions.js";import{reporter as E}from"../tools/notifiers/reporter.js";import{logger as P}from"../tools/notifiers/logger.js";import{envConfig as A}from"../config/env-config.js";import{shaDirPathShort as z}from"../utils/crypto/sha-dir-path-short.js";import{customPagesPlugin as M}from"../../server/plugins/pages/index.js";import{openAPIDocsPlugin as q}from"../../server/plugins/openapi-docs/index.js";import{asyncAPIDocsPlugin as I}from"../../server/plugins/asyncapi-docs/index.js";import{configParserPlugin as U}from"./config-parser/index.js";import{markdownPlugin as G}from"./markdown/index.js";import{generateBrowserPluginsModule as W,generateClientRoutes as K,generateTemplatesModule as H}from"../esbuild/generate.js";import{graphqlDocsPlugin as Y}from"./graphql-docs/index.js";import{searchPlugin as J}from"./search/index.js";import{defaultThemePlugin as Q}from"./default-theme/index.js";import{apiKeyMgmtPlugin as X}from"./dev-onboarding/index.js";import{apiFunctionsPlugin as Z}from"./api-functions/index.js";import{scorecardClassicPlugin as ee}from"./scorecard-classic/index.js";import{lintPlugin as te}from"./lint/index.js";import{resolveExternalPlugins as oe}from"../external-plugins/resolve-external-plugins.js";import{sidebarsPlugin as ie}from"./sidebars/index.js";import{l10nPlugin as ne}from"./l10n/index.js";import{analyticsPlugins as re}from"./analytics/index.js";import{sitemapPlugin as se}from"./sitemap/index.js";import{entitlementsPlugin as ae}from"./entitlements/index.js";import{getBilledPagesCount as le,slug as ce}from"../utils/index.js";import{telemetry as ue}from"../../cli/telemetry/index.js";import{telemetryTraceStep as b}from"../../cli/telemetry/helpers/trace-step.js";import{EntitlementsProvider as D}from"../entitlements/entitlements-provider.js";import{ssoPlugin as fe}from"./sso/index.js";import{Cache as me}from"../fs/cache.js";import{ContentFs as de}from"../fs/content-fs.js";import{findProductBySlug as ge}from"../utils/product.js";import{parseBaseName as pe}from"./utils.js";import{isRouteReserved as Pe}from"./get-reserved-routes.js";import{catalogClassicPlugin as he}from"./catalog-classic/index.js";import{arazzoDocsPlugin as ye}from"./arazzo-docs/index.js";const Ce=[U,fe,Q,ne,G,q,I,ye,ee,te,Z,M,Y,X,he,{importPath:"./catalog-entities/plugin.js",loadCondition:()=>A.NEW_CATALOG_ENABLED==="true"},{importPath:"./scorecards/plugin.js",loadCondition:()=>A.NEW_SCORECARDS_ENABLED==="true"},{importPath:"./mcp/index.js",loadCondition:()=>D.instance().canAccessFeature("mcp")},ie,se,ae,J,x,...re];async function pt(o,t=Ce){return await b("build.plugins_init",async()=>{const n=[],w=D.instance(),h={};for(const f of t){let a;if("loadCondition"in f){if(!f.loadCondition())continue;const e=await import(f.importPath);if(!e.default||typeof e.default!="function"){await E.panicOnBuild(`Dynamic plugin ${f.importPath} does not export a default export or it is not a function`);continue}a=e.default}else a=f;const d=await a(o);for(const[e,i]of Object.entries(d.loaders||{}))h[e]&&await E.panicOnBuild(`Duplicate loader with name ${e}`),h[e]=i;(!d.requiredEntitlements||d.requiredEntitlements?.every(e=>w.canAccessFeature(e)))&&n.push(d)}const s=new de(o.contentDir);await s.ready;const u=new me(s);return u.setLoaders(h),P.verbose("All plugins instantiated"),{pluginInstances:n,lifecycleContext:ve(s,u)}})}function _(o){P.verbose("Generating templates"),b("build.write_client_entries",()=>{H(o),W(o),K(o)})}async function we(o){const t=o.getAllRoutes();le(t)||await E.panicOnBuild("No routes created by plugins. Please check your project configuration.")}async function Pt(o,t,n,w={}){const h=D.instance();try{await b("build.plugins_run",async()=>{t.startPluginsRun();let s=[];await b("build.plugins_process_content",async a=>{for(const e of o){const i=P.startTiming();await e.processContent?.(t,n),P.verboseTime(i,`processContent for ${e.id}`)}s=(await oe(t.contentDir,t.config.plugins)).map(e=>e.lifecyclePlugin).filter(e=>j(e)&&(!e.requiredEntitlements||e.requiredEntitlements?.every(i=>h.canAccessFeature(i)))),n.cache.setLoaders(Object.fromEntries(s.flatMap(e=>Object.entries(e.loaders||{}))));for(const e of s){const i=P.startTiming();await e.processContent?.(t,n),P.verboseTime(i,`processContent for ${e.id}`)}a?.setAttribute("externalPluginsProcessed",s.length.toString())});const u=await Re(t,n),f=[...o,...s];_(t),A.isDevelopMode?await t.userCodeReady:t.buildRevision++,await b("build.plugins_after_routes_created",async()=>{for(const a of f){const d=P.startTiming();await a.afterRoutesCreated?.(t,u),P.verboseTime(d,`afterRoutesCreated for ${a.id}`)}}),await t.reportUnsetEnvVars(),await we(t),_(t)})}catch(s){const u="Unhandled error in plugin. "+s.message+`
2
- `+s.stack;ue.sendCliErrorCaughtMessage({message:u}),w.failFast?await E.panic(u):await E.panicOnBuild(u)}finally{t.finishPluginsRun()}}async function Re(o,t){const{cache:n,fs:w}=t,h=await t.getConfig(),s=Object.values(h.products||{}),u=(await n.load("versions-config","versions-config")).data,f=(await n.load("content-slugs","content-slugs")).data;for(const{duplicateInAllLocales:e,slugSuffix:i,sharedData:y=[],redirectFrom:C=[],...l}of o.newRoutes){const c=T(l.slug?l.slug:a(l.fsPath)),g=F(i?v(c,i):c),r={...l,[O]:{slug:g,fsPath:l.fsPath},slug:g,baseSlug:c,versions:d(l.fsPath,i),product:ge(s,g,a)};Pe(g,h)&&await E.panicOnBuildContentError(`Route "${g}" is reserved and cannot be used. Please choose a different slug for "${l.fsPath}".`),o.routesByFsPath.set(r.fsPath,r.slug),o.routesBySlug.set(r.slug,r);for(const{key:p,id:m}of y)o.addRouteSharedData(r.slug,p,m);for(const p of C)o.addRedirect(p.from,{type:p.type,to:r.slug});if(e)for(const p of w.localeFolders){const m={...r,slug:"/"+p.toLowerCase()+r.slug};o.routesByFsPath.set(m.fsPath,m.slug),o.routesBySlug.set(m.slug,m);for(const{key:R,id:S}of y)o.addRouteSharedData(m.slug,R,S);for(const R of C){const S=v(w.localizationFolder,p,R.from);o.addRedirect(S,{type:R.type,to:m.slug})}}}return o.newRoutes=[],{...t,slugify:a};function a(e){const i=k(e).replace(new RegExp("^(@i18n|@l10n)\\/"),""),y=f.fileSlugs.get(i)||f.dirSlugs.get(F(i));if(y)return y;const{baseName:C,isIndexFile:l}=pe(e);let c=B.dirname(e.replace(new RegExp("^(@i18n|@l10n)\\/"),""));return c=c==="."?"/":c,v("/",ce(l?c:v(c,C)),"/")}function d(e,i=""){const y=$(e);if(!y?.versionName)return;const{versionFolderPath:C,filePathInVersion:l,versionName:c}=y,g=u.get(C);if(g)return g.versions.map(r=>{const p=g.defaultVersion===r.version,m=V(v(C,L+r.version,l)),R=a(m);return{version:r.version,label:r.name||r.version,link:T(v(R,i)),default:p,active:c===r.version,folderId:z(`${C}`)}})}}function ve(o,t){return{fs:o,cache:t,getConfig:async(n=".")=>(await t.load(n,"nearest-redocly-config",o.localeFolders)).data,isPathIgnored:async n=>(await t.load(n,"is-ignored")).data,withPathPrefix:N,logger:P}}export{Ce as INTERNAL_PLUGINS,ve as createLifecycleContext,pt as initPlugins,Pt as runPlugins,_ as writeClientEntries};
1
+ import x from"@redocly/portal-plugin-mock-server";import B from"path";import{REDOCLY_ROUTE_RBAC as O}from"@redocly/config";import{combineUrls as v,withPathPrefix as N}from"@redocly/theme/core/utils";import{VERSION_SEPARATOR as L}from"../constants/common.js";import{removeTrailingSlash as F}from"../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as V}from"../../utils/url/remove-leading-slash.js";import{isTruthy as j}from"../../utils/guards/is-truthy.js";import{normalizeRouteSlug as T}from"../../utils/path/normalize-route-slug.js";import{slash as k}from"../../utils/path/slash.js";import{parsePathVersions as $}from"../../utils/path/parse-path-versions.js";import{reporter as E}from"../tools/notifiers/reporter.js";import{logger as P}from"../tools/notifiers/logger.js";import{envConfig as A}from"../config/env-config.js";import{shaDirPathShort as z}from"../utils/crypto/sha-dir-path-short.js";import{customPagesPlugin as M}from"../../server/plugins/pages/index.js";import{openAPIDocsPlugin as q}from"../../server/plugins/openapi-docs/index.js";import{asyncAPIDocsPlugin as I}from"../../server/plugins/asyncapi-docs/index.js";import{configParserPlugin as U}from"./config-parser/index.js";import{markdownPlugin as G}from"./markdown/index.js";import{generateBrowserPluginsModule as W,generateClientRoutes as K,generateTemplatesModule as H}from"../esbuild/generate.js";import{graphqlDocsPlugin as Y}from"./graphql-docs/index.js";import{searchPlugin as J}from"./search/index.js";import{defaultThemePlugin as Q}from"./default-theme/index.js";import{apiKeyMgmtPlugin as X}from"./dev-onboarding/index.js";import{apiFunctionsPlugin as Z}from"./api-functions/index.js";import{scorecardClassicPlugin as ee}from"./scorecard-classic/index.js";import{lintPlugin as te}from"./lint/index.js";import{resolveExternalPlugins as oe}from"../external-plugins/resolve-external-plugins.js";import{sidebarsPlugin as ie}from"./sidebars/index.js";import{l10nPlugin as ne}from"./l10n/index.js";import{analyticsPlugins as re}from"./analytics/index.js";import{sitemapPlugin as se}from"./sitemap/index.js";import{entitlementsPlugin as ae}from"./entitlements/index.js";import{getBilledPagesCount as le,slug as ce}from"../utils/index.js";import{telemetry as ue}from"../../cli/telemetry/index.js";import{telemetryTraceStep as b}from"../../cli/telemetry/helpers/trace-step.js";import{EntitlementsProvider as D}from"../entitlements/entitlements-provider.js";import{enforceLoginPlugin as fe}from"./enforce-login/index.js";import{ssoPlugin as me}from"./sso/index.js";import{Cache as de}from"../fs/cache.js";import{ContentFs as ge}from"../fs/content-fs.js";import{findProductBySlug as pe}from"../utils/product.js";import{parseBaseName as Pe}from"./utils.js";import{isRouteReserved as he}from"./get-reserved-routes.js";import{catalogClassicPlugin as ye}from"./catalog-classic/index.js";import{arazzoDocsPlugin as Ce}from"./arazzo-docs/index.js";const we=[U,fe,me,Q,ne,G,q,I,Ce,ee,te,Z,M,Y,X,ye,{importPath:"./catalog-entities/plugin.js",loadCondition:()=>A.NEW_CATALOG_ENABLED==="true"},{importPath:"./scorecards/plugin.js",loadCondition:()=>A.NEW_SCORECARDS_ENABLED==="true"},{importPath:"./mcp/index.js",loadCondition:()=>D.instance().canAccessFeature("mcp")},ie,se,ae,J,x,...re];async function ht(o,t=we){return await b("build.plugins_init",async()=>{const n=[],w=D.instance(),h={};for(const f of t){let a;if("loadCondition"in f){if(!f.loadCondition())continue;const e=await import(f.importPath);if(!e.default||typeof e.default!="function"){await E.panicOnBuild(`Dynamic plugin ${f.importPath} does not export a default export or it is not a function`);continue}a=e.default}else a=f;const d=await a(o);for(const[e,i]of Object.entries(d.loaders||{}))h[e]&&await E.panicOnBuild(`Duplicate loader with name ${e}`),h[e]=i;(!d.requiredEntitlements||d.requiredEntitlements?.every(e=>w.canAccessFeature(e)))&&n.push(d)}const s=new ge(o.contentDir);await s.ready;const u=new de(s);return u.setLoaders(h),P.verbose("All plugins instantiated"),{pluginInstances:n,lifecycleContext:Ee(s,u)}})}function _(o){P.verbose("Generating templates"),b("build.write_client_entries",()=>{H(o),W(o),K(o)})}async function Re(o){const t=o.getAllRoutes();le(t)||await E.panicOnBuild("No routes created by plugins. Please check your project configuration.")}async function yt(o,t,n,w={}){const h=D.instance();try{await b("build.plugins_run",async()=>{t.startPluginsRun();let s=[];await b("build.plugins_process_content",async a=>{for(const e of o){const i=P.startTiming();await e.processContent?.(t,n),P.verboseTime(i,`processContent for ${e.id}`)}s=(await oe(t.contentDir,t.config.plugins)).map(e=>e.lifecyclePlugin).filter(e=>j(e)&&(!e.requiredEntitlements||e.requiredEntitlements?.every(i=>h.canAccessFeature(i)))),n.cache.setLoaders(Object.fromEntries(s.flatMap(e=>Object.entries(e.loaders||{}))));for(const e of s){const i=P.startTiming();await e.processContent?.(t,n),P.verboseTime(i,`processContent for ${e.id}`)}a?.setAttribute("externalPluginsProcessed",s.length.toString())});const u=await ve(t,n),f=[...o,...s];_(t),A.isDevelopMode?await t.userCodeReady:t.buildRevision++,await b("build.plugins_after_routes_created",async()=>{for(const a of f){const d=P.startTiming();await a.afterRoutesCreated?.(t,u),P.verboseTime(d,`afterRoutesCreated for ${a.id}`)}}),await t.reportUnsetEnvVars(),await Re(t),_(t)})}catch(s){const u="Unhandled error in plugin. "+s.message+`
2
+ `+s.stack;ue.sendCliErrorCaughtMessage({message:u}),w.failFast?await E.panic(u):await E.panicOnBuild(u)}finally{t.finishPluginsRun()}}async function ve(o,t){const{cache:n,fs:w}=t,h=await t.getConfig(),s=Object.values(h.products||{}),u=(await n.load("versions-config","versions-config")).data,f=(await n.load("content-slugs","content-slugs")).data;for(const{duplicateInAllLocales:e,slugSuffix:i,sharedData:y=[],redirectFrom:C=[],...l}of o.newRoutes){const c=T(l.slug?l.slug:a(l.fsPath)),g=F(i?v(c,i):c),r={...l,[O]:{slug:g,fsPath:l.fsPath},slug:g,baseSlug:c,versions:d(l.fsPath,i),product:pe(s,g,a)};he(g,h)&&await E.panicOnBuildContentError(`Route "${g}" is reserved and cannot be used. Please choose a different slug for "${l.fsPath}".`),o.routesByFsPath.set(r.fsPath,r.slug),o.routesBySlug.set(r.slug,r);for(const{key:p,id:m}of y)o.addRouteSharedData(r.slug,p,m);for(const p of C)o.addRedirect(p.from,{type:p.type,to:r.slug});if(e)for(const p of w.localeFolders){const m={...r,slug:"/"+p.toLowerCase()+r.slug};o.routesByFsPath.set(m.fsPath,m.slug),o.routesBySlug.set(m.slug,m);for(const{key:R,id:S}of y)o.addRouteSharedData(m.slug,R,S);for(const R of C){const S=v(w.localizationFolder,p,R.from);o.addRedirect(S,{type:R.type,to:m.slug})}}}return o.newRoutes=[],{...t,slugify:a};function a(e){const i=k(e).replace(new RegExp("^(@i18n|@l10n)\\/"),""),y=f.fileSlugs.get(i)||f.dirSlugs.get(F(i));if(y)return y;const{baseName:C,isIndexFile:l}=Pe(e);let c=B.dirname(e.replace(new RegExp("^(@i18n|@l10n)\\/"),""));return c=c==="."?"/":c,v("/",ce(l?c:v(c,C)),"/")}function d(e,i=""){const y=$(e);if(!y?.versionName)return;const{versionFolderPath:C,filePathInVersion:l,versionName:c}=y,g=u.get(C);if(g)return g.versions.map(r=>{const p=g.defaultVersion===r.version,m=V(v(C,L+r.version,l)),R=a(m);return{version:r.version,label:r.name||r.version,link:T(v(R,i)),default:p,active:c===r.version,folderId:z(`${C}`)}})}}function Ee(o,t){return{fs:o,cache:t,getConfig:async(n=".")=>(await t.load(n,"nearest-redocly-config",o.localeFolders)).data,isPathIgnored:async n=>(await t.load(n,"is-ignored")).data,withPathPrefix:N,logger:P}}export{we as INTERNAL_PLUGINS,Ee as createLifecycleContext,ht as initPlugins,yt as runPlugins,_ as writeClientEntries};
@@ -35,7 +35,7 @@ export declare function resolveAndValidateMarkdoc(parsedAstChunk: ParsedAstChunk
35
35
  export declare function getAst(relativePath: string, rawContent: string): ParsedAstChunk;
36
36
  export declare function extractMdFirstHeading(relativePath: string, context: LifecycleContext): Promise<string | undefined>;
37
37
  export declare function validateAllMarkdowns(store: Store, context?: LifecycleContext): Promise<void>;
38
- export declare function parseAndResolveMarkdoc(input: MarkdownParseInput, markdocOpts: Config | undefined, rootContext: MarkdocResolveContext): Promise<import("../../types").LoadResult<{
38
+ export declare function parseAndResolveMarkdoc(input: MarkdownParseInput, markdocOpts: Config | undefined, rootContext: MarkdocResolveContext, resource?: string): Promise<import("../../types").LoadResult<{
39
39
  ast: Node;
40
40
  info: MarkdocInfo;
41
41
  }>>;
@@ -1 +1 @@
1
- import L from"@markdoc/markdoc";import*as M from"path";import{GATED_MARKDOC_TAGS as O}from"../../constants/entitlements.js";import{logger as F}from"../../tools/notifiers/logger.js";import{reporter as N}from"../../tools/notifiers/reporter.js";import{sha1 as j}from"../../utils/crypto/sha1.js";import{formatMarkdocError as H}from"./errors.js";import{extractFirstHeading as x,visit as K}from"./markdoc/plugins/utils.js";import{attributeResolvers as y}from"./attribute-resolvers/index.js";import{MdResolveError as $}from"./attribute-resolvers/md-resolve-error.js";import{processHtmlTokens as U}from"./html/process-html-tokens.js";import{resolveRawPartials as W}from"./markdoc/resolve-raw-partials.js";import{EntitlementsProvider as Y}from"../../entitlements/entitlements-provider.js";import{MARKDOC_PARTIALS_DEPS_KEY as B}from"../../store.js";import{getLinkOriginalAttrName as V}from"./attribute-resolvers/utils.js";const q="EMPTY";async function C(a,s,e){const c=Y.instance(),{actions:g}=e,{relativePath:o,resolveErrors:S}=a,f=new Set,u=new Set,l=new Set,w=new Set,n={},k=new Set,b={},_={};function E(t,P){const D=P||q;t[D]=(t[D]||0)+1}const A=[];return a.resolveErrors.length=0,K(a.ast,t=>{const P=D();A.push(P.then(r=>{r?.sharedDataIds&&r.sharedDataIds.forEach(d=>f.add(d))}).catch(G));async function D(){const r=[];switch(t.type){case"fence":E(b,t.attributes.language);break;case"link":case"image":await y.nativeMdLink(t,t.type==="link"?"href":"src",o,e);break;case"tag":if(!t.tag)break;const d=s?.tags?.[t.tag];if(!d){O[t.tag]&&!c.canAccessFeature(O[t.tag])&&(t.errors.push({level:"warning",id:"invalid-tag",message:`Undefined tag: ${t.tag}`}),t.tag="",t.type="error",t.attributes={});break}const p=t.tag==="html"?t.attributes.name:t.tag;if((t.tag==="html"?k:w).add(p),n[p]=(n[p]||0)+1,p==="code-snippet"&&E(b,t.attributes.language),d.attributes?.__idx&&(t.attributes.__idx=n[t.tag]),d.dynamicComponentLib&&u.add(d.dynamicComponentLib),!d.attributes)break;if(p==="partial"&&t.attributes?.file){const i=V("file"),m=t[i]||t.attributes.file,h=m.startsWith("/")?m.slice(1):M.posix.normalize(M.posix.join(M.posix.dirname(o),m));l.add(h);const v=(g.getGlobalConfig(B)||{})[h];if(v?.dynamicComponents)for(const R of v.dynamicComponents)u.add(R);if(v?.sharedDataDeps)for(const R of v.sharedDataDeps)f.add(R)}for(const[i,m]of Object.entries(d.attributes)){const h=m.type;if(h&&(h.resolver||m.resolver)){const T=y[h.resolver||m.resolver],v=await T?.(t,i,o,e);v?.sharedDataId&&r.push(v.sharedDataId)}}if(p==="code-walkthrough")for(const i of t.attributes.resolvedFilesets||[])for(const m of i.files||[])E(_,m.language);const I=t.attributes?.attrs;if(I&&t.tag==="html")for(const i of Object.keys(I))i==="src"||i==="srcSet"?await y.htmlSourceAttribute(t,i,o,e):i==="href"&&await y.htmlHref(t,i,o,e);break}return{sharedDataIds:r}}async function G(r){if(!(r instanceof $)){await N.panicOnBuild(r.message);return}S.push(H({type:"resolve_link",meta:{...r.meta,link:r.meta.link??r.meta.rawLink},lines:t.lines,location:t.location,error:{id:"",level:"error",message:r.message,location:t.location}},a.relativePath,a.rawContent))}}),await Promise.all(A),a.sharedDataDeps=f,a.dynamicMarkdocComponents=u,a.validatedAtRevision<g.buildRevision&&(a.markdocErrors=L.validate(a.ast,s).map(t=>H(t,o,a.rawContent)),a.validatedAtRevision=g.buildRevision),{sharedDataDeps:a.sharedDataDeps,dynamicMarkdocComponents:Array.from(a.dynamicMarkdocComponents?.values()??[]),partials:Array.from(l),tagList:Array.from(w),htmlTagsList:Array.from(k),tagOccurrence:n,codeSnippetLanguages:b,codeWalkthroughLanguages:_}}const z=new L.Tokenizer({html:!0,allowIndentation:!0,allowComments:!0});z.parser.block.ruler.getRules("reference").length=0;function J(a,s){const e=z.tokenize(s),c=U(e);return{ast:L.parse(c,{file:a,slots:!0}),rawContent:s,resolveErrors:[],markdocErrors:[],relativePath:a,sharedDataDeps:void 0,validatedAtRevision:-1}}async function dt(a,s){const{data:e}=await s.cache.load(a,"markdown-ast");return x(e.ast)}async function gt(a,s){N.clearMarkdocProblems();const e=a.getAllRoutes();let c=0;const g=F.isInteractive();for(const o of e)await a.resolveRouteStaticData(o,s,!0),c++,g&&c%100===0&&F.logInFooter("validate",` \u{1F50D} Status: validating markdoc (${c}/${e.length})`)}async function vt(a,s,e){const c=a.content?j(a.content):"";return await e.context.cache.load(a.relativePath,{loader:o,name:"markdown-inline-parser"},[c,String(e.actions.buildRevision)]);async function o(S,f,u){let l;if(a.content){const n=a.content?a.content:await f.fs.read(a.relativePath),k=await f.getConfig(),b=await W(n,a.relativePath,k.markdown?.partialsFolders,f);l=J(a.relativePath,b)}else l=(await f.cache.load(a.relativePath,"markdown-ast")).data;let w={};if(e.actions.buildRevision!==0&&(w=await C(l,s,e)),!a.isVirtual){for(const n of l.markdocErrors)u(n);for(const n of l.resolveErrors)u(n)}return{ast:l.ast,info:w}}}export{dt as extractMdFirstHeading,J as getAst,vt as parseAndResolveMarkdoc,C as resolveAndValidateMarkdoc,gt as validateAllMarkdowns};
1
+ import M from"@markdoc/markdoc";import*as S from"path";import{GATED_MARKDOC_TAGS as O}from"../../constants/entitlements.js";import{logger as F}from"../../tools/notifiers/logger.js";import{reporter as N}from"../../tools/notifiers/reporter.js";import{sha1 as G}from"../../utils/crypto/sha1.js";import{formatMarkdocError as H}from"./errors.js";import{extractFirstHeading as j,visit as K}from"./markdoc/plugins/utils.js";import{attributeResolvers as y}from"./attribute-resolvers/index.js";import{MdResolveError as $}from"./attribute-resolvers/md-resolve-error.js";import{processHtmlTokens as U}from"./html/process-html-tokens.js";import{resolveRawPartials as W}from"./markdoc/resolve-raw-partials.js";import{EntitlementsProvider as Y}from"../../entitlements/entitlements-provider.js";import{MARKDOC_PARTIALS_DEPS_KEY as B}from"../../store.js";import{getLinkOriginalAttrName as V}from"./attribute-resolvers/utils.js";const q="EMPTY";async function C(a,s,e){const n=Y.instance(),{actions:m}=e,{relativePath:i,resolveErrors:E}=a,k=new Set,g=new Set,b=new Set,c=new Set,u={},f=new Set,w={},_={};function R(t,P){const D=P||q;t[D]=(t[D]||0)+1}const A=[];return a.resolveErrors.length=0,K(a.ast,t=>{const P=D();A.push(P.then(r=>{r?.sharedDataIds&&r.sharedDataIds.forEach(d=>k.add(d))}).catch(z));async function D(){const r=[];switch(t.type){case"fence":R(w,t.attributes.language);break;case"link":case"image":await y.nativeMdLink(t,t.type==="link"?"href":"src",i,e);break;case"tag":if(!t.tag)break;const d=s?.tags?.[t.tag];if(!d){O[t.tag]&&!n.canAccessFeature(O[t.tag])&&(t.errors.push({level:"warning",id:"invalid-tag",message:`Undefined tag: ${t.tag}`}),t.tag="",t.type="error",t.attributes={});break}const v=t.tag==="html"?t.attributes.name:t.tag;if((t.tag==="html"?f:c).add(v),u[v]=(u[v]||0)+1,v==="code-snippet"&&R(w,t.attributes.language),d.attributes?.__idx&&(t.attributes.__idx=u[t.tag]),d.dynamicComponentLib&&g.add(d.dynamicComponentLib),!d.attributes)break;if(v==="partial"&&t.attributes?.file){const o=V("file"),l=t[o]||t.attributes.file,h=l.startsWith("/")?l.slice(1):S.posix.normalize(S.posix.join(S.posix.dirname(i),l));b.add(h);const p=(m.getGlobalConfig(B)||{})[h];if(p?.dynamicComponents)for(const L of p.dynamicComponents)g.add(L);if(p?.sharedDataDeps)for(const L of p.sharedDataDeps)k.add(L)}for(const[o,l]of Object.entries(d.attributes)){const h=l.type;if(h&&(h.resolver||l.resolver)){const T=y[h.resolver||l.resolver],p=await T?.(t,o,i,e);p?.sharedDataId&&r.push(p.sharedDataId)}}if(v==="code-walkthrough")for(const o of t.attributes.resolvedFilesets||[])for(const l of o.files||[])R(_,l.language);const I=t.attributes?.attrs;if(I&&t.tag==="html")for(const o of Object.keys(I))o==="src"||o==="srcSet"?await y.htmlSourceAttribute(t,o,i,e):o==="href"&&await y.htmlHref(t,o,i,e);break}return{sharedDataIds:r}}async function z(r){if(!(r instanceof $)){await N.panicOnBuild(r.message);return}E.push(H({type:"resolve_link",meta:{...r.meta,link:r.meta.link??r.meta.rawLink},lines:t.lines,location:t.location,error:{id:"",level:"error",message:r.message,location:t.location}},a.relativePath,a.rawContent))}}),await Promise.all(A),a.sharedDataDeps=k,a.dynamicMarkdocComponents=g,a.validatedAtRevision<m.buildRevision&&(a.markdocErrors=M.validate(a.ast,s).map(t=>H(t,i,a.rawContent)),a.validatedAtRevision=m.buildRevision),{sharedDataDeps:a.sharedDataDeps,dynamicMarkdocComponents:Array.from(a.dynamicMarkdocComponents?.values()??[]),partials:Array.from(b),tagList:Array.from(c),htmlTagsList:Array.from(f),tagOccurrence:u,codeSnippetLanguages:w,codeWalkthroughLanguages:_}}const x=new M.Tokenizer({html:!0,allowIndentation:!0,allowComments:!0});x.parser.block.ruler.getRules("reference").length=0;function J(a,s){const e=x.tokenize(s),n=U(e);return{ast:M.parse(n,{file:a,slots:!0}),rawContent:s,resolveErrors:[],markdocErrors:[],relativePath:a,sharedDataDeps:void 0,validatedAtRevision:-1}}async function dt(a,s){const{data:e}=await s.cache.load(a,"markdown-ast");return j(e.ast)}async function gt(a,s){N.clearMarkdocProblems();const e=a.getAllRoutes();let n=0;const m=F.isInteractive();for(const i of e)await a.resolveRouteStaticData(i,s,!0),n++,m&&n%100===0&&F.logInFooter("validate",` \u{1F50D} Status: validating markdoc (${n}/${e.length})`)}async function ut(a,s,e,n){const m=a.content?G(a.content):"";return await e.context.cache.load(n||a.relativePath,{loader:E,name:"markdown-inline-parser"},[m,String(e.actions.buildRevision)]);async function E(k,g,b){let c;if(a.content){const f=await g.getConfig(),w=await W(a.content,a.relativePath,f.markdown?.partialsFolders,g);c=J(a.relativePath,w)}else c=(await g.cache.load(a.relativePath,"markdown-ast")).data;let u={};if(e.actions.buildRevision!==0&&(u=await C(c,s,e)),!a.isVirtual){for(const f of c.markdocErrors)b(f);for(const f of c.resolveErrors)b(f)}return{ast:c.ast,info:u}}}export{dt as extractMdFirstHeading,J as getAst,ut as parseAndResolveMarkdoc,C as resolveAndValidateMarkdoc,gt as validateAllMarkdowns};
@@ -1 +1 @@
1
- import f from"@markdoc/markdoc";import{getPublicEnvVariables as m}from"../../utils/envs/get-public-env-variables.js";import{transformMdAst as p}from"./runtime-transform";const c=async(v,a,r,e)=>{const{ast:s,frontmatter:t,props:o,editPage:i,lastModified:l}=a,{headings:n,renderableAst:d}=await p(f.Ast.fromJSON(s),{partials:r.partials,variables:{frontmatter:t,...r.variables,env:m()}},e.serverOutDir);return{...o,ast:d,headings:n,frontmatter:t,editPage:i,lastModified:l}};var A=c;export{A as default};
1
+ import s from"@markdoc/markdoc";import{getPublicEnvVariables as u}from"../../utils/envs/get-public-env-variables.js";import{transformMdAst as i}from"./runtime-transform";const v=async(A,o,t,e)=>{const{ast:n,frontmatter:r,props:l,editPage:f,lastModified:m}=o,{headings:d,renderableAst:p}=await i(s.Ast.fromJSON(n),{partials:t.partials,variables:{frontmatter:r,...t.variables,env:u()}},e.serverOutDir);return Array.isArray(r.banner)&&(r.banner=await Promise.all(r.banner.map(async a=>{if(a.ast){const{renderableAst:b}=await i(s.Ast.fromJSON(a.ast),{partials:{},variables:{}},e.serverOutDir);return{...a,ast:b}}return a}))),{...l,ast:p,headings:d,frontmatter:r,editPage:f,lastModified:m}};var P=v;export{P as default};
@@ -1 +1 @@
1
- import g from"path";import{REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{MARKDOC_PARTIALS_DATA_KEY as y}from"../../store.js";import{reporter as D}from"../../tools/notifiers/reporter.js";import{canAccessFeature as R}from"../../utils/entitlements/can-access-feature.js";import{extractMdFirstHeading as A,getAst as C}from"./compiler.js";import{getTemplatePath as w}from"./get-template-path.js";import{prepareMarkdocPartials as M}from"./markdoc/partials.js";import{searchResolver as T}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 z}from"./markdown-frontmatter-loader.js";import{resolveRawPartials as B}from"./markdoc/resolve-raw-partials.js";import{getAiDocumentsStore as K}from"./search/get-ai-search-documents.js";import{registerPageProps as N}from"../register-page-props.js";import{sanitizeMalformedMdContent as W}from"./utils/sanitize-malformed-md-content.js";import{telemetryTraceStep as Y}from"../../../cli/telemetry/helpers/trace-step.js";async function le(h){return{id:"markdoc",requiredEntitlements:["markdown"],loaders:{"markdown-frontmatter":z,"markdown-ast":async(t,r)=>{const i=await r.fs.read(t),n=await r.getConfig(),d=await B(i,t,n?.markdown?.partialsFolders,r),l=W(d);return C(t,l)}},processContent:async(t,r)=>{await Y("build.plugin.markdown",async i=>{const{markdown:n}=await r.getConfig();i?.setAttribute("config",JSON.stringify(n||{}));const d=n?.partialsFolders??[],l=t.createTemplate("markdown","@redocly/theme/core/templates/Markdown"),S=t.registerServerPropsGetter("markdown",w("./get-server-props.js"));t.createTemplate("error",w("../../../client/app/Error/ErrorDetails.js"));for(const o of r.fs.scan(/\.md$/))if(!await r.isPathIgnored(o.relativePath)&&!j(o.relativePath,d))try{await k(o)}catch(a){t.addRoute(I(o.relativePath,a)),i?.error(a),await D.panicOnBuild("Failed to create route for markdown file: %s",a.message)}async function k(o){const{relativePath:a,realRelativePath:P}=o,{data:{frontmatter:e}}=await r.cache.load(a,"markdown-frontmatter"),F=e?.metadata||{},b=await _(a,"markdown-frontmatter",e,r),p=L(b,a);let c=null;e?.sidebar&&(c=await G(e.sidebar,a,r.fs));let u=l;if(e?.template){const f=e.template.startsWith("./")||e.template.startsWith("../");let m=e.template;if(f){const s=g.posix.dirname(P);m=g.resolve(h.contentDir,s,e.template)}u=t.createTemplate(e.template,m)}e?.rbac&&(R("rbac")?O({content:{[a]:e.rbac}}):e.rbac=void 0),await N(o,r.fs,t),(p.length?p.reverse():[void 0]).forEach(f=>{t.addRoute({excludeFromSearch:e?.excludeFromSearch||!1,slug:f,fsPath:a,templateId:u,sharedData:c?[{id:c,key:"sidebar"}]:void 0,redirectFrom:Object.entries(e.redirects||{}).map(([m,{type:s}])=>({type:s||301,from:m})),[v]:e?.rbac,getNavText:async()=>(e?.seo?.title||await A(a,r)||"").toString(),metadata:{type:"markdown",...F},async getStaticData(m,s){return E(o,m,r,e,s)},getSearchDocuments:T(e,a,t.getSearchFacets,t.setSearchFacets),getAiDocumentsStore:K(t.getSearchFacets,e),serverPropsGetterIds:[S]})})}})},afterRoutesCreated:async(t,r)=>{const i=await M(r,t);t.setGlobalConfig({[y]:i})}}}export{le as markdownPlugin};
1
+ import g from"path";import{REDOCLY_TEAMS_RBAC as y}from"@redocly/config";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../store.js";import{reporter as R}from"../../tools/notifiers/reporter.js";import{canAccessFeature as w}from"../../utils/entitlements/can-access-feature.js";import{extractMdFirstHeading as A,getAst as C}from"./compiler.js";import{getTemplatePath as h}from"./get-template-path.js";import{prepareMarkdocPartials as M}from"./markdoc/partials.js";import{searchResolver as T}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 z}from"./markdown-frontmatter-loader.js";import{resolveRawPartials as B}from"./markdoc/resolve-raw-partials.js";import{getAiDocumentsStore as K}from"./search/get-ai-search-documents.js";import{registerPageProps as N}from"../register-page-props.js";import{sanitizeMalformedMdContent as W}from"./utils/sanitize-malformed-md-content.js";import{telemetryTraceStep as Y}from"../../../cli/telemetry/helpers/trace-step.js";async function le(S){return{id:"markdoc",requiredEntitlements:["markdown"],loaders:{"markdown-frontmatter":z,"markdown-ast":async(t,r)=>{const i=await r.fs.read(t),n=await r.getConfig(),d=await B(i,t,n?.markdown?.partialsFolders,r),l=W(d);return C(t,l)}},processContent:async(t,r)=>{await Y("build.plugin.markdown",async i=>{const{markdown:n}=await r.getConfig();i?.setAttribute("config",JSON.stringify(n||{}));const d=n?.partialsFolders??[],l=t.createTemplate("markdown","@redocly/theme/core/templates/Markdown"),k=t.registerServerPropsGetter("markdown",h("./get-server-props.js"));t.createTemplate("error",h("../../../client/app/Error/ErrorDetails.js"));for(const o of r.fs.scan(/\.md$/))if(!await r.isPathIgnored(o.relativePath)&&!j(o.relativePath,d))try{await P(o)}catch(a){t.addRoute(I(o.relativePath,a)),i?.error(a),await R.panicOnBuild("Failed to create route for markdown file: %s",a.message)}async function P(o){const{relativePath:a,realRelativePath:b}=o,{data:{frontmatter:e}}=await r.cache.load(a,"markdown-frontmatter"),F=e?.metadata||{},v=await _(a,"markdown-frontmatter",e,r),p=L(v,a);let f=null;e?.sidebar&&(f=await G(e.sidebar,a,r.fs));let u=l;if(e?.template){const c=e.template.startsWith("./")||e.template.startsWith("../");let m=e.template;if(c){const s=g.posix.dirname(b);m=g.resolve(S.contentDir,s,e.template)}u=t.createTemplate(e.template,m)}e?.rbac&&(w("rbac")?O({content:{[a]:e.rbac}}):e.rbac=void 0),w("banner")||(e.banner=void 0),await N(o,r.fs,t),(p.length?p.reverse():[void 0]).forEach(c=>{t.addRoute({excludeFromSearch:e?.excludeFromSearch||!1,slug:c,fsPath:a,templateId:u,sharedData:f?[{id:f,key:"sidebar"}]:void 0,redirectFrom:Object.entries(e.redirects||{}).map(([m,{type:s}])=>({type:s||301,from:m})),[y]:e?.rbac,getNavText:async()=>(e?.seo?.title||await A(a,r)||"").toString(),metadata:{type:"markdown",...F},async getStaticData(m,s){return E(o,m,r,e,s)},getSearchDocuments:T(e,a,t.getSearchFacets,t.setSearchFacets),getAiDocumentsStore:K(t.getSearchFacets,e),serverPropsGetterIds:[k]})})}})},afterRoutesCreated:async(t,r)=>{const i=await M(r,t);t.setGlobalConfig({[D]:i})}}}export{le as markdownPlugin};
@@ -1 +1 @@
1
- import*as f from"path";import{MARKDOC_PARTIALS_DATA_KEY as D,MARKDOC_PARTIALS_DEPS_KEY as A}from"../../../store.js";import{isPartial as y}from"../is-partial.js";function h(t,s){return Promise.all(t.map(s)).then(i=>t.filter((o,n)=>i[n]))}async function b(t,s){const{markdown:i}=await t.getConfig(),o=i?.partialsFolders??[],n=await h(t.fs.scan(/\.md$/),async a=>!(!f.posix.basename(a.relativePath).endsWith(".md")||await t.isPathIgnored(a.relativePath)||!y(a.relativePath,o)));s.setGlobalConfig({[D]:Object.fromEntries(n.map(a=>[a.relativePath,{}]))});const p={},m={};for(const a of n){const{ast:e,info:r}=await s.parseMarkdoc(a,t);p[a.relativePath]=e;const l=Array.isArray(r.dynamicMarkdocComponents)?r.dynamicMarkdocComponents:[],c=r.sharedDataDeps instanceof Set?Array.from(r.sharedDataDeps):Array.isArray(r.sharedDataDeps)?r.sharedDataDeps:[],d=Array.isArray(r.partials)?r.partials:[];m[a.relativePath]={dynamicComponents:new Set(l),sharedDataDeps:new Set(c),partials:new Set(d)}}return s.setGlobalConfig({[A]:Object.fromEntries(Object.entries(m).map(([a,e])=>[a,{dynamicComponents:Array.from(e.dynamicComponents),sharedDataDeps:Array.from(e.sharedDataDeps),partials:Array.from(e.partials)}]))}),p}export{b as prepareMarkdocPartials};
1
+ import*as f from"path";import{MARKDOC_PARTIALS_DATA_KEY as D,MARKDOC_PARTIALS_DEPS_KEY as A}from"../../../store.js";import{isPartial as y}from"../is-partial.js";function h(t,s){return Promise.all(t.map(s)).then(i=>t.filter((o,n)=>i[n]))}async function b(t,s){const{markdown:i}=await t.getConfig(),o=i?.partialsFolders??[],n=await h(t.fs.scan(/\.md$/),async a=>!(!f.posix.basename(a.relativePath).endsWith(".md")||await t.isPathIgnored(a.relativePath)||!y(a.relativePath,o)));s.setGlobalConfig({[D]:Object.fromEntries(n.map(a=>[a.relativePath,{}]))});const p={},m={};for(const a of n){const{ast:e,info:r}=await s.parseMarkdoc({input:a,context:t});p[a.relativePath]=e;const l=Array.isArray(r.dynamicMarkdocComponents)?r.dynamicMarkdocComponents:[],c=r.sharedDataDeps instanceof Set?Array.from(r.sharedDataDeps):Array.isArray(r.sharedDataDeps)?r.sharedDataDeps:[],d=Array.isArray(r.partials)?r.partials:[];m[a.relativePath]={dynamicComponents:new Set(l),sharedDataDeps:new Set(c),partials:new Set(d)}}return s.setGlobalConfig({[A]:Object.fromEntries(Object.entries(m).map(([a,e])=>[a,{dynamicComponents:Array.from(e.dynamicComponents),sharedDataDeps:Array.from(e.sharedDataDeps),partials:Array.from(e.partials)}]))}),p}export{b as prepareMarkdocPartials};
@@ -1 +1 @@
1
- import R from"path";import{REDOCLY_TEAMS_RBAC as b,REDOCLY_ROUTE_RBAC as C}from"@redocly/config";import{removeTrailingSlash as S}from"../../../utils/url/remove-trailing-slash.js";import{addLeadingSlash as T}from"../../../utils/url/add-leading-slash.js";import{resolveFrontmatterKeys as m}from"../resolve-frontmatter-keys.js";import{resolveItem as B}from"../nav-utils.js";const A=new WeakMap;async function F(l,i,s,e,a){const d=await s.getConfig(),{ast:t,compoundHash:n,info:c}=await a.parseMarkdoc(l,s),g={...d.markdown?.editPage,...e.markdown?.editPage},o=i.fsPath!=null?s.fs.getFileInfo(i.fsPath):null,f=!g?.hide&&g?.baseUrl?{to:S(g.baseUrl)+T(o?.realRelativePath||i.fsPath||"")}:void 0,u={...d.feedback,...e.feedback},w=e.feedback?{type:u.type||"sentiment",settings:u.settings||{},hide:e.feedback?.hide}:void 0;Array.isArray(e.banner)&&(e.banner=e.banner.map(r=>r&&r.rbac?{...r,[b]:r.rbac}:r));let v=A.get(t),h=v?.ast;(!h||v?.compoundHash!==n)&&(h=JSON.stringify(t),A.set(t,{ast:h,compoundHash:n}));let p;e.navigation&&(p={...e.navigation,nextButton:await L(e.navigation.nextButton,i,a,s),previousButton:await L(e.navigation.previousButton,i,a,s)});const k=e?.seo?await m(e.seo,["image"],i.fsPath||"",a,s):void 0,y=c.tagList;Array.isArray(y)&&y.includes("code-walkthrough")&&(e.markdown=e.markdown||{},e.markdown.toc={hide:!0},e.footer=e.footer||{},e.footer={hide:!0});const P=e?.seo?.title||await i.getNavText?.();return{ast:h,frontmatter:await m({...e,...w!==void 0?{feedback:w}:{},...k!==void 0?{seo:k}:{},...p!==void 0?{navigation:p}:{}},d.markdown?.frontMatterKeysToResolve||["image","links"],i.fsPath||"",a,s),editPage:f,props:{metadata:{markdoc:{tagList:c.tagList}},seo:{...k,...P?{title:P}:{}}},[b]:i[b],[C]:i[C]}}async function L(l,i,s,e){if(!l||typeof l!="object")return;let a=l,d,t;if("page"in a&&typeof a.page=="string"){const{page:o,...f}=a;a=f,d=o}if("label"in a&&typeof a.label=="string"){const{label:o,...f}=a;a=f,t=o}let n;if(d){const o=await B({page:d},i.fsPath?R.dirname(i.fsPath):".",s,e,{navFile:i.fsPath||""});n=Array.isArray(o)?o[0]:o,n=n?.type!=="error"?n:void 0}const c=n?.routeSlug,g=t??n?.label;return{...a,label:g,link:c}}export{F as markdownStaticDataLoader};
1
+ import D from"path";import{REDOCLY_TEAMS_RBAC as v,REDOCLY_ROUTE_RBAC as A}from"@redocly/config";import{removeTrailingSlash as M}from"../../../utils/url/remove-trailing-slash.js";import{addLeadingSlash as N}from"../../../utils/url/add-leading-slash.js";import{shaHexShort as E}from"../../utils/crypto/sha-hex-short.js";import{isDefined as I}from"../../../utils/guards/is-defined.js";import{resolveFrontmatterKeys as L}from"../resolve-frontmatter-keys.js";import{resolveItem as _}from"../nav-utils.js";const R=new WeakMap;async function j(o,i,s,e,a){const d=await s.getConfig(),{ast:l,compoundHash:n,info:g}=await a.parseMarkdoc({input:o,context:s}),r={...d.markdown?.editPage,...e.markdown?.editPage},t=i.fsPath!=null?s.fs.getFileInfo(i.fsPath):null,f=!r?.hide&&r?.baseUrl?{to:M(r.baseUrl)+N(t?.realRelativePath||i.fsPath||"")}:void 0,w={...d.feedback,...e.feedback},m=e.feedback?{type:w.type||"sentiment",settings:w.settings||{},hide:e.feedback?.hide}:void 0;let h;Array.isArray(e.banner)&&(h=(await Promise.all(e.banner.map(async(B,O)=>{const{content:k,...b}=B;if(!k)return;const{ast:T}=await a.parseMarkdoc({input:{content:k,relativePath:o.relativePath,isVirtual:o.isVirtual},context:s,resource:`${o.relativePath}#banner${O}`});return{...b,...b.rbac?{[v]:b.rbac}:{},ast:JSON.stringify(T),hash:E(k)}}))).filter(I));let y=R.get(l),c=y?.ast;(!c||y?.compoundHash!==n)&&(c=JSON.stringify(l),R.set(l,{ast:c,compoundHash:n}));let p;e.navigation&&(p={...e.navigation,nextButton:await S(e.navigation.nextButton,i,a,s),previousButton:await S(e.navigation.previousButton,i,a,s)});const u=e?.seo?await L(e.seo,["image"],i.fsPath||"",a,s):void 0,P=g.tagList;Array.isArray(P)&&P.includes("code-walkthrough")&&(e.markdown=e.markdown||{},e.markdown.toc={hide:!0},e.footer=e.footer||{},e.footer={hide:!0});const C=e?.seo?.title||await i.getNavText?.();return{ast:c,frontmatter:await L({...e,...m!==void 0?{feedback:m}:{},...u!==void 0?{seo:u}:{},...p!==void 0?{navigation:p}:{},...h!==void 0?{banner:h}:{}},d.markdown?.frontMatterKeysToResolve||["image","links"],i.fsPath||"",a,s),editPage:f,props:{metadata:{markdoc:{tagList:g.tagList}},seo:{...u,...C?{title:C}:{}}},[v]:i[v],[A]:i[A]}}async function S(o,i,s,e){if(!o||typeof o!="object")return;let a=o,d,l;if("page"in a&&typeof a.page=="string"){const{page:t,...f}=a;a=f,d=t}if("label"in a&&typeof a.label=="string"){const{label:t,...f}=a;a=f,l=t}let n;if(d){const t=await _({page:d},i.fsPath?D.dirname(i.fsPath):".",s,e,{navFile:i.fsPath||""});n=Array.isArray(t)?t[0]:t,n=n?.type!=="error"?n:void 0}const g=n?.routeSlug,r=l??n?.label;return{...a,label:r,link:g}}export{j as markdownStaticDataLoader};
@@ -1,10 +1,10 @@
1
- import _ from"@markdoc/markdoc";import D from"node:path";import{AI_SEARCH_CHUNK_SIZE as E,AI_SEARCH_DOCUMENT_CHUNK_SIZE as M}from"../../../constants/plugins/search.js";import{slugger as P}from"../../../../utils/slugger.js";import{toMarkdown as U}from"./to-markdown.js";import{AstToSearchNodeTransformer as b}from"./walk-sections.js";import{getLocaleFromRelativePath as x}from"../../../fs/utils/get-locale-from-relative-path.js";import{HeadingNode as I}from"./nodes/heading-node.js";import{extractDocumentSearchFacets as y}from"./search-facets.js";import{formatDocumentMetadata as L}from"../../search/utils.js";import{TagNode as H}from"./nodes/tag-node.js";import{MARKDOC_PARTIALS_DATA_KEY as K}from"../../../store.js";const N=Symbol(),W=(n,c)=>async(e,r,u,s)=>{if(c?.excludeFromSearch)return;P.reset();const i=await e.getNavText?.()||D.basename(e.fsPath),p=_.Ast.fromJSON(r.ast),m=new b({partials:s.getGlobalConfig(K)||{},getInnerContent:U,ast:p,skipConditionals:!0}),f=Array.from(m.transform());return{async getLLMsTxts(){const o=c?.seo,g=o&&typeof o=="object"&&"description"in o?String(o.description):void 0,C=f.map(t=>t.content).filter(Boolean).join(`
2
- `).trim();return[{title:i,description:g,slug:e.slug,fsPath:e.fsPath,content:C,includeInLLMsTxt:!0}]},async getSearchDocuments(){return j(e,f,n,i)}}};function j(n,c,e,r){const u=n.slug,s=new Map,i=n.metadata||{},p=y(i,e),m=L(i),f=m?`Metadata:
3
- ${m}
4
- `:"";let o=[];for(const t of c)if(t instanceof I){o.splice(t.attributes.level-1,6);const a=t.attributes.level>2,l=o[o.length-1]?.title,S=o[o.length-1]?.url,A=a&&l?l:w(r,t),T=a&&S?S:t.getUrl(u),d={title:A,content:"",url:T,level:t.attributes.level,toc:o.map(v=>h(v.section)).join(`
5
- `)};(t.attributes.level>1||h(t)!==r)&&(d.content+=d.content?`
6
- `:"",d.content+=t.content.trimEnd()),s.set(t.id,d),o.push({section:t,title:A,url:T})}else if(t instanceof H)s.set(t.id,{title:t.content,content:t.content,url:t.getUrl(u),level:t.attributes.level+1,toc:o.map(a=>h(a.section)).concat(t.content).join(`
7
- `)});else{const a=t.parentNode?.id??N,l=s.get(a)??{title:r,content:"",url:u,level:1/0,toc:""};l.content+=l.content?`
8
- `:"",l.content+=t.content.trimEnd(),s.set(a,l)}const g=R(Array.from(s.values())),C=x(n.fsPath);return g.filter(t=>t.content).map(t=>({title:t.title,url:t.url,content:[f,t.toc||`# ${r}`,t.content].filter(Boolean).join(`
9
- `),fsPath:n.fsPath,locale:C,product:n.product?.name,facets:p}))}function k(n){return n.length/4}function R(n){if(n.length===0)return[];const c=[];let e=n[0];for(const r of n.slice(1)){const u=k(e.content),s=k(r.content),i=n.indexOf(r)===n.length-1;s<E&&(u<M||i)&&r.level>e.level?e.content+=`
10
- `+r.content:(c.push(e),e=r)}return c.push(e),c}function w(n,c){return c.content===n?n:`${n} \u2192 ${h(c)}`}function h(n){return n.content.replace(/^#+/,"").trim()}export{W as getAiDocumentsStore};
1
+ import _ from"@markdoc/markdoc";import D from"node:path";import{AI_SEARCH_CHUNK_SIZE as E,AI_SEARCH_DOCUMENT_CHUNK_SIZE as M}from"../../../constants/plugins/search.js";import{slugger as P}from"../../../../utils/slugger.js";import{toMarkdown as U}from"./to-markdown.js";import{AstToSearchNodeTransformer as b}from"./walk-sections.js";import{getLocaleFromRelativePath as I}from"../../../fs/utils/get-locale-from-relative-path.js";import{HeadingNode as x}from"./nodes/heading-node.js";import{extractDocumentSearchFacets as y}from"./search-facets.js";import{formatDocumentMetadata as L}from"../../search/utils.js";import{TagNode as H}from"./nodes/tag-node.js";import{MARKDOC_PARTIALS_DATA_KEY as K}from"../../../store.js";const N=Symbol(),W=(n,r)=>async(e,c,s,i)=>{if(r?.excludeFromSearch)return;P.reset();const a=await e.getNavText?.()||D.basename(e.fsPath),m=_.Ast.fromJSON(c.ast),f=new b({partials:i.getGlobalConfig(K)||{},getInnerContent:U,ast:m,skipConditionals:!0}),d=Array.from(f.transform());return{async getLLMsTxts(){const o=r?.seo,g=o&&typeof o=="object"&&"description"in o?String(o.description):void 0,C=d.map(t=>t.content).filter(Boolean).join(`
2
+ `).trim();return[{title:a,description:g,slug:e.slug,fsPath:e.fsPath,content:C,includeInLLMsTxt:!0}]},async getSearchDocuments(){return j(e,d,n,a)}}};function j(n,r,e,c){const s=n.slug,i=new Map,a=n.metadata||{},m=y(a,e),f=L(a),d=f?`Metadata:
3
+ ${f}
4
+ `:"";let o=[];for(const t of r)if(t instanceof x){o.splice(t.attributes.level-1,6);const l=t.attributes.level>2,u=o[o.length-1]?.title,S=o[o.length-1]?.url,A=l&&u?u:w(c,t),T=l&&S?S:t.getUrl(s),h={title:A,content:"",url:T,level:t.attributes.level,toc:o.map(v=>p(v.section)).join(`
5
+ `)};(t.attributes.level>1||p(t)!==c)&&(h.content+=h.content?`
6
+ `:"",h.content+=t.content.trimEnd()),i.set(t.id,h),o.push({section:t,title:A,url:T})}else if(t instanceof H)i.set(t.id,{title:t.content,content:t.content,url:t.getUrl(s),level:t.attributes.level+1,toc:o.map(l=>p(l.section)).concat(t.content).join(`
7
+ `)});else{const l=t.parentNode?.id??N,u=i.get(l)??{title:c,content:"",url:s,level:1/0,toc:""};u.content+=u.content?`
8
+ `:"",u.content+=t.content.trimEnd(),i.set(l,u)}const g=R(Array.from(i.values())),C=I(n.fsPath);return g.filter(t=>t.content).map(t=>({title:t.title,url:t.url,content:[d,t.toc||`# ${c}`,t.content].filter(Boolean).join(`
9
+ `),fsPath:n.fsPath,locale:C,product:n.product?.name,facets:m}))}function k(n){return n.length/4}function R(n){if(n.length===0)return[];const r=[];let e=n[0];for(let c=1;c<n.length;c++){const s=n[c],i=k(e.content),a=k(s.content),m=c===n.length-1;a<E&&(i<M||m)&&s.level>e.level?e.content+=`
10
+ `+s.content:(r.push(e),e=s)}return r.push(e),r}function w(n,r){return r.content===n?n:`${n} \u2192 ${p(r)}`}function p(n){return n.content.replace(/^#+/,"").trim()}export{W as getAiDocumentsStore};
@@ -1 +1 @@
1
- import{createMcpRequestHandler as h}from"./mcp-request-handler.js";import{createDocsMcpServer as y}from"../servers/docs-server.js";import{filterApiDescriptionsByRbac as b}from"../utils.js";import{createInternalServerError as A}from"./errors.js";import{McpServerType as m}from"../constants.js";import{telemetry as u}from"../../../telemetry/index.js";import{constructInvalidTokenResponse as L,constructUnauthorizedResponse as S,handleMcpAuth as I,shouldHandleMcpAuth as R}from"../auth/auth-handlers.js";async function w(e,s,i,n){try{u.initialize();const r=s,t=r?.props?.config?.apiDescriptionsMap||{},a=r?.props?.outdir||"",o=r?.props?.config?.mcpDocsServerName||"Docs MCP server",f=new URL(n.url).origin,{user:c,config:{rbac:p={},mcp:l={}}}=e,d=b(t,c,p,e.config.requiresLogin||!1),g=l.docs?.name||o,v=e.config.products?Object.values(e.config.products).map(D=>D?.name):[],M={rbac:p,email:c?.email,teams:c?.teams,isAuthenticated:!!c?.isAuthenticated,requiresLogin:e.config.requiresLogin||!1};return await y({name:g,baseUrl:f,headers:i,apiDescriptionsMap:d,outdir:a,accessInfo:M,products:v})}catch(r){throw u.sendMcpErrorMessage([{object:"mcp_server",server_type:m.Docs,message:r?.message||"",stack:r?.stack||""}]),A(r?.message||"Internal server error mcp docs")}}const T=h({createServerInstance:w,serverType:m.Docs}),U=async(e,s,i)=>{const n=!!s?.config?.requiresLogin,r=s?.config?.rbac;if(R(n,r)){const{isAuthenticated:t,isTokenValid:a,currentUser:o}=await I(e,s);if(!t)return S(new URL(e.url).origin);if(!a)return L();o&&(s.user=o)}return T(e,s,i)};var N=U;export{N as default};
1
+ import{createMcpRequestHandler as y}from"./mcp-request-handler.js";import{createDocsMcpServer as A}from"../servers/docs-server.js";import{filterApiDescriptionsByRbac as S}from"../utils.js";import{createInternalServerError as I}from"./errors.js";import{McpServerType as f}from"../constants.js";import{telemetry as d}from"../../../telemetry/index.js";import{constructInvalidTokenResponse as L,constructUnauthorizedResponse as R,handleMcpAuth as w,shouldHandleMcpAuth as T}from"../auth/auth-handlers.js";async function U(r,s,t,n){try{d.initialize();const e=s,a=e?.props?.config?.apiDescriptionsMap||{},i=e?.props?.outdir||"",c=e?.props?.config?.mcpDocsServerName||"Docs MCP server",l=new URL(n.url).origin,{user:o,config:{access:p,mcp:g={}}}=r,m=p?.rbac||{},u=p?.requiresLogin||!1,v=S(a,o,m,u),M=g.docs?.name||c,D=r.config.products?Object.values(r.config.products).map(b=>b?.name):[],h={rbac:m,email:o?.email,teams:o?.teams,isAuthenticated:!!o?.isAuthenticated,requiresLogin:u};return await A({name:M,baseUrl:l,headers:t,apiDescriptionsMap:v,outdir:i,accessInfo:h,products:D})}catch(e){throw d.sendMcpErrorMessage([{object:"mcp_server",server_type:f.Docs,message:e?.message||"",stack:e?.stack||""}]),I(e?.message||"Internal server error mcp docs")}}const k=y({createServerInstance:U,serverType:f.Docs}),H=async(r,s,t)=>{const n=!!s?.config?.access?.requiresLogin,e=s?.config?.access?.rbac;if(T(n,e)){const{isAuthenticated:a,isTokenValid:i,currentUser:c}=await w(r,s);if(!a)return R(new URL(r.url).origin);if(!i)return L();c&&(s.user=c)}return k(r,s,t)};var B=H;export{B as default};
@@ -1 +1 @@
1
- import{getPublicEnvVariables as n}from"../../utils/envs/get-public-env-variables.js";const l=async({fsPath:r,slug:e},t,{variables:a,partials:i},o)=>{const s=o.getPartialsForRoute?.(e)||i;return{definitionId:r,...t.props,markdown:{partials:s,variables:{...a,env:n()}}}};var d=l;export{d as default};
1
+ import{getPublicEnvVariables as n}from"../../utils/envs/get-public-env-variables.js";const l=async({fsPath:r,slug:t},a,{variables:i,partials:o},s)=>{const e=s.getPartialsForRoute?.(t);return{definitionId:r,...a.props,markdown:{partials:e&&Object.keys(e).length>0?e:o,variables:{...i,env:n()}}}};var c=l;export{c as default};
@@ -1 +1 @@
1
- import{simplifyAstStructure as Z}from"@redocly/openapi-docs";import{REDOCLY_TEAMS_RBAC as D}from"@redocly/config";import{OPENAPI_DOCS_TEMPLATE_ID as $,PUBLIC_RBAC_SCOPE_ITEM as j}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as ee,PUBLIC_API_DEFINITIONS_FOLDER as te}from"../../constants/common.js";import{OPENAPI_CUSTOM_FIELDS_SERVER_PROPS_GETTER_ID as oe,OPENAPI_SHARED_DATA_PREFIX as U}from"../../constants/plugins/openapi-docs.js";import{envConfig as V}from"../../config/env-config.js";import{searchResolver as ae}from"./search/search-resolver.js";import{convertOpenAPIDocs2Sidebar as re,shouldAddRoute as se}from"./utils.js";import{getTemplatePath as b}from"./get-template-path.js";import{storeDefinitionBundles as ne}from"./store-definition-bundles.js";import{definitionLoader as ie,definitionsLoader as pe}from"./load-definition.js";import{getAiDocumentsStore as de}from"./search/get-ai-search-documents.js";import{fromCurrentDir as ce}from"../../utils/paths.js";import{telemetryTraceStep as le}from"../../../cli/telemetry/helpers/trace-step.js";const w="openapi-spec-download";async function Ce(){let M=[],R={},L=new Set;return{id:"openapi",requiredEntitlements:["openapi"],loaders:{"load-oas-docs":pe,"load-oas":ie},processContent:async(e,p)=>{await le("build.plugin.openapi_docs",async u=>{e.createRequestHandler(w,ce(import.meta.url,"./spec-download.api.js")),e.addApiRoute({slug:te+"/*",requestHandlerId:w,httpMethod:"all",[D]:j,getStaticData:async()=>({props:{}})}),e.addApiRoute({slug:ee+"/*",requestHandlerId:w,httpMethod:"all",[D]:j,getStaticData:async()=>({props:{}})});const A=e.createTemplate($,b("../../../client/templates/openapi-docs/template.js")),a=e.registerServerPropsGetter($,b("./get-server-props.js")),s=e.registerServerPropsGetter(oe,b("./get-server-props-custom-fields.js")),d=await p.getConfig();u?.setAttribute("config",JSON.stringify(d.openapi||{}));const g=d.rules?.["custom-fields-schema"];R={};const m=await e.loadOpenApiDefinitions(p);M=m.map(({markdocChunks:r,relativePath:f,customOutputRelativeFile:i,isVirtual:n,realRelativePath:c})=>({chunks:r,relativePath:f,realRelativePath:c,isVirtual:i!=null||n})),ne(m,e.outdir);const S={};for(const r of m||[]){const{definition:f,config:i,relativePath:n,customOutputRelativeFile:c,contentItems:_,flatItems:k,parser:E,options:B,rawOptions:q,hash:J}=r,N=c||n,o=[],x={},{definition:Q}=E||{},{info:l}=Q||{},v=l?.["x-metadata"],C=!!i.openapi?.excludeFromSearch||!!i.theme?.openapi?.excludeFromSearch||!!d.openapi?.excludeFromSearch||!!d.theme?.openapi?.excludeFromSearch,G={title:l?.title,description:l?.description,summary:l?.summary,...i.metadata,...v},h={untagged:[],tagged:new Map};for(const t of k){const{id:O,href:I,operationDefinition:y}=t;if(y){const{tags:P}=y;if(P)for(const T of P)h.tagged.has(T)||h.tagged.set(T,[]),h.tagged.get(T)?.push(t);else h.untagged.push(t);V.isDevelopMode&&(x[`#${y.pointer}`]=t.href)}if(!se({item:t}))continue;const F=t,Y=F.type==="section"&&!!F.infoDefinition,z=I.split("#")[0]+"/",K=t?.operationDefinition?.[D];o.push({excludeFromSearch:C,slugSuffix:z,fsPath:N,metadata:{subType:"openapi-operation"},httpVerb:t?.httpVerb||"",path:n,templateId:A,[D]:K||i.rbac,getAiDocumentsStore:de({parser:E,options:B,info:l,tagOperations:h,openapiContentItem:F,metadata:G,relativePath:n,getSearchFacets:e.getSearchFacets,includeInLLMsTxt:Y,excludeFromSearch:C}),getStaticData:async P=>({props:{dynamicMarkdocComponents:["openapi"],baseSlug:P.baseSlug,seo:t["x-metadata"]?.seo||{title:t.name,description:t.description},itemId:O,disableAutoScroll:!0}})})}o[0]={...o[0],metadata:{type:"openapi",...G},hasClientRoutes:!0,getSidebar:(t,O)=>{const I=[];return re({contentItems:_,sidebarItems:I,routeSlug:t.slug,navItem:O}),I},getNavText:()=>l?.title,getSearchDocuments:ae(E,B,k,e.getSearchFacets,e.setSearchFacets,C)},v?.apiId&&(S[v.apiId]={slug:o[0]?.slug||""});const W=o[0];o[0]=o[o.length-1],o[o.length-1]=W;for(const t of o)e.addRoute({...t,serverPropsGetterIds:g?[a,s]:[a]});const X=V.isDevelopMode?n:void 0,H=`${U}${n}`;R[H]={fsPath:N,definition:f,options:q,sourcePath:X,routesMapping:x,hash:J};for(const t of o)e.addRoute({...t,sharedData:[{id:H,key:"openAPIDocsStore"}],serverPropsGetterIds:g?[a,s]:[a]})}e.setGlobalData({apiProducts:S})})},afterRoutesCreated:async(e,p)=>{const u=new Set;for(const{chunks:a,relativePath:s,isVirtual:d,realRelativePath:g}of M){const m=e.getAllRoutes().filter(r=>r.fsPath===s).map(r=>r.slug),S=(await p.cache.load(g,"load-oas")).compoundHash;await p.cache.load(s,{loader:async function(){for(const{node:f,markdown:i,key:n,relativePath:c}of a){const{ast:_}=await e.parseMarkdoc({content:i,relativePath:c,isVirtual:d},p,{sharedDataIds:[`${U}${c}`],routeSlugs:m});f[`x-parsed-md-${n}`]={result:Z(_)}}},name:"openapi-markdoc-inline-parser"},[S]);for(const{pointer:r}of a)u.add(r)}const A=L.difference(u);for(const a of A)p.cache.delete(a);L=u;for(const[a,s]of Object.entries(R))await e.createSharedData(a,{...s,baseSlug:e.getRouteByFsPath(s.fsPath)?.baseSlug},s.hash)}}}export{Ce as openAPIDocsPlugin};
1
+ import{simplifyAstStructure as ee}from"@redocly/openapi-docs";import{REDOCLY_TEAMS_RBAC as D}from"@redocly/config";import{OPENAPI_DOCS_TEMPLATE_ID as $,PUBLIC_RBAC_SCOPE_ITEM as j}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as te,PUBLIC_API_DEFINITIONS_FOLDER as oe}from"../../constants/common.js";import{OPENAPI_CUSTOM_FIELDS_SERVER_PROPS_GETTER_ID as ae,OPENAPI_SHARED_DATA_PREFIX as U}from"../../constants/plugins/openapi-docs.js";import{envConfig as V}from"../../config/env-config.js";import{isRbacScopeItems as re}from"../../utils/rbac/is-rbac-scope-items.js";import{getRouteSlugsForPath as se}from"../utils.js";import{searchResolver as ne}from"./search/search-resolver.js";import{convertOpenAPIDocs2Sidebar as ie,shouldAddRoute as pe}from"./utils.js";import{getTemplatePath as T}from"./get-template-path.js";import{storeDefinitionBundles as ce}from"./store-definition-bundles.js";import{definitionLoader as de,definitionsLoader as le}from"./load-definition.js";import{getAiDocumentsStore as ue}from"./search/get-ai-search-documents.js";import{fromCurrentDir as me}from"../../utils/paths.js";import{telemetryTraceStep as fe}from"../../../cli/telemetry/helpers/trace-step.js";const w="openapi-spec-download";async function Te(){let M=[],R={},L=new Set;return{id:"openapi",requiredEntitlements:["openapi"],loaders:{"load-oas-docs":le,"load-oas":de},processContent:async(e,i)=>{await fe("build.plugin.openapi_docs",async u=>{e.createRequestHandler(w,me(import.meta.url,"./spec-download.api.js")),e.addApiRoute({slug:oe+"/*",requestHandlerId:w,httpMethod:"all",[D]:j,getStaticData:async()=>({props:{}})}),e.addApiRoute({slug:te+"/*",requestHandlerId:w,httpMethod:"all",[D]:j,getStaticData:async()=>({props:{}})});const A=e.createTemplate($,T("../../../client/templates/openapi-docs/template.js")),a=e.registerServerPropsGetter($,T("./get-server-props.js")),r=e.registerServerPropsGetter(ae,T("./get-server-props-custom-fields.js")),p=await i.getConfig();u?.setAttribute("config",JSON.stringify(p.openapi||{}));const h=p.rules?.["custom-fields-schema"];R={};const m=await e.loadOpenApiDefinitions(i);M=m.map(({markdocChunks:c,relativePath:f,customOutputRelativeFile:s,isVirtual:n,realRelativePath:d})=>({chunks:c,relativePath:f,realRelativePath:d,isVirtual:s!=null||n})),ce(m,e.outdir);const S={};for(const c of m||[]){const{definition:f,config:s,relativePath:n,customOutputRelativeFile:d,contentItems:_,flatItems:k,parser:E,options:B,rawOptions:q,hash:J}=c,N=d||n,o=[],x={},{definition:Q}=E||{},{info:l}=Q||{},v=l?.["x-metadata"],C=!!s.openapi?.excludeFromSearch||!!s.theme?.openapi?.excludeFromSearch||!!p.openapi?.excludeFromSearch||!!p.theme?.openapi?.excludeFromSearch,G={title:l?.title,description:l?.description,summary:l?.summary,...s.metadata,...v},g={untagged:[],tagged:new Map};for(const t of k){const{id:O,href:I,operationDefinition:b}=t;if(b){const{tags:P}=b;if(P)for(const F of P)g.tagged.has(F)||g.tagged.set(F,[]),g.tagged.get(F)?.push(t);else g.untagged.push(t);V.isDevelopMode&&(x[`#${b.pointer}`]=t.href)}if(!pe({item:t}))continue;const y=t,Y=y.type==="section"&&!!y.infoDefinition,z=I.split("#")[0]+"/",K=t?.operationDefinition?.[D],Z=re(s.access?.rbac)?s.access.rbac:void 0;o.push({excludeFromSearch:C,slugSuffix:z,fsPath:N,metadata:{subType:"openapi-operation"},httpVerb:t?.httpVerb||"",path:n,templateId:A,[D]:K||Z,getAiDocumentsStore:ue({parser:E,options:B,info:l,tagOperations:g,openapiContentItem:y,metadata:G,relativePath:n,getSearchFacets:e.getSearchFacets,includeInLLMsTxt:Y,excludeFromSearch:C}),getStaticData:async P=>({props:{dynamicMarkdocComponents:["openapi"],baseSlug:P.baseSlug,seo:t["x-metadata"]?.seo||{title:t.name,description:t.description},itemId:O,disableAutoScroll:!0}})})}o[0]={...o[0],metadata:{type:"openapi",...G},hasClientRoutes:!0,getSidebar:(t,O)=>{const I=[];return ie({contentItems:_,sidebarItems:I,routeSlug:t.slug,navItem:O}),I},getNavText:()=>l?.title,getSearchDocuments:ne(E,B,k,e.getSearchFacets,e.setSearchFacets,C)},v?.apiId&&(S[v.apiId]={slug:o[0]?.slug||""});const W=o[0];o[0]=o[o.length-1],o[o.length-1]=W;for(const t of o)e.addRoute({...t,serverPropsGetterIds:h?[a,r]:[a]});const X=V.isDevelopMode?n:void 0,H=`${U}${n}`;R[H]={fsPath:N,definition:f,options:q,sourcePath:X,routesMapping:x,hash:J};for(const t of o)e.addRoute({...t,sharedData:[{id:H,key:"openAPIDocsStore"}],serverPropsGetterIds:h?[a,r]:[a]})}e.setGlobalData({apiProducts:S})})},afterRoutesCreated:async(e,i)=>{const u=new Set;for(const{chunks:a,relativePath:r,isVirtual:p,realRelativePath:h}of M){const m=se(e.getAllRoutes(),r),S=(await i.cache.load(h,"load-oas")).compoundHash;await i.cache.load(r,{loader:async function(){for(const{node:f,markdown:s,key:n,relativePath:d}of a){const{ast:_}=await e.parseMarkdoc({input:{content:s,relativePath:d,isVirtual:p},context:i,deps:{sharedDataIds:[`${U}${d}`],routeSlugs:m}});f[`x-parsed-md-${n}`]={result:ee(_)}}},name:"openapi-markdoc-inline-parser"},[S]);for(const{pointer:c}of a)u.add(c)}const A=L.difference(u);for(const a of A)i.cache.delete(a);L=u;for(const[a,r]of Object.entries(R))await e.createSharedData(a,{...r,baseSlug:e.getRouteByFsPath(r.fsPath)?.baseSlug},r.hash)}}}export{Te as openAPIDocsPlugin};
@@ -1,3 +1,3 @@
1
- import*as l from"path";import{convertSwagger2OpenAPI as oo}from"@redocly/openapi-docs/lib/utils/convertSwagger2OpenAPI.js";import{Source as no,bundle as ro,createConfig as to,getTotals as io,resolvePlugins as eo}from"@redocly/openapi-core";import{normalizeOptions as ao,OpenAPIParser as so,buildContentItems as co}from"@redocly/openapi-docs";import{combineUrls as E}from"@redocly/theme/core/utils";import{CONFIG_FILE_NAME as A}from"../../../constants/common.js";import{PUBLIC_API_DEFINITIONS_FOLDER as P}from"../../constants/common.js";import{MAX_BUNDLING_ERRORS_TO_PRINT as fo}from"../../constants/plugins/openapi-docs.js";import{unique as lo}from"../../../utils/array/unique.js";import{deepMerge as F}from"../../../utils/object/deep-merge.js";import{pluralize as R}from"../../../utils/string/pluralize.js";import{replaceEnvVariablesDeep as po}from"../../utils/envs/replace-env-variables-deep.js";import{logger as N}from"../../tools/notifiers/logger.js";import{reporter as b}from"../../tools/notifiers/reporter.js";import{injectDecoratorIntoConfig as uo}from"./decorators.js";import{getAllApiConfigsByPath as mo}from"../get-api-config.js";import{normalizeFeedbackOptions as go}from"./utils.js";import{replaceFileExtension as L}from"./store-definition-bundles.js";import{ExternalResolver as wo}from"../../fs/utils/external-ref-resolver.js";import{formatBundleError as ho}from"./format-bundle-error.js";async function Mo(o,u){const{fs:r,cache:O,getConfig:g,isPathIgnored:m}=u;if(l.posix.basename(o)===A)return[];let s;try{s=(await O.load(o,"yaml")).data}catch{return[]}if(!s?.openapi&&!s?.swagger)return N.verbose(`${o} file is not definition. Skipping`),[];const p=await g("."),e=r.getFileInfo(o),n=await g(l.posix.dirname(o)),M=mo(n?.apis,o,n.configPath),S=[],V=await m(o);for(const c of M){if(!c.output&&V)continue;const T=F({decorators:p.decorators},n,{rbac:void 0},c),{resolvedObj:a}=po(T);if(a.decorators&&typeof a.decorators!="object"){await b.panicOnBuildContentError(`'decorators' must be an object at redocly.yaml, got '${typeof a.decorators}'`);continue}if(a.plugins&&!Array.isArray(a.plugins)){await b.panicOnBuildContentError(`'plugins' must be an array at redocly.yaml, got '${typeof a.plugins}'`);continue}const U=n.configPath?l.posix.dirname(n.configPath):".",t=c.output?l.posix.join(U,c.output):o;if(await m(t))continue;e&&c.output&&!r.exists(t)&&r.addVirtualFile(t,e);const z=l.resolve(r.cwd,n.realConfigPath||A),v=new wo(r),C=await to(uo(a,t,r.cwd),{configPath:z,externalRefResolver:v});p.plugins&&p.configPath!==n.configPath&&(C.plugins=lo([...C.plugins||[],...await eo(p.plugins,r.cwd)],f=>f.id));const D=l.resolve(r.cwd,o),G=await r.read(o),J={config:C,base:l.dirname(D),doc:{source:new no(D,G),parsed:JSON.parse(JSON.stringify(s))},externalRefResolver:v},{bundle:{parsed:y},problems:B,visitorsData:q}=await ro(J),H=q["markdown/markdown"]?.markdocChunks??[],i=io(B);let _=[i.errors&&`${i.errors} ${R(i.errors,"error","errors")}`,i.warnings&&`${i.warnings} ${R(i.warnings,"warning","warnings")}`,i.ignored&&`${i.ignored} ignored`].filter(Boolean).join(", ");if(i.errors){const f=B.filter(d=>d.severity==="error");let $=`${_} while bundling ${t} definition:
2
- `;const x=Math.min(f.length,fo);for(let d=0;d<x;d++){const Y=f[d],Z=await ho(Y,r.cwd);$+=`${Z}
3
- `}if(f.length>x){const d=f.length-x;$+=`... and ${d} more ${R(d,"error","errors")}`}await b.panicOnBuild($)}i.warnings&&N.warn(`${_} while bundling %rp definition`,t);const w=bo(y.swagger!==void 0?await oo(y):y,n.metadata),h=F(p.openapi||{},n.openapi||{},c.openapi||c?.theme?.openapi||{});h.showSchemaCatalogLinks&&(w["x-schema-catalog-link"]=E(P,t));const X=w["x-feedback"]||h.feedback||n.feedback,j={...h,feedback:go(X),hideSidebar:!0,disableRouter:!0,mockServer:a?.mockServer||p?.mockServer,downloadUrls:h.downloadUrls||[{url:E(P,`${L(t,".json")}?download`)},{url:E(P,`${L(t,".yaml")}?download`)}]},I=ao(j);let k;try{k=new so(w,void 0,I)}catch(f){await b.panicOnBuild(f);continue}const{contentItems:K,flatItems:Q}=co(k,I),W={definition:w,config:a,relativePath:t,realRelativePath:e?.realRelativePath||t,customOutputRelativeFile:c.output&&t,markdocChunks:H,contentItems:K,flatItems:Q,options:I,rawOptions:j,parser:k,isVirtual:e?.isVirtual??!1};S.push(W)}return S}async function Vo(o,u){const{fs:r,cache:O,getConfig:g}=u,m=[];for(const s of r.scan(/(\.ya?ml|\.json)$/)){if(!await g(l.posix.dirname(s.relativePath)))continue;const e=await O.load(s.relativePath,"load-oas");e.data&&e.data.length&&m.push(...e.data.map(n=>({...n,isVirtual:s.isVirtual||n.isVirtual,hash:e.compoundHash})))}return m}function bo(o,u){return u?{...o,info:{...o.info,"x-metadata":{...o.info["x-metadata"],...u}}}:o}export{Mo as definitionLoader,Vo as definitionsLoader};
1
+ import*as l from"path";import{convertSwagger2OpenAPI as no}from"@redocly/openapi-docs/lib/utils/convertSwagger2OpenAPI.js";import{Source as ro,bundle as to,createConfig as io,getTotals as eo,resolvePlugins as ao}from"@redocly/openapi-core";import{normalizeOptions as so,OpenAPIParser as co,buildContentItems as fo}from"@redocly/openapi-docs";import{combineUrls as E}from"@redocly/theme/core/utils";import{CONFIG_FILE_NAME as j}from"../../../constants/common.js";import{PUBLIC_API_DEFINITIONS_FOLDER as P}from"../../constants/common.js";import{MAX_BUNDLING_ERRORS_TO_PRINT as lo}from"../../constants/plugins/openapi-docs.js";import{unique as po}from"../../../utils/array/unique.js";import{deepMerge as F}from"../../../utils/object/deep-merge.js";import{pluralize as R}from"../../../utils/string/pluralize.js";import{replaceEnvVariablesDeep as uo}from"../../utils/envs/replace-env-variables-deep.js";import{logger as N}from"../../tools/notifiers/logger.js";import{reporter as b}from"../../tools/notifiers/reporter.js";import{injectDecoratorIntoConfig as mo}from"./decorators.js";import{getAllApiConfigsByPath as go}from"../get-api-config.js";import{normalizeFeedbackOptions as wo}from"./utils.js";import{replaceFileExtension as L}from"./store-definition-bundles.js";import{ExternalResolver as ho}from"../../fs/utils/external-ref-resolver.js";import{formatBundleError as bo}from"./format-bundle-error.js";import{ensureAccessBackwardsCompatibility as Oo}from"../config-parser/loaders/utils/read-and-validate-config.js";async function Uo(o,u){const{fs:r,cache:O,getConfig:g,isPathIgnored:m}=u;if(l.posix.basename(o)===j)return[];let s;try{s=(await O.load(o,"yaml")).data}catch{return[]}if(!s?.openapi&&!s?.swagger)return N.verbose(`${o} file is not definition. Skipping`),[];const p=await g("."),e=r.getFileInfo(o),n=await g(l.posix.dirname(o)),M=go(n?.apis,o,n.configPath),S=[],V=await m(o);for(const c of M){if(!c.output&&V)continue;const T=F({decorators:p.decorators},n,{rbac:void 0,access:{rbac:void 0}},c),{resolvedObj:U}=uo(T),a=Oo(U);if(a.decorators&&typeof a.decorators!="object"){await b.panicOnBuildContentError(`'decorators' must be an object at redocly.yaml, got '${typeof a.decorators}'`);continue}if(a.plugins&&!Array.isArray(a.plugins)){await b.panicOnBuildContentError(`'plugins' must be an array at redocly.yaml, got '${typeof a.plugins}'`);continue}const z=n.configPath?l.posix.dirname(n.configPath):".",t=c.output?l.posix.join(z,c.output):o;if(await m(t))continue;e&&c.output&&!r.exists(t)&&r.addVirtualFile(t,e);const G=l.resolve(r.cwd,n.realConfigPath||j),v=new ho(r),C=await io(mo(a,t,r.cwd),{configPath:G,externalRefResolver:v});p.plugins&&p.configPath!==n.configPath&&(C.plugins=po([...C.plugins||[],...await ao(p.plugins,r.cwd)],f=>f.id));const B=l.resolve(r.cwd,o),J=await r.read(o),q={config:C,base:l.dirname(B),doc:{source:new ro(B,J),parsed:JSON.parse(JSON.stringify(s))},externalRefResolver:v},{bundle:{parsed:y},problems:D,visitorsData:H}=await to(q),X=H["markdown/markdown"]?.markdocChunks??[],i=eo(D);let A=[i.errors&&`${i.errors} ${R(i.errors,"error","errors")}`,i.warnings&&`${i.warnings} ${R(i.warnings,"warning","warnings")}`,i.ignored&&`${i.ignored} ignored`].filter(Boolean).join(", ");if(i.errors){const f=D.filter(d=>d.severity==="error");let $=`${A} while bundling ${t} definition:
2
+ `;const x=Math.min(f.length,lo);for(let d=0;d<x;d++){const Z=f[d],oo=await bo(Z,r.cwd);$+=`${oo}
3
+ `}if(f.length>x){const d=f.length-x;$+=`... and ${d} more ${R(d,"error","errors")}`}await b.panicOnBuild($)}i.warnings&&N.warn(`${A} while bundling %rp definition`,t);const w=Co(y.swagger!==void 0?await no(y):y,n.metadata),h=F(p.openapi||{},n.openapi||{},c.openapi||c?.theme?.openapi||{});h.showSchemaCatalogLinks&&(w["x-schema-catalog-link"]=E(P,t));const K=w["x-feedback"]||h.feedback||n.feedback,_={...h,feedback:wo(K),hideSidebar:!0,disableRouter:!0,mockServer:a?.mockServer||p?.mockServer,downloadUrls:h.downloadUrls||[{url:E(P,`${L(t,".json")}?download`)},{url:E(P,`${L(t,".yaml")}?download`)}]},I=so(_);let k;try{k=new co(w,void 0,I)}catch(f){await b.panicOnBuild(f);continue}const{contentItems:Q,flatItems:W}=fo(k,I),Y={definition:w,config:a,relativePath:t,realRelativePath:e?.realRelativePath||t,customOutputRelativeFile:c.output&&t,markdocChunks:X,contentItems:Q,flatItems:W,options:I,rawOptions:_,parser:k,isVirtual:e?.isVirtual??!1};S.push(Y)}return S}async function zo(o,u){const{fs:r,cache:O,getConfig:g}=u,m=[];for(const s of r.scan(/(\.ya?ml|\.json)$/)){if(!await g(l.posix.dirname(s.relativePath)))continue;const e=await O.load(s.relativePath,"load-oas");e.data&&e.data.length&&m.push(...e.data.map(n=>({...n,isVirtual:s.isVirtual||n.isVirtual,hash:e.compoundHash})))}return m}function Co(o,u){return u?{...o,info:{...o.info,"x-metadata":{...o.info["x-metadata"],...u}}}:o}export{Uo as definitionLoader,zo as definitionsLoader};
@@ -1,5 +1,5 @@
1
- import{REDOCLY_TEAMS_RBAC as k}from"@redocly/config";import{basename as F,join as L}from"node:path";import{toMarkdown as _}from"../../../plugins/markdown/search/to-markdown.js";import{canDownloadApiDefinition as G,isResourcePubliclyAccessible as J}from"../../../utils/rbac.js";import{PUBLIC_API_DEFINITIONS_FOLDER as q}from"../../../constants/common.js";import{DEFAULT_ANONYMOUS_VISITOR_TEAM as z}from"../../../../constants/common.js";import{SearchIndexer as V}from"../search-indexer.js";import{getLocaleFromRelativePath as B}from"../../../fs/utils/get-locale-from-relative-path.js";import{extractDocumentSearchFacets as C}from"./search-facets.js";import{formatDocumentMetadata as Y}from"../../search/utils.js";import{getLLMsTxtMdSlug as H,llmsTxtLink as E}from"../../search/llmstxt/index.js";import{replaceFileExtension as K}from"../store-definition-bundles.js";const x=new Map,he=({parser:s,options:c,info:t,tagOperations:i,relativePath:n,openapiContentItem:e,metadata:r,getSearchFacets:o,includeInLLMsTxt:a,excludeFromSearch:m})=>async(u,f,l)=>{if(m)return;const D=await u.getNavText?.()||F(u.fsPath),A=new V(s,c,u.baseSlug||u.slug),p=A.addItem(e);if(!p)return;const O=await l.getConfig(),S=Array.isArray(p.title)?p.title.join(" "):p.title;let g,d,$=x.get(n);if((e.type==="tag"||e.type==="section"&&e.infoDefinition)&&!$){const{all:b,publiclyAccessible:y}=ne(i.tagged,A,O),{all:T,publiclyAccessible:w}=te(i.untagged,A,O);x.set(n,{taggedSearchDocuments:new Map(b),untaggedSearchDocuments:T,publiclyAccessibleTaggedSearchDocuments:new Map(y),publiclyAccessibleUntaggedSearchDocuments:w})}$=x.get(n);const h="#";switch(e.type){case"operation":const b=A.getOperation(e);g=d=Z({title:S,security:s.definition.security,document:p,version:p.version||t.version,headingLevel:h,operation:b});break;case"section":if(e.infoDefinition){$=x.get(n),d=await M({parser:s,info:t,staticData:f,relativePath:n,headingLevel:h,pageName:D,config:O}),d+=`
2
- `;for(const[T,w]of $?.publiclyAccessibleTaggedSearchDocuments?.entries()||[]){if(!w.length)return;const U=s.definition.tags?.find(N=>N.name===T);d+=j({title:U?.["x-displayName"]||T,description:U?.description,operationSearchDocuments:w,headingLevel:`${h}#`})}const y=$?.publiclyAccessibleUntaggedSearchDocuments||[];y.length&&(d+=j({title:"Other",description:void 0,operationSearchDocuments:y,headingLevel:`${h}#`})),g=await M({parser:s,info:t,staticData:f,relativePath:n,headingLevel:h,pageName:D,config:O})}else e.ast&&(d=g=_(e.ast));break;case"tag":d=j({title:S,description:e.description,operationSearchDocuments:$?.publiclyAccessibleTaggedSearchDocuments.get(e.name)||[],headingLevel:h}),g=j({title:S,description:e.description,operationSearchDocuments:[],headingLevel:h});break;case"rsrc":case"prompt":case"tool":d=I({title:S,description:e.description,name:e.name,xMcpConfig:s.definition["x-mcp"],headingLevel:h}),g=d;break}return{async getLLMsTxts(){return[{title:e.name,description:e.type==="tag"?e.description:void 0,content:d||"",slug:u.slug,fsPath:u.fsPath,includeInLLMsTxt:a}]},async getSearchDocuments(){if(e.type==="operation"||e.type==="section"&&(e.infoDefinition||e.ast)||e.type==="tag"){const b=B(u.fsPath),y=C({...p,...r},t,o);return[{title:S,description:Array.isArray(p.text)?p.text.join(" "):p.text,content:g||"",url:p.url??u.slug,fsPath:u.fsPath,locale:b,product:u.product?.name,rbacTeams:p.rbacTeams,facets:y}]}return[]}}};async function M({parser:s,info:c,staticData:t,relativePath:i,pageName:n,headingLevel:e,config:r}){const o=Y(c["x-metadata"]);let a=c.title?`${e} ${c.title}
1
+ import{REDOCLY_TEAMS_RBAC as k}from"@redocly/config";import{basename as F,join as L}from"node:path";import{toMarkdown as _}from"../../../plugins/markdown/search/to-markdown.js";import{canDownloadApiDefinition as q,isResourcePubliclyAccessible as G}from"../../../utils/rbac.js";import{PUBLIC_API_DEFINITIONS_FOLDER as J}from"../../../constants/common.js";import{DEFAULT_ANONYMOUS_VISITOR_TEAM as z}from"../../../../constants/common.js";import{getLlmsTxtMdPathBySlug as B}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{SearchIndexer as V}from"../search-indexer.js";import{getLocaleFromRelativePath as C}from"../../../fs/utils/get-locale-from-relative-path.js";import{extractDocumentSearchFacets as Y}from"./search-facets.js";import{formatDocumentMetadata as H}from"../../search/utils.js";import{llmsTxtLink as E}from"../../search/llmstxt/index.js";import{replaceFileExtension as K}from"../store-definition-bundles.js";const x=new Map,ge=({parser:s,options:c,info:t,tagOperations:r,relativePath:n,openapiContentItem:e,metadata:i,getSearchFacets:o,includeInLLMsTxt:a,excludeFromSearch:f})=>async(u,m,l)=>{if(f)return;const D=await u.getNavText?.()||F(u.fsPath),A=new V(s,c,u.baseSlug||u.slug),p=A.addItem(e);if(!p)return;const O=await l.getConfig(),S=Array.isArray(p.title)?p.title.join(" "):p.title;let g,d,$=x.get(n);if((e.type==="tag"||e.type==="section"&&e.infoDefinition)&&!$){const{all:b,publiclyAccessible:y}=ne(r.tagged,A,O),{all:T,publiclyAccessible:w}=te(r.untagged,A,O);x.set(n,{taggedSearchDocuments:new Map(b),untaggedSearchDocuments:T,publiclyAccessibleTaggedSearchDocuments:new Map(y),publiclyAccessibleUntaggedSearchDocuments:w})}$=x.get(n);const h="#";switch(e.type){case"operation":const b=A.getOperation(e);g=d=Z({title:S,security:s.definition.security,document:p,version:p.version||t.version,headingLevel:h,operation:b});break;case"section":if(e.infoDefinition){$=x.get(n),d=await M({parser:s,info:t,staticData:m,relativePath:n,headingLevel:h,pageName:D,config:O}),d+=`
2
+ `;for(const[T,w]of $?.publiclyAccessibleTaggedSearchDocuments?.entries()||[]){if(!w.length)return;const U=s.definition.tags?.find(N=>N.name===T);d+=j({title:U?.["x-displayName"]||T,description:U?.description,operationSearchDocuments:w,headingLevel:`${h}#`})}const y=$?.publiclyAccessibleUntaggedSearchDocuments||[];y.length&&(d+=j({title:"Other",description:void 0,operationSearchDocuments:y,headingLevel:`${h}#`})),g=await M({parser:s,info:t,staticData:m,relativePath:n,headingLevel:h,pageName:D,config:O})}else e.ast&&(d=g=_(e.ast));break;case"tag":d=j({title:S,description:e.description,operationSearchDocuments:$?.publiclyAccessibleTaggedSearchDocuments.get(e.name)||[],headingLevel:h}),g=j({title:S,description:e.description,operationSearchDocuments:[],headingLevel:h});break;case"rsrc":case"prompt":case"tool":d=I({title:S,description:e.description,name:e.name,xMcpConfig:s.definition["x-mcp"],headingLevel:h}),g=d;break}return{async getLLMsTxts(){return[{title:e.name,description:e.type==="tag"?e.description:void 0,content:d||"",slug:u.slug,fsPath:u.fsPath,includeInLLMsTxt:a}]},async getSearchDocuments(){if(e.type==="operation"||e.type==="section"&&(e.infoDefinition||e.ast)||e.type==="tag"){const b=C(u.fsPath),y=Y({...p,...i},t,o);return[{title:S,description:Array.isArray(p.text)?p.text.join(" "):p.text,content:g||"",url:p.url??u.slug,fsPath:u.fsPath,locale:b,product:u.product?.name,rbacTeams:p.rbacTeams,facets:y}]}return[]}}};async function M({parser:s,info:c,staticData:t,relativePath:r,pageName:n,headingLevel:e,config:i}){const o=H(c["x-metadata"]);let a=c.title?`${e} ${c.title}
3
3
 
4
4
  `:`${e} ${n}
5
5
 
@@ -12,30 +12,30 @@ import{REDOCLY_TEAMS_RBAC as k}from"@redocly/config";import{basename as F,join a
12
12
  `:"",e=`${e}#`,a+=o.length?`Metadata:
13
13
  ${o}
14
14
  `:"",a+=`
15
- `,a+=Q({parser:s,headingLevel:e}),a+=X({parser:s,headingLevel:e}),a+=await W({info:c,staticData:t,relativePath:i,pageName:n,headingLevel:e,config:r}),a}function j({title:s="",description:c,operationSearchDocuments:t,headingLevel:i}){let n=`${i} ${s}
15
+ `,a+=Q({parser:s,headingLevel:e}),a+=X({parser:s,headingLevel:e}),a+=await W({info:c,staticData:t,relativePath:r,pageName:n,headingLevel:e,config:i}),a}function j({title:s="",description:c,operationSearchDocuments:t,headingLevel:r}){let n=`${r} ${s}
16
16
 
17
17
  `;return c&&(n+=`${c}
18
18
 
19
- `),t.length&&t.forEach(e=>{const r=Array.isArray(e.title)?e.title.join(" "):e.title;n+=`${i}# ${r}${e.deprecated?" (deprecated)":""}
19
+ `),t.length&&t.forEach(e=>{const i=Array.isArray(e.title)?e.title.join(" "):e.title;n+=`${r}# ${i}${e.deprecated?" (deprecated)":""}
20
20
 
21
- `,n+=` - ${E({title:`${e.httpMethod?.toUpperCase()} ${e.httpPath}`,description:Array.isArray(e.text)?e.text.join(" "):e.text,slug:H(e.url)})}`,n+=`
22
- `}),n}function Q({parser:s,headingLevel:c}){const{servers:t}=s.definition;if(t&&t.length){let i=`${c} Servers
21
+ `,n+=` - ${E({title:`${e.httpMethod?.toUpperCase()} ${e.httpPath}`,description:Array.isArray(e.text)?e.text.join(" "):e.text,slug:B(e.url)})}`,n+=`
22
+ `}),n}function Q({parser:s,headingLevel:c}){const{servers:t}=s.definition;if(t&&t.length){let r=`${c} Servers
23
23
 
24
- `;return t.forEach(n=>{i+=n.description?`${n.description}
25
- `:"",i+=`\`\`\`
24
+ `;return t.forEach(n=>{r+=n.description?`${n.description}
25
+ `:"",r+=`\`\`\`
26
26
  ${n.url}
27
27
  \`\`\`
28
28
 
29
- `,n.variables&&(i+=`Variables:
30
- `,Object.entries(n.variables).forEach(([e,r])=>{i+=`- \`${e}\`${r.description?`: ${r.description}`:""}
31
- `,i+=r.default?`Default: ${JSON.stringify(r.default)}
32
- `:"",i+=r.enum?`Enum: ${r.enum.map(o=>JSON.stringify(o)).join(", ")}
33
- `:""}),i+=`
34
- `)}),i}return""}async function W({info:s,staticData:c,relativePath:t,pageName:i,headingLevel:n,config:e}){const r=L(c.props?.outdir||"",q,K(t,".yaml"));if(G(r,e.rbac||{},e.requiresLogin||!1,{isAuthenticated:!1,teams:[z]})){let o=`${n} Download OpenAPI description
29
+ `,n.variables&&(r+=`Variables:
30
+ `,Object.entries(n.variables).forEach(([e,i])=>{r+=`- \`${e}\`${i.description?`: ${i.description}`:""}
31
+ `,r+=i.default?`Default: ${JSON.stringify(i.default)}
32
+ `:"",r+=i.enum?`Enum: ${i.enum.map(o=>JSON.stringify(o)).join(", ")}
33
+ `:""}),r+=`
34
+ `)}),r}return""}async function W({info:s,staticData:c,relativePath:t,pageName:r,headingLevel:n,config:e}){const i=L(c.props?.outdir||"",J,K(t,".yaml")),o=e.access?.rbac,a=e.access?.requiresLogin;if(q(i,o??{},a??!1,{isAuthenticated:!1,teams:[z]})){let f=`${n} Download OpenAPI description
35
35
 
36
- `;return o+=E({title:s.title||i||"OpenAPI definition",description:void 0,slug:r}),o}return""}function X({parser:s,headingLevel:c}){if(!s.definition.components?.securitySchemes)return"";let t=`${c} Security
36
+ `;return f+=E({title:s.title||r||"OpenAPI definition",description:void 0,slug:i}),f}return""}function X({parser:s,headingLevel:c}){if(!s.definition.components?.securitySchemes)return"";let t=`${c} Security
37
37
 
38
- `;const{securitySchemes:i}=s.definition.components;return Object.keys(i).forEach(n=>{const e=i[n];e&&(t+=`${c}# ${n}
38
+ `;const{securitySchemes:r}=s.definition.components;return Object.keys(r).forEach(n=>{const e=r[n];e&&(t+=`${c}# ${n}
39
39
 
40
40
  `,t+=e.description?`${e.description}
41
41
 
@@ -47,46 +47,46 @@ ${n.url}
47
47
  `),e.bearerFormat&&(t+=`Bearer Format: ${e.bearerFormat}
48
48
  `),e.flows?.implicit?.authorizationUrl&&(t+=`Authorization URL: ${e.flows.implicit?.authorizationUrl}
49
49
  `),e.flows?.implicit?.scopes&&(t+=`Scopes:
50
- `,Object.entries(e.flows?.implicit?.scopes||{}).forEach(([r,o])=>{t+=`- \`${r}\`: ${o}
50
+ `,Object.entries(e.flows?.implicit?.scopes||{}).forEach(([i,o])=>{t+=`- \`${i}\`: ${o}
51
51
  `})),e.flows?.password?.tokenUrl&&(t+=`Token URL: ${e.flows.password?.tokenUrl}
52
52
  `),e.flows?.password?.scopes&&(t+=`Scopes:
53
- `,Object.entries(e.flows?.password?.scopes||{}).forEach(([r,o])=>{t+=`- \`${r}\`: ${o}
53
+ `,Object.entries(e.flows?.password?.scopes||{}).forEach(([i,o])=>{t+=`- \`${i}\`: ${o}
54
54
  `})),t+=`
55
- `)}),t}function Z({title:s,security:c,document:t,version:i,headingLevel:n,operation:e}){const{text:r,httpMethod:o,httpPath:a,deprecated:m}=t,u=ee(t.parameters||[],`${n}#`),f=v(`${n}#`,t.parameters,e);let l=s?`${n} ${s}${m?" (deprecated)":""}
55
+ `)}),t}function Z({title:s,security:c,document:t,version:r,headingLevel:n,operation:e}){const{text:i,httpMethod:o,httpPath:a,deprecated:f}=t,u=ee(t.parameters||[],`${n}#`),m=v(`${n}#`,t.parameters,e);let l=s?`${n} ${s}${f?" (deprecated)":""}
56
56
 
57
- `:"";return l+=r?`${r}
57
+ `:"";return l+=i?`${i}
58
58
 
59
59
  `:"",l+=`Endpoint: ${o?.toUpperCase()} ${a}
60
- `,l+=i?`Version: ${i}
60
+ `,l+=r?`Version: ${r}
61
61
  `:"",l+=t.security?.length?`Security: ${t.security.join(", ")}
62
62
  `:c?.length?`Security: ${c.map(D=>D.id).join(", ")}
63
63
  `:"",l+=`
64
64
  `,l+=u?`${u}
65
65
  `:"",l+=`
66
- `,l+=`${f.join(`
67
- `)}`,l}function I({title:s,name:c,xMcpConfig:t,headingLevel:i}){const n=t?.tools.find(r=>r.name===c);if(!n)return"";let e=`${i} ${s}
66
+ `,l+=`${m.join(`
67
+ `)}`,l}function I({title:s,name:c,xMcpConfig:t,headingLevel:r}){const n=t?.tools.find(i=>i.name===c);if(!n)return"";let e=`${r} ${s}
68
68
 
69
69
  `;return e+=n.description?`${n.description}
70
70
 
71
- `:"",e+=`${i}# Input schema:
71
+ `:"",e+=`${r}# Input schema:
72
72
 
73
73
  `,e+=`\`\`\`json
74
74
  ${JSON.stringify(n.inputSchema,null,2)}
75
75
  \`\`\`
76
76
 
77
- `,n.outputSchema&&(e+=`${i}# Output schema:
77
+ `,n.outputSchema&&(e+=`${r}# Output schema:
78
78
 
79
79
  `,e+=`\`\`\`json
80
80
  ${JSON.stringify(n.outputSchema,null,2)}
81
81
  \`\`\`
82
82
 
83
83
  `),e}function v(s,c,t){return!c&&!t||!t?.responses?[]:t?.responses.filter(n=>!n.content?.mediaTypes[0]?.schema).map(n=>`${s} ${P(`response ${n.code} fields`)}
84
- `)}function ee(s,c){const t={};for(const n of s){const e=`${n.place}${n.mediaType?` (${n.mediaType})`:""}`;t[e]=[...t[e]||[],n]}return Object.entries(t).map(([n,e])=>{const r=e.map(o=>{const a=" ",m=[...o.path||[],o.name],u=Array.isArray(o.description)?o.description.join(" "):o.description;let f=` - \`${m.join(".")}\` (${o.type}${o.required?", required":""})
85
- `;return f+=u?`${a}${u.trim()}
86
- `:"",o.enum?f+=`${a}Enum: ${o.enum.map(l=>JSON.stringify(l)).join(", ")}
87
- `:o.example&&(f+=`${a}Example: ${o.example}
88
- `),f});return`${c} ${P(n)}:
84
+ `)}function ee(s,c){const t={};for(const n of s){const e=`${n.place}${n.mediaType?` (${n.mediaType})`:""}`;t[e]=[...t[e]||[],n]}return Object.entries(t).map(([n,e])=>{const i=e.map(o=>{const a=" ",f=[...o.path||[],o.name],u=Array.isArray(o.description)?o.description.join(" "):o.description;let m=` - \`${f.join(".")}\` (${o.type}${o.required?", required":""})
85
+ `;return m+=u?`${a}${u.trim()}
86
+ `:"",o.enum?m+=`${a}Enum: ${o.enum.map(l=>JSON.stringify(l)).join(", ")}
87
+ `:o.example&&(m+=`${a}Example: ${o.example}
88
+ `),m});return`${c} ${P(n)}:
89
89
 
90
- ${r.join(`
90
+ ${i.join(`
91
91
  `)}`}).join(`
92
- `)}function ne(s,c,t){const i=[],n=[];return s.forEach((e,r)=>{const o=[],a=[];e.forEach(m=>{const u=c.addItem(m);u&&(o.push(u),R({[k]:m[k],slug:u.url},t)&&a.push(u))}),i.push([r,o]),n.push([r,a])}),{all:i,publiclyAccessible:n}}function te(s,c,t){const i=[],n=[];return s.forEach(e=>{const r=c.addItem(e);r&&(i.push(r),R({[k]:e[k],slug:r.url},t)&&n.push(r))}),{all:i,publiclyAccessible:n}}function P(s){return s.charAt(0).toUpperCase()+s.slice(1)}function R(s,c){return c.requiresLogin?!0:J(s,c)}export{he as getAiDocumentsStore};
92
+ `)}function ne(s,c,t){const r=[],n=[];return s.forEach((e,i)=>{const o=[],a=[];e.forEach(f=>{const u=c.addItem(f);u&&(o.push(u),R({[k]:f[k],slug:u.url},t)&&a.push(u))}),r.push([i,o]),n.push([i,a])}),{all:r,publiclyAccessible:n}}function te(s,c,t){const r=[],n=[];return s.forEach(e=>{const i=c.addItem(e);i&&(r.push(i),R({[k]:e[k],slug:i.url},t)&&n.push(i))}),{all:r,publiclyAccessible:n}}function P(s){return s.charAt(0).toUpperCase()+s.slice(1)}function R(s,c){return c.access?.requiresLogin?!0:G(s,c)}export{ge as getAiDocumentsStore};
@@ -1 +1 @@
1
- import o from"node:path";import{readFile as x,existsSync as h}from"node:fs";import{promisify as N}from"node:util";import S from"js-yaml";import{withoutPathPrefix as _}from"@redocly/theme/core/utils";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as P,PUBLIC_API_DEFINITIONS_FOLDER as F}from"../../constants/common.js";import{canDownloadApiDefinition as L,filterDataByAccessDeep as O}from"../../utils/rbac.js";import{replaceFileExtension as y}from"./store-definition-bundles.js";const U=N(x),j=async(I,s,n)=>{const{isAuthenticated:e,teams:a,claims:{email:i}}=s.user,A=new URL(I.url),r=_(A.pathname),t=decodeURIComponent(r.replace(F,"").replace(P,"")),{rbac:c={},requiresLogin:p=!1}=s.config;if(!L(r,c,p,{isAuthenticated:e,email:i,teams:a}))return new Response("Unauthorized",{status:e?403:401});const l=o.join(n.props?.outdir||"",F,y(t,".json")),m=o.join(n.props?.outdir||"",P,y(t,".json")),f=h(l),D=h(m);if(!f&&!D)return new Response("Not found",{status:404});const E=await U(f?l:m,"utf-8"),R=JSON.parse(E),u=O(R,{isAuthenticated:e,email:i,teams:a},c,p),d=o.extname(t),w=d===".yaml"?S.dump(u):JSON.stringify(u,null,2);return new Response(w,{headers:{"Content-Type":d===".yaml"?"application/yaml":"application/json"}})};var H=j;export{H as default};
1
+ import o from"node:path";import{readFile as L,existsSync as P}from"node:fs";import{promisify as N}from"node:util";import S from"js-yaml";import{withoutPathPrefix as _}from"@redocly/theme/core/utils";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as F,PUBLIC_API_DEFINITIONS_FOLDER as y}from"../../constants/common.js";import{canDownloadApiDefinition as C,filterDataByAccessDeep as O}from"../../utils/rbac.js";import{replaceFileExtension as I}from"./store-definition-bundles.js";const U=N(L),g=async(A,s,n)=>{const{isAuthenticated:e,teams:a,claims:{email:i}}=s.user,D=new URL(A.url),r=_(D.pathname),t=decodeURIComponent(r.replace(y,"").replace(F,"")),c=s.config.access??{},p=c.rbac??{},l=c.requiresLogin??!1;if(!C(r,p,l,{isAuthenticated:e,email:i,teams:a}))return new Response("Unauthorized",{status:e?403:401});const m=o.join(n.props?.outdir||"",y,I(t,".json")),f=o.join(n.props?.outdir||"",F,I(t,".json")),u=P(m),E=P(f);if(!u&&!E)return new Response("Not found",{status:404});const R=await U(u?m:f,"utf-8"),w=JSON.parse(R),d=O(w,{isAuthenticated:e,email:i,teams:a},p,l),h=o.extname(t),x=h===".yaml"?S.dump(d):JSON.stringify(d,null,2);return new Response(x,{headers:{"Content-Type":h===".yaml"?"application/yaml":"application/json"}})};var K=g;export{K as default};
@@ -1,4 +1,4 @@
1
- import w from"node:path";import R from"picomatch";import{removeLeadingSlash as S}from"@redocly/theme/core/utils";import{parsePathVersions as O}from"../../../utils/path/parse-path-versions.js";import{logger as l}from"../../tools/notifiers/logger.js";import{ScorecardStatus as g}from"./types.js";import{getTarget as L}from"./loaders/scorecard.js";const P=15;async function $({actions:t,context:e,scorecardConfig:a,reuniteConfig:n}){l.info("Computing scorecard...");const i=a.levels||[],o=i[0],m=await t.loadOpenApiDefinitions(e),s=a.ignore||[],d=R(s),f=new Set,h=l.startTiming(),c={},p={};for(const r of m){if(!M(r,d,f))continue;const v=r.customOutputRelativeFile||r.realRelativePath;f.add(v);const u=await T(r,e,a,i,o);c[r.realRelativePath]=u,p[u.relativePath]=u}return l.infoTime(h,"Scorecard processed"),N(c,n,a),p}function M(t,e,a){if(t.isVirtual||!t.definition)return!1;const n=t.customOutputRelativeFile||t.realRelativePath,i=S(t.realRelativePath);return e(i)?(l.info(`Skipping scorecard calculation for ignored file: ${t.realRelativePath}`),!1):!a.has(n)}function D(t,e,a){return t-1<e?g.BelowMinimum:e<a-1?g.Minimum:g.Highest}async function T(t,e,a,n,i){let o=i.name;if(a.targets?.length){const r=await e.getConfig(w.posix.dirname(t.realRelativePath)),v=t.definition.info?.["x-metadata"]||{},u={title:t.definition.info?.title,version:t.definition.info?.version,...v,...r.metadata};o=await B(a,u)||i.name}const{data:{levels:m,scorecardLevelIdx:s,scorecardLevel:d}}=await e.cache.load(t.realRelativePath,"scorecard"),f=n.findIndex(r=>r.name===o),h=D(s,f,n.length),c=t.customOutputRelativeFile||t.realRelativePath,p=O(c)?.versionName;return{levels:m,status:h,targetLevel:o,scorecardLevel:d,scorecardLevelIdx:s,relativePath:c,title:t.definition.info?.title,version:p}}function N(t,e,a){const n=Object.values(t).filter(s=>s.status===g.BelowMinimum);if(n.length===0)return;const i=n.map(s=>s.relativePath);let o=`Detected OpenAPI definitions with score below minimum level:
2
- - ${i.slice(0,P).map(()=>"%rp").join(`
3
- - `)}`;i.length>P&&(o+=`
4
- ... and ${i.length-P} more`),e?.ignoreLint??a.ignoreNonCompliant?l.warn(o,...i):l.error(o,...i)}async function B(t,e){return(await L(t.targets,e))?.minimumLevel}export{$ as computeScorecard};
1
+ import w from"node:path";import R from"picomatch";import{removeLeadingSlash as S}from"@redocly/theme/core/utils";import{parsePathVersions as O}from"../../../utils/path/parse-path-versions.js";import{logger as l}from"../../tools/notifiers/logger.js";import{ScorecardStatus as d}from"./types.js";import{getTarget as M}from"./loaders/scorecard.js";const P=15;async function y({actions:t,context:i,scorecardConfig:e,reuniteConfig:o}){l.info("Computing scorecard...");const a=e.levels||[],n=a[0],u=await t.loadOpenApiDefinitions(i),s=e.ignore||[],h=R(s),f=new Set,g=l.startTiming(),c={},p={};for(const r of u){if(!D(r,h,f))continue;const v=r.customOutputRelativeFile||r.realRelativePath;f.add(v);const m=await N(r,i,e,a,n);c[r.realRelativePath]=m,p[m.relativePath]=m}return l.infoTime(g,"Scorecard processed"),T(c,o,e),p}function D(t,i,e){if(t.isVirtual||!t.definition)return!1;const o=t.customOutputRelativeFile||t.realRelativePath,a=S(t.realRelativePath);return i(a)?(l.info(`Skipping scorecard calculation for ignored file: ${t.realRelativePath}`),!1):!e.has(o)}function L(t,i,e){return t-1<i?d.BelowMinimum:i<e-1?d.Minimum:d.Highest}async function N(t,i,e,o,a){let n=a.name;if(e.targets?.length){const r=await i.getConfig(w.posix.dirname(t.realRelativePath)),v=t.definition.info?.["x-metadata"]||{},m={title:t.definition.info?.title,version:t.definition.info?.version,...v,...r.metadata};n=(await M(e.targets,m))?.minimumLevel||a.name}const{data:{levels:u,scorecardLevelIdx:s,scorecardLevel:h}}=await i.cache.load(t.realRelativePath,"scorecard"),f=o.findIndex(r=>r.name===n),g=L(s,f,o.length),c=t.customOutputRelativeFile||t.realRelativePath,p=O(c)?.versionName;return{levels:u,status:g,targetLevel:n,scorecardLevel:h,scorecardLevelIdx:s,relativePath:c,title:t.definition.info?.title,version:p}}function T(t,i,e){const o=Object.values(t).filter(s=>s.status===d.BelowMinimum);if(o.length===0)return;const a=o.map(s=>s.relativePath);let n=`Detected OpenAPI definitions with score below minimum level:
2
+ - ${a.slice(0,P).map(()=>"%rp").join(`
3
+ - `)}`;a.length>P&&(n+=`
4
+ ... and ${a.length-P} more`),i?.ignoreLint??e.ignoreNonCompliant?l.warn(n,...a):l.error(n,...a)}export{y as computeScorecard};
@@ -1 +1 @@
1
- import l from"node:path";import{createConfig as m,loadIgnoreConfig as u}from"@redocly/openapi-core";import{ruleTypes as p}from"@redocly/config";import{ExternalResolver as C}from"../../../fs/utils/external-ref-resolver.js";import{deepMerge as d}from"../../../../utils/object/deep-merge.js";import{CONFIG_FILE_NAME as v}from"../../../../constants/common.js";import{getScorecardConfig as w}from"../get-scorecard-config.js";async function N(i,r){const e=await r.getConfig(),n=w(e),t=n.levels??[],o=l.join(r.fs.cwd,v),f=new C(r.fs),s=await u(o,f),c=await a(t,e.plugins,o,s),g=await y(n.targets,t,e.plugins,o,s);return{levelsConfig:t,configs:c,targets:g}}async function a(i,r=[],e,n){const t={};for(const o of i)t[o.name]=await m({...o,plugins:r},{configPath:e,ignore:n});return t}async function y(i,r,e=[],n,t){return i?Promise.all(i?.filter(o=>!!o.rules).map(async o=>{const f=r.map(s=>({...s,...L(s,o.rules)}));return{...o,configs:await a(f,e,n,t)}})||[]):[]}function L(i,r){return p.reduce((e,n)=>(e[n]=d(i[n]??{},r??{}),e),{})}export{N as scorecardConfigLoader};
1
+ import l from"node:path";import{createConfig as c,loadIgnoreConfig as m}from"@redocly/openapi-core";import{ExternalResolver as u}from"../../../fs/utils/external-ref-resolver.js";import{CONFIG_FILE_NAME as C}from"../../../../constants/common.js";import{getScorecardConfig as p}from"../get-scorecard-config.js";async function _(i,e){const r=await e.getConfig(),s=p(r),n=s.levels??[],o=l.join(e.fs.cwd,C),t=new u(e.fs),a=await m(o,t),f=await v(n,r.plugins,o,a),g=await d(s.targets,n,r.plugins,o,a);return{levelsConfig:n,configs:f,targets:g}}async function v(i,e=[],r,s){const n={};for(const o of i)n[o.name]=await c({...o,plugins:e},{configPath:r,ignore:s});return n}async function w(i,e,r=[],s,n){const o={};for(const t of i){const a=await c({...t,apis:{[t.name]:{root:"scorecard-target",rules:e}},plugins:r},{configPath:s,ignore:n});o[t.name]=a.forAlias(t.name)}return o}async function d(i,e,r=[],s,n){return i?Promise.all(i?.filter(o=>!!o.rules).map(async o=>({...o,configs:await w(e,o.rules,r,s,n)}))||[]):[]}export{_ as scorecardConfigLoader};