@redocly/framework 1.0.0-next.4 → 1.0.0-next.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/dist/bundler/build/output-metadata.js +1 -1
  2. package/dist/bundler/build/run.js +1 -1
  3. package/dist/bundler/build/theme-global-style-compiler.js +1 -0
  4. package/dist/bundler/build/theme-global-stylesheets.js +1 -0
  5. package/dist/bundler/build/vite-config.js +2 -2
  6. package/dist/bundler/dev/routes/dev-problems-route.js +1 -1
  7. package/dist/bundler/dev/routes/source-sync-route.js +1 -1
  8. package/dist/bundler/dev/run.js +1 -1
  9. package/dist/bundler/dev/runtime-app.js +1 -1
  10. package/dist/bundler/dev/vite-chunk-url.js +1 -1
  11. package/dist/bundler/node-bundle.js +1 -0
  12. package/dist/bundler/runtime-files.js +1 -1
  13. package/dist/bundler/user-markdoc-schema.js +1 -1
  14. package/dist/bundler/vite-config.base.js +12 -12
  15. package/dist/cli/commands/build.js +1 -1
  16. package/dist/cli/commands/dev.js +1 -1
  17. package/dist/cli/commands/ingest.js +1 -1
  18. package/dist/cli/commands/translate.js +2 -2
  19. package/dist/cli/dev-console/index.js +1 -1
  20. package/dist/cli/log-output/index.js +1 -1
  21. package/dist/cli/validate-react-pages.js +1 -1
  22. package/dist/client/ApiAccess.js +3 -0
  23. package/dist/client/NavigationProgress.js +1 -1
  24. package/dist/client/ProductsProvider.js +1 -1
  25. package/dist/client/RouteErrorBoundary.js +1 -1
  26. package/dist/client/RuntimeLink.js +1 -1
  27. package/dist/client/ThemeGlobalStyle.js +1 -0
  28. package/dist/client/UnversionedVersionButton.js +1 -1
  29. package/dist/client/ai-search/use-ai-search.js +1 -1
  30. package/dist/client/analytics-page-view.js +1 -1
  31. package/dist/client/app.js +3 -3
  32. package/dist/client/client-entry.js +1 -1
  33. package/dist/client/contexts.js +1 -1
  34. package/dist/client/dev-problems/ProblemsBar.js +6 -6
  35. package/dist/client/dev-problems/ProblemsModal.js +15 -15
  36. package/dist/client/feedback.js +1 -1
  37. package/dist/client/l10n/use-l10n-config.js +1 -1
  38. package/dist/client/l10n/use-l10n-href.js +1 -1
  39. package/dist/client/l10n/use-translate.js +1 -1
  40. package/dist/client/products.js +1 -1
  41. package/dist/client/review/ReviewBar.js +61 -61
  42. package/dist/client/review/use-review.js +1 -1
  43. package/dist/client/sidebar/PoweredByRedocly.js +2 -2
  44. package/dist/client/sidebar/SidebarDataProvider.js +1 -1
  45. package/dist/client/sidebar/drilldown.js +1 -1
  46. package/dist/client/ssr.js +1 -1
  47. package/dist/client/telemetry/config.js +1 -1
  48. package/dist/client/telemetry/report-preload-failure.js +1 -0
  49. package/dist/client/templates/dev-login.js +4 -4
  50. package/dist/client/templates/unauthorized.js +5 -5
  51. package/dist/client/theme-global-css.js +1 -0
  52. package/dist/client/use-banner.js +1 -1
  53. package/dist/client/use-entity-revisions.js +1 -1
  54. package/dist/client/use-page-versions.js +1 -1
  55. package/dist/client/use-search.js +1 -1
  56. package/dist/client/webmcp/tools/shared.js +1 -1
  57. package/dist/client/webmcp/tools/site-tools.js +1 -1
  58. package/dist/client/webmcp/use-webmcp-tools.js +1 -1
  59. package/dist/content-layer/allowed-packages.js +1 -1
  60. package/dist/content-layer/config-schema.d.ts +5 -1
  61. package/dist/content-layer/config-schema.js +1 -1
  62. package/dist/content-layer/config.d.ts +6 -2
  63. package/dist/content-layer/config.js +1 -1
  64. package/dist/content-layer/database/adapters/node-sqlite-client.js +1 -1
  65. package/dist/content-layer/database/connection.js +1 -1
  66. package/dist/content-layer/database/entity-store.d.ts +9 -1
  67. package/dist/content-layer/database/entity-store.js +1 -1
  68. package/dist/content-layer/database/invalidation.js +26 -26
  69. package/dist/content-layer/database/origins.d.ts +2 -4
  70. package/dist/content-layer/database/origins.js +1 -1
  71. package/dist/content-layer/ingest/extract-all-phase.js +1 -1
  72. package/dist/content-layer/ingest/finalize-phase.js +1 -1
  73. package/dist/content-layer/ingest/hook-inputs.js +1 -1
  74. package/dist/content-layer/ingest/l10n-warnings.js +1 -1
  75. package/dist/content-layer/ingest/normalize-artifacts.js +1 -1
  76. package/dist/content-layer/ingest/rbac-teams.js +1 -1
  77. package/dist/content-layer/ingest/run.js +1 -1
  78. package/dist/content-layer/ingest/scan.d.ts +1 -1
  79. package/dist/content-layer/ingest/scan.js +1 -1
  80. package/dist/content-layer/ingest/search-sync.js +1 -1
  81. package/dist/content-layer/ingest/slugger/resolve-final-slugs.js +1 -1
  82. package/dist/content-layer/ingest/sync.js +1 -1
  83. package/dist/content-layer/link-checker/load-view.js +1 -1
  84. package/dist/content-layer/link-checker/validate.js +1 -1
  85. package/dist/content-layer/loaders/context.js +1 -1
  86. package/dist/content-layer/markdown/client/OpenapiTagComponents.js +2 -2
  87. package/dist/content-layer/markdown/client/dynamic-components.js +1 -1
  88. package/dist/content-layer/markdown/client/markdoc-components.js +2 -2
  89. package/dist/content-layer/markdown/client/markdown-text.js +1 -1
  90. package/dist/content-layer/markdown/constants/builtin-tags.js +1 -1
  91. package/dist/content-layer/markdown/constants/markdown-text-tag-set.js +1 -1
  92. package/dist/content-layer/markdown/constants/tag-sets.js +1 -1
  93. package/dist/content-layer/markdown/nodes/fence.js +1 -1
  94. package/dist/content-layer/markdown/nodes/heading.js +1 -1
  95. package/dist/content-layer/markdown/nodes/table.js +1 -1
  96. package/dist/content-layer/markdown/resolve/ast.js +1 -1
  97. package/dist/content-layer/markdown/resolve/audience-tag.d.ts +1 -1
  98. package/dist/content-layer/markdown/resolve/audience-tag.js +1 -1
  99. package/dist/content-layer/markdown/resolve/markdoc-resolvers/json-schema.js +1 -1
  100. package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.d.ts +1 -1
  101. package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.js +1 -1
  102. package/dist/content-layer/markdown/resolve/markdoc-resolvers/partial.js +1 -1
  103. package/dist/content-layer/markdown/resolve/markdoc.js +1 -1
  104. package/dist/content-layer/markdown/resolve/references.js +1 -1
  105. package/dist/content-layer/markdown/search/to-markdown.js +2 -2
  106. package/dist/content-layer/markdown/search/to-sections.js +1 -1
  107. package/dist/content-layer/markdown/server/render.js +1 -1
  108. package/dist/content-layer/markdown/service.js +1 -1
  109. package/dist/content-layer/markdown/tags/html.d.ts +4 -1
  110. package/dist/content-layer/markdown/tags/html.js +1 -1
  111. package/dist/content-layer/markdown/tags/partial.d.ts +7 -2
  112. package/dist/content-layer/markdown/tags/partial.js +1 -1
  113. package/dist/content-layer/markdown/tags/variant.js +1 -1
  114. package/dist/content-layer/markdown/types/service.d.ts +4 -0
  115. package/dist/content-layer/markdown/utils/parse-cache.js +1 -1
  116. package/dist/content-layer/markdown/utils/reparse-example-fences.d.ts +4 -1
  117. package/dist/content-layer/markdown/utils/reparse-example-fences.js +1 -1
  118. package/dist/content-layer/markdown/utils/substitute-variables.js +1 -1
  119. package/dist/content-layer/markdown/utils/walk-markdoc-ast.d.ts +2 -2
  120. package/dist/content-layer/markdown/utils/walk-markdoc-ast.js +1 -1
  121. package/dist/content-layer/materialization/entity.js +1 -1
  122. package/dist/content-layer/materialization/materializer.js +1 -0
  123. package/dist/content-layer/materialization/static-files.js +1 -1
  124. package/dist/content-layer/plan-gates.d.ts +3 -2
  125. package/dist/content-layer/plan-gates.js +1 -1
  126. package/dist/content-layer/plugins/index.js +1 -1
  127. package/dist/content-layer/plugins/internal/api-docs/client/template.js +4 -4
  128. package/dist/content-layer/plugins/internal/api-docs/index.js +1 -1
  129. package/dist/content-layer/plugins/internal/api-docs/server/build-definition.d.ts +2 -2
  130. package/dist/content-layer/plugins/internal/api-docs/server/build-definition.js +1 -1
  131. package/dist/content-layer/plugins/internal/api-docs/server/build-sidebar.js +1 -1
  132. package/dist/content-layer/plugins/internal/api-docs/server/markdown-docs.js +13 -13
  133. package/dist/content-layer/plugins/internal/api-docs/server/options.d.ts +4 -2
  134. package/dist/content-layer/plugins/internal/api-docs/server/options.js +1 -1
  135. package/dist/content-layer/plugins/internal/api-docs/server/search-documents.js +1 -1
  136. package/dist/content-layer/plugins/internal/api-docs/server/spec-download.js +1 -1
  137. package/dist/content-layer/plugins/internal/api-functions/index.js +1 -1
  138. package/dist/content-layer/plugins/internal/api-functions/server/access.js +1 -1
  139. package/dist/content-layer/plugins/internal/api-functions/server/dispatch.js +1 -1
  140. package/dist/content-layer/plugins/internal/app-data/banner.js +1 -1
  141. package/dist/content-layer/plugins/internal/app-data/index.js +1 -1
  142. package/dist/content-layer/plugins/internal/app-data/products.d.ts +2 -0
  143. package/dist/content-layer/plugins/internal/app-data/products.js +1 -1
  144. package/dist/content-layer/plugins/internal/catalog-classic/client/use-catalog-classic.js +1 -1
  145. package/dist/content-layer/plugins/internal/catalog-classic/index.js +1 -1
  146. package/dist/content-layer/plugins/internal/index.js +1 -1
  147. package/dist/content-layer/plugins/internal/l10n/index.js +1 -1
  148. package/dist/content-layer/plugins/internal/markdoc/client/template.js +1 -1
  149. package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
  150. package/dist/content-layer/plugins/internal/markdoc/server/shared.d.ts +1 -1
  151. package/dist/content-layer/plugins/internal/mcp/constants.d.ts +6 -0
  152. package/dist/content-layer/plugins/internal/mcp/constants.js +1 -1
  153. package/dist/content-layer/plugins/internal/mcp/content-tools.js +1 -1
  154. package/dist/content-layer/plugins/internal/mcp/ignored-routes.js +1 -1
  155. package/dist/content-layer/plugins/internal/mcp/index.js +1 -1
  156. package/dist/content-layer/plugins/internal/mcp/server/agent-card.js +1 -1
  157. package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
  158. package/dist/content-layer/plugins/internal/mcp/server/auth.js +1 -1
  159. package/dist/content-layer/plugins/internal/mcp/server/codemode/capabilities.js +3 -3
  160. package/dist/content-layer/plugins/internal/mcp/server/codemode/constants.js +1 -1
  161. package/dist/content-layer/plugins/internal/mcp/server/codemode/discover.js +1 -1
  162. package/dist/content-layer/plugins/internal/mcp/server/codemode/execute-schema.js +1 -1
  163. package/dist/content-layer/plugins/internal/mcp/server/codemode/execution-budget.js +1 -0
  164. package/dist/content-layer/plugins/internal/mcp/server/codemode/index.js +1 -1
  165. package/dist/content-layer/plugins/internal/mcp/server/codemode/prompts.js +8 -8
  166. package/dist/content-layer/plugins/internal/mcp/server/codemode/read-result.js +1 -0
  167. package/dist/content-layer/plugins/internal/mcp/server/codemode/return-last-expression.js +6 -0
  168. package/dist/content-layer/plugins/internal/mcp/server/codemode/returns-from-top-level.js +1 -0
  169. package/dist/content-layer/plugins/internal/mcp/server/codemode/sandbox.js +1 -1
  170. package/dist/content-layer/plugins/internal/mcp/server/codemode/tool-declarations.js +4 -0
  171. package/dist/content-layer/plugins/internal/mcp/server/codemode/tool-list.js +1 -1
  172. package/dist/content-layer/plugins/internal/mcp/server/codemode/unknown-tool-hint.js +3 -0
  173. package/dist/content-layer/plugins/internal/mcp/server/config-gate.js +1 -1
  174. package/dist/content-layer/plugins/internal/mcp/server/custom-tools.js +1 -1
  175. package/dist/content-layer/plugins/internal/mcp/server/gateway/__tests__/secret-store-fixture.js +1 -0
  176. package/dist/content-layer/plugins/internal/mcp/server/gateway/api-call-operations.js +1 -1
  177. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js +1 -1
  178. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/site-branding.js +1 -1
  179. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
  180. package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +7 -7
  181. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-bridge.js +1 -1
  182. package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +3 -3
  183. package/dist/content-layer/plugins/internal/mcp/server/gateway/secret-store.js +1 -1
  184. package/dist/content-layer/plugins/internal/mcp/server/gateway/subject.js +1 -1
  185. package/dist/content-layer/plugins/internal/mcp/server/gateway/tools.js +4 -4
  186. package/dist/content-layer/plugins/internal/mcp/server/gateway/upstream-auth-scheme.js +2 -2
  187. package/dist/content-layer/plugins/internal/mcp/server/handler.js +1 -1
  188. package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
  189. package/dist/content-layer/plugins/internal/mcp/server/mcp-telemetry.js +1 -1
  190. package/dist/content-layer/plugins/internal/mcp/server/oauth/authorize.js +1 -1
  191. package/dist/content-layer/plugins/internal/mcp/server/oauth/discovery.js +1 -1
  192. package/dist/content-layer/plugins/internal/mcp/server/rate-limit.js +1 -1
  193. package/dist/content-layer/plugins/internal/mcp/server/server-card.js +1 -1
  194. package/dist/content-layer/plugins/internal/mcp/server/server-info.js +1 -1
  195. package/dist/content-layer/plugins/internal/mcp/server/skills-resources.js +1 -1
  196. package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-catalog.js +1 -1
  197. package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-constants.js +1 -0
  198. package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-document.js +1 -1
  199. package/dist/content-layer/plugins/internal/mcp/server/tools/graphql.js +1 -1
  200. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-catalog.js +1 -1
  201. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-document.js +1 -1
  202. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-refs.js +1 -1
  203. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi.js +1 -1
  204. package/dist/content-layer/plugins/internal/mcp/server/tools/pages-constants.js +1 -0
  205. package/dist/content-layer/plugins/internal/mcp/server/tools/pages-navigation.js +1 -1
  206. package/dist/content-layer/plugins/internal/mcp/server/tools/pages.js +3 -3
  207. package/dist/content-layer/plugins/internal/mcp/server/tools/schemas.js +1 -0
  208. package/dist/content-layer/plugins/internal/mcp/server/tools/search.js +1 -1
  209. package/dist/content-layer/plugins/internal/mcp/server/tools/submit-feedback.js +1 -1
  210. package/dist/content-layer/plugins/internal/mcp/server/tools/whoami.js +1 -1
  211. package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
  212. package/dist/content-layer/plugins/internal/react-page/index.js +1 -1
  213. package/dist/content-layer/plugins/internal/scorecard-classic/client/Grid.js +11 -11
  214. package/dist/content-layer/plugins/internal/scorecard-classic/client/ScorecardViews.js +1 -1
  215. package/dist/content-layer/plugins/internal/scorecard-classic/client/ScorecardWidgets.js +7 -7
  216. package/dist/content-layer/plugins/internal/scorecard-classic/client/template.js +2 -2
  217. package/dist/content-layer/plugins/internal/scorecard-classic/index.js +1 -1
  218. package/dist/content-layer/plugins/internal/sidebar/bundle.d.ts +1 -1
  219. package/dist/content-layer/plugins/internal/sidebar/bundle.js +1 -1
  220. package/dist/content-layer/plugins/internal/sidebar/index.d.ts +1 -1
  221. package/dist/content-layer/plugins/internal/sidebar/index.js +2 -2
  222. package/dist/content-layer/plugins/internal/skills/index.js +1 -1
  223. package/dist/content-layer/plugins/internal/skills/server/routes.js +1 -1
  224. package/dist/content-layer/plugins/project/load.js +2 -2
  225. package/dist/content-layer/plugins/registry.js +1 -1
  226. package/dist/content-layer/plugins/request-context.d.ts +5 -0
  227. package/dist/content-layer/plugins/types/api-entity.d.ts +2 -6
  228. package/dist/content-layer/plugins/types/api-entity.js +1 -1
  229. package/dist/content-layer/plugins/types/plugin.d.ts +8 -0
  230. package/dist/content-layer/plugins/types/search.d.ts +1 -1
  231. package/dist/content-layer/plugins/utils/link-access.js +1 -1
  232. package/dist/content-layer/plugins/utils/route-index.d.ts +1 -1
  233. package/dist/content-layer/plugins/utils/route-index.js +1 -1
  234. package/dist/content-layer/plugins/utils/version-path.js +1 -1
  235. package/dist/content-layer/revisions/config.js +1 -1
  236. package/dist/content-layer/server/context.js +1 -1
  237. package/dist/content-layer/server/materialize.js +1 -1
  238. package/dist/content-layer/static/audience.js +1 -1
  239. package/dist/content-layer/static/registry.js +1 -1
  240. package/dist/content-layer/templates/template-set.js +1 -1
  241. package/dist/content-layer/versions/redirect.d.ts +11 -6
  242. package/dist/content-layer/versions/redirect.js +1 -1
  243. package/dist/content-layer/versions/resolve.js +1 -1
  244. package/dist/plugin-api.d.ts +3 -0
  245. package/dist/plugin-api.js +1 -1
  246. package/dist/server/__tests__/rbac-fixture.js +1 -1
  247. package/dist/server/app.js +3 -3
  248. package/dist/server/ask-ai/feature-gate.js +1 -1
  249. package/dist/server/ask-ai/route.js +1 -1
  250. package/dist/server/auth/gate.js +1 -1
  251. package/dist/server/auth/middleware.js +1 -1
  252. package/dist/server/auth/request.js +1 -1
  253. package/dist/server/auth/routes.js +1 -1
  254. package/dist/server/auth/runtime.js +1 -1
  255. package/dist/server/content-assets/access.js +1 -1
  256. package/dist/server/content.js +12 -12
  257. package/dist/server/cors-proxy/handler.js +1 -1
  258. package/dist/server/feedback/route.js +1 -1
  259. package/dist/server/lambda-entry.js +1 -1
  260. package/dist/server/manifest-assets.js +4 -4
  261. package/dist/server/metrics/request-metrics.js +1 -1
  262. package/dist/server/node-entry.js +1 -1
  263. package/dist/server/plugin-context.js +1 -1
  264. package/dist/server/plugin-routes.js +1 -1
  265. package/dist/server/rbac/content-asset-access.js +1 -1
  266. package/dist/server/replay-oauth2/route.js +1 -1
  267. package/dist/server/review/route.js +1 -1
  268. package/dist/server/runtime-config.js +1 -1
  269. package/dist/server/search/route.js +1 -1
  270. package/dist/server/seo-tags.js +2 -2
  271. package/dist/server/static-files/serve.js +1 -1
  272. package/dist/server/subprocess/runner.js +1 -1
  273. package/dist/server/telemetry/route.js +1 -1
  274. package/dist/server/template-ids.js +1 -1
  275. package/dist/shared/constants/api-spec-kinds.d.ts +6 -0
  276. package/dist/shared/constants/api-spec-kinds.js +1 -0
  277. package/dist/shared/constants/l10n/langs/ar.js +1 -1
  278. package/dist/shared/constants/l10n/langs/de.js +1 -1
  279. package/dist/shared/constants/l10n/langs/en.js +1 -1
  280. package/dist/shared/constants/l10n/langs/es.js +1 -1
  281. package/dist/shared/constants/l10n/langs/fr.js +1 -1
  282. package/dist/shared/constants/l10n/langs/hi.js +1 -1
  283. package/dist/shared/constants/l10n/langs/it.js +1 -1
  284. package/dist/shared/constants/l10n/langs/ja.js +1 -1
  285. package/dist/shared/constants/l10n/langs/ko.js +1 -1
  286. package/dist/shared/constants/l10n/langs/pl.js +1 -1
  287. package/dist/shared/constants/l10n/langs/pt-br.js +1 -1
  288. package/dist/shared/constants/l10n/langs/pt.js +1 -1
  289. package/dist/shared/constants/l10n/langs/ru.js +1 -1
  290. package/dist/shared/constants/l10n/langs/uk.js +1 -1
  291. package/dist/shared/constants/l10n/langs/zh.js +1 -1
  292. package/dist/{server → shared}/constants/system-routes.d.ts +1 -1
  293. package/dist/shared/constants/system-routes.js +1 -0
  294. package/dist/shared/plan-gates.d.ts +6 -1
  295. package/dist/shared/plan-gates.js +1 -1
  296. package/dist/shared/products.js +1 -1
  297. package/dist/{server → shared}/project-env.d.ts +1 -1
  298. package/dist/{server → shared}/rbac/api-docs.d.ts +1 -1
  299. package/dist/{server → shared}/rbac/engine.d.ts +1 -1
  300. package/dist/shared/rbac/engine.js +0 -0
  301. package/dist/shared/rbac/filter.js +1 -0
  302. package/dist/{server → shared}/rbac/l10n-rules.d.ts +1 -1
  303. package/dist/shared/rbac/l10n-rules.js +1 -0
  304. package/dist/shared/rbac/route-scope.js +1 -0
  305. package/dist/{server → shared}/rbac/team-templates.d.ts +6 -2
  306. package/dist/shared/rbac/team-templates.js +1 -0
  307. package/dist/{server → shared}/rbac/teams.d.ts +1 -1
  308. package/dist/shared/rbac/types.js +1 -0
  309. package/dist/shared/types/config.d.ts +2 -0
  310. package/dist/shared/utils/l10n.js +1 -1
  311. package/dist/shared/utils/routes/file-path-to-route-slug.js +1 -1
  312. package/package.json +8 -10
  313. package/dist/content-layer/server/config.js +0 -1
  314. package/dist/server/constants/system-routes.js +0 -1
  315. package/dist/server/rbac/engine.js +0 -0
  316. package/dist/server/rbac/filter.js +0 -1
  317. package/dist/server/rbac/l10n-rules.js +0 -1
  318. package/dist/server/rbac/route-scope.js +0 -1
  319. package/dist/server/rbac/team-templates.js +0 -1
  320. package/dist/server/rbac/types.js +0 -1
  321. /package/dist/{server → shared}/project-env.js +0 -0
  322. /package/dist/{server → shared}/rbac/api-docs.js +0 -0
  323. /package/dist/{server → shared}/rbac/entity-scope.js +0 -0
  324. /package/dist/{server → shared}/rbac/filter.d.ts +0 -0
  325. /package/dist/{server → shared}/rbac/route-scope.d.ts +0 -0
  326. /package/dist/{server → shared}/rbac/teams.js +0 -0
  327. /package/dist/{server → shared}/rbac/types.d.ts +0 -0
  328. /package/dist/{content-layer/markdown → shared}/utils/packed-ast.d.ts +0 -0
  329. /package/dist/{content-layer/markdown → shared}/utils/packed-ast.js +0 -0
@@ -1 +1 @@
1
- import{L10N_DIR as e,TRANSLATIONS_FILE_NAMES as t,TRANSLATIONS_FILE_PATTERN as n}from"../../shared/constants/l10n/defaults.js";import{compareStrings as r}from"../../shared/utils/compare-strings.js";import{isObject as i}from"../../shared/utils/is-object.js";import{slugifySegment as a}from"../../shared/utils/routes/slugify-segment.js";import{collectL10nDirLocales as o,isLocaleCode as s,l10nDirOf as c,normalizeL10nConfig as l}from"../../shared/utils/l10n.js";import{createProblem as u}from"../problems/codes.js";function d(e){if(e==null)return[];if(!i(e))return[f("Invalid `l10n` config: expected an object")];let t=[],{defaultLocale:n,locales:r}=e,a=n!=null;if(a&&!s(n)&&t.push(f("Invalid `l10n.defaultLocale`: expected a non-empty string")),r==null)return t;if(!Array.isArray(r))return t.push(f("Invalid `l10n.locales`: expected an array")),t;for(let e of r)(!i(e)||!s(e.code))&&t.push(f("Invalid `l10n.locales` entry: expected an object with a string `code`"));return a?s(n)&&!l(e).locales?.some(e=>e.code===n)&&t.push(f(`Invalid \`l10n.locales\`: the default locale \`${n}\` must be listed`)):t.push(f("Invalid `l10n`: `locales` requires `defaultLocale`")),t}function f(e){return u({code:`configuration/l10n-invalid`,message:e})}function p(e){let{localeContext:t}=e,n=[...e.filePaths],r=o(n),i=t.locales,s=[];r.includes(t.defaultLocale)&&s.push({kind:`default-locale-dir`,dir:t.defaultLocale});let u=n.filter(e=>e.startsWith(`@l10n/`)&&c(e)===void 0);u.length>0&&s.push({kind:`stray-file`,paths:u.sort()});let d=/* @__PURE__ */ new Map;for(let e of i){let t=a(e);d.set(t,[...d.get(t)??[],e])}for(let e of d.values())e.length>1&&s.push({kind:`dir-slug-collision`,codes:e});s.push(...m(n,t));let f=l(e.l10n).locales;if(f===void 0)return s;let p=new Set(f.map(e=>e.code)),h=[...p].filter(e=>e!==t.defaultLocale&&!t.isLocale(e));h.length>0&&s.push({kind:`locale-without-dir`,locales:h});let g=i.filter(e=>!p.has(e));return g.length>0&&s.push({kind:`dir-not-in-config`,dirs:g}),s}function m(e,t){let n=/* @__PURE__ */ new Map;for(let i of[...e].sort(r)){let e=h(i,t);e!==void 0&&n.set(e,[...n.get(e)??[],i])}return[...n.entries()].filter(([,e])=>e.length>1).map(([e,t])=>({kind:`duplicate-translations`,locale:e,paths:t}))}function h(r,i){let a=r.toLowerCase();if(!n.test(a))return;if(t.some(e=>a===e))return i.defaultLocale;let o=RegExp(`^${e}/([^/]+)/(translations\\.ya?ml)$`,`i`).exec(r);if(o!==null)return i.isLocale(o[1])?o[1]:void 0}function g(e){return e.map(e=>u({code:`configuration/l10n-layout`,message:_(e),data:{...e}}))}function _(t){switch(t.kind){case`default-locale-dir`:return`Ignored \`${e}/${t.dir}/\`: the default locale lives at the project root`;case`stray-file`:return`Ignored files directly under \`${e}/\`, expected \`${e}/<locale>/<path>\`: ${t.paths.join(`, `)}`;case`dir-slug-collision`:return`Two \`${e}\` directories map to the same URL segment: ${t.codes.join(`, `)}`;case`locale-without-dir`:return`Missing \`${e}/<locale>/\` directory for configured locales: ${t.locales.join(`, `)}`;case`dir-not-in-config`:return`\`${e}/\` directories not listed in \`l10n.locales\` are hidden from the language picker: ${t.dirs.join(`, `)}`;case`duplicate-translations`:return`Loaded only the first translations file for \`${t.locale}\`: ${t.paths.join(`, `)}`}}export{p as collectL10nWarnings,g as l10nLayoutProblems,h as translationsFileLocale,d as validateL10nConfig};
1
+ import{compareStrings as e}from"../../shared/utils/compare-strings.js";import{L10N_DIR as t,TRANSLATIONS_FILE_NAMES as n,TRANSLATIONS_FILE_PATTERN as r}from"../../shared/constants/l10n/defaults.js";import{isObject as i}from"../../shared/utils/is-object.js";import{slugifySegment as a}from"../../shared/utils/routes/slugify-segment.js";import{collectL10nDirLocales as o,isLocaleCode as s,l10nDirOf as c,normalizeL10nConfig as l}from"../../shared/utils/l10n.js";import{createProblem as u}from"../problems/codes.js";function d(e){if(e==null)return[];if(!i(e))return[f("Invalid `l10n` config: expected an object")];let t=[],{defaultLocale:n,locales:r}=e,a=n!=null;if(a&&!s(n)&&t.push(f("Invalid `l10n.defaultLocale`: expected a non-empty string")),r==null)return t;if(!Array.isArray(r))return t.push(f("Invalid `l10n.locales`: expected an array")),t;for(let e of r)(!i(e)||!s(e.code))&&t.push(f("Invalid `l10n.locales` entry: expected an object with a string `code`"));return a?s(n)&&!l(e).locales?.some(e=>e.code===n)&&t.push(f(`Invalid \`l10n.locales\`: the default locale \`${n}\` must be listed`)):t.push(f("Invalid `l10n`: `locales` requires `defaultLocale`")),t}function f(e){return u({code:`configuration/l10n-invalid`,message:e})}function p(e){let{localeContext:t}=e,n=[...e.filePaths],r=o(n),i=t.locales,s=[];r.includes(t.defaultLocale)&&s.push({kind:`default-locale-dir`,dir:t.defaultLocale});let u=n.filter(e=>e.startsWith(`@l10n/`)&&c(e)===void 0);u.length>0&&s.push({kind:`stray-file`,paths:u.sort()});let d=/* @__PURE__ */ new Map;for(let e of i){let t=a(e);d.set(t,[...d.get(t)??[],e])}for(let e of d.values())e.length>1&&s.push({kind:`dir-slug-collision`,codes:e});s.push(...m(n,t));let f=l(e.l10n).locales;if(f===void 0)return s;let p=new Set(f.map(e=>e.code)),h=[...p].filter(e=>e!==t.defaultLocale&&!t.isLocale(e));h.length>0&&s.push({kind:`locale-without-dir`,locales:h});let g=i.filter(e=>!p.has(e));return g.length>0&&s.push({kind:`dir-not-in-config`,dirs:g}),s}function m(t,n){let r=/* @__PURE__ */ new Map;for(let i of[...t].sort(e)){let e=h(i,n);e!==void 0&&r.set(e,[...r.get(e)??[],i])}return[...r.entries()].filter(([,e])=>e.length>1).map(([e,t])=>({kind:`duplicate-translations`,locale:e,paths:t}))}function h(e,i){let a=e.toLowerCase();if(!r.test(a))return;if(n.some(e=>a===e))return i.defaultLocale;let o=RegExp(`^${t}/([^/]+)/(translations\\.ya?ml)$`,`i`).exec(e);if(o!==null)return i.isLocale(o[1])?o[1]:void 0}function g(e){return e.map(e=>u({code:`configuration/l10n-layout`,message:_(e),data:{...e}}))}function _(e){switch(e.kind){case`default-locale-dir`:return`Ignored \`${t}/${e.dir}/\`: the default locale lives at the project root`;case`stray-file`:return`Ignored files directly under \`${t}/\`, expected \`${t}/<locale>/<path>\`: ${e.paths.join(`, `)}`;case`dir-slug-collision`:return`Two \`${t}\` directories map to the same URL segment: ${e.codes.join(`, `)}`;case`locale-without-dir`:return`Missing \`${t}/<locale>/\` directory for configured locales: ${e.locales.join(`, `)}`;case`dir-not-in-config`:return`\`${t}/\` directories not listed in \`l10n.locales\` are hidden from the language picker: ${e.dirs.join(`, `)}`;case`duplicate-translations`:return`Loaded only the first translations file for \`${e.locale}\`: ${e.paths.join(`, `)}`}}export{p as collectL10nWarnings,g as l10nLayoutProblems,h as translationsFileLocale,d as validateL10nConfig};
@@ -1 +1 @@
1
- import{hashJsonValue as e,toJsonObject as t,toJsonValue as n}from"../database/utils/json.js";import{isEntityLoaderReference as r,isInlineEntityReference as i,isRawEntityReference as a}from"../loaders/define.js";import{createStoredEntityReference as o,isServerFnReference as s}from"../plugins/server-fn.js";import{compareStrings as c}from"../../shared/utils/compare-strings.js";import{isObject as l}from"../../shared/utils/is-object.js";import{isCoreRouteDepKey as u}from"../../shared/constants/route-deps.js";import{LIST_REVISIONS_SERVER_FN_ID as d,REVISIONS_ROUTE_DEP_KEY as f}from"../../shared/constants/revisions.js";import{matchContentPathMap as p}from"../plugins/utils/glob.js";import{parseContentVersion as m}from"../plugins/utils/version-path.js";import{deriveLocalizedRequestedSlug as h,deriveRequestedSlug as g}from"./slugger/derive-requested-slug.js";function _(e){let n=v(e);if(n===`skip`)return{routeDependencies:[],routes:[],entities:[]};let r=e.filePath===null?null:m(e.filePath),i=b(e.context,e.pluginId,r?.version??null),a=/* @__PURE__ */ new Map,o=[],s=[];for(let t of e.standaloneEntities){let e=i(t);a.set(e.key,e)}let _=/* @__PURE__ */ new Set,x=e.filePath===null?void 0:p(e.filePath,e.context.config.metadataGlobs);for(let c of e.routeDrafts){let{requestedSlug:p,slugType:m,canonicalSlug:v}=n?h({route:c,locale:n.locale,canonicalPath:n.canonicalPath,localeContext:n.localeContext,resolveCanonicalRoute:e.resolveCanonicalRoute}):{...g(c,e.filePath??``),canonicalSlug:``},b=`${c.routeId}\u0000${p}`;if(_.has(b))continue;_.add(b);let{rbac:S,excludeFromSearch:C,...w}=l(c.metadata?.metadata)?c.metadata.metadata:{},T=t({...x,...c.metadata,...w}),E=null;if(c.sidebarSubtree){let e=i(c.sidebarSubtree);a.set(e.key,e),E=e.key}for(let[t,n]of Object.entries(c.deps??{})){let r=y({dependency:n,describeEntity:i,key:t,registerEntity:e=>{a.set(e.key,e)},routeSlug:p,sourcePath:e.filePath??void 0});o.push({...r,routeId:c.routeId})}if(e.filePath!==null&&e.revisions?.isTracked(e.filePath)||r){let e=[...new Set(o.filter(e=>e.routeSlug===p&&e.dependencyType===`entity`&&!u(e.key)).map(e=>e.target))];o.push({args:{entityKeys:e,routeSlug:p},dependencyType:`serverFn`,key:f,routeId:c.routeId,routeSlug:p,target:d}),T.revisionsEnabled=!0}s.push({metadata:T,pluginId:e.pluginId,routeId:c.routeId,sidebarSubtreeEntityKey:E,wildcardPrefix:c.wildcardPrefix===!0,slug:p,requestedSlug:p,slugType:m,template:c.template?.trim()||``,versionGroup:r?.versionGroup??null,version:r?.version??null,locale:n?n.locale:``,isFallback:!1,canonicalSlug:v})}return{routeDependencies:o,routes:s,entities:[...a.values()].sort((e,t)=>c(e.key,t.key))}}function v(e){let{filePath:t,localeContext:n}=e;if(t===null||n===void 0||!n.isL10nPath(t))return null;if(!n.enabled)return`skip`;let{locale:r,canonicalPath:i}=n.splitLocaleFromPath(t);return i===``||!n.isLocale(r)?`skip`:{locale:r,canonicalPath:i,localeContext:n}}function y(e){let{dependency:t,key:n,routeSlug:r}=e;if(s(t))return{args:S(t.args,t=>{let n=e.describeEntity(t);return e.registerEntity(n),n.key}),dependencyType:`serverFn`,key:n,routeSlug:r,target:t.id};if(!a(t)){let t=e.sourcePath?` on "${e.sourcePath}"`:``;throw Error(`Unsupported route dependency "${n}"${t}.`)}let i=e.describeEntity(t);return e.registerEntity(i),{args:null,dependencyType:`entity`,key:n,routeSlug:r,target:i.key}}function b(e,t,n=null){let r=/* @__PURE__ */ new Map;return i=>{let a=r.get(i);return a===void 0&&(a=x(e,t,i,n),r.set(i,a)),a}}function x(t,n,a,s=null){if(i(a)){let t=a.key?.trim()||null;return{loaderArgs:null,kind:`inline`,type:a.type??null,metadata:a.metadata??null,loaderId:null,pluginId:n,shouldInvalidateValue:!1,key:t??`inline:${e(a.value)}`,value:a.value,isSystem:!1,version:s,searchable:a.searchable}}if(!r(a))throw Error(`Unsupported entity reference.`);let c=a.key?.trim()||null,l=S(a.args,e=>o(x(t,n,e,s).key)),u=t.pluginRegistry.getEntityLoaderById(a.id);if(!u)throw Error(`Entity loader "${a.id}" is not registered.`);return{loaderArgs:l,kind:`loader`,type:a.type??null,metadata:a.metadata??null,loaderId:a.id,pluginId:u.pluginId,shouldInvalidateValue:!0,key:c??`${a.id}:${e(l)}`,value:null,isSystem:!1,version:s}}function S(e,t){if(a(e))return t(e);if(Array.isArray(e))return e.map(e=>S(e,t));if(e&&typeof e==`object`){let r=Object.entries(e).map(([e,n])=>[e,S(n,t)]);return n(Object.fromEntries(r))}return n(e)}export{b as createEntityDescriber,x as createEntityDescriptor,_ as normalizePluginArtifacts,y as normalizeRouteDependency};
1
+ import{hashJsonValue as e,toJsonObject as t,toJsonValue as n}from"../database/utils/json.js";import{isEntityLoaderReference as r,isInlineEntityReference as i,isRawEntityReference as a}from"../loaders/define.js";import{createStoredEntityReference as o,isServerFnReference as s}from"../plugins/server-fn.js";import{compareStrings as c}from"../../shared/utils/compare-strings.js";import{isObject as l}from"../../shared/utils/is-object.js";import{matchContentPathMap as u}from"../plugins/utils/glob.js";import{parseContentVersion as d}from"../plugins/utils/version-path.js";import{isCoreRouteDepKey as f}from"../../shared/constants/route-deps.js";import{LIST_REVISIONS_SERVER_FN_ID as p,REVISIONS_ROUTE_DEP_KEY as m}from"../../shared/constants/revisions.js";import{deriveLocalizedRequestedSlug as h,deriveRequestedSlug as g}from"./slugger/derive-requested-slug.js";function _(e){let n=v(e);if(n===`skip`)return{routeDependencies:[],routes:[],entities:[]};let r=e.filePath===null?null:d(e.filePath),i=b(e.context,e.pluginId,r?.version??null),a=/* @__PURE__ */ new Map,o=[],s=[];for(let t of e.standaloneEntities){let e=i(t);a.set(e.key,e)}let _=/* @__PURE__ */ new Set,x=e.filePath===null?void 0:u(e.filePath,e.context.config.metadataGlobs);for(let c of e.routeDrafts){let{requestedSlug:u,slugType:d,canonicalSlug:v}=n?h({route:c,locale:n.locale,canonicalPath:n.canonicalPath,localeContext:n.localeContext,resolveCanonicalRoute:e.resolveCanonicalRoute}):{...g(c,e.filePath??``),canonicalSlug:``},b=`${c.routeId}\u0000${u}`;if(_.has(b))continue;_.add(b);let{rbac:S,excludeFromSearch:C,...w}=l(c.metadata?.metadata)?c.metadata.metadata:{},T=t({...x,...c.metadata,...w}),E=null;if(c.sidebarSubtree){let e=i(c.sidebarSubtree);a.set(e.key,e),E=e.key}for(let[t,n]of Object.entries(c.deps??{})){let r=y({dependency:n,describeEntity:i,key:t,registerEntity:e=>{a.set(e.key,e)},routeSlug:u,sourcePath:e.filePath??void 0});o.push({...r,routeId:c.routeId})}if(e.filePath!==null&&e.revisions?.isTracked(e.filePath)||r){let e=[...new Set(o.filter(e=>e.routeSlug===u&&e.dependencyType===`entity`&&!f(e.key)).map(e=>e.target))];o.push({args:{entityKeys:e,routeSlug:u},dependencyType:`serverFn`,key:m,routeId:c.routeId,routeSlug:u,target:p}),T.revisionsEnabled=!0}s.push({metadata:T,pluginId:e.pluginId,routeId:c.routeId,sidebarSubtreeEntityKey:E,wildcardPrefix:c.wildcardPrefix===!0,slug:u,requestedSlug:u,slugType:d,template:c.template?.trim()||``,versionGroup:r?.versionGroup??null,version:r?.version??null,locale:n?n.locale:``,isFallback:!1,canonicalSlug:v})}return{routeDependencies:o,routes:s,entities:[...a.values()].sort((e,t)=>c(e.key,t.key))}}function v(e){let{filePath:t,localeContext:n}=e;if(t===null||n===void 0||!n.isL10nPath(t))return null;if(!n.enabled)return`skip`;let{locale:r,canonicalPath:i}=n.splitLocaleFromPath(t);return i===``||!n.isLocale(r)?`skip`:{locale:r,canonicalPath:i,localeContext:n}}function y(e){let{dependency:t,key:n,routeSlug:r}=e;if(s(t))return{args:S(t.args,t=>{let n=e.describeEntity(t);return e.registerEntity(n),n.key}),dependencyType:`serverFn`,key:n,routeSlug:r,target:t.id};if(!a(t)){let t=e.sourcePath?` on "${e.sourcePath}"`:``;throw Error(`Unsupported route dependency "${n}"${t}.`)}let i=e.describeEntity(t);return e.registerEntity(i),{args:null,dependencyType:`entity`,key:n,routeSlug:r,target:i.key}}function b(e,t,n=null){let r=/* @__PURE__ */ new Map;return i=>{let a=r.get(i);return a===void 0&&(a=x(e,t,i,n),r.set(i,a)),a}}function x(t,n,a,s=null){if(i(a)){let t=a.key?.trim()||null;return{loaderArgs:null,kind:`inline`,type:a.type??null,metadata:a.metadata??null,loaderId:null,pluginId:n,shouldInvalidateValue:!1,key:t??`inline:${e(a.value)}`,value:a.value,isSystem:!1,version:s,searchable:a.searchable}}if(!r(a))throw Error(`Unsupported entity reference.`);let c=a.key?.trim()||null,l=S(a.args,e=>o(x(t,n,e,s).key)),u=t.pluginRegistry.getEntityLoaderById(a.id);if(!u)throw Error(`Entity loader "${a.id}" is not registered.`);return{loaderArgs:l,kind:`loader`,type:a.type??null,metadata:a.metadata??null,loaderId:a.id,pluginId:u.pluginId,shouldInvalidateValue:!0,key:c??`${a.id}:${e(l)}`,value:null,isSystem:!1,version:s}}function S(e,t){if(a(e))return t(e);if(Array.isArray(e))return e.map(e=>S(e,t));if(e&&typeof e==`object`){let r=Object.entries(e).map(([e,n])=>[e,S(n,t)]);return n(Object.fromEntries(r))}return n(e)}export{b as createEntityDescriber,x as createEntityDescriptor,_ as normalizePluginArtifacts,y as normalizeRouteDependency};
@@ -1 +1 @@
1
- import{RBAC_TEAM_ANONYMOUS as e,RBAC_TEAM_AUTHENTICATED as t}from"../../server/rbac/types.js";function n(n){if(n===null)return[e,t];if(n===void 0)return[];let r=n[`*`],i=r===void 0?{...n}:{[e]:r,[t]:r,...n},a=/* @__PURE__ */ new Set;for(let[e,t]of Object.entries(i))e!==`*`&&t!==`none`&&a.add(e.toLowerCase());return[...a].sort()}function r(e,t){let r=n(e);if(t===void 0)return r;let i=n(t),a=(e,t)=>e.includes(t)||e.includes(`authenticated`),o=/* @__PURE__ */ new Set;for(let e of[...r,...i])e===`anonymous`||e===`authenticated`?r.includes(e)&&i.includes(e)&&o.add(e):a(r,e)&&a(i,e)&&o.add(e);return[...o].sort()}export{n as toRbacTeams,r as toRbacTeamsWithinRoute};
1
+ import{RBAC_TEAM_ANONYMOUS as e,RBAC_TEAM_AUTHENTICATED as t}from"../../shared/rbac/types.js";function n(n){if(n===null)return[e,t];if(n===void 0)return[];let r=n[`*`],i=r===void 0?{...n}:{[e]:r,[t]:r,...n},a=/* @__PURE__ */ new Set;for(let[e,t]of Object.entries(i))e!==`*`&&t!==`none`&&a.add(e.toLowerCase());return[...a].sort()}function r(e,t){let r=n(e);if(t===void 0)return r;let i=n(t),a=(e,t)=>e.includes(t)||e.includes(`authenticated`),o=/* @__PURE__ */ new Set;for(let e of[...r,...i])e===`anonymous`||e===`authenticated`?r.includes(e)&&i.includes(e)&&o.add(e):a(r,e)&&a(i,e)&&o.add(e);return[...o].sort()}export{n as toRbacTeams,r as toRbacTeamsWithinRoute};
@@ -1 +1 @@
1
- import"../../shared/constants/app-data.js";import{L10N_DIR as e}from"../../shared/constants/l10n/defaults.js";import{collectL10nDirLocales as t,l10nDirOf as n,resolveLocaleContext as r}from"../../shared/utils/l10n.js";import{formatCount as i}from"../../shared/log-format.js";import{createLogger as a,stopwatch as o}from"../../shared/logger.js";import{loadEffectiveConfigHash as s,writeSiteConfig as c}from"../database/site-config.js";import{isConfigChanged as l,isNestedConfigPath as u,loadContentLayerConfig as ee,readNestedConfigProblems as te}from"../config.js";import{contentIgnoreMatcherOf as ne,normalizeHintPaths as re,scanContentFiles as d}from"./scan.js";import{resolveContentPluginsForFile as f}from"../plugins/registry.js";import{resolveContentLayerContext as ie}from"../context.js";import{openContentLayerDatabase as p}from"../database/connection.js";import{garbageCollectOrphanBlobs as ae}from"../database/blobs.js";import{isPlanFeatureGranted as m}from"../../shared/plan-gates.js";import{listConfiguredProducts as oe,productFolderProblems as se}from"../products.js";import{appDataSystemEntityDescriptor as ce}from"../plugins/internal/app-data/index.js";import{warnWhenProjectPluginsAreNotLoaded as le}from"../plugins/project/loaded-set.js";import{apiOutputFiles as ue,readApiOutputs as de,withApiOutputHints as fe}from"../api-outputs.js";import{createContentPlugins as h}from"../plugins/create-content-plugins.js";import"../plugins/index.js";import{assembleTemplateSet as pe}from"../templates/template-set.js";import{assembleServerModuleSet as me}from"../server-modules/module-set.js";import{listRegisteredAssets as he}from"../database/assets.js";import{createProblem as g}from"../problems/codes.js";import{computeDirtyConfigOrigins as ge,computeDirtyFileOrigins as _e,garbageCollectOrphanedEntities as ve,loadOriginDependencyRows as ye,propagateConfigDependencyInvalidation as be,propagateEntityInvalidation as xe,propagateRetryableProblemInvalidation as Se}from"../database/invalidation.js";import{hasGlobalProblemsForSource as _,listGlobalProblems as Ce,listProblems as we,problemRow as v,replaceGlobalProblemsForKeysTx as Te,replaceGlobalProblemsForSourceTx as y}from"../database/problems.js";import{persistContentFileState as Ee,refreshFileLastModified as De}from"../database/files.js";import{loadContentLayerState as b,partitionIgnoredFiles as Oe}from"../context-state.js";import{hashContentFiles as x}from"./hash.js";import{selectCurrentContentFiles as S}from"./current-files.js";import{collectL10nWarnings as ke,l10nLayoutProblems as Ae,validateL10nConfig as je}from"./l10n-warnings.js";import{garbageCollectOrphanAssetFiles as Me,restoreMissingAssetFiles as Ne}from"../materialization/asset-reconcile.js";import{loadPluginHookState as Pe}from"../database/plugin-hook-state.js";import{loadRouteQueryDependencyRows as Fe}from"../database/route-query-deps.js";import{collectAppDataFragmentOwnerIds as Ie,reconcilePluginScopedRows as Le,registerSystemEntities as Re}from"../database/finalize.js";import{hasStaleManifestVersion as ze,resetContentDatabase as Be}from"../database/reset.js";import{readGitLastModified as Ve}from"./git-last-modified.js";import{createContentScanPlan as He}from"./scan-plan.js";import{collectPageRedirects as C}from"../page-redirects.js";import{runSearchSync as Ue}from"./search-sync.js";import{syncContentFiles as We}from"./sync.js";import{checkAllowedPackages as Ge}from"../allowed-packages.js";import{syncConfigLinkRefs as Ke}from"../link-checker/config-links.js";import{collectCollisionPeerOrigins as qe}from"./slugger/collision-peers.js";async function w(e){let n=ie({contentDir:e.contentDir,context:e.context,currentFileIndex:e.currentFileIndex,logger:e.logger??a(),plugins:h(e.contentDir)}),d=n.contentDir,f=n.logger.child(`content-layer`),m=f.child(`content-layer:scan`),x=f.child(`content-layer:hash`),S=f.child(`content-layer:db`),C=f.child(`content-layer:plan`),w=f.child(`content-layer:diff`),T=f.child(`content-layer:sync`),E=o();f.debug(`Starting content ingest`,{contentDir:d,hints:e.hints??[]});let D=e.database===void 0,O=e.database??await p({contentDir:d,databaseUrl:e.databaseUrl,migrationsDir:e.migrationsDir,runMigrations:e.runMigrations,platform:n.platform,logger:S});try{if(await ze(O)){S.warn(`manifest version changed — resetting content database`);let e=o();await Be(O,{logger:S}),S.info(`Reset content database`,{durationMs:e()}),n.state=void 0}let a=re(d,e.hints??[]),ie=o(),p=o(),h=await b({context:n,database:O}),D=[...h.filesByPath.values(),...h.ignoredFilesByPath.values()].sort((e,t)=>e.path.localeCompare(t.path));S.debug(`Loaded previous content state`,{loadedCount:D.length,totalCount:D.length,durationMs:p()});let j=await ee({context:n,force:!0});await le({contentDir:d,config:j.config,fs:n.platform.fs,logger:f});let M=l(A(j.config,h.routeBySlug.values()),await s(O)),N=je(n.config.l10n);for(let e of N)f.debug(e.message);(M||N.length>0||await _(O,`l10n-config`))&&await O.db.transaction(e=>y(e,`l10n-config`,N.map(e=>v(e,{scope:`global`,source:`l10n-config`})))),(M||j.problems.length>0||await _(O,`config`))&&await O.db.transaction(e=>y(e,`config`,j.problems.map(e=>v(g(e),{scope:`global`,source:`config`}))));let Xe=await Ge(j.config,d,n.platform.fs);(Xe.length>0||await _(O,`allowed-packages`))&&await O.db.transaction(e=>y(e,`allowed-packages`,Xe.map(e=>v(g(e),{scope:`global`,source:`allowed-packages`}))));let P=ne(n.config);Oe(h,P);let F=e=>de({config:n.config,contentDir:d,fs:n.platform.fs,nestedConfigPaths:e,isIgnored:P}),I=M||a.some(u),L=await F([...h.filesByPath.keys()].filter(u)),Ze=o(),R=await He({contentDir:d,fs:n.platform.fs,previousFiles:D,hints:fe(a,L),ignoredDirectories:e.ignoredDirectories,configChanged:I,logger:C});C.debug(`Resolved ingest scan plan`,{hints:R.hintedPaths.length,configChanged:I,scanTargets:R.scanTargets.length,affectedPreviousFiles:R.affectedPreviousFiles.length,durationMs:Ze()});let z=new Map(D.map(e=>[e.path,e.hash])),B=await Ye({contentDir:d,currentFileIndex:n.currentFileIndex,fs:n.platform.fs,scanPlan:R,ignoredDirectories:e.ignoredDirectories,scanLogger:m,hashLogger:x,previous:n.currentFileIndex?void 0:z,onProgress:e.onProgress});(R.hintedPaths.length===0||R.hintedPaths.includes(``))&&(L=await F(B.map(e=>e.path).filter(e=>u(e)&&!P(e))));let Qe=await ue({outputs:L,files:B,contentDir:d,fs:n.platform.fs,previous:z}),V=[...B.filter(e=>!L.has(e.path)),...Qe],H=new Map(await Ve(d,m));for(let[e,t]of L){let n=H.get(t);n!==void 0&&H.set(e,n)}f.info(`Scanned ${i(V.length)} files`,{durationMs:ie()});let $e=o(),U=k(V,R.affectedPreviousFiles,{hintScopes:R.hintScopes,totalPrevious:D.length});w.debug(`Computed content diff`,{...U.summary,durationMs:$e()}),f.info(`Compared with the previous state: ${U.summary.added} added, ${U.summary.changed} changed, ${U.summary.removed} removed, ${U.summary.unchanged} unchanged`);let et=o(),tt=o(),nt=await Ee(O,{upserts:[...U.added.map(e=>({path:e.path,hash:e.hash,lastModifiedAt:H.get(e.path)??null,manifest:JSON.stringify(e.manifest??{}),manifestVersion:e.manifestVersion})),...U.changed.map(e=>({path:e.path,hash:e.nextHash,lastModifiedAt:H.get(e.path)??null,manifest:JSON.stringify(e.file.manifest??{}),manifestVersion:e.file.manifestVersion}))],removedPaths:U.removed.map(e=>e.path),logger:S});S.debug(`Persisted content file state`,{upserts:U.added.length+U.changed.length,removed:U.removed.length,durationMs:tt()});for(let e of U.removed)h.filesByPath.delete(e.path),h.ignoredFilesByPath.delete(e.path);for(let e of nt)(P(e.path)?h.ignoredFilesByPath:h.filesByPath).set(e.path,e);let W=r(n.config.l10n,t(h.filesByPath.keys())),G=n.currentFileIndex!==void 0||I||R.hintedPaths.length===0||R.hintedPaths.includes(``);if(G){let e=Ae(ke({l10n:n.config.l10n,localeContext:W,filePaths:h.filesByPath.keys()})),t=se(oe(n.config),h.filesByPath.keys());for(let t of e)f.debug(t.message);for(let e of t)f.debug(e.message);await O.db.transaction(async n=>{await y(n,`l10n-layout`,e.map(e=>v(e,{scope:`global`,source:`l10n-layout`}))),await y(n,`products`,t.map(e=>v(g(e),{scope:`global`,source:`products`})))})}let K=G?[...h.filesByPath.keys()].filter(u):[...U.added,...U.changed].map(e=>e.path).filter(e=>u(e)&&!P(e)),q=U.removed.map(e=>e.path).filter(u);if(G||K.length>0||q.length>0){let e=(await te({contentDir:d,fs:n.platform.fs,paths:K})).map(e=>v(g(e),{scope:`global`,source:`nested-config`,key:e.location?.filePath}));await O.db.transaction(t=>G?y(t,`nested-config`,e):Te(t,`nested-config`,[...K,...q],e))}let J=V.flatMap(e=>{let t=h.filesByPath.get(e.path),n=H.get(e.path)??null;return!t||t.lastModifiedAt===n?[]:(h.filesByPath.set(e.path,{...t,lastModifiedAt:n}),[{path:e.path,lastModifiedAt:n}])});await De(O,J,S),await xe(O,{changedFilePaths:[...U.added.map(e=>e.path),...U.changed.map(e=>e.path),...U.removed.map(e=>e.path),...J.map(e=>e.path)],membershipChangedPaths:[...U.added,...U.removed].map(e=>e.path).filter(e=>!P(e)),logger:S});let rt=n.pluginRegistry.listExtractAllPlugins(),it=n.pluginRegistry.listFinalizePlugins(),at=new Set(it.map(e=>e.id)),Y=[...Ie(h.entitiesByKey.get(`app-data`)?.loaderArgs??null)].filter(e=>!at.has(e)),ot=await Le(O,[...rt.map(e=>({pluginId:e.id,hook:`extractAll`})),...it.map(e=>({pluginId:e.id,hook:`finalize`}))],{logger:S});Y.length>0&&await Re(O,[ce({fragmentUpdates:new Map(Y.map(e=>[e,null]))})],{logger:S});let[X,st,ct]=await Promise.all([ye(O),Fe(O),Pe(O)]),lt=ge(X,n.config),ut=_e(X,h);await be(O,{config:n.config,logger:S}),await Se(O,{logger:S}),await ve(O,S),(ot||Y.length>0)&&(n.state=void 0,h=await b({context:n,database:O}));let dt=await Ce(O,`slugger`),ft=qe(dt,{touchedPaths:[...U.added.map(e=>e.path),...U.changed.map(e=>e.path),...U.removed.map(e=>e.path),...lt.map(e=>e.originFilePath),...ut.map(e=>e.originFilePath)],storedFilesByPath:h.filesByPath}),Z=Je({context:n,diff:U,currentFiles:V,dirtyOrigins:[...lt,...ut,...ft],hintedPaths:R.hintedPaths,storedFilesByPath:h.filesByPath,storedPluginsByPath:h.filePluginsByPath}),pt=o(),Q=await We({context:n,database:O,localeContext:W,files:Z,removedPaths:new Set(U.removed.map(e=>e.path)),pluginScopedOriginRows:X,routeQueryRows:st,hookState:ct,storedSluggerProblems:dt,captureRevisions:e.captureRevisions,onFileSynced:(t,n)=>e.onProgress?.({stage:`sync`,done:t,total:n})});T.debug(`Synchronized content routes`,{files:Z.length,durationMs:pt()}),await Ke({database:O,config:n.config,configChanged:M,logger:S}),f.info(`Updated content state: ${U.added.length+U.changed.length} upserted, ${U.removed.length} removed, ${Z.length} synced`,{durationMs:et()}),e.searchSync!==!1&&await Ue({context:n,database:O,inlineSearchables:Q.inlineSearchables});let mt=await ae(O,{logger:S});mt.removed>0&&S.debug(`blob GC removed orphan blobs`,{count:mt.removed});let $=await Me(n.pluginIO,{contentDir:d,database:O,logger:S});if($.removedRows>0&&S.debug(`asset GC removed orphan assets`,{count:$.removedRows,swept:$.sweptFilenames.length}),e.reconcileAssetFiles??!0){let e=await Ne(n.pluginIO,{contentDir:d,registered:await he(O)});e.restored.length>0&&f.info(`Restored ${e.restored.length} missing content ${e.restored.length===1?`asset`:`assets`}`),e.missingSources.length>0&&S.warn(`registered assets are missing their source file`,{paths:e.missingSources}),e.failed.length>0&&S.warn(`could not restore missing content assets; /content-assets/* will 404`,{paths:e.failed})}let{routeBySlug:ht}=await b({context:n,database:O});n.config=A(j.config,ht.values()),await c(O,A(j.siteConfig,ht.values()),n.config);try{await O.db.transaction(e=>y(e,`system`,[]))}catch(e){S.warn(`could not clear the stored run failure`,{error:e instanceof Error?e.message:String(e)})}let gt=e.collectProblems===!1?[]:await we(O);f.debug(`Content ingest complete`,{durationMs:E()});let _t=n.state??h,vt=pe({registry:n.pluginRegistry,routes:_t.routeBySlug.values()}),yt=me({registry:n.pluginRegistry,entities:_t.entitiesByKey.values()});return{contentDir:d,diff:U,currentFiles:B,previousFiles:R.affectedPreviousFiles,problems:gt,templateSet:vt,serverModuleSet:yt,inlineSearchables:Q.inlineSearchables,routeChanges:{...Q.routeChanges,unbounded:Q.routeChanges.unbounded||M}}}finally{D&&await O.close()}}function Je(e){let t=/* @__PURE__ */ new Map;for(let n of e.diff.added)t.set(n.path,n);for(let n of e.diff.changed)t.set(n.path,n.file);let n=new Map(e.currentFiles.map(e=>[e.path,e]));for(let n of e.currentFiles)t.has(n.path)||E(e.context,n,e.storedPluginsByPath.get(n.path))&&t.set(n.path,n);for(let r of e.dirtyOrigins){let i=n.get(r.originFilePath)??O(e.context.contentDir,e.storedFilesByPath.get(r.originFilePath));i&&t.set(i.path,i)}let r=[...t.keys(),...e.diff.removed.map(e=>e.path)];for(let i of T(r,e.storedFilesByPath.keys())){if(t.has(i))continue;let r=n.get(i)??O(e.context.contentDir,e.storedFilesByPath.get(i));r&&t.set(i,r)}return Array.from(t.values())}function T(t,r){let i=new Set([...t].filter(t=>!t.startsWith(`${e}/`))),a=[];for(let e of r){let t=n(e);t!==void 0&&i.has(e.slice(`@l10n/${t}/`.length))&&a.push(e)}return a}function E(e,t,n){let r=f(e,t.path).map(e=>({id:e.id,version:e.version})).sort((e,t)=>e.id.localeCompare(t.id)),i=[...n??[]].sort((e,t)=>e.pluginId.localeCompare(t.pluginId));return r.length!==i.length||r.some((e,t)=>{let n=i[t];return n===void 0||n.pluginId!==e.id||n.pluginVersion!==e.version})}function D(e,t){return`${e.replace(/\/$/,``)}/${t}`}function O(e,t){if(t)return{absolutePath:D(e,t.path),hash:t.hash,manifestVersion:t.manifestVersion,path:t.path}}function k(e,t,n={}){let r=new Map(e.map(e=>[e.path,e])),i=new Map(t.map(e=>[e.path,e])),a=n.hintScopes??[],o=[],s=[],c=[],l=[];for(let t of e){let e=i.get(t.path);if(!e){o.push(t);continue}if(e.hash!==t.hash){s.push({path:t.path,previousHash:e.hash,nextHash:t.hash,file:t});continue}c.push(t)}for(let e of t)r.has(e.path)||l.push(e);return{added:o,changed:s,removed:l,unchanged:c,hintScopes:a,summary:{added:o.length,changed:s.length,removed:l.length,unchanged:c.length,totalCurrent:n.totalPrevious===void 0?e.length:n.totalPrevious-l.length+o.length,totalPrevious:n.totalPrevious??t.length}}}async function Ye(e){if(e.currentFileIndex){let t=S({currentFileIndex:e.currentFileIndex,hintScopes:e.scanPlan.hintScopes,hintedPaths:e.scanPlan.hintedPaths});return e.scanLogger.debug(`Using provided current file snapshot`,{count:t.length,totalCount:e.currentFileIndex.size}),t}let t=o(),n=await d({fs:e.fs,rootDir:e.contentDir,targets:e.scanPlan.scanTargets,ignoredDirectories:e.ignoredDirectories,logger:e.scanLogger});e.scanLogger.debug(`Scanned content files`,{count:n.length,durationMs:t()});let r=o(),i=await x(n,{fs:e.fs,logger:e.hashLogger,previous:e.previous,onFileHashed:(t,n)=>e.onProgress?.({stage:`scan`,done:t,total:n})});return e.hashLogger.debug(`Computed content hashes`,{count:i.length,durationMs:r()}),i}function A(e,t){let n=m(e,`redirects`)?C(t):{};return{...e,redirects:{...n,...e.redirects}}}export{k as diffContentFiles,w as runContentIngest};
1
+ import{isPlanFeatureGranted as e}from"../../shared/plan-gates.js";import{assembleTemplateSet as t}from"../templates/template-set.js";import{assembleServerModuleSet as n}from"../server-modules/module-set.js";import{formatCount as r}from"../../shared/log-format.js";import{createLogger as i,stopwatch as a}from"../../shared/logger.js";import{L10N_DIR as o}from"../../shared/constants/l10n/defaults.js";import{collectL10nDirLocales as s,l10nDirOf as c,resolveLocaleContext as l}from"../../shared/utils/l10n.js";import{loadEffectiveConfigHash as ee,writeSiteConfig as te}from"../database/site-config.js";import{isConfigChanged as ne,isNestedConfigPath as u,loadContentLayerConfig as re,readNestedConfigProblems as ie}from"../config.js";import{contentIgnoreMatcherOf as ae,normalizeHintPaths as oe,scanContentFiles as d}from"./scan.js";import{resolveContentPluginsForFile as f}from"../plugins/registry.js";import{resolveContentLayerContext as p}from"../context.js";import{openContentLayerDatabase as m}from"../database/connection.js";import{garbageCollectOrphanBlobs as se}from"../database/blobs.js";import"../../shared/constants/app-data.js";import{listConfiguredProducts as ce,productFolderProblems as le}from"../products.js";import{appDataSystemEntityDescriptor as ue}from"../plugins/internal/app-data/index.js";import{warnWhenProjectPluginsAreNotLoaded as de}from"../plugins/project/loaded-set.js";import{apiOutputFiles as fe,readApiOutputs as pe,withApiOutputHints as me}from"../api-outputs.js";import{createContentPlugins as h}from"../plugins/create-content-plugins.js";import"../plugins/index.js";import{listRegisteredAssets as he}from"../database/assets.js";import{createProblem as g}from"../problems/codes.js";import{computeDirtyConfigOrigins as ge,computeDirtyFileOrigins as _e,garbageCollectOrphanedEntities as ve,loadOriginDependencyRows as ye,propagateConfigDependencyInvalidation as be,propagateEntityInvalidation as xe,propagateRetryableProblemInvalidation as Se}from"../database/invalidation.js";import{hasGlobalProblemsForSource as _,listGlobalProblems as Ce,listProblems as we,problemRow as v,replaceGlobalProblemsForKeysTx as Te,replaceGlobalProblemsForSourceTx as y}from"../database/problems.js";import{persistContentFileState as Ee,refreshFileLastModified as De}from"../database/files.js";import{loadContentLayerState as b,partitionIgnoredFiles as Oe,reloadContentLayerEntities as ke}from"../context-state.js";import{garbageCollectOrphanAssetFiles as Ae,restoreMissingAssetFiles as je}from"../materialization/asset-reconcile.js";import{resolveRevisionCapture as Me}from"../revisions/config.js";import{loadPluginHookState as Ne}from"../database/plugin-hook-state.js";import{loadRouteQueryDependencyRows as Pe}from"../database/route-query-deps.js";import{createEntityMaterializer as Fe}from"../materialization/materializer.js";import{runSearchSync as Ie}from"./search-sync.js";import{hashContentFiles as x}from"./hash.js";import{selectCurrentContentFiles as S}from"./current-files.js";import{collectL10nWarnings as Le,l10nLayoutProblems as Re,validateL10nConfig as ze}from"./l10n-warnings.js";import{collectAppDataFragmentOwnerIds as Be,reconcilePluginScopedRows as Ve,registerSystemEntities as He}from"../database/finalize.js";import{hasStaleManifestVersion as Ue,resetContentDatabase as We}from"../database/reset.js";import{readGitLastModified as Ge}from"./git-last-modified.js";import{createContentScanPlan as Ke}from"./scan-plan.js";import{collectPageRedirects as C}from"../page-redirects.js";import{syncContentFiles as qe}from"./sync.js";import{checkAllowedPackages as Je}from"../allowed-packages.js";import{syncConfigLinkRefs as Ye}from"../link-checker/config-links.js";import{collectCollisionPeerOrigins as Xe}from"./slugger/collision-peers.js";async function w(e){let o=p({contentDir:e.contentDir,context:e.context,currentFileIndex:e.currentFileIndex,logger:e.logger??i(),plugins:h(e.contentDir)}),c=o.contentDir,d=o.logger.child(`content-layer`),f=d.child(`content-layer:scan`),x=d.child(`content-layer:hash`),S=d.child(`content-layer:db`),C=d.child(`content-layer:plan`),w=d.child(`content-layer:diff`),T=d.child(`content-layer:sync`),E=e.captureRevisions===!0,D=a();d.debug(`Starting content ingest`,{contentDir:c,hints:e.hints??[]});let O=e.database===void 0,j=e.database??await m({contentDir:c,databaseUrl:e.databaseUrl,migrationsDir:e.migrationsDir,runMigrations:e.runMigrations,platform:o.platform,logger:S});try{if(await Ue(j)){S.warn(`manifest version changed — resetting content database`);let e=a();await We(j,{logger:S}),S.info(`Reset content database`,{durationMs:e()}),o.state=void 0}let i=oe(c,e.hints??[]),p=a(),m=a(),h=await b({context:o,database:j}),O=[...h.filesByPath.values(),...h.ignoredFilesByPath.values()].sort((e,t)=>e.path.localeCompare(t.path));S.debug(`Loaded previous content state`,{loadedCount:O.length,totalCount:O.length,durationMs:m()});let M=await re({context:o,force:!0});await de({contentDir:c,config:M.config,fs:o.platform.fs,logger:d});let N=ne(A(M.config,h.routeBySlug.values()),await ee(j)),P=ze(o.config.l10n);for(let e of P)d.debug(e.message);(N||P.length>0||await _(j,`l10n-config`))&&await j.db.transaction(e=>y(e,`l10n-config`,P.map(e=>v(e,{scope:`global`,source:`l10n-config`})))),(N||M.problems.length>0||await _(j,`config`))&&await j.db.transaction(e=>y(e,`config`,M.problems.map(e=>v(g(e),{scope:`global`,source:`config`}))));let F=await Je(M.config,c,o.platform.fs);(F.length>0||await _(j,`allowed-packages`))&&await j.db.transaction(e=>y(e,`allowed-packages`,F.map(e=>v(g(e),{scope:`global`,source:`allowed-packages`}))));let I=ae(o.config);Oe(h,I);let L=e=>pe({config:o.config,contentDir:c,fs:o.platform.fs,nestedConfigPaths:e,isIgnored:I}),R=N||i.some(u),z=await L([...h.filesByPath.keys()].filter(u)),$e=a(),B=await Ke({contentDir:c,fs:o.platform.fs,previousFiles:O,hints:me(i,z),ignoredDirectories:e.ignoredDirectories,configChanged:R,logger:C});C.debug(`Resolved ingest scan plan`,{hints:B.hintedPaths.length,configChanged:R,scanTargets:B.scanTargets.length,affectedPreviousFiles:B.affectedPreviousFiles.length,durationMs:$e()});let et=new Map(O.map(e=>[e.path,e.hash])),V=await Qe({contentDir:c,currentFileIndex:o.currentFileIndex,fs:o.platform.fs,scanPlan:B,ignoredDirectories:e.ignoredDirectories,scanLogger:f,hashLogger:x,previous:o.currentFileIndex?void 0:et,onProgress:e.onProgress});(B.hintedPaths.length===0||B.hintedPaths.includes(``))&&(z=await L(V.map(e=>e.path).filter(e=>u(e)&&!I(e))));let tt=await fe({outputs:z,files:V,contentDir:c,fs:o.platform.fs,previous:et}),H=[...V.filter(e=>!z.has(e.path)),...tt],U=new Map(await Ge(c,f));for(let[e,t]of z){let n=U.get(t);n!==void 0&&U.set(e,n)}d.info(`Scanned ${r(H.length)} files`,{durationMs:p()});let nt=a(),W=k(H,B.affectedPreviousFiles,{hintScopes:B.hintScopes,totalPrevious:O.length});w.debug(`Computed content diff`,{...W.summary,durationMs:nt()}),d.info(`Compared with the previous state: ${W.summary.added} added, ${W.summary.changed} changed, ${W.summary.removed} removed, ${W.summary.unchanged} unchanged`);let rt=a(),it=a(),at=await Ee(j,{upserts:[...W.added.map(e=>({path:e.path,hash:e.hash,lastModifiedAt:U.get(e.path)??null,manifest:JSON.stringify(e.manifest??{}),manifestVersion:e.manifestVersion})),...W.changed.map(e=>({path:e.path,hash:e.nextHash,lastModifiedAt:U.get(e.path)??null,manifest:JSON.stringify(e.file.manifest??{}),manifestVersion:e.file.manifestVersion}))],removedPaths:W.removed.map(e=>e.path),logger:S});S.debug(`Persisted content file state`,{upserts:W.added.length+W.changed.length,removed:W.removed.length,durationMs:it()});for(let e of W.removed)h.filesByPath.delete(e.path),h.ignoredFilesByPath.delete(e.path);for(let e of at)(I(e.path)?h.ignoredFilesByPath:h.filesByPath).set(e.path,e);let ot=l(o.config.l10n,s(h.filesByPath.keys())),G=o.currentFileIndex!==void 0||R||B.hintedPaths.length===0||B.hintedPaths.includes(``);if(G){let e=Re(Le({l10n:o.config.l10n,localeContext:ot,filePaths:h.filesByPath.keys()})),t=le(ce(o.config),h.filesByPath.keys());for(let t of e)d.debug(t.message);for(let e of t)d.debug(e.message);await j.db.transaction(async n=>{await y(n,`l10n-layout`,e.map(e=>v(e,{scope:`global`,source:`l10n-layout`}))),await y(n,`products`,t.map(e=>v(g(e),{scope:`global`,source:`products`})))})}let K=G?[...h.filesByPath.keys()].filter(u):[...W.added,...W.changed].map(e=>e.path).filter(e=>u(e)&&!I(e)),st=W.removed.map(e=>e.path).filter(u);if(G||K.length>0||st.length>0){let e=(await ie({contentDir:c,fs:o.platform.fs,paths:K})).map(e=>v(g(e),{scope:`global`,source:`nested-config`,key:e.location?.filePath}));await j.db.transaction(t=>G?y(t,`nested-config`,e):Te(t,`nested-config`,[...K,...st],e))}let ct=H.flatMap(e=>{let t=h.filesByPath.get(e.path),n=U.get(e.path)??null;return!t||t.lastModifiedAt===n?[]:(h.filesByPath.set(e.path,{...t,lastModifiedAt:n}),[{path:e.path,lastModifiedAt:n}])});await De(j,ct,S);let lt=await xe(j,{changedFilePaths:[...W.added.map(e=>e.path),...W.changed.map(e=>e.path),...W.removed.map(e=>e.path),...ct.map(e=>e.path)],membershipChangedPaths:[...W.added,...W.removed].map(e=>e.path).filter(e=>!I(e)),logger:S}),ut=o.pluginRegistry.listExtractAllPlugins(),dt=o.pluginRegistry.listFinalizePlugins(),ft=new Set(dt.map(e=>e.id)),q=[...Be(h.entitiesByKey.get(`app-data`)?.loaderArgs??null)].filter(e=>!ft.has(e)),pt=await Ve(j,[...ut.map(e=>({pluginId:e.id,hook:`extractAll`})),...dt.map(e=>({pluginId:e.id,hook:`finalize`}))],{logger:S});q.length>0&&await He(j,[ue({fragmentUpdates:new Map(q.map(e=>[e,null]))})],{logger:S});let[J,mt,ht]=await Promise.all([ye(j),Pe(j),Ne(j)]),gt=ge(J,o.config),_t=_e(J,h),vt=await be(j,{config:o.config,logger:S}),yt=await Se(j,{logger:S});if((await ve(j,S)).removedOrphans)await ke({state:h,database:j});else for(let e of[...lt.invalidatedKeys,...vt.invalidatedKeys,...yt.invalidatedKeys]){let t=h.entitiesByKey.get(e);t&&(t.status=`stale`)}(pt||q.length>0)&&(o.state=void 0,h=await b({context:o,database:j}));let bt=await Ce(j,`slugger`),xt=Xe(bt,{touchedPaths:[...W.added.map(e=>e.path),...W.changed.map(e=>e.path),...W.removed.map(e=>e.path),...gt.map(e=>e.originFilePath),..._t.map(e=>e.originFilePath)],storedFilesByPath:h.filesByPath}),Y=Ze({context:o,diff:W,currentFiles:H,dirtyOrigins:[...gt,..._t,...xt],hintedPaths:B.hintedPaths,storedFilesByPath:h.filesByPath,storedPluginsByPath:h.filePluginsByPath}),St=a(),X=Me(o.config,E),Z=await qe({context:o,database:j,localeContext:ot,files:Y,removedPaths:new Set(W.removed.map(e=>e.path)),pluginScopedOriginRows:J,routeQueryRows:mt,hookState:ht,storedSluggerProblems:bt,revisions:X,onFileSynced:(t,n)=>e.onProgress?.({stage:`sync`,done:t,total:n})});o.state=Z.state,T.debug(`Synchronized content routes`,{files:Y.length,durationMs:St()}),await Ye({database:j,config:o.config,configChanged:N,logger:S}),d.info(`Updated content state: ${W.added.length+W.changed.length} upserted, ${W.removed.length} removed, ${Y.length} synced`,{durationMs:rt()}),e.searchSync!==!1&&await Ie({context:o,database:j,inlineSearchables:Z.inlineSearchables,materializer:Fe({deps:{...o,state:Z.state},database:j,revisions:X})});let Ct=await se(j,{logger:S});Ct.removed>0&&S.debug(`blob GC removed orphan blobs`,{count:Ct.removed});let Q=await Ae(o.pluginIO,{contentDir:c,database:j,logger:S});if(Q.removedRows>0&&S.debug(`asset GC removed orphan assets`,{count:Q.removedRows,swept:Q.sweptFilenames.length}),e.reconcileAssetFiles??!0){let e=await je(o.pluginIO,{contentDir:c,registered:await he(j)});e.restored.length>0&&d.info(`Restored ${e.restored.length} missing content ${e.restored.length===1?`asset`:`assets`}`),e.missingSources.length>0&&S.warn(`registered assets are missing their source file`,{paths:e.missingSources}),e.failed.length>0&&S.warn(`could not restore missing content assets; /content-assets/* will 404`,{paths:e.failed})}let{routeBySlug:wt}=Z.state;o.config=A(M.config,wt.values()),await te(j,A(M.siteConfig,wt.values()),o.config);try{await j.db.transaction(e=>y(e,`system`,[]))}catch(e){S.warn(`could not clear the stored run failure`,{error:e instanceof Error?e.message:String(e)})}let Tt=e.collectProblems===!1?[]:await we(j);d.debug(`Content ingest complete`,{durationMs:D()});let $=Z.state,Et=t({registry:o.pluginRegistry,routes:$.routeBySlug.values()}),Dt=n({registry:o.pluginRegistry,entities:$.entitiesByKey.values()});return{contentDir:c,diff:W,currentFiles:V,previousFiles:B.affectedPreviousFiles,problems:Tt,templateSet:Et,serverModuleSet:Dt,inlineSearchables:Z.inlineSearchables,routeChanges:{...Z.routeChanges,unbounded:Z.routeChanges.unbounded||N}}}finally{O&&await j.close()}}function Ze(e){let t=/* @__PURE__ */ new Map;for(let n of e.diff.added)t.set(n.path,n);for(let n of e.diff.changed)t.set(n.path,n.file);let n=new Map(e.currentFiles.map(e=>[e.path,e]));for(let n of e.currentFiles)t.has(n.path)||E(e.context,n,e.storedPluginsByPath.get(n.path))&&t.set(n.path,n);for(let r of e.dirtyOrigins){let i=n.get(r.originFilePath)??O(e.context.contentDir,e.storedFilesByPath.get(r.originFilePath));i&&t.set(i.path,i)}let r=[...t.keys(),...e.diff.removed.map(e=>e.path)];for(let i of T(r,e.storedFilesByPath.keys())){if(t.has(i))continue;let r=n.get(i)??O(e.context.contentDir,e.storedFilesByPath.get(i));r&&t.set(i,r)}return Array.from(t.values())}function T(e,t){let n=new Set([...e].filter(e=>!e.startsWith(`${o}/`))),r=[];for(let e of t){let t=c(e);t!==void 0&&n.has(e.slice(`@l10n/${t}/`.length))&&r.push(e)}return r}function E(e,t,n){let r=f(e,t.path).map(e=>({id:e.id,version:e.version})).sort((e,t)=>e.id.localeCompare(t.id)),i=[...n??[]].sort((e,t)=>e.pluginId.localeCompare(t.pluginId));return r.length!==i.length||r.some((e,t)=>{let n=i[t];return n===void 0||n.pluginId!==e.id||n.pluginVersion!==e.version})}function D(e,t){return`${e.replace(/\/$/,``)}/${t}`}function O(e,t){if(t)return{absolutePath:D(e,t.path),hash:t.hash,manifestVersion:t.manifestVersion,path:t.path}}function k(e,t,n={}){let r=new Map(e.map(e=>[e.path,e])),i=new Map(t.map(e=>[e.path,e])),a=n.hintScopes??[],o=[],s=[],c=[],l=[];for(let t of e){let e=i.get(t.path);if(!e){o.push(t);continue}if(e.hash!==t.hash){s.push({path:t.path,previousHash:e.hash,nextHash:t.hash,file:t});continue}c.push(t)}for(let e of t)r.has(e.path)||l.push(e);return{added:o,changed:s,removed:l,unchanged:c,hintScopes:a,summary:{added:o.length,changed:s.length,removed:l.length,unchanged:c.length,totalCurrent:n.totalPrevious===void 0?e.length:n.totalPrevious-l.length+o.length,totalPrevious:n.totalPrevious??t.length}}}async function Qe(e){if(e.currentFileIndex){let t=S({currentFileIndex:e.currentFileIndex,hintScopes:e.scanPlan.hintScopes,hintedPaths:e.scanPlan.hintedPaths});return e.scanLogger.debug(`Using provided current file snapshot`,{count:t.length,totalCount:e.currentFileIndex.size}),t}let t=a(),n=await d({fs:e.fs,rootDir:e.contentDir,targets:e.scanPlan.scanTargets,ignoredDirectories:e.ignoredDirectories,logger:e.scanLogger});e.scanLogger.debug(`Scanned content files`,{count:n.length,durationMs:t()});let r=a(),i=await x(n,{fs:e.fs,logger:e.hashLogger,previous:e.previous,onFileHashed:(t,n)=>e.onProgress?.({stage:`scan`,done:t,total:n})});return e.hashLogger.debug(`Computed content hashes`,{count:i.length,durationMs:r()}),i}function A(t,n){let r=e(t,`redirects`)?C(n):{};return{...t,redirects:{...r,...t.redirects}}}export{k as diffContentFiles,w as runContentIngest};
@@ -1,6 +1,6 @@
1
1
  import type { PlatformFs } from '../../platform/types/fs.js';
2
2
  import type { Logger } from '../../shared/logger.js';
3
- export declare const DEFAULT_IGNORED_DIRECTORIES: readonly ['.git', '.realm', '.realm-lazy', '.realm-sahpool', 'dist', 'node_modules'];
3
+ export declare const DEFAULT_IGNORED_DIRECTORIES: readonly ['.git', '.realm', '.realm-lazy', '.realm-sahpool', '@sdk', 'dist', 'node_modules'];
4
4
  export type ContentHint = string;
5
5
  export type ContentPathScope = {
6
6
  path: string;
@@ -1 +1 @@
1
- import{toPosixPath as e}from"../../shared/utils/to-posix-path.js";import{REDOCLY_CONFIG_FILENAMES as t}from"../config.js";import{compileContentGlob as n}from"../plugins/utils/glob.js";import{isAbsolute as r,join as i,posix as a,relative as o,resolve as s}from"node:path";const c=[`.git`,`.realm`,`.realm-lazy`,`.realm-sahpool`,`dist`,`node_modules`];async function l(e){let t=s(e.rootDir),n=new Set(e.ignoredDirectories??c),r=e.targets===void 0?[{path:``,absolutePath:t,recursive:!0}]:d(e.targets),a=[],o=/* @__PURE__ */ new Set,l=e.logger,u=e=>{let r=v(t,e);if(!(r===``||o.has(r))){if(_(r,n)){l?.debug(`Skipping ignored file`,{path:r});return}o.add(r),a.push({path:r,absolutePath:e})}},f=async r=>{let a=await e.fs.readdir(r);for(let e of a){let a=i(r,e.name),o=v(t,a);if(e.type===`symlink`){l?.debug(`Skipping symbolic link`,{path:o});continue}if(e.type===`directory`){if(_(o,n)){l?.debug(`Skipping ignored directory`,{name:e.name,path:o});continue}await f(a);continue}if(e.type!==`file`){l?.debug(`Skipping non-file entry`,{path:o});continue}u(a)}};for(let e of r){if(e.recursive){if(e.path!==``&&_(e.path,n)){l?.debug(`Skipping ignored scan target`,{path:e.path});continue}await f(e.absolutePath);continue}u(e.absolutePath)}return a.sort((e,t)=>e.path.localeCompare(t.path)),a}function u(e,t){let n=/* @__PURE__ */ new Set,r=s(e);for(let e of t){let t=b(r,e);t!==null&&n.add(t)}return[...n].sort((e,t)=>e.localeCompare(t))}function d(e){let t=[];for(let n of[...e].sort(x))t.some(e=>p(e,n.path))||t.push(n);return t}function f(e,t){return t.some(t=>p(t,e))}function p(e,t){return e.path===``?e.recursive:e.path===t||e.recursive&&t.startsWith(`${e.path}/`)}const m=/* @__PURE__ */ new WeakMap;function h(e){let t=m.get(e);return t===void 0&&(t=g(e.ignore),m.set(e,t)),t}function g(e){let r=typeof e==`string`?[e]:Array.isArray(e)?e:[],i=[];for(let e of r){if(typeof e!=`string`)continue;let t=e.startsWith(`!`),r=(t?e.slice(1):e).replace(/^\.?\/+/,``).replace(/(?<!\/)\/+$/,``);r!==``&&i.push({negated:t,matches:n([r,`${r}/**`])})}return e=>{if(t.includes(e))return!1;let n=!1;for(let t of i)t.matches(e)&&(n=!t.negated);return n}}function _(t,n){let r=n instanceof Set?n:new Set(n);return e(t).split(`/`).filter(Boolean).some(e=>r.has(e))}function v(e,t){return w(o(s(e),t))}function y(e,t){if(/^[a-z][a-z\d+.-]*:\/\//i.test(t))return null;let n=v(e,t);return n===``||n===`..`||n.startsWith(`../`)||r(n)||/^[a-z]:/i.test(n)?null:n}function b(e,t){if(t.trim()===``)return null;if(r(t)){let n=o(e,t);return n===``||C(n)?w(n):null}return w(t)}function x(e,t){let n=S(e.path),r=S(t.path);return n===r?e.recursive===t.recursive?e.path.localeCompare(t.path):e.recursive?-1:1:n-r}function S(e){return e===``?0:e.split(`/`).filter(Boolean).length}function C(e){return e!==`..`&&!e.startsWith(`..${a.sep}`)&&!e.startsWith(`..\\`)}function w(t){let n=a.normalize(e(t)).replace(/^\.\//,``);return n===`.`?``:n}export{c as DEFAULT_IGNORED_DIRECTORIES,d as compactScopes,h as contentIgnoreMatcherOf,g as createContentIgnoreMatcher,_ as isIgnoredContentPath,f as isPathCoveredByScopes,u as normalizeHintPaths,l as scanContentFiles,p as scopeCoversPath,y as toContainedContentPath,v as toContentPath};
1
+ import{toPosixPath as e}from"../../shared/utils/to-posix-path.js";import{REDOCLY_CONFIG_FILENAMES as t}from"../config.js";import{compileContentGlob as n}from"../plugins/utils/glob.js";import{isAbsolute as r,join as i,posix as a,relative as o,resolve as s}from"node:path";const c=[`.git`,`.realm`,`.realm-lazy`,`.realm-sahpool`,`@sdk`,`dist`,`node_modules`];async function l(e){let t=s(e.rootDir),n=new Set(e.ignoredDirectories??c),r=e.targets===void 0?[{path:``,absolutePath:t,recursive:!0}]:d(e.targets),a=[],o=/* @__PURE__ */ new Set,l=e.logger,u=e=>{let r=v(t,e);if(!(r===``||o.has(r))){if(_(r,n)){l?.debug(`Skipping ignored file`,{path:r});return}o.add(r),a.push({path:r,absolutePath:e})}},f=async r=>{let a=await e.fs.readdir(r);for(let e of a){let a=i(r,e.name),o=v(t,a);if(e.type===`symlink`){l?.debug(`Skipping symbolic link`,{path:o});continue}if(e.type===`directory`){if(_(o,n)){l?.debug(`Skipping ignored directory`,{name:e.name,path:o});continue}await f(a);continue}if(e.type!==`file`){l?.debug(`Skipping non-file entry`,{path:o});continue}u(a)}};for(let e of r){if(e.recursive){if(e.path!==``&&_(e.path,n)){l?.debug(`Skipping ignored scan target`,{path:e.path});continue}await f(e.absolutePath);continue}u(e.absolutePath)}return a.sort((e,t)=>e.path.localeCompare(t.path)),a}function u(e,t){let n=/* @__PURE__ */ new Set,r=s(e);for(let e of t){let t=b(r,e);t!==null&&n.add(t)}return[...n].sort((e,t)=>e.localeCompare(t))}function d(e){let t=[];for(let n of[...e].sort(x))t.some(e=>p(e,n.path))||t.push(n);return t}function f(e,t){return t.some(t=>p(t,e))}function p(e,t){return e.path===``?e.recursive:e.path===t||e.recursive&&t.startsWith(`${e.path}/`)}const m=/* @__PURE__ */ new WeakMap;function h(e){let t=m.get(e);return t===void 0&&(t=g(e.ignore),m.set(e,t)),t}function g(e){let r=typeof e==`string`?[e]:Array.isArray(e)?e:[],i=[];for(let e of r){if(typeof e!=`string`)continue;let t=e.startsWith(`!`),r=(t?e.slice(1):e).replace(/^\.?\/+/,``).replace(/(?<!\/)\/+$/,``);r!==``&&i.push({negated:t,matches:n([r,`${r}/**`])})}return e=>{if(t.includes(e))return!1;let n=!1;for(let t of i)t.matches(e)&&(n=!t.negated);return n}}function _(t,n){let r=n instanceof Set?n:new Set(n);return e(t).split(`/`).filter(Boolean).some(e=>r.has(e))}function v(e,t){return w(o(s(e),t))}function y(e,t){if(/^[a-z][a-z\d+.-]*:\/\//i.test(t))return null;let n=v(e,t);return n===``||n===`..`||n.startsWith(`../`)||r(n)||/^[a-z]:/i.test(n)?null:n}function b(e,t){if(t.trim()===``)return null;if(r(t)){let n=o(e,t);return n===``||C(n)?w(n):null}return w(t)}function x(e,t){let n=S(e.path),r=S(t.path);return n===r?e.recursive===t.recursive?e.path.localeCompare(t.path):e.recursive?-1:1:n-r}function S(e){return e===``?0:e.split(`/`).filter(Boolean).length}function C(e){return e!==`..`&&!e.startsWith(`..${a.sep}`)&&!e.startsWith(`..\\`)}function w(t){let n=a.normalize(e(t)).replace(/^\.\//,``);return n===`.`?``:n}export{c as DEFAULT_IGNORED_DIRECTORIES,d as compactScopes,h as contentIgnoreMatcherOf,g as createContentIgnoreMatcher,_ as isIgnoredContentPath,f as isPathCoveredByScopes,u as normalizeHintPaths,l as scanContentFiles,p as scopeCoversPath,y as toContainedContentPath,v as toContentPath};
@@ -1 +1 @@
1
- import{hashJsonValue as e}from"../database/utils/json.js";import{SEARCH_GROUP_FACET_FIELD as t,resolveSearchFacets as n}from"../../shared/search/facets.js";import{findProductForSlug as r}from"../../shared/products.js";import{normalizeRouteSlug as i}from"../../shared/utils/routes/normalize-route-slug.js";import{userMarkdocSchemaDigest as a}from"../markdown/constants/tag-sets.js";import{formatDuration as o}from"../../shared/log-format.js";import{hashContentBytes as s}from"../../shared/utils/content-hash.js";import{isRbacScope as c}from"../../server/rbac/engine.js";import{entities as l,pageMarkdown as u,routeQueryDeps as d,searchDocuments as f}from"../database/schema.js";import{computePathPrefixes as p}from"../../shared/utils/routes/compute-path-prefixes.js";import{replaceDataRefMarkers as m}from"../materialization/data-ref.js";import{batchValues as h,normalizeBatchSize as g}from"../database/connection.js";import{resolveDataRef as _}from"../database/blobs.js";import{createRouteQueryEvaluator as v,dedupeRouteQueryDependencies as y,isRouteQueryStale as b}from"../plugins/utils/route-index.js";import{listConfiguredProducts as x}from"../products.js";import{curationKeywordsOf as S}from"../search/keywords.js";import{createMarkdownCopyRule as ee}from"../markdown-copy-rule.js";import{createProblem as C}from"../problems/codes.js";import{problemRow as w,replaceEntityProblemsForCodesBatchTx as T}from"../database/problems.js";import"../search/postings/postings-store.js";import{createSearchStore as E}from"../search/store.js";import{loadContentLayerState as D}from"../context-state.js";import{replaceEntityRouteQueryDepsTx as O}from"../database/route-query-deps.js";import{loadAttachedRouteSlugs as te}from"../database/route-deps.js";import{toRbacTeams as k,toRbacTeamsWithinRoute as A}from"./rbac-teams.js";import{buildDocumentFacets as j}from"../search/facet-rows.js";import{SEARCH_PROBLEM_CODES as M,searchFacetInvalidProblem as N,searchableFailedProblem as P}from"../problems/producers.js";import{createHookEntityStore as F}from"./hook-inputs.js";import{and as I,eq as L,inArray as R}from"drizzle-orm";function ne(t,n,r,i){let a=[...t].sort(),o=n.map(e=>[e.name,e.slug]);return(t,n)=>{let s=[2,t,a,o,r];return n&&i!==void 0&&s.push(i),e(s)}}async function z(e){let{context:t,database:n}=e,r=t.logger.child(`content-layer:search`),i=[],s=/* @__PURE__ */ new Map,c=new Map(t.pluginRegistry.listEntityLoaders().filter(e=>e.definition.searchable!==void 0||e.definition.markdown!==void 0).map(e=>[e.definition.id,e])),l=e.inlineSearchables??/* @__PURE__ */ new Map,u=e.entityKeys===void 0?void 0:[...e.entityKeys,...l.keys()],d=await re(n,u);if(c.size===0&&l.size===0&&d.size===0)return{synced:0,problems:i};let f=await D({context:t,database:n}),p=E(n),m=v(f,t.config),g=x(t.config),_=q(f,m,g),y=_(),b=J(t),S=ee(t.config),C=ne(b,g,S.settings,a()),T=X(r,{configuredFields:b}),O=0,k=(e,t)=>{i.push(...t),s.set(e,t.map(t=>w(t,{scope:`entity`,entityId:e})))},A=(e,t,n,a)=>{let o=a instanceof Error?a.message:String(a);r.warn(`searchable failed for "${t}"; keeping its last documents: ${o}`);let c=P({entityKey:t,pluginId:n,message:o});i.push(c),s.set(e,[w(c,{scope:`entity`,entityId:e})])},j=async()=>(await B(n,s,M,r),{synced:O,problems:i});u===void 0&&await U({context:t,database:n,state:f,store:p,stored:d,searchableLoaders:c});let N=[];for(let[e,n]of l){let i=f.entitiesByKey.get(e);if(i&&i.kind===`inline`){if(n===void 0){d.has(e)&&await p.removeSource(e);continue}try{let a=await T.prepare(e,n.docs,y);N.push({entityKey:e,docs:a.docs,...Y(e,n,a.docs),sourceHash:C(i.dataHash??``,!1),pluginVersion:t.pluginRegistry.getById(i.pluginId)?.version??``}),k(i.id,[...H(e,n.problems,r),...a.problems])}catch(t){A(i.id,e,i.pluginId,t)}}}if(await p.replaceSourceDocuments(N),O+=N.length,c.size===0)return j();let F=await ie(n,[...c.keys()],e.entityKeys),I=await ae(n,m,F.map(e=>e.id)),L=F.filter(e=>{let n=c.get(e.loaderId),r=n?t.pluginRegistry.getById(n.pluginId)?.version:void 0,i=d.get(e.key);return i===void 0||i.sourceHash!==C(e.dataHash??``,n?.definition.usesProjectMarkdocSchema===!0)||i.pluginVersion!==r||I.has(e.id)});if(L.length===0)return j();let R=await te(n,L.map(e=>e.key)),z=0,G=0,Z=0,Q=0,$=0;for(let r of h(L,50)){z+=1;let i=Date.now(),a=await K(n,r);Z+=Date.now()-i,i=Date.now();let o=[];for(let i of r){let r=c.get(i.loaderId);if(r){try{let e=await W({row:i,entry:r,value:a.get(i.id),attachedSlug:R.get(i.key),context:t,database:n,state:f,evaluator:m,resolveAccess:_,prepare:T.prepare,stampOf:C,allowsMarkdownCopy:S.allows});o.push(e),k(i.id,e.problems)}catch(e){A(i.id,i.key,r.pluginId,e)}G+=1,e.onProgress?.(G,L.length)}}Q+=Date.now()-i,i=Date.now(),await V({context:t,database:n,store:p,outputs:o}),$+=Date.now()-i,O+=o.length}return u===void 0&&r.info(`Synced ${L.length} content ${L.length===1?`item`:`items`} for search in ${z} ${z===1?`chunk`:`chunks`} (load ${o(Z)}, producers ${o(Q)}, writes ${o($)})`),j()}async function B(e,t,n,r){if(t.size!==0)try{await e.db.transaction(e=>T(e,t,n))}catch(e){r.warn(`could not store the search problems of this pass`,{error:e instanceof Error?e.message:String(e)})}}async function V(e){let{context:t,outputs:n}=e;n.length!==0&&await e.database.db.transaction(async r=>{await e.store.replaceSourceDocuments(n.map(e=>({entityKey:e.row.key,docs:e.docs,fragments:e.fragments,uses:e.uses,sourceHash:e.sourceHash,pluginVersion:t.pluginRegistry.getById(e.entry.pluginId)?.version??``})),r),await O(r,{hook:`searchable`,scopes:n.map(e=>({originPluginId:e.entry.pluginId,entityId:e.row.id,dependencies:y(e.reads)}))});for(let e of n){if(await r.delete(u).where(L(u.entityKey,e.row.key)),e.markdownDocs.length===0)continue;let n=t.pluginRegistry.getById(e.entry.pluginId)?.version??``;for(let t of e.markdownDocs){let i=await Promise.all(t.chunks.map(async(r,i)=>{let a=t.headings?.[i]??null;return{entityKey:e.row.key,chunkIndex:i,routeSlug:t.routeSlug,text:r,heading:a?.heading??null,anchor:a?.anchor??null,title:t.title??null,description:t.description??null,rbacTeams:t.rbacTeams,hash:await s(new TextEncoder().encode(r)),sourceHash:e.sourceHash,pluginVersion:n}}));await r.insert(u).values(i)}}})}function H(e,t,n){let r=[],i=/* @__PURE__ */ new Set;for(let e of t??[])M.includes(e.code)?r.push(C(e)):i.add(e.code);for(let t of i)n.warn(`searchable for "${e}" reported problem code "${t}", which the search sync does not own; use one of ${M.join(`, `)}`);return r}async function U(e){for(let t of e.stored.keys()){let n=e.state.entitiesByKey.get(t);n&&(e.context.pluginRegistry.getById(n.pluginId)===void 0||n.kind!==`inline`&&(n.loaderId===null||!e.searchableLoaders.has(n.loaderId)))&&(await e.store.removeSource(t),await e.database.db.delete(u).where(L(u.entityKey,t)))}}async function W(e){let{row:t,entry:n,database:r}=e,i=n.definition.searchable,a=n.definition.markdown,o=e.value;if(!o||o.data===null||o.dataHash===null)throw Error(`Entity "${t.key}" has no stored value.`);let s=e.stampOf(o.dataHash,n.definition.usesProjectMarkdocSchema),c=await m(o.data,e=>_(r,e)),l=[],u=e=>l.push(e),d=e.evaluator.index(u),f=e.attachedSlug===void 0?void 0:d.get(e.attachedSlug),p=e.resolveAccess(u),h={config:e.context.config,entities:F(e.context,r,e.state,u),logger:e.context.logger.child(`content-layer:searchable:${n.definition.id}`),routes:d,route:f},g=i?await i(c,h):{docs:[]},v=a&&e.allowsMarkdownCopy(f)?await a(c,h):null,y=G(t.key,v,e.attachedSlug).map(e=>Object.assign(e,{rbacTeams:p.rbacTeamsForSlug(e.routeSlug)})),b=await e.prepare(t.key,g.docs??[],p);return{row:t,entry:n,docs:b.docs,...Y(t.key,g,b.docs),markdownDocs:y,sourceHash:s,reads:l,problems:[...H(t.key,g.problems,e.context.logger),...b.problems]}}function G(e,t,n){if(t===null)return[];if(!Array.isArray(t))throw Error(`markdown for "${e}" must return an array or null.`);let r=t.length>0&&typeof t[0]==`string`?[{chunks:t}]:t,i=/* @__PURE__ */ new Set,a=[];for(let t of r){let r=t.routeSlug??n;if(r!==void 0){if(!Array.isArray(t.chunks)||t.chunks.some(e=>typeof e!=`string`))throw Error(`markdown for "${e}" returned a document without string chunks.`);if(t.chunks.length!==0){if(i.has(r))throw Error(`markdown for "${e}" returned "${r}" twice.`);i.add(r),a.push({routeSlug:r,chunks:t.chunks,headings:t.headings,...typeof t.title==`string`&&t.title!==``?{title:t.title}:{},...typeof t.description==`string`&&t.description!==``?{description:t.description}:{}})}}}return a}async function K(e,t){let n=await e.db.select({id:l.id,data:l.data,dataHash:l.dataHash}).from(l).where(R(l.id,t.map(e=>e.id)));return new Map(n.map(e=>[e.id,e]))}function q(e,t,n){let i=[...e.routeBySlug.values()].filter(e=>e.wildcardPrefix),a=t=>{if(e.routeBySlug.has(t))return t;let n=new Set(p(t)),r;for(let e of i)n.has(e.slug)&&(r===void 0||e.slug.length>r.length)&&(r=e.slug);return r};return i=>{let o=t.index(i),s=e=>o.getAccess(a(e)??e),c=t=>e.routeBySlug.get(a(t)??t);return{accessForSlug:s,rbacTeamsForSlug:e=>k(s(e)),localeForSlug:e=>c(e)?.locale??``,originFilePathForSlug:e=>c(e)?.originFilePath??null,versionForSlug:e=>{let t=c(e);return t?.versionGroup!=null&&t.version!=null?{group:t.versionGroup,version:t.version}:null},productForSlug:e=>{let t=c(e),i=t?t.canonicalSlug||t.slug:e;return r(n,i)}}}}function J(e){return new Set(n(e.config).map(e=>e.field).filter(e=>e!==t))}function Y(e,t,n){let r=t.fragments??[],i=t.uses??[];if(!Array.isArray(r)||!Array.isArray(i))throw Error(`searchable for "${e}" must return fragments and uses as arrays.`);for(let t of r)if(typeof t.fragmentKey!=`string`||typeof t.name!=`string`)throw Error(`searchable for "${e}" returned a fragment without a key or name.`);let a=new Set(n.map(e=>e.docKey));return{fragments:r,uses:i.filter(e=>a.has(e.docKey))}}function X(e,t){return{async prepare(n,r,a){if(!Array.isArray(r))throw Error(`searchable for "${n}" must return { docs: SearchDocument[] }.`);let o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Set,c=[],l=[];for(let u of r){if(Q(n,u),o.has(u.docKey))throw Error(`searchable for "${n}" returned docKey "${u.docKey}" twice.`);o.add(u.docKey);let r=i(u.routeSlug),d=a.accessForSlug(r);if(d===void 0){e.warn(`search document "${u.docKey}" of "${n}" dropped: no route "${r}"`);continue}let{facets:f,rbacScope:p,keywords:m,...h}=u,g=a.productForSlug(r),_=a.versionForSlug(r),v=j({facets:f,configuredFields:t.configuredFields,groupKey:u.groupKey,teams:A(d,p),version:_,product:g?.name??null,keywords:S(m),onDropped:(e,t)=>{let i=`${e}\u0000${t}`;s.has(i)||(s.add(i),c.push(N({entityKey:n,field:e,reason:Z[t],filePath:a.originFilePathForSlug(r)})))}}),y={...h,routeSlug:r,locale:a.localeForSlug(r),facets:v};g&&(y.product={name:g.name,folder:g.folder}),_&&(y.version=_),l.push(y)}return{docs:l,problems:c}}}}const Z={"not-an-object":`facets must be an object of field to string or string list`,reserved:`fields starting with "redocly_" are derived by the engine`,invalid:`a value must be a string, number, boolean, or a list of those`,"too-long":`a value must be at most 500 characters`,"too-many-words":`a keyword must have at most 10 words`};function Q(e,t){let n=t;if(!(typeof n==`object`&&n&&typeof n.docKey==`string`&&n.docKey!==``&&typeof n.routeSlug==`string`&&typeof n.title==`string`&&typeof n.text==`string`))throw Error(`searchable for "${e}" returned an invalid document (docKey, routeSlug, title, text are required strings).`);if(n.rbacScope!==void 0&&!c(n.rbacScope))throw Error(`searchable for "${e}" returned document "${n.docKey}" with an invalid rbacScope.`)}async function re(e,t){let n=/* @__PURE__ */ new Map;for(let r of t===void 0?[void 0]:h(t,g(void 0))){let t=await e.db.selectDistinct({entityKey:f.entityKey,sourceHash:f.sourceHash,pluginVersion:f.pluginVersion}).from(f).where(r===void 0?void 0:R(f.entityKey,[...r]));for(let{entityKey:e,...r}of t)n.set(e,r);let i=await e.db.selectDistinct({entityKey:u.entityKey,sourceHash:u.sourceHash,pluginVersion:u.pluginVersion}).from(u).where(r===void 0?void 0:R(u.entityKey,[...r]));for(let{entityKey:e,...t}of i)n.has(e)||n.set(e,t)}return n}async function ie(e,t,n){return n!==void 0&&n.length===0?[]:(await e.db.select({id:l.id,key:l.key,loaderId:l.loaderId,dataHash:l.dataHash}).from(l).where(I(L(l.status,`ready`),L(l.isCurrent,1),R(l.loaderId,[...t]),n===void 0?void 0:R(l.key,[...n]))).orderBy(l.key)).filter(e=>e.loaderId!==null)}async function ae(e,t,n){let r=/* @__PURE__ */ new Set;if(n.length===0)return r;let i=new Set(n),a=n.length<=g(void 0),o=await e.db.select({entityId:d.entityId,kind:d.kind,argument:d.argument,resultHash:d.resultHash}).from(d).where(I(L(d.hook,`searchable`),a?R(d.entityId,[...n]):void 0));for(let e of o)e.entityId!==null&&i.has(e.entityId)&&!r.has(e.entityId)&&b(t,e)&&r.add(e.entityId);return r}function $(e,t){for(let n of e)n.kind===`inline`&&t.set(n.key,n.searchable)}export{$ as collectInlineSearchables,z as runSearchSync};
1
+ import{hashJsonValue as e}from"../database/utils/json.js";import{SEARCH_GROUP_FACET_FIELD as t,resolveSearchFacets as n}from"../../shared/search/facets.js";import{hashContentBytes as r}from"../../shared/utils/content-hash.js";import{formatDuration as i}from"../../shared/log-format.js";import{isRbacScope as a}from"../../shared/rbac/engine.js";import{normalizeRouteSlug as o}from"../../shared/utils/routes/normalize-route-slug.js";import{entities as s,pageMarkdown as c,routeQueryDeps as l,searchDocuments as u}from"../database/schema.js";import{computePathPrefixes as d}from"../../shared/utils/routes/compute-path-prefixes.js";import{replaceDataRefMarkers as f}from"../materialization/data-ref.js";import{batchValues as p,normalizeBatchSize as m}from"../database/connection.js";import{resolveDataRef as h}from"../database/blobs.js";import{createRouteQueryEvaluator as g,dedupeRouteQueryDependencies as _,isRouteQueryStale as v}from"../plugins/utils/route-index.js";import{listConfiguredProducts as y}from"../products.js";import{userMarkdocSchemaDigest as b}from"../markdown/constants/tag-sets.js";import{curationKeywordsOf as x}from"../search/keywords.js";import{findProductForSlug as S}from"../../shared/products.js";import{createMarkdownCopyRule as C}from"../markdown-copy-rule.js";import{createProblem as w}from"../problems/codes.js";import{problemRow as T,replaceEntityProblemsForCodesBatchTx as E}from"../database/problems.js";import"../search/postings/postings-store.js";import{createSearchStore as D}from"../search/store.js";import{replaceEntityRouteQueryDepsTx as O}from"../database/route-query-deps.js";import{SEARCH_PROBLEM_CODES as k,searchFacetInvalidProblem as A,searchableFailedProblem as j}from"../problems/producers.js";import{loadAttachedRouteSlugs as M}from"../database/route-deps.js";import{toRbacTeams as N,toRbacTeamsWithinRoute as P}from"./rbac-teams.js";import{buildDocumentFacets as F}from"../search/facet-rows.js";import{createHookEntityStore as I}from"./hook-inputs.js";import{and as L,eq as R,inArray as z}from"drizzle-orm";function B(t,n,r,i){let a=[...t].sort(),o=n.map(e=>[e.name,e.slug]);return(t,n)=>{let s=[2,t,a,o,r];return n&&i!==void 0&&s.push(i),e(s)}}async function V(e){let{context:t,database:n}=e,r=t.logger.child(`content-layer:search`),a=[],o=/* @__PURE__ */ new Map,s=new Map(t.pluginRegistry.listEntityLoaders().filter(e=>e.definition.searchable!==void 0||e.definition.markdown!==void 0).map(e=>[e.definition.id,e])),c=e.inlineSearchables??/* @__PURE__ */ new Map,l=e.entityKeys===void 0?void 0:[...e.entityKeys,...c.keys()],u=await re(n,l);if(s.size===0&&c.size===0&&u.size===0)return{synced:0,problems:a};let{materializer:d}=e,{state:f}=d,m=D(n),h=g(f,t.config),_=y(t.config),v=ee(f,h,_),x=v(),S=te(t),w=C(t.config),E=B(S,_,w.settings,b()),O=ne(r,{configuredFields:S}),A=0,N=(e,t)=>{a.push(...t),o.set(e,t.map(t=>T(t,{scope:`entity`,entityId:e})))},P=(e,t,n,i)=>{let s=i instanceof Error?i.message:String(i);r.warn(`searchable failed for "${t}"; keeping its last documents: ${s}`);let c=j({entityKey:t,pluginId:n,message:s});a.push(c),o.set(e,[T(c,{scope:`entity`,entityId:e})])},F=async()=>(await H(n,o,k,r),{synced:A,problems:a});l===void 0&&await G({context:t,database:n,state:f,store:m,stored:u,searchableLoaders:s});let I=[];for(let[e,n]of c){let i=f.entitiesByKey.get(e);if(i&&i.kind===`inline`){if(n===void 0){u.has(e)&&await m.removeSource(e);continue}try{let a=await O.prepare(e,n.docs,x);I.push({entityKey:e,docs:a.docs,...Y(e,n,a.docs),sourceHash:E(i.dataHash??``,!1),pluginVersion:t.pluginRegistry.getById(i.pluginId)?.version??``}),N(i.id,[...W(e,n.problems,r),...a.problems])}catch(t){P(i.id,e,i.pluginId,t)}}}if(await m.replaceSourceDocuments(I),A+=I.length,s.size===0)return F();let L=await ie(n,[...s.keys()],e.entityKeys),R=await ae(n,h,L.map(e=>e.id)),z=L.filter(e=>{let n=s.get(e.loaderId),r=n?t.pluginRegistry.getById(n.pluginId)?.version:void 0,i=u.get(e.key);return i===void 0||i.sourceHash!==E(e.dataHash??``,n?.definition.usesProjectMarkdocSchema===!0)||i.pluginVersion!==r||R.has(e.id)});if(z.length===0)return F();let V=await M(n,z.map(e=>e.key)),q=0,X=0,Z=0,Q=0,$=0;for(let r of p(z,50)){q+=1;let i=Date.now(),a=await J(n,r);Z+=Date.now()-i,i=Date.now();let o=[];for(let i of r){let r=s.get(i.loaderId);if(r){try{let e=await K({row:i,entry:r,value:a.get(i.id),attachedSlug:V.get(i.key),context:t,database:n,materializer:d,evaluator:h,resolveAccess:v,prepare:O.prepare,stampOf:E,allowsMarkdownCopy:w.allows});o.push(e),N(i.id,e.problems)}catch(e){P(i.id,i.key,r.pluginId,e)}X+=1,e.onProgress?.(X,z.length)}}Q+=Date.now()-i,i=Date.now(),await U({context:t,database:n,store:m,outputs:o}),$+=Date.now()-i,A+=o.length}return l===void 0&&r.info(`Synced ${z.length} content ${z.length===1?`item`:`items`} for search in ${q} ${q===1?`chunk`:`chunks`} (load ${i(Z)}, producers ${i(Q)}, writes ${i($)})`),F()}async function H(e,t,n,r){if(t.size!==0)try{await e.db.transaction(e=>E(e,t,n))}catch(e){r.warn(`could not store the search problems of this pass`,{error:e instanceof Error?e.message:String(e)})}}async function U(e){let{context:t,outputs:n}=e;n.length!==0&&await e.database.db.transaction(async i=>{await e.store.replaceSourceDocuments(n.map(e=>({entityKey:e.row.key,docs:e.docs,fragments:e.fragments,uses:e.uses,sourceHash:e.sourceHash,pluginVersion:t.pluginRegistry.getById(e.entry.pluginId)?.version??``})),i),await O(i,{hook:`searchable`,scopes:n.map(e=>({originPluginId:e.entry.pluginId,entityId:e.row.id,dependencies:_(e.reads)}))});for(let e of n){if(await i.delete(c).where(R(c.entityKey,e.row.key)),e.markdownDocs.length===0)continue;let n=t.pluginRegistry.getById(e.entry.pluginId)?.version??``;for(let t of e.markdownDocs){let a=await Promise.all(t.chunks.map(async(i,a)=>{let o=t.headings?.[a]??null;return{entityKey:e.row.key,chunkIndex:a,routeSlug:t.routeSlug,text:i,heading:o?.heading??null,anchor:o?.anchor??null,title:t.title??null,description:t.description??null,rbacTeams:t.rbacTeams,hash:await r(new TextEncoder().encode(i)),sourceHash:e.sourceHash,pluginVersion:n}}));await i.insert(c).values(a)}}})}function W(e,t,n){let r=[],i=/* @__PURE__ */ new Set;for(let e of t??[])k.includes(e.code)?r.push(w(e)):i.add(e.code);for(let t of i)n.warn(`searchable for "${e}" reported problem code "${t}", which the search sync does not own; use one of ${k.join(`, `)}`);return r}async function G(e){for(let t of e.stored.keys()){let n=e.state.entitiesByKey.get(t);n&&(e.context.pluginRegistry.getById(n.pluginId)===void 0||n.kind!==`inline`&&(n.loaderId===null||!e.searchableLoaders.has(n.loaderId)))&&(await e.store.removeSource(t),await e.database.db.delete(c).where(R(c.entityKey,t)))}}async function K(e){let{row:t,entry:n,database:r}=e,i=n.definition.searchable,a=n.definition.markdown,o=e.value;if(!o||o.data===null||o.dataHash===null)throw Error(`Entity "${t.key}" has no stored value.`);let s=e.stampOf(o.dataHash,n.definition.usesProjectMarkdocSchema),c=await f(o.data,e=>h(r,e)),l=[],u=e=>l.push(e),d=e.evaluator.index(u),p=e.attachedSlug===void 0?void 0:d.get(e.attachedSlug),m=e.resolveAccess(u),g={config:e.context.config,entities:I(r,e.materializer,u),logger:e.context.logger.child(`content-layer:searchable:${n.definition.id}`),routes:d,route:p},_=i?await i(c,g):{docs:[]},v=a&&e.allowsMarkdownCopy(p)?await a(c,g):null,y=q(t.key,v,e.attachedSlug).map(e=>Object.assign(e,{rbacTeams:m.rbacTeamsForSlug(e.routeSlug)})),b=await e.prepare(t.key,_.docs??[],m);return{row:t,entry:n,docs:b.docs,...Y(t.key,_,b.docs),markdownDocs:y,sourceHash:s,reads:l,problems:[...W(t.key,_.problems,e.context.logger),...b.problems]}}function q(e,t,n){if(t===null)return[];if(!Array.isArray(t))throw Error(`markdown for "${e}" must return an array or null.`);let r=t.length>0&&typeof t[0]==`string`?[{chunks:t}]:t,i=/* @__PURE__ */ new Set,a=[];for(let t of r){let r=t.routeSlug??n;if(r!==void 0){if(!Array.isArray(t.chunks)||t.chunks.some(e=>typeof e!=`string`))throw Error(`markdown for "${e}" returned a document without string chunks.`);if(t.chunks.length!==0){if(i.has(r))throw Error(`markdown for "${e}" returned "${r}" twice.`);i.add(r),a.push({routeSlug:r,chunks:t.chunks,headings:t.headings,...typeof t.title==`string`&&t.title!==``?{title:t.title}:{},...typeof t.description==`string`&&t.description!==``?{description:t.description}:{}})}}}return a}async function J(e,t){let n=await e.db.select({id:s.id,data:s.data,dataHash:s.dataHash}).from(s).where(z(s.id,t.map(e=>e.id)));return new Map(n.map(e=>[e.id,e]))}function ee(e,t,n){let r=[...e.routeBySlug.values()].filter(e=>e.wildcardPrefix),i=t=>{if(e.routeBySlug.has(t))return t;let n=new Set(d(t)),i;for(let e of r)n.has(e.slug)&&(i===void 0||e.slug.length>i.length)&&(i=e.slug);return i};return r=>{let a=t.index(r),o=e=>a.getAccess(i(e)??e),s=t=>e.routeBySlug.get(i(t)??t);return{accessForSlug:o,rbacTeamsForSlug:e=>N(o(e)),localeForSlug:e=>s(e)?.locale??``,originFilePathForSlug:e=>s(e)?.originFilePath??null,versionForSlug:e=>{let t=s(e);return t?.versionGroup!=null&&t.version!=null?{group:t.versionGroup,version:t.version}:null},productForSlug:e=>{let t=s(e),r=t?t.canonicalSlug||t.slug:e;return S(n,r)}}}}function te(e){return new Set(n(e.config).map(e=>e.field).filter(e=>e!==t))}function Y(e,t,n){let r=t.fragments??[],i=t.uses??[];if(!Array.isArray(r)||!Array.isArray(i))throw Error(`searchable for "${e}" must return fragments and uses as arrays.`);for(let t of r)if(typeof t.fragmentKey!=`string`||typeof t.name!=`string`)throw Error(`searchable for "${e}" returned a fragment without a key or name.`);let a=new Set(n.map(e=>e.docKey));return{fragments:r,uses:i.filter(e=>a.has(e.docKey))}}function ne(e,t){return{async prepare(n,r,i){if(!Array.isArray(r))throw Error(`searchable for "${n}" must return { docs: SearchDocument[] }.`);let a=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Set,c=[],l=[];for(let u of r){if(Z(n,u),a.has(u.docKey))throw Error(`searchable for "${n}" returned docKey "${u.docKey}" twice.`);a.add(u.docKey);let r=o(u.routeSlug),d=i.accessForSlug(r);if(d===void 0){e.warn(`search document "${u.docKey}" of "${n}" dropped: no route "${r}"`);continue}let{facets:f,rbacScope:p,keywords:m,...h}=u,g=i.productForSlug(r),_=i.versionForSlug(r),v=F({facets:f,configuredFields:t.configuredFields,groupKey:u.groupKey,teams:P(d,p),version:_,product:g?.name??null,keywords:x(m),onDropped:(e,t)=>{let a=`${e}\u0000${t}`;s.has(a)||(s.add(a),c.push(A({entityKey:n,field:e,reason:X[t],filePath:i.originFilePathForSlug(r)})))}}),y={...h,routeSlug:r,locale:i.localeForSlug(r),facets:v};g&&(y.product={name:g.name,folder:g.folder}),_&&(y.version=_),l.push(y)}return{docs:l,problems:c}}}}const X={"not-an-object":`facets must be an object of field to string or string list`,reserved:`fields starting with "redocly_" are derived by the engine`,invalid:`a value must be a string, number, boolean, or a list of those`,"too-long":`a value must be at most 500 characters`,"too-many-words":`a keyword must have at most 10 words`};function Z(e,t){let n=t;if(!(typeof n==`object`&&n&&typeof n.docKey==`string`&&n.docKey!==``&&typeof n.routeSlug==`string`&&typeof n.title==`string`&&typeof n.text==`string`))throw Error(`searchable for "${e}" returned an invalid document (docKey, routeSlug, title, text are required strings).`);if(n.rbacScope!==void 0&&!a(n.rbacScope))throw Error(`searchable for "${e}" returned document "${n.docKey}" with an invalid rbacScope.`)}async function re(e,t){let n=/* @__PURE__ */ new Map;for(let r of t===void 0?[void 0]:p(t,m(void 0))){let t=await e.db.selectDistinct({entityKey:u.entityKey,sourceHash:u.sourceHash,pluginVersion:u.pluginVersion}).from(u).where(r===void 0?void 0:z(u.entityKey,[...r]));for(let{entityKey:e,...r}of t)n.set(e,r);let i=await e.db.selectDistinct({entityKey:c.entityKey,sourceHash:c.sourceHash,pluginVersion:c.pluginVersion}).from(c).where(r===void 0?void 0:z(c.entityKey,[...r]));for(let{entityKey:e,...t}of i)n.has(e)||n.set(e,t)}return n}async function ie(e,t,n){return n!==void 0&&n.length===0?[]:(await e.db.select({id:s.id,key:s.key,loaderId:s.loaderId,dataHash:s.dataHash}).from(s).where(L(R(s.status,`ready`),R(s.isCurrent,1),z(s.loaderId,[...t]),n===void 0?void 0:z(s.key,[...n]))).orderBy(s.key)).filter(e=>e.loaderId!==null)}async function ae(e,t,n){let r=/* @__PURE__ */ new Set;if(n.length===0)return r;let i=new Set(n),a=n.length<=m(void 0),o=await e.db.select({entityId:l.entityId,kind:l.kind,argument:l.argument,resultHash:l.resultHash}).from(l).where(L(R(l.hook,`searchable`),a?z(l.entityId,[...n]):void 0));for(let e of o)e.entityId!==null&&i.has(e.entityId)&&!r.has(e.entityId)&&v(t,e)&&r.add(e.entityId);return r}function Q(e,t){for(let n of e)n.kind===`inline`&&t.set(n.key,n.searchable)}export{Q as collectInlineSearchables,V as runSearchSync};
@@ -1 +1 @@
1
- import{normalizeRouteSlug as e}from"../../../shared/utils/routes/normalize-route-slug.js";import{SYSTEM_ROUTES as t}from"../../../server/constants/system-routes.js";import{toSlugCollisionProblems as n,toWildcardShadowProblems as r}from"../../problems/producers.js";import{resolveSlugsAndHandleCollisions as i}from"./resolve-slugs-and-handle-collisions.js";const a=new Set(t.map(e));function o(e){return/* @__PURE__ */ new Set([...a,...e?.keys()??[]])}function s(e){let t=[...e.state.routesByOriginKey.values()].flat(),o=new Map([...a].map(e=>[e,null]));for(let[t,n]of e.reservedSlugs??[])o.has(t)||o.set(t,n);let{collisions:s,resolved:u,warnings:d}=i(t,o);for(let t of s)e.logger.debug(`Route slug collision — dev serves the first processed member`,{slug:t.slug,kind:t.kind,members:t.members.map(e=>`${e.originFilePath} (${e.originPluginId})`)});let f=new Set(d.map(c));l({warnings:d,previousShadowKeys:e.previousWildcardShadows,logger:e.logger});let p=new Map(s.map(e=>[e.slug,e]));return{collisions:p,routeBySlug:new Map(u.map(e=>[e.slug,e.candidate])),wildcardShadows:f,problems:[...n(p),...r(d)]}}function c(e){return`${e.slug} ${e.paths[1]??``}`}function l(e){for(let t of e.warnings)e.previousShadowKeys.has(c(t))||e.logger.debug(`Route slug conflict`,t)}export{a as SYSTEM_SLUGS,o as allReservedSlugs,s as resolveFinalSlugs};
1
+ import{normalizeRouteSlug as e}from"../../../shared/utils/routes/normalize-route-slug.js";import{SYSTEM_ROUTES as t}from"../../../shared/constants/system-routes.js";import{toSlugCollisionProblems as n,toWildcardShadowProblems as r}from"../../problems/producers.js";import{resolveSlugsAndHandleCollisions as i}from"./resolve-slugs-and-handle-collisions.js";const a=new Set(t.map(e));function o(e){return/* @__PURE__ */ new Set([...a,...e?.keys()??[]])}function s(e){let t=[...e.state.routesByOriginKey.values()].flat(),o=new Map([...a].map(e=>[e,null]));for(let[t,n]of e.reservedSlugs??[])o.has(t)||o.set(t,n);let{collisions:s,resolved:u,warnings:d}=i(t,o);for(let t of s)e.logger.debug(`Route slug collision — dev serves the first processed member`,{slug:t.slug,kind:t.kind,members:t.members.map(e=>`${e.originFilePath} (${e.originPluginId})`)});let f=new Set(d.map(c));l({warnings:d,previousShadowKeys:e.previousWildcardShadows,logger:e.logger});let p=new Map(s.map(e=>[e.slug,e]));return{collisions:p,routeBySlug:new Map(u.map(e=>[e.slug,e.candidate])),wildcardShadows:f,problems:[...n(p),...r(d)]}}function c(e){return`${e.slug} ${e.paths[1]??``}`}function l(e){for(let t of e.warnings)e.previousShadowKeys.has(c(t))||e.logger.debug(`Route slug conflict`,t)}export{a as SYSTEM_SLUGS,o as allReservedSlugs,s as resolveFinalSlugs};
@@ -1 +1 @@
1
- import{L10N_DIR as e}from"../../shared/constants/l10n/defaults.js";import{resolveContentPluginsForFile as t}from"../plugins/registry.js";import{hashContentConfigDependency as n}from"../config-deps.js";import{extractFileContributions as r}from"../plugins/execute.js";import{createSourceFile as i}from"../plugins/source-file.js";import{createContentOriginKey as a}from"../plugins/utils/origin-key.js";import{L10N_PLUGIN_ID as o}from"../plugins/internal/l10n/translations-loader.js";import"../plugins/internal/l10n/index.js";import"../plugins/index.js";import{createProblem as s}from"../problems/codes.js";import{garbageCollectOrphanedEntities as c,propagateRouteQueryInvalidation as l}from"../database/invalidation.js";import{problemRow as u}from"../database/problems.js";import{loadFileManifestsByPaths as d}from"../database/files.js";import{loadContentLayerState as f,reloadContentLayerEntities as p}from"../context-state.js";import{bulkSyncOrigins as m}from"../database/origins.js";import{extractFailedProblem as h,sluggerProblemSources as ee}from"../problems/producers.js";import{finalizeHookInputs as g,hasAnyPluginHookTrigger as _}from"./hook-inputs.js";import{collectInlineSearchables as v}from"./search-sync.js";import{resolveRevisionsConfig as y}from"../revisions/config.js";import{dropCollidingRoutes as b}from"./slugger/drop-colliding-routes.js";import{allReservedSlugs as te,resolveFinalSlugs as x}from"./slugger/resolve-final-slugs.js";import{normalizePluginArtifacts as S}from"./normalize-artifacts.js";import{runFinalizePhase as C}from"./finalize-phase.js";import{applyOriginRoutesToWorkingState as w,cloneContentLayerState as T,removeFileFromWorkingState as ne,removeOriginFromWorkingState as E}from"./working-state.js";import{dropCollidingExtractAllRoutes as D,runExtractAllPhase as O}from"./extract-all-phase.js";import{diffFallbackRoutes as k,generateFallbackRoutes as A}from"./generate-fallback-routes.js";async function j(n){let s=await f({context:n.context,database:n.database}),l=T(s);for(let e of n.removedPaths)ne(l,e);if(n.files.length===0&&n.removedPaths.size===0&&![`extractAll`,`finalize`].some(e=>_(e,n.context,s,n.pluginScopedOriginRows,n.routeQueryRows,n.hookState,e===`finalize`?g(n.localeContext):void 0)))return await P(n,l),n.context.state=l,{inlineSearchables:/* @__PURE__ */ new Map,routeChanges:{changedSlugs:[],unbounded:!1}};let h=n.context.logger.child(`content-layer:sync`),{localeContext:S}=n,j=I(n.context.config,`/l10n`),M=I(n.context.config,`/metadataGlobs`),N=await O({context:n.context,database:n.database,workingState:l,files:n.files,originRows:n.pluginScopedOriginRows,routeQueryRows:n.routeQueryRows,hookState:n.hookState,logger:n.context.logger.child(`content-layer:extractAll`)}),F=n.context.logger.child(`content-layer:plugin`),R=y(n.context.config),z=n.files.filter(e=>e.manifest===void 0).map(e=>e.path),B=await d(n.database,z),V=n.context.pluginRegistry.list().map(e=>e.id);E(l,V,o,null);let H=[],U=`${e}/`,W=n.files.map(e=>({file:e,localized:Number(e.path.startsWith(U))})).sort((e,t)=>e.localized-t.localized).map(e=>e.file);for(let[e,a]of W.entries()){let o=l.filesByPath.get(a.path)??l.ignoredFilesByPath.get(a.path);if(!o)throw Error(`Missing stored file state for "${a.path}".`);let s=t(n.context,a.path),c=(l.filePluginsByPath.get(a.path)??[]).map(e=>e.pluginId).filter(e=>!s.some(t=>t.id===e)),u=[];for(let e of c)E(l,V,e,a.path),u.push({hook:`extract`,originDependencies:[],originFileId:o.id,originFilePath:a.path,originPluginId:e,routeDependencies:[],routes:[],entities:[],problems:[]});for(let e of s)E(l,V,e.id,a.path);let d=i({path:a.path,hash:a.hash,manifest:a.manifest??B.get(a.path)??{}}),f=await r(s,d,{config:n.context.config,fs:n.context.platform.fs,contentDir:n.context.contentDir,scannedPaths:()=>l.filesByPath.keys(),logger:F});for(let e of f)L({context:n.context,workingState:l,allPluginIds:V,filePath:a.path,fileRecord:o,attempt:e,origins:u,revisions:R,localeContext:S,l10nConfigDependency:j,metadataGlobsConfigDependency:M,pluginLogger:F});let p=s.map(e=>({id:e.id,version:e.version}));H.push({fileId:o.id,filePath:a.path,plugins:p,origins:u}),l.filePluginsByPath.set(a.path,p.map(e=>({fileId:o.id,pluginId:e.id,pluginVersion:e.version}))),n.onFileSynced?.(e+1,W.length)}let G=n.context.pluginRegistry.listReservedSlugs(),{collisions:K,routeBySlug:q,wildcardShadows:J,problems:Y}=x({state:l,previousWildcardShadows:s.wildcardShadows,reservedSlugs:G,logger:h});l.wildcardShadows=J,l.routeBySlug=q;let ie=/* @__PURE__ */ new Set([...n.files.map(e=>e.path),...n.removedPaths,...N.pending.map(e=>e.pluginId),...N.failures.map(e=>e.pluginId)]),X=new Set(Y.map(e=>e.key));for(let e of n.storedSluggerProblems){if(e.key===null)continue;let t=ee(e.data);t.length>0&&t.every(e=>ie.has(e))&&X.add(e.key)}b({state:l,bulkItems:H,collisions:K,allPluginIds:V}),D(N.pending,K);let Z=A({state:l,localeContext:S,reservedSlugs:te(G)}),ae=k(s.routesByOriginKey.get(a(`internal.l10n`,null))??[],Z);w(l,V,o,null,Z);let Q=/* @__PURE__ */ new Map;for(let e of H)for(let t of e.origins)v(t.entities,Q);for(let e of N.pending)v(e.entities,Q);let $=/* @__PURE__ */ new Set;if(R){for(let e of H)if(R.isTracked(e.filePath))for(let t of e.origins)for(let e of t.entities)$.add(e.key)}await m(n.database,H,{logger:F,revisions:R?{max:R.max,trackedKeys:$,capture:n.captureRevisions===!0}:void 0,extractAllOrigins:N.pending.map(e=>({hook:`extractAll`,originFileId:null,originFilePath:null,originPluginId:e.pluginId,originDependencies:e.originDependencies,routeDependencies:e.routeDependencies,routes:e.routes,entities:e.entities,problems:[],fingerprint:e.inputsHash,routeQueries:e.routeQueries})),extractAllFailures:N.failures,globalProblems:{source:`slugger`,keys:[...X],newProblems:Y.map(e=>u(e.problem,{scope:`global`,source:`slugger`,key:e.key}))},fallbackRoutes:{pluginId:o,...ae}}),await p({state:l,database:n.database}),await P(n,l);let oe=await C({context:n.context,database:n.database,localeContext:S,workingState:l,files:n.files,pluginScopedOriginRows:n.pluginScopedOriginRows,routeQueryRows:n.routeQueryRows,hookState:n.hookState,logger:n.context.logger.child(`content-layer:finalize`),collectEntities:e=>v(e,Q)}),se=await c(n.database);return(oe.ranPluginIds.length>0||se.removedOrphans)&&await p({state:l,database:n.database}),n.context.state=l,{inlineSearchables:Q,routeChanges:re(s.routeBySlug,l.routeBySlug)}}function re(e,t){let n=[];for(let[r,i]of e){let e=t.get(r);(e===void 0||e.originFilePath!==i.originFilePath)&&n.push(r)}for(let r of t.keys())e.has(r)||n.push(r);return{changedSlugs:n,unbounded:!M(e,t)}}function M(e,t){let n=N(e),r=N(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function N(e){let t=/* @__PURE__ */ new Set;for(let[n,r]of e)r.wildcardPrefix&&t.add(n);return t}async function P(e,t){let{invalidatedKeys:n}=await l(e.database,{rows:e.routeQueryRows,state:t,config:e.context.config,logger:e.context.logger.child(`content-layer:db`)});for(let e of n){let n=t.entitiesByKey.get(e);n&&(n.status=`stale`)}}function F(e){return[...e.configDependencies.map(e=>({...e,source:`config`})),...e.fileDependencies]}function I(e,t){return{source:`config`,accessType:`value`,path:t,valueHash:n(e,{accessType:`value`,path:t})}}function L(e){let{context:t,workingState:n,allPluginIds:r,filePath:i,fileRecord:o,attempt:c}=e,l=c.result.ok?c.result.value:null,u=e.localeContext.isL10nPath(i)?[...F(c),e.l10nConfigDependency]:F(c);if(!l){e.origins.push({hook:`extract`,originDependencies:u,originFileId:o.id,originFilePath:i,originPluginId:c.plugin.id,routeDependencies:[],routes:[],entities:[],problems:c.result.ok?[]:[h({filePath:i,pluginId:c.plugin.id,message:c.result.error.message})]});return}let d=S({context:t,filePath:i,pluginId:c.plugin.id,revisions:e.revisions,routeDrafts:l.routes,standaloneEntities:l.entities??[],localeContext:e.localeContext,resolveCanonicalRoute:(e,t)=>n.routesByOriginKey.get(a(c.plugin.id,e))?.find(e=>e.routeId===t)});w(n,r,c.plugin.id,i,d.routes),e.origins.push({hook:`extract`,originDependencies:d.routes.length>0?[...u,e.metadataGlobsConfigDependency]:u,originFileId:o.id,originFilePath:i,originPluginId:c.plugin.id,routeDependencies:d.routeDependencies,routes:d.routes,entities:d.entities,problems:(l.problems??[]).map(e=>s({...e,location:e.location??{filePath:i}})),linkRefs:l.linkRefs})}export{j as syncContentFiles};
1
+ import{L10N_DIR as e}from"../../shared/constants/l10n/defaults.js";import{resolveContentPluginsForFile as t}from"../plugins/registry.js";import{hashContentConfigDependency as n}from"../config-deps.js";import{extractFileContributions as r}from"../plugins/execute.js";import{createSourceFile as i}from"../plugins/source-file.js";import{createContentOriginKey as a}from"../plugins/utils/origin-key.js";import{L10N_PLUGIN_ID as o}from"../plugins/internal/l10n/translations-loader.js";import"../plugins/internal/l10n/index.js";import"../plugins/index.js";import{createProblem as s}from"../problems/codes.js";import{garbageCollectOrphanedEntities as c,propagateRouteQueryInvalidation as l}from"../database/invalidation.js";import{problemRow as u}from"../database/problems.js";import{loadFileManifestsByPaths as d}from"../database/files.js";import{loadContentLayerState as f,reloadContentLayerEntities as p}from"../context-state.js";import{resolveRevisionsConfig as m}from"../revisions/config.js";import{bulkSyncOrigins as ee}from"../database/origins.js";import{extractFailedProblem as h,sluggerProblemSources as g}from"../problems/producers.js";import{createEntityMaterializer as _}from"../materialization/materializer.js";import{finalizeHookInputs as te,hasAnyPluginHookTrigger as ne}from"./hook-inputs.js";import{collectInlineSearchables as v}from"./search-sync.js";import{dropCollidingRoutes as y}from"./slugger/drop-colliding-routes.js";import{allReservedSlugs as b,resolveFinalSlugs as x}from"./slugger/resolve-final-slugs.js";import{normalizePluginArtifacts as S}from"./normalize-artifacts.js";import{runFinalizePhase as C}from"./finalize-phase.js";import{applyOriginRoutesToWorkingState as w,cloneContentLayerState as T,removeFileFromWorkingState as E,removeOriginFromWorkingState as D}from"./working-state.js";import{dropCollidingExtractAllRoutes as O,runExtractAllPhase as k}from"./extract-all-phase.js";import{diffFallbackRoutes as re,generateFallbackRoutes as ie}from"./generate-fallback-routes.js";async function A(n){let s=await f({context:n.context,database:n.database}),l=T(s);for(let e of n.removedPaths)E(l,e);if(n.files.length===0&&n.removedPaths.size===0&&![`extractAll`,`finalize`].some(e=>ne(e,n.context,s,n.pluginScopedOriginRows,n.routeQueryRows,n.hookState,e===`finalize`?te(n.localeContext):void 0)))return await N(n,l),{state:l,inlineSearchables:/* @__PURE__ */ new Map,routeChanges:{changedSlugs:[],unbounded:!1}};let h=n.context.logger.child(`content-layer:sync`),{localeContext:S}=n,A=F(n.context.config,`/l10n`),j=F(n.context.config,`/metadataGlobs`),M=m(n.context.config),P=n.revisions,L=()=>_({deps:{...n.context,state:l},database:n.database,revisions:P}),R=await k({context:n.context,database:n.database,materializer:L(),files:n.files,originRows:n.pluginScopedOriginRows,routeQueryRows:n.routeQueryRows,hookState:n.hookState,logger:n.context.logger.child(`content-layer:extractAll`)}),z=n.context.logger.child(`content-layer:plugin`),B=n.files.filter(e=>e.manifest===void 0).map(e=>e.path),V=await d(n.database,B),H=n.context.pluginRegistry.list().map(e=>e.id);D(l,H,o,null);let U=[],W=`${e}/`,G=n.files.map(e=>({file:e,localized:Number(e.path.startsWith(W))})).sort((e,t)=>e.localized-t.localized).map(e=>e.file);for(let[e,a]of G.entries()){let o=l.filesByPath.get(a.path)??l.ignoredFilesByPath.get(a.path);if(!o)throw Error(`Missing stored file state for "${a.path}".`);let s=t(n.context,a.path),c=(l.filePluginsByPath.get(a.path)??[]).map(e=>e.pluginId).filter(e=>!s.some(t=>t.id===e)),u=[];for(let e of c)D(l,H,e,a.path),u.push({hook:`extract`,originDependencies:[],originFileId:o.id,originFilePath:a.path,originPluginId:e,routeDependencies:[],routes:[],entities:[],problems:[]});for(let e of s)D(l,H,e.id,a.path);let d=i({path:a.path,hash:a.hash,manifest:a.manifest??V.get(a.path)??{}}),f=await r(s,d,{config:n.context.config,fs:n.context.platform.fs,contentDir:n.context.contentDir,scannedPaths:()=>l.filesByPath.keys(),logger:z});for(let e of f)I({context:n.context,workingState:l,allPluginIds:H,filePath:a.path,fileRecord:o,attempt:e,origins:u,revisions:M,localeContext:S,l10nConfigDependency:A,metadataGlobsConfigDependency:j,pluginLogger:z});let p=s.map(e=>({id:e.id,version:e.version}));U.push({fileId:o.id,filePath:a.path,plugins:p,origins:u}),l.filePluginsByPath.set(a.path,p.map(e=>({fileId:o.id,pluginId:e.id,pluginVersion:e.version}))),n.onFileSynced?.(e+1,G.length)}let K=n.context.pluginRegistry.listReservedSlugs(),{collisions:q,routeBySlug:oe,wildcardShadows:se,problems:J}=x({state:l,previousWildcardShadows:s.wildcardShadows,reservedSlugs:K,logger:h});l.wildcardShadows=se,l.routeBySlug=oe;let ce=/* @__PURE__ */ new Set([...n.files.map(e=>e.path),...n.removedPaths,...R.pending.map(e=>e.pluginId),...R.failures.map(e=>e.pluginId)]),Y=new Set(J.map(e=>e.key));for(let e of n.storedSluggerProblems){if(e.key===null)continue;let t=g(e.data);t.length>0&&t.every(e=>ce.has(e))&&Y.add(e.key)}y({state:l,bulkItems:U,collisions:q,allPluginIds:H}),O(R.pending,q);let X=ie({state:l,localeContext:S,reservedSlugs:b(K)}),le=re(s.routesByOriginKey.get(a(`internal.l10n`,null))??[],X);w(l,H,o,null,X);let Z=/* @__PURE__ */ new Map;for(let e of U)for(let t of e.origins)v(t.entities,Z);for(let e of R.pending)v(e.entities,Z);let Q=/* @__PURE__ */ new Set;if(P){for(let e of U)if(P.isTracked(e.filePath))for(let t of e.origins)for(let e of t.entities)Q.add(e.key)}await ee(n.database,U,{logger:z,revisions:P?{max:P.max,trackedKeys:Q}:void 0,extractAllOrigins:R.pending.map(e=>({hook:`extractAll`,originFileId:null,originFilePath:null,originPluginId:e.pluginId,originDependencies:e.originDependencies,routeDependencies:e.routeDependencies,routes:e.routes,entities:e.entities,problems:[],fingerprint:e.inputsHash,routeQueries:e.routeQueries})),extractAllFailures:R.failures,globalProblems:{source:`slugger`,keys:[...Y],newProblems:J.map(e=>u(e.problem,{scope:`global`,source:`slugger`,key:e.key}))},fallbackRoutes:{pluginId:o,...le}}),await p({state:l,database:n.database}),await N(n,l);let $=await C({context:n.context,database:n.database,localeContext:S,materializer:L(),files:n.files,pluginScopedOriginRows:n.pluginScopedOriginRows,routeQueryRows:n.routeQueryRows,hookState:n.hookState,logger:n.context.logger.child(`content-layer:finalize`),collectEntities:e=>v(e,Z)}),ue=await c(n.database);return($.ranPluginIds.length>0||ue.removedOrphans)&&await p({state:l,database:n.database}),{state:l,inlineSearchables:Z,routeChanges:ae(s.routeBySlug,l.routeBySlug)}}function ae(e,t){let n=[];for(let[r,i]of e){let e=t.get(r);(e===void 0||e.originFilePath!==i.originFilePath)&&n.push(r)}for(let r of t.keys())e.has(r)||n.push(r);return{changedSlugs:n,unbounded:!j(e,t)}}function j(e,t){let n=M(e),r=M(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function M(e){let t=/* @__PURE__ */ new Set;for(let[n,r]of e)r.wildcardPrefix&&t.add(n);return t}async function N(e,t){let{invalidatedKeys:n}=await l(e.database,{rows:e.routeQueryRows,state:t,config:e.context.config,logger:e.context.logger.child(`content-layer:db`)});for(let e of n){let n=t.entitiesByKey.get(e);n&&(n.status=`stale`)}}function P(e){return[...e.configDependencies.map(e=>({...e,source:`config`})),...e.fileDependencies]}function F(e,t){return{source:`config`,accessType:`value`,path:t,valueHash:n(e,{accessType:`value`,path:t})}}function I(e){let{context:t,workingState:n,allPluginIds:r,filePath:i,fileRecord:o,attempt:c}=e,l=c.result.ok?c.result.value:null,u=e.localeContext.isL10nPath(i)?[...P(c),e.l10nConfigDependency]:P(c);if(!l){e.origins.push({hook:`extract`,originDependencies:u,originFileId:o.id,originFilePath:i,originPluginId:c.plugin.id,routeDependencies:[],routes:[],entities:[],problems:c.result.ok?[]:[h({filePath:i,pluginId:c.plugin.id,message:c.result.error.message})]});return}let d=S({context:t,filePath:i,pluginId:c.plugin.id,revisions:e.revisions,routeDrafts:l.routes,standaloneEntities:l.entities??[],localeContext:e.localeContext,resolveCanonicalRoute:(e,t)=>n.routesByOriginKey.get(a(c.plugin.id,e))?.find(e=>e.routeId===t)});w(n,r,c.plugin.id,i,d.routes),e.origins.push({hook:`extract`,originDependencies:d.routes.length>0?[...u,e.metadataGlobsConfigDependency]:u,originFileId:o.id,originFilePath:i,originPluginId:c.plugin.id,routeDependencies:d.routeDependencies,routes:d.routes,entities:d.entities,problems:(l.problems??[]).map(e=>s({...e,location:e.location??{filePath:i}})),linkRefs:l.linkRefs})}export{A as syncContentFiles};
@@ -1 +1 @@
1
- import{collectL10nDirLocales as e,resolveLocaleContext as t}from"../../shared/utils/l10n.js";import{toPublicVersionedSlug as n}from"../../shared/constants/versions.js";import{files as r,routes as i,staticFiles as a,targetInventories as o}from"../database/schema.js";import{getVersionCatalog as s}from"../versions/resolve.js";import{buildLinkCheckView as c}from"./view.js";import{asc as l,eq as u}from"drizzle-orm";async function d(n){let{database:s}=n,[d,m,h,g]=await Promise.all([s.db.select({slug:i.slug,wildcardPrefix:i.wildcardPrefix,sourcePath:r.path,version:i.version,versionGroup:i.versionGroup}).from(i).leftJoin(r,u(i.sourceId,r.id)).orderBy(l(i.id)),s.db.select({filePath:r.path,kind:o.kind,exhaustive:o.exhaustive,targets:o.targets}).from(o).innerJoin(r,u(o.fileId,r.id)),s.db.select({path:r.path}).from(r),s.db.select({path:a.path}).from(a)]),_=h.map(e=>e.path),v=t(n.config.l10n,e(_));return c({routes:await p(s,d),filePaths:_,inventories:m,redirects:f(n.config),servedStaticPaths:g.map(e=>`/${e.path}`),localeContext:v,checkAnchors:n.config.linkChecker?.anchors?.hide!==!0})}function f(e){return Object.fromEntries(Object.entries(e.redirects??{}).map(([e,t])=>[e,t.to]))}async function p(e,t){let r=await s(e.db),i=new Set(t.map(e=>e.slug)),a=[];for(let e of t){if(!e.versionGroup||!e.version||(await r.groupInfo(e.versionGroup)).defaultVersion!==e.version)continue;let t=n(e.slug,e.versionGroup,e.version,!0);t!==e.slug&&!i.has(t)&&a.push({...e,slug:t})}return[...t,...a]}export{d as loadLinkCheckView};
1
+ import{collectL10nDirLocales as e,resolveLocaleContext as t}from"../../shared/utils/l10n.js";import{files as n,routes as r,staticFiles as i,targetInventories as a}from"../database/schema.js";import{toPublicVersionedSlug as o}from"../../shared/constants/versions.js";import{getVersionCatalog as s}from"../versions/resolve.js";import{buildLinkCheckView as c}from"./view.js";import{asc as l,eq as u}from"drizzle-orm";async function d(o){let{database:s}=o,[d,m,h,g]=await Promise.all([s.db.select({slug:r.slug,wildcardPrefix:r.wildcardPrefix,sourcePath:n.path,version:r.version,versionGroup:r.versionGroup}).from(r).leftJoin(n,u(r.sourceId,n.id)).orderBy(l(r.id)),s.db.select({filePath:n.path,kind:a.kind,exhaustive:a.exhaustive,targets:a.targets}).from(a).innerJoin(n,u(a.fileId,n.id)),s.db.select({path:n.path}).from(n),s.db.select({path:i.path}).from(i)]),_=h.map(e=>e.path),v=t(o.config.l10n,e(_));return c({routes:await p(s,d),filePaths:_,inventories:m,redirects:f(o.config),servedStaticPaths:g.map(e=>`/${e.path}`),localeContext:v,checkAnchors:o.config.linkChecker?.anchors?.hide!==!0})}function f(e){return Object.fromEntries(Object.entries(e.redirects??{}).map(([e,t])=>[e,t.to]))}async function p(e,t){let n=await s(e.db),r=new Set(t.map(e=>e.slug)),i=[];for(let e of t){if(!e.versionGroup||!e.version||(await n.groupInfo(e.versionGroup)).defaultVersion!==e.version)continue;let t=o(e.slug,e.versionGroup,e.version,!0);t!==e.slug&&!r.has(t)&&i.push({...e,slug:t})}return[...t,...i]}export{d as loadLinkCheckView};
@@ -1 +1 @@
1
- import{delocalizeL10nPath as e}from"../../shared/utils/l10n.js";import"../plugins/internal/api-docs/server/shared.js";import{filePathToRouteSlug as t}from"../../shared/utils/routes/file-path-to-route-slug.js";import{computePathPrefixes as n}from"../../shared/utils/routes/compute-path-prefixes.js";import{isIndexPagePath as r,resolveRelativeSlug as i}from"../../shared/utils/routes/resolve-relative-slug.js";import{splitHash as a}from"../markdown/resolve/references.js";import{inventoryKey as o}from"./view.js";import{posix as s}from"node:path";function c(e,t){let n=[];for(let r of e){let e=r.targetKind===`slug`?u(r,t):f(r,t);e!==null&&n.push({ref:r,problem:e})}return n}function l(t,n){let r=[t.target,t.filePath],i=[],a=e=>{t.raw.startsWith(`/`)?i.push(`/${e}`):s.extname(e)===``&&i.push(m(t,e,n))};a(t.target);let o=e(t.target);return o!==void 0&&(r.push(o),a(o)),{filePaths:r,slugs:i}}function u(e,t){let n=d(e,e.target,t);return n===void 0?S(e,e.target):n}function d(e,t,n){let r=n.routeBySlug.get(t);if(r!==void 0)return g(e,r.sourcePath,n,t);if(n.redirects.has(t)||v(t,n)||n.servedStaticPaths.has(t))return null;let i=y(t,n);if(i===null)return;let a=b(n,i.sourcePath,`subpath`);return x(a,i.remainder)&&x(a,i.remainder.toLowerCase())?S(e,t):null}function f(t,n){let r=p(t,t.target,n);if(r!==void 0)return r;let i=e(t.target);if(i!==void 0){let{locale:e}=n.localeContext.splitLocaleFromPath(t.target),r=p(t,i,n,e);if(r!==void 0)return r}return S(t,h(t.target,n))}function p(e,t,n,r){let i=n.primaryRouteByFilePath.get(t);if(i!==void 0)return g(e,t,n,r===void 0?i:n.localeContext.toL10nSlug(i,r));if(n.filePaths.has(t))return null;if(e.raw.startsWith(`/`))return d(e,`/${t}`,n);if(s.extname(t)===``)return e.originPluginId===`internal.api-docs`?null:d(e,m(e,t,n),n)}function m(e,n,o){let s=o.primaryRouteByFilePath.get(e.filePath);if(s===void 0)return t(n);let c=a(e.raw).path.split(`?`,1)[0]??``;return i(c,s,r(e.filePath))}function h(n,r){let i=e(n);if(i===void 0)return t(n);let{locale:a}=r.localeContext.splitLocaleFromPath(n);return r.localeContext.toL10nSlug(t(i),a)}function g(e,t,n,r){if(!n.checkAnchors||e.kind===`image`||e.fragment===null||e.fragment===``||t===null)return null;let i=_(e.fragment);if(i.toLowerCase()===`top`)return null;let a=b(n,t,`anchor`);return x(a,e.fragment)&&x(a,i)?C(e,r):null}function _(e){try{return decodeURIComponent(e)}catch{return e}}function v(e,t){return t.redirectWildcards.some(t=>t===`/`||e===t||e.startsWith(`${t}/`))}function y(e,t){let r=new Set(n(e));for(let n of t.wildcardSlugs){if(!r.has(n))continue;let i=t.routeBySlug.get(n),a=n===`/`?e:e.slice(n.length);return{sourcePath:i?.sourcePath??null,remainder:a.replace(/^\/+/,``)}}return null}function b(e,t,n){return t===null?void 0:e.inventories.get(o(t,n))}function x(e,t){return e!==void 0&&e.exhaustive&&!e.targets.has(t)}function S(e,t){return w(e,`link/missing-target`,e.targetKind===`slug`?`Route "${e.target}" does not exist.`:`"${E(e)}" does not exist.`,T(t,e.fragment))}function C(e,t){return w(e,`link/missing-anchor`,`"#${e.fragment}" does not exist on "${E(e)}".`,T(t,e.fragment))}function w(e,t,n,r){return{code:t,message:n,location:{filePath:e.filePath,...e.range===null?{}:{range:e.range}},data:{raw:e.raw,target:e.target,fragment:e.fragment,kind:e.kind,title:e.title,url:r,...e.data??{}}}}function T(e,t){return t===null||t===``?e:`${e}#${t}`}function E(e){let t=a(e.raw).path;return t===``?e.target:t}export{l as unresolvedFilePathRefReads,c as validateLinkRefs};
1
+ import{delocalizeL10nPath as e}from"../../shared/utils/l10n.js";import{filePathToRouteSlug as t}from"../../shared/utils/routes/file-path-to-route-slug.js";import{computePathPrefixes as n}from"../../shared/utils/routes/compute-path-prefixes.js";import{isIndexPagePath as r,resolveRelativeSlug as i}from"../../shared/utils/routes/resolve-relative-slug.js";import{splitHash as a}from"../markdown/resolve/references.js";import"../plugins/internal/api-docs/server/shared.js";import{inventoryKey as o}from"./view.js";import{posix as s}from"node:path";function c(e,t){let n=[];for(let r of e){let e=r.targetKind===`slug`?u(r,t):f(r,t);e!==null&&n.push({ref:r,problem:e})}return n}function l(t,n){let r=[t.target,t.filePath],i=[],a=e=>{t.raw.startsWith(`/`)?i.push(`/${e}`):s.extname(e)===``&&i.push(m(t,e,n))};a(t.target);let o=e(t.target);return o!==void 0&&(r.push(o),a(o)),{filePaths:r,slugs:i}}function u(e,t){let n=d(e,e.target,t);return n===void 0?S(e,e.target):n}function d(e,t,n){let r=n.routeBySlug.get(t);if(r!==void 0)return g(e,r.sourcePath,n,t);if(n.redirects.has(t)||v(t,n)||n.servedStaticPaths.has(t))return null;let i=y(t,n);if(i===null)return;let a=b(n,i.sourcePath,`subpath`);return x(a,i.remainder)&&x(a,i.remainder.toLowerCase())?S(e,t):null}function f(t,n){let r=p(t,t.target,n);if(r!==void 0)return r;let i=e(t.target);if(i!==void 0){let{locale:e}=n.localeContext.splitLocaleFromPath(t.target),r=p(t,i,n,e);if(r!==void 0)return r}return S(t,h(t.target,n))}function p(e,t,n,r){let i=n.primaryRouteByFilePath.get(t);if(i!==void 0)return g(e,t,n,r===void 0?i:n.localeContext.toL10nSlug(i,r));if(n.filePaths.has(t))return null;if(e.raw.startsWith(`/`))return d(e,`/${t}`,n);if(s.extname(t)===``)return e.originPluginId===`internal.api-docs`?null:d(e,m(e,t,n),n)}function m(e,n,o){let s=o.primaryRouteByFilePath.get(e.filePath);if(s===void 0)return t(n);let c=a(e.raw).path.split(`?`,1)[0]??``;return i(c,s,r(e.filePath))}function h(n,r){let i=e(n);if(i===void 0)return t(n);let{locale:a}=r.localeContext.splitLocaleFromPath(n);return r.localeContext.toL10nSlug(t(i),a)}function g(e,t,n,r){if(!n.checkAnchors||e.kind===`image`||e.fragment===null||e.fragment===``||t===null)return null;let i=_(e.fragment);if(i.toLowerCase()===`top`)return null;let a=b(n,t,`anchor`);return x(a,e.fragment)&&x(a,i)?C(e,r):null}function _(e){try{return decodeURIComponent(e)}catch{return e}}function v(e,t){return t.redirectWildcards.some(t=>t===`/`||e===t||e.startsWith(`${t}/`))}function y(e,t){let r=new Set(n(e));for(let n of t.wildcardSlugs){if(!r.has(n))continue;let i=t.routeBySlug.get(n),a=n===`/`?e:e.slice(n.length);return{sourcePath:i?.sourcePath??null,remainder:a.replace(/^\/+/,``)}}return null}function b(e,t,n){return t===null?void 0:e.inventories.get(o(t,n))}function x(e,t){return e!==void 0&&e.exhaustive&&!e.targets.has(t)}function S(e,t){return w(e,`link/missing-target`,e.targetKind===`slug`?`Route "${e.target}" does not exist.`:`"${E(e)}" does not exist.`,T(t,e.fragment))}function C(e,t){return w(e,`link/missing-anchor`,`"#${e.fragment}" does not exist on "${E(e)}".`,T(t,e.fragment))}function w(e,t,n,r){return{code:t,message:n,location:{filePath:e.filePath,...e.range===null?{}:{range:e.range}},data:{raw:e.raw,target:e.target,fragment:e.fragment,kind:e.kind,title:e.title,url:r,...e.data??{}}}}function T(e,t){return t===null||t===``?e:`${e}#${t}`}function E(e){let t=a(e.raw).path;return t===``?e.target:t}export{l as unresolvedFilePathRefReads,c as validateLinkRefs};
@@ -1 +1 @@
1
- import{collectL10nDirLocales as e,resolveLocaleContext as t}from"../../shared/utils/l10n.js";import{matchGlob as n}from"../plugins/utils/glob.js";import{createTrackedRedoclyConfig as r}from"../config-deps.js";import{buildDataRefMarker as i,hashBlobContent as a}from"../materialization/data-ref.js";import{resolveDataRef as o,upsertBlob as s}from"../database/blobs.js";import{createEntityStore as c}from"../database/entity-store.js";import{createRouteQueryEvaluator as l}from"../plugins/utils/route-index.js";import{createSearchHandle as u}from"../search/store.js";import{materializeEntityByKey as d}from"../materialization/entity.js";import{createMarkdownService as f}from"../markdown/service.js";import{createAudienceTagResolver as p}from"../markdown/resolve/audience-tag.js";import{resolve as m}from"node:path";function h(h,g,_={}){let v,y,b,x,S;return function C(w,T,E){let D=h.pluginRegistry.getById(w.pluginId);if(!D)throw Error(`Entity loader "${w.definition.id}" references missing plugin "${w.pluginId}".`);let{state:O}=h;if(!O)throw Error(`Entity loader "${w.definition.id}" ran before content state was loaded.`);let k=r(h.config),A=k.config.access?.rbac,j=h.config.access?.rbac;(j!==v||y===void 0)&&(v=j,y=p(A,e=>h.logger.warn(e)));let M=y,N=k.config.l10n?.defaultLocale;(S===void 0||S.defaultLocale!==N)&&(x??=e(O.filesByPath.keys()),S={defaultLocale:N,locales:t({defaultLocale:N},x).locales});let P=S.locales,F=[],I=[],L=[];return(b?.state!==O||b.config!==h.config)&&(b={state:O,config:h.config,evaluator:l(O,h.config)}),{args:T??{},config:k.config,contentDir:h.contentDir,file:{absolutePath:m(h.contentDir,E),path:E,lastModifiedAt:O.filesByPath.get(E)?.lastModifiedAt??null},io:{...h.pluginIO,async glob(e){return L.push(e),n(O.filesByPath.keys(),e)}},entities:c({database:g,state:O,materialize:e=>d({database:g,key:e,loaderRegistry:h.pluginRegistry,loaderContextFactory:C,contentDir:h.contentDir,revisions:_.revisions,logger:h.logger}),onEntityRead:e=>F.push(e),record:e=>I.push(e)}),search:u(g),logger:h.logger.child(`content-layer:entity:${w.definition.id}`),plugin:{id:D.id,version:D.version},pluginRegistry:h.pluginRegistry,resolveAudienceTag:M,routes:b.evaluator.index(e=>I.push(e)),markdown:f({state:O,resolveAudienceTag:M,contentLocales:P}),createBlobRef:async(e,t)=>{let n=t?.format??`json`,r=typeof e==`string`?e:Buffer.from(e).toString(`base64`),o=a(r);return await s(g,{key:o,content:r,size:r.length}),i(o,n)},resolveDataRef:e=>o(g,e),_trackedConfig:k,_loadedEntityKeys:F,_globPatterns:L,_routeQueries:I}}}export{h as createBuildTimeEntityLoaderContextFactory};
1
+ import{collectL10nDirLocales as e,resolveLocaleContext as t}from"../../shared/utils/l10n.js";import{matchGlob as n}from"../plugins/utils/glob.js";import{createTrackedRedoclyConfig as r}from"../config-deps.js";import{buildDataRefMarker as i,hashBlobContent as a}from"../materialization/data-ref.js";import{resolveDataRef as o,upsertBlob as s}from"../database/blobs.js";import{createEntityStore as c}from"../database/entity-store.js";import{createRouteQueryEvaluator as l}from"../plugins/utils/route-index.js";import{createSearchHandle as u}from"../search/store.js";import{createAudienceTagResolver as d}from"../markdown/resolve/audience-tag.js";import{createMarkdownService as f}from"../markdown/service.js";import{resolve as p}from"node:path";function m(m,h,g){let _,v,y,b,x;return function(S,C,w){let T=m.pluginRegistry.getById(S.pluginId);if(!T)throw Error(`Entity loader "${S.definition.id}" references missing plugin "${S.pluginId}".`);let{state:E}=m,D=r(m.config),O=D.config.access?.rbac,k=m.config.access?.rbac;(k!==_||v===void 0)&&(_=k,v=d(O,e=>m.logger.warn(e)));let A=v,j=D.config.l10n?.defaultLocale;(x===void 0||x.defaultLocale!==j)&&(b??=e(E.filesByPath.keys()),x={defaultLocale:j,locales:t({defaultLocale:j},b).locales});let M=x.locales,N=[],P=[],F=[];return(y?.state!==E||y.config!==m.config)&&(y={state:E,config:m.config,evaluator:l(E,m.config)}),{args:C??{},config:D.config,contentDir:m.contentDir,file:{absolutePath:p(m.contentDir,w),path:w,lastModifiedAt:E.filesByPath.get(w)?.lastModifiedAt??null},io:{...m.pluginIO,async glob(e){return F.push(e),n(E.filesByPath.keys(),e)}},entities:c({database:h,state:E,materialize:g,onEntityRead:e=>N.push(e),record:e=>P.push(e)}),search:u(h),logger:m.logger.child(`content-layer:entity:${S.definition.id}`),plugin:{id:T.id,version:T.version},pluginRegistry:m.pluginRegistry,resolveAudienceTag:A,routes:y.evaluator.index(e=>P.push(e)),markdown:f({state:E,resolveAudienceTag:A,contentLocales:M}),createBlobRef:async(e,t)=>{let n=t?.format??`json`,r=typeof e==`string`?e:Buffer.from(e).toString(`base64`),o=a(r);return await s(h,{key:o,content:r,size:r.length}),i(o,n)},resolveDataRef:e=>o(h,e),_trackedConfig:D,_loadedEntityKeys:N,_globPatterns:F,_routeQueries:P}}}export{m as createBuildTimeEntityLoaderContextFactory};
@@ -1,7 +1,7 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{ClipboardService as n}from"@redocly/theme/core/utils";import r from"styled-components";import{JsonViewer as i}from"@redocly/theme/components/JsonViewer/JsonViewer";function a({json:r,title:a,errors:c}){let l=!!c?.length,u=l?c:r,d=/* @__PURE__ */ e(i,{data:u,expandLevel:3,onCopyClick:()=>{n.copyCustom(JSON.stringify(u))},title:a});return l?/* @__PURE__ */ t(o,{children:[/* @__PURE__ */ e(s,{children:`error`}),d]}):d}const o=r.div`
1
+ import e from"styled-components";import{ClipboardService as t}from"@redocly/theme/core/utils";import{jsx as n,jsxs as r}from"react/jsx-runtime";import{JsonViewer as i}from"@redocly/theme/components/JsonViewer/JsonViewer";function a({json:e,title:a,errors:c}){let l=!!c?.length,u=l?c:e,d=/* @__PURE__ */ n(i,{data:u,expandLevel:3,onCopyClick:()=>{t.copyCustom(JSON.stringify(u))},title:a});return l?/* @__PURE__ */ r(o,{children:[/* @__PURE__ */ n(s,{children:`error`}),d]}):d}const o=e.div`
2
2
  background-color: var(--code-block-bg-color);
3
3
  border: 2px solid var(--color-error-border);
4
- `,s=r.p`
4
+ `,s=e.p`
5
5
  color: var(--color-error-text);
6
6
  padding-left: var(--spacing-xs);
7
7
  `;export{a as JsonExample};
@@ -1 +1 @@
1
- import{markdocComponents as e}from"./markdoc-components.js";const t=e=>typeof e==`object`&&!!e&&e.$$mdtype===`Tag`,n=e=>typeof e?.preload==`function`;function r(e,n){if(Array.isArray(e)){for(let t of e)r(t,n);return}if(t(e)&&(typeof e.name==`string`&&n.add(e.name),r(e.children,n),typeof e.attributes==`object`&&e.attributes!==null))for(let t of Object.values(e.attributes))r(t,n)}async function i(t){let i=/* @__PURE__ */ new Set;for(let e of Object.values(t))typeof e==`object`&&e&&`ast`in e&&r(e.ast,i);await Promise.all([...i].map(async t=>{let r=Object.hasOwn(e,t)?e[t]:null;if(n(r))try{await r.preload()}catch(e){console.error(`Realm: failed to preload the ${t} component.`,e)}}))}export{i as preloadDynamicMarkdocComponents};
1
+ import{markdocComponents as e}from"./markdoc-components.js";const t=e=>typeof e==`object`&&!!e&&e.$$mdtype===`Tag`,n=e=>typeof e?.preload==`function`;function r(e,n){if(Array.isArray(e)){for(let t of e)r(t,n);return}if(t(e)&&(typeof e.name==`string`&&n.add(e.name),r(e.children,n),typeof e.attributes==`object`&&e.attributes!==null))for(let t of Object.values(e.attributes))r(t,n)}async function i(t,i){let a=/* @__PURE__ */ new Set;for(let e of Object.values(t))typeof e==`object`&&e&&`ast`in e&&r(e.ast,a);await Promise.all([...a].map(async t=>{let r=Object.hasOwn(e,t)?e[t]:null;if(n(r))try{await r.preload()}catch(e){console.error(`Realm: failed to preload the ${t} component.`,e),i(e)}}))}export{i as preloadDynamicMarkdocComponents};
@@ -1,4 +1,4 @@
1
- import{withPathPrefix as e,withPathPrefixForSrcSet as t}from"../../../shared/path-prefix.js";import{isRouterPath as n}from"../../../client/utils/routes/is-router-path.js";import{resolveRelativeHref as r}from"../../../client/utils/routes/resolve-relative-href.js";import*as i from"react";import{Link as a,useLocation as o}from"react-router";import{jsx as s}from"react/jsx-runtime";import{dynamic as c}from"@redocly/theme/core/utils";import l from"styled-components";import{CodeSnippetProvider as u,PageActionsContext as d}from"@redocly/theme/core/contexts";import{Accordion as ee}from"@redocly/theme/markdoc/components/Accordion/Accordion";import{AccordionGroup as f}from"@redocly/theme/markdoc/components/Accordion/AccordionGroup";import{Admonition as p}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{Card as m}from"@redocly/theme/markdoc/components/Cards/Card";import{Cards as h}from"@redocly/theme/markdoc/components/Cards/Cards";import{CodeBlock as g}from"@redocly/theme/markdoc/components/CodeBlock/CodeBlock";import{CodeGroup as _}from"@redocly/theme/markdoc/components/CodeGroup/CodeGroup";import{CodeStep as te}from"@redocly/theme/markdoc/components/CodeWalkthrough/CodeStep";import{CodeToggle as ne}from"@redocly/theme/markdoc/components/CodeWalkthrough/CodeToggle";import{CodeWalkthrough as re}from"@redocly/theme/markdoc/components/CodeWalkthrough/CodeWalkthrough";import{ConnectMCP as v}from"@redocly/theme/markdoc/components/ConnectMCP/ConnectMCP";import{Diagram as y}from"@redocly/theme/markdoc/components/Diagram/Diagram";import{Experiment as b}from"@redocly/theme/components/Experiment/Experiment";import{Variant as x}from"@redocly/theme/components/Experiment/Variant";import{Heading as S}from"@redocly/theme/markdoc/components/Heading/Heading";import{Input as C}from"@redocly/theme/markdoc/components/CodeWalkthrough/Input";import{Icon as w}from"@redocly/theme/markdoc/components/Icon/Icon";import{Image as T}from"@redocly/theme/markdoc/components/Image/Image";import{InlineSvg as E}from"@redocly/theme/markdoc/components/InlineSvg/InlineSvg";import{LoginButton as D}from"@redocly/theme/markdoc/components/LoginButton/LoginButton";import{MarkdocExample as O}from"@redocly/theme/markdoc/components/MarkdocExample/MarkdocExample";import{NumberedItem as k}from"@redocly/theme/markdoc/components/NumberedList/NumberedItem";import{NumberedList as A}from"@redocly/theme/markdoc/components/NumberedList/NumberedList";import{Prompt as j}from"@redocly/theme/markdoc/components/Prompt/Prompt";import{Tabs as M}from"@redocly/theme/markdoc/components/Tabs/Tabs";import{TabItemFragment as N}from"@redocly/theme/markdoc/components/Tabs/TabItemFragment";import{Markdown as P}from"@redocly/theme/components/Markdown/Markdown";import{SearchAiCitation as F}from"@redocly/theme/components/Search/SearchAiCitation";import I from"@redocly/markdoc/dist/react.js";import{useL10nHref as ie}from"virtual:realm-runtime";import{userMarkdocComponents as L}from"virtual:realm-markdoc-components";const R=t=>typeof t==`string`?e(t):void 0,z=e=>typeof e==`string`?t(e):void 0,B=e=>/^(https?:|\/\/)/.test(e);function V(e){let t=ie(),{pathname:i}=o();if(!e||B(e)||e.startsWith(`mailto:`))return{kind:`external`,href:e};let a=r(e,i);return n(a)?{kind:`page`,href:t(a)}:{kind:`file`,href:a}}function H({href:t,children:n,...r}){let i=V(t);if(i.kind===`external`){let e=t&&B(t)?`_blank`:void 0;return/* @__PURE__ */ s(`a`,{href:t,target:e,...r,rel:typeof r.rel==`string`?r.rel:`noreferrer`,children:n})}return i.kind===`file`?/* @__PURE__ */ s(`a`,{href:e(i.href),...r,children:n}):/* @__PURE__ */ s(a,{to:i.href,...r,children:n})}function U(e){return function({href:t,...n}){return/* @__PURE__ */ s(e,{...n,href:V(t).href})}}const{MarkdownLink:W,...G}=L;function K({src:e,srcSet:t,...n}){return/* @__PURE__ */ s(T,{...n,src:R(e),srcSet:z(t)})}let q=Promise.resolve();function J(){return q}function Y(e,t){return new Promise(n=>{t&&(e.addEventListener(`load`,()=>n()),e.addEventListener(`error`,()=>n())),document.body.appendChild(e),t||n()})}function X({src:e,children:t,...n}){return i.useEffect(()=>{let r=typeof e==`string`?e:void 0;if(r&&document.querySelector(`script[src="${CSS.escape(r)}"]`))return;let a=document.createElement(`script`);r?a.src=r:t!=null&&(a.textContent=i.Children.toArray(t).join(``));for(let[e,t]of Object.entries(n))(typeof t==`string`||typeof t==`boolean`)&&a.setAttribute(e,String(t));r&&n.async?Y(a,!0):q=q.then(()=>Y(a,!!r))},[e]),null}function Z({image:e,icon:t,...n}){return/* @__PURE__ */ s(m,{...n,image:R(e),icon:R(t)})}const ae=l.span.attrs({role:`alert`,"data-component-name":`MarkdocInlineError`})`
1
+ import{withPathPrefix as e,withPathPrefixForSrcSet as t}from"../../../shared/path-prefix.js";import{isRouterPath as n}from"../../../client/utils/routes/is-router-path.js";import{resolveRelativeHref as r}from"../../../client/utils/routes/resolve-relative-href.js";import*as i from"react";import a from"styled-components";import{Link as o,useLocation as s}from"react-router";import{dynamic as c}from"@redocly/theme/core/utils";import{jsx as l}from"react/jsx-runtime";import{CodeSnippetProvider as u,PageActionsContext as d}from"@redocly/theme/core/contexts";import{Accordion as ee}from"@redocly/theme/markdoc/components/Accordion/Accordion";import{AccordionGroup as f}from"@redocly/theme/markdoc/components/Accordion/AccordionGroup";import{Admonition as p}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{Card as m}from"@redocly/theme/markdoc/components/Cards/Card";import{Cards as h}from"@redocly/theme/markdoc/components/Cards/Cards";import{CodeBlock as g}from"@redocly/theme/markdoc/components/CodeBlock/CodeBlock";import{CodeGroup as _}from"@redocly/theme/markdoc/components/CodeGroup/CodeGroup";import{CodeStep as te}from"@redocly/theme/markdoc/components/CodeWalkthrough/CodeStep";import{CodeToggle as ne}from"@redocly/theme/markdoc/components/CodeWalkthrough/CodeToggle";import{CodeWalkthrough as re}from"@redocly/theme/markdoc/components/CodeWalkthrough/CodeWalkthrough";import{ConnectMCP as v}from"@redocly/theme/markdoc/components/ConnectMCP/ConnectMCP";import{Diagram as y}from"@redocly/theme/markdoc/components/Diagram/Diagram";import{Experiment as b}from"@redocly/theme/components/Experiment/Experiment";import{Variant as x}from"@redocly/theme/components/Experiment/Variant";import{Heading as S}from"@redocly/theme/markdoc/components/Heading/Heading";import{Input as C}from"@redocly/theme/markdoc/components/CodeWalkthrough/Input";import{Icon as w}from"@redocly/theme/markdoc/components/Icon/Icon";import{Image as T}from"@redocly/theme/markdoc/components/Image/Image";import{InlineSvg as E}from"@redocly/theme/markdoc/components/InlineSvg/InlineSvg";import{LoginButton as D}from"@redocly/theme/markdoc/components/LoginButton/LoginButton";import{MarkdocExample as O}from"@redocly/theme/markdoc/components/MarkdocExample/MarkdocExample";import{NumberedItem as k}from"@redocly/theme/markdoc/components/NumberedList/NumberedItem";import{NumberedList as A}from"@redocly/theme/markdoc/components/NumberedList/NumberedList";import{Prompt as j}from"@redocly/theme/markdoc/components/Prompt/Prompt";import{Tabs as M}from"@redocly/theme/markdoc/components/Tabs/Tabs";import{TabItemFragment as N}from"@redocly/theme/markdoc/components/Tabs/TabItemFragment";import{Markdown as P}from"@redocly/theme/components/Markdown/Markdown";import{SearchAiCitation as F}from"@redocly/theme/components/Search/SearchAiCitation";import I from"@redocly/markdoc/dist/react.js";import{useL10nHref as ie}from"virtual:realm-runtime";import{userMarkdocComponents as L}from"virtual:realm-markdoc-components";const R=t=>typeof t==`string`?e(t):void 0,z=e=>typeof e==`string`?t(e):void 0,B=e=>/^(https?:|\/\/)/.test(e);function V(e){let t=ie(),{pathname:i}=s();if(!e||B(e)||e.startsWith(`mailto:`))return{kind:`external`,href:e};let a=r(e,i);return n(a)?{kind:`page`,href:t(a)}:{kind:`file`,href:a}}function H({href:t,children:n,...r}){let i=V(t);if(i.kind===`external`){let e=t&&B(t)?`_blank`:void 0;return/* @__PURE__ */ l(`a`,{href:t,target:e,...r,rel:typeof r.rel==`string`?r.rel:`noreferrer`,children:n})}return i.kind===`file`?/* @__PURE__ */ l(`a`,{href:e(i.href),...r,children:n}):/* @__PURE__ */ l(o,{to:i.href,...r,children:n})}function U(e){return function({href:t,...n}){return/* @__PURE__ */ l(e,{...n,href:V(t).href})}}const{MarkdownLink:W,...G}=L;function K({src:e,srcSet:t,...n}){return/* @__PURE__ */ l(T,{...n,src:R(e),srcSet:z(t)})}let q=Promise.resolve();function J(){return q}function Y(e,t){return new Promise(n=>{t&&(e.addEventListener(`load`,()=>n()),e.addEventListener(`error`,()=>n())),document.body.appendChild(e),t||n()})}function X({src:e,children:t,...n}){return i.useEffect(()=>{let r=typeof e==`string`?e:void 0;if(r&&document.querySelector(`script[src="${CSS.escape(r)}"]`))return;let a=document.createElement(`script`);r?a.src=r:t!=null&&(a.textContent=i.Children.toArray(t).join(``));for(let[e,t]of Object.entries(n))(typeof t==`string`||typeof t==`boolean`)&&a.setAttribute(e,String(t));r&&n.async?Y(a,!0):q=q.then(()=>Y(a,!!r))},[e]),null}function Z({image:e,icon:t,...n}){return/* @__PURE__ */ l(m,{...n,image:R(e),icon:R(t)})}const ae=a.span.attrs({role:`alert`,"data-component-name":`MarkdocInlineError`})`
2
2
  display: inline;
3
3
  padding: 0 var(--spacing-xs);
4
4
  border: var(--admonition-danger-border);
@@ -6,4 +6,4 @@ import{withPathPrefix as e,withPathPrefixForSrcSet as t}from"../../../shared/pat
6
6
  background-color: var(--admonition-danger-bg-color);
7
7
  color: var(--admonition-danger-text-color);
8
8
  font-size: var(--font-size-sm);
9
- `,Q={Accordion:ee,AccordionGroup:f,Admonition:p,AiCitation:F,Card:Z,Cards:h,CodeBlock:g,CodeGroup:_,CodeStep:te,CodeToggle:ne,CodeWalkthrough:re,ConnectMCP:v,Diagram:y,Experiment:b,ExperimentVariant:x,Heading:S,HtmlScript:X,Icon:w,Image:K,InlineSvg:E,Input:C,JsonExample:c(()=>import(`./OpenapiTagComponents.js`).then(e=>e.JsonExample)),JsonSchema:c(()=>import(`./JsonSchemaTag.js`).then(e=>e.JsonSchemaTag)),LoginButton:D,MarkdocExample:O,MarkdocInlineError:ae,NumberedItem:k,NumberedList:A,OpenApiCodeSample:c(()=>import(`./OpenApiEmbedTags.js`).then(e=>e.OpenApiCodeSample)),OpenApiExample:c(()=>import(`./OpenApiEmbedTags.js`).then(e=>e.OpenApiExample)),OpenApiResponseSample:c(()=>import(`./OpenApiEmbedTags.js`).then(e=>e.OpenApiResponseSample)),Prompt:j,ReplayOpenApi:c(()=>import(`./ReplayOpenApiTag.js`).then(e=>e.ReplayOpenApiTag)),Tabs:M,TabItemFragment:N,Link:H,...G,MarkdownLink:W===void 0?H:U(W)},oe=I;function $(e,t=Q){return/* @__PURE__ */ s(u,{children:oe(e,i,{components:t})})}function se({ast:e,components:t=Q,withPageActions:n}){let r=i.useMemo(()=>$(e,t),[e,t]);return/* @__PURE__ */ s(d.Provider,{value:n??null,children:/* @__PURE__ */ s(P,{children:r})})}export{X as HtmlScript,Z as MarkdocCard,K as MarkdocImage,H as MarkdocLink,se as MarkdocRenderer,Q as markdocComponents,$ as renderMarkdocAst,J as waitForMarkdownScripts};
9
+ `,Q={Accordion:ee,AccordionGroup:f,Admonition:p,AiCitation:F,Card:Z,Cards:h,CodeBlock:g,CodeGroup:_,CodeStep:te,CodeToggle:ne,CodeWalkthrough:re,ConnectMCP:v,Diagram:y,Experiment:b,ExperimentVariant:x,Heading:S,HtmlScript:X,Icon:w,Image:K,InlineSvg:E,Input:C,JsonExample:c(()=>import(`./OpenapiTagComponents.js`).then(e=>e.JsonExample)),JsonSchema:c(()=>import(`./JsonSchemaTag.js`).then(e=>e.JsonSchemaTag)),LoginButton:D,MarkdocExample:O,MarkdocInlineError:ae,NumberedItem:k,NumberedList:A,OpenApiCodeSample:c(()=>import(`./OpenApiEmbedTags.js`).then(e=>e.OpenApiCodeSample)),OpenApiExample:c(()=>import(`./OpenApiEmbedTags.js`).then(e=>e.OpenApiExample)),OpenApiResponseSample:c(()=>import(`./OpenApiEmbedTags.js`).then(e=>e.OpenApiResponseSample)),Prompt:j,ReplayOpenApi:c(()=>import(`./ReplayOpenApiTag.js`).then(e=>e.ReplayOpenApiTag)),Tabs:M,TabItemFragment:N,Link:H,...G,MarkdownLink:W===void 0?H:U(W)},oe=I;function $(e,t=Q){return/* @__PURE__ */ l(u,{children:oe(e,i,{components:t})})}function se({ast:e,components:t=Q,withPageActions:n}){let r=i.useMemo(()=>$(e,t),[e,t]);return/* @__PURE__ */ l(d.Provider,{value:n??null,children:/* @__PURE__ */ l(P,{children:r})})}export{X as HtmlScript,Z as MarkdocCard,K as MarkdocImage,H as MarkdocLink,se as MarkdocRenderer,Q as markdocComponents,$ as renderMarkdocAst,J as waitForMarkdownScripts};
@@ -1 +1 @@
1
- import{renderMarkdocAst as e}from"./markdoc-components.js";import{headingSlugger as t}from"../utils/heading-slugger.js";import{buildMarkdownTextTagSet as n}from"../constants/markdown-text-tag-set.js";import r from"@redocly/markdoc";import{userMarkdocFunctions as i,userMarkdocNodes as a,userMarkdocTags as o}from"virtual:realm-markdoc-schema";let s;function c(c){return c?(s??=n({tags:o,nodes:a,functions:i}),t.reset(),e(r.transform(r.parse(c),s))):null}export{c as renderMarkdownText};
1
+ import{headingSlugger as e}from"../utils/heading-slugger.js";import{renderMarkdocAst as t}from"./markdoc-components.js";import{buildMarkdownTextTagSet as n}from"../constants/markdown-text-tag-set.js";import r from"@redocly/markdoc";import{userMarkdocFunctions as i,userMarkdocNodes as a,userMarkdocTags as o}from"virtual:realm-markdoc-schema";let s;function c(c){return c?(s??=n({tags:o,nodes:a,functions:i}),e.reset(),t(r.transform(r.parse(c),s))):null}export{c as renderMarkdownText};
@@ -1 +1 @@
1
- import{jsonExampleTag as e,jsonSchemaTag as t,openapiCodeSampleTag as n,openapiExampleTag as r,openapiResponseSampleTag as i,replayOpenapiTag as a}from"../tags/openapi.js";import{codeSnippetTag as o}from"../tags/code-snippet.js";import{diagramTag as s}from"../tags/diagram.js";import{html as c}from"../tags/html.js";import{MARKDOC_ERROR_TAG as l,markdocError as u}from"../tags/markdoc-error.js";import{partial as d}from"../tags/partial.js";import{variant as f}from"../tags/variant.js";import{fence as p}from"../nodes/fence.js";import{heading as m}from"../nodes/heading.js";import{item as h}from"../nodes/gfm-list-item.js";import{table as g,td as _,th as v}from"../nodes/table.js";import{text as y}from"../nodes/text.js";import{VARIANT_TAG as b}from"@redocly/theme/markdoc/tags/variant";import x from"@redocly/markdoc";import{accordion as S}from"@redocly/theme/markdoc/tags/accordion";import{accordionGroup as C}from"@redocly/theme/markdoc/tags/accordion-group";import{admonition as w}from"@redocly/theme/markdoc/tags/admonition";import{card as T}from"@redocly/theme/markdoc/tags/card";import{cards as E}from"@redocly/theme/markdoc/tags/cards";import{codeGroup as D}from"@redocly/theme/markdoc/tags/code-group";import{codeStep as O}from"@redocly/theme/markdoc/tags/code-step";import{toggle as k}from"@redocly/theme/markdoc/tags/code-toggle";import{codeWalkthrough as A}from"@redocly/theme/markdoc/tags/code-walkthrough";import{connectMcp as j}from"@redocly/theme/markdoc/tags/connect-mcp";import{debug as M}from"@redocly/theme/markdoc/tags/debug";import{experiment as N}from"@redocly/theme/markdoc/tags/experiment";import{icon as P}from"@redocly/theme/markdoc/tags/icon";import{img as F}from"@redocly/theme/markdoc/tags/img";import{inlineSvg as I}from"@redocly/theme/markdoc/tags/inline-svg";import{input as L}from"@redocly/theme/markdoc/tags/input";import{loginButton as R}from"@redocly/theme/markdoc/tags/login-button";import{markdocExample as z}from"@redocly/theme/markdoc/tags/markdoc-example";import{numberedItem as B}from"@redocly/theme/markdoc/tags/numbered-item";import{numberedList as V}from"@redocly/theme/markdoc/tags/numbered-list";import{prompt as H}from"@redocly/theme/markdoc/tags/prompt";import{tab as U}from"@redocly/theme/markdoc/tags/tab";import{tabs as W}from"@redocly/theme/markdoc/tags/tabs";import{visibility as G}from"@redocly/theme/markdoc/tags/visibility";const K=[A.tagName,O.tagName,k.tagName,L.tagName],q={[S.tagName]:S.schema,[C.tagName]:C.schema,[w.tagName]:w.schema,[T.tagName]:T.schema,[E.tagName]:E.schema,[D.tagName]:D.schema,"code-snippet":o,[O.tagName]:O.schema,[A.tagName]:A.schema,[j.tagName]:j.schema,[M.tagName]:M.schema,diagram:s,[N.tagName]:N.schema,html:c,[P.tagName]:P.schema,[F.tagName]:F.schema,[I.tagName]:I.schema,[L.tagName]:L.schema,"json-example":e,"json-schema":t,[R.tagName]:R.schema,[l]:u,[z.tagName]:z.schema,[B.tagName]:B.schema,[V.tagName]:V.schema,"openapi-code-sample":n,"openapi-example":r,"openapi-response-sample":i,partial:d,[H.tagName]:H.schema,"replay-openapi":a,[U.tagName]:U.schema,[W.tagName]:W.schema,[k.tagName]:k.schema,[b]:f,[G.tagName]:G.schema},J=(e,t)=>({...e,children:[...e.children??[],...t]}),Y={link:J({...x.nodes.link,render:`MarkdownLink`},[`softbreak`,`image`]),strong:J(x.nodes.strong,[`softbreak`,`em`,`strong`]),em:J(x.nodes.em,[`softbreak`,`em`,`strong`]),s:J(x.nodes.s,[`softbreak`]),image:{...x.nodes.image,render:`Image`},fence:p,heading:m,item:h,table:g,td:_,th:v,text:y};export{K as CODE_WALKTHROUGH_TAG_NAMES,Y as builtInMarkdocNodes,q as builtInMarkdocTags};
1
+ import{jsonExampleTag as e,jsonSchemaTag as t,openapiCodeSampleTag as n,openapiExampleTag as r,openapiResponseSampleTag as i,replayOpenapiTag as a}from"../tags/openapi.js";import{codeSnippetTag as o}from"../tags/code-snippet.js";import{diagramTag as s}from"../tags/diagram.js";import{html as c}from"../tags/html.js";import{MARKDOC_ERROR_TAG as l,markdocError as u}from"../tags/markdoc-error.js";import{partial as d}from"../tags/partial.js";import{variant as f}from"../tags/variant.js";import{fence as p}from"../nodes/fence.js";import{heading as m}from"../nodes/heading.js";import{item as h}from"../nodes/gfm-list-item.js";import{table as g,td as _,th as v}from"../nodes/table.js";import{text as y}from"../nodes/text.js";import b from"@redocly/markdoc";import{accordion as x}from"@redocly/theme/markdoc/tags/accordion";import{accordionGroup as S}from"@redocly/theme/markdoc/tags/accordion-group";import{admonition as C}from"@redocly/theme/markdoc/tags/admonition";import{card as w}from"@redocly/theme/markdoc/tags/card";import{cards as T}from"@redocly/theme/markdoc/tags/cards";import{codeGroup as E}from"@redocly/theme/markdoc/tags/code-group";import{codeStep as D}from"@redocly/theme/markdoc/tags/code-step";import{toggle as O}from"@redocly/theme/markdoc/tags/code-toggle";import{codeWalkthrough as k}from"@redocly/theme/markdoc/tags/code-walkthrough";import{connectMcp as A}from"@redocly/theme/markdoc/tags/connect-mcp";import{debug as j}from"@redocly/theme/markdoc/tags/debug";import{experiment as M}from"@redocly/theme/markdoc/tags/experiment";import{icon as N}from"@redocly/theme/markdoc/tags/icon";import{img as P}from"@redocly/theme/markdoc/tags/img";import{inlineSvg as F}from"@redocly/theme/markdoc/tags/inline-svg";import{input as I}from"@redocly/theme/markdoc/tags/input";import{loginButton as L}from"@redocly/theme/markdoc/tags/login-button";import{markdocExample as R}from"@redocly/theme/markdoc/tags/markdoc-example";import{numberedItem as z}from"@redocly/theme/markdoc/tags/numbered-item";import{numberedList as B}from"@redocly/theme/markdoc/tags/numbered-list";import{prompt as V}from"@redocly/theme/markdoc/tags/prompt";import{tab as H}from"@redocly/theme/markdoc/tags/tab";import{tabs as U}from"@redocly/theme/markdoc/tags/tabs";import{VARIANT_TAG as W}from"@redocly/theme/markdoc/tags/variant";import{visibility as G}from"@redocly/theme/markdoc/tags/visibility";const K=[k.tagName,D.tagName,O.tagName,I.tagName],q={[x.tagName]:x.schema,[S.tagName]:S.schema,[C.tagName]:C.schema,[w.tagName]:w.schema,[T.tagName]:T.schema,[E.tagName]:E.schema,"code-snippet":o,[D.tagName]:D.schema,[k.tagName]:k.schema,[A.tagName]:A.schema,[j.tagName]:j.schema,diagram:s,[M.tagName]:M.schema,html:c,[N.tagName]:N.schema,[P.tagName]:P.schema,[F.tagName]:F.schema,[I.tagName]:I.schema,"json-example":e,"json-schema":t,[L.tagName]:L.schema,[l]:u,[R.tagName]:R.schema,[z.tagName]:z.schema,[B.tagName]:B.schema,"openapi-code-sample":n,"openapi-example":r,"openapi-response-sample":i,partial:d,[V.tagName]:V.schema,"replay-openapi":a,[H.tagName]:H.schema,[U.tagName]:U.schema,[O.tagName]:O.schema,[W]:f,[G.tagName]:G.schema},J=(e,t)=>({...e,children:[...e.children??[],...t]}),Y={link:J({...b.nodes.link,render:`MarkdownLink`},[`softbreak`,`image`]),strong:J(b.nodes.strong,[`softbreak`,`em`,`strong`]),em:J(b.nodes.em,[`softbreak`,`em`,`strong`]),s:J(b.nodes.s,[`softbreak`]),image:{...b.nodes.image,render:`Image`},fence:p,heading:m,item:h,table:g,td:_,th:v,text:y};export{K as CODE_WALKTHROUGH_TAG_NAMES,Y as builtInMarkdocNodes,q as builtInMarkdocTags};
@@ -1 +1 @@
1
- import{builtInMarkdocFunctions as e}from"./builtin-functions.js";import{builtInMarkdocNodes as t,builtInMarkdocTags as n}from"./builtin-tags.js";import{isSchemaLike as r}from"./tag-sets.js";import{getAttributeBuildTimeResolver as i}from"../resolve/attribute-resolver-key.js";import a from"@redocly/markdoc";const o=/* @__PURE__ */ new Set([`codeSnippetFile`,`svgContent`,`tagRawContent`,`codeWalkthroughFilesets`,`partialFile`,`jsonSchemaRef`,`sampleFromJsonSchema`,`jsonExampleRef`,`openapiCodeSamples`,`openapiCodeSamplePanel`,`openapiReplay`,`openapiResponseSamples`,`openapiResponsePanel`,`openapiExample`]),s=/* @__PURE__ */ new Set([`diagram`]);function c(e){return Object.values(e.attributes??{}).some(e=>i(e)!==null)}function l(e,t){return s.has(e)||Object.values(t.attributes??{}).some(e=>{let t=i(e);return t!==null&&o.has(t)})}function u(e){return{transform:()=>new a.Tag(`Admonition`,{type:`danger`},[`The "${e}" tag is not available in inline markdown.`])}}function d(i){let o={};for(let[e,t]of Object.entries(n))o[e]=l(e,t)?u(e):t;let s={...t};for(let[e,t]of[[`tags`,o],[`nodes`,s]])for(let[n,a]of Object.entries(i?.[e]??{}))r(a)&&!c(a)&&(t[n]=a);return o[`ai-citation`]={render:`AiCitation`,selfClosing:!0,attributes:{number:{type:Number,required:!0},url:{type:String,required:!0}}},s.document={...a.nodes.document,render:`div`},{tags:o,nodes:s,functions:{...i?.functions,...e}}}export{d as buildMarkdownTextTagSet};
1
+ import{builtInMarkdocNodes as e,builtInMarkdocTags as t}from"./builtin-tags.js";import{getAttributeBuildTimeResolver as n}from"../resolve/attribute-resolver-key.js";import{builtInMarkdocFunctions as r}from"./builtin-functions.js";import{isSchemaLike as i}from"./tag-sets.js";import a from"@redocly/markdoc";const o=/* @__PURE__ */ new Set([`codeSnippetFile`,`svgContent`,`tagRawContent`,`codeWalkthroughFilesets`,`partialFile`,`jsonSchemaRef`,`sampleFromJsonSchema`,`jsonExampleRef`,`openapiCodeSamples`,`openapiCodeSamplePanel`,`openapiReplay`,`openapiResponseSamples`,`openapiResponsePanel`,`openapiExample`]),s=/* @__PURE__ */ new Set([`diagram`]);function c(e){return Object.values(e.attributes??{}).some(e=>n(e)!==null)}function l(e,t){return s.has(e)||Object.values(t.attributes??{}).some(e=>{let t=n(e);return t!==null&&o.has(t)})}function u(e){return{transform:()=>new a.Tag(`Admonition`,{type:`danger`},[`The "${e}" tag is not available in inline markdown.`])}}function d(n){let o={};for(let[e,n]of Object.entries(t))o[e]=l(e,n)?u(e):n;let s={...e};for(let[e,t]of[[`tags`,o],[`nodes`,s]])for(let[r,a]of Object.entries(n?.[e]??{}))i(a)&&!c(a)&&(t[r]=a);return o[`ai-citation`]={render:`AiCitation`,selfClosing:!0,attributes:{number:{type:Number,required:!0},url:{type:String,required:!0}}},s.document={...a.nodes.document,render:`div`},{tags:o,nodes:s,functions:{...n?.functions,...r}}}export{d as buildMarkdownTextTagSet};
@@ -1 +1 @@
1
- import{builtInMarkdocFunctions as e}from"./builtin-functions.js";import{builtInMarkdocNodes as t,builtInMarkdocTags as n}from"./builtin-tags.js";const r=`@theme/markdoc/schema.ts`;let i,a,o=!1;function s(e,t,n){globalThis.__REALM_MARKDOC_USER_SCHEMA__=e,i=t,a=n,o=!1}function c(e){s(void 0,void 0,e),o=!0}function l(){return a}function u(){return Object.keys(globalThis.__REALM_MARKDOC_USER_SCHEMA__?.tags??{})}function d(){return a!==void 0&&!o}function f(){return i}const p=`builtin`,m=`api-docs`,h={[m]:async()=>{let{apiDocsMarkdocNodes:e,apiDocsMarkdocTags:t}=await import(`@redocly/api-docs/lib/components/markdoc/defaultMarkdocConfig.js`);return{tags:t,nodes:e}}},g=/* @__PURE__ */ new Map;let _;const v=/* @__PURE__ */ new Set,y=e=>!!e&&typeof e==`object`;function b(t,n){let r={tags:{...t.tags},nodes:{...t.nodes},functions:{...e,...t.functions}};for(let e of[`tags`,`nodes`,`functions`])for(let[t,i]of Object.entries(n[e]??{}))if(y(i)){if(e===`functions`&&t in r.functions){v.has(t)||(v.add(t),console.warn(`[markdoc] The user schema defines the "${t}" function, but the engine already defines it. The engine function is used.`));continue}r[e][t]=i}return r}async function x(r){let i=globalThis.__REALM_MARKDOC_USER_SCHEMA__;i!==_&&(_=i,g.clear(),v.clear());let a=r??`builtin`,o=g.get(a);if(o)return o;let s={tags:n,nodes:t,functions:e};if(i&&(s=b(s,i)),a!==`builtin`){let e=await h[a]?.();if(!e)throw Error(`Unknown markdoc tag set "${a}".`);s={tags:{...s.tags,...e.tags},nodes:{...s.nodes,...e.nodes},functions:{...s.functions,...e.functions}}}return g.set(a,s),s}const S=`page-validation`;async function C(){let e=await x(),t=await x(m),n=g.get(S);if(n)return n;let r={...t,tags:{...t.tags,...e.tags},nodes:{...t.nodes,...e.nodes}};return g.set(S,r),r}export{m as API_DOCS_MARKDOC_TAG_SET,p as BUILTIN_MARKDOC_TAG_SET,r as USER_MARKDOC_SCHEMA_FILE,d as isMarkdocValidationEnabled,y as isSchemaLike,s as registerUserMarkdocSchema,c as registerUserMarkdocSchemaFailure,x as resolveMarkdocTagSet,C as resolveMarkdownPageValidationSet,f as userMarkdocSchemaDigest,l as userMarkdocSchemaFiles,u as userMarkdocTagNames};
1
+ import{builtInMarkdocNodes as e,builtInMarkdocTags as t}from"./builtin-tags.js";import{builtInMarkdocFunctions as n}from"./builtin-functions.js";const r=`@theme/markdoc/schema.ts`;let i,a,o=!1;function s(e,t,n){globalThis.__REALM_MARKDOC_USER_SCHEMA__=e,i=t,a=n,o=!1}function c(e){s(void 0,void 0,e),o=!0}function l(){return a}function u(){return Object.keys(globalThis.__REALM_MARKDOC_USER_SCHEMA__?.tags??{})}function d(){return a!==void 0&&!o}function f(){return i}const p=`builtin`,m=`api-docs`,h={[m]:async()=>{let{apiDocsMarkdocNodes:e,apiDocsMarkdocTags:t}=await import(`@redocly/api-docs/markdoc`);return{tags:t,nodes:e}}},g=/* @__PURE__ */ new Map;let _;const v=/* @__PURE__ */ new Set,y=e=>!!e&&typeof e==`object`;function b(e,t){let r={tags:{...e.tags},nodes:{...e.nodes},functions:{...n,...e.functions}};for(let e of[`tags`,`nodes`,`functions`])for(let[n,i]of Object.entries(t[e]??{}))if(y(i)){if(e===`functions`&&n in r.functions){v.has(n)||(v.add(n),console.warn(`[markdoc] The user schema defines the "${n}" function, but the engine already defines it. The engine function is used.`));continue}r[e][n]=i}return r}async function x(r){let i=globalThis.__REALM_MARKDOC_USER_SCHEMA__;i!==_&&(_=i,g.clear(),v.clear());let a=r??`builtin`,o=g.get(a);if(o)return o;let s={tags:t,nodes:e,functions:n};if(i&&(s=b(s,i)),a!==`builtin`){let e=await h[a]?.();if(!e)throw Error(`Unknown markdoc tag set "${a}".`);s={tags:{...s.tags,...e.tags},nodes:{...s.nodes,...e.nodes},functions:{...s.functions,...e.functions}}}return g.set(a,s),s}const S=`page-validation`;async function C(){let e=await x(),t=await x(m),n=g.get(S);if(n)return n;let r={...t,tags:{...t.tags,...e.tags},nodes:{...t.nodes,...e.nodes}};return g.set(S,r),r}export{m as API_DOCS_MARKDOC_TAG_SET,p as BUILTIN_MARKDOC_TAG_SET,r as USER_MARKDOC_SCHEMA_FILE,d as isMarkdocValidationEnabled,y as isSchemaLike,s as registerUserMarkdocSchema,c as registerUserMarkdocSchemaFailure,x as resolveMarkdocTagSet,C as resolveMarkdownPageValidationSet,f as userMarkdocSchemaDigest,l as userMarkdocSchemaFiles,u as userMarkdocTagNames};
@@ -1 +1 @@
1
- import{EXAMPLE_CONTENT_ATTRIBUTE as e}from"@redocly/theme/core/constants";import t from"@redocly/markdoc";const n=/* @__PURE__ */ new Set([`mermaid`,`excalidraw`,`plantuml`]),r={...t.nodes.fence,attributes:{...t.nodes.fence.attributes,label:{type:String,render:`data-label`},title:{type:String,render:`data-title`},highlight:{type:String,render:`data-highlight`},align:{type:String,matches:[`left`,`center`,`right`]},width:{type:String},[e]:{type:Object,render:!1}},transform(e,r){let i=e.transformAttributes(r),a=e.transformChildren(r),o=i[`data-language`],s=i[`data-title`];if(e.attributes.process===!1&&(a=[e.attributes.content]),typeof a[0]!=`string`)return new t.Tag(e.tag,i,a);if(typeof o==`string`&&n.has(o)){let{diagramHtml:n,diagramHtmlDark:r,diagramError:s}=e.attributes;if(typeof n==`string`||typeof s==`string`)return new t.Tag(`Diagram`,{...i,diagramType:o,diagramSource:a[0],diagramHtml:n,diagramHtmlDark:r,diagramError:s},[])}let c=a.map(e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e.toString():t.Tag.isTag(e)?String(e.attributes?.rawtag??``):``).join(``);return new t.Tag(`CodeBlock`,{...i,header:{title:s,controls:{copy:{}}},source:c,lang:o},[])}};export{n as DIAGRAM_LANGUAGES,r as fence};
1
+ import e from"@redocly/markdoc";import{EXAMPLE_CONTENT_ATTRIBUTE as t}from"@redocly/theme/core/constants";const n=/* @__PURE__ */ new Set([`mermaid`,`excalidraw`,`plantuml`]),r={...e.nodes.fence,attributes:{...e.nodes.fence.attributes,label:{type:String,render:`data-label`},title:{type:String,render:`data-title`},highlight:{type:String,render:`data-highlight`},align:{type:String,matches:[`left`,`center`,`right`]},width:{type:String},[t]:{type:Object,render:!1}},transform(t,r){let i=t.transformAttributes(r),a=t.transformChildren(r),o=i[`data-language`],s=i[`data-title`];if(t.attributes.process===!1&&(a=[t.attributes.content]),typeof a[0]!=`string`)return new e.Tag(t.tag,i,a);if(typeof o==`string`&&n.has(o)){let{diagramHtml:n,diagramHtmlDark:r,diagramError:s}=t.attributes;if(typeof n==`string`||typeof s==`string`)return new e.Tag(`Diagram`,{...i,diagramType:o,diagramSource:a[0],diagramHtml:n,diagramHtmlDark:r,diagramError:s},[])}let c=a.map(t=>typeof t==`string`||typeof t==`number`||typeof t==`boolean`?t.toString():e.Tag.isTag(t)?String(t.attributes?.rawtag??``):``).join(``);return new e.Tag(`CodeBlock`,{...i,header:{title:s,controls:{copy:{}}},source:c,lang:o},[])}};export{n as DIAGRAM_LANGUAGES,r as fence};
@@ -1 +1 @@
1
- import{getInnerText as e}from"../utils/get-inner-text.js";import{headingSlugger as t}from"../utils/heading-slugger.js";import n from"@redocly/markdoc";const r={children:[`inline`],attributes:{id:{type:String},level:{type:Number,required:!0,default:1}},transform(r,i){let a=r.transformAttributes(i),o=r.transformChildren(i),s=typeof a.id==`string`?t.explicit(a.id):t.slug(e(o));return new n.Tag(`Heading`,{...a,id:s,level:r.attributes.level},o)}};export{r as heading};
1
+ import{headingSlugger as e}from"../utils/heading-slugger.js";import{getInnerText as t}from"../utils/get-inner-text.js";import n from"@redocly/markdoc";const r={children:[`inline`],attributes:{id:{type:String},level:{type:Number,required:!0,default:1}},transform(r,i){let a=r.transformAttributes(i),o=r.transformChildren(i),s=typeof a.id==`string`?e.explicit(a.id):e.slug(t(o));return new n.Tag(`Heading`,{...a,id:s,level:r.attributes.level},o)}};export{r as heading};
@@ -1 +1 @@
1
- import{MARKDOWN_CLASS_NAME as e}from"@redocly/theme/core/constants";import t from"@redocly/markdoc";const n={transform(n,r){let{class:i,...a}=n.transformAttributes(r),s=n.transformChildren(r);return o(s),new t.Tag(`div`,{className:`md-table-wrapper`},[new t.Tag(`table`,{...a,className:[e,i].filter(Boolean).join(` `)},s)])}},r={type:String,matches:[`top`,`middle`,`bottom`],render:`vAlign`},i={...t.nodes.td,attributes:{...t.nodes.td.attributes,valign:r}},a={...t.nodes.th,attributes:{...t.nodes.th.attributes,valign:r}};function o([e]){if(t.Tag.isTag(e)&&e.name===`thead`){for(let n of e.children)if(t.Tag.isTag(n))for(let e of n.children)t.Tag.isTag(e)&&e.name===`th`&&(e.attributes[`data-label`]=s(e.children))}}function s(e){return e.map(e=>typeof e==`string`||typeof e==`number`?String(e):t.Tag.isTag(e)?s(e.children):``).join(``).trim()}export{n as table,i as td,a as th};
1
+ import e from"@redocly/markdoc";import{MARKDOWN_CLASS_NAME as t}from"@redocly/theme/core/constants";const n={transform(n,r){let{class:i,...a}=n.transformAttributes(r),s=n.transformChildren(r);return o(s),new e.Tag(`div`,{className:`md-table-wrapper`},[new e.Tag(`table`,{...a,className:[t,i].filter(Boolean).join(` `)},s)])}},r={type:String,matches:[`top`,`middle`,`bottom`],render:`vAlign`},i={...e.nodes.td,attributes:{...e.nodes.td.attributes,valign:r}},a={...e.nodes.th,attributes:{...e.nodes.th.attributes,valign:r}};function o([t]){if(e.Tag.isTag(t)&&t.name===`thead`){for(let n of t.children)if(e.Tag.isTag(n))for(let t of n.children)e.Tag.isTag(t)&&t.name===`th`&&(t.attributes[`data-label`]=s(t.children))}}function s(t){return t.map(t=>typeof t==`string`||typeof t==`number`?String(t):e.Tag.isTag(t)?s(t.children):``).join(``).trim()}export{n as table,i as td,a as th};
@@ -1 +1 @@
1
- import{markdocNodeRange as e}from"../utils/node-source-range.js";import{builtInMarkdocTags as t}from"../constants/builtin-tags.js";import{getExampleContent as n,walkWithExampleContent as r}from"../utils/reparse-example-fences.js";import{parseMarkdownDocument as i}from"../utils/parse-cache.js";import{substituteStaticVariables as a}from"../utils/substitute-variables.js";import{collectMarkdocTagNames as o,isPromptTag as s,resolveMarkdocBuildTimeAttributes as c}from"./markdoc.js";import{inlineRawPartials as l}from"./raw-partials.js";import{renderMarkdocDiagrams as u}from"./render-diagrams.js";import d from"@redocly/markdoc";const f=/* @__PURE__ */ new Set([`parse-error`,`missing-opening`,`missing-closing`,`fence-tag-error`,`no-inline-annotations`]);async function p(e,n,r){let s=await l(e,n,r.resolverContext),f=i(s.source),p=r.validation?v(f,n,h(r.validation)):[],{entityDeps:m,assetUsages:g,linkRefs:_,problems:y}=await c(f,{tags:r.tags??t,sourceFilePath:n,resolverContext:r.resolverContext,source:s.source});r.variables&&a(f,r.variables);let x=await u(f,n,r.resolverContext.logger),S=b(f,n),C=r.transform?.(f)??[];return{ast:d.compact(f),entityDeps:[...s.entityDeps,...m],assetUsages:g,linkRefs:_,tagList:o(f),problems:[...s.problems,...y,...S,...p,...C,...x]}}const m=/* @__PURE__ */ new WeakMap;function h(e){let t=m.get(e);return t===void 0&&(t=d.prepareConfig({...e,tags:g(e.tags),nodes:g(e.nodes)}),m.set(e,t)),t}function g(e){if(e!==void 0)return Object.fromEntries(Object.entries(e).map(([e,t])=>{let{validate:n}=t;return n===void 0?[e,t]:[e,{...t,validate(e,t){try{return n.call(this,e,t)}catch(t){return[{id:`validate-failed`,level:`error`,message:`The validate() of '${e.tag??e.type}' failed: ${_(t)}`}]}}}]}))}const _=e=>e instanceof Error?e.message:String(e);function v(e,t,i){let a=[e],o=/* @__PURE__ */ new Set,c=[];for(let t of r(e,s)){for(let e of t.errors??[])o.add(e);let e=n(t);e&&a.push(e),s(t)&&c.push({node:t,children:t.children})}for(let e of c)e.node.children=[];try{return a.flatMap(e=>d.validate(e,i)).filter(e=>!o.has(e.error)).map(e=>y(e,t))}catch(e){return[{code:`markdoc/validation-error`,message:`Markdoc validation failed: ${_(e)}`,location:{filePath:t,range:{start:{line:1},end:{line:1}}}}]}finally{for(let e of c)e.node.children=e.children}}function y(t,n){let{level:r,message:i}=t.error,a={code:`markdoc/validation-error`,message:i,location:{filePath:n,range:e(t)??{start:{line:1},end:{line:1}}}};return r!==`error`&&r!==`critical`&&(a.severity=`warning`),a}function b(t,n){let i=[];for(let a of r(t))for(let t of a.errors){let r=f.has(t.id)?`markdoc/parse-error`:`markdoc/validation-error`;i.push({code:r,message:t.message,location:{filePath:n,range:e(a)??{start:{line:1},end:{line:1}}}})}return i}export{p as resolveMarkdownAst};
1
+ import{isObject as e}from"../../../shared/utils/is-object.js";import{markdocNodeRange as t}from"../utils/node-source-range.js";import{PARTIAL_L10N_ATTRIBUTE as n}from"../tags/partial.js";import{builtInMarkdocTags as r}from"../constants/builtin-tags.js";import{walkMarkdocAst as i}from"../utils/walk-markdoc-ast.js";import{getExampleContent as a,walkWithExampleContent as o}from"../utils/reparse-example-fences.js";import{parseMarkdownDocument as s}from"../utils/parse-cache.js";import{substituteStaticVariables as c}from"../utils/substitute-variables.js";import{collectMarkdocTagNames as l,isPromptTag as u,resolveMarkdocBuildTimeAttributes as d}from"./markdoc.js";import{inlineRawPartials as f}from"./raw-partials.js";import{renderMarkdocDiagrams as p}from"./render-diagrams.js";import m from"@redocly/markdoc";const h=/* @__PURE__ */ new Set([`parse-error`,`missing-opening`,`missing-closing`,`fence-tag-error`,`no-inline-annotations`]);async function g(e,t,n){let i=await f(e,t,n.resolverContext),a=s(i.source),o=n.validation?x(a,t,v(n.validation)):[],{entityDeps:u,assetUsages:h,linkRefs:g,problems:_}=await d(a,{tags:n.tags??r,sourceFilePath:t,resolverContext:n.resolverContext,source:i.source});n.variables&&c(a,n.variables);let y=await p(a,t,n.resolverContext.logger),b=w(a,t),S=n.transform?.(a)??[];return C(a),{ast:m.compact(a),entityDeps:[...i.entityDeps,...u],assetUsages:h,linkRefs:g,tagList:l(a),problems:[...i.problems,..._,...b,...o,...S,...y]}}const _=/* @__PURE__ */ new WeakMap;function v(e){let t=_.get(e);return t===void 0&&(t=m.prepareConfig({...e,tags:y(e.tags),nodes:y(e.nodes)}),_.set(e,t)),t}function y(e){if(e!==void 0)return Object.fromEntries(Object.entries(e).map(([e,t])=>{let{validate:n}=t;return n===void 0?[e,t]:[e,{...t,validate(e,t){try{return n.call(this,e,t)}catch(t){return[{id:`validate-failed`,level:`error`,message:`The validate() of '${e.tag??e.type}' failed: ${b(t)}`}]}}}]}))}const b=e=>e instanceof Error?e.message:String(e);function x(e,t,n){let r=[e],i=/* @__PURE__ */ new Set,s=[];for(let t of o(e,u)){for(let e of t.errors??[])i.add(e);let e=a(t);e&&r.push(e),u(t)&&s.push({node:t,children:t.children})}for(let e of s)e.node.children=[];try{return r.flatMap(e=>m.validate(e,n)).filter(e=>!i.has(e.error)).map(e=>S(e,t))}catch(e){return[{code:`markdoc/validation-error`,message:`Markdoc validation failed: ${b(e)}`,location:{filePath:t,range:{start:{line:1},end:{line:1}}}}]}finally{for(let e of s)e.node.children=e.children}}function S(e,n){let{level:r,message:i}=e.error,a={code:`markdoc/validation-error`,message:i,location:{filePath:n,range:t(e)??{start:{line:1},end:{line:1}}}};return r!==`error`&&r!==`critical`&&(a.severity=`warning`),a}function C(t){for(let r of i(t)){let t=r.tag===`partial`?r.attributes[n]:void 0;e(t)&&(r.attributes[n]=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,m.compact(t)])))}}function w(e,n){let r=[];for(let i of o(e))for(let e of i.errors){let a=h.has(e.id)?`markdoc/parse-error`:`markdoc/validation-error`;r.push({code:a,message:e.message,location:{filePath:n,range:t(i)??{start:{line:1},end:{line:1}}}})}return r}export{g as resolveMarkdownAst};
@@ -1,4 +1,4 @@
1
- import { type AssetAudienceDescriptor } from '../../../server/rbac/engine.js';
1
+ import { type AssetAudienceDescriptor } from '../../../shared/rbac/engine.js';
2
2
  export type AudienceTagResolver = (path: string) => Promise<string | null>;
3
3
  /**
4
4
  * Builds a per-invocation resolver from a raw `access.rbac` config value —
@@ -1 +1 @@
1
- import{compileAssetAudiences as e,compileRbacMatcher as t,deriveAssetTag as n,parseRbacConfigData as r,resolveAssetTagInputs as i}from"../../../server/rbac/engine.js";function a(e,a){let o=r(e);if(!o)return async()=>null;let s=t(o);return async e=>{let t=i(s,e);return t===null?null:(t.pattern===``&&a?.(`rbac config: "${e}" matches no content rule — it will be unreachable by any viewer. Add a catch-all "**" rule if this asset should be public.`),n(t))}}async function o(n,i){let a=r(n);return a?e(t(a),i):null}export{o as compileAssetAudienceTable,a as createAudienceTagResolver};
1
+ import{compileAssetAudiences as e,compileRbacMatcher as t,deriveAssetTag as n,parseRbacConfigData as r,resolveAssetTagInputs as i}from"../../../shared/rbac/engine.js";function a(e,a){let o=r(e);if(!o)return async()=>null;let s=t(o);return async e=>{let t=i(s,e);return t===null?null:(t.pattern===``&&a?.(`rbac config: "${e}" matches no content rule — it will be unreachable by any viewer. Add a catch-all "**" rule if this asset should be public.`),n(t))}}async function o(n,i){let a=r(n);return a?e(t(a),i):null}export{o as compileAssetAudienceTable,a as createAudienceTagResolver};
@@ -1 +1 @@
1
- import{isObject as e}from"../../../../shared/utils/is-object.js";import{markdocNodeProblem as t}from"../../utils/node-source-range.js";import{toContainedContentPath as n}from"../../../ingest/scan.js";import{resolveResolverTarget as r}from"./context-paths.js";import{join as i}from"node:path";async function a(e,t){let{bundle:n,createConfig:r,Source:a}=await import(`@redocly/openapi-core`),s=JSON.parse(JSON.stringify({openapi:`3.1.0`,components:{schemas:{__root:t}}})),c=i(e.contentDir,e.sourceFilePath),l=await n({config:await r({}),doc:{source:new a(c,``),parsed:s}}),u=l.bundle.parsed,d=u.components?.schemas,f=d?.__root?.$ref,p=typeof f==`string`?f.split(`/`).at(-1):void 0;return{oas:u,schema:p?d?.[p]:d?.__root,errors:(l.problems??[]).slice(0,1).map(e=>e.message),fileDeps:o(l.fileDependencies,e.contentDir,c)}}function o(e,t,r){if(e===void 0)return[];let i=/* @__PURE__ */ new Set;for(let a of e){let e=n(t,a);a!==r&&e!==null&&i.add(e)}return[...i].sort()}function s(e,t=[]){return e.length>0||t.length>0?{entityDeps:e.map(e=>({kind:`file`,path:e})),problems:t}:null}function c(e,n){let{node:r,attributeName:i}=e;return r.attributes[`${i}ResolvedErrors`]=n,e.logger?.warn(`${r.tag} in ${e.sourceFilePath}: ${n[0]}`),t(r,n[0],e.sourceFilePath)}async function l(t){let{node:n,attributeName:r}=t,i=n.attributes[r];if(!e(i))return null;let{oas:o,errors:l,fileDeps:u}=await a(t,i);return n.attributes[`${r}Resolved`]=o,l.length>0?s(u,[c(t,l)]):s(u)}async function u(t){let{node:n,attributeName:r}=t,i=n.attributes[r];if(!e(i)||n.attributes.value!==void 0)return null;let{oas:o,schema:l,errors:u,fileDeps:d}=await a(t,i);if(u.length>0)return s(d,[c(t,u)]);let f=n.attributes.mode,p=await import(`openapi-sampler`);try{n.attributes[`${r}Resolved`]=p.sample(l,{...f===`read`?{skipWriteOnly:!0}:void 0,...f===`write`?{skipReadOnly:!0}:void 0},o)}catch(e){return s(d,[c(t,[`Failed to generate a sample from the schema: ${e?.message??e}`])])}return s(d)}async function d(t){let{node:n,attributeName:i}=t,a=n.attributes[i],o=e=>({problems:[c(t,[e])]});if(a!==void 0&&n.attributes.schema!==void 0)return o(`The "schema" and "value" attributes are mutually exclusive, use only one.`);if(a===void 0)return n.attributes.schema===void 0?o(`The tag requires a "schema" or "value" attribute.`):null;let s=e(a)?a.$ref:void 0;if(typeof s!=`string`)return n.attributes[`${i}Resolved`]=a,null;let[l,u]=s.split(`#`),d=l?r(t,l):null;if(d===null||t.io===void 0)return o(`Invalid $ref "${s}": the path must stay inside the content directory.`);if(!await t.io.exists(d.absolutePath))return o(`Invalid $ref: no such file ${d.contentPath}`);let p=await t.io.readFile(d.absolutePath),m=[{kind:`file`,path:d.contentPath}],h;try{h=(await import(`js-yaml`)).load(p)}catch(e){return{entityDeps:m,...o(`File ${d.contentPath} must be valid JSON or YAML: ${e.message}`)}}let g=u?f(h,u):h;return u&&g===void 0?{entityDeps:m,...o(`Invalid $ref: ${d.contentPath} has no value at #${u}`)}:(n.attributes[`${i}Resolved`]=g,{entityDeps:m})}function f(t,n){let r=t;for(let t of n.split(`/`).slice(+!!n.startsWith(`/`))){let n=t.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`);if(Array.isArray(r))r=r[Number(n)];else if(e(r))r=r[n];else return}return r}export{d as resolveJsonExampleRefAttribute,l as resolveJsonSchemaRefAttribute,u as resolveSampleFromJsonSchemaAttribute};
1
+ import{isObject as e}from"../../../../shared/utils/is-object.js";import{toContainedContentPath as t}from"../../../ingest/scan.js";import{markdocNodeProblem as n}from"../../utils/node-source-range.js";import{resolveResolverTarget as r}from"./context-paths.js";import{join as i}from"node:path";async function a(e,t){let{bundle:n,createConfig:r,Source:a}=await import(`@redocly/openapi-core`),s=JSON.parse(JSON.stringify({openapi:`3.1.0`,components:{schemas:{__root:t}}})),c=i(e.contentDir,e.sourceFilePath),l=await n({config:await r({}),doc:{source:new a(c,``),parsed:s}}),u=l.bundle.parsed,d=u.components?.schemas,f=d?.__root?.$ref,p=typeof f==`string`?f.split(`/`).at(-1):void 0;return{oas:u,schema:p?d?.[p]:d?.__root,errors:(l.problems??[]).slice(0,1).map(e=>e.message),fileDeps:o(l.fileDependencies,e.contentDir,c)}}function o(e,n,r){if(e===void 0)return[];let i=/* @__PURE__ */ new Set;for(let a of e){let e=t(n,a);a!==r&&e!==null&&i.add(e)}return[...i].sort()}function s(e,t=[]){return e.length>0||t.length>0?{entityDeps:e.map(e=>({kind:`file`,path:e})),problems:t}:null}function c(e,t){let{node:r,attributeName:i}=e;return r.attributes[`${i}ResolvedErrors`]=t,e.logger?.warn(`${r.tag} in ${e.sourceFilePath}: ${t[0]}`),n(r,t[0],e.sourceFilePath)}async function l(t){let{node:n,attributeName:r}=t,i=n.attributes[r];if(!e(i))return null;let{oas:o,errors:l,fileDeps:u}=await a(t,i);return n.attributes[`${r}Resolved`]=o,l.length>0?s(u,[c(t,l)]):s(u)}async function u(t){let{node:n,attributeName:r}=t,i=n.attributes[r];if(!e(i)||n.attributes.value!==void 0)return null;let{oas:o,schema:l,errors:u,fileDeps:d}=await a(t,i);if(u.length>0)return s(d,[c(t,u)]);let f=n.attributes.mode,p=await import(`openapi-sampler`);try{n.attributes[`${r}Resolved`]=p.sample(l,{...f===`read`?{skipWriteOnly:!0}:void 0,...f===`write`?{skipReadOnly:!0}:void 0},o)}catch(e){return s(d,[c(t,[`Failed to generate a sample from the schema: ${e?.message??e}`])])}return s(d)}async function d(t){let{node:n,attributeName:i}=t,a=n.attributes[i],o=e=>({problems:[c(t,[e])]});if(a!==void 0&&n.attributes.schema!==void 0)return o(`The "schema" and "value" attributes are mutually exclusive, use only one.`);if(a===void 0)return n.attributes.schema===void 0?o(`The tag requires a "schema" or "value" attribute.`):null;let s=e(a)?a.$ref:void 0;if(typeof s!=`string`)return n.attributes[`${i}Resolved`]=a,null;let[l,u]=s.split(`#`),d=l?r(t,l):null;if(d===null||t.io===void 0)return o(`Invalid $ref "${s}": the path must stay inside the content directory.`);if(!await t.io.exists(d.absolutePath))return o(`Invalid $ref: no such file ${d.contentPath}`);let p=await t.io.readFile(d.absolutePath),m=[{kind:`file`,path:d.contentPath}],h;try{h=(await import(`js-yaml`)).load(p)}catch(e){return{entityDeps:m,...o(`File ${d.contentPath} must be valid JSON or YAML: ${e.message}`)}}let g=u?f(h,u):h;return u&&g===void 0?{entityDeps:m,...o(`Invalid $ref: ${d.contentPath} has no value at #${u}`)}:(n.attributes[`${i}Resolved`]=g,{entityDeps:m})}function f(t,n){let r=t;for(let t of n.split(`/`).slice(+!!n.startsWith(`/`))){let n=t.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`);if(Array.isArray(r))r=r[Number(n)];else if(e(r))r=r[n];else return}return r}export{d as resolveJsonExampleRefAttribute,l as resolveJsonSchemaRefAttribute,u as resolveSampleFromJsonSchemaAttribute};
@@ -1,7 +1,7 @@
1
1
  import type { ApiStore, CodeSamplePanelItem, CodeSampleSource, OpenAPIDefinition, ResponseCodeItem, findExampleEncoding } from '@redocly/api-docs';
2
2
  import { REDOCLY_TEAMS_RBAC } from '@redocly/config';
3
3
  import type { MarkdocAttributeResolverContext, MarkdocAttributeResolverResult } from '../../../plugins/types/markdoc.js';
4
- import type { RbacScope } from '../../../../server/rbac/types.js';
4
+ import type { RbacScope } from '../../../../shared/rbac/types.js';
5
5
  export type ResolvedSampleBlock = {
6
6
  lang: string;
7
7
  title: string;