@redocly/realm 0.136.0-next.6 → 0.136.0-next.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/dist/bin.js +1 -1
- package/dist/cli/build/analytics/collect-analytics.js +1 -1
- package/dist/cli/build/index.js +1 -1
- package/dist/cli/eject/resolveEjectParams.js +1 -1
- package/dist/cli/stats/collectors/openapi/index.js +1 -1
- package/dist/cli/stats/index.js +1 -1
- package/dist/client/App.js +1 -1
- package/dist/client/TestProvider.js +1 -1
- package/dist/client/api-docs-builder-entry.d.ts +3 -0
- package/dist/client/api-docs-builder-entry.js +1 -0
- package/dist/client/app/Feedback/useSubmitFeedback.js +1 -1
- package/dist/client/app/Sidebar/Sidebar.js +3 -3
- package/dist/client/app/Sidebar/useActions.js +1 -1
- package/dist/client/app/hooks/codeHighlight/useCodeHighlight.js +1 -1
- package/dist/client/app/hooks/index.d.ts +1 -0
- package/dist/client/app/hooks/index.js +1 -1
- package/dist/client/app/hooks/useAutoScroll.js +1 -1
- package/dist/client/app/hooks/useUserClaims.js +1 -1
- package/dist/client/app/l10n/hooks/index.d.ts +1 -0
- package/dist/client/app/l10n/hooks/index.js +1 -1
- package/dist/client/app/l10n/hooks/useTranslationKeys.d.ts +2 -0
- package/dist/client/app/l10n/hooks/useTranslationKeys.js +1 -0
- package/dist/client/app/markdoc/custom-components/openapi/json-schema.d.ts +1 -1
- package/dist/client/app/markdoc/custom-components/openapi/json-schema.js +1 -1
- package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.d.ts +1 -5
- package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.js +1 -1
- package/dist/client/app/markdoc/custom-components/openapi/openapi-example.js +1 -1
- package/dist/client/app/markdoc/custom-components/openapi/openapi-response-sample.js +1 -1
- package/dist/client/app/markdoc/custom-components/openapi/replay-openapi.d.ts +8 -24
- package/dist/client/app/markdoc/custom-components/openapi/replay-openapi.js +1 -1
- package/dist/client/app/markdoc/hooks/use-store.d.ts +8 -6
- package/dist/client/app/markdoc/utils/build-replay-operation-source-map.d.ts +20 -0
- package/dist/client/app/markdoc/utils/build-replay-operation-source-map.js +1 -0
- package/dist/client/app/markdoc/utils/find-api-item.d.ts +15 -0
- package/dist/client/app/markdoc/utils/find-api-item.js +1 -0
- package/dist/client/app/markdoc/utils/find-code-sample-panel.d.ts +11 -0
- package/dist/client/app/markdoc/utils/find-code-sample-panel.js +1 -0
- package/dist/client/app/markdoc/utils/find-openapi-response-samples.d.ts +15 -0
- package/dist/client/app/markdoc/utils/find-openapi-response-samples.js +1 -0
- package/dist/client/app/markdoc/utils/openapi-panel-entry.d.ts +18 -0
- package/dist/client/app/markdoc/utils/openapi-panel-entry.js +1 -0
- package/dist/client/app/utils/resolveRouteBySlug.js +1 -1
- package/dist/client/providers/theme/ThemeDataProvider.js +1 -1
- package/dist/client/runtime/loader.js +1 -1
- package/dist/client/templates/api-docs/helpers.d.ts +10 -0
- package/dist/client/templates/api-docs/helpers.js +1 -0
- package/dist/client/templates/api-docs/template.d.ts +17 -0
- package/dist/client/templates/api-docs/template.js +14 -0
- package/dist/client/types/sidebar.d.ts +0 -1
- package/dist/client/utils/utils.d.ts +0 -2
- package/dist/client/utils/utils.js +1 -1
- package/dist/constants/common.d.ts +1 -0
- package/dist/constants/common.js +1 -1
- package/dist/constants/l10n/langs/ar.js +1 -1
- package/dist/constants/l10n/langs/de.js +1 -1
- package/dist/constants/l10n/langs/en.js +1 -1
- package/dist/constants/l10n/langs/es.js +1 -1
- package/dist/constants/l10n/langs/fr.js +1 -1
- package/dist/constants/l10n/langs/hi.js +1 -1
- package/dist/constants/l10n/langs/it.js +1 -1
- package/dist/constants/l10n/langs/ja.js +1 -1
- package/dist/constants/l10n/langs/ko.js +1 -1
- package/dist/constants/l10n/langs/pl.js +1 -1
- package/dist/constants/l10n/langs/pt-BR.js +1 -1
- package/dist/constants/l10n/langs/pt.js +1 -1
- package/dist/constants/l10n/langs/ru.js +1 -1
- package/dist/constants/l10n/langs/uk.js +1 -1
- package/dist/constants/l10n/langs/zh.js +1 -1
- package/dist/server/constants/plugins/api-docs.d.ts +3 -0
- package/dist/server/constants/plugins/api-docs.js +1 -0
- package/dist/server/esbuild/esbuild-logger.js +3 -3
- package/dist/server/esbuild/esbuild.js +3 -3
- package/dist/server/esbuild/plugins/api-docs-module-replacer/empty-check.d.ts +9 -0
- package/dist/server/esbuild/plugins/api-docs-module-replacer/empty-check.js +1 -0
- package/dist/server/esbuild/plugins/api-docs-module-replacer/empty-overlay.d.ts +2 -0
- package/dist/server/esbuild/plugins/api-docs-module-replacer/empty-overlay.js +1 -0
- package/dist/server/esbuild/plugins/api-docs-module-replacer/index.d.ts +6 -0
- package/dist/server/esbuild/plugins/api-docs-module-replacer/index.js +1 -0
- package/dist/server/plugins/api-docs/get-server-props.d.ts +4 -0
- package/dist/server/plugins/api-docs/get-server-props.js +1 -0
- package/dist/server/plugins/api-docs/get-template-path.d.ts +2 -0
- package/dist/server/plugins/api-docs/get-template-path.js +1 -0
- package/dist/server/plugins/api-docs/import-api-docs-builder.d.ts +8 -0
- package/dist/server/plugins/api-docs/import-api-docs-builder.js +1 -0
- package/dist/server/plugins/api-docs/index.d.ts +19 -0
- package/dist/server/plugins/api-docs/index.js +1 -0
- package/dist/server/plugins/api-docs/loader.d.ts +35 -0
- package/dist/server/plugins/api-docs/loader.js +3 -0
- package/dist/server/plugins/api-docs/options.d.ts +14 -0
- package/dist/server/plugins/api-docs/options.js +1 -0
- package/dist/server/plugins/api-docs/search/get-ai-search-documents.d.ts +20 -0
- package/dist/server/plugins/api-docs/search/get-ai-search-documents.js +105 -0
- package/dist/server/plugins/api-docs/search/search-facets.d.ts +10 -0
- package/dist/server/plugins/api-docs/search/search-facets.js +1 -0
- package/dist/server/plugins/api-docs/search/search-indexer.d.ts +9 -0
- package/dist/server/plugins/api-docs/search/search-indexer.js +1 -0
- package/dist/server/plugins/api-docs/search/search-resolver.d.ts +5 -0
- package/dist/server/plugins/api-docs/search/search-resolver.js +1 -0
- package/dist/server/plugins/api-docs/spec-download.api.d.ts +4 -0
- package/dist/server/plugins/api-docs/spec-download.api.js +1 -0
- package/dist/server/plugins/api-docs/store-definition-bundles.d.ts +3 -0
- package/dist/server/plugins/api-docs/store-definition-bundles.js +1 -0
- package/dist/server/plugins/api-docs/utils/build-item-positions.d.ts +17 -0
- package/dist/server/plugins/api-docs/utils/build-item-positions.js +1 -0
- package/dist/server/plugins/api-docs/utils/build-routes-mapping.d.ts +3 -0
- package/dist/server/plugins/api-docs/utils/build-routes-mapping.js +1 -0
- package/dist/server/plugins/api-docs/utils/collect-item-routes.d.ts +12 -0
- package/dist/server/plugins/api-docs/utils/collect-item-routes.js +1 -0
- package/dist/server/plugins/api-docs/utils/decorators.d.ts +26 -0
- package/dist/server/plugins/api-docs/utils/decorators.js +1 -0
- package/dist/server/plugins/api-docs/utils/format-bundle-error.d.ts +6 -0
- package/dist/server/plugins/api-docs/utils/format-bundle-error.js +5 -0
- package/dist/server/plugins/api-docs/utils/normalize-api-version.d.ts +2 -0
- package/dist/server/plugins/api-docs/utils/normalize-api-version.js +1 -0
- package/dist/server/plugins/api-docs/utils/normalize-feedback-options.d.ts +2 -0
- package/dist/server/plugins/api-docs/utils/normalize-feedback-options.js +1 -0
- package/dist/server/plugins/api-docs/utils/relative-path-to-base-slug.d.ts +20 -0
- package/dist/server/plugins/api-docs/utils/relative-path-to-base-slug.js +1 -0
- package/dist/server/plugins/api-docs/utils/replace-file-extension.d.ts +2 -0
- package/dist/server/plugins/api-docs/utils/replace-file-extension.js +1 -0
- package/dist/server/plugins/api-docs/utils/resolve-api-doc-title.d.ts +3 -0
- package/dist/server/plugins/api-docs/utils/resolve-api-doc-title.js +1 -0
- package/dist/server/plugins/api-docs/utils/resolve-config-rbac.d.ts +10 -0
- package/dist/server/plugins/api-docs/utils/resolve-config-rbac.js +1 -0
- package/dist/server/plugins/api-docs/utils/to-relative-slug.d.ts +2 -0
- package/dist/server/plugins/api-docs/utils/to-relative-slug.js +1 -0
- package/dist/server/plugins/api-functions/index.js +1 -1
- package/dist/server/plugins/arazzo-docs/index.js +1 -1
- package/dist/server/plugins/asyncapi-docs/index.js +1 -1
- package/dist/server/plugins/catalog-classic/index.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/arazzo-entities-extractor.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/asyncapi-entities-extractor.d.ts +13 -5
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/asyncapi-entities-extractor.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/base.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/graphql-entities-extractor.d.ts +6 -5
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/graphql-entities-extractor.js +2 -2
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/openapi-entities-extractor.d.ts +12 -5
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/openapi-entities-extractor.js +1 -1
- package/dist/server/plugins/catalog-entities/plugin.js +1 -1
- package/dist/server/plugins/catalog-entities/template/index.js +1 -1
- package/dist/server/plugins/catalog-entities/types/openapi.d.ts +1 -1
- package/dist/server/plugins/catalog-entities/utils/openapi-component-content-extractor.d.ts +3 -3
- package/dist/server/plugins/catalog-entities/utils/openapi-component-content-extractor.js +1 -1
- package/dist/server/plugins/catalog-entities/utils/openapi-schema-resolver.d.ts +4 -3
- package/dist/server/plugins/catalog-entities/utils/openapi-schema-resolver.js +1 -1
- package/dist/server/plugins/config-parser/index.js +1 -1
- package/dist/server/plugins/create-slugify.d.ts +17 -0
- package/dist/server/plugins/create-slugify.js +1 -0
- package/dist/server/plugins/default-theme/index.js +1 -1
- package/dist/server/plugins/dev-onboarding/index.js +1 -1
- package/dist/server/plugins/entitlements/index.js +1 -1
- package/dist/server/plugins/graphql-docs/index.js +1 -1
- package/dist/server/plugins/helpers/parse-partials.d.ts +3 -0
- package/dist/server/plugins/helpers/parse-partials.js +1 -0
- package/dist/server/plugins/l10n/index.js +1 -1
- package/dist/server/plugins/lifecycle.js +2 -2
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/load-openapi-bundle.d.ts +5 -3
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/load-openapi-bundle.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-json-example-ref.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-open-api-ref.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-code-samples.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-response-samples.js +1 -1
- package/dist/server/plugins/markdown/index.js +1 -1
- package/dist/server/plugins/markdown/search/walk-sections.js +1 -1
- package/dist/server/plugins/mcp/codemode/constants.js +1 -1
- package/dist/server/plugins/mcp/codemode/tools/execute-schema.js +1 -1
- package/dist/server/plugins/mcp/codemode/tools/execute.d.ts +1 -0
- package/dist/server/plugins/mcp/constants.d.ts +1 -0
- package/dist/server/plugins/mcp/constants.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tool-schemas.d.ts +1 -0
- package/dist/server/plugins/mcp/docs-mcp/tool-schemas.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/core/create-anonymous-session.d.ts +11 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/core/create-anonymous-session.js +1 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/constants.d.ts +4 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/constants.js +1 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/get-graphql-type-list.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/get-graphql-type.js +7 -4
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/types.d.ts +7 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/types.js +0 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/utils.d.ts +5 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/utils.js +4 -2
- package/dist/server/plugins/mcp/docs-mcp/tools/index.d.ts +4 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/index.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/load-api-description.d.ts +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/utils.d.ts +1 -1
- package/dist/server/plugins/mcp/docs-mcp/utils.d.ts +1 -1
- package/dist/server/plugins/mcp/gateway-mcp/elicitation.d.ts +2 -2
- package/dist/server/plugins/mcp/gateway-mcp/elicitation.js +2 -2
- package/dist/server/plugins/mcp/gateway-mcp/eligibility.d.ts +1 -2
- package/dist/server/plugins/mcp/gateway-mcp/fetch/allowed-hosts.d.ts +1 -1
- package/dist/server/plugins/mcp/gateway-mcp/secret-store.d.ts +4 -4
- package/dist/server/plugins/mcp/gateway-mcp/secret-store.js +1 -1
- package/dist/server/plugins/mcp/gateway-mcp/subject.d.ts +20 -0
- package/dist/server/plugins/mcp/gateway-mcp/subject.js +1 -0
- package/dist/server/plugins/mcp/handlers/mcp-credentials-handler.js +9 -9
- package/dist/server/plugins/mcp/index.js +1 -1
- package/dist/server/plugins/mcp/servers/docs-server.js +1 -1
- package/dist/server/plugins/mcp/servers/mcp-server.js +1 -1
- package/dist/server/plugins/mcp/types.d.ts +1 -2
- package/dist/server/plugins/mcp/utils/xmcp-utils.d.ts +1 -1
- package/dist/server/plugins/mcp/utils.d.ts +17 -5
- package/dist/server/plugins/mcp/utils.js +1 -1
- package/dist/server/plugins/openapi-docs/index.js +1 -1
- package/dist/server/plugins/pages/index.js +1 -1
- package/dist/server/plugins/scorecard-classic/compute-scorecard.js +4 -4
- package/dist/server/plugins/scorecard-classic/index.js +1 -1
- package/dist/server/plugins/scorecards/plugin.js +1 -1
- package/dist/server/plugins/search/ai-indexer/prepare-semantic-documents.js +2 -2
- package/dist/server/plugins/search/documents/search-documents.js +1 -1
- package/dist/server/plugins/search/index.js +1 -1
- package/dist/server/plugins/search/llmstxt/index.js +4 -4
- package/dist/server/plugins/sidebars/index.js +1 -1
- package/dist/server/plugins/sitemap/index.js +1 -1
- package/dist/server/plugins/sso/index.js +1 -1
- package/dist/server/ssr/render.js +1 -1
- package/dist/server/ssr/utils.d.ts +1 -0
- package/dist/server/ssr/utils.js +5 -5
- package/dist/server/store.d.ts +2 -6
- package/dist/server/store.js +1 -1
- package/dist/server/types/plugins/common.d.ts +3 -5
- package/dist/server/types/plugins/markdown.d.ts +1 -3
- package/dist/server/types/plugins/search.d.ts +1 -0
- package/dist/server/utils/catalog-classic/get-route-slug-to-catalog-slug-map.test.js +1 -1
- package/dist/server/utils/report-all-errors.js +1 -1
- package/dist/server/utils/shared-data.js +1 -1
- package/dist/server/web-server/routes/resolve-route.js +1 -1
- package/dist/types/markdoc.d.ts +2 -1
- package/dist/utils/url/get-shared-data-fetch-url.d.ts +17 -0
- package/dist/utils/url/get-shared-data-fetch-url.js +1 -0
- package/package.json +9 -8
- package/dist/markdoc/helpers/get-operation/get-operation-info-by-id.d.ts +0 -4
- package/dist/markdoc/helpers/get-operation/get-operation-info-by-id.js +0 -1
- package/dist/markdoc/helpers/get-operation/get-operation-info-by-pointer.d.ts +0 -4
- package/dist/markdoc/helpers/get-operation/get-operation-info-by-pointer.js +0 -1
- package/dist/markdoc/helpers/get-operation/get-operation.d.ts +0 -14
- package/dist/markdoc/helpers/get-operation/get-operation.js +0 -1
- package/dist/markdoc/helpers/get-operation/index.d.ts +0 -4
- package/dist/markdoc/helpers/get-operation/index.js +0 -1
- package/dist/markdoc/helpers/get-operation/types/index.d.ts +0 -4
- package/dist/markdoc/helpers/get-operation/types/index.js +0 -0
- package/dist/markdoc/helpers/get-operation/types/operation-identifier.d.ts +0 -5
- package/dist/markdoc/helpers/get-operation/types/operation-identifier.js +0 -0
- package/dist/markdoc/helpers/get-operation/types/operation-info.d.ts +0 -6
- package/dist/markdoc/helpers/get-operation/types/operation-info.js +0 -0
- package/dist/markdoc/helpers/get-operation/types/operation-parameters.d.ts +0 -3
- package/dist/markdoc/helpers/get-operation/types/operation-parameters.js +0 -0
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/get-media-content-samples.d.ts +0 -4
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/get-media-content-samples.js +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { buildItems } from '@redocly/api-docs/src/adapters/build.js';
|
|
2
|
+
import type { simplifyAstStructure } from '@redocly/api-docs/src/adapters/utils/simplifyAstStructure.js';
|
|
3
|
+
export type ApiDocsBuilder = {
|
|
4
|
+
buildItems: typeof buildItems;
|
|
5
|
+
simplifyAstStructure: typeof simplifyAstStructure;
|
|
6
|
+
};
|
|
7
|
+
export declare function importApiDocsBuilder(serverOutDir: string): Promise<ApiDocsBuilder>;
|
|
8
|
+
//# sourceMappingURL=import-api-docs-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as m,statSync as a}from"node:fs";import{pathToFileURL as c}from"node:url";import{buildItems as p,simplifyAstStructure as n}from"@redocly/api-docs";import{slash as u}from"../../../utils/path/slash.js";import{logger as l}from"../../tools/notifiers/logger.js";async function h(i){const s=u(i),r=`${s}/api-docs-builder-entry.mjs`,e=`${s}/api-docs-builder-entry.js`,o=m(r)?r:e;try{const t=a(o).mtimeMs;return await import(c(o).toString()+"?"+t)}catch(t){return l.verbose(`api-docs: using statically imported builder (remapped bundle not found in '${i}'): ${t?.message}`),{buildItems:p,simplifyAstStructure:n}}}export{h as importApiDocsBuilder};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LifecyclePluginInstance } from '../../types';
|
|
2
|
+
export declare function apiDocsPlugin(): Promise<LifecyclePluginInstance>;
|
|
3
|
+
/**
|
|
4
|
+
* Item links are absolute (adapter contract: basePath baked in at build time),
|
|
5
|
+
* but routes register relative to fsPath. Map the link to route-slug fields so
|
|
6
|
+
* core route creation runs slugify(fsPath) and keeps content-slugs transforms
|
|
7
|
+
* (versioned `@x.y` folders, custom slugs) applied — an explicit `slug` bypasses
|
|
8
|
+
* them and 404s the public URLs:
|
|
9
|
+
* - under basePath → `{ slugSuffix }` (also feeds getPageVersions, so the
|
|
10
|
+
* version picker retains the current page)
|
|
11
|
+
* - the base route (or an empty suffix) → `{}` — register at fsPath alone
|
|
12
|
+
* - outside basePath → `{ slug }` (explicit fallback)
|
|
13
|
+
*/
|
|
14
|
+
export declare function toRouteSlugFields(link: string, basePath: string): {
|
|
15
|
+
slugSuffix: string;
|
|
16
|
+
} | {
|
|
17
|
+
slug: string;
|
|
18
|
+
} | Record<string, never>;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{REDOCLY_ROUTE_RBAC as w,REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{mcpTagSchemas as Z,schemaDefinitionTag as ee,markdocParser as N}from"@redocly/api-docs";import{withPathPrefix as B}from"@redocly/theme/core/utils";import{API_DOCS_TEMPLATE_ID as U,GRAPHQL_SPEC_SLUG as te,PUBLIC_RBAC_SCOPE_ITEM as q}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 C}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 ne}from"../create-slugify.js";import{apiDocLoader as ie,apiDocsLoader as ce}from"./loader.js";import{getTemplatePath as V}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 ge}from"./utils/collect-item-routes.js";import{buildRoutesMapping as he}from"./utils/build-routes-mapping.js";import{buildItemPositions as De}from"./utils/build-item-positions.js";import{resolveApiDocTitle as Se}from"./utils/resolve-api-doc-title.js";import{resolveConfigRbac as Pe}from"./utils/resolve-config-rbac.js";import{relativePathToBaseSlug as ye}from"./utils/relative-path-to-base-slug.js";import{normalizeApiVersion as Ie}from"./utils/normalize-api-version.js";import{importApiDocsBuilder as j}from"./import-api-docs-builder.js";import{envConfig as x}from"../../config/env-config.js";import{logger as Ae}from"../../tools/notifiers/logger.js";const T="openapi-spec-download",ve={asyncapi:"AsyncAPI Docs",graphql:"GraphQL Docs",openapi:"OpenAPI Docs"};async function rt(){let t=[],r=new Map;const s=new WeakMap;let i=new Set,m={};function k(o,g,A){const P=s.get(o)??new Map;s.set(o,P);const h=g??"";return P.get(h)===A?!1:(P.set(h,A),!0)}return{id:"api-docs",requiredEntitlements:["openapi","asyncapi","graphql"],loaders:{"api-doc":ie,"api-docs":ce},processContent:async(o,g)=>{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]:q,getStaticData:async()=>({props:{}})}),o.addApiRoute({slug:oe+"/*",requestHandlerId:T,httpMethod:"all",[v]:q,getStaticData:async()=>({props:{}})}),o.addApiRoute({slug:te+"/*",requestHandlerId:T,httpMethod:"all",[v]:q,getStaticData:async()=>({props:{}})});const A=o.createTemplate(U,V("../../../client/templates/api-docs/template.js")),P=o.registerServerPropsGetter(U,V("./get-server-props.js")),h=await g.getConfig();r=new Map,m={};const y=await o.loadApiDocuments(g);pe(y,o.outdir);const E=!!h.plugins?.some(e=>typeof e=="string"&&e.startsWith("@redocly/portal-plugin-async-api/"));E&&y.some(e=>e.type==="asyncapi")&&Ae.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");const c=E?y.filter(e=>e.type!=="asyncapi"):y;t=c.map(({markdocChunks:e,relativePath:I,isVirtual:u,customOutputRelativeFile:a,realRelativePath:f})=>({chunks:e??[],relativePath:I,realRelativePath:f,isVirtual:a!=null||u}));const{buildItems:n}=await j(o.serverOutDir),D=(await g.cache.load("content-slugs","content-slugs")).data,S=ne(D),O=e=>se(S(e));for(const e of c){const I=e.customOutputRelativeFile||e.relativePath,u=O(I);_e(e,u);const{items:a,store:f}=await n({type:e.type,document:e.document,options:e.options,basePath:u,markdownParser:N}),R=`${C}${e.relativePath}`,M=x.isDevelopMode?e.relativePath:void 0,p=we(e.document),b=p?.["x-metadata"],_=e.isVirtual?void 0:b?.apiId,$={document:e,basePath:u,sourcePath:M,apiId:_};await o.createSharedData(R,W($,a,f));const z=Pe(e.config),F=!!e.options.excludeFromSearch,K=e.type==="openapi",d=ge(a,z).map(l=>{const J=l.metadata?.seo,H={...Ee(l.link,u),fsPath:I,templateId:A,sharedData:[{key:"apiDocsStore",id:R}],serverPropsGetterIds:[P],excludeFromSearch:F,getStaticData:be(l.label,J),[v]:l[v]};return K?{...H,...l.httpVerb?{httpVerb:l.httpVerb,metadata:{subType:"openapi-operation"}}:{}}:H});if(!d.length)continue;const G=Se(p,e.type,a),Y=Ie(p?.version),L={type:e.type,title:G,version:Y,description:typeof p?.description=="string"?p.description:void 0,summary:typeof p?.summary=="string"?p.summary:void 0,...p?.["x-metadata"]&&typeof p["x-metadata"]=="object"?p["x-metadata"]:{}};d[0]={...d[0],metadata:L,hasClientRoutes:!0,getSidebar:()=>Q(a),getNavText:()=>G??ve[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:u,getSearchFacets:o.getSearchFacets,markdocTags:{...Z,schemaDefinition:ee}})};const X=d[0];d[0]=d[d.length-1],d[d.length-1]=X;for(const l of d)o.addRoute(l);if(_){const l=me(e.config?.apis,e.realRelativePath);m[_]={[v]:l.rbac,[w]:{fsPath:I}}}r.set(R,$)}})},afterRoutesCreated:async(o,g)=>{const{buildItems:A,simplifyAstStructure:P}=await j(o.serverOutDir),h=new Set,y=new Set;for(const{chunks:c,relativePath:n,isVirtual:D}of t){const S=`${C}${n}`,O=fe(o.getAllRoutes(),n);for(const{node:e,markdown:I,pointer:u,key:a,relativePath:f}of c){const{ast:R,compoundHash:M}=await o.parseMarkdoc({input:{content:I,relativePath:f,isVirtual:D},resource:u,context:g,deps:{sharedDataIds:[`${C}${f}`],routeSlugs:O}});if(h.add(u),!(a==="graphql-docs"?e?.description?.value!==void 0:!!(a&&e[a]))||!k(e,a,M))continue;y.add(S);const b=P(R);if(a==="graphql-docs"){e.description&&(e.description.value=b);const _=`${C}${f}`;Re(r.get(_),b)}else a&&(e[a]=b)}}const E=i.difference(h);for(const c of E)g.cache.delete(c);i=h,Object.entries(m).forEach(([c,n])=>{const D=n[w]?.fsPath;if(!D)return;const S=o.getRouteByFsPath(D)?.baseSlug;m[c]={...n,[w]:{...n[w],slug:S},slug:S}}),o.setGlobalData({apiProducts:m});for(const[c,n]of r){if(!y.has(c))continue;const{items:D,store:S}=await A({type:n.document.type,document:n.document.document,options:n.document.options,basePath:n.basePath,markdownParser:N});await o.createSharedData(c,W(n,D,S))}}}}function W({document:t,basePath:r,sourcePath:s,apiId:i},m,k){return{items:m,store:k,options:t.options,baseSlug:r,routesMapping:x.isDevelopMode?he(m,r):{},graphqlPositions:x.isDevelopMode&&t.type==="graphql"?De(m,r):void 0,sourcePath:s,apiId:i}}function Re(t,r){t?.document.type!=="graphql"||!t.document.options||(t.document.options.info={...t.document.options.info||{},description:r})}function be(t,r){return async function(s){return{props:{settings:{baseUrlPath:B(s.baseSlug)},disableAutoScroll:!0,seo:{title:t,...r}}}}}function _e(t,r){const s=t.options?.mockServer,i=B(`/_mock${ye(t.relativePath)}`);s?.url===i&&(t.options={...t.options,mockServer:{...s,url:B(`/_mock${r}`)}})}function Ee(t,r){if(t===r)return{};const s=r==="/"?"/":`${r}/`;if(t.startsWith(s)){const i=t.slice(s.length);return i?{slugSuffix:i}:{}}return{slug:t}}function we(t){if(t&&typeof t=="object"&&"info"in t)return t.info}function Q(t){return t.map(({content:r,items:s,...i})=>({...i,...s&&{items:Q(s)}}))}export{rt as apiDocsPlugin,Ee as toRouteSlugFields};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { OpenAPIDefinition, AsyncApiDefinition, ApiSpecType } from '@redocly/api-docs';
|
|
2
|
+
import type { Node as MarkdocNode } from '@markdoc/markdoc';
|
|
3
|
+
import type { ASTNode, DocumentNode } from 'graphql';
|
|
4
|
+
import type { LifecycleContext } from '../../types';
|
|
5
|
+
import type { RawApiDocsOptions } from '@redocly/api-docs';
|
|
6
|
+
import type { RedoclyConfig } from '@redocly/config';
|
|
7
|
+
export type MarkdocChunk = {
|
|
8
|
+
node: Record<string, unknown> & {
|
|
9
|
+
description?: {
|
|
10
|
+
value?: string | ASTNode[] | ASTNode | MarkdocNode | MarkdocNode[];
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
pointer: string;
|
|
14
|
+
markdown: string;
|
|
15
|
+
relativePath: string;
|
|
16
|
+
key: string | null;
|
|
17
|
+
};
|
|
18
|
+
export type BundledApiDefinition = {
|
|
19
|
+
type: ApiSpecType;
|
|
20
|
+
document: OpenAPIDefinition | AsyncApiDefinition | DocumentNode;
|
|
21
|
+
config: Partial<RedoclyConfig & NonNullable<RedoclyConfig['apis']>[string]>;
|
|
22
|
+
relativePath: string;
|
|
23
|
+
realRelativePath: string;
|
|
24
|
+
customOutputRelativeFile?: string;
|
|
25
|
+
markdocChunks?: MarkdocChunk[];
|
|
26
|
+
isVirtual?: boolean;
|
|
27
|
+
hash: string;
|
|
28
|
+
options: RawApiDocsOptions;
|
|
29
|
+
};
|
|
30
|
+
type PartialDefinition = Omit<BundledApiDefinition, 'hash'>;
|
|
31
|
+
export declare function apiDocLoader(relativePath: string, context: LifecycleContext): Promise<PartialDefinition[]>;
|
|
32
|
+
export declare function apiDocsLoader(_: string, context: LifecycleContext): Promise<BundledApiDefinition[]>;
|
|
33
|
+
export declare function collectGraphqlMarkdocChunks(schemaAst: DocumentNode): MarkdocChunk[];
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import*as p from"node:path";import{parse as B,visit as x}from"graphql";import{Source as N,bundle as _,createConfig as D,getTotals as M,resolvePlugins as V}from"@redocly/openapi-core";import{convertSwagger2OpenAPI as j}from"@redocly/api-docs/lib/adapters/utils/convertSwagger2OpenAPI.js";import{CONFIG_FILE_NAME as k}from"../../../constants/common.js";import{MAX_BUNDLING_ERRORS_TO_PRINT as S}from"../../constants/plugins/api-docs.js";import{unique as F}from"../../../utils/array/unique.js";import{deepMerge as G}from"../../../utils/object/deep-merge.js";import{pluralize as C}from"../../../utils/string/pluralize.js";import{replaceEnvVariablesDeep as L}from"../../utils/envs/replace-env-variables-deep.js";import{logger as q}from"../../tools/notifiers/logger.js";import{reporter as h}from"../../tools/notifiers/reporter.js";import{ExternalResolver as b}from"../../fs/utils/external-ref-resolver.js";import{injectDecoratorIntoConfig as z,isPlainNonMarkdownText as H}from"./utils/decorators.js";import{getAllApiConfigsByPath as J,getApiConfigByPath as Q}from"../get-api-config.js";import{formatBundleError as U}from"./utils/format-bundle-error.js";import{createOptions as O}from"./options.js";const X=/(\.ya?ml|\.json|\.gql|\.graphql)$/,P=/(\.gql|\.graphql)$/;async function kn(n,r){if(p.posix.basename(n)===k)return[];if(P.test(n)){if(await r.isPathIgnored(n))return[];const u=await tn(n,r);return u?[u]:[]}let o;try{o=(await r.cache.load(n,"yaml")).data}catch{return[]}const t=Y(n,o);if(!t||!o||t==="graphql")return t===null&&q.verbose(`${n} file is not a recognized API spec. Skipping`),[];const{fs:c,getConfig:a,isPathIgnored:s}=r,e=t==="openapi"?await a("."):null,i=c.getFileInfo(n),f=await a(p.posix.dirname(n)),l=J(f?.apis,n,f.configPath),w=await s(n),d=[];for(const u of l){if(!u.output&&w)continue;const y=f.configPath?p.posix.dirname(f.configPath):".",g=u.output?p.posix.join(y,u.output):n;if(!await s(g)){i&&u.output&&!c.exists(g)&&c.addVirtualFile(g,i);try{const m=await on({relativePath:n,outputRelativePath:g,loaded:o,specType:t,rootConfig:e,config:f,apiConfig:u,fileRecord:i,fs:c});m&&d.push(m)}catch(m){await h.panicOnBuildContentError(m)}}}return d}async function qn(n,r){const{fs:o,cache:t}=r,c=[];for(const a of o.scan(X)){let s;try{s=await t.load(a.relativePath,"api-doc")}catch{continue}if(s.data?.length)for(const e of s.data)c.push({...e,isVirtual:a.isVirtual||e.isVirtual,hash:s.compoundHash})}return c}function K(n){const r=[];return x(n,{leave:o=>{!("description"in o)||!o.description?.value||!("name"in o)||H(o.description.value)||r.push({node:o,pointer:`#/types/${o?.name?.value}`,markdown:o.description.value,relativePath:"",key:"graphql-docs"})}}),r}async function W(n){try{const r=B(n);return{document:r,markdocChunks:K(r)}}catch(r){await h.panicOnBuildContentError(r);return}}function Y(n,r){return P.test(n)?"graphql":r?.openapi||r?.swagger?"openapi":r?.asyncapi?"asyncapi":null}function $(n,r){return r?{...n,info:{...n.info,"x-metadata":{...n.info?.["x-metadata"],...r}}}:n}async function Z(n,r,o){if(n==="openapi"){const t=r.swagger!==void 0?await j(r):r;return $(t,o)}return $(r,o)}async function nn(n){const{outputRelativePath:r,rootConfig:o,config:t,apiConfig:c,fs:a}=n,s=G({decorators:o?.decorators},t,{rbac:void 0},c),{resolvedObj:e}=L(s);if(e.decorators&&typeof e.decorators!="object"){await h.panicOnBuildContentError(`'decorators' must be an object at redocly.yaml, got '${typeof e.decorators}'`);return}if(e.plugins&&!Array.isArray(e.plugins)){await h.panicOnBuildContentError(`'plugins' must be an array at redocly.yaml, got '${typeof e.plugins}'`);return}const i=p.resolve(a.cwd,t.realConfigPath||k),f=new b(a),l=await D(z(e,r,a.cwd),{configPath:i,externalRefResolver:f});return o?.plugins&&o.configPath!==t.configPath&&(l.plugins=F([...l.plugins||[],...await V(o.plugins,a.cwd)],w=>w.id)),{coreConfig:l,mergedConfig:e}}async function rn(n,r,o){const t=M(n),c=[t.errors&&`${t.errors} ${C(t.errors,"error","errors")}`,t.warnings&&`${t.warnings} ${C(t.warnings,"warning","warnings")}`,t.ignored&&`${t.ignored} ignored`].filter(Boolean).join(", ");if(t.errors){const a=n.filter(i=>i.severity==="error");let s=`${c} while bundling ${r} definition:
|
|
2
|
+
`;const e=Math.min(a.length,S);for(let i=0;i<e;i++){const f=await U(a[i],o);s+=`${f}
|
|
3
|
+
`}if(a.length>e){const i=a.length-e;s+=`... and ${i} more ${C(i,"error","errors")}`}return await h.panicOnBuild(s),!0}return t.warnings&&q.warn(`${c} while bundling %rp definition`,r),!1}async function on(n){const{relativePath:r,outputRelativePath:o,loaded:t,specType:c,rootConfig:a,config:s,apiConfig:e,fileRecord:i,fs:f}=n,l=await nn(n);if(!l)return;const{coreConfig:w,mergedConfig:d}=l,u=p.resolve(f.cwd,r),y=new b(f),g={config:w,base:p.dirname(u),doc:{source:new N(u,await f.read(r)),parsed:JSON.parse(JSON.stringify(t))},externalRefResolver:y},{bundle:{parsed:R},problems:m,visitorsData:v}=await _(g);if(await rn(m,o,f.cwd))return;const I=v["markdown/markdown"]?.markdocChunks??[],A=d.metadata,E=await Z(c,R,A),T=O(c,E,{rootConfig:a,config:s,apiConfig:e,mergedConfig:d,relativePath:o});return{type:c,document:E,config:d,relativePath:o,realRelativePath:i?.realRelativePath||o,customOutputRelativeFile:e.output?o:void 0,markdocChunks:I,isVirtual:i?.isVirtual,options:T}}async function tn(n,r){const{fs:o,getConfig:t}=r,c=await o.read(n),a=o.getFileInfo(n),{document:s,markdocChunks:e}=await W(c)||{};if(!s){await h.panicOnBuildContentError(new Error("Failed to build GraphQL document"));return}const i=await t(),f=Q(i.apis,n);i.graphql?.info?.description&&e?.unshift({node:{description:{value:i.graphql?.info?.description}},pointer:"#/info",markdown:i.graphql?.info?.description,relativePath:"",key:"graphql-docs"});const l=O("graphql",s,{rootConfig:null,config:i,apiConfig:f??{},mergedConfig:{graphql:{...i.graphql??{},...f?.graphql??{}}},relativePath:n});return{type:"graphql",document:s,config:{...i,...f},relativePath:n,realRelativePath:a?.realRelativePath||n,markdocChunks:e,isVirtual:a?.isVirtual,options:l}}export{kn as apiDocLoader,qn as apiDocsLoader,K as collectGraphqlMarkdocChunks};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ApiSpecType, OpenAPIDefinition, AsyncApiDefinition, DownloadUrl, RawApiDocsOptions } from '@redocly/api-docs';
|
|
2
|
+
import type { DocumentNode } from 'graphql';
|
|
3
|
+
export type DocumentBuildContext = {
|
|
4
|
+
rootConfig: Record<string, unknown> | null;
|
|
5
|
+
config: Record<string, unknown>;
|
|
6
|
+
apiConfig: Record<string, unknown>;
|
|
7
|
+
mergedConfig: Record<string, unknown>;
|
|
8
|
+
relativePath: string;
|
|
9
|
+
};
|
|
10
|
+
type CreateOptionsDocument = OpenAPIDefinition | AsyncApiDefinition | DocumentNode;
|
|
11
|
+
export declare function buildDownloadUrls(relativePath: string, specType: ApiSpecType): DownloadUrl[];
|
|
12
|
+
export declare function createOptions(specType: ApiSpecType, document: CreateOptionsDocument, context: DocumentBuildContext): RawApiDocsOptions;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as w from"node:path";import{findFirstBinding as M,markdocParser as P}from"@redocly/api-docs";import{combineUrls as i}from"@redocly/theme/core/openapi";import{withPathPrefix as p}from"@redocly/theme/core/utils";import{GRAPHQL_SPEC_SLUG as _}from"../../../constants/common.js";import{PUBLIC_API_DEFINITIONS_FOLDER as f}from"../../constants/common.js";import{deepMerge as B}from"../../../utils/object/deep-merge.js";import{normalizeFeedbackOptions as E}from"./utils/normalize-feedback-options.js";import{replaceFileExtension as u}from"./utils/replace-file-extension.js";import{relativePathToBaseSlug as I}from"./utils/relative-path-to-base-slug.js";const U={tags:{},nodes:{},components:{}};function A(o,r){if(!(o?.off!==!0))return o;const t=I(r);return{url:p(`/_mock${t}`),position:"first",description:"Mock server",...o}}function L(o,r){return(r==="graphql"?[i(_,`${u(o,w.posix.extname(o))}?download`)]:[i(f,`${u(o,".json")}?download`),i(f,`${u(o,".yaml")}?download`)]).map(t=>({url:p(t)}))}function H(o,r,m){const{rootConfig:t,config:c,apiConfig:d,mergedConfig:e,relativePath:s}=m,a=B(t?.[o]||{},c[o]||{},d[o]||d.theme?.[o]||{}),b=r["x-feedback"]||a.feedback||c.feedback,S=!!e[o]?.excludeFromSearch||!!e.theme?.[o]?.excludeFromSearch||!!t?.[o]?.excludeFromSearch||!!t?.theme?.[o]?.excludeFromSearch,x=e.rbac||d.rbac,g=E(b),h=c.metadata,O={...g&&{feedback:g},hideSidebar:!0,mockServer:A(e?.mockServer||t?.mockServer,s),disableRouter:!0,downloadUrls:a.downloadUrls||L(s,o),excludeFromSearch:S,rbac:x,markdownParser:P};let l;if(o==="graphql"){const n=a;l={title:n.info?.title,...h,...n.metadata??{}}}else{const n=r.info,F=n?.["x-metadata"];l={title:n?.title,description:n?.description,...o==="openapi"&&{summary:n?.summary},...h,...F}}o==="openapi"&&a.showSchemaCatalogLinks&&(r["x-schema-catalog-link"]=i(f,s));const C=a.markdocOptions??U,k={...a,...O,specType:o,markdocOptions:C,metadata:l};return o==="asyncapi"&&(k.protocol=M(r)??void 0),k}export{L as buildDownloadUrls,H as createOptions};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SearchFacet } from '@redocly/theme/core/types';
|
|
2
|
+
import type { ApiItem, ApiDocsMetadata, ApiStore, ApiSpecType, OpenAPIDefinition, AsyncApiDefinition } from '@redocly/api-docs';
|
|
3
|
+
import type { AfterRoutesCreatedActions, AfterRoutesCreatedLifecycleContext, PageRouteDetails } from '../../../types';
|
|
4
|
+
import type { MarkdocTagSchema } from '@redocly/theme/markdoc/tags/types';
|
|
5
|
+
import type { AiDocumentsStore } from '../../../plugins/search/types.js';
|
|
6
|
+
type ApiDocument = OpenAPIDefinition | AsyncApiDefinition | Record<string, unknown>;
|
|
7
|
+
type AiDocumentsStoreParams = {
|
|
8
|
+
items: ApiItem[];
|
|
9
|
+
metadata: ApiDocsMetadata;
|
|
10
|
+
store?: ApiStore;
|
|
11
|
+
document?: ApiDocument;
|
|
12
|
+
specType: ApiSpecType;
|
|
13
|
+
excludeFromSearch?: boolean;
|
|
14
|
+
basePath: string;
|
|
15
|
+
getSearchFacets: () => Map<string, SearchFacet>;
|
|
16
|
+
markdocTags?: Record<string, MarkdocTagSchema>;
|
|
17
|
+
};
|
|
18
|
+
export declare function getAiDocumentsStore({ items, metadata, store, document, specType, excludeFromSearch, basePath, getSearchFacets, markdocTags, }: AiDocumentsStoreParams): (route: PageRouteDetails, _staticData: unknown, context: AfterRoutesCreatedLifecycleContext, actions: AfterRoutesCreatedActions) => Promise<AiDocumentsStore | undefined>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=get-ai-search-documents.d.ts.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import P from"node:path";import{REDOCLY_TEAMS_RBAC as O}from"@redocly/config";import{nodeTypes as h,contentType as g}from"@redocly/api-docs";import{normalizeApiVersion as sn}from"../utils/normalize-api-version.js";import{replaceFileExtension as v}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{DEFAULT_ANONYMOUS_VISITOR_TEAM as an,GRAPHQL_SPEC_SLUG as pn}from"../../../../constants/common.js";import{toMarkdown as N}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 w}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as mn}from"../../search/utils.js";import{extractDocumentSearchFacets as $n}from"./search-facets.js";import{ApiDocsSearchIndexer as gn}from"./search-indexer.js";function A(t,r){return r==="openapi"&&"openapi"in t}function Y(t,r){return r==="asyncapi"&&"asyncapi"in t}function Jn({items:t,metadata:r,store:c,document:n,specType:o,excludeFromSearch:i,basePath:e,getSearchFacets:l,markdocTags:s}){return async(f,a,u,d)=>{if(i)return;const m={...d.markdocOptions?.tags,...s},{locale:X,translate:Z}=await hn(f.slug,d.getGlobalData?.().l10n),C=un(m,X,Z),x=await u.getConfig(),R=dn(f.fsPath),M=new gn(e,c?.schemaStore,n),j=y=>{for(const p of y)M.addItem(p),p.items?.length&&j(p.items)};j(t);const nn=M.getResult(),V=new Map;for(const y of nn)V.set(y.url,y);const L=typeof r.title=="string"?r.title:void 0,_=sn(r.version),E=$n(f.metadata||{},L,_,l),I=[],S=[],F=yn(r,n,o),q=bn(o,r,f.fsPath,x),tn=Sn(t,x,C),en=F+q+`
|
|
2
|
+
`+tn,on=F+q;S.push({title:L||"API Overview",description:typeof r.description=="string"?r.description:void 0,content:en,slug:e,fsPath:f.fsPath,includeInLLMsTxt:!0}),I.push({title:L||"API Overview",content:on,url:e,fsPath:f.fsPath,locale:R,product:f.product?.name,facets:E});const rn=n&&A(n,o)?n.security:void 0,D=y=>{for(const p of y){if(!p.content||!p.link){p.items?.length&&D(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===g.ITEM){const $=Pn(p,n,o)??H(p,k,o,_,rn,C);if($){const b=p.label||"";S.push({title:b,description:void 0,content:$,slug:p.link,fsPath:f.fsPath,includeInLLMsTxt:!1}),I.push({title:b,content:$,url:p.link,fsPath:f.fsPath,locale:R,product:f.product?.name,facets:E,rbacTeams:B})}}else if(G===g.GROUP){const $=On(p,x,o,C);if($){const b=p.label||"";S.push({title:b,description:k?Ln(k.text):void 0,content:$.llmstxt,slug:p.link,fsPath:f.fsPath,includeInLLMsTxt:!1}),I.push({title:b,content:$.aiSearch,url:p.link,fsPath:f.fsPath,locale:R,product:f.product?.name,facets:E,rbacTeams:B})}}p.items?.length&&D(p.items)}};return D(t),{async getLLMsTxts(){return S},async getSearchDocuments(){return I}}}}function yn(t,r,c){const n=typeof t.title=="string"?t.title:"",o=typeof t.description=="string"?t.description:"",i=typeof t.summary=="string"?t.summary:"",e=typeof t.version=="string"?t.version:"";let l=n?`# ${n}
|
|
3
|
+
|
|
4
|
+
`:"";if(l+=o?`${o}
|
|
5
|
+
|
|
6
|
+
`:"",l+=i?`${i}
|
|
7
|
+
|
|
8
|
+
`:"",l+=e?`Version: ${e}
|
|
9
|
+
`:"",r){if(A(r,c)){const{info:s}=r;s?.license?.name&&(l+=`License: ${s.license.name}
|
|
10
|
+
`);const f=s["x-metadata"],a=mn(f);a&&(l+=`
|
|
11
|
+
Metadata:
|
|
12
|
+
${a}
|
|
13
|
+
`)}else if(Y(r,c)){const{info:s}=r;s?.license?.name&&(l+=`License: ${s.license.name}
|
|
14
|
+
`)}}return l+=`
|
|
15
|
+
`,l+=An(r,c),l+=In(r,c),l}function bn(t,r,c,n){if(!c)return"";let o,i,e;if(t==="openapi")o=P.posix.join(Q,v(c,".yaml")),i="## Download OpenAPI description",e="OpenAPI definition";else if(t==="asyncapi")o=P.posix.join(Q,v(c,".yaml")),i="## Download AsyncAPI description",e="AsyncAPI definition";else if(t==="graphql"){const f=P.posix.extname(c)||".graphql";o=P.posix.join(pn,v(c,f)),i="## Download GraphQL schema",e="GraphQL schema"}else return"";if(!ln(o,n.access?.rbac??{},n.access?.requiresLogin??!1,{isAuthenticated:!1,teams:[an]}))return"";const s=typeof r.title=="string"&&r.title||e;return`${i}
|
|
16
|
+
|
|
17
|
+
- ${w({title:s,description:void 0,slug:o})}`}function An(t,r){if(!t)return"";if(A(t,r)){const{servers:c}=t;if(!c?.length)return"";let n=`## Servers
|
|
18
|
+
|
|
19
|
+
`;for(const o of c)if(o.description&&(n+=`${o.description}
|
|
20
|
+
`),n+=`\`\`\`
|
|
21
|
+
${o.url}
|
|
22
|
+
\`\`\`
|
|
23
|
+
|
|
24
|
+
`,o.variables){n+=`Variables:
|
|
25
|
+
`;for(const[i,e]of Object.entries(o.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(", ")}
|
|
28
|
+
`);n+=`
|
|
29
|
+
`}return n}if(Y(t,r)){const{servers:c}=t;if(!c||!Object.keys(c).length)return"";let n=`## Servers
|
|
30
|
+
|
|
31
|
+
`;for(const[o,i]of Object.entries(c))n+=`### ${o}
|
|
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}
|
|
38
|
+
`),n+=`
|
|
39
|
+
`;return n}return""}function In(t,r){if(!t||!A(t,r))return"";const c=t.components?.securitySchemes;if(!c)return"";let n=`## Security
|
|
40
|
+
|
|
41
|
+
`;for(const[o,i]of Object.entries(c)){if(!i||"$ref"in i)continue;const e=i;n+=`### ${o}
|
|
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,s=l?.implicit||l?.password||l?.clientCredentials||l?.authorizationCode;if(s&&("authorizationUrl"in s&&s.authorizationUrl&&(n+=`Authorization URL: ${s.authorizationUrl}
|
|
52
|
+
`),"tokenUrl"in s&&s.tokenUrl&&(n+=`Token URL: ${s.tokenUrl}
|
|
53
|
+
`),s.scopes)){n+=`Scopes:
|
|
54
|
+
`;for(const[f,a]of Object.entries(s.scopes))n+=`- \`${f}\`: ${a}
|
|
55
|
+
`}n+=`
|
|
56
|
+
`}return n}function Sn(t,r,c){let n="";const o=(i,e)=>{for(const l of i)if(l.link){if(l.content?.contentType===g.GROUP)n+=`${e} ${l.label||""}
|
|
57
|
+
|
|
58
|
+
`,l.items?.length&&o(l.items,e+"#");else if(l.content?.contentType===g.ITEM){if(!U(l,r))continue;const s=l,f=s.httpVerb,a=s.httpPath,u=f&&a?`${f.toUpperCase()} ${a}`:l.label||"",d=l.content?T(l.content.children,c):void 0;n+=` - ${w({title:u,description:d?d.slice(0,200):void 0,slug:J(l.link)})}`}}};return o(t,"##"),n}function H(t,r,c,n,o,i){if(!t.content)return;const e=t,l=t.label||"",s=T(t.content.children,i),f=t.content.meta?.deprecated;let a=`# ${l}${f?" (deprecated)":""}
|
|
59
|
+
|
|
60
|
+
`;if(s&&(a+=`${s}
|
|
61
|
+
|
|
62
|
+
`),c==="openapi"||c==="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,o);m&&(a+=`Security: ${m}
|
|
66
|
+
`)}return r?.parameters?.length&&c!=="graphql"&&(a+=`
|
|
67
|
+
`+Cn(r.parameters)+`
|
|
68
|
+
`),c==="graphql"&&(a+=xn(t.content.children)),a}function Pn(t,r,c){if(t.httpVerb!=="tool"||!r||!A(r,c))return;const n=t.content?.meta?.name,o=n?r["x-mcp"]?.tools?.find(e=>e.name===n):void 0;if(!o)return;let i=`# ${t.label||o.name}
|
|
69
|
+
|
|
70
|
+
`;return typeof o.description=="string"&&o.description&&(i+=`${o.description}
|
|
71
|
+
|
|
72
|
+
`),i+=`## Input schema:
|
|
73
|
+
|
|
74
|
+
`,i+=`\`\`\`json
|
|
75
|
+
${JSON.stringify(o.inputSchema,null,2)}
|
|
76
|
+
\`\`\`
|
|
77
|
+
|
|
78
|
+
`,o.outputSchema&&(i+=`## Output schema:
|
|
79
|
+
|
|
80
|
+
`,i+=`\`\`\`json
|
|
81
|
+
${JSON.stringify(o.outputSchema,null,2)}
|
|
82
|
+
\`\`\`
|
|
83
|
+
|
|
84
|
+
`),i}function On(t,r,c,n){if(!t.content)return;const o=t.label||"",i=T(t.content.children,n);let e=`# ${o}
|
|
85
|
+
|
|
86
|
+
`;if(i&&(e+=`${i}
|
|
87
|
+
|
|
88
|
+
`),c==="graphql"){let s="";const f=a=>{for(const u of a??[])if(!(!u.content||!U(u,r)))if(u.content.contentType===g.ITEM){const d=H(u,void 0,c,void 0,void 0,n);d&&(s+=`${d}
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
`)}else u.content.contentType===g.GROUP&&f(u.items)};return f(t.items),{llmstxt:e+s,aiSearch:e}}let l="";if(t.items?.length)for(const s of t.items){if(!s.link||!s.content||s.content.contentType!==g.ITEM||!U(s,r))continue;const f=s,a=f.httpVerb,u=f.httpPath,d=a&&u?`${a.toUpperCase()} ${u}`:s.label||"",m=s.content?T(s.content.children,n):void 0;l+=` - ${w({title:d,description:m?m.slice(0,200):void 0,slug:J(s.link)})}`}return{llmstxt:e+l,aiSearch:e}}function Tn(t,r){const c=[],n=o=>{for(const i of o)if(i.nodeType===h.SECURITY){const e=i;for(const l of e.requirements)for(const s of l.schemes)s[O]||s.name&&!c.includes(s.name)&&c.push(s.name)}else(i.nodeType===h.CONTAINER||i.nodeType===h.OVERVIEW_SECTION_WRAPPER)&&n(i.children)};if(n(t),c.length)return c.join(", ");if(r?.length){const o=r.flatMap(i=>Object.keys(i));if(o.length)return[...new Set(o)].join(", ")}}function Cn(t){const r={};for(const n of t){const o=`${n.place}${n.mediaType?` (${n.mediaType})`:""}`;r[o]||(r[o]=[]),r[o].push(n)}return Object.entries(r).map(([n,o])=>{const i=o.map(e=>{const l=[...e.path||[],e.name],s=Array.isArray(e.description)?e.description.join(" "):e.description;let f=` - \`${l.join(".")}\` (${e.type}${e.required?", required":""})
|
|
93
|
+
`;return s&&(f+=` ${s.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)}:
|
|
97
|
+
|
|
98
|
+
${i.join(`
|
|
99
|
+
`)}`}).join(`
|
|
100
|
+
`)}function xn(t){let r="";const c=n=>{for(const o of n)if(o.nodeType===h.ITEM){const i=o;i.graphqlSchema&&(r+=Rn(i.graphqlSchema,i.variant))}else(o.nodeType===h.CONTAINER||o.nodeType===h.OVERVIEW_SECTION_WRAPPER)&&c(o.children)};return c(t),r}function Rn(t,r){let n=`
|
|
101
|
+
## ${K(r==="return-type"?"Return type":r==="graphql-args"||r==="arguments"?"Arguments":r==="graphql-fields"?"Fields":r)}:
|
|
102
|
+
|
|
103
|
+
`;const o=i=>{const e=i.description?N(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?N(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+=o(e);return n}if(!t.length)return"";for(const i of t)n+=o(i);return n}function T(t,r){const c=[],n=i=>{for(const e of i)if(e.nodeType===h.MARKDOC){const l=e.content,s=Array.isArray(l)?l:[l],f=N(s,{renderTag:r}).trim();f&&c.push(f)}else(e.nodeType===h.CONTAINER||e.nodeType===h.OVERVIEW_SECTION_WRAPPER)&&n(e.children)};return n(t),c.join(" ").trim()||void 0}function Ln(t){return(Array.isArray(t)?t.join(" "):t)||void 0}function K(t){return t.charAt(0).toUpperCase()+t.slice(1)}function U(t,r){return r.access?.requiresLogin?!0:cn({slug:t.link||"",[O]:t[O]},r)}export{Jn as getAiDocumentsStore};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SearchFacet } from '@redocly/theme/core/types';
|
|
2
|
+
export declare function setDocumentSearchFacets(documentSearchFacets: {
|
|
3
|
+
[key: string]: string | Set<string>;
|
|
4
|
+
}, getSearchFacets: () => Map<string, SearchFacet>, setSearchFacets: (searchFacets: Map<string, SearchFacet>) => void): void;
|
|
5
|
+
export declare function extractDocumentSearchFacets(metadata: {
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}, apiTitle: string | undefined, apiVersion: string | undefined, getSearchFacets: () => Map<string, SearchFacet>): {
|
|
8
|
+
[key: string]: string;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=search-facets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SEARCH_GROUP_FACET_FIELD as a}from"../../../../constants/common.js";import{SEARCH_GROUP_NAME_API as u}from"../../../constants/plugins/search.js";function F(e,n,s){const f=n();for(const[t,o]of Object.entries(e)){const c=f.get(t);if(c){const r=new Set(c.values??[]);if(o instanceof Set)for(const i of o)r.add(i);else r.add(o);c.values=Array.from(r)}}s(f)}function h(e,n,s,f){const t={[a]:u,...n&&{apiTitle:n},...s&&{apiVersion:s}};if(!e)return t;const o=f();for(const[c,r]of Object.entries(e))o.has(c)&&(t[c]=String(r));return e.title&&(t.apiTitle=String(e.title)),t}export{h as extractDocumentSearchFacets,F as setDocumentSearchFacets};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ApiItem, SchemaEntry } from '@redocly/api-docs';
|
|
2
|
+
import type { SearchDocument } from '../../../types';
|
|
3
|
+
export declare class ApiDocsSearchIndexer {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(basePath: string, schemaStore?: Record<string, SchemaEntry>, document?: Record<string, unknown>);
|
|
6
|
+
addItem(item: ApiItem): void;
|
|
7
|
+
getResult(): SearchDocument[];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=search-indexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as p}from"@redocly/config";import{extractFullText as W,nodeTypes as g,contentType as P,schemaKind as j}from"@redocly/api-docs";import{toMarkdown as H}from"../../markdown/search/to-markdown.js";const L=10,_=200,C="message payload",D="message headers";function E(h){if(typeof h=="string")return h;const e=Array.isArray(h)?h:[h];return H(e).trim()}function N(h){return h.length>_?`${h.slice(0,_)}\u2026`:h}class B{#c=[];#i;#s;#o;#f;constructor(e,t,n){this.#i=e,this.#s=t,this.#o=n}addItem(e){if(!(!e.link||!e.content))try{switch(e.content.contentType){case P.OVERVIEW:this.#a(e,this.#i);break;case P.GROUP:case P.ITEM:this.#a(e,e.link);break}}catch(t){console.error(`Cannot add item to api-docs search indexer [${e.label}, ${e.link}]:`,t.message)}}#a(e,t){if(!e.content)return;const n=t.startsWith(this.#i+"/")?t.slice(this.#i.length+1):t.split("/").slice(-2).join("/"),i=e.content.children,o=this.#p(i),f=this.#y(i,n),r=e,s={id:t,url:t,title:e.label??"",text:o,path:[],deprecated:e.content.meta?.deprecated,..."httpVerb"in e&&e.httpVerb?{httpMethod:e.httpVerb}:{},..."httpPath"in e&&e.httpPath?{httpPath:e.httpPath}:{},..."badges"in e&&Array.isArray(e.badges)&&e.badges.length?{badges:e.badges}:{},..."isAdditionalOperation"in e&&e.isAdditionalOperation?{isAdditionalOperation:!0}:{},[p]:r[p],...f.length&&{parameters:f}};this.#c.push(s)}#p(e){const t=[],n=i=>{for(const o of i)if(o.nodeType===g.MARKDOC){const f=o;if(this.#h(f.content))continue;const r=W(f.content);r&&t.push(r)}else(o.nodeType===g.CONTAINER||o.nodeType===g.OVERVIEW_SECTION_WRAPPER)&&n(o.children)};return n(e),t.join(" ").trim()}#h(e){let t=!1,n=!1;const i=f=>{f.type==="code"&&f.attributes?.content?t=!0:f.type==="text"&&f.attributes?.content&&(n=!0);for(const r of f.children??[])i(r)},o=Array.isArray(e)?e:[e];for(const f of o)i(f);return t&&!n}#y(e,t){const n={},i=new Set,o=f=>{for(const r of f)if(r.nodeType===g.ITEM){const s=r;if(s[p])continue;if(s.parameters?.length)for(const a of s.parameters){if(a[p])continue;const d=this.#O(s.variant),c=this.#$(s.variant),u=a.description?E(a.description):"",l=this.#A(a.schemaId),$={name:a.name,description:u,place:d,mediaType:void 0,type:l,required:a.required??!1,deepLink:this.#d(t,"request",c,void 0,void 0,[a.name]),example:void 0,enum:void 0};n[this.#n($)]=$}this.#g(s,n,i,t)}else if(r.nodeType===g.CONTAINER){const s=r;if(s[p])continue;o(s.children)}else r.nodeType===g.OVERVIEW_SECTION_WRAPPER&&o(r.children)};return o(e),Object.values(n)}#n(e){return[...Array.isArray(e.path)?e.path:[],e.name.toString()].join(".")+e.description+e.place}#d(e,t,n,i,o,f){if(!e)return"";const r=f.join("/"),s=[`t=${t}`];return n&&s.push(`in=${n}`),o&&s.push(`c=${o}`),i&&s.push(`ct=${i}`),r&&s.push(`path=${r}`),`/${e}#${e}/${s.join("&")}`.toLowerCase()}#m(e,t,n,i){if(!e)return"";let o="messages";t&&(o+=`&m=${t}`),o+=`&t=${n}`;const f=i.join("/");return f&&(o+=`&path=${f}`),`/${e}#${e}/${o}`.toLowerCase()}#$(e){switch(e){case"query":return"query";case"path":return"path";case"headers":return"header";case"cookies":return"cookie";default:return}}#O(e){switch(e){case"query":return"query parameters";case"path":return"path parameters";case"headers":return"header parameters";case"cookies":return"cookie parameters";case"parameters":return"channel parameters";default:return e?`${e} parameters`:"parameters"}}#A(e){const t=this.#s?.[e];if(!t||t.kind!==j.JSON_SCHEMA)return"unknown";const n=t.data,i=this.#l(n);return this.#u(i)}#u(e){return Array.isArray(e.type)?e.type.join(" | "):e.type?e.type:e.properties||e.additionalProperties?"object":e.items?"array":e.enum?"string":"any"}#g(e,t,n,i){const o=this.#E(e);if(e.graphqlSchema&&Array.isArray(e.graphqlSchema)){this.#S(e.graphqlSchema,o,t);return}if(!this.#s||!this.#o)return;const f=o.startsWith("response");if(e.mediaTypeSchemas){const r=Object.entries(e.mediaTypeSchemas),s=r.find(([,a])=>!a[p]);if(s){const[a,d]=s;d.schemaId&&this.#r(d.schemaId,o,a,r.length>1,f,t,[],n,i)}}else e.schemaId&&this.#r(e.schemaId,o,void 0,!1,f,t,[],n,i);if(e.responses)for(const r of e.responses){if(r[p])continue;const s=`response ${r.code} fields`,a=new Set;if(r.mediaTypeContent){const d=Object.entries(r.mediaTypeContent),c=d.find(([,u])=>!u[p]);if(c){const[u,l]=c;l.schemaId&&this.#r(l.schemaId,s,u,d.length>1,!0,t,[],a,i)}}else r.schemaId&&this.#r(r.schemaId,s,r.mediaType,!1,!0,t,[],a,i)}if(e.messages)for(const r of e.messages){if(r[p])continue;const s=r.description?E(r.description):"",a=r.summary??"",d={name:r.name,description:(s+a).trim(),place:"message",mediaType:void 0,type:"unknown",required:!1,example:void 0,enum:void 0};t[this.#n(d)]=d,this.#f=r.name;const c=new Set;r.schemaId&&this.#r(r.schemaId,C,r.contentType,!1,!1,t,[],c,i),r.headerSchemaId&&this.#r(r.headerSchemaId,D,void 0,!1,!1,t,[],c,i),this.#f=void 0}}#E(e){switch(e.variant){case"body":return"request fields";case"responses":return"response fields";case"graphql-fields":return"fields";case"graphql-args":return"arguments";case"return-type":return"return type fields";default:return e.variant??"fields"}}#S(e,t,n){for(const i of e){const o=i.description?E(i.description):"",f={name:i.name,description:o,place:t,mediaType:void 0,path:[],type:i.type??"unknown",required:!1,example:void 0,enum:void 0};if(n[this.#n(f)]=f,i.args?.length)for(const r of i.args){const s=r.description?E(r.description):"",a={name:r.name,description:s,place:"arguments",mediaType:void 0,path:[i.name],type:r.type??"unknown",required:!1,example:void 0,enum:void 0};n[this.#n(a)]=a}}}#r(e,t,n,i,o,f,r,s,a=""){const d=this.#s?.[e];if(!d||d.kind!==j.JSON_SCHEMA||d[p])return;const c=d.data,u=i?n:void 0;this.#t(c,t,n,u,o,f,r,s,0,a)}#I(e){const t=e.match(/^response (\d+)/);return t?t[1]:void 0}#l(e){if(e.allOf){const t={};for(const n of e.allOf){const i=n.$ref?this.#e(n.$ref):n;if(i){const o=t.properties,f=t.required;Object.assign(t,i),(o||i.properties)&&(t.properties={...o||{},...i.properties||{}}),(f||i.required)&&(t.required=[...f||[],...i.required||[]])}}return delete t.allOf,e.description&&(t.description=e.description),t}if(e.$ref){const t=this.#e(e.$ref);if(t){const n={...t};return e.description&&(n.description=e.description),n}}return e}#e(e){if(!e.startsWith("#/"))return;const t=e.slice(2).split("/");let n=this.#o;for(const i of t){if(n==null||typeof n!="object")return;n=n[i]}return n!=null&&typeof n=="object"?n:void 0}#t(e,t,n,i,o,f,r,s,a,d=""){if(!(a>L||e[p])){if(e.$ref){if(s.has(e.$ref))return;s.add(e.$ref);const c=this.#e(e.$ref);c&&this.#t(c,t,n,i,o,f,r,s,a,d);return}if(e.allOf){const c={};for(const u of e.allOf){let l=u;if(u.$ref){if(s.has(u.$ref))continue;s.add(u.$ref),l=this.#e(u.$ref)}if(l){const $=c.properties,A=c.required;Object.assign(c,l),($||l.properties)&&(c.properties={...$||{},...l.properties||{}}),(A||l.required)&&(c.required=[...A||[],...l.required||[]])}}delete c.allOf,this.#t(c,t,n,i,o,f,r,s,a,d);return}if(e.discriminator&&e.properties&&e.oneOf){this.#t({...e,oneOf:void 0,discriminator:void 0},t,n,i,o,f,r,s,a,d);return}if(e.oneOf||e.anyOf){for(const c of e.oneOf||e.anyOf||[]){if(c.$ref){if(s.has(c.$ref))continue;s.add(c.$ref)}const u=c.$ref?this.#e(c.$ref):c;u&&this.#t(u,t,n,i,o,f,r,s,a+1,d)}return}if(e.properties){const c=e.required||[],u=this.#I(t),l=o?"response":"request",$=t===C?"payload":t===D?"headers":void 0;for(const[A,O]of Object.entries(e.properties)){if(O[p])continue;if(O.$ref){if(s.has(O.$ref))continue;s.add(O.$ref)}const m=O.$ref?this.#e(O.$ref):O;if(!m)continue;let x=!1;if(m.allOf){let b=!1;for(const q of m.allOf)q.$ref?s.has(q.$ref)||(s.add(q.$ref),b=!0):b=!0;x=!b}const y=this.#l(m);if(m[p]||y[p]||y.readOnly&&!o||y.writeOnly&&o||m.additionalProperties!==void 0&&!m.properties)continue;const T=m.description??y.description,R=T?E(T):"",S=m.example??y.example,V=S!==void 0?N(typeof S=="string"?S:JSON.stringify(S)):void 0,v=Array.isArray(y.enum)&&y.enum.length?y.enum:void 0,I=[...r,A],w={name:A,description:R,place:t,mediaType:n,path:r,type:this.#u(y),required:c.includes(A),deepLink:$?this.#m(d,this.#f,$,I):this.#d(d,l,void 0,i,u,I),example:V,enum:v},k=this.#n(w);f[k]==null&&(f[k]=w,x||this.#t(y,t,n,i,o,f,I,s,a+1,d))}}if(e.items&&typeof e.items=="object"&&!Array.isArray(e.items)){if(e.items.$ref){if(s.has(e.items.$ref))return;s.add(e.items.$ref)}const c=e.items.$ref?this.#e(e.items.$ref):e.items;c&&this.#t(c,t,n,i,o,f,r,s,a+1,d)}}}getResult(){return this.#c}}export{B as ApiDocsSearchIndexer};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SearchFacet } from '@redocly/theme/core/types';
|
|
2
|
+
import type { ApiItem, ApiDocsMetadata, ApiStore } from '@redocly/api-docs';
|
|
3
|
+
import type { PageRouteDetails, SearchDocument } from '../../../types';
|
|
4
|
+
export declare function searchResolver(items: ApiItem[], metadata: ApiDocsMetadata, getSearchFacets: () => Map<string, SearchFacet>, setSearchFacets: (searchFacets: Map<string, SearchFacet>) => void, excludeFromSearch?: boolean, store?: ApiStore, document?: Record<string, unknown>): (route: PageRouteDetails) => Promise<SearchDocument[]>;
|
|
5
|
+
//# sourceMappingURL=search-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{REDOCLY_ROUTE_RBAC as p,REDOCLY_TEAMS_RBAC as o}from"@redocly/config";import{extractDocumentSearchFacets as A,setDocumentSearchFacets as D}from"./search-facets.js";import{ApiDocsSearchIndexer as d}from"./search-indexer.js";import{normalizeApiVersion as x}from"../utils/normalize-api-version.js";function O(h,i,c,u,R,g,S){return async e=>{if(R)return[];const a=e.baseSlug||e.slug,m=new d(a,g?.schemaStore,S),f=t=>{for(const r of t)m.addItem(r),r.items?.length&&f(r.items)};f(h);const s=typeof i.title=="string"?i.title:void 0,n=x(i.version),l=A(e.metadata||{},s,n,c);return D(l,c,u),m.getResult().map(t=>({...t,...t.url===a&&s&&{title:n?`${s} (${n})`:s},[o]:t[o]??e[o],[p]:e[p]??{slug:e.slug,fsPath:e.fsPath},facets:l}))}}export{O as searchResolver};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"node:path";import{existsSync as c}from"node:fs";import{readFile as F}from"node:fs/promises";import C from"js-yaml";import{withoutPathPrefix as U}from"@redocly/theme/core/utils";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as I,PUBLIC_API_DEFINITIONS_FOLDER as p}from"../../constants/common.js";import{GRAPHQL_SPEC_SLUG as y}from"../../../constants/common.js";import{canDownloadApiDefinition as O,filterDataByAccessDeep as q}from"../../utils/rbac.js";function A(a,t){const n=e.parse(a);return e.join(n.dir,n.name+t)}const T=async(a,t,n)=>{const{isAuthenticated:i,teams:l,claims:{email:f}}=t.user,S=new URL(a.url),o=U(S.pathname),m=o.startsWith(y),s=decodeURIComponent(m?o.replace(y,""):o.replace(p,"").replace(I,"")),{rbac:u={},requiresLogin:d=!1}=t.config.access||{};if(!O(o,u,d,{isAuthenticated:i,email:f,teams:l}))return new Response("Unauthorized",{status:i?403:401});const r=n.props?.outdir||"";if(m){const E=e.join(r,p,s);if(!c(E))return new Response("Not found",{status:404});const x=await F(E,"utf-8");return new Response(x,{headers:{"Content-Type":"application/graphql"}})}const h=e.join(r,p,A(s,".json")),P=e.join(r,I,A(s,".json")),R=c(h),_=c(P);if(!R&&!_)return new Response("Not found",{status:404});const L=await F(R?h:P,"utf-8"),N=JSON.parse(L),w=q(N,{isAuthenticated:i,email:f,teams:l},u,d),D=e.extname(s),j=D===".yaml"?C.dump(w):JSON.stringify(w,null,2);return new Response(j,{headers:{"Content-Type":D===".yaml"?"application/yaml":"application/json"}})};var k=T;export{k as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as m}from"fs";import p from"path";import{print as d}from"graphql";import{PUBLIC_API_DEFINITIONS_FOLDER as h,PUBLIC_STATIC_FOLDER as a}from"../../constants/common.js";import{logger as u}from"../../tools/notifiers/logger.js";import{ensureDir as g}from"../../utils/fs.js";import{replaceFileExtension as S}from"./utils/replace-file-extension.js";const r=new Map;function D(f,t){const n=h.slice(1);try{for(const e of f){const{document:s,relativePath:i,hash:o,type:c}=e;if(r.get(i)!==o){if(c==="graphql"){l({outDir:t,definitionFolder:n,relativePath:i,definitionString:d(s)}),r.set(i,o);continue}if(i.startsWith(a+"/")){l({outDir:t,definitionFolder:".",relativePath:i.replace(a+"/",""),definitionString:JSON.stringify(s,null,2)}),r.set(i,o);continue}l({outDir:t,definitionFolder:n,relativePath:S(i,".json"),definitionString:JSON.stringify(s,null,2)}),r.set(i,o)}}}catch(e){u.error("failed to store definition bundles",e)}}function l({outDir:f,definitionString:t,relativePath:n,definitionFolder:e}){m(g(p.resolve(f,`${e}/${n}`)),t,"utf8")}export{D as storeDefinitionBundles};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ApiItem } from '@redocly/api-docs';
|
|
2
|
+
export type ItemPosition = {
|
|
3
|
+
position: {
|
|
4
|
+
start: {
|
|
5
|
+
lineNumber: number;
|
|
6
|
+
column: number;
|
|
7
|
+
};
|
|
8
|
+
end?: {
|
|
9
|
+
lineNumber: number;
|
|
10
|
+
column: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
startLine: number;
|
|
14
|
+
endLine: number;
|
|
15
|
+
};
|
|
16
|
+
export declare function buildItemPositions(items: ApiItem[], baseSlug: string, acc?: Record<string, ItemPosition>): Record<string, ItemPosition>;
|
|
17
|
+
//# sourceMappingURL=build-item-positions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{toRelativeSlug as s}from"./to-relative-slug.js";function m(r,n,i={}){for(const t of r){const e=t.content?.meta?.position,o=t.routeSlug??t.link;e&&o&&(i[s(o,n)]={position:e,startLine:e.start.lineNumber,endLine:e.end?.lineNumber??e.start.lineNumber}),t.items?.length&&m(t.items,n,i)}return i}export{m as buildItemPositions};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{toRelativeSlug as u}from"./to-relative-slug.js";function f(r,e,o={}){for(const t of r){const i=t.content?.meta?.pointer,n=t.routeSlug??t.link;i&&n&&(o[`#${i}`]=u(n,e)),t.items?.length&&f(t.items,e,o)}return o}export{f as buildRoutesMapping};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { REDOCLY_TEAMS_RBAC } from '@redocly/config';
|
|
2
|
+
import type { ApiItem } from '@redocly/api-docs';
|
|
3
|
+
import type { RbacScopeItems } from '@redocly/config';
|
|
4
|
+
export type ItemRouteEntry = {
|
|
5
|
+
link: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
httpVerb?: string;
|
|
8
|
+
metadata?: Record<string, unknown>;
|
|
9
|
+
[REDOCLY_TEAMS_RBAC]?: RbacScopeItems;
|
|
10
|
+
};
|
|
11
|
+
export declare function collectItemRoutes(items: ApiItem[], configRbac?: RbacScopeItems, inheritedRbac?: RbacScopeItems): ItemRouteEntry[];
|
|
12
|
+
//# sourceMappingURL=collect-item-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as n}from"@redocly/config";function i(m,o,l){const e=[];for(const t of m){const s=t[n],a=s??l??o;t.link&&e.push({link:t.link,label:t.label,httpVerb:t.httpVerb,metadata:t.metadata,[n]:a}),t.items&&t.items.length>0&&e.push(...i(t.items,o,s??l))}return e}export{i as collectItemRoutes};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RawUniversalConfig } from '@redocly/openapi-core';
|
|
2
|
+
export declare function isPlainNonMarkdownText(markdown: string): boolean;
|
|
3
|
+
export declare const MarkdownParserDecorator: ({ outputRelativePath, cwd, }: {
|
|
4
|
+
outputRelativePath: string;
|
|
5
|
+
cwd: string;
|
|
6
|
+
}) => {
|
|
7
|
+
any: {
|
|
8
|
+
leave(node: Record<string, unknown>, ctx: any): void;
|
|
9
|
+
};
|
|
10
|
+
ref: {
|
|
11
|
+
leave(node: Record<string, unknown>, ctx: any): void;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare const RbacDecorator: () => {
|
|
15
|
+
Tag: {
|
|
16
|
+
enter(node: Record<string, unknown>): void;
|
|
17
|
+
};
|
|
18
|
+
any: {
|
|
19
|
+
leave(node: Record<string, unknown>, ctx: any): void;
|
|
20
|
+
};
|
|
21
|
+
ref: {
|
|
22
|
+
leave(node: Record<string, unknown>): void;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare function injectDecoratorIntoConfig(config: RawUniversalConfig, outputRelativePath: string, cwd: string): RawUniversalConfig;
|
|
26
|
+
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import b from"node:path";import{REDOCLY_TEAMS_RBAC as p}from"@redocly/config";import{slash as k}from"../../../../utils/path/slash.js";function f(t,r,a){if(!r)throw new Error("Visitor required");if(t){t.description&&r(t,"description",a.location.absolutePointer+"/description",a);for(const o in t["x-enumDescriptions"])r(t["x-enumDescriptions"],o,a.location.absolutePointer+"/x-enumDescriptions/"+o,a)}}const x=/^[a-zA-Z0-9\s\-,.!\?:;'"()/]+$/,d=/^\s*(?:[-+*]\s|\d+[.)]\s)/m;function g(t){return x.test(t)&&!d.test(t)}const s=({outputRelativePath:t,cwd:r})=>{const a=function(e,m,l,u){const{node:n}=u.resolve(e[m]);if(!n||typeof n!="string"||g(n))return;const i=u.getVisitorData();i.markdocChunks=i.markdocChunks||[],i.markdocChunks.push({node:e,pointer:k(b.relative(r,l)),markdown:n,relativePath:t,key:m})};return{any:{leave(o,e){f(o,a,e)}},ref:{leave(o,e){f(o,a,e)}}}},c=()=>{const t={};return{Tag:{enter(r){r?.["x-rbac"]&&(t[String(r.name)]=r["x-rbac"])}},any:{leave(r,a){if((a.type.name==="Operation"||a.type.name==="Webhook")&&"tags"in r&&Array.isArray(r.tags))for(const o of r.tags)t[o]&&(r["x-rbac"]=r["x-rbac"]||t[o]);r?.["x-rbac"]&&(r[p]=r["x-rbac"],delete r["x-rbac"])}},ref:{leave(r){r?.["x-rbac"]&&(r[p]=r["x-rbac"],delete r["x-rbac"])}}}};function D(t,r,a){const o={id:"markdown",decorators:{oas2:{markdown:s,rbac:c},oas3:{markdown:s,rbac:c},async3:{markdown:s,rbac:c}}};return{...t,decorators:{"markdown/rbac":"on","markdown/markdown":{outputRelativePath:r,cwd:a},...t.decorators||{}},plugins:[...t.plugins||[],o]}}export{s as MarkdownParserDecorator,c as RbacDecorator,D as injectDecoratorIntoConfig,g as isPlainNonMarkdownText};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type NormalizedProblem } from '@redocly/openapi-core';
|
|
2
|
+
/**
|
|
3
|
+
* Formats a bundle error with file path, line/column, and codeframe for better debugging.
|
|
4
|
+
*/
|
|
5
|
+
export declare function formatBundleError(problem: NormalizedProblem, cwd: string): Promise<string>;
|
|
6
|
+
//# sourceMappingURL=format-bundle-error.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import f from"node:path";import{getLineColLocation as m,isAbsoluteUrl as g}from"@redocly/openapi-core";import{gray as s}from"../../../tools/notifiers/helpers/colors.js";import{getCodeframe as h}from"../../../utils/codeframes/codeframes.js";async function P(o,c){const e=o.location?.[0];if(!e)return`${o.message} at `;if(!e.source){const t=e.pointer??"";return`${o.message} at ${t}`}const n=g(e.source.absoluteRef)?e.source.absoluteRef:f.relative(c,e.source.absoluteRef);try{const t=m(e),i=e.pointer?s(`at ${e.pointer}`):"",l=`${n}:${t.start.line}:${t.start.col}`;let r="";try{const a=e.source?.getLines()??[],u={start:{line:t.start.line,character:t.start.col},end:{line:t.end?.line??t.start.line,character:t.end?.col??Math.max(t.start.col+1,a[t.start.line-1]?.length??t.start.col)},lines:a},{frame:$}=h(u,!0);r=$}catch{r=""}return`${l} ${i}
|
|
2
|
+
${o.message}
|
|
3
|
+
${r?`${r}
|
|
4
|
+
`:""}`}catch{const t=e.pointer?s(`at ${e.pointer}`):"";return`${n} ${t}
|
|
5
|
+
${o.message}`}}export{P as formatBundleError};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(n){if(!(n==null||typeof n=="object"))return String(n)}export{r as normalizeApiVersion};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{FEEDBACK_TYPES as t}from"../../../../constants/common.js";function o(s){if(!s)return;let e="";const{type:i,settings:a}=s;switch(i){case t.RATING:e="Rate this section";break;case t.SENTIMENT:e="Was this section helpful?";break;case t.MOOD:e="Was this section helpful?";break;case t.COMMENT:e="Share your feedback about this section";break;case t.SCALE:e="How would you rate this section?";break}return{...s,settings:{...a,label:a?.label||e}}}export{o as normalizeFeedbackOptions};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a spec file's relative path to its base route slug, applying the same
|
|
3
|
+
* l10n transform the route builder uses (`@l10n/de/foo.yaml` -> `/de/foo`).
|
|
4
|
+
*
|
|
5
|
+
* Index files map to their directory URL (`foo/index.yaml` -> `/foo`). The
|
|
6
|
+
* index decision reuses `parseBaseName` — the exact primitive the core route
|
|
7
|
+
* slugifier uses (`isIndexFile` in server/plugins/lifecycle.ts) — so it can't
|
|
8
|
+
* drift from the core / openapi-docs. Without it, an API mounted at
|
|
9
|
+
* `output: foo/index.yaml` would land at `/foo/index` and break links/sidebar
|
|
10
|
+
* entries that reference it by its `index.yaml` output path.
|
|
11
|
+
*
|
|
12
|
+
* NOTE: this transform does NOT apply the content-slugs normalizations
|
|
13
|
+
* (versioned `@x.y` folders, custom slugs) — route building derives slugs
|
|
14
|
+
* through `createSlugify` instead. It is used by the loader-time mock-server
|
|
15
|
+
* URL (`options.ts`) and by `rebaseAutoMockServerUrl` (`index.ts`), which
|
|
16
|
+
* reconstructs the same value to detect the auto-generated URL and rebase it
|
|
17
|
+
* onto the normalized route slug.
|
|
18
|
+
*/
|
|
19
|
+
export declare function relativePathToBaseSlug(relativePath: string): string;
|
|
20
|
+
//# sourceMappingURL=relative-path-to-base-slug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import i from"node:path";import{isL10nPath as m}from"../../../fs/utils/is-l10n-path.js";import{getLocaleFromRelativePath as n}from"../../../fs/utils/get-locale-from-relative-path.js";import{removeL10nPrefix as s}from"../../../fs/utils/remove-l10n-prefix.js";import{parseBaseName as p}from"../../utils.js";function h(r){const{baseName:t,isIndexFile:a}=p(r),e=i.posix.dirname(r),o=a?e==="."?"":e:e==="."?t:i.posix.join(e,t);return m(o)?("/"+n(o).toLowerCase()+"/"+s(o)).replace(/\/{2,}/g,"/"):("/"+o).replace(/\/{2,}/g,"/")}export{h as relativePathToBaseSlug};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from"node:path";function s(o,e){const i=n.posix.dirname(o),p=n.posix.basename(o,n.posix.extname(o))+e;return n.posix.join(i,p)}export{s as replaceFileExtension};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(e,r,i){if(typeof e?.title=="string")return e.title;if(r==="graphql"){const t=i[0]?.label;if(typeof t=="string")return t}}export{n as resolveApiDocTitle};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RbacScopeItems } from '@redocly/config';
|
|
2
|
+
type ConfigWithRbac = {
|
|
3
|
+
access?: {
|
|
4
|
+
rbac?: unknown;
|
|
5
|
+
};
|
|
6
|
+
rbac?: unknown;
|
|
7
|
+
};
|
|
8
|
+
export declare function resolveConfigRbac(config?: ConfigWithRbac): RbacScopeItems | undefined;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=resolve-config-rbac.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isRbacScopeItems as e}from"../../../utils/rbac/is-rbac-scope-items.js";function a(r){if(e(r?.access?.rbac))return r.access.rbac;if(e(r?.rbac))return r.rbac}export{a as resolveConfigRbac};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function i(r,t){return t?r===t?"":r.startsWith(`${t}/`)?r.slice(t.length+1):r:r}export{i as toRelativeSlug};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as c}from"path";import{transformSync as l}from"esbuild";import{REDOCLY_ROUTE_RBAC as p}from"@redocly/config";import{removeTrailingSlash as d}from"../../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as m}from"../../../utils/url/remove-leading-slash.js";import{logger as u}from"../../tools/notifiers/logger.js";import{envConfig as g}from"../../config/env-config.js";import{USER_DEFINED_API_FUNCTIONS_COUNTER_KEY as h}from"../../../server/store.js";import{parseRouteFsPathForHono as F}from"./helpers/parse-route-fs-path-for-hono.js";import{telemetryTraceStep as A}from"../../../cli/telemetry/helpers/trace-step.js";const f="api-functions",P=/\bexport\s+default\b|\bexport\s*\{[^}]*\b(?:default\s*[,}]|\w+\s+as\s+default\b)/;async function E(t,o){let
|
|
1
|
+
import{join as c}from"path";import{transformSync as l}from"esbuild";import{REDOCLY_ROUTE_RBAC as p}from"@redocly/config";import{removeTrailingSlash as d}from"../../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as m}from"../../../utils/url/remove-leading-slash.js";import{logger as u}from"../../tools/notifiers/logger.js";import{envConfig as g}from"../../config/env-config.js";import{USER_DEFINED_API_FUNCTIONS_COUNTER_KEY as h}from"../../../server/store.js";import{parseRouteFsPathForHono as F}from"./helpers/parse-route-fs-path-for-hono.js";import{telemetryTraceStep as A}from"../../../cli/telemetry/helpers/trace-step.js";const f="api-functions",P=/\bexport\s+default\b|\bexport\s*\{[^}]*\b(?:default\s*[,}]|\w+\s+as\s+default\b)/;async function E(t,o){let r;try{r=await o.fs.read(t),l(r,{loader:t.endsWith(".js")?"js":"ts"})}catch(e){const a=e instanceof Error?e.message:String(e);return u.warn(`Skipping API function ${t} because it cannot be parsed: ${a}`),!1}if(!P.test(r)){const e=`API function ${t} does not export a default function. Add 'export default function (request, context) { ... }' to define an API function.`;return g.isDevelopMode?(u.warn(e),!0):(u.warn(`Skipping ${e}`),!1)}return!0}function R(t){return m(d(t))}function I(t){return`^${R(t)}`}function b(t){const o=t.map(I);return o.push(".*@api"),new RegExp(`(${o.join("|")})/.*.(ts|js)$`)}async function H(){return{id:"ApiFunctions",requiredEntitlements:["apiFunctions"],async processContent(t,o){await A("com.redocly.build.plugin.apiFunctions",async r=>{const e=await o.getConfig();r?.setAttribute("config",JSON.stringify(e.apiFunctions||{}));const a=b(e.apiFunctions?.folders||[]),s=[];for(const n of o.fs.scan(a)){if(n.isVirtual)continue;const i=F(n.relativePath);i&&await E(n.relativePath,o)&&s.push({requestHandlerId:`${f}:${i.handler}`,fullPath:c(t.contentDir,i.handler),slug:i.path,httpMethod:i.method,fsPath:n.relativePath})}t.clearRequestHandlersByPrefix(`${f}:`);for(const n of s)t.createRequestHandler(n.requestHandlerId,n.fullPath),t.addApiRoute({requestHandlerId:n.requestHandlerId,slug:n.slug,fsPath:n.fsPath,httpMethod:n.httpMethod,[p]:{fsPath:n.fsPath,slug:n.slug}});r?.setAttribute("definedApiFunctions",String(s.length)),t.setGlobalConfig({[h]:s.length})})}}}export{f as API_FUNCTIONS_REQUEST_HANDLER_ID,H as apiFunctionsPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{simplifyAstStructure as h}from"@redocly/
|
|
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};
|