@redocly/revel 0.138.1 → 0.139.0-next.10

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 (139) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/dist/cli/eject/resolveEjectParams.js +1 -1
  3. package/dist/client/app/Sidebar/RequestAccessButton.js +2 -2
  4. package/dist/client/app/hooks/useL10nConfig.d.ts +1 -0
  5. package/dist/client/app/markdoc/custom-components/openapi/openapi-example.js +1 -1
  6. package/dist/client/app/markdoc/custom-components/openapi/replay-openapi.js +1 -1
  7. package/dist/client/app/search/useSearch.js +1 -1
  8. package/dist/client/app/utils/programmatic-scroll.js +1 -1
  9. package/dist/client/app/webmcp/tools/api-tools.js +1 -1
  10. package/dist/client/app/webmcp/tools/site-tools.js +2 -2
  11. package/dist/client/app/webmcp/useWebMcpTools.js +1 -1
  12. package/dist/client/templates/api-docs/template.js +10 -8
  13. package/dist/constants/common.d.ts +1 -0
  14. package/dist/constants/common.js +1 -1
  15. package/dist/constants/l10n/langs/ar.js +1 -1
  16. package/dist/constants/l10n/langs/de.js +1 -1
  17. package/dist/constants/l10n/langs/en.js +1 -1
  18. package/dist/constants/l10n/langs/es.js +1 -1
  19. package/dist/constants/l10n/langs/fr.js +1 -1
  20. package/dist/constants/l10n/langs/hi.js +1 -1
  21. package/dist/constants/l10n/langs/it.js +1 -1
  22. package/dist/constants/l10n/langs/ja.js +1 -1
  23. package/dist/constants/l10n/langs/ko.js +1 -1
  24. package/dist/constants/l10n/langs/pl.js +1 -1
  25. package/dist/constants/l10n/langs/pt-BR.js +1 -1
  26. package/dist/constants/l10n/langs/pt.js +1 -1
  27. package/dist/constants/l10n/langs/ru.js +1 -1
  28. package/dist/constants/l10n/langs/uk.js +1 -1
  29. package/dist/constants/l10n/langs/zh.js +1 -1
  30. package/dist/markdoc/helpers/get-inner-text.d.ts +2 -0
  31. package/dist/markdoc/helpers/get-inner-text.js +2 -2
  32. package/dist/markdoc/helpers/remove-markdoc-tags.js +1 -1
  33. package/dist/server/config/env-schemas/feature-flags.d.ts +1 -1
  34. package/dist/server/constants/entitlements.d.ts +2 -2
  35. package/dist/server/constants/entitlements.js +1 -1
  36. package/dist/server/entitlements/entitlements-provider.d.ts +2 -2
  37. package/dist/server/entitlements/is-valid-plan.d.ts +2 -2
  38. package/dist/server/entitlements/is-valid-plan.js +1 -1
  39. package/dist/server/fs/content-fs.js +1 -1
  40. package/dist/server/fs/utils/external-ref-resolver.js +2 -2
  41. package/dist/server/fs/utils/is-translation-fallback.d.ts +9 -0
  42. package/dist/server/fs/utils/is-translation-fallback.js +1 -0
  43. package/dist/server/node-bundle-entry.js +1 -1
  44. package/dist/server/plugins/api-docs/get-server-props.js +1 -1
  45. package/dist/server/plugins/api-docs/index.js +1 -1
  46. package/dist/server/plugins/api-docs/search/create-indexer.d.ts +9 -2
  47. package/dist/server/plugins/api-docs/search/create-indexer.js +1 -1
  48. package/dist/server/plugins/api-docs/search/get-ai-search-documents.js +72 -72
  49. package/dist/server/plugins/api-docs/search/search-resolver.js +1 -1
  50. package/dist/server/plugins/arazzo-docs/arazzo-doc-loader.js +2 -2
  51. package/dist/server/plugins/arazzo-docs/index.js +1 -1
  52. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/openapi-entities-extractor.js +1 -1
  53. package/dist/server/plugins/catalog-entities/template/index.js +1 -1
  54. package/dist/server/plugins/config-parser/loaders/utils/read-and-validate-config.js +1 -1
  55. package/dist/server/plugins/config-parser/loaders/versions-config-loader.js +1 -1
  56. package/dist/server/plugins/default-theme/resolve-logo.js +1 -1
  57. package/dist/server/plugins/dev-onboarding/api/routes/index.js +1 -1
  58. package/dist/server/plugins/dev-onboarding/api/routes/products.js +1 -1
  59. package/dist/server/plugins/dev-onboarding/template/App.js +4 -4
  60. package/dist/server/plugins/dev-onboarding/template/AppsList.js +7 -7
  61. package/dist/server/plugins/dev-onboarding/template/CreateAppDialog.js +3 -3
  62. package/dist/server/plugins/dev-onboarding/template/components/ApiKeyItem.js +4 -4
  63. package/dist/server/plugins/dev-onboarding/template/components/ApiLogDetails.js +7 -7
  64. package/dist/server/plugins/dev-onboarding/template/components/ApiLogs.js +5 -5
  65. package/dist/server/plugins/dev-onboarding/template/components/ApiLogsActions.js +6 -6
  66. package/dist/server/plugins/dev-onboarding/template/components/ApisList.js +1 -1
  67. package/dist/server/plugins/dev-onboarding/template/components/CreateApiKey.js +1 -1
  68. package/dist/server/plugins/dev-onboarding/template/components/DeleteAppDialog.js +1 -1
  69. package/dist/server/plugins/dev-onboarding/template/components/EditApis.js +1 -1
  70. package/dist/server/plugins/dev-onboarding/template/components/EditAppDescriptionDialog.js +1 -1
  71. package/dist/server/plugins/dev-onboarding/template/components/EditAppDialog.js +1 -1
  72. package/dist/server/plugins/dev-onboarding/template/components/EditCallbackUrlDialog.js +1 -1
  73. package/dist/server/plugins/dev-onboarding/template/components/RevokeAPIKey.js +5 -5
  74. package/dist/server/plugins/dev-onboarding/template/components/RollAPIKey.js +5 -5
  75. package/dist/server/plugins/dev-onboarding/template/components/UpdateApiKey.js +1 -1
  76. package/dist/server/plugins/l10n/index.js +1 -1
  77. package/dist/server/plugins/markdown/attribute-resolvers/resolve-json-example-ref.js +1 -1
  78. package/dist/server/plugins/markdown/attribute-resolvers/resolve-link.js +1 -1
  79. package/dist/server/plugins/markdown/get-server-props.js +1 -1
  80. package/dist/server/plugins/markdown/index.js +1 -1
  81. package/dist/server/plugins/markdown/markdoc/plugins/utils.js +1 -1
  82. package/dist/server/plugins/markdown/markdoc/resolve-raw-partials.js +1 -1
  83. package/dist/server/plugins/markdown/markdown-static-data-loader.js +1 -1
  84. package/dist/server/plugins/markdown/read-file-content.js +1 -1
  85. package/dist/server/plugins/markdown/search/search-resolver.js +1 -1
  86. package/dist/server/plugins/mcp/codemode/capabilities/utils.js +4 -4
  87. package/dist/server/plugins/mcp/codemode/constants.js +1 -1
  88. package/dist/server/plugins/mcp/codemode/prompts.d.ts +2 -2
  89. package/dist/server/plugins/mcp/codemode/prompts.js +8 -8
  90. package/dist/server/plugins/mcp/codemode/tools/describe-tools.js +2 -2
  91. package/dist/server/plugins/mcp/codemode/tools/execute-schema.d.ts +2 -0
  92. package/dist/server/plugins/mcp/codemode/tools/execute-schema.js +1 -1
  93. package/dist/server/plugins/mcp/constants.d.ts +2 -2
  94. package/dist/server/plugins/mcp/constants.js +1 -1
  95. package/dist/server/plugins/mcp/docs-mcp/tool-schemas.js +1 -1
  96. package/dist/server/plugins/mcp/docs-mcp/tools/core/create-anonymous-session.js +1 -1
  97. package/dist/server/plugins/mcp/docs-mcp/tools/core/submit-feedback.js +2 -2
  98. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/endpoint-suggestions.d.ts +0 -2
  99. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/endpoint-suggestions.js +1 -1
  100. package/dist/server/plugins/mcp/gateway-mcp/allowed-http-methods.d.ts +0 -5
  101. package/dist/server/plugins/mcp/gateway-mcp/allowed-http-methods.js +1 -1
  102. package/dist/server/plugins/mcp/gateway-mcp/callable-apis.d.ts +3 -2
  103. package/dist/server/plugins/mcp/gateway-mcp/callable-apis.js +1 -1
  104. package/dist/server/plugins/mcp/gateway-mcp/caller-api-calls.d.ts +3 -4
  105. package/dist/server/plugins/mcp/gateway-mcp/caller-api-calls.js +1 -1
  106. package/dist/server/plugins/mcp/gateway-mcp/eligibility.d.ts +1 -12
  107. package/dist/server/plugins/mcp/gateway-mcp/eligibility.js +1 -1
  108. package/dist/server/plugins/mcp/handlers/docs-mcp-handler.js +1 -1
  109. package/dist/server/plugins/mcp/handlers/errors.d.ts +0 -2
  110. package/dist/server/plugins/mcp/handlers/errors.js +1 -1
  111. package/dist/server/plugins/mcp/servers/docs-server.js +1 -1
  112. package/dist/server/plugins/mcp/utils/docs-site-url.d.ts +6 -0
  113. package/dist/server/plugins/mcp/utils/docs-site-url.js +1 -0
  114. package/dist/server/plugins/mcp/utils.d.ts +0 -8
  115. package/dist/server/plugins/mcp/utils.js +1 -1
  116. package/dist/server/plugins/nav-utils.js +1 -1
  117. package/dist/server/plugins/pages/index.js +1 -1
  118. package/dist/server/plugins/register-page-props.d.ts +1 -1
  119. package/dist/server/plugins/register-page-props.js +1 -1
  120. package/dist/server/plugins/sidebars/index.js +1 -1
  121. package/dist/server/plugins/sidebars/utils.js +1 -1
  122. package/dist/server/types/plugins/markdown.d.ts +1 -0
  123. package/dist/server/utils/envs/load-env-variables.js +1 -1
  124. package/dist/server/utils/rbac-expand.d.ts +4 -0
  125. package/dist/server/utils/rbac-expand.js +1 -1
  126. package/dist/server/utils/rbac.js +1 -1
  127. package/dist/server/utils/resolve-asset-path.js +1 -1
  128. package/dist/server/web-server/auth.d.ts +2 -0
  129. package/dist/server/web-server/auth.js +3 -3
  130. package/dist/server/web-server/jwt/jwt.js +1 -1
  131. package/dist/server/web-server/middleware/catalogAuthMiddleware.js +1 -1
  132. package/dist/server/web-server/routes/mcp-routes/mcp-server-card.js +1 -1
  133. package/dist/types/entitlements.d.ts +2 -1
  134. package/dist/types/global-data.d.ts +1 -0
  135. package/dist/utils/url/api-keys-url.d.ts +11 -0
  136. package/dist/utils/url/api-keys-url.js +1 -0
  137. package/package.json +7 -7
  138. package/dist/server/plugins/mcp/docs-mcp/tools/core/utils.d.ts +0 -3
  139. package/dist/server/plugins/mcp/docs-mcp/tools/core/utils.js +0 -11
@@ -12,6 +12,8 @@ import type { GetInnerContentFnOptions } from '../../types/index.js';
12
12
  * - `isTrim` (default: true): Whether to trim whitespace from each part and the final result.
13
13
  * - `skipConditionals`: If true, conditional nodes are skipped entirely.
14
14
  * - `variables`: Optional variable values to resolve `Variable` nodes.
15
+ * - `renderTag`: Optional custom renderer for tag nodes; falls back to the default
16
+ * child-walk when it returns `undefined`.
15
17
  *
16
18
  * @returns A concatenated string of inner text extracted from the provided nodes.
17
19
  */
@@ -1,2 +1,2 @@
1
- import{isPrimitive as n}from"../../utils/guards/is-primitive.js";import{getNodeAttribute as o}from"./get-node-attribute.js";import{getVariable as p}from"./get-variable.js";import{isNode as l}from"./guards/is-node.js";import{isTag as a}from"./guards/is-tag.js";import{isCodeNode as u}from"./guards/is-code-node.js";import{isConditionalNode as c}from"./guards/is-conditional-node.js";import{isExampleNode as d}from"./guards/is-example-node.js";import{isFenceNode as h}from"./guards/is-fence-node.js";import{isTextNode as N}from"./guards/is-text-node.js";import{isFunction as b}from"./guards/is-function.js";import{isVariable as g}from"./guards/is-variable.js";import{isPromptNode as x}from"./guards/is-prompt-node.js";function t(m,r={}){const{isTrim:s=!0}=r,e=[];for(const i of m){if(n(i))e.push(String(i));else if(l(i)){if(x(i))continue;if(i.type==="tr"&&e.push(`
2
- `),N(i)||u(i)||h(i))e.push(t([o(i,"content")],r));else if(d(i))e.push(t(i.children.map(f=>o(f,"content")),r));else{if(c(i)&&r.skipConditionals)continue;e.push(t(i.children,r))}}else a(i)?e.push(t(i.children,r)):b(i)&&e.push(t(Object.values(i.parameters),r));g(i)&&e.push(t([p(i,r.variables)],r))}return s?e.map(i=>i.trim()).join(" ").trim():e.join(" ")}export{t as getInnerText};
1
+ import{isPrimitive as n}from"../../utils/guards/is-primitive.js";import{getNodeAttribute as o}from"./get-node-attribute.js";import{getVariable as l}from"./get-variable.js";import{isNode as p}from"./guards/is-node.js";import{isTag as a}from"./guards/is-tag.js";import{isCodeNode as d}from"./guards/is-code-node.js";import{isConditionalNode as c}from"./guards/is-conditional-node.js";import{isExampleNode as u}from"./guards/is-example-node.js";import{isFenceNode as h}from"./guards/is-fence-node.js";import{isTextNode as g}from"./guards/is-text-node.js";import{isFunction as N}from"./guards/is-function.js";import{isVariable as T}from"./guards/is-variable.js";import{isPromptNode as b}from"./guards/is-prompt-node.js";function t(f,r={}){const{isTrim:s=!0}=r,i=[];for(const e of f){if(n(e))i.push(String(e));else if(p(e)){if(b(e))continue;if(e.type==="tr"&&i.push(`
2
+ `),g(e)||d(e)||h(e))i.push(t([o(e,"content")],r));else if(u(e))i.push(t(e.children.map(m=>o(m,"content")),r));else{if(c(e)&&r.skipConditionals)continue;if(e.type==="tag"&&r.renderTag){const m=()=>t(e.children,r);i.push(r.renderTag(e,{getBody:m})??m())}else i.push(t(e.children,r))}}else a(e)?i.push(t(e.children,r)):N(e)&&i.push(t(Object.values(e.parameters),r));T(e)&&i.push(t([l(e,r.variables)],r))}return s?i.map(e=>e.trim()).join(" ").trim():i.join(" ")}export{t as getInnerText};
@@ -1 +1 @@
1
- import e from"@markdoc/markdoc";import{getInnerText as n}from"./get-inner-text.js";function a(r){if(!r)return r;const o=e.parse(r);return n([o])}export{a as removeMarkdocTags};
1
+ import n from"@markdoc/markdoc";import{skipAgentsOnlyContent as e}from"@redocly/theme/markdoc/tags/visibility";import{getInnerText as t}from"./get-inner-text.js";function a(r){if(!r)return r;const o=n.parse(r);return t([o],{renderTag:e})}export{a as removeMarkdocTags};
@@ -15,7 +15,7 @@ export declare const featureFlagsSchema: z.ZodObject<{
15
15
  REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_URL: z.ZodOptional<z.ZodString>;
16
16
  /** (Optional) API endpoint for the agent feedback endpoint;**/
17
17
  REDOCLY_EXP_LLMSTXT_AGENT_ENDPOINT: z.ZodOptional<z.ZodString>;
18
- /** Experimental: enables the GraphQL request body in Try It and embedded Replay. */
18
+ /** Experimental: enables the GraphQL request body in Try It and embedded Replay, and shows Try it on GraphQL operation pages. */
19
19
  REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED: z.ZodEffects<z.ZodOptional<z.ZodEnum<["true", "false"]>>, boolean | undefined, "false" | "true" | undefined>;
20
20
  }, "strip", z.ZodTypeAny, {
21
21
  NEW_CATALOG_ENABLED?: boolean | undefined;
@@ -1,6 +1,6 @@
1
- import type { PlanGates, ProductPlan, Feature } from '../../types/index.js';
1
+ import type { PlanGates, PricingTier, Feature } from '../../types/index.js';
2
2
  export declare const PLAN_GATES_DEFAULTS: {
3
- [key in ProductPlan]: PlanGates;
3
+ [key in PricingTier]: PlanGates;
4
4
  };
5
5
  export declare const GATED_PLUGINS: string[];
6
6
  export declare const GATED_MARKDOC_TAGS: Record<string, Feature>;
@@ -1 +1 @@
1
- import{GATEWAY_FETCH_LIMIT_DEFAULTS as e,MCP_REQUEST_LIMIT_DEFAULTS as t}from"../../constants/common.js";const r={pro:{rbac:!1,sso:!1,cookieConsent:!1,analytics:!0,removeAttribution:!1,advancedSearch:!1,ssoDirect:!1,aiSearchLimit:0,kvStorageLimit:.5,mcp:!1,mcpGateway:!1,mcpMode:"tools",gatewayFetchRatePerMin:e.ratePerMin,gatewayFetchQuotaPerDay:e.quotaPerDay,gatewayFetchBudgetPerExec:e.budgetPerExec,mcpRequestRatePerMin:t.ratePerMin,mcpRequestQuotaPerDay:t.quotaPerDay},enterprise:{rbac:!0,sso:!0,cookieConsent:!0,analytics:!0,removeAttribution:!0,advancedSearch:!0,ssoDirect:!1,aiSearchLimit:750,kvStorageLimit:5,mcp:!0,mcpGateway:!0,mcpMode:"code",gatewayFetchRatePerMin:e.ratePerMin,gatewayFetchQuotaPerDay:e.quotaPerDay,gatewayFetchBudgetPerExec:e.budgetPerExec,mcpRequestRatePerMin:t.ratePerMin,mcpRequestQuotaPerDay:t.quotaPerDay}},o=["@redocly/portal-plugin-async-api/plugin.js","@redocly/portal-plugin-mock-server/plugin.js","@redocly/portal-plugin-soap-api/plugin.js"],c={"code-walkthrough":"codeWalkthrough",step:"codeWalkthrough",toggle:"codeWalkthrough",input:"codeWalkthrough"};export{c as GATED_MARKDOC_TAGS,o as GATED_PLUGINS,r as PLAN_GATES_DEFAULTS};
1
+ import{GATEWAY_FETCH_LIMIT_DEFAULTS as e,MCP_REQUEST_LIMIT_DEFAULTS as t}from"../../constants/common.js";const r={pro:{rbac:!1,sso:!1,cookieConsent:!1,analytics:!0,removeAttribution:!1,advancedSearch:!1,ssoDirect:!1,aiSearchLimit:750,kvStorageLimit:.5,mcp:!0,mcpGateway:!1,sdkGeneration:!1,mcpMode:"tools",gatewayFetchRatePerMin:e.ratePerMin,gatewayFetchQuotaPerDay:e.quotaPerDay,gatewayFetchBudgetPerExec:e.budgetPerExec,mcpRequestRatePerMin:t.ratePerMin,mcpRequestQuotaPerDay:t.quotaPerDay},scale:{rbac:!1,sso:!0,cookieConsent:!0,analytics:!0,removeAttribution:!0,advancedSearch:!0,ssoDirect:!0,aiSearchLimit:750,kvStorageLimit:5,mcp:!0,mcpGateway:!1,sdkGeneration:!0,mcpMode:"tools",gatewayFetchRatePerMin:e.ratePerMin,gatewayFetchQuotaPerDay:e.quotaPerDay,gatewayFetchBudgetPerExec:e.budgetPerExec,mcpRequestRatePerMin:t.ratePerMin,mcpRequestQuotaPerDay:t.quotaPerDay},enterprise:{rbac:!0,sso:!0,cookieConsent:!0,analytics:!0,removeAttribution:!0,advancedSearch:!0,ssoDirect:!1,aiSearchLimit:750,kvStorageLimit:5,mcp:!0,mcpGateway:!0,sdkGeneration:!0,mcpMode:"code",gatewayFetchRatePerMin:e.ratePerMin,gatewayFetchQuotaPerDay:e.quotaPerDay,gatewayFetchBudgetPerExec:e.budgetPerExec,mcpRequestRatePerMin:t.ratePerMin,mcpRequestQuotaPerDay:t.quotaPerDay}},o=["@redocly/portal-plugin-async-api/plugin.js","@redocly/portal-plugin-mock-server/plugin.js","@redocly/portal-plugin-soap-api/plugin.js"],c={"code-walkthrough":"codeWalkthrough",step:"codeWalkthrough",toggle:"codeWalkthrough",input:"codeWalkthrough"};export{c as GATED_MARKDOC_TAGS,o as GATED_PLUGINS,r as PLAN_GATES_DEFAULTS};
@@ -1,7 +1,7 @@
1
- import type { Entitlements, Feature, ProductPlan } from '../../types/index.js';
1
+ import type { Entitlements, Feature, PricingTier } from '../../types/index.js';
2
2
  type InitOptions = {
3
3
  ignoreTokenExpiration?: boolean;
4
- developModePlan?: ProductPlan;
4
+ developModePlan?: PricingTier;
5
5
  };
6
6
  export declare class EntitlementsProvider {
7
7
  #private;
@@ -1,3 +1,3 @@
1
- import type { ProductPlan } from '../../types/index.js';
2
- export declare function isValidPlan(plan: string): plan is ProductPlan;
1
+ import type { PricingTier } from '../../types/index.js';
2
+ export declare function isValidPlan(plan: string): plan is PricingTier;
3
3
  //# sourceMappingURL=is-valid-plan.d.ts.map
@@ -1 +1 @@
1
- function n(e){return["pro","enterprise"].includes(e)}export{n as isValidPlan};
1
+ function n(e){return["pro","scale","enterprise"].includes(e)}export{n as isValidPlan};
@@ -1 +1 @@
1
- import m from"node:path";import{I18N_DIR_NAME as f,L10N_DIR_NAME as h}from"../constants/common.js";import{logger as c}from"../tools/notifiers/logger.js";import{Fs as F}from"./fs.js";import{isL10nPath as n}from"./utils/is-l10n-path.js";import{getLocaleFromRelativePath as d}from"./utils/get-locale-from-relative-path.js";import{isL10nRootFile as u}from"./utils/is-l10n-root-file.js";import{removeL10nPrefix as l}from"./utils/remove-l10n-prefix.js";import{LastModifiedTracker as g}from"./last-modified-tracker.js";class b extends F{cwd;ignored;#e=new Map;#t=new Set;#i;#s;constructor(e,t=[]){super(e,t),this.cwd=e,this.ignored=t,this.#i=new g(this),this.#r()}get localeFolders(){return Array.from(this.#e.keys())}get localizationFolder(){if(this.#s)return this.#s;let e=!1,t=!1;const s=this.localeFolders;if(!s.length)return;for(const i of s)for(const r of this.#e.get(i)?.values()||[]){const a=r.startsWith(h),p=r.startsWith(f);a&&!e&&(e=!0),p&&!t&&(t=!0)}e&&t?c.warn("Detected both `@l10n` and `@i18n` folders. Using `@l10n` folder for localization because `@i18n` folder is deprecated."):t&&c.warn("`@i18n` folder is deprecated. Please use `@l10n` folder instead.");const o=e?h:f;return this.#s=o,o}getFileInfo(e){if(e=e.replace(/^\.\//g,""),n(e)){if(super.exists(e))return super.getFileInfo(e);const t=l(e),s=super.getFileInfo(t);return s&&{...s,relativePath:e,realRelativePath:t,dirname:m.posix.dirname(e),isVirtual:!0}}return super.getFileInfo(e)}exists(e){return e=e.replace(/^\.\//g,""),n(e)?super.exists(e)||super.exists(l(e)):super.exists(e)}async read(e,t="utf-8"){return n(e)?await super.exists(e)?super.read(e,t):super.read(l(e),t):super.read(e,t)}scan(e){let t=super.scan(e);this.#t.size>0&&(t=t.filter(i=>!this.#t.has(i.relativePath)));const s={},o=new Set;for(const i of t)if(n(i.relativePath)){const r=d(i.relativePath),a=s[r]||new Set;a.add(l(i.relativePath)),s[r]=a}else o.add(i.relativePath);for(const i of o.values())for(const r of this.#e.keys())if(!s[r]?.has(i)){const a=`${this.localizationFolder}/${r}/${i}`;t.push({realRelativePath:i,relativePath:a,isVirtual:!0,hash:void 0})}return t}getLastModified(e){const t=this.getFileInfo(e);return this.#i.getLastModified(t?.realRelativePath||e)}#o(e){this.#t.add(e);const t=e.split("/")[0];c.warn(`The file %rp is placed directly in the ${t} folder root and does not belong to any locale, so it is ignored. Move it into a locale folder, for example ${t}/<locale>/.`,e)}async#r(){await this.watcher,this.#e=new Map,this.#t=new Set;for(const e of this.filesList.values()){if(!n(e.relativePath))continue;if(u(e.relativePath)){this.#o(e.relativePath);continue}const t=d(e.relativePath),s=this.#e.get(t)||new Set;s.add(e.relativePath),this.#e.set(t,s)}super.watch(async e=>{for(const t of e){if(t.event==="code-updated"||!n(t.path))continue;if(u(t.path)){t.event==="add"&&this.#o(t.path),t.event==="unlink"&&this.#t.delete(t.path);continue}const s=d(t.path),o=this.#e.get(s)||new Set;switch(t.event){case"add":o.add(t.path),this.#e.set(s,o);break;case"unlink":o&&(o.delete(t.path),o.size===0&&this.#e.delete(s));break}}})}}export{b as ContentFs};
1
+ import m from"node:path";import{I18N_DIR_NAME as f,L10N_DIR_NAME as h}from"../constants/common.js";import{logger as c}from"../tools/notifiers/logger.js";import{Fs as F}from"./fs.js";import{isL10nPath as n}from"./utils/is-l10n-path.js";import{getLocaleFromRelativePath as d}from"./utils/get-locale-from-relative-path.js";import{isL10nRootFile as u}from"./utils/is-l10n-root-file.js";import{removeL10nPrefix as l}from"./utils/remove-l10n-prefix.js";import{LastModifiedTracker as g}from"./last-modified-tracker.js";class b extends F{cwd;ignored;#e=new Map;#t=new Set;#i;#s;constructor(e,t=[]){super(e,t),this.cwd=e,this.ignored=t,this.#i=new g(this),this.#r()}get localeFolders(){return Array.from(this.#e.keys())}get localizationFolder(){if(this.#s)return this.#s;let e=!1,t=!1;const s=this.localeFolders;if(!s.length)return;for(const i of s)for(const r of this.#e.get(i)?.values()||[]){const a=r.startsWith(h),p=r.startsWith(f);a&&!e&&(e=!0),p&&!t&&(t=!0)}e&&t?c.warn("Detected both `@l10n` and `@i18n` folders. Using `@l10n` folder for localization because `@i18n` folder is deprecated."):t&&c.warn("`@i18n` folder is deprecated. Please use `@l10n` folder instead.");const o=e?h:f;return this.#s=o,o}getFileInfo(e){if(e=e.replace(/^\.\//g,""),n(e)){if(super.exists(e))return super.getFileInfo(e);const t=l(e),s=super.getFileInfo(t);return s&&{...s,relativePath:e,realRelativePath:t,dirname:m.posix.dirname(e),isVirtual:!0}}return super.getFileInfo(e)}exists(e){return e=e.replace(/^\.\//g,""),n(e)?super.exists(e)||super.exists(l(e)):super.exists(e)}async read(e,t="utf-8"){return n(e)?super.exists(e)?super.read(e,t):super.read(l(e),t):super.read(e,t)}scan(e){let t=super.scan(e);this.#t.size>0&&(t=t.filter(i=>!this.#t.has(i.relativePath)));const s={},o=new Set;for(const i of t)if(n(i.relativePath)){const r=d(i.relativePath),a=s[r]||new Set;a.add(l(i.relativePath)),s[r]=a}else o.add(i.relativePath);for(const i of o.values())for(const r of this.#e.keys())if(!s[r]?.has(i)){const a=`${this.localizationFolder}/${r}/${i}`;t.push({realRelativePath:i,relativePath:a,isVirtual:!0,hash:void 0})}return t}getLastModified(e){const t=this.getFileInfo(e);return this.#i.getLastModified(t?.realRelativePath||e)}#o(e){this.#t.add(e);const t=e.split("/")[0];c.warn(`The file %rp is placed directly in the ${t} folder root and does not belong to any locale, so it is ignored. Move it into a locale folder, for example ${t}/<locale>/.`,e)}async#r(){await this.watcher,this.#e=new Map,this.#t=new Set;for(const e of this.filesList.values()){if(!n(e.relativePath))continue;if(u(e.relativePath)){this.#o(e.relativePath);continue}const t=d(e.relativePath),s=this.#e.get(t)||new Set;s.add(e.relativePath),this.#e.set(t,s)}super.watch(async e=>{for(const t of e){if(t.event==="code-updated"||!n(t.path))continue;if(u(t.path)){t.event==="add"&&this.#o(t.path),t.event==="unlink"&&this.#t.delete(t.path);continue}const s=d(t.path),o=this.#e.get(s)||new Set;switch(t.event){case"add":o.add(t.path),this.#e.set(s,o);break;case"unlink":o&&(o.delete(t.path),o.size===0&&this.#e.delete(s));break}}})}}export{b as ContentFs};
@@ -1,3 +1,3 @@
1
- import{BaseResolver as i,ResolveError as h,Source as n,isAbsoluteUrl as l,readFileFromUrl as m}from"@redocly/openapi-core";import f from"path";import{slash as p}from"../../../utils/path/slash.js";const d=/^https?:\/\/.*\/_bundle\/(.*\.(?:yaml|json)$)/;class v extends i{fs;constructor(t){super(),this.fs=t}async resolveDocument(t,s,e=!1){const r=this.resolveExternalRef(t,s),a=this.cache.get(r);if(a)return a;const c=this.loadExternalRef(r).then(o=>this.parseDocument(o,e));return this.cache.set(r,c),c}async loadExternalRef(t){try{const s=t.match(d);if(s){const[,e]=s;if(await this.fs.exists(e)){const r=await this.fs.read(e);return new n(e,r.replace(/\r\n/g,`
2
- `))}}if(l(t)){const{body:e,mimeType:r}=await m(t,this.config.http);return new n(t,e,r)}else{const e=p(f.relative(this.fs.cwd,t)),r=await this.fs.read(e);return new n(t,r.replace(/\r\n/g,`
1
+ import{BaseResolver as i,ResolveError as h,Source as n,isAbsoluteUrl as l,readFileFromUrl as m}from"@redocly/openapi-core";import f from"path";import{slash as p}from"../../../utils/path/slash.js";const d=/^https?:\/\/.*\/_bundle\/(.*\.(?:yaml|json)$)/;class v extends i{fs;constructor(e){super(),this.fs=e}async resolveDocument(e,s,t=!1){const r=this.resolveExternalRef(e,s),c=this.cache.get(r);if(c)return c;const a=this.loadExternalRef(r).then(o=>this.parseDocument(o,t));return this.cache.set(r,a),a}async loadExternalRef(e){try{const s=e.match(d);if(s){const[,t]=s;if(this.fs.exists(t)){const r=await this.fs.read(t);return new n(t,r.replace(/\r\n/g,`
2
+ `))}}if(l(e)){const{body:t,mimeType:r}=await m(e,this.config.http);return new n(e,t,r)}else{const t=p(f.relative(this.fs.cwd,e)),r=await this.fs.read(t);return new n(e,r.replace(/\r\n/g,`
3
3
  `))}}catch(s){throw s.message=s.message.replace(", lstat",""),new h(s)}}}export{v as ExternalResolver};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Tells if a file record is the default-locale file that a missing translation falls back to.
3
+ * A virtual record outside the locale folders is a generated file, not a fallback.
4
+ */
5
+ export declare function isTranslationFallback(record?: {
6
+ relativePath?: string;
7
+ isVirtual?: boolean;
8
+ }): boolean;
9
+ //# sourceMappingURL=is-translation-fallback.d.ts.map
@@ -0,0 +1 @@
1
+ import{isL10nPath as t}from"./is-l10n-path.js";function l(a){return!!(a?.isVirtual&&a.relativePath&&t(a.relativePath))}export{l as isTranslationFallback};
@@ -1 +1 @@
1
- import{resolve as n,dirname as f}from"node:path";import{fileURLToPath as l}from"node:url";import{readFile as u}from"fs/promises";import{createReadStream as d}from"fs";import{envConfig as v}from"./config/env-config.js";import{telemetry as g}from"./telemetry/index.js";import{createRouter as S}from"./web-server/router.js";import{installProdRoutes as R}from"./web-server/routes/index.js";import{Store as w}from"./store.js";import{loadEnvVariables as x}from"./utils/envs/load-env-variables.js";import{startHttpServer as D}from"./web-server/http.js";import{readStaticData as P}from"./utils/static-data.js";import{startIdleTimeout as E}from"./web-server/middleware/idleTimeoutMiddleware.js";import{reporter as y}from"./tools/notifiers/reporter.js";import{logger as b}from"./tools/notifiers/logger.js";import{EntitlementsProvider as h}from"./entitlements/entitlements-provider.js";import{DatabasePreconnectService as I}from"./providers/database/database-preconnect-service.js";import{KvService as O}from"./persistence/kv/services/kv-service.js";import{runScorecardsWorker as N}from"./plugins/scorecards/workers/run-scorecards-worker.js";import{isScorecardsEnabled as T}from"./utils/is-scorecards-enabled.js";import{isRealmOrReef as k}from"./utils/is-realm-or-reef.js";import{renderPage as or}from"./ssr/index.js";const A=new URL(import.meta.url),F=A.searchParams.get("only-exports")==="true";if(!F){let p=function(){const r=process.argv.findIndex(i=>i==="--port"||i==="-p");if(r===-1)return null;const t=process.argv[r+1];if(t.startsWith("-"))return null;const o=parseInt(t,10);return isNaN(o)?null:o};const e=f(l(import.meta.url));await x(e);const s=JSON.parse(await u(n(e,"./store.json"),"utf-8")),m=w.fromJson(s,{outdir:n(e,"../client"),serverOutDir:e,serverMode:!0,contentDir:""});if(await h.instance().init({ignoreTokenExpiration:!0}),k()){await I.init(e);const r=await O.getInstance({baseDbDir:e});setInterval(()=>{r.clearExpired().catch(t=>{b.error("Failed to clear expired KV entries",t)})},300*1e3)}c(m).catch(r=>{console.error(r)});async function c(r){g.initialize();const t=await S();R(t,r,{readStaticAsset:async a=>d(a),resolveRouteData:async a=>P(a.slug,r.outdir)}),y.printErrors();const o=p(),i=v.PORT;return await D(t,o??i??4e3),E(),T(r.config)&&N(r.serverOutDir,r.config.scorecards),t}}export{or as renderPage};
1
+ import{resolve as n,dirname as f}from"node:path";import{fileURLToPath as l}from"node:url";import{readFile as u}from"fs/promises";import{createReadStream as d}from"fs";import{envConfig as v}from"./config/env-config.js";import{telemetry as g}from"./telemetry/index.js";import{createRouter as S}from"./web-server/router.js";import{installProdRoutes as R}from"./web-server/routes/index.js";import{Store as x}from"./store.js";import{loadEnvVariables as D}from"./utils/envs/load-env-variables.js";import{startHttpServer as P}from"./web-server/http.js";import{readStaticData as w}from"./utils/static-data.js";import{startIdleTimeout as E}from"./web-server/middleware/idleTimeoutMiddleware.js";import{reporter as y}from"./tools/notifiers/reporter.js";import{logger as b}from"./tools/notifiers/logger.js";import{EntitlementsProvider as h}from"./entitlements/entitlements-provider.js";import{DatabasePreconnectService as I}from"./providers/database/database-preconnect-service.js";import{KvService as O}from"./persistence/kv/services/kv-service.js";import{runScorecardsWorker as N}from"./plugins/scorecards/workers/run-scorecards-worker.js";import{isScorecardsEnabled as T}from"./utils/is-scorecards-enabled.js";import{isRealmOrReef as k}from"./utils/is-realm-or-reef.js";import{renderPage as or}from"./ssr/index.js";const A=new URL(import.meta.url),F=A.searchParams.get("only-exports")==="true";if(!F){let p=function(){const r=process.argv.findIndex(i=>i==="--port"||i==="-p");if(r===-1)return null;const t=process.argv[r+1];if(t.startsWith("-"))return null;const o=parseInt(t,10);return isNaN(o)?null:o};const e=f(l(import.meta.url));await D(e);const s=JSON.parse(await u(n(e,"./store.json"),"utf-8")),m=x.fromJson(s,{outdir:n(e,"../client"),serverOutDir:e,serverMode:!0,contentDir:""});if(await h.instance().init({ignoreTokenExpiration:!0}),k()){await I.init(e);const r=await O.getInstance({baseDbDir:e});setInterval(()=>{r.clearExpired().catch(t=>{b.error("Failed to clear expired KV entries",t)})},300*1e3)}c(m).catch(r=>{console.error(r)});async function c(r){g.initialize();const t=S();R(t,r,{readStaticAsset:async a=>d(a),resolveRouteData:async a=>w(a.slug,r.outdir)}),y.printErrors();const o=p(),i=v.PORT;return await P(t,o??i??4e3),E(),T(r.config)&&N(r.serverOutDir,r.config.scorecards),t}}export{or as renderPage};
@@ -1 +1 @@
1
- import{getPublicEnvVariables as n}from"../../utils/envs/get-public-env-variables.js";const l=async({fsPath:r,slug:e},t,{partials:a,variables:i},o)=>{const s=o.getPartialsForRoute?.(e)||a;return{definitionId:r,...t.props,markdown:{partials:s,variables:{...i,env:n()}}}};var d=l;export{d as default};
1
+ import{getPublicEnvVariables as n}from"../../utils/envs/get-public-env-variables.js";const o=async({fsPath:a,slug:t},r,{partials:e,variables:i},l)=>{const s=l.getPartialsForRoute?.(t)||e;return{definitionId:a,...r.props,markdown:{partials:s,variables:{...i,env:n()}},...r.isTranslationFallback?{isTranslationFallback:!0}:{}}};var p=o;export{p as default};
@@ -1 +1 @@
1
- import{REDOCLY_ROUTE_RBAC as E,REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{mcpTagSchemas as Z,schemaDefinitionTag as ee,markdocParser as U}from"@redocly/api-docs";import{withPathPrefix as q}from"@redocly/theme/core/utils";import{API_DOCS_TEMPLATE_ID as V,GRAPHQL_SPEC_SLUG as te,PUBLIC_RBAC_SCOPE_ITEM as x}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as oe,PUBLIC_API_DEFINITIONS_FOLDER as re}from"../../constants/common.js";import{API_DOCS_SHARED_DATA_PREFIX as w}from"../../constants/plugins/api-docs.js";import{fromCurrentDir as ae}from"../../utils/paths.js";import{normalizeRouteSlug as se}from"../../../utils/path/normalize-route-slug.js";import{createSlugify as ie}from"../create-slugify.js";import{apiDocLoader as ne,apiDocsLoader as ce}from"./loader.js";import{getTemplatePath as j}from"./get-template-path.js";import{storeDefinitionBundles as pe}from"./store-definition-bundles.js";import{telemetryTraceStep as ue}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as de}from"./search/search-resolver.js";import{getAiDocumentsStore as le}from"./search/get-ai-search-documents.js";import{getApiConfigByPath as me}from"../get-api-config.js";import{getRouteSlugsForPath as fe}from"../utils.js";import{collectItemRoutes as he}from"./utils/collect-item-routes.js";import{isChunkCurrent as ge}from"./utils/decorators.js";import{applyNavItemToRoot as De}from"./utils/apply-nav-item-to-root.js";import{buildRoutesMapping as Se}from"./utils/build-routes-mapping.js";import{buildItemPositions as Pe}from"./utils/build-item-positions.js";import{resolveApiDocTitle as ye}from"./utils/resolve-api-doc-title.js";import{resolveConfigRbac as Ie}from"./utils/resolve-config-rbac.js";import{relativePathToBaseSlug as Ae}from"./utils/relative-path-to-base-slug.js";import{normalizeApiVersion as ve}from"./utils/normalize-api-version.js";import{importApiDocsBuilder as W}from"./import-api-docs-builder.js";import{envConfig as $}from"../../config/env-config.js";import{logger as Re}from"../../tools/notifiers/logger.js";const T="openapi-spec-download",be={asyncapi:"AsyncAPI Docs",graphql:"GraphQL Docs",openapi:"OpenAPI Docs"};async function nt(){let t=[],r=new Map;const s=new WeakMap;let n=new Set,m={};function k(o,h,A){const y=s.get(o)??new Map;s.set(o,y);const g=h??"";return y.get(g)===A?!1:(y.set(g,A),!0)}return{id:"api-docs",requiredEntitlements:["openapi","asyncapi","graphql"],loaders:{"api-doc":ne,"api-docs":ce},processContent:async(o,h)=>{await ue("com.redocly.build.plugin.apiDocs",async()=>{o.createRequestHandler(T,ae(import.meta.url,"./spec-download.api.js")),o.addApiRoute({slug:re+"/*",requestHandlerId:T,httpMethod:"all",[v]:x,getStaticData:async()=>({props:{}})}),o.addApiRoute({slug:oe+"/*",requestHandlerId:T,httpMethod:"all",[v]:x,getStaticData:async()=>({props:{}})}),o.addApiRoute({slug:te+"/*",requestHandlerId:T,httpMethod:"all",[v]:x,getStaticData:async()=>({props:{}})});const A=o.createTemplate(V,j("../../../client/templates/api-docs/template.js")),y=o.registerServerPropsGetter(V,j("./get-server-props.js")),g=await h.getConfig();r=new Map,m={};const I=await o.loadApiDocuments(h);pe(I,o.outdir);const C=!!g.plugins?.some(e=>typeof e=="string"&&e.startsWith("@redocly/portal-plugin-async-api/"));C&&I.some(e=>e.type==="asyncapi")&&Re.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");const c=C?I.filter(e=>e.type!=="asyncapi"):I;t=c.map(({markdocChunks:e,relativePath:P,isVirtual:p,customOutputRelativeFile:a,realRelativePath:f})=>({chunks:e??[],relativePath:P,realRelativePath:f,isVirtual:a!=null||p}));const{buildItems:i}=await W(o.serverOutDir),D=(await h.cache.load("content-slugs","content-slugs")).data,S=ie(D),O=e=>se(S(e));for(const e of c){const P=e.customOutputRelativeFile||e.relativePath,p=O(P);Ee(e,p);const{items:a,store:f}=await i({type:e.type,document:e.document,options:e.options,basePath:p,markdownParser:U}),R=`${w}${e.relativePath}`,M=$.isDevelopMode?e.relativePath:void 0,u=Te(e.document),b=u?.["x-metadata"],_=e.isVirtual?void 0:b?.apiId,N={document:e,basePath:p,sourcePath:M,apiId:_};await o.createSharedData(R,Q(N,a,f));const K=Ie(e.config),F=!!e.options.excludeFromSearch,Y=e.type==="openapi",l=he(a,K).map(d=>{const B=d.metadata?.seo,H={...we(d.link,p),fsPath:P,templateId:A,sharedData:[{key:"apiDocsStore",id:R}],serverPropsGetterIds:[y],excludeFromSearch:F,getStaticData:Ce(d.label,B),[v]:d[v]};return Y?{...H,...d.httpVerb?{httpVerb:d.httpVerb,metadata:{subType:"openapi-operation"}}:{}}:H});if(!l.length)continue;const G=ye(u,e.type,a),X=ve(u?.version),L={type:e.type,title:G,version:X,description:typeof u?.description=="string"?u.description:void 0,summary:typeof u?.summary=="string"?u.summary:void 0,...u?.["x-metadata"]&&typeof u["x-metadata"]=="object"?u["x-metadata"]:{}};l[0]={...l[0],metadata:L,hasClientRoutes:!0,getSidebar:(d,B)=>De(z(a),p,B),getNavText:()=>G??be[e.type]??"API Docs",getSearchDocuments:de(a,L,o.getSearchFacets,o.setSearchFacets,F,f,e.document),getAiDocumentsStore:le({items:a,metadata:L,store:f,document:e.document,specType:e.type,excludeFromSearch:F,basePath:p,getSearchFacets:o.getSearchFacets,markdocTags:{...Z,schemaDefinition:ee}})};const J=l[0];l[0]=l[l.length-1],l[l.length-1]=J;for(const d of l)o.addRoute(d);if(_){const d=me(e.config?.apis,e.realRelativePath);m[_]={[v]:d.rbac,[E]:{fsPath:P}}}r.set(R,N)}})},afterRoutesCreated:async(o,h)=>{const{buildItems:A,simplifyAstStructure:y}=await W(o.serverOutDir),g=new Set,I=new Set;for(const{chunks:c,relativePath:i,isVirtual:D}of t){const S=`${w}${i}`,O=fe(o.getAllRoutes(),i);for(const{node:e,markdown:P,pointer:p,key:a,relativePath:f}of c){const{ast:R,compoundHash:M}=await o.parseMarkdoc({input:{content:P,relativePath:f,isVirtual:D},resource:p,context:h,deps:{sharedDataIds:[`${w}${f}`],routeSlugs:O}});if(g.add(p),!(a==="graphql-docs"?e?.description?.value!==void 0:!!a&&ge(e,a,P))||!k(e,a,M))continue;I.add(S);const b=y(R);if(a==="graphql-docs"){e.description&&(e.description.value=b);const _=`${w}${f}`;_e(r.get(_),b)}else a&&(e[a]=b)}}const C=n.difference(g);for(const c of C)h.cache.delete(c);n=g,Object.entries(m).forEach(([c,i])=>{const D=i[E]?.fsPath;if(!D)return;const S=o.getRouteByFsPath(D)?.baseSlug;m[c]={...i,[E]:{...i[E],slug:S},slug:S}}),o.setGlobalData({apiProducts:m});for(const[c,i]of r){if(!I.has(c))continue;const{items:D,store:S}=await A({type:i.document.type,document:i.document.document,options:i.document.options,basePath:i.basePath,markdownParser:U});await o.createSharedData(c,Q(i,D,S))}}}}function Q({document:t,basePath:r,sourcePath:s,apiId:n},m,k){return{items:m,store:k,options:t.options,baseSlug:r,routesMapping:$.isDevelopMode?Se(m,r):{},graphqlPositions:$.isDevelopMode&&t.type==="graphql"?Pe(m,r):void 0,sourcePath:s,apiId:n}}function _e(t,r){t?.document.type!=="graphql"||!t.document.options||(t.document.options.info={...t.document.options.info||{},description:r})}function Ce(t,r){return async function(s){return{props:{settings:{baseUrlPath:q(s.baseSlug)},disableAutoScroll:!0,seo:{title:t,...r}}}}}function Ee(t,r){const s=t.options?.mockServer,n=q(`/_mock${Ae(t.relativePath)}`);s?.url===n&&(t.options={...t.options,mockServer:{...s,url:q(`/_mock${r}`)}})}function we(t,r){if(t===r)return{};const s=r==="/"?"/":`${r}/`;if(t.startsWith(s)){const n=t.slice(s.length);return n?{slugSuffix:n}:{}}return{slug:t}}function Te(t){if(t&&typeof t=="object"&&"info"in t)return t.info}function z(t){return t.map(({content:r,items:s,...n})=>({...n,...s&&{items:z(s)}}))}export{nt as apiDocsPlugin,we as toRouteSlugFields};
1
+ import{REDOCLY_ROUTE_RBAC as w,REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{mcpTagSchemas as et,schemaDefinitionTag as ot,markdocParser as U}from"@redocly/api-docs";import{withPathPrefix as q}from"@redocly/theme/core/utils";import{API_DOCS_TEMPLATE_ID as V,GRAPHQL_SPEC_SLUG as rt,PUBLIC_RBAC_SCOPE_ITEM as x}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as at,PUBLIC_API_DEFINITIONS_FOLDER as st}from"../../constants/common.js";import{API_DOCS_SHARED_DATA_PREFIX as E}from"../../constants/plugins/api-docs.js";import{fromCurrentDir as it}from"../../utils/paths.js";import{normalizeRouteSlug as nt}from"../../../utils/path/normalize-route-slug.js";import{isTranslationFallback as ct}from"../../fs/utils/is-translation-fallback.js";import{createSlugify as pt}from"../create-slugify.js";import{apiDocLoader as ut,apiDocsLoader as lt}from"./loader.js";import{getTemplatePath as j}from"./get-template-path.js";import{storeDefinitionBundles as dt}from"./store-definition-bundles.js";import{telemetryTraceStep as mt}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as ft}from"./search/search-resolver.js";import{getAiDocumentsStore as ht}from"./search/get-ai-search-documents.js";import{getApiConfigByPath as gt}from"../get-api-config.js";import{getRouteSlugsForPath as Dt}from"../utils.js";import{collectItemRoutes as St}from"./utils/collect-item-routes.js";import{isChunkCurrent as Pt}from"./utils/decorators.js";import{applyNavItemToRoot as yt}from"./utils/apply-nav-item-to-root.js";import{buildRoutesMapping as It}from"./utils/build-routes-mapping.js";import{buildItemPositions as At}from"./utils/build-item-positions.js";import{resolveApiDocTitle as vt}from"./utils/resolve-api-doc-title.js";import{resolveConfigRbac as bt}from"./utils/resolve-config-rbac.js";import{relativePathToBaseSlug as Rt}from"./utils/relative-path-to-base-slug.js";import{normalizeApiVersion as _t}from"./utils/normalize-api-version.js";import{importApiDocsBuilder as W}from"./import-api-docs-builder.js";import{envConfig as $}from"../../config/env-config.js";import{logger as Ct}from"../../tools/notifiers/logger.js";const T="openapi-spec-download",wt={asyncapi:"AsyncAPI Docs",graphql:"GraphQL Docs",openapi:"OpenAPI Docs"};async function ue(){let e=[],r=new Map;const s=new WeakMap;let n=new Set,m={};function k(o,h,A){const y=s.get(o)??new Map;s.set(o,y);const g=h??"";return y.get(g)===A?!1:(y.set(g,A),!0)}return{id:"api-docs",requiredEntitlements:["openapi","asyncapi","graphql"],loaders:{"api-doc":ut,"api-docs":lt},processContent:async(o,h)=>{await mt("com.redocly.build.plugin.apiDocs",async()=>{o.createRequestHandler(T,it(import.meta.url,"./spec-download.api.js")),o.addApiRoute({slug:st+"/*",requestHandlerId:T,httpMethod:"all",[v]:x,getStaticData:async()=>({props:{}})}),o.addApiRoute({slug:at+"/*",requestHandlerId:T,httpMethod:"all",[v]:x,getStaticData:async()=>({props:{}})}),o.addApiRoute({slug:rt+"/*",requestHandlerId:T,httpMethod:"all",[v]:x,getStaticData:async()=>({props:{}})});const A=o.createTemplate(V,j("../../../client/templates/api-docs/template.js")),y=o.registerServerPropsGetter(V,j("./get-server-props.js")),g=await h.getConfig();r=new Map,m={};const I=await o.loadApiDocuments(h);dt(I,o.outdir);const C=!!g.plugins?.some(t=>typeof t=="string"&&t.startsWith("@redocly/portal-plugin-async-api/"));C&&I.some(t=>t.type==="asyncapi")&&Ct.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");const c=C?I.filter(t=>t.type!=="asyncapi"):I;e=c.map(({markdocChunks:t,relativePath:P,isVirtual:p,customOutputRelativeFile:a,realRelativePath:f})=>({chunks:t??[],relativePath:P,realRelativePath:f,isVirtual:a!=null||p}));const{buildItems:i}=await W(o.serverOutDir),D=(await h.cache.load("content-slugs","content-slugs")).data,S=pt(D),F=t=>nt(S(t));for(const t of c){const P=t.customOutputRelativeFile||t.relativePath,p=F(P);kt(t,p);const{items:a,store:f}=await i({type:t.type,document:t.document,options:t.options,basePath:p,markdownParser:U}),b=`${E}${t.relativePath}`,O=$.isDevelopMode?t.relativePath:void 0,u=Ot(t.document),R=u?.["x-metadata"],_=t.isVirtual?void 0:R?.apiId,N={document:t,basePath:p,sourcePath:O,apiId:_};await o.createSharedData(b,Q(N,a,f));const K=bt(t.config),M=!!t.options.excludeFromSearch,Y=t.type==="openapi",X=St(a,K),J=ct(t),d=X.map(l=>{const B=l.metadata?.seo,H={...Ft(l.link,p),fsPath:P,templateId:A,sharedData:[{key:"apiDocsStore",id:b}],serverPropsGetterIds:[y],excludeFromSearch:M,getStaticData:Tt(l.label,B,J),[v]:l[v]};return Y?{...H,...l.httpVerb?{httpVerb:l.httpVerb,metadata:{subType:"openapi-operation"}}:{}}:H});if(!d.length)continue;const G=vt(u,t.type,a),Z=_t(u?.version),L={type:t.type,title:G,version:Z,description:typeof u?.description=="string"?u.description:void 0,summary:typeof u?.summary=="string"?u.summary:void 0,...u?.["x-metadata"]&&typeof u["x-metadata"]=="object"?u["x-metadata"]:{}};d[0]={...d[0],metadata:L,hasClientRoutes:!0,getSidebar:(l,B)=>yt(z(a),p,B),getNavText:()=>G??wt[t.type]??"API Docs",getSearchDocuments:ft(a,L,o.getSearchFacets,o.setSearchFacets,M,f,t.document),getAiDocumentsStore:ht({items:a,metadata:L,store:f,document:t.document,specType:t.type,excludeFromSearch:M,basePath:p,getSearchFacets:o.getSearchFacets,markdocTags:{...et,schemaDefinition:ot}})};const tt=d[0];d[0]=d[d.length-1],d[d.length-1]=tt;for(const l of d)o.addRoute(l);if(_){const l=gt(t.config?.apis,t.realRelativePath);m[_]={[v]:l.rbac,[w]:{fsPath:P}}}r.set(b,N)}})},afterRoutesCreated:async(o,h)=>{const{buildItems:A,simplifyAstStructure:y}=await W(o.serverOutDir),g=new Set,I=new Set;for(const{chunks:c,relativePath:i,isVirtual:D}of e){const S=`${E}${i}`,F=Dt(o.getAllRoutes(),i);for(const{node:t,markdown:P,pointer:p,key:a,relativePath:f}of c){const{ast:b,compoundHash:O}=await o.parseMarkdoc({input:{content:P,relativePath:f,isVirtual:D},resource:p,context:h,deps:{sharedDataIds:[`${E}${f}`],routeSlugs:F}});if(g.add(p),!(a==="graphql-docs"?t?.description?.value!==void 0:!!a&&Pt(t,a,P))||!k(t,a,O))continue;I.add(S);const R=y(b);if(a==="graphql-docs"){t.description&&(t.description.value=R);const _=`${E}${f}`;Et(r.get(_),R)}else a&&(t[a]=R)}}const C=n.difference(g);for(const c of C)h.cache.delete(c);n=g,Object.entries(m).forEach(([c,i])=>{const D=i[w]?.fsPath;if(!D)return;const S=o.getRouteByFsPath(D)?.baseSlug;m[c]={...i,[w]:{...i[w],slug:S},slug:S}}),o.setGlobalData({apiProducts:m});for(const[c,i]of r){if(!I.has(c))continue;const{items:D,store:S}=await A({type:i.document.type,document:i.document.document,options:i.document.options,basePath:i.basePath,markdownParser:U});await o.createSharedData(c,Q(i,D,S))}}}}function Q({document:e,basePath:r,sourcePath:s,apiId:n},m,k){return{items:m,store:k,options:e.options,baseSlug:r,routesMapping:$.isDevelopMode?It(m,r):{},graphqlPositions:$.isDevelopMode&&e.type==="graphql"?At(m,r):void 0,sourcePath:s,apiId:n}}function Et(e,r){e?.document.type!=="graphql"||!e.document.options||(e.document.options.info={...e.document.options.info||{},description:r})}function Tt(e,r,s){return async function(n){return{...s?{isTranslationFallback:!0}:{},props:{settings:{baseUrlPath:q(n.baseSlug)},disableAutoScroll:!0,seo:{title:e,...r}}}}}function kt(e,r){const s=e.options?.mockServer,n=q(`/_mock${Rt(e.relativePath)}`);s?.url===n&&(e.options={...e.options,mockServer:{...s,url:q(`/_mock${r}`)}})}function Ft(e,r){if(e===r)return{};const s=r==="/"?"/":`${r}/`;if(e.startsWith(s)){const n=e.slice(s.length);return n?{slugSuffix:n}:{}}return{slug:e}}function Ot(e){if(e&&typeof e=="object"&&"info"in e)return e.info}function z(e){return e.map(({content:r,items:s,...n})=>({...n,...s&&{items:z(s)}}))}export{ue as apiDocsPlugin,Ft as toRouteSlugFields};
@@ -1,5 +1,12 @@
1
1
  import { ApiDocsSearchIndexer } from '@redocly/api-docs';
2
- import type { ExampleEntry, SchemaEntry } from '@redocly/api-docs';
2
+ import type { ExampleEntry, GraphqlStoreMeta, SchemaEntry, SearchIndexerOptions } from '@redocly/api-docs';
3
+ import type { RenderTagFn } from '../../../../types/index.js';
4
+ export type DescriptionFormatter = NonNullable<SearchIndexerOptions['formatDescription']>;
5
+ /**
6
+ * Formats an API description (a string or a Markdoc AST) as Markdown for AI search documents and
7
+ * llms.txt. Tags render through `renderTag` (their `renderForLlms`).
8
+ */
9
+ export declare function createLlmDescriptionFormatter(renderTag?: RenderTagFn): DescriptionFormatter;
3
10
  /** The shared api-docs indexer with Markdown descriptions — AI search documents and llms.txt need Markdown. */
4
- export declare function createApiDocsSearchIndexer(basePath: string, schemaStore?: Record<string, SchemaEntry>, document?: Record<string, unknown>, exampleStore?: Record<string, ExampleEntry>): ApiDocsSearchIndexer;
11
+ export declare function createApiDocsSearchIndexer(basePath: string, formatDescription: DescriptionFormatter, schemaStore?: Record<string, SchemaEntry>, document?: Record<string, unknown>, exampleStore?: Record<string, ExampleEntry>, graphqlMeta?: GraphqlStoreMeta): ApiDocsSearchIndexer;
5
12
  //# sourceMappingURL=create-indexer.d.ts.map
@@ -1 +1 @@
1
- import{ApiDocsSearchIndexer as e}from"@redocly/api-docs";import{toMarkdown as i}from"../../markdown/search/to-markdown.js";function a(r){if(typeof r=="string")return r;const t=Array.isArray(r)?r:[r];return i(t).trim()}function f(r,t,o,n){return new e(r,t,o,{formatDescription:a,exampleStore:n})}export{f as createApiDocsSearchIndexer};
1
+ import{ApiDocsSearchIndexer as a,markdocParser as f,parseMarkdown as p}from"@redocly/api-docs";import{toMarkdown as s}from"../../markdown/search/to-markdown.js";function u(i){const n=new Map;return r=>{if(typeof r=="string"&&!r.includes("{%"))return r;const e=typeof r=="string"?n.get(r):void 0;if(e!==void 0)return e;const t=p(r,{markdownParser:f}),o=!t||typeof t=="string"?t??"":s(Array.isArray(t)?t:[t],{renderTag:i}).trim();return typeof r=="string"&&n.set(r,o),o}}function d(i,n,r,e,t,o){return new a(i,r,e,{formatDescription:n,exampleStore:t,graphqlMeta:o})}export{d as createApiDocsSearchIndexer,u as createLlmDescriptionFormatter};
@@ -1,105 +1,105 @@
1
- import P from"node:path";import{REDOCLY_TEAMS_RBAC as O}from"@redocly/config";import{nodeTypes as h,contentType as y}from"@redocly/api-docs";import{normalizeApiVersion as sn}from"../utils/normalize-api-version.js";import{replaceFileExtension as U}from"../utils/replace-file-extension.js";import{isResourcePubliclyAccessible as cn,canDownloadApiDefinition as ln,extractTeamsFromScopeItems as fn}from"../../../utils/rbac.js";import{getLlmsTxtMdPathBySlug as J}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{PUBLIC_API_DEFINITIONS_FOLDER as Q}from"../../../constants/common.js";import{GRAPHQL_SPEC_SLUG as an}from"../../../../constants/common.js";import{ANONYMOUS_AUTH_DETAILS as pn}from"../../../constants/rbac.js";import{toMarkdown as v}from"../../markdown/search/to-markdown.js";import{createRenderTagFn as un}from"../../markdown/search/create-render-tag-fn.js";import{getLocaleFromRelativePath as dn}from"../../../fs/utils/get-locale-from-relative-path.js";import{getBuildTranslateContext as hn}from"../../../utils/l10n/get-build-translate-context.js";import{llmsTxtLink as N}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as mn}from"../../search/utils.js";import{extractDocumentSearchFacets as $n}from"./search-facets.js";import{createApiDocsSearchIndexer as yn}from"./create-indexer.js";function A(t,o){return o==="openapi"&&"openapi"in t}function H(t,o){return o==="asyncapi"&&"asyncapi"in t}function Qn({items:t,metadata:o,store:s,document:n,specType:r,excludeFromSearch:i,basePath:e,getSearchFacets:l,markdocTags:c}){return async(f,a,u,d)=>{if(i)return;const m={...d.markdocOptions?.tags,...c},{locale:X,translate:Z}=await hn(f.slug,d.getGlobalData?.().l10n),x=un(m,X,Z),C=d.getConfig(),L=dn(f.fsPath),j=yn(e,s?.schemaStore,n,s?.exampleStore),M=g=>{for(const p of g)j.addItem(p),p.items?.length&&M(p.items)};M(t);const nn=j.getResult(),V=new Map;for(const g of nn)V.set(g.url,g);const R=typeof o.title=="string"?o.title:void 0,_=sn(o.version),D=$n(f.metadata||{},R,_,l),S=[],I=[],q=gn(o,n,r),F=bn(r,o,f.fsPath,C),tn=In(t,C,x),en=q+F+`
2
- `+tn,on=q+F;I.push({title:R||"API Overview",description:typeof o.description=="string"?o.description:void 0,content:en,slug:e,fsPath:f.fsPath,includeInLLMsTxt:!0}),S.push({title:R||"API Overview",content:on,url:e,fsPath:f.fsPath,locale:L,product:f.product?.name,facets:D});const rn=n&&A(n,r)?n.security:void 0,E=g=>{for(const p of g){if(!p.content||!p.link){p.items?.length&&E(p.items);continue}const k=V.get(p.link),G=p.content.contentType,z=p[O],W=z?fn(z):void 0,B=W?.length?W:void 0;if(G===y.ITEM){const $=Pn(p,n,r)??Y(p,k,r,_,rn,x);if($){const b=p.label||"";I.push({title:b,description:void 0,content:$,slug:p.link,fsPath:f.fsPath,includeInLLMsTxt:!1}),S.push({title:b,content:$,url:p.link,fsPath:f.fsPath,locale:L,product:f.product?.name,facets:D,rbacTeams:B})}}else if(G===y.GROUP){const $=On(p,C,r,x);if($){const b=p.label||"";I.push({title:b,description:k?Rn(k.text):void 0,content:$.llmstxt,slug:p.link,fsPath:f.fsPath,includeInLLMsTxt:!1}),S.push({title:b,content:$.aiSearch,url:p.link,fsPath:f.fsPath,locale:L,product:f.product?.name,facets:D,rbacTeams:B})}}p.items?.length&&E(p.items)}};return E(t),{async getLLMsTxts(){return I},async getSearchDocuments(){return S}}}}function gn(t,o,s){const n=typeof t.title=="string"?t.title:"",r=typeof t.description=="string"?t.description:"",i=typeof t.summary=="string"?t.summary:"",e=typeof t.version=="string"?t.version:"";let l=n?`# ${n}
1
+ import C from"node:path";import{REDOCLY_TEAMS_RBAC as x}from"@redocly/config";import{nodeTypes as m,contentType as g,isGraphqlFieldsNode as ln,resolveGraphqlItemFields as fn}from"@redocly/api-docs";import{normalizeApiVersion as an}from"../utils/normalize-api-version.js";import{replaceFileExtension as v}from"../utils/replace-file-extension.js";import{isResourcePubliclyAccessible as pn,canDownloadApiDefinition as un,extractTeamsFromScopeItems as dn}from"../../../utils/rbac.js";import{getLlmsTxtMdPathBySlug as H}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{PUBLIC_API_DEFINITIONS_FOLDER as Y}from"../../../constants/common.js";import{GRAPHQL_SPEC_SLUG as hn}from"../../../../constants/common.js";import{ANONYMOUS_AUTH_DETAILS as mn}from"../../../constants/rbac.js";import{toMarkdown as N}from"../../markdown/search/to-markdown.js";import{createRenderTagFn as $n}from"../../markdown/search/create-render-tag-fn.js";import{getLocaleFromRelativePath as yn}from"../../../fs/utils/get-locale-from-relative-path.js";import{getBuildTranslateContext as gn}from"../../../utils/l10n/get-build-translate-context.js";import{llmsTxtLink as w}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as bn}from"../../search/utils.js";import{extractDocumentSearchFacets as In}from"./search-facets.js";import{createApiDocsSearchIndexer as Pn,createLlmDescriptionFormatter as Sn}from"./create-indexer.js";function P(e,s){return s==="openapi"&&"openapi"in e}function K(e,s){return s==="asyncapi"&&"asyncapi"in e}function Xn({items:e,metadata:s,store:c,document:r,specType:n,excludeFromSearch:l,basePath:t,getSearchFacets:i,markdocTags:f}){return async(o,d,p,u)=>{if(l)return;const h={...u.markdocOptions?.tags,...f},{locale:$,translate:nn}=await gn(o.slug,u.getGlobalData?.().l10n),S=$n(h,$,nn),L=u.getConfig(),R=yn(o.fsPath),D=Sn(S),j=Pn(t,D,c?.schemaStore,r,c?.exampleStore,c?.graphqlMeta),V=b=>{for(const a of b)j.addItem(a),a.items?.length&&V(a.items)};V(e);const tn=j.getResult(),F=new Map;for(const b of tn)F.set(b.url,b);const E=typeof s.title=="string"?s.title:void 0,_=an(s.version),k=In(o.metadata||{},E,_,i),A=[],O=[],q=typeof s.description=="string"&&s.description?D(s.description):void 0,G=An(s,q,r,n,D),z=On(n,s,o.fsPath,L),en=Tn(e,L,S),on=G+z+`
2
+ `+en,sn=G+z;O.push({title:E||"API Overview",description:q,content:on,slug:t,fsPath:o.fsPath,includeInLLMsTxt:!0}),A.push({title:E||"API Overview",content:sn,url:t,fsPath:o.fsPath,locale:R,product:o.product?.name,facets:k});const rn=r&&P(r,n)?r.security:void 0,U=b=>{for(const a of b){if(!a.content||!a.link){a.items?.length&&U(a.items);continue}const cn=F.get(a.link),W=a.content.contentType,B=a[x],J=B?dn(B):void 0,Q=J?.length?J:void 0;if(W===g.ITEM){const y=Ln(a,r,n)??X(a,cn,n,_,rn,S,c);if(y){const I=a.label||"";O.push({title:I,description:void 0,content:y,slug:a.link,fsPath:o.fsPath,includeInLLMsTxt:!1}),A.push({title:I,content:y,url:a.link,fsPath:o.fsPath,locale:R,product:o.product?.name,facets:k,rbacTeams:Q})}}else if(W===g.GROUP){const y=Rn(a,L,n,S,c);if(y){const I=a.label||"";O.push({title:I,description:void 0,content:y.llmstxt,slug:a.link,fsPath:o.fsPath,includeInLLMsTxt:!1}),A.push({title:I,content:y.aiSearch,url:a.link,fsPath:o.fsPath,locale:R,product:o.product?.name,facets:k,rbacTeams:Q})}}a.items?.length&&U(a.items)}};return U(e),{async getLLMsTxts(){return O},async getSearchDocuments(){return A}}}}function An(e,s,c,r,n){const l=typeof e.title=="string"?e.title:"",t=typeof e.summary=="string"?e.summary:"",i=typeof e.version=="string"?e.version:"";let f=l?`# ${l}
3
3
 
4
- `:"";if(l+=r?`${r}
4
+ `:"";if(f+=s?`${s}
5
5
 
6
- `:"",l+=i?`${i}
6
+ `:"",f+=t?`${t}
7
7
 
8
- `:"",l+=e?`Version: ${e}
9
- `:"",o){if(A(o,s)){const{info:c}=o;c?.license?.name&&(l+=`License: ${c.license.name}
10
- `);const f=c["x-metadata"],a=mn(f);a&&(l+=`
8
+ `:"",f+=i?`Version: ${i}
9
+ `:"",c){if(P(c,r)){const{info:o}=c;o?.license?.name&&(f+=`License: ${o.license.name}
10
+ `);const d=o["x-metadata"],p=bn(d);p&&(f+=`
11
11
  Metadata:
12
- ${a}
13
- `)}else if(H(o,s)){const{info:c}=o;c?.license?.name&&(l+=`License: ${c.license.name}
14
- `)}}return l+=`
15
- `,l+=An(o,s),l+=Sn(o,s),l}function bn(t,o,s,n){if(!s)return"";let r,i,e;if(t==="openapi")r=P.posix.join(Q,U(s,".yaml")),i="## Download OpenAPI description",e="OpenAPI definition";else if(t==="asyncapi")r=P.posix.join(Q,U(s,".yaml")),i="## Download AsyncAPI description",e="AsyncAPI definition";else if(t==="graphql"){const f=P.posix.extname(s)||".graphql";r=P.posix.join(an,U(s,f)),i="## Download GraphQL schema",e="GraphQL schema"}else return"";if(!ln(r,n.access?.rbac??{},n.access?.requiresLogin??!1,pn))return"";const c=typeof o.title=="string"&&o.title||e;return`${i}
12
+ ${p}
13
+ `)}else if(K(c,r)){const{info:o}=c;o?.license?.name&&(f+=`License: ${o.license.name}
14
+ `)}}return f+=`
15
+ `,f+=Cn(c,r,n),f+=xn(c,r,n),f}function On(e,s,c,r){if(!c)return"";let n,l,t;if(e==="openapi")n=C.posix.join(Y,v(c,".yaml")),l="## Download OpenAPI description",t="OpenAPI definition";else if(e==="asyncapi")n=C.posix.join(Y,v(c,".yaml")),l="## Download AsyncAPI description",t="AsyncAPI definition";else if(e==="graphql"){const o=C.posix.extname(c)||".graphql";n=C.posix.join(hn,v(c,o)),l="## Download GraphQL schema",t="GraphQL schema"}else return"";if(!un(n,r.access?.rbac??{},r.access?.requiresLogin??!1,mn))return"";const f=typeof s.title=="string"&&s.title||t;return`${l}
16
16
 
17
- - ${N({title:c,description:void 0,slug:r,siteUrl:n.seo?.siteUrl})}`}function An(t,o){if(!t)return"";if(A(t,o)){const{servers:s}=t;if(!s?.length)return"";let n=`## Servers
17
+ - ${w({title:f,description:void 0,slug:n,siteUrl:r.seo?.siteUrl})}`}function Cn(e,s,c){if(!e)return"";if(P(e,s)){const{servers:r}=e;if(!r?.length)return"";let n=`## Servers
18
18
 
19
- `;for(const r of s)if(r.description&&(n+=`${r.description}
19
+ `;for(const l of r)if(l.description&&(n+=`${c(l.description)}
20
20
  `),n+=`\`\`\`
21
- ${r.url}
21
+ ${l.url}
22
22
  \`\`\`
23
23
 
24
- `,r.variables){n+=`Variables:
25
- `;for(const[i,e]of Object.entries(r.variables))n+=`- \`${i}\`${e.description?`: ${e.description}`:""}
26
- `,e.default&&(n+=` Default: ${JSON.stringify(e.default)}
27
- `),e.enum&&(n+=` Enum: ${e.enum.map(l=>JSON.stringify(l)).join(", ")}
24
+ `,l.variables){n+=`Variables:
25
+ `;for(const[t,i]of Object.entries(l.variables))n+=`- \`${t}\`${i.description?`: ${c(i.description).replace(/\s+/g," ")}`:""}
26
+ `,i.default&&(n+=` Default: ${JSON.stringify(i.default)}
27
+ `),i.enum&&(n+=` Enum: ${i.enum.map(f=>JSON.stringify(f)).join(", ")}
28
28
  `);n+=`
29
- `}return n}if(H(t,o)){const{servers:s}=t;if(!s||!Object.keys(s).length)return"";let n=`## Servers
29
+ `}return n}if(K(e,s)){const{servers:r}=e;if(!r||!Object.keys(r).length)return"";let n=`## Servers
30
30
 
31
- `;for(const[r,i]of Object.entries(s))n+=`### ${r}
31
+ `;for(const[l,t]of Object.entries(r))n+=`### ${l}
32
32
 
33
- `,i.description&&(n+=`${i.description}
34
- `),i.host&&(n+=`Host: ${i.host}
35
- `),i.protocol&&(n+=`Protocol: ${i.protocol}
36
- `),i.protocolVersion&&(n+=`Protocol Version: ${i.protocolVersion}
37
- `),i.pathname&&(n+=`Pathname: ${i.pathname}
33
+ `,t.description&&(n+=`${c(t.description)}
34
+ `),t.host&&(n+=`Host: ${t.host}
35
+ `),t.protocol&&(n+=`Protocol: ${t.protocol}
36
+ `),t.protocolVersion&&(n+=`Protocol Version: ${t.protocolVersion}
37
+ `),t.pathname&&(n+=`Pathname: ${t.pathname}
38
38
  `),n+=`
39
- `;return n}return""}function Sn(t,o){if(!t||!A(t,o))return"";const s=t.components?.securitySchemes;if(!s)return"";let n=`## Security
40
-
41
- `;for(const[r,i]of Object.entries(s)){if(!i||"$ref"in i)continue;const e=i;n+=`### ${r}
42
-
43
- `,e.description&&(n+=`${e.description}
44
-
45
- `),e.type&&(n+=`Type: ${e.type}
46
- `),e.in&&(n+=`In: ${e.in}
47
- `),e.name&&(n+=`Name: ${e.name}
48
- `),e.scheme&&(n+=`Scheme: ${e.scheme}
49
- `),e.bearerFormat&&(n+=`Bearer Format: ${e.bearerFormat}
50
- `),e.openIdConnectUrl&&(n+=`OpenID Connect URL: ${e.openIdConnectUrl}
51
- `);const l=e.flows,c=l?.implicit||l?.password||l?.clientCredentials||l?.authorizationCode;if(c&&("authorizationUrl"in c&&c.authorizationUrl&&(n+=`Authorization URL: ${c.authorizationUrl}
52
- `),"tokenUrl"in c&&c.tokenUrl&&(n+=`Token URL: ${c.tokenUrl}
53
- `),c.scopes)){n+=`Scopes:
54
- `;for(const[f,a]of Object.entries(c.scopes))n+=`- \`${f}\`: ${a}
39
+ `;return n}return""}function xn(e,s,c){if(!e||!P(e,s))return"";const r=e.components?.securitySchemes;if(!r)return"";let n=`## Security
40
+
41
+ `;for(const[l,t]of Object.entries(r)){if(!t||"$ref"in t)continue;const i=t;n+=`### ${l}
42
+
43
+ `,i.description&&(n+=`${c(i.description)}
44
+
45
+ `),i.type&&(n+=`Type: ${i.type}
46
+ `),i.in&&(n+=`In: ${i.in}
47
+ `),i.name&&(n+=`Name: ${i.name}
48
+ `),i.scheme&&(n+=`Scheme: ${i.scheme}
49
+ `),i.bearerFormat&&(n+=`Bearer Format: ${i.bearerFormat}
50
+ `),i.openIdConnectUrl&&(n+=`OpenID Connect URL: ${i.openIdConnectUrl}
51
+ `);const f=i.flows,o=f?.implicit||f?.password||f?.clientCredentials||f?.authorizationCode;if(o&&("authorizationUrl"in o&&o.authorizationUrl&&(n+=`Authorization URL: ${o.authorizationUrl}
52
+ `),"tokenUrl"in o&&o.tokenUrl&&(n+=`Token URL: ${o.tokenUrl}
53
+ `),o.scopes)){n+=`Scopes:
54
+ `;for(const[d,p]of Object.entries(o.scopes))n+=`- \`${d}\`: ${p}
55
55
  `}n+=`
56
- `}return n}function In(t,o,s){let n="";const r=(i,e)=>{for(const l of i)if(l.link){if(l.content?.contentType===y.GROUP)n+=`${e} ${l.label||""}
56
+ `}return n}function Tn(e,s,c){let r="";const n=(l,t)=>{for(const i of l)if(i.link){if(i.content?.contentType===g.GROUP)r+=`${t} ${i.label||""}
57
57
 
58
- `,l.items?.length&&r(l.items,e+"#");else if(l.content?.contentType===y.ITEM){if(!w(l,o))continue;const c=l,f=c.httpVerb,a=c.httpPath,u=f&&a?`${f.toUpperCase()} ${a}`:l.label||"",d=l.content?T(l.content.children,s):void 0;n+=` - ${N({title:u,description:d?d.slice(0,200):void 0,slug:J(l.link),siteUrl:o.seo?.siteUrl})}`}}};return r(t,"##"),n}function Y(t,o,s,n,r,i){if(!t.content)return;const e=t,l=t.label||"",c=T(t.content.children,i),f=t.content.meta?.deprecated;let a=`# ${l}${f?" (deprecated)":""}
58
+ `,i.items?.length&&n(i.items,t+"#");else if(i.content?.contentType===g.ITEM){if(!M(i,s))continue;const f=i,o=f.httpVerb,d=f.httpPath,p=o&&d?`${o.toUpperCase()} ${d}`:i.label||"",u=i.content?T(i.content.children,c):void 0;r+=` - ${w({title:p,description:u?u.slice(0,200):void 0,slug:H(i.link),siteUrl:s.seo?.siteUrl})}`}}};return n(e,"##"),r}function X(e,s,c,r,n,l,t){if(!e.content)return;const i=e,f=e.label||"",o=T(e.content.children,l),d=e.content.meta?.deprecated;let p=`# ${f}${d?" (deprecated)":""}
59
59
 
60
- `;if(c&&(a+=`${c}
60
+ `;if(o&&(p+=`${o}
61
61
 
62
- `),s==="openapi"||s==="asyncapi"){const u=e.httpVerb,d=e.httpPath;u&&d?a+=`Endpoint: ${u.toUpperCase()} ${d}
63
- `:u&&(a+=`Method: ${u.toUpperCase()}
64
- `),n&&(a+=`Version: ${n}
65
- `);const m=Tn(t.content.children,r);m&&(a+=`Security: ${m}
66
- `)}return o?.parameters?.length&&s!=="graphql"&&(a+=`
67
- `+xn(o.parameters)+`
68
- `),s==="graphql"&&(a+=Cn(t.content.children)),a}function Pn(t,o,s){if(t.httpVerb!=="tool"||!o||!A(o,s))return;const n=t.content?.meta?.name,r=n?o["x-mcp"]?.tools?.find(e=>e.name===n):void 0;if(!r)return;let i=`# ${t.label||r.name}
62
+ `),c==="openapi"||c==="asyncapi"){const u=i.httpVerb,h=i.httpPath;u&&h?p+=`Endpoint: ${u.toUpperCase()} ${h}
63
+ `:u&&(p+=`Method: ${u.toUpperCase()}
64
+ `),r&&(p+=`Version: ${r}
65
+ `);const $=Dn(e.content.children,n);$&&(p+=`Security: ${$}
66
+ `)}return s?.parameters?.length&&c!=="graphql"&&(p+=`
67
+ `+En(s.parameters)+`
68
+ `),c==="graphql"&&(p+=kn(e.content.children,t,l)),p}function Ln(e,s,c){if(e.httpVerb!=="tool"||!s||!P(s,c))return;const r=e.content?.meta?.name,n=r?s["x-mcp"]?.tools?.find(t=>t.name===r):void 0;if(!n)return;let l=`# ${e.label||n.name}
69
69
 
70
- `;return typeof r.description=="string"&&r.description&&(i+=`${r.description}
70
+ `;return typeof n.description=="string"&&n.description&&(l+=`${n.description}
71
71
 
72
- `),i+=`## Input schema:
72
+ `),l+=`## Input schema:
73
73
 
74
- `,i+=`\`\`\`json
75
- ${JSON.stringify(r.inputSchema,null,2)}
74
+ `,l+=`\`\`\`json
75
+ ${JSON.stringify(n.inputSchema,null,2)}
76
76
  \`\`\`
77
77
 
78
- `,r.outputSchema&&(i+=`## Output schema:
78
+ `,n.outputSchema&&(l+=`## Output schema:
79
79
 
80
- `,i+=`\`\`\`json
81
- ${JSON.stringify(r.outputSchema,null,2)}
80
+ `,l+=`\`\`\`json
81
+ ${JSON.stringify(n.outputSchema,null,2)}
82
82
  \`\`\`
83
83
 
84
- `),i}function On(t,o,s,n){if(!t.content)return;const r=t.label||"",i=T(t.content.children,n);let e=`# ${r}
84
+ `),l}function Rn(e,s,c,r,n){if(!e.content)return;const l=e.label||"",t=T(e.content.children,r);let i=`# ${l}
85
85
 
86
- `;if(i&&(e+=`${i}
86
+ `;if(t&&(i+=`${t}
87
87
 
88
- `),s==="graphql"){let c="";const f=a=>{for(const u of a??[])if(!(!u.content||!w(u,o)))if(u.content.contentType===y.ITEM){const d=Y(u,void 0,s,void 0,void 0,n);d&&(c+=`${d}
88
+ `),c==="graphql"){let o="";const d=p=>{for(const u of p??[])if(!(!u.content||!M(u,s)))if(u.content.contentType===g.ITEM){const h=X(u,void 0,c,void 0,void 0,r,n);h&&(o+=`${h}
89
89
 
90
90
  ---
91
91
 
92
- `)}else u.content.contentType===y.GROUP&&f(u.items)};return f(t.items),{llmstxt:e+c,aiSearch:e}}let l="";if(t.items?.length)for(const c of t.items){if(!c.link||!c.content||c.content.contentType!==y.ITEM||!w(c,o))continue;const f=c,a=f.httpVerb,u=f.httpPath,d=a&&u?`${a.toUpperCase()} ${u}`:c.label||"",m=c.content?T(c.content.children,n):void 0;l+=` - ${N({title:d,description:m?m.slice(0,200):void 0,slug:J(c.link),siteUrl:o.seo?.siteUrl})}`}return{llmstxt:e+l,aiSearch:e}}function Tn(t,o){const s=[],n=r=>{for(const i of r)if(i.nodeType===h.SECURITY){const e=i;for(const l of e.requirements)for(const c of l.schemes)c[O]||c.name&&!s.includes(c.name)&&s.push(c.name)}else(i.nodeType===h.CONTAINER||i.nodeType===h.OVERVIEW_SECTION_WRAPPER)&&n(i.children)};if(n(t),s.length)return s.join(", ");if(o?.length){const r=o.flatMap(i=>Object.keys(i));if(r.length)return[...new Set(r)].join(", ")}}function xn(t){const o={};for(const n of t){const r=`${n.place}${n.mediaType?` (${n.mediaType})`:""}`;o[r]||(o[r]=[]),o[r].push(n)}return Object.entries(o).map(([n,r])=>{const i=r.map(e=>{const l=[...e.path||[],e.name],c=Array.isArray(e.description)?e.description.join(" "):e.description;let f=` - \`${l.join(".")}\` (${e.type}${e.required?", required":""})
93
- `;return c&&(f+=` ${c.trim()}
94
- `),e.enum?f+=` Enum: ${e.enum.map(a=>JSON.stringify(a)).join(", ")}
95
- `:e.example&&(f+=` Example: ${e.example}
96
- `),f});return`## ${K(n)}:
92
+ `)}else u.content.contentType===g.GROUP&&d(u.items)};return d(e.items),{llmstxt:i+o,aiSearch:i}}let f="";if(e.items?.length)for(const o of e.items){if(!o.link||!o.content||o.content.contentType!==g.ITEM||!M(o,s))continue;const d=o,p=d.httpVerb,u=d.httpPath,h=p&&u?`${p.toUpperCase()} ${u}`:o.label||"",$=o.content?T(o.content.children,r):void 0;f+=` - ${w({title:h,description:$?$.slice(0,200):void 0,slug:H(o.link),siteUrl:s.seo?.siteUrl})}`}return{llmstxt:i+f,aiSearch:i}}function Dn(e,s){const c=[],r=n=>{for(const l of n)if(l.nodeType===m.SECURITY){const t=l;for(const i of t.requirements)for(const f of i.schemes)f[x]||f.name&&!c.includes(f.name)&&c.push(f.name)}else(l.nodeType===m.CONTAINER||l.nodeType===m.OVERVIEW_SECTION_WRAPPER)&&r(l.children)};if(r(e),c.length)return c.join(", ");if(s?.length){const n=s.flatMap(l=>Object.keys(l));if(n.length)return[...new Set(n)].join(", ")}}function En(e){const s={};for(const r of e){const n=`${r.place}${r.mediaType?` (${r.mediaType})`:""}`;s[n]||(s[n]=[]),s[n].push(r)}return Object.entries(s).map(([r,n])=>{const l=n.map(t=>{const i=[...t.path||[],t.name],f=Array.isArray(t.description)?t.description.join(" "):t.description;let o=` - \`${i.join(".")}\` (${t.type}${t.required?", required":""})
93
+ `;return f&&(o+=` ${f.trim()}
94
+ `),t.enum?o+=` Enum: ${t.enum.map(d=>JSON.stringify(d)).join(", ")}
95
+ `:t.example&&(o+=` Example: ${t.example}
96
+ `),o});return`## ${Z(r)}:
97
97
 
98
- ${i.join(`
98
+ ${l.join(`
99
99
  `)}`}).join(`
100
- `)}function Cn(t){let o="";const s=n=>{for(const r of n)if(r.nodeType===h.ITEM){const i=r;i.graphqlSchema&&(o+=Ln(i.graphqlSchema,i.variant))}else(r.nodeType===h.CONTAINER||r.nodeType===h.OVERVIEW_SECTION_WRAPPER)&&s(r.children)};return s(t),o}function Ln(t,o){let n=`
101
- ## ${K(o==="return-type"?"Return type":o==="graphql-args"||o==="arguments"?"Arguments":o==="graphql-fields"?"Fields":o)}:
100
+ `)}function kn(e,s,c){let r="";const n=l=>{for(const t of l)if(t.nodeType===m.ITEM){const i=ln(t)?fn(t,s??{}):void 0;i&&(r+=Un(i,t.variant,c))}else(t.nodeType===m.CONTAINER||t.nodeType===m.OVERVIEW_SECTION_WRAPPER)&&n(t.children)};return n(e),r}function Un(e,s,c){let n=`
101
+ ## ${Z(s==="return-type"?"Return type":s==="graphql-args"||s==="arguments"?"Arguments":s==="graphql-fields"?"Fields":s)}:
102
102
 
103
- `;const r=i=>{const e=i.description?v(Array.isArray(i.description)?i.description:[i.description]).trim():"";return` - \`${i.name}\` (${i.type})${e?`: ${e}`:""}
104
- `};if(!Array.isArray(t)){const i=t.description?v(Array.isArray(t.description)?t.description:[t.description]).trim():"";n+=` Type: ${t.type}`,i&&(n+=` - ${i}`),n+=`
105
- `;for(const e of t.fields??[])n+=r(e);return n}if(!t.length)return"";for(const i of t)n+=r(i);return n}function T(t,o){const s=[],n=i=>{for(const e of i)if(e.nodeType===h.MARKDOC){const l=e.content,c=Array.isArray(l)?l:[l],f=v(c,{renderTag:o}).trim();f&&s.push(f)}else(e.nodeType===h.CONTAINER||e.nodeType===h.OVERVIEW_SECTION_WRAPPER)&&n(e.children)};return n(t),s.join(" ").trim()||void 0}function Rn(t){return(Array.isArray(t)?t.join(" "):t)||void 0}function K(t){return t.charAt(0).toUpperCase()+t.slice(1)}function w(t,o){return o.access?.requiresLogin?!0:cn({slug:t.link||"",[O]:t[O]},o)}export{Qn as getAiDocumentsStore};
103
+ `;const l=t=>{const i=t.description?N(Array.isArray(t.description)?t.description:[t.description],{renderTag:c}).trim():"";return` - \`${t.name}\` (${t.type.display})${i?`: ${i}`:""}
104
+ `};if(e.type){const t=e.type.description?N(Array.isArray(e.type.description)?e.type.description:[e.type.description],{renderTag:c}).trim():"";n+=` Type: ${e.type.display}`,t&&(n+=` - ${t}`),n+=`
105
+ `}else if(!e.fields.length)return"";for(const t of e.fields)n+=l(t);return n}function T(e,s){const c=[],r=l=>{for(const t of l)if(t.nodeType===m.MARKDOC){const i=t.content,f=Array.isArray(i)?i:[i],o=N(f,{renderTag:s}).trim();o&&c.push(o)}else(t.nodeType===m.CONTAINER||t.nodeType===m.OVERVIEW_SECTION_WRAPPER)&&r(t.children)};return r(e),c.join(" ").trim()||void 0}function Z(e){return e.charAt(0).toUpperCase()+e.slice(1)}function M(e,s){return s.access?.requiresLogin?!0:pn({slug:e.link||"",[x]:e[x]},s)}export{Xn as getAiDocumentsStore};
@@ -1 +1 @@
1
- import{REDOCLY_ROUTE_RBAC as h,REDOCLY_TEAMS_RBAC as o}from"@redocly/config";import{extractDocumentSearchFacets as x,setDocumentSearchFacets as A}from"./search-facets.js";import{ApiDocsSearchIndexer as D}from"@redocly/api-docs";import{normalizeApiVersion as d}from"../utils/normalize-api-version.js";function O(u,i,c,S,R,a,g){return async e=>{if(R)return[];const m=e.baseSlug||e.slug,l=new D(m,a?.schemaStore,g,{exampleStore:a?.exampleStore}),f=t=>{for(const r of t)l.addItem(r),r.items?.length&&f(r.items)};f(u);const s=typeof i.title=="string"?i.title:void 0,n=d(i.version),p=x(e.metadata||{},s,n,c);return A(p,c,S),l.getResult().map(t=>({...t,...t.url===m&&s&&{title:n?`${s} (${n})`:s},[o]:t[o]??e[o],[h]:e[h]??{slug:e.slug,fsPath:e.fsPath},facets:p}))}}export{O as searchResolver};
1
+ import{REDOCLY_ROUTE_RBAC as h,REDOCLY_TEAMS_RBAC as o}from"@redocly/config";import{extractDocumentSearchFacets as x,setDocumentSearchFacets as A}from"./search-facets.js";import{ApiDocsSearchIndexer as D}from"@redocly/api-docs";import{normalizeApiVersion as d}from"../utils/normalize-api-version.js";function M(g,i,c,u,S,n,R){return async e=>{if(S)return[];const m=e.baseSlug||e.slug,l=new D(m,n?.schemaStore,R,{exampleStore:n?.exampleStore,graphqlMeta:n?.graphqlMeta}),p=t=>{for(const a of t)l.addItem(a),a.items?.length&&p(a.items)};p(g);const s=typeof i.title=="string"?i.title:void 0,r=d(i.version),f=x(e.metadata||{},s,r,c);return A(f,c,u),l.getResult().map(t=>({...t,...t.url===m&&s&&{title:r?`${s} (${r})`:s},[o]:t[o]??e[o],[h]:e[h]??{slug:e.slug,fsPath:e.fsPath},facets:f}))}}export{M as searchResolver};
@@ -1,5 +1,5 @@
1
- import s from"node:path";import{bundle as R,createConfig as I,getTotals as B}from"@redocly/openapi-core";import{CONFIG_FILE_NAME as J}from"../../../constants/common.js";import{deepMerge as L}from"../../../utils/object/deep-merge.js";import{pluralize as $}from"../../../utils/string/pluralize.js";import{getAllApiConfigsByPath as M}from"../get-api-config.js";import{injectDecoratorIntoConfig as W}from"../api-docs/utils/decorators.js";import{ExternalResolver as _}from"../../fs/utils/external-ref-resolver.js";async function Y(o,{fs:n,logger:d,cache:u,getConfig:l,isPathIgnored:f}){let i;try{i=(await u.load(o,"yaml")).data}catch{return[]}if(!i?.arazzo)return d.verbose(`${o} file is not Arazzo document. Skipping`),[];const p=[],e=n.getFileInfo(o),t=await l(s.posix.dirname(o)),x=M(t?.apis,o,t.configPath),D=await f(o);for(const c of x){if(!c.output&&D)continue;const k=t.configPath?s.posix.dirname(t.configPath):".",a=c.output?s.posix.join(k,c.output):o;e&&c.output&&!await n.exists(a)&&n.addVirtualFile(a,e);const m=L(t,{rbac:void 0},c),v=s.resolve(n.cwd,t.realConfigPath||J),w=new _(n),O=await I(W(m,a,n.cwd),{configPath:v,externalRefResolver:w}),h=s.resolve(n.cwd,o),g={config:O,base:s.dirname(h),doc:{source:{absoluteRef:h},parsed:JSON.parse(JSON.stringify(i))}},{bundle:{parsed:N},problems:z,visitorsData:P}=await R({...g,dereference:!0,externalRefResolver:w}),{bundle:{parsed:S}}=await R({...g,doc:{...g.doc,parsed:JSON.parse(JSON.stringify(i))}}),V=P["markdown/markdown"]?.markdocChunks??[],r=B(z),b=[r.errors&&`${r.errors} ${$(r.errors,"error","errors")}`,r.warnings&&`${r.warnings} ${$(r.warnings,"warning","warnings")}`,r.ignored&&`${r.ignored} ignored`].filter(Boolean).join(", ");if(r.errors){const C=z.find(F=>F.severity==="error");throw new Error(`${b} while bundling ${a} definition.
1
+ import s from"node:path";import{bundle as R,createConfig as I,getTotals as B}from"@redocly/openapi-core";import{CONFIG_FILE_NAME as J}from"../../../constants/common.js";import{deepMerge as L}from"../../../utils/object/deep-merge.js";import{pluralize as $}from"../../../utils/string/pluralize.js";import{getAllApiConfigsByPath as M}from"../get-api-config.js";import{injectDecoratorIntoConfig as W}from"../api-docs/utils/decorators.js";import{ExternalResolver as _}from"../../fs/utils/external-ref-resolver.js";async function Y(o,{fs:n,logger:d,cache:u,getConfig:l,isPathIgnored:f}){let i;try{i=(await u.load(o,"yaml")).data}catch{return[]}if(!i?.arazzo)return d.verbose(`${o} file is not Arazzo document. Skipping`),[];const p=[],e=n.getFileInfo(o),t=await l(s.posix.dirname(o)),x=M(t?.apis,o,t.configPath),D=await f(o);for(const c of x){if(!c.output&&D)continue;const k=t.configPath?s.posix.dirname(t.configPath):".",a=c.output?s.posix.join(k,c.output):o;e&&c.output&&!n.exists(a)&&n.addVirtualFile(a,e);const m=L(t,{rbac:void 0},c),v=s.resolve(n.cwd,t.realConfigPath||J),w=new _(n),O=await I(W(m,a,n.cwd),{configPath:v,externalRefResolver:w}),h=s.resolve(n.cwd,o),g={config:O,base:s.dirname(h),doc:{source:{absoluteRef:h},parsed:JSON.parse(JSON.stringify(i))}},{bundle:{parsed:N},problems:z,visitorsData:P}=await R({...g,dereference:!0,externalRefResolver:w}),{bundle:{parsed:S}}=await R({...g,doc:{...g.doc,parsed:JSON.parse(JSON.stringify(i))}}),V=P["markdown/markdown"]?.markdocChunks??[],r=B(z),b=[r.errors&&`${r.errors} ${$(r.errors,"error","errors")}`,r.warnings&&`${r.warnings} ${$(r.warnings,"warning","warnings")}`,r.ignored&&`${r.ignored} ignored`].filter(Boolean).join(", ");if(r.errors){const C=z.find(F=>F.severity==="error");throw new Error(`${b} while bundling ${a} definition.
2
2
 
3
3
  ${C?.message} at ${C?.location?.[0]?.pointer}
4
4
 
5
- `)}r.warnings&&d.warn(`${b} while bundling %rp definition`,a);const j=y(N,t.metadata),A=y(S,t.metadata),E={document:j,documentWithReferences:A,config:m,relativePath:a,realRelativePath:e?.realRelativePath||a,customOutputRelativeFile:c.output&&a,markdocChunks:V,isVirtual:e?.isVirtual??!1};p.push(E)}return p}async function Z(o,n){const{fs:d,cache:u,getConfig:l}=n,f=[];for(const i of await d.scan(/(\.ya?ml|\.json)$/)){if(!await l(s.posix.dirname(i.relativePath)))continue;let e;try{e=await u.load(i.relativePath,"arazzo-doc")}catch{continue}e.data?.length&&f.push(...e.data.map(t=>({...t,isVirtual:i.isVirtual||t.isVirtual,hash:e.compoundHash})))}return f}function y(o,n){return n?{...o,info:{...o.info,...n}}:o}export{Y as arazzoDocLoader,Z as arazzoDocsLoader};
5
+ `)}r.warnings&&d.warn(`${b} while bundling %rp definition`,a);const j=y(N,t.metadata),A=y(S,t.metadata),E={document:j,documentWithReferences:A,config:m,relativePath:a,realRelativePath:e?.realRelativePath||a,customOutputRelativeFile:c.output&&a,markdocChunks:V,isVirtual:e?.isVirtual??!1};p.push(E)}return p}async function Z(o,n){const{fs:d,cache:u,getConfig:l}=n,f=[];for(const i of d.scan(/(\.ya?ml|\.json)$/)){if(!await l(s.posix.dirname(i.relativePath)))continue;let e;try{e=await u.load(i.relativePath,"arazzo-doc")}catch{continue}e.data?.length&&f.push(...e.data.map(t=>({...t,isVirtual:i.isVirtual||t.isVirtual,hash:e.compoundHash})))}return f}function y(o,n){return n?{...o,info:{...o.info,...n}}:o}export{Y as arazzoDocLoader,Z as arazzoDocsLoader};
@@ -1 +1 @@
1
- import{simplifyAstStructure as h}from"@redocly/api-docs";import{storeDefinitionBundles as p}from"./store-definition-bundles.js";import{arazzoDocLoader as y,arazzoDocsLoader as D}from"./arazzo-doc-loader.js";import{telemetryTraceStep as P}from"../../../cli/telemetry/helpers/trace-step.js";const u="arazzo-docs-";async function $(k){let l=[];return{id:"arazzo",loaders:{"arazzo-doc":y,"arazzo-docs":D},processContent:async(e,o)=>{await P("com.redocly.build.plugin.arazzoDocs",async()=>{for(const t of await o.fs.scan(/(\.ya?ml|\.json)$/))if(!await o.isPathIgnored(t.relativePath))try{const{data:a,compoundHash:n}=await o.cache.load(t.realRelativePath,"arazzo-doc");if(!a?.length)continue;l=a.map(({markdocChunks:r,relativePath:c,isVirtual:i,customOutputRelativeFile:s,realRelativePath:d})=>({chunks:r,relativePath:c,realRelativePath:d,isVirtual:s!=null||t.isVirtual||i})),p(a,e.outdir,n);for(const r of a){const c=`${u}${r.relativePath}`;await e.createSharedData(c,{document:r.document})}}catch(a){console.error(a)}})},afterRoutesCreated:async(e,o)=>{for(const{chunks:t,relativePath:a,isVirtual:n,realRelativePath:r}of l)await o.cache.load(a,{loader:async function(){await o.cache.load(r,"arazzo-doc");for(const{node:i,markdown:s,pointer:d,key:z,relativePath:m}of t){const{ast:f}=await e.parseMarkdoc({input:{content:s,relativePath:d,isVirtual:n},context:o,deps:{sharedDataIds:[`${u}${m}`]}});i[`x-parsed-md-${z}`]={result:h(f)}}},name:"arazzo-markdoc-inline-parser"})}}}export{$ as arazzoDocsPlugin};
1
+ import{simplifyAstStructure as h}from"@redocly/api-docs";import{storeDefinitionBundles as p}from"./store-definition-bundles.js";import{arazzoDocLoader as y,arazzoDocsLoader as D}from"./arazzo-doc-loader.js";import{telemetryTraceStep as P}from"../../../cli/telemetry/helpers/trace-step.js";const u="arazzo-docs-";async function $(k){let l=[];return{id:"arazzo",loaders:{"arazzo-doc":y,"arazzo-docs":D},processContent:async(e,o)=>{await P("com.redocly.build.plugin.arazzoDocs",async()=>{for(const t of o.fs.scan(/(\.ya?ml|\.json)$/))if(!await o.isPathIgnored(t.relativePath))try{const{data:a,compoundHash:n}=await o.cache.load(t.realRelativePath,"arazzo-doc");if(!a?.length)continue;l=a.map(({markdocChunks:r,relativePath:c,isVirtual:s,customOutputRelativeFile:i,realRelativePath:d})=>({chunks:r,relativePath:c,realRelativePath:d,isVirtual:i!=null||t.isVirtual||s})),p(a,e.outdir,n);for(const r of a){const c=`${u}${r.relativePath}`;await e.createSharedData(c,{document:r.document})}}catch(a){console.error(a)}})},afterRoutesCreated:async(e,o)=>{for(const{chunks:t,relativePath:a,isVirtual:n,realRelativePath:r}of l)await o.cache.load(a,{loader:async function(){await o.cache.load(r,"arazzo-doc");for(const{node:s,markdown:i,pointer:d,key:z,relativePath:m}of t){const{ast:f}=await e.parseMarkdoc({input:{content:i,relativePath:d,isVirtual:n},context:o,deps:{sharedDataIds:[`${u}${m}`]}});s[`x-parsed-md-${z}`]={result:h(f)}}},name:"arazzo-markdoc-inline-parser"})}}}export{$ as arazzoDocsPlugin};
@@ -1 +1 @@
1
- import{REDOCLY_TEAMS_RBAC as R}from"@redocly/config";import{removeLeadingSlash as O}from"@redocly/theme/core/utils";import{toKebabCase as y}from"../../../../../../utils/string/to-kebab-case.js";import{promiseMapLimit as E}from"../../../../../utils/async/promise-map-limit.js";import{promiseMapLimitWithStatus as x}from"../../../../../utils/async/promise-map-limit-with-status.js";import{extractTeamsFromScopeItems as $}from"../../../../../utils/rbac.js";import{removeMarkdocTags as S}from"../../../../../../markdoc/helpers/remove-markdoc-tags.js";import{BaseApiEntitiesExtractor as b}from"./base.js";import{OpenapiSchemaResolver as w}from"../../../utils/openapi-schema-resolver.js";import{extractPartsFromComponentsRef as N}from"../../../utils/extract-parts-from-components-ref.js";import{isValidTagName as d}from"../../../utils/is-valid-tag-name.js";const A=["get","post","put","delete","patch"],T=15,v=15;class V extends b{#e;constructor(e){super("openapi",e),this.#e=e.context.logger}async loadApiDescriptions(){return(await this.actions.loadApiDocuments(this.context)).filter(o=>o.type==="openapi").map(o=>({...o,isVirtual:o.isVirtual??!1}))}mapApiDescriptionToEntity(e,o){const n=O(e.realRelativePath),s=e.document.info.title,t=this.resolveEntityKey({realRelativePath:e.realRelativePath,customKey:e.document["x-redocly-catalog-key"]});return{type:this.type,key:t,title:s,summary:S(typeof e.document.info.description=="string"?e.document.info.description:void 0),tags:e.document.tags?.filter(a=>a.name&&d(a.name)).map(a=>a.name),metadata:{specType:this.specType,descriptionFile:n},version:o}}async processApiDescription(e,o,n,s){if(w.clearSchemaCache(),!e?.document)throw new Error("OpenAPI definition is missing a bundled document");const t=this.getRbacTeamsForDefinition(e.relativePath),a=this.mapApiDescriptionToEntity(e,n);await this.catalogEntitiesService.createEntity({entity:a,sourceFile:e.realRelativePath,fileHash:e.hash,source:"file",isRootEntity:!0,rbacTeams:t,revision:o}),s.delete(`${a.key}:${n}`),await this.#o(e,a.key,a.version,n,o,s,t);const r=this.#n(e.document.paths);if(r.length!==0){const i=(await x(r,T,async({operation:m,path:h,method:f})=>{if(!m.operationId)return;const l=await this.#c(m,h,f,e,a.key,a.version,o,t);s.delete(`${l}:${n}`)},this.#e)).count.failed;i>0&&this.#e.warn(`Extraction completed with ${i} failures out of ${r.length} operations for ${a.key}`)}}#n(e){return Object.entries(e??{}).flatMap(([o,n])=>A.filter(s=>n[s]).map(s=>{const t=n[s];if(!t)throw new Error(`Operation not found for method ${s} on path ${o}`);return{operation:t,path:o,method:s.toUpperCase()}}))}async#o(e,o,n,s,t,a,r){const c=e.document.components?.schemas;if(!c)return;const i=Object.entries(c);i.length!==0&&await E(i,v,async([m,h])=>{const f=`${o}-${y(m)}`,l=await this.#r({schemaName:m,schema:h,description:e,parentKey:o,parentVersion:n,parentRevision:t,rbacTeams:r});a.delete(`${f}:${s}`),l&&await this.catalogEntitiesService.createEntityRelation({sourceKey:o,sourceVersion:n,sourceRevision:t,type:"uses",targetKey:l.key,targetVersion:n,targetRevision:t,sourceFile:e.realRelativePath,fileHash:e.hash})})}async#r({schemaName:e,schema:o,description:n,parentKey:s,parentVersion:t,parentRevision:a,rbacTeams:r}){const c=w.resolveSchemaRefs(o,n.document),i=JSON.stringify(c),m=c[R]?$(c[R]):r,h=$(c["x-rbac"]),f={type:"data-schema",key:`${s}-${y(e)}`,title:e,summary:(typeof c.description=="string"?c.description:c.title)??null,tags:[],metadata:{specType:this.specType,schema:i},version:t};try{return await this.catalogEntitiesService.createEntity({entity:f,sourceFile:n.realRelativePath,fileHash:n.hash,rbacTeams:h.length?h:m,source:"file",revision:a})}catch(l){return this.#e.error(`Failed to create data schema entity for ${e}: ${l instanceof Error?l.message:"Unknown error"}`),null}}async#c(e,o,n,s,t,a,r,c){const i=`${t}-${y(`${e.operationId}`)}`,m=await Promise.all([this.#h(e.requestBody??null,s),this.#l(e.responses??{},s)]),h=m[0].schemaNames,f=m[1].schemaNames;m[0].errors.length>0&&this.#e.warn(`Schema extraction errors for operation ${e.operationId}: ${m[0].errors.join(", ")}`),m[1].errors.length>0&&this.#e.warn(`Response schema extraction errors for operation ${e.operationId}: ${m[1].errors.join(", ")}`);const l=h.map(p=>`${t}-${y(p)}`),u=f.map(p=>`${t}-${y(p)}`),g=await this.#p({path:o,method:n,operation:e,requestBodySchemasKeys:l,responseSchemasKeys:u,description:s,parentKey:t,parentVersion:a,parentRevision:r,rbacTeams:c});return g&&await Promise.all([this.#i(h,e.operationId??"",s.realRelativePath,s.hash,t,a,r),this.#m(f,e.operationId??"",s.realRelativePath,s.hash,t,a,r),this.#y({apiOperationKey:g.key,operationRelations:e["x-catalogRelations"],descriptionUniqueKey:t,description:s,parentVersion:a,parentRevision:r})]),i}async#i(e,o,n,s,t,a,r){return e.length===0||!o?[]:await this.#s(e,o,n,s,t,a,r)}async#m(e,o,n,s,t,a,r){return e.length===0||!o?[]:await this.#s(e,o,n,s,t,a,r)}#h(e,o){const n=[],s=[];try{if(e&&"content"in e&&e.content)for(const t of Object.values(e.content)){const a=this.#a(t,o);if(!a)continue;const r=this.#t(a);r?.componentType==="schemas"&&r.componentName&&n.push(r.componentName)}if(e&&e.$ref){const t=this.#t(e.$ref);if(t?.componentType==="requestBodies"&&t.componentName){const a=o.document.components?.requestBodies?.[t.componentName];if(a&&"content"in a)for(const r of Object.values(a.content??{})){const c=this.#a(r,o);if(!c)continue;const i=this.#t(c);i?.componentType==="schemas"&&i.componentName&&n.push(i.componentName)}}}}catch(t){s.push(`Failed to extract request body schemas: ${t instanceof Error?t.message:"Unknown error"}`)}return{schemaNames:[...new Set(n)],errors:s}}#l(e,o){const n=[],s=[];try{for(const t of Object.values(e)){if(t&&"content"in t&&t.content)for(const a of Object.values(t.content)){const r=this.#a(a,o);if(!r)continue;const c=this.#t(r);c?.componentType==="schemas"&&c.componentName&&n.push(c.componentName)}if(t&&t.$ref){const a=this.#t(t.$ref);if(a?.componentType==="responses"&&a.componentName){const r=o.document.components?.responses?.[a.componentName];if(r&&"content"in r)for(const c of Object.values(r.content??{})){const i=this.#a(c,o);if(!i)continue;const m=this.#t(i);m?.componentType==="schemas"&&m.componentName&&n.push(m.componentName)}}}}}catch(t){s.push(`Failed to extract response schemas: ${t instanceof Error?t.message:"Unknown error"}`)}return{schemaNames:[...new Set(n)],errors:s}}#a(e,o){const n=new Set;let s=e;for(;s&&"$ref"in s;){const t=this.#t(s.$ref),a=t?.componentName;if(t?.componentType!=="mediaTypes"||!a||n.has(a))return;n.add(a),s=o.document.components?.mediaTypes?.[a]}return s?.schema?.$ref}#t(e){try{return N(e)}catch{return{componentType:"",componentName:null}}}async#s(e,o,n,s,t,a,r){return e.length===0?[]:await E(e,v,async c=>await this.#f({operationId:o,schemaName:c,descriptionSourceFile:n,descriptionHash:s,parentKey:t,parentVersion:a,parentRevision:r}))}async#f({operationId:e,schemaName:o,descriptionSourceFile:n,descriptionHash:s,parentKey:t,parentVersion:a,parentRevision:r}){const c=`${t}-${y(o)}`;try{return await this.catalogEntitiesService.createEntityRelation({sourceKey:`${t}-${y(e)}`,type:"uses",targetKey:c,sourceFile:n,fileHash:s,sourceVersion:a,targetVersion:a,sourceRevision:r,targetRevision:r}),c}catch(i){throw this.#e.error(`Failed to create relation between operation ${e} and schema ${o}: ${i instanceof Error?i.message:"Unknown error"}`),i}}async#p({path:e,method:o,operation:n,requestBodySchemasKeys:s,responseSchemasKeys:t,description:a,parentKey:r,parentVersion:c,parentRevision:i,rbacTeams:m}){const h=`${n.operationId}`,f=`${r}-${y(h)}`,l=n[R]?$(n[R]):m,u=$(n["x-rbac"]),g={type:"api-operation",key:f,title:h,summary:S(n.summary),tags:n.tags?.filter(p=>d(p)),metadata:{path:e,method:o,payload:s,responses:t},version:c};try{return await this.catalogEntitiesService.createEntity({entity:g,sourceFile:a.realRelativePath,fileHash:a.hash,rbacTeams:u.length>0?u:l,source:"file",revision:i})}catch(p){return this.#e.error(`Failed to create API operation entity for ${h}: ${p instanceof Error?p.message:"Unknown error"}`),null}}async#y({apiOperationKey:e,operationRelations:o,descriptionUniqueKey:n,description:s,parentVersion:t,parentRevision:a}){try{await this.catalogEntitiesService.createEntityRelation({sourceKey:e,type:"partOf",targetKey:n,sourceFile:s.realRelativePath,fileHash:s.hash,sourceVersion:t,targetVersion:t,sourceRevision:a,targetRevision:a}),await this.#u(e,s,o,t,a)}catch(r){this.#e.error(`Failed to create API operation relations for ${e}: ${r instanceof Error?r.message:"Unknown error"}`)}}async#u(e,o,n,s,t){n?.length&&await E(n,T,async a=>{try{this.validateEntityRelationFileSchema(a),await this.catalogEntitiesService.createEntityRelation({sourceKey:e,type:a.type,targetKey:a.key,sourceFile:o.realRelativePath,fileHash:o.hash,sourceVersion:s,targetVersion:"",sourceRevision:t,targetRevision:""})}catch(r){this.context.logger.warn(`Error creating entity relation for operation ${e} based on custom property: ${r instanceof Error?r.message:"Unknown error"}`)}})}}export{V as OpenApiEntitiesExtractor};
1
+ import{REDOCLY_TEAMS_RBAC as g}from"@redocly/config";import{removeLeadingSlash as x}from"@redocly/theme/core/utils";import{toKebabCase as p}from"../../../../../../utils/string/to-kebab-case.js";import{promiseMapLimit as S}from"../../../../../utils/async/promise-map-limit.js";import{promiseMapLimitWithStatus as b}from"../../../../../utils/async/promise-map-limit-with-status.js";import{extractTeamsFromScopeItems as R}from"../../../../../utils/rbac.js";import{removeMarkdocTags as w}from"../../../../../../markdoc/helpers/remove-markdoc-tags.js";import{BaseApiEntitiesExtractor as N}from"./base.js";import{OpenapiSchemaResolver as d}from"../../../utils/openapi-schema-resolver.js";import{extractPartsFromComponentsRef as A}from"../../../utils/extract-parts-from-components-ref.js";import{isValidTagName as T}from"../../../utils/is-valid-tag-name.js";const k=["get","post","put","delete","patch"],v=15,O=15;class _ extends N{#e;constructor(e){super("openapi",e),this.#e=e.context.logger}async loadApiDescriptions(){return(await this.actions.loadApiDocuments(this.context)).filter(o=>o.type==="openapi").map(o=>({...o,isVirtual:o.isVirtual??!1}))}mapApiDescriptionToEntity(e,o){const n=x(e.realRelativePath),s=e.document.info.title,t=this.resolveEntityKey({realRelativePath:e.realRelativePath,customKey:e.document["x-redocly-catalog-key"]});return{type:this.type,key:t,title:s,summary:w(typeof e.document.info.description=="string"?e.document.info.description:void 0),tags:e.document.tags?.filter(a=>a.name&&T(a.name)).map(a=>a.name),metadata:{specType:this.specType,descriptionFile:n},version:o}}async processApiDescription(e,o,n,s){if(d.clearSchemaCache(),!e?.document)throw new Error("OpenAPI definition is missing a bundled document");const t=this.getRbacTeamsForDefinition(e.relativePath),a=this.mapApiDescriptionToEntity(e,n);await this.catalogEntitiesService.createEntity({entity:a,sourceFile:e.realRelativePath,fileHash:e.hash,source:"file",isRootEntity:!0,rbacTeams:t,revision:o}),s.delete(`${a.key}:${n}`),await this.#o(e,a.key,a.version,n,o,s,t);const r=this.#n(e.document.paths);if(r.length!==0){const i=(await b(r,v,async({operation:m,path:h,method:f})=>{if(!m.operationId)return;const l=await this.#c(m,h,f,e,a.key,a.version,o,t);s.delete(`${l}:${n}`)},this.#e)).count.failed;i>0&&this.#e.warn(`Extraction completed with ${i} failures out of ${r.length} operations for ${a.key}`)}}#n(e){return Object.entries(e??{}).flatMap(([o,n])=>k.filter(s=>n[s]).map(s=>{const t=n[s];if(!t)throw new Error(`Operation not found for method ${s} on path ${o}`);return{operation:t,path:o,method:s.toUpperCase()}}))}async#o(e,o,n,s,t,a,r){const c=e.document.components?.schemas;if(!c)return;const i=Object.entries(c);i.length!==0&&await S(i,O,async([m,h])=>{const f=`${o}-${p(m)}`,l=await this.#r({schemaName:m,schema:h,description:e,parentKey:o,parentVersion:n,parentRevision:t,rbacTeams:r});a.delete(`${f}:${s}`),l&&await this.catalogEntitiesService.createEntityRelation({sourceKey:o,sourceVersion:n,sourceRevision:t,type:"uses",targetKey:l.key,targetVersion:n,targetRevision:t,sourceFile:e.realRelativePath,fileHash:e.hash})})}async#r({schemaName:e,schema:o,description:n,parentKey:s,parentVersion:t,parentRevision:a,rbacTeams:r}){const c=d.resolveSchemaRefs(o,n.document),i=JSON.stringify(c),m=c[g]?R(c[g]):r,h=R(c["x-rbac"]),f={type:"data-schema",key:`${s}-${p(e)}`,title:e,summary:(typeof c.description=="string"?c.description:c.title)??null,tags:[],metadata:{specType:this.specType,schema:i},version:t};try{return await this.catalogEntitiesService.createEntity({entity:f,sourceFile:n.realRelativePath,fileHash:n.hash,rbacTeams:h.length?h:m,source:"file",revision:a})}catch(l){return this.#e.error(`Failed to create data schema entity for ${e}: ${l instanceof Error?l.message:"Unknown error"}`),null}}async#c(e,o,n,s,t,a,r,c){const i=`${t}-${p(`${e.operationId}`)}`,m=this.#h(e.requestBody??null,s),h=this.#l(e.responses??{},s),f=m.schemaNames,l=h.schemaNames;m.errors.length>0&&this.#e.warn(`Schema extraction errors for operation ${e.operationId}: ${m.errors.join(", ")}`),h.errors.length>0&&this.#e.warn(`Response schema extraction errors for operation ${e.operationId}: ${h.errors.join(", ")}`);const u=f.map(E=>`${t}-${p(E)}`),$=l.map(E=>`${t}-${p(E)}`),y=await this.#p({path:o,method:n,operation:e,requestBodySchemasKeys:u,responseSchemasKeys:$,description:s,parentKey:t,parentVersion:a,parentRevision:r,rbacTeams:c});return y&&await Promise.all([this.#i(f,e.operationId??"",s.realRelativePath,s.hash,t,a,r),this.#m(l,e.operationId??"",s.realRelativePath,s.hash,t,a,r),this.#y({apiOperationKey:y.key,operationRelations:e["x-catalogRelations"],descriptionUniqueKey:t,description:s,parentVersion:a,parentRevision:r})]),i}async#i(e,o,n,s,t,a,r){return e.length===0||!o?[]:await this.#s(e,o,n,s,t,a,r)}async#m(e,o,n,s,t,a,r){return e.length===0||!o?[]:await this.#s(e,o,n,s,t,a,r)}#h(e,o){const n=[],s=[];try{if(e&&"content"in e&&e.content)for(const t of Object.values(e.content)){const a=this.#a(t,o);if(!a)continue;const r=this.#t(a);r?.componentType==="schemas"&&r.componentName&&n.push(r.componentName)}if(e&&e.$ref){const t=this.#t(e.$ref);if(t?.componentType==="requestBodies"&&t.componentName){const a=o.document.components?.requestBodies?.[t.componentName];if(a&&"content"in a)for(const r of Object.values(a.content??{})){const c=this.#a(r,o);if(!c)continue;const i=this.#t(c);i?.componentType==="schemas"&&i.componentName&&n.push(i.componentName)}}}}catch(t){s.push(`Failed to extract request body schemas: ${t instanceof Error?t.message:"Unknown error"}`)}return{schemaNames:[...new Set(n)],errors:s}}#l(e,o){const n=[],s=[];try{for(const t of Object.values(e)){if(t&&"content"in t&&t.content)for(const a of Object.values(t.content)){const r=this.#a(a,o);if(!r)continue;const c=this.#t(r);c?.componentType==="schemas"&&c.componentName&&n.push(c.componentName)}if(t&&t.$ref){const a=this.#t(t.$ref);if(a?.componentType==="responses"&&a.componentName){const r=o.document.components?.responses?.[a.componentName];if(r&&"content"in r)for(const c of Object.values(r.content??{})){const i=this.#a(c,o);if(!i)continue;const m=this.#t(i);m?.componentType==="schemas"&&m.componentName&&n.push(m.componentName)}}}}}catch(t){s.push(`Failed to extract response schemas: ${t instanceof Error?t.message:"Unknown error"}`)}return{schemaNames:[...new Set(n)],errors:s}}#a(e,o){const n=new Set;let s=e;for(;s&&"$ref"in s;){const t=this.#t(s.$ref),a=t?.componentName;if(t?.componentType!=="mediaTypes"||!a||n.has(a))return;n.add(a),s=o.document.components?.mediaTypes?.[a]}return s?.schema?.$ref}#t(e){try{return A(e)}catch{return{componentType:"",componentName:null}}}async#s(e,o,n,s,t,a,r){return e.length===0?[]:await S(e,O,async c=>await this.#f({operationId:o,schemaName:c,descriptionSourceFile:n,descriptionHash:s,parentKey:t,parentVersion:a,parentRevision:r}))}async#f({operationId:e,schemaName:o,descriptionSourceFile:n,descriptionHash:s,parentKey:t,parentVersion:a,parentRevision:r}){const c=`${t}-${p(o)}`;try{return await this.catalogEntitiesService.createEntityRelation({sourceKey:`${t}-${p(e)}`,type:"uses",targetKey:c,sourceFile:n,fileHash:s,sourceVersion:a,targetVersion:a,sourceRevision:r,targetRevision:r}),c}catch(i){throw this.#e.error(`Failed to create relation between operation ${e} and schema ${o}: ${i instanceof Error?i.message:"Unknown error"}`),i}}async#p({path:e,method:o,operation:n,requestBodySchemasKeys:s,responseSchemasKeys:t,description:a,parentKey:r,parentVersion:c,parentRevision:i,rbacTeams:m}){const h=`${n.operationId}`,f=`${r}-${p(h)}`,l=n[g]?R(n[g]):m,u=R(n["x-rbac"]),$={type:"api-operation",key:f,title:h,summary:w(n.summary),tags:n.tags?.filter(y=>T(y)),metadata:{path:e,method:o,payload:s,responses:t},version:c};try{return await this.catalogEntitiesService.createEntity({entity:$,sourceFile:a.realRelativePath,fileHash:a.hash,rbacTeams:u.length>0?u:l,source:"file",revision:i})}catch(y){return this.#e.error(`Failed to create API operation entity for ${h}: ${y instanceof Error?y.message:"Unknown error"}`),null}}async#y({apiOperationKey:e,operationRelations:o,descriptionUniqueKey:n,description:s,parentVersion:t,parentRevision:a}){try{await this.catalogEntitiesService.createEntityRelation({sourceKey:e,type:"partOf",targetKey:n,sourceFile:s.realRelativePath,fileHash:s.hash,sourceVersion:t,targetVersion:t,sourceRevision:a,targetRevision:a}),await this.#u(e,s,o,t,a)}catch(r){this.#e.error(`Failed to create API operation relations for ${e}: ${r instanceof Error?r.message:"Unknown error"}`)}}async#u(e,o,n,s,t){n?.length&&await S(n,v,async a=>{try{this.validateEntityRelationFileSchema(a),await this.catalogEntitiesService.createEntityRelation({sourceKey:e,type:a.type,targetKey:a.key,sourceFile:o.realRelativePath,fileHash:o.hash,sourceVersion:s,targetVersion:"",sourceRevision:t,targetRevision:""})}catch(r){this.context.logger.warn(`Error creating entity relation for operation ${e} based on custom property: ${r instanceof Error?r.message:"Unknown error"}`)}})}}export{_ as OpenApiEntitiesExtractor};
@@ -1 +1 @@
1
- import*as t from"react";import{useMemo as l}from"react";import{QueryClientProvider as c,QueryClient as m}from"@tanstack/react-query";import{RedocSchema as u,StoreProvider as i,GraphQLTypeViewByName as d,MarkdownAdapterProvider as n,createMarkdocAdapter as f,buildGraphqlStoreFromSdl as s}from"@redocly/api-docs";import{Catalog as y}from"@redocly/theme/components/Catalog/Catalog";import{CatalogEntity as p}from"@redocly/theme/components/Catalog/CatalogEntity/CatalogEntity";import{NotFound as h}from"@redocly/theme/layouts/NotFound";const E=new m({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),o=f();function S({sdl:e,typeName:a}){const r=l(()=>{try{return s(e)}catch{return null}},[e]);return r?t.createElement(i,{apiStore:r,options:{specType:"graphql"}},t.createElement(n,{value:o},t.createElement(d,{typeName:a,fieldExpandLevel:0}))):null}function w({pageProps:e}){return e.status==="notFound"?t.createElement(h,null):t.createElement(c,{client:E},"entities"in e&&t.createElement(y,{entitiesTypes:e.entitiesTypes,catalogConfig:e.catalogConfig,filters:e.filters,initialEntitiesList:e.entities,catalogSwitcherItems:e.catalogSwitcherItems,initialViewMode:e.initialViewMode}),"entity"in e&&t.createElement(n,{value:o},t.createElement(p,{RedocSchema:u,StoreProvider:i,GraphqlTypeRenderer:S})))}export{w as default};
1
+ import*as t from"react";import{useMemo as l}from"react";import{QueryClientProvider as m,QueryClient as c}from"@tanstack/react-query";import{RedocSchema as u,StoreProvider as i,GraphQLTypeViewByName as d,MarkdownAdapterProvider as n,createMarkdocAdapter as f}from"@redocly/api-docs";import{buildGraphqlStoreFromSdl as s}from"@redocly/api-docs/lib/adapters/graphql/buildStoreFromSdl.js";import{Catalog as p}from"@redocly/theme/components/Catalog/Catalog";import{CatalogEntity as y}from"@redocly/theme/components/Catalog/CatalogEntity/CatalogEntity";import{NotFound as h}from"@redocly/theme/layouts/NotFound";const E=new c({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),o=f();function S({sdl:e,typeName:a}){const r=l(()=>{try{return s(e)}catch{return null}},[e]);return r?t.createElement(i,{apiStore:r,options:{specType:"graphql"}},t.createElement(n,{value:o},t.createElement(d,{typeName:a,fieldExpandLevel:0}))):null}function w({pageProps:e}){return e.status==="notFound"?t.createElement(h,null):t.createElement(m,{client:E},"entities"in e&&t.createElement(p,{entitiesTypes:e.entitiesTypes,catalogConfig:e.catalogConfig,filters:e.filters,initialEntitiesList:e.entities,catalogSwitcherItems:e.catalogSwitcherItems,initialViewMode:e.initialViewMode}),"entity"in e&&t.createElement(n,{value:o},t.createElement(y,{RedocSchema:u,StoreProvider:i,GraphqlTypeRenderer:S})))}export{w as default};