@redocly/realm 0.131.0 → 0.132.0-next.1

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 (54) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/client/app/hooks/catalog/useCatalogSort.d.ts +1 -1
  3. package/dist/client/app/hooks/catalog/useCatalogSort.js +1 -1
  4. package/dist/client/app/hooks/catalog/useFetchCatalogEntities.js +1 -1
  5. package/dist/client/app/l10n/hooks/useTranslate.js +1 -1
  6. package/dist/client/app/markdoc/custom-components/ExcalidrawRenderer.d.ts +8 -0
  7. package/dist/client/app/markdoc/custom-components/ExcalidrawRenderer.js +14 -0
  8. package/dist/client/app/markdoc/custom-components/index.d.ts +1 -0
  9. package/dist/client/app/markdoc/custom-components/index.js +1 -1
  10. package/dist/markdoc/helpers/extract-rbac-from-condition-node.d.ts +6 -15
  11. package/dist/markdoc/helpers/extract-rbac-from-condition-node.js +1 -1
  12. package/dist/markdoc/helpers/guards/is-function.d.ts +1 -0
  13. package/dist/markdoc/helpers/guards/is-variable.d.ts +3 -3
  14. package/dist/markdoc/nodes/fence/index.js +1 -1
  15. package/dist/markdoc/tags/excalidraw.d.ts +3 -0
  16. package/dist/markdoc/tags/excalidraw.js +1 -0
  17. package/dist/markdoc/tags/index.d.ts +4 -0
  18. package/dist/markdoc/tags/index.js +1 -1
  19. package/dist/server/config/env-config.d.ts +1 -0
  20. package/dist/server/config/env-config.js +1 -1
  21. package/dist/server/config/env-schema.d.ts +3 -3
  22. package/dist/server/config/env-schemas/server-config.d.ts +3 -3
  23. package/dist/server/config/env-schemas/server-config.js +1 -1
  24. package/dist/server/esbuild/esbuild-logger.js +3 -3
  25. package/dist/server/fs/fast-mtime.js +3 -3
  26. package/dist/server/plugins/api-functions/helpers/parse-route-fs-path-for-hono.js +1 -1
  27. package/dist/server/plugins/api-functions/index.js +1 -1
  28. package/dist/server/plugins/asyncapi-docs/get-server-props.js +1 -1
  29. package/dist/server/plugins/asyncapi-docs/index.js +1 -1
  30. package/dist/server/plugins/catalog-entities/get-server-props.js +1 -1
  31. package/dist/server/plugins/markdown/search/get-search-documents.d.ts +1 -1
  32. package/dist/server/plugins/markdown/search/get-search-documents.js +2 -2
  33. package/dist/server/plugins/markdown/search/nodes/section-node.d.ts +2 -2
  34. package/dist/server/plugins/markdown/search/nodes/section-node.js +1 -1
  35. package/dist/server/plugins/markdown/search/walk-sections.js +1 -1
  36. package/dist/server/plugins/openapi-docs/get-server-props.js +1 -1
  37. package/dist/server/plugins/openapi-docs/index.js +1 -1
  38. package/dist/server/plugins/openapi-docs/search-indexer.js +1 -1
  39. package/dist/server/plugins/scorecard-classic/compute-scorecard.js +4 -4
  40. package/dist/server/plugins/search/engines/flexsearch/search-index.js +1 -1
  41. package/dist/server/plugins/sidebars/index.d.ts +1 -1
  42. package/dist/server/plugins/sidebars/index.js +2 -2
  43. package/dist/server/plugins/utils.d.ts +4 -0
  44. package/dist/server/plugins/utils.js +1 -1
  45. package/dist/server/providers/database/pagination/after-and-before.js +1 -1
  46. package/dist/server/providers/database/pagination/utils/create-cursor.d.ts +7 -1
  47. package/dist/server/providers/database/pagination/utils/create-cursor.js +1 -1
  48. package/dist/server/tools/notifiers/formatter.js +3 -3
  49. package/dist/server/tools/notifiers/helpers/colors.js +1 -1
  50. package/dist/server/utils/search/highlight-text-for-search.d.ts +2 -0
  51. package/dist/server/utils/search/highlight-text-for-search.js +1 -0
  52. package/dist/server/web-server/routes/feedback.js +1 -1
  53. package/dist/server/web-server/utils/prepare-list-response.js +1 -1
  54. package/package.json +10 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # @redocly/realm
2
2
 
3
+ ## 0.132.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 4003b73d9ca: Added `excalidraw` Markdoc tag to support Excalidraw integration.
8
+
9
+ ### Patch Changes
10
+
11
+ - 6561be12489: Fixed an issue where the "Last updated" date displayed incorrect values on project pages.
12
+ - 60b9b77bc39: Fixed a bug that caused search result highlighting to break in Flexsearch when the query contained duplicate words.
13
+ - f1edba375c0: Updated translate memoization to depend on the active language, ensuring hooks recompute and translations update on language switch.
14
+ - ae3272861b4: Added support for `x-badges` in OpenAPI and AsyncAPI parameters and schema properties.
15
+ Badges can now be rendered before and after field names.
16
+ - 87a97521127: Fixed an issue where `partial` Markdoc tags in OpenAPI and AsyncAPI `description` fields did not resolve when path separators differed.
17
+ - Updated dependencies [4003b73d9ca]
18
+ - Updated dependencies [ae3272861b4]
19
+ - Updated dependencies [87a97521127]
20
+ - Updated dependencies [b24ffd4d9fb]
21
+ - @redocly/theme@0.64.0-next.1
22
+ - @redocly/asyncapi-docs@1.9.0-next.1
23
+ - @redocly/openapi-docs@3.20.0-next.1
24
+ - @redocly/graphql-docs@1.9.0-next.1
25
+ - @redocly/portal-plugin-mock-server@0.17.0-next.1
26
+
27
+ ## 0.132.0-next.0
28
+
29
+ ### Minor Changes
30
+
31
+ - ce5a165177d: Added support for `or` functions in RBAC conditions within Markdoc content.
32
+
33
+ ### Patch Changes
34
+
35
+ - ce5a165177d: Fixed a bug where Markdoc content wrapped in an RBAC condition did not appear in search results for users with access.
36
+ - b3e65a364b6: Fixed out-of-memory error in the search indexer that occurred when indexing deeply nested schemas.
37
+ - cd5f1c2d680: Fixed an issue in `scorecardClassic` where the `minimumLevel` calculation in `targets` resulted in incorrect values.
38
+ - ea340565546: Fixed an issue where the catalog tile descriptions displayed Markdown syntax as raw text.
39
+ - f90fa0dd771: Enter prerelease mode.
40
+ - Updated dependencies [f90fa0dd771]
41
+ - @redocly/portal-plugin-mock-server@0.17.0-next.0
42
+ - @redocly/realm-asyncapi-sdk@0.10.0-next.0
43
+ - @redocly/portal-legacy-ui@0.15.0-next.0
44
+ - @redocly/asyncapi-docs@1.9.0-next.0
45
+ - @redocly/graphql-docs@1.9.0-next.0
46
+ - @redocly/openapi-docs@3.20.0-next.0
47
+ - @redocly/theme@0.64.0-next.0
48
+
3
49
  ## 0.131.0
4
50
 
5
51
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  import type { SortOption } from '@redocly/theme/core/types';
2
- export declare function useCatalogSort(): {
2
+ export declare function useCatalogSort(defaultSortOption?: SortOption | null): {
3
3
  sortOption: SortOption | null;
4
4
  setSortOption: import("react").Dispatch<import("react").SetStateAction<SortOption | null>>;
5
5
  handleSortClick: (sortKey: string, direction: "asc" | "desc") => void;
@@ -1 +1 @@
1
- import{useCallback as c,useEffect as S,useState as m}from"react";import{useSearchParams as p}from"react-router-dom";function h(){const[s,a]=p(),l=s.get("sort")||null,[e,r]=m(l);S(()=>{const t=new URLSearchParams(s);e?t.set("sort",e):t.delete("sort"),a(t,{replace:!0})},[e,s,a]);const u=c((t,n)=>{const o=n==="desc"?t:`-${t}`;r(e===o?null:o)},[e,r]),i=c((t,n)=>{if(!t||!e)return!1;const o=n==="desc"?t:`-${t}`;return e===o},[e]);return{sortOption:e,setSortOption:r,handleSortClick:u,isColumnSorted:i}}export{h as useCatalogSort};
1
+ import{useCallback as c,useEffect as m,useState as p}from"react";import{useSearchParams as f}from"react-router-dom";function O(l){const[s,a]=f(),u=s.get("sort")||null,[e,r]=p(u??l??null);m(()=>{const t=new URLSearchParams(s);e?t.set("sort",e):t.delete("sort"),a(t,{replace:!0})},[e,s,a]);const i=c((t,n)=>{const o=n==="desc"?t:`-${t}`;r(e===o?null:o)},[e,r]),S=c((t,n)=>{if(!t||!e)return!1;const o=n==="desc"?t:`-${t}`;return e===o},[e]);return{sortOption:e,setSortOption:r,handleSortClick:i,isColumnSorted:S}}export{O as useCatalogSort};
@@ -1 +1 @@
1
- import{useInfiniteQuery as y}from"@tanstack/react-query";import{useMemo as m,useRef as w}from"react";import{withPathPrefix as R}from"@redocly/theme/core/utils";import{getNextPageParam as S}from"../../../utils/catalog/get-next-page-param";import{useSearchTracker as F}from"./useSearchTracker";function x({limit:o=20,filter:i,sort:s="type",search:n}={},r){const d=r?r.items.map(e=>e.key).join("-"):[],c=w(!0),l=c.current&&r;c.current&&(c.current=!1);const a=y({queryFn:async e=>{const t=new URLSearchParams;i&&t.append("filter",i),s&&t.append("sort",s),o&&t.append("limit",o.toString()),n&&t.append("search",n),e.pageParam&&Object.entries(e.pageParam).forEach(([P,f])=>{f!=null&&t.append(P,f.toString())});const p=new URL(R("/bff/catalog-entities"),window.location.origin);p.search=t.toString();const u=await fetch(p.toString());if(!u.ok)throw new Error(`Failed to fetch catalog entities from ${p.pathname}`);return u.json()},queryKey:["bff/catalog-entities",{limit:o,filter:i,sort:s,search:n,initialDataKeys:d}],initialData:l?{pages:[r],pageParams:[null]}:void 0,initialPageParam:null,getNextPageParam:S,refetchOnMount:!0,placeholderData:e=>e}),h=m(()=>{const e=a.data?.pages||[];return e[e.length-1]?.page.total},[a.data?.pages]),g=m(()=>(a.data?.pages||[]).flatMap(e=>e.items||[]),[a.data?.pages]);return F({isLoading:a.isLoading||a.isFetching,items:g,apiResource:"entities",searchQuery:n??""}),{query:a,items:g,total:h}}export{x as useFetchCatalogEntities};
1
+ import{useInfiniteQuery as y}from"@tanstack/react-query";import{useMemo as m,useRef as w}from"react";import{withPathPrefix as R}from"@redocly/theme/core/utils";import{getNextPageParam as S}from"../../../utils/catalog/get-next-page-param";import{useSearchTracker as F}from"./useSearchTracker";function x({limit:o=20,filter:i,sort:s="type,title",search:n}={},r){const l=r?r.items.map(e=>e.key).join("-"):[],c=w(!0),d=c.current&&r;c.current&&(c.current=!1);const a=y({queryFn:async e=>{const t=new URLSearchParams;i&&t.append("filter",i),s&&t.append("sort",s),o&&t.append("limit",o.toString()),n&&t.append("search",n),e.pageParam&&Object.entries(e.pageParam).forEach(([P,f])=>{f!=null&&t.append(P,f.toString())});const p=new URL(R("/bff/catalog-entities"),window.location.origin);p.search=t.toString();const u=await fetch(p.toString());if(!u.ok)throw new Error(`Failed to fetch catalog entities from ${p.pathname}`);return u.json()},queryKey:["bff/catalog-entities",{limit:o,filter:i,sort:s,search:n,initialDataKeys:l}],initialData:d?{pages:[r],pageParams:[null]}:void 0,initialPageParam:null,getNextPageParam:S,refetchOnMount:!0,placeholderData:e=>e}),h=m(()=>{const e=a.data?.pages||[];return e[e.length-1]?.page.total},[a.data?.pages]),g=m(()=>(a.data?.pages||[]).flatMap(e=>e.items||[]),[a.data?.pages]);return F({isLoading:a.isLoading||a.isFetching,items:g,apiResource:"entities",searchQuery:n??""}),{query:a,items:g,total:h}}export{x as useFetchCatalogEntities};
@@ -1 +1 @@
1
- import a from"i18next";import{useCallback as l}from"react";const s=(t,e)=>{let n=e&&typeof e=="string"?e:void 0,r=n?void 0:e;return t?a.t(t,{defaultValue:n,...r})||n||t||"":n??""},c=()=>({translate:l(s,[])});export{c as useTranslate};
1
+ import a from"i18next";import{useMemo as u}from"react";import{useL10n as o}from"./useL10n";const d=()=>{const{lang:r}=o();return{translate:u(()=>(n,t)=>{let e=t&&typeof t=="string"?t:void 0,s=e?void 0:t;return n?a.t(n,{defaultValue:e,...s})||e||n||"":e??""},[r])}};export{d as useTranslate};
@@ -0,0 +1,8 @@
1
+ import type { JSX } from 'react';
2
+ type ExcalidrawRendererProps = {
3
+ diagramSource: string;
4
+ className?: string;
5
+ };
6
+ export declare function ExcalidrawRenderer({ diagramSource, className, }: ExcalidrawRendererProps): JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=ExcalidrawRenderer.d.ts.map
@@ -0,0 +1,14 @@
1
+ import o,{useState as f,useEffect as g,useMemo as h,useRef as b}from"react";import x from"styled-components";import{useColorSwitcher as y}from"@redocly/theme/core/hooks";import{ExcalidrawDiagram as k}from"@redocly/theme/markdoc/components/ExcalidrawDiagram/ExcalidrawDiagram";import{SpinnerLoader as S}from"@redocly/theme/components/Loaders/SpinnerLoader";function F({diagramSource:n,className:v}){const{activeColorMode:w}=y(),[u,l]=f(null),[m,r]=f(null),c=b({}),i=w==="dark",s=i?"dark":"light",e=h(()=>{try{return{data:JSON.parse(n),error:null}}catch(a){return{data:null,error:a instanceof Error?a.message:"Failed to parse Excalidraw diagram"}}},[n]);return g(()=>{c.current={},l(null),r(null)},[n]),g(()=>{if(e.error){r(e.error);return}if(!e.data){r("Failed to parse Excalidraw diagram");return}const a=c.current[s];if(a){l(a),r(null);return}let d=!1;async function E(){try{const{exportToSvg:t}=await import("@excalidraw/excalidraw"),p=await t({elements:e.data?.elements||[],appState:{...e.data?.appState||{},exportWithDarkMode:i,exportBackground:!1},files:e.data?.files||null});d||(c.current[s]=p.outerHTML,l(p.outerHTML),r(null))}catch(t){d||r(t instanceof Error?t.message:"Failed to render Excalidraw diagram")}}return r(null),E(),()=>{d=!0}},[e,i,s]),m?o.createElement(M,{className:"excalidraw-wrapper"},m):u?o.createElement(k,{diagramHtml:u,className:v}):o.createElement(H,{className:"excalidraw-wrapper"},o.createElement(S,{color:"var(--border-color-secondary)",size:"32px"}))}const H=x.div`
2
+ background-color: var(--excalidraw-bg-color);
3
+ border-radius: var(--excalidraw-border-radius);
4
+ min-height: 200px;
5
+ display: flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ `,M=x.div`
9
+ background-color: var(--admonition-danger-bg-color);
10
+ color: var(--admonition-danger-text-color);
11
+ border-radius: var(--excalidraw-border-radius);
12
+ padding: var(--spacing-md);
13
+ font-size: var(--font-size-sm);
14
+ `;export{F as ExcalidrawRenderer};
@@ -1,3 +1,4 @@
1
1
  export * from './html-script.js';
2
+ export * from './ExcalidrawRenderer.js';
2
3
  export declare function openapi(): Promise<typeof import("./openapi/index.js")>;
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- export*from"./html-script.js";async function n(){return await import("./openapi/index.js")}export{n as openapi};
1
+ export*from"./html-script.js";export*from"./ExcalidrawRenderer.js";async function n(){return await import("./openapi/index.js")}export{n as openapi};
@@ -1,22 +1,13 @@
1
1
  import type { Node } from '@markdoc/markdoc';
2
2
  /**
3
- * Extracts an RBAC team identifier from a conditional Markdoc node.
3
+ * Extracts RBAC team(s) from a conditional Markdoc node.
4
4
  *
5
- * This function analyzes an `if` conditional node to determine if it contains
6
- * an `includes` function call that checks for RBAC team membership. It specifically
7
- * looks for conditions of the form `includes(rbac.teams, "team-name")`.
5
+ * Supports:
6
+ * - `includes(rbac.teams, "team-name")` returns an array with a single team string.
7
+ * - `or(includes(rbac.teams, "a"), includes(rbac.teams, "b"), ...)` → returns an array of team strings (only if every argument is an RBAC includes condition).
8
8
  *
9
9
  * @param node - The Markdoc conditional node with tag 'if' to analyze.
10
- * @returns The team name as a string if the condition matches the expected RBAC pattern, otherwise `null`.
11
- *
12
- * @example
13
- * ```typescript
14
- * // For a node representing: {% if includes(rbac.teams, "admin") %}
15
- * const teamName = extractRbacFromCondition(node);
16
- * // Returns: "admin"
17
- * ```
10
+ * @returns An array of team names, or `undefined` if the condition does not match an RBAC pattern.
18
11
  */
19
- export declare function extractRbacFromCondition(node: Node & {
20
- tag: 'if';
21
- }): string | null;
12
+ export declare function extractRbacFromCondition(node: Node): string[] | undefined;
22
13
  //# sourceMappingURL=extract-rbac-from-condition-node.d.ts.map
@@ -1 +1 @@
1
- function n(t){const a=t.attributes.primary?.name==="includes",r=t.attributes.primary?.parameters;return a&&Array.isArray(r)&&r[0]?.path?.[0]==="rbac"&&r[0]?.path?.[1]==="teams"?r[1]:null}export{n as extractRbacFromCondition};
1
+ import{isFunction as o}from"./guards/is-function.js";import{isVariable as c}from"./guards/is-variable.js";import{isConditionalNode as s}from"./guards/is-conditional-node.js";function i(n){const t=n.parameters;if(typeof t!="object")return;const r=t?.[0],e=t?.[1];if(!(!c(r)||typeof e!="string")&&!(r.path?.[0]!=="rbac"||r.path?.[1]!=="teams"))return e}function m(n){const t=n.parameters,r=[];for(const e of Object.values(t)){if(!o(e)||e.name!=="includes")continue;const a=i(e);a&&r.push(a)}return r}function b(n){if(!s(n))return;const t=n.attributes.primary;if(o(t)){if(t.name==="or")return m(t);if(t.name==="includes"){const r=i(t);if(r)return[r]}}}export{b as extractRbacFromCondition};
@@ -1,3 +1,4 @@
1
+ import type { Function } from '@markdoc/markdoc';
1
2
  /**
2
3
  * Checks whether the given value is a Markdoc `Function` node.
3
4
  *
@@ -1,13 +1,13 @@
1
1
  import type { Variable } from '@markdoc/markdoc';
2
2
  /**
3
- * Checks if a given value is a Markdoc `Variable` or `Node` of type `Variable`.
3
+ * Checks if a given value is a Markdoc `Variable`.
4
4
  *
5
5
  * A valid variable must:
6
6
  * - Be an object with a `$$mdtype` property
7
7
  * - Have `$$mdtype` equal to `'Variable'`
8
8
  *
9
9
  * @param value - Any value to check.
10
- * @returns `true` if the value is a Markdoc `Variable` or `Node` with type `'Variable'`, otherwise `false`.
10
+ * @returns `true` if the value is a Markdoc `Variable`, otherwise `false`.
11
11
  */
12
- export declare function isVariable(value?: unknown): value is Variable | Node;
12
+ export declare function isVariable(value?: unknown): value is Variable;
13
13
  //# sourceMappingURL=is-variable.d.ts.map
@@ -1 +1 @@
1
- import a from"@markdoc/markdoc";import{isPrimitive as m}from"../../../utils/guards/is-primitive.js";import{isStringNode as s}from"../../helpers/guards/is-string-node.js";import{isTag as u}from"../../helpers/guards/is-tag.js";const g=a.nodes.fence,w={...g,attributes:{...g.attributes,label:{type:String,render:"data-label"},title:{type:String,render:"data-title"},highlight:{type:String,render:"data-highlight"}},transform(r,i){const e=r.transformAttributes(i);let t=r.transformChildren(i);const o=e["data-language"],l=e["data-title"];switch(r.attributes.process===!1&&(t=[r.attributes.content]),o){case"mermaid":return s(t[0])?new a.Tag("Mermaid",{...e,diagramSource:t[0]},t):new a.Tag(r.tag,e,t);default:const c=t.map(n=>m(n)?n.toString():u(n)?n?.attributes?.rawtag:"").join("");return s(t[0])?new a.Tag("CodeBlock",{...e,header:{title:l,controls:{copy:{}}},source:c,lang:o},[]):new a.Tag(r.tag,e,t)}}};export{w as fence};
1
+ import a from"@markdoc/markdoc";import{isPrimitive as u}from"../../../utils/guards/is-primitive.js";import{isStringNode as i}from"../../helpers/guards/is-string-node.js";import{isTag as m}from"../../helpers/guards/is-tag.js";const g=a.nodes.fence,h={...g,attributes:{...g.attributes,label:{type:String,render:"data-label"},title:{type:String,render:"data-title"},highlight:{type:String,render:"data-highlight"}},transform(e,s){const r=e.transformAttributes(s);let t=e.transformChildren(s);const o=r["data-language"],c=r["data-title"];switch(e.attributes.process===!1&&(t=[e.attributes.content]),o){case"mermaid":return i(t[0])?new a.Tag("Mermaid",{...r,diagramSource:t[0]},t):new a.Tag(e.tag,r,t);case"excalidraw":return i(t[0])?new a.Tag("ExcalidrawRenderer",{...r,diagramSource:t[0]},t):new a.Tag(e.tag,r,t);default:const l=t.map(n=>u(n)?n.toString():m(n)?n?.attributes?.rawtag:"").join("");return i(t[0])?new a.Tag("CodeBlock",{...r,header:{title:c,controls:{copy:{}}},source:l,lang:o},[]):new a.Tag(e.tag,r,t)}}};export{h as fence};
@@ -0,0 +1,3 @@
1
+ import type { CustomMarkdocTag } from '../types.js';
2
+ export declare const excalidraw: CustomMarkdocTag;
3
+ //# sourceMappingURL=excalidraw.d.ts.map
@@ -0,0 +1 @@
1
+ import a from"@markdoc/markdoc";import{RawContent as s}from"../attributes/raw-content.js";const c={schema:{attributes:{src:{type:s,required:!0},srcRawContent:{type:String,render:!1}},render:"ExcalidrawRenderer",selfClosing:!0,transform:(r,n)=>{const t=r.transformAttributes(n),e=r.attributes.srcRawContent;return typeof e=="string"?new a.Tag("ExcalidrawRenderer",{...t,diagramSource:e},[]):new a.Tag(r.tag,t,[])}},tagName:"excalidraw"};export{c as excalidraw};
@@ -4,6 +4,7 @@ import { openApiExample } from './openapi-example.js';
4
4
  import { replayOpenApi } from './replay-openapi.js';
5
5
  import { openApiResponseSample } from './openapi-response-sample.js';
6
6
  import { jsonExample } from './json-example.js';
7
+ import { excalidraw } from './excalidraw.js';
7
8
  declare const _default: {
8
9
  [jsonSchema.tagName]: import("@markdoc/markdoc").Schema & {
9
10
  dynamicComponentLib?: string;
@@ -23,6 +24,9 @@ declare const _default: {
23
24
  [jsonExample.tagName]: import("@markdoc/markdoc").Schema & {
24
25
  dynamicComponentLib?: string;
25
26
  };
27
+ [excalidraw.tagName]: import("@markdoc/markdoc").Schema & {
28
+ dynamicComponentLib?: string;
29
+ };
26
30
  };
27
31
  export default _default;
28
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- import{jsonSchema as m}from"./json-schema.js";import{openApiCodeSample as e}from"./openapi-code-sample.js";import{openApiExample as a}from"./openapi-example.js";import{replayOpenApi as p}from"./replay-openapi.js";import{openApiResponseSample as o}from"./openapi-response-sample.js";import{jsonExample as r}from"./json-example.js";var n={[m.tagName]:m.schema,[e.tagName]:e.schema,[a.tagName]:a.schema,[p.tagName]:p.schema,[o.tagName]:o.schema,[r.tagName]:r.schema};export{n as default};
1
+ import{jsonSchema as m}from"./json-schema.js";import{openApiCodeSample as a}from"./openapi-code-sample.js";import{openApiExample as e}from"./openapi-example.js";import{replayOpenApi as o}from"./replay-openapi.js";import{openApiResponseSample as p}from"./openapi-response-sample.js";import{jsonExample as r}from"./json-example.js";import{excalidraw as t}from"./excalidraw.js";var n={[m.tagName]:m.schema,[a.tagName]:a.schema,[e.tagName]:e.schema,[o.tagName]:o.schema,[p.tagName]:p.schema,[r.tagName]:r.schema,[t.tagName]:t.schema};export{n as default};
@@ -11,6 +11,7 @@ export type EnvConfigDerived = {
11
11
  isBuildMode: boolean;
12
12
  isDevelopMode: boolean;
13
13
  isRuntimeMode: boolean;
14
+ logFormat: string | undefined;
14
15
  };
15
16
  export type EnvConfigWithDerived = EnvConfig & EnvConfigDerived;
16
17
  export declare const envConfig: EnvConfigWithDerived;
@@ -1 +1 @@
1
- import{readEnvVariable as u}from"../utils/envs/read-env-variable.js";import{envSchema as c}from"./env-schema.js";function i(){const n=Object.fromEntries(Object.keys(process.env).map(e=>[e,u(e)]));return n.REDOCLY_PORTAL_VERSION=process.env.REDOCLY_PORTAL_VERSION,c.parse(n)}function r(){return i().REDOCLY_ENV??"development"}function o(){const n=process.env.REDOCLY_EXECUTION_MODE;return n==="build"||n==="develop"||n==="runtime"?n:"develop"}function s(){const e=i().REDOCLY_INTERNAL_DEV;return e==="true"||e==="1"}function v(n){switch(n){case"redoclyEnv":return r();case"executionMode":return o();case"isProductionEnv":return r()==="production";case"isPreviewEnv":return r()==="preview";case"isReunite":{const e=r(),t=s();return e==="production"||e==="preview"||e==="development"&&!t}case"isBuildMode":return o()==="build";case"isDevelopMode":return o()==="develop";case"isRuntimeMode":return o()==="runtime";default:return n}}const d=new Set(["redoclyEnv","executionMode","isProductionEnv","isPreviewEnv","isReunite","isBuildMode","isDevelopMode","isRuntimeMode"]),l=Object.freeze(new Proxy({},{get(n,e){if(typeof e!="string")return;const t=e;return d.has(t)?v(t):i()[e]}}));export{l as envConfig};
1
+ import{readEnvVariable as u}from"../utils/envs/read-env-variable.js";import{envSchema as c}from"./env-schema.js";function r(){const n=Object.fromEntries(Object.keys(process.env).map(e=>[e,u(e)]));return n.REDOCLY_PORTAL_VERSION=process.env.REDOCLY_PORTAL_VERSION,c.parse(n)}function o(){return r().REDOCLY_ENV??"development"}function i(){const n=process.env.REDOCLY_EXECUTION_MODE;return n==="build"||n==="develop"||n==="runtime"?n:"develop"}function s(){const e=r().REDOCLY_INTERNAL_DEV;return e==="true"||e==="1"}function v(){return r().REDOCLY_LOG_FORMAT}function d(n){switch(n){case"logFormat":return v();case"redoclyEnv":return o();case"executionMode":return i();case"isProductionEnv":return o()==="production";case"isPreviewEnv":return o()==="preview";case"isReunite":{const e=o(),t=s();return e==="production"||e==="preview"||e==="development"&&!t}case"isBuildMode":return i()==="build";case"isDevelopMode":return i()==="develop";case"isRuntimeMode":return i()==="runtime";default:return n}}const a=new Set(["logFormat","redoclyEnv","executionMode","isProductionEnv","isPreviewEnv","isReunite","isBuildMode","isDevelopMode","isRuntimeMode"]),p=Object.freeze(new Proxy({},{get(n,e){if(typeof e!="string")return;const t=e;return a.has(t)?d(t):r()[e]}}));export{p as envConfig};
@@ -7,7 +7,7 @@ export declare const envSchema: z.ZodObject<{
7
7
  CI: z.ZodOptional<z.ZodString>;
8
8
  } & {
9
9
  PORT: z.ZodOptional<z.ZodNumber>;
10
- PORTAL_LOG_FORMAT: z.ZodOptional<z.ZodString>;
10
+ REDOCLY_LOG_FORMAT: z.ZodOptional<z.ZodString>;
11
11
  REDOCLY_LOG_LEVEL: z.ZodOptional<z.ZodString>;
12
12
  TERM: z.ZodOptional<z.ZodString>;
13
13
  INSPECT_MODE: z.ZodOptional<z.ZodString>;
@@ -87,7 +87,7 @@ export declare const envSchema: z.ZodObject<{
87
87
  CI: z.ZodOptional<z.ZodString>;
88
88
  } & {
89
89
  PORT: z.ZodOptional<z.ZodNumber>;
90
- PORTAL_LOG_FORMAT: z.ZodOptional<z.ZodString>;
90
+ REDOCLY_LOG_FORMAT: z.ZodOptional<z.ZodString>;
91
91
  REDOCLY_LOG_LEVEL: z.ZodOptional<z.ZodString>;
92
92
  TERM: z.ZodOptional<z.ZodString>;
93
93
  INSPECT_MODE: z.ZodOptional<z.ZodString>;
@@ -167,7 +167,7 @@ export declare const envSchema: z.ZodObject<{
167
167
  CI: z.ZodOptional<z.ZodString>;
168
168
  } & {
169
169
  PORT: z.ZodOptional<z.ZodNumber>;
170
- PORTAL_LOG_FORMAT: z.ZodOptional<z.ZodString>;
170
+ REDOCLY_LOG_FORMAT: z.ZodOptional<z.ZodString>;
171
171
  REDOCLY_LOG_LEVEL: z.ZodOptional<z.ZodString>;
172
172
  TERM: z.ZodOptional<z.ZodString>;
173
173
  INSPECT_MODE: z.ZodOptional<z.ZodString>;
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
  */
5
5
  export declare const serverConfigSchema: z.ZodObject<{
6
6
  PORT: z.ZodOptional<z.ZodNumber>;
7
- PORTAL_LOG_FORMAT: z.ZodOptional<z.ZodString>;
7
+ REDOCLY_LOG_FORMAT: z.ZodOptional<z.ZodString>;
8
8
  REDOCLY_LOG_LEVEL: z.ZodOptional<z.ZodString>;
9
9
  TERM: z.ZodOptional<z.ZodString>;
10
10
  INSPECT_MODE: z.ZodOptional<z.ZodString>;
@@ -19,7 +19,7 @@ export declare const serverConfigSchema: z.ZodObject<{
19
19
  REDOCLY_METADATA_OUTPUT_FOLDER: z.ZodOptional<z.ZodString>;
20
20
  }, "strip", z.ZodTypeAny, {
21
21
  PORT?: number | undefined;
22
- PORTAL_LOG_FORMAT?: string | undefined;
22
+ REDOCLY_LOG_FORMAT?: string | undefined;
23
23
  REDOCLY_LOG_LEVEL?: string | undefined;
24
24
  TERM?: string | undefined;
25
25
  INSPECT_MODE?: string | undefined;
@@ -34,7 +34,7 @@ export declare const serverConfigSchema: z.ZodObject<{
34
34
  REDOCLY_METADATA_OUTPUT_FOLDER?: string | undefined;
35
35
  }, {
36
36
  PORT?: number | undefined;
37
- PORTAL_LOG_FORMAT?: string | undefined;
37
+ REDOCLY_LOG_FORMAT?: string | undefined;
38
38
  REDOCLY_LOG_LEVEL?: string | undefined;
39
39
  TERM?: string | undefined;
40
40
  INSPECT_MODE?: string | undefined;
@@ -1 +1 @@
1
- import{z as E}from"zod";const t=E.object({PORT:E.coerce.number().optional(),PORTAL_LOG_FORMAT:E.string().optional(),REDOCLY_LOG_LEVEL:E.string().optional(),TERM:E.string().optional(),INSPECT_MODE:E.string().optional(),REDOCLY_PREFIX_PATHS:E.string().optional(),REDOCLY_CONTENT_DIR:E.string().optional(),REDOCLY_PORTAL_VERSION:E.string().optional(),REDOCLY_TELEMETRY:E.string().optional(),REDOCLY_TELEMETRY_ENDPOINT:E.string().url().optional(),TELEMETRY_DEV_DEBUG:E.enum(["true","false"]).optional(),WEB_SERVER_IDLE_TIMEOUT:E.string().optional(),REDOCLY_PROBLEMS_OUTPUT_FILE:E.string().optional(),REDOCLY_METADATA_OUTPUT_FOLDER:E.string().optional()});export{t as serverConfigSchema};
1
+ import{z as E}from"zod";const t=E.object({PORT:E.coerce.number().optional(),REDOCLY_LOG_FORMAT:E.string().optional(),REDOCLY_LOG_LEVEL:E.string().optional(),TERM:E.string().optional(),INSPECT_MODE:E.string().optional(),REDOCLY_PREFIX_PATHS:E.string().optional(),REDOCLY_CONTENT_DIR:E.string().optional(),REDOCLY_PORTAL_VERSION:E.string().optional(),REDOCLY_TELEMETRY:E.string().optional(),REDOCLY_TELEMETRY_ENDPOINT:E.string().url().optional(),TELEMETRY_DEV_DEBUG:E.enum(["true","false"]).optional(),WEB_SERVER_IDLE_TIMEOUT:E.string().optional(),REDOCLY_PROBLEMS_OUTPUT_FILE:E.string().optional(),REDOCLY_METADATA_OUTPUT_FOLDER:E.string().optional()});export{t as serverConfigSchema};
@@ -1,3 +1,3 @@
1
- import*as E from"esbuild";import{logger as c}from"../tools/notifiers/logger.js";import{reporter as f}from"../tools/notifiers/reporter.js";import{envConfig as u}from"../config/env-config.js";import{telemetry as m}from"../../cli/telemetry/index.js";import{stopAllCompilers as M}from"./esbuild.js";import{getCodeframe as w}from"../utils/codeframes/codeframes.js";import{shutdowner as x}from"../tools/shutdowner.js";class N extends Error{errors;warnings;constructor({errors:e=[],warnings:r=[]}){super(),this.errors=e,this.warnings=r}}async function S({errors:n,warnings:e}){const r=await d(n,"error"),s=await d(e,"warning");e.forEach((t,o)=>{c.warn(s[o])}),n.forEach((t,o)=>{const i=t.location?.file||"";i&&i.includes("node_modules/")?(c.error(r[o]),m.sendCliErrorCaughtMessage({message:JSON.stringify(t)})):(c.contentError(r[o]),m.sendCliErrorCaughtMessage({message:JSON.stringify(t),scope:"content"}))}),n.length&&u.isBuildMode&&(await M(),await x.exitWithCode(1))}async function d(n,e){switch(u.PORTAL_LOG_FORMAT){case"JSON":return n.map(r=>JSON.stringify(r));default:return await E.formatMessages(n,{kind:e,color:!1,terminalWidth:0})}}function y(n,e){if(!e?.lineText)return{line:1,column:1,lines:n.split(`
2
- `),hasMatched:!1};const r=n.split(`
3
- `),{lineText:s}=e,t=i=>{const a=i.indexOf(s);return a===-1?null:a};if(e.line&&e.line<=r.length&&t(r[e.line-1]))return{line:e.line,column:e.column||1,lines:r,hasMatched:!0};const o=r.findIndex(i=>t(i)!==null);if(o>=0){const i=t(r[o]);return{line:o+1,column:(i??0)+1,lines:r,hasMatched:!0}}return{line:1,column:1,lines:r,hasMatched:!1}}function _(n,e,r,s){const{line:t,column:o,lines:i,hasMatched:a}=y(r,s),{frame:h,start:p}=w({start:{line:t,character:o},end:{line:t,character:o+(s?.lineText?.length||0)},lines:i},!0),g=`${n}::${e}::${t}`,l={message:n,sourceFileRelativePath:e,sourceFileLocation:p,codeframe:h,hasMatched:a};return f.getCompilationProblem(g)||f.reportCompilationError({type:"ERROR",severity:"ERROR",...l}),l}export{N as EsbuildError,S as esbuildLogger,_ as reportEsbuildError};
1
+ import*as E from"esbuild";import{logger as c}from"../tools/notifiers/logger.js";import{reporter as f}from"../tools/notifiers/reporter.js";import{envConfig as u}from"../config/env-config.js";import{telemetry as m}from"../../cli/telemetry/index.js";import{stopAllCompilers as w}from"./esbuild.js";import{getCodeframe as x}from"../utils/codeframes/codeframes.js";import{shutdowner as y}from"../tools/shutdowner.js";class S extends Error{errors;warnings;constructor({errors:r=[],warnings:e=[]}){super(),this.errors=r,this.warnings=e}}async function T({errors:n,warnings:r}){const e=await d(n,"error"),s=await d(r,"warning");r.forEach((t,o)=>{c.warn(s[o])}),n.forEach((t,o)=>{const i=t.location?.file||"";i&&i.includes("node_modules/")?(c.error(e[o]),m.sendCliErrorCaughtMessage({message:JSON.stringify(t)})):(c.contentError(e[o]),m.sendCliErrorCaughtMessage({message:JSON.stringify(t),scope:"content"}))}),n.length&&u.isBuildMode&&(await w(),await y.exitWithCode(1))}async function d(n,r){switch(u.logFormat){case"JSON":return n.map(e=>JSON.stringify(e));default:return await E.formatMessages(n,{kind:r,color:!1,terminalWidth:0})}}function C(n,r){if(!r?.lineText)return{line:1,column:1,lines:n.split(`
2
+ `),hasMatched:!1};const e=n.split(`
3
+ `),{lineText:s}=r,t=i=>{const a=i.indexOf(s);return a===-1?null:a};if(r.line&&r.line<=e.length&&t(e[r.line-1]))return{line:r.line,column:r.column||1,lines:e,hasMatched:!0};const o=e.findIndex(i=>t(i)!==null);if(o>=0){const i=t(e[o]);return{line:o+1,column:(i??0)+1,lines:e,hasMatched:!0}}return{line:1,column:1,lines:e,hasMatched:!1}}function W(n,r,e,s){const{line:t,column:o,lines:i,hasMatched:a}=C(e,s),{frame:h,start:p}=x({start:{line:t,character:o},end:{line:t,character:o+(s?.lineText?.length||0)},lines:i},!0),g=`${n}::${r}::${t}`,l={message:n,sourceFileRelativePath:r,sourceFileLocation:p,codeframe:h,hasMatched:a};return f.getCompilationProblem(g)||f.reportCompilationError({type:"ERROR",severity:"ERROR",...l}),l}export{S as EsbuildError,T as esbuildLogger,W as reportEsbuildError};
@@ -1,3 +1,3 @@
1
- import{spawn as h}from"child_process";import w from"path";async function v(a,l){if(!l)return new Map;let r,c;try{const t=await l.revparse(["--show-toplevel"]);r=new Set((await l.raw("ls-files",a)).split(`
2
- `).map(s=>s.trim()));const e=t&&w.relative(t,a);c=e&&e.length&&e.length+1||0}catch(t){if(t.message.includes("not a git repository"))return new Map;throw t}return new Promise(t=>{const e=new Map;let s=0;const o=h("git",["whatchanged","--pretty=%at","--",a],{stdio:"pipe"});let p="";function u(f){p+=String(f);const m=p.split(`
3
- `);p=m.pop()||"",m.forEach(i=>{if(i=i.trim(),!!i){if(i.startsWith(":")){const n=i.split(" ").slice(-1)[0].slice(c);if(e.has(n))return;r.has(n)&&r.delete(n),e.set(n,new Date(s*1e3).toISOString())}else s=Number(i);r.size===0&&(o.kill(),t(e))}})}o.stdout.on("data",f=>{u(f)}),o.stdout.on("end",()=>{u(""),o.kill(),t(e)})})}export{v as fastMtime};
1
+ import{spawn as w}from"child_process";import h from"path";async function v(a,l){if(!l)return new Map;let i,c;try{const t=await l.revparse(["--show-toplevel"]);i=new Set((await l.raw("ls-files",a)).split(`
2
+ `).map(s=>s.trim()));const e=t&&h.relative(t,a);c=e&&e.length&&e.length+1||0}catch(t){if(t.message.includes("not a git repository"))return new Map;throw t}return new Promise(t=>{const e=new Map;let s=0;const o=w("git",["log","--raw","--no-merges","--pretty=%at","--",a],{stdio:"pipe"});let p="";function m(f){p+=String(f);const u=p.split(`
3
+ `);p=u.pop()||"",u.forEach(r=>{if(r=r.trim(),!!r){if(r.startsWith(":")){const n=r.split(" ").slice(-1)[0].slice(c);if(e.has(n))return;i.has(n)&&i.delete(n),e.set(n,new Date(s*1e3).toISOString())}else s=Number(r);i.size===0&&(o.kill(),t(e))}})}o.stdout.on("data",f=>{m(f)}),o.stdout.on("end",()=>{m(""),o.kill(),t(e)})})}export{v as fastMtime};
@@ -1 +1 @@
1
- import{parse as d}from"path";function N(p){const a=p.split("/");let i=-1;for(let t=0;t<a.length;t++)if(a[t]==="@api"){i=t;break}let e="",r=p;i!==-1&&(e=a.slice(0,i).join("/"),r=a.slice(i+1).join("/"),e=e?`/${e}/api`:"/api");const{dir:c,name:o}=d(r),s=o.match(/\.(get|post|put|delete|patch)$/i),h=s?s[1]:"all",l=o.replace(/\.(get|post|put|delete|patch)$/,"");let n=c.split("/");l!=="index"&&n.push(l);const m=n.map(t=>t.startsWith("[...")&&t.endsWith("]")?`:${t.slice(4,-1)}{.+}`:t.startsWith("[")&&t.endsWith("]")?`:${t.slice(1,-1)}`:t).join("/");return{path:`${e}/${m}`.replace(/\/+/g,"/").replace(/\/$/,""),method:h,handler:p}}export{N as parseRouteFsPathForHono};
1
+ import{parse as o}from"path";function p(t){const e=t.split("/");let a=-1;for(let i=0;i<e.length;i++)if(e[i]==="@api"){a=i;break}if(a===-1)return{prefixPath:"",apiPath:t};const n=e.slice(0,a).join("/"),r=e.slice(a+1).join("/");return{prefixPath:n?`/${n}/api`:"/api",apiPath:r}}function c(t){const{dir:e,name:a}=o(t),n=a.match(/\.(get|post|put|delete|patch)$/i);return{dir:e,method:n?n[1]:"all",routeName:a.replace(/\.(get|post|put|delete|patch)$/,"")}}function s(t){return t.startsWith("[...")&&t.endsWith("]")?`:${t.slice(4,-1)}{.+}`:t.startsWith("[")&&t.endsWith("]")?`:${t.slice(1,-1)}`:t}function h(t,e){const a=t.split("/");return e!=="index"&&a.push(e),a}function u(t,e){return`${t}/${e.join("/")}`.replace(/\/+/g,"/").replace(/\/$/,"")}function f(t){const{prefixPath:e,apiPath:a}=p(t),{dir:n,routeName:r,method:i}=c(a);return{path:u(e,h(n,r).map(s)),method:i,handler:t}}export{f as parseRouteFsPathForHono};
@@ -1 +1 @@
1
- import{join as f}from"path";import{REDOCLY_ROUTE_RBAC as c}from"@redocly/config";import{removeTrailingSlash as d}from"../../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as m}from"../../../utils/url/remove-leading-slash.js";import{USER_DEFINED_API_FUNCTIONS_COUNTER_KEY as h}from"../../../server/store.js";import{parseRouteFsPathForHono as g}from"./helpers/parse-route-fs-path-for-hono.js";import{telemetryTraceStep as F}from"../../../cli/telemetry/helpers/trace-step.js";const R="api-functions";async function S(){return{id:"ApiFunctions",requiredEntitlements:["apiFunctions"],async processContent(n,i){await F("build.plugin.api_functions",async r=>{const s=await i.getConfig(),a=(s.apiFunctions?.folders||[]).map(e=>`^${m(d(e))}`);r?.setAttribute("config",JSON.stringify(s.apiFunctions||{})),a.push(".*@api");const l=new RegExp(`(${a.join("|")})/.*.(ts|js)$`);let o=0;for(const e of i.fs.scan(l)){if(e.isVirtual)continue;const t=g(e.relativePath);if(!t)continue;const u=`${R}:${t.handler}`,p=f(n.contentDir,t.handler);n.createRequestHandler(u,p),n.addApiRoute({requestHandlerId:u,slug:t.path,fsPath:e.relativePath,httpMethod:t.method,[c]:{fsPath:e.relativePath,slug:t.path}}),o++}r?.setAttribute("definedApiFunctions",String(o)),n.setGlobalConfig({[h]:o})})}}}export{R as API_FUNCTIONS_REQUEST_HANDLER_ID,S as apiFunctionsPlugin};
1
+ import{join as p}from"path";import{REDOCLY_ROUTE_RBAC as f}from"@redocly/config";import{removeTrailingSlash as l}from"../../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as d}from"../../../utils/url/remove-leading-slash.js";import{USER_DEFINED_API_FUNCTIONS_COUNTER_KEY as m}from"../../../server/store.js";import{parseRouteFsPathForHono as h}from"./helpers/parse-route-fs-path-for-hono.js";import{telemetryTraceStep as F}from"../../../cli/telemetry/helpers/trace-step.js";const g="api-functions";function A(t){return d(l(t))}function R(t){return`^${A(t)}`}function E(t){const i=t.map(R);return i.push(".*@api"),new RegExp(`(${i.join("|")})/.*.(ts|js)$`)}async function T(){return{id:"ApiFunctions",requiredEntitlements:["apiFunctions"],async processContent(t,i){await F("build.plugin.api_functions",async r=>{const s=await i.getConfig();r?.setAttribute("config",JSON.stringify(s.apiFunctions||{}));const a=E(s.apiFunctions?.folders||[]);let o=0;for(const e of i.fs.scan(a)){if(e.isVirtual)continue;const n=h(e.relativePath);if(!n)continue;const u=`${g}:${n.handler}`,c=p(t.contentDir,n.handler);t.createRequestHandler(u,c),t.addApiRoute({requestHandlerId:u,slug:n.path,fsPath:e.relativePath,httpMethod:n.method,[f]:{fsPath:e.relativePath,slug:n.path}}),o++}r?.setAttribute("definedApiFunctions",String(o)),t.setGlobalConfig({[m]:o})})}}}export{g as API_FUNCTIONS_REQUEST_HANDLER_ID,T as apiFunctionsPlugin};
@@ -1 +1 @@
1
- import{getPublicEnvVariables as n}from"../../utils/envs/get-public-env-variables.js";const l=async({fsPath:r,slug:e},t,{partials:a,variables:i},o)=>{const s=o.getPartialsForRoute?.(e)||a;return{definitionId:r,...t.props,markdown:{partials:s,variables:{...i,env:n()}}}};var d=l;export{d as default};
1
+ import{getPublicEnvVariables as n}from"../../utils/envs/get-public-env-variables.js";const l=async({fsPath:r,slug:t},a,{partials:i,variables:o},s)=>{const e=s.getPartialsForRoute?.(t);return{definitionId:r,...a.props,markdown:{partials:e&&Object.keys(e).length>0?e:i,variables:{...o,env:n()}}}};var c=l;export{c as default};
@@ -1 +1 @@
1
- import A from"path";import{simplifyAstStructure as E}from"@redocly/openapi-docs/lib/utils/simplifyAstStructure.js";import{buildMenuItems as $}from"@redocly/asyncapi-docs/lib/utils/build-menu-items.js";import{findFirstBinding as T}from"@redocly/asyncapi-docs/lib/utils/find-first-binding.js";import{ASYNC_API_DOCS_TEMPLATE_ID as v}from"../../../constants/common.js";import{combineUrls as D}from"@redocly/theme/core/utils";import{PUBLIC_API_DEFINITIONS_FOLDER as b}from"../../constants/common.js";import{logger as x}from"../../tools/notifiers/logger.js";import{getTemplatePath as R}from"./get-template-path.js";import{storeDefinitionBundles as O}from"./store-definition-bundles.js";import{asyncapiDocLoader as F,asyncapiDocsLoader as N}from"./asyncapi-doc-loader.js";import{searchResolver as j}from"./search/search-resolver.js";import{getAiDocumentsStore as L}from"./search/get-ai-search-documents.js";import{telemetryTraceStep as G}from"../../../cli/telemetry/helpers/trace-step.js";const _="asyncapi-docs-";async function tt(d){let p=[],u=new Set;return{id:"asyncapi",requiredEntitlements:["asyncapi"],loaders:{"asyncapi-doc":F,"asyncapi-docs":N},processContent:async(e,a)=>{await G("build.plugin.asyncapi_docs",async()=>{if((await a.getConfig()).plugins?.some(l=>l.startsWith("@redocly/portal-plugin-async-api/"))){x.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");return}const c=e.createTemplate(v,R("../../../client/templates/asyncapi-docs/template.js")),g=e.registerServerPropsGetter(v,R("./get-server-props.js"));for(const l of await a.fs.scan(/(\.ya?ml|\.json)$/))if(!await a.isPathIgnored(l.relativePath))try{const{data:s,compoundHash:w}=await a.cache.load(l.realRelativePath,"asyncapi-doc");if(!s?.length)continue;p=s.map(({markdocChunks:t,relativePath:o,isVirtual:m,customOutputRelativeFile:f,realRelativePath:y})=>({chunks:t,relativePath:o,realRelativePath:y,isVirtual:f!=null||l.isVirtual||m})),O(s,e.outdir,w);for(const t of s){const o=`${_}${t.relativePath}`,m=T(t.document),{navItems:f,apiItems:y}=$({asyncApiDoc:t.document,protocol:m||""}),I=[{url:D(b,`${C(t.relativePath,".json")}?download`)},{url:D(b,`${C(t.relativePath,".yaml")}?download`)}];await e.createSharedData(o,{document:t.document,apiItems:y,protocol:m,downloadUrls:I}),f.forEach(r=>{const n={fsPath:t.relativePath,slugSuffix:`/${r.link}`,templateId:c,sharedData:[{key:"AsyncApiDefinition",id:o}],getStaticData:S(a.withPathPrefix,r.label),serverPropsGetterIds:[g]};e.addRoute(n),r.items&&r.items.forEach(i=>{e.addRoute({...n,slugSuffix:`/${i.link}`,getStaticData:S(a.withPathPrefix,i.label)}),i.items&&i.items.forEach(h=>{e.addRoute({...n,slugSuffix:`/${h.link}`,getStaticData:S(a.withPathPrefix,i.label)})})})}),e.addRoute({fsPath:t.customOutputRelativeFile||t.relativePath,templateId:c,hasClientRoutes:!0,getSidebar:r=>{const n=i=>{const h={...i};return i.link&&(h.routeSlug=D(r.slug,i.link),h.link=D(r.slug,i.link)),i.items&&(h.items=i.items.map(n)),h};return[{type:"link",label:t.document.info?.title??"AsyncAPI Overview",routeSlug:r.slug,link:r.slug},...f.map(n)]},getSearchDocuments:j(e,t.document),getStaticData:S(a.withPathPrefix,t.document.info?.title??"AsyncAPI Docs"),getAiDocumentsStore:L({actions:e,document:t.document,metadata:{type:"asyncapi",title:t.document.info?.title??"AsyncAPI Docs",description:t.document.info?.description??"",...t.document.info?.["x-metadata"]??{}}}),metadata:{type:"asyncapi",title:t.document.info?.title??"AsyncAPI Docs",description:t.document.info?.description??"",...t.document.info?.["x-metadata"]??{}},sharedData:[{key:"AsyncApiDefinition",id:o}]})}}catch(s){console.error(s)}})},afterRoutesCreated:async(e,a)=>{const P=new Set;for(const{chunks:c,relativePath:g,isVirtual:l,realRelativePath:s}of p){const w=e.getAllRoutes().filter(o=>o.fsPath===g).map(o=>o.slug),t=(await a.cache.load(s,"asyncapi-doc")).compoundHash;await a.cache.load(g,{loader:async function(){for(const{node:m,markdown:f,pointer:y,key:I,relativePath:r}of c){const{ast:n}=await e.parseMarkdoc({content:f,relativePath:y,isVirtual:l},a,{sharedDataIds:[`${_}${r}`],routeSlugs:w});m[`x-parsed-md-${I}`]={result:E(n)}}},name:"asyncapi-markdoc-inline-parser"},[t]);for(const{pointer:o}of c)P.add(o)}const k=u.difference(P);for(const c of k)a.cache.delete(c);u=P}}}function S(d,p){return async function(u,e){return{props:{settings:{baseUrlPath:d(u.baseSlug)},disableAutoScroll:!0,seo:{title:p}}}}}function C(d,p){const u=A.posix.dirname(d),e=A.posix.basename(d,A.posix.extname(d))+p;return A.posix.join(u,e)}export{tt as asyncAPIDocsPlugin};
1
+ import A from"path";import{simplifyAstStructure as E}from"@redocly/openapi-docs/lib/utils/simplifyAstStructure.js";import{buildMenuItems as $}from"@redocly/asyncapi-docs/lib/utils/build-menu-items.js";import{findFirstBinding as T}from"@redocly/asyncapi-docs/lib/utils/find-first-binding.js";import{ASYNC_API_DOCS_TEMPLATE_ID as v}from"../../../constants/common.js";import{combineUrls as D}from"@redocly/theme/core/utils";import{PUBLIC_API_DEFINITIONS_FOLDER as R}from"../../constants/common.js";import{logger as x}from"../../tools/notifiers/logger.js";import{getRouteSlugsForPath as F}from"../utils.js";import{getTemplatePath as b}from"./get-template-path.js";import{storeDefinitionBundles as O}from"./store-definition-bundles.js";import{asyncapiDocLoader as N,asyncapiDocsLoader as j}from"./asyncapi-doc-loader.js";import{searchResolver as L}from"./search/search-resolver.js";import{getAiDocumentsStore as G}from"./search/get-ai-search-documents.js";import{telemetryTraceStep as M}from"../../../cli/telemetry/helpers/trace-step.js";const _="asyncapi-docs-";async function ot(d){let p=[],u=new Set;return{id:"asyncapi",requiredEntitlements:["asyncapi"],loaders:{"asyncapi-doc":N,"asyncapi-docs":j},processContent:async(e,o)=>{await M("build.plugin.asyncapi_docs",async()=>{if((await o.getConfig()).plugins?.some(l=>l.startsWith("@redocly/portal-plugin-async-api/"))){x.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");return}const c=e.createTemplate(v,b("../../../client/templates/asyncapi-docs/template.js")),g=e.registerServerPropsGetter(v,b("./get-server-props.js"));for(const l of await o.fs.scan(/(\.ya?ml|\.json)$/))if(!await o.isPathIgnored(l.relativePath))try{const{data:r,compoundHash:w}=await o.cache.load(l.realRelativePath,"asyncapi-doc");if(!r?.length)continue;p=r.map(({markdocChunks:t,relativePath:s,isVirtual:m,customOutputRelativeFile:f,realRelativePath:y})=>({chunks:t,relativePath:s,realRelativePath:y,isVirtual:f!=null||l.isVirtual||m})),O(r,e.outdir,w);for(const t of r){const s=`${_}${t.relativePath}`,m=T(t.document),{navItems:f,apiItems:y}=$({asyncApiDoc:t.document,protocol:m||""}),I=[{url:D(R,`${C(t.relativePath,".json")}?download`)},{url:D(R,`${C(t.relativePath,".yaml")}?download`)}];await e.createSharedData(s,{document:t.document,apiItems:y,protocol:m,downloadUrls:I}),f.forEach(i=>{const n={fsPath:t.relativePath,slugSuffix:`/${i.link}`,templateId:c,sharedData:[{key:"AsyncApiDefinition",id:s}],getStaticData:S(o.withPathPrefix,i.label),serverPropsGetterIds:[g]};e.addRoute(n),i.items&&i.items.forEach(a=>{e.addRoute({...n,slugSuffix:`/${a.link}`,getStaticData:S(o.withPathPrefix,a.label)}),a.items&&a.items.forEach(h=>{e.addRoute({...n,slugSuffix:`/${h.link}`,getStaticData:S(o.withPathPrefix,a.label)})})})}),e.addRoute({fsPath:t.customOutputRelativeFile||t.relativePath,templateId:c,hasClientRoutes:!0,getSidebar:i=>{const n=a=>{const h={...a};return a.link&&(h.routeSlug=D(i.slug,a.link),h.link=D(i.slug,a.link)),a.items&&(h.items=a.items.map(n)),h};return[{type:"link",label:t.document.info?.title??"AsyncAPI Overview",routeSlug:i.slug,link:i.slug},...f.map(n)]},getSearchDocuments:L(e,t.document),getStaticData:S(o.withPathPrefix,t.document.info?.title??"AsyncAPI Docs"),getAiDocumentsStore:G({actions:e,document:t.document,metadata:{type:"asyncapi",title:t.document.info?.title??"AsyncAPI Docs",description:t.document.info?.description??"",...t.document.info?.["x-metadata"]??{}}}),metadata:{type:"asyncapi",title:t.document.info?.title??"AsyncAPI Docs",description:t.document.info?.description??"",...t.document.info?.["x-metadata"]??{}},sharedData:[{key:"AsyncApiDefinition",id:s}]})}}catch(r){console.error(r)}})},afterRoutesCreated:async(e,o)=>{const P=new Set;for(const{chunks:c,relativePath:g,isVirtual:l,realRelativePath:r}of p){const w=F(e.getAllRoutes(),g),t=(await o.cache.load(r,"asyncapi-doc")).compoundHash;await o.cache.load(g,{loader:async function(){for(const{node:m,markdown:f,pointer:y,key:I,relativePath:i}of c){const{ast:n}=await e.parseMarkdoc({content:f,relativePath:y,isVirtual:l},o,{sharedDataIds:[`${_}${i}`],routeSlugs:w});m[`x-parsed-md-${I}`]={result:E(n)}}},name:"asyncapi-markdoc-inline-parser"},[t]);for(const{pointer:s}of c)P.add(s)}const k=u.difference(P);for(const c of k)o.cache.delete(c);u=P}}}function S(d,p){return async function(u,e){return{props:{settings:{baseUrlPath:d(u.baseSlug)},disableAutoScroll:!0,seo:{title:p}}}}}function C(d,p){const u=A.posix.dirname(d),e=A.posix.basename(d,A.posix.extname(d))+p;return A.posix.join(u,e)}export{ot as asyncAPIDocsPlugin};
@@ -1 +1 @@
1
- import{sha1 as A}from"../../utils/crypto/sha1.js";import{isValidSanitizedString as T}from"../../utils/validate-and-sanitize-string";import{CatalogEntitiesService as w}from"./database/catalog-entities-service.js";import{createPaginationParamsValidator as I}from"../../providers/database/pagination/schemas";import{parseSearch as D}from"../../providers/database/pagination/search";import{OPERATORS as E}from"../../providers/database/pagination/constants.js";import{CacheService as R}from"../../persistence/cache/services/cache-service.js";import{CATALOG_FILTERS_CACHE_NAMESPACE as F,CATALOG_FILTERS_CACHE_TTL_IN_SECONDS as P}from"../../constants/plugins/catalog-entities.js";import{isValidIsoDate as N}from"../../utils/is-valid-iso-date.js";import{expandTeamsForRead as V}from"../../utils";import{getNotAccessibleCatalogResources as _}from"./utils/get-not-accessible-catalog-resources.js";const it={all:"all",domains:"domain",services:"service",teams:"team",users:"user","api-descriptions":"api-description","data-schemas":"data-schema"},L={team:{field:"type",operator:"equal",value:"user"},"api-description":{field:"type",operator:"equal",value:"api-operation"}},O=async({entitiesTypes:e,serverOutDir:a,catalogConfig:i,queries:t={},rbacTeams:n,excludedTypes:p,excludedEntities:c})=>{const u=await w.getInstance({baseDbDir:a}),f=B.concat("domains","owners"),l=I(f).parse(t),o=i.excludes?.map(s=>s.key)??[],g=e.filter(s=>s!=="all"),m=W(g,o);return l.filter?l.filter={op:E.AND,conditions:[l.filter,m]}:l.filter=m,await u.getEntitiesWithRelations({paginationParams:{sort:[{field:"type",order:"ASC"}],limit:10,...l},rbacTeams:n,excludedTypes:p,excludedEntities:c})},M=async({entityKey:e,serverOutDir:a,queries:i,rbacTeams:t,excludedTypes:n,excludedEntities:p})=>{const c=await w.getInstance({baseDbDir:a});let u=null;const f=i?.revision;f&&N(f)&&(u=f);const l=i?.version;if(!T(l,{pattern:/^[a-zA-Z0-9._-]+$/,maxLength:100,allowEmpty:!0}))return null;const o=await c.getEntityWithRelationsByKey({entityKey:e,filter:{revision:u,version:l},rbacTeams:t,excludedTypes:n,excludedEntities:p});if(!o)return null;const g=o.type==="data-schema"?await c.getRelatedEntities({entityKey:e,paginationParams:{limit:1,filter:{field:"type",operator:"equal",value:"api-description"}}}).then(h=>h.items?.[0]??null):null,m=L[o.type]??void 0,d=j(m,l,u),s=await c.getRelatedEntities({entityKey:e,paginationParams:{limit:10,sort:[{field:"title",order:"ASC"}],filter:d,search:i?.search?D(i?.search,["key","type","title","summary"]):void 0},rbacTeams:t,excludedTypes:n,excludedEntities:p});return{status:"success",entity:o,relatedEntity:g,relations:s}},k=e=>{const a=JSON.stringify({entitiesTypes:e.entitiesTypes.sort(),filtersConfig:e.filtersConfig,rbacTeams:e.rbacTeams,excludedTypes:e.excludedTypes,excludedEntities:e.excludedEntities});return A(a)},q=async({serverOutDir:e,entitiesTypes:a,filtersConfig:i,rbacTeams:t,excludedTypes:n,excludedEntities:p})=>{if(!i||i.length===0)return{};const c=k({entitiesTypes:a,filtersConfig:i,rbacTeams:t,excludedTypes:n,excludedEntities:p}),u=await R.getInstance({baseDbDir:e}),f=await u.get({key:c,namespace:F});if(f)return f;const l=await w.getInstance({baseDbDir:e}),o=[],g=new Map;for(const s of i)!s.options||s.options.length===0?o.push(s.property):g.set(s.property,s.options);const m=await l.getCatalogFilters({entitiesTypes:a,emptyFilters:o,rbacTeams:t,excludedTypes:n,excludedEntities:p}),d={};for(const s of i){const h=g.get(s.property);if(!h){const r=m[s.property];d[s.property]=r&&r.length>0?r:[];continue}const b=(await l.getCatalogFilters({entitiesTypes:a,emptyFilters:[s.property],rbacTeams:t,excludedTypes:n,excludedEntities:p}))[s.property];if(!b){d[s.property]=[];continue}const v=new Map;for(const r of b){const y=r.value.toLowerCase().trim();v.set(y,{originalValue:r.value,count:r.count})}d[s.property]=h.map(r=>{const y=r.toLowerCase().trim(),S=v.get(y);return{value:S?.originalValue??r,count:S?.count??0}}).filter(r=>r.count>0).sort((r,y)=>r.value.localeCompare(y.value))}return await u.set({key:c,value:d,namespace:F,ttlInSeconds:P}),d},x=async(e,{props:a},{variables:i},{serverOutDir:t,getRouteSharedDataByFsPath:n,getConfig:p})=>{const c=a?.catalogConfig||{};if(!e.params||!a?.catalogConfig)return{status:"notFound"};const[u,f,l]=e.params;if(!u)return{status:"notFound"};const o=K(c,u),g=o?.includes?.map(y=>y.type)??[];if(!o||o.hide)return{status:"notFound"};const m=V(p().rbac||{},i?.rbac.teams||[]),{catalogs:d,types:s,entities:h}=_({rbacConfig:p().rbac||{},currentRbacTeams:i?.rbac.teams||[]});if(d.includes(u))return{status:"notFound"};if(!l&&f!=="entities"){const y=await q({entitiesTypes:g,serverOutDir:t,filtersConfig:o.filters,rbacTeams:m,excludedTypes:s,excludedEntities:h}),S=e.queries?.viewMode??"table";return{status:"success",catalogSwitcherItems:z(c,o,d),entitiesTypes:g,entities:await O({entitiesTypes:g,serverOutDir:t,catalogConfig:o,queries:e.queries,rbacTeams:m,excludedTypes:s,excludedEntities:h}),catalogConfig:o,filters:y,initialViewMode:S}}const C=await M({entityKey:l,serverOutDir:t,queries:e.queries,rbacTeams:m,excludedTypes:s,excludedEntities:h});if(!C)return{status:"notFound"};const b=C?.entity.sourceFile,v=C?.entity.type==="api-description",r=b&&v&&n(b)||{};return{status:"success",entity:C.entity,relatedEntity:C.relatedEntity,relations:C.relations,entitiesCatalogConfig:c,catalogConfig:o,sharedDataIds:r}},K=(e,a)=>Object.values(e.catalogs??{}).find(i=>i&&typeof i=="object"&&"slug"in i&&i.slug===a),z=(e,a,i)=>Object.values(e.catalogs??{}).filter(t=>!t?.hide&&!i.includes(t?.slug??"")).map(t=>({labelTranslationKey:t?.catalogSwitcherLabelTranslationKey??t?.slug??"",slug:t?.slug??"",selected:t?.slug===a.slug})).sort((t,n)=>t.slug.localeCompare(n.slug)),W=(e,a)=>({op:"AND",conditions:[...e.length?[{field:"type",operator:"in",value:e}]:[],...a.length?[{field:"key",operator:"in",value:a,modifier:"not"}]:[]]}),j=(e,a,i)=>{let t=e;if(a!==void 0){const n={field:"version",operator:"equal",value:a};t=t?{op:E.AND,conditions:[t,n]}:n}if(i){const n={field:"revision",operator:"equal",value:i};t=t?{op:E.AND,conditions:[t,n]}:n}return t},B=["type","key","title","summary","tags","metadata","metadata.*","git","contact","links","id","source","sourceFile","createdAt","updatedAt"];var st=x;export{st as default};
1
+ import{sha1 as I}from"../../utils/crypto/sha1.js";import{isValidSanitizedString as D}from"../../utils/validate-and-sanitize-string";import{CatalogEntitiesService as F}from"./database/catalog-entities-service.js";import{createPaginationParamsValidator as E}from"../../providers/database/pagination/schemas";import{parseSearch as R}from"../../providers/database/pagination/search";import{OPERATORS as w}from"../../providers/database/pagination/constants.js";import{CacheService as P}from"../../persistence/cache/services/cache-service.js";import{CATALOG_FILTERS_CACHE_NAMESPACE as A,CATALOG_FILTERS_CACHE_TTL_IN_SECONDS as N}from"../../constants/plugins/catalog-entities.js";import{isValidIsoDate as V}from"../../utils/is-valid-iso-date.js";import{expandTeamsForRead as _}from"../../utils";import{getNotAccessibleCatalogResources as L}from"./utils/get-not-accessible-catalog-resources.js";const st={all:"all",domains:"domain",services:"service",teams:"team",users:"user","api-descriptions":"api-description","data-schemas":"data-schema"},O={team:{field:"type",operator:"equal",value:"user"},"api-description":{field:"type",operator:"equal",value:"api-operation"}},M=async({entitiesTypes:e,serverOutDir:i,catalogConfig:s,queries:t={},rbacTeams:o,excludedTypes:p,excludedEntities:c})=>{const u=await F.getInstance({baseDbDir:i}),f=T.concat("domains","owners"),l=E(f).parse(t),n=s.excludes?.map(a=>a.key)??[],g=e.filter(a=>a!=="all"),m=j(g,n);return l.filter?l.filter={op:w.AND,conditions:[l.filter,m]}:l.filter=m,await u.getEntitiesWithRelations({paginationParams:{sort:[{field:"type",order:"ASC"},{field:"title",order:"ASC"}],limit:10,...l},rbacTeams:o,excludedTypes:p,excludedEntities:c})},k=async({entityKey:e,serverOutDir:i,queries:s,rbacTeams:t,excludedTypes:o,excludedEntities:p})=>{const c=await F.getInstance({baseDbDir:i});let u=null;const f=s?.revision;f&&V(f)&&(u=f);const l=s?.version;if(!D(l,{pattern:/^[a-zA-Z0-9._-]+$/,maxLength:100,allowEmpty:!0}))return null;const n=await c.getEntityWithRelationsByKey({entityKey:e,filter:{revision:u,version:l},rbacTeams:t,excludedTypes:o,excludedEntities:p});if(!n)return null;const g=n.type==="data-schema"?await c.getRelatedEntities({entityKey:e,paginationParams:{limit:1,filter:{field:"type",operator:"equal",value:"api-description"}}}).then(b=>b.items?.[0]??null):null,m=O[n.type]??void 0,d=B(m,l,u),y=E(T).parse(s),h=await c.getRelatedEntities({entityKey:e,paginationParams:{limit:10,sort:y.sort?.length?y.sort:[{field:"title",order:"ASC"}],filter:d,search:s?.search?R(s?.search,["key","type","title","summary"]):void 0},rbacTeams:t,excludedTypes:o,excludedEntities:p});return{status:"success",entity:n,relatedEntity:g,relations:h}},q=e=>{const i=JSON.stringify({entitiesTypes:e.entitiesTypes.sort(),filtersConfig:e.filtersConfig,rbacTeams:e.rbacTeams,excludedTypes:e.excludedTypes,excludedEntities:e.excludedEntities});return I(i)},x=async({serverOutDir:e,entitiesTypes:i,filtersConfig:s,rbacTeams:t,excludedTypes:o,excludedEntities:p})=>{if(!s||s.length===0)return{};const c=q({entitiesTypes:i,filtersConfig:s,rbacTeams:t,excludedTypes:o,excludedEntities:p}),u=await P.getInstance({baseDbDir:e}),f=await u.get({key:c,namespace:A});if(f)return f;const l=await F.getInstance({baseDbDir:e}),n=[],g=new Map;for(const a of s)!a.options||a.options.length===0?n.push(a.property):g.set(a.property,a.options);const m=await l.getCatalogFilters({entitiesTypes:i,emptyFilters:n,rbacTeams:t,excludedTypes:o,excludedEntities:p}),d={};for(const a of s){const y=g.get(a.property);if(!y){const r=m[a.property];d[a.property]=r&&r.length>0?r:[];continue}const b=(await l.getCatalogFilters({entitiesTypes:i,emptyFilters:[a.property],rbacTeams:t,excludedTypes:o,excludedEntities:p}))[a.property];if(!b){d[a.property]=[];continue}const S=new Map;for(const r of b){const C=r.value.toLowerCase().trim();S.set(C,{originalValue:r.value,count:r.count})}d[a.property]=y.map(r=>{const C=r.toLowerCase().trim(),v=S.get(C);return{value:v?.originalValue??r,count:v?.count??0}}).filter(r=>r.count>0).sort((r,C)=>r.value.localeCompare(C.value))}return await u.set({key:c,value:d,namespace:A,ttlInSeconds:N}),d},K=async(e,{props:i},{variables:s},{serverOutDir:t,getRouteSharedDataByFsPath:o,getConfig:p})=>{const c=i?.catalogConfig||{};if(!e.params||!i?.catalogConfig)return{status:"notFound"};const[u,f,l]=e.params;if(!u)return{status:"notFound"};const n=z(c,u),g=n?.includes?.map(C=>C.type)??[];if(!n||n.hide)return{status:"notFound"};const m=_(p().rbac||{},s?.rbac.teams||[]),{catalogs:d,types:a,entities:y}=L({rbacConfig:p().rbac||{},currentRbacTeams:s?.rbac.teams||[]});if(d.includes(u))return{status:"notFound"};if(!l&&f!=="entities"){const C=await x({entitiesTypes:g,serverOutDir:t,filtersConfig:n.filters,rbacTeams:m,excludedTypes:a,excludedEntities:y}),v=e.queries?.viewMode??"table";return{status:"success",catalogSwitcherItems:W(c,n,d),entitiesTypes:g,entities:await M({entitiesTypes:g,serverOutDir:t,catalogConfig:n,queries:e.queries,rbacTeams:m,excludedTypes:a,excludedEntities:y}),catalogConfig:n,filters:C,initialViewMode:v}}const h=await k({entityKey:l,serverOutDir:t,queries:e.queries,rbacTeams:m,excludedTypes:a,excludedEntities:y});if(!h)return{status:"notFound"};const b=h?.entity.sourceFile,S=h?.entity.type==="api-description",r=b&&S&&o(b)||{};return{status:"success",entity:h.entity,relatedEntity:h.relatedEntity,relations:h.relations,entitiesCatalogConfig:c,catalogConfig:n,sharedDataIds:r}},z=(e,i)=>Object.values(e.catalogs??{}).find(s=>s&&typeof s=="object"&&"slug"in s&&s.slug===i),W=(e,i,s)=>Object.values(e.catalogs??{}).filter(t=>!t?.hide&&!s.includes(t?.slug??"")).map(t=>({labelTranslationKey:t?.catalogSwitcherLabelTranslationKey??t?.slug??"",slug:t?.slug??"",selected:t?.slug===i.slug})).sort((t,o)=>t.slug.localeCompare(o.slug)),j=(e,i)=>({op:"AND",conditions:[...e.length?[{field:"type",operator:"in",value:e}]:[],...i.length?[{field:"key",operator:"in",value:i,modifier:"not"}]:[]]}),B=(e,i,s)=>{let t=e;if(i!==void 0){const o={field:"version",operator:"equal",value:i};t=t?{op:w.AND,conditions:[t,o]}:o}if(s){const o={field:"revision",operator:"equal",value:s};t=t?{op:w.AND,conditions:[t,o]}:o}return t},T=["type","key","title","summary","tags","metadata","metadata.*","git","contact","links","id","source","sourceFile","createdAt","updatedAt"];var it=K;export{it as default};
@@ -1,4 +1,4 @@
1
- import type { RbacScopeItems } from '@redocly/config';
1
+ import { type RbacScopeItems } from '@redocly/config';
2
2
  import type { FrontmatterKeywords } from '../../../types/index.js';
3
3
  import type { AstToSearchNodeTransformer } from './walk-sections.js';
4
4
  import { MdSearchDocument } from './md-search-document.js';
@@ -1,2 +1,2 @@
1
- import{SEARCH_DOCUMENT_METADATA_KEY as p}from"../../../constants/plugins/search.js";import{slugger as E}from"../../../../utils/slugger.js";import{TagNode as U}from"./nodes/tag-node.js";import{TextNode as M}from"./nodes/text-node.js";import{MdSearchDocument as A}from"./md-search-document.js";import{HeadingNode as N}from"./nodes/heading-node.js";const T=Symbol();function _(c,e){if(!c)return e;if(!e)return c;const u=[" ",`
2
- `," "],s=u.some(n=>c.endsWith(n)),a=u.some(n=>e.startsWith(n));return c+(!s&&!a?" ":"")+e}function v(c,e,u,s,a,d={},n){const g=new Map(Array.from({length:6},(t,m)=>[m,""])),i=new Map;let h=null;s=s??{},E.reset();for(const t of c.transform()){const m=t.getUrl(e),f={...s};if(t.rbacTeam&&(f[t.rbacTeam.toLowerCase()]="read"),t instanceof M){const o=t.parentNode?.id,r=o?`${m}#${o}`:T,l=i.get(r)??new A(u,e,[],d,f,a);l.text=_(l.text,t.content),l.facets=d,i.set(r,l);continue}if(t instanceof U){const o=`${m}#${t.id}`,r=new A(t.content,t.getUrl(e),t.getPath(g),d,f,a);i.set(o,r);continue}if(t instanceof N){g.set(t.attributes.level,t.content);const o=new A(t.content,t.getUrl(e),t.getPath(g),d,f,a),r=`${m}#${t.id}`;i.set(r,o),h===null&&(h=o)}}const D=Array.from(i.values()),S=h??D[0];if(S&&n?.includes&&(S[p].curated=!0,S[p].includes=n.includes),n?.excludes)for(const t of D)t[p].curated=!0,t[p].excludes=n.excludes;return D}export{v as getSearchDocuments};
1
+ import{REDOCLY_TEAMS_RBAC as $}from"@redocly/config";import{SEARCH_DOCUMENT_METADATA_KEY as g}from"../../../constants/plugins/search.js";import{slugger as x}from"../../../../utils/slugger.js";import{TagNode as M}from"./nodes/tag-node.js";import{TextNode as U}from"./nodes/text-node.js";import{MdSearchDocument as D}from"./md-search-document.js";import{HeadingNode as N}from"./nodes/heading-node.js";const C=Symbol();function H(r,e){if(!r)return e;if(!e)return r;const d=[" ",`
2
+ `," "],u=d.some(o=>r.endsWith(o)),s=d.some(o=>e.startsWith(o));return r+(!u&&!s?" ":"")+e}function Y(r,e,d,u,s,a={},o){const h=new Map(Array.from({length:6},(t,c)=>[c,""])),i=new Map;let S=null,_=0;u=u??{},x.reset();for(const t of r.transform()){const c=t.getUrl(e),f={...u};for(const n of t.rbacTeams??[])f[n.toLowerCase()]="read";if(t instanceof U){const n=t.parentNode?.id,m=n?`${c}#${n}`:C,A=i.get(m),l=A??new D(d,e,[],a,f,s),E=Object.keys(l[$]??{});if(A&&t.rbacTeams&&t.rbacTeams.length>0&&(E.length===0||!E.every(p=>(t.rbacTeams||[]).includes(p)))){const p=new D(A?.title??d,c,t.getPath(h),a,f,s);p.text=t.content,i.set(`${c}#rbac-text-${_++}`,p)}else l.text=H(l.text,t.content),l.facets=a,i.set(m,l);continue}if(t instanceof M){const n=`${c}#${t.id}`,m=new D(t.content,t.getUrl(e),t.getPath(h),a,f,s);i.set(n,m);continue}if(t instanceof N){h.set(t.attributes.level,t.content);const n=new D(t.content,t.getUrl(e),t.getPath(h),a,f,s),m=`${c}#${t.id}`;i.set(m,n),S===null&&(S=n)}}const T=Array.from(i.values()),b=S??T[0];if(b&&o?.includes&&(b[g].curated=!0,b[g].includes=o.includes),o?.excludes)for(const t of T)t[g].curated=!0,t[g].excludes=o.excludes;return T}export{Y as getSearchDocuments};
@@ -4,7 +4,7 @@ export type SectionNodeParams = {
4
4
  node: Node;
5
5
  content: string;
6
6
  parentNode: SearchParentNode;
7
- rbacTeam?: string;
7
+ rbacTeams?: string[];
8
8
  };
9
9
  export declare class SectionNode {
10
10
  #private;
@@ -14,7 +14,7 @@ export declare class SectionNode {
14
14
  get node(): Node;
15
15
  get id(): string | number;
16
16
  get parentNode(): SearchParentNode;
17
- get rbacTeam(): string | undefined;
17
+ get rbacTeams(): string[] | undefined;
18
18
  }
19
19
  type Constructor<T = any> = new (...args: any[]) => T;
20
20
  export declare function WithCounterId<TBase extends Constructor>(Base: TBase): {
@@ -1 +1 @@
1
- import{getInnerText as o}from"../../../../../markdoc/helpers/get-inner-text.js";import{slugger as c}from"../../../../../utils/slugger.js";class a{#t;#e;#r;#n;constructor(t){const{node:r,content:n,rbacTeam:s,parentNode:i}=t;this.#t=r,this.#e=n,this.#r=i,this.#n=s}get attributes(){return this.#t.attributes}get content(){return this.#e}get node(){return this.#t}get id(){throw new Error("SectionNode needs an id mixin applied")}get parentNode(){return this.#r}get rbacTeam(){return this.#n}}function h(e){let t=0;return class extends e{#t=++t;get id(){return this.#t}}}function g(e){return class extends e{#t;constructor(...t){super(...t);const r=this;this.#t=c.slug(o(r.node.children),{replaceDots:!0,replaceSlashes:!0})}get id(){return this.#t}}}export{a as SectionNode,h as WithCounterId,g as WithSlugId};
1
+ import{getInnerText as o}from"../../../../../markdoc/helpers/get-inner-text.js";import{slugger as c}from"../../../../../utils/slugger.js";class a{#t;#e;#r;#n;constructor(t){const{node:r,content:n,rbacTeams:s,parentNode:i}=t;this.#t=r,this.#e=n,this.#r=i,this.#n=s}get attributes(){return this.#t.attributes}get content(){return this.#e}get node(){return this.#t}get id(){throw new Error("SectionNode needs an id mixin applied")}get parentNode(){return this.#r}get rbacTeams(){return this.#n}}function h(e){let t=0;return class extends e{#t=++t;get id(){return this.#t}}}function g(e){return class extends e{#t;constructor(...t){super(...t);const r=this;this.#t=c.slug(o(r.node.children),{replaceDots:!0,replaceSlashes:!0})}get id(){return this.#t}}}export{a as SectionNode,h as WithCounterId,g as WithSlugId};
@@ -1 +1 @@
1
- import{logger as a}from"../../../tools/notifiers/logger.js";import{isNode as f}from"../../../../markdoc/helpers/guards/is-node.js";import{isConditionalNode as u}from"../../../../markdoc/helpers/guards/is-conditional-node.js";import{isContentNode as y}from"../../../../markdoc/helpers/guards/is-content-node.js";import{getNodeAttribute as h}from"../../../../markdoc/helpers/get-node-attribute.js";import{extractRbacFromCondition as N}from"../../../../markdoc/helpers/extract-rbac-from-condition-node.js";import{TextNode as e}from"./nodes/text-node.js";import{TAG_TITLE_ATTRIBUTES as T,TagNode as n}from"./nodes/tag-node.js";import{HeadingNode as p}from"./nodes/heading-node.js";class C{#t;#o;#i;#s;constructor({ast:i,partials:t,skipConditionals:r=!1,getInnerContent:s}){if(this.#t=i,this.#o=t,this.#i=r,this.#s=s,!this.#t||!f(this.#t))throw new Error("ast is not a valid Markdoc Node.")}*transform(){yield*this.#l(this.#t,{parentNode:null})}*#l(i,t,r=this.#s){if(!(!i||!f(i))){if(u(i)){if(this.#i)return;const s=N(i);s!==null&&(yield*this.#r(i,{...t,rbacTeam:s},r));return}if(y(i)){yield new e({node:i,content:r([i],{skipConditionals:this.#i}),...t});return}if(i.type==="heading"){yield new p({node:i,content:r([i],{skipConditionals:this.#i}),rbacTeam:t?.rbacTeam});return}if(i.type==="tag"){yield*this.#c(i,t,r);return}yield*this.#r(i,t,r)}}*#c(i,t,r=this.#s){switch(i.tag){case"partial":{const s=i.attributes.file,o=i.attributes.variables??{};if(s&&this.#o[s]){yield*this.#l(this.#o[s],t,(l,c)=>r(l,{...c,variables:o}));return}a.warn(`Could not create search indexes for partial \u201C${s}\u201D: file not found`);return}case"cards":case"tabs":case"code-walkthrough":{yield*this.#r(i,t,r);return}case"markdoc-example":{const s=r([i],{skipConditionals:this.#i});yield new e({node:i,content:s,...t});return}case"code-snippet":{const s=h(i,"title"),o=r([i],{skipConditionals:this.#i});if(s){const l=new n({node:i,content:s,...t});t={...t,parentNode:l},yield l}o&&(yield new e({node:i,content:o,...t}));return}default:{const s=T.find(c=>c in i.attributes),o=(s&&h(i,s))??"",l=typeof o=="string"?o:r([o]);if(l){const c=new n({node:i,content:l,...t});t={...t,parentNode:c},yield c}yield*this.#r(i,t,r);return}}}*#r(i,t,r=this.#s){for(const s of[...Object.values(i.slots),...i.children])for(const o of this.#l(s,t,r))o instanceof p&&(t={...t,parentNode:o}),yield o}}export{C as AstToSearchNodeTransformer};
1
+ import{logger as a}from"../../../tools/notifiers/logger.js";import{isNode as f}from"../../../../markdoc/helpers/guards/is-node.js";import{isConditionalNode as u}from"../../../../markdoc/helpers/guards/is-conditional-node.js";import{isContentNode as y}from"../../../../markdoc/helpers/guards/is-content-node.js";import{getNodeAttribute as h}from"../../../../markdoc/helpers/get-node-attribute.js";import{extractRbacFromCondition as N}from"../../../../markdoc/helpers/extract-rbac-from-condition-node.js";import{TextNode as e}from"./nodes/text-node.js";import{TAG_TITLE_ATTRIBUTES as T,TagNode as n}from"./nodes/tag-node.js";import{HeadingNode as p}from"./nodes/heading-node.js";class C{#t;#o;#i;#s;constructor({ast:i,partials:t,skipConditionals:r=!1,getInnerContent:s}){if(this.#t=i,this.#o=t,this.#i=r,this.#s=s,!this.#t||!f(this.#t))throw new Error("ast is not a valid Markdoc Node.")}*transform(){yield*this.#c(this.#t,{parentNode:null})}*#c(i,t,r=this.#s){if(!(!i||!f(i))){if(u(i)){if(this.#i)return;const s=N(i);s&&s.length>0&&(yield*this.#r(i,{...t,rbacTeams:s},r));return}if(y(i)){yield new e({node:i,content:r([i],{skipConditionals:this.#i}),...t});return}if(i.type==="heading"){yield new p({node:i,content:r([i],{skipConditionals:this.#i}),rbacTeams:t?.rbacTeams});return}if(i.type==="tag"){yield*this.#l(i,t,r);return}yield*this.#r(i,t,r)}}*#l(i,t,r=this.#s){switch(i.tag){case"partial":{const s=i.attributes.file,o=i.attributes.variables??{};if(s&&this.#o[s]){yield*this.#c(this.#o[s],t,(c,l)=>r(c,{...l,variables:o}));return}a.warn(`Could not create search indexes for partial \u201C${s}\u201D: file not found`);return}case"cards":case"tabs":case"code-walkthrough":{yield*this.#r(i,t,r);return}case"markdoc-example":{const s=r([i],{skipConditionals:this.#i});yield new e({node:i,content:s,...t});return}case"code-snippet":{const s=h(i,"title"),o=r([i],{skipConditionals:this.#i});if(s){const c=new n({node:i,content:s,...t});t={...t,parentNode:c},yield c}o&&(yield new e({node:i,content:o,...t}));return}default:{const s=T.find(l=>l in i.attributes),o=(s&&h(i,s))??"",c=typeof o=="string"?o:r([o]);if(c){const l=new n({node:i,content:c,...t});t={...t,parentNode:l},yield l}yield*this.#r(i,t,r);return}}}*#r(i,t,r=this.#s){for(const s of[...Object.values(i.slots),...i.children])for(const o of this.#c(s,t,r))o instanceof p&&(t={...t,parentNode:o}),yield o}}export{C as AstToSearchNodeTransformer};
@@ -1 +1 @@
1
- import{getPublicEnvVariables as n}from"../../utils/envs/get-public-env-variables.js";const l=async({fsPath:r,slug:e},t,{variables:a,partials:i},o)=>{const s=o.getPartialsForRoute?.(e)||i;return{definitionId:r,...t.props,markdown:{partials:s,variables:{...a,env:n()}}}};var d=l;export{d as default};
1
+ import{getPublicEnvVariables as n}from"../../utils/envs/get-public-env-variables.js";const l=async({fsPath:r,slug:t},a,{variables:i,partials:o},s)=>{const e=s.getPartialsForRoute?.(t);return{definitionId:r,...a.props,markdown:{partials:e&&Object.keys(e).length>0?e:o,variables:{...i,env:n()}}}};var c=l;export{c as default};
@@ -1 +1 @@
1
- import{simplifyAstStructure as Z}from"@redocly/openapi-docs";import{REDOCLY_TEAMS_RBAC as D}from"@redocly/config";import{OPENAPI_DOCS_TEMPLATE_ID as $,PUBLIC_RBAC_SCOPE_ITEM as j}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as ee,PUBLIC_API_DEFINITIONS_FOLDER as te}from"../../constants/common.js";import{OPENAPI_CUSTOM_FIELDS_SERVER_PROPS_GETTER_ID as oe,OPENAPI_SHARED_DATA_PREFIX as U}from"../../constants/plugins/openapi-docs.js";import{envConfig as V}from"../../config/env-config.js";import{searchResolver as ae}from"./search/search-resolver.js";import{convertOpenAPIDocs2Sidebar as re,shouldAddRoute as se}from"./utils.js";import{getTemplatePath as b}from"./get-template-path.js";import{storeDefinitionBundles as ne}from"./store-definition-bundles.js";import{definitionLoader as ie,definitionsLoader as pe}from"./load-definition.js";import{getAiDocumentsStore as de}from"./search/get-ai-search-documents.js";import{fromCurrentDir as ce}from"../../utils/paths.js";import{telemetryTraceStep as le}from"../../../cli/telemetry/helpers/trace-step.js";const w="openapi-spec-download";async function Ce(){let M=[],R={},L=new Set;return{id:"openapi",requiredEntitlements:["openapi"],loaders:{"load-oas-docs":pe,"load-oas":ie},processContent:async(e,p)=>{await le("build.plugin.openapi_docs",async u=>{e.createRequestHandler(w,ce(import.meta.url,"./spec-download.api.js")),e.addApiRoute({slug:te+"/*",requestHandlerId:w,httpMethod:"all",[D]:j,getStaticData:async()=>({props:{}})}),e.addApiRoute({slug:ee+"/*",requestHandlerId:w,httpMethod:"all",[D]:j,getStaticData:async()=>({props:{}})});const A=e.createTemplate($,b("../../../client/templates/openapi-docs/template.js")),a=e.registerServerPropsGetter($,b("./get-server-props.js")),s=e.registerServerPropsGetter(oe,b("./get-server-props-custom-fields.js")),d=await p.getConfig();u?.setAttribute("config",JSON.stringify(d.openapi||{}));const g=d.rules?.["custom-fields-schema"];R={};const m=await e.loadOpenApiDefinitions(p);M=m.map(({markdocChunks:r,relativePath:f,customOutputRelativeFile:i,isVirtual:n,realRelativePath:c})=>({chunks:r,relativePath:f,realRelativePath:c,isVirtual:i!=null||n})),ne(m,e.outdir);const S={};for(const r of m||[]){const{definition:f,config:i,relativePath:n,customOutputRelativeFile:c,contentItems:_,flatItems:k,parser:E,options:B,rawOptions:q,hash:J}=r,N=c||n,o=[],x={},{definition:Q}=E||{},{info:l}=Q||{},v=l?.["x-metadata"],C=!!i.openapi?.excludeFromSearch||!!i.theme?.openapi?.excludeFromSearch||!!d.openapi?.excludeFromSearch||!!d.theme?.openapi?.excludeFromSearch,G={title:l?.title,description:l?.description,summary:l?.summary,...i.metadata,...v},h={untagged:[],tagged:new Map};for(const t of k){const{id:O,href:I,operationDefinition:y}=t;if(y){const{tags:P}=y;if(P)for(const T of P)h.tagged.has(T)||h.tagged.set(T,[]),h.tagged.get(T)?.push(t);else h.untagged.push(t);V.isDevelopMode&&(x[`#${y.pointer}`]=t.href)}if(!se({item:t}))continue;const F=t,Y=F.type==="section"&&!!F.infoDefinition,z=I.split("#")[0]+"/",K=t?.operationDefinition?.[D];o.push({excludeFromSearch:C,slugSuffix:z,fsPath:N,metadata:{subType:"openapi-operation"},httpVerb:t?.httpVerb||"",path:n,templateId:A,[D]:K||i.rbac,getAiDocumentsStore:de({parser:E,options:B,info:l,tagOperations:h,openapiContentItem:F,metadata:G,relativePath:n,getSearchFacets:e.getSearchFacets,includeInLLMsTxt:Y,excludeFromSearch:C}),getStaticData:async P=>({props:{dynamicMarkdocComponents:["openapi"],baseSlug:P.baseSlug,seo:t["x-metadata"]?.seo||{title:t.name,description:t.description},itemId:O,disableAutoScroll:!0}})})}o[0]={...o[0],metadata:{type:"openapi",...G},hasClientRoutes:!0,getSidebar:(t,O)=>{const I=[];return re({contentItems:_,sidebarItems:I,routeSlug:t.slug,navItem:O}),I},getNavText:()=>l?.title,getSearchDocuments:ae(E,B,k,e.getSearchFacets,e.setSearchFacets,C)},v?.apiId&&(S[v.apiId]={slug:o[0]?.slug||""});const W=o[0];o[0]=o[o.length-1],o[o.length-1]=W;for(const t of o)e.addRoute({...t,serverPropsGetterIds:g?[a,s]:[a]});const X=V.isDevelopMode?n:void 0,H=`${U}${n}`;R[H]={fsPath:N,definition:f,options:q,sourcePath:X,routesMapping:x,hash:J};for(const t of o)e.addRoute({...t,sharedData:[{id:H,key:"openAPIDocsStore"}],serverPropsGetterIds:g?[a,s]:[a]})}e.setGlobalData({apiProducts:S})})},afterRoutesCreated:async(e,p)=>{const u=new Set;for(const{chunks:a,relativePath:s,isVirtual:d,realRelativePath:g}of M){const m=e.getAllRoutes().filter(r=>r.fsPath===s).map(r=>r.slug),S=(await p.cache.load(g,"load-oas")).compoundHash;await p.cache.load(s,{loader:async function(){for(const{node:f,markdown:i,key:n,relativePath:c}of a){const{ast:_}=await e.parseMarkdoc({content:i,relativePath:c,isVirtual:d},p,{sharedDataIds:[`${U}${c}`],routeSlugs:m});f[`x-parsed-md-${n}`]={result:Z(_)}}},name:"openapi-markdoc-inline-parser"},[S]);for(const{pointer:r}of a)u.add(r)}const A=L.difference(u);for(const a of A)p.cache.delete(a);L=u;for(const[a,s]of Object.entries(R))await e.createSharedData(a,{...s,baseSlug:e.getRouteByFsPath(s.fsPath)?.baseSlug},s.hash)}}}export{Ce as openAPIDocsPlugin};
1
+ import{simplifyAstStructure as Z}from"@redocly/openapi-docs";import{REDOCLY_TEAMS_RBAC as D}from"@redocly/config";import{OPENAPI_DOCS_TEMPLATE_ID as $,PUBLIC_RBAC_SCOPE_ITEM as j}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as ee,PUBLIC_API_DEFINITIONS_FOLDER as te}from"../../constants/common.js";import{OPENAPI_CUSTOM_FIELDS_SERVER_PROPS_GETTER_ID as oe,OPENAPI_SHARED_DATA_PREFIX as U}from"../../constants/plugins/openapi-docs.js";import{envConfig as V}from"../../config/env-config.js";import{getRouteSlugsForPath as ae}from"../utils.js";import{searchResolver as re}from"./search/search-resolver.js";import{convertOpenAPIDocs2Sidebar as se,shouldAddRoute as ne}from"./utils.js";import{getTemplatePath as b}from"./get-template-path.js";import{storeDefinitionBundles as ie}from"./store-definition-bundles.js";import{definitionLoader as pe,definitionsLoader as de}from"./load-definition.js";import{getAiDocumentsStore as ce}from"./search/get-ai-search-documents.js";import{fromCurrentDir as le}from"../../utils/paths.js";import{telemetryTraceStep as ue}from"../../../cli/telemetry/helpers/trace-step.js";const w="openapi-spec-download";async function ye(){let M=[],R={},L=new Set;return{id:"openapi",requiredEntitlements:["openapi"],loaders:{"load-oas-docs":de,"load-oas":pe},processContent:async(e,i)=>{await ue("build.plugin.openapi_docs",async u=>{e.createRequestHandler(w,le(import.meta.url,"./spec-download.api.js")),e.addApiRoute({slug:te+"/*",requestHandlerId:w,httpMethod:"all",[D]:j,getStaticData:async()=>({props:{}})}),e.addApiRoute({slug:ee+"/*",requestHandlerId:w,httpMethod:"all",[D]:j,getStaticData:async()=>({props:{}})});const A=e.createTemplate($,b("../../../client/templates/openapi-docs/template.js")),a=e.registerServerPropsGetter($,b("./get-server-props.js")),r=e.registerServerPropsGetter(oe,b("./get-server-props-custom-fields.js")),p=await i.getConfig();u?.setAttribute("config",JSON.stringify(p.openapi||{}));const h=p.rules?.["custom-fields-schema"];R={};const m=await e.loadOpenApiDefinitions(i);M=m.map(({markdocChunks:d,relativePath:f,customOutputRelativeFile:n,isVirtual:s,realRelativePath:c})=>({chunks:d,relativePath:f,realRelativePath:c,isVirtual:n!=null||s})),ie(m,e.outdir);const S={};for(const d of m||[]){const{definition:f,config:n,relativePath:s,customOutputRelativeFile:c,contentItems:_,flatItems:k,parser:E,options:B,rawOptions:q,hash:J}=d,N=c||s,o=[],x={},{definition:Q}=E||{},{info:l}=Q||{},v=l?.["x-metadata"],C=!!n.openapi?.excludeFromSearch||!!n.theme?.openapi?.excludeFromSearch||!!p.openapi?.excludeFromSearch||!!p.theme?.openapi?.excludeFromSearch,G={title:l?.title,description:l?.description,summary:l?.summary,...n.metadata,...v},g={untagged:[],tagged:new Map};for(const t of k){const{id:O,href:I,operationDefinition:y}=t;if(y){const{tags:P}=y;if(P)for(const T of P)g.tagged.has(T)||g.tagged.set(T,[]),g.tagged.get(T)?.push(t);else g.untagged.push(t);V.isDevelopMode&&(x[`#${y.pointer}`]=t.href)}if(!ne({item:t}))continue;const F=t,Y=F.type==="section"&&!!F.infoDefinition,z=I.split("#")[0]+"/",K=t?.operationDefinition?.[D];o.push({excludeFromSearch:C,slugSuffix:z,fsPath:N,metadata:{subType:"openapi-operation"},httpVerb:t?.httpVerb||"",path:s,templateId:A,[D]:K||n.rbac,getAiDocumentsStore:ce({parser:E,options:B,info:l,tagOperations:g,openapiContentItem:F,metadata:G,relativePath:s,getSearchFacets:e.getSearchFacets,includeInLLMsTxt:Y,excludeFromSearch:C}),getStaticData:async P=>({props:{dynamicMarkdocComponents:["openapi"],baseSlug:P.baseSlug,seo:t["x-metadata"]?.seo||{title:t.name,description:t.description},itemId:O,disableAutoScroll:!0}})})}o[0]={...o[0],metadata:{type:"openapi",...G},hasClientRoutes:!0,getSidebar:(t,O)=>{const I=[];return se({contentItems:_,sidebarItems:I,routeSlug:t.slug,navItem:O}),I},getNavText:()=>l?.title,getSearchDocuments:re(E,B,k,e.getSearchFacets,e.setSearchFacets,C)},v?.apiId&&(S[v.apiId]={slug:o[0]?.slug||""});const W=o[0];o[0]=o[o.length-1],o[o.length-1]=W;for(const t of o)e.addRoute({...t,serverPropsGetterIds:h?[a,r]:[a]});const X=V.isDevelopMode?s:void 0,H=`${U}${s}`;R[H]={fsPath:N,definition:f,options:q,sourcePath:X,routesMapping:x,hash:J};for(const t of o)e.addRoute({...t,sharedData:[{id:H,key:"openAPIDocsStore"}],serverPropsGetterIds:h?[a,r]:[a]})}e.setGlobalData({apiProducts:S})})},afterRoutesCreated:async(e,i)=>{const u=new Set;for(const{chunks:a,relativePath:r,isVirtual:p,realRelativePath:h}of M){const m=ae(e.getAllRoutes(),r),S=(await i.cache.load(h,"load-oas")).compoundHash;await i.cache.load(r,{loader:async function(){for(const{node:f,markdown:n,key:s,relativePath:c}of a){const{ast:_}=await e.parseMarkdoc({content:n,relativePath:c,isVirtual:p},i,{sharedDataIds:[`${U}${c}`],routeSlugs:m});f[`x-parsed-md-${s}`]={result:Z(_)}}},name:"openapi-markdoc-inline-parser"},[S]);for(const{pointer:d}of a)u.add(d)}const A=L.difference(u);for(const a of A)i.cache.delete(a);L=u;for(const[a,r]of Object.entries(R))await e.createSharedData(a,{...r,baseSlug:e.getRouteByFsPath(r.fsPath)?.baseSlug},r.hash)}}}export{ye as openAPIDocsPlugin};
@@ -1 +1 @@
1
- import*as g from"@redocly/openapi-docs";import{REDOCLY_TEAMS_RBAC as d}from"@redocly/config";import{combineUrls as l}from"@redocly/theme/core/utils";import{SEARCH_DOCUMENT_METADATA_KEY as y}from"../../constants/plugins/search.js";import{removeMarkdownLinks as c,stripFormatting as a}from"./utils.js";import{normalizeFrontmatterKeywords as x}from"../helpers/normalize-frontmatter-keywords.js";const u=g.default||g;class T{#n=[];#r;#s;#e;#i;constructor(e,t,n){this.#r=e,this.#s=t,this.#e=n}addItem(e){const{result:t}=x(e.keywords||e.operationDefinition?.keywords);t?.excludes&&e.type==="section"&&e.id===""&&(this.#i=t.excludes);try{let n;switch(e.type){case"tag":n=this.#c(e);break;case"operation":const o=this.getOperation(e);n=this.#d(o,e[d]);break;case"section":n=this.#p(e);break;case"rsrc":case"prompt":case"tool":n=this.#o(e);break}if(!n)return;const s=[...new Set([...t?.excludes?t.excludes:[],...this.#i?this.#i:[]])];return(t||s.length)&&(n[y]={curated:!0,...t,excludes:s}),this.#n.push(n),n}catch(n){console.error("Cannot add item to search indexer",n.message)}}addInfo(e,t){const n=this.#e,s={id:n,url:n,text:a(c(e.description||"")),title:a(`${e.title} (${e.version})`),metadata:t};return this.#n.push(s),s}#o(e){const t=l(this.#e,e.href);return{id:t,url:t,text:a(c(e.description||"")),title:e.name}}getResult(){return this.#n}getOperation(e){return u.getOperation(this.#r,e.operationDefinition,e.parent,{...this.#s,internal_skipSamples:!0},e.href)}#a(e){return[...e.path||[],e.name.toString()].join(".")+e.description+e.place}#d(e,t){if(e.type!=="operation")return;let n={};for(let i of e.parameters){if(i[d])continue;const r=i.schema?.example||i.example,p={name:i.name,description:a(c(i.description)),place:i.in+" parameters",mediaType:void 0,type:i.schema?.type.toString()||"unknown",deepLink:u.generateDeepLink(i),[d]:i[d],required:i.required,example:r?JSON.stringify(r):void 0,enum:i.schema?.enum?.length?i.schema.enum:void 0};n[this.#a(p)]=p}this.#t(n,e.requestBody?.content?.mediaTypes[0]?.schema,e.requestBody?.content?.mediaTypes[0]?.name,"request fields",!1);for(let i of e.responses){const r=`response ${i.code} fields`;this.#t(n,i.content?.mediaTypes[0]?.schema,i.content?.mediaTypes[0]?.name,r,!0)}let s=l(this.#e,e.href);return{id:s,url:s,title:a(e.name),text:a(c(e.description||"")),httpMethod:e.httpVerb,httpPath:e.path,deprecated:e.deprecated,isAdditionalOperation:e.isAdditionalOperation,security:e.security.map(i=>i.schemes.map(r=>r.id)).flat().filter(Boolean),parameters:Object.values(n),badges:e.badges.length?e.badges:void 0,[d]:t}}#t(e,t,n,s,o,i=[]){if(!(!t||t.isCircular)){if(t?.fields)for(let r of t.fields){if(t[d]||r.kind==="additionalProperties"||r.schema?.readOnly&&!o||r.schema?.writeOnly&&o)continue;const p=r.schema?.example||r.example,h=r.schema?.enum,m={name:r.name,description:a(r.description),place:s,mediaType:n,path:i,deepLink:u.generateDeepLink(r),type:r.schema?.type.toString()||"unknown",required:r.required||t.schema.required?.includes(r.name)||!1,example:p?JSON.stringify(p):void 0,enum:h?.length?h:void 0},f=this.#a(m);e[f]==null&&(e[f]=m,this.#t(e,r.schema,n,s,o,i.concat([r.name])))}t?.items&&this.#t(e,t.items,n,s,o,i)}}#c(e){const t=l(this.#e,e.href);return{id:t,url:t,text:a(c(e.description||"")),title:a(e.name)}}#p(e){const t=l(this.#e,e.href);return{id:t,url:t,text:a(c(e.description||"")),title:a(e.name)}}}export{T as SearchIndexer};
1
+ import*as y from"@redocly/openapi-docs";import{REDOCLY_TEAMS_RBAC as d}from"@redocly/config";import{combineUrls as u}from"@redocly/theme/core/utils";import{SEARCH_DOCUMENT_METADATA_KEY as x}from"../../constants/plugins/search.js";import{removeMarkdownLinks as c,stripFormatting as a}from"./utils.js";import{normalizeFrontmatterKeywords as k}from"../helpers/normalize-frontmatter-keywords.js";const h=y.default||y;class q{#n=[];#r;#s;#e;#i;constructor(e,t,n){this.#r=e,this.#s=t,this.#e=n}addItem(e){const{result:t}=k(e.keywords||e.operationDefinition?.keywords);t?.excludes&&e.type==="section"&&e.id===""&&(this.#i=t.excludes);try{let n;switch(e.type){case"tag":n=this.#c(e);break;case"operation":const o=this.getOperation(e);n=this.#d(o,e[d]);break;case"section":n=this.#p(e);break;case"rsrc":case"prompt":case"tool":n=this.#o(e);break}if(!n)return;const s=[...new Set([...t?.excludes?t.excludes:[],...this.#i?this.#i:[]])];return(t||s.length)&&(n[x]={curated:!0,...t,excludes:s}),this.#n.push(n),n}catch(n){console.error("Cannot add item to search indexer",n.message)}}addInfo(e,t){const n=this.#e,s={id:n,url:n,text:a(c(e.description||"")),title:a(`${e.title} (${e.version})`),metadata:t};return this.#n.push(s),s}#o(e){const t=u(this.#e,e.href);return{id:t,url:t,text:a(c(e.description||"")),title:e.name}}getResult(){return this.#n}getOperation(e){return h.getOperation(this.#r,e.operationDefinition,e.parent,{...this.#s,internal_skipSamples:!0},e.href)}#a(e){return[...e.path||[],e.name.toString()].join(".")+e.description+e.place}#d(e,t){if(e.type!=="operation")return;let n={};for(let i of e.parameters){if(i[d])continue;const r=i.schema?.example||i.example,p={name:i.name,description:a(c(i.description)),place:i.in+" parameters",mediaType:void 0,type:i.schema?.type.toString()||"unknown",deepLink:h.generateDeepLink(i),[d]:i[d],required:i.required,example:r?JSON.stringify(r):void 0,enum:i.schema?.enum?.length?i.schema.enum:void 0};n[this.#a(p)]=p}const s=new Set;this.#t(n,e.requestBody?.content?.mediaTypes[0]?.schema,e.requestBody?.content?.mediaTypes[0]?.name,"request fields",!1,[],s);for(let i of e.responses){const r=`response ${i.code} fields`;this.#t(n,i.content?.mediaTypes[0]?.schema,i.content?.mediaTypes[0]?.name,r,!0,[],s)}let o=u(this.#e,e.href);return{id:o,url:o,title:a(e.name),text:a(c(e.description||"")),httpMethod:e.httpVerb,httpPath:e.path,deprecated:e.deprecated,isAdditionalOperation:e.isAdditionalOperation,security:e.security.map(i=>i.schemes.map(r=>r.id)).flat().filter(Boolean),parameters:Object.values(n),badges:e.badges.length?e.badges:void 0,[d]:t}}#t(e,t,n,s,o,l=[],i=new Set){if(!(!t||t.isCircular)){if(t.pointer){if(i.has(t.pointer))return;i.add(t.pointer)}if(t?.fields)for(let r of t.fields){if(t[d]||r.kind==="additionalProperties"||r.schema?.readOnly&&!o||r.schema?.writeOnly&&o)continue;const p=r.schema?.example||r.example,m=r.schema?.enum,f={name:r.name,description:a(r.description),place:s,mediaType:n,path:l,deepLink:h.generateDeepLink(r),type:r.schema?.type.toString()||"unknown",required:r.required||t.schema.required?.includes(r.name)||!1,example:p?JSON.stringify(p):void 0,enum:m?.length?m:void 0},g=this.#a(f);e[g]==null&&(e[g]=f,this.#t(e,r.schema,n,s,o,l.concat([r.name]),i))}t?.items&&this.#t(e,t.items,n,s,o,l,i)}}#c(e){const t=u(this.#e,e.href);return{id:t,url:t,text:a(c(e.description||"")),title:a(e.name)}}#p(e){const t=u(this.#e,e.href);return{id:t,url:t,text:a(c(e.description||"")),title:a(e.name)}}}export{q as SearchIndexer};
@@ -1,4 +1,4 @@
1
- import w from"picomatch";import{removeLeadingSlash as S}from"@redocly/theme/core/utils";import{parsePathVersions as O}from"../../../utils/path/parse-path-versions.js";import{logger as c}from"../../tools/notifiers/logger.js";import{ScorecardStatus as p}from"./types.js";import{getTarget as R}from"./loaders/scorecard.js";const P=15;async function x({actions:e,context:t,scorecardConfig:a,reuniteConfig:n}){c.info("Computing scorecard...");const o=a.levels||[],r=o[0],l=await e.loadOpenApiDefinitions(t),i=a.ignore||[],m=w(i),f=new Set,g=c.startTiming(),d={},u={};for(const s of l){if(!L(s,m,f))continue;const h=s.customOutputRelativeFile||s.realRelativePath;f.add(h);const v=await D(s,t,a,o,r);d[s.realRelativePath]=v,u[v.relativePath]=v}return c.infoTime(g,"Scorecard processed"),T(d,n,a),u}function L(e,t,a){if(e.isVirtual||!e.definition)return!1;const n=e.customOutputRelativeFile||e.realRelativePath,o=S(e.realRelativePath);return t(o)?(c.info(`Skipping scorecard calculation for ignored file: ${e.realRelativePath}`),!1):!a.has(n)}function M(e,t,a){return e-1<t?p.BelowMinimum:t<a-1?p.Minimum:p.Highest}async function D(e,t,a,n,o){const r=e.definition.info?.["x-metadata"]||{},l=await N(a,r)||o.name,{data:{levels:i,scorecardLevelIdx:m,scorecardLevel:f}}=await t.cache.load(e.realRelativePath,"scorecard"),g=n.findIndex(h=>h.name===l),d=M(m,g,n.length),u=e.customOutputRelativeFile||e.realRelativePath,s=O(u)?.versionName;return{levels:i,status:d,targetLevel:l,scorecardLevel:f,scorecardLevelIdx:m,relativePath:u,title:e.definition.info?.title,version:s}}function T(e,t,a){const n=Object.values(e).filter(i=>i.status===p.BelowMinimum);if(n.length===0)return;const o=n.map(i=>i.relativePath);let r=`Detected OpenAPI definitions with score below minimum level:
2
- - ${o.slice(0,P).map(()=>"%rp").join(`
3
- - `)}`;o.length>P&&(r+=`
4
- ... and ${o.length-P} more`),t?.ignoreLint??a.ignoreNonCompliant?c.warn(r,...o):c.error(r,...o)}async function N(e,t){return(await R(e.targets,t))?.minimumLevel}export{x as computeScorecard};
1
+ import w from"node:path";import R from"picomatch";import{removeLeadingSlash as S}from"@redocly/theme/core/utils";import{parsePathVersions as O}from"../../../utils/path/parse-path-versions.js";import{logger as l}from"../../tools/notifiers/logger.js";import{ScorecardStatus as g}from"./types.js";import{getTarget as L}from"./loaders/scorecard.js";const P=15;async function $({actions:t,context:e,scorecardConfig:a,reuniteConfig:n}){l.info("Computing scorecard...");const i=a.levels||[],o=i[0],m=await t.loadOpenApiDefinitions(e),s=a.ignore||[],d=R(s),f=new Set,h=l.startTiming(),c={},p={};for(const r of m){if(!M(r,d,f))continue;const v=r.customOutputRelativeFile||r.realRelativePath;f.add(v);const u=await T(r,e,a,i,o);c[r.realRelativePath]=u,p[u.relativePath]=u}return l.infoTime(h,"Scorecard processed"),N(c,n,a),p}function M(t,e,a){if(t.isVirtual||!t.definition)return!1;const n=t.customOutputRelativeFile||t.realRelativePath,i=S(t.realRelativePath);return e(i)?(l.info(`Skipping scorecard calculation for ignored file: ${t.realRelativePath}`),!1):!a.has(n)}function D(t,e,a){return t-1<e?g.BelowMinimum:e<a-1?g.Minimum:g.Highest}async function T(t,e,a,n,i){let o=i.name;if(a.targets?.length){const r=await e.getConfig(w.posix.dirname(t.realRelativePath)),v=t.definition.info?.["x-metadata"]||{},u={title:t.definition.info?.title,version:t.definition.info?.version,...v,...r.metadata};o=await B(a,u)||i.name}const{data:{levels:m,scorecardLevelIdx:s,scorecardLevel:d}}=await e.cache.load(t.realRelativePath,"scorecard"),f=n.findIndex(r=>r.name===o),h=D(s,f,n.length),c=t.customOutputRelativeFile||t.realRelativePath,p=O(c)?.versionName;return{levels:m,status:h,targetLevel:o,scorecardLevel:d,scorecardLevelIdx:s,relativePath:c,title:t.definition.info?.title,version:p}}function N(t,e,a){const n=Object.values(t).filter(s=>s.status===g.BelowMinimum);if(n.length===0)return;const i=n.map(s=>s.relativePath);let o=`Detected OpenAPI definitions with score below minimum level:
2
+ - ${i.slice(0,P).map(()=>"%rp").join(`
3
+ - `)}`;i.length>P&&(o+=`
4
+ ... and ${i.length-P} more`),e?.ignoreLint??a.ignoreNonCompliant?l.warn(o,...i):l.error(o,...i)}async function B(t,e){return(await L(t.targets,e))?.minimumLevel}export{$ as computeScorecard};
@@ -1 +1 @@
1
- import L from"flexsearch";import{REDOCLY_TEAMS_RBAC as g}from"@redocly/config";import{DISABLE_DEEP_LINK_IF_FIELDS_EXIST as w,HIGHLIGHTED_TEXT_MAX_LENGTH as S,SEARCH_LIMIT as I}from"../../../../constants/plugins/search.js";import{telemetryTraceStep as E}from"../../../../telemetry/helpers/trace-step.js";class T{#e;#t=new Map;#r=1;id;constructor(e,t){this.id=e,this.#e=new L.Document(t)}get documents(){return this.#t.entries()}get documentsCount(){return this.#r}clearDocuments(){this.#t.clear()}async export(e){await this.#e.export(e)}async import(e){const{documents:t,index:r}=e;this.#t.clear();for(const[i,s]of t)this.#t.set(i,s);for(const[i,s]of Object.entries(r))await this.#e.import(i,s)}add(e){e.tags||(e.tags=[]),this.#t.set(this.#r,e[g]?e:{...e,[g]:void 0}),this.#e.add(this.#r,e),this.#r++}async search(e){return await E("search",async t=>{const{query:r,offset:i,auth:s,product:n,versions:a}=e,o=[],c=s.teams,h={limit:I,offset:i};let d=new Map,p=await this.#e.searchAsync(r,{...h,tag:c});if(n){const l=await this.#e.searchAsync(r,{...h,tag:n});p=this.#n(p,l),t?.setAttribute("product",n)}if(a&&a.length){const l=await this.#e.searchAsync(r,{...h,tag:a});p=this.#n(p,l),t?.setAttribute("versions",a.join(","))}for(const l of p)for(const u of l.result){const f=d.get(u)?.fields||[];d.set(u,{fields:l.field?[...f,l.field]:[...f]})}let m=0;for(const[l,u]of d.entries()){if(m>=I)break;const f=this.#t.get(l);f&&!this.#c(f,a)&&(o.push({document:this.#o(f,r,u.fields),highlight:this.#a(f,r,u.fields)}),m++)}return{documents:{[this.id]:o},facets:{}}})}#o(e,t,r){return this.#h(e,t,r)}#a(e,t,r){const i={};let s=!1;for(const n of r)if(n==="path")i.path=e.path?e.path.map(a=>this.#s(t,a)):[];else if(n.includes("parameters")){if(!s){const a=n.split(":")[1],o=e.parameters?.find(c=>{const h=c[a];return this.#i(t,typeof h=="boolean"?h.toString():h)});o&&(i.parameters=[{name:this.#s(t,o.name),description:this.#s(t,o.description),place:this.#s(t,o.place),path:o.path?o.path.map(c=>this.#s(t,c)):[]}],s=!0)}}else i[n]=this.#s(t,e[n]);return i}#s(e,t){const r=e.split(/\s+/g),i=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=r.reduce((n,a)=>a?n?.replace?.(new RegExp(`(^|\\s)${i(a)}`,"i"),o=>`<mark>${o}</mark>`):n,t);if(!s)return t||"";if(s.length<S)return s;{const n=s.indexOf("<mark>"),a=s.indexOf("</mark>")+7,o=S/2+e.length/2,c=n<o,h=a+o<s.length,d=s.substring(c?0:n-o,h?a+o:s.length);return`${c?"":"..."}${d}${h?"...":""}`}}#i=(e,t)=>{if(t){const r=e.split(/\s+/g);return Array.isArray(t)?t.some(i=>r.some(s=>i.toLowerCase().includes(s.toLowerCase()))):r.some(i=>t.toLowerCase().includes(i.toLowerCase()))}else return!1};#n(e,t){const r=[];for(const i of e){const s=[];for(const n of t)for(const a of i.result){const o=n.result.find(c=>c===a);o&&s.push(o)}s.length&&r.push({result:s,field:i.field})}return r}#c(e,t){return!!(t&&t.length&&e.isDefaultVersion&&e.versionFolderId&&e.version&&t.some(r=>r.includes(e.versionFolderId??""))&&!t.some(r=>r.includes(e.version??"")))}#h(e,t,r){for(const s of w)if(r.some(n=>n===s))return e;let i;for(const s of r)if(s.includes("parameters")){const n=s.split(":")[1],a=e.parameters?.find(o=>{const c=o[n];return this.#i(t,typeof c=="boolean"?c.toString():c)});if(a){i=a.deepLink;break}}if(i){const s=i.split("#")[1];return{...e,url:`${e.url}#${s}`}}return e}}export{T as FlexSearchIndex};
1
+ import I from"flexsearch";import{REDOCLY_TEAMS_RBAC as S}from"@redocly/config";import{DISABLE_DEEP_LINK_IF_FIELDS_EXIST as L,SEARCH_LIMIT as w}from"../../../../constants/plugins/search.js";import{telemetryTraceStep as D}from"../../../../telemetry/helpers/trace-step.js";import{highlightTextForSearch as p}from"../../../../utils/search/highlight-text-for-search.js";class y{#e;#t=new Map;#s=1;id;constructor(e,t){this.id=e,this.#e=new I.Document(t)}get documents(){return this.#t.entries()}get documentsCount(){return this.#s}clearDocuments(){this.#t.clear()}async export(e){await this.#e.export(e)}async import(e){const{documents:t,index:s}=e;this.#t.clear();for(const[r,i]of t)this.#t.set(r,i);for(const[r,i]of Object.entries(s))await this.#e.import(r,i)}add(e){e.tags||(e.tags=[]),this.#t.set(this.#s,e[S]?e:{...e,[S]:void 0}),this.#e.add(this.#s,e),this.#s++}async search(e){return await D("search",async t=>{const{query:s,offset:r,auth:i,product:o,versions:a}=e,n=[],c=i.teams,h={limit:w,offset:r};let m=new Map,u=await this.#e.searchAsync(s,{...h,tag:c});if(o){const l=await this.#e.searchAsync(s,{...h,tag:o});u=this.#i(u,l),t?.setAttribute("product",o)}if(a&&a.length){const l=await this.#e.searchAsync(s,{...h,tag:a});u=this.#i(u,l),t?.setAttribute("versions",a.join(","))}for(const l of u)for(const d of l.result){const f=m.get(d)?.fields||[];m.set(d,{fields:l.field?[...f,l.field]:[...f]})}let g=0;for(const[l,d]of m.entries()){if(g>=w)break;const f=this.#t.get(l);f&&!this.#n(f,a)&&(n.push({document:this.#o(f,s,d.fields),highlight:this.#a(f,s,d.fields)}),g++)}return{documents:{[this.id]:n},facets:{}}})}#o(e,t,s){return this.#c(e,t,s)}#a(e,t,s){const r={};let i=!1;for(const o of s)if(o==="path")r.path=e.path?e.path.map(a=>p(t,a)):[];else if(o.includes("parameters")){if(!i){const a=o.split(":")[1],n=e.parameters?.find(c=>{const h=c[a];return this.#r(t,typeof h=="boolean"?h.toString():h)});n&&(r.parameters=[{name:p(t,n.name),description:p(t,n.description),place:p(t,n.place),path:n.path?n.path.map(c=>p(t,c)):[]}],i=!0)}}else r[o]=p(t,e[o]);return r}#r=(e,t)=>{if(t){const s=e.split(/\s+/g);return Array.isArray(t)?t.some(r=>s.some(i=>r.toLowerCase().includes(i.toLowerCase()))):s.some(r=>t.toLowerCase().includes(r.toLowerCase()))}else return!1};#i(e,t){const s=[];for(const r of e){const i=[];for(const o of t)for(const a of r.result){const n=o.result.find(c=>c===a);n&&i.push(n)}i.length&&s.push({result:i,field:r.field})}return s}#n(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??"")))}#c(e,t,s){for(const i of L)if(s.some(o=>o===i))return e;let r;for(const i of s)if(i.includes("parameters")){const o=i.split(":")[1],a=e.parameters?.find(n=>{const c=n[o];return this.#r(t,typeof c=="boolean"?c.toString():c)});if(a){r=a.deepLink;break}}if(r){const i=r.split("#")[1];return{...e,url:`${e.url}#${i}`}}return e}}export{y as FlexSearchIndex};
@@ -2,6 +2,6 @@ import type { LifecyclePluginInstance, PluginOptions } from '../../types';
2
2
  import type { ResolvedNavItem } from '@redocly/config';
3
3
  import type { ContentFs } from '../../fs/content-fs.js';
4
4
  export declare function sidebarsPlugin({ contentDir, }: PluginOptions): Promise<LifecyclePluginInstance>;
5
- export declare function removeMarkdownTags(items: ResolvedNavItem[]): ResolvedNavItem[];
5
+ export declare function stripMarkdocFromDescriptions(items: ResolvedNavItem[]): void;
6
6
  export declare function resolveSidebarId(relativePath: string, sidebarPath: string, fs: ContentFs): Promise<string | null>;
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,3 @@
1
- import{writeFileSync as tt}from"node:fs";import*as u from"path";import et from"@markdoc/markdoc";import{withoutHash as ot}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as v,SIDEBAR_PREFIX as at,CONFIG_FILE_NAME as V}from"../../../constants/common.js";import{CATALOG_OUTPUT_FILE_NAME as rt}from"../../constants/common.js";import{findDeepFirst as M}from"../../../utils/tree/find-deep-first.js";import{isDefined as X}from"../../../utils/guards/is-defined.js";import{partition as it}from"../../../utils/array/partition.js";import{collectPropValueDeep as N}from"../../../utils/tree/collect-prop-value-deep.js";import{envConfig as nt}from"../../config/env-config.js";import{isLocalLink as st}from"../../../utils/path/is-local-link.js";import{normalizeRouteSlug as Y}from"../../../utils/path/normalize-route-slug.js";import{slash as lt}from"../../../utils/path/slash.js";import{parsePathVersions as ct}from"../../../utils/path/parse-path-versions.js";import{reporter as k}from"../../tools/notifiers/reporter.js";import{logger as B}from"../../tools/notifiers/logger.js";import{sha1 as ft}from"../../utils/crypto/sha1.js";import{getInnerText as dt}from"../../../markdoc/helpers/get-inner-text.js";import{collectItemsLinkedToSidebars as ut,resolveItems as J}from"../nav-utils.js";import{getExcludedFromLinkCheckerPatterns as mt,getSidebarReferences as gt,hasCircularDependency as pt}from"./utils.js";import{getLocaleFromRelativePath as ht}from"../../fs/utils/get-locale-from-relative-path.js";import{isSystemRouteSlug as St}from"../../utils/system-routes.js";import{ENTITIES_MAP_GLOBAL_DATA_KEY as yt}from"../../constants/plugins/catalog-entities.js";import{telemetryTraceStep as Ft}from"../../../cli/telemetry/helpers/trace-step.js";import{isPathIgnored as It}from"../../utils/paths.js";const bt=180,Ct=170,Dt=10;async function Qt({contentDir:c}){return{id:"sidebars",async afterRoutesCreated(o,s){await Ft("build.plugin.sidebars",async()=>{const{cache:f,fs:d}=s,b=o.getConfig(),C=new Map,D=new Set,x=[v,...d.localeFolders],j=o.getGlobalData()[yt]||{},G=new Map;let R=d.scan(/sidebars.yaml$/).map(({relativePath:t})=>t).filter(t=>!It(t,b.ignore??[])&&t);const $=await gt(s,c,R),Q=it(R.filter(t=>!$.has(t)),t=>ct(t)?.versionFolderPath||t),_=mt(b),Z=await ut(b?.navbar,o,s,{navFile:V,excludedFromLinkCheckerPatterns:_});let P;const T=pt($);T&&Array.isArray(T)&&await k.panicOnBuildContentError(`Sidebar references have circular dependency. Please check your sidebar files.
1
+ import{writeFileSync as tt}from"node:fs";import*as d from"path";import{removeMarkdocTags as et}from"../../../markdoc/helpers/remove-markdoc-tags.js";import{withoutHash as ot}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as v,SIDEBAR_PREFIX as at,CONFIG_FILE_NAME as V}from"../../../constants/common.js";import{CATALOG_OUTPUT_FILE_NAME as rt}from"../../constants/common.js";import{findDeepFirst as M}from"../../../utils/tree/find-deep-first.js";import{isDefined as X}from"../../../utils/guards/is-defined.js";import{partition as it}from"../../../utils/array/partition.js";import{collectPropValueDeep as N}from"../../../utils/tree/collect-prop-value-deep.js";import{envConfig as st}from"../../config/env-config.js";import{isLocalLink as nt}from"../../../utils/path/is-local-link.js";import{normalizeRouteSlug as Y}from"../../../utils/path/normalize-route-slug.js";import{slash as lt}from"../../../utils/path/slash.js";import{parsePathVersions as ct}from"../../../utils/path/parse-path-versions.js";import{reporter as k}from"../../tools/notifiers/reporter.js";import{logger as B}from"../../tools/notifiers/logger.js";import{sha1 as ft}from"../../utils/crypto/sha1.js";import{collectItemsLinkedToSidebars as dt,resolveItems as J}from"../nav-utils.js";import{getExcludedFromLinkCheckerPatterns as ut,getSidebarReferences as mt,hasCircularDependency as gt}from"./utils.js";import{getLocaleFromRelativePath as pt}from"../../fs/utils/get-locale-from-relative-path.js";import{isSystemRouteSlug as ht}from"../../utils/system-routes.js";import{ENTITIES_MAP_GLOBAL_DATA_KEY as St}from"../../constants/plugins/catalog-entities.js";import{telemetryTraceStep as yt}from"../../../cli/telemetry/helpers/trace-step.js";import{isPathIgnored as Ft}from"../../utils/paths.js";const It=180,bt=170,Dt=10;async function Jt({contentDir:c}){return{id:"sidebars",async afterRoutesCreated(o,i){await yt("build.plugin.sidebars",async()=>{const{cache:p,fs:f}=i,b=o.getConfig(),D=new Map,C=new Set,x=[v,...f.localeFolders],j=o.getGlobalData()[St]||{},G=new Map;let R=f.scan(/sidebars.yaml$/).map(({relativePath:t})=>t).filter(t=>!Ft(t,b.ignore??[])&&t);const $=await mt(i,c,R),Q=it(R.filter(t=>!$.has(t)),t=>ct(t)?.versionFolderPath||t),_=ut(b),Z=await dt(b?.navbar,o,i,{navFile:V,excludedFromLinkCheckerPatterns:_});let P;const T=gt($);T&&Array.isArray(T)&&await k.panicOnBuildContentError(`Sidebar references have circular dependency. Please check your sidebar files.
2
2
  Circular dependency chain: ${T.reverse().join(" -> ")}
3
- `);for(const t of Q){const m=(await Promise.all(t.map(async i=>{const e=(await f.load(i,"yaml")).data;if(!Array.isArray(e)){await k.panicOnBuildContentErrorForRealFile('Invalid sidebar contents at %rp, items should be an array, got "%s"',i,d,i,typeof e);return}return{items:e,sidebarRelativePath:i,locale:ht(i)}}))).filter(X),r=(await A(m))?.firstLink;P||(P=r)}const H=Object.entries(b?.catalogClassic??{});for(const t of x){for(const[e,n]of H)await z(e,n,t);const m={},r=new Set,i=o.getAllRoutesForLocale(t);for(const e of i)if(W(e)&&e.fsPath&&!r.has(e.fsPath)){r.add(e.fsPath);let l=u.posix.dirname(e.fsPath);const h=u.parse(l).root;do m[l]=(m[l]||0)+1,l=u.dirname(l);while(l&&l!="."&&h!=l)}for(const e of i){if(C.has(e.slug))continue;const n=W(e),l=u.dirname(e.fsPath),h=m[l]===1,g=vt(e.baseSlug||e.slug);n&&h?await A([{items:[{directory:l}],sidebarRelativePath:"sidebar.yaml_"+g,locale:t}]):e.getSidebar!==void 0&&await A([{items:[{page:e.fsPath}],sidebarRelativePath:"sidebar.yaml_"+g,locale:t}])}for(const[e,n]of H)await z(e,n,t,!0)}if(R.length===0)for(const t of x){B.verbose("Creating default sidebar");const m=t===v,r=`sidebars.yaml${m?"":"_"+t}`,i=m?"":`${d.localizationFolder}/${t}`,e=(await A([{items:[{directory:`./${i}`}],sidebarRelativePath:r,locale:t,ignoredRoutes:D}]))?.firstLink;P||(P=e)}if(!o.getRouteBySlug("/")&&!o.getConfig().redirects?.["/"]){const m=o.getAllRoutes().find(i=>!St(i.slug)),r=P?P.link:m?.baseSlug??null;if(r){const i=ot(r);o.addRedirect("/",{to:i,type:302}),B.info("Creating default redirect for index page => %s",i)}}const U=nt.REDOCLY_METADATA_OUTPUT_FOLDER;U&&(B.info("Writing catalog data..."),tt(u.join(U,rt),JSON.stringify(Object.fromEntries(G.entries()))));function W(t){return D.has(t.slug)||j[t.fsPath]}async function A(t){if(t.length===0)return;const r=(await Promise.all(t.map(async({items:g,locale:I,sidebarRelativePath:p,ignoredRoutes:L})=>{const a=await J(g,u.dirname(u.join(c,p)),o,s,{locale:I,ignoredRoutes:L,navFile:p,excludedFromLinkCheckerPatterns:_});if(!a){await k.panicOnBuild("Failed to resolve sidebar configuration. Make sure %rp is valid",p);return}return a}))).flat().filter(X),i=N(r,"routeSlug"),e=t[0].sidebarRelativePath,n=q(e),l=new Set;for(const g of i){const I=o.getRouteBySlug(g)?.fsPath??"",p=j[I];p&&(Array.from(l).find(a=>a.key===p.key&&a.version===p.version)||l.add(p)),o.addRouteSharedData(g,"sidebar",n),C.set(Y(g),r)}const h=l.size===1?Array.from(l)[0]:void 0;return await o.createSharedData(n,{relatedNavbarItem:Z?.get(e),items:r,catalogEntity:h?{key:h.key,version:h.version}:void 0}),{firstLink:M(r,g=>!!g.link),resolved:r}}async function z(t,m,r,i=!1){const e=structuredClone(m);r&&r!==v&&e.items.forEach(a=>{a.directory=u.posix.join(d.localizationFolder||"",r,a.directory||"")});let n=await J(e.items,c,o,s,{groupCustomSidebars:!0,locale:r,navFile:V,excludedFromLinkCheckerPatterns:_});if(n&&(n=wt(n)),!n){await k.panicOnBuild(`Failed to resolve catalog configuration. Make sure catalog ${t} has valid config`);return}const l=r===v?"":"/"+r.toLowerCase(),h=r===v?"":`-${r}`,g=Y(u.posix.join(l,e.slug));if(i)for(const a of n){const S=M(a.items||[],F=>!!F.routeSlug);if(!S?.routeSlug)continue;const y=C.get(S.routeSlug);if(!y)continue;const O=N(y,"routeSlug"),E="current-catalog-info-"+a.routeSlug+h,w={catalog:{label:e.title,titleTranslationKey:e.titleTranslationKey,link:g,icon:e?.icon},item:{label:a.metadata?.title,link:a.link,icon:a.icon}};await o.createSharedData(E,w);for(const F of O)o.addRouteSharedData(F,"current-catalog-info",E),D.add(F);const K=M(y,F=>!!F.link&&!F.external&&st(F.link)&&(!a.version||F.version===a.version));K&&(a.sidebar=[{...K,items:void 0}])}const I={},p=new Set;for(const a of n){if(!(a.routeSlug||a.sidebar?.[0]?.routeSlug)||!a.fsPath||p.has(a.fsPath))continue;p.add(a.fsPath);const y=u.dirname(a.fsPath);I[y]=(I[y]||0)+1}if(i){const a=await o.createSharedData("catalog-"+t+h,n.flatMap(S=>{const y=u.dirname(S.fsPath??""),O=I[y]===1,E=w=>({...w,fsPath:O?y:w.fsPath??""});return S.type==="group"&&S.items?.every(w=>w.type==="group")?(S.items||[]).map(E):E(S)}));o.addRouteSharedData(g,"catalog",a),Pt(r,n,G,I)}const L=N(n,"routeSlug");for(const a of L)D.add(a)}})}}}function Pt(c,o,s,f){if(c===v)for(const d of o){const b=d.routeSlug||d.sidebar?.[0]?.routeSlug;if(!b||!d.fsPath)continue;const C=u.dirname(d.fsPath),D=f[C]===1;s.set(b,{rootFileFsPath:d.fsPath,fsPath:D?C:d.fsPath,metadata:d.metadata||{},title:d.metadata?.title||d.label||"Untitled",version:d.version||"latest"})}}function wt(c){const o=s=>{if(!s)return s;const f=et.parse(s);return dt([f])};return c.map(s=>{const f={...s};return f.metadata?.description&&(f.metadata={...f.metadata,description:o(f.metadata.description)}),f})}function q(c){return at+lt(c)}async function Zt(c,o,s){const f=u.posix.join(u.dirname(c),o);return await s.exists(f)?q(f):(await k.panicOnBuildContentErrorForRealFile("File %rp: Failed to create relative path for sidebars.yaml using %s",c,s,c,o),null)}function vt(c){const o=c.replaceAll("/","_");if(o.length>bt){const s=o.slice(0,Ct),f=ft(c).slice(0,Dt).replaceAll("/","_");return s+f}else return o}export{wt as removeMarkdownTags,Zt as resolveSidebarId,Qt as sidebarsPlugin};
3
+ `);for(const t of Q){const u=(await Promise.all(t.map(async s=>{const e=(await p.load(s,"yaml")).data;if(!Array.isArray(e)){await k.panicOnBuildContentErrorForRealFile('Invalid sidebar contents at %rp, items should be an array, got "%s"',s,f,s,typeof e);return}return{items:e,sidebarRelativePath:s,locale:pt(s)}}))).filter(X),r=(await A(u))?.firstLink;P||(P=r)}const H=Object.entries(b?.catalogClassic??{});for(const t of x){for(const[e,l]of H)await z(e,l,t);const u={},r=new Set,s=o.getAllRoutesForLocale(t);for(const e of s)if(W(e)&&e.fsPath&&!r.has(e.fsPath)){r.add(e.fsPath);let n=d.posix.dirname(e.fsPath);const h=d.parse(n).root;do u[n]=(u[n]||0)+1,n=d.dirname(n);while(n&&n!="."&&h!=n)}for(const e of s){if(D.has(e.slug))continue;const l=W(e),n=d.dirname(e.fsPath),h=u[n]===1,m=Et(e.baseSlug||e.slug);l&&h?await A([{items:[{directory:n}],sidebarRelativePath:"sidebar.yaml_"+m,locale:t}]):e.getSidebar!==void 0&&await A([{items:[{page:e.fsPath}],sidebarRelativePath:"sidebar.yaml_"+m,locale:t}])}for(const[e,l]of H)await z(e,l,t,!0)}if(R.length===0)for(const t of x){B.verbose("Creating default sidebar");const u=t===v,r=`sidebars.yaml${u?"":"_"+t}`,s=u?"":`${f.localizationFolder}/${t}`,e=(await A([{items:[{directory:`./${s}`}],sidebarRelativePath:r,locale:t,ignoredRoutes:C}]))?.firstLink;P||(P=e)}if(!o.getRouteBySlug("/")&&!o.getConfig().redirects?.["/"]){const u=o.getAllRoutes().find(s=>!ht(s.slug)),r=P?P.link:u?.baseSlug??null;if(r){const s=ot(r);o.addRedirect("/",{to:s,type:302}),B.info("Creating default redirect for index page => %s",s)}}const U=st.REDOCLY_METADATA_OUTPUT_FOLDER;U&&(B.info("Writing catalog data..."),tt(d.join(U,rt),JSON.stringify(Object.fromEntries(G.entries()))));function W(t){return C.has(t.slug)||j[t.fsPath]}async function A(t){if(t.length===0)return;const r=(await Promise.all(t.map(async({items:m,locale:I,sidebarRelativePath:g,ignoredRoutes:L})=>{const a=await J(m,d.dirname(d.join(c,g)),o,i,{locale:I,ignoredRoutes:L,navFile:g,excludedFromLinkCheckerPatterns:_});if(!a){await k.panicOnBuild("Failed to resolve sidebar configuration. Make sure %rp is valid",g);return}return a}))).flat().filter(X),s=N(r,"routeSlug"),e=t[0].sidebarRelativePath,l=q(e),n=new Set;for(const m of s){const I=o.getRouteBySlug(m)?.fsPath??"",g=j[I];g&&(Array.from(n).find(a=>a.key===g.key&&a.version===g.version)||n.add(g)),o.addRouteSharedData(m,"sidebar",l),D.set(Y(m),r)}const h=n.size===1?Array.from(n)[0]:void 0;return await o.createSharedData(l,{relatedNavbarItem:Z?.get(e),items:r,catalogEntity:h?{key:h.key,version:h.version}:void 0}),{firstLink:M(r,m=>!!m.link),resolved:r}}async function z(t,u,r,s=!1){const e=structuredClone(u);r&&r!==v&&e.items.forEach(a=>{a.directory=d.posix.join(f.localizationFolder||"",r,a.directory||"")});let l=await J(e.items,c,o,i,{groupCustomSidebars:!0,locale:r,navFile:V,excludedFromLinkCheckerPatterns:_});if(!l){await k.panicOnBuild(`Failed to resolve catalog configuration. Make sure catalog ${t} has valid config`);return}Pt(l);const n=r===v?"":"/"+r.toLowerCase(),h=r===v?"":`-${r}`,m=Y(d.posix.join(n,e.slug));if(s)for(const a of l){const S=M(a.items||[],F=>!!F.routeSlug);if(!S?.routeSlug)continue;const y=D.get(S.routeSlug);if(!y)continue;const O=N(y,"routeSlug"),w="current-catalog-info-"+a.routeSlug+h,E={catalog:{label:e.title,titleTranslationKey:e.titleTranslationKey,link:m,icon:e?.icon},item:{label:a.metadata?.title,link:a.link,icon:a.icon}};await o.createSharedData(w,E);for(const F of O)o.addRouteSharedData(F,"current-catalog-info",w),C.add(F);const K=M(y,F=>!!F.link&&!F.external&&nt(F.link)&&(!a.version||F.version===a.version));K&&(a.sidebar=[{...K,items:void 0}])}const I={},g=new Set;for(const a of l){if(!(a.routeSlug||a.sidebar?.[0]?.routeSlug)||!a.fsPath||g.has(a.fsPath))continue;g.add(a.fsPath);const y=d.dirname(a.fsPath);I[y]=(I[y]||0)+1}if(s){const a=await o.createSharedData("catalog-"+t+h,l.flatMap(S=>{const y=d.dirname(S.fsPath??""),O=I[y]===1,w=E=>({...E,fsPath:O?y:E.fsPath??""});return S.type==="group"&&S.items?.every(E=>E.type==="group")?(S.items||[]).map(w):w(S)}));o.addRouteSharedData(m,"catalog",a),Ct(r,l,G,I)}const L=N(l,"routeSlug");for(const a of L)C.add(a)}})}}}function Ct(c,o,i,p){if(c===v)for(const f of o){const b=f.routeSlug||f.sidebar?.[0]?.routeSlug;if(!b||!f.fsPath)continue;const D=d.dirname(f.fsPath),C=p[D]===1;i.set(b,{rootFileFsPath:f.fsPath,fsPath:C?D:f.fsPath,metadata:f.metadata||{},title:f.metadata?.title||f.label||"Untitled",version:f.version||"latest"})}}function Pt(c){const o=i=>{typeof i.metadata?.description=="string"&&(i.metadata={...i.metadata,description:et(i.metadata.description)})};for(const i of c)if(i.routeSlug)o(i);else for(const p of i.items||[])o(p)}function q(c){return at+lt(c)}async function qt(c,o,i){const p=d.posix.join(d.dirname(c),o);return await i.exists(p)?q(p):(await k.panicOnBuildContentErrorForRealFile("File %rp: Failed to create relative path for sidebars.yaml using %s",c,i,c,o),null)}function Et(c){const o=c.replaceAll("/","_");if(o.length>It){const i=o.slice(0,bt),p=ft(c).slice(0,Dt).replaceAll("/","_");return i+p}else return o}export{qt as resolveSidebarId,Jt as sidebarsPlugin,Pt as stripMarkdocFromDescriptions};
@@ -9,4 +9,8 @@ export declare function findFrontmatterSlugs(relativePath: string, loaderName: s
9
9
  export declare function getSidebarSharedDataId(sidebar: string | {
10
10
  path: string;
11
11
  }, relativePath: string, fs: ContentFs): Promise<string | null>;
12
+ export declare function getRouteSlugsForPath(routes: {
13
+ fsPath: string;
14
+ slug: string;
15
+ }[], relativePath: string): string[];
12
16
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- import a from"path";import{DEFAULT_LOCALE_PLACEHOLDER as s}from"../../constants/common.js";import{normalizeRouteSlug as m}from"../../utils/path/normalize-route-slug.js";import{logger as l}from"../tools/notifiers/logger.js";import{getLocaleFromRelativePath as p}from"../fs/utils/get-locale-from-relative-path.js";import{isL10nPath as f}from"../fs/utils/is-l10n-path.js";import{removeL10nPrefix as u}from"../fs/utils/remove-l10n-prefix.js";import{resolveSidebarId as c}from"./sidebars/index.js";function E(e,o){return(Array.isArray(e)?e:e?[e]:[]).map(r=>d(r,o))}function d(e,o){const t=p(o).toLowerCase(),r=m(e);return t!==s?`/${t}${r}`:r}function b(e){const o=e.endsWith(".page.tsx")?".page.tsx":a.posix.extname(e),t=a.posix.basename(e,o);return{baseName:t,isIndexFile:t==="index"}}async function R(e,o,t,r){if(t?.slug||!f(e))return t?.slug;const n=u(e);if(!r.fs.exists(n))return;const{data:i}=await r.cache.load(n,o);return i?.frontmatter?.slug}async function I(e,o,t){const r=typeof e=="string",n=r?e:e.path;return r&&l.warnForRealFile("The 'sidebar' property in the front matter of %rp is deprecated. Use 'sidebar.path' instead.",o,t),n?c(o,n,t):null}export{R as findFrontmatterSlugs,I as getSidebarSharedDataId,b as parseBaseName,E as resolveFrontmatterSlugs};
1
+ import a from"path";import{DEFAULT_LOCALE_PLACEHOLDER as m}from"../../constants/common.js";import{normalizeRouteSlug as l}from"../../utils/path/normalize-route-slug.js";import{slash as i}from"../../utils/path/slash.js";import{logger as u}from"../tools/notifiers/logger.js";import{getLocaleFromRelativePath as f}from"../fs/utils/get-locale-from-relative-path.js";import{isL10nPath as p}from"../fs/utils/is-l10n-path.js";import{removeL10nPrefix as c}from"../fs/utils/remove-l10n-prefix.js";import{resolveSidebarId as d}from"./sidebars/index.js";function b(e,r){return(Array.isArray(e)?e:e?[e]:[]).map(o=>g(o,r))}function g(e,r){const t=f(r).toLowerCase(),o=l(e);return t!==m?`/${t}${o}`:o}function I(e){const r=e.endsWith(".page.tsx")?".page.tsx":a.posix.extname(e),t=a.posix.basename(e,r);return{baseName:t,isIndexFile:t==="index"}}async function P(e,r,t,o){if(t?.slug||!p(e))return t?.slug;const n=c(e);if(!o.fs.exists(n))return;const{data:s}=await o.cache.load(n,r);return s?.frontmatter?.slug}async function w(e,r,t){const o=typeof e=="string",n=o?e:e.path;return o&&u.warnForRealFile("The 'sidebar' property in the front matter of %rp is deprecated. Use 'sidebar.path' instead.",r,t),n?d(r,n,t):null}function C(e,r){return e.filter(t=>i(t.fsPath)===i(r)).map(t=>t.slug)}export{P as findFrontmatterSlugs,C as getRouteSlugsForPath,w as getSidebarSharedDataId,I as parseBaseName,b as resolveFrontmatterSlugs};
@@ -1 +1 @@
1
- import{and as c,eq as C,gt as s,lt as f,or as p,sql as O}from"drizzle-orm";import{decodeCursor as a}from"./utils/decode-cursor.js";const w=i=>{if(i===null||typeof i!="object")return!1;const n=i;return typeof n.value=="string"&&typeof n.id=="string"},D=(i,n)=>{const{after:A,before:b}=n;if(!A&&!b)return{sqlBuilder:i,whereCondition:null};const S=a(A),m=a(b),h=S!=null,j=m!=null&&!h,l=(n.sort&&n.sort.length>0?n.sort:[{field:"id",order:"DESC"}])[0],e=O.identifier(l.field),r=O.identifier("id");let y=null;function g(v,u){if(!v)return null;try{const d=JSON.parse(v);if(!w(d))return null;const t=String(d.value),o=String(d.id);return l.field==="id"?l.order==="ASC"?u==="after"?s(r,o):f(r,o):u==="after"?f(r,o):s(r,o):l.order==="ASC"?u==="after"?p(s(e,t),c(C(e,t),s(r,o))):p(f(e,t),c(C(e,t),f(r,o))):u==="after"?p(f(e,t),c(C(e,t),f(r,o))):p(s(e,t),c(C(e,t),s(r,o)))}catch{return null}}return h?y=g(S,"after"):j&&(y=g(m,"before")),{sqlBuilder:i,whereCondition:y}};export{D as applyAfterAndBefore};
1
+ import{and as g,eq as v,gt as c,lt as a,or as b,sql as p}from"drizzle-orm";import{decodeCursor as q}from"./utils/decode-cursor.js";const G=e=>{if(e===null||typeof e!="object")return!1;const r=e;return typeof r.value=="string"&&typeof r.id=="string"},M=e=>{if(e===null||typeof e!="object")return!1;const r=e;return Array.isArray(r.values)&&r.values.every(f=>typeof f=="string")&&typeof r.id=="string"};function k(e,r,f){if(e.length!==r.length)return p`0`;const h=[];for(let t=0;t<e.length;t++){const C=p.identifier(e[t].field),y=r[t],m=e[t].order==="ASC",d=f==="after"&&m||f==="before"&&!m?c(C,y):a(C,y);if(t===0)h.push(d);else{const o=e.slice(0,t).map((i,S)=>v(p.identifier(i.field),r[S]));h.push(g(g(...o),d))}}return b(...h)}const N=(e,r)=>{const{after:f,before:h}=r;if(!f&&!h)return{sqlBuilder:e,whereCondition:null};const t=q(f),C=q(h),y=t!=null,m=C!=null&&!y,l=r.sort&&r.sort.length>0?r.sort:[{field:"id",order:"ASC"}],d=l[0],o=p.identifier(d.field),i=p.identifier("id");let S=null;function j(B,A){if(!B)return null;try{const n=JSON.parse(B);if(M(n)){const F=l[l.length-1]?.field==="id",I=n.id!=null,w=l.length===n.values.length+1&&F&&I,T=!F&&I&&l.length===n.values.length,x=T?[...l,{field:"id",order:l[0]?.order??"ASC"}]:l,E=w||T?[...n.values,n.id]:n.values;return k(x,E,A)}if(!G(n))return null;const s=String(n.value),u=String(n.id);return d.field==="id"?d.order==="ASC"?A==="after"?c(i,u):a(i,u):A==="after"?a(i,u):c(i,u):d.order==="ASC"?A==="after"?b(c(o,s),g(v(o,s),c(i,u))):b(a(o,s),g(v(o,s),a(i,u))):A==="after"?b(a(o,s),g(v(o,s),a(i,u))):b(c(o,s),g(v(o,s),c(i,u)))}catch{return null}}return y?S=j(t,"after"):m&&(S=j(C,"before")),{sqlBuilder:e,whereCondition:S}};export{N as applyAfterAndBefore};
@@ -1,4 +1,10 @@
1
+ import type { SortOption } from '../types.js';
2
+ /**
3
+ * Create a cursor from an entity and the full sort definition.
4
+ * Encodes all sort field values so that "after" pagination is correct for multi-column sort
5
+ * (e.g. sort by type, title, id). Single-field sort still uses { value, id } for backward compat.
6
+ */
1
7
  export declare function createCursor<T extends {
2
8
  id: string;
3
- }>(entity: T, cursorField: string): string;
9
+ }>(entity: T, sortOptions: SortOption[], nameTransformationsFromDatabase?: Record<string, string>): string;
4
10
  //# sourceMappingURL=create-cursor.d.ts.map
@@ -1 +1 @@
1
- function o(t,e){const n=t[e];if(n===void 0)throw new Error(`Cursor field '${e}' not found in entity`);const r=t.id;if(r!=null){const i={value:String(n),id:String(r)};return Buffer.from(JSON.stringify(i)).toString("base64")}return Buffer.from(String(n)).toString("base64")}export{o as createCursor};
1
+ import{transformToCamelCase as d}from"./transform-to-camel-case.js";function c(r,t){return t?.[r]??d(r)}function S(r,t,u){if(!t.length){const n={value:String(r.id),id:String(r.id)};return Buffer.from(JSON.stringify(n)).toString("base64")}const i=t.map(n=>{const o=c(n.field,u),s=r[o];if(s===void 0&&n.field!=="id")throw new Error(`Cursor field '${n.field}' (key: ${String(o)}) not found in entity`);return String(s??r.id)}),e=r.id;if(e==null)return Buffer.from(JSON.stringify({values:i})).toString("base64");const f=String(e);if(i.length===1){const n={value:i[0],id:f};return Buffer.from(JSON.stringify(n)).toString("base64")}const g={values:i,id:f};return Buffer.from(JSON.stringify(g)).toString("base64")}export{S as createCursor};
@@ -1,3 +1,3 @@
1
- import*as g from"node:path";import{envConfig as R}from"../../config/env-config.js";import{maskEmail as T}from"./helpers/privacy/mask-email.js";import{maskSubject as E}from"./helpers/privacy/mask-subject.js";import{removePii as A}from"./helpers/privacy/remove-pii.js";import{removePiiFromUrl as C}from"./helpers/privacy/remove-pii-from-url.js";import{red as $,green as x,bold as j,blue as p,gray as i,yellow as P,cyan as w}from"./helpers/colors.js";var n;(function(e){e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.SUCCESS="SUCCESS",e.VERBOSE="VERBOSE",e.HTTP="HTTP"})(n||(n={}));const b={[n.VERBOSE]:0,[n.HTTP]:1,[n.INFO]:2,[n.SUCCESS]:2,[n.WARN]:3,[n.ERROR]:4};function W(e,s){return b[e]>=b[s]}function L(e){if(!e)return;const s=e.toUpperCase();if(s in n)return s}const F={[n.INFO]:p,[n.SUCCESS]:x,[n.WARN]:P,[n.ERROR]:$,[n.HTTP]:w,[n.VERBOSE]:i},I={"%ap":e=>p(g.resolve(e)),"%rp":e=>p(g.relative(process.cwd(),e)),"%s":e=>e?.toString(),"%c":e=>p(e)},v={format(e){switch(R.PORTAL_LOG_FORMAT){case"JSON":return M(e);default:return H(e)}},interpolate(e,...s){const a=Object.keys(I).map(t=>`(${t})`).join("|"),m=new RegExp(a,"g");let o,u=e;for(;(o=m.exec(e))!==null;){o.index===m.lastIndex&&m.lastIndex++;const t=s.shift();if(t===void 0)break;const r=o[0];u=u.replace(r,I[r](t))}return u}};var z=v;const H=e=>{const{level:s,message:a,duration:m,context:o}=e,u=R.isRuntimeMode,t=[F[s](j(`[${s.toLowerCase()}]`))];if(u&&t.push(i(`time="${N()}"`)),o){const{email:r,ipAddress:f,subject:l,method:d,pathname:c,statusCode:S,teams:h,apiFunction:O}=o;O&&t.push(p(`fn="${O}"`)),S&&t.push(U(S)),e.level===n.HTTP&&(d&&t.push(i(`method="${d}"`)),c&&t.push(i(`path="${C(c)}"`))),f&&t.push(i(`ip="${f}"`)),r&&t.push(i(`email="${T(r)}"`)),l&&t.push(i(`sub="${E(l)}"`)),h?.length&&t.push(i(`teams="${h.join(", ")}"`))}if(a){const r=u?`msg="${String(A(a)).replaceAll?.('"','\\"')}"`:String(a);t.push(r)}return e.level===n.HTTP&&o?.userAgent&&t.push(i(`agent="${o.userAgent}"`)),m&&t.push(y(m)),t.join(" ")+`
2
- `},M=({context:e,message:s,...a})=>{const{method:m,pathname:o,statusCode:u,userAgent:t,subject:r,email:f,teams:l,apiFunction:d}=e||{},c={...a,email:f&&T(f),subject:r&&E(r),teams:l,apiFunction:d,...a.level===n.HTTP?{method:m,pathname:String(C(o)),statusCode:u,userAgent:t}:{message:String(A(s))}};return R.isRuntimeMode&&(c.time=N()),JSON.stringify(c,["time","level","scope","message","duration","method","pathname","statusCode","userAgent","subject","ipAddress","email","apiFunction"])+`
3
- `},U=e=>(e%500<100?$:e%400<100?P:x)(`status="${e}"`),N=()=>{let e=new Date().getTimezoneOffset()*6e4;return new Date(Date.now()-e).toISOString().slice(0,-1)},y=e=>i(`dur="${Math.round(e)}ms"`);export{n as LogLevel,z as default,L as parseLogLevel,W as shouldLog};
1
+ import*as O from"node:path";import{envConfig as S}from"../../config/env-config.js";import{maskEmail as E}from"./helpers/privacy/mask-email.js";import{maskSubject as T}from"./helpers/privacy/mask-subject.js";import{removePii as C}from"./helpers/privacy/remove-pii.js";import{removePiiFromUrl as $}from"./helpers/privacy/remove-pii-from-url.js";import{red as x,green as A,bold as j,blue as p,gray as i,yellow as P,cyan as w}from"./helpers/colors.js";var n;(function(e){e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.SUCCESS="SUCCESS",e.VERBOSE="VERBOSE",e.HTTP="HTTP"})(n||(n={}));const b={[n.VERBOSE]:0,[n.HTTP]:1,[n.INFO]:2,[n.SUCCESS]:2,[n.WARN]:3,[n.ERROR]:4};function _(e,s){return b[e]>=b[s]}function z(e){if(!e)return;const s=e.toUpperCase();if(s in n)return s}const F={[n.INFO]:p,[n.SUCCESS]:A,[n.WARN]:P,[n.ERROR]:x,[n.HTTP]:w,[n.VERBOSE]:i},I={"%ap":e=>p(O.resolve(e)),"%rp":e=>p(O.relative(process.cwd(),e)),"%s":e=>e?.toString(),"%c":e=>p(e)},v={format(e){switch(S.logFormat){case"JSON":return U(e);default:return H(e)}},interpolate(e,...s){const a=Object.keys(I).map(t=>`(${t})`).join("|"),m=new RegExp(a,"g");let o,u=e;for(;(o=m.exec(e))!==null;){o.index===m.lastIndex&&m.lastIndex++;const t=s.shift();if(t===void 0)break;const r=o[0];u=u.replace(r,I[r](t))}return u}};var G=v;const H=e=>{const{level:s,message:a,duration:m,context:o}=e,u=S.isRuntimeMode,t=[F[s](j(`[${s.toLowerCase()}]`))];if(u&&t.push(i(`time="${N()}"`)),o){const{email:r,ipAddress:f,subject:l,method:d,pathname:c,statusCode:R,teams:h,apiFunction:g}=o;g&&t.push(p(`fn="${g}"`)),R&&t.push(y(R)),e.level===n.HTTP&&(d&&t.push(i(`method="${d}"`)),c&&t.push(i(`path="${$(c)}"`))),f&&t.push(i(`ip="${f}"`)),r&&t.push(i(`email="${E(r)}"`)),l&&t.push(i(`sub="${T(l)}"`)),h?.length&&t.push(i(`teams="${h.join(", ")}"`))}if(a){const r=u?`msg="${String(C(a)).replaceAll?.('"','\\"')}"`:String(a);t.push(r)}return e.level===n.HTTP&&o?.userAgent&&t.push(i(`agent="${o.userAgent}"`)),m&&t.push(M(m)),t.join(" ")+`
2
+ `},U=({context:e,message:s,...a})=>{const{method:m,pathname:o,statusCode:u,userAgent:t,subject:r,email:f,teams:l,apiFunction:d}=e||{},c={...a,email:f&&E(f),subject:r&&T(r),teams:l,apiFunction:d,...a.level===n.HTTP?{method:m,pathname:String($(o)),statusCode:u,userAgent:t}:{message:String(C(s))}};return S.isRuntimeMode&&(c.time=N()),JSON.stringify(c,["time","level","scope","message","duration","method","pathname","statusCode","userAgent","subject","ipAddress","email","apiFunction"])+`
3
+ `},y=e=>(e%500<100?x:e%400<100?P:A)(`status="${e}"`),N=()=>{let e=new Date().getTimezoneOffset()*6e4;return new Date(Date.now()-e).toISOString().slice(0,-1)},M=e=>i(`dur="${Math.round(e)}ms"`);export{n as LogLevel,G as default,z as parseLogLevel,_ as shouldLog};
@@ -1 +1 @@
1
- import{createColors as e}from"colorette";import{envConfig as l}from"../../../config/env-config.js";const r=l.PORTAL_LOG_FORMAT!=="JSON",{red:s,green:t,bold:c,blue:n,gray:a,yellow:g,cyan:d}=e({useColor:r}),f=o=>typeof o=="string"?o.replace(/\x1B[[(?);]{0,2}(;?\d)*./g,""):o;export{n as blue,c as bold,r as colorsAreEnabled,d as cyan,a as gray,t as green,s as red,f as stripColors,g as yellow};
1
+ import{createColors as e}from"colorette";import{envConfig as l}from"../../../config/env-config.js";const r=l.logFormat!=="JSON",{red:s,green:t,bold:c,blue:n,gray:a,yellow:g,cyan:m}=e({useColor:r}),d=o=>typeof o=="string"?o.replace(/\x1B[[(?);]{0,2}(;?\d)*./g,""):o;export{n as blue,c as bold,r as colorsAreEnabled,m as cyan,a as gray,t as green,s as red,d as stripColors,g as yellow};
@@ -0,0 +1,2 @@
1
+ export declare function highlightTextForSearch(query: string, text: string): string;
2
+ //# sourceMappingURL=highlight-text-for-search.d.ts.map
@@ -0,0 +1 @@
1
+ import{HIGHLIGHTED_TEXT_MAX_LENGTH as a}from"../../constants/plugins/search.js";function L(n,g){const p=n.split(/\s+/g),d=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),e=p.reduce((t,h)=>{if(!h||!t?.replace)return t;const u=new RegExp(`(^|\\s)${d(h)}`,"gi");return t.replace(u,(l,H,x,k)=>{const m=k.substring(0,x),T=(m.match(/<mark>/g)??[]).length,$=(m.match(/<\/mark>/g)??[]).length;return T>$?l:`<mark>${l}</mark>`})},g);if(!e)return g||"";if(e.replace(/<mark>/g,"").replace(/<\/mark>/g,"").length<a)return e;const s=e.indexOf("<mark>"),i=e.indexOf("</mark>")+7,r=a/2+n.length/2,o=s<r,c=i+r<e.length,f=e.substring(o?0:s-r,c?i+r:e.length);return`${o?"":"..."}${f}${c?"...":""}`}export{L as highlightTextForSearch};
@@ -1 +1 @@
1
- import{FEEDBACK_API_URL as k}from"../../constants/common.js";import{MAX_CONTEXT_LENGTH as p,MAX_EMAIL_LENGTH as _,MAX_LANG_LENGTH as j,MAX_PATH_LENGTH as E,MAX_REASONS_COUNT as N}from"../../constants/feedback.js";import{mapObject as T}from"../../../utils/object/map-object.js";import{getClientIp as C}from"../utils/get-client-ip.js";import{canAccessResource as S}from"../../utils/rbac.js";function o(n,e){if(n!=null)return String(n).replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,"").trim().slice(0,e)||void 0}function F(n){if(!n)return n;const e=["userAgent","firstName","lastName","auth_time","platform","id","email","ipAddress"];return T(n,(r,a)=>e.includes(a)?r:"*****")}function L({component:n,path:e,location:r,lang:a,score:m,max:s,reasons:i,comment:t,metadata:f,email:u}){const l=Array.isArray(i)?i.map(c=>o(String(c),p)).filter(c=>!!c).slice(0,N):void 0;return{feedbackComponent:n.toUpperCase(),path:o(e,E),location:o(r,p),lang:o(a,j),score:typeof m=="number"?m:void 0,maxScore:typeof s=="number"?s:void 0,reasons:l?.length?l:void 0,comment:o(t,p),email:o(u,_),metadata:F(f)}}async function w(n,e){return(await fetch(k,{method:"POST",body:JSON.stringify(L(n)),headers:e})).json()}function G(n){return async e=>{const r=await e.req.json(),a=e.req.header("user-agent"),m=C(e.req.raw),s=e.req.header("Sec-Ch-Ua-Platform"),i={...r.metadata,userAgent:a,ipAddress:m,platform:s?s.replace(/"/g,""):"unknown"},t=[];(!r.path||r.path==="")&&t.push("`path` is required");const f=["sentiment","rating","comment","problem","mood","scale"];if(f.includes(r.component)||t.push(`\`component\` field should be one of ${f.join(", ")}.`),t.length)return e.json({errors:t},400);const{claims:u,isAuthenticated:l,teams:c}=e.get("auth"),b={isAuthenticated:l,email:u?.email,teams:c};if(Object.keys(n.config.rbac||{}).length>0){const d=r.path,y=new URL(d).pathname,g=n.getRouteBySlug(y);if(!g)return e.json({errors:["Resource not found"]},404);if(!S(g,b,n.config.rbac,n.config.requiresLogin))return e.json({errors:["Forbidden: no permission to send feedback for resource"]},403)}const A={"Content-Type":"application/json"},h=u?.email||r?.email||i?.email;try{const d=await w({...r,email:h,metadata:{email:h,...i}},A);return e.json({message:"Thanks for your feedback",...d},200,{})}catch(d){return e.json({errors:["Failed to send feedback",d.message]},500)}}}export{G as feedbackHandler,F as normalizeFeedbackMetadata};
1
+ import{FEEDBACK_API_URL as _}from"../../constants/common.js";import{MAX_CONTEXT_LENGTH as g,MAX_EMAIL_LENGTH as C,MAX_LANG_LENGTH as j,MAX_PATH_LENGTH as E,MAX_REASONS_COUNT as N}from"../../constants/feedback.js";import{mapObject as T}from"../../../utils/object/map-object.js";import{getClientIp as q}from"../utils/get-client-ip.js";import{canAccessResource as w}from"../../utils/rbac.js";function a(e,n){if(e!=null)return String(e).replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,"").trim().slice(0,n)||void 0}function S(e){if(!e)return e;const n=["userAgent","firstName","lastName","auth_time","platform","id","email","ipAddress"];return T(e,(o,r)=>n.includes(r)?o:"*****")}function L({component:e,path:n,location:o,lang:r,score:u,max:i,reasons:s,comment:m,metadata:t,email:l}){const c=Array.isArray(s)?s.map(d=>a(String(d),g)).filter(d=>!!d).slice(0,N):void 0;return{feedbackComponent:e.toUpperCase(),path:a(n,E),location:a(o,g),lang:a(r,j),score:typeof u=="number"?u:void 0,maxScore:typeof i=="number"?i:void 0,reasons:c?.length?c:void 0,comment:a(m,g),email:a(l,C),metadata:S(t)}}async function R(e,n){return(await fetch(_,{method:"POST",body:JSON.stringify(L(e)),headers:n})).json()}function G(e){return async n=>{const o=n.get("logger"),r=await n.req.json(),u=n.req.header("user-agent"),i=q(n.req.raw),s=n.req.header("Sec-Ch-Ua-Platform"),m={...r.metadata,userAgent:u,ipAddress:i,platform:s?s.replace(/"/g,""):"unknown"};o.info("Feedback IP diagnostics",I(n,i??void 0));const t=[];(!r.path||r.path==="")&&t.push("`path` is required");const l=["sentiment","rating","comment","problem","mood","scale"];if(l.includes(r.component)||t.push(`\`component\` field should be one of ${l.join(", ")}.`),t.length)return n.json({errors:t},400);const{claims:c,isAuthenticated:d,teams:A}=n.get("auth"),k={isAuthenticated:d,email:c?.email,teams:A};if(Object.keys(e.config.rbac||{}).length>0){const f=r.path,F=new URL(f).pathname,b=e.getRouteBySlug(F);if(!b)return n.json({errors:["Resource not found"]},404);if(!w(b,k,e.config.rbac,e.config.requiresLogin))return n.json({errors:["Forbidden: no permission to send feedback for resource"]},403)}const y={"Content-Type":"application/json"},h=c?.email||r?.email||m?.email;try{const f=await R({...r,email:h,metadata:{email:h,...m}},y);return n.json({message:"Thanks for your feedback",...f},200,{})}catch(f){return n.json({errors:["Failed to send feedback",f.message]},500)}}}function I(e,n){return{extractedIpAddress:n,xForwardedFor:p(e.req.header("x-forwarded-for")),xRealIp:p(e.req.header("x-real-ip")),trueClientIp:p(e.req.header("true-client-ip")),cfConnectingIp:p(e.req.header("cf-connecting-ip"))}}function p(e){if(e)return e.slice(0,256)}export{G as feedbackHandler,S as normalizeFeedbackMetadata};
@@ -1 +1 @@
1
- import{createCursor as l}from"../../providers/database/pagination/utils/create-cursor.js";import{transformToCamelCase as g}from"../../providers/database/pagination/utils/transform-to-camel-case.js";import{DEFAULT_LIMIT as f}from"../../providers/database/pagination/limit.js";function h(e){return!!(e.after||e.before)}function P(e,r,i){const n=h(r),t=r.limit??f;if(n){if(r.before)return!0;if(r.after)return e.length===t}return i!==void 0&&r.skip!==void 0?r.skip+t<i:i!==void 0?t<i:e.length===t}function b(e){return!!(e.after||e.before||e.skip!==void 0&&e.skip>0)}function k({data:e,params:r,totalCount:i,nameTransformationsFromDatabase:n={},hasMore:t}){if(!e.length)return{object:"list",items:[],page:{total:0,limit:r.limit??f,hasNextPage:!1,hasPrevPage:!1,startCursor:null,endCursor:null}};const o=r.sort?.[0],s=n[o?.field]||g(o?.field||"id"),u=t??P(e,r,i),c=b(r);return{object:"list",items:e,page:{total:i??0,limit:r.limit??f,hasNextPage:u,hasPrevPage:c,startCursor:l(e[0],s),endCursor:l(e[e.length-1],s)}}}export{k as prepareListResponse};
1
+ import{createCursor as l}from"../../providers/database/pagination/utils/create-cursor.js";import{DEFAULT_LIMIT as o}from"../../providers/database/pagination/limit.js";function c(e){return!!(e.after||e.before)}function g(e,i,r){const n=c(i),t=i.limit??o;if(n){if(i.before)return!0;if(i.after)return e.length===t}return r!==void 0&&i.skip!==void 0?i.skip+t<r:r!==void 0?t<r:e.length===t}function h(e){return!!(e.after||e.before||e.skip!==void 0&&e.skip>0)}function d({data:e,params:i,totalCount:r,nameTransformationsFromDatabase:n={},hasMore:t}){if(!e.length)return{object:"list",items:[],page:{total:0,limit:i.limit??o,hasNextPage:!1,hasPrevPage:!1,startCursor:null,endCursor:null}};const f=i.sort?.length?i.sort:[{field:"id",order:"ASC"}],s=t??g(e,i,r),u=h(i);return{object:"list",items:e,page:{total:r??0,limit:i.limit??o,hasNextPage:s,hasPrevPage:u,startCursor:l(e[0],f,n),endCursor:l(e[e.length-1],f,n)}}}export{d as prepareListResponse};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/realm",
3
- "version": "0.131.0",
3
+ "version": "0.132.0-next.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {
@@ -16,6 +16,7 @@
16
16
  "dependencies": {
17
17
  "@babel/core": "7.23.5",
18
18
  "@dr.pogodin/react-helmet": "3.0.2",
19
+ "@excalidraw/excalidraw": "0.18.0",
19
20
  "@libsql/client": "0.15.4",
20
21
  "@markdoc/markdoc": "0.5.2",
21
22
  "@opentelemetry/api": "1.9.0",
@@ -77,7 +78,7 @@
77
78
  "reactjs-popup": "2.0.6",
78
79
  "semver": "7.7.3",
79
80
  "shiki": "3.21.0",
80
- "simple-git": "3.20.0",
81
+ "simple-git": "3.32.3",
81
82
  "sitemap": "7.1.1",
82
83
  "stream-http": "3.2.0",
83
84
  "styled-components": "5.3.11",
@@ -91,14 +92,14 @@
91
92
  "xpath": "0.0.34",
92
93
  "yaml-ast-parser": "0.0.43",
93
94
  "zod": "^3.25.76",
95
+ "@redocly/asyncapi-docs": "1.9.0-next.1",
94
96
  "@redocly/config": "0.44.1",
95
- "@redocly/asyncapi-docs": "1.8.0",
96
- "@redocly/openapi-docs": "3.19.0",
97
- "@redocly/portal-legacy-ui": "0.14.0",
98
- "@redocly/graphql-docs": "1.8.0",
99
- "@redocly/portal-plugin-mock-server": "0.16.0",
100
- "@redocly/theme": "0.63.0",
101
- "@redocly/realm-asyncapi-sdk": "0.9.0"
97
+ "@redocly/graphql-docs": "1.9.0-next.1",
98
+ "@redocly/openapi-docs": "3.20.0-next.1",
99
+ "@redocly/portal-legacy-ui": "0.15.0-next.0",
100
+ "@redocly/portal-plugin-mock-server": "0.17.0-next.1",
101
+ "@redocly/realm-asyncapi-sdk": "0.10.0-next.0",
102
+ "@redocly/theme": "0.64.0-next.1"
102
103
  },
103
104
  "peerDependencies": {
104
105
  "react": "^19.2.4",