@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
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createCipheriv as o,createDecipheriv as f,createHash as u,hkdfSync as a,randomBytes as h,randomUUID as m}from"node:crypto";import{JWT_SECRET_KEY as c}from"../../../constants/common.js";const
|
|
1
|
+
import{createCipheriv as o,createDecipheriv as f,createHash as u,hkdfSync as a,randomBytes as h,randomUUID as m}from"node:crypto";import{JWT_SECRET_KEY as c}from"../../../constants/common.js";import{secretTtlSeconds as l}from"./subject.js";const p=900*1e3,d="mcp-upstream-secrets",y="mcp-elicitation",S="mcp-elicitation";class g{async setSecret(t,e,r,n){const i={api:r,...this.#c(this.#a(e),n,r)};await t.set(this.#n(e,r),i,{ttlInSeconds:l(e)})}async getSecretsForSubject(t,e){const r=this.#a(e),{items:n}=await t.list({prefix:this.#i(e)}),i={};for(const s of n)if(s.value)try{i[s.value.api]=this.#r(r,s.value,s.value.api)}catch{continue}return i}async deleteSubject(t,e){const{items:r}=await t.list({prefix:this.#i(e)}),n=r.flatMap(i=>i.value?[this.#n(e,i.value.api)]:[]);n.length!==0&&await t.transaction(async i=>{for(const s of n)await i.delete(s)})}async createElicitation(t,e){const r=m();return await t.set(this.#t(r),this.#c(this.#e(),e),{ttlInSeconds:p/1e3}),r}async peekElicitation(t,e){const r=await t.get(this.#t(e));if(r)try{return this.#r(this.#e(),r)}catch{return}}async consumeElicitation(t,e){const r=this.#t(e),n=await t.transaction(async i=>{const s=await i.get(r);return s&&await i.delete(r),s});if(n)try{return this.#r(this.#e(),n)}catch{return}}#i(t){return["mcp","secret",this.#s(t)]}#n(t,e){return["mcp","secret",this.#s(t),e]}#t(t){return["mcp","elicitation",t]}#s(t){return u("sha256").update(t).digest("hex")}#a(t){return Buffer.from(a("sha256",c,t,d,32))}#e(){return Buffer.from(a("sha256",c,S,y,32))}#c(t,e,r){const n=h(12),i=o("aes-256-gcm",t,n);r&&i.setAAD(Buffer.from(r,"utf8"));const s=Buffer.concat([i.update(JSON.stringify(e),"utf8"),i.final()]);return{iv:n.toString("base64"),tag:i.getAuthTag().toString("base64"),data:s.toString("base64")}}#r(t,e,r){const n=f("aes-256-gcm",t,Buffer.from(e.iv,"base64"));r&&n.setAAD(Buffer.from(r,"utf8")),n.setAuthTag(Buffer.from(e.tag,"base64"));const i=Buffer.concat([n.update(Buffer.from(e.data,"base64")),n.final()]).toString("utf8");return JSON.parse(i)}}const E=new g;export{p as ELICITATION_TTL_MS,g as SecretStore,E as secretStore};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ApiFunctionsUser } from '@redocly/config';
|
|
2
|
+
export declare const ANONYMOUS_SUBJECT_PREFIX = "anon:";
|
|
3
|
+
export declare const USER_SUBJECT_PREFIX = "user:";
|
|
4
|
+
export declare const MISSING_SESSION_HANDLE_MESSAGE = "This API requires credentials and the caller is anonymous; call createAnonymousSession first, then retry with sessionHandle";
|
|
5
|
+
export declare const MALFORMED_SESSION_HANDLE_MESSAGE = "The sessionHandle is not a valid handle; call createAnonymousSession to obtain one";
|
|
6
|
+
export type SubjectResolution = {
|
|
7
|
+
kind: 'resolved';
|
|
8
|
+
subject: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'anonymous';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'invalid';
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function createSessionHandle(): string;
|
|
16
|
+
export declare function isValidSessionHandle(value: string): boolean;
|
|
17
|
+
export declare function userSubject(user: ApiFunctionsUser | undefined): string | undefined;
|
|
18
|
+
export declare function resolveSecretSubject(user: ApiFunctionsUser | undefined, sessionHandle: string | undefined): SubjectResolution;
|
|
19
|
+
export declare function secretTtlSeconds(subject: string): number;
|
|
20
|
+
//# sourceMappingURL=subject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{randomBytes as r}from"node:crypto";const i=32,S=/^[A-Za-z0-9_-]{43}$/,c=1440*60,u=720*60*60,s="anon:",d="user:",f="This API requires credentials and the caller is anonymous; call createAnonymousSession first, then retry with sessionHandle",a="The sessionHandle is not a valid handle; call createAnonymousSession to obtain one";function N(){return r(i).toString("base64url")}function E(e){return S.test(e)}function l(e){if(!e?.isAuthenticated)return;const n=e.claims,o=(typeof n?.sub=="string"&&n.sub?n.sub:void 0)??(e.email||void 0);if(o)return`${d}${e.idpId??"local"}:${o}`}function A(e,n){const t=l(e);return t?{kind:"resolved",subject:t}:n===void 0?{kind:"anonymous"}:E(n)?{kind:"resolved",subject:`${s}${n}`}:{kind:"invalid",message:a}}function T(e){return e.startsWith(s)?c:u}export{s as ANONYMOUS_SUBJECT_PREFIX,a as MALFORMED_SESSION_HANDLE_MESSAGE,f as MISSING_SESSION_HANDLE_MESSAGE,d as USER_SUBJECT_PREFIX,N as createSessionHandle,E as isValidSessionHandle,A as resolveSecretSubject,T as secretTtlSeconds,l as userSubject};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{secretStore as l}from"../gateway-mcp/secret-store.js";import{buildAllowedHostMatchers as
|
|
1
|
+
import{secretStore as l}from"../gateway-mcp/secret-store.js";import{buildAllowedHostMatchers as C}from"../gateway-mcp/fetch/allowed-hosts.js";import{assertUrlAllowed as P}from"../gateway-mcp/fetch/ssrf-guard.js";import{readCappedBody as I,getDefaultAgent as _}from"../gateway-mcp/fetch/fetch-bridge.js";const m={"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store","X-Frame-Options":"DENY","Referrer-Policy":"no-referrer","Content-Security-Policy":"default-src 'none'; style-src 'unsafe-inline'; form-action 'self'"},E=3e4,T=64*1024;let v=fetch;function L(e){v=e}const z=async(e,t)=>{const o=await t.getKv();if(e.method==="GET"){const n=new URL(e.url).searchParams.get("token")??"",r=await l.peekElicitation(o,n);return r?new Response(q(r,n),{status:200,headers:m}):u()}if(e.method==="POST"){const n=await e.formData(),r=String(n.get("token")??"");return String(n.get("mode")??"token")==="client-credentials"?F(o,n,r):R(o,n,r)}return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, POST"}})};async function R(e,t,o){const n=String(t.get("secret")??"");if(!n)return u();const r=await l.consumeElicitation(e,o);return r?(await l.setSecret(e,r.subject,r.api,O(r.auth,n)),new Response(x(r.name),{status:200,headers:m})):u()}async function F(e,t,o){const n=String(t.get("client_id")??"").trim(),r=String(t.get("client_secret")??"").trim();if(!n||!r)return u();const b=await l.peekElicitation(e,o);if(!b||b.auth.kind!=="oauth2ClientCredentials")return u();const a=await l.consumeElicitation(e,o);if(!a||a.auth.kind!=="oauth2ClientCredentials")return u();const f=a.auth;try{const A=C([{url:f.tokenUrl}]),S=P(f.tokenUrl,A),w=new AbortController,$=setTimeout(()=>w.abort(),E);let y;try{y=await v(S,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"client_credentials",client_id:n,client_secret:r,...f.scopes.length>0?{scope:f.scopes.join(" ")}:{}}),redirect:"manual",signal:w.signal,dispatcher:_()})}finally{clearTimeout($)}if(!y.ok)return h(a.name);let k;try{k=await I(y,T)}catch{return h(a.name)}let p;try{p=JSON.parse(k)}catch{return h(a.name)}const g=typeof p=="object"&&p!==null&&"access_token"in p?p.access_token:void 0;return typeof g!="string"||!g?h(a.name):(await l.setSecret(e,a.subject,a.api,{header:"Authorization",value:`Bearer ${g}`}),new Response(x(a.name),{status:200,headers:m}))}catch{return h(a.name)}}function O(e,t){return e.kind==="apiKey"?{header:e.header,value:t}:e.kind==="bearer"||e.kind==="oauth2ClientCredentials"?{header:"Authorization",value:B(t)}:{header:"Authorization",value:t}}function B(e){const t=e.trim();return t.toLowerCase().startsWith("bearer")?t:`Bearer ${t}`}function i(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function s(e){return`<!doctype html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
@@ -34,9 +34,9 @@ footer{border-top-color:#1f2937;color:#6b7280}
|
|
|
34
34
|
</style>
|
|
35
35
|
</head>
|
|
36
36
|
<body><div class="card">${e}</div></body>
|
|
37
|
-
</html>`}function c(e){return`<h1>\u{1F512} ${i(e)}</h1>`}function d(){return"<footer>Secured by Redocly · credentials never enter the AI conversation</footer>"}function
|
|
37
|
+
</html>`}function c(e){return`<h1>\u{1F512} ${i(e)}</h1>`}function d(){return"<footer>Secured by Redocly · credentials never enter the AI conversation</footer>"}function q(e,t){switch(e.auth.kind){case"bearer":return H(e.name,t);case"apiKey":return N(e.name,t,e.auth.header);case"oauth2ClientCredentials":return U(e.name,t,e.auth.scopes);default:return j(e.name,t)}}function H(e,t){return s(`
|
|
38
38
|
${c(`Credentials for ${e}`)}
|
|
39
|
-
<p class="hint">Stored encrypted for
|
|
39
|
+
<p class="hint">Stored encrypted for you only (24 hours for anonymous callers, 30 days when signed in) and sent to the API as the <code>Authorization</code> header. It never passes through the AI conversation.</p>
|
|
40
40
|
<form method="post" action="/mcp/credentials" autocomplete="off">
|
|
41
41
|
<input type="hidden" name="token" value="${i(t)}">
|
|
42
42
|
<input type="hidden" name="mode" value="token">
|
|
@@ -45,9 +45,9 @@ ${c(`Credentials for ${e}`)}
|
|
|
45
45
|
<p class="hint">Paste the raw token or one already prefixed with <code>Bearer</code> — we add the prefix automatically if it is missing.</p>
|
|
46
46
|
<button type="submit">Save credentials</button>
|
|
47
47
|
</form>
|
|
48
|
-
${d()}`)}function
|
|
48
|
+
${d()}`)}function N(e,t,o){return s(`
|
|
49
49
|
${c(`Credentials for ${e}`)}
|
|
50
|
-
<p class="hint">Stored encrypted for
|
|
50
|
+
<p class="hint">Stored encrypted for you only (24 hours for anonymous callers, 30 days when signed in) and sent to the API as the <code>${i(o)}</code> header. It never passes through the AI conversation.</p>
|
|
51
51
|
<form method="post" action="/mcp/credentials" autocomplete="off">
|
|
52
52
|
<input type="hidden" name="token" value="${i(t)}">
|
|
53
53
|
<input type="hidden" name="mode" value="token">
|
|
@@ -55,7 +55,7 @@ ${c(`Credentials for ${e}`)}
|
|
|
55
55
|
<input type="password" id="secret" name="secret" placeholder="value" required autofocus>
|
|
56
56
|
<button type="submit">Save credentials</button>
|
|
57
57
|
</form>
|
|
58
|
-
${d()}`)}function
|
|
58
|
+
${d()}`)}function U(e,t,o){const n=o.length>0?o.map(i).join(", "):"default scopes";return s(`
|
|
59
59
|
${c(`Credentials for ${e}`)}
|
|
60
60
|
<p class="hint">Paste a token you already have, or let us exchange client credentials for one via OAuth2 client_credentials.</p>
|
|
61
61
|
<div class="section">
|
|
@@ -82,9 +82,9 @@ ${c(`Credentials for ${e}`)}
|
|
|
82
82
|
<button type="submit">Exchange & save</button>
|
|
83
83
|
</form>
|
|
84
84
|
</div>
|
|
85
|
-
${d()}`)}function
|
|
85
|
+
${d()}`)}function j(e,t){return s(`
|
|
86
86
|
${c(`Credentials for ${e}`)}
|
|
87
|
-
<p class="hint">The value is stored encrypted for
|
|
87
|
+
<p class="hint">The value is stored encrypted for you only (24 hours for anonymous callers, 30 days when signed in) and is sent to the API as the <code>Authorization</code> header. It never passes through the AI conversation.</p>
|
|
88
88
|
<form method="post" action="/mcp/credentials" autocomplete="off">
|
|
89
89
|
<input type="hidden" name="token" value="${i(t)}">
|
|
90
90
|
<input type="hidden" name="mode" value="token">
|
|
@@ -98,4 +98,4 @@ ${c("Credentials saved")}
|
|
|
98
98
|
${d()}`)}function h(e){return new Response(s(`
|
|
99
99
|
${c("Exchange failed")}
|
|
100
100
|
<p>We could not exchange your client credentials for a token for ${i(e)}. This link has been used up - go back to your AI client and request a new link, then try again.</p>
|
|
101
|
-
${d()}`),{status:502,headers:m})}function u(){return new Response(s(`${c("Link expired")}<p>This credentials link is invalid or has expired. Retry the request in your AI client to get a fresh link.</p>${d()}`),{status:404,headers:m})}var W=z;export{W as default,
|
|
101
|
+
${d()}`),{status:502,headers:m})}function u(){return new Response(s(`${c("Link expired")}<p>This credentials link is invalid or has expired. Retry the request in your AI client to get a fresh link.</p>${d()}`),{status:404,headers:m})}var W=z;export{W as default,L as setCredentialsFetchImpl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileURLToPath as w}from"node:url";import{dirname as q,join as p}from"node:path";import{logger as f}from"../../tools/notifiers/logger.js";import{reporter as G}from"../../tools/notifiers/reporter.js";import{isDefined as N}from"../../../utils/guards/is-defined.js";import{
|
|
1
|
+
import{fileURLToPath as w}from"node:url";import{dirname as q,join as p}from"node:path";import{logger as f}from"../../tools/notifiers/logger.js";import{reporter as G}from"../../tools/notifiers/reporter.js";import{isDefined as N}from"../../../utils/guards/is-defined.js";import{bundledOpenApiDocumentsToMcpOpenApi as H,bundledGraphqlDocumentsToMcpOpenApi as I,buildGraphqlDescriptions as U,filterIgnoredApiDescriptions as M,getCleanedUpApiDescriptions as j,isMcpInRedirects as x}from"./utils.js";import{getMcpMode as F,isMcpElicitationEnabled as B}from"./utils/mode.js";import{getDefaultToolSchemas as V}from"./docs-mcp/tool-schemas.js";import{EXECUTE_TOOL_SCHEMA as J}from"./codemode/tools/execute-schema.js";import{isGatewayCapabilityEnabled as W,isGatewayEligible as X}from"./gateway-mcp/eligibility.js";import{resolveGatewayFetchLimits as k}from"./gateway-mcp/rate-limit/limits.js";import{telemetryTraceStep as z}from"../../../cli/telemetry/helpers/trace-step.js";import{DEFAULT_DOCS_MCP_SERVER_NAME as C,MCP_NOT_ALLOWED_TEMPLATE_ID as K}from"./constants.js";const P="mcp-docs-server-handler",Q="/mcp",_="mcp-credentials-handler",Y="/mcp/credentials",d=q(w(import.meta.url));async function Z(){let i=!1;return{id:"mcp",async processContent(t,r){i||await z("com.redocly.build.plugin.mcp",async c=>{const s=H(await t.loadApiDocuments(r)),l=I(await t.loadApiDocuments(r)),n=await r.getConfig(),{mcp:o,redirects:a}=n;if(c?.setAttribute("config",JSON.stringify(o||{})),!(o?.hide||o?.docs?.hide)&&(x(a)&&await G.panicOnBuildContentError('The reserved route "/mcp" cannot be used in redirect configuration. Please remove any redirects involving "/mcp" from your redocly.yaml config.'),t.createTemplate(K,"@redocly/theme/layouts/McpNotAllowed"),!o?.docs?.hide)){f.info("Configuring MCP servers...");const m=p(d,"./handlers/docs-mcp-handler.js"),y=j(M(s,o?.docs?.ignore||[])),v=!!n?.access?.requiresLogin,u=n?.access?.rbac||{},A=W(o),g=new Map;for(const e of y){const O=e.definition.info?.title||"",L=e.definition.info?.version||"";g.set(e.relativePath,{name:O,description:typeof e.definition.info?.description=="string"?e.definition.info.description:"",version:L,servers:e.definition.servers||[],relativePath:e.relativePath,...A&&X(e.definition.info,e.relativePath,u)?{fetchEligible:!0}:{}})}const h=U(M(l,o?.docs?.ignore||[])),b=Object.values(n.products||{}).map(e=>e?.name).filter(N),R=n.l10n?.locales?.map(e=>e.code)??r.fs.localeFolders,D=F(),E=B(),{budgetPerExec:S}=k(),T=V({products:b,locales:R,requiresLogin:v,rbac:u,hasGraphqlApis:h.length>0,elicitationEnabled:E});t.addMcpTools(p(d,"./docs-mcp/tools/index.js"),T),D==="code"&&t.addMcpTools(p(d,"./codemode/tools/execute.js"),[J]),await $({actions:t,handlerPath:m,apiDescriptionsMap:Object.fromEntries(g),graphqlDescriptions:h,mcpConfig:o,mcpMode:D,elicitationEnabled:E,gatewayFetchBudgetPerExec:S}),i=!0}})},async afterRoutesCreated(t,r){const c=await r.getConfig(),{mcp:s}=c;t.setGlobalData({mcpData:{docs:{enabled:!s?.hide&&!s?.docs?.hide,name:s?.docs?.name||C}}})}}}var fe=Z;async function $({actions:i,handlerPath:t,apiDescriptionsMap:r,graphqlDescriptions:c,mcpConfig:s,mcpMode:l,elicitationEnabled:n,gatewayFetchBudgetPerExec:o}){if(i.createRequestHandler(P,t),i.addApiRoute({slug:Q,requestHandlerId:P,httpMethod:"all",getStaticData:async()=>({props:{config:{apiDescriptionsMap:r,graphqlDescriptions:c,mcpDocsServerName:s?.docs?.name||C,mcpMode:l,elicitationEnabled:n,gatewayFetchBudgetPerExec:o},serverOutDir:i.serverOutDir,tools:i.getMcpTools().map(({importPath:a,...m})=>m)}})}),f.info("Registered Docs MCP Server endpoint at /mcp"),n){const a=p(d,"./handlers/mcp-credentials-handler.js");i.createRequestHandler(_,a),i.addApiRoute({slug:Y,requestHandlerId:_,httpMethod:"all",getStaticData:async()=>({props:{}})}),f.info("Registered MCP credentials endpoint at /mcp/credentials")}}export{_ as MCP_CREDENTIALS_HANDLER_ID,P as MCP_DOCS_SERVER_HANDLER_ID,fe as default,Z as mcpServerPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logger as
|
|
1
|
+
import{logger as C}from"../../../tools/notifiers/logger.js";import{mcpToolWorkers as S,MCP_TOOL_IS_AVAILABLE_KEY as b}from"../../../workers/mcp-tool-worker-pool.js";import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as A}from"../constants.js";import{isAnonymousSessionToolAvailable as f}from"../docs-mcp/tools/core/create-anonymous-session.js";import{EXECUTE_TOOL_SCHEMA as M}from"../codemode/tools/execute-schema.js";import{EXECUTE_TOOL_NAME as O,DESCRIBE_TOOLS_TOOL_NAME as h,CODE_MODE_TOOL_NAMES as L,FETCH_TOOL_NAME as v}from"../codemode/constants.js";import{buildCodeModeInstructions as g,buildExecuteDescription as y,DESCRIBE_TOOLS_DESCRIPTION as D}from"../codemode/prompts.js";import{composeExecuteAnnotations as x,getActiveCapabilities as I}from"../codemode/capabilities/index.js";import{describeToolsSchema as N,describeTools as k}from"../codemode/tools/describe-tools.js";import{connectMcpServer as w,createMcpServer as R,createToolDispatch as F,extractSerializableContext as H}from"./mcp-server.js";function P(a){const t=M.schema;if(f(a))return t;const{sessionHandle:i,...c}=t.properties;return{...t,properties:c}}async function q({name:a,tools:t,context:i,sessionHooks:c,skills:T=[],getKv:_}){const m=i.mcpMode==="code",s=m?I(i):[],p=s.some(e=>e.id===v),{server:r,transport:u}=R(a,m?g(p):void 0,c),E=H(i),l=F(E,{getClientCapabilities:()=>r.server.getClientCapabilities(),getKv:_}),d=async e=>{try{return await S.exec(b,[{toolName:e,context:E}],{timeout:1e4})}catch(o){return C.error(`Failed to check MCP tool availability for "${e}": ${o instanceof Error?o.message:String(o)}`),!1}};if(m){const e=t.filter(n=>!L.has(n.name));r.tool(O,y(p),P(i),x(s),l(O)),r.tool(h,D,N(e,s),k(e,d,s,i));const o=t.find(n=>n.name===A);o&&f(i)&&r.tool(o.name,o.description,o.schema,o.annotations??{title:o.name},l(o.name))}else await Promise.all(t.map(async e=>{const o=e.annotations||{title:e.name},n=r.tool(e.name,e.description,e.schema,o,l(e.name));await d(e.name)||n.disable()}));for(const e of T)r.registerResource(e.slug,e.uri,{title:e.name,description:e.description,mimeType:"text/markdown"},async()=>({contents:[{uri:e.uri,mimeType:"text/markdown",text:e.content}]}));return w(r,u)}export{q as createDocsMcpServer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomUUID as w}from"node:crypto";import{McpServer as
|
|
1
|
+
import{randomUUID as w}from"node:crypto";import{McpServer as v}from"@redocly/mcp-typescript-sdk/server/mcp.js";import{StreamableHTTPServerTransport as M}from"@redocly/mcp-typescript-sdk/server/streamableHttp.js";import{logger as f}from"../../../tools/notifiers/logger.js";import{mcpToolWorkers as y,MCP_TOOL_WORKER_KEY as b}from"../../../workers/mcp-tool-worker-pool.js";import{secretStore as q}from"../gateway-mcp/secret-store.js";import{readAuthRequiredMeta as T,stripAuthRequiredMeta as S}from"../gateway-mcp/upstream-auth.js";import{runUpstreamCredentialElicitation as U}from"../gateway-mcp/elicitation.js";import{resolveUpstreamAuthScheme as _}from"../gateway-mcp/upstream-auth-scheme.js";import{MISSING_SESSION_HANDLE_MESSAGE as D,resolveSecretSubject as O}from"../gateway-mcp/subject.js";const k=6e4,d=new Map;function A(e,t){const r=d.get(e);if(r)return r;const i=t().finally(()=>{d.delete(e)});return d.set(e,i),i}function H(e,t,r){const i=new v({name:e,version:new Date().toISOString().slice(0,10)},{capabilities:{logging:{}},...t?{instructions:t}:{}}),c=new M(r?{sessionIdGenerator:()=>w(),onsessioninitialized:r.onInitialized,onsessionclosed:r.onClosed}:{sessionIdGenerator:void 0});return{server:i,transport:c}}async function Y(e,t){return await e.connect(t),{server:e,transport:t,cleanup:async()=>{t.close()}}}function C(e,t){return r=>async(i,c)=>{f.info(`MCP tool called: ${r}`);const u=e.elicitationEnabled?O(e.user,i.sessionHandle):{kind:"anonymous"},o=u.kind==="resolved"?u.subject:void 0;if(u.kind==="invalid")return{content:[{type:"text",text:u.message}],isError:!0};const g=async()=>{if(!(!e.elicitationEnabled||!o||!t?.getKv))try{const a=await t.getKv();return await q.getSecretsForSubject(a,o)}catch(a){f.warn(`gateway mcp secret store error, continuing unauthenticated: ${String(a)}`);return}},m=async()=>{const a=await g(),p={toolName:r,args:i,context:{...e,upstreamSecrets:a},extra:K(c)};return await y.exec(b,[p],{timeout:k})};let n=await m();const s=T(n);if(s.length>0&&e.elicitationEnabled&&!o)return S({...n,content:[{type:"text",text:D}],isError:!0});if(s.length>0&&e.elicitationEnabled&&o&&t?.getKv){const a=await t.getKv(),p=await _(e,s[0].api),l=await A(`${o}:${s[0].api}`,()=>U({sendRequest:(E,I,h)=>c.sendRequest(E,I,h),clientSupportsElicitation:!!t?.getClientCapabilities()?.elicitation,subject:o,baseUrl:e.baseUrl??"",events:s,auth:p,kv:a}));l.status==="accepted"?n=await m():l.status==="fallback"&&(n={...n,content:[...n.content,{type:"text",text:l.text}]})}return S(n)}}function K(e){return{sessionId:e.sessionId,authInfo:e.authInfo,requestId:e.requestId,requestInfo:e.requestInfo,_meta:e._meta}}function J(e){return{user:e.user,config:e.config,outdir:e.outdir,baseUrl:e.baseUrl,params:e.params,query:e.query,cookies:e.cookies,apiDescriptionsMap:e.apiDescriptionsMap,graphqlDescriptions:e.graphqlDescriptions,products:e.products,accessToken:e.accessToken,metadata:e.metadata,upstreamAuthorization:e.upstreamAuthorization,mcpMode:e.mcpMode,elicitationEnabled:e.elicitationEnabled,gatewayFetchBudgetPerExec:e.gatewayFetchBudgetPerExec,clientIp:e.clientIp,upstreamSecrets:e.upstreamSecrets}}export{Y as connectMcpServer,H as createMcpServer,C as createToolDispatch,J as extractSerializableContext};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { OpenAPIOperation, OpenAPIPath } from '@redocly/openapi-docs/src/types';
|
|
2
1
|
import type { ApiFunctionsContext, ApiFunctionsContextMethods, PageStaticData } from '@redocly/config';
|
|
3
2
|
import type { CallToolResult, RequestId, RequestInfo, RequestMeta } from '@redocly/mcp-typescript-sdk/types.js';
|
|
4
3
|
import type { AuthInfo } from '@redocly/mcp-typescript-sdk/server/types.js';
|
|
5
|
-
import type { OpenAPIServer } from '@redocly/
|
|
4
|
+
import type { OpenAPIPath, OpenAPIServer, OpenAPIOperation } from '@redocly/api-docs';
|
|
6
5
|
import type { McpErrorCodes, McpServerType } from './constants';
|
|
7
6
|
import type { McpToolSchema } from '../../types';
|
|
8
7
|
import type { Skill } from '../../types/plugins/skills.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OpenAPIDefinition } from '@redocly/
|
|
1
|
+
import type { OpenAPIDefinition } from '@redocly/api-docs';
|
|
2
2
|
import type { XMcpConfig, XMcpSection } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Returns false when the endpoint is hidden for `section`; otherwise strips x-mcp from the
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
import type { DocumentNode } from 'graphql';
|
|
1
2
|
import type { ApiFunctionsUser, RbacConfig, RedirectConfig } from '@redocly/config';
|
|
2
|
-
import type { ProcessContentActions } from '../../types';
|
|
3
|
-
import type { BundledDefinition as GraphqlBundledDefinition } from '../../plugins/graphql-docs/graphql-doc-loader';
|
|
4
3
|
import type { ApiDescriptionInfo, GraphqlDescriptionInfo } from './types.js';
|
|
5
|
-
|
|
4
|
+
import type { OpenAPIDefinition } from '@redocly/api-docs';
|
|
5
|
+
import type { BundledApiDefinition } from '../api-docs/loader.js';
|
|
6
|
+
/** OpenAPI specs only; MCP lists paths/servers from OpenAPI documents. */
|
|
7
|
+
export type McpOpenApiSpec = {
|
|
8
|
+
relativePath: string;
|
|
9
|
+
definition: OpenAPIDefinition;
|
|
10
|
+
};
|
|
11
|
+
export type McpGraphqlSpec = {
|
|
12
|
+
relativePath: string;
|
|
13
|
+
definition: DocumentNode;
|
|
14
|
+
options: BundledApiDefinition['options'];
|
|
15
|
+
};
|
|
16
|
+
export declare function bundledOpenApiDocumentsToMcpOpenApi(bundled: BundledApiDefinition[]): McpOpenApiSpec[];
|
|
17
|
+
export declare function bundledGraphqlDocumentsToMcpOpenApi(bundled: BundledApiDefinition[]): McpGraphqlSpec[];
|
|
6
18
|
/**
|
|
7
19
|
* Filters out localizations and definitions with no public paths.
|
|
8
20
|
*
|
|
@@ -19,7 +31,7 @@ export type ApiDescriptions = Awaited<ReturnType<ProcessContentActions['loadOpen
|
|
|
19
31
|
* { relativePath: 'api.yaml', definition: { paths: { '/users': {} } } }
|
|
20
32
|
* ]); // Returns only the api.yaml definition
|
|
21
33
|
*/
|
|
22
|
-
export declare function getCleanedUpApiDescriptions(apiDescriptions:
|
|
34
|
+
export declare function getCleanedUpApiDescriptions(apiDescriptions: McpOpenApiSpec[]): McpOpenApiSpec[];
|
|
23
35
|
/**
|
|
24
36
|
* Filters OpenAPI definitions based on user RBAC permissions.
|
|
25
37
|
*
|
|
@@ -39,7 +51,7 @@ export declare function getCleanedUpApiDescriptions(apiDescriptions: ApiDescript
|
|
|
39
51
|
*/
|
|
40
52
|
export declare function filterApiDescriptionsByRbac(apiDescriptions: Record<string, ApiDescriptionInfo>, user: ApiFunctionsUser, rbac: RbacConfig, requiresLogin: boolean): Record<string, ApiDescriptionInfo>;
|
|
41
53
|
export declare function filterGraphqlDescriptionsByRbac(graphqlDescriptions: GraphqlDescriptionInfo[], user: ApiFunctionsUser, rbac: RbacConfig, requiresLogin: boolean): GraphqlDescriptionInfo[];
|
|
42
|
-
export declare function buildGraphqlDescriptions(definitions:
|
|
54
|
+
export declare function buildGraphqlDescriptions(definitions: McpGraphqlSpec[]): GraphqlDescriptionInfo[];
|
|
43
55
|
export declare function filterIgnoredApiDescriptions<T extends {
|
|
44
56
|
relativePath: string;
|
|
45
57
|
}>(apiDescriptions: T[], ignoredPaths: string[]): T[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import a,{join as f}from"node:path";import u from"picomatch";import{PUBLIC_API_DEFINITIONS_FOLDER as l,L10N_DIR_NAME as o,I18N_DIR_NAME as p}from"../../constants/common.js";import{RESERVED_ROUTES as h}from"../../plugins/get-reserved-routes.js";import{canDownloadApiDefinition as m}from"../../utils/rbac.js";function x(e){return e.filter(t=>t.type==="openapi").map(t=>({relativePath:t.relativePath,definition:t.document}))}function g(e){return e.filter(t=>t.type==="graphql").map(t=>({relativePath:t.relativePath,definition:t.document,options:t.options}))}function s(e){if(typeof e!="object"||e===null)return e;if(Array.isArray(e))return e.map(s);const t={};for(const i in e)if(Object.hasOwn(e,i)){if(i.toString().startsWith("x-parsed-"))continue;t[i]=s(e[i])}return t}function P(e){return e.reduce((t,i)=>(i.relativePath.startsWith(o)||i.relativePath.startsWith(p)||!i.definition||typeof i.definition!="object"||!("paths"in i.definition)||i.definition?.paths&&Object.keys(i.definition.paths).length>0&&t.push({...i,definition:s(i.definition)}),t),[])}function R(e,t,i,r){const n={};for(const[d,c]of Object.entries(e))m(f(l,c.relativePath),i,r,t)&&(n[d]=c);return n}function E(e,t,i,r){return e.filter(n=>m(f(l,n.relativePath),i,r,t))}function _(e){return e.filter(({relativePath:t})=>!t.startsWith(o)&&!t.startsWith(p)).map(({relativePath:t,options:i})=>({name:i.info?.title||a.basename(t,a.extname(t)),description:i.info?.description,relativePath:t}))}function W(e,t){return e.filter(({relativePath:i})=>!u(t||[])(i))}function b(e={}){for(const[t,i]of Object.entries(e))if(t===h.mcp||(typeof i=="string"?i:i.to)===h.mcp)return!0;return!1}function M(e,t,i){return e.startsWith(o)||e.startsWith(p)||!t?.paths||Object.keys(t.paths).length===0?!1:!u(i?.docs?.ignore||[])(e)}export{_ as buildGraphqlDescriptions,g as bundledGraphqlDocumentsToMcpOpenApi,x as bundledOpenApiDocumentsToMcpOpenApi,R as filterApiDescriptionsByRbac,E as filterGraphqlDescriptionsByRbac,W as filterIgnoredApiDescriptions,P as getCleanedUpApiDescriptions,M as isApiIncludedInDocsMcp,b as isMcpInRedirects};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{simplifyAstStructure as Z}from"@redocly/openapi-docs";import{REDOCLY_ROUTE_RBAC as y,REDOCLY_TEAMS_RBAC as D}from"@redocly/config";import{OPENAPI_DOCS_TEMPLATE_ID as j,PUBLIC_RBAC_SCOPE_ITEM as U}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as ee,PUBLIC_API_DEFINITIONS_FOLDER as te}from"../../constants/common.js";import{OPENAPI_SHARED_DATA_PREFIX as L}from"../../constants/plugins/openapi-docs.js";import{envConfig as V}from"../../config/env-config.js";import{isRbacScopeItems as oe}from"../../utils/rbac/is-rbac-scope-items.js";import{getRouteSlugsForPath as ae}from"../utils.js";import{searchResolver as re}from"./search/search-resolver.js";import{convertOpenAPIDocs2Sidebar as
|
|
1
|
+
import{simplifyAstStructure as Z}from"@redocly/openapi-docs";import{REDOCLY_ROUTE_RBAC as y,REDOCLY_TEAMS_RBAC as D}from"@redocly/config";import{OPENAPI_DOCS_TEMPLATE_ID as j,PUBLIC_RBAC_SCOPE_ITEM as U}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as ee,PUBLIC_API_DEFINITIONS_FOLDER as te}from"../../constants/common.js";import{OPENAPI_SHARED_DATA_PREFIX as L}from"../../constants/plugins/openapi-docs.js";import{envConfig as V}from"../../config/env-config.js";import{isRbacScopeItems as oe}from"../../utils/rbac/is-rbac-scope-items.js";import{getRouteSlugsForPath as ae}from"../utils.js";import{searchResolver as re}from"./search/search-resolver.js";import{convertOpenAPIDocs2Sidebar as se,shouldAddRoute as ie}from"./utils.js";import{getTemplatePath as q}from"./get-template-path.js";import{storeDefinitionBundles as ne}from"./store-definition-bundles.js";import{definitionLoader as ce,definitionsLoader as pe}from"./load-definition.js";import{getAiDocumentsStore as de}from"./search/get-ai-search-documents.js";import{fromCurrentDir as le}from"../../utils/paths.js";import{telemetryTraceStep as fe}from"../../../cli/telemetry/helpers/trace-step.js";import{getApiConfigByPath as ue}from"../get-api-config.js";import{shouldAdvertiseGatewayXMcp as me,buildGatewayXMcp as ge}from"../mcp/gateway-mcp/eligibility.js";const x="openapi-spec-download";async function Be(){let k=[],C={},N=new Set,d={};return{id:"openapi",requiredEntitlements:["openapi"],loaders:{"load-oas-docs":pe,"load-oas":ce},processContent:async(e,n)=>{await fe("com.redocly.build.plugin.openapiDocs",async l=>{e.createRequestHandler(x,le(import.meta.url,"./spec-download.api.js")),e.addApiRoute({slug:te+"/*",requestHandlerId:x,httpMethod:"all",[D]:U,getStaticData:async()=>({props:{}})}),e.addApiRoute({slug:ee+"/*",requestHandlerId:x,httpMethod:"all",[D]:U,getStaticData:async()=>({props:{}})});const E=e.createTemplate(j,q("../../../client/templates/openapi-docs/template.js")),f=e.registerServerPropsGetter(j,q("./get-server-props.js")),u=await n.getConfig();l?.setAttribute("config",JSON.stringify(u.openapi||{})),C={},d={};const c=(await n.cache.load(".","load-oas-docs")).data;k=c.map(({markdocChunks:a,relativePath:o,customOutputRelativeFile:r,isVirtual:s,realRelativePath:m})=>({chunks:a,relativePath:o,realRelativePath:m,isVirtual:r!=null||s})),ne(c,e.outdir);for(const a of c||[]){const{definition:o,config:r,relativePath:s,customOutputRelativeFile:m,contentItems:_,flatItems:g,parser:h,options:I,rawOptions:v,hash:R}=a,S=m||s,i=[],G={},{definition:X}=h||{},{info:p}=X||{},O=p?.["x-metadata"],w=!!r.openapi?.excludeFromSearch||!!r.theme?.openapi?.excludeFromSearch||!!u.openapi?.excludeFromSearch||!!u.theme?.openapi?.excludeFromSearch,H={title:p?.title,description:p?.description,summary:p?.summary,...r.metadata,...O},P={untagged:[],tagged:new Map};for(const t of g){const{id:F,href:A,operationDefinition:T}=t;if(T){const{tags:b}=T;if(b)for(const B of b)P.tagged.has(B)||P.tagged.set(B,[]),P.tagged.get(B)?.push(t);else P.untagged.push(t);V.isDevelopMode&&(G[`#${T.pointer}`]=t.href)}if(!ie({item:t}))continue;const M=t,Q=M.type==="section"&&!!M.infoDefinition,W=A.split("#")[0]+"/",z=t?.operationDefinition?.[D],K=oe(r.access?.rbac)?r.access.rbac:void 0;i.push({excludeFromSearch:w,slugSuffix:W,fsPath:S,metadata:{subType:"openapi-operation"},httpVerb:t?.httpVerb||"",path:s,templateId:E,[D]:z||K,getAiDocumentsStore:de({parser:h,options:I,info:p,tagOperations:P,openapiContentItem:M,metadata:H,relativePath:s,getSearchFacets:e.getSearchFacets,includeInLLMsTxt:Q,excludeFromSearch:w}),getStaticData:async b=>({props:{dynamicMarkdocComponents:["openapi"],baseSlug:b.baseSlug,seo:t["x-metadata"]?.seo||{title:t.name,description:t.description},itemId:F,disableAutoScroll:!0}})})}if(i[0]={...i[0],metadata:{type:"openapi",...H},hasClientRoutes:!0,getSidebar:(t,F)=>{const A=[];return se({contentItems:_,sidebarItems:A,routeSlug:t.slug,navItem:F}),A},getNavText:()=>p?.title,getSearchDocuments:re(h,I,g,e.getSearchFacets,e.setSearchFacets,w)},O?.apiId&&!a.isVirtual){const t=ue(a.config.apis,a.realRelativePath);d[O.apiId]={[D]:t.rbac,[y]:{fsPath:S}}}const Y=i[0];i[0]=i[i.length-1],i[i.length-1]=Y;for(const t of i)e.addRoute({...t,serverPropsGetterIds:[f]});const J=V.isDevelopMode?s:void 0,$=`${L}${s}`;C[$]={fsPath:S,definition:o,options:v,sourcePath:J,routesMapping:G,hash:R};for(const t of i)e.addRoute({...t,sharedData:[{id:$,key:"openAPIDocsStore"}],serverPropsGetterIds:[f]})}})},afterRoutesCreated:async(e,n)=>{const l=new Set;for(const{chunks:a,relativePath:o,isVirtual:r,realRelativePath:s}of k){const m=ae(e.getAllRoutes(),o),_=(await n.cache.load(s,"load-oas")).compoundHash;await n.cache.load(o,{loader:async function(){for(const{node:h,markdown:I,key:v,relativePath:R}of a){const{ast:S}=await e.parseMarkdoc({input:{content:I,relativePath:R,isVirtual:r},context:n,deps:{sharedDataIds:[`${L}${R}`],routeSlugs:m}});h[`x-parsed-md-${v}`]={result:Z(S)}}},name:"openapi-markdoc-inline-parser"},[_]);for(const{pointer:g}of a)l.add(g)}const E=N.difference(l);for(const a of E)n.cache.delete(a);N=l;const f=e.getConfig(),u=f.access?.rbac??{},c=n.withPathPrefix("/mcp");for(const[a,o]of Object.entries(C)){const r=e.getRouteByFsPath(o.fsPath)?.baseSlug,s=r&&me(o.definition,a.slice(L.length),u,f.mcp)?{...o.definition,"x-mcp":{...ge(c),...o.definition["x-mcp"],servers:[{url:c}]}}:o.definition;await e.createSharedData(a,{...o,definition:s,baseSlug:r},o.hash)}Object.entries(d).forEach(([a,o])=>{const r=o[y]?.fsPath;if(!r)return;const s=e.getRouteByFsPath(r)?.baseSlug;d[a]={...o,[y]:{...o[y],slug:s},slug:s}}),e.setGlobalData({apiProducts:d})}}}export{Be as openAPIDocsPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import g from"node:path";import{REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import{slash as S}from"../../../utils/path/slash.js";import{canAccessFeature as
|
|
1
|
+
import g from"node:path";import{REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import{slash as S}from"../../../utils/path/slash.js";import{canAccessFeature as y}from"../../utils/entitlements/can-access-feature.js";import{staticDataLoader as b}from"./loaders/static-data-loader.js";import{findFrontmatterSlugs as F,getSidebarSharedDataId as P,resolveFrontmatterSlugs as w}from"../utils.js";import{reactFrontmatterLoader as v}from"./loaders/react-frontmatter-loader.js";import{registerPageProps as D}from"../register-page-props.js";import{telemetryTraceStep as R}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as E}from"./search/search-resolver.js";async function x(){return{loaders:{"react-frontmatter":v},id:"react-pages",requiredEntitlements:["reactPages"],processContent:async(r,a)=>{await R("com.redocly.build.plugin.pages",async()=>{const{fs:o,cache:f}=a;for(const n of o.scan(/\.page\.tsx?$/)){const{relativePath:e,realRelativePath:l}=n;if(await a.isPathIgnored(e))continue;const p=r.createTemplate(S(e),g.resolve(o.cwd,l));await D(n,o,r);const{data:t}=await f.load(e,"react-frontmatter"),u=await F(e,"react-frontmatter",t,a),s=w(u,e);let c=null;t?.sidebar&&(c=await P(t.sidebar,e,a.fs)),(s.length?s.reverse():[void 0]).forEach(i=>{r.addRoute({excludeFromSearch:t?.excludeFromSearch||!1,slug:i,templateId:p,fsPath:e,sharedData:c?[{id:c,key:"sidebar"}]:void 0,[h]:y("rbac")?t?.rbac:void 0,getNavText:async()=>t?.seo?.title,getStaticData:async(m,d)=>({props:await b({frontmatter:t,relativePath:e},a,d)}),getSearchDocuments:E(t,e,r.getSearchFacets,r.setSearchFacets)})});for(const[i,{to:m,type:d}]of Object.entries(t?.redirects||{}))r.addRedirect(i,{to:m||s[0],type:d||301})}})}}}export{x as customPagesPlugin};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import w from"node:path";import
|
|
2
|
-
- ${a.slice(0,
|
|
3
|
-
- `)}`;a.length>
|
|
4
|
-
... and ${a.length-
|
|
1
|
+
import w from"node:path";import S from"picomatch";import{removeLeadingSlash as O}from"@redocly/theme/core/utils";import{parsePathVersions as D}from"../../../utils/path/parse-path-versions.js";import{logger as c}from"../../tools/notifiers/logger.js";import{ScorecardStatus as d}from"./types.js";import{getTarget as M}from"./loaders/scorecard.js";const R=15;async function $({actions:t,context:i,scorecardConfig:e,reuniteConfig:o}){c.info("Computing scorecard...");const a=e.levels||[],n=a[0],u=await t.loadApiDocuments(i),r=B(u),h=e.ignore||[],v=S(h),m=new Set,f=c.startTiming(),p={},l={};for(const s of r){if(!L(s,v,m))continue;const g=s.customOutputRelativeFile||s.realRelativePath;m.add(g);const P=await N(s,i,e,a,n);p[s.realRelativePath]=P,l[P.relativePath]=P}return c.infoTime(f,"Scorecard processed"),T(p,o,e),l}function L(t,i,e){if(t.isVirtual||!t.definition)return!1;const o=t.customOutputRelativeFile||t.realRelativePath,a=O(t.realRelativePath);return i(a)?(c.info(`Skipping scorecard calculation for ignored file: ${t.realRelativePath}`),!1):!e.has(o)}function F(t,i,e){return t-1<i?d.BelowMinimum:i<e-1?d.Minimum:d.Highest}async function N(t,i,e,o,a){let n=a.name;if(e.targets?.length){const l=await i.getConfig(w.posix.dirname(t.realRelativePath)),s=t.definition.info?.["x-metadata"]||{},g={title:t.definition.info?.title,version:t.definition.info?.version,...s,...l.metadata};n=(await M(e.targets,g))?.minimumLevel||a.name}const{data:{levels:u,scorecardLevelIdx:r,scorecardLevel:h}}=await i.cache.load(t.realRelativePath,"scorecard"),v=o.findIndex(l=>l.name===n),m=F(r,v,o.length),f=t.customOutputRelativeFile||t.realRelativePath,p=D(f)?.versionName;return{levels:u,status:m,targetLevel:n,scorecardLevel:h,scorecardLevelIdx:r,relativePath:f,title:t.definition.info?.title,version:p}}function T(t,i,e){const o=Object.values(t).filter(r=>r.status===d.BelowMinimum);if(o.length===0)return;const a=o.map(r=>r.relativePath);let n=`Detected OpenAPI definitions with score below minimum level:
|
|
2
|
+
- ${a.slice(0,R).map(()=>"%rp").join(`
|
|
3
|
+
- `)}`;a.length>R&&(n+=`
|
|
4
|
+
... and ${a.length-R} more`),i?.ignoreLint??e.ignoreNonCompliant?c.warn(n,...a):c.error(n,...a)}function B(t){const i=[];for(const e of t){if(e.type!=="openapi")continue;const o=e.document;i.push({realRelativePath:e.realRelativePath,customOutputRelativeFile:e.customOutputRelativeFile,isVirtual:e.isVirtual,definition:{info:o.info}})}return i}export{$ as computeScorecard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFileSync as D}from"node:fs";import L from"path";import{SCORECARD_OUTPUT_FILE_NAME as w}from"../../constants/common.js";import{mapObject as E}from"../../../utils/object/map-object.js";import{envConfig as A}from"../../config/env-config.js";import{removeLeadingSlash as j}from"../../../utils/url/remove-leading-slash.js";import{combineUrls as O}from"@redocly/theme/core/utils";import{logger as _}from"../../tools/notifiers/logger.js";import{getRouteSlugToCatalogSlugMap as F}from"../../utils/catalog-classic/get-route-slug-to-catalog-slug-map.js";import{deepEqual as I}from"../../../utils/object/deep-equal.js";import{ensureDir as N}from"../../utils/index.js";import{getTemplatePath as q}from"./get-template-path.js";import{getAllRuleNames as U}from"./lint.js";import{getScorecardConfig as T}from"./get-scorecard-config.js";import{getScorecardSlug as k}from"./shared-utils.js";import{scorecardConfigLoader as M}from"./loaders/scorecard-config.js";import{scorecardLoader as W}from"./loaders/scorecard.js";import{computeScorecard as B}from"./compute-scorecard.js";import{telemetryTraceStep as J}from"../../../cli/telemetry/helpers/trace-step.js";const $="scorecardClassic";let u={},R={};async function ne({id:b,requiredEntitlements:P,loadersPrefix:v=""}){let p=null,y=null,h=!1;return{id:b??"scorecardClassic",requiredEntitlements:P??["scorecard"],loaders:{[`${v}scorecard-config`]:M,[`${v}scorecard`]:W},async processContent(r,l){await J("build.plugin.
|
|
1
|
+
import{writeFileSync as D}from"node:fs";import L from"path";import{SCORECARD_OUTPUT_FILE_NAME as w}from"../../constants/common.js";import{mapObject as E}from"../../../utils/object/map-object.js";import{envConfig as A}from"../../config/env-config.js";import{removeLeadingSlash as j}from"../../../utils/url/remove-leading-slash.js";import{combineUrls as O}from"@redocly/theme/core/utils";import{logger as _}from"../../tools/notifiers/logger.js";import{getRouteSlugToCatalogSlugMap as F}from"../../utils/catalog-classic/get-route-slug-to-catalog-slug-map.js";import{deepEqual as I}from"../../../utils/object/deep-equal.js";import{ensureDir as N}from"../../utils/index.js";import{getTemplatePath as q}from"./get-template-path.js";import{getAllRuleNames as U}from"./lint.js";import{getScorecardConfig as T}from"./get-scorecard-config.js";import{getScorecardSlug as k}from"./shared-utils.js";import{scorecardConfigLoader as M}from"./loaders/scorecard-config.js";import{scorecardLoader as W}from"./loaders/scorecard.js";import{computeScorecard as B}from"./compute-scorecard.js";import{telemetryTraceStep as J}from"../../../cli/telemetry/helpers/trace-step.js";const $="scorecardClassic";let u={},R={};async function ne({id:b,requiredEntitlements:P,loadersPrefix:v=""}){let p=null,y=null,h=!1;return{id:b??"scorecardClassic",requiredEntitlements:P??["scorecard"],loaders:{[`${v}scorecard-config`]:M,[`${v}scorecard`]:W},async processContent(r,l){await J("com.redocly.build.plugin.scorecardClassic",async S=>{const a=r.createTemplate($,q("./template/index.js")),g=await l.getConfig(),m=T(g),f=g?.reunite??{},i=[()=>p===null,()=>!I(u,m),()=>!I(R,f)].some(e=>e());u=m,S?.setAttribute("config",JSON.stringify(u||{})),R=f;const n=g.catalogClassic??{},c=u.levels||[];if(c.length<1)throw Error("Invalid configuration of levels config");i&&(p=await B({actions:r,context:l,scorecardConfig:u,reuniteConfig:R}));const{data:{configs:o}}=await l.cache.load("",`${v}scorecard-config`),{perLevel:d,all:s}=U(o);y={levelNames:c.map(e=>e.name),rules:s,rulesPerLevel:d};for(const[e,t]of Object.entries(n)){const C=O(t.slug,"scorecard/");r.addRoute({duplicateInAllLocales:!0,slug:C,fsPath:O(t.slug,"scorecard/"),templateId:a,hasClientRoutes:!0,excludeFromSidebar:!0,serverPropsGetterIds:[],sharedData:[{id:"scorecard",key:"scorecard"},{key:"catalog",id:"catalog-"+e}],getNavText:()=>Promise.resolve(t.title||"API design scorecard"),getStaticData:async()=>({props:{catalogId:e,catalogConfig:{...t,items:void 0},scorecardConfig:u,scorecardInfo:y}})})}})},afterRoutesCreated:async(r,l)=>{const S=await l.getConfig(),a=S.catalogClassic??{},g=T(S);if(Object.keys(a).length){const i=Object.keys(a).length>1?await F(r,l,a):null,n={};for(const[c,o]of Object.entries(p||{})){const d=r.getRouteByFsPath(c),s=d?.slug;if(s){if(d&&!g.ignoreMetadata){const e=i?i.get(s)??Object.values(a)[0].slug:Object.values(a)[0].slug,t=O(e,"scorecard/");d.metadata={...d.metadata,scorecardStatus:o.status,scorecardLevel:o.scorecardLevel,scorecardLevelIdx:o.scorecardLevelIdx,scorecardLevels:E(o.levels,C=>({uniqueErrors:C.uniqueErrors,uniqueWarnings:C.uniqueWarnings})),scoreCardSlug:t+"apis/"+encodeURIComponent(j(s))}}if(n[s]={...o,levels:E(o.levels,e=>({...e,problems:e.problems.map(t=>({ruleId:t.ruleId,severity:t.severity}))}))},!h){const e=L.resolve(r.outdir,"_scorecard",k(s));D(N(e),JSON.stringify(o))}}}await r.createSharedData("scorecard",n)}const m={};for(const[i,n]of Object.entries(p||{})){const c=r.getRouteByFsPath(i)?.slug;c&&(m[c]=n)}const f=A.REDOCLY_METADATA_OUTPUT_FOLDER;!h&&f&&(_.info("Writing scorecard data..."),D(L.join(f,w),JSON.stringify({scorecardData:m,...y}))),h=!0}}}export{ne as scorecardClassicPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{envConfig as
|
|
1
|
+
import{envConfig as a}from"../../config/env-config.js";import{SCORECARDS_BASE_SLUG as i,SCORECARDS_TEMPLATE_ID as n}from"../../constants/plugins/scorecards.js";import{getTemplatePath as d}from"./utils/get-template-path.js";import{telemetryTraceStep as l}from"../../../cli/telemetry/helpers/trace-step.js";async function u(){return{id:"Scorecards",requiredEntitlements:["scorecards"],async processContent(e,r){await l("com.redocly.build.plugin.scorecards",async c=>{if(!a.NEW_SCORECARDS_ENABLED)return;const t=(await r.getConfig()).scorecards;c?.setAttribute("config",JSON.stringify(t));const{logger:o}=r;o.info("Scorecards plugin started");const s=e.createTemplate(n,d("../template/index.js"));e.addRoute({duplicateInAllLocales:!0,slug:i,fsPath:"",templateId:s,excludeFromSidebar:!0,hasClientRoutes:!0,getNavText:()=>Promise.resolve("Scorecards"),getStaticData:async()=>({props:{scorecardsConfig:t}})}),o.info("Scorecards plugin finished")})}}}var C=u;export{C as default,u as scorecardsPlugin};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import p from"node:path";import{existsSync as X}from"node:fs";import{writeFile as D,access as N,rm as k,constants as B}from"fs/promises";import{REDOCLY_ROUTE_RBAC as _,REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import U from"picomatch";import{combineUrls as j}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as E}from"../../../../constants/common.js";import{AI_INDEX_EXPORT_FOLDER as G}from"../../../constants/plugins/search.js";import{LLMS_TXT_FILE_NAME as H}from"../../../constants/common.js";import{envConfig as C}from"../../../config/env-config.js";import{logger as
|
|
1
|
+
import p from"node:path";import{existsSync as X}from"node:fs";import{writeFile as D,access as N,rm as k,constants as B}from"fs/promises";import{REDOCLY_ROUTE_RBAC as _,REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import U from"picomatch";import{combineUrls as j}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as E}from"../../../../constants/common.js";import{AI_INDEX_EXPORT_FOLDER as G}from"../../../constants/plugins/search.js";import{LLMS_TXT_FILE_NAME as H}from"../../../constants/common.js";import{envConfig as C}from"../../../config/env-config.js";import{logger as c}from"../../../tools/notifiers/logger.js";import{shaHexShort as Y}from"../../../utils/crypto/sha-hex-short.js";import{promiseMapLimit as P}from"../../../utils/async/promise-map-limit.js";import{getLlmsTxtMdPathBySlug as K}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{buildAgentFeedbackLlmsFooter as J}from"../../../utils/llmstxt/agent-feedback-llms-footer.js";import{validateLLMsTxtConfig as V,generateLLMsTxt as W}from"../llmstxt/index.js";import{ensureDir as F}from"../../../utils/fs.js";import{isResourcePubliclyAccessible as q,extractTeamsFromScopeItems as z,getRbacTeamsListForResource as Q}from"../../../utils/rbac.js";const w=20,S="llms.txt:";async function Dt(t,i,{embeddingsEnabled:o,llmstxtEnabled:n}){const l=p.join(t.outdir,H);if(!n){try{await N(l,B.W_OK),await k(l)}catch{}if(!o)return}o&&c.info("Preparing semantic documents..."),n&&c.info(`${S} Generating llms.txt files...`);const T=c.startTiming(),a=c.startTiming(),m=t.getGlobalConfig("seo"),f=m?.llmstxt,d=C.REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_ENABLED??!1,M=p.resolve(t.outdir,G),u=t.getConfig(),b=u.access?.rbac??{},O=t.getAllRoutes(),y=u?.l10n?.defaultLocale||u?.i18n?.defaultLocale||E,I=(f?.excludeFiles||[]).map(e=>U(e)),R=[];if(await P(O,w,async e=>{if(e.excludeFromSearch)return;const v=await Z(e,t),x=await tt(e,v,i,t);if(x){if(n)for(const s of await x.getLLMsTxts()){if(I.some($=>$(s.fsPath)))continue;const g=K(s.slug),r=p.join(t.outdir,g);F(r);const L=d?J(m,s.slug):void 0,A=L?`
|
|
2
2
|
|
|
3
|
-
${L}`:"";await D(r,`${s.content}${A}`),t.setResourceResponseHeaders(g,[{name:"X-Robots-Tag",value:"noindex, follow"},...u.seo?.siteUrl?[{name:"Link",value:`<${j(u.seo.siteUrl,s.slug)}>; rel="canonical"`}]:[]]),s.includeInLLMsTxt&&q(e,u)&&R.push(s)}if(o&&C.isBuildMode){const s=await x.getSearchDocuments();if(!s.length)return;const g=et(e,
|
|
3
|
+
${L}`:"";await D(r,`${s.content}${A}`),t.setResourceResponseHeaders(g,[{name:"X-Robots-Tag",value:"noindex, follow"},...u.seo?.siteUrl?[{name:"Link",value:`<${j(u.seo.siteUrl,s.slug)}>; rel="canonical"`}]:[]]),s.includeInLLMsTxt&&q(e,u)&&R.push(s)}if(o&&C.isBuildMode){const s=await x.getSearchDocuments();if(!s.length)return;const g=et(e,b),r=e.versions?.find(({active:A})=>A),L=r&&{folder:r.folderId,label:r.label,default:r.default};await ot(s,e.fsPath,g,M,y,L)}}}),o&&c.infoTime(a,"Semantic search documents prepared"),R.length)try{V(f);const e=await W(R,f,{title:m?.title,description:m?.description},i);F(l),await D(l,e),c.infoTime(T,`${S} files generated`)}catch(e){c.error(`${S} Failed to generate llms.txt file. ${e.message}`)}}async function Z(t,i){return t.getStaticData?t.getStaticData(t,i):{}}async function tt(t,i,o,n){if(t.getAiDocumentsStore)return t.getAiDocumentsStore(t,{...i,[h]:t[h],[_]:t[_]},o,n)}function et(t,i){const o=z(t?.[h]);return o?.length?o:Q(t,i)}async function ot(t,i,o,n,l,T){await P(t,w,async a=>{const m=`${Y(i+a.content)}.json`,f=F(p.join(n,m)),d=a.locale===E?l:a.locale;X(f)||await D(f,JSON.stringify({...a,rbacTeams:a.rbacTeams??o??[],version:T,locale:d}),"utf-8")})}export{Dt as prepareSemanticDocuments};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_ROUTE_RBAC as
|
|
1
|
+
import{REDOCLY_ROUTE_RBAC as b,REDOCLY_TEAMS_RBAC as g}from"@redocly/config";import{existsSync as A}from"fs";import{rm as O}from"node:fs/promises";import B from"node:path";import{DEFAULT_LOCALE_PLACEHOLDER as H}from"../../../../constants/common.js";import{SEARCH_DATA_EXPORT_FOLDER as D}from"../../../constants/plugins/search.js";import{envConfig as l}from"../../../config/env-config.js";import{logger as i}from"../../../tools/notifiers/logger.js";import{extractTeamsFromScopeItems as M,getRbacTeamsListForResource as P}from"../../../utils/index.js";import{getSearchDocumentGroup as U}from"../utils.js";import{telemetry as V}from"../../../../cli/telemetry/index.js";import{telemetryTraceStep as R}from"../../../../cli/telemetry/helpers/trace-step.js";async function Q(C,r,f){await R("com.redocly.build.plugin.search.prepareSearchDocuments",async()=>{i.info("Preparing search documents and create indexes...");const n=l.SEARCH_DEV_DEBUG?B.join(r.contentDir,"..","public","client"):r.outdir;(l.SEARCH_DEV_DEBUG||l.isBuildMode)&&A(`${n}/${D}`)&&await O(`${n}/${D}`,{recursive:!0});const _=i.startTiming(),v=r.getConfig().access?.rbac,F=[H,...C.localeFolders.map(a=>a.toLowerCase())];for(const a of F)await R("com.redocly.build.plugin.search.prepareSearchDocuments.locale",async c=>{const w=r.getAllRoutesForLocale(a);let h=0,S=0;for(const t of w){if(h++,t.excludeFromSearch)continue;const d=new Map,{product:u}=t,L=await t.getStaticData?.(t,r)||{},s=await t.getSearchDocuments?.(t,{...L,[g]:t[g],[b]:t[b]},r),o=t.versions?.find(m=>m.active),x=P(t,v??{});if(s){if(s&&s.length){S+=s.length;for(const m in s){let e=s[m];const T=M(e?.[g]),E=T?.length?T:x,y=e.tags||[];e={...e,...o&&{version:o.version,isDefaultVersion:o.default,versionFolderId:o.folderId},...u&&{product:u},rbacTeams:E,tags:[...y,...E,...o?o.default?["v:default"]:[`v:${o.folderId}:${o.version}`]:["v:default"],...u?[`p:${u.name}`]:[]],url:e.url&&(e.path&&e.path.length>1?e.url:e.url.split("#")[0])};const p=U(e.facets);if(p){const $=d.get(p)??[];d.set(p,[...$,e])}}}for(const[m,e]of d)await f.addDocuments(e,{locale:a,group:m,outDir:n})}}c?.setAttribute("locale",a),c?.setAttribute("totalDocuments",h),c?.setAttribute("totalSearchDocuments",S)});if(f.cleanupFacetValues(r),i.infoTime(_,"Search indexes created"),l.SEARCH_DEV_DEBUG||l.isBuildMode){i.info("Writing out search data...");const a=i.startTiming();await f.export(n);const c=i.infoTime(a,"Search data written");c&&V.sendTimingPerformedMessage([{id:"buildStep",object:"timing",uri:"urn:redocly:realm:cli:timing:buildStep",...c}]),A(`${n}/${D}`)||i.warn("No content available for search. Consider hiding search in config.")}})}export{Q as prepareSearchDocuments};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEFAULT_SEARCH_ENGINE as s,REDOCLY_TEAMS_RBAC as E}from"@redocly/config";import{envConfig as c}from"../../config/env-config.js";import{logger as p}from"../../tools/notifiers/logger.js";import{reporter as u}from"../../tools/notifiers/reporter.js";import{prepareSearchDocuments as S}from"./documents/search-documents.js";import{SearchEngine as b}from"./engines/search-engine.js";import{prepareSemanticDocuments as
|
|
1
|
+
import{DEFAULT_SEARCH_ENGINE as s,REDOCLY_TEAMS_RBAC as E}from"@redocly/config";import{envConfig as c}from"../../config/env-config.js";import{logger as p}from"../../tools/notifiers/logger.js";import{reporter as u}from"../../tools/notifiers/reporter.js";import{prepareSearchDocuments as S}from"./documents/search-documents.js";import{SearchEngine as b}from"./engines/search-engine.js";import{prepareSemanticDocuments as y}from"./ai-indexer/prepare-semantic-documents.js";import{isAiSearchEnabled as D,shouldGenerateEmbeddings as A}from"./utils.js";import{telemetryTraceStep as C}from"../../../cli/telemetry/helpers/trace-step.js";import{EntitlementsProvider as R}from"../../entitlements/entitlements-provider.js";async function k(){let e=!0;return{async afterRoutesCreated(t,n){(c.SEARCH_DEV_REINIT||e)&&await _(t,n),e=!1},id:"search"}}async function _(e,t){await C("com.redocly.build.plugin.search",async n=>{const r=e.getConfig();if(n?.setAttribute("config",JSON.stringify(r.search||{})),r.search?.hide){p.info("Search is disabled in the config, skipping");return}const o=r.search?.engine||s,m=c.isDevelopMode?c.SEARCH_DEV_DEBUG?o:s:o,{l10n:l}=e.getGlobalData(),d=D(r),i=r.access?.rbac?.features?.aiSearch,f=A(r);let a;try{a=new b(m,l)}catch(g){await u.panic(g);return}await a.initIndexSchema(e.getSearchFacets()),e.setSearchEngine(a),e.setGlobalData({searchFeatures:{advanced:{enabled:m!==s&&!r.search?.filters?.hide},ai:{enabled:d,[E]:i&&Object.keys(i).length?i:void 0}}}),await S(t.fs,e,a);const h=R.instance().canAccessFeature("seo")===!0&&r.seo?.llmstxt?.hide!==!0;await y(e,t,{embeddingsEnabled:f,llmstxtEnabled:h})})}export{k as searchPlugin};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import d from"picomatch";import{dirname as T,resolve as x}from"node:path";import{access as $,readFile as E,constants as F}from"fs/promises";import{removeTrailingSlash as w}from"../../../../utils/url/remove-trailing-slash.js";import{logger as g}from"../../../tools/notifiers/logger.js";import{withPathPrefix as y}from"@redocly/theme/core/utils";import{envConfig as I}from"../../../config/env-config.js";import{getLlmsTxtMdPathBySlug as v}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";const a="llms.txt",u="Table of contents";async function
|
|
1
|
+
import d from"picomatch";import{dirname as T,resolve as x}from"node:path";import{access as $,readFile as E,constants as F}from"fs/promises";import{removeTrailingSlash as w}from"../../../../utils/url/remove-trailing-slash.js";import{logger as g}from"../../../tools/notifiers/logger.js";import{withPathPrefix as y}from"@redocly/theme/core/utils";import{envConfig as I}from"../../../config/env-config.js";import{getLlmsTxtMdPathBySlug as v}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";const a="llms.txt",u="Table of contents";async function D(t,e,n={title:a,description:void 0},o){if(!e)return{title:n.title||a,description:n.description,details:void 0,sections:[{title:u,description:void 0,llmstxts:t}]};const s=e.title||n.title||a,r=e.description||n.description,i=await M(e,o),c=e.sections?.map(l=>{const{title:f,description:h,excludeFiles:m,includeFiles:L}=l,P=p(t,{excludeFiles:m,includeFiles:L});return{title:f,description:h,llmstxts:P}});return{title:s,description:r,details:i,sections:c||[{title:u,description:void 0,llmstxts:p(t,{includeFiles:["**/*"],excludeFiles:[]})}]}}async function M(t,e){const n=await e.getConfig();if(t?.details?.path&&n.configPath)try{const o=e.fs.getFileInfo(n.configPath);if(!o)throw new Error(`Config file ${n.configPath} not found`);const s=x(e.fs.cwd,T(o.relativePath),t.details.path);return await $(s,F.R_OK),E(s,"utf-8")}catch{throw new Error(`${t.details.path} is not accessible`)}if(t?.details?.content)return t.details.content}function p(t,e){const{excludeFiles:n,includeFiles:o}=e,s=n?.map(i=>d(i)),r=o?.map(i=>d(i));return t.filter(i=>s?.some(l=>l(i.fsPath))?!1:r?.some(l=>l(i.fsPath)))}async function j(t,e,n={title:a,description:void 0},o){const s=await D(t,e,n,o),r=[`# ${s.title}
|
|
2
2
|
|
|
3
3
|
`];return s.description&&r.push(`> ${s.description}
|
|
4
4
|
|
|
@@ -8,6 +8,6 @@ import d from"picomatch";import{dirname as T,resolve as x}from"node:path";import
|
|
|
8
8
|
`),i.description?r.push(`${i.description.replace(/\n+$/,"")}
|
|
9
9
|
|
|
10
10
|
`):r.push(`
|
|
11
|
-
`),i.llmstxts.forEach(c=>{r.push(` - ${
|
|
12
|
-
`)}),r.join("")}function
|
|
13
|
-
`}function K(t){if(t?.details?.path&&t?.details?.content)throw new Error('"details.path" and "details.content" are mutually exclusive. Please use only one of them.')}export{j as generateLLMsTxt,
|
|
11
|
+
`),i.llmstxts.forEach(c=>{r.push(` - ${_({title:c.title,description:c.description,slug:v(c.slug)})}`)}),r.push(`
|
|
12
|
+
`)}),r.join("")}function _({title:t,description:e,slug:n}){const o=e?.replace(/\s+/g," ").trim();return`[${t}](${w(I.REDOCLY_PUBLIC_URL||"")}${encodeURI(y(n))})${o?`: ${o}`:""}
|
|
13
|
+
`}function K(t){if(t?.details?.path&&t?.details?.content)throw new Error('"details.path" and "details.content" are mutually exclusive. Please use only one of them.')}export{j as generateLLMsTxt,_ as llmsTxtLink,K as validateLLMsTxtConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{writeFileSync as tt}from"node:fs";import*as u from"path";import{removeMarkdocTags as et}from"../../../markdoc/helpers/remove-markdoc-tags.js";import{withoutHash as ot}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as E,SIDEBAR_PREFIX as rt,CONFIG_FILE_NAME as K}from"../../../constants/common.js";import{CATALOG_OUTPUT_FILE_NAME as at}from"../../constants/common.js";import{findDeepFirst as M}from"../../../utils/tree/find-deep-first.js";import{isDefined as X}from"../../../utils/guards/is-defined.js";import{partition as it}from"../../../utils/array/partition.js";import{collectPropValueDeep as N}from"../../../utils/tree/collect-prop-value-deep.js";import{envConfig as nt}from"../../config/env-config.js";import{isLocalLink as st}from"../../../utils/path/is-local-link.js";import{normalizeRouteSlug as Y}from"../../../utils/path/normalize-route-slug.js";import{slash as lt}from"../../../utils/path/slash.js";import{parsePathVersions as ct}from"../../../utils/path/parse-path-versions.js";import{reporter as k}from"../../tools/notifiers/reporter.js";import{logger as B}from"../../tools/notifiers/logger.js";import{sha1 as ft}from"../../utils/crypto/sha1.js";import{collectItemsLinkedToSidebars as dt,resolveItems as J}from"../nav-utils.js";import{getExcludedFromLinkCheckerPatterns as ut,getSidebarReferences as mt,hasCircularDependency as gt}from"./utils.js";import{getLocaleFromRelativePath as pt}from"../../fs/utils/get-locale-from-relative-path.js";import{isSystemRouteSlug as ht}from"../../utils/system-routes.js";import{ENTITIES_MAP_GLOBAL_DATA_KEY as St}from"../../constants/plugins/catalog-entities.js";import{telemetryTraceStep as yt}from"../../../cli/telemetry/helpers/trace-step.js";import{isPathIgnored as Ft}from"../../utils/paths.js";const It=180,bt=170,Dt=10;async function Jt({contentDir:f}){return{id:"sidebars",async afterRoutesCreated(o,i){await yt("build.plugin.sidebars",async()=>{const{cache:p,fs:d}=i,b=o.getConfig(),D=new Map,P=new Set,x=[E,...d.localeFolders],$=o.getGlobalData()[St]||{},j=new Map;let R=d.scan(/sidebars.yaml$/).map(({relativePath:t})=>t).filter(t=>!Ft(t,b.ignore??[])&&t);const G=await mt(i,f,R),Q=it(R.filter(t=>!G.has(t)),t=>{const l=ct(t);return l?`@versioned/${l.versionFolderPath}\0${l.filePathInVersion}`:t}),_=ut(b),Z=await dt(b?.navbar,o,i,{navFile:K,excludedFromLinkCheckerPatterns:_});let C;const T=gt(G);T&&Array.isArray(T)&&await k.panicOnBuildContentError(`Sidebar references have circular dependency. Please check your sidebar files.
|
|
1
|
+
import{writeFileSync as tt}from"node:fs";import*as u from"path";import{removeMarkdocTags as et}from"../../../markdoc/helpers/remove-markdoc-tags.js";import{withoutHash as ot}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as E,SIDEBAR_PREFIX as rt,CONFIG_FILE_NAME as K}from"../../../constants/common.js";import{CATALOG_OUTPUT_FILE_NAME as at}from"../../constants/common.js";import{findDeepFirst as M}from"../../../utils/tree/find-deep-first.js";import{isDefined as X}from"../../../utils/guards/is-defined.js";import{partition as it}from"../../../utils/array/partition.js";import{collectPropValueDeep as N}from"../../../utils/tree/collect-prop-value-deep.js";import{envConfig as nt}from"../../config/env-config.js";import{isLocalLink as st}from"../../../utils/path/is-local-link.js";import{normalizeRouteSlug as Y}from"../../../utils/path/normalize-route-slug.js";import{slash as lt}from"../../../utils/path/slash.js";import{parsePathVersions as ct}from"../../../utils/path/parse-path-versions.js";import{reporter as k}from"../../tools/notifiers/reporter.js";import{logger as B}from"../../tools/notifiers/logger.js";import{sha1 as ft}from"../../utils/crypto/sha1.js";import{collectItemsLinkedToSidebars as dt,resolveItems as J}from"../nav-utils.js";import{getExcludedFromLinkCheckerPatterns as ut,getSidebarReferences as mt,hasCircularDependency as gt}from"./utils.js";import{getLocaleFromRelativePath as pt}from"../../fs/utils/get-locale-from-relative-path.js";import{isSystemRouteSlug as ht}from"../../utils/system-routes.js";import{ENTITIES_MAP_GLOBAL_DATA_KEY as St}from"../../constants/plugins/catalog-entities.js";import{telemetryTraceStep as yt}from"../../../cli/telemetry/helpers/trace-step.js";import{isPathIgnored as Ft}from"../../utils/paths.js";const It=180,bt=170,Dt=10;async function Jt({contentDir:f}){return{id:"sidebars",async afterRoutesCreated(o,i){await yt("com.redocly.build.plugin.sidebars",async()=>{const{cache:p,fs:d}=i,b=o.getConfig(),D=new Map,P=new Set,x=[E,...d.localeFolders],$=o.getGlobalData()[St]||{},j=new Map;let R=d.scan(/sidebars.yaml$/).map(({relativePath:t})=>t).filter(t=>!Ft(t,b.ignore??[])&&t);const G=await mt(i,f,R),Q=it(R.filter(t=>!G.has(t)),t=>{const l=ct(t);return l?`@versioned/${l.versionFolderPath}\0${l.filePathInVersion}`:t}),_=ut(b),Z=await dt(b?.navbar,o,i,{navFile:K,excludedFromLinkCheckerPatterns:_});let C;const T=gt(G);T&&Array.isArray(T)&&await k.panicOnBuildContentError(`Sidebar references have circular dependency. Please check your sidebar files.
|
|
2
2
|
Circular dependency chain: ${T.reverse().join(" -> ")}
|
|
3
3
|
`);for(const t of Q){const l=(await Promise.all(t.map(async n=>{const e=(await p.load(n,"yaml")).data;if(!Array.isArray(e)){await k.panicOnBuildContentErrorForRealFile('Invalid sidebar contents at %rp, items should be an array, got "%s"',n,d,n,typeof e);return}return{items:e,sidebarRelativePath:n,locale:pt(n)}}))).filter(X),a=(await A(l))?.firstLink;C||(C=a)}const H=Object.entries(b?.catalogClassic??{});for(const t of x){for(const[e,c]of H)await z(e,c,t);const l={},a=new Set,n=o.getAllRoutesForLocale(t);for(const e of n)if(W(e)&&e.fsPath&&!a.has(e.fsPath)){a.add(e.fsPath);let s=u.posix.dirname(e.fsPath);const h=u.parse(s).root;do l[s]=(l[s]||0)+1,s=u.dirname(s);while(s&&s!="."&&h!=s)}for(const e of n){if(D.has(e.slug))continue;const c=W(e),s=u.dirname(e.fsPath),h=l[s]===1,m=vt(e.baseSlug||e.slug);c&&h?await A([{items:[{directory:s}],sidebarRelativePath:"sidebar.yaml_"+m,locale:t}]):e.getSidebar!==void 0&&await A([{items:[{page:e.fsPath}],sidebarRelativePath:"sidebar.yaml_"+m,locale:t}])}for(const[e,c]of H)await z(e,c,t,!0)}if(R.length===0)for(const t of x){B.verbose("Creating default sidebar");const l=t===E,a=`sidebars.yaml${l?"":"_"+t}`,n=l?"":`${d.localizationFolder}/${t}`,e=(await A([{items:[{directory:`./${n}`}],sidebarRelativePath:a,locale:t,ignoredRoutes:P}]))?.firstLink;C||(C=e)}if(!o.getRouteBySlug("/")&&!o.getConfig().redirects?.["/"]){const l=o.getAllRoutes().find(n=>!ht(n.slug)),a=C?C.link:l?.baseSlug??null;if(a){const n=ot(a);o.addRedirect("/",{to:n,type:302}),B.info("Creating default redirect for index page => %s",n)}}const U=nt.REDOCLY_METADATA_OUTPUT_FOLDER;U&&(B.info("Writing catalog data..."),tt(u.join(U,at),JSON.stringify(Object.fromEntries(j.entries()))));function W(t){return P.has(t.slug)||$[t.fsPath]}async function A(t){if(t.length===0)return;const a=(await Promise.all(t.map(async({items:m,locale:I,sidebarRelativePath:g,ignoredRoutes:L})=>{const r=await J(m,u.dirname(u.join(f,g)),o,i,{locale:I,ignoredRoutes:L,navFile:g,excludedFromLinkCheckerPatterns:_});if(!r){await k.panicOnBuild("Failed to resolve sidebar configuration. Make sure %rp is valid",g);return}return r}))).flat().filter(X),n=N(a,"routeSlug"),e=t[0].sidebarRelativePath,c=q(e),s=new Set;for(const m of n){const I=o.getRouteBySlug(m)?.fsPath??"",g=$[I];g&&(Array.from(s).find(r=>r.key===g.key&&r.version===g.version)||s.add(g)),o.addRouteSharedData(m,"sidebar",c),D.set(Y(m),a)}const h=s.size===1?Array.from(s)[0]:void 0;return await o.createSharedData(c,{relatedNavbarItem:Z?.get(e),items:a,catalogEntity:h?{key:h.key,version:h.version}:void 0}),{firstLink:M(a,m=>!!m.link),resolved:a}}async function z(t,l,a,n=!1){const e=structuredClone(l);a&&a!==E&&e.items.forEach(r=>{r.directory=u.posix.join(d.localizationFolder||"",a,r.directory||"")});let c=await J(e.items,f,o,i,{groupCustomSidebars:!0,locale:a,navFile:K,excludedFromLinkCheckerPatterns:_});if(!c){await k.panicOnBuild(`Failed to resolve catalog configuration. Make sure catalog ${t} has valid config`);return}Ct(c);const s=a===E?"":"/"+a.toLowerCase(),h=a===E?"":`-${a}`,m=Y(u.posix.join(s,e.slug));if(n)for(const r of c){const S=M(r.items||[],F=>!!F.routeSlug);if(!S?.routeSlug)continue;const y=D.get(S.routeSlug);if(!y)continue;const O=N(y,"routeSlug"),w="current-catalog-info-"+r.routeSlug+h,v={catalog:{label:e.title,titleTranslationKey:e.titleTranslationKey,link:m,icon:e?.icon},item:{label:r.metadata?.title,link:r.link,icon:r.icon}};await o.createSharedData(w,v);for(const F of O)o.addRouteSharedData(F,"current-catalog-info",w),P.add(F);const V=M(y,F=>!!F.link&&!F.external&&st(F.link)&&(!r.version||F.version===r.version));V&&(r.sidebar=[{...V,items:void 0}])}const I={},g=new Set;for(const r of c){if(!(r.routeSlug||r.sidebar?.[0]?.routeSlug)||!r.fsPath||g.has(r.fsPath))continue;g.add(r.fsPath);const y=u.dirname(r.fsPath);I[y]=(I[y]||0)+1}if(n){const r=await o.createSharedData("catalog-"+t+h,c.flatMap(S=>{const y=u.dirname(S.fsPath??""),O=I[y]===1,w=v=>({...v,fsPath:O?y:v.fsPath??""});return S.type==="group"&&S.items?.every(v=>v.type==="group")?(S.items||[]).map(w):w(S)}));o.addRouteSharedData(m,"catalog",r),Pt(a,c,j,I)}const L=N(c,"routeSlug");for(const r of L)P.add(r)}})}}}function Pt(f,o,i,p){if(f===E)for(const d of o){const b=d.routeSlug||d.sidebar?.[0]?.routeSlug;if(!b||!d.fsPath)continue;const D=u.dirname(d.fsPath),P=p[D]===1;i.set(b,{rootFileFsPath:d.fsPath,fsPath:P?D:d.fsPath,metadata:d.metadata||{},title:d.metadata?.title||d.label||"Untitled",version:d.version||"latest"})}}function Ct(f){const o=i=>{typeof i.metadata?.description=="string"&&(i.metadata={...i.metadata,description:et(i.metadata.description)})};for(const i of f)if(i.routeSlug)o(i);else for(const p of i.items||[])o(p)}function q(f){return rt+lt(f)}async function qt(f,o,i){const p=u.posix.join(u.dirname(f),o);return await i.exists(p)?q(p):(await k.panicOnBuildContentErrorForRealFile("File %rp: Failed to create relative path for sidebars.yaml using %s",f,i,f,o),null)}function vt(f){const o=f.replaceAll("/","_");if(o.length>It){const i=o.slice(0,bt),p=ft(f).slice(0,Dt).replaceAll("/","_");return i+p}else return o}export{qt as resolveSidebarId,Jt as sidebarsPlugin,Ct as stripMarkdocFromDescriptions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SitemapStream as l,streamToPromise as d}from"sitemap";import{Readable as p}from"stream";import{writeFileSync as y}from"fs";import g from"path";import{SITEMAP_FILE_NAME as h}from"../../constants/common.js";import{ServerRoutes as w}from"../../../constants/api.js";import{withPathPrefix as P}from"@redocly/theme/core/utils";import{logger as s}from"../../tools/notifiers/logger.js";import{isResourcePubliclyAccessible as b}from"../../utils/index.js";import{telemetryTraceStep as S}from"../../../cli/telemetry/helpers/trace-step.js";async function R(t,n){if(!t)return;const r=t.endsWith(".tsx"),i=t.endsWith(".md");if(!(!r&&!i))try{const o=r?"react-frontmatter":"markdown-frontmatter",e=await n.load(t,o);return e.data.frontmatter?.seo?.priority??e.data.seo?.priority}catch{return}}async function v(t,n){const r=t.fsPath?await R(t.fsPath,n):void 0;if(typeof r=="number"){if(r>=0&&r<=1)return r;s.warn(`Invalid SEO priority value "${r}" found for route "${t.slug}". Priority must be between 0 and 1. Using default priority instead.`)}const i=t.versions?.find(o=>o.active);return i?.default||!i?.5:.3}async function $(){return{id:"sitemap",async afterRoutesCreated(t,n){await S("build.plugin.sitemap",async r=>{const{seo:i}=t.getConfig();if(r?.setAttribute("config",JSON.stringify(i||{})),!i?.siteUrl)return;const o=t.getAllRoutes().filter(e=>!e.excludeFromSearch&&b(e,t.getConfig())&&!Object.keys(w).includes(e.slug));if(o.length)try{const e=g.join(t.outdir,h),m=new l({hostname:i.siteUrl}),c=await Promise.all(o.map(async a=>{const u=await v(a,n.cache);return{url:P(a.slug),priority:u}})),f=await d(p.from(c).pipe(m)).then(a=>a.toString());y(e,f),t.hasSitemap=!0}catch(e){r?.error(e),s.error(`Error creating sitemap: ${e.message}`)}})}}}export{$ as sitemapPlugin};
|
|
1
|
+
import{SitemapStream as l,streamToPromise as d}from"sitemap";import{Readable as p}from"stream";import{writeFileSync as y}from"fs";import g from"path";import{SITEMAP_FILE_NAME as h}from"../../constants/common.js";import{ServerRoutes as w}from"../../../constants/api.js";import{withPathPrefix as P}from"@redocly/theme/core/utils";import{logger as s}from"../../tools/notifiers/logger.js";import{isResourcePubliclyAccessible as b}from"../../utils/index.js";import{telemetryTraceStep as S}from"../../../cli/telemetry/helpers/trace-step.js";async function R(t,n){if(!t)return;const r=t.endsWith(".tsx"),i=t.endsWith(".md");if(!(!r&&!i))try{const o=r?"react-frontmatter":"markdown-frontmatter",e=await n.load(t,o);return e.data.frontmatter?.seo?.priority??e.data.seo?.priority}catch{return}}async function v(t,n){const r=t.fsPath?await R(t.fsPath,n):void 0;if(typeof r=="number"){if(r>=0&&r<=1)return r;s.warn(`Invalid SEO priority value "${r}" found for route "${t.slug}". Priority must be between 0 and 1. Using default priority instead.`)}const i=t.versions?.find(o=>o.active);return i?.default||!i?.5:.3}async function $(){return{id:"sitemap",async afterRoutesCreated(t,n){await S("com.redocly.build.plugin.sitemap",async r=>{const{seo:i}=t.getConfig();if(r?.setAttribute("config",JSON.stringify(i||{})),!i?.siteUrl)return;const o=t.getAllRoutes().filter(e=>!e.excludeFromSearch&&b(e,t.getConfig())&&!Object.keys(w).includes(e.slug));if(o.length)try{const e=g.join(t.outdir,h),m=new l({hostname:i.siteUrl}),c=await Promise.all(o.map(async a=>{const u=await v(a,n.cache);return{url:P(a.slug),priority:u}})),f=await d(p.from(c).pipe(m)).then(a=>a.toString());y(e,f),t.hasSitemap=!0}catch(e){r?.error(e),s.error(`Error creating sitemap: ${e.message}`)}})}}}export{$ as sitemapPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DEFAULT_SSO_IDP_TITLE as A}from"../../../constants/common.js";import{envConfig as d}from"../../config/env-config.js";import{telemetryTraceStep as I}from"../../../cli/telemetry/helpers/trace-step.js";import{logger as C}from"../../tools/notifiers/logger.js";const O="https://auth.cloud.redocly.com/oidc/.well-known/openid-configuration",_="https://auth.cloud.redocly.com/api/sso/oidc/introspect";async function S(T){return{id:"sso",async processContent(i){await I("build.plugin.sso",async f=>{const o=i.getConfig(),s=o.access;if(f?.setAttribute("config",`{"ssoDirect": ${JSON.stringify(o.ssoDirect||{})}}, {"sso": ${JSON.stringify(s?.sso||{})}}, {"idps": ${JSON.stringify(s?.idps||{})}}`),o.ssoDirect&&typeof o.ssoDirect=="object"&&Object.keys(o.ssoDirect).length!==0)return;const y=!!s?.sso&&(Array.isArray(s.sso)?s.sso.length>0:!0),r=!!s?.idps&&(Array.isArray(s.idps)?s.idps.length>0:!0);if(s?.sso&&Array.isArray(s.sso)&&!s.sso.length&&!r)return;const g=!!(s?.rbac&&typeof s.rbac=="object"&&Object.keys(s.rbac).length!==0),u=s?.requiresLogin;if(!g&&!u)return;y&&r&&C.error("access.sso and access.idps both set \u2014 should have been rejected by config validation",{sso:s.sso,idps:s.idps});let c=O,a=d.REDOCLY_OAUTH_USE_INTROSPECT?_:"";const e=s?.residency;if(e){const l=e.endsWith("/")?e.slice(0,-1):e;c=`${l.replace("app.","auth.")}/oidc/.well-known/openid-configuration`,a=d.REDOCLY_OAUTH_USE_INTROSPECT?`${l}/api/sso/oidc/introspect`:""}let n="AUTO";s?.sso&&(Array.isArray(s.sso)?n=s.sso.join(","):n=s.sso);let t="";s?.idps&&(Array.isArray(s.idps)?t=s.idps.join(","):t=s.idps);const p={login_hint:"{{ process.env.ORGANIZATION_ID }}",login_type:n};t&&(p.login_idps=t);const m={oidc:{title:A,type:"OIDC",configurationUrl:c,clientId:"{{ process.env.OAUTH_CLIENT_ID }}",clientSecret:"{{ process.env.OAUTH_CLIENT_SECRET }}",teamsClaimName:"https://redocly.com/sso/teams",scopes:["openid","offline"],authorizationRequestCustomParams:p,audience:"{{ process.env.ORGANIZATION_ID }}",introspectEndpoint:a}};i.setGlobalConfig({ssoDirect:m})})},async afterRoutesCreated(i){}}}export{S as ssoPlugin};
|
|
1
|
+
import{DEFAULT_SSO_IDP_TITLE as A}from"../../../constants/common.js";import{envConfig as d}from"../../config/env-config.js";import{telemetryTraceStep as I}from"../../../cli/telemetry/helpers/trace-step.js";import{logger as C}from"../../tools/notifiers/logger.js";const O="https://auth.cloud.redocly.com/oidc/.well-known/openid-configuration",_="https://auth.cloud.redocly.com/api/sso/oidc/introspect";async function S(T){return{id:"sso",async processContent(i){await I("com.redocly.build.plugin.sso",async f=>{const o=i.getConfig(),s=o.access;if(f?.setAttribute("config",`{"ssoDirect": ${JSON.stringify(o.ssoDirect||{})}}, {"sso": ${JSON.stringify(s?.sso||{})}}, {"idps": ${JSON.stringify(s?.idps||{})}}`),o.ssoDirect&&typeof o.ssoDirect=="object"&&Object.keys(o.ssoDirect).length!==0)return;const y=!!s?.sso&&(Array.isArray(s.sso)?s.sso.length>0:!0),r=!!s?.idps&&(Array.isArray(s.idps)?s.idps.length>0:!0);if(s?.sso&&Array.isArray(s.sso)&&!s.sso.length&&!r)return;const g=!!(s?.rbac&&typeof s.rbac=="object"&&Object.keys(s.rbac).length!==0),u=s?.requiresLogin;if(!g&&!u)return;y&&r&&C.error("access.sso and access.idps both set \u2014 should have been rejected by config validation",{sso:s.sso,idps:s.idps});let c=O,a=d.REDOCLY_OAUTH_USE_INTROSPECT?_:"";const e=s?.residency;if(e){const l=e.endsWith("/")?e.slice(0,-1):e;c=`${l.replace("app.","auth.")}/oidc/.well-known/openid-configuration`,a=d.REDOCLY_OAUTH_USE_INTROSPECT?`${l}/api/sso/oidc/introspect`:""}let n="AUTO";s?.sso&&(Array.isArray(s.sso)?n=s.sso.join(","):n=s.sso);let t="";s?.idps&&(Array.isArray(s.idps)?t=s.idps.join(","):t=s.idps);const p={login_hint:"{{ process.env.ORGANIZATION_ID }}",login_type:n};t&&(p.login_idps=t);const m={oidc:{title:A,type:"OIDC",configurationUrl:c,clientId:"{{ process.env.OAUTH_CLIENT_ID }}",clientSecret:"{{ process.env.OAUTH_CLIENT_SECRET }}",teamsClaimName:"https://redocly.com/sso/teams",scopes:["openid","offline"],authorizationRequestCustomParams:p,audience:"{{ process.env.ORGANIZATION_ID }}",introspectEndpoint:a}};i.setGlobalConfig({ssoDirect:m})})},async afterRoutesCreated(i){}}}export{S as ssoPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pathToFileURL as
|
|
1
|
+
import{pathToFileURL as z}from"url";import{HelmetProvider as G}from"@dr.pogodin/react-helmet";import{renderToString as l}from"react-dom/server";import{StaticRouterProvider as J,createStaticHandler as K,createStaticRouter as Q}from"react-router-dom";import r from"react";import{readFile as V}from"fs/promises";import{join as W}from"path";import{withPathPrefix as m,getLocaleFromPathname as X,withoutPathPrefix as Y,removeTrailingSlash as Z}from"@redocly/theme/core/utils";import{RUNTIME_RESOURCES_DIR as T}from"../constants/common.js";import{slash as tt}from"../../utils/path/slash.js";import{reporter as et}from"../tools/notifiers/reporter.js";import{envConfig as p}from"../config/env-config.js";import{slug as rt}from"../../utils/slugger.js";import{shouldForwardProp as ot}from"../../utils/should-forward-prop.js";import{htmlTemplate as st}from"./template.js";import{detectColorSchemaScript as nt,generatePreloadPageData as at,generatePreloadSharedData as it}from"./utils.js";import"./hijack-console.js";import{getSitemapLinkTag as ct}from"./get-sitemap-link-tag.js";let g="";async function lt(t){return p.isRuntimeMode?await import("../../client/server-entry.js"):await import(z(`${tt(t)}/server-entry.js`)+"?"+new Date)}async function Bt(t){if(!p.isRuntimeMode){const e=et.getCompilationProblems();if(e.length>0){const{renderCompilationError:n}=await import("./render-compilation-error.js");return n(e)}}const{Loader:u,App:R,routes:w,ServerStyleSheet:E,StyleSheetManager:P,ErrorDetails:C,initL10n:D}=await lt(t.serverOutDir),{page:h,store:{globalData:S,hasSitemap:y},sharedData:v,ssrHref:b}=t,d=S?.l10n,i=X(Y(h.slug),d?.defaultLocale,d?.locales),f=t.page.request?.url||"http://localhost/";await u.prepare({...h,slug:Z(new URL(f).pathname)},v,S,i),await D(i);const c=new E,{query:M,dataRoutes:x}=K([{Component:R,path:m("*"),children:w}]),s=await M(new Request(f));if(s instanceof Response)throw s;const B=Q(x,s);try{globalThis.SSR_HOSTNAME=b,globalThis.SSR_USER_AGENT=t.userAgent,globalThis.SSR_OMIT_SUSPENSE=t.omitSuspense;const e={},n=l(r.createElement(G,{context:e},r.createElement(P,{sheet:c.instance,shouldForwardProp:ot},r.createElement(J,{router:B,context:s})))),L=y?ct():"",a=e.helmet,j=a?.title.toString()||"",k=t.store.globalData?.logo?.favicon,o=t.store.config,_=`<link rel="preload" as="fetch" crossorigin="anonymous" href="${m("/app-data.json")}" />`,F=at(t.page.slug),H=it(t.page.sharedDataIds),U=nt(o),A=t.page.product?.name?`product-${rt(t.page.product.name)}`:"",$=t.store.ssr.headTags.join(""),I=t.store.ssr.postBodyTags.join(""),N=t.store.ssr.preBodyTags.join(""),O=`<link rel="stylesheet" href="${m(T)}/browser-entry.css" />`;!p.isDevelopMode&&!g&&(g=`<style>${await V(W(t.outdir,T,"browser-entry.css"),"utf-8")}</style>`);const q={bodyHtml:n,linkTags:o.linkTags+c.getStyleTags()+(a?.link.toString()||""),title:j,favicon:k,headScriptTags:L+U+o.headScriptTags+$+(a?.script.toString()||"")+(a?.meta.toString()||""),preload:[_,F,...H],postBodyScriptTags:o.postBodyScriptTags+I,preBodyScriptTags:o.preBodyScriptTags||""+N,lang:i,productClass:A,runtimeCss:g||O};return{html:st(q),statusCode:200}}catch(e){return t.telemetry.sendSsrErrorCaughtMessage([{id:"ssr",object:"error",uri:"urn:redocly:realm:cli:error:ssr",message:e.message}]),{html:l(r.createElement(C,{error:e})),statusCode:500,error:e}}finally{c.seal(),u.clear()}}function Lt(t){return l(r.createElement(r.Fragment,null,...t))}export{Bt as render,Lt as renderComponents};
|
|
@@ -4,6 +4,7 @@ import type { PageRouteDetails } from '../types/index.js';
|
|
|
4
4
|
export declare function detectColorSchemaScript(config?: RedoclyConfig): string;
|
|
5
5
|
export declare function importServerProps(serverOutDir: string): Promise<any>;
|
|
6
6
|
export declare function generatePreloadPageData(slug: string): string;
|
|
7
|
+
export declare function generatePreloadSharedData(sharedDataIds?: Record<string, string>): string[];
|
|
7
8
|
export declare const getPathParams: (route: PageRouteDetails, ctx: Context | null) => {
|
|
8
9
|
params: string[];
|
|
9
10
|
queries: Record<string, string>;
|