@redocly/framework 1.0.0-next.5 → 1.0.0-next.6
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/dist/bundler/build/output-metadata.js +1 -1
- package/dist/bundler/build/run.js +1 -1
- package/dist/bundler/build/theme-global-style-compiler.js +1 -0
- package/dist/bundler/build/theme-global-stylesheets.js +1 -0
- package/dist/bundler/build/vite-config.js +2 -2
- package/dist/bundler/dev/materialization-sweeper.js +1 -1
- package/dist/bundler/dev/run.js +1 -1
- package/dist/bundler/dev/runtime-app.js +1 -1
- package/dist/bundler/node-bundle.js +1 -0
- package/dist/bundler/runtime-files.js +1 -1
- package/dist/bundler/user-markdoc-schema.js +1 -1
- package/dist/bundler/vite-config.base.js +12 -12
- package/dist/cli/commands/ingest.js +1 -1
- package/dist/cli/commands/translate.js +1 -1
- package/dist/cli/validate-react-pages.js +1 -1
- package/dist/client/ApiAccess.js +3 -0
- package/dist/client/NavigationProgress.js +1 -1
- package/dist/client/ProductsProvider.js +1 -1
- package/dist/client/RouteErrorBoundary.js +1 -1
- package/dist/client/ThemeGlobalStyle.js +1 -0
- package/dist/client/UnversionedVersionButton.js +1 -1
- package/dist/client/app.js +3 -3
- package/dist/client/client-entry.js +1 -1
- package/dist/client/dev-problems/ProblemsBar.js +6 -6
- package/dist/client/dev-problems/ProblemsModal.js +15 -15
- package/dist/client/l10n/use-l10n-config.js +1 -1
- package/dist/client/l10n/use-l10n-href.js +1 -1
- package/dist/client/l10n/use-translate.js +1 -1
- package/dist/client/products.js +1 -1
- package/dist/client/review/ReviewBar.js +53 -53
- package/dist/client/sidebar/PoweredByRedocly.js +2 -2
- package/dist/client/ssr.js +1 -1
- package/dist/client/telemetry/report-preload-failure.js +1 -0
- package/dist/client/templates/dev-login.js +4 -4
- package/dist/client/templates/unauthorized.js +5 -5
- package/dist/client/theme-global-css.js +1 -0
- package/dist/client/use-banner.js +1 -1
- package/dist/client/use-search.js +1 -1
- package/dist/content-layer/allowed-packages.js +1 -1
- package/dist/content-layer/config-schema.d.ts +5 -1
- package/dist/content-layer/config-schema.js +1 -1
- package/dist/content-layer/config.d.ts +6 -2
- package/dist/content-layer/config.js +1 -1
- package/dist/content-layer/database/adapters/node-sqlite-client.js +1 -1
- package/dist/content-layer/database/connection.js +1 -1
- package/dist/content-layer/database/entity-store.d.ts +9 -1
- package/dist/content-layer/database/entity-store.js +1 -1
- package/dist/content-layer/database/origins.d.ts +2 -4
- package/dist/content-layer/database/origins.js +1 -1
- package/dist/content-layer/ingest/extract-all-phase.js +1 -1
- package/dist/content-layer/ingest/finalize-phase.js +1 -1
- package/dist/content-layer/ingest/hook-inputs.js +1 -1
- package/dist/content-layer/ingest/l10n-warnings.js +1 -1
- package/dist/content-layer/ingest/rbac-teams.js +1 -1
- package/dist/content-layer/ingest/run.js +1 -1
- package/dist/content-layer/ingest/scan.d.ts +1 -1
- package/dist/content-layer/ingest/scan.js +1 -1
- package/dist/content-layer/ingest/search-sync.js +1 -1
- package/dist/content-layer/ingest/slugger/resolve-final-slugs.js +1 -1
- package/dist/content-layer/ingest/sync.js +1 -1
- package/dist/content-layer/loaders/context.js +1 -1
- package/dist/content-layer/markdown/client/OpenapiTagComponents.js +2 -2
- package/dist/content-layer/markdown/client/dynamic-components.js +1 -1
- package/dist/content-layer/markdown/client/markdoc-components.js +2 -2
- package/dist/content-layer/markdown/constants/tag-sets.js +1 -1
- package/dist/content-layer/markdown/nodes/fence.js +1 -1
- package/dist/content-layer/markdown/nodes/table.js +1 -1
- package/dist/content-layer/markdown/resolve/audience-tag.d.ts +1 -1
- package/dist/content-layer/markdown/resolve/audience-tag.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.d.ts +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/partial.js +1 -1
- package/dist/content-layer/markdown/search/to-markdown.js +2 -2
- package/dist/content-layer/markdown/search/to-sections.js +1 -1
- package/dist/content-layer/markdown/server/render.js +1 -1
- package/dist/content-layer/markdown/service.js +1 -1
- package/dist/content-layer/markdown/tags/html.d.ts +4 -1
- package/dist/content-layer/markdown/tags/html.js +1 -1
- package/dist/content-layer/markdown/types/service.d.ts +2 -0
- package/dist/content-layer/materialization/entity.js +1 -1
- package/dist/content-layer/materialization/materializer.js +1 -0
- package/dist/content-layer/materialization/static-files.js +1 -1
- package/dist/content-layer/plan-gates.d.ts +3 -2
- package/dist/content-layer/plan-gates.js +1 -1
- package/dist/content-layer/plugins/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/client/template.js +4 -4
- package/dist/content-layer/plugins/internal/api-docs/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/build-definition.d.ts +2 -2
- package/dist/content-layer/plugins/internal/api-docs/server/build-definition.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/build-sidebar.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/markdown-docs.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/options.d.ts +4 -2
- package/dist/content-layer/plugins/internal/api-docs/server/options.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/search-documents.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/spec-download.js +1 -1
- package/dist/content-layer/plugins/internal/api-functions/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-functions/server/access.js +1 -1
- package/dist/content-layer/plugins/internal/api-functions/server/dispatch.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/banner.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/index.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/products.d.ts +2 -0
- package/dist/content-layer/plugins/internal/app-data/products.js +1 -1
- package/dist/content-layer/plugins/internal/index.js +1 -1
- package/dist/content-layer/plugins/internal/l10n/index.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/client/template.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/server/shared.d.ts +1 -1
- package/dist/content-layer/plugins/internal/mcp/content-tools.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/agent-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/auth.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/config-gate.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/custom-tools.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/__tests__/secret-store-fixture.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +7 -7
- package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-bridge.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +3 -3
- package/dist/content-layer/plugins/internal/mcp/server/gateway/secret-store.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/tools.js +3 -3
- package/dist/content-layer/plugins/internal/mcp/server/handler.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/authorize.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/discovery.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/server-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/skills-resources.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-catalog.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-catalog.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-document.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-refs.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/openapi.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/pages-navigation.js +1 -1
- package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
- package/dist/content-layer/plugins/internal/react-page/index.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/client/Grid.js +11 -11
- package/dist/content-layer/plugins/internal/scorecard-classic/client/ScorecardViews.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/client/ScorecardWidgets.js +7 -7
- package/dist/content-layer/plugins/internal/scorecard-classic/client/template.js +2 -2
- package/dist/content-layer/plugins/internal/sidebar/bundle.d.ts +1 -1
- package/dist/content-layer/plugins/internal/sidebar/bundle.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/index.d.ts +1 -1
- package/dist/content-layer/plugins/internal/sidebar/index.js +1 -1
- package/dist/content-layer/plugins/internal/skills/index.js +1 -1
- package/dist/content-layer/plugins/internal/skills/server/routes.js +1 -1
- package/dist/content-layer/plugins/project/load.js +2 -2
- package/dist/content-layer/plugins/registry.js +1 -1
- package/dist/content-layer/plugins/request-context.d.ts +5 -0
- package/dist/content-layer/plugins/types/api-entity.d.ts +2 -6
- package/dist/content-layer/plugins/types/api-entity.js +1 -1
- package/dist/content-layer/plugins/types/plugin.d.ts +8 -0
- package/dist/content-layer/plugins/types/search.d.ts +1 -1
- package/dist/content-layer/plugins/utils/route-index.d.ts +1 -1
- package/dist/content-layer/plugins/utils/route-index.js +1 -1
- package/dist/content-layer/plugins/utils/version-path.js +1 -1
- package/dist/content-layer/revisions/config.js +1 -1
- package/dist/content-layer/server/context.js +1 -1
- package/dist/content-layer/server/materialize.js +1 -1
- package/dist/content-layer/static/audience.js +1 -1
- package/dist/content-layer/static/registry.js +1 -1
- package/dist/content-layer/templates/template-set.js +1 -1
- package/dist/content-layer/versions/redirect.d.ts +11 -6
- package/dist/content-layer/versions/redirect.js +1 -1
- package/dist/plugin-api.d.ts +3 -0
- package/dist/plugin-api.js +1 -1
- package/dist/server/__tests__/rbac-fixture.js +1 -1
- package/dist/server/app.js +2 -2
- package/dist/server/ask-ai/feature-gate.js +1 -1
- package/dist/server/ask-ai/route.js +1 -1
- package/dist/server/auth/gate.js +1 -1
- package/dist/server/auth/middleware.js +1 -1
- package/dist/server/auth/request.js +1 -1
- package/dist/server/auth/routes.js +1 -1
- package/dist/server/auth/runtime.js +1 -1
- package/dist/server/content-assets/access.js +1 -1
- package/dist/server/content.js +12 -12
- package/dist/server/feedback/route.js +1 -1
- package/dist/server/lambda-entry.js +1 -1
- package/dist/server/metrics/request-metrics.js +1 -1
- package/dist/server/node-entry.js +1 -1
- package/dist/server/plugin-context.js +1 -1
- package/dist/server/plugin-routes.js +1 -1
- package/dist/server/rbac/content-asset-access.js +1 -1
- package/dist/server/replay-oauth2/route.js +1 -1
- package/dist/server/review/route.js +1 -1
- package/dist/server/runtime-config.js +1 -1
- package/dist/server/search/route.js +1 -1
- package/dist/server/static-files/serve.js +1 -1
- package/dist/server/subprocess/runner.js +1 -1
- package/dist/server/telemetry/route.js +1 -1
- package/dist/server/template-ids.js +1 -1
- package/dist/shared/constants/api-spec-kinds.d.ts +6 -0
- package/dist/shared/constants/api-spec-kinds.js +1 -0
- package/dist/shared/constants/l10n/langs/ar.js +1 -1
- package/dist/shared/constants/l10n/langs/de.js +1 -1
- package/dist/shared/constants/l10n/langs/en.js +1 -1
- package/dist/shared/constants/l10n/langs/es.js +1 -1
- package/dist/shared/constants/l10n/langs/fr.js +1 -1
- package/dist/shared/constants/l10n/langs/hi.js +1 -1
- package/dist/shared/constants/l10n/langs/it.js +1 -1
- package/dist/shared/constants/l10n/langs/ja.js +1 -1
- package/dist/shared/constants/l10n/langs/ko.js +1 -1
- package/dist/shared/constants/l10n/langs/pl.js +1 -1
- package/dist/shared/constants/l10n/langs/pt-br.js +1 -1
- package/dist/shared/constants/l10n/langs/pt.js +1 -1
- package/dist/shared/constants/l10n/langs/ru.js +1 -1
- package/dist/shared/constants/l10n/langs/uk.js +1 -1
- package/dist/shared/constants/l10n/langs/zh.js +1 -1
- package/dist/{server → shared}/constants/system-routes.d.ts +1 -1
- package/dist/shared/constants/system-routes.js +1 -0
- package/dist/shared/plan-gates.d.ts +6 -1
- package/dist/shared/plan-gates.js +1 -1
- package/dist/shared/products.js +1 -1
- package/dist/{server → shared}/project-env.d.ts +1 -1
- package/dist/{server → shared}/rbac/api-docs.d.ts +1 -1
- package/dist/{server → shared}/rbac/engine.d.ts +1 -1
- package/dist/shared/rbac/engine.js +0 -0
- package/dist/shared/rbac/filter.js +1 -0
- package/dist/{server → shared}/rbac/l10n-rules.d.ts +1 -1
- package/dist/shared/rbac/l10n-rules.js +1 -0
- package/dist/shared/rbac/route-scope.js +1 -0
- package/dist/{server → shared}/rbac/team-templates.d.ts +6 -2
- package/dist/shared/rbac/team-templates.js +1 -0
- package/dist/{server → shared}/rbac/teams.d.ts +1 -1
- package/dist/shared/rbac/types.js +1 -0
- package/dist/shared/types/config.d.ts +2 -0
- package/dist/shared/utils/l10n.js +1 -1
- package/package.json +8 -8
- package/dist/content-layer/server/config.js +0 -1
- package/dist/server/constants/system-routes.js +0 -1
- package/dist/server/rbac/engine.js +0 -0
- package/dist/server/rbac/filter.js +0 -1
- package/dist/server/rbac/l10n-rules.js +0 -1
- package/dist/server/rbac/route-scope.js +0 -1
- package/dist/server/rbac/team-templates.js +0 -1
- package/dist/server/rbac/types.js +0 -1
- /package/dist/{server → shared}/project-env.js +0 -0
- /package/dist/{server → shared}/rbac/api-docs.js +0 -0
- /package/dist/{server → shared}/rbac/entity-scope.js +0 -0
- /package/dist/{server → shared}/rbac/filter.d.ts +0 -0
- /package/dist/{server → shared}/rbac/route-scope.d.ts +0 -0
- /package/dist/{server → shared}/rbac/teams.js +0 -0
- /package/dist/{server → shared}/rbac/types.d.ts +0 -0
- /package/dist/{content-layer/markdown → shared}/utils/packed-ast.d.ts +0 -0
- /package/dist/{content-layer/markdown → shared}/utils/packed-ast.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isRbacScope as e}from"../../../../../
|
|
1
|
+
import{isRbacScope as e}from"../../../../../shared/rbac/engine.js";import{REDOCLY_TEAMS_RBAC as t}from"@redocly/config";function n(e){return e.map(o)}function r(e){let t=/* @__PURE__ */ new Set,n=e=>{for(let r of e){let e=i(r.slugSuffix??``);e!==``&&t.add(e),r.items&&r.items.length>0&&n(r.items)}};return n(e),[...t]}function i(e){return e.replace(/^\/+/,``)}function a(e){return e===``||e.startsWith(`/`)?e:`/${e}`}function o(n){let r={};n.label!==void 0&&(r.label=n.label),n.link!==void 0&&(r.slugSuffix=a(n.link)),n.httpVerb!==void 0&&(r.httpVerb=n.httpVerb),n.deprecated!==void 0&&(r.deprecated=n.deprecated),n.badges!==void 0&&(r.badges=n.badges),n.external!==void 0&&(r.external=n.external),n.separatorLine!==void 0&&(r.separatorLine=n.separatorLine),n.icon!==void 0&&(r.icon=n.icon),n.variant!==void 0&&(r.variant=n.variant);let i=n[t];return e(i)&&(r[t]=i),(n.type===`link`||n.type===`group`||n.type===`separator`)&&(r.type=n.type),r.type===`separator`&&(r.separatorLine=!0),n.items&&n.items.length>0&&(r.items=n.items.map(o)),r}export{r as collectSidebarSubpathTargets,n as toSidebarSubtree,i as toSubpathTarget};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{RBAC_TEAM_ANONYMOUS as e}from"../../../../../
|
|
1
|
+
import{RBAC_TEAM_ANONYMOUS as e}from"../../../../../shared/rbac/types.js";import{canView as t,isRbacScope as n,resolveRole as r}from"../../../../../shared/rbac/engine.js";import{isObject as i}from"../../../../../shared/utils/is-object.js";import{headingSlugger as a}from"../../../../markdown/utils/heading-slugger.js";import{parseMarkdown as o}from"../../../../markdown/utils/parse-cache.js";import{SPEC_DOWNLOAD_ROUTE_PATHS as s}from"./shared.js";import{markdocAstToMarkdownChunks as c}from"../../../../markdown/search/to-markdown.js";import{REDOCLY_TEAMS_RBAC as l}from"@redocly/config";const u=i=>{let a=i[l];return a!==void 0&&!t(r(n(a)?a:{},[e]))};function d(e,t,n,r={}){let a=/* @__PURE__ */ new Map,s=e=>{let t=y(e)?e:{type:`document`,children:Array.isArray(e)?e:[e]};return c(t,r)},l=e=>{if(typeof e!=`string`)return s(e);if(!e.includes(`{%`)){let t=e.trim();return t===``?[]:[t]}let t=a.get(e);return t===void 0&&(t=s(o(e)),a.set(e,t)),t},d=[],m=/* @__PURE__ */ new Set,h=e.items,g=i(e.store)?e.store.schemaStore:{},x=i(t)?t:void 0,S=x?.security,C=i(x?.info)?x.info:{},w=(e,t,n,r)=>{d.push({routeSlug:e,chunks:t,headings:f(t),...typeof n==`string`&&n!==``?{title:n}:{},...r?{description:r}:{}})},T=i(C[`x-metadata`])?C[`x-metadata`]:{},E=l((typeof T.description==`string`?T.description:void 0)??C.description).join(`
|
|
2
2
|
|
|
3
3
|
`),D=t=>{let r=t.content,i=r?.contentType??(t.items?.length&&t.link?`group`:void 0);if(!u(t)&&typeof t.link==`string`&&i!==void 0){let a=i===`overview`,o=t.link;if(!m.has(o)){if(a&&r)m.add(o),w(o,p({doc:x,info:C,description:E,specType:e.specType,items:h,originFilePath:n,renderMarkdown:l}),C.title,E);else if(i===`item`&&r)m.add(o),w(o,v(t,{info:C,schemaStore:g,document:x,globalSecurity:S,specType:e.specType,renderMarkdown:l}),t.label);else if(i===`group`){m.add(o);let e=t.deprecated===!0||r?.meta?.deprecated===!0,n=_(t.items??[],l);w(o,[`# ${t.label??``}${e?` (deprecated)`:``}`.trim(),...b(r?.children??[],l),...n?[n]:[]].filter(e=>e!==``),t.label)}}}for(let e of t.items??[])D(e)};for(let e of h)D(e);return d}function f(e){return a.reset(),e.map(e=>{let t=/^#{1,6} +(?! )(.+)$/.exec(e.split(`
|
|
4
4
|
`,1)[0]??``);if(!t)return null;let n=t[1].trim();return{heading:n,anchor:a.slug(n)}})}function p(e){let{doc:t,info:n}=e,r=[],a=[];typeof n.title==`string`&&n.title&&a.push(`# ${n.title}`),e.description&&a.push(e.description),typeof n.summary==`string`&&n.summary&&a.push(n.summary);let o=[];n.version!==void 0&&n.version!==``&&o.push(`Version: ${String(n.version)}`);let s=i(n.license)?n.license:void 0;typeof s?.name==`string`&&o.push(`License: ${s.name}`);let c=i(n[`x-metadata`])?n[`x-metadata`]:void 0;if(c){let e=Object.entries(c).filter(([,e])=>typeof e==`string`||typeof e==`number`).filter(([e,t])=>e!==`description`||typeof t!=`string`).map(([e,t])=>`- ${e}: ${String(t)}`);e.length>0&&o.push(`Metadata:\n${e.join(`
|
|
@@ -39,8 +39,10 @@ export declare function resolveNestedFeedback(io: Pick<PluginIO, 'readFile'>, co
|
|
|
39
39
|
*/
|
|
40
40
|
export declare function withMockServerOption(options: Record<string, unknown>, config: Pick<RealmConfig, 'mockServer' | 'planGates'>, routeSlug: string | undefined): Record<string, unknown>;
|
|
41
41
|
/**
|
|
42
|
-
* The api-docs `downloadUrls`
|
|
43
|
-
* `sourcePath`, path-prefixed, unless the per-API
|
|
42
|
+
* The api-docs `downloadUrls` and `replayDefinitionUrl` options. `downloadUrls` is the spec
|
|
43
|
+
* download routes (`server/spec-download.ts`) for `sourcePath`, path-prefixed, unless the per-API
|
|
44
|
+
* config sets its own list. `replayDefinitionUrl` is always the first of those routes, so Try it
|
|
45
|
+
* loads the description from this site even when the configured list points to another origin.
|
|
44
46
|
*/
|
|
45
47
|
export declare function withDownloadUrls(options: Record<string, unknown>, sourcePath: string, kind: ApiSpecType): Record<string, unknown>;
|
|
46
48
|
/** The `x-schema-catalog-link` value: the bundle route for `sourcePath` (`showSchemaCatalogLinks`). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isPlanFeatureGranted as e}from"../../../../../shared/plan-gates.js";import{toPosixPath as t}from"../../../../../shared/utils/to-posix-path.js";import{isMissingError as n}from"../../../../../shared/utils/is-missing-error.js";import{isObject as r}from"../../../../../shared/utils/is-object.js";import{NESTED_CONFIG_FILENAME as i,deepMergeConfig as a,parseNestedConfig as o}from"../../../../config.js";import{contentIgnoreMatcherOf as s}from"../../../../ingest/scan.js";import{SPEC_KIND_GRAPHQL as c}from"../../../../../shared/constants/api-spec-kinds.js";import{MOCK_SERVER_ROUTE_PREFIX as l,mockPathPrefix as u}from"../../../types/api-entity.js";import{withPathPrefix as d}from"../../../../../shared/path-prefix.js";import{SPEC_DOWNLOAD_ROUTE_PATHS as f}from"./shared.js";import{posix as p}from"node:path";import{decoratorTypes as m,preprocessorTypes as h}from"@redocly/config";import{FEEDBACK_TYPES as g}from"@redocly/theme/core/constants";const _=[`openapi`,`asyncapi`,`graphql`];function v(e,t,n){let r=O(t),i=Object.values(e.apis??{}),a=e=>O(p.join(n,e))===r;return i.find(e=>e.output!==void 0&&a(e.output))??i.find(e=>e.output===void 0&&a(e.root))}function y(e,t,n=``){let r=v(e,t,n);if(!r)return{};let i={};r.metadata&&(i.metadata=r.metadata);for(let e of _)r[e]&&typeof r[e]==`object`&&Object.assign(i,r[e]);return r.rbac!==void 0&&(i.rbac=r.rbac),i}async function b(e,t,n,r,i=n){let o=T(t,r),c=await w(e,i,s(t));return c===null?a(o,y(t,n)):a(a(o,E(c.config,r)),y(c.config,n,c.dir))}const x=[...m,...h];async function S(e,t,n,i=n){let o=await w(e,i,s(t)),c=o===null?[t,v(t,n,``)]:[t,o.config,v(o.config,n,o.dir)],l={};for(let e of c){if(!r(e))continue;let t={};for(let n of x)r(e[n])&&(t[n]=e[n]);l=a(l,t)}return{config:l,configDir:o?.dir??``}}async function C(e,t,n){return(await w(e,n,s(t)))?.config.feedback}async function w(e,t,n){for(let r=p.dirname(t);r!==`.`&&r!==`/`;r=p.dirname(r)){let t=p.join(r,i);if(n(t))continue;let a=await D(e,t);if(a!==null)return{config:a,dir:r}}return null}function T(e,t){return t===`arazzo`?{}:e[t]??{}}function E(e,t){let n={...T(e,t)};return e.mockServer&&(n.mockServer=e.mockServer),n}async function D(e,t){let r;try{r=await e.readFile(t)}catch(e){if(n(e))return null;throw e}return o(r,t).config}function O(e){return p.normalize(t(e)).replace(/^\.\/+/,``).replace(/^\/+/,``)}function k(t,n,i){let a=r(t.mockServer)?t.mockServer:{},o={...n.mockServer,...a};if(i===void 0||o.off===!0||!e(n,`mockServer`))return t;let s=d(l+u(i));return{...t,mockServer:{url:s,position:`first`,description:`Mock server`,...o}}}function A(e,t,n){let r=e=>e.split(`/`).map(encodeURIComponent).join(`/`),i=n===c,a=i?f.graphql:f.bundle,o=(i?[t]:[`.json`,`.yaml`].map(e=>t.replace(/\.[^./]+$/u,e))).map(e=>({url:d(`${a}/${r(e)}?download`),title:p.basename(e)}));return{...e,downloadUrls:Array.isArray(e.downloadUrls)?e.downloadUrls:o,replayDefinitionUrl:o[0]?.url}}function j(e){return d(`${f.bundle}/${e}`)}const M={[g.RATING]:`Rate this section`,[g.SENTIMENT]:`Was this section helpful?`,[g.MOOD]:`Was this section helpful?`,[g.COMMENT]:`Share your feedback about this section`,[g.SCALE]:`How would you rate this section?`};function N(e,t,n){let i=[r(t)?t[`x-feedback`]:void 0,e.feedback,n].find(r);if(i===void 0)return e;let a=r(i.settings)?i.settings:{},o=typeof i.type==`string`?M[i.type]:void 0,s=a.label||o||``;return{...e,feedback:{...i,settings:{...a,label:s}}}}export{y as readApiOptionsFromConfig,S as resolveApiBundleConfig,b as resolveApiOptions,C as resolveNestedFeedback,j as schemaCatalogLink,A as withDownloadUrls,N as withFeedbackOption,k as withMockServerOption};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SEARCH_HTTP_METHOD_FACET_FIELD as e,SEARCH_HTTP_PATH_FACET_FIELD as t}from"../../../../../shared/search/facets.js";import{isRbacScope as n}from"../../../../../
|
|
1
|
+
import{SEARCH_HTTP_METHOD_FACET_FIELD as e,SEARCH_HTTP_PATH_FACET_FIELD as t}from"../../../../../shared/search/facets.js";import{isRbacScope as n}from"../../../../../shared/rbac/engine.js";import{annotateApiDocsRbac as r}from"../../../../../shared/rbac/api-docs.js";import{withImpliedDiscriminatorMappings as i}from"./implied-discriminators.js";import{createHash as a}from"node:crypto";import{REDOCLY_TEAMS_RBAC as o}from"@redocly/config";import{ApiDocsSearchIndexer as s,isOperationName as c}from"@redocly/api-docs/server";const l=`API Reference`;function u(e,t,n={}){let a=h(e.store)?e.store:{},o=r(t,e.specType,{warn:n.warn??(()=>{})}),c=i(o),l=new s(e.basePath,a.schemaStore,h(c)?c:void 0,{exampleStore:a.exampleStore}),u=e=>{for(let t of e)l.addItem(t),h(t)&&Array.isArray(t.items)&&u(t.items)};u(e.items);let m=[],g=/* @__PURE__ */ new Set,_=[];return{docs:l.getResult().map(e=>{for(let t of e.parameters??[]){let n=f(t),r=n.fragmentKey;g.has(r)||(g.add(r),m.push(n));let i={docKey:e.id,fragmentKey:r,place:t.place,anchor:p(t.deepLink)};t.path&&t.path.length>0&&(i.path=t.path),_.push(i)}return d(e,n)}),fragments:m,uses:_}}function d(r,i){let a=r.httpPath?m(r.httpPath):void 0,s={...i.facets},l=r.isAdditionalOperation?r.httpMethod:r.httpMethod&&c(r.httpMethod)?r.httpMethod.toLowerCase():void 0;l&&(s[e]=l,a&&(s[t]=a));let u={docKey:r.id,routeSlug:r.url,title:m(r.title),text:m(r.text),groupKey:i.groupKey??`API Reference`,facets:s},d=r[o];return n(d)&&(u.rbacScope=d),r.httpMethod&&(u.httpMethod=r.httpMethod),a&&(u.httpPath=a),r.deprecated&&(u.deprecated=!0),r.isAdditionalOperation&&(u.isAdditionalOperation=!0),r.badges&&r.badges.length>0&&(u.badges=r.badges),u}function f(e){let t={name:m(e.name),description:m(e.description)};return e.example&&(t.example=e.example),e.enum&&e.enum.length>0&&(t.enum=e.enum),{fragmentKey:a(`sha1`).update(JSON.stringify([t.name,t.description,t.example??null,t.enum??null])).digest(`hex`),...t}}function p(e){if(!e)return``;let t=e.indexOf(`#`);return t>=0?e.slice(t+1):e}function m(e){return Array.isArray(e)?e.join(` `):e}function h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{l as API_DOCS_SEARCH_GROUP,u as buildApiDocsSearchDocuments};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{filePathToRouteSlug as e}from"../../../../../shared/utils/routes/file-path-to-route-slug.js";import"
|
|
1
|
+
import{filePathToRouteSlug as e}from"../../../../../shared/utils/routes/file-path-to-route-slug.js";import"../../../../../shared/constants/api-spec-kinds.js";import{createApiEntityKey as t}from"../../../utils/api-entity-key.js";import{filterApiDocsByRbac as n}from"../../../../../shared/rbac/api-docs.js";import{EntityAccessDeniedError as r,notFoundResponse as i}from"../../../../../server/plugin-context.js";import{attachmentDisposition as a}from"../../../../../shared/utils/attachment-disposition.js";import{posix as o}from"node:path";import s from"js-yaml";const c={"Cache-Control":`no-store`};function l(e){return e.replace(/\.[^./]+$/u,``)}async function u(e,t,n){let r=l(t);return(await e.entities.list({type:`api`})).find(({metadata:e})=>{let{sourcePath:t,specType:i}=e??{};return typeof t==`string`&&l(t)===r&&i===`graphql`===n})??null}async function d(n,a){let o=e(a);return await n.hasRoute(o)&&!n.isSlugVisible(o)?new r(t(a),n.request.teams).getResponse():i()}function f(e,t,n,r,i){let o=new URL(t.request.url).searchParams.has(`download`);return e.body(n,200,{...c,"Content-Type":r,...o?{"Content-Disposition":a(i)}:{}})}async function p(e,t){let r=e.req.param(`api`)??``,i=await u(t,r,!1);if(!i)return d(t,r);let a=n(await t.entities.load(i.key),i.metadata?.specType,t.request.teams,{warn:e=>t.logger?.warn(e)}),c=/\.ya?ml$/u.test(r),p=l(o.basename(String(i.metadata?.sourcePath)))+(c?`.yaml`:`.json`);return c?f(e,t,s.dump(a),`application/yaml`,p):f(e,t,JSON.stringify(a,null,2),`application/json`,p)}async function m(e,t){let n=e.req.param(`api`)??``,r=await u(t,n,!0);if(!r)return d(t,n);let i=await t.entities.load(r.key),a=String(r.metadata?.sourcePath);return f(e,t,i,`application/graphql`,o.basename(a))}export{p as bundle,m as graphql};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineContentPlugin as e}from"../../define.js";import{createInlineEntity as t}from"../../../loaders/define.js";import{
|
|
1
|
+
import{defineContentPlugin as e}from"../../define.js";import{createInlineEntity as t}from"../../../loaders/define.js";import{isPlanFeatureGranted as n}from"../../../../shared/plan-gates.js";import{API_FUNCTION_ENTITY_TYPE as r,apiFunctionEntityKey as i}from"./constants.js";import{notInPlanProblem as a}from"../../../plan-gates.js";import{parseApiFunctionRoute as o}from"./route-path.js";const s=`internal.api-functions`,c=/\.(ts|js)$/u,l=e({id:s,version:`1.1.0`,content:{filter:{match:e=>c.test(e)},extractFile(e,s){let c=o(e.path,s.config.apiFunctions?.folders??[]);if(!c)return null;if(!n(s.config,`apiFunctions`))return{routes:[],problems:[a(`API functions`)]};let l={...c,sourcePath:e.path};return{routes:[],entities:[t(l,{stableKey:i(e.path),type:r,metadata:l})]}}},server:{routes:[{path:`/*`,handler:{filePath:`./server/dispatch.ts`,importer:import.meta.url,exportName:`dispatch`}}]}});export{s as API_FUNCTIONS_PLUGIN_ID,l as apiFunctionsContentPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{canView as e,compileRouteAccessMatcher as t,matchContentRule as n,resolveRbacDenialStatus as r,resolveRole as i}from"../../../../../
|
|
1
|
+
import{canView as e,compileRouteAccessMatcher as t,matchContentRule as n,resolveRbacDenialStatus as r,resolveRole as i}from"../../../../../shared/rbac/engine.js";const a=/* @__PURE__ */ new WeakMap;function o(e){let n=a.get(e);return n===void 0&&(n=t(e),a.set(e,n)),n}function s(t,a){let o=n(t,{filePath:a.sourcePath,slug:a.pathname})?.scope;return e(i(o,a.teams))?{allow:!0}:{allow:!1,status:r(a.teams)}}export{s as resolveApiFunctionAccess,o as resolveRbacMatcher};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{API_FUNCTION_ENTITY_TYPE as e}from"../constants.js";import{stripPathPrefix as t}from"../../../../../shared/path-prefix.js";import{compareApiFunctionRoutes as n}from"../route-path.js";import{errorMessage as r}from"../../../../../shared/utils/error-message.js";import{isSubprocessError as i}from"../../../../../server/subprocess/runner.js";import{resolveApiFunctionAccess as a,resolveRbacMatcher as o}from"./access.js";import{sendApiFunctionEvent as s}from"./api-function-telemetry.js";import{BodyTooLargeError as c,MAX_REQUEST_BODY_BYTES as l,MAX_RESPONSE_BODY_BYTES as u,deserializeResponse as d,serializeRequest as f}from"./serialize.js";import{invoke as p}from"./invoke.js";import{fileURLToPath as m}from"node:url";import{getCookie as h}from"hono/cookie";import{TrieRouter as g}from"hono/router/trie-router";import{getPath as _,tryDecodeURIComponent as v}from"hono/utils/url";const y=1048576,b=m(import.meta.url);function x(e){let{method:t,honoPath:n,sourcePath:r}=e.metadata??{};return typeof t==`string`&&typeof n==`string`&&typeof r==`string`?{method:t,honoPath:n,sourcePath:r}:null}const S=/* @__PURE__ */ new WeakMap;function C(e){let t=S.get(e);if(!t){t=new g;let r=e.map(x).filter(e=>e!==null);for(let e of r.sort(n))t.add(e.method,e.honoPath,e);S.set(e,t)}return t}function w(e,t,n){let r=C(e),i=t.toUpperCase(),[[a]]=r.match(i===`HEAD`?`GET`:i,n);if(!a)return null;let[o,s]=a,c=Object.fromEntries(Object.entries(s).map(([e,t])=>{let n=v(t);return[e,o.honoPath.includes(`:${e}{.+}`)?n.split(`/`).filter(Boolean):n]}));return{sourcePath:o.sourcePath,params:c}}function T(e){let t={};for(let n of new Set(e.searchParams.keys())){let r=e.searchParams.getAll(n);t[n]=r.length===1?r[0]:r}return t}const E=1048576,D=`Request body size exceeded limit of ${l/E} MB.`,O=`Response size exceeded limit of ${u/E}MB`,k=1e4,A=`Promise timed out after ${k} ms`;function j(e,t){return Response.json({message:t},{status:e,headers:{"Cache-Control":`no-store`}})}function M(e,t){switch(e){case`timeout`:return N(504,`Timeout exceeded`,A);case`input-too-large`:return N(413,D);case`output-too-large`:case`response-too-large`:return N(500,O);default:return N(500,import.meta.env.DEV?t:`Internal server error`,t)}}function N(e,t,n=t){return{response:j(e,t),failure:n}}async function P(n,i,c){let l=t(_(n.req.raw));if(l===null)return i();let u=new URL(c.request.url),d=w(await c.entities.list({type:e}),c.request.method,l);if(!d)return i();n.set(`realmApiFunctionResponder`,`runtime`);let f=o(c.config);if(f){let e=a(f,{sourcePath:d.sourcePath,pathname:l,teams:c.request.teams});if(!e.allow)return j(e.status,e.status===401?`Unauthorized`:`Forbidden`)}let{subprocess:p}=c;if(!p)return j(501,`API functions do not run on this host.`);let m=(e,t)=>s({sourcePath:d.sourcePath,status:e,failure:t},{logger:c.logger}),h;try{h=await F(n,c,p,d,u)}catch(e){throw await m(500,r(e)),e}return await m(h.response.status,h.failure),h.response}async function F(e,t,n,r,a){let o;try{o={modulePath:n.resolveContentModule(r.sourcePath),request:await f(e.req.raw,l),params:r.params,query:T(a),cookies:h(e),user:{teams:t.request.teams,claims:{...t.request.viewer},email:t.request.viewer?.email,idpAccessToken:void 0,idpId:void 0,isAuthenticated:t.request.viewer?.isAuthenticated??!1},config:t.config,baseUrl:a.origin}}catch(e){if(e instanceof c)return M(`input-too-large`,e.message);throw e}let s;try{s=await n.run({modulePath:b,exportName:`invoke`,input:o,reuse:!import.meta.env.DEV,timeoutMs:k,maxInputBytes:Math.ceil(4/3*l)+y,maxOutputBytes:Math.ceil(4/3*u)+y})}catch(n){if(!i(n))throw n;return n.code===`output-too-large`&&e.set(`realmApiFunctionResponder`,`project`),t.logger?.error(`API function ${r.sourcePath} failed (${n.code}): ${n.message}`),M(n.code,n.message)}if(e.set(`realmApiFunctionResponder`,`project`),!s.ok)return t.logger?.error(`API function ${r.sourcePath} failed (${s.code}): ${s.stack??s.message}`),M(s.code,s.message);let p=d(s.response);return p.headers.has(`cache-control`)||p.headers.set(`Cache-Control`,`no-store`),{response:p}}export{P as dispatch,p as invoke,w as matchApiFunction};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toJsonValue as e}from"../../../database/utils/json.js";import{isRbacScope as t}from"../../../../
|
|
1
|
+
import{toJsonValue as e}from"../../../database/utils/json.js";import{isRbacScope as t}from"../../../../shared/rbac/engine.js";import{hashBlobContent as n}from"../../../materialization/data-ref.js";import{builtInMarkdocTags as r}from"../../../markdown/constants/builtin-tags.js";import{resolveMarkdownAst as i}from"../../../markdown/resolve/ast.js";import{REDOCLY_TEAMS_RBAC as a}from"@redocly/config";async function o(o,s){if(!o||o.length===0)return null;let c=[],l=[],u=[];for(let[d,f]of o.entries()){if(!f.content){s.logger?.warn(`${s.file.path}: banner[${d}] has no content — the item is not shown`);continue}let{content:o,rbac:p,...m}=f,{ast:h,entityDeps:g,assetUsages:_}=await i(f.content,s.file.path,{resolverContext:s,tags:r}),v=p===void 0?{}:{[a]:t(p)?p:(s.logger?.warn(`${s.file.path}: banner[${d}] has an invalid "rbac" value — the item is hidden from everyone`),{})};c.push(e({...m,...v,ast:h,hash:n(f.content)})),l.push(...g),u.push(..._)}return c.length>0?{banner:c,deps:l,assetUsages:u}:null}export{o as resolveBannerForAppData};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineContentPlugin as e}from"../../define.js";import{toJsonObject as t,toJsonValue as n}from"../../../database/utils/json.js";import{createEntityLoader as r}from"../../../loaders/define.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{buildSearchAppData as a}from"../../../../shared/search/facets.js";import{
|
|
1
|
+
import{defineContentPlugin as e}from"../../define.js";import{toJsonObject as t,toJsonValue as n}from"../../../database/utils/json.js";import{createEntityLoader as r}from"../../../loaders/define.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{buildSearchAppData as a}from"../../../../shared/search/facets.js";import{isAttributionRemoved as o,isPlanFeatureGranted as s}from"../../../../shared/plan-gates.js";import{isObject as c}from"../../../../shared/utils/is-object.js";import{isAiHidden as l}from"../../../../shared/ask-ai/config-gate.js";import{APP_DATA_STATIC_DATA_SLUG as u}from"../../../../shared/constants/app-data.js";import{splitUrlSuffix as d}from"../../../../shared/utils/routes/split-url-suffix.js";import{toNavItemRbacAnnotation as f}from"../../../../shared/rbac/filter.js";import{resolvePageTarget as p}from"../../../../shared/utils/routes/resolve-page-target.js";import{listConfiguredProducts as m}from"../../../products.js";import{collectVersionGroups as h,findVersionedDirectories as g}from"../../../versions/version-groups.js";import{publicLink as _}from"../../../versions/public-link.js";import{linkedPageAccess as v}from"../../utils/link-access.js";import{loadSidebarSubtreeLabel as ee}from"../../utils/sidebar-label.js";import{resolveBannerForAppData as te}from"./banner.js";import{resolveLogoForAppData as ne}from"./logo.js";import{resolveNavbarIconsForAppData as y}from"./navbar-icons.js";import{resolveHtmlForAppData as b}from"./html.js";import{resolveSeoForAppData as x}from"./seo.js";import{productConfigPath as S,productLandingLink as C,readProductConfig as w,resolveProductAssetsForAppData as T}from"./products.js";import{dirname as E,resolve as D}from"node:path";import{REDOCLY_TEAMS_RBAC as O}from"@redocly/config";const k=`internal.app-data`,A=`1.32.0`,j=i(k,`app-data`);function M(e){return c(e)&&typeof e.owner==`string`&&`value`in e}const N=r(j,async e=>{let n=new Set(e.pluginRegistry.listFinalizePlugins().map(e=>e.id)),r={};for(let[t,i]of Object.entries(e.args.fragments??{}))M(i)&&n.has(i.owner)&&(r[t]=i.value);let i=await ne(e.config.logo,e.markdown,e.file.path);if(Object.keys(i.logo).length>0){let e=c(r.theme)?r.theme:{};r.theme=t({...e,logo:i.logo})}let a=await te(e.config.banner,e);if(a){let e=c(r.theme)?r.theme:{};r.theme=t({...e,banner:a.banner})}let o=await y(c(r.theme)?r.theme.navbar:void 0,e.markdown,e.file.path);if(o){let e=c(r.theme)?r.theme:{};r.theme=t({...e,navbar:o.navbar})}let s=await y(c(r.theme)?r.theme.footer:void 0,e.markdown,e.file.path);if(s){let e=c(r.theme)?r.theme:{};r.theme=t({...e,footer:s.navbar})}let l=await T(c(r.theme)?r.theme.products:void 0,e.markdown,e.file.path);if(l){let e=c(r.theme)?r.theme:{};r.theme=t({...e,products:l.products})}let u=await b(e.config,e.markdown,e.file.path,t=>e.io.readFile(D(E(e.file.absolutePath),t)),e.logger);u&&(r.html=t(u.html));let d=await x(r.seo,e.markdown,e.file.path);d&&(r.seo=d.seo);let f=[i,a,o,s,l,u,d];return{value:r,entityDeps:f.flatMap(e=>e?.deps??[]),assetUsages:f.flatMap(e=>e?.assetUsages??[])}});function P(e){return{isSystem:!0,key:u,kind:`loader`,type:null,metadata:null,loaderArgs:{pluginVersion:A},loaderId:j,pluginId:k,shouldInvalidateValue:!1,value:null,version:null,fragmentUpdates:e.fragmentUpdates}}const F=e({id:k,version:A,async finalize(e){let r=await h({io:e.io,routes:e.routes,versionedDirectories:g(e.routes.all())}),i=e=>e&&_(e,r),a=t=>t&&{slug:_(t,r),loadLabel:()=>ee(e.entities,t)},o=t=>a(e.routes.byFilePath(t)),s=t=>a(e.routes.bySlug(t)),l=t=>v(t,e.routes,r),u=await B(e.config,o,s,e.logger,l),d=await L(e,o,s,i,l);if(Object.keys(d).length>0){let e=c(u.theme)?u.theme:{};u.theme=t({...e,products:d}),u.pageProducts=n(Object.values(d).map(I))}return{appData:u}},loaders:[N]});function I(e){let{name:t,slug:n,configOverride:r}=e,i={name:t,slug:n},a=r?.analytics?.ga;return a&&(i.ga=a),i}async function L(e,n,r,i,o){let s={};for(let t of m(e.config)){let c=await C(t,e.routes,e.io,i);if(c===void 0){e.logger.warn(`Product "${t.id}" is left out of the product picker: "${t.folder}" has no page.`);continue}let l={name:t.name,folder:t.folder,slug:t.slug,link:c,[O]:o(c)??void 0};t.icon!==void 0&&(l.icon=t.icon);let u=S(t.folder),d=await e.io.exists(u)?await R(w(await e.io.readFile(u),u),{page:Q(n,r,u,e.logger),access:o},a(e.config),e.config):{};Object.keys(d).length>0&&(l.configOverride=d),s[t.id]=l}return t(s)}async function R(e,t,n,r){let i={},a=await G(e.navbar,t),o=await W(e.footer,t),c=U(e.breadcrumbs,t);return e.logo&&(i.logo=e.logo),a&&(i.navbar=a),o&&(i.footer=o),c&&s(r,`breadcrumbs`)&&(i.breadcrumbs=c),e.feedback&&(i.feedback=e.feedback),e.sidebar&&(i.sidebar=e.sidebar),e.codeSnippet&&(i.codeSnippet=e.codeSnippet),e.palette&&(i.palette=e.palette),e.search&&(i.search=await z(e.search,n,t)),e.analytics?.ga&&s(r,`analytics`)&&(i.analytics={ga:e.analytics.ga}),i}async function z(e,n,r){let i={...n},a=await K(e?.suggestedPages,r);return e?.hide!==void 0&&(i.hide=e.hide),e?.placement!==void 0&&(i.placement=e.placement),e?.shortcuts!==void 0&&(i.shortcuts=e.shortcuts),a.length>0&&(i.suggestedPages=a),t(i)}async function B(e,n,r,i,s=()=>void 0){let c={},l={page:Q(n,r,Z,i),access:s},u=await G(e.navbar,l),d=await W(e.footer,l),f=e.seo?.projectTitle,p=U(e.breadcrumbs,l),m={...u?{navbar:u}:{},...d?{footer:d}:{},...p?{breadcrumbs:p}:{},markdown:e.markdown,navigation:e.navigation,userMenu:await Y(e.userMenu,l),feedback:e.feedback,consent:e.consent,...f?{seo:{projectTitle:f}}:{},aiAssistant:V(e),mcp:H(e),search:await z(e.search,a(e),l),sidebar:e.sidebar,versionPicker:e.versionPicker,codeSnippet:e.codeSnippet,palette:e.palette};if(e.colorMode&&(m.colorMode=e.colorMode),Object.keys(m).length>0&&(c.theme=m),e.analytics&&(c.analytics=e.analytics),e.planGates&&(c.removeAttribution=o(e)),e.removeAttribution===!0&&(c.removeConsoleAttribution=!0),e.seo){let{projectTitle:t,llmstxt:n,...r}=e.seo;Object.keys(r).length>0&&(c.seo=r)}return t(c)}function V(e){let t=l(e),n=e.aiAssistant?.trigger;return{...e.aiAssistant,hide:t,trigger:{...n,hide:n?.hide??t}}}function H(e){let t=e.mcp?.hide===!0;return{hide:t,docs:{hide:t}}}function U(e,n){if(!e)return null;let r={};e.hide!==void 0&&(r.hide=e.hide);let i=(e.prefixItems??[]).map(e=>{let t=e.page?n.page(e.page)?.link:void 0;return{icon:$(e.icon),label:$(e.label)??``,labelTranslationKey:$(e.labelTranslationKey),link:t,[O]:J(n,t)}});return i.length>0&&(r.prefixItems=i),Object.keys(r).length>0?t(r):null}async function W(e,n){if(!e)return null;let r={hide:e.hide===!0},i=await K(e.items,n);return e.copyrightText!==void 0&&(r.copyrightText=e.copyrightText),e.logo&&(r.logo=e.logo),i.length>0&&(r.items=i),t(r)}async function G(e,n){if(!e)return null;let r={},i=await K(e.items,n);return e.hide!==void 0&&(r.hide=e.hide),i.length>0&&(r.items=i),Object.keys(r).length>0?t(r):null}async function K(e,t){return Array.isArray(e)?(await Promise.all(e.map(e=>q(e,t)))).filter(e=>e!==null):[]}async function q(e,n){if(typeof e==`string`)return q({page:e},n);if(!c(e))return null;if(typeof e.separator==`string`)return t({...X(e),label:e.separator,type:`separator`});let r=await K(e.items,n),i=ie(e,n.page),a=i?.link,o=e.rbac===void 0?J(n,a):void 0,s=$(e.label)??$(e.group)??(i?i.anchor??await i.loadLabel?.()??i.link:``);return typeof e.group==`string`||r.length>0?t({...X(e),...a?{link:a}:{},...r.length>0?{items:r}:{},label:s,labelTranslationKey:$(e.groupTranslationKey)??$(e.labelTranslationKey),type:`group`,[O]:o}):a?t({...X(e),...se(e.external)??ae(a)?{external:!0}:{},label:s,link:a,type:`link`,[O]:o}):null}function J(e,t){return t===void 0?void 0:e.access(t)??void 0}async function Y(e,n){if(!e)return;let r=[];for(let t of e.items??[])r.push({...t,href:t.link});let i=await K(r,n);return t({...e,menu:i.length>0?i:void 0})}function X(e){let t=oe(e,[`additionalProps`,`expanded`,`labelTranslationKey`,`languageInsensitive`,`linePosition`,`linkedSidebars`,`menuStyle`,`selectFirstItemOnExpand`,`separatorLine`,`target`,`version`]),n=re(e.icon);return n.icon&&(t.icon=n.icon),n.srcSet&&(t.srcSet=n.srcSet),{...t,...f(e.rbac)}}function re(e){return typeof e==`string`?{icon:e}:c(e)&&typeof e.srcSet==`string`?{srcSet:e.srcSet}:{}}function ie(e,t){return typeof e.href==`string`&&e.href.trim()!==``?{link:e.href.trim()}:typeof e.page==`string`&&e.page.trim()!==``?t(e.page):null}const Z=`redocly.yaml`;function Q(e,t,n,r){let i={bySlug:e=>t?.(e),byFilePath:t=>e?.(t)};return e=>{let{path:t,suffix:a,anchor:o}=d(e.trim()),s=p(t,n,i);return s.kind===`escaped`?(r?.warn(`Config page reference escapes the content root`,{page:e}),null):s.kind===`missing`?(r?.warn(`Config page has no matching route`,{page:e}),{link:e.trim()}):{link:`${s.value.slug}${a}`,anchor:o,loadLabel:s.value.loadLabel}}}function ae(e){return/^(?:[a-z][a-z\d+.-]*:)?\/\//i.test(e)||/^(?:mailto|tel):/i.test(e)}function oe(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function $(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function se(e){return typeof e==`boolean`?e:void 0}export{k as APP_DATA_PLUGIN_ID,A as APP_DATA_PLUGIN_VERSION,j as APP_DATA_STATIC_DATA_LOADER_ID,u as APP_DATA_STATIC_DATA_SLUG,F as appDataContentPlugin,P as appDataSystemEntityDescriptor,B as buildConfigAppData,M as isAppDataFragment};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NestedConfig } from '../../../../shared/types/config.js';
|
|
1
2
|
import type { JsonObject } from '../../../database/schema.js';
|
|
2
3
|
import type { AssetUsage } from '../../../markdown/types/asset-usage.js';
|
|
3
4
|
import type { MarkdownService } from '../../../markdown/types/service.js';
|
|
@@ -7,6 +8,7 @@ import type { EntityInvalidationDep } from '../../types/plugin.js';
|
|
|
7
8
|
import type { RouteIndex, RouteRow } from '../../utils/route-index.js';
|
|
8
9
|
/** The content path of a product's own config file. */
|
|
9
10
|
export declare function productConfigPath(folder: string): string;
|
|
11
|
+
export declare function readProductConfig(source: string, path: string): NestedConfig;
|
|
10
12
|
/**
|
|
11
13
|
* The link a product's picker entry opens: the folder's index page, else the first link of
|
|
12
14
|
* the shallowest sidebar file in the folder, else the folder's first page by slug.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toJsonObject as e}from"../../../database/utils/json.js";import{isObject as t}from"../../../../shared/utils/is-object.js";import{resolveContentPath as n}from"../../../../shared/utils/resolve-content-path.js";import{PRODUCT_CONFIG_FILENAME as
|
|
1
|
+
import{toJsonObject as e}from"../../../database/utils/json.js";import{isObject as t}from"../../../../shared/utils/is-object.js";import{resolveContentPath as n}from"../../../../shared/utils/resolve-content-path.js";import{parseNestedConfig as r}from"../../../config.js";import{PRODUCT_CONFIG_FILENAME as i,isInFolder as a}from"../../../products.js";import{resolveConfigImagePath as o,resolveConfigImageSrcSet as s}from"./logo.js";import{resolveNavbarIconsForAppData as c}from"./navbar-icons.js";import{SIDEBAR_FILENAME_REGEX as l}from"../sidebar/index.js";import u from"js-yaml";function d(e){return e===``?i:`${e}/${i}`}function f(e,t){try{return r(e,t).config}catch{return{}}}async function p(e,r,i,o){let s=r.bySlug(e.slug===`/`?`/`:e.slug.slice(0,-1));if(s?.originFilePath&&a(s.originFilePath,e.folder))return o(s);let[c]=(await i.glob(e.folder===``?`**`:`${e.folder}/**`)).filter(e=>l.test(e)).sort((e,t)=>e.split(`/`).length-t.split(`/`).length||e.localeCompare(t));if(c){let e=d(m(await i.readFile(c)),c);if(e!==void 0)return e}let[u]=r.inDirectory(e.folder);return u?o(u):void 0;function d(e,n){if(Array.isArray(e))for(let r of e){if(!t(r))continue;let e=f(r,n),i=e?o(e):void 0;if(i!==void 0)return i;if(typeof r.href==`string`&&r.href.trim()!==``)return r.href.trim();let a=d(r.items,n);if(a!==void 0)return a}}function f(e,t){if(typeof e.page==`string`){let i=n(e.page,t);return i===null?void 0:r.byFilePath(i)}if(typeof e.directory==`string`){let i=n(e.directory,t);return i===null?void 0:r.inDirectory(i)[0]}}}function m(e){try{return u.load(e)}catch{return}}async function h(n,r,i){if(!t(n))return null;let a=[],l=[],u={};for(let[e,f]of Object.entries(n)){if(!t(f)||typeof f.folder!=`string`)continue;let n={...f};if(typeof f.icon==`string`){let[e,t,s]=await o(f.icon,r,i);n.icon=e,a.push(...t),l.push(...s)}if(t(f.configOverride)){let e={...f.configOverride},i=d(f.folder);if(t(e.logo)){let{favicon:t,...n}=e.logo;if(typeof n.image==`string`){let[e,t,s]=await o(n.image,r,i);n.image=e,a.push(...t),l.push(...s)}if(typeof n.srcSet==`string`){let[e,t,o]=await s(n.srcSet,r,i);n.srcSet=e,a.push(...t),l.push(...o)}Object.keys(n).length>0?e.logo=n:delete e.logo}for(let t of[`navbar`,`footer`]){let n=await c(e[t],r,i);n&&(e[t]=n.navbar,a.push(...n.deps),l.push(...n.assetUsages))}n.configOverride=e}u[e]=n}return{products:e(u),deps:a,assetUsages:l}}export{d as productConfigPath,p as productLandingLink,f as readProductConfig,h as resolveProductAssetsForAppData};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{STATIC_FOLDER_PLUGIN_ID as e,STATIC_FOLDER_PREFIX as t,isStaticFolderPath as n,staticFolderContentPlugin as r}from"./static-folder/index.js";import{ASSETS_PLUGIN_ID as i,ASSET_ENTITY_KEY_PREFIX as a,assetsContentPlugin as o}from"./assets/index.js";import{APP_DATA_STATIC_DATA_SLUG as s}from"../../../shared/constants/app-data.js";import{SIDEBAR_ROUTE_DEP_KEY as c}from"../../../shared/constants/route-deps.js";import{FOLDER_SIDEBAR_FILENAME_REGEX as l,SIDEBAR_AGGREGATOR_LOADER_ID as u,SIDEBAR_FILENAME_REGEX as d,SIDEBAR_PLUGIN_ID as f,isTabbedSidebar as p,resolveAutoSidebar as m,sidebarContentPlugin as h}from"./sidebar/index.js";import{APP_DATA_PLUGIN_ID as g,APP_DATA_PLUGIN_VERSION as ee,APP_DATA_STATIC_DATA_LOADER_ID as _,appDataContentPlugin as v,appDataSystemEntityDescriptor as y,buildConfigAppData as b,isAppDataFragment as x}from"./app-data/index.js";import{apiDocsContentPlugin as S}from"./api-docs/index.js";import
|
|
1
|
+
import"./api-functions/constants.js";import{STATIC_FOLDER_PLUGIN_ID as e,STATIC_FOLDER_PREFIX as t,isStaticFolderPath as n,staticFolderContentPlugin as r}from"./static-folder/index.js";import{ASSETS_PLUGIN_ID as i,ASSET_ENTITY_KEY_PREFIX as a,assetsContentPlugin as o}from"./assets/index.js";import{APP_DATA_STATIC_DATA_SLUG as s}from"../../../shared/constants/app-data.js";import{SIDEBAR_ROUTE_DEP_KEY as c}from"../../../shared/constants/route-deps.js";import{FOLDER_SIDEBAR_FILENAME_REGEX as l,SIDEBAR_AGGREGATOR_LOADER_ID as u,SIDEBAR_FILENAME_REGEX as d,SIDEBAR_PLUGIN_ID as f,isTabbedSidebar as p,resolveAutoSidebar as m,sidebarContentPlugin as h}from"./sidebar/index.js";import{APP_DATA_PLUGIN_ID as g,APP_DATA_PLUGIN_VERSION as ee,APP_DATA_STATIC_DATA_LOADER_ID as _,appDataContentPlugin as v,appDataSystemEntityDescriptor as y,buildConfigAppData as b,isAppDataFragment as x}from"./app-data/index.js";import{apiDocsContentPlugin as S}from"./api-docs/index.js";import{API_FUNCTIONS_PLUGIN_ID as C,apiFunctionsContentPlugin as w}from"./api-functions/index.js";import{CATALOG_CLASSIC_LOADER_ID as T,CATALOG_CLASSIC_PLUGIN_ID as E,CATALOG_CLASSIC_SERVER_FN_ID as D,CATALOG_CLASSIC_SIDEBARS_LOADER_ID as O,CATALOG_CLASSIC_TEMPLATE_ID as k,catalogClassicContentPlugin as A}from"./catalog-classic/index.js";import{L10N_PLUGIN_ID as j}from"./l10n/translations-loader.js";import{L10N_PLUGIN_VERSION as M,l10nContentPlugin as N}from"./l10n/index.js";import{MARKDOC_DOCUMENT_LOADER_ID as P,MARKDOC_SEARCH_GROUP as F,MARKDOC_SIDEBAR_ITEM_LOADER_ID as te,MARKDOC_TEMPLATE_ID as I,markdocContentPlugin as L}from"./markdoc/index.js";import{mcpContentPlugin as R}from"./mcp/index.js";import{MOCK_SERVER_PLUGIN_ID as z,MOCK_SERVER_ROUTE_PATH as B,mockServerContentPlugin as V}from"./mock/index.js";import{REACT_PAGE_SEARCH_LOADER_KEY as H,reactPageContentPlugin as U}from"./react-page/index.js";import{REVISIONS_PLUGIN_ID as W,revisionsContentPlugin as G}from"./revisions/index.js";import{SCORECARD_CLASSIC_PLUGIN_ID as K,SCORECARD_CLASSIC_TEMPLATE_ID as q,scorecardClassicContentPlugin as J}from"./scorecard-classic/index.js";import{SKILLS_PLUGIN_ID as Y,SKILL_MARKDOWN_ROUTE_PATH as X,skillsContentPlugin as Z}from"./skills/index.js";import{VERSIONS_PLUGIN_ID as Q,versionsContentPlugin as $}from"./versions/index.js";function ne(){return[v,N,r,o,L,h,$,G,A,S,J,w,V,R,U,Z]}export{C as API_FUNCTIONS_PLUGIN_ID,g as APP_DATA_PLUGIN_ID,ee as APP_DATA_PLUGIN_VERSION,_ as APP_DATA_STATIC_DATA_LOADER_ID,s as APP_DATA_STATIC_DATA_SLUG,i as ASSETS_PLUGIN_ID,a as ASSET_ENTITY_KEY_PREFIX,T as CATALOG_CLASSIC_LOADER_ID,E as CATALOG_CLASSIC_PLUGIN_ID,D as CATALOG_CLASSIC_SERVER_FN_ID,O as CATALOG_CLASSIC_SIDEBARS_LOADER_ID,k as CATALOG_CLASSIC_TEMPLATE_ID,l as FOLDER_SIDEBAR_FILENAME_REGEX,j as L10N_PLUGIN_ID,M as L10N_PLUGIN_VERSION,P as MARKDOC_DOCUMENT_LOADER_ID,F as MARKDOC_SEARCH_GROUP,te as MARKDOC_SIDEBAR_ITEM_LOADER_ID,I as MARKDOC_TEMPLATE_ID,z as MOCK_SERVER_PLUGIN_ID,B as MOCK_SERVER_ROUTE_PATH,H as REACT_PAGE_SEARCH_LOADER_KEY,W as REVISIONS_PLUGIN_ID,K as SCORECARD_CLASSIC_PLUGIN_ID,q as SCORECARD_CLASSIC_TEMPLATE_ID,u as SIDEBAR_AGGREGATOR_LOADER_ID,d as SIDEBAR_FILENAME_REGEX,f as SIDEBAR_PLUGIN_ID,c as SIDEBAR_ROUTE_DEP_KEY,Y as SKILLS_PLUGIN_ID,X as SKILL_MARKDOWN_ROUTE_PATH,e as STATIC_FOLDER_PLUGIN_ID,t as STATIC_FOLDER_PREFIX,Q as VERSIONS_PLUGIN_ID,S as apiDocsContentPlugin,w as apiFunctionsContentPlugin,v as appDataContentPlugin,y as appDataSystemEntityDescriptor,o as assetsContentPlugin,b as buildConfigAppData,A as catalogClassicContentPlugin,ne as createInternalContentPlugins,x as isAppDataFragment,n as isStaticFolderPath,p as isTabbedSidebar,N as l10nContentPlugin,L as markdocContentPlugin,R as mcpContentPlugin,V as mockServerContentPlugin,U as reactPageContentPlugin,m as resolveAutoSidebar,G as revisionsContentPlugin,J as scorecardClassicContentPlugin,h as sidebarContentPlugin,Z as skillsContentPlugin,r as staticFolderContentPlugin,$ as versionsContentPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineContentPlugin as e}from"../../define.js";import{toJsonObject as t}from"../../../database/utils/json.js";import{
|
|
1
|
+
import{defineContentPlugin as e}from"../../define.js";import{toJsonObject as t}from"../../../database/utils/json.js";import{isPlanFeatureGranted as n}from"../../../../shared/plan-gates.js";import{compareStrings as r}from"../../../../shared/utils/compare-strings.js";import{TRANSLATIONS_FILE_PATTERN as i}from"../../../../shared/constants/l10n/defaults.js";import{normalizeL10nConfig as a}from"../../../../shared/utils/l10n.js";import{collectSlugOverrides as o}from"../../utils/slug-overrides.js";import{L10N_PLUGIN_ID as s,L10N_TRANSLATIONS_ENTITY_TYPE as c,l10nTranslationsLoader as l}from"./translations-loader.js";const u=`0.2.0`,d=e({id:s,version:u,loaders:[l],content:{filter:{match:e=>i.test(e)},extractFile(e){return{routes:[],entities:[l.withArgs({path:e.path},{stableKey:`${c}:${e.path}`,type:c})]}}},async finalize(e){let r=a(e.config.l10n).locales,{localeContext:i}=e,{defaultLocale:s,locales:c}=i,l={},u=n(e.config,`l10n`)?await f(e,i):/* @__PURE__ */ new Map;for(let[e,t]of u)l[e]={translation:t};l[s]??={translation:{}};let d={defaultLocale:s,locales:r??[s,...c].map(e=>({code:e,name:e})),contentLocales:[...c],slugOverrides:o(e.routes.all(),i),translations:l};return{appData:t({l10n:d})}}});async function f(e,t){let n=await e.entities.list({type:c}),i=/* @__PURE__ */ new Map;for(let a of[...n].sort((e,t)=>r(e.key,t.key))){let n=await e.entities.load(a.key),r=n?.dir;if(r==null)continue;let o=r===``?t.defaultLocale:r;(r===``||t.isLocale(r))&&(i.has(o)||i.set(o,n.translation))}return i}export{s as L10N_PLUGIN_ID,u as L10N_PLUGIN_VERSION,d as l10nContentPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MARKDOC_DOCUMENT_LOADER_KEY as e}from"../../../../../shared/constants/route-deps.js";import{collectHeadings as t}from"../../../../markdown/utils/collect-headings.js";import{MarkdocRenderer as n}from"../../../../markdown/client/markdoc-components.js";import{DEFAULT_FEEDBACK_TYPE as r}from"@redocly/theme/core/constants";import*as i from"react";import{
|
|
1
|
+
import{MARKDOC_DOCUMENT_LOADER_KEY as e}from"../../../../../shared/constants/route-deps.js";import{collectHeadings as t}from"../../../../markdown/utils/collect-headings.js";import{MarkdocRenderer as n}from"../../../../markdown/client/markdoc-components.js";import{DEFAULT_FEEDBACK_TYPE as r}from"@redocly/theme/core/constants";import*as i from"react";import{extendDetailsBehaviour as a}from"@redocly/theme/core/utils";import{jsx as o}from"react/jsx-runtime";import{useThemeConfig as s,useThemeHooks as c}from"@redocly/theme/core/hooks";import{useLoaderData as l}from"virtual:realm-runtime";import{Feedback as u}from"@redocly/theme/components/Feedback/Feedback";import{TableOfContent as d}from"@redocly/theme/components/TableOfContent/TableOfContent";import{CodeWalkthroughLayout as f}from"@redocly/theme/layouts/CodeWalkthroughLayout";import{DocumentationLayout as p}from"@redocly/theme/layouts/DocumentationLayout";function m(m){let h=l(e),{useSidebarSiblingsData:g}=c(),{markdown:_,feedback:v}=s(),{nextPage:y,prevPage:b}=g()??{},[x,S]=i.useState(null),C=i.useMemo(()=>h?t(h.ast):[],[h]);if(i.useEffect(()=>a(),[h]),!h)return null;let w=/* @__PURE__ */ o(n,{ast:h.ast,withPageActions:!0});return h.tagList?.includes(`code-walkthrough`)?/* @__PURE__ */ o(f,{children:w}):/* @__PURE__ */ o(p,{config:_,editPage:h.editPage,lastModified:h.lastModified,feedback:/* @__PURE__ */ o(u,{...v,type:v?.type??r,settings:v?.settings??{},path:m.page.slug??m.page.path}),nextPage:y,prevPage:b,tableOfContent:/* @__PURE__ */ o(d,{contentWrapper:x,headings:C}),children:/* @__PURE__ */ o(`div`,{ref:S,children:w})})}export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{createPluginScopedId as r}from"../../utils/scoped-id.js";import{runtimeTemplate as i}from"../../templates.js";import{SEARCH_GROUP_FACET_FIELD as a}from"../../../../shared/search/facets.js";import{configuredFacetFields as o,extractFacetsFromFrontmatter as s,invalidFacetValueProblems as c,searchCategoryOf as l}from"../../../search/facet-values.js";import{isObject as u}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as d}from"../../../../shared/utils/routes/normalize-route-slug.js";import{resolveContentPath as f}from"../../../../shared/utils/resolve-content-path.js";import{PAGE_BANNER_SCHEMA as p,sanitizeConfig as m}from"../../../config-schema.js";import{notInPlanProblem as h}from"../../../plan-gates.js";import{matchPathMap as g}from"../../utils/glob.js";import{filePathToRouteSlug as _}from"../../../../shared/utils/routes/file-path-to-route-slug.js";import{isPlanFeatureGranted as v}from"../../../../shared/plan-gates.js";import{splitUrlSuffix as y}from"../../../../shared/utils/routes/split-url-suffix.js";import{packMarkdocAst as ee,unpackMarkdocAst as b}from"../../../markdown/utils/packed-ast.js";import{isRouteSlugTarget as x}from"../../../../shared/utils/routes/is-route-slug-target.js";import{loadSidebarSubtreeLabel as S}from"../../utils/sidebar-label.js";import{markdocNodeRange as C}from"../../../markdown/utils/node-source-range.js";import{replaceWithMarkdocError as te}from"../../../markdown/tags/markdoc-error.js";import{getPartialTwins as ne}from"../../../markdown/tags/partial.js";import{CODE_WALKTHROUGH_TAG_NAMES as re,builtInMarkdocTags as ie}from"../../../markdown/constants/builtin-tags.js";import{walkMarkdocAst as w}from"../../../markdown/utils/walk-markdoc-ast.js";import{markdocFirstHeading as ae}from"../../../markdown/search/to-text.js";import{safeDecodeURI as oe}from"../../../../shared/utils/safe-decode-uri.js";import{shiftRange as se}from"../../../../shared/utils/shift-range.js";import{classifyLinkTarget as ce}from"../../../link-checker/classify.js";import{onDiskLinkRefs as le}from"../../../link-checker/node-ref.js";import{isPartialPath as ue}from"../../../markdown/utils/partials.js";import{FRONTMATTER_BLOCK_RE as de,computeFrontmatterLineOffset as fe}from"../../../markdown/utils/frontmatter-offset.js";import{inlineRawPartials as T}from"../../../markdown/resolve/raw-partials.js";import{resolveMarkdownAst as E}from"../../../markdown/resolve/ast.js";import{resolveBannerForAppData as D}from"../app-data/banner.js";import{MARKDOC_DOCUMENT_LOADER_KEY as O}from"../../../../shared/constants/route-deps.js";import{isMarkdocValidationEnabled as k,resolveMarkdocTagSet as A,resolveMarkdownPageValidationSet as j,userMarkdocSchemaFiles as M,userMarkdocTagNames as N}from"../../../markdown/constants/tag-sets.js";import{pageLocale as P}from"../../utils/page-locale.js";import{markdocAstToMarkdownDoc as F}from"../../../markdown/search/to-markdown.js";import{collectAnchors as I}from"../../../markdown/utils/collect-anchors.js";import{frontmatterVariable as L}from"../../../markdown/utils/frontmatter-variable.js";import{markdownFirstHeading as R}from"../../../markdown/utils/first-heading.js";import{markdocAstToSearchSections as z}from"../../../markdown/search/to-sections.js";import{isInternalPagePath as B}from"../../utils/internal-page-path.js";import{parseExplicitSlugs as V}from"../../utils/explicit-slugs.js";import{isSkillContentPath as pe}from"../../utils/skill-paths.js";import{SOURCE_TEMPLATE_PREFIX as me}from"../../../../shared/constants/template-ids.js";import{captureSnippet as H,splitSourceLines as he}from"../../../../shared/utils/capture-snippet.js";import{curationKeywordsOf as ge}from"../../../search/keywords.js";import _e from"js-yaml";const U=`markdoc-page`,W=r(`internal.markdoc`,`document`),G=r(`internal.markdoc`,`sidebar-item`),ve=`Documentation`,K=t(W,async e=>{let t=await e.io.readFile(e.file.absolutePath),{content:n,frontmatter:r,frontmatterError:i}=Y(t),a=J(e),{ast:o,entityDeps:s,assetUsages:c,tagList:l,problems:u,linkRefs:d}=await E(n,e.file.path,{resolverContext:a,tags:(await A()).tags,variables:{get env(){return e.config.publicEnv??{}}},transform:t=>De(t,e.file.path,Ee(e.config)),validation:k()?await j():void 0}),f=fe(t);Me(o);let p=await Te(r.seo,e),m=v(e.config,`banner`)?await D(Ne(r,e.file.path,e.logger),a):void 0,h=await ke(r,e),g=await Ae(r.navigation,e),_={...h.frontmatter,navigation:g.value,seo:p.seo,banner:m?.banner},y=Pe(r,o);return{value:{ast:ee(o),frontmatter:_,tagList:l,title:y,editPage:we(e.config,r,e.file.path),lastModified:e.file.lastModifiedAt},entityDeps:[...s,...be(),...p.entityDeps,...m?.deps??[],...h.entityDeps,...g.entityDeps],assetUsages:[...c,...p.assetUsages,...m?.assetUsages??[],...h.assetUsages],problems:xe(t,e.file.path,f,u,i),linkRefs:[...le(d,f),...g.linkRefs],targetInventories:[Se(o,{frontmatter:L(_,y)})]}},{usesProjectMarkdocSchema:!0,async markdown(e,t){let{tags:n}=await A(),{chunks:r,headings:i}=F(b(e.ast),{tags:n,locale:P(t),variables:{frontmatter:L(e.frontmatter,e.title),env:t.config.publicEnv??{}}});return[{chunks:r,headings:i,...e.title?{title:e.title}:{}}]},searchable(e,t){if(t.route===void 0||t.route.metadata.excludeFromSearch===!0)return{docs:[]};let n=t.route.slug,r=e.title??Q(t.route.originFilePath??n),{category:i,isInvalid:u}=l(t.route.metadata),{facets:d,invalidFields:f}=s(t.route.metadata,o(t.config)),p=ge(e.frontmatter.keywords);return{docs:z(b(e.ast),r,{frontmatter:L(e.frontmatter,e.title)}).map((e,t)=>{let r={docKey:e.docKey,routeSlug:n,title:e.title,text:e.text,groupKey:i??`Documentation`,facets:d};e.anchor!==void 0&&(r.anchor=e.anchor),e.path!==void 0&&(r.path=e.path);let a=t===0?p:{excludes:p?.excludes};return(a?.includes||a?.excludes)&&(r.keywords=a),e.rbacTeams!==void 0&&(r.rbacScope=Object.fromEntries(e.rbacTeams.map(e=>[e,`read`]))),r}),problems:c([...f,...u?[a]:[]],t.route.originFilePath)}}}),q=t(G,async e=>{let{content:t,frontmatter:n}=Y(await e.io.readFile(e.file.absolutePath)),r=await T(t,e.file.path,J(e));return{value:{label:Z(n)??R(r.source)??Q(e.args.filePath)},entityDeps:r.entityDeps}});function J(e){return{config:e.config,contentDir:e.contentDir,entities:e.entities,file:e.file,io:e.io,logger:e.logger,markdown:e.markdown,plugin:e.plugin}}const ye=e({id:`internal.markdoc`,version:`3.45.0`,content:{filter:{match:e=>e.toLowerCase().endsWith(`.md`)&&!pe(e)},extractFile(e,t){if(B(e.path)||ue(e.path,t.config))return{routes:[]};if(!v(t.config,`markdown`))return{routes:[],problems:[h(`Markdown pages`)]};let{banner:n,...r}=e.manifest,i=Fe(e,t),a=V(r.slug),o=K.withArgs({filePath:e.path}),s=q.withArgs({filePath:e.path});return{routes:a.length>0?a.map(e=>({deps:{[O]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:e,slugHint:null,template:i})):[{deps:{[O]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:null,slugHint:_(e.path),template:i}],entities:[o]}}},loaders:[K,q],templates:{[U]:i(n(`./client/template.tsx`,import.meta.url))}});function Y(e){let t=e.match(de);if(!t)return{content:e,frontmatter:{}};let n=t[1]??``;try{let r=_e.load(n);return{content:e.slice(t[0].length),frontmatter:u(r)?r:{}}}catch(n){let r=n instanceof Error?n.message:String(n);return{content:e.slice(t[0].length),frontmatter:{},frontmatterError:r}}}function be(){return(M()??[]).map(e=>({kind:`file`,path:e}))}function xe(e,t,n,r,i){if(r.length===0&&i===void 0)return[];let a=he(e),o=r.map(e=>Ce(e,a,n,t));if(i!==void 0){let e={start:{line:1},end:{line:n}};o.push({code:`markdown/frontmatter-parse`,message:i,location:{filePath:t,range:e,snippet:H(a,e)}})}return o}function Se(e,t){let{ids:n,exhaustive:r}=I(e,t);return{kind:`anchor`,exhaustive:r,targets:n}}function Ce(e,t,n,r){let i=e.location?.range;if(!i)return e;let a=se(i,n);return{...e,location:{filePath:r,range:a,snippet:H(t,a)}}}function we(e,t,n){let r=u(t.markdown)?t.markdown:{},i={...e.markdown?.editPage,...u(r.editPage)?r.editPage:{}};if(i.hide!==!0&&typeof i.baseUrl==`string`&&i.baseUrl!==``)return{to:`${i.baseUrl.replace(/(?<!\/)\/+$/,``)}/${n}`}}async function Te(e,t){if(!u(e)||typeof e.image!=`string`)return{seo:e,entityDeps:[],assetUsages:[]};let n=await t.markdown.resolveImageReference(e.image,t.file.path);return n.result.kind===`assetRef`?{seo:{...e,image:n.result.url},entityDeps:n.entityDeps,assetUsages:n.assetUsages}:{seo:e,entityDeps:n.entityDeps,assetUsages:[]}}function Ee(e){let t=/* @__PURE__ */ new Map;if(!v(e,`customMarkdocTags`))for(let e of N())t.set(e,`Custom Markdoc tags are not in this project's plan, so \`${e}\` is ignored.`);if(!v(e,`codeWalkthrough`))for(let e of re)t.set(e,`\`${e}\` is not in this project's plan and is ignored.`);return t}function De(e,t,n){let r=[];if(n.size===0)return r;for(let i of w(e,{getExtraNodes:ne})){let e=i.type===`tag`&&i.tag!==void 0?n.get(i.tag):void 0;e!==void 0&&(r.push({code:`configuration/ignored`,message:e,location:{filePath:t,range:C(i)??{start:{line:1},end:{line:1}}}}),te(i,e))}return r}const Oe=[`image`,`links`];async function ke(e,t){let n=t.config.markdown?.frontMatterKeysToResolve??Oe,r={...e},i=[],a=[];for(let o of n){let n=e[o];if(typeof n!=`string`)continue;let s=await t.markdown.resolveLocalReference(n,t.file.path);i.push(...s.entityDeps),a.push(...s.assetUsages),s.result.kind!==`passthrough`&&(r[o]=s.result.url)}return{frontmatter:r,entityDeps:i,assetUsages:a}}async function Ae(e,t){let n=[],r=[];if(!u(e))return{value:e,entityDeps:n,linkRefs:r};let i={...e};for(let a of[`nextButton`,`previousButton`]){let o=e[a];if(!u(o)||typeof o.page!=`string`)continue;let{page:s,...c}=o,l=ce(oe(s),t.file.path);l!==null&&r.push({kind:`link`,raw:s,...l});let d=await je(s,t);n.push(...d.entityDeps),i[a]={...c,label:typeof c.label==`string`?c.label:d.route&&await X(d.route,t),link:d.link}}return{value:i,entityDeps:n,linkRefs:r}}async function X(e,t){let n=await S(t.entities,e);if(n!==void 0)return n;let r=t.routes.get(e.slug)?.metadata.seo;return u(r)&&typeof r.title==`string`&&r.title.trim()!==``?r.title:e.slug}async function je(e,t){let n=e.trim(),{path:r,suffix:i}=y(n);if(x(r)){let e=t.routes.bySlug(d(r));return{link:e&&`${e.slug}${i}`,route:e,entityDeps:[]}}let a=await t.markdown.resolveLocalReference(n,t.file.path);if(a.result.kind!==`pageUrl`)return{entityDeps:a.entityDeps};let o=a.result.url;return{link:o,route:t.routes.bySlug(y(o).path)??a.entityDeps.map(e=>e.kind===`file`?t.routes.byFilePath(e.path):void 0).reverse().find(e=>e!==void 0),entityDeps:a.entityDeps}}function Me(e){let t=/* @__PURE__ */ new Map;for(let n of w(e)){if(n.type!==`tag`||n.tag===void 0||ie[n.tag]?.attributes?.__idx===void 0)continue;let e=(t.get(n.tag)??0)+1;t.set(n.tag,e),n.attributes.__idx=e}}function Ne(e,t,n){if(e.banner===void 0)return;let{value:r,problems:i}=m(p,{banner:e.banner});for(let e of i)n?.warn(`${t}: ${e.message}`);return r.banner}function Pe(e,t){return Z(e)??ae(t)??void 0}function Z(e){let t=u(e.seo)?e.seo.title:void 0;return typeof t==`string`&&t.trim()!==``?t:void 0}function Q(e){let t=(e.split(`/`).pop()??e).replace(/\.[^.]+$/,``);return t===``?e:t}function Fe(e,t){let n=e.manifest.template;if(typeof n==`string`&&n.trim()!==``)return $(n,e.path,t.logger);let r=g(e.path,t.config.markdown?.template);return typeof r==`string`&&r.trim()!==``?$(r,`redocly.yaml`,t.logger):U}function $(e,t,n){if(!e.startsWith(`./`)&&!e.startsWith(`../`)&&!e.startsWith(`/`))return e;let r=f(e,t);return r===null?(n.warn(`Template reference "${e}" in ${t} escapes the content root; falling back to ${U}.`),U):`${me}${r}`}export{W as MARKDOC_DOCUMENT_LOADER_ID,ve as MARKDOC_SEARCH_GROUP,G as MARKDOC_SIDEBAR_ITEM_LOADER_ID,U as MARKDOC_TEMPLATE_ID,ye as markdocContentPlugin};
|
|
1
|
+
import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{createPluginScopedId as r}from"../../utils/scoped-id.js";import{runtimeTemplate as i}from"../../templates.js";import{SEARCH_GROUP_FACET_FIELD as a}from"../../../../shared/search/facets.js";import{configuredFacetFields as o,extractFacetsFromFrontmatter as s,invalidFacetValueProblems as c,searchCategoryOf as l}from"../../../search/facet-values.js";import{isPlanFeatureGranted as u}from"../../../../shared/plan-gates.js";import{SOURCE_TEMPLATE_PREFIX as d}from"../../../../shared/constants/template-ids.js";import{isObject as f}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as p}from"../../../../shared/utils/routes/normalize-route-slug.js";import{resolveContentPath as m}from"../../../../shared/utils/resolve-content-path.js";import{PAGE_BANNER_SCHEMA as h,sanitizeConfig as g}from"../../../config-schema.js";import{notInPlanProblem as _}from"../../../plan-gates.js";import{matchPathMap as v}from"../../utils/glob.js";import{filePathToRouteSlug as y}from"../../../../shared/utils/routes/file-path-to-route-slug.js";import{splitUrlSuffix as b}from"../../../../shared/utils/routes/split-url-suffix.js";import{packMarkdocAst as x,unpackMarkdocAst as S}from"../../../../shared/utils/packed-ast.js";import{isRouteSlugTarget as ee}from"../../../../shared/utils/routes/is-route-slug-target.js";import{loadSidebarSubtreeLabel as te}from"../../utils/sidebar-label.js";import{markdocNodeRange as ne}from"../../../markdown/utils/node-source-range.js";import{replaceWithMarkdocError as C}from"../../../markdown/tags/markdoc-error.js";import{getPartialTwins as w}from"../../../markdown/tags/partial.js";import{CODE_WALKTHROUGH_TAG_NAMES as re,builtInMarkdocTags as ie}from"../../../markdown/constants/builtin-tags.js";import{walkMarkdocAst as T}from"../../../markdown/utils/walk-markdoc-ast.js";import{markdocFirstHeading as ae}from"../../../markdown/search/to-text.js";import{safeDecodeURI as oe}from"../../../../shared/utils/safe-decode-uri.js";import{shiftRange as se}from"../../../../shared/utils/shift-range.js";import{classifyLinkTarget as ce}from"../../../link-checker/classify.js";import{onDiskLinkRefs as le}from"../../../link-checker/node-ref.js";import{isPartialPath as ue}from"../../../markdown/utils/partials.js";import{FRONTMATTER_BLOCK_RE as de,computeFrontmatterLineOffset as fe}from"../../../markdown/utils/frontmatter-offset.js";import{inlineRawPartials as E}from"../../../markdown/resolve/raw-partials.js";import{resolveMarkdownAst as D}from"../../../markdown/resolve/ast.js";import{resolveBannerForAppData as O}from"../app-data/banner.js";import{MARKDOC_DOCUMENT_LOADER_KEY as k}from"../../../../shared/constants/route-deps.js";import{isMarkdocValidationEnabled as A,resolveMarkdocTagSet as j,resolveMarkdownPageValidationSet as M,userMarkdocSchemaFiles as N,userMarkdocTagNames as P}from"../../../markdown/constants/tag-sets.js";import{pageLocale as F}from"../../utils/page-locale.js";import{markdocAstToMarkdownDoc as I}from"../../../markdown/search/to-markdown.js";import{collectAnchors as L}from"../../../markdown/utils/collect-anchors.js";import{frontmatterVariable as R}from"../../../markdown/utils/frontmatter-variable.js";import{markdownFirstHeading as z}from"../../../markdown/utils/first-heading.js";import{markdocAstToSearchSections as B}from"../../../markdown/search/to-sections.js";import{isInternalPagePath as V}from"../../utils/internal-page-path.js";import{parseExplicitSlugs as pe}from"../../utils/explicit-slugs.js";import{isSkillContentPath as me}from"../../utils/skill-paths.js";import{captureSnippet as H,splitSourceLines as he}from"../../../../shared/utils/capture-snippet.js";import{curationKeywordsOf as U}from"../../../search/keywords.js";import ge from"js-yaml";const W=`markdoc-page`,G=r(`internal.markdoc`,`document`),K=r(`internal.markdoc`,`sidebar-item`),_e=`Documentation`,q=t(G,async e=>{let t=await e.io.readFile(e.file.absolutePath),{content:n,frontmatter:r,frontmatterError:i}=X(t),a=Y(e),{ast:o,entityDeps:s,assetUsages:c,tagList:l,problems:d,linkRefs:f}=await D(n,e.file.path,{resolverContext:a,tags:(await j()).tags,variables:{get env(){return e.config.publicEnv??{}}},transform:t=>Ee(t,e.file.path,Te(e.config)),validation:A()?await M():void 0}),p=fe(t);Me(o);let m=await we(r.seo,e),h=u(e.config,`banner`)?await O(Ne(r,e.file.path,e.logger),a):void 0,g=await Oe(r,e),_=await ke(r.navigation,e),v={...g.frontmatter,navigation:_.value,seo:m.seo,banner:h?.banner},y=Pe(r,o);return{value:{ast:x(o),frontmatter:v,tagList:l,title:y,editPage:Ce(e.config,r,e.file.path),lastModified:e.file.lastModifiedAt},entityDeps:[...s,...ye(),...m.entityDeps,...h?.deps??[],...g.entityDeps,..._.entityDeps],assetUsages:[...c,...m.assetUsages,...h?.assetUsages??[],...g.assetUsages],problems:be(t,e.file.path,p,d,i),linkRefs:[...le(f,p),..._.linkRefs],targetInventories:[xe(o,{frontmatter:R(v,y)})]}},{usesProjectMarkdocSchema:!0,async markdown(e,t){let{tags:n}=await j(),{chunks:r,headings:i}=I(S(e.ast),{tags:n,locale:F(t),variables:{frontmatter:R(e.frontmatter,e.title),env:t.config.publicEnv??{}}});return[{chunks:r,headings:i,...e.title?{title:e.title}:{}}]},searchable(e,t){if(t.route===void 0||t.route.metadata.excludeFromSearch===!0)return{docs:[]};let n=t.route.slug,r=e.title??Q(t.route.originFilePath??n),{category:i,isInvalid:u}=l(t.route.metadata),{facets:d,invalidFields:f}=s(t.route.metadata,o(t.config)),p=U(e.frontmatter.keywords);return{docs:B(S(e.ast),r,{frontmatter:R(e.frontmatter,e.title)}).map((e,t)=>{let r={docKey:e.docKey,routeSlug:n,title:e.title,text:e.text,groupKey:i??`Documentation`,facets:d};e.anchor!==void 0&&(r.anchor=e.anchor),e.path!==void 0&&(r.path=e.path);let a=t===0?p:{excludes:p?.excludes};return(a?.includes||a?.excludes)&&(r.keywords=a),e.rbacTeams!==void 0&&(r.rbacScope=Object.fromEntries(e.rbacTeams.map(e=>[e,`read`]))),r}),problems:c([...f,...u?[a]:[]],t.route.originFilePath)}}}),J=t(K,async e=>{let{content:t,frontmatter:n}=X(await e.io.readFile(e.file.absolutePath)),r=await E(t,e.file.path,Y(e));return{value:{label:Z(n)??z(r.source)??Q(e.args.filePath)},entityDeps:r.entityDeps}});function Y(e){return{config:e.config,contentDir:e.contentDir,entities:e.entities,file:e.file,io:e.io,logger:e.logger,markdown:e.markdown,plugin:e.plugin}}const ve=e({id:`internal.markdoc`,version:`3.46.0`,content:{filter:{match:e=>e.toLowerCase().endsWith(`.md`)&&!me(e)},extractFile(e,t){if(V(e.path)||ue(e.path,t.config))return{routes:[]};if(!u(t.config,`markdown`))return{routes:[],problems:[_(`Markdown pages`)]};let{banner:n,...r}=e.manifest,i=Fe(e,t),a=pe(r.slug),o=q.withArgs({filePath:e.path}),s=J.withArgs({filePath:e.path});return{routes:a.length>0?a.map(e=>({deps:{[k]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:e,slugHint:null,template:i})):[{deps:{[k]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:null,slugHint:y(e.path),template:i}],entities:[o]}}},loaders:[q,J],templates:{[W]:i(n(`./client/template.tsx`,import.meta.url))}});function X(e){let t=e.match(de);if(!t)return{content:e,frontmatter:{}};let n=t[1]??``;try{let r=ge.load(n);return{content:e.slice(t[0].length),frontmatter:f(r)?r:{}}}catch(n){let r=n instanceof Error?n.message:String(n);return{content:e.slice(t[0].length),frontmatter:{},frontmatterError:r}}}function ye(){return(N()??[]).map(e=>({kind:`file`,path:e}))}function be(e,t,n,r,i){if(r.length===0&&i===void 0)return[];let a=he(e),o=r.map(e=>Se(e,a,n,t));if(i!==void 0){let e={start:{line:1},end:{line:n}};o.push({code:`markdown/frontmatter-parse`,message:i,location:{filePath:t,range:e,snippet:H(a,e)}})}return o}function xe(e,t){let{ids:n,exhaustive:r}=L(e,t);return{kind:`anchor`,exhaustive:r,targets:n}}function Se(e,t,n,r){let i=e.location?.range;if(!i)return e;let a=se(i,n);return{...e,location:{filePath:r,range:a,snippet:H(t,a)}}}function Ce(e,t,n){let r=f(t.markdown)?t.markdown:{},i={...e.markdown?.editPage,...f(r.editPage)?r.editPage:{}};if(i.hide!==!0&&typeof i.baseUrl==`string`&&i.baseUrl!==``)return{to:`${i.baseUrl.replace(/(?<!\/)\/+$/,``)}/${n}`}}async function we(e,t){if(!f(e)||typeof e.image!=`string`)return{seo:e,entityDeps:[],assetUsages:[]};let n=await t.markdown.resolveImageReference(e.image,t.file.path);return n.result.kind===`assetRef`?{seo:{...e,image:n.result.url},entityDeps:n.entityDeps,assetUsages:n.assetUsages}:{seo:e,entityDeps:n.entityDeps,assetUsages:[]}}function Te(e){let t=/* @__PURE__ */ new Map;if(!u(e,`customMarkdocTags`))for(let e of P())t.set(e,`Custom Markdoc tags are not in this project's plan, so \`${e}\` is ignored.`);if(!u(e,`codeWalkthrough`))for(let e of re)t.set(e,`\`${e}\` is not in this project's plan and is ignored.`);return t}function Ee(e,t,n){let r=[];if(n.size===0)return r;for(let i of T(e,{getExtraNodes:w})){let e=i.type===`tag`&&i.tag!==void 0?n.get(i.tag):void 0;e!==void 0&&(r.push({code:`configuration/ignored`,message:e,location:{filePath:t,range:ne(i)??{start:{line:1},end:{line:1}}}}),C(i,e))}return r}const De=[`image`,`links`];async function Oe(e,t){let n=t.config.markdown?.frontMatterKeysToResolve??De,r={...e},i=[],a=[];for(let o of n){let n=e[o];if(typeof n!=`string`)continue;let s=await t.markdown.resolveLocalReference(n,t.file.path);i.push(...s.entityDeps),a.push(...s.assetUsages),s.result.kind!==`passthrough`&&(r[o]=s.result.url)}return{frontmatter:r,entityDeps:i,assetUsages:a}}async function ke(e,t){let n=[],r=[];if(!f(e))return{value:e,entityDeps:n,linkRefs:r};let i={...e};for(let a of[`nextButton`,`previousButton`]){let o=e[a];if(!f(o)||typeof o.page!=`string`)continue;let{page:s,...c}=o,l=ce(oe(s),t.file.path);l!==null&&r.push({kind:`link`,raw:s,...l});let u=await je(s,t);n.push(...u.entityDeps),i[a]={...c,label:typeof c.label==`string`?c.label:u.route&&await Ae(u.route,t),link:u.link}}return{value:i,entityDeps:n,linkRefs:r}}async function Ae(e,t){let n=await te(t.entities,e);if(n!==void 0)return n;let r=t.routes.get(e.slug)?.metadata.seo;return f(r)&&typeof r.title==`string`&&r.title.trim()!==``?r.title:e.slug}async function je(e,t){let n=e.trim(),{path:r,suffix:i}=b(n);if(ee(r)){let e=t.routes.bySlug(p(r));return{link:e&&`${e.slug}${i}`,route:e,entityDeps:[]}}let a=await t.markdown.resolveLocalReference(n,t.file.path);if(a.result.kind!==`pageUrl`)return{entityDeps:a.entityDeps};let o=a.result.url;return{link:o,route:t.routes.bySlug(b(o).path)??a.entityDeps.map(e=>e.kind===`file`?t.routes.byFilePath(e.path):void 0).reverse().find(e=>e!==void 0),entityDeps:a.entityDeps}}function Me(e){let t=/* @__PURE__ */ new Map;for(let n of T(e)){if(n.type!==`tag`||n.tag===void 0||ie[n.tag]?.attributes?.__idx===void 0)continue;let e=(t.get(n.tag)??0)+1;t.set(n.tag,e),n.attributes.__idx=e}}function Ne(e,t,n){if(e.banner===void 0)return;let{value:r,problems:i}=g(h,{banner:e.banner});for(let e of i)n?.warn(`${t}: ${e.message}`);return r.banner}function Pe(e,t){return Z(e)??ae(t)??void 0}function Z(e){let t=f(e.seo)?e.seo.title:void 0;return typeof t==`string`&&t.trim()!==``?t:void 0}function Q(e){let t=(e.split(`/`).pop()??e).replace(/\.[^.]+$/,``);return t===``?e:t}function Fe(e,t){let n=e.manifest.template;if(typeof n==`string`&&n.trim()!==``)return $(n,e.path,t.logger);let r=v(e.path,t.config.markdown?.template);return typeof r==`string`&&r.trim()!==``?$(r,`redocly.yaml`,t.logger):W}function $(e,t,n){if(!e.startsWith(`./`)&&!e.startsWith(`../`)&&!e.startsWith(`/`))return e;let r=m(e,t);return r===null?(n.warn(`Template reference "${e}" in ${t} escapes the content root; falling back to ${W}.`),W):`${d}${r}`}export{G as MARKDOC_DOCUMENT_LOADER_ID,_e as MARKDOC_SEARCH_GROUP,K as MARKDOC_SIDEBAR_ITEM_LOADER_ID,W as MARKDOC_TEMPLATE_ID,ve as markdocContentPlugin};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PackedMarkdocAst } from '
|
|
1
|
+
import type { PackedMarkdocAst } from '../../../../../shared/utils/packed-ast.js';
|
|
2
2
|
export type MarkdocDocumentStaticData = {
|
|
3
3
|
ast: PackedMarkdocAst;
|
|
4
4
|
frontmatter: Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createInlineEntity as e}from"../../../loaders/define.js";import{
|
|
1
|
+
import{createInlineEntity as e}from"../../../loaders/define.js";import{isPlanFeatureGranted as t}from"../../../../shared/plan-gates.js";import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as n,DISCOVER_TOOL_NAME as r,EXECUTE_TOOL_NAME as i,MANAGE_API_CREDENTIALS_TOOL_NAME as a,MCP_TOOLS_ENTITY_TYPE as o,REMOVE_API_CREDENTIALS_TOOL_NAME as s,SUBMIT_FEEDBACK_TOOL_NAME as c}from"./constants.js";import{notInPlanProblem as l}from"../../../plan-gates.js";import{MCP_TOOL_NAME_PATTERN as u}from"../../registry.js";import{isMcpHidden as d}from"./server/config-gate.js";import{buildMcpSetupPageRoutes as f}from"./setup-page.js";const p=`@mcp`,m=`mcp/invalid-tool`,h=/\.(ts|js)$/u,g=/\.d\.ts$/u,_=/* @__PURE__ */ new Set([`search`,`list-apis`,`get-endpoints`,`get-endpoint-info`,`get-security-schemes`,`get-full-api-description`,`list-graphql-apis`,`get-graphql-type-list`,`get-graphql-type`,`get-graphql-schema`,`list-pages`,`get-page`,`grep-pages`,`whoami`,c,i,r,`describe-tools`,n,a,s]);function v(e){return`mcp-tool-file:${e}`}function y(e){if(g.test(e)||!h.test(e))return!1;let t=e.split(`/`),n=t.indexOf(p);return n!==-1&&n<t.length-1}function b(e,t,n){if(!u.test(e))return`Invalid MCP tool file "${t}": the tool name "${e}" is derived from the file name and may only contain letters, numbers, hyphens, and underscores (max 64 characters). Rename the file.`;if(n!==void 0)return`Duplicate MCP tool name "${e}": defined by both "${n}" and "${t}". Tool names are file names, so each file name must be unique across @mcp folders.`;if(_.has(e))return`Invalid MCP tool file "${t}": the tool name "${e}" is already used by a built-in MCP tool. Rename the file.`}function x(n){let r=[],i=[];if(d(n.config))return{entities:r,problems:i};if(!t(n.config,`customMcpTools`)){for(let{path:e}of n.files)i.push({...l(`Custom MCP tools`),location:{filePath:e}});return{entities:r,problems:i}}let a=/* @__PURE__ */ new Map;for(let{path:t}of n.files){let n=t.slice(t.lastIndexOf(`/`)+1).replace(h,``),s=b(n,t,a.get(n));if(s!==void 0){i.push({code:m,message:s,location:{filePath:t}});continue}a.set(n,t);let c={name:n,sourcePath:t};r.push(e(c,{stableKey:v(t),type:o,metadata:c}))}return{entities:r,problems:i}}const S={filter:{match:y},extractAll(e){return{routes:f(e.config),entities:[]}}};export{p as MCP_DIR_SEGMENT,m as MCP_TOOL_PROBLEM_CODE,_ as RESERVED_MCP_TOOL_NAMES,y as isMcpToolFile,S as mcpContent,v as mcpToolFileEntityKey,x as scanMcpToolFiles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineContentPlugin as e}from"../../define.js";import{createInlineEntity as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{runtimeTemplate as r}from"../../templates.js";import{
|
|
1
|
+
import{defineContentPlugin as e}from"../../define.js";import{createInlineEntity as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{runtimeTemplate as r}from"../../templates.js";import{A2A_ROUTE as i,AGENT_CARD_ROUTE as a,MCP_AUTHORIZATION_SERVER_ROUTE as o,MCP_AUTHORIZE_ROUTE as s,MCP_CALLBACK_ROUTE as c,MCP_CREDENTIALS_ROUTE as l,MCP_PROTECTED_RESOURCE_ROUTE as u,MCP_REGISTER_ROUTE as d,MCP_ROUTE as f,MCP_SERVER_CARD_ROUTE as p,MCP_SETUP_TEMPLATE_ID as m,MCP_TOKEN_ROUTE as h,PUBLIC_MCP_ROUTE as g}from"./constants.js";import{collectVersionGroups as _,findVersionedDirectories as v}from"../../../versions/version-groups.js";import{MCP_CREDENTIALS_THEME_ENTITY_KEY as y,MCP_IGNORED_ROUTES_ENTITY_KEY as b}from"../../../../shared/constants/mcp.js";import{buildMcpAppData as x}from"./app-data.js";import{readCredentialsTheme as S}from"./credentials-theme.js";import{mcpContent as C,scanMcpToolFiles as w}from"./content-tools.js";import{collectIgnoredRouteSlugs as T}from"./ignored-routes.js";import{findMcpRedirectConflict as E}from"./redirects.js";function D(e,t,n,r){return{path:e,auth:`manual`,...r?{method:r}:{},handler:{filePath:t,importer:import.meta.url,exportName:n}}}const O=[D(f,`./server/handler.ts`,`mcp`),D(g,`./server/handler.ts`,`mcpPublic`),D(p,`./server/server-card.ts`,`mcpServerCard`,`GET`),D(u,`./server/oauth/discovery.ts`,`oauthProtectedResource`,`GET`),D(o,`./server/oauth/discovery.ts`,`oauthAuthorizationServer`,`GET`),D(d,`./server/oauth/register.ts`,`mcpRegister`,`POST`),D(s,`./server/oauth/authorize.ts`,`mcpAuthorize`,`GET`),D(h,`./server/oauth/token.ts`,`mcpToken`,`POST`),D(c,`./server/oauth/callback.ts`,`mcpCallback`,`GET`),D(`${c}/*`,`./server/oauth/callback.ts`,`mcpCallback`,`GET`),D(c,`./server/oauth/callback.ts`,`mcpConsent`,`POST`),D(`${c}/*`,`./server/oauth/callback.ts`,`mcpConsent`,`POST`),D(l,`./server/gateway/credentials-handler.ts`,`mcpCredentials`,`ALL`),D(a,`./server/agent-card.ts`,`agentCard`,`GET`),D(i,`./server/agent-card.ts`,`a2a`,`POST`)],k=e({id:`internal.mcp`,version:`1.10.0`,content:C,server:{routes:O},templates:{[m]:r(n(`./client/template.tsx`,import.meta.url))},async finalize(e){let n=E(e.config.redirects);if(n)throw Error(`Redirect "${n.from}" references the reserved MCP route "${n.route}". Remove it: the MCP endpoints are served by the internal.mcp plugin and a redirect would shadow them.`);let r={mcp:x(e.config)},{entities:i,problems:a}=w(e),o=await S(e.io,e.config.palette,t=>e.logger.debug(t));i.push(t(o,{stableKey:y}));let s=e.config.mcp?.ignore??[];if(s.length===0)return{appData:r,problems:a,entities:i};let c=await _({io:e.io,routes:e.routes,versionedDirectories:v(e.routes.all())}),l=T(e.routes.all(),s,c,e.localeContext);return l.length===0?{appData:r,problems:a,entities:i}:(e.logger.debug(`mcp.ignore: hiding ${l.length} routes from the MCP tools`),i.push(t(l,{stableKey:b})),{appData:r,problems:a,entities:i})}});export{k as mcpContentPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A2A_ROUTE as e,MCP_ROUTE as t,MCP_SERVER_CARD_ROUTE as n}from"../constants.js";import{withPathPrefix as r}from"../../../../../shared/path-prefix.js";import{SKILLS_INDEX_SLUG as i,skillMarkdownPath as a}from"../../../utils/skill-paths.js";import{isMcpContentProtected as o,isMcpHidden as s,resolveMcpAccess as c}from"./config-gate.js";import{SKILL_ENTITY_TYPE as l}from"../../../types/skill-entity.js";import{isEntityScopeVisible as u}from"../../../../../shared/rbac/entity-scope.js";import{notFoundResponse as d}from"../../../../../server/plugin-context.js";import{publicBaseUrl as f}from"../../../utils/request-origin.js";import{CORS_ANY_ORIGIN as p,MCP_AUTH_SCHEMES as m}from"./oauth/constants.js";import"./auth.js";const h=[`text/plain`],g=[`text/plain`],_={streaming:!1,pushNotifications:!1},v={"Cache-Control":`no-store`};async function y(e,t){let n=!!e.request.viewer?.isAuthenticated;return o(c(e.config))&&!n?[]:(await e.entities.list({type:l})).flatMap(n=>{let{slug:i,title:o,description:s}=n.metadata??{};return typeof i!=`string`||!u(n,e.request.teams,t=>e.logger?.warn(t))?[]:[{id:i,name:o??i,description:s??``,tags:[],url:`${t}${r(a(i))}`}]})}async function b(n,i){if(s(i.config)||i.config.skills?.hide===!0)return d();n.set(`realmCacheControlOwned`,!0);let a=f(i.config,i.request),l=o(c(i.config)),u=i.config.seo;return n.json({name:u?.title||u?.projectTitle||`Developer Documentation`,description:u?.description||`Documentation agent card announcing this site's agent skills and MCP server.`,url:`${a}${r(e)}`,documentationUrl:`${a}${r(`/`)}`,version:`0.0.1`,protocolVersion:`0.3.0`,preferredTransport:`HTTP+JSON`,capabilities:{..._,extensions:[{uri:`https://modelcontextprotocol.io`,description:`Model Context Protocol server exposing the documentation tools and skills.`,params:{url:`${a}${r(t)}`,...l?{authentication:{required:!0,schemes:[...m]}}:{}}}]},defaultInputModes:h,defaultOutputModes:g,skills:await y(i,a)},200,{...v,...p})}function x(e,t){if(s(t.config))return d();let a=[`<${r(n)}>; rel="mcp-server-card"`];return t.config.skills?.hide!==!0&&a.push(`<${r(i)}>; rel="agent-skills"`),e.json({error:{code:`405`,message:`Method not allowed`}},405,{Link:a.join(`, `),...p,"Access-Control-Expose-Headers":`Link`})}export{x as a2a,b as agentCard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as e}from"../../../../../shared/utils/is-object.js";import
|
|
1
|
+
import"../constants.js";import{isObject as e}from"../../../../../shared/utils/is-object.js";import{thrownErrorClass as t}from"./tool-errors.js";import{maskCodeCredentials as n}from"./code-credentials.js";import{redactSecretsFromString as r}from"./gateway/fetch/redact.js";import{redactSecretShapes as i}from"./secret-patterns.js";import{createHash as a}from"node:crypto";function o(e){return{client:e.client,clientVersion:e.clientVersion,requestId:e.requestId,messageId:e.messageId,callerSubject:e.callerSubject,clientIp:e.request.ip??void 0}}const s=`[mcp-audit]`,c=4096;function l(e){return a(`sha256`).update(e,`utf8`).digest(`hex`)}function u(e){if(e.length<=4096)return e;let t=e.slice(0,c),n=t.search(/\s\S*$/),r=n>0?t.slice(0,n):t;return`${r}…[truncated: kept ${r.length} of ${e.length} chars]`}function d(e,t=[]){return i(r(u(e),t))}const f=/(?<=^|[\s('"])(?:file:\/\/\/?|\/)(?:[^\s()/:'"]+\/)+/gm;function p(e){return d(e.replace(f,``))}function m(e){return{sha256:l(e),bytes:Buffer.byteLength(e,`utf8`)}}function h(e){return Object.keys(e??{}).map(e=>e.toLowerCase()).sort().join(`,`)}const g=/* @__PURE__ */ new Set([`access_token`,`api-key`,`api_key`,`apikey`,`assertion`,`auth`,`client_secret`,`code`,`code_verifier`,`id_token`,`id_token_hint`,`key`,`password`,`refresh_token`,`samlresponse`,`secret`,`session`,`sig`,`signature`,`token`,`x-amz-credential`,`x-amz-security-token`,`x-amz-signature`]);function _(e,t=[],n=[]){let r;try{r=new URL(e)}catch{return d(e,t)}let i=new Set(n.map(e=>e.toLowerCase()));for(let e of[...r.searchParams.keys()]){let t=e.toLowerCase();(g.has(t)||i.has(t))&&r.searchParams.set(e,`redacted`)}return r.username=``,r.password=``,d(r.href,t)}function v(e,t,n){let r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!==void 0&&e!==``));try{e?.info(`${s} ${t}`,r)}catch{}}const y=/(169\.254\.169\.254|metadata\.google\.internal|\.consul\b|\.internal\b|localhost|127\.0\.0\.1|\b10\.\d{1,3}\.\d{1,3}\.\d{1,3}\b|\b192\.168\.\d{1,3}\.\d{1,3}\b|\b172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}\b)/i,b=/(process\s*(?:\.\s*env\b|\[)|globalThis|require\s*\(|__proto__)/;function x(e){let t=[];return b.test(e)&&t.push(`env_probe`),y.test(e)&&t.push(`internal_target`),{sha256:l(e),length:e.length,flags:t.sort().join(`,`)}}function S(e){try{return JSON.stringify(e)??String(e)}catch{return`«[unserializable]»`}}function C(e,{tool:t,mode:n,args:r,result:i,errorClass:a,client:o,clientVersion:s,requestId:c,messageId:u,callerSubject:f,clientIp:p}){if(t===`execute`)return;let h=S(r),g=i===void 0?void 0:m(i),_=r?.sessionHandle,y=typeof _==`string`&&_!==``?_:void 0,b=f??y;v(e,`Record MCP tool call`,{tool:t,mode:n,server_type:`docs`,error_class:a,client:o,client_version:s,request_id:c,message_id:u,subject_sha256:b?l(b):void 0,client_ip:p,args_sha256:l(h),args:d(h,y?[y]:[]),result_sha256:g?.sha256,result_bytes:g?.bytes})}async function w(e,n,r,i){let a={tool:n,mode:e.mcpMode,args:r,...o(e)},s=Date.now(),c;try{c=await i()}catch(r){throw C(e.logger,{...a,errorClass:t(r)}),e.telemetry?.toolThrew(n,Date.now()-s,r),await e.telemetry?.flush(),r}let l=E(c)&&c.isError===!0;return C(e.logger,{...a,result:k(c),errorClass:l?`tool_error`:void 0}),e.telemetry?.toolReturned(n,Date.now()-s,c),await e.telemetry?.flush(),c}const T=/* @__PURE__ */ new Set([`text`,`image`,`audio`,`resource`,`resource_link`]);function E(t){return e(t)&&Array.isArray(t.content)&&t.content.every(t=>e(t)&&T.has(t.type))}function D(t){return e(t)&&t.resultType===`input_required`}function O(e,t=``){return e.content.map(e=>e.type===`text`?e.text:``).join(t)}function k(e){if(typeof e==`string`)return e;if(E(e))return O(e);if(D(e))return``;try{return JSON.stringify(e)??``}catch{return``}}function A(e,{audit:t,code:r,description:i,sessionHandle:a,toolNames:o,fetchBudget:s,fetchCapable:c,requestId:u,messageId:f,callerSubject:p,clientIp:m}){let h=p??a;v(e,`Record code execution input`,{code_sha256:t.sha256,code_length:t.length,request_id:u,message_id:f,flags:t.flags,subject_sha256:h?l(h):void 0,client_ip:m,description:d(i),tools:[...o].sort().join(`,`),fetch_capable:c,fetch_budget:s,code:d(n(r))})}function j(e,{rawUrl:t,method:n,host:r,outcome:i,durationMs:a,injectedSecretValues:o,credentialQueryParams:s,path:c,api:u,status:f,injectedScheme:p,requestHeaders:g,requestBody:y,responseHeaders:b,responseBody:x,caller:S={}}){let{requestId:C,callerSubject:w,clientIp:T}=S,E=x===void 0?void 0:m(x);v(e,`Record gateway fetch`,{url_sha256:l(t),host:r,method:n,path:c,api:u,outcome:i,status:f,injected_scheme:p,duration_ms:a,request_id:C,subject_sha256:w?l(w):void 0,client_ip:T,url:_(t,o,s),request_header_names:h(g),request_body:y===void 0?void 0:d(y,o),response_header_names:h(b),response_sha256:E?.sha256,response_bytes:E?.bytes})}export{c as AUDIT_FIELD_MAX_CHARS,s as AUDIT_LOG_PREFIX,x as auditCode,h as auditHeaderNames,d as auditInput,l as auditSha256,p as auditStack,w as auditToolCall,_ as auditUrl,o as callAttribution,E as isCallToolResult,v as logAuditRecord,A as logCodeExecutionAudit,j as logGatewayFetchAudit,C as logMcpToolCallAudit,k as toolOutputText,O as toolResultText,u as truncateAuditField};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{MCP_AUTHORIZATION_SERVER_ROUTE as e,MCP_PROTECTED_RESOURCE_ROUTE as t,PUBLIC_MCP_ROUTE as n}from"../constants.js";import{withPathPrefix as r}from"../../../../../shared/path-prefix.js";import{ANONYMOUS_VIEWER as i}from"../../../../../shared/types/auth.js";import{canAccessMcpFeature as a,isMcpContentProtected as o,isPublicEndpointServed as s,resolveMcpAccess as c}from"./config-gate.js";import{getBearerVerifier as l,getSessionIssuer as u}from"../../../../../server/auth/middleware.js";import{publicOrigin as d}from"../../../utils/request-origin.js";import{isAssistantAnonymousToken as f}from"../../../../../server/ask-ai/assistant-anonymous-token.js";import{CORS_ANY_ORIGIN as p,CORS_EXPOSE_CHALLENGE as m,SUPPORTED_MCP_SCOPES as h}from"./oauth/constants.js";function g(e){let t=/^Bearer\s+(\S+)$/i.exec((e??``).trim());return t?t[1]:null}function _(n,i){let a=i?[`error="${i.code}"`,`error_description="${i.description}"`]:[];return a.push(`resource_metadata="${n}${r(t)}"`,`scope="${h.join(` `)}"`,`authorization_uri="${n}${r(e)}"`),`Bearer ${a.join(`, `)}`}function v(e,t){return t?`${e}. A public endpoint that serves anonymous-accessible content is available at ${t}.`:e}function y(e,t,n){return new Response(JSON.stringify(t),{status:e,headers:{"Content-Type":`application/json`,"Cache-Control":`no-store`,...n}})}function b(e,t){return y(401,{error:`unauthorized`,message:v(`Authentication required`,t)},{"WWW-Authenticate":_(e),...m})}function x(e,t){return y(401,{error:`invalid_token`,message:v(`Invalid or expired token`,t)},{"WWW-Authenticate":_(e,{code:`invalid_token`,description:`Invalid or expired token`}),...m})}function S(){return y(403,{error:`forbidden`,message:`You do not have access to this MCP server`},{...p})}async function C(e){let{c:t,ctx:p}=e,m=e=>p.logger?.warn(e),h=c(p.config),_=o(h);if(e.forceAnonymous){let e=await p.withViewer(i);return a(h,e.request.teams,!1,m)?{kind:`allow`,ctx:e,isProtected:_}:{kind:`deny`,response:S()}}let v=e=>{let t=d(p.request);return{kind:`deny`,response:e(t,s(p.config,h)?`${t}${r(n)}`:void 0)}},y=p.request.viewer??i,C,w,T=p,E=g(t.req.header(`authorization`)),D=u(t)?.artifactSecret,O=E!==null&&D!==void 0&&await f(E,D);if(!_)w=O||E===null?void 0:E;else if(O)y=i,T=await p.withViewer(i);else if(E!==null){let e=await l(t)?.(E);if(!e)return v(x);y=e.viewer,C=e.claims,w=E,T=await p.withViewer(y)}else if(!y.isAuthenticated)return v(b);return a(h,T.request.teams,y.isAuthenticated,m)?{kind:`allow`,ctx:T,isProtected:_,accessToken:w,claims:C}:{kind:`deny`,response:S()}}export{C as authorizeMcpRequest,o as isMcpContentProtected,s as isPublicEndpointServed,g as readBearerToken,c as resolveMcpAccess};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{RBAC_TEAM_ANONYMOUS as e}from"../../../../../
|
|
1
|
+
import{RBAC_TEAM_ANONYMOUS as e}from"../../../../../shared/rbac/types.js";import{canView as t,parseRbacScope as n,resolveRole as r}from"../../../../../shared/rbac/engine.js";import{resolveViewerTeams as i}from"../../../../../shared/rbac/teams.js";import{ANONYMOUS_VIEWER as a}from"../../../../../shared/types/auth.js";function o(e){return!!e.mcp?.hide}function s(e){return e!==void 0&&(Object.keys(e),!0)}function c(i){if(!i||typeof i!=`object`||Object.keys(i).length===0)return!1;let a=n(i,`rbac`,()=>{});return!t(r(a,[e]))}function l(e){let t=e.access?.rbac;return{requiresLogin:e.access?.requiresLogin===!0,rbacConfigured:s(t),rbacDeniesAnonymous:Object.values(t?.content??{}).some(c)||c(t?.features?.mcp),featureScope:t?.features?.mcp}}function u(e){return e.requiresLogin||e.rbacDeniesAnonymous}function d(e,t){return!!e.mcp?.publicEndpoint&&u(t)&&p(t,i(a),!1)}function f(e){return d(e,l(e))}function p(e,i,a,o=()=>{}){return e.rbacConfigured?e.featureScope===void 0||t(r(n(e.featureScope,`features.mcp`,o),i)):!e.requiresLogin||a}export{p as canAccessMcpFeature,u as isMcpContentProtected,o as isMcpHidden,d as isPublicEndpointServed,f as isPublicEndpointServedFromConfig,l as resolveMcpAccess};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MCP_TOOLS_ENTITY_TYPE as e}from"../constants.js";import{publicOrigin as t}from"../../../utils/request-origin.js";import{errorMessage as n}from"../../../../../shared/utils/error-message.js";import{isSubprocessError as r}from"../../../../../server/subprocess/runner.js";import{ToolHandlerError as i}from"./tool-errors.js";import{fileURLToPath as a}from"node:url";import{parse as o}from"hono/utils/cookie";const s=a(import.meta.url);function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e){return`MCP tool "${e}" is not registered or its module does not export a handler for "${e}". Expected \`export default { '${e}': handler }\` or a single tool definition with \`description\` and \`execute\` as the default export.`}function u(e,t){if(c(e))return typeof e.execute==`function`&&typeof e.description==`string`?e:e[t]}const d=/* @__PURE__ */ new Set([`text`,`image`,`audio`,`resource`,`resource_link`]);function f(e){return c(e)&&Array.isArray(e.content)&&e.content.every(e=>c(e)&&d.has(e.type))}function p(e,t){if(f(t))return t;if(typeof t==`string`)return{content:[{type:`text`,text:t}]};let n;try{n=JSON.stringify(t)}catch(t){throw Error(`MCP tool "${e}" returned a value that cannot be serialized to JSON: ${S(t)}`)}if(n===void 0)throw Error(`MCP tool "${e}" returned an invalid result.`);return{content:[{type:`text`,text:n}]}}const m={readFile:async()=>{throw Error(`Project files are not available in this environment.`)}};async function h(e,t){let r=u((await t.loadModule(e.handlerModulePath)).default,e.toolName),i=typeof r==`function`?r:r?.execute;if(typeof i!=`function`)return{ok:!1,code:`no-handler-export`,message:l(e.toolName)};let a={...e.context,fs:m};try{if(e.mode===`isAvailable`){let e=typeof r==`function`?void 0:r?.isAvailable;return{ok:!0,output:!e||await e(a)}}let t=await i(e.args,a,e.extra);return{ok:!0,output:p(e.toolName,t)}}catch(e){return{ok:!1,code:`handler-error`,message:n(e),stack:e instanceof Error?e.stack:void 0}}}function g(e){let n=e.request.viewer;return{user:{teams:e.request.teams,claims:e.claims??{...n},email:n?.email,idpAccessToken:void 0,idpId:void 0,isAuthenticated:n?.isAuthenticated??!1},config:e.config,baseUrl:t(e.request),params:{},query:Object.fromEntries(new URL(e.request.url).searchParams),cookies:o(e.request.headers.cookie??``),products:Object.values(e.config.products??{}).map(e=>e.name),accessToken:e.accessToken,metadata:e.metadata}}function _(e,t,n){if(!c(e)||e.type!==`object`)return null;let r=`Invalid arguments for tool "${n}":`;if(!c(t))return`${r} expected an object.`;let i=Array.isArray(e.required)?e.required:[];for(let e of i)if(typeof e==`string`&&!(e in t))return`${r} missing required field "${e}".`;let a=c(e.properties)?e.properties:{};for(let[e,n]of Object.entries(t)){let t=a[e];if(c(t)){if(typeof t.type==`string`&&!v(n,t.type))return`${r} field "${e}" must be ${t.type}.`;if(Array.isArray(t.enum)&&!t.enum.includes(n))return`${r} field "${e}" must be one of ${JSON.stringify(t.enum)}.`}}return null}function v(e,t){switch(t){case`string`:return typeof e==`string`;case`number`:return typeof e==`number`&&Number.isFinite(e);case`integer`:return typeof e==`number`&&Number.isInteger(e);case`boolean`:return typeof e==`boolean`;case`object`:return c(e);case`array`:return Array.isArray(e);case`null`:return e===null;default:return!0}}function y(e,t,n,r,i){if(!t.subprocess)throw Error(`MCP tool "${e.toolName}" cannot run on this host: no subprocess.`);return t.subprocess.run({modulePath:s,exportName:`invokeCustomTool`,input:{handlerModulePath:t.subprocess.resolveContentModule(e.handlerFilePath),toolName:e.toolName,mode:n,args:r,context:g(t),extra:{sessionId:i?.sessionId,requestId:i?.mcpReq.id??t.requestId,_meta:i?.mcpReq._meta}},timeoutMs:3e4})}function b(e,t){return{schema:e,isAvailable:t.hasAvailabilityGate?async n=>{if(!n.subprocess)return!1;let r=n.isAvailableMemo?.get(e.name);if(r)return r;let i=(async()=>{try{let e=await y(t,n,`isAvailable`);return e.ok&&e.output===!0}catch(t){return n.logger?.warn(`MCP tool "${e.name}" isAvailable failed: ${S(t)}`),!1}})();return n.isAvailableMemo?.set(e.name,i),i}:void 0,async execute(n,r,a){let o=_(t.argsSchema,n,e.name);if(o)throw Error(o);let s=await y(t,r,`execute`,n,a);if(!s.ok){let e=new i(s.message);throw e.stack=s.stack??e.stack,e}return s.output}}}function x(e){let{declaration:t}=e;return b({name:t.name,title:t.title,description:t.description,schema:t.schema,outputSchema:t.outputSchema,annotations:t.annotations},{toolName:t.name,handlerFilePath:e.handler.filePath,argsSchema:t.schema,hasAvailabilityGate:!0})}function S(e){return r(e)?`${e.code}: ${e.message}`:n(e)}function C(e,t){if(!c(t))return{ok:!1,errors:["the default export must be an object with `description` and `execute` properties. Move shared helper code outside the `@mcp` folder."]};let{description:n,inputSchema:r,outputSchema:i,annotations:a,isAvailable:o,execute:s}=t,l=[];return(typeof n!=`string`||n.trim()===``)&&l.push("`description` must be a non-empty string."),typeof s!=`function`&&l.push("`execute` must be a function."),r!==void 0&&(c(r)?r.type!==void 0&&r.type!==`object`&&l.push('`inputSchema.type` must be "object" because MCP tool arguments are named.'):l.push("`inputSchema` must be a JSON Schema object.")),i!==void 0&&!c(i)&&l.push("`outputSchema` must be a JSON Schema object."),a!==void 0&&!c(a)&&l.push("`annotations` must be an object."),o!==void 0&&typeof o!=`function`&&l.push("`isAvailable` must be a function."),l.length>0||typeof n!=`string`?{ok:!1,errors:l}:{ok:!0,schema:{name:e,description:n,schema:Object.assign({type:`object`},r??{properties:{}}),outputSchema:i,annotations:a},hasAvailabilityGate:typeof o==`function`}}async function w(t){let n=[],r=[];for(let i of await t.entities.list({type:e})){let{name:e,sourcePath:a}=i.metadata,o=e=>r.push(`Invalid MCP tool file "${a}": ${e}`);if(t.reservedNames.has(e)){o(`the tool name "${e}" is already used by a built-in MCP tool. Rename the file.`);continue}let s;try{s=(await t.loadContentModule(a)).default}catch(e){o(`the file failed to load: ${S(e)}. Tool files must not have module-level side effects.`);continue}let c=C(e,s);if(!c.ok){o(c.errors.join(` `));continue}n.push({schema:c.schema,sourcePath:a,hasAvailabilityGate:c.hasAvailabilityGate})}return{tools:n,errors:r}}function T(e){return`MCP tool "${e.schema.name}" in ${e.sourcePath} declares no \`outputSchema\`. Add one that describes the returned value.`}const E=/* @__PURE__ */ new Set;function D(e,t){e&&!E.has(t)&&(E.add(t),e.warn(t))}async function O(e){let{loadContentModule:t,logger:n}=e;if(!t)return[];let{tools:r,errors:i}=await w({entities:e.entities,loadContentModule:t,reservedNames:e.reservedNames});for(let e of i)D(n,e);for(let e of r)e.schema.outputSchema===void 0&&D(n,T(e));return r.map(e=>b(e.schema,{toolName:e.schema.name,handlerFilePath:e.sourcePath,argsSchema:e.schema.schema,hasAvailabilityGate:e.hasAvailabilityGate}))}export{O as buildMcpFileTools,x as createCustomTool,h as invokeCustomTool,w as loadMcpFileTools,T as missingOutputSchemaWarning,C as validateToolDefinition};
|
|
1
|
+
import{MCP_TOOLS_ENTITY_TYPE as e}from"../constants.js";import{publicOrigin as t}from"../../../utils/request-origin.js";import{errorMessage as n}from"../../../../../shared/utils/error-message.js";import{isSubprocessError as r}from"../../../../../server/subprocess/runner.js";import{ToolHandlerError as i}from"./tool-errors.js";import{fileURLToPath as a}from"node:url";import{parse as o}from"hono/utils/cookie";const s=a(import.meta.url);function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e){return`MCP tool "${e}" is not registered or its module does not export a handler for "${e}". Expected \`export default { '${e}': handler }\` or a single tool definition with \`description\` and \`execute\` as the default export.`}function u(e,t){if(c(e))return typeof e.execute==`function`&&typeof e.description==`string`?e:e[t]}const d=/* @__PURE__ */ new Set([`text`,`image`,`audio`,`resource`,`resource_link`]);function f(e){return c(e)&&Array.isArray(e.content)&&e.content.every(e=>c(e)&&d.has(e.type))}function p(e,t){if(f(t))return t;if(typeof t==`string`)return{content:[{type:`text`,text:t}]};let n;try{n=JSON.stringify(t)}catch(t){throw Error(`MCP tool "${e}" returned a value that cannot be serialized to JSON: ${S(t)}`)}if(n===void 0)throw Error(`MCP tool "${e}" returned an invalid result.`);return{content:[{type:`text`,text:n}]}}const m={readFile:async()=>{throw Error(`Project files are not available in this environment.`)}};async function h(e,t){let r=u((await t.loadModule(e.handlerModulePath)).default,e.toolName),i=typeof r==`function`?r:r?.execute;if(typeof i!=`function`)return{ok:!1,code:`no-handler-export`,message:l(e.toolName)};let a={...e.context,fs:m};try{if(e.mode===`isAvailable`){let e=typeof r==`function`?void 0:r?.isAvailable;return{ok:!0,output:!e||await e(a)}}let t=await i(e.args,a,e.extra);return{ok:!0,output:p(e.toolName,t)}}catch(e){return{ok:!1,code:`handler-error`,message:n(e),stack:e instanceof Error?e.stack:void 0}}}function g(e){let n=e.request.viewer;return{user:{teams:e.request.teams,claims:e.claims??{...n},email:n?.email,idpAccessToken:void 0,idpId:void 0,isAuthenticated:n?.isAuthenticated??!1},config:e.config,baseUrl:t(e.request),params:{},query:Object.fromEntries(new URL(e.request.url).searchParams),cookies:o(e.request.headers.cookie??``),products:Object.values(e.config.products??{}).map(e=>e.name),accessToken:e.accessToken,metadata:e.metadata}}function _(e,t,n){if(!c(e)||e.type!==`object`)return null;let r=`Invalid arguments for tool "${n}":`;if(!c(t))return`${r} expected an object.`;let i=Array.isArray(e.required)?e.required:[];for(let e of i)if(typeof e==`string`&&!(e in t))return`${r} missing required field "${e}".`;let a=c(e.properties)?e.properties:{};for(let[e,n]of Object.entries(t)){let t=a[e];if(c(t)){if(typeof t.type==`string`&&!v(n,t.type))return`${r} field "${e}" must be ${t.type}.`;if(Array.isArray(t.enum)&&!t.enum.includes(n))return`${r} field "${e}" must be one of ${JSON.stringify(t.enum)}.`}}return null}function v(e,t){switch(t){case`string`:return typeof e==`string`;case`number`:return typeof e==`number`&&Number.isFinite(e);case`integer`:return typeof e==`number`&&Number.isInteger(e);case`boolean`:return typeof e==`boolean`;case`object`:return c(e);case`array`:return Array.isArray(e);case`null`:return e===null;default:return!0}}function y(e,t,n,r,i){if(!t.subprocess)throw Error(`MCP tool "${e.toolName}" cannot run on this host: no subprocess.`);return t.subprocess.run({modulePath:s,exportName:`invokeCustomTool`,input:{handlerModulePath:t.subprocess.resolveContentModule(e.handlerFilePath),toolName:e.toolName,mode:n,args:r,context:g(t),extra:{sessionId:i?.sessionId,requestId:i?.mcpReq.id??t.requestId,_meta:i?.mcpReq._meta}},reuse:!import.meta.env.DEV,timeoutMs:3e4})}function b(e,t){return{schema:e,isAvailable:t.hasAvailabilityGate?async n=>{if(!n.subprocess)return!1;let r=n.isAvailableMemo?.get(e.name);if(r)return r;let i=(async()=>{try{let e=await y(t,n,`isAvailable`);return e.ok&&e.output===!0}catch(t){return n.logger?.warn(`MCP tool "${e.name}" isAvailable failed: ${S(t)}`),!1}})();return n.isAvailableMemo?.set(e.name,i),i}:void 0,async execute(n,r,a){let o=_(t.argsSchema,n,e.name);if(o)throw Error(o);let s=await y(t,r,`execute`,n,a);if(!s.ok){let e=new i(s.message);throw e.stack=s.stack??e.stack,e}return s.output}}}function x(e){let{declaration:t}=e;return b({name:t.name,title:t.title,description:t.description,schema:t.schema,outputSchema:t.outputSchema,annotations:t.annotations},{toolName:t.name,handlerFilePath:e.handler.filePath,argsSchema:t.schema,hasAvailabilityGate:!0})}function S(e){return r(e)?`${e.code}: ${e.message}`:n(e)}function C(e,t){if(!c(t))return{ok:!1,errors:["the default export must be an object with `description` and `execute` properties. Move shared helper code outside the `@mcp` folder."]};let{description:n,inputSchema:r,outputSchema:i,annotations:a,isAvailable:o,execute:s}=t,l=[];return(typeof n!=`string`||n.trim()===``)&&l.push("`description` must be a non-empty string."),typeof s!=`function`&&l.push("`execute` must be a function."),r!==void 0&&(c(r)?r.type!==void 0&&r.type!==`object`&&l.push('`inputSchema.type` must be "object" because MCP tool arguments are named.'):l.push("`inputSchema` must be a JSON Schema object.")),i!==void 0&&!c(i)&&l.push("`outputSchema` must be a JSON Schema object."),a!==void 0&&!c(a)&&l.push("`annotations` must be an object."),o!==void 0&&typeof o!=`function`&&l.push("`isAvailable` must be a function."),l.length>0||typeof n!=`string`?{ok:!1,errors:l}:{ok:!0,schema:{name:e,description:n,schema:Object.assign({type:`object`},r??{properties:{}}),outputSchema:i,annotations:a},hasAvailabilityGate:typeof o==`function`}}async function w(t){let n=[],r=[];for(let i of await t.entities.list({type:e})){let{name:e,sourcePath:a}=i.metadata,o=e=>r.push(`Invalid MCP tool file "${a}": ${e}`);if(t.reservedNames.has(e)){o(`the tool name "${e}" is already used by a built-in MCP tool. Rename the file.`);continue}let s;try{s=(await t.loadContentModule(a)).default}catch(e){o(`the file failed to load: ${S(e)}. Tool files must not have module-level side effects.`);continue}let c=C(e,s);if(!c.ok){o(c.errors.join(` `));continue}n.push({schema:c.schema,sourcePath:a,hasAvailabilityGate:c.hasAvailabilityGate})}return{tools:n,errors:r}}function T(e){return`MCP tool "${e.schema.name}" in ${e.sourcePath} declares no \`outputSchema\`. Add one that describes the returned value.`}const E=/* @__PURE__ */ new Set;function D(e,t){e&&!E.has(t)&&(E.add(t),e.warn(t))}async function O(e){let{loadContentModule:t,logger:n}=e;if(!t)return[];let{tools:r,errors:i}=await w({entities:e.entities,loadContentModule:t,reservedNames:e.reservedNames});for(let e of i)D(n,e);for(let e of r)e.schema.outputSchema===void 0&&D(n,T(e));return r.map(e=>b(e.schema,{toolName:e.schema.name,handlerFilePath:e.sourcePath,argsSchema:e.schema.schema,hasAvailabilityGate:e.hasAvailabilityGate}))}export{O as buildMcpFileTools,x as createCustomTool,h as invokeCustomTool,w as loadMcpFileTools,T as missingOutputSchemaWarning,C as validateToolDefinition};
|
package/dist/content-layer/plugins/internal/mcp/server/gateway/__tests__/secret-store-fixture.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SecretStore as e}from"../secret-store.js";const t=`test-gateway-secret-seed`,n=new e(t);export{t as TEST_GATEWAY_SECRET_SEED,n as secretStore};
|
package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{MCP_CREDENTIALS_ROUTE as e}from"../../../constants.js";import{withPathPrefix as t}from"../../../../../../../shared/path-prefix.js";import{FORM_ACTIONS as n}from"./constants.js";import{secretTtlSeconds as r}from"../subject.js";import{credentialSchemesOf as i,schemeFieldName as a}from"./form-contract.js";import{ELICITATION_TTL_MS as o}from"../secret-store.js";import{ICONS as s,code as c,escapeHtml as l,siteHeader as u,targetTitle as d}from"./layout.js";const f=`form-error`,p=new Intl.DateTimeFormat(`en-GB`,{day:`numeric`,month:`short`,year:`numeric`,timeZone:`UTC`}),m={bearer:{title:`API token`,noun:`API token`,placeholder:`Paste your API token`},apiKey:{title:`API key`,noun:`API key`,placeholder:`Paste your API key`},cookie:{title:`Cookie`,noun:`cookie value`,placeholder:`Paste the cookie value`},oauth2ClientCredentials:{title:`OAuth2`,noun:`access token`,placeholder:`Paste an access token`},raw:{title:`Authorization header`,noun:`header value`,placeholder:`Bearer <token>`}};function h(r){let{site:a,target:c,token:p,error:m}=r,h=t(e),y=i(c),b=y.length>1,x=g(r,y),S=x.some(e=>e.isStored),C=b&&S,w=x.map(e=>b?v(e):_(e)).join(``),O=C?`<button class="text-danger" type="submit" form="remove-all">Remove all credentials</button>`:``,k=m?`<div class="banner" role="alert" id="${f}">${s.alert}<p>${l(m.message)}</p></div>`:``,j=c.subject.startsWith(`anon:`)?`<div class="banner warning">${s.warning}<p>This link is not tied to an account. The person who sent it to you can use the credentials that you save here. Continue only if you asked your AI client for this link at ${A(c.expiresAt-o)} UTC.</p></div>`:``;return{title:`Credentials for ${d(c)}`,body:`<div class="page">
|
|
2
2
|
<main class="card">
|
|
3
3
|
${u(a)}
|
|
4
4
|
<h1>${S?`Update`:`Add`} credentials for ${l(d(c))}</h1>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SystemRoute as e}from"../../../../../../
|
|
1
|
+
import{SystemRoute as e}from"../../../../../../shared/constants/system-routes.js";import{withPathPrefix as t}from"../../../../../../shared/path-prefix.js";import{FORM_ACTIONS as n}from"./credentials-page/constants.js";import{userSubject as r}from"./subject.js";import{rejectCredential as i}from"./credential-validation.js";import{credentialSchemesOf as a,schemeFieldName as o}from"./credentials-page/form-contract.js";import{SecretStore as s}from"./secret-store.js";import{htmlDocument as c}from"./credentials-page/layout.js";import{formPage as l}from"./credentials-page/form-page.js";import{declinedPage as u,expiredPage as d,otherAccountPage as f,outcomePage as p,signInPage as m}from"./credentials-page/outcome-pages.js";import{loadPageSite as h}from"./credentials-page/site-branding.js";import{buildAllowedOriginMatchers as g}from"./fetch/allowed-hosts.js";import{assertUrlAllowed as _}from"./fetch/ssrf-guard.js";import{getDefaultAgent as v,readCappedBody as y}from"./fetch/fetch-bridge.js";const b={"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'; img-src 'self'; form-action 'self'; frame-ancestors 'none'; base-uri 'none'`},x=/^bearer\s+/i,S=/^\d+$/;async function C(e,t){let{kv:r}=t,i=new s(t.gatewaySecretSeed);if(e.req.method===`GET`){let n=await h(t),a=e.req.query(`token`)??``,o=await i.peekElicitation(r,a);return o?R(o,t,n)??M({secretStore:i,kv:r,site:n,token:a,target:o},{},200):L(n)}if(e.req.method===`POST`){let o=await h(t),s=await e.req.formData(),c=F(s,`token`),l=await i.peekElicitation(r,c);if(!l)return L(o);let u=R(l,t,o);if(u)return u;let d={secretStore:i,kv:r,site:o,token:c,target:l,form:s,ctx:t};switch(F(s,`action`)){case n.remove:return O(d,k(l,F(s,`scheme`)));case n.removeAll:return O(d,a(l));case n.decline:return A(d);default:return w(d)}}return new Response(`Method Not Allowed`,{status:405,headers:{Allow:`GET, POST`}})}async function w(e){let{target:t,form:n,ctx:r}=e,i=a(t),s=i.map((e,t)=>F(n,o(`client_id`,t)).trim()),c=t=>M(e,{error:t,clientIds:s},400),l=T(i,n);if(`error`in l)return c(l.error);if(l.writes.length===0)return c(E(i));let u=[];for(let e of l.writes){if(e.kind!==`exchange`){u.push(e);continue}let n=await N(e.auth,e.clientId,e.clientSecret);if(!n.ok)return r.logger?.warn(`gateway oauth2 client_credentials exchange failed for ${t.api}: ${n.reason}`),c(D(i,e.schemeIndex,`client_id`,`We could not exchange those client credentials for a token. Check the client ID and secret, then try again.`));u.push({kind:`set`,scheme:e.scheme,secret:n.secret})}return j(e,u)}function T(e,t){let n=[];for(let[r,a]of e.entries()){let s=F(t,o(`secret`,r)).trim();if(s){let t=i(a.auth,s);if(t)return{error:D(e,r,`secret`,t)};n.push({kind:`set`,scheme:a.name,secret:z(a.auth,s)});continue}if(a.auth.kind!==`oauth2ClientCredentials`)continue;let c=F(t,o(`client_id`,r)).trim(),l=F(t,o(`client_secret`,r)).trim();if(c&&l)n.push({kind:`exchange`,scheme:a.name,schemeIndex:r,auth:a.auth,clientId:c,clientSecret:l});else if(c||l)return{error:D(e,r,c?`client_secret`:`client_id`,`Enter both the client ID and the client secret, or leave both blank.`)}}return{writes:n}}function E(e){return e.length>1?{message:`Fill in at least one credential before saving.`}:{message:e[0].auth.kind===`oauth2ClientCredentials`?`Enter an access token, or the client ID and the client secret, before saving.`:`Enter a value before saving.`,schemeIndex:0,field:`secret`}}function D(e,t,n,r){return{message:e.length>1?`${e[t].name}: ${r}`:r,schemeIndex:t,field:n}}async function O(e,t){let{secretStore:n,kv:r,target:i}=e,a=await n.getStoredSchemes(r,i.subject,i.api),o=t.filter(e=>a[e.name]).map(e=>({kind:`remove`,scheme:e.name}));return o.length===0?M(e,{error:{message:`No credential is stored there, so there is nothing to remove.`}},400):j(e,o)}function k(e,t){let n=S.test(t)?a(e)[Number(t)]:void 0;return n?[n]:[]}async function A({secretStore:e,kv:t,site:n,token:r}){return await e.consumeElicitation(t,r)?I(n,u(),200):L(n)}async function j({secretStore:e,kv:t,site:n,token:r},i){let a=await e.consumeElicitation(t,r);if(!a)return L(n);for(let n of i)n.kind===`remove`?await e.deleteSecret(t,a.subject,a.api,n.scheme):await e.setSecret(t,a.subject,a.api,n.scheme,n.secret);let o=await e.getStoredSchemes(t,a.subject,a.api),s={action:i.some(e=>e.kind===`set`)?`saved`:`removed`,schemes:i.map(e=>e.scheme),stored:Object.keys(o).sort()};return I(n,p(a,s),200)}async function M({secretStore:e,kv:t,site:n,token:r,target:i},a,o){let s=await e.getStoredSchemes(t,i.subject,i.api);return I(n,l({site:n,target:i,token:r,stored:s,...a}),o)}async function N(e,t,n){try{let r=g([{url:e.tokenUrl}]),a=_(e.tokenUrl,r),o=new AbortController,s=setTimeout(()=>o.abort(),3e4),c;try{c=await fetch(a,{method:`POST`,headers:{"content-type":`application/x-www-form-urlencoded`},body:new URLSearchParams({grant_type:`client_credentials`,client_id:t,client_secret:n}),redirect:`manual`,signal:o.signal,dispatcher:v()})}finally{clearTimeout(s)}if(!c.ok)return P(`token endpoint returned ${c.status}`);let l;try{l=await y(c,65536)}catch{return P(`token response exceeded the size cap`)}let u;try{u=JSON.parse(l)}catch{return P(`token response was not valid JSON`)}let d=typeof u==`object`&&u&&`access_token`in u?u.access_token:void 0,f=typeof d==`string`?d.trim():``;return f?i(e,f)?P(`token response had an access_token that cannot be sent in a header`):{ok:!0,secret:{header:`Authorization`,value:`Bearer ${f}`}}:P(`token response had no access_token`)}catch(e){return P(e instanceof Error?e.message:String(e))}}function P(e){return{ok:!1,reason:e}}function F(e,t){let n=e.get(t);return typeof n==`string`?n:``}function I(e,t,n){return new Response(c(t,e),{status:n,headers:b})}function L(e){return I(e,d(),404)}function R(n,i,a){if(!n.subject.startsWith(`user:`))return;let{viewer:o}=i.request,s=r(o);if(s===n.subject)return;if(s)return I(a,f(o?.email),403);let c=`${t(e.AuthIdpLogin)}?${new URLSearchParams({redirectTo:`/`})}`;return I(a,m(a.host,c),403)}function z(e,t){return e.kind===`apiKey`?{header:e.header,value:t}:e.kind===`cookie`?{header:`Cookie`,value:`${e.name}=${t}`}:e.kind===`bearer`||e.kind===`oauth2ClientCredentials`?{header:`Authorization`,value:B(t)}:{header:`Authorization`,value:t}}function B(e){return`Bearer ${e.replace(x,``)}`}export{C as serveCredentials};
|