@redocly/reef 0.131.0-next.9 → 0.132.0-next.0

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 (85) hide show
  1. package/CHANGELOG.md +167 -1
  2. package/dist/bin.js +1 -1
  3. package/dist/cli/stats/collectors/{openapi.d.ts → openapi/index.d.ts} +2 -2
  4. package/dist/cli/stats/collectors/openapi/index.js +1 -0
  5. package/dist/cli/stats/collectors/openapi/oas32.d.ts +15 -0
  6. package/dist/cli/stats/collectors/openapi/oas32.js +1 -0
  7. package/dist/cli/stats/index.js +1 -1
  8. package/dist/client/app/hooks/catalog/useCatalogSort.d.ts +1 -1
  9. package/dist/client/app/hooks/catalog/useCatalogSort.js +1 -1
  10. package/dist/client/app/hooks/catalog/useFetchCatalogEntities.js +1 -1
  11. package/dist/client/app/hooks/useAnchorPositioning.js +1 -1
  12. package/dist/client/app/l10n/index.js +1 -1
  13. package/dist/client/app/search/useAiSearch.js +1 -1
  14. package/dist/client/app/seo/SeoTags.js +1 -1
  15. package/dist/client/templates/asyncapi-docs/template.js +1 -3
  16. package/dist/client/templates/openapi-docs/template.js +2 -6
  17. package/dist/client/types/ai-search.d.ts +1 -0
  18. package/dist/constants/l10n/langs/ar.js +1 -1
  19. package/dist/constants/l10n/langs/de.js +1 -1
  20. package/dist/constants/l10n/langs/en.js +1 -1
  21. package/dist/constants/l10n/langs/es.js +1 -1
  22. package/dist/constants/l10n/langs/fr.js +1 -1
  23. package/dist/constants/l10n/langs/hi.js +1 -1
  24. package/dist/constants/l10n/langs/it.js +1 -1
  25. package/dist/constants/l10n/langs/ja.js +1 -1
  26. package/dist/constants/l10n/langs/ko.js +1 -1
  27. package/dist/constants/l10n/langs/pl.js +1 -1
  28. package/dist/constants/l10n/langs/pt-BR.js +1 -1
  29. package/dist/constants/l10n/langs/pt.js +1 -1
  30. package/dist/constants/l10n/langs/ru.js +1 -1
  31. package/dist/constants/l10n/langs/uk.js +1 -1
  32. package/dist/constants/l10n/langs/zh.js +1 -1
  33. package/dist/markdoc/helpers/extract-rbac-from-condition-node.d.ts +6 -15
  34. package/dist/markdoc/helpers/extract-rbac-from-condition-node.js +1 -1
  35. package/dist/markdoc/helpers/guards/is-function.d.ts +1 -0
  36. package/dist/markdoc/helpers/guards/is-variable.d.ts +3 -3
  37. package/dist/server/api-routes/execute-api-route.js +1 -1
  38. package/dist/server/config/env-config.d.ts +1 -0
  39. package/dist/server/config/env-config.js +1 -1
  40. package/dist/server/config/env-schema.d.ts +3 -3
  41. package/dist/server/config/env-schemas/server-config.d.ts +3 -3
  42. package/dist/server/config/env-schemas/server-config.js +1 -1
  43. package/dist/server/esbuild/esbuild-logger.js +3 -3
  44. package/dist/server/node-bundle-entry.js +1 -1
  45. package/dist/server/plugins/asyncapi-docs/search/get-ai-search-documents.js +37 -37
  46. package/dist/server/plugins/catalog-entities/database/catalog-entities-service.d.ts +7 -0
  47. package/dist/server/plugins/catalog-entities/database/catalog-entities-service.js +1 -1
  48. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-read-repository.d.ts +22 -0
  49. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-read-repository.js +29 -15
  50. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.d.ts +6 -0
  51. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.js +1 -1
  52. package/dist/server/plugins/catalog-entities/get-server-props.js +1 -1
  53. package/dist/server/plugins/entitlements/index.js +1 -1
  54. package/dist/server/plugins/entitlements/utils/get-billed-catalog-build-pages-count.d.ts +6 -0
  55. package/dist/server/plugins/entitlements/utils/get-billed-catalog-build-pages-count.js +1 -0
  56. package/dist/server/plugins/graphql-docs/index.js +1 -1
  57. package/dist/server/plugins/markdown/search/get-search-documents.d.ts +1 -1
  58. package/dist/server/plugins/markdown/search/get-search-documents.js +2 -2
  59. package/dist/server/plugins/markdown/search/nodes/heading-node.js +1 -1
  60. package/dist/server/plugins/markdown/search/nodes/section-node.d.ts +2 -2
  61. package/dist/server/plugins/markdown/search/nodes/section-node.js +1 -1
  62. package/dist/server/plugins/markdown/search/walk-sections.js +1 -1
  63. package/dist/server/plugins/openapi-docs/search/get-ai-search-documents.js +25 -25
  64. package/dist/server/plugins/openapi-docs/search-indexer.js +1 -1
  65. package/dist/server/plugins/pages/validators/validate-react-pages.js +1 -1
  66. package/dist/server/plugins/scorecard-classic/compute-scorecard.js +4 -4
  67. package/dist/server/plugins/sidebars/index.d.ts +1 -2
  68. package/dist/server/plugins/sidebars/index.js +2 -2
  69. package/dist/server/providers/database/pagination/after-and-before.js +1 -1
  70. package/dist/server/providers/database/pagination/utils/create-cursor.d.ts +7 -1
  71. package/dist/server/providers/database/pagination/utils/create-cursor.js +1 -1
  72. package/dist/server/ssr/template.js +3 -3
  73. package/dist/server/tools/notifiers/formatter.js +3 -3
  74. package/dist/server/tools/notifiers/helpers/colors.js +1 -1
  75. package/dist/server/tools/notifiers/logger.d.ts +2 -2
  76. package/dist/server/tools/notifiers/logger.js +2 -2
  77. package/dist/server/tools/notifiers/terminal-manager.d.ts +1 -1
  78. package/dist/server/tools/notifiers/terminal-manager.js +4 -4
  79. package/dist/server/web-server/routes/catalog/catalog.js +1 -1
  80. package/dist/server/web-server/routes/catalog/helpers/upsert-pages-stats.d.ts +12 -0
  81. package/dist/server/web-server/routes/catalog/helpers/upsert-pages-stats.js +1 -0
  82. package/dist/server/web-server/routes/cors-proxy.js +2 -2
  83. package/dist/server/web-server/utils/prepare-list-response.js +1 -1
  84. package/package.json +13 -13
  85. package/dist/cli/stats/collectors/openapi.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,171 @@
1
1
  # @redocly/reef
2
2
 
3
+ ## 0.132.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ce5a165177d: Added support for `or` functions in RBAC conditions within Markdoc content.
8
+
9
+ ### Patch Changes
10
+
11
+ - ce5a165177d: Fixed a bug where Markdoc content wrapped in an RBAC condition did not appear in search results for users with access.
12
+ - cd5f1c2d680: Fixed an issue in `scorecardClassic` where the `minimumLevel` calculation in `targets` resulted in incorrect values.
13
+ - ea340565546: Fixed an issue where the catalog tile descriptions displayed Markdown syntax as raw text.
14
+ - f90fa0dd771: Enter prerelease mode.
15
+ - Updated dependencies [f90fa0dd771]
16
+ - @redocly/portal-plugin-mock-server@0.17.0-next.0
17
+ - @redocly/realm-asyncapi-sdk@0.10.0-next.0
18
+ - @redocly/portal-legacy-ui@0.15.0-next.0
19
+ - @redocly/asyncapi-docs@1.9.0-next.0
20
+ - @redocly/graphql-docs@1.9.0-next.0
21
+ - @redocly/openapi-docs@3.20.0-next.0
22
+ - @redocly/theme@0.64.0-next.0
23
+
24
+ ## 0.131.0
25
+
26
+ ### Minor Changes
27
+
28
+ - d87ca0f750: Replaced the separate right-side development mode controls in Realm docs UI with a single bottom floating status bar to improve user experience.
29
+ - 447b0dc32a: Added support for the product filter on **Project Analytics** page.
30
+ - 1d7c82d350: Added support for `badges` option in `sidebars.yaml` to display visual indicators next to sidebar item labels.
31
+ - 8a6153095f: Added an internal `/_api/cors` proxy endpoint in Realm and configured embedded Replay to use it by default.
32
+ - 703634d21f: Enabled semantic search for Docs MCP.
33
+ - c2b1717b2b: Added stricter validation to feedback forms.
34
+ - 34ef22b17c: Added `code-snippet` Markdoc tag support for `llms.txt`.
35
+
36
+ ### Patch Changes
37
+
38
+ - 7f8301f1ed: Fixed an issue where the **Connect to MCP** button ignored the configured prefix path.
39
+ - bfdf798d61: Fixed **View as Markdown** and **Copy for LLM** page actions incorrectly omitting schema properties that share a name with a property at a different nesting level.
40
+ - dc4442ab07: Fixed canonical URLs on versioned pages to use the default version.
41
+ - 5ef75a3b5d: Fixed an issue where the **Copy for LLM** and **View as Markdown** page actions ignored the respective path prefix for the root page.
42
+ - 8b42559201: Fixed an issue where sidebar groups were displayed even though they contained no valid items in the active version.
43
+ - eb7a37ae27: Fixed tooltip visibility in browsers without anchor positioning support.
44
+ - 466f4ca3ba: Fixed an issue where custom Markdoc heading IDs were not used in search results.
45
+ - f7b6c52055: Improved appearance and deep linking for the `tabs` Markdoc tag.
46
+ - 2d305eec36: Fixed the built-in CORS proxy failing with "fetch failed" for certain URLs.
47
+ Now the browser's `accept-encoding` header isn't forwarded and the error message surfaces the underlying cause.
48
+ - 807547ecbd: Improved build memory usage for large projects.
49
+ - 7276b4e5d6: Fixed an issue in AI Search where clearing the product tag would still include the product in the search request.
50
+ - a9a1ee0fe1: Fixed an issue where page actions remained visible even though `search` was disabled.
51
+ - 130c111688: Fixed security vulnerability `CVE-2026-26996` by upgrading `minimatch` to version `10.2.1`.
52
+ - 7e3400d4a8: Fixed page actions overlapping the navbar.
53
+ - d264713872: Fixed an issue where `rbac` configuration ignored versioned content folder paths with leading slashes.
54
+ - 652e464285: Fixed an issue where the root `.md` pages for OpenAPI and AsyncAPI files failed to generate when `requiresLogin` was set to `true` in `redocly.yaml`.
55
+ - c50df09073: Fixed an issue where scorecard displayed a "Lint completed without rules" message when rules were configured in the `apis` section of `redocly.yaml` rather than at the root level.
56
+ - 263c8021c3: Fixed an issue where the terminal output retained artifacts from previous commands.
57
+ - ce4a06bc15: Fixed a bug where Segment analytics ignored `trackPage=false` in configuration when a custom script was used to send page view events.
58
+ - 7abfb7ff61: Updated `@redocly/openapi-core` to version `2.20.5`.
59
+ - adf0e98992: Fixed an issue where the expand dropdown buttons were displayed over open dropdown menus.
60
+ - b2504fea98: Fixed an issue where `sidebars.yaml` files in ignored folders weren't excluded from link checking.
61
+ - 2bb21c43ec: Fixed security vulnerability `CVE-2026-26278` by upgrading `fast-xml-parser` to version `5.3.6`.
62
+ - Updated dependencies [7f8301f1ed]
63
+ - Updated dependencies [3554f6b8da]
64
+ - Updated dependencies [43955ab32f]
65
+ - Updated dependencies [5ef75a3b5d]
66
+ - Updated dependencies [447b0dc32a]
67
+ - Updated dependencies [c2b1717b2b]
68
+ - Updated dependencies [eb7a37ae27]
69
+ - Updated dependencies [17aafeac4a]
70
+ - Updated dependencies [f7b6c52055]
71
+ - Updated dependencies [1eb287db9f]
72
+ - Updated dependencies [8a5957c080]
73
+ - Updated dependencies [e7cc4036fc]
74
+ - Updated dependencies [7276b4e5d6]
75
+ - Updated dependencies [cf845446a0]
76
+ - Updated dependencies [a9a1ee0fe1]
77
+ - Updated dependencies [2bb21c43ec]
78
+ - Updated dependencies [377e39138a]
79
+ - Updated dependencies [4aa015b6ea]
80
+ - Updated dependencies [9b9b43a1b4]
81
+ - Updated dependencies [1cc1909566]
82
+ - Updated dependencies [10585dd0d0]
83
+ - Updated dependencies [7e3400d4a8]
84
+ - Updated dependencies [aca4d30c49]
85
+ - Updated dependencies [34ef22b17c]
86
+ - Updated dependencies [e6944434c8]
87
+ - Updated dependencies [721799cba5]
88
+ - Updated dependencies [721799cba5]
89
+ - Updated dependencies [32c0b1683b]
90
+ - Updated dependencies [7abfb7ff61]
91
+ - Updated dependencies [2641586046]
92
+ - Updated dependencies [adf0e98992]
93
+ - Updated dependencies [1b2efd5ab7]
94
+ - Updated dependencies [2bb21c43ec]
95
+ - @redocly/theme@0.63.0
96
+ - @redocly/realm-asyncapi-sdk@0.9.0
97
+ - @redocly/asyncapi-docs@1.8.0
98
+ - @redocly/graphql-docs@1.8.0
99
+ - @redocly/openapi-docs@3.19.0
100
+ - @redocly/portal-plugin-mock-server@0.16.0
101
+ - @redocly/portal-legacy-ui@0.14.0
102
+
103
+ ## 0.131.0-next.14
104
+
105
+ ### Patch Changes
106
+
107
+ - 2d305eec36a: Fixed the built-in CORS proxy failing with "fetch failed" for certain URLs.
108
+ Now the browser's `accept-encoding` header isn't forwarded and the error message surfaces the underlying cause.
109
+
110
+ ## 0.131.0-next.13
111
+
112
+ ### Patch Changes
113
+
114
+ - 466f4ca3ba3: Fixed an issue where custom Markdoc heading IDs were not used in search results.
115
+ - f7b6c520559: Improved appearance and deep linking for the `tabs` Markdoc tag.
116
+ - 0140f0ba709: Fixed an issue where React page validation failed silently, causing error reporting to be skipped during builds.
117
+ - 7abfb7ff617: Updated `@redocly/openapi-core` to version `2.20.5`.
118
+ - 8983e235fd1: Updated `openapi-sampler` from version 1.7.0 to 1.7.2.
119
+ - Updated dependencies [3554f6b8da8]
120
+ - Updated dependencies [f7b6c520559]
121
+ - Updated dependencies [cf845446a06]
122
+ - Updated dependencies [7abfb7ff617]
123
+ - Updated dependencies [8983e235fd1]
124
+ - @redocly/realm-asyncapi-sdk@0.9.0-next.5
125
+ - @redocly/theme@0.63.0-next.6
126
+ - @redocly/openapi-docs@3.19.0-next.9
127
+ - @redocly/asyncapi-docs@1.8.0-next.9
128
+ - @redocly/graphql-docs@1.8.0-next.7
129
+ - @redocly/portal-plugin-mock-server@0.16.0-next.9
130
+
131
+ ## 0.131.0-next.12
132
+
133
+ ### Patch Changes
134
+
135
+ - 7276b4e5d63: Fixed an issue in AI Search where clearing the product tag would still include the product in the search request.
136
+ - d59b5669cea: Updated `@redocly/openapi-core` to version `2.20.4`.
137
+ - Updated dependencies [43955ab32fd]
138
+ - Updated dependencies [7276b4e5d63]
139
+ - Updated dependencies [1cc1909566f]
140
+ - Updated dependencies [d59b5669cea]
141
+ - @redocly/asyncapi-docs@1.8.0-next.8
142
+ - @redocly/graphql-docs@1.8.0-next.6
143
+ - @redocly/openapi-docs@3.19.0-next.8
144
+ - @redocly/theme@0.63.0-next.5
145
+ - @redocly/portal-plugin-mock-server@0.16.0-next.8
146
+
147
+ ## 0.131.0-next.11
148
+
149
+ ### Patch Changes
150
+
151
+ - dc4442ab07: Fixed canonical URLs on versioned pages to use the default version.
152
+ - b2504fea98: Fixed an issue where `sidebars.yaml` files in folders added to `ignore` configuration weren't excluded from link checking.
153
+ - Updated dependencies [8a5957c080]
154
+ - @redocly/realm-asyncapi-sdk@0.9.0-next.4
155
+ - @redocly/theme@0.63.0-next.4
156
+
157
+ ## 0.131.0-next.10
158
+
159
+ ### Patch Changes
160
+
161
+ - d59d3fce3d: Updated `@redocly/openapi-core` to version `2.20.3`.
162
+ - 652e464285: Fixed an issue where the root `.md` pages for OpenAPI/AsyncAPI files failed to generate when `requiresLogin` was set to `true` in `redocly.yaml`.
163
+ - Updated dependencies [d59d3fce3d]
164
+ - Updated dependencies [1eb287db9f]
165
+ - @redocly/openapi-docs@3.19.0-next.7
166
+ - @redocly/asyncapi-docs@1.8.0-next.7
167
+ - @redocly/portal-plugin-mock-server@0.16.0-next.7
168
+
3
169
  ## 0.131.0-next.9
4
170
 
5
171
  ### Minor Changes
@@ -108,7 +274,7 @@
108
274
 
109
275
  ### Minor Changes
110
276
 
111
- - d87ca0f750: Replaces the separate right-side development mode controls in Realm docs UI with a single bottom floating status bar to improve user experience.
277
+ - d87ca0f750: Replaced the separate right-side development mode controls in Realm docs UI with a single bottom floating status bar to improve user experience.
112
278
  - 703634d21f: Enabled semantic search for Docs MCP.
113
279
 
114
280
  ### Patch Changes
package/dist/bin.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import"./server/utils/set-execution-mode.js";import"./cli/utils/node-version-check.js";import o from"mri";import*as r from"node:path";import{tmpdir as x}from"node:os";import*as T from"node:fs";import"./server/node-fetch-polyfill.js";import{cliCommandNames as g}from"./constants/common.js";import{initPlugins as y}from"./server/plugins/lifecycle.js";import{loadEnvVariables as k}from"./server/utils/envs/load-env-variables.js";import{PORTAL_VERSION as S}from"./server/version.js";import{logger as l}from"./server/tools/notifiers/logger.js";import{reporter as t}from"./server/tools/notifiers/reporter.js";import{sha as I}from"./server/utils/crypto/sha.js";import{envConfig as L}from"./server/config/env-config.js";import{PACKAGE_NAME as b}from"./config/product-gates.js";import{develop as V}from"./cli/develop.js";import{eject as _}from"./cli/eject/index.js";import{beforeCommand as w}from"./server/utils/lifecycle-hooks.js";import{Store as C}from"./server/store.js";import{build as M}from"./cli/build/index.js";import{fromCurrentDir as N}from"./server/utils/paths.js";import{translationsCliOpts as R}from"./cli/translations/options.js";import{generateTranslations as F}from"./cli/translations/index.js";import{EntitlementsProvider as $}from"./server/entitlements/entitlements-provider.js";import{isValidPlan as U}from"./server/entitlements/is-valid-plan.js";import{stopAllCompilers as B}from"./server/esbuild/esbuild.js";import{copyLibsqlPrebuiltBinary as G}from"./cli/build/libsql/copy-prebuilt-binary.js";import{telemetry as d}from"./cli/telemetry/index.js";import{stats as q}from"./cli/stats/index.js";import{statsCliOpts as K}from"./cli/stats/options.js";const n=process.argv[2];let i;const f={alias:{d:"project-dir",p:"port"},default:{"project-dir":L.REDOCLY_CONTENT_DIR||process.cwd(),outdir:"public"}},Y={alias:f.alias,default:{...f.default,plan:"enterprise"}},z={alias:{d:"buildDir"},default:{buildDir:"public"}},H={boolean:["force"],alias:{f:"force",d:"project-dir"},default:{"project-dir":process.cwd()}};process.on("uncaughtException",async function(e){e?.code==="ERR_INVALID_STATE"?console.log("Ignore premature close error"):(l.error("Uncaught exception occurred. Stopping compilers."),await B(),l.error("Exiting due to uncaught exception"),await t.panic(e))});try{n||await t.panicOnContentError("Command not specified.");const e=$.instance();switch(["build","prepare","serve","stats"].includes(n)&&await e.init(),["eject","translate"].includes(n)&&await e.init({developModePlan:"enterprise"}),n){case"develop":case"preview":const a=o(process.argv.slice(3),Y),E=r.resolve(a["project-dir"]),j=r.join(x(),"redocly-public-"+I(E)),p=a.plan.toLowerCase();U(p)||await t.panicOnContentError(`Invalid --plan argument value '${p}'.`),await e.init({developModePlan:p}),i=new C({contentDir:r.resolve(a["project-dir"]),outdir:j,serverOutDir:N(import.meta.url,"./server/esbuild/cache/server")}),await w(g.DEVELOP,a,i),await V(a,i);break;case"build":case"prepare":const s=o(process.argv.slice(3),f),u=r.resolve(r.join(s.outdir,"server"));i=new C({contentDir:r.resolve(s["project-dir"]),outdir:r.resolve(s.outdir,"client"),serverOutDir:u}),await w(g.BUILD,s,i),G(u),await M(s,i);break;case"serve":await k();const O=o(process.argv.slice(3),z),h=r.resolve(O.buildDir);d.sendServeCliCommandExecutedMessage();const v=r.join(h,"server","index.mjs");T.existsSync(v)||await t.panic(`Server not found. Please run \`${b} build\` first (or \`${b} prepare\` for the deprecated command)`),import(v).catch(async c=>{await t.panic("Failed to load server",c)});break;case"eject":e.canAccessFeature("themeEjecting")||await t.panicOnContentError('The "eject" command is not available for this project');const m=o(process.argv.slice(3),H),{lifecycleContext:{getConfig:A,fs:D}}=await y({outdir:"",contentDir:r.resolve(m["project-dir"]),setGlobalConfig:()=>null});D.dispose(),d.sendCliCommandEjectExecutedMessage([{object:"cli_command",arguments:m}]),await _({...m,config:await A()}),l.clearAllTimeouts();break;case"translate":if(e.canAccessFeature("l10n")){const c=o(process.argv.slice(3),R);d.sendCliCommandTranslateExecutedMessage({arguments:c}),await F(c)}else await t.panicOnContentError('The "translate" command is not available for this project');break;case"stats":const P=o(process.argv.slice(3),K);await q(P);break;case"--version":console.log(S);break;default:await t.panicOnContentError(`Unknown command "${n}"`)}}catch(e){l.error("Exiting due to uncaught exception"),await t.panic(e)}
2
+ import"./server/utils/set-execution-mode.js";import"./cli/utils/node-version-check.js";import o from"mri";import*as r from"node:path";import{tmpdir as T}from"node:os";import*as u from"node:fs";import"./server/node-fetch-polyfill.js";import{cliCommandNames as C}from"./constants/common.js";import{initPlugins as S}from"./server/plugins/lifecycle.js";import{loadEnvVariables as k}from"./server/utils/envs/load-env-variables.js";import{PORTAL_VERSION as I}from"./server/version.js";import{logger as i}from"./server/tools/notifiers/logger.js";import{reporter as t}from"./server/tools/notifiers/reporter.js";import{sha as V}from"./server/utils/crypto/sha.js";import{envConfig as L}from"./server/config/env-config.js";import{PACKAGE_NAME as w}from"./config/product-gates.js";import{develop as R}from"./cli/develop.js";import{eject as _}from"./cli/eject/index.js";import{beforeCommand as E}from"./server/utils/lifecycle-hooks.js";import{Store as j}from"./server/store.js";import{build as M}from"./cli/build/index.js";import{fromCurrentDir as N}from"./server/utils/paths.js";import{translationsCliOpts as F}from"./cli/translations/options.js";import{generateTranslations as U}from"./cli/translations/index.js";import{EntitlementsProvider as $}from"./server/entitlements/entitlements-provider.js";import{isValidPlan as B}from"./server/entitlements/is-valid-plan.js";import{stopAllCompilers as G}from"./server/esbuild/esbuild.js";import{copyLibsqlPrebuiltBinary as q}from"./cli/build/libsql/copy-prebuilt-binary.js";import{telemetry as f}from"./cli/telemetry/index.js";import{stats as K}from"./cli/stats/index.js";import{statsCliOpts as Y}from"./cli/stats/options.js";const c=process.argv[2];let a;const v={alias:{d:"project-dir",p:"port"},default:{"project-dir":L.REDOCLY_CONTENT_DIR||process.cwd(),outdir:"public"}},z={alias:v.alias,default:{...v.default,plan:"enterprise"}},H={alias:{d:"buildDir"},default:{buildDir:"public"}},J={boolean:["force"],alias:{f:"force",d:"project-dir"},default:{"project-dir":process.cwd()}};process.on("uncaughtException",async function(e){e?.code==="ERR_INVALID_STATE"?console.log("Ignore premature close error"):(i.error("Uncaught exception occurred. Stopping compilers."),await G(),i.error("Exiting due to uncaught exception"),await t.panic(e))});try{c||await t.panicOnContentError("Command not specified.");const e=$.instance();switch(["build","prepare","serve","stats"].includes(c)&&await e.init(),["eject","translate"].includes(c)&&await e.init({developModePlan:"enterprise"}),c){case"develop":case"preview":const s=o(process.argv.slice(3),z),O=r.resolve(s["project-dir"]),h=encodeURIComponent(V(O)),p=r.join(T(),"redocly-public-"+h);u.existsSync(p)&&(i.verbose("Cleaning temporary output directory..."),u.rmSync(p,{recursive:!0,force:!0}),i.verbose("Temporary output directory cleaned."));const m=s.plan.toLowerCase();B(m)||await t.panicOnContentError(`Invalid --plan argument value '${m}'.`),await e.init({developModePlan:m}),a=new j({contentDir:r.resolve(s["project-dir"]),outdir:p,serverOutDir:N(import.meta.url,"./server/esbuild/cache/server")}),await E(C.DEVELOP,s,a),await R(s,a);break;case"build":case"prepare":const n=o(process.argv.slice(3),v),g=r.resolve(r.join(n.outdir,"server"));a=new j({contentDir:r.resolve(n["project-dir"]),outdir:r.resolve(n.outdir,"client"),serverOutDir:g}),await E(C.BUILD,n,a),q(g),await M(n,a);break;case"serve":await k();const A=o(process.argv.slice(3),H),D=r.resolve(A.buildDir);f.sendServeCliCommandExecutedMessage();const b=r.join(D,"server","index.mjs");u.existsSync(b)||await t.panic(`Server not found. Please run \`${w} build\` first (or \`${w} prepare\` for the deprecated command)`),import(b).catch(async l=>{await t.panic("Failed to load server",l)});break;case"eject":e.canAccessFeature("themeEjecting")||await t.panicOnContentError('The "eject" command is not available for this project');const d=o(process.argv.slice(3),J),{lifecycleContext:{getConfig:y,fs:P}}=await S({outdir:"",contentDir:r.resolve(d["project-dir"]),setGlobalConfig:()=>null});P.dispose(),f.sendCliCommandEjectExecutedMessage([{object:"cli_command",arguments:d}]),await _({...d,config:await y()}),i.clearAllTimeouts();break;case"translate":if(e.canAccessFeature("l10n")){const l=o(process.argv.slice(3),F);f.sendCliCommandTranslateExecutedMessage({arguments:l}),await U(l)}else await t.panicOnContentError('The "translate" command is not available for this project');break;case"stats":const x=o(process.argv.slice(3),Y);await K(x);break;case"--version":console.log(I);break;default:await t.panicOnContentError(`Unknown command "${c}"`)}}catch(e){i.error("Exiting due to uncaught exception"),await t.panic(e)}
@@ -1,3 +1,3 @@
1
- import type { LifecycleContext } from '../../../server/types';
1
+ import type { LifecycleContext } from '../../../../server/types';
2
2
  export declare function collectOpenapiDocumentsStatistics(lifecycleContext: LifecycleContext, telemetryEnabled: boolean): Promise<void>;
3
- //# sourceMappingURL=openapi.d.ts.map
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ import{detectSpec as u,getTypes as d,normalizeTypes as w,normalizeVisitors as h,resolveDocument as S,BaseResolver as g,StatsOAS as y,walkDocument as D}from"@redocly/openapi-core";import{logger as m}from"../../../../server/tools/notifiers/logger.js";import{envConfig as I}from"../../../../server/config/env-config.js";import{telemetryTraceStep as O}from"../../../telemetry/helpers/trace-step.js";import{telemetry as v}from"../../../telemetry/index.js";import{computeOas32Stats as b}from"./oas32.js";const t={refs:{metric:"References",total:0,color:"red",items:new Set},externalDocs:{metric:"External Documents",total:0,color:"magenta"},schemas:{metric:"Schemas",total:0,color:"white"},parameters:{metric:"Parameters",total:0,color:"yellow",items:new Set},links:{metric:"Links",total:0,color:"cyan",items:new Set},pathItems:{metric:"Path Items",total:0,color:"green"},webhooks:{metric:"Webhooks",total:0,color:"green"},operations:{metric:"Operations",total:0,color:"yellow"},tags:{metric:"Tags",total:0,color:"white",items:new Set}};async function _(a,o){await O("stats.openapi",async()=>{m.info("OpenAPI collector: start processing documents...");const e=(await a.cache.load(".","load-oas-docs")).data,s=[];for(const r of e)if(!r.isVirtual){const n=await k(r);s.push(n),v.sendStatsOpenapiCollectedMessage([{...n,projectBuildId:I.PROJECT_BUILD_ID||""}])}o||console.table(s),m.info("OpenAPI collector: openapi documents processing completed.")})}async function k(a){const o=a.definition,e=u(o),s=w(d(e)),r=h([{severity:"warn",ruleId:"openapi_stats",visitor:y(t)}],s),n={problems:[],specVersion:e,visitorsData:{}},c={source:{absoluteRef:""},parsed:o},i=s.Root;if(!i)throw new Error("Root type not found in OpenAPI spec types");const f=await S({rootDocument:c,rootType:i,externalRefResolver:new g});D({rootType:i,normalizedVisitors:r,resolvedRefMap:f,document:c,ctx:n});const l={path:a.relativePath,refs:t.refs.total,externalDocs:t.externalDocs.total,schemas:t.schemas.total,parameters:t.parameters.total,links:t.links.total,pathItems:t.pathItems.total,webhooks:t.webhooks.total,operations:t.operations.total,tags:t.tags.total,version:e};if(e==="oas3_2"){const p=b(o);p&&Object.assign(l,p)}return l}export{_ as collectOpenapiDocumentsStatistics};
@@ -0,0 +1,15 @@
1
+ export type OpenapiStatsOas32 = {
2
+ streamingOperations: number;
3
+ itemSchemaMediaTypes: number;
4
+ additionalOperations: number;
5
+ serversWithName: number;
6
+ discriminatorSchemas: number;
7
+ queryMethodOperations: number;
8
+ parametersWithQueryString: number;
9
+ oauth2WithMetadataUrl: number;
10
+ oauth2DeviceAuthorization: number;
11
+ componentMediaTypes: number;
12
+ xmlNodeTypeUsage: number;
13
+ };
14
+ export declare function computeOas32Stats(doc: unknown): OpenapiStatsOas32 | null;
15
+ //# sourceMappingURL=oas32.d.ts.map
@@ -0,0 +1 @@
1
+ const q=new Set(["text/event-stream","application/jsonl","application/json-seq","multipart/mixed"]);function i(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function c(e,t){const s=e[t];return i(s)?s:void 0}function l(e,t){const s=e[t];return Array.isArray(s)?s:[]}function b(e,t){let s=0;for(const a of Object.keys(e))t.has(a)&&s++;return s}function O(e){let t=0;for(const s of Object.values(e))i(s)&&s.itemSchema!=null&&t++;return t}function S(e){return b(e,q)}function d(e){return e.filter(t=>i(t)?t.in==="querystring":!1).length}function g(e,t){const s=e.responses;if(i(s))for(const o of Object.values(s))i(o)&&i(o.content)&&(t.streaming+=S(o.content),t.itemSchema+=O(o.content));const a=c(e,"requestBody");if(a){const o=c(a,"content");o&&(t.streaming+=S(o),t.itemSchema+=O(o))}const m=l(e,"parameters");t.queryStringParams+=d(m)}function v(e,t){const s=l(e,"parameters");t.queryStringParams+=d(s);const a=["get","put","post","delete","patch","head","options","trace","query"];for(const o of a){const n=e[o];i(n)&&(o==="query"&&t.queryMethod++,g(n,t))}const m=c(e,"additionalOperations");if(m){t.additionalOps+=Object.keys(m).length;for(const o of Object.values(m))i(o)&&g(o,t)}}function f(e,t){e.discriminator!=null&&t.discriminator++,c(e,"xml")?.nodeType!=null&&t.xmlNodeType++;const a=e.items;i(a)&&f(a,t);for(const o of["properties","patternProperties"]){const n=e[o];if(i(n))for(const r of Object.values(n))i(r)&&f(r,t)}const m=e.additionalProperties;i(m)&&f(m,t);for(const o of["oneOf","anyOf","allOf","prefixItems"]){const n=e[o];if(Array.isArray(n))for(const r of n)i(r)&&f(r,t)}}function T(e){if(!i(e))return null;const t={streamingOperations:0,itemSchemaMediaTypes:0,additionalOperations:0,serversWithName:0,discriminatorSchemas:0,queryMethodOperations:0,parametersWithQueryString:0,oauth2WithMetadataUrl:0,oauth2DeviceAuthorization:0,componentMediaTypes:0,xmlNodeTypeUsage:0},s=l(e,"servers");for(const n of s)i(n)&&n.name!=null&&t.serversWithName++;const a=c(e,"paths");if(a){const n={streaming:0,additionalOps:0,queryMethod:0,queryStringParams:0,itemSchema:0};for(const r of Object.values(a))i(r)&&v(r,n);t.streamingOperations=n.streaming,t.additionalOperations=n.additionalOps,t.queryMethodOperations=n.queryMethod,t.parametersWithQueryString=n.queryStringParams,t.itemSchemaMediaTypes=n.itemSchema}const m=c(e,"webhooks");if(m){const n={streaming:0,additionalOps:0,queryMethod:0,queryStringParams:0,itemSchema:0};for(const r of Object.values(m))i(r)&&v(r,n);t.streamingOperations+=n.streaming,t.additionalOperations+=n.additionalOps,t.queryMethodOperations+=n.queryMethod,t.parametersWithQueryString+=n.queryStringParams,t.itemSchemaMediaTypes+=n.itemSchema}const o=c(e,"components");if(o){const n=c(o,"mediaTypes");if(n){t.componentMediaTypes=Object.keys(n).length;for(const u of Object.values(n))i(u)&&u.itemSchema!=null&&t.itemSchemaMediaTypes++}const r=c(o,"schemas");if(r){const u={discriminator:0,xmlNodeType:0};for(const p of Object.values(r))i(p)&&f(p,u);t.discriminatorSchemas=u.discriminator,t.xmlNodeTypeUsage=u.xmlNodeType}const h=c(o,"securitySchemes");if(h)for(const u of Object.values(h))i(u)&&u.type==="oauth2"&&(u.oauth2MetadataUrl!=null&&t.oauth2WithMetadataUrl++,c(u,"flows")?.deviceAuthorization!=null&&t.oauth2DeviceAuthorization++);const y=c(o,"parameters");y&&(t.parametersWithQueryString+=d(Object.values(y)))}return t}export{T as computeOas32Stats};
@@ -1 +1 @@
1
- import{initPlugins as n}from"../../server/plugins/lifecycle.js";import{configParserPlugin as a}from"../../server/plugins/config-parser/index.js";import{openAPIDocsPlugin as c}from"../../server/plugins/openapi-docs/index.js";import{shutdowner as s}from"../../server/tools/shutdowner.js";import{PORTAL_VERSION as p}from"../../server/version.js";import{collectOpenapiDocumentsStatistics as l}from"./collectors/openapi.js";import{telemetry as f}from"../telemetry/index.js";import{telemetryTraceStep as y}from"../telemetry/helpers/trace-step.js";async function I(e){const{"project-dir":o,telemetry:t,verbose:i}=e;f.initialize(p,t,i),await y("stats",async()=>{const r=[a,c],{lifecycleContext:m}=await n({contentDir:o},r);await l(m,t)}),await s.exitWithCode(0)}export{I as stats};
1
+ import{initPlugins as n}from"../../server/plugins/lifecycle.js";import{configParserPlugin as a}from"../../server/plugins/config-parser/index.js";import{openAPIDocsPlugin as c}from"../../server/plugins/openapi-docs/index.js";import{shutdowner as s}from"../../server/tools/shutdowner.js";import{PORTAL_VERSION as p}from"../../server/version.js";import{collectOpenapiDocumentsStatistics as l}from"./collectors/openapi/index.js";import{telemetry as f}from"../telemetry/index.js";import{telemetryTraceStep as y}from"../telemetry/helpers/trace-step.js";async function I(e){const{"project-dir":o,telemetry:t,verbose:i}=e;f.initialize(p,t,i),await y("stats",async()=>{const r=[a,c],{lifecycleContext:m}=await n({contentDir:o},r);await l(m,t)}),await s.exitWithCode(0)}export{I as stats};
@@ -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{useMemo as o}from"react";const r=()=>({isSupported:o(()=>t(),[])});function t(){return typeof CSS>"u"||typeof CSS.supports!="function"?!1:CSS.supports("anchor-name: --a")&&CSS.supports("position-anchor: --a")&&CSS.supports("top: anchor(top)")}export{r as useAnchorPositioning};
1
+ import{useState as n,useEffect as s}from"react";const e=()=>{const[o,t]=n(!1);return s(()=>{t(p())},[]),{isSupported:o}};function p(){return typeof CSS>"u"||typeof CSS.supports!="function"?!1:CSS.supports("anchor-name: --a")&&CSS.supports("position-anchor: --a")&&CSS.supports("top: anchor(top)")}export{e as useAnchorPositioning};
@@ -1 +1 @@
1
- import o from"i18next";import{useEffect as a}from"react";import{DEFAULT_LOCALE_PLACEHOLDER as s}from"../../../constants/common";import{defaultTranslationImports as l}from"../../../constants/l10n/default-translations";import{useL10nConfig as u}from"../hooks";const p=()=>{const{currentLocale:t}=u();a(()=>{!t||t===s?document.documentElement.removeAttribute("lang"):document.documentElement.setAttribute("lang",t)},[t])},g=async t=>{if(!t)return;const n=new Set(o.languages);for(const e of Object.keys(t.translations)){const r=await l[e]?.()||{};o.addResourceBundle(e,"translation",{...r,...t.translations[e]?.translation??{}},!0,!0),n.delete(e)}for(const e of n)o.removeResourceBundle(e,"translation")};export{g as updateTranslations,p as useL10n};
1
+ import e from"i18next";import{useEffect as a}from"react";import{DEFAULT_LOCALE_PLACEHOLDER as s}from"../../../constants/common";import{defaultTranslationImports as l}from"../../../constants/l10n/default-translations";import{useL10nConfig as i}from"../hooks";const p=()=>{const{currentLocale:t}=i();a(()=>{const o=!t||t===s?"en":t;document.documentElement.setAttribute("lang",o)},[t])},g=async t=>{if(!t)return;const o=new Set(e.languages);for(const n of Object.keys(t.translations)){const r=await l[n]?.()||{};e.addResourceBundle(n,"translation",{...r,...t.translations[n]?.translation??{}},!0,!0),o.delete(n)}for(const n of o)e.removeResourceBundle(n,"translation")};export{g as updateTranslations,p as useL10n};
@@ -1 +1 @@
1
- import{useCallback as E,useEffect as J,useMemo as N,useRef as m,useState as C}from"react";import{AiSearchError as d}from"@redocly/theme/core/constants";import{withPathPrefix as V,splitContentByToolCalls as j}from"@redocly/theme/core/utils";import{ServerRoutes as B}from"../../../constants/common";import{useSearchSession as D}from"@redocly/theme/core/contexts";import{AI_SEARCH_REQUEST_HEADERS as G,HTTP_ERROR_MAP as K}from"../../constants";import{useI18nConfig as L,useCurrentProduct as U,usePageVersions as z}from"../hooks";import{telemetry as W}from"../telemetry/index.js";import{streamSSEMessages as X}from"./sse-parser";import{handleSSEMessage as Y}from"./message-handlers";function ur(b){const{searchSessionId:p}=D(),[r,s]=C({status:"idle"}),[w,g]=C([]),[S,y]=C([]),t=m(null),u=m(""),o=m(""),a=m([]),{currentLocale:A}=L(),i=U(),{versions:M=[]}=z()||{},l=M.find(e=>e?.active),f=E(()=>{s({status:"idle",response:""}),y([]),u.current="",o.current="",a.current=[]},[]),O=E(()=>{t.current?.abort(),t.current=null,f(),g([])},[f]);J(()=>()=>{t.current?.abort()},[]);const k=E(async(e,F)=>{if(!e)return;t.current?.abort();const h=new AbortController;t.current=h,f(),s({status:"loading",question:e,response:"",resources:[]});try{const n=await fetch(V(B.ASK_AI),{method:"POST",headers:G,body:JSON.stringify({text:e,history:F||[],locale:A,product:i?.name,filter:b?.filter,version:l&&{folder:l.folderId,label:l.label},searchSessionId:p}),signal:h.signal});if(!n.ok){s({status:"error",question:e,error:K[n.status]??d.HttpRequestFailed});return}const I=n.body;if(!I){s({status:"error",question:e,error:d.HttpRequestFailed});return}let v=!1;for await(const c of X(I,h.signal)){const Q={messageId:u.current,resources:a.current,accumulatedResponse:o.current,setConversation:g,setState:s,setToolCalls:y},{messageId:H,resources:P,accumulatedResponse:_}=Y(c,Q);H&&(u.current=H),P&&(a.current=P),_&&(o.current=_),c.type==="error"&&(v=!0)}t.current=null,s(c=>c.status==="error"?c:o.current?{status:"success",question:e,response:o.current,resources:a.current}:{status:"error",question:e,error:d.EmptyResponse}),!v&&o.current&&e.trim()&&u.current&&W.sendSearchAIQueryMessage([{object:"search",question:e,answer:o.current,resources:JSON.stringify(a.current),searchSessionId:p,messageId:u.current,...i?.name&&{product:i.name}}])}catch(n){if(n instanceof Error&&n.name==="AbortError")return;t.current=null,s({status:"error",question:e,error:d.HttpRequestFailed})}},[f,A,i?.name,b?.filter,l,p]),R=r.status==="loading"||r.status==="success"||r.status==="idle"?r.response:void 0,q=N(()=>j(R,S),[R,S]);return{askQuestion:k,isGeneratingResponse:r.status==="loading",response:R,resources:r.status==="loading"||r.status==="success"?r.resources:[],question:r.status!=="idle"?r.question:"",error:r.status==="error"?r.error:null,clearConversation:O,conversation:w,setConversation:g,toolCalls:S,contentSegments:q}}export{ur as useAiSearch};
1
+ import{useCallback as E,useEffect as Q,useMemo as J,useRef as m,useState as b}from"react";import{AiSearchError as d}from"@redocly/theme/core/constants";import{withPathPrefix as N,splitContentByToolCalls as V}from"@redocly/theme/core/utils";import{ServerRoutes as j}from"../../../constants/common";import{useSearchSession as B}from"@redocly/theme/core/contexts";import{AI_SEARCH_REQUEST_HEADERS as D,HTTP_ERROR_MAP as G}from"../../constants";import{useI18nConfig as K,usePageVersions as L}from"../hooks";import{telemetry as U}from"../telemetry/index.js";import{streamSSEMessages as z}from"./sse-parser";import{handleSSEMessage as W}from"./message-handlers";function or(n){const{searchSessionId:p}=B(),[r,s]=b({status:"idle"}),[_,g]=b([]),[S,y]=b([]),t=m(null),c=m(""),o=m(""),a=m([]),{currentLocale:C}=K(),{versions:w=[]}=L()||{},l=w.find(e=>e?.active),f=E(()=>{s({status:"idle",response:""}),y([]),c.current="",o.current="",a.current=[]},[]),M=E(()=>{t.current?.abort(),t.current=null,f(),g([])},[f]);Q(()=>()=>{t.current?.abort()},[]);const O=E(async(e,q)=>{if(!e)return;t.current?.abort();const h=new AbortController;t.current=h,f(),s({status:"loading",question:e,response:"",resources:[]});try{const u=await fetch(N(j.ASK_AI),{method:"POST",headers:D,body:JSON.stringify({text:e,history:q||[],locale:C,product:n?.product,filter:n?.filter,version:l&&{folder:l.folderId,label:l.label},searchSessionId:p}),signal:h.signal});if(!u.ok){s({status:"error",question:e,error:G[u.status]??d.HttpRequestFailed});return}const A=u.body;if(!A){s({status:"error",question:e,error:d.HttpRequestFailed});return}let I=!1;for await(const i of z(A,h.signal)){const F={messageId:c.current,resources:a.current,accumulatedResponse:o.current,setConversation:g,setState:s,setToolCalls:y},{messageId:v,resources:H,accumulatedResponse:P}=W(i,F);v&&(c.current=v),H&&(a.current=H),P&&(o.current=P),i.type==="error"&&(I=!0)}t.current=null,s(i=>i.status==="error"?i:o.current?{status:"success",question:e,response:o.current,resources:a.current}:{status:"error",question:e,error:d.EmptyResponse}),!I&&o.current&&e.trim()&&c.current&&U.sendSearchAIQueryMessage([{object:"search",question:e,answer:o.current,resources:JSON.stringify(a.current),searchSessionId:p,messageId:c.current,...n?.product&&{product:n.product}}])}catch(u){if(u instanceof Error&&u.name==="AbortError")return;t.current=null,s({status:"error",question:e,error:d.HttpRequestFailed})}},[f,n?.product,C,n?.filter,l,p]),R=r.status==="loading"||r.status==="success"||r.status==="idle"?r.response:void 0,k=J(()=>V(R,S),[R,S]);return{askQuestion:O,isGeneratingResponse:r.status==="loading",response:R,resources:r.status==="loading"||r.status==="success"?r.resources:[],question:r.status!=="idle"?r.question:"",error:r.status==="error"?r.error:null,clearConversation:M,conversation:_,setConversation:g,toolCalls:S,contentSegments:k}}export{or as useAiSearch};
@@ -1 +1 @@
1
- import e from"react";import{Helmet as s}from"@dr.pogodin/react-helmet";import{combineUrls as a}from"@redocly/theme/core/utils";import{isTruthy as c}from"../../../utils/guards/is-truthy";import{getMetaTagsAttributes as p}from"../utils/get-meta-tags-attributes";function T(r){const{seo:t,slug:l}=r;if(!t)return null;const n=p(t),i=[t.title,t.projectTitle].filter(c).join(" | ");return e.createElement(s,null,e.createElement("title",null,i),t.siteUrl?e.createElement("link",{rel:"canonical",href:a(t.siteUrl,l)}):null,t.jsonLd?e.createElement("script",{type:"application/ld+json"},JSON.stringify(t.jsonLd)):null,n.map((o,m)=>e.createElement("meta",{key:m,...o})))}export{T as SeoTags};
1
+ import e from"react";import{Helmet as c}from"@dr.pogodin/react-helmet";import{combineUrls as u}from"@redocly/theme/core/utils";import{isTruthy as f}from"../../../utils/guards/is-truthy";import{usePageVersions as p}from"../../providers/page-data/hooks";import{getMetaTagsAttributes as g}from"../utils/get-meta-tags-attributes";function b(r){const{seo:t,slug:i}=r,{versions:l}=p();if(!t)return null;const o=g(t),s=[t.title,t.projectTitle].filter(f).join(" | "),a=l.find(n=>n.default)?.link||i;return e.createElement(c,null,e.createElement("title",null,s),t.siteUrl?e.createElement("link",{rel:"canonical",href:u(t.siteUrl,a)}):null,t.jsonLd?e.createElement("script",{type:"application/ld+json"},JSON.stringify(t.jsonLd)):null,o.map((n,m)=>e.createElement("meta",{key:m,...n})))}export{b as SeoTags};
@@ -2,9 +2,7 @@ import l from"styled-components";import*as o from"react";import{RedoclyAsyncAPID
2
2
  a[id],
3
3
  a[data-section-id],
4
4
  div[data-section-id] {
5
- scroll-margin-top: calc(
6
- var(--navbar-height) + var(--banner-height) + var(--panel-gap-vertical)
7
- );
5
+ scroll-margin-top: calc(var(--navbar-height) + var(--banner-height) + var(--panel-gap-vertical));
8
6
  }
9
7
 
10
8
  --sidebar-width: 0px;
@@ -4,14 +4,10 @@ import*as a from"react";import i from"styled-components";import{RedoclyOpenAPIDo
4
4
  }
5
5
  `,g=i.div`
6
6
  div[id] {
7
- scroll-margin-top: calc(
8
- var(--navbar-height) + var(--banner-height) - var(--panel-gap-vertical)
9
- );
7
+ scroll-margin-top: calc(var(--navbar-height) + var(--banner-height) - var(--panel-gap-vertical));
10
8
  }
11
9
  a[id] {
12
- scroll-margin-top: calc(
13
- var(--navbar-height) + var(--banner-height) + var(--panel-gap-vertical)
14
- );
10
+ scroll-margin-top: calc(var(--navbar-height) + var(--banner-height) + var(--panel-gap-vertical));
15
11
  }
16
12
 
17
13
  --sidebar-width: 0px;
@@ -51,6 +51,7 @@ export type ToolCallState = {
51
51
  };
52
52
  export type AiSearchOptions = {
53
53
  filter?: SearchFilterItem[];
54
+ product?: string;
54
55
  };
55
56
  export type AiSearchState = {
56
57
  status: 'idle';