@redocly/realm 0.135.0-next.4 → 0.135.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/CHANGELOG.md +70 -0
- package/dist/cli/build/analytics/collect-analytics.js +1 -1
- package/dist/cli/build/analytics/collectors/get-nested-configs-usage.js +1 -1
- package/dist/cli/telemetry/get-portal-config-stats.js +1 -1
- package/dist/cli/telemetry/index.js +1 -1
- package/dist/client/app/Sidebar/RequestAccessButton.js +2 -2
- package/dist/client/app/Sidebar/Sidebar.js +3 -3
- package/dist/client/app/Sidebar/helpers/filter-out-versioned-items.d.ts +5 -2
- package/dist/client/app/Sidebar/helpers/filter-out-versioned-items.js +1 -1
- package/dist/client/app/hooks/catalog/useCatalogClassic.js +1 -1
- package/dist/client/app/hooks/catalog/useCatalogFilter.js +1 -1
- package/dist/client/app/hooks/useRouteChangeTracker.js +1 -1
- package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.js +1 -1
- package/dist/client/app/markdoc/custom-components/openapi/openapi-response-sample.js +1 -1
- package/dist/client/app/markdoc/custom-components/openapi/replay-openapi.js +1 -1
- package/dist/client/app/pages/DevLogin/DevLogin.js +1 -1
- package/dist/client/app/search/useSearch.js +1 -1
- package/dist/client/providers/theme/ThemeDataProvider.js +1 -1
- package/dist/markdoc/helpers/get-operation/get-operation.js +1 -0
- package/dist/markdoc/helpers/get-operation/index.d.ts +4 -0
- package/dist/markdoc/helpers/get-operation/index.js +1 -0
- package/dist/markdoc/helpers/get-resolved-sample-code-block.d.ts +3 -0
- package/dist/markdoc/helpers/get-resolved-sample-code-block.js +5 -0
- package/dist/markdoc/tags/openapi-code-sample.js +1 -1
- package/dist/markdoc/tags/openapi-response-sample.js +1 -1
- package/dist/server/config/env-config.d.ts +2 -0
- package/dist/server/config/env-schema.d.ts +5 -0
- package/dist/server/config/env-schemas/feature-flags.d.ts +4 -0
- package/dist/server/config/env-schemas/feature-flags.js +1 -1
- package/dist/server/constants/common.d.ts +2 -0
- package/dist/server/constants/common.js +1 -1
- package/dist/server/constants/plugins/search.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/get-media-content-samples.d.ts +4 -0
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/get-media-content-samples.js +1 -0
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/load-openapi-bundle.d.ts +7 -0
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/load-openapi-bundle.js +1 -0
- package/dist/server/plugins/markdown/attribute-resolvers/index.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-code-samples.d.ts +4 -0
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-code-samples.js +1 -0
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-response-samples.d.ts +4 -0
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-response-samples.js +1 -0
- package/dist/server/plugins/markdown/attribute-resolvers/utils.d.ts +2 -0
- package/dist/server/plugins/markdown/attribute-resolvers/utils.js +1 -1
- package/dist/server/plugins/markdown/compiler.js +1 -1
- package/dist/server/plugins/markdown/extract-frontmatter.d.ts +6 -0
- package/dist/server/plugins/markdown/extract-frontmatter.js +1 -0
- package/dist/server/plugins/markdown/index.js +1 -1
- package/dist/server/plugins/markdown/markdoc/partials.js +1 -1
- package/dist/server/plugins/markdown/markdown-frontmatter-loader.js +1 -1
- package/dist/server/plugins/markdown/search/get-ai-search-documents.js +1 -1
- package/dist/server/plugins/markdown/search/search-resolver.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/codemode/build-execute-tool-description.d.ts +4 -0
- package/dist/server/plugins/mcp/docs-mcp/codemode/build-execute-tool-description.js +4 -0
- package/dist/server/plugins/mcp/docs-mcp/codemode/sandbox.d.ts +3 -0
- package/dist/server/plugins/mcp/docs-mcp/codemode/sandbox.js +7 -0
- package/dist/server/plugins/mcp/docs-mcp/codemode/types.d.ts +9 -0
- package/dist/server/plugins/mcp/docs-mcp/codemode/types.js +0 -0
- package/dist/server/plugins/mcp/docs-mcp/tool-schemas.d.ts +2 -0
- package/dist/server/plugins/mcp/docs-mcp/tool-schemas.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/core/search.d.ts +2 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/core/types.d.ts +6 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/core/types.js +0 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/core/whoami.d.ts +2 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/execute.d.ts +9 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/execute.js +1 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/get-graphql-schema.d.ts +2 -3
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/get-graphql-type-list.d.ts +2 -9
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/get-graphql-type.d.ts +2 -5
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/list-graphql-apis.d.ts +2 -5
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/types.d.ts +21 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/index.d.ts +11 -46
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-endpoint-info.d.ts +2 -6
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-endpoints.d.ts +2 -4
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-full-api-description.d.ts +2 -4
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-security-schemes.d.ts +2 -4
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/list-apis.d.ts +2 -5
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/types.d.ts +16 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/types.js +0 -0
- package/dist/server/plugins/mcp/handlers/errors.js +1 -1
- package/dist/server/plugins/mcp/index.js +1 -1
- package/dist/server/plugins/mcp/mode.d.ts +9 -0
- package/dist/server/plugins/mcp/mode.js +1 -0
- package/dist/server/plugins/mcp/servers/docs-server.js +1 -1
- package/dist/server/plugins/mcp/types.d.ts +1 -0
- package/dist/server/plugins/mcp/workers/execute-mcp-tool.js +1 -1
- package/dist/server/plugins/mcp/workers/mcp-tool-telemetry.d.ts +4 -0
- package/dist/server/plugins/mcp/workers/mcp-tool-telemetry.js +1 -0
- package/dist/server/plugins/scorecard-classic/get-scorecard-config.d.ts +11 -0
- package/dist/server/plugins/search/engines/typesense/index.js +1 -1
- package/dist/server/ssr/server-side-props/get-server-props-from-system-handlers.js +1 -1
- package/dist/server/store.d.ts +0 -2
- package/dist/server/store.js +1 -1
- package/dist/server/telemetry/index.js +1 -1
- package/dist/server/types/plugins/common.d.ts +3 -0
- package/dist/types/markdoc.d.ts +5 -0
- package/package.json +12 -11
- package/dist/client/app/markdoc/custom-components/openapi/get-operation/get-operation.js +0 -1
- package/dist/client/app/markdoc/custom-components/openapi/get-operation/index.d.ts +0 -4
- package/dist/client/app/markdoc/custom-components/openapi/get-operation/index.js +0 -1
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation-info-by-id.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation-info-by-id.js +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation-info-by-pointer.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation-info-by-pointer.js +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/index.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/index.js +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-identifier.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-identifier.js +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-info.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-info.js +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-parameters.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-parameters.js +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpMode } from '../types.js';
|
|
2
|
+
export declare function reportMcpToolCalled(tool: string, mode: McpMode, outputLength: number): void;
|
|
3
|
+
export declare function reportMcpToolError(tool: string, message: string, mode: McpMode, stack?: string): void;
|
|
4
|
+
//# sourceMappingURL=mcp-tool-telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{telemetry as p}from"../../../telemetry/index.js";import{McpServerType as t}from"../constants.js";const c={id:t.Docs,object:"mcpServer",uri:`urn:redocly:realm:mcp:server:${t.Docs}`,server_type:t.Docs};function m(e,r,o){p.sendMcpToolCalledMessage([{...c,tool:e,mode:r,output_length:o}])}function i(e,r,o,s=""){p.sendMcpErrorMessage([{...c,tool:e,message:r,stack:s,mode:o}])}export{m as reportMcpToolCalled,i as reportMcpToolError};
|
|
@@ -13,6 +13,17 @@ export declare const getScorecardConfig: (config: Partial<RedoclyConfig>) => {
|
|
|
13
13
|
[x: string]: unknown;
|
|
14
14
|
};
|
|
15
15
|
} | undefined;
|
|
16
|
+
arazzo1_1Decorators?: {
|
|
17
|
+
[x: string]: unknown;
|
|
18
|
+
} | undefined;
|
|
19
|
+
arazzo1_1Preprocessors?: {
|
|
20
|
+
[x: string]: unknown;
|
|
21
|
+
} | undefined;
|
|
22
|
+
arazzo1_1Rules?: {
|
|
23
|
+
[x: string]: string | {
|
|
24
|
+
[x: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
} | undefined;
|
|
16
27
|
async2Decorators?: {
|
|
17
28
|
[x: string]: unknown;
|
|
18
29
|
} | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{appendFile as g}from"node:fs/promises";import{existsSync as I}from"node:fs";import m from"node:path";import{Client as $}from"typesense";import{SEARCH_GROUP_FACET_FIELD as E,SEARCH_PRODUCT_FIELD as R,SEARCH_RBAC_FIELD as A,SEARCH_VERSION_FIELD as f}from"../../../../../constants/common.js";import{BASE_SEARCH_DOCUMENT as T,DISABLE_DEEP_LINK_IF_FIELDS_EXIST as O,HIGHLIGHTED_TEXT_MAX_LENGTH as b,SEARCH_DATA_EXPORT_FOLDER as F,SEARCH_DOCUMENT_METADATA_KEY as P,SEARCH_GROUP_LIMIT as N,SEARCH_MAX_FACET_VALUES as S,SEARCH_MAX_INMEMORY_DOCUMENTS_COUNT as C}from"../../../../constants/plugins/search.js";import{telemetryTraceStep as D}from"../../../../telemetry/helpers/trace-step.js";import{envConfig as p}from"../../../../config/env-config.js";import{ensureDir as d}from"../../../../utils/index.js";class U{#e=null;#
|
|
1
|
+
import{appendFile as g}from"node:fs/promises";import{existsSync as I}from"node:fs";import m from"node:path";import{Client as $}from"typesense";import{SEARCH_GROUP_FACET_FIELD as E,SEARCH_PRODUCT_FIELD as R,SEARCH_RBAC_FIELD as A,SEARCH_VERSION_FIELD as f}from"../../../../../constants/common.js";import{BASE_SEARCH_DOCUMENT as T,DISABLE_DEEP_LINK_IF_FIELDS_EXIST as O,HIGHLIGHTED_TEXT_MAX_LENGTH as b,SEARCH_DATA_EXPORT_FOLDER as F,SEARCH_DOCUMENT_METADATA_KEY as P,SEARCH_GROUP_LIMIT as N,SEARCH_MAX_FACET_VALUES as S,SEARCH_MAX_INMEMORY_DOCUMENTS_COUNT as C}from"../../../../constants/plugins/search.js";import{telemetryTraceStep as D}from"../../../../telemetry/helpers/trace-step.js";import{envConfig as p}from"../../../../config/env-config.js";import{ensureDir as d}from"../../../../utils/index.js";class U{#e=null;#r="";#t=[{name:"title",type:"string",facet:!1,optional:!0},{name:"text",type:"string",facet:!1,optional:!0},{name:"path",type:"string[]",facet:!1,optional:!0},{name:"isAdditionalOperation",type:"bool",facet:!1,optional:!0,queryable:!1},{name:"deprecated",type:"bool",facet:!1,optional:!0,queryable:!1},{name:"parameters",type:"object[]",facet:!1,optional:!0},{name:R,type:"string",facet:!0,optional:!0},{name:f,type:"object",facet:!0,optional:!0},{name:A,type:"string[]",facet:!0},{name:"metadata_curated",type:"bool",facet:!1,optional:!0,queryable:!1},{name:"metadata_keywords_excludes",type:"string[]",facet:!1,optional:!0,queryable:!1},{name:"metadata_keywords_includes",type:"string[]",facet:!1,optional:!0,queryable:!1}];#s=new Map;#n={ORGANIZATION_ID:p.ORGANIZATION_ID??"",PROJECT_ID:p.PROJECT_ID??"",TYPESENSE_API_URL:p.TYPESENSE_API_URL??"",TYPESENSE_API_KEY:p.TYPESENSE_API_KEY??""};constructor(){if(!p.isBuildMode){for(const[e,t]of Object.entries(this.#n))if(!t)throw new Error(`Cannot initialize search index. ${e} is not set`);this.#r=`${this.#n.ORGANIZATION_ID}_${this.#n.PROJECT_ID}_`,this.#e=new $({nodes:[{url:this.#n.TYPESENSE_API_URL}],apiKey:this.#n.TYPESENSE_API_KEY,connectionTimeoutSeconds:5})}}async initIndexSchema(e){this.#p(e)}async addDocuments(e,t){e.push(T);const{locale:n,outDir:o}=t,s=e.map(i=>{const r={...i},c=i[P];return c&&(c.curated&&(r.metadata_curated=c.curated),c.excludes&&(r.metadata_keywords_excludes=c.excludes),c.includes&&(r.metadata_keywords_includes=c.includes)),r}),a=this.#s.get(n)??[];this.#s.set(n,a.concat(s)),a.length+e.length>=C&&await this.exportDocuments(o)}async search(e,t){return await D("search",async n=>{const{query:o,locale:s,filter:a,loadMore:i}=e,r=this.#c(s),c={collection:r,q:o||"*",query_by:this.#l(),max_facet_values:S};if(n?.setAttribute("collectionName",r),n?.setAttribute("locale",s),this.#e)if(i){const{groupKey:l,offset:u}=i,h={offset:u,filter_by:this.#o(t,a),facet_by:"*"};return n?.setAttribute("isLoadMore",!0),n?.setAttribute("filter",h.filter_by),this.#u(await this.#e.collections(r).documents().search({...c,...h}),l)}else{const l={group_by:this.#m(),group_limit:N,filter_by:this.#o(t,a)};n?.setAttribute("groups",l.group_by),n?.setAttribute("filter",l.filter_by);const u=[l,...this.#y(t,a)];return this.#f(await this.#e?.multiSearch.perform({searches:u},c),a)}else return{facets:{},documents:{}}})}#u(e,t){const n={facets:{},documents:{[t]:[]}};if(e.hits&&e.hits.length)for(const o of e.hits)n.documents[t].push({document:this.#a(o),highlight:this.#i(o)});return n}#f(e,t){const n={facets:{},documents:{}};for(const o of this.#_(t))n.documents[o]=[];if("results"in e)for(const o of e.results){if(o.facet_counts&&o.facet_counts.length)for(const s of o.facet_counts)n.facets[s.field_name]=s.counts.map(a=>({value:a.value,count:a.count}));if(o.grouped_hits&&o.grouped_hits.length)for(const s of o.grouped_hits){const a=s.group_key[0],i=[];for(const r of s.hits)i.push({document:this.#a(r),highlight:this.#i(r)});n.documents[a]=i}}return n}#a(e){return this.#h(e)}#i(e){const t={},n=[];for(const[o,s]of Object.entries(e.highlight??{}))if(Array.isArray(s)){if(o==="path"){const a=s,i=[];for(const r of a)i.push(r.snippet);t.path=i}else if(o==="parameters"){const a=s;for(const i of a){let r=!1;for(const[c,l]of Object.entries(i))if(c!=="deepLink")if(Array.isArray(l))for(const u of l)u.matched_tokens?.length&&(r=!0);else l.matched_tokens?.length&&(r=!0);if(r){const c={name:i.name?.snippet||"",description:i.description?.snippet||"",place:i.place?.snippet||"",path:i.path?.map(l=>l?.snippet)||[]};t.parameters=[c];break}}}}else t[o]=s.snippet,n.push(o);for(const[o,s]of Object.entries(e.document))!n.includes(o)&&typeof s=="string"&&(t[o]=s.length>b?`${s.substring(0,b)}...`:s);return t.parameters||(t.parameters=[]),t}#h(e){let t;const n=Object.keys(e.highlight);for(const s of O)if(n.some(a=>a===s))return e.document;const o=e.highlight.parameters;if(o){for(const s of o)for(const[a,i]of Object.entries(s))if(a!=="deepLink"){if(Array.isArray(i)){for(const r of i)if(r.matched_tokens?.length){t=s.deepLink.snippet;break}}else if(i.matched_tokens?.length){t=s.deepLink.snippet;break}}}if(t){const s=t.split("#")[1];return{...e.document,url:`${e.document.url}#${s}`}}return e.document}async exportDocuments(e){const t='{"documents":[',n=d(m.join(e,F));for(const[o,s]of this.#s){if(s.length===0)continue;const a=d(m.join(n,`${o}.json`)),i=!I(a),r=JSON.stringify(s).substring(1).slice(0,-1),c=i?t+r:","+r;await g(a,c,{encoding:"utf8"}),this.#s.set(o,[])}}async exportIndexes(e){const t=d(m.join(e,F));for(const n of this.#s.keys()){const o=d(m.join(t,`${n}.json`)),s=`],"schemaFields":${JSON.stringify(this.#t)}}`;await g(o,s,{encoding:"utf8"})}}async import(e){}async countFacets(e,t){return await D("search.facets",async n=>{const{locale:o,query:s,facetQuery:a,filter:i,field:r}=e,c=this.#c(o),l={q:s||"*",query_by:this.#l(),facet_by:"*",facet_query:this.#d(a,r),filter_by:this.#o(t,i,r),max_facet_values:S};if(n?.setAttribute("collectionName",c),n?.setAttribute("query",l.q),n?.setAttribute("facetQuery",l.facet_query),n?.setAttribute("filter",l.filter_by),this.#e){const u={},h=await this.#e.collections(c).documents().search(l);if(h.facet_counts&&h.facet_counts.length)for(const _ of h.facet_counts)u[_.field_name]=_.counts.map(y=>({value:y.value,count:y.count,isCounterVisible:!!s||(i?.length||0)>0}));return u}else return{}})}#c(e){return`${this.#r}${e}`}#p(e){for(const[t,{queryable:n}]of e)this.#t.find(o=>o.name===t)||this.#t.push({queryable:n,name:t,type:"string",facet:!0,optional:!0})}#l(){return this.#t.filter(e=>e.facet?e.queryable:e.queryable!==!1).map(e=>e.name).join(",")}#m(){return this.#t.filter(e=>e.facet&&e.name===E).map(e=>e.name).join(",")}#o(e,t,n){const o=`${A}:[${e.teams.map(a=>`'${a}'`).join(", ")}]`;let s=`${f}.isDefault:true`;if(t&&t.length){const a=t.filter(r=>r.field!==n&&r.field!==f).map(r=>{const c=r.values.map(l=>`'${l}'`);return c.length?`${r.field}:=[${c.join(", ")}]`:""}).join(" && "),i=t.find(r=>r.field===f);if(i&&i.values.length&&i.values.length===2){const r=i.values[0],c=i.values[1],l=`(${f}.folderId:! ${r} && ${f}.isDefault:true)`,u=`(${f}.folderId: ${r} && ${f}.version:='${c}')`;s=`(${l} || ${u})`}return a?`${o} && ${a} && ${s}`:`${o} && ${s}`}else return`${o} && ${s}`}#d(e,t){return e&&t?`${t}:${e}`:""}#_(e){const t=[];if(e&&e.length)for(const n of e)n.field===E&&t.push(...n.values);return t}#y(e,t){const n=[],o=this.#t.filter(s=>s.facet);for(const s of o){const a={facet_by:s.name,filter_by:this.#o(e,t,s.name)};n.push(a)}return n}cleanupFacetValues(e){const t=e.getSearchFacets();t.forEach(n=>{n.values=[]}),e.setSearchFacets(t)}}export{U as Typesense};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{reporter as f}from"../../tools/notifiers/reporter.js";import{MARKDOC_PARTIALS_DATA_KEY as u}from"../../
|
|
1
|
+
import{reporter as f}from"../../tools/notifiers/reporter.js";import{MARKDOC_PARTIALS_DATA_KEY as u}from"../../constants/common.js";async function c(r,e,n,i,l,o,a){const m=!!e?.props?.compilationErrors?.length,s=r?.serverPropsGetterIds;return s?.length?Promise.all(s.map(async t=>{const p=l[t];if(!p){if(m)return{...e.props};await f.panicOnBuild(`Invalid server props getter id: "${t}" for route "${r.slug}"`)}return await(await p()).default({...r,...a},e,{variables:{...n,pageProps:i},partials:o.getGlobalConfig(u)},o)})||[]):[]}export{c as getServerPropsFromSystemHandlers};
|
package/dist/server/store.d.ts
CHANGED
|
@@ -9,8 +9,6 @@ import type { BundledDefinition as AsyncApiBundledDefinition } from './plugins/a
|
|
|
9
9
|
import type { BundledDefinition as GraphqlBundledDefinition } from './plugins/graphql-docs/graphql-doc-loader.js';
|
|
10
10
|
import type { SearchEngine } from './plugins/search/engines/search-engine.js';
|
|
11
11
|
import { KvService } from './persistence/kv/services/kv-service.js';
|
|
12
|
-
export declare const MARKDOC_PARTIALS_DATA_KEY = "markdown/partials";
|
|
13
|
-
export declare const MARKDOC_PARTIALS_DEPS_KEY = "markdown/partials-deps";
|
|
14
12
|
export declare const USER_DEFINED_API_FUNCTIONS_COUNTER_KEY = "userDefinedApiFunctions";
|
|
15
13
|
type LifecycleEventType = 'global-data-updated' | 'shared-data-updated' | 'routes-updated' | 'build-updated' | 'build-started' | 'errors-updated' | 'pages-updated';
|
|
16
14
|
export type StoreOptions = {
|
package/dist/server/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import b from"@markdoc/markdoc";import{getPathnameForLocale as A}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as g}from"../constants/common.js";import{DEFAULT_TITLE as T}from"./constants/common.js";import{GATED_MARKDOC_TAGS as D}from"./constants/entitlements.js";import{isObject as O}from"../utils/guards/is-object.js";import{mapObject as M}from"../utils/object/map-object.js";import{getValueDeep as R}from"../utils/object/get-value-deep.js";import{removeTrailingSlash as L}from"../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as h}from"../utils/path/normalize-route-slug.js";import{isLocalLink as y}from"../utils/path/is-local-link.js";import{reporter as w}from"./tools/notifiers/reporter.js";import{logger as u}from"./tools/notifiers/logger.js";import{sha1 as k}from"./utils/crypto/sha1.js";import{envConfig as _,setEnv as G}from"./config/env-config.js";import{KvService as F}from"./persistence/kv/services/kv-service.js";import{writeSharedData as B}from"./utils/index.js";import{renderComponents as I}from"./ssr/render.js";import{readStaticData as H,writeStaticData as N}from"./utils/static-data.js";import{parseAndResolveMarkdoc as V}from"./plugins/markdown/compiler.js";import{getMarkdocOptions as j}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as S}from"./entitlements/entitlements-provider.js";import{isL10nPath as q}from"./fs/utils/is-l10n-path.js";import{resolveGlobMapValue as K}from"./utils/globs.js";import{replaceEnvVariablesDeep as U}from"./utils/envs/replace-env-variables-deep.js";import{findRedirect as x}from"./utils/redirects/find-redirect.js";import{followRedirectChain as J}from"./utils/redirects/follow-redirect-chain.js";import{addWildcardRedirectToTree as W}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as $}from"../cli/telemetry/helpers/trace-step.js";const v={routesBySlug:"map",apiRoutes:"object",middleware:"object",routesByFsPath:"map",routesSharedData:"map",globalData:"object",config:"object",ssr:"object",searchFacets:"map",routesPartials:"map",mcpToolHandlers:"map"},m="markdown/partials",z="markdown/partials-deps",E="PLAN_GATES",Y=["OAUTH_CLIENT_ID","OAUTH_CLIENT_SECRET","ORGANIZATION_SLUG","ORGANIZATION_ID","ORG_ID"],Ae="userDefinedApiFunctions";class P{routesBySlug=new Map;replacedEnvVars={};unsetEnvVars=new Set;lifecycleContext;newRoutes=[];#e={};routesByFsPath=new Map;apiRoutes=[];middleware=[];routesSharedData=new Map;sharedDataDeps=new Map;sharedDataMarkdocComponents=new Map;routesDynamicComponents=new Map;routesPartials=new Map;ssr={preBodyTags:[],postBodyTags:[],headTags:[]};searchFacets=new Map;searchEngine;templates=new Map;browserPlugins=new Set;apiRoutesRequestHandlers=new Map;mcpToolHandlers=new Map;serverPropsGetters=new Map;pagePropsGetters=new Map;listeners=new Map;globalData={};#s=void 0;config={configFilePath:"",redirects:{},wildcardRedirectsTree:{},access:{rbac:{},requiresLogin:!1},directoryPermissions:{},devLogin:!1,ssoDirect:{}};#r;serverMode;serverOutDir;outdir;buildRevision=0;hasSitemap=!1;compilationErrors=[];#a;userCodeReady;#o=Promise.resolve();#i;#n=Promise.resolve();#c;#t=new Map;constructor({outdir:e,contentDir:s,serverMode:t=!1,serverOutDir:a}){this.#r=s,this.outdir=e,this.serverMode=t,this.serverOutDir=a,this.userCodeReady=new Promise(r=>{this.#a=r})}on(e,s){const t=this.listeners.get(e);t?t.add(s):this.listeners.set(e,new Set([s]))}queueEvent=(e,s,...t)=>{this.#t.set(e+String(s),[e,s,...t])};runListeners=(e,s,...t)=>{for(const a of this.listeners.get(e)||new Set)s?a(s,...t):a(...t)};startPluginsRun(){this.clear(),this.#o=new Promise(e=>{this.#i=e})}waitForPluginsLifecycle(){return Promise.all([this.#o,this.#n])}finishPluginsRun(){this.#i?.();for(const e of this.#t.values())this.runListeners(...e);this.#t.clear()}startEsbuildRun(){this.#n=new Promise(e=>{this.#c=e})}finishEsbuildRun(){this.#c?.()}get contentDir(){if(this.serverMode)throw new Error("contentDir should not be used in server mode");return this.#r}markUserCodeReady(){this.#a?.(!0)}async reloadMarkdocOptions(){await $("build.reload_markdoc_options",async()=>{const e=S.instance(),s=await j(this.serverOutDir),t=Object.fromEntries(Object.entries(s.tags).filter(([a])=>D[a]!=null?e.canAccessFeature(D[a]):!0));this.#s={...s,tags:t}})}get markdocOptions(){return{...this.#s,partials:this.getGlobalConfig(m),themeConfig:this.config.markdown}}setGlobalData=e=>{const s=this.globalData,t={...this.globalData,...e};this.globalData=t,JSON.stringify(t)!==JSON.stringify(s)&&this.queueEvent("global-data-updated",void 0,t)};getGlobalData=()=>this.globalData;getKv=async()=>F.getInstance({baseDbDir:this.serverOutDir});parseMarkdoc=async({input:e,context:s,deps:t,resource:a})=>{const{data:{info:r,ast:o},compoundHash:l}=await V(e,this.markdocOptions,{actions:this,context:s},a);for(const i of r.sharedDataDeps||[]){for(const n of t?.routeSlugs||[])this.addRouteSharedData(n,i,i);for(const n of t?.sharedDataIds||[]){const c=this.sharedDataDeps.get(n)||new Set;c.add(i),this.sharedDataDeps.set(n,c)}}for(const i of r.dynamicMarkdocComponents||[]){for(const n of t?.routeSlugs||[]){const c=this.routesDynamicComponents.get(n)||new Set;c.add(i),this.routesDynamicComponents.set(n,c)}for(const n of t?.sharedDataIds||[]){const c=this.sharedDataMarkdocComponents.get(n)||new Set;c.add(i),this.sharedDataMarkdocComponents.set(n,c)}}if(t?.routeSlugs&&r.partials?.length)for(const i of t.routeSlugs){const n=this.routesPartials.get(i)||[];for(const c of r.partials)n.includes(c)||n.push(c);this.routesPartials.set(i,n)}return{info:r,ast:o,compoundHash:l}};async loadOpenApiDefinitions(e){return(await e.cache.load(".","load-oas-docs")).data}async loadAsyncApiDefinitions(e){return(await e.cache.load(".","asyncapi-docs")).data}async loadGraphqlDefinitions(e){return(await e.cache.load(".","load-graphql-docs")).data}setSearchEngine(e){this.searchEngine=e}setSearchFacets=e=>{this.searchFacets=e};setGlobalConfig=e=>{const s=Object.keys(e);for(const o of s)for(const l in this.replacedEnvVars)if(l===o||l.startsWith(`${o}:`)){const i=l.split(":"),{error:n,value:c}=R(e,i);(n||c!==this.replacedEnvVars[l].replaced)&&delete this.replacedEnvVars[l]}const{resolvedObj:t,unsetEnvVars:a,replacedValues:r}=U(e);for(const o of a)this.unsetEnvVars.add(o);Object.assign(this.replacedEnvVars,r),Object.assign(this.config,t)};getConfig=()=>this.config;getGlobalConfig=e=>this.config[e];getSearchFacets=()=>this.searchFacets;addRedirect=(e,s,t={})=>{if(!S.instance().canAccessFeature("redirects")&&e!=="/")return;this.config.redirects||(this.config.redirects={});const o=h(e).toLowerCase();this.config.redirects[o]=s;const{trackOriginalSource:l=!0}=t,i=this.getGlobalConfig("originalRedirectSources");l&&Array.isArray(i)&&!i.includes(o)&&i.push(o),o.endsWith("*")&&W(this.config.wildcardRedirectsTree,o)};getRedirect=e=>{const s=h(e).toLowerCase(),t=x(s,this.config.redirects,this.config.wildcardRedirectsTree);if(!t)return null;if(y(t.to)){const a=h(t.to).toLowerCase();if(!a.endsWith("*")&&J(a,[s],this.config.redirects,this.config.wildcardRedirectsTree).type==="cycle")return null}return{to:t.to,type:t.type}};createSharedData=async(e,s,t)=>{if(t&&this.#e[e]===t)return e;const a=JSON.stringify(s),r=t??k(a);return this.#e[e]===r||(this.#e[e]=r,await B(e,a,this.outdir),this.queueEvent("shared-data-updated",e)),e};addRouteSharedData=(e,s,t)=>{const a=L(e),r=this.routesSharedData.get(a)||{};r[s]=t,this.routesSharedData.set(a,r),u.verbose(`Adding shared data to ${e}, ${s}, ${t}`)};getRouteSharedDataByFsPath=e=>{const s=this.routesByFsPath.get(e);return s?this.routesSharedData.get(s)||{}:{}};getPartialsForRoute=e=>{const s=this.getGlobalConfig(m)||{},t=this.routesPartials.get(e);if(!t||t.length===0)return{};const a=this.getGlobalConfig(z)||{},r=new Set(t),o=Array.from(t);for(let i=0;i<o.length;i++){const n=o[i],c=a[n]?.partials??[];for(const d of c)r.has(d)||(r.add(d),o.push(d))}const l={};for(const i of r)s[i]&&(l[i]=s[i]);return l};addRoute=e=>{const t={...K(e.fsPath,this.config.metadataGlobs),...e.metadata||{}};this.newRoutes.push({...e,metadata:t}),u.verbose("Created route %s",e.slug)};addRouteSharedDataToAllLocales=(e,s,t)=>{const a=[g,...this.lifecycleContext?.fs.localeFolders||[]].map(r=>({code:r,name:r}));for(const r of a){const o=A(e,g,r.code,a);this.addRouteSharedData(o,s,t)}};addApiRoute=e=>{this.apiRoutes.push(e),u.verbose("Created API route %s",e.slug)};addMcpTools=(e,s)=>{for(const t of s)this.mcpToolHandlers.set(t.name,{...t,importPath:e}),u.verbose("Created MCP tool %s",t.name)};getMcpTools=()=>Array.from(this.mcpToolHandlers.values());addMiddleware=e=>{this.middleware.push(e),u.verbose("Created middleware %s",e.id)};setResourceResponseHeaders=(e,s)=>{this.config.responseHeaders||(this.config.responseHeaders={});const t=new Set(s.map(o=>o.name.toLowerCase())),r=[...(this.config.responseHeaders[e]??[]).filter(o=>!t.has(o.name.toLowerCase())),...s];this.config.responseHeaders[e]=r};getRouteByFsPath=e=>{const s=this.routesByFsPath.get(e);return s?this.getRouteBySlug(s):void 0};getRouteBySlug=(e,s={})=>{const{followRedirect:t=!0}=s,a=this.getRedirect(e);return t&&a?this.routesBySlug.get(h(a.to)):this.routesBySlug.get(e)};hasRouteOrRedirectBySlug=e=>{if(this.routesBySlug.has(e))return!0;const s=this.getRedirect(e);if(!s)return!1;if(!y(s.to))return!0;const t=h(s.to);return this.routesBySlug.has(t)};getRoutesByTemplateId=e=>this.newRoutes.filter(s=>s.templateId===e);getAllRoutesForLocale=(e=g)=>{const s=Array.from(this.routesBySlug.values()),t=e.toLowerCase();return s.filter(a=>e===g?!q(a.fsPath):a.slug.startsWith(`/${t}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=e=>this.templates.get(e);getRequestHandler=e=>this.apiRoutesRequestHandlers.get(e);createTemplate=(e,s)=>(this.templates.set(e,s),e);addBrowserPlugin=e=>{this.browserPlugins.add(e)};createRequestHandler=(e,s)=>(this.apiRoutesRequestHandlers.set(e,s),e);clearRequestHandlersByPrefix=e=>{for(const s of this.apiRoutesRequestHandlers.keys())s.startsWith(e)&&this.apiRoutesRequestHandlers.delete(s)};registerServerPropsGetter=(e,s)=>(this.serverPropsGetters.set(e,s),e);registerPagePropsGetter=(e,s)=>{this.pagePropsGetters.set(e,s)};async writeRouteStaticData(e,s){const t=await this.resolveRouteStaticData(e,s,!1);t&&N(e.slug,t,this.outdir)}async resolveRouteStaticData(e,s,t){if(this.serverMode)return H(e.slug,this.outdir);const a={...this,contentDir:this.contentDir,parseMarkdoc:({input:c,context:d,resource:f})=>this.parseMarkdoc({input:c,context:d,deps:{routeSlugs:[e.slug]},resource:f})},r=await e.getStaticData?.(e,a)||{},o=new Set(this.routesDynamicComponents.get(e.slug)),l=this.routesSharedData.get(e.slug)||{};for(const c of Object.values(l)){const d=this.sharedDataMarkdocComponents.get(c);d&&d.forEach(p=>o.add(p));const f=this.sharedDataDeps.get(c);f&&f.forEach(p=>this.addRouteSharedData(e.slug,p,p))}const i=this.getGlobalConfig("seo"),n=r?.frontmatter||{};return{...r,frontmatter:{...n,seo:{...n?.seo,title:n?.seo?.title||await e.getNavText?.()}},props:{...r.props,dynamicMarkdocComponents:Array.from(o),metadata:{...r?.props?.metadata,...e.metadata},seo:{title:T,...i,...r.props?.seo},compilationErrors:this.compilationErrors},lastModified:t||!e.fsPath?null:await this.lifecycleContext?.fs.getLastModified(e.fsPath)}}addSsrComponents(e,s){if(!e?.length)return;const t=typeof e[0]=="string"?e.join(""):I(e);t&&(s==="head"?this.ssr.headTags.push(t):s==="preBody"?this.ssr.preBodyTags.push(t):this.ssr.postBodyTags.push(t))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.routesPartials.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};async toJson(){const e=[];for(const[t,a]of Object.entries(v))switch(a){case"map":const r=Array.from(this[t].entries());e.push([t,r]);break;case"object":t==="config"&&e.push([t,await this.getConfigWithEnvPlaceholders()]),e.push([t,this[t]]);break;default:throw new Error("Invalid format")}const s=Object.fromEntries(e);return s[E]=_.PLAN_GATES,s}static fromJson(e,s){const t=new P(s);for(const[r,o]of Object.entries(v))switch(o){case"map":t[r]=new Map(e[r]);break;case"object":if(r==="config"){t.setGlobalConfig(e[r]);break}t[r]=e[r];break;default:throw new Error("Invalid format")}t.config[m]=Z(t.config[m]||{});const a=e[E];return a&&G("PLAN_GATES",a),t}async getConfigWithEnvPlaceholders(){const e=JSON.parse(JSON.stringify(this.config));for(const s in this.replacedEnvVars){const{original:t}=this.replacedEnvVars[s],a=s.split(":"),r=a.pop(),{error:o,value:l}=R(e,a);if(o||!O(l)&&!Array.isArray(l)){await w.panicOnBuild(`Failed to replace env var with env name for ${s}`);continue}l[r]=t}return e}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const e=Array.from(this.unsetEnvVars).filter(t=>!Y.includes(t));if(e.length===0)return;const s=`Failed to resolve config. The following environment variables are not set: ${e.join(", ")}`;await w.panicOnBuildContentError(s)}}function Z(C){return M(C,e=>b.Ast.fromJSON(JSON.stringify(e)))}export{m as MARKDOC_PARTIALS_DATA_KEY,z as MARKDOC_PARTIALS_DEPS_KEY,P as Store,Ae as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
|
|
1
|
+
import b from"@markdoc/markdoc";import{getPathnameForLocale as A}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as g}from"../constants/common.js";import{DEFAULT_TITLE as T}from"./constants/common.js";import{GATED_MARKDOC_TAGS as D}from"./constants/entitlements.js";import{MARKDOC_PARTIALS_DATA_KEY as m,MARKDOC_PARTIALS_DEPS_KEY as O}from"./constants/common.js";import{isObject as M}from"../utils/guards/is-object.js";import{mapObject as L}from"../utils/object/map-object.js";import{getValueDeep as R}from"../utils/object/get-value-deep.js";import{removeTrailingSlash as k}from"../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as h}from"../utils/path/normalize-route-slug.js";import{isLocalLink as y}from"../utils/path/is-local-link.js";import{reporter as S}from"./tools/notifiers/reporter.js";import{logger as u}from"./tools/notifiers/logger.js";import{sha1 as _}from"./utils/crypto/sha1.js";import{envConfig as G,setEnv as F}from"./config/env-config.js";import{KvService as B}from"./persistence/kv/services/kv-service.js";import{writeSharedData as I}from"./utils/index.js";import{renderComponents as H}from"./ssr/render.js";import{readStaticData as N,writeStaticData as V}from"./utils/static-data.js";import{parseAndResolveMarkdoc as j}from"./plugins/markdown/compiler.js";import{getMarkdocOptions as q}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as w}from"./entitlements/entitlements-provider.js";import{isL10nPath as K}from"./fs/utils/is-l10n-path.js";import{resolveGlobMapValue as U}from"./utils/globs.js";import{replaceEnvVariablesDeep as J}from"./utils/envs/replace-env-variables-deep.js";import{findRedirect as x}from"./utils/redirects/find-redirect.js";import{followRedirectChain as W}from"./utils/redirects/follow-redirect-chain.js";import{addWildcardRedirectToTree as $}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as z}from"../cli/telemetry/helpers/trace-step.js";const v={routesBySlug:"map",apiRoutes:"object",middleware:"object",routesByFsPath:"map",routesSharedData:"map",globalData:"object",config:"object",ssr:"object",searchFacets:"map",routesPartials:"map",mcpToolHandlers:"map"},E="PLAN_GATES",Y=["OAUTH_CLIENT_ID","OAUTH_CLIENT_SECRET","ORGANIZATION_SLUG","ORGANIZATION_ID","ORG_ID"],Te="userDefinedApiFunctions";class P{routesBySlug=new Map;replacedEnvVars={};unsetEnvVars=new Set;lifecycleContext;newRoutes=[];#e={};routesByFsPath=new Map;apiRoutes=[];middleware=[];routesSharedData=new Map;sharedDataDeps=new Map;sharedDataMarkdocComponents=new Map;routesDynamicComponents=new Map;routesPartials=new Map;ssr={preBodyTags:[],postBodyTags:[],headTags:[]};searchFacets=new Map;searchEngine;templates=new Map;browserPlugins=new Set;apiRoutesRequestHandlers=new Map;mcpToolHandlers=new Map;serverPropsGetters=new Map;pagePropsGetters=new Map;listeners=new Map;globalData={};#s=void 0;config={configFilePath:"",redirects:{},wildcardRedirectsTree:{},access:{rbac:{},requiresLogin:!1},directoryPermissions:{},devLogin:!1,ssoDirect:{}};#r;serverMode;serverOutDir;outdir;buildRevision=0;hasSitemap=!1;compilationErrors=[];#a;userCodeReady;#o=Promise.resolve();#i;#n=Promise.resolve();#c;#t=new Map;constructor({outdir:e,contentDir:s,serverMode:t=!1,serverOutDir:a}){this.#r=s,this.outdir=e,this.serverMode=t,this.serverOutDir=a,this.userCodeReady=new Promise(r=>{this.#a=r})}on(e,s){const t=this.listeners.get(e);t?t.add(s):this.listeners.set(e,new Set([s]))}queueEvent=(e,s,...t)=>{this.#t.set(e+String(s),[e,s,...t])};runListeners=(e,s,...t)=>{for(const a of this.listeners.get(e)||new Set)s?a(s,...t):a(...t)};startPluginsRun(){this.clear(),this.#o=new Promise(e=>{this.#i=e})}waitForPluginsLifecycle(){return Promise.all([this.#o,this.#n])}finishPluginsRun(){this.#i?.();for(const e of this.#t.values())this.runListeners(...e);this.#t.clear()}startEsbuildRun(){this.#n=new Promise(e=>{this.#c=e})}finishEsbuildRun(){this.#c?.()}get contentDir(){if(this.serverMode)throw new Error("contentDir should not be used in server mode");return this.#r}markUserCodeReady(){this.#a?.(!0)}async reloadMarkdocOptions(){await z("build.reload_markdoc_options",async()=>{const e=w.instance(),s=await q(this.serverOutDir),t=Object.fromEntries(Object.entries(s.tags).filter(([a])=>D[a]!=null?e.canAccessFeature(D[a]):!0));this.#s={...s,tags:t}})}get markdocOptions(){return{...this.#s,partials:this.getGlobalConfig(m),themeConfig:this.config.markdown}}setGlobalData=e=>{const s=this.globalData,t={...this.globalData,...e};this.globalData=t,JSON.stringify(t)!==JSON.stringify(s)&&this.queueEvent("global-data-updated",void 0,t)};getGlobalData=()=>this.globalData;getKv=async()=>B.getInstance({baseDbDir:this.serverOutDir});parseMarkdoc=async({input:e,context:s,deps:t,resource:a})=>{const{data:{info:r,ast:o},compoundHash:l}=await j(e,this.markdocOptions,{actions:this,context:s},a);for(const i of r.sharedDataDeps||[]){for(const n of t?.routeSlugs||[])this.addRouteSharedData(n,i,i);for(const n of t?.sharedDataIds||[]){const c=this.sharedDataDeps.get(n)||new Set;c.add(i),this.sharedDataDeps.set(n,c)}}for(const i of r.dynamicMarkdocComponents||[]){for(const n of t?.routeSlugs||[]){const c=this.routesDynamicComponents.get(n)||new Set;c.add(i),this.routesDynamicComponents.set(n,c)}for(const n of t?.sharedDataIds||[]){const c=this.sharedDataMarkdocComponents.get(n)||new Set;c.add(i),this.sharedDataMarkdocComponents.set(n,c)}}if(t?.routeSlugs&&r.partials?.length)for(const i of t.routeSlugs){const n=this.routesPartials.get(i)||[];for(const c of r.partials)n.includes(c)||n.push(c);this.routesPartials.set(i,n)}return{info:r,ast:o,compoundHash:l}};async loadOpenApiDefinitions(e){return(await e.cache.load(".","load-oas-docs")).data}async loadAsyncApiDefinitions(e){return(await e.cache.load(".","asyncapi-docs")).data}async loadGraphqlDefinitions(e){return(await e.cache.load(".","load-graphql-docs")).data}setSearchEngine(e){this.searchEngine=e}setSearchFacets=e=>{this.searchFacets=e};setGlobalConfig=e=>{const s=Object.keys(e);for(const o of s)for(const l in this.replacedEnvVars)if(l===o||l.startsWith(`${o}:`)){const i=l.split(":"),{error:n,value:c}=R(e,i);(n||c!==this.replacedEnvVars[l].replaced)&&delete this.replacedEnvVars[l]}const{resolvedObj:t,unsetEnvVars:a,replacedValues:r}=J(e);for(const o of a)this.unsetEnvVars.add(o);Object.assign(this.replacedEnvVars,r),Object.assign(this.config,t)};getConfig=()=>this.config;getGlobalConfig=e=>this.config[e];getSearchFacets=()=>this.searchFacets;addRedirect=(e,s,t={})=>{if(!w.instance().canAccessFeature("redirects")&&e!=="/")return;this.config.redirects||(this.config.redirects={});const o=h(e).toLowerCase();this.config.redirects[o]=s;const{trackOriginalSource:l=!0}=t,i=this.getGlobalConfig("originalRedirectSources");l&&Array.isArray(i)&&!i.includes(o)&&i.push(o),o.endsWith("*")&&$(this.config.wildcardRedirectsTree,o)};getRedirect=e=>{const s=h(e).toLowerCase(),t=x(s,this.config.redirects,this.config.wildcardRedirectsTree);if(!t)return null;if(y(t.to)){const a=h(t.to).toLowerCase();if(!a.endsWith("*")&&W(a,[s],this.config.redirects,this.config.wildcardRedirectsTree).type==="cycle")return null}return{to:t.to,type:t.type}};createSharedData=async(e,s,t)=>{if(t&&this.#e[e]===t)return e;const a=JSON.stringify(s),r=t??_(a);return this.#e[e]===r||(this.#e[e]=r,await I(e,a,this.outdir),this.queueEvent("shared-data-updated",e)),e};addRouteSharedData=(e,s,t)=>{const a=k(e),r=this.routesSharedData.get(a)||{};r[s]=t,this.routesSharedData.set(a,r),u.verbose(`Adding shared data to ${e}, ${s}, ${t}`)};getRouteSharedDataByFsPath=e=>{const s=this.routesByFsPath.get(e);return s?this.routesSharedData.get(s)||{}:{}};getPartialsForRoute=e=>{const s=this.getGlobalConfig(m)||{},t=this.routesPartials.get(e);if(!t||t.length===0)return{};const a=this.getGlobalConfig(O)||{},r=new Set(t),o=Array.from(t);for(let i=0;i<o.length;i++){const n=o[i],c=a[n]?.partials??[];for(const d of c)r.has(d)||(r.add(d),o.push(d))}const l={};for(const i of r)s[i]&&(l[i]=s[i]);return l};addRoute=e=>{const t={...U(e.fsPath,this.config.metadataGlobs),...e.metadata||{}};this.newRoutes.push({...e,metadata:t}),u.verbose("Created route %s",e.slug)};addRouteSharedDataToAllLocales=(e,s,t)=>{const a=[g,...this.lifecycleContext?.fs.localeFolders||[]].map(r=>({code:r,name:r}));for(const r of a){const o=A(e,g,r.code,a);this.addRouteSharedData(o,s,t)}};addApiRoute=e=>{this.apiRoutes.push(e),u.verbose("Created API route %s",e.slug)};addMcpTools=(e,s)=>{for(const t of s)this.mcpToolHandlers.set(t.name,{...t,importPath:e}),u.verbose("Created MCP tool %s",t.name)};getMcpTools=()=>Array.from(this.mcpToolHandlers.values());addMiddleware=e=>{this.middleware.push(e),u.verbose("Created middleware %s",e.id)};setResourceResponseHeaders=(e,s)=>{this.config.responseHeaders||(this.config.responseHeaders={});const t=new Set(s.map(o=>o.name.toLowerCase())),r=[...(this.config.responseHeaders[e]??[]).filter(o=>!t.has(o.name.toLowerCase())),...s];this.config.responseHeaders[e]=r};getRouteByFsPath=e=>{const s=this.routesByFsPath.get(e);return s?this.getRouteBySlug(s):void 0};getRouteBySlug=(e,s={})=>{const{followRedirect:t=!0}=s,a=this.getRedirect(e);return t&&a?this.routesBySlug.get(h(a.to)):this.routesBySlug.get(e)};hasRouteOrRedirectBySlug=e=>{if(this.routesBySlug.has(e))return!0;const s=this.getRedirect(e);if(!s)return!1;if(!y(s.to))return!0;const t=h(s.to);return this.routesBySlug.has(t)};getRoutesByTemplateId=e=>this.newRoutes.filter(s=>s.templateId===e);getAllRoutesForLocale=(e=g)=>{const s=Array.from(this.routesBySlug.values()),t=e.toLowerCase();return s.filter(a=>e===g?!K(a.fsPath):a.slug.startsWith(`/${t}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=e=>this.templates.get(e);getRequestHandler=e=>this.apiRoutesRequestHandlers.get(e);createTemplate=(e,s)=>(this.templates.set(e,s),e);addBrowserPlugin=e=>{this.browserPlugins.add(e)};createRequestHandler=(e,s)=>(this.apiRoutesRequestHandlers.set(e,s),e);clearRequestHandlersByPrefix=e=>{for(const s of this.apiRoutesRequestHandlers.keys())s.startsWith(e)&&this.apiRoutesRequestHandlers.delete(s)};registerServerPropsGetter=(e,s)=>(this.serverPropsGetters.set(e,s),e);registerPagePropsGetter=(e,s)=>{this.pagePropsGetters.set(e,s)};async writeRouteStaticData(e,s){const t=await this.resolveRouteStaticData(e,s,!1);t&&V(e.slug,t,this.outdir)}async resolveRouteStaticData(e,s,t){if(this.serverMode)return N(e.slug,this.outdir);const a={...this,contentDir:this.contentDir,parseMarkdoc:({input:c,context:d,resource:f})=>this.parseMarkdoc({input:c,context:d,deps:{routeSlugs:[e.slug]},resource:f})},r=await e.getStaticData?.(e,a)||{},o=new Set(this.routesDynamicComponents.get(e.slug)),l=this.routesSharedData.get(e.slug)||{};for(const c of Object.values(l)){const d=this.sharedDataMarkdocComponents.get(c);d&&d.forEach(p=>o.add(p));const f=this.sharedDataDeps.get(c);f&&f.forEach(p=>this.addRouteSharedData(e.slug,p,p))}const i=this.getGlobalConfig("seo"),n=r?.frontmatter||{};return{...r,frontmatter:{...n,seo:{...n?.seo,title:n?.seo?.title||await e.getNavText?.()}},props:{...r.props,dynamicMarkdocComponents:Array.from(o),metadata:{...r?.props?.metadata,...e.metadata},seo:{title:T,...i,...r.props?.seo},compilationErrors:this.compilationErrors},lastModified:t||!e.fsPath?null:await this.lifecycleContext?.fs.getLastModified(e.fsPath)}}addSsrComponents(e,s){if(!e?.length)return;const t=typeof e[0]=="string"?e.join(""):H(e);t&&(s==="head"?this.ssr.headTags.push(t):s==="preBody"?this.ssr.preBodyTags.push(t):this.ssr.postBodyTags.push(t))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.routesPartials.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};async toJson(){const e=[];for(const[t,a]of Object.entries(v))switch(a){case"map":const r=Array.from(this[t].entries());e.push([t,r]);break;case"object":t==="config"&&e.push([t,await this.getConfigWithEnvPlaceholders()]),e.push([t,this[t]]);break;default:throw new Error("Invalid format")}const s=Object.fromEntries(e);return s[E]=G.PLAN_GATES,s}static fromJson(e,s){const t=new P(s);for(const[r,o]of Object.entries(v))switch(o){case"map":t[r]=new Map(e[r]);break;case"object":if(r==="config"){t.setGlobalConfig(e[r]);break}t[r]=e[r];break;default:throw new Error("Invalid format")}t.config[m]=Z(t.config[m]||{});const a=e[E];return a&&F("PLAN_GATES",a),t}async getConfigWithEnvPlaceholders(){const e=JSON.parse(JSON.stringify(this.config));for(const s in this.replacedEnvVars){const{original:t}=this.replacedEnvVars[s],a=s.split(":"),r=a.pop(),{error:o,value:l}=R(e,a);if(o||!M(l)&&!Array.isArray(l)){await S.panicOnBuild(`Failed to replace env var with env name for ${s}`);continue}l[r]=t}return e}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const e=Array.from(this.unsetEnvVars).filter(t=>!Y.includes(t));if(e.length===0)return;const s=`Failed to resolve config. The following environment variables are not set: ${e.join(", ")}`;await S.panicOnBuildContentError(s)}}function Z(C){return L(C,e=>b.Ast.fromJSON(JSON.stringify(e)))}export{P as Store,Te as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AsyncApiRealmAPI as o}from"@redocly/realm-asyncapi-sdk";import{envConfig as e}from"../config/env-config.js";import{PACKAGE_NAME as t}from"../../config/product-gates.js";import{OTEL_TRACES_DEV_URL as i,TELEMETRY_ENABLED as
|
|
1
|
+
import{AsyncApiRealmAPI as o}from"@redocly/realm-asyncapi-sdk";import{envConfig as e}from"../config/env-config.js";import{PACKAGE_NAME as t}from"../../config/product-gates.js";import{OTEL_TRACES_DEV_URL as i,TELEMETRY_ENABLED as l}from"../constants/common.js";class s extends o.Telemetry{constructor(){super(),this.updateCloudEventData(()=>({organizationId:e.ORGANIZATION_ID||"",organizationSlug:e.ORGANIZATION_SLUG||"",projectId:e.PROJECT_ID||"",projectSlug:e.PROJECT_SLUG||"",origin:"realmApi",actor:{id:"Anonymous",object:"user",uri:""},source:"urn:redocly:realm:api",env:e.REDOCLY_ENV}))}initialize(r=!1){this.init({otel:{serviceName:"realm-server",serviceVersion:`${t}@${e.REDOCLY_PORTAL_VERSION||""}`,collectorTraceUrl:r?i:e.OTEL_TRACES_URL||"https://otel.cloud.redocly.com/v1/traces",isProd:e.isProductionEnv,version:"1.0",tracerName:"server-telemetry",delayMillis:100},disabled:r?!e.TELEMETRY_DEV_DEBUG:!l})}}const A=new s;export{A as telemetry};
|
|
@@ -17,6 +17,7 @@ import type { Logger } from '../../tools/notifiers/logger.js';
|
|
|
17
17
|
import type { AiDocumentsStore } from '../../plugins/search/types';
|
|
18
18
|
import type { ParseMarkdocOpts } from '../../types/plugins/markdown';
|
|
19
19
|
import type { MarkdocConfigProps } from '../../plugins/markdown/compiler';
|
|
20
|
+
import type { ToolAnnotations } from '@redocly/mcp-typescript-sdk/types.js';
|
|
20
21
|
export type ResolveItemsOptions = {
|
|
21
22
|
groupCustomSidebars?: boolean;
|
|
22
23
|
locale?: string;
|
|
@@ -124,6 +125,8 @@ export type McpToolSchema = {
|
|
|
124
125
|
name: string;
|
|
125
126
|
description: string;
|
|
126
127
|
schema: Record<string, unknown>;
|
|
128
|
+
outputSchema?: Record<string, unknown>;
|
|
129
|
+
annotations?: ToolAnnotations;
|
|
127
130
|
};
|
|
128
131
|
export type McpToolRegistration = McpToolSchema & {
|
|
129
132
|
importPath: string;
|
package/dist/types/markdoc.d.ts
CHANGED
|
@@ -8,4 +8,9 @@ export type GetInnerContentFnOptions = {
|
|
|
8
8
|
renderTag?: RenderTagFn;
|
|
9
9
|
};
|
|
10
10
|
export type GetInnerContentFn = (children: (RenderableTreeNode | Node | Variable | Function)[], options?: GetInnerContentFnOptions) => string;
|
|
11
|
+
export type ResolvedSampleBlock = {
|
|
12
|
+
lang?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
source: string;
|
|
15
|
+
};
|
|
11
16
|
//# sourceMappingURL=markdoc.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/realm",
|
|
3
|
-
"version": "0.135.0-next.
|
|
3
|
+
"version": "0.135.0-next.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@dr.pogodin/react-helmet": "3.0.2",
|
|
19
19
|
"@emotion/is-prop-valid": "^1.3.1",
|
|
20
20
|
"@hono/zod-validator": "0.8.0",
|
|
21
|
+
"@jitl/quickjs-singlefile-mjs-release-sync": "0.32.0",
|
|
21
22
|
"@libsql/client": "0.17.3",
|
|
22
23
|
"@markdoc/markdoc": "0.5.2",
|
|
23
24
|
"@opentelemetry/api": "1.9.0",
|
|
@@ -31,12 +32,12 @@
|
|
|
31
32
|
"@opentelemetry/sdk-trace-web": "2.8.0",
|
|
32
33
|
"@opentelemetry/semantic-conventions": "1.40.0",
|
|
33
34
|
"@redocly/ajv": "8.18.0",
|
|
34
|
-
"@redocly/
|
|
35
|
+
"@redocly/mcp-typescript-sdk": "1.18.1",
|
|
36
|
+
"@redocly/openapi-core": "2.35.0",
|
|
35
37
|
"@shikijs/transformers": "3.21.0",
|
|
36
38
|
"@tanstack/react-query": "5.62.3",
|
|
37
39
|
"@tanstack/react-table": "8.21.3",
|
|
38
40
|
"@tanstack/react-virtual": "3.13.0",
|
|
39
|
-
"@redocly/mcp-typescript-sdk": "1.18.1",
|
|
40
41
|
"@wojtekmaj/react-datetimerange-picker": "6.0.0",
|
|
41
42
|
"@xmldom/xmldom": "0.9.10",
|
|
42
43
|
"ajv-formats": "^3.0.1",
|
|
@@ -54,7 +55,6 @@
|
|
|
54
55
|
"fflate": "0.7.4",
|
|
55
56
|
"flexsearch": "0.7.43",
|
|
56
57
|
"graphql": "16.12.0",
|
|
57
|
-
"gray-matter": "4.0.3",
|
|
58
58
|
"hono": "4.12.25",
|
|
59
59
|
"htmlparser2": "8.0.2",
|
|
60
60
|
"i18next": "22.4.15",
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
"os-browserify": "0.3.0",
|
|
70
70
|
"path-browserify": "1.0.1",
|
|
71
71
|
"picomatch": "2.3.2",
|
|
72
|
+
"quickjs-emscripten-core": "0.32.0",
|
|
72
73
|
"react": "^19.2.4",
|
|
73
74
|
"react-calendar": "5.1.0",
|
|
74
75
|
"react-date-picker": "11.0.0",
|
|
@@ -92,14 +93,14 @@
|
|
|
92
93
|
"xpath": "0.0.34",
|
|
93
94
|
"yaml-ast-parser": "0.0.43",
|
|
94
95
|
"zod": "^3.25.76",
|
|
95
|
-
"@redocly/asyncapi-docs": "1.12.0-next.
|
|
96
|
-
"@redocly/config": "0.49.
|
|
97
|
-
"@redocly/graphql-docs": "1.12.0-next.
|
|
98
|
-
"@redocly/openapi-docs": "3.23.0-next.
|
|
96
|
+
"@redocly/asyncapi-docs": "1.12.0-next.6",
|
|
97
|
+
"@redocly/config": "0.49.1",
|
|
98
|
+
"@redocly/graphql-docs": "1.12.0-next.6",
|
|
99
|
+
"@redocly/openapi-docs": "3.23.0-next.6",
|
|
99
100
|
"@redocly/portal-legacy-ui": "0.18.0-next.0",
|
|
100
|
-
"@redocly/portal-plugin-mock-server": "0.20.0-next.
|
|
101
|
-
"@redocly/realm-asyncapi-sdk": "0.13.0-next.
|
|
102
|
-
"@redocly/theme": "0.67.0-next.
|
|
101
|
+
"@redocly/portal-plugin-mock-server": "0.20.0-next.6",
|
|
102
|
+
"@redocly/realm-asyncapi-sdk": "0.13.0-next.4",
|
|
103
|
+
"@redocly/theme": "0.67.0-next.5"
|
|
103
104
|
},
|
|
104
105
|
"peerDependencies": {
|
|
105
106
|
"react": "^19.2.4",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{getOperation as E,getServerEnvName as l,normalizeOptions as x,OpenAPIParser as h,getTagOrGroup as q}from"@redocly/openapi-docs";import{getOperationInfoById as v}from"./get-operation-info-by-id";import{getOperationInfoByPointer as y}from"./get-operation-info-by-pointer";function M(s,{operationId:i,pointer:f},m,{exampleKey:r,mimeType:a,environments:p,environment:d,requestBody:g}){let o;if(i?o=v(s.definition,i):f&&(o=y(s.definition,f)),!o)return;const O=new h(s.definition,void 0,x(s.options)),u=o.tags?.[0],B=u?q("group",{name:u},void 0):void 0,n=E(O,o,B,m,"");if(a&&n.requestBody?.content?.mediaTypes&&(n.requestBody.content.mediaTypes=n.requestBody?.content?.mediaTypes.filter(e=>e.name===a)),r&&(n.requestBody?.content?.mediaTypes.forEach(e=>{if(!e.examples)return;const t=e.examples[r];e.examples=t?{[r]:t}:{}}),n.responses?.forEach(e=>{e.content?.mediaTypes?.forEach(t=>{if(!t.examples)return;const c=t.examples[r];t.examples=c?{[r]:c}:{}})})),g&&n.requestBody?.content?.mediaTypes.forEach(e=>{e.examples={}}),p&&(n.servers=n.servers.map(e=>{const t=p?.[l(e)];return t?{...e,url:t.server||e.url}:e})),d){const e=n.servers.filter(t=>d===l(t));n.servers=e.length?e:n.servers}return n}export{M as getOperation};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export*from"./get-operation-info-by-id";export*from"./get-operation-info-by-pointer";export*from"./get-operation";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|