@redocly/redoc-reef 0.141.0-next.14 → 0.141.0-next.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.d.ts +2 -1
  3. package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.js +1 -1
  4. package/dist/client/app/markdoc/custom-components/openapi/openapi-example.d.ts +1 -1
  5. package/dist/client/app/markdoc/custom-components/openapi/openapi-example.js +1 -1
  6. package/dist/client/app/markdoc/custom-components/openapi/openapi-response-sample.d.ts +2 -1
  7. package/dist/client/app/markdoc/custom-components/openapi/openapi-response-sample.js +1 -1
  8. package/dist/client/app/markdoc/custom-components/openapi/replay-openapi.d.ts +2 -1
  9. package/dist/client/app/markdoc/custom-components/openapi/replay-openapi.js +1 -1
  10. package/dist/client/app/markdoc/hooks/use-store.d.ts +12 -0
  11. package/dist/client/app/markdoc/hooks/use-store.js +1 -1
  12. package/dist/client/runtime/loader.js +1 -1
  13. package/dist/markdoc/tags/openapi-code-sample.js +1 -1
  14. package/dist/markdoc/tags/openapi-response-sample.js +1 -1
  15. package/dist/markdoc/tags/replay-openapi.js +1 -1
  16. package/dist/server/constants/plugins/search.d.ts +0 -1
  17. package/dist/server/constants/plugins/search.js +1 -1
  18. package/dist/server/esbuild/plugins/dependency-resolver.js +1 -1
  19. package/dist/server/plugins/api-docs/search/create-indexer.d.ts +1 -4
  20. package/dist/server/plugins/api-docs/search/create-indexer.js +1 -1
  21. package/dist/server/plugins/api-docs/search/get-ai-search-documents.js +23 -23
  22. package/dist/server/plugins/api-docs/search/search-resolver.js +1 -1
  23. package/dist/server/plugins/markdown/attribute-resolvers/helpers/load-openapi-bundle.d.ts +1 -0
  24. package/dist/server/plugins/markdown/attribute-resolvers/helpers/load-openapi-bundle.js +1 -1
  25. package/dist/server/plugins/markdown/attribute-resolvers/index.js +1 -1
  26. package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-operation.d.ts +10 -0
  27. package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-operation.js +1 -0
  28. package/dist/server/plugins/search/engines/flexsearch/search-index.js +1 -1
  29. package/dist/server/plugins/search/engines/typesense/index.js +1 -1
  30. package/dist/server/utils/crypto/sha-dir-path-short.js +1 -1
  31. package/package.json +3 -3
  32. package/dist/server/utils/search/highlight-text-for-search.d.ts +0 -3
  33. package/dist/server/utils/search/highlight-text-for-search.js +0 -1
  34. package/dist/server/utils/search/text-match.d.ts +0 -6
  35. package/dist/server/utils/search/text-match.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @redocly/redoc-reef
2
2
 
3
+ ## 0.141.0-next.15
4
+
5
+ ### Patch Changes
6
+
7
+ - 76b1e1997fa: Fixed an issue where the copy button showed the translated "Copied!" message instead of the `toasterText` passed to `CopyButton` or to the `copy` control of `CodeBlockControls`.
8
+ - 59e8b8343b8: Fixed an issue where OpenAPI Markdoc tags, such as `openapi-code-sample`, displayed an error to users without access to an RBAC-protected API description.
9
+ Users without access don't see the tags, and the rest of the page loads as usual.
10
+ - 9b2d7aa1c9e: Fixed an issue where the MCP server failed a tool call that took longer than 30 seconds for clients on MCP protocol version `2026-07-28`, such as the Claude connector.
11
+ - 8e9cfa19ca0: Fixed links in projects with a path prefix.
12
+ Pages whose paths only start with the prefix text, such as `/docs-v2` with the prefix `/docs`, no longer lose a part of their URLs.
13
+ A prefix of `/` or `.` means no prefix.
14
+ - 708e74e266a: Fixed an issue where custom React components that imported from `react-dom`, such as `createPortal`, failed to render.
15
+ - 212626dc290: Fixed an issue where the **Try it** console crashed when custom components passed a missing value, such as a signed-out user's token.
16
+ - Updated dependencies [fa021f82293]
17
+ - Updated dependencies [fa021f82293]
18
+ - Updated dependencies [76b1e1997fa]
19
+ - Updated dependencies [8e9cfa19ca0]
20
+ - Updated dependencies [4a0076adf72]
21
+ - @redocly/api-docs@0.6.0-next.15
22
+ - @redocly/theme@0.73.0-next.11
23
+
3
24
  ## 0.141.0-next.14
4
25
 
5
26
  ### Minor Changes
@@ -13,7 +13,8 @@ type OpenApiCodeSampleProps = {
13
13
  options?: Partial<RedocConfig>;
14
14
  environment?: string;
15
15
  environments?: Record<string, Record<string, string>>;
16
+ embedResolved?: boolean;
16
17
  };
17
- export declare function OpenApiCodeSample(props: OpenApiCodeSampleProps): React.JSX.Element;
18
+ export declare function OpenApiCodeSample(props: OpenApiCodeSampleProps): React.JSX.Element | null;
18
19
  export {};
19
20
  //# sourceMappingURL=openapi-code-sample.d.ts.map
@@ -1 +1 @@
1
- import*as o from"react";import{MarkdownAdapterProvider as h,StoreProvider as E,RedocCodeSample as A,appendUndeclaredConfigureParameters as C,excludeMockServers as m,markdocParser as M}from"@redocly/api-docs";import{ErrorMessage as q,OpenApiComponentWrap as w}from"../styled.elements";import{useStore as x}from"../../hooks/use-store";import{findCodeSamplePanel as I}from"../../utils/find-code-sample-panel.js";import{usePortalMarkdownAdapter as O}from"./use-markdown-adapter";function N(d){const{descriptionFile:c,operationId:s,pointer:p,exampleKey:l,mimeType:u,language:n,requestBody:f,parameters:e,options:a,environment:v,environments:y}=d,{store:r,error:S}=x(c),g=O(),k=o.useMemo(()=>({specType:"openapi",...r?.options,...a,codeSamples:{...r?.options?.codeSamples,...a?.codeSamples,...n&&{languages:[{lang:n}]}},markdownParser:M}),[n,a,r?.options]),i=o.useMemo(()=>{if(!r?.items?.length)return;const t=I(r.items,{pointer:p,sourceId:s});if(!t)return;const P=C({...t.source,servers:m(t.source.servers)},{...e?.path&&{path:e.path},...e?.query&&{query:e.query},...e?.header&&{headers:e.header},...e?.cookie&&{cookie:e.cookie}});return{...t,...t.servers&&{servers:m(t.servers)},source:P}},[r?.items,p,s,e]);return r?i?o.createElement(w,{"data-testid":"openapi-code-sample"},o.createElement(E,{options:k,apiStore:r.store},o.createElement(h,{value:g},o.createElement(A,{node:i,mimeType:u,exampleKey:l,requestBody:f,parameters:e,environment:v,environments:y})))):o.createElement("pre",{style:{color:"red"}},"Cannot find OpenAPI operation (use pointer or operationId)"):o.createElement(q,null,S)}export{N as OpenApiCodeSample};
1
+ import*as o from"react";import{MarkdownAdapterProvider as A,StoreProvider as C,RedocCodeSample as M,appendUndeclaredConfigureParameters as q,excludeMockServers as m,markdocParser as w}from"@redocly/api-docs";import{ErrorMessage as x,OpenApiComponentWrap as I}from"../styled.elements";import{isEmbedTargetWithheld as O,useStore as T}from"../../hooks/use-store";import{findCodeSamplePanel as R}from"../../utils/find-code-sample-panel.js";import{usePortalMarkdownAdapter as b}from"./use-markdown-adapter";function U(d){const{descriptionFile:c,operationId:a,pointer:p,exampleKey:l,mimeType:u,language:n,requestBody:f,parameters:e,options:s,environment:v,environments:y,embedResolved:S}=d,{store:r,error:g,restricted:h}=T(c),k=b(),E=o.useMemo(()=>({specType:"openapi",...r?.options,...s,codeSamples:{...r?.options?.codeSamples,...s?.codeSamples,...n&&{languages:[{lang:n}]}},markdownParser:w}),[n,s,r?.options]),i=o.useMemo(()=>{if(!r?.items?.length)return;const t=R(r.items,{pointer:p,sourceId:a});if(!t)return;const P=q({...t.source,servers:m(t.source.servers)},{...e?.path&&{path:e.path},...e?.query&&{query:e.query},...e?.header&&{headers:e.header},...e?.cookie&&{cookie:e.cookie}});return{...t,...t.servers&&{servers:m(t.servers)},source:P}},[r?.items,p,a,e]);return r?i?o.createElement(I,{"data-testid":"openapi-code-sample"},o.createElement(C,{options:E,apiStore:r.store},o.createElement(A,{value:k},o.createElement(M,{node:i,mimeType:u,exampleKey:l,requestBody:f,parameters:e,environment:v,environments:y})))):O(S)?null:o.createElement("pre",{style:{color:"red"}},"Cannot find OpenAPI operation (use pointer or operationId)"):h?null:o.createElement(x,null,g)}export{U as OpenApiCodeSample};
@@ -6,6 +6,6 @@ type OpenApiExampleProps = {
6
6
  mimeType?: string;
7
7
  options?: Partial<RedocConfig>;
8
8
  };
9
- export declare function OpenApiExample(props: OpenApiExampleProps): React.JSX.Element;
9
+ export declare function OpenApiExample(props: OpenApiExampleProps): React.JSX.Element | null;
10
10
  export {};
11
11
  //# sourceMappingURL=openapi-example.d.ts.map
@@ -1 +1 @@
1
- import*as e from"react";import{MarkdownAdapterProvider as c,RedocExample as l,StoreProvider as E,findExampleEncoding as f,markdocParser as u}from"@redocly/api-docs";import{ErrorMessage as k,OpenApiComponentWrap as x}from"../styled.elements";import{useStore as A}from"../../hooks/use-store";import{usePortalMarkdownAdapter as P}from"./use-markdown-adapter";function S(n){const{descriptionFile:i,pointer:o,options:p,mimeType:a}=n,{store:r,error:m}=A(i),s=P(),t=r?.items,d=e.useMemo(()=>t?f(t,o):void 0,[t,o]);return r?e.createElement(x,{"data-testid":"openapi-example"},e.createElement(E,{options:{...r.options,...p,markdownParser:u},apiStore:r.store},e.createElement(c,{value:s},e.createElement(l,{pointer:o,mimeType:a||"application/json",encoding:d})))):e.createElement(k,null,m)}export{S as OpenApiExample};
1
+ import*as e from"react";import{MarkdownAdapterProvider as l,RedocExample as u,StoreProvider as E,findExampleEncoding as f,markdocParser as k}from"@redocly/api-docs";import{ErrorMessage as x,OpenApiComponentWrap as A}from"../styled.elements";import{useStore as P}from"../../hooks/use-store";import{usePortalMarkdownAdapter as g}from"./use-markdown-adapter";function y(n){const{descriptionFile:i,pointer:o,options:p,mimeType:a}=n,{store:r,error:m,restricted:s}=P(i),d=g(),t=r?.items,c=e.useMemo(()=>t?f(t,o):void 0,[t,o]);return r?e.createElement(A,{"data-testid":"openapi-example"},e.createElement(E,{options:{...r.options,...p,markdownParser:k},apiStore:r.store},e.createElement(l,{value:d},e.createElement(u,{pointer:o,mimeType:a||"application/json",encoding:c})))):s?null:e.createElement(x,null,m)}export{y as OpenApiExample};
@@ -4,7 +4,8 @@ type OpenApiResponseSampleProps = {
4
4
  operationId?: string;
5
5
  pointer?: string;
6
6
  exampleKey?: string;
7
+ embedResolved?: boolean;
7
8
  };
8
- export declare function OpenApiResponseSample(props: OpenApiResponseSampleProps): React.JSX.Element;
9
+ export declare function OpenApiResponseSample(props: OpenApiResponseSampleProps): React.JSX.Element | null;
9
10
  export {};
10
11
  //# sourceMappingURL=openapi-response-sample.d.ts.map
@@ -1 +1 @@
1
- import*as e from"react";import{MarkdownAdapterProvider as c,RedocResponseSamples as f,StoreProvider as u,markdocParser as E}from"@redocly/api-docs";import{ErrorMessage as t,OpenApiComponentWrap as S}from"../styled.elements";import{useStore as P}from"../../hooks/use-store";import{findResponseSamples as h}from"../../utils/find-openapi-response-samples.js";import{usePortalMarkdownAdapter as k}from"./use-markdown-adapter";function w(n){const{descriptionFile:s,operationId:p,pointer:a,exampleKey:i}=n,{store:o,error:m}=P(s),d=k(),l=e.useMemo(()=>({...o?.options,specType:"openapi",markdownParser:E}),[o?.options]);if(!o)return e.createElement(t,null,m);const r=o.items?.length?h(o.items,{pointer:a,sourceId:p}):void 0;return r?.responseCodes.length?e.createElement(S,{"data-testid":"openapi-response-sample"},e.createElement(u,{options:l,apiStore:o.store},e.createElement(c,{value:d},e.createElement(f,{responseCodes:r.responseCodes,exampleKey:i,schemaId:r.schemaId})))):e.createElement(t,null,"Cannot find response samples for the given operation")}export{w as OpenApiResponseSample};
1
+ import*as e from"react";import{MarkdownAdapterProvider as f,RedocResponseSamples as E,StoreProvider as h,markdocParser as S}from"@redocly/api-docs";import{ErrorMessage as t,OpenApiComponentWrap as P}from"../styled.elements";import{isEmbedTargetWithheld as R,useStore as g}from"../../hooks/use-store";import{findResponseSamples as k}from"../../utils/find-openapi-response-samples.js";import{usePortalMarkdownAdapter as v}from"./use-markdown-adapter";function x(n){const{descriptionFile:s,operationId:p,pointer:a,exampleKey:i,embedResolved:m}=n,{store:r,error:d,restricted:l}=g(s),c=v(),u=e.useMemo(()=>({...r?.options,specType:"openapi",markdownParser:S}),[r?.options]);if(!r)return l?null:e.createElement(t,null,d);const o=r.items?.length?k(r.items,{pointer:a,sourceId:p}):void 0;return o?.responseCodes.length?e.createElement(P,{"data-testid":"openapi-response-sample"},e.createElement(h,{options:u,apiStore:r.store},e.createElement(f,{value:c},e.createElement(E,{responseCodes:o.responseCodes,exampleKey:i,schemaId:o.schemaId})))):R(m)?null:e.createElement(t,null,"Cannot find response samples for the given operation")}export{x as OpenApiResponseSample};
@@ -13,6 +13,7 @@ export type ReplayOpenApiProps = {
13
13
  environment?: string;
14
14
  environments?: Record<string, Record<string, string>>;
15
15
  hideOtherSecuritySchemes?: boolean;
16
+ embedResolved?: boolean;
16
17
  };
17
- export declare const ReplayOpenApi: (props: ReplayOpenApiProps) => React.JSX.Element;
18
+ export declare const ReplayOpenApi: (props: ReplayOpenApiProps) => React.JSX.Element | null;
18
19
  //# sourceMappingURL=replay-openapi.d.ts.map
@@ -1 +1 @@
1
- import o from"react";import{useLocation as g}from"react-router";import{EmbeddedReplay as k,StoreProvider as I,buildReplayPredefinedEnvValues as P,mergeEnvData as b,useOpenApiDefinition as h,withReplayPrefetch as R,markdocParser as w}from"@redocly/api-docs";import{Admonition as V}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{ErrorMessage as C,OpenApiComponentWrap as D}from"../styled.elements.js";import{useStore as v}from"../../hooks/use-store.js";import{getMockServerDocsConfig as y}from"../../../../templates/api-docs/mock-server-config.js";import{buildReplayOperationSourceMap as F}from"../../utils/build-replay-operation-source-map.js";import{findApiItem as $}from"../../utils/find-api-item.js";const x=R(function({descriptionFile:p,operationId:r,pointer:n,exampleKey:s,mimeType:e,requestBody:d,parameters:a,environment:i,environments:c,hideOtherSecuritySchemes:m}){const f=g(),{store:t,baseSlug:S}=v(p),u=h(),O=o.useMemo(()=>{if(!u)return{};const M=y(t?.options?.mockServer,S??""),A=P(u,M);return b(A,c??{})},[u,t?.options?.mockServer,S,c]),E=o.useMemo(()=>t?.items?F(t.items,{pointer:n,sourceId:r},{mimeType:e,exampleKey:s},t.store?.exampleStore??{}):new Map,[t?.items,t?.store?.exampleStore,n,r,e,s]);return o.createElement(k,{key:`${f.pathname}-${p}-${r||n}`,activeOperationId:r,fullOpenApi:u,pointer:n,operationSourceMap:E,hideOtherSecuritySchemes:m,predefinedEnvValues:O,allowedEnvironments:i?[i]:void 0,requestValues:{body:d,...a},activeMimeName:e})},{immediate:!0}),J=l=>{const{descriptionFile:p,operationId:r,pointer:n,options:s}=l,{store:e,error:d,baseSlug:a}=v(p),i=o.useMemo(()=>({...e?.options,...s}),[s,e?.options]),c=o.useMemo(()=>({specType:"openapi",...i,mockServer:y(i.mockServer,a??""),basePath:a,markdownParser:w,replayFeatures:e?.options.replayFeatures}),[i,a,e?.options.replayFeatures]),m=o.useMemo(()=>e?.items?.length?$(e.items,{pointer:n,sourceId:r}):void 0,[e?.items,n,r]);if(!e)return o.createElement(C,null,d);if(!m?.content?.meta?.pointer)return o.createElement(V,{type:"danger"},"Cannot find OpenAPI operation by operationId or pointer in ",p);const f=m.content.meta.pointer,t=m.content.meta.sourceId??"";return o.createElement(D,{"data-testid":"replay-openapi"},o.createElement(I,{apiStore:e.store,options:c},o.createElement(x,{...l,pointer:f,operationId:t})))};export{J as ReplayOpenApi};
1
+ import o from"react";import{useLocation as g}from"react-router";import{EmbeddedReplay as h,StoreProvider as A,buildReplayPredefinedEnvValues as k,mergeEnvData as I,useOpenApiDefinition as P,withReplayPrefetch as R,markdocParser as w}from"@redocly/api-docs";import{Admonition as V}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{ErrorMessage as C,OpenApiComponentWrap as D}from"../styled.elements.js";import{isEmbedTargetWithheld as F,useStore as v}from"../../hooks/use-store.js";import{getMockServerDocsConfig as y}from"../../../../templates/api-docs/mock-server-config.js";import{buildReplayOperationSourceMap as $}from"../../utils/build-replay-operation-source-map.js";import{findApiItem as x}from"../../utils/find-api-item.js";const W=R(function({descriptionFile:s,operationId:r,pointer:n,exampleKey:a,mimeType:m,requestBody:e,parameters:f,environment:l,environments:i,hideOtherSecuritySchemes:c}){const S=g(),{store:t,baseSlug:u}=v(s),p=P(),E=o.useMemo(()=>{if(!p)return{};const M=y(t?.options?.mockServer,u??""),b=k(p,M);return I(b,i??{})},[p,t?.options?.mockServer,u,i]),O=o.useMemo(()=>t?.items?$(t.items,{pointer:n,sourceId:r},{mimeType:m,exampleKey:a},t.store?.exampleStore??{}):new Map,[t?.items,t?.store?.exampleStore,n,r,m,a]);return o.createElement(h,{key:`${S.pathname}-${s}-${r||n}`,activeOperationId:r,fullOpenApi:p,pointer:n,operationSourceMap:O,hideOtherSecuritySchemes:c,predefinedEnvValues:E,allowedEnvironments:l?[l]:void 0,requestValues:{body:e,...f},activeMimeName:m})},{immediate:!0}),Q=d=>{const{descriptionFile:s,operationId:r,pointer:n,options:a,embedResolved:m}=d,{store:e,error:f,restricted:l,baseSlug:i}=v(s),c=o.useMemo(()=>({...e?.options,...a}),[a,e?.options]),S=o.useMemo(()=>({specType:"openapi",...c,mockServer:y(c.mockServer,i??""),basePath:i,markdownParser:w,replayFeatures:e?.options.replayFeatures}),[c,i,e?.options.replayFeatures]),t=o.useMemo(()=>e?.items?.length?x(e.items,{pointer:n,sourceId:r}):void 0,[e?.items,n,r]);if(!e)return l?null:o.createElement(C,null,f);if(!t?.content?.meta?.pointer)return F(m)?null:o.createElement(V,{type:"danger"},"Cannot find OpenAPI operation by operationId or pointer in ",s);const u=t.content.meta.pointer,p=t.content.meta.sourceId??"";return o.createElement(D,{"data-testid":"replay-openapi"},o.createElement(A,{apiStore:e.store,options:S},o.createElement(W,{...d,pointer:u,operationId:p})))};export{Q as ReplayOpenApi};
@@ -5,13 +5,25 @@ export type ApiDefinitionEmbedSharedData = {
5
5
  options: RawApiDocsOptions;
6
6
  baseSlug: string;
7
7
  };
8
+ /**
9
+ * The API description an embed tag reads. `restricted` tells that the page depends on the
10
+ * description and the access rules kept it from this viewer: in production the tag then renders
11
+ * nothing in place of its error.
12
+ */
8
13
  export declare function useStore(sharedDataKey?: string): {
9
14
  store: undefined;
10
15
  error: string;
16
+ restricted: boolean;
11
17
  baseSlug?: undefined;
12
18
  } | {
13
19
  store: ApiDefinitionEmbedSharedData;
14
20
  error: null;
15
21
  baseSlug: string;
22
+ restricted: boolean;
16
23
  };
24
+ /**
25
+ * True in production for a tag whose target the build found (`embedResolved`) while the delivered
26
+ * description lacks it: the access rules withheld it, and the tag renders nothing.
27
+ */
28
+ export declare function isEmbedTargetWithheld(embedResolved: boolean | undefined): boolean;
17
29
  //# sourceMappingURL=use-store.d.ts.map
@@ -1 +1 @@
1
- import{usePageSharedData as t}from"../../../providers/page-data/hooks";function n(r){const e=t(r||"");return e?{store:e,error:null,baseSlug:e.baseSlug}:{store:void 0,error:"Incorrect OpenAPI file path"}}export{n as useStore};
1
+ import{usePageData as s,usePageSharedData as o}from"../../../providers/page-data/hooks";function c(e){const r=o(e||""),t=s()?.sharedDataIds;return r?{store:r,error:null,baseSlug:r.baseSlug,restricted:!1}:{store:void 0,error:"Incorrect OpenAPI file path",restricted:process.env.NODE_ENV==="production"&&!!e&&Object.values(t||{}).includes(e)}}function i(e){return process.env.NODE_ENV==="production"&&e===!0}export{i as isEmbedTargetWithheld,c as useStore};
@@ -1 +1 @@
1
- import*as y from"react";import{withPathPrefix as L}from"@redocly/theme/core/utils";import{appendSearchParams as N}from"../utils";import{mapObject as x}from"../../utils/object/map-object.js";import{mapObjectAsync as $}from"../../utils/object/map-object-async.js";import{isFunction as z}from"../../utils/guards/is-function.js";import{isBrowser as I}from"../../utils/env/is-browser.js";import{GLOBAL_DATA_URL as G}from"../../constants/common.js";import{getClientPageDataUrl as V}from"../../utils/url/get-client-page-data-url.js";import{getSharedDataFetchUrl as F}from"../../utils/url/get-shared-data-fetch-url.js";import{normalizeRouteSlug as c}from"../../utils/path/normalize-route-slug.js";import{templates as R}from"./generated/templates.js";import{AsyncCache as E}from"./cache.js";import{fetch as D}from"./fetch.js";import{updateTranslations as B}from"../app/l10n";import{PageMissingDefaultExportError as b}from"./errors/page-missing-default-export-error.js";import{PageAsyncComponentError as K}from"./errors/page-async-component-error.js";import{ErrorDetails as q}from"../app/Error/ErrorDetails";const l=new E,m=new E;let g=null,d,W;const u=new Set;async function H(){const o=await(await D(L(G))).json();return d=o,o}async function v(o){const t=F(o,process.env.NODE_ENV==="development");return await(await D(t)).json()}async function J(o){return m.has(o)||m.set(o,v(o)),m.get(o)}function ht(){const[,o]=y.useReducer(t=>t+1,0);y.useEffect(()=>{process.env.NODE_ENV!=="production"&&(window.__redoclyRefresh=o)},[o])}function C(o,t){const e=t?new URLSearchParams(t).get("revision"):null,a=t?new URLSearchParams(t).get("version"):null;return e||a?`${o}?${e?`revision=${encodeURIComponent(e)}`:""}${a?`&version=${encodeURIComponent(a)}`:""}`.trim():o}class p{static markdocComponents={};static async updateTemplate(t,e,a){const n=c(t);R[a]=()=>e;const r=c(window.location.pathname);n===r&&(await this.load(t,!0),window.__redoclyRefresh())}static async update(t){const e=c(t),a=c(window.location.pathname);if(e!==a){l.delete(e);return}await this.load(t,!0),window.__redoclyRefresh()}static async updateSharedData(t){await m.set(t,v(t)),window.__redoclyRefresh()}static addGlobalDataListener(t){u.add(t)}static removeGlobalDataListener(t){u.delete(t)}static updateGlobalData(t){u.forEach(e=>e(t)),d=t,B(d.l10n)}static async tryLoad(t,e,a){try{return await this.load(t,e,a)}catch{return null}}static async loadDynamicMarkdocComponents(t){const e=this.markdocComponents?.[t];e&&z(e)&&Object.assign(this.markdocComponents,await e())}static async load(t,e,a){const n=c(t),r=C(n,a);if(!d&&!g&&(g=H()),!e&&l.has(r)){const f=await l.get(r);if(f)return f}const[i]=await Promise.all([l.set(r,s(a)),g]);return i;async function s(f){const _=V(n),T=N(_,f),O=await D(T),{templateId:P,sharedDataIds:w,props:S,userData:A,versions:j,redirectTo:k,isPublic:M}=await O.json(),[U]=await Promise.all([(async()=>p.loadTemplate(P))(),Promise.all((S.dynamicMarkdocComponents||[]).map(h=>p.loadDynamicMarkdocComponents(h))),w?$(w,h=>J(h)):Promise.resolve({})]);return{templateId:P,slug:n,sharedDataIds:w,redirectTo:k,props:S,Template:U,userData:A,versions:j,isPublic:M}}}static loadSync(t){const e=c(t),a=C(e,typeof window<"u"?window.location.search:void 0),n=l.tryGetSync(a);if(!n)return;const r=x(n.sharedDataIds,i=>m.getSync(i,"Data dependency not cached ahead of time: "+i));return{...n,sharedData:r}}static async prepare(t,e,a,n){const r=t.templateId;if(await Promise.all((t.props.dynamicMarkdocComponents||[]).map(s=>this.loadDynamicMarkdocComponents(s))),e)for(const s of Object.keys(e))m.setSync(s,e[s]);const i=await p.loadTemplate(r);if(i){const s=c(t.slug);l.setSync(s,{templateId:r,slug:s,props:t.props,sharedDataIds:t.sharedDataIds||{},Template:i,userData:t.userInfo,versions:t.versions,isPublic:t.isPublic})}d=a,W=n}static async loadTemplate(t){try{const e=await R[t](),a=/page\.tsx?$/.test(t);if(a&&!e.default)throw new b(t);const n=e.default,r=Y(n)?n:n?.default;return a&&X(r)?Q(t):r}catch(e){if(!(process.env.NODE_ENV==="development")||!I())throw e;return e instanceof b?()=>(window.location.reload(),null):(window.location.reload(),null)}}static clear(){u.clear(),m.clear(),l.clear()}}(typeof window<"u"?window:global).__LOADER=p;function Q(o){const t=new K(o),{name:e,message:a}=t;return function(){const r=!!globalThis.SSR_OMIT_SUSPENSE;if(process.env.NODE_ENV!=="development"||r)throw t;return y.createElement(q,{error:{name:e,message:a}})}}function X(o){return Object.prototype.toString.call(o)==="[object AsyncFunction]"}function Y(o){return typeof o=="function"||typeof o=="object"&&o!==null&&"$$typeof"in o}export{p as Loader,J as getSharedData,d as globalData,W as initLocale,ht as useRefresh};
1
+ import*as y from"react";import{withPathPrefix as L}from"@redocly/theme/core/utils";import{appendSearchParams as N}from"../utils";import{mapObject as x}from"../../utils/object/map-object.js";import{mapObjectAsync as I}from"../../utils/object/map-object-async.js";import{isFunction as $}from"../../utils/guards/is-function.js";import{isBrowser as z}from"../../utils/env/is-browser.js";import{GLOBAL_DATA_URL as G}from"../../constants/common.js";import{getClientPageDataUrl as V}from"../../utils/url/get-client-page-data-url.js";import{getSharedDataFetchUrl as F}from"../../utils/url/get-shared-data-fetch-url.js";import{normalizeRouteSlug as l}from"../../utils/path/normalize-route-slug.js";import{templates as R}from"./generated/templates.js";import{AsyncCache as b}from"./cache.js";import{fetch as D}from"./fetch.js";import{updateTranslations as B}from"../app/l10n";import{PageMissingDefaultExportError as E}from"./errors/page-missing-default-export-error.js";import{PageAsyncComponentError as K}from"./errors/page-async-component-error.js";import{ErrorDetails as q}from"../app/Error/ErrorDetails";const d=new b,i=new b;let P=null,m,W;const u=new Set;async function H(){const o=await(await D(L(G))).json();return m=o,o}async function v(o){const t=F(o,process.env.NODE_ENV==="development"),e=await D(t);if(e.status!==404)return e.json()}async function J(o){return i.has(o)||i.set(o,v(o)),i.get(o)}function ht(){const[,o]=y.useReducer(t=>t+1,0);y.useEffect(()=>{process.env.NODE_ENV!=="production"&&(window.__redoclyRefresh=o)},[o])}function C(o,t){const e=t?new URLSearchParams(t).get("revision"):null,n=t?new URLSearchParams(t).get("version"):null;return e||n?`${o}?${e?`revision=${encodeURIComponent(e)}`:""}${n?`&version=${encodeURIComponent(n)}`:""}`.trim():o}class p{static markdocComponents={};static async updateTemplate(t,e,n){const a=l(t);R[n]=()=>e;const r=l(window.location.pathname);a===r&&(await this.load(t,!0),window.__redoclyRefresh())}static async update(t){const e=l(t),n=l(window.location.pathname);if(e!==n){d.delete(e);return}await this.load(t,!0),window.__redoclyRefresh()}static async updateSharedData(t){await i.set(t,v(t)),window.__redoclyRefresh()}static addGlobalDataListener(t){u.add(t)}static removeGlobalDataListener(t){u.delete(t)}static updateGlobalData(t){u.forEach(e=>e(t)),m=t,B(m.l10n)}static async tryLoad(t,e,n){try{return await this.load(t,e,n)}catch{return null}}static async loadDynamicMarkdocComponents(t){const e=this.markdocComponents?.[t];e&&$(e)&&Object.assign(this.markdocComponents,await e())}static async load(t,e,n){const a=l(t),r=C(a,n);if(!m&&!P&&(P=H()),!e&&d.has(r)){const f=await d.get(r);if(f)return f}const[c]=await Promise.all([d.set(r,s(n)),P]);return c;async function s(f){const _=V(a),T=N(_,f),O=await D(T),{templateId:g,sharedDataIds:w,props:S,userData:j,versions:A,redirectTo:k,isPublic:M}=await O.json(),[U]=await Promise.all([(async()=>p.loadTemplate(g))(),Promise.all((S.dynamicMarkdocComponents||[]).map(h=>p.loadDynamicMarkdocComponents(h))),w?I(w,h=>J(h)):Promise.resolve({})]);return{templateId:g,slug:a,sharedDataIds:w,redirectTo:k,props:S,Template:U,userData:j,versions:A,isPublic:M}}}static loadSync(t){const e=l(t),n=C(e,typeof window<"u"?window.location.search:void 0),a=d.tryGetSync(n);if(!a)return;const r=x(a.sharedDataIds,c=>i.getSync(c,"Data dependency not cached ahead of time: "+c));return{...a,sharedData:r}}static async prepare(t,e,n,a){const r=t.templateId;if(await Promise.all((t.props.dynamicMarkdocComponents||[]).map(s=>this.loadDynamicMarkdocComponents(s))),e)for(const s of Object.keys(e))i.setSync(s,e[s]);for(const s of Object.values(t.sharedDataIds||{}))i.has(s)||i.setSync(s,void 0);const c=await p.loadTemplate(r);if(c){const s=l(t.slug);d.setSync(s,{templateId:r,slug:s,props:t.props,sharedDataIds:t.sharedDataIds||{},Template:c,userData:t.userInfo,versions:t.versions,isPublic:t.isPublic})}m=n,W=a}static async loadTemplate(t){try{const e=await R[t](),n=/page\.tsx?$/.test(t);if(n&&!e.default)throw new E(t);const a=e.default,r=Y(a)?a:a?.default;return n&&X(r)?Q(t):r}catch(e){if(!(process.env.NODE_ENV==="development")||!z())throw e;return e instanceof E?()=>(window.location.reload(),null):(window.location.reload(),null)}}static clear(){u.clear(),i.clear(),d.clear()}}(typeof window<"u"?window:global).__LOADER=p;function Q(o){const t=new K(o),{name:e,message:n}=t;return function(){const r=!!globalThis.SSR_OMIT_SUSPENSE;if(process.env.NODE_ENV!=="development"||r)throw t;return y.createElement(q,{error:{name:e,message:n}})}}function X(o){return Object.prototype.toString.call(o)==="[object AsyncFunction]"}function Y(o){return typeof o=="function"||typeof o=="object"&&o!==null&&"$$typeof"in o}export{p as Loader,J as getSharedData,m as globalData,W as initLocale,ht as useRefresh};
@@ -1 +1 @@
1
- import i from"@redocly/markdoc";import{DefinitionPath as o}from"../attributes/index.js";import{getNodeAttribute as a}from"../helpers/get-node-attribute.js";import{getResolvedSampleCodeBlock as p}from"../helpers/get-resolved-sample-code-block.js";const m={schema:{attributes:{descriptionFile:{type:o,required:!0},pointer:{type:String,required:!1},operationId:{type:String,required:!1},exampleKey:{type:String,required:!1},mimeType:{type:String,required:!1},language:{type:String,required:!1},parameters:{type:Object,default:{},required:!1},requestBody:{type:Object,required:!1},options:{type:Object,default:{},required:!1},environments:{type:Object,default:{},required:!1},environment:{type:String,required:!1},codeSamplesResolved:{type:Array,required:!1,resolver:"openapiCodeSamples"}},validate(r){const e=[];return r.attributes.pointer&&r.attributes.operationId&&e.push({id:"pointer-and-operationId-attributes-are-mutually-exclusive",level:"error",message:'The "pointer" and "operationId" attributes are mutually exclusive, you can only use one.'}),!r.attributes.pointer&&!r.attributes.operationId&&e.push({id:"pointer-or-operationId-attribute-required",level:"error",message:'This tag requires the "pointer" or "operationId" attribute to render correctly.'}),e},render:"OpenApiCodeSample",selfClosing:!0,dynamicComponentLib:"openapi",transform(r,e){const{codeSamplesResolved:s,...t}=r.transformAttributes(e);return new i.Tag("OpenApiCodeSample",t)},renderForLlms(r){const e=a(r,"codeSamplesResolved");return!Array.isArray(e)||e.length===0?"":e.map(p).join("")}},tagName:"openapi-code-sample"};export{m as openApiCodeSample};
1
+ import i from"@redocly/markdoc";import{DefinitionPath as o}from"../attributes/index.js";import{getNodeAttribute as a}from"../helpers/get-node-attribute.js";import{getResolvedSampleCodeBlock as p}from"../helpers/get-resolved-sample-code-block.js";const m={schema:{attributes:{descriptionFile:{type:o,required:!0},pointer:{type:String,required:!1},operationId:{type:String,required:!1},exampleKey:{type:String,required:!1},mimeType:{type:String,required:!1},language:{type:String,required:!1},parameters:{type:Object,default:{},required:!1},requestBody:{type:Object,required:!1},options:{type:Object,default:{},required:!1},environments:{type:Object,default:{},required:!1},environment:{type:String,required:!1},codeSamplesResolved:{type:Array,required:!1,resolver:"openapiCodeSamples"},embedResolved:{type:Boolean,required:!1,resolver:"openapiOperation"}},validate(r){const e=[];return r.attributes.pointer&&r.attributes.operationId&&e.push({id:"pointer-and-operationId-attributes-are-mutually-exclusive",level:"error",message:'The "pointer" and "operationId" attributes are mutually exclusive, you can only use one.'}),!r.attributes.pointer&&!r.attributes.operationId&&e.push({id:"pointer-or-operationId-attribute-required",level:"error",message:'This tag requires the "pointer" or "operationId" attribute to render correctly.'}),e},render:"OpenApiCodeSample",selfClosing:!0,dynamicComponentLib:"openapi",transform(r,e){const{codeSamplesResolved:s,...t}=r.transformAttributes(e);return new i.Tag("OpenApiCodeSample",t)},renderForLlms(r){const e=a(r,"codeSamplesResolved");return!Array.isArray(e)||e.length===0?"":e.map(p).join("")}},tagName:"openapi-code-sample"};export{m as openApiCodeSample};
@@ -1 +1 @@
1
- import o from"@redocly/markdoc";import{DefinitionPath as s}from"../attributes/index.js";import{getNodeAttribute as i}from"../helpers/get-node-attribute.js";import{getResolvedSampleCodeBlock as a}from"../helpers/get-resolved-sample-code-block.js";const d={schema:{attributes:{descriptionFile:{type:s,required:!0},pointer:{type:String,required:!1},operationId:{type:String,required:!1},exampleKey:{type:String,required:!1},responseSamplesResolved:{type:Array,required:!1,resolver:"openapiResponseSamples"}},validate(r){const e=[];return r.attributes.pointer&&r.attributes.operationId&&e.push({id:"pointer-and-operationId-attributes-are-mutually-exclusive",level:"error",message:'The "pointer" and "operationId" attributes are mutually exclusive, you can only use one.'}),!r.attributes.pointer&&!r.attributes.operationId&&e.push({id:"pointer-or-operationId-attribute-required",level:"error",message:'This tag requires the "pointer" or "operationId" attribute to render correctly.'}),e},render:"OpenApiResponseSample",selfClosing:!0,dynamicComponentLib:"openapi",transform(r,e){const{responseSamplesResolved:p,...t}=r.transformAttributes(e);return new o.Tag("OpenApiResponseSample",t)},renderForLlms(r){const e=i(r,"responseSamplesResolved");return!Array.isArray(e)||e.length===0?"":e.map(a).join("")}},tagName:"openapi-response-sample"};export{d as openApiResponseSample};
1
+ import o from"@redocly/markdoc";import{DefinitionPath as s}from"../attributes/index.js";import{getNodeAttribute as i}from"../helpers/get-node-attribute.js";import{getResolvedSampleCodeBlock as a}from"../helpers/get-resolved-sample-code-block.js";const d={schema:{attributes:{descriptionFile:{type:s,required:!0},pointer:{type:String,required:!1},operationId:{type:String,required:!1},exampleKey:{type:String,required:!1},responseSamplesResolved:{type:Array,required:!1,resolver:"openapiResponseSamples"},embedResolved:{type:Boolean,required:!1,resolver:"openapiOperation"}},validate(r){const e=[];return r.attributes.pointer&&r.attributes.operationId&&e.push({id:"pointer-and-operationId-attributes-are-mutually-exclusive",level:"error",message:'The "pointer" and "operationId" attributes are mutually exclusive, you can only use one.'}),!r.attributes.pointer&&!r.attributes.operationId&&e.push({id:"pointer-or-operationId-attribute-required",level:"error",message:'This tag requires the "pointer" or "operationId" attribute to render correctly.'}),e},render:"OpenApiResponseSample",selfClosing:!0,dynamicComponentLib:"openapi",transform(r,e){const{responseSamplesResolved:p,...t}=r.transformAttributes(e);return new o.Tag("OpenApiResponseSample",t)},renderForLlms(r){const e=i(r,"responseSamplesResolved");return!Array.isArray(e)||e.length===0?"":e.map(a).join("")}},tagName:"openapi-response-sample"};export{d as openApiResponseSample};
@@ -1 +1 @@
1
- import{DefinitionPath as t}from"../attributes/index.js";const a={schema:{attributes:{descriptionFile:{type:t,required:!0},pointer:{type:String,required:!1},operationId:{type:String,required:!1},exampleKey:{type:String,required:!1},mimeType:{type:String,required:!1},parameters:{type:Object,default:{},required:!1},requestBody:{type:Object,required:!1},options:{type:Object,default:{},required:!1},environments:{type:Object,default:{},required:!1},environment:{type:String,required:!1},hideOtherSecuritySchemes:{type:Boolean,required:!1}},validate(e){const r=[];return e.attributes.pointer&&e.attributes.operationId&&r.push({id:"pointer-and-operationId-attributes-are-mutually-exclusive",level:"error",message:'The "pointer" and "operationId" attributes are mutually exclusive, you can only use one.'}),!e.attributes.pointer&&!e.attributes.operationId&&r.push({id:"pointer-or-operationId-attribute-required",level:"error",message:'This tag requires the "pointer" or "operationId" attribute to render correctly.'}),r},render:"ReplayOpenApi",selfClosing:!0,dynamicComponentLib:"openapi"},tagName:"replay-openapi"};export{a as replayOpenApi};
1
+ import{DefinitionPath as t}from"../attributes/index.js";const a={schema:{attributes:{descriptionFile:{type:t,required:!0},pointer:{type:String,required:!1},operationId:{type:String,required:!1},exampleKey:{type:String,required:!1},mimeType:{type:String,required:!1},parameters:{type:Object,default:{},required:!1},requestBody:{type:Object,required:!1},options:{type:Object,default:{},required:!1},environments:{type:Object,default:{},required:!1},environment:{type:String,required:!1},hideOtherSecuritySchemes:{type:Boolean,required:!1},embedResolved:{type:Boolean,required:!1,resolver:"openapiOperation"}},validate(e){const r=[];return e.attributes.pointer&&e.attributes.operationId&&r.push({id:"pointer-and-operationId-attributes-are-mutually-exclusive",level:"error",message:'The "pointer" and "operationId" attributes are mutually exclusive, you can only use one.'}),!e.attributes.pointer&&!e.attributes.operationId&&r.push({id:"pointer-or-operationId-attribute-required",level:"error",message:'This tag requires the "pointer" or "operationId" attribute to render correctly.'}),r},render:"ReplayOpenApi",selfClosing:!0,dynamicComponentLib:"openapi"},tagName:"replay-openapi"};export{a as replayOpenApi};
@@ -6,7 +6,6 @@ export declare const SEARCH_LIMIT = 100;
6
6
  export declare const SEARCH_GROUP_LIMIT = 10;
7
7
  export declare const SEARCH_MAX_FACET_VALUES = 25;
8
8
  export declare const SEARCH_MAX_INMEMORY_DOCUMENTS_COUNT = 100;
9
- export declare const HIGHLIGHTED_TEXT_MAX_LENGTH = 150;
10
9
  export declare const AI_INDEX_EXPORT_FOLDER = "ai-search";
11
10
  export declare const AI_SEARCH_CHUNK_SIZE = 50;
12
11
  export declare const AI_SEARCH_DOCUMENT_CHUNK_SIZE = 250;
@@ -1 +1 @@
1
- const t=["title","text","path","httpMethod","httpPath","parameters[]:name","parameters[]:description","parameters[]:path","parameters[]:example","parameters[]:enum"],_="Documentation",e="API Reference",E="search",o=100,A=10,r=25,p=100,I=150,s="ai-search",a=50,n=250,R=Symbol("metadata"),S=!0,c=["title"];export{s as AI_INDEX_EXPORT_FOLDER,a as AI_SEARCH_CHUNK_SIZE,n as AI_SEARCH_DOCUMENT_CHUNK_SIZE,S as DEFAULT_AI_SEARCH_ENABLED,c as DISABLE_DEEP_LINK_IF_FIELDS_EXIST,I as HIGHLIGHTED_TEXT_MAX_LENGTH,E as SEARCH_DATA_EXPORT_FOLDER,R as SEARCH_DOCUMENT_METADATA_KEY,A as SEARCH_GROUP_LIMIT,e as SEARCH_GROUP_NAME_API,_ as SEARCH_GROUP_NAME_DOCUMENTATION,t as SEARCH_INDEX_FIELDS,o as SEARCH_LIMIT,r as SEARCH_MAX_FACET_VALUES,p as SEARCH_MAX_INMEMORY_DOCUMENTS_COUNT};
1
+ const t=["title","text","path","httpMethod","httpPath","parameters[]:name","parameters[]:description","parameters[]:path","parameters[]:example","parameters[]:enum"],e="Documentation",_="API Reference",E="search",o=100,A=10,r=25,p=100,a="ai-search",s=50,I=250,R=Symbol("metadata"),S=!0,n=["title"];export{a as AI_INDEX_EXPORT_FOLDER,s as AI_SEARCH_CHUNK_SIZE,I as AI_SEARCH_DOCUMENT_CHUNK_SIZE,S as DEFAULT_AI_SEARCH_ENABLED,n as DISABLE_DEEP_LINK_IF_FIELDS_EXIST,E as SEARCH_DATA_EXPORT_FOLDER,R as SEARCH_DOCUMENT_METADATA_KEY,A as SEARCH_GROUP_LIMIT,_ as SEARCH_GROUP_NAME_API,e as SEARCH_GROUP_NAME_DOCUMENTATION,t as SEARCH_INDEX_FIELDS,o as SEARCH_LIMIT,r as SEARCH_MAX_FACET_VALUES,p as SEARCH_MAX_INMEMORY_DOCUMENTS_COUNT};
@@ -1 +1 @@
1
- import{generatePortalResolverDir as u}from"./codegen/generate-resolver-dir.js";const l={"@markdoc/markdoc":"@redocly/markdoc"},v=()=>{const t={},a=u(),i=["react","styled-components",...Object.keys(l)];return{name:"dependency-resolver",setup(n){for(const o of i){const p=s(o),m=l[o]??o;n.onResolve({filter:p,namespace:"file"},async e=>{if(e.resolveDir==="")return;if(t[e.path]!==void 0)return t[e.path];const r=m+e.path.slice(o.length),c=!!n.initialOptions.external?.some(d=>s(d).test(r));return c?(t[e.path]=Promise.resolve({path:r,external:c}),t[e.path]):(t[e.path]=n.resolve(r,{kind:e.kind,resolveDir:a}),t[e.path])})}}}};function s(t){return new RegExp(`^${t}(/|$)`)}export{v as DependencyResolver};
1
+ import{generatePortalResolverDir as u}from"./codegen/generate-resolver-dir.js";const l={"@markdoc/markdoc":"@redocly/markdoc"},v=()=>{const t={},a=u(),i=["react","react-dom","styled-components",...Object.keys(l)];return{name:"dependency-resolver",setup(n){for(const o of i){const m=s(o),p=l[o]??o;n.onResolve({filter:m,namespace:"file"},async e=>{if(e.resolveDir==="")return;if(t[e.path]!==void 0)return t[e.path];const r=p+e.path.slice(o.length),c=!!n.initialOptions.external?.some(d=>s(d).test(r));return c?(t[e.path]=Promise.resolve({path:r,external:c}),t[e.path]):(t[e.path]=n.resolve(r,{kind:e.kind,resolveDir:a}),t[e.path])})}}}};function s(t){return new RegExp(`^${t}(/|$)`)}export{v as DependencyResolver};
@@ -1,5 +1,4 @@
1
- import { ApiDocsSearchIndexer } from '@redocly/api-docs';
2
- import type { ExampleEntry, GraphqlStoreMeta, SchemaEntry, SearchIndexerOptions } from '@redocly/api-docs';
1
+ import type { SearchIndexerOptions } from '@redocly/api-docs';
3
2
  import type { RenderTagFn } from '../../../../types/index.js';
4
3
  export type DescriptionFormatter = NonNullable<SearchIndexerOptions['formatDescription']>;
5
4
  /**
@@ -7,6 +6,4 @@ export type DescriptionFormatter = NonNullable<SearchIndexerOptions['formatDescr
7
6
  * llms.txt. Tags render through `renderTag` (their `renderForLlms`).
8
7
  */
9
8
  export declare function createLlmDescriptionFormatter(renderTag?: RenderTagFn): DescriptionFormatter;
10
- /** The shared api-docs indexer with Markdown descriptions — AI search documents and llms.txt need Markdown. */
11
- export declare function createApiDocsSearchIndexer(basePath: string, formatDescription: DescriptionFormatter, schemaStore?: Record<string, SchemaEntry>, document?: Record<string, unknown>, exampleStore?: Record<string, ExampleEntry>, graphqlMeta?: GraphqlStoreMeta): ApiDocsSearchIndexer;
12
9
  //# sourceMappingURL=create-indexer.d.ts.map
@@ -1 +1 @@
1
- import{ApiDocsSearchIndexer as a,markdocParser as f,parseMarkdown as p}from"@redocly/api-docs";import{toMarkdown as s}from"../../markdown/search/to-markdown.js";function u(i){const n=new Map;return r=>{if(typeof r=="string"&&!r.includes("{%"))return r;const e=typeof r=="string"?n.get(r):void 0;if(e!==void 0)return e;const t=p(r,{markdownParser:f}),o=!t||typeof t=="string"?t??"":s(Array.isArray(t)?t:[t],{renderTag:i}).trim();return typeof r=="string"&&n.set(r,o),o}}function d(i,n,r,e,t,o){return new a(i,r,e,{formatDescription:n,exampleStore:t,graphqlMeta:o})}export{d as createApiDocsSearchIndexer,u as createLlmDescriptionFormatter};
1
+ import{markdocParser as a,parseMarkdown as f}from"@redocly/api-docs";import{toMarkdown as m}from"../../markdown/search/to-markdown.js";function u(i){const n=new Map;return r=>{if(typeof r=="string"&&!r.includes("{%"))return r;const o=typeof r=="string"?n.get(r):void 0;if(o!==void 0)return o;const t=f(r,{markdownParser:a}),e=!t||typeof t=="string"?t??"":m(Array.isArray(t)?t:[t],{renderTag:i}).trim();return typeof r=="string"&&n.set(r,e),e}}export{u as createLlmDescriptionFormatter};
@@ -1,20 +1,20 @@
1
- import C from"node:path";import{REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{nodeTypes as y,contentType as A,isGraphqlFieldsNode as un,resolveGraphqlItemFields as dn}from"@redocly/api-docs";import{normalizeApiVersion as mn}from"../utils/normalize-api-version.js";import{replaceFileExtension as U}from"../utils/replace-file-extension.js";import{isResourcePubliclyAccessible as hn,canDownloadApiDefinition as yn,extractTeamsFromScopeItems as $n}from"../../../utils/rbac.js";import{getMarkdownCopyPath as gn}from"@redocly/theme/core/utils";import{PUBLIC_API_DEFINITIONS_FOLDER as Y}from"../../../constants/common.js";import{GRAPHQL_SPEC_SLUG as bn}from"../../../../constants/common.js";import{isPlainObject as $}from"../../../../utils/guards/is-plain-object.js";import{ANONYMOUS_AUTH_DETAILS as An}from"../../../constants/rbac.js";import{toMarkdown as w}from"../../markdown/search/to-markdown.js";import{createRenderTagFn as In}from"../../markdown/search/create-render-tag-fn.js";import{getLocaleFromRelativePath as On}from"../../../fs/utils/get-locale-from-relative-path.js";import{getBuildTranslateContext as Pn}from"../../../utils/l10n/get-build-translate-context.js";import{getPublicEnvVariables as Sn}from"../../../utils/envs/get-public-env-variables.js";import{llmsTxtLink as K}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as xn}from"../../search/utils.js";import{extractDocumentSearchFacets as Cn}from"./search-facets.js";import{createApiDocsSearchIndexer as vn,createLlmDescriptionFormatter as Ln}from"./create-indexer.js";function O(t,s){return s==="openapi"&&"openapi"in t}function X(t,s){return s==="asyncapi"&&"asyncapi"in t}function se({getBuild:t,metadata:s,document:r,specType:c,excludeFromSearch:n,basePath:o,getSearchFacets:e,markdocTags:l}){return async(i,f,m,a)=>{if(n)return;const{items:d,store:u}=t(),h={...a.markdocOptions?.tags,...l},{locale:on,translate:rn}=await Pn(i.slug,a.getGlobalData?.().l10n),P=In(h,on,rn,{env:Sn()}),L=a.getConfig(),R=On(i.fsPath),T=Ln(P),j=vn(o,T,u?.schemaStore,r,u?.exampleStore,u?.graphqlMeta),M=b=>{for(const p of b)j.addItem(p),p.items?.length&&M(p.items)};M(d);const sn=j.getResult(),V=new Map;for(const b of sn)V.set(b.url,b);const D=typeof s.title=="string"?s.title:void 0,F=mn(s.version),E=Cn(i.metadata||{},D,F,e),S=[],x=[],_=Rn(r,s),q=_?T(_):void 0,G=Tn(s,q,r,c,T),z=Dn(c,s,i.fsPath,L),W=new Map,cn=Z(d,L,W,P),ln=G+z+`
2
- `+cn,fn=G+z;x.push({title:D||"API Overview",description:q,content:ln,slug:o,fsPath:i.fsPath,includeInLLMsTxt:!0}),S.push({title:D||"API Overview",content:fn,url:o,fsPath:i.fsPath,locale:R,product:i.product?.name,facets:E});const an=r&&O(r,c)?r.security:void 0,k=b=>{for(const p of b){if(!p.content||!p.link){p.items?.length&&k(p.items);continue}const pn=V.get(p.link),J=p.content.contentType,Q=p[v],B=Q?$n(Q):void 0,H=B?.length?B:void 0;if(J===A.ITEM){const g=Un(p,r,c)??nn(p,pn,c,F,an,P,u);if(g){const I=p.label||"";x.push({title:I,description:void 0,content:g,slug:p.link,fsPath:i.fsPath,includeInLLMsTxt:!1}),S.push({title:I,content:g,url:p.link,fsPath:i.fsPath,locale:R,product:i.product?.name,facets:E,rbacTeams:H})}}else if(J===A.GROUP){const g=wn(p,L,c,W,P,u);if(g){const I=p.label||"";x.push({title:I,description:void 0,content:g.llmstxt,slug:p.link,fsPath:i.fsPath,includeInLLMsTxt:!1}),S.push({title:I,content:g.aiSearch,url:p.link,fsPath:i.fsPath,locale:R,product:i.product?.name,facets:E,rbacTeams:H})}}p.items?.length&&k(p.items)}};return k(d),{async getLLMsTxts(){return x},async getSearchDocuments(){return S}}}}function Rn(t,s){const r=$(t?.info)?t.info:void 0,c=$(r?.["x-metadata"])?r["x-metadata"]:{},o=(typeof c.description=="string"?c.description:void 0)??r?.description??s.description;return typeof o=="string"?o||void 0:o&&typeof o=="object"?o:void 0}function Tn(t,s,r,c,n){const o=typeof t.title=="string"?t.title:"",e=typeof t.summary=="string"?t.summary:"",l=typeof t.version=="string"?t.version:"";let i=o?`# ${o}
1
+ import C from"node:path";import{REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{ApiDocsSearchIndexer as an,nodeTypes as y,contentType as b,isGraphqlFieldsNode as pn,resolveGraphqlItemFields as un}from"@redocly/api-docs";import{normalizeApiVersion as dn}from"../utils/normalize-api-version.js";import{replaceFileExtension as w}from"../utils/replace-file-extension.js";import{isResourcePubliclyAccessible as mn,canDownloadApiDefinition as hn,extractTeamsFromScopeItems as yn}from"../../../utils/rbac.js";import{getMarkdownCopyPath as $n}from"@redocly/theme/core/utils";import{PUBLIC_API_DEFINITIONS_FOLDER as B}from"../../../constants/common.js";import{GRAPHQL_SPEC_SLUG as gn}from"../../../../constants/common.js";import{isPlainObject as $}from"../../../../utils/guards/is-plain-object.js";import{ANONYMOUS_AUTH_DETAILS as bn}from"../../../constants/rbac.js";import{toMarkdown as U}from"../../markdown/search/to-markdown.js";import{createRenderTagFn as An}from"../../markdown/search/create-render-tag-fn.js";import{getLocaleFromRelativePath as In}from"../../../fs/utils/get-locale-from-relative-path.js";import{getBuildTranslateContext as On}from"../../../utils/l10n/get-build-translate-context.js";import{getPublicEnvVariables as Pn}from"../../../utils/envs/get-public-env-variables.js";import{llmsTxtLink as H}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as Sn}from"../../search/utils.js";import{extractDocumentSearchFacets as xn}from"./search-facets.js";import{createLlmDescriptionFormatter as Cn}from"./create-indexer.js";function I(t,s){return s==="openapi"&&"openapi"in t}function Y(t,s){return s==="asyncapi"&&"asyncapi"in t}function re({getBuild:t,metadata:s,document:r,specType:c,excludeFromSearch:n,basePath:o,getSearchFacets:e,markdocTags:l}){return async(i,f,m,a)=>{if(n)return;const{items:d,store:u}=t(),h={...a.markdocOptions?.tags,...l},{locale:en,translate:tn}=await On(i.slug,a.getGlobalData?.().l10n),O=An(h,en,tn,{env:Pn()}),L=a.getConfig(),T=In(i.fsPath),D=Cn(O),on=new an({basePath:o,store:u,document:r,formatDescription:D}).documents(d),j=new Map;for(const x of on)j.set(x.url,x);const E=typeof s.title=="string"?s.title:void 0,M=dn(s.version),R=xn(i.metadata||{},E,M,e),P=[],S=[],V=vn(r,s),F=V?D(V):void 0,_=Ln(s,F,r,c,D),q=Tn(c,s,i.fsPath,L),G=new Map,rn=K(d,L,G,O),sn=_+q+`
2
+ `+rn,cn=_+q;S.push({title:E||"API Overview",description:F,content:sn,slug:o,fsPath:i.fsPath,includeInLLMsTxt:!0}),P.push({title:E||"API Overview",content:cn,url:o,fsPath:i.fsPath,locale:T,product:i.product?.name,facets:R});const ln=r&&I(r,c)?r.security:void 0,k=x=>{for(const p of x){if(!p.content||!p.link){p.items?.length&&k(p.items);continue}const fn=j.get(p.link),z=p.content.contentType,W=p[v],J=W?yn(W):void 0,Q=J?.length?J:void 0;if(z===b.ITEM){const g=Rn(p,r,c)??X(p,fn,c,M,ln,O,u);if(g){const A=p.label||"";S.push({title:A,description:void 0,content:g,slug:p.link,fsPath:i.fsPath,includeInLLMsTxt:!1}),P.push({title:A,content:g,url:p.link,fsPath:i.fsPath,locale:T,product:i.product?.name,facets:R,rbacTeams:Q})}}else if(z===b.GROUP){const g=kn(p,L,c,G,O,u);if(g){const A=p.label||"";S.push({title:A,description:void 0,content:g.llmstxt,slug:p.link,fsPath:i.fsPath,includeInLLMsTxt:!1}),P.push({title:A,content:g.aiSearch,url:p.link,fsPath:i.fsPath,locale:T,product:i.product?.name,facets:R,rbacTeams:Q})}}p.items?.length&&k(p.items)}};return k(d),{async getLLMsTxts(){return S},async getSearchDocuments(){return P}}}}function vn(t,s){const r=$(t?.info)?t.info:void 0,c=$(r?.["x-metadata"])?r["x-metadata"]:{},o=(typeof c.description=="string"?c.description:void 0)??r?.description??s.description;return typeof o=="string"?o||void 0:o&&typeof o=="object"?o:void 0}function Ln(t,s,r,c,n){const o=typeof t.title=="string"?t.title:"",e=typeof t.summary=="string"?t.summary:"",l=typeof t.version=="string"?t.version:"";let i=o?`# ${o}
3
3
 
4
4
  `:"";if(i+=s?`${s}
5
5
 
6
6
  `:"",i+=e?`${e}
7
7
 
8
8
  `:"",i+=l?`Version: ${l}
9
- `:"",r){if(O(r,c)){const{info:f}=r;f?.license?.name&&(i+=`License: ${f.license.name}
10
- `);const m=f["x-metadata"],a=Object.entries($(m)?m:{}).filter(([u,h])=>u!=="description"||typeof h!="string"),d=xn(Object.fromEntries(a));d&&(i+=`
9
+ `:"",r){if(I(r,c)){const{info:f}=r;f?.license?.name&&(i+=`License: ${f.license.name}
10
+ `);const m=f["x-metadata"],a=Object.entries($(m)?m:{}).filter(([u,h])=>u!=="description"||typeof h!="string"),d=Sn(Object.fromEntries(a));d&&(i+=`
11
11
  Metadata:
12
12
  ${d}
13
- `)}else if(X(r,c)){const{info:f}=r;f?.license?.name&&(i+=`License: ${f.license.name}
13
+ `)}else if(Y(r,c)){const{info:f}=r;f?.license?.name&&(i+=`License: ${f.license.name}
14
14
  `)}}return i+=`
15
- `,i+=En(r,c,n),i+=kn(r,c,n),i}function Dn(t,s,r,c){if(!r)return"";let n,o,e;if(t==="openapi")n=C.posix.join(Y,U(r,".yaml")),o="## Download OpenAPI description",e="OpenAPI definition";else if(t==="asyncapi")n=C.posix.join(Y,U(r,".yaml")),o="## Download AsyncAPI description",e="AsyncAPI definition";else if(t==="graphql"){const f=C.posix.extname(r)||".graphql";n=C.posix.join(bn,U(r,f)),o="## Download GraphQL schema",e="GraphQL schema"}else return"";if(!yn(n,c.access?.rbac??{},c.access?.requiresLogin??!1,An))return"";const i=typeof s.title=="string"&&s.title||e;return`${o}
15
+ `,i+=Dn(r,c,n),i+=En(r,c,n),i}function Tn(t,s,r,c){if(!r)return"";let n,o,e;if(t==="openapi")n=C.posix.join(B,w(r,".yaml")),o="## Download OpenAPI description",e="OpenAPI definition";else if(t==="asyncapi")n=C.posix.join(B,w(r,".yaml")),o="## Download AsyncAPI description",e="AsyncAPI definition";else if(t==="graphql"){const f=C.posix.extname(r)||".graphql";n=C.posix.join(gn,w(r,f)),o="## Download GraphQL schema",e="GraphQL schema"}else return"";if(!hn(n,c.access?.rbac??{},c.access?.requiresLogin??!1,bn))return"";const i=typeof s.title=="string"&&s.title||e;return`${o}
16
16
 
17
- - ${K({title:i,description:void 0,slug:n,siteUrl:c.seo?.siteUrl})}`}function En(t,s,r){if(!t)return"";if(O(t,s)){const c=Array.isArray(t.servers)?t.servers.filter($):[];if(!c.length)return"";let n=`## Servers
17
+ - ${H({title:i,description:void 0,slug:n,siteUrl:c.seo?.siteUrl})}`}function Dn(t,s,r){if(!t)return"";if(I(t,s)){const c=Array.isArray(t.servers)?t.servers.filter($):[];if(!c.length)return"";let n=`## Servers
18
18
 
19
19
  `;for(const o of c){o.description&&(n+=`${r(o.description)}
20
20
  `),n+=`\`\`\`
@@ -26,7 +26,7 @@ ${o.url}
26
26
  `,i.default&&(n+=` Default: ${JSON.stringify(i.default)}
27
27
  `),Array.isArray(i.enum)&&(n+=` Enum: ${i.enum.map(f=>JSON.stringify(f)).join(", ")}
28
28
  `);n+=`
29
- `}}return n}if(X(t,s)){const c=Object.entries($(t.servers)?t.servers:{}).filter(([,o])=>$(o));if(!c.length)return"";let n=`## Servers
29
+ `}}return n}if(Y(t,s)){const c=Object.entries($(t.servers)?t.servers:{}).filter(([,o])=>$(o));if(!c.length)return"";let n=`## Servers
30
30
 
31
31
  `;for(const[o,e]of c)n+=`### ${o}
32
32
 
@@ -36,7 +36,7 @@ ${o.url}
36
36
  `),e.protocolVersion&&(n+=`Protocol Version: ${e.protocolVersion}
37
37
  `),e.pathname&&(n+=`Pathname: ${e.pathname}
38
38
  `),n+=`
39
- `;return n}return""}function kn(t,s,r){if(!t||!O(t,s))return"";const c=t.components?.securitySchemes;if(!c)return"";let n=`## Security
39
+ `;return n}return""}function En(t,s,r){if(!t||!I(t,s))return"";const c=t.components?.securitySchemes;if(!c)return"";let n=`## Security
40
40
 
41
41
  `;for(const[o,e]of Object.entries(c)){if(!e||"$ref"in e)continue;const l=e;n+=`### ${o}
42
42
 
@@ -53,19 +53,19 @@ ${o.url}
53
53
  `),f.scopes)){n+=`Scopes:
54
54
  `;for(const[m,a]of Object.entries(f.scopes))n+=`- \`${m}\`: ${a}
55
55
  `}n+=`
56
- `}return n}function Z(t,s,r,c){let n="";const o=(e,l)=>{for(const i of e)if(!(!i.link||!tn(i,s))){if(i.content?.contentType===A.GROUP)n+=`${l} ${i.label||""}
56
+ `}return n}function K(t,s,r,c){let n="";const o=(e,l)=>{for(const i of e)if(!(!i.link||!nn(i,s))){if(i.content?.contentType===b.GROUP)n+=`${l} ${i.label||""}
57
57
 
58
- `,i.items?.length&&o(i.items,l+"#");else if(i.content?.contentType===A.ITEM){let f=r.get(i.link);if(f===void 0){const m=i,a=m.httpVerb,d=m.httpPath,u=a&&d?`${a.toUpperCase()} ${d}`:i.label||"",h=N(i.content.children,c);f=` - ${K({title:u,description:h?h.slice(0,200):void 0,slug:gn(i.link),siteUrl:s.seo?.siteUrl})}`,r.set(i.link,f)}n+=f}}};return o(t,"##"),n}function nn(t,s,r,c,n,o,e){if(!t.content)return;const l=t,i=t.label||"",f=N(t.content.children,o),m=t.content.meta?.deprecated;let a=`# ${i}${m?" (deprecated)":""}
58
+ `,i.items?.length&&o(i.items,l+"#");else if(i.content?.contentType===b.ITEM){let f=r.get(i.link);if(f===void 0){const m=i,a=m.httpVerb,d=m.httpPath,u=a&&d?`${a.toUpperCase()} ${d}`:i.label||"",h=N(i.content.children,c);f=` - ${H({title:u,description:h?h.slice(0,200):void 0,slug:$n(i.link),siteUrl:s.seo?.siteUrl})}`,r.set(i.link,f)}n+=f}}};return o(t,"##"),n}function X(t,s,r,c,n,o,e){if(!t.content)return;const l=t,i=t.label||"",f=N(t.content.children,o),m=t.content.meta?.deprecated;let a=`# ${i}${m?" (deprecated)":""}
59
59
 
60
60
  `;if(f&&(a+=`${f}
61
61
 
62
62
  `),r==="openapi"||r==="asyncapi"){const d=l.httpVerb,u=l.httpPath;d&&u?a+=`Endpoint: ${d.toUpperCase()} ${u}
63
63
  `:d&&(a+=`Method: ${d.toUpperCase()}
64
64
  `),c&&(a+=`Version: ${c}
65
- `);const h=Nn(t.content.children,n);h&&(a+=`Security: ${h}
65
+ `);const h=wn(t.content.children,n);h&&(a+=`Security: ${h}
66
66
  `)}return s?.parameters?.length&&r!=="graphql"&&(a+=`
67
- `+jn(s.parameters)+`
68
- `),r==="graphql"&&(a+=Mn(t.content.children,e,o)),a}function Un(t,s,r){if(t.httpVerb!=="tool"||!s||!O(s,r))return;const c=t.content?.meta?.name,n=c?s["x-mcp"]?.tools?.find(e=>e.name===c):void 0;if(!n)return;let o=`# ${t.label||n.name}
67
+ `+Un(s.parameters)+`
68
+ `),r==="graphql"&&(a+=Nn(t.content.children,e,o)),a}function Rn(t,s,r){if(t.httpVerb!=="tool"||!s||!I(s,r))return;const c=t.content?.meta?.name,n=c?s["x-mcp"]?.tools?.find(e=>e.name===c):void 0;if(!n)return;let o=`# ${t.label||n.name}
69
69
 
70
70
  `;return typeof n.description=="string"&&n.description&&(o+=`${n.description}
71
71
 
@@ -81,25 +81,25 @@ ${JSON.stringify(n.inputSchema,null,2)}
81
81
  ${JSON.stringify(n.outputSchema,null,2)}
82
82
  \`\`\`
83
83
 
84
- `),o}function wn(t,s,r,c,n,o){if(!t.content)return;const e=t.label||"",l=N(t.content.children,n);let i=`# ${e}
84
+ `),o}function kn(t,s,r,c,n,o){if(!t.content)return;const e=t.label||"",l=N(t.content.children,n);let i=`# ${e}
85
85
 
86
86
  `;if(l&&(i+=`${l}
87
87
 
88
- `),r==="graphql"){let m="";const a=d=>{for(const u of d??[])if(!(!u.content||!tn(u,s)))if(u.content.contentType===A.ITEM){const h=nn(u,void 0,r,void 0,void 0,n,o);h&&(m+=`${h}
88
+ `),r==="graphql"){let m="";const a=d=>{for(const u of d??[])if(!(!u.content||!nn(u,s)))if(u.content.contentType===b.ITEM){const h=X(u,void 0,r,void 0,void 0,n,o);h&&(m+=`${h}
89
89
 
90
90
  ---
91
91
 
92
- `)}else u.content.contentType===A.GROUP&&a(u.items)};return a(t.items),{llmstxt:i+m,aiSearch:i}}const f=Z(t.items??[],s,c,n);return{llmstxt:i+f,aiSearch:i}}function Nn(t,s){const r=[],c=n=>{for(const o of n)if(o.nodeType===y.SECURITY){const e=o;for(const l of e.requirements)for(const i of l.schemes)i[v]||i.name&&!r.includes(i.name)&&r.push(i.name)}else(o.nodeType===y.CONTAINER||o.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&c(o.children)};if(c(t),r.length)return r.join(", ");if(s?.length){const n=s.flatMap(o=>Object.keys(o));if(n.length)return[...new Set(n)].join(", ")}}function jn(t){const s={};for(const c of t){const n=`${c.place}${c.mediaType?` (${c.mediaType})`:""}`;s[n]||(s[n]=[]),s[n].push(c)}return Object.entries(s).map(([c,n])=>{const o=n.map(e=>{const l=[...e.path||[],e.name],i=Array.isArray(e.description)?e.description.join(" "):e.description;let f=` - \`${l.join(".")}\` (${e.type}${e.required?", required":""})
92
+ `)}else u.content.contentType===b.GROUP&&a(u.items)};return a(t.items),{llmstxt:i+m,aiSearch:i}}const f=K(t.items??[],s,c,n);return{llmstxt:i+f,aiSearch:i}}function wn(t,s){const r=[],c=n=>{for(const o of n)if(o.nodeType===y.SECURITY){const e=o;for(const l of e.requirements)for(const i of l.schemes)i[v]||i.name&&!r.includes(i.name)&&r.push(i.name)}else(o.nodeType===y.CONTAINER||o.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&c(o.children)};if(c(t),r.length)return r.join(", ");if(s?.length){const n=s.flatMap(o=>Object.keys(o));if(n.length)return[...new Set(n)].join(", ")}}function Un(t){const s={};for(const c of t){const n=`${c.place}${c.mediaType?` (${c.mediaType})`:""}`;s[n]||(s[n]=[]),s[n].push(c)}return Object.entries(s).map(([c,n])=>{const o=n.map(e=>{const l=[...e.path||[],e.name],i=Array.isArray(e.description)?e.description.join(" "):e.description;let f=` - \`${l.join(".")}\` (${e.type}${e.required?", required":""})
93
93
  `;return i&&(f+=` ${i.trim()}
94
94
  `),e.enum?f+=` Enum: ${e.enum.map(m=>JSON.stringify(m)).join(", ")}
95
95
  `:e.example&&(f+=` Example: ${e.example}
96
- `),f});return`## ${en(c)}:
96
+ `),f});return`## ${Z(c)}:
97
97
 
98
98
  ${o.join(`
99
99
  `)}`}).join(`
100
- `)}function Mn(t,s,r){let c="";const n=o=>{for(const e of o)if(e.nodeType===y.ITEM){const l=un(e)?dn(e,s??{}):void 0;l&&(c+=Vn(l,e.variant,r))}else(e.nodeType===y.CONTAINER||e.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&n(e.children)};return n(t),c}function Vn(t,s,r){let n=`
101
- ## ${en(s==="return-type"?"Return type":s==="graphql-args"||s==="arguments"?"Arguments":s==="graphql-fields"?"Fields":s)}:
100
+ `)}function Nn(t,s,r){let c="";const n=o=>{for(const e of o)if(e.nodeType===y.ITEM){const l=pn(e)?un(e,s??{}):void 0;l&&(c+=jn(l,e.variant,r))}else(e.nodeType===y.CONTAINER||e.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&n(e.children)};return n(t),c}function jn(t,s,r){let n=`
101
+ ## ${Z(s==="return-type"?"Return type":s==="graphql-args"||s==="arguments"?"Arguments":s==="graphql-fields"?"Fields":s)}:
102
102
 
103
- `;const o=e=>{const l=e.description?w(Array.isArray(e.description)?e.description:[e.description],{renderTag:r}).trim():"";return` - \`${e.name}\` (${e.type.display})${l?`: ${l}`:""}
104
- `};if(t.type){const e=t.type.description?w(Array.isArray(t.type.description)?t.type.description:[t.type.description],{renderTag:r}).trim():"";n+=` Type: ${t.type.display}`,e&&(n+=` - ${e}`),n+=`
105
- `}else if(!t.fields.length)return"";for(const e of t.fields)n+=o(e);return n}function N(t,s){const r=[],c=o=>{for(const e of o)if(e.nodeType===y.MARKDOC){const l=e.content,i=Array.isArray(l)?l:[l],f=w(i,{renderTag:s}).trim();f&&r.push(f)}else(e.nodeType===y.CONTAINER||e.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&c(e.children)};return c(t),r.join(" ").trim()||void 0}function en(t){return t.charAt(0).toUpperCase()+t.slice(1)}function tn(t,s){return s.access?.requiresLogin?!0:hn({slug:t.link||"",[v]:t[v]},s)}export{se as getAiDocumentsStore};
103
+ `;const o=e=>{const l=e.description?U(Array.isArray(e.description)?e.description:[e.description],{renderTag:r}).trim():"";return` - \`${e.name}\` (${e.type.display})${l?`: ${l}`:""}
104
+ `};if(t.type){const e=t.type.description?U(Array.isArray(t.type.description)?t.type.description:[t.type.description],{renderTag:r}).trim():"";n+=` Type: ${t.type.display}`,e&&(n+=` - ${e}`),n+=`
105
+ `}else if(!t.fields.length)return"";for(const e of t.fields)n+=o(e);return n}function N(t,s){const r=[],c=o=>{for(const e of o)if(e.nodeType===y.MARKDOC){const l=e.content,i=Array.isArray(l)?l:[l],f=U(i,{renderTag:s}).trim();f&&r.push(f)}else(e.nodeType===y.CONTAINER||e.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&c(e.children)};return c(t),r.join(" ").trim()||void 0}function Z(t){return t.charAt(0).toUpperCase()+t.slice(1)}function nn(t,s){return s.access?.requiresLogin?!0:mn({slug:t.link||"",[v]:t[v]},s)}export{re as getAiDocumentsStore};
@@ -1 +1 @@
1
- import{REDOCLY_ROUTE_RBAC as h,REDOCLY_TEAMS_RBAC as o}from"@redocly/config";import{extractDocumentSearchFacets as x,setDocumentSearchFacets as A}from"./search-facets.js";import{ApiDocsSearchIndexer as D}from"@redocly/api-docs";import{normalizeApiVersion as d}from"../utils/normalize-api-version.js";function M(g,i,c,u,S,n,R){return async e=>{if(S)return[];const m=e.baseSlug||e.slug,l=new D(m,n?.schemaStore,R,{exampleStore:n?.exampleStore,graphqlMeta:n?.graphqlMeta}),p=t=>{for(const a of t)l.addItem(a),a.items?.length&&p(a.items)};p(g);const s=typeof i.title=="string"?i.title:void 0,r=d(i.version),f=x(e.metadata||{},s,r,c);return A(f,c,u),l.getResult().map(t=>({...t,...t.url===m&&s&&{title:r?`${s} (${r})`:s},[o]:t[o]??e[o],[h]:e[h]??{slug:e.slug,fsPath:e.fsPath},facets:f}))}}export{M as searchResolver};
1
+ import{REDOCLY_ROUTE_RBAC as m,REDOCLY_TEAMS_RBAC as c}from"@redocly/config";import{extractDocumentSearchFacets as g,setDocumentSearchFacets as A}from"./search-facets.js";import{ApiDocsSearchIndexer as D}from"@redocly/api-docs";import{normalizeApiVersion as S}from"../utils/normalize-api-version.js";function _(p,s,r,l,u,h,d){return async t=>{if(u)return[];const i=t.baseSlug||t.slug,R=new D({basePath:i,store:h,document:d}),e=typeof s.title=="string"?s.title:void 0,n=S(s.version),a=g(t.metadata||{},e,n,r);A(a,r,l);const f=[];for(const o of R.documents(p))f.push(Object.assign(o,{path:[],...o.url===i&&e&&{title:n?`${e} (${n})`:e},[c]:o[c]??t[c],[m]:t[m]??{slug:t.slug,fsPath:t.fsPath},facets:a}));return f}}export{_ as searchResolver};
@@ -6,4 +6,5 @@ export type OpenapiBundle = {
6
6
  rawOptions: RawApiDocsOptions;
7
7
  };
8
8
  export declare function loadOpenapiBundle(node: Node, context: LifecycleContext): Promise<OpenapiBundle | undefined>;
9
+ export declare function loadFullOpenapiBundle(node: Node, context: LifecycleContext): Promise<OpenapiBundle | undefined>;
9
10
  //# sourceMappingURL=load-openapi-bundle.d.ts.map
@@ -1 +1 @@
1
- import{REDOCLY_ROUTE_RBAC as u,REDOCLY_TEAMS_RBAC as p}from"@redocly/config";import{API_DOCS_SHARED_DATA_PREFIX as f}from"../../../../constants/plugins/api-docs.js";import{ANONYMOUS_AUTH_DETAILS as l}from"../../../../constants/rbac.js";import{applyL10nToRbacConfig as m,canAccessResource as d,filterDataByAccessDeep as g}from"../../../../utils/rbac.js";import{describeDefinitionAccess as A}from"../../../../plugins/api-docs/definition-access.js";import{createSlugify as R}from"../../../../plugins/create-slugify.js";import{normalizeRouteSlug as h}from"../../../../../utils/path/normalize-route-slug.js";import{getNodeAttribute as D}from"../../../../../markdoc/helpers/get-node-attribute.js";import{logger as b}from"../../../../tools/notifiers/logger.js";const c=new WeakMap;function y(t){return c.has(t)||c.set(t,g(t,l)),c.get(t)}async function O(t,e){const[n,r]=await Promise.all([e.getConfig(),e.cache.load("content-slugs","content-slugs")]),o=R(r.data),{rbac:i,slug:a,sourcePath:s}=A(t,h(o(t.customOutputRelativeFile||t.relativePath)));return d({[p]:i,[u]:{slug:a,fsPath:s}},l,m(e.fs,n.access?.rbac))}async function I(t,e){const n=D(t,"descriptionFile");if(typeof n!="string"||!n.startsWith(f))return;const r=n.slice(f.length);try{const{data:o}=await e.cache.load(r,"api-doc"),i=o?.find(s=>s.type==="openapi");if(!i||!await O(i,e))return;const a=y(i.document);return a&&{definition:a,rawOptions:i.options}}catch(o){b.verbose(`Failed to load OpenAPI definition ${r} for the ${t.tag} tag: ${o instanceof Error?o.message:"Unknown error"}`);return}}export{I as loadOpenapiBundle};
1
+ import{REDOCLY_ROUTE_RBAC as p,REDOCLY_TEAMS_RBAC as d}from"@redocly/config";import{API_DOCS_SHARED_DATA_PREFIX as u}from"../../../../constants/plugins/api-docs.js";import{ANONYMOUS_AUTH_DETAILS as f}from"../../../../constants/rbac.js";import{applyL10nToRbacConfig as m,canAccessResource as g,filterDataByAccessDeep as A}from"../../../../utils/rbac.js";import{describeDefinitionAccess as y}from"../../../../plugins/api-docs/definition-access.js";import{createSlugify as D}from"../../../../plugins/create-slugify.js";import{normalizeRouteSlug as O}from"../../../../../utils/path/normalize-route-slug.js";import{getNodeAttribute as R}from"../../../../../markdoc/helpers/get-node-attribute.js";import{logger as h}from"../../../../tools/notifiers/logger.js";const c=new WeakMap;function b(t){return c.has(t)||c.set(t,A(t,f)),c.get(t)}async function _(t,e){const[n,o]=await Promise.all([e.getConfig(),e.cache.load("content-slugs","content-slugs")]),r=D(o.data),{rbac:i,slug:a,sourcePath:s}=y(t,O(r(t.customOutputRelativeFile||t.relativePath)));return g({[d]:i,[p]:{slug:a,fsPath:s}},f,m(e.fs,n.access?.rbac))}async function l(t,e,n){const o=R(t,"descriptionFile");if(typeof o!="string"||!o.startsWith(u))return;const r=o.slice(u.length);try{const{data:i}=await e.cache.load(r,"api-doc"),a=i?.find(s=>s.type==="openapi");return a&&await n(a)}catch(i){h.verbose(`Failed to load OpenAPI definition ${r} for the ${t.tag} tag: ${i instanceof Error?i.message:"Unknown error"}`);return}}async function L(t,e){return l(t,e,async n=>{if(!await _(n,e))return;const o=b(n.document);return o&&{definition:o,rawOptions:n.options}})}async function U(t,e){return l(t,e,async n=>({definition:n.document,rawOptions:n.options}))}export{U as loadFullOpenapiBundle,L as loadOpenapiBundle};
@@ -1 +1 @@
1
- import{resolveOpenApiRef as e}from"./resolve-open-api-ref.js";import{resolveJsonSchemaRef as o}from"./resolve-json-schema-ref.js";import{resolveParsedYaml as r}from"./resolve-parsed-yaml.js";import{resolveRawContent as m}from"./resolve-raw-content.js";import{resolveTagRawContent as t}from"./resolve-tag-raw-content.js";import{resolveSvgContent as i}from"./resolve-svg-content.js";import{resolveRelativePath as l}from"./resolve-relative-path.js";import{resolveLink as a}from"./resolve-link.js";import{resolveNativeMdLink as p}from"./resolve-native-md-link.js";import{resolveCodeSnippetFromFile as s}from"./resolve-code-snippet-from-file.js";import{resolveDiagramFromFile as n}from"./resolve-diagram-from-file.js";import{resolveHtmlSourceAttribute as v}from"./resolve-html-source-attribute.js";import{resolveHtmlHref as f}from"./resolve-html-href.js";import{resolveImageSrc as S}from"./resolve-image-src.js";import{resolveImageSrcSet as c}from"./resolve-image-src-set.js";import{resolveImageGallery as g}from"./resolve-image-gallery.js";import{resolveNavLinks as R}from"./resolve-nav-links.js";import{resolveRelativeOrCdnIcon as d}from"./resolve-relative-or-cdn-icon.js";import{resolveCodeWalkthroughFilesets as h}from"./code-walkthrough/filesets-resolver.js";import{resolveJsonExampleRef as C}from"./resolve-json-example-ref.js";import{resolveSampleFromJsonSchema as F}from"./resolve-sample-from-json-schema.js";import{resolveOpenapiCodeSamples as k}from"./resolve-openapi-code-samples.js";import{resolveOpenapiResponseSamples as u}from"./resolve-openapi-response-samples.js";const K={openapiRef:e,jsonSchemaRef:o,parsedYaml:r,rawContent:m,tagRawContent:t,svgContent:i,relativePath:l,link:a,nativeMdLink:p,codeSnippetFile:s,diagramFile:n,htmlSourceAttribute:v,htmlHref:f,imageSrc:S,imageSrcSet:c,imageGallery:g,navLinks:R,relativeOrCdnIcon:d,codeWalkthroughFilesets:h,jsonExampleRef:C,sampleFromJsonSchema:F,openapiCodeSamples:k,openapiResponseSamples:u};export{K as attributeResolvers};
1
+ import{resolveOpenApiRef as e}from"./resolve-open-api-ref.js";import{resolveJsonSchemaRef as o}from"./resolve-json-schema-ref.js";import{resolveParsedYaml as r}from"./resolve-parsed-yaml.js";import{resolveRawContent as m}from"./resolve-raw-content.js";import{resolveTagRawContent as t}from"./resolve-tag-raw-content.js";import{resolveSvgContent as i}from"./resolve-svg-content.js";import{resolveRelativePath as p}from"./resolve-relative-path.js";import{resolveLink as a}from"./resolve-link.js";import{resolveNativeMdLink as l}from"./resolve-native-md-link.js";import{resolveCodeSnippetFromFile as s}from"./resolve-code-snippet-from-file.js";import{resolveDiagramFromFile as n}from"./resolve-diagram-from-file.js";import{resolveHtmlSourceAttribute as v}from"./resolve-html-source-attribute.js";import{resolveHtmlHref as f}from"./resolve-html-href.js";import{resolveImageSrc as S}from"./resolve-image-src.js";import{resolveImageSrcSet as c}from"./resolve-image-src-set.js";import{resolveImageGallery as g}from"./resolve-image-gallery.js";import{resolveNavLinks as R}from"./resolve-nav-links.js";import{resolveRelativeOrCdnIcon as d}from"./resolve-relative-or-cdn-icon.js";import{resolveCodeWalkthroughFilesets as h}from"./code-walkthrough/filesets-resolver.js";import{resolveJsonExampleRef as C}from"./resolve-json-example-ref.js";import{resolveSampleFromJsonSchema as F}from"./resolve-sample-from-json-schema.js";import{resolveOpenapiCodeSamples as k}from"./resolve-openapi-code-samples.js";import{resolveOpenapiResponseSamples as O}from"./resolve-openapi-response-samples.js";import{resolveOpenapiOperation as u}from"./resolve-openapi-operation.js";const U={openapiRef:e,jsonSchemaRef:o,parsedYaml:r,rawContent:m,tagRawContent:t,svgContent:i,relativePath:p,link:a,nativeMdLink:l,codeSnippetFile:s,diagramFile:n,htmlSourceAttribute:v,htmlHref:f,imageSrc:S,imageSrcSet:c,imageGallery:g,navLinks:R,relativeOrCdnIcon:d,codeWalkthroughFilesets:h,jsonExampleRef:C,sampleFromJsonSchema:F,openapiCodeSamples:k,openapiResponseSamples:O,openapiOperation:u};export{U as attributeResolvers};
@@ -0,0 +1,10 @@
1
+ import type { Node } from '@redocly/markdoc';
2
+ import type { MarkdocResolveContext } from '../../../types';
3
+ /**
4
+ * Marks a tag whose target the whole description has: the operation that `operationId` or
5
+ * `pointer` names and, for `openapi-response-sample`, its response samples. When the description
6
+ * delivered to a viewer lacks that target, the access rules withheld it, and the tag renders
7
+ * nothing in production in place of its error.
8
+ */
9
+ export declare function resolveOpenapiOperation(node: Node, attrName: string, _relativePath: string, { context }: MarkdocResolveContext): Promise<void>;
10
+ //# sourceMappingURL=resolve-openapi-operation.d.ts.map
@@ -0,0 +1 @@
1
+ import{getResponseSamples as p,normalizeOptions as a,resolveOperationSampleContext as l}from"@redocly/api-docs";import{setNodeAttributeValue as s}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{loadFullOpenapiBundle as m}from"./helpers/load-openapi-bundle.js";import{getOptionalAttribute as r}from"./utils.js";async function b(t,i,u,{context:n}){const e=await m(t,n);if(!e)return;const o=l(e.definition,a(e.rawOptions),{operationId:r(t,"operationId"),pointer:r(t,"pointer")});o&&(t.tag==="openapi-response-sample"&&p(o).length===0||s(t,i,!0))}export{b as resolveOpenapiOperation};
@@ -1 +1 @@
1
- import _ from"flexsearch";import{REDOCLY_TEAMS_RBAC as L}from"@redocly/config";import{DISABLE_DEEP_LINK_IF_FIELDS_EXIST as C,SEARCH_LIMIT as R}from"../../../../constants/plugins/search.js";import{telemetryTraceStep as b}from"../../../../telemetry/helpers/trace-step.js";import{highlightTextForSearch as m,markMatchedValue as D}from"../../../../utils/search/highlight-text-for-search.js";import{MIN_QUERY_WORD_LENGTH as M,containsQueryWord as S,matchableQueryWords as j}from"../../../../utils/search/text-match.js";function k(I){const{name:e,description:t,place:s,path:i,deepLink:r,example:n,enum:a}=I,o=r?.indexOf("#")??-1;return{name:e,description:t,place:s,...i&&{path:i},...r&&{deepLink:o>=0?r.slice(o+1):r},example:n,enum:a}}class T{#t;#e=new Map;#s=1;id;constructor(e,t){this.id=e,this.#t=new _.Document(t)}get documents(){return this.#e.entries()}get documentsCount(){return this.#s}clearDocuments(){this.#e.clear()}async export(e){await this.#t.export(e)}async import(e){this.#e.clear();for await(const t of e)if("document"in t){const[s,i]=t.document;this.#e.set(s,i)}else{const[s,i]=t.index;await this.#t.import(s,i)}}add(e){const t={...e,tags:e.tags??[],[L]:e[L],...e.parameters&&{parameters:e.parameters.map(k)}};this.#e.set(this.#s,t),this.#t.add(this.#s,t),this.#s++}async search(e){return await b("com.redocly.search.performed",async t=>{t?.setAttribute("id","searchQueryId"),t?.setAttribute("object","searchQuery"),t?.setAttribute("uri","urn:redocly:realm:api:searchQuery:searchQueryId");const{query:s,offset:i,auth:r,product:n,versions:a}=e,o=[],l=r.teams,p={limit:R,offset:i},c=this.#r(s);if(!c.length&&s.trim())return{documents:{[this.id]:[]},facets:{},hasCoveringHit:!1};let d=new Map,g=await this.#t.searchAsync(s,{...p,tag:l});if(n){const h=await this.#t.searchAsync(s,{...p,tag:n});g=this.#a(g,h),t?.setAttribute("product",n)}if(a&&a.length){const h=await this.#t.searchAsync(s,{...p,tag:a});g=this.#a(g,h),t?.setAttribute("versions",a.join(","))}for(const h of g)for(const u of h.result){const f=d.get(u)?.fields||[];d.set(u,{fields:h.field?[...f,h.field]:[...f]})}!i&&c.length&&!d.size&&(d=this.#l(c,l,n,a));const x=[];for(const[h,u]of d.entries()){const f=this.#e.get(h);f&&!this.#d(f,a)&&x.push({document:f,fields:u.fields,score:this.#m(c,f)})}const y=x.filter(h=>h.score>=c.length),A=y.length?y:x;A.sort((h,u)=>u.score-h.score);for(const h of A.slice(0,R))o.push({document:this.#o(h.document,s,h.fields),highlight:this.#h(h.document,s,h.fields)});return{documents:{[this.id]:o},facets:{},hasCoveringHit:y.length>0}})}#o(e,t,s){return this.#g(e,t,s)}#h(e,t,s){const i={};let r=!1;for(const n of s)if(n==="path")i.path=e.path?e.path.map(a=>m(t,a)):[];else if(n.includes("parameters")){if(!r){const a=n.split(":")[1],o=this.#n(t,a,e.parameters);o&&(i.parameters=[{name:m(t,o.name),description:m(t,o.description),place:m(t,o.place),path:o.path?o.path.map(l=>m(t,l)):[],...this.#c(t,o)}],r=!0)}}else n!=="httpMethod"&&(i[n]=m(t,e[n]));return i}#c(e,t){return{enum:D(e,(t.enum??[]).join(", ")),example:D(e,t.example??"")}}#r(e){return j(e)}#l(e,t,s,i){const r=new Map;if(!e.length)return r;for(const[n,a]of this.#e)this.#p(a,t,s,i)&&this.#f(e,a)&&r.set(n,{fields:this.#u(e,a)});return r}#f(e,t){const s=i=>{if(i==null)return!1;const r=(Array.isArray(i)?i.join(" "):String(i)).toLowerCase();return!!r&&e.every(n=>S(r,n))};return s(t.title)||s(t.text)||s(t.httpPath)||s(t.path)?!0:(t.parameters??[]).some(i=>s(i.name)||s(i.description)||s(i.example)||s(i.enum))}#p(e,t,s,i){const r=new Set(e.tags??[]);return!(t.length&&!t.some(n=>r.has(n))||s&&!r.has(s)||i&&i.length&&!i.some(n=>r.has(n)))}#u(e,t){const s=r=>{if(r==null)return!1;const n=(Array.isArray(r)?r.join(" "):String(r)).toLowerCase();return e.some(a=>S(n,a))},i=[];s(t.title)&&i.push("title"),s(t.text)&&i.push("text"),s(t.path)&&i.push("path"),t.httpMethod&&e.some(r=>r.length>=M&&t.httpMethod?.toLowerCase().startsWith(r))&&i.push("httpMethod"),s(t.httpPath)&&i.push("httpPath");for(const r of["name","description","path","example","enum"])t.parameters?.some(n=>s(n[r]))&&i.push(`parameters[]:${r}`);return i}#i(e,t){const s=t.toLowerCase().replace(/\s+/g," "),i=e.filter(n=>S(s,n)).length;let r=0;for(let n=1;n<e.length;n++)s.includes(`${e[n-1]} ${e[n]}`)&&r++;return i+r/e.length}#m(e,t){let s=0;const i=r=>{if(r==null)return;const n=this.#i(e,String(r));n>s&&(s=n)};if(i(t.title),i(t.text),i(t.httpPath),i(t.path?.join(" ")),t.httpMethod){const r=t.httpMethod.toLowerCase(),n=e.filter(a=>a.length>=M&&r.startsWith(a)).length;n>s&&(s=n)}for(const r of t.parameters??[])i([r.name,r.description,r.place,r.example,r.enum?.join(" ")].filter(Boolean).join(" "));return s}#n(e,t,s){const i=this.#r(e);let r,n=0;for(const a of s??[]){const o=a[t],l=(Array.isArray(o)?o:[o]).filter(c=>c!=null).map(c=>String(c)).join(" "),p=this.#i(i,l);p>n&&(n=p,r=a)}return r}#a(e,t){const s=[];for(const i of e){const r=[];for(const n of t)for(const a of i.result){const o=n.result.find(l=>l===a);o&&r.push(o)}r.length&&s.push({result:r,field:i.field})}return s}#d(e,t){return!!(t&&t.length&&e.isDefaultVersion&&e.versionFolderId&&e.version&&t.some(s=>s.includes(e.versionFolderId??""))&&!t.some(s=>s.includes(e.version??"")))}#g(e,t,s){for(const r of C)if(s.some(n=>n===r))return e;let i;for(const r of s)if(r.includes("parameters")){const n=r.split(":")[1],a=this.#n(t,n,e.parameters);if(a){i=a.deepLink;break}}return i?{...e,url:`${e.url}#${i}`}:e}}export{T as FlexSearchIndex};
1
+ import _ from"flexsearch";import{REDOCLY_TEAMS_RBAC as L}from"@redocly/config";import{DISABLE_DEEP_LINK_IF_FIELDS_EXIST as C,SEARCH_LIMIT as R}from"../../../../constants/plugins/search.js";import{telemetryTraceStep as b}from"../../../../telemetry/helpers/trace-step.js";import{highlightTextForSearch as m,markMatchedValue as D}from"@redocly/theme/core/utils/search-highlight";import{MIN_QUERY_WORD_LENGTH as M,containsQueryWord as S,matchableQueryWords as j}from"@redocly/theme/core/utils/search-text-match";function k(I){const{name:e,description:t,place:s,path:i,deepLink:r,example:n,enum:a}=I,o=r?.indexOf("#")??-1;return{name:e,description:t,place:s,...i&&{path:i},...r&&{deepLink:o>=0?r.slice(o+1):r},example:n,enum:a}}class T{#t;#e=new Map;#s=1;id;constructor(e,t){this.id=e,this.#t=new _.Document(t)}get documents(){return this.#e.entries()}get documentsCount(){return this.#s}clearDocuments(){this.#e.clear()}async export(e){await this.#t.export(e)}async import(e){this.#e.clear();for await(const t of e)if("document"in t){const[s,i]=t.document;this.#e.set(s,i)}else{const[s,i]=t.index;await this.#t.import(s,i)}}add(e){const t={...e,tags:e.tags??[],[L]:e[L],...e.parameters&&{parameters:e.parameters.map(k)}};this.#e.set(this.#s,t),this.#t.add(this.#s,t),this.#s++}async search(e){return await b("com.redocly.search.performed",async t=>{t?.setAttribute("id","searchQueryId"),t?.setAttribute("object","searchQuery"),t?.setAttribute("uri","urn:redocly:realm:api:searchQuery:searchQueryId");const{query:s,offset:i,auth:r,product:n,versions:a}=e,o=[],l=r.teams,p={limit:R,offset:i},c=this.#r(s);if(!c.length&&s.trim())return{documents:{[this.id]:[]},facets:{},hasCoveringHit:!1};let d=new Map,g=await this.#t.searchAsync(s,{...p,tag:l});if(n){const h=await this.#t.searchAsync(s,{...p,tag:n});g=this.#a(g,h),t?.setAttribute("product",n)}if(a&&a.length){const h=await this.#t.searchAsync(s,{...p,tag:a});g=this.#a(g,h),t?.setAttribute("versions",a.join(","))}for(const h of g)for(const u of h.result){const f=d.get(u)?.fields||[];d.set(u,{fields:h.field?[...f,h.field]:[...f]})}!i&&c.length&&!d.size&&(d=this.#l(c,l,n,a));const x=[];for(const[h,u]of d.entries()){const f=this.#e.get(h);f&&!this.#d(f,a)&&x.push({document:f,fields:u.fields,score:this.#m(c,f)})}const y=x.filter(h=>h.score>=c.length),A=y.length?y:x;A.sort((h,u)=>u.score-h.score);for(const h of A.slice(0,R))o.push({document:this.#o(h.document,s,h.fields),highlight:this.#h(h.document,s,h.fields)});return{documents:{[this.id]:o},facets:{},hasCoveringHit:y.length>0}})}#o(e,t,s){return this.#g(e,t,s)}#h(e,t,s){const i={};let r=!1;for(const n of s)if(n==="path")i.path=e.path?e.path.map(a=>m(t,a)):[];else if(n.includes("parameters")){if(!r){const a=n.split(":")[1],o=this.#n(t,a,e.parameters);o&&(i.parameters=[{name:m(t,o.name),description:m(t,o.description),place:m(t,o.place),path:o.path?o.path.map(l=>m(t,l)):[],...this.#c(t,o)}],r=!0)}}else n!=="httpMethod"&&(i[n]=m(t,e[n]));return i}#c(e,t){return{enum:D(e,(t.enum??[]).join(", ")),example:D(e,t.example??"")}}#r(e){return j(e)}#l(e,t,s,i){const r=new Map;if(!e.length)return r;for(const[n,a]of this.#e)this.#p(a,t,s,i)&&this.#f(e,a)&&r.set(n,{fields:this.#u(e,a)});return r}#f(e,t){const s=i=>{if(i==null)return!1;const r=(Array.isArray(i)?i.join(" "):String(i)).toLowerCase();return!!r&&e.every(n=>S(r,n))};return s(t.title)||s(t.text)||s(t.httpPath)||s(t.path)?!0:(t.parameters??[]).some(i=>s(i.name)||s(i.description)||s(i.example)||s(i.enum))}#p(e,t,s,i){const r=new Set(e.tags??[]);return!(t.length&&!t.some(n=>r.has(n))||s&&!r.has(s)||i&&i.length&&!i.some(n=>r.has(n)))}#u(e,t){const s=r=>{if(r==null)return!1;const n=(Array.isArray(r)?r.join(" "):String(r)).toLowerCase();return e.some(a=>S(n,a))},i=[];s(t.title)&&i.push("title"),s(t.text)&&i.push("text"),s(t.path)&&i.push("path"),t.httpMethod&&e.some(r=>r.length>=M&&t.httpMethod?.toLowerCase().startsWith(r))&&i.push("httpMethod"),s(t.httpPath)&&i.push("httpPath");for(const r of["name","description","path","example","enum"])t.parameters?.some(n=>s(n[r]))&&i.push(`parameters[]:${r}`);return i}#i(e,t){const s=t.toLowerCase().replace(/\s+/g," "),i=e.filter(n=>S(s,n)).length;let r=0;for(let n=1;n<e.length;n++)s.includes(`${e[n-1]} ${e[n]}`)&&r++;return i+r/e.length}#m(e,t){let s=0;const i=r=>{if(r==null)return;const n=this.#i(e,String(r));n>s&&(s=n)};if(i(t.title),i(t.text),i(t.httpPath),i(t.path?.join(" ")),t.httpMethod){const r=t.httpMethod.toLowerCase(),n=e.filter(a=>a.length>=M&&r.startsWith(a)).length;n>s&&(s=n)}for(const r of t.parameters??[])i([r.name,r.description,r.place,r.example,r.enum?.join(" ")].filter(Boolean).join(" "));return s}#n(e,t,s){const i=this.#r(e);let r,n=0;for(const a of s??[]){const o=a[t],l=(Array.isArray(o)?o:[o]).filter(c=>c!=null).map(c=>String(c)).join(" "),p=this.#i(i,l);p>n&&(n=p,r=a)}return r}#a(e,t){const s=[];for(const i of e){const r=[];for(const n of t)for(const a of i.result){const o=n.result.find(l=>l===a);o&&r.push(o)}r.length&&s.push({result:r,field:i.field})}return s}#d(e,t){return!!(t&&t.length&&e.isDefaultVersion&&e.versionFolderId&&e.version&&t.some(s=>s.includes(e.versionFolderId??""))&&!t.some(s=>s.includes(e.version??"")))}#g(e,t,s){for(const r of C)if(s.some(n=>n===r))return e;let i;for(const r of s)if(r.includes("parameters")){const n=r.split(":")[1],a=this.#n(t,n,e.parameters);if(a){i=a.deepLink;break}}return i?{...e,url:`${e.url}#${i}`}:e}}export{T as FlexSearchIndex};
@@ -1 +1 @@
1
- import{appendFile as T}from"node:fs/promises";import{existsSync as P}from"node:fs";import b from"node:path";import{Client as q}from"typesense";import{SEARCH_GROUP_FACET_FIELD as F,SEARCH_PRODUCT_FIELD as L,SEARCH_RBAC_FIELD as d,SEARCH_VERSION_FIELD as h}from"../../../../../constants/common.js";import{DISABLE_DEEP_LINK_IF_FIELDS_EXIST as v,HIGHLIGHTED_TEXT_MAX_LENGTH as C,SEARCH_DATA_EXPORT_FOLDER as R,SEARCH_DOCUMENT_METADATA_KEY as j,SEARCH_GROUP_LIMIT as O,SEARCH_MAX_FACET_VALUES as y,SEARCH_MAX_INMEMORY_DOCUMENTS_COUNT as k}from"../../../../constants/plugins/search.js";import{telemetryTraceStep as N}from"../../../../telemetry/helpers/trace-step.js";import{envConfig as _}from"../../../../config/env-config.js";import{logger as I}from"../../../../tools/notifiers/logger.js";import{ensureDir as E}from"../../../../utils/index.js";class X{#e=null;#i="";#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:"parameters.name",type:"string[]",facet:!1,optional:!0,queryable:!1},{name:"parameters.description",type:"string[]",facet:!1,optional:!0,queryable:!1},{name:"parameters.place",type:"string[]",facet:!1,optional:!0,queryable:!1},{name:"parameters.path",type:"string[]",facet:!1,optional:!0,queryable:!1},{name:L,type:"string",facet:!0,optional:!0},{name:h,type:"object",facet:!0,optional:!0},{name:d,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;#r={ORGANIZATION_ID:_.ORGANIZATION_ID??"",PROJECT_ID:_.PROJECT_ID??"",TYPESENSE_API_URL:_.TYPESENSE_API_URL??"",TYPESENSE_API_KEY:_.TYPESENSE_API_KEY??""};constructor(){if(!_.isBuildMode){for(const[e,t]of Object.entries(this.#r))if(!t)throw new Error(`Cannot initialize search index. ${e} is not set`);this.#i=`${this.#r.ORGANIZATION_ID}_${this.#r.PROJECT_ID}_`,this.#e=new q({nodes:[{url:this.#r.TYPESENSE_API_URL}],apiKey:this.#r.TYPESENSE_API_KEY,connectionTimeoutSeconds:5})}}async initIndexSchema(e){this.#b(e)}async addDocuments(e,t){const{locale:s,outDir:a}=t,n=e.map(r=>{const i={...r},c=r[j];return c&&(c.curated&&(i.metadata_curated=c.curated),c.excludes&&(i.metadata_keywords_excludes=c.excludes),c.includes&&(i.metadata_keywords_includes=c.includes)),i}),o=this.#s.get(s)??[];this.#s.set(s,o.concat(n)),o.length+e.length>=k&&await this.exportDocuments(a)}async search(e,t){return await N("com.redocly.search.performed",async s=>{s?.setAttribute("id","searchQueryId"),s?.setAttribute("object","searchQuery"),s?.setAttribute("uri","urn:redocly:realm:api:searchQuery:searchQueryId");const{query:a,locale:n,filter:o,loadMore:r}=e,i=this.#f(n),c={collection:i,q:a||"*",query_by:this.#h(),max_facet_values:y};if(s?.setAttribute("collectionName",i),s?.setAttribute("locale",n),this.#e)if(r){const{groupKey:l,offset:u}=r,f={offset:u,filter_by:this.#n(t,o),facet_by:"*",per_page:O};return s?.setAttribute("isLoadMore",!0),s?.setAttribute("filter",f.filter_by),this.#d(await this.#e.collections(i).documents().search({...c,...f}),l)}else{const l=this.#n(t,o);s?.setAttribute("filter",l);const u=await this.#e.multiSearch.perform({searches:this.#F(t,o)},c),f=this.#c(u,this.#o());f&&I.warn("Search facet requests failed: %s",f);const p=this.#y(u),m=(p[F]??[]).map(A=>A.value);s?.setAttribute("groups",m.join(",")),m.length===y&&I.warn("Search category facet list reached the limit of %s; results for some categories may be missing",y);const D=[...new Set(this.#m(o))].slice(0,y),g=D.length?D:m;if(!g.length)return{facets:p,documents:{},groupCounts:{}};const S=await this.#e.multiSearch.perform({searches:g.map(A=>({filter_by:`${l} && (${F}:=${this.#a(A)})`,per_page:O}))},c),$=this.#c(S,g);return $&&I.warn("Search category requests failed: %s",$),this.#_(S,g,p,o)}else return{facets:{},documents:{}}})}#d(e,t){const s={facets:{},documents:{[t]:[]},groupCounts:typeof e.found=="number"?{[t]:e.found}:{}};if(e.hits&&e.hits.length)for(const a of e.hits)s.documents[t].push({document:this.#l(a),highlight:this.#u(a)});return s}#y(e){const t={};if("results"in e){for(const s of e.results)if(s.facet_counts&&s.facet_counts.length)for(const a of s.facet_counts)t[a.field_name]=a.counts.map(n=>({value:n.value,count:n.count}))}return t}#c(e,t){return"results"in e?e.results.map((s,a)=>({result:s,label:t[a]})).filter(({result:s})=>"error"in s).map(({result:s,label:a})=>`${a}: ${s.error}`).join("; "):""}#_(e,t,s,a){const n={},o={facets:s,documents:{},groupCounts:n};for(const r of this.#m(a))o.documents[r]=[];return"results"in e&&e.results.forEach((r,i)=>{const c=t[i];typeof r.found=="number"&&(n[c]=r.found);const l=r.hits??[];l.length&&(o.documents[c]=l.map(u=>({document:this.#l(u),highlight:this.#u(u)})))}),o}#l(e){return this.#g(e)}#u(e){const t={},s=[];for(const[a,n]of Object.entries(e.highlight??{}))if(Array.isArray(n)){if(a==="path"){const o=n,r=[];for(const i of o)r.push(i.snippet);t.path=r}else if(a==="parameters"){const o=n;for(const r of o){let i=!1;for(const[c,l]of Object.entries(r))if(c!=="deepLink")if(Array.isArray(l))for(const u of l)u.matched_tokens?.length&&(i=!0);else l.matched_tokens?.length&&(i=!0);if(i){const c={name:r.name?.snippet||"",description:r.description?.snippet||"",place:r.place?.snippet||"",path:r.path?.map(l=>l?.snippet)||[]};t.parameters=[c];break}}}}else t[a]=n.snippet,s.push(a);for(const[a,n]of Object.entries(e.document))!s.includes(a)&&typeof n=="string"&&(t[a]=n.length>C?`${n.substring(0,C)}...`:n);return t.parameters||(t.parameters=[]),t}#g(e){let t;const s=Object.keys(e.highlight??{});for(const n of v)if(s.some(o=>o===n))return e.document;const a=e.highlight?.parameters;if(a){for(const n of a)for(const[o,r]of Object.entries(n))if(o!=="deepLink"){if(Array.isArray(r)){for(const i of r)if(i.matched_tokens?.length){t=n.deepLink?.snippet??t;break}}else if(r.matched_tokens?.length){t=n.deepLink?.snippet??t;break}}}if(t){const n=t.split("#")[1];return{...e.document,url:`${e.document.url}#${n}`}}return e.document}async exportDocuments(e){const t='{"documents":[',s=E(b.join(e,R));for(const[a,n]of this.#s){if(n.length===0)continue;const o=E(b.join(s,`${a}.json`)),r=!P(o),i=JSON.stringify(n).substring(1).slice(0,-1),c=r?t+i:","+i;await T(o,c,{encoding:"utf8"}),this.#s.set(a,[])}}async exportIndexes(e){const t=E(b.join(e,R));for(const s of this.#s.keys()){const a=E(b.join(t,`${s}.json`)),n=`],"schemaFields":${JSON.stringify(this.#t)}}`;await T(a,n,{encoding:"utf8"})}}async import(e){}async countFacets(e,t){return await N("com.redocly.search.facets",async s=>{s?.setAttribute("id","searchFacetsId"),s?.setAttribute("object","searchFacets"),s?.setAttribute("uri","urn:redocly:realm:api:searchFacets:searchFacetsId");const{locale:a,query:n,facetQuery:o,filter:r,field:i}=e,c=this.#f(a),l={q:n||"*",query_by:this.#h(),facet_by:"*",facet_query:this.#A(o,i),filter_by:this.#n(t,r,i),max_facet_values:y,per_page:0};if(s?.setAttribute("collectionName",c),s?.setAttribute("query",l.q),s?.setAttribute("facetQuery",l.facet_query),s?.setAttribute("filter",l.filter_by),this.#e){const u={},f=await this.#e.collections(c).documents().search(l);if(f.facet_counts&&f.facet_counts.length)for(const p of f.facet_counts)u[p.field_name]=p.counts.map(m=>({value:m.value,count:m.count,isCounterVisible:!!n||(r?.length||0)>0}));return u}else return{}})}#f(e){return`${this.#i}${e}`}#b(e){for(const[t,{queryable:s}]of e)this.#t.find(a=>a.name===t)||this.#t.push({queryable:s,name:t,type:"string",facet:!0,optional:!0})}#h(){return this.#t.filter(e=>e.facet?e.queryable:e.queryable!==!1).map(e=>e.name).join(",")}#a(e){return`\`${e.replaceAll("`","")}\``}#n(e,t,s){const a=e.teams.filter(r=>!r.includes("`")&&!r.includes("*")).map(r=>this.#a(r)),n=a.length?`${d}:=[${a.join(", ")}]`:`${d}:=[\`anonymous\`] && ${d}:!=[\`anonymous\`]`,o=(t??[]).filter(r=>r.field!==s&&r.field!==h&&r.values.length&&this.#p(r.field)).map(r=>{const i=r.values.map(c=>this.#a(c));return`${r.field}:=[${i.join(", ")}]`});return[n,...o,this.#E(t)].map(r=>`(${r})`).join(" && ")}#p(e){return this.#o().includes(e)}#o(){return this.#t.filter(e=>e.facet&&e.name!==d&&e.name===e.name.trim()).map(e=>e.name)}#E(e){const t=e?.find(r=>r.field===h);if(t?.values.length!==2)return`${h}.isDefault:true`;const[s,a]=t.values.map(r=>this.#a(r)),n=`(${h}.folderId:! ${s} && ${h}.isDefault:true)`,o=`(${h}.folderId: ${s} && ${h}.version:=${a})`;return`${n} || ${o}`}#A(e,t){return e&&t&&this.#p(t)?`${t}:${e}`:""}#m(e){const t=[];if(e&&e.length)for(const s of e)s.field===F&&t.push(...s.values);return t}#F(e,t){const s=[];for(const a of this.#o()){const n={facet_by:a,filter_by:this.#n(e,t,a),per_page:0};s.push(n)}return s}cleanupFacetValues(e){const t=e.getSearchFacets();t.forEach(s=>{s.values=[]}),e.setSearchFacets(t)}}export{X as Typesense};
1
+ import{appendFile as T}from"node:fs/promises";import{existsSync as P}from"node:fs";import b from"node:path";import{Client as q}from"typesense";import{SEARCH_GROUP_FACET_FIELD as F,SEARCH_PRODUCT_FIELD as L,SEARCH_RBAC_FIELD as d,SEARCH_VERSION_FIELD as h}from"../../../../../constants/common.js";import{DISABLE_DEEP_LINK_IF_FIELDS_EXIST as v,SEARCH_DATA_EXPORT_FOLDER as C,SEARCH_DOCUMENT_METADATA_KEY as j,SEARCH_GROUP_LIMIT as R,SEARCH_MAX_FACET_VALUES as y,SEARCH_MAX_INMEMORY_DOCUMENTS_COUNT as k}from"../../../../constants/plugins/search.js";import{telemetryTraceStep as O}from"../../../../telemetry/helpers/trace-step.js";import{envConfig as _}from"../../../../config/env-config.js";import{logger as I}from"../../../../tools/notifiers/logger.js";import{HIGHLIGHTED_TEXT_MAX_LENGTH as N}from"@redocly/theme/core/utils/search-highlight";import{ensureDir as E}from"../../../../utils/index.js";class J{#e=null;#i="";#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:"parameters.name",type:"string[]",facet:!1,optional:!0,queryable:!1},{name:"parameters.description",type:"string[]",facet:!1,optional:!0,queryable:!1},{name:"parameters.place",type:"string[]",facet:!1,optional:!0,queryable:!1},{name:"parameters.path",type:"string[]",facet:!1,optional:!0,queryable:!1},{name:L,type:"string",facet:!0,optional:!0},{name:h,type:"object",facet:!0,optional:!0},{name:d,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;#r={ORGANIZATION_ID:_.ORGANIZATION_ID??"",PROJECT_ID:_.PROJECT_ID??"",TYPESENSE_API_URL:_.TYPESENSE_API_URL??"",TYPESENSE_API_KEY:_.TYPESENSE_API_KEY??""};constructor(){if(!_.isBuildMode){for(const[e,t]of Object.entries(this.#r))if(!t)throw new Error(`Cannot initialize search index. ${e} is not set`);this.#i=`${this.#r.ORGANIZATION_ID}_${this.#r.PROJECT_ID}_`,this.#e=new q({nodes:[{url:this.#r.TYPESENSE_API_URL}],apiKey:this.#r.TYPESENSE_API_KEY,connectionTimeoutSeconds:5})}}async initIndexSchema(e){this.#b(e)}async addDocuments(e,t){const{locale:s,outDir:a}=t,n=e.map(r=>{const i={...r},c=r[j];return c&&(c.curated&&(i.metadata_curated=c.curated),c.excludes&&(i.metadata_keywords_excludes=c.excludes),c.includes&&(i.metadata_keywords_includes=c.includes)),i}),o=this.#s.get(s)??[];this.#s.set(s,o.concat(n)),o.length+e.length>=k&&await this.exportDocuments(a)}async search(e,t){return await O("com.redocly.search.performed",async s=>{s?.setAttribute("id","searchQueryId"),s?.setAttribute("object","searchQuery"),s?.setAttribute("uri","urn:redocly:realm:api:searchQuery:searchQueryId");const{query:a,locale:n,filter:o,loadMore:r}=e,i=this.#f(n),c={collection:i,q:a||"*",query_by:this.#h(),max_facet_values:y};if(s?.setAttribute("collectionName",i),s?.setAttribute("locale",n),this.#e)if(r){const{groupKey:l,offset:u}=r,f={offset:u,filter_by:this.#n(t,o),facet_by:"*",per_page:R};return s?.setAttribute("isLoadMore",!0),s?.setAttribute("filter",f.filter_by),this.#d(await this.#e.collections(i).documents().search({...c,...f}),l)}else{const l=this.#n(t,o);s?.setAttribute("filter",l);const u=await this.#e.multiSearch.perform({searches:this.#F(t,o)},c),f=this.#c(u,this.#o());f&&I.warn("Search facet requests failed: %s",f);const p=this.#y(u),m=(p[F]??[]).map(A=>A.value);s?.setAttribute("groups",m.join(",")),m.length===y&&I.warn("Search category facet list reached the limit of %s; results for some categories may be missing",y);const D=[...new Set(this.#m(o))].slice(0,y),g=D.length?D:m;if(!g.length)return{facets:p,documents:{},groupCounts:{}};const S=await this.#e.multiSearch.perform({searches:g.map(A=>({filter_by:`${l} && (${F}:=${this.#a(A)})`,per_page:R}))},c),$=this.#c(S,g);return $&&I.warn("Search category requests failed: %s",$),this.#_(S,g,p,o)}else return{facets:{},documents:{}}})}#d(e,t){const s={facets:{},documents:{[t]:[]},groupCounts:typeof e.found=="number"?{[t]:e.found}:{}};if(e.hits&&e.hits.length)for(const a of e.hits)s.documents[t].push({document:this.#l(a),highlight:this.#u(a)});return s}#y(e){const t={};if("results"in e){for(const s of e.results)if(s.facet_counts&&s.facet_counts.length)for(const a of s.facet_counts)t[a.field_name]=a.counts.map(n=>({value:n.value,count:n.count}))}return t}#c(e,t){return"results"in e?e.results.map((s,a)=>({result:s,label:t[a]})).filter(({result:s})=>"error"in s).map(({result:s,label:a})=>`${a}: ${s.error}`).join("; "):""}#_(e,t,s,a){const n={},o={facets:s,documents:{},groupCounts:n};for(const r of this.#m(a))o.documents[r]=[];return"results"in e&&e.results.forEach((r,i)=>{const c=t[i];typeof r.found=="number"&&(n[c]=r.found);const l=r.hits??[];l.length&&(o.documents[c]=l.map(u=>({document:this.#l(u),highlight:this.#u(u)})))}),o}#l(e){return this.#g(e)}#u(e){const t={},s=[];for(const[a,n]of Object.entries(e.highlight??{}))if(Array.isArray(n)){if(a==="path"){const o=n,r=[];for(const i of o)r.push(i.snippet);t.path=r}else if(a==="parameters"){const o=n;for(const r of o){let i=!1;for(const[c,l]of Object.entries(r))if(c!=="deepLink")if(Array.isArray(l))for(const u of l)u.matched_tokens?.length&&(i=!0);else l.matched_tokens?.length&&(i=!0);if(i){const c={name:r.name?.snippet||"",description:r.description?.snippet||"",place:r.place?.snippet||"",path:r.path?.map(l=>l?.snippet)||[]};t.parameters=[c];break}}}}else t[a]=n.snippet,s.push(a);for(const[a,n]of Object.entries(e.document))!s.includes(a)&&typeof n=="string"&&(t[a]=n.length>N?`${n.substring(0,N)}...`:n);return t.parameters||(t.parameters=[]),t}#g(e){let t;const s=Object.keys(e.highlight??{});for(const n of v)if(s.some(o=>o===n))return e.document;const a=e.highlight?.parameters;if(a){for(const n of a)for(const[o,r]of Object.entries(n))if(o!=="deepLink"){if(Array.isArray(r)){for(const i of r)if(i.matched_tokens?.length){t=n.deepLink?.snippet??t;break}}else if(r.matched_tokens?.length){t=n.deepLink?.snippet??t;break}}}if(t){const n=t.split("#")[1];return{...e.document,url:`${e.document.url}#${n}`}}return e.document}async exportDocuments(e){const t='{"documents":[',s=E(b.join(e,C));for(const[a,n]of this.#s){if(n.length===0)continue;const o=E(b.join(s,`${a}.json`)),r=!P(o),i=JSON.stringify(n).substring(1).slice(0,-1),c=r?t+i:","+i;await T(o,c,{encoding:"utf8"}),this.#s.set(a,[])}}async exportIndexes(e){const t=E(b.join(e,C));for(const s of this.#s.keys()){const a=E(b.join(t,`${s}.json`)),n=`],"schemaFields":${JSON.stringify(this.#t)}}`;await T(a,n,{encoding:"utf8"})}}async import(e){}async countFacets(e,t){return await O("com.redocly.search.facets",async s=>{s?.setAttribute("id","searchFacetsId"),s?.setAttribute("object","searchFacets"),s?.setAttribute("uri","urn:redocly:realm:api:searchFacets:searchFacetsId");const{locale:a,query:n,facetQuery:o,filter:r,field:i}=e,c=this.#f(a),l={q:n||"*",query_by:this.#h(),facet_by:"*",facet_query:this.#A(o,i),filter_by:this.#n(t,r,i),max_facet_values:y,per_page:0};if(s?.setAttribute("collectionName",c),s?.setAttribute("query",l.q),s?.setAttribute("facetQuery",l.facet_query),s?.setAttribute("filter",l.filter_by),this.#e){const u={},f=await this.#e.collections(c).documents().search(l);if(f.facet_counts&&f.facet_counts.length)for(const p of f.facet_counts)u[p.field_name]=p.counts.map(m=>({value:m.value,count:m.count,isCounterVisible:!!n||(r?.length||0)>0}));return u}else return{}})}#f(e){return`${this.#i}${e}`}#b(e){for(const[t,{queryable:s}]of e)this.#t.find(a=>a.name===t)||this.#t.push({queryable:s,name:t,type:"string",facet:!0,optional:!0})}#h(){return this.#t.filter(e=>e.facet?e.queryable:e.queryable!==!1).map(e=>e.name).join(",")}#a(e){return`\`${e.replaceAll("`","")}\``}#n(e,t,s){const a=e.teams.filter(r=>!r.includes("`")&&!r.includes("*")).map(r=>this.#a(r)),n=a.length?`${d}:=[${a.join(", ")}]`:`${d}:=[\`anonymous\`] && ${d}:!=[\`anonymous\`]`,o=(t??[]).filter(r=>r.field!==s&&r.field!==h&&r.values.length&&this.#p(r.field)).map(r=>{const i=r.values.map(c=>this.#a(c));return`${r.field}:=[${i.join(", ")}]`});return[n,...o,this.#E(t)].map(r=>`(${r})`).join(" && ")}#p(e){return this.#o().includes(e)}#o(){return this.#t.filter(e=>e.facet&&e.name!==d&&e.name===e.name.trim()).map(e=>e.name)}#E(e){const t=e?.find(r=>r.field===h);if(t?.values.length!==2)return`${h}.isDefault:true`;const[s,a]=t.values.map(r=>this.#a(r)),n=`(${h}.folderId:! ${s} && ${h}.isDefault:true)`,o=`(${h}.folderId: ${s} && ${h}.version:=${a})`;return`${n} || ${o}`}#A(e,t){return e&&t&&this.#p(t)?`${t}:${e}`:""}#m(e){const t=[];if(e&&e.length)for(const s of e)s.field===F&&t.push(...s.values);return t}#F(e,t){const s=[];for(const a of this.#o()){const n={facet_by:a,filter_by:this.#n(e,t,a),per_page:0};s.push(n)}return s}cleanupFacetValues(e){const t=e.getSearchFacets();t.forEach(s=>{s.values=[]}),e.setSearchFacets(t)}}export{J as Typesense};
@@ -1 +1 @@
1
- import{normalizePathPrefix as t}from"@redocly/theme/core/utils";import{shaHexShort as h}from"./sha-hex-short.js";function n(r){const o=r==="."?"/":t(r);return h(o)}export{n as shaDirPathShort};
1
+ import{addLeadingSlash as a,removeTrailingSlash as t}from"@redocly/theme/core/utils";import{shaHexShort as h}from"./sha-hex-short.js";function m(r){const o=r==="."?"/":a(t(r));return h(o)}export{m as shaDirPathShort};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/redoc-reef",
3
- "version": "0.141.0-next.14",
3
+ "version": "0.141.0-next.15",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,14 +33,14 @@
33
33
  "@opentelemetry/sdk-trace-web": "2.8.0",
34
34
  "@opentelemetry/semantic-conventions": "1.40.0",
35
35
  "@redocly/ajv": "8.18.0",
36
- "@redocly/api-docs": "0.6.0-next.14",
36
+ "@redocly/api-docs": "0.6.0-next.15",
37
37
  "@redocly/config": "0.75.0",
38
38
  "@redocly/markdoc": "0.7.1",
39
39
  "@redocly/openapi-core": "2.78.0",
40
40
  "@redocly/portal-legacy-ui": "0.19.0",
41
41
  "@redocly/portal-plugin-mock-server": "0.26.0-next.4",
42
42
  "@redocly/realm-asyncapi-sdk": "0.18.0-next.1",
43
- "@redocly/theme": "0.73.0-next.10",
43
+ "@redocly/theme": "0.73.0-next.11",
44
44
  "@shikijs/transformers": "3.21.0",
45
45
  "@tanstack/react-query": "5.62.3",
46
46
  "@tanstack/react-table": "8.21.3",
@@ -1,3 +0,0 @@
1
- export declare function highlightTextForSearch(query: string, text: string): string;
2
- export declare function markMatchedValue(query: string, value: string): string | undefined;
3
- //# sourceMappingURL=highlight-text-for-search.d.ts.map
@@ -1 +0,0 @@
1
- import{HIGHLIGHTED_TEXT_MAX_LENGTH as f}from"../../constants/plugins/search.js";import{MIN_INFIX_MATCH_LENGTH as h,MIN_QUERY_WORD_LENGTH as g,isWordChar as c,matchableQueryWords as m}from"./text-match.js";function w(t,e){if(!e)return"";const r=p(t);if(!r.length)return e;const n=f+t.length;if(e.length<=n)return u(r,e);const o=M(l(r,e),n)??{start:0,end:0},{start:s,end:d}=_(e,o,n),a=u(r,e.slice(s,d));return`${s>0?"...":""}${a}${d<e.length?"...":""}`}function I(t,e){if(!e)return;const r=w(t,e);return r.includes("<mark>")?r:void 0}function p(t){return m(t).sort((e,r)=>r.length-e.length)}function l(t,e){const r=e.toLowerCase(),n=[];for(const o of t)for(let s=r.indexOf(o);s!==-1;s=r.indexOf(o,s+1)){const d=!c(r[s-1]);if(!d&&o.length<h||o.length<g&&c(r[s+o.length]))continue;let a=s+o.length;if(d)for(;c(r[a]);)a++;n.push({start:s,end:a,word:o})}return n.sort((o,s)=>o.start-s.start||o.end-s.end)}function M(t,e){let r;for(let n=0;n<t.length;n++){const o=new Set;let s=t[n].end;for(let a=n;a<t.length&&t[a].end-t[n].start<=e;a++)o.has(t[a].word)||(o.add(t[a].word),s=t[a].end);const d=s-t[n].start;(!r||o.size>r.count||o.size===r.count&&d<r.end-r.start)&&(r={start:t[n].start,end:s,count:o.size})}return r&&{start:r.start,end:r.end}}function _(t,e,r){const n=Math.max(r,e.end-e.start),o=n-(e.end-e.start),s=Math.min(t.length,Math.max(0,Math.floor(e.start-o/2))+n),d=Math.max(0,s-n);return{start:H(t,d,e.start),end:T(t,s,e.end)}}function H(t,e,r){let n=e;if(n>0&&!i(t[n-1]))for(;n<r&&!i(t[n]);)n++;for(;n<r&&i(t[n]);)n++;return n}function T(t,e,r){let n=e;if(n<t.length&&!i(t[n]))for(;n>r&&!i(t[n]);)n--;for(;n>r&&i(t[n-1]);)n--;return n}function i(t){return t!==void 0&&/\s/.test(t)}function u(t,e){const r=l(t,e);if(!r.length)return e;const n=[];for(const d of r){const a=n[n.length-1];a&&(d.start<=a.end||!e.slice(a.end,d.start).trim())?a.end=Math.max(a.end,d.end):n.push({start:d.start,end:d.end})}let o="",s=0;for(const d of n)o+=`${e.slice(s,d.start)}<mark>${e.slice(d.start,d.end)}</mark>`,s=d.end;return o+e.slice(s)}export{w as highlightTextForSearch,I as markMatchedValue};
@@ -1,6 +0,0 @@
1
- export declare const MIN_QUERY_WORD_LENGTH = 2;
2
- export declare const MIN_INFIX_MATCH_LENGTH = 3;
3
- export declare function isWordChar(char: string | undefined): boolean;
4
- export declare function matchableQueryWords(query: string): string[];
5
- export declare function containsQueryWord(lowered: string, word: string): boolean;
6
- //# sourceMappingURL=text-match.d.ts.map
@@ -1 +0,0 @@
1
- const i=2,o=3,r=/[\p{L}\p{N}_-]/u;function _(t){return t!==void 0&&r.test(t)}function s(t){const n=[...new Set(t.toLowerCase().split(/\s+/g).filter(Boolean))];return n.some(e=>e.length>=2)?n:[]}function u(t,n){if(n.length>=3)return t.includes(n);for(let e=t.indexOf(n);e!==-1;e=t.indexOf(n,e+1))if(!_(t[e-1])&&(n.length>=2||!_(t[e+n.length])))return!0;return!1}export{o as MIN_INFIX_MATCH_LENGTH,i as MIN_QUERY_WORD_LENGTH,u as containsQueryWord,_ as isWordChar,s as matchableQueryWords};