@redocly/realm 0.129.0-next.2 → 0.129.0-next.4

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 (249) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/cli/develop.d.ts +1 -1
  4. package/dist/cli/develop.js +1 -1
  5. package/dist/cli/prepare/analytics/collectors/get-file-extensions-usage.js +1 -1
  6. package/dist/cli/prepare/analytics/collectors/get-frontmatter-usage.js +1 -1
  7. package/dist/cli/prepare/analytics/collectors/get-markdoc-usage.js +1 -1
  8. package/dist/cli/prepare/analytics/collectors/get-nested-configs-usage.js +1 -1
  9. package/dist/cli/prepare/analytics/collectors/get-refs-usage.js +1 -1
  10. package/dist/cli/prepare/index.d.ts +1 -1
  11. package/dist/cli/translations/collect-config-translations.js +1 -1
  12. package/dist/cli/translations/update-translations.js +1 -1
  13. package/dist/client/TestProvider.js +1 -1
  14. package/dist/client/app/Sidebar/RequestAccessButton.js +2 -2
  15. package/dist/client/app/Sidebar/Sidebar.js +7 -2
  16. package/dist/client/app/Sidebar/useSidebarItems.d.ts +1 -0
  17. package/dist/client/app/Sidebar/useSidebarItems.js +1 -1
  18. package/dist/client/app/hooks/catalog/useFetchCatalogEntities.js +1 -1
  19. package/dist/client/app/hooks/catalog/useFetchCatalogEntitiesRelations.js +1 -1
  20. package/dist/client/app/hooks/catalog/useFetchCatalogEntityRevisions.d.ts +10 -0
  21. package/dist/client/app/hooks/catalog/useFetchCatalogEntityRevisions.js +1 -0
  22. package/dist/client/app/hooks/index.d.ts +1 -0
  23. package/dist/client/app/hooks/index.js +1 -1
  24. package/dist/client/app/hooks/useLoginUrl.js +1 -1
  25. package/dist/client/app/pages/DevLogin/DevLogin.js +1 -1
  26. package/dist/client/app/pages/Login/Login.js +1 -1
  27. package/dist/client/app/utils/loadAndNavigate.js +1 -1
  28. package/dist/client/browser-entry.js +2 -2
  29. package/dist/client/providers/page-data/hooks.d.ts +2 -1
  30. package/dist/client/providers/page-data/hooks.js +1 -1
  31. package/dist/client/providers/theme/ThemeDataProvider.js +1 -1
  32. package/dist/client/runtime/loader.js +1 -1
  33. package/dist/client/utils/catalog/inject-catalog-items.d.ts +1 -1
  34. package/dist/client/utils/catalog/inject-catalog-items.js +1 -1
  35. package/dist/constants/common.d.ts +0 -4
  36. package/dist/constants/common.js +1 -1
  37. package/dist/constants/l10n/langs/ar.js +1 -1
  38. package/dist/constants/l10n/langs/de.js +1 -1
  39. package/dist/constants/l10n/langs/en.js +1 -1
  40. package/dist/constants/l10n/langs/es.js +1 -1
  41. package/dist/constants/l10n/langs/fr.js +1 -1
  42. package/dist/constants/l10n/langs/hi.js +1 -1
  43. package/dist/constants/l10n/langs/it.js +1 -1
  44. package/dist/constants/l10n/langs/ja.js +1 -1
  45. package/dist/constants/l10n/langs/ko.js +1 -1
  46. package/dist/constants/l10n/langs/pl.js +1 -1
  47. package/dist/constants/l10n/langs/pt-BR.js +1 -1
  48. package/dist/constants/l10n/langs/pt.js +1 -1
  49. package/dist/constants/l10n/langs/ru.js +1 -1
  50. package/dist/constants/l10n/langs/uk.js +1 -1
  51. package/dist/constants/l10n/langs/zh.js +1 -1
  52. package/dist/server/api-routes/execute-api-route.d.ts +0 -7
  53. package/dist/server/api-routes/execute-api-route.js +1 -1
  54. package/dist/server/api-routes/helpers/setup-logger.d.ts +2 -2
  55. package/dist/server/api-routes/helpers/setup-logger.js +1 -1
  56. package/dist/server/api-routes/run-api-routes-worker.js +1 -1
  57. package/dist/server/fs/cache.d.ts +1 -2
  58. package/dist/server/fs/cache.js +1 -1
  59. package/dist/server/fs/content-fs.d.ts +9 -4
  60. package/dist/server/fs/content-fs.js +1 -1
  61. package/dist/server/fs/fs.d.ts +6 -6
  62. package/dist/server/fs/fs.js +1 -3
  63. package/dist/server/fs/load-error.d.ts +2 -2
  64. package/dist/server/fs/load-error.js +1 -1
  65. package/dist/server/fs/utils/async-storage.d.ts +0 -8
  66. package/dist/server/fs/utils/async-storage.js +1 -1
  67. package/dist/server/fs/utils/isVirtualFile.d.ts +1 -1
  68. package/dist/server/fs/utils/isVirtualFile.js +1 -1
  69. package/dist/server/plugins/api-functions/index.js +1 -1
  70. package/dist/server/plugins/arazzo-docs/arazzo-doc-loader.d.ts +1 -1
  71. package/dist/server/plugins/arazzo-docs/arazzo-doc-loader.js +2 -2
  72. package/dist/server/plugins/arazzo-docs/index.d.ts +1 -1
  73. package/dist/server/plugins/arazzo-docs/index.js +1 -1
  74. package/dist/server/plugins/asyncapi-docs/asyncapi-doc-loader.d.ts +1 -1
  75. package/dist/server/plugins/asyncapi-docs/asyncapi-doc-loader.js +2 -2
  76. package/dist/server/plugins/asyncapi-docs/index.d.ts +1 -1
  77. package/dist/server/plugins/asyncapi-docs/index.js +1 -1
  78. package/dist/server/plugins/asyncapi-docs/is-asyncapi-doc.js +1 -1
  79. package/dist/server/plugins/catalog-entities/database/catalog-entities-service.d.ts +23 -18
  80. package/dist/server/plugins/catalog-entities/database/catalog-entities-service.js +1 -1
  81. package/dist/server/plugins/catalog-entities/database/mappers/create-bff-entity.js +1 -1
  82. package/dist/server/plugins/catalog-entities/database/mappers/create-bff-related-entity.d.ts +9 -0
  83. package/dist/server/plugins/catalog-entities/database/mappers/create-bff-related-entity.js +1 -1
  84. package/dist/server/plugins/catalog-entities/database/mappers/create-entity-db-record.d.ts +1 -0
  85. package/dist/server/plugins/catalog-entities/database/mappers/create-entity-db-record.js +1 -1
  86. package/dist/server/plugins/catalog-entities/database/mappers/create-entity-read-model.js +1 -1
  87. package/dist/server/plugins/catalog-entities/database/mappers/create-entity-relation-db-record-from-dto.js +1 -1
  88. package/dist/server/plugins/catalog-entities/database/mappers/create-entity-relation-db-record-from-file-schema.js +1 -1
  89. package/dist/server/plugins/catalog-entities/database/mappers/create-entity-relation.js +1 -1
  90. package/dist/server/plugins/catalog-entities/database/mappers/map-entity-relation-row.d.ts +12 -0
  91. package/dist/server/plugins/catalog-entities/database/mappers/map-entity-relation-row.js +1 -0
  92. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-read-repository.d.ts +15 -4
  93. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-read-repository.js +67 -55
  94. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.d.ts +21 -15
  95. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.js +1 -1
  96. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-write-repository.d.ts +16 -3
  97. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-write-repository.js +1 -1
  98. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-relations-repository.d.ts +17 -0
  99. package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-relations-repository.js +1 -0
  100. package/dist/server/plugins/catalog-entities/database/repositories/utils.d.ts +4 -4
  101. package/dist/server/plugins/catalog-entities/database/repositories/utils.js +1 -1
  102. package/dist/server/plugins/catalog-entities/entities/{extract-entities-content.d.ts → extract-file-content.d.ts} +1 -1
  103. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/arazzo-entities-extractor.d.ts +2 -2
  104. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/arazzo-entities-extractor.js +1 -1
  105. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/asyncapi-entities-extractor.d.ts +2 -2
  106. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/asyncapi-entities-extractor.js +1 -1
  107. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/base.d.ts +2 -2
  108. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/base.js +1 -1
  109. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/graphql-entities-extractor.d.ts +2 -2
  110. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/graphql-entities-extractor.js +2 -2
  111. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/openapi-entities-extractor.d.ts +2 -2
  112. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/openapi-entities-extractor.js +1 -1
  113. package/dist/server/plugins/catalog-entities/extensions/extractors/fs-entities-extractor.js +1 -1
  114. package/dist/server/plugins/catalog-entities/get-server-props.d.ts +1 -2
  115. package/dist/server/plugins/catalog-entities/get-server-props.js +1 -1
  116. package/dist/server/plugins/catalog-entities/schemas/database-schemas.d.ts +64 -0
  117. package/dist/server/plugins/catalog-entities/schemas/database-schemas.js +1 -1
  118. package/dist/server/plugins/catalog-entities/schemas/dto-schemas.d.ts +6 -12
  119. package/dist/server/plugins/catalog-entities/schemas/dto-schemas.js +1 -1
  120. package/dist/server/plugins/catalog-entities/schemas/read-model-schemas.d.ts +4 -8
  121. package/dist/server/plugins/catalog-entities/schemas/read-model-schemas.js +1 -1
  122. package/dist/server/plugins/catalog-entities/utils/catalog-data-collector.js +1 -1
  123. package/dist/server/plugins/catalog-entities/utils/read-string.d.ts +7 -0
  124. package/dist/server/plugins/catalog-entities/utils/read-string.js +1 -0
  125. package/dist/server/plugins/config-parser/loaders/content-slugs-loader.js +1 -1
  126. package/dist/server/plugins/config-parser/loaders/nearest-redocly-config-loader.js +1 -1
  127. package/dist/server/plugins/config-parser/loaders/utils/read-and-validate-config.js +1 -1
  128. package/dist/server/plugins/config-parser/loaders/yaml-parser.js +1 -1
  129. package/dist/server/plugins/default-theme/resolve-products-config.js +1 -1
  130. package/dist/server/plugins/ensure-frontmatter-theme-compatibility.js +1 -1
  131. package/dist/server/plugins/entitlements/index.js +1 -1
  132. package/dist/server/plugins/graphql-docs/index.js +1 -1
  133. package/dist/server/plugins/l10n/index.js +1 -1
  134. package/dist/server/plugins/lifecycle.js +2 -2
  135. package/dist/server/plugins/markdown/attribute-resolvers/code-walkthrough/filesets-resolver.js +1 -1
  136. package/dist/server/plugins/markdown/attribute-resolvers/resolve-code-snippet-from-file.js +1 -1
  137. package/dist/server/plugins/markdown/attribute-resolvers/resolve-link.d.ts +1 -1
  138. package/dist/server/plugins/markdown/attribute-resolvers/resolve-link.js +1 -1
  139. package/dist/server/plugins/markdown/attribute-resolvers/resolve-open-api-ref.js +1 -1
  140. package/dist/server/plugins/markdown/attribute-resolvers/resolve-parsed-yaml.js +1 -1
  141. package/dist/server/plugins/markdown/attribute-resolvers/resolve-raw-content.js +1 -1
  142. package/dist/server/plugins/markdown/attribute-resolvers/resolve-svg-content.js +1 -1
  143. package/dist/server/plugins/markdown/compiler.js +1 -1
  144. package/dist/server/plugins/markdown/get-server-props.js +1 -1
  145. package/dist/server/plugins/markdown/index.js +1 -1
  146. package/dist/server/plugins/markdown/markdoc/partials.js +1 -1
  147. package/dist/server/plugins/markdown/markdoc/resolve-raw-partials.js +1 -1
  148. package/dist/server/plugins/markdown/markdown-static-data-loader.js +1 -1
  149. package/dist/server/plugins/mcp/auth/auth-handlers.d.ts +1 -1
  150. package/dist/server/plugins/mcp/auth/auth-handlers.js +1 -1
  151. package/dist/server/plugins/mcp/docs-mcp/tools/get-endpoint-info.d.ts +7 -2
  152. package/dist/server/plugins/mcp/docs-mcp/tools/get-endpoint-info.js +1 -1
  153. package/dist/server/plugins/mcp/docs-mcp/tools/get-endpoints.d.ts +7 -2
  154. package/dist/server/plugins/mcp/docs-mcp/tools/get-endpoints.js +1 -1
  155. package/dist/server/plugins/mcp/docs-mcp/tools/get-full-api-description.d.ts +7 -2
  156. package/dist/server/plugins/mcp/docs-mcp/tools/get-full-api-description.js +1 -1
  157. package/dist/server/plugins/mcp/docs-mcp/tools/get-security-schemes.d.ts +7 -2
  158. package/dist/server/plugins/mcp/docs-mcp/tools/get-security-schemes.js +1 -1
  159. package/dist/server/plugins/mcp/docs-mcp/tools/index.d.ts +4 -3
  160. package/dist/server/plugins/mcp/docs-mcp/tools/index.js +1 -1
  161. package/dist/server/plugins/mcp/docs-mcp/tools/list-apis.d.ts +5 -2
  162. package/dist/server/plugins/mcp/docs-mcp/tools/list-apis.js +1 -1
  163. package/dist/server/plugins/mcp/docs-mcp/tools/utils.d.ts +6 -0
  164. package/dist/server/plugins/mcp/docs-mcp/tools/utils.js +6 -6
  165. package/dist/server/plugins/mcp/docs-mcp/tools/whoami.js +1 -1
  166. package/dist/server/plugins/mcp/docs-mcp/utils.d.ts +3 -3
  167. package/dist/server/plugins/mcp/docs-mcp/utils.js +1 -1
  168. package/dist/server/plugins/mcp/handlers/docs-mcp-handler.js +1 -1
  169. package/dist/server/plugins/mcp/index.js +1 -1
  170. package/dist/server/plugins/mcp/servers/docs-server.d.ts +10 -3
  171. package/dist/server/plugins/mcp/servers/docs-server.js +1 -1
  172. package/dist/server/plugins/mcp/types.d.ts +26 -2
  173. package/dist/server/plugins/mcp/utils.d.ts +9 -8
  174. package/dist/server/plugins/mcp/utils.js +1 -1
  175. package/dist/server/plugins/mcp/workers/run-api-routes-worker.js +1 -1
  176. package/dist/server/plugins/nav-utils.js +1 -1
  177. package/dist/server/plugins/openapi-docs/decorators.d.ts +3 -2
  178. package/dist/server/plugins/openapi-docs/decorators.js +1 -1
  179. package/dist/server/plugins/openapi-docs/index.d.ts +2 -2
  180. package/dist/server/plugins/openapi-docs/index.js +1 -1
  181. package/dist/server/plugins/openapi-docs/is-openapi-doc.js +1 -1
  182. package/dist/server/plugins/openapi-docs/load-definition.d.ts +1 -1
  183. package/dist/server/plugins/openapi-docs/load-definition.js +3 -3
  184. package/dist/server/plugins/pages/index.js +1 -1
  185. package/dist/server/plugins/search/llmstxt/index.js +5 -5
  186. package/dist/server/plugins/sidebars/index.js +3 -3
  187. package/dist/server/plugins/utils.js +1 -1
  188. package/dist/server/providers/database/databases/catalog-sqlite/migrations/0003_catalog_versions_and_revisions_relations.sql +40 -0
  189. package/dist/server/providers/database/databases/catalog-sqlite/migrations/meta/0003_snapshot.json +392 -0
  190. package/dist/server/providers/database/databases/catalog-sqlite/migrations/meta/_journal.json +7 -0
  191. package/dist/server/providers/database/databases/catalog-sqlite/schemas/entities-relations-table.d.ts +25 -46
  192. package/dist/server/providers/database/databases/catalog-sqlite/schemas/entities-relations-table.js +1 -1
  193. package/dist/server/providers/database/databases/catalog-sqlite/schemas/entities-table.d.ts +20 -3
  194. package/dist/server/providers/database/databases/catalog-sqlite/schemas/entities-table.js +1 -1
  195. package/dist/server/providers/database/databases/main-sqlite/migrations/meta/0005_snapshot.json +263 -0
  196. package/dist/server/providers/database/databases/sqld-sqlite/migrations/0006_catalog-versions-and-revisions-relations.sql +40 -0
  197. package/dist/server/providers/database/databases/sqld-sqlite/migrations/meta/0005_snapshot.json +825 -0
  198. package/dist/server/providers/database/databases/sqld-sqlite/migrations/meta/0006_snapshot.json +832 -0
  199. package/dist/server/providers/database/databases/sqld-sqlite/migrations/meta/_journal.json +7 -0
  200. package/dist/server/providers/database/pagination/combined-filters.d.ts +4 -1
  201. package/dist/server/providers/database/pagination/combined-filters.js +1 -1
  202. package/dist/server/providers/database/pagination/filter.d.ts +1 -0
  203. package/dist/server/providers/database/pagination/filter.js +1 -1
  204. package/dist/server/providers/database/pagination/index.d.ts +4 -1
  205. package/dist/server/store.js +1 -1
  206. package/dist/server/tools/notifiers/formatter.d.ts +2 -0
  207. package/dist/server/tools/notifiers/formatter.js +3 -3
  208. package/dist/server/tools/notifiers/logger.d.ts +18 -39
  209. package/dist/server/tools/notifiers/logger.js +2 -6
  210. package/dist/server/tools/notifiers/reporter.js +9 -9
  211. package/dist/server/tools/notifiers/terminal-manager.d.ts +8 -0
  212. package/dist/server/tools/notifiers/terminal-manager.js +5 -0
  213. package/dist/server/types/fs.d.ts +5 -10
  214. package/dist/server/types/plugins/api-routes.d.ts +0 -3
  215. package/dist/server/types/plugins/common.d.ts +0 -1
  216. package/dist/server/utils/is-valid-iso-date.d.ts +5 -0
  217. package/dist/server/utils/is-valid-iso-date.js +1 -0
  218. package/dist/server/utils/lifecycle-hooks.js +1 -1
  219. package/dist/server/utils/queue.js +1 -1
  220. package/dist/server/utils/redirects/find-redirect.d.ts +4 -2
  221. package/dist/server/utils/redirects/find-redirect.js +1 -1
  222. package/dist/server/utils/resolve-asset-path.js +1 -1
  223. package/dist/server/utils/validate-and-sanitize-string.d.ts +29 -0
  224. package/dist/server/utils/validate-and-sanitize-string.js +1 -0
  225. package/dist/server/web-server/auth.d.ts +5 -0
  226. package/dist/server/web-server/auth.js +3 -3
  227. package/dist/server/web-server/http.js +2 -2
  228. package/dist/server/web-server/middleware/loggerMiddleware.js +1 -1
  229. package/dist/server/web-server/routes/auth.js +1 -1
  230. package/dist/server/web-server/routes/catalog/bff-catalog-related-entities.js +1 -1
  231. package/dist/server/web-server/routes/catalog/bff-catalog.js +1 -1
  232. package/dist/server/web-server/routes/catalog/catalog-relations.js +1 -1
  233. package/dist/server/web-server/routes/mcp-oauth.js +1 -1
  234. package/dist/server/web-server/routes/search.js +1 -1
  235. package/dist/server/web-server/utils/get-redirect-login-url.js +1 -1
  236. package/dist/utils/auth/build-login-url.d.ts +1 -3
  237. package/dist/utils/auth/build-login-url.js +1 -1
  238. package/dist/utils/env/is-local-development.d.ts +13 -0
  239. package/dist/utils/env/is-local-development.js +1 -0
  240. package/dist/utils/env/is-production.d.ts +13 -0
  241. package/dist/utils/env/is-production.js +1 -0
  242. package/dist/utils/env/is-web-view.d.ts +14 -0
  243. package/dist/utils/env/is-web-view.js +1 -0
  244. package/dist/utils/path/remove-fragment.d.ts +16 -0
  245. package/dist/utils/path/remove-fragment.js +1 -0
  246. package/package.json +10 -10
  247. package/dist/server/web-server/routes/otel/types.d.ts +0 -61
  248. package/dist/server/web-server/routes/otel/types.js +0 -1
  249. /package/dist/server/plugins/catalog-entities/entities/{extract-entities-content.js → extract-file-content.js} +0 -0
@@ -43,6 +43,13 @@
43
43
  "when": 1765477755000,
44
44
  "tag": "0005_recreate-scorecards-tables",
45
45
  "breakpoints": true
46
+ },
47
+ {
48
+ "idx": 6,
49
+ "version": "6",
50
+ "when": 1766391516611,
51
+ "tag": "0006_catalog-versions-and-revisions-relations",
52
+ "breakpoints": true
46
53
  }
47
54
  ]
48
55
  }
@@ -1,4 +1,7 @@
1
1
  import type { SQLiteSelect } from 'drizzle-orm/sqlite-core';
2
+ import type { SQL } from 'drizzle-orm';
2
3
  import type { PaginationParams } from './schemas.js';
3
- export declare const applyCombinedFilters: <T extends SQLiteSelect>(sqlBuilder: T, paginationParams: PaginationParams) => T;
4
+ export declare const applyCombinedFilters: <T extends SQLiteSelect>(sqlBuilder: T, paginationParams: PaginationParams & {
5
+ baseWhereCondition?: SQL;
6
+ }) => T;
4
7
  //# sourceMappingURL=combined-filters.d.ts.map
@@ -1 +1 @@
1
- import{and as p}from"drizzle-orm";import{applyFilter as f}from"./filter.js";import{applySearch as h}from"./search.js";import{applyAfterAndBefore as c}from"./after-and-before.js";const d=(e,t)=>{const o=[],{whereCondition:r}=f(e,t.filter);r&&o.push(r);const{whereCondition:n}=h(e,t);n&&o.push(n);const{whereCondition:i}=c(e,t);return i&&o.push(i),o.length===0?e:o.length===1?e.where(o[0]):e.where(p(...o))};export{d as applyCombinedFilters};
1
+ import{and as h}from"drizzle-orm";import{applyFilter as f}from"./filter.js";import{applySearch as p}from"./search.js";import{applyAfterAndBefore as C}from"./after-and-before.js";const m=(o,t)=>{const e=[];t.baseWhereCondition&&e.push(t.baseWhereCondition);const{whereCondition:r}=f(o,t.filter);r&&e.push(r);const{whereCondition:n}=p(o,t);n&&e.push(n);const{whereCondition:i}=C(o,t);return i&&e.push(i),e.length===0?o:e.length===1?o.where(e[0]):o.where(h(...e))};export{m as applyCombinedFilters};
@@ -8,4 +8,5 @@ export declare function applyFilter<T extends SQLiteSelect | SQLiteDelete>(sqlBu
8
8
  export declare function convertFilterToWhereCondition(filter?: Filter): SQL | undefined;
9
9
  export declare function getFirstFilterFieldValue(filter: Filter | undefined, fieldName: string): FilterClause['value'] | undefined;
10
10
  export declare function parseFilterQuery(query?: string, availableFields?: string[], fieldsTransformations?: Record<string, string>): Filter | undefined;
11
+ export declare function excludeFieldsFromFilter(filter: Filter | undefined, fieldsToExclude: string[]): Filter | undefined;
11
12
  //# sourceMappingURL=filter.d.ts.map
@@ -1 +1 @@
1
- import{and as R,between as T,eq as x,inArray as C,isNotNull as L,isNull as I,like as v,ne as k,notBetween as y,notInArray as W,notLike as b,or as d,sql as a}from"drizzle-orm";import{isFilterCondition as g}from"./types.js";import{transformToSnakeCase as q}from"./utils/transform-to-snake-case.js";import{isFieldAllowed as D}from"./utils/field-pattern-matcher.js";import{OPERATORS as $}from"./constants.js";const U=["domains","owners"],P=["tags"];function z(t,e){const o=J(e);return o?{sqlBuilder:t,whereCondition:o}:{sqlBuilder:t,whereCondition:null}}function J(t){if(t)return g(t)?j(t):A(t)}const j=t=>{const{op:e,conditions:o}=t,n=[];for(const c of o){if(g(c)){const r=j(c);r&&n.push(r);continue}const i=A(c);i&&n.push(i)}return e===$.AND?R(...n):d(...n)},H=(t,e)=>e.length>1?`$.${e.slice(1).join(".")}.${t}`:`$.${t}`,E=({operator:t,value:e,field:o,parentFields:n,negation:c})=>{const i=a.identifier(n[0]),r=H(o,n);switch(t){case"equal":return c?a`(json_extract(${i}, ${r}) != ${e} OR json_extract(${i}, ${r}) IS NULL)`:a`json_extract(${i}, ${r}) == ${e}`;case"equalNull":return c?a`json_extract(${i}, ${r}) IS NOT NULL`:a`json_extract(${i}, ${r}) IS NULL`;case"contains":return c?a`(json_extract(${i}, ${r}) NOT LIKE ${e} OR json_extract(${i}, ${r}) IS NULL)`:a`json_extract(${i}, ${r}) LIKE ${e}`;case"in":if(Array.isArray(e)){const s=e.map(l=>a`json_extract(${i}, ${r}) == ${l}`);return c?a`(NOT (${d(...s)}) OR json_extract(${i}, ${r}) IS NULL)`:d(...s)}break;case"between":if(Array.isArray(e)&&e.length===2)return c?a`(NOT (json_extract(${i}, ${r}) BETWEEN ${e[0]} AND ${e[1]}) OR json_extract(${i}, ${r}) IS NULL)`:a`json_extract(${i}, ${r}) BETWEEN ${e[0]} AND ${e[1]}`;break;default:throw new Error(`Unsupported operator: ${t} for json path`)}};function G(t,e){if(!t)return;const o=c=>{if(g(c)){for(const i of c.conditions){const r=o(i);if(r!==void 0)return r}return}if(c.field===e)return c.value},n=o(t);return typeof n=="string"?n.trim()===""?null:n.trim():n??null}const M=t=>{const{field:e,operator:o,value:n,modifier:c,parentFields:i}=t,r=c==="not";if(!i||i.length<1)throw new Error("convertNestedFilterClauseToSql called without parentFields");switch(o){case"equal":return E(n===null?{operator:"equalNull",value:n,field:e,parentFields:i,negation:r}:{operator:o,value:n,field:e,parentFields:i,negation:r});case"contains":if(typeof n=="string"){const s=n.startsWith("%")||n.endsWith("%")?n:`%${n}%`;return E({operator:o,value:s,field:e,parentFields:i,negation:r})}break;case"in":if(Array.isArray(n))return E({operator:o,value:n,field:e,parentFields:i,negation:r});break;case"between":if(Array.isArray(n)&&n.length===2)return E({operator:o,value:n,field:e,parentFields:i,negation:r});break;default:throw new Error(`Unsupported filter operator: ${o}`)}},A=t=>{const{field:e,operator:o,value:n,modifier:c,parentFields:i}=t;if(i&&i.length>=1)return M(t);const r=c==="not",s=a.identifier(e),l=P.includes(e),f=U.includes(e);switch(o){case"equal":return n===null?r?L(s):I(s):f?r?a`NOT EXISTS (SELECT 1 FROM json_each(${s}) WHERE json_extract(json_each.value, '$.key') = ${n})`:a`EXISTS (SELECT 1 FROM json_each(${s}) WHERE json_extract(json_each.value, '$.key') = ${n})`:l?r?a`NOT EXISTS (SELECT 1 FROM json_each(${s}) WHERE json_each.value = ${n})`:a`EXISTS (SELECT 1 FROM json_each(${s}) WHERE json_each.value = ${n})`:r?k(s,n):x(s,n);case"contains":if(typeof n=="string"){const u=n.startsWith("%")||n.endsWith("%")?n:`%${n}%`;return r?b(s,u):v(s,u)}break;case"in":if(Array.isArray(n)){if(f){const u=n.map(p=>a`EXISTS (SELECT 1 FROM json_each(${s}) WHERE json_extract(json_each.value, '$.key') = ${p})`);return r?a`NOT (${d(...u)})`:d(...u)}else if(l){const u=n.map(p=>a`EXISTS (SELECT 1 FROM json_each(${s}) WHERE json_each.value = ${p})`);return r?a`NOT (${d(...u)})`:d(...u)}return r?W(s,n):C(s,n)}break;case"between":if(Array.isArray(n)&&n.length===2)return r?y(s,n[0],n[1]):T(s,n[0],n[1]);break;default:throw new Error(`Unsupported filter operator: ${o}`)}},N=["'",'"'];function Z(t="",e=[],o={}){if(!t||!t.trim())return;const n=S(t);return O(n,e,o)}function F(t){const e=X(t);if(e.operator===":"){const o=w(e.value,",");if(o.length>1)return{operator:"in",field:e.field,parentFields:e.parentFields,value:o.map(m),modifier:e.modifier};const n=w(e.value,"..");return n.length===2?{operator:"between",field:e.field,parentFields:e.parentFields,value:[m(n[0]),m(n[1])],modifier:e.modifier}:{operator:"equal",field:e.field,parentFields:e.parentFields,value:e.value==="null"?null:m(e.value),modifier:e.modifier}}else if(e.operator==="~")return{operator:"contains",field:e.field,parentFields:e.parentFields,value:m(e.value),modifier:e.modifier};throw new Error(`Unsupported filter clause: ${t}`)}function X(t){const e="^(?<modifier>^-?)",o="(?<field>[a-z][\\w.]*)",n="(?<operator>:|~)",c="(?<value>.+)",i=new RegExp(`^${e}${o}${n}${c}$`,"i"),r=t.match(i);if(!r||!r.groups)throw new Error(`Invalid filter clause: ${t}`);const{operator:s,value:l,modifier:f}=r.groups,u=r.groups.field.split(".");return{field:u.pop(),parentFields:u,operator:s,value:l,modifier:f==="-"?"not":void 0}}function w(t,e){const o=[];let n="",c=!1,i=0;for(let r=0;r<t.length;r++){const s=t[r-1],l=t[r];if(i>0){i--;continue}s!=="\\"&&N.includes(l)&&(c=!c),!c&&t.slice(r,r+e.length)===e?(o.push(n),n="",i=e.length-1):n+=l}return n&&o.push(n),o}function m(t){for(const e of N)if(t.startsWith(e)&&t.endsWith(e))return t.slice(1,-1);return t}function S(t){let e="",o=0,n=!1,c="";const i=[];for(let s=0;s<t.length;s++){const l=t[s],f=t[s+1];if(['"',"'"].includes(l)&&(s===0||t[s-1]!=="\\")){if(!n){n=!0,c=l,e+=l;continue}if(l===c){n=!1,c="",e+=l;continue}}if(n){e+=l;continue}if(o===0){const u=f==="A"&&t.slice(s+1,s+5)===`${$.AND} `;if(l===" "&&u){const h=e.trim();h&&(i.push(F(h)),e="");const _=S(t.slice(s+5));return{op:$.AND,conditions:[...i,_]}}const p=f==="O"&&t.slice(s+1,s+4)===`${$.OR} `;if(l===" "&&p){const h=e.trim();h&&(i.push(F(h)),e="");const _=S(t.slice(s+4));return{op:$.OR,conditions:[...i,_]}}}if(l==="("){const u=e.trim();o===0&&u&&(i.push(F(u)),e=""),o++,e+=l;continue}if(l===")"){if(o--,e+=l,o===0){const u=e.slice(1,-1);i.push(S(u)),e=""}continue}e+=l}const r=e.trim();return r&&i.push(F(r)),i.length===1?i[0]:{op:$.AND,conditions:i}}function O(t,e,o){if("field"in t){const n=t.parentFields?.length?`${t.parentFields.join(".")}.${t.field}`:t.field;if(!D(n,e))throw new Error(`Invalid filter field: ${n}`);const c=t.parentFields?.length?t.field:o[t.field]||q(t.field);return{...t,field:c}}else return{...t,conditions:t.conditions.map(n=>O(n,e,o))}}export{z as applyFilter,J as convertFilterToWhereCondition,G as getFirstFilterFieldValue,Z as parseFilterQuery};
1
+ import{and as O,between as R,eq as T,inArray as C,isNotNull as L,isNull as I,like as v,ne as k,notBetween as y,notInArray as W,notLike as b,or as d,sql as a}from"drizzle-orm";import{isFilterCondition as F}from"./types.js";import{transformToSnakeCase as q}from"./utils/transform-to-snake-case.js";import{isFieldAllowed as D}from"./utils/field-pattern-matcher.js";import{OPERATORS as h}from"./constants.js";const U=["domains","owners"],P=["tags"];function z(t,e){const o=J(e);return o?{sqlBuilder:t,whereCondition:o}:{sqlBuilder:t,whereCondition:null}}function J(t){if(t)return F(t)?j(t):x(t)}const j=t=>{const{op:e,conditions:o}=t,n=[];for(const l of o){if(F(l)){const r=j(l);r&&n.push(r);continue}const i=x(l);i&&n.push(i)}return e===h.AND?O(...n):d(...n)},H=(t,e)=>e.length>1?`$.${e.slice(1).join(".")}.${t}`:`$.${t}`,m=({operator:t,value:e,field:o,parentFields:n,negation:l})=>{const i=a.identifier(n[0]),r=H(o,n);switch(t){case"equal":return l?a`(json_extract(${i}, ${r}) != ${e} OR json_extract(${i}, ${r}) IS NULL)`:a`json_extract(${i}, ${r}) == ${e}`;case"equalNull":return l?a`json_extract(${i}, ${r}) IS NOT NULL`:a`json_extract(${i}, ${r}) IS NULL`;case"contains":return l?a`(json_extract(${i}, ${r}) NOT LIKE ${e} OR json_extract(${i}, ${r}) IS NULL)`:a`json_extract(${i}, ${r}) LIKE ${e}`;case"in":if(Array.isArray(e)){const s=e.map(c=>a`json_extract(${i}, ${r}) == ${c}`);return l?a`(NOT (${d(...s)}) OR json_extract(${i}, ${r}) IS NULL)`:d(...s)}break;case"between":if(Array.isArray(e)&&e.length===2)return l?a`(NOT (json_extract(${i}, ${r}) BETWEEN ${e[0]} AND ${e[1]}) OR json_extract(${i}, ${r}) IS NULL)`:a`json_extract(${i}, ${r}) BETWEEN ${e[0]} AND ${e[1]}`;break;default:throw new Error(`Unsupported operator: ${t} for json path`)}};function G(t,e){if(!t)return;const o=l=>{if(F(l)){for(const i of l.conditions){const r=o(i);if(r!==void 0)return r}return}if(l.field===e)return l.value},n=o(t);return typeof n=="string"?n.trim()===""?null:n.trim():n??null}const M=t=>{const{field:e,operator:o,value:n,modifier:l,parentFields:i}=t,r=l==="not";if(!i||i.length<1)throw new Error("convertNestedFilterClauseToSql called without parentFields");switch(o){case"equal":return m(n===null?{operator:"equalNull",value:n,field:e,parentFields:i,negation:r}:{operator:o,value:n,field:e,parentFields:i,negation:r});case"contains":if(typeof n=="string"){const s=n.startsWith("%")||n.endsWith("%")?n:`%${n}%`;return m({operator:o,value:s,field:e,parentFields:i,negation:r})}break;case"in":if(Array.isArray(n))return m({operator:o,value:n,field:e,parentFields:i,negation:r});break;case"between":if(Array.isArray(n)&&n.length===2)return m({operator:o,value:n,field:e,parentFields:i,negation:r});break;default:throw new Error(`Unsupported filter operator: ${o}`)}},x=t=>{const{field:e,operator:o,value:n,modifier:l,parentFields:i}=t;if(i&&i.length>=1)return M(t);const r=l==="not",s=a.identifier(e),c=P.includes(e),f=U.includes(e);switch(o){case"equal":return n===null?r?L(s):I(s):f?r?a`NOT EXISTS (SELECT 1 FROM json_each(${s}) WHERE json_extract(json_each.value, '$.key') = ${n})`:a`EXISTS (SELECT 1 FROM json_each(${s}) WHERE json_extract(json_each.value, '$.key') = ${n})`:c?r?a`NOT EXISTS (SELECT 1 FROM json_each(${s}) WHERE json_each.value = ${n})`:a`EXISTS (SELECT 1 FROM json_each(${s}) WHERE json_each.value = ${n})`:r?k(s,n):T(s,n);case"contains":if(typeof n=="string"){const u=n.startsWith("%")||n.endsWith("%")?n:`%${n}%`;return r?b(s,u):v(s,u)}break;case"in":if(Array.isArray(n)){if(f){const u=n.map(p=>a`EXISTS (SELECT 1 FROM json_each(${s}) WHERE json_extract(json_each.value, '$.key') = ${p})`);return r?a`NOT (${d(...u)})`:d(...u)}else if(c){const u=n.map(p=>a`EXISTS (SELECT 1 FROM json_each(${s}) WHERE json_each.value = ${p})`);return r?a`NOT (${d(...u)})`:d(...u)}return r?W(s,n):C(s,n)}break;case"between":if(Array.isArray(n)&&n.length===2)return r?y(s,n[0],n[1]):R(s,n[0],n[1]);break;default:throw new Error(`Unsupported filter operator: ${o}`)}},A=["'",'"'];function Z(t="",e=[],o={}){if(!t||!t.trim())return;const n=g(t);return w(n,e,o)}function S(t){const e=X(t);if(e.operator===":"){const o=N(e.value,",");if(o.length>1)return{operator:"in",field:e.field,parentFields:e.parentFields,value:o.map(E),modifier:e.modifier};const n=N(e.value,"..");return n.length===2?{operator:"between",field:e.field,parentFields:e.parentFields,value:[E(n[0]),E(n[1])],modifier:e.modifier}:{operator:"equal",field:e.field,parentFields:e.parentFields,value:e.value==="null"?null:E(e.value),modifier:e.modifier}}else if(e.operator==="~")return{operator:"contains",field:e.field,parentFields:e.parentFields,value:E(e.value),modifier:e.modifier};throw new Error(`Unsupported filter clause: ${t}`)}function X(t){const e="^(?<modifier>^-?)",o="(?<field>[a-z][\\w.]*)",n="(?<operator>:|~)",l="(?<value>.+)",i=new RegExp(`^${e}${o}${n}${l}$`,"i"),r=t.match(i);if(!r||!r.groups)throw new Error(`Invalid filter clause: ${t}`);const{operator:s,value:c,modifier:f}=r.groups,u=r.groups.field.split(".");return{field:u.pop(),parentFields:u,operator:s,value:c,modifier:f==="-"?"not":void 0}}function N(t,e){const o=[];let n="",l=!1,i=0;for(let r=0;r<t.length;r++){const s=t[r-1],c=t[r];if(i>0){i--;continue}s!=="\\"&&A.includes(c)&&(l=!l),!l&&t.slice(r,r+e.length)===e?(o.push(n),n="",i=e.length-1):n+=c}return n&&o.push(n),o}function E(t){for(const e of A)if(t.startsWith(e)&&t.endsWith(e))return t.slice(1,-1);return t}function g(t){let e="",o=0,n=!1,l="";const i=[];for(let s=0;s<t.length;s++){const c=t[s],f=t[s+1];if(['"',"'"].includes(c)&&(s===0||t[s-1]!=="\\")){if(!n){n=!0,l=c,e+=c;continue}if(c===l){n=!1,l="",e+=c;continue}}if(n){e+=c;continue}if(o===0){const u=f==="A"&&t.slice(s+1,s+5)===`${h.AND} `;if(c===" "&&u){const $=e.trim();$&&(i.push(S($)),e="");const _=g(t.slice(s+5));return{op:h.AND,conditions:[...i,_]}}const p=f==="O"&&t.slice(s+1,s+4)===`${h.OR} `;if(c===" "&&p){const $=e.trim();$&&(i.push(S($)),e="");const _=g(t.slice(s+4));return{op:h.OR,conditions:[...i,_]}}}if(c==="("){const u=e.trim();o===0&&u&&(i.push(S(u)),e=""),o++,e+=c;continue}if(c===")"){if(o--,e+=c,o===0){const u=e.slice(1,-1);i.push(g(u)),e=""}continue}e+=c}const r=e.trim();return r&&i.push(S(r)),i.length===1?i[0]:{op:h.AND,conditions:i}}function w(t,e,o){if("field"in t){const n=t.parentFields?.length?`${t.parentFields.join(".")}.${t.field}`:t.field;if(!D(n,e))throw new Error(`Invalid filter field: ${n}`);const l=t.parentFields?.length?t.field:o[t.field]||q(t.field);return{...t,field:l}}else return{...t,conditions:t.conditions.map(n=>w(n,e,o))}}function ee(t,e){if(!t)return;const o=i=>e.includes(i),n=i=>{if(F(i)){const r=i.conditions.map(n).filter(s=>s!==null);return r.length===0?null:r.length===1?r[0]:{...i,conditions:r}}else return o(i.field)?null:i};return n(t)||void 0}export{z as applyFilter,J as convertFilterToWhereCondition,ee as excludeFieldsFromFilter,G as getFirstFilterFieldValue,Z as parseFilterQuery};
@@ -1,4 +1,7 @@
1
1
  import type { SQLiteSelect } from 'drizzle-orm/sqlite-core';
2
+ import type { SQL } from 'drizzle-orm';
2
3
  import type { PaginationParams } from './schemas.js';
3
- export declare const applyPagination: <T extends SQLiteSelect>(sqlBuilderInstance: T, paginationParams: PaginationParams, tableAlias?: string) => T;
4
+ export declare const applyPagination: <T extends SQLiteSelect>(sqlBuilderInstance: T, paginationParams: PaginationParams & {
5
+ baseWhereCondition?: SQL;
6
+ }, tableAlias?: string) => T;
4
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- import A from"@markdoc/markdoc";import{getPathnameForLocale as C}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as f}from"../constants/common.js";import{DEFAULT_TITLE as P}from"./constants/common.js";import{GATED_MARKDOC_TAGS as D}from"./constants/entitlements.js";import{isObject as T}from"../utils/guards/is-object.js";import{mapObject as O}from"../utils/object/map-object.js";import{getValueDeep as w}from"../utils/object/get-value-deep.js";import{removeTrailingSlash as M}from"../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as l}from"../utils/path/normalize-route-slug.js";import{isLocalLink as k}from"../utils/path/is-local-link.js";import{reporter as S}from"./tools/notifiers/reporter.js";import{logger as p}from"./tools/notifiers/logger.js";import{sha1 as L}from"./utils/crypto/sha1.js";import{writeEnvVariable as _}from"./utils/envs/write-env-variable.js";import{readEnvVariable as F}from"./utils/envs/read-env-variable.js";import{writeSharedData as B}from"./utils/index.js";import{renderComponents as G}from"./ssr/render.js";import{readStaticData as I,writeStaticData as N}from"./utils/static-data.js";import{parseAndResolveMarkdoc as V}from"./plugins/markdown/compiler.js";import{getMarkdocOptions as j}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as y}from"./entitlements/entitlements-provider.js";import{isL10nPath as H}from"./fs/utils/is-l10n-path.js";import{resolveMetadataGlobs as J}from"./utils/globs.js";import{replaceEnvVariablesDeep as U}from"./utils/envs/replace-env-variables-deep.js";import{findRedirect as x}from"./utils/redirects/find-redirect.js";import{addWildcardRedirectToTree as K}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as q}from"../cli/telemetry/helpers/trace-step.js";const R={routesBySlug:"map",apiRoutes:"object",middleware:"object",routesByFsPath:"map",routesSharedData:"map",globalData:"object",config:"object",ssr:"object",searchFacets:"map"},g="markdown/partials",Ee="markdown/partials-deps",v="PLAN_GATES",$=["OAUTH_CLIENT_ID","OAUTH_CLIENT_SECRET","ORG_ID"],be="userDefinedApiFunctions";class E{routesBySlug=new Map;replacedEnvVars={};unsetEnvVars=new Set;lifecycleContext;newRoutes=[];#e={};routesByFsPath=new Map;apiRoutes=[];middleware=[];routesSharedData=new Map;sharedDataDeps=new Map;sharedDataMarkdocComponents=new Map;routesDynamicComponents=new Map;ssr={preBodyTags:[],postBodyTags:[],headTags:[]};searchFacets=new Map;searchEngine;templates=new Map;browserPlugins=new Set;apiRoutesRequestHandlers=new Map;serverPropsGetters=new Map;pagePropsGetters=new Map;listeners=new Map;globalData={};#s=void 0;config={configFilePath:"",redirects:{},wildcardRedirectsTree:{},rbac:{},directoryPermissions:{},devLogin:!1,ssoDirect:{}};#r;serverMode;serverOutDir;outdir;buildRevision=0;hasSitemap=!1;compilationErrors=[];#a;userCodeReady;#o=Promise.resolve();#i;#n=Promise.resolve();#c;#t=new Map;constructor({outdir:e,contentDir:t,serverMode:s=!1,serverOutDir:r}){this.#r=t,this.outdir=e,this.serverMode=s,this.serverOutDir=r,this.userCodeReady=new Promise(a=>{this.#a=a})}on(e,t){const s=this.listeners.get(e);s?s.add(t):this.listeners.set(e,new Set([t]))}queueEvent=(e,t,...s)=>{this.#t.set(e+String(t),[e,t,...s])};runListeners=(e,t,...s)=>{for(const r of this.listeners.get(e)||new Set)t?r(t,...s):r(...s)};startPluginsRun(){this.clear(),this.#o=new Promise(e=>{this.#i=e})}waitForPluginsLifecycle(){return Promise.all([this.#o,this.#n])}finishPluginsRun(){this.#i?.();for(const e of this.#t.values())this.runListeners(...e);this.#t.clear()}startEsbuildRun(){this.#n=new Promise(e=>{this.#c=e})}finishEsbuildRun(){this.#c?.()}get contentDir(){if(this.serverMode)throw new Error("contentDir should not be used in server mode");return this.#r}markUserCodeReady(){this.#a?.(!0)}async reloadMarkdocOptions(){await q("build.reload_markdoc_options",async()=>{const e=y.instance(),t=await j(this.serverOutDir),s=Object.fromEntries(Object.entries(t.tags).filter(([r])=>D[r]!=null?e.canAccessFeature(D[r]):!0));this.#s={...t,tags:s}})}get markdocOptions(){return{...this.#s,partials:this.getGlobalConfig(g),themeConfig:this.config.markdown}}setGlobalData=e=>{const t=this.globalData,s={...this.globalData,...e};this.globalData=s,JSON.stringify(s)!==JSON.stringify(t)&&this.queueEvent("global-data-updated",void 0,s)};getGlobalData=()=>this.globalData;parseMarkdoc=async(e,t,s)=>{const{data:{info:r,ast:a},compoundHash:i}=await V(e,this.markdocOptions,{actions:this,context:t});for(const o of r.sharedDataDeps||[]){for(const n of s?.routeSlugs||[])this.addRouteSharedData(n,o,o);for(const n of s?.sharedDataIds||[]){const c=this.sharedDataDeps.get(n)||new Set;c.add(o),this.sharedDataDeps.set(n,c)}}for(const o of r.dynamicMarkdocComponents||[]){for(const n of s?.routeSlugs||[]){const c=this.routesDynamicComponents.get(n)||new Set;c.add(o),this.routesDynamicComponents.set(n,c)}for(const n of s?.sharedDataIds||[]){const c=this.sharedDataMarkdocComponents.get(n)||new Set;c.add(o),this.sharedDataMarkdocComponents.set(n,c)}}return{info:r,ast:a,compoundHash:i}};async loadOpenApiDefinitions(e){return(await e.cache.load(".","load-oas-docs")).data}async loadAsyncApiDefinitions(e){return(await e.cache.load(".","asyncapi-docs")).data}setSearchEngine(e){this.searchEngine=e}setSearchFacets=e=>{this.searchFacets=e};setGlobalConfig=e=>{const t=Object.keys(e);for(const i of t)for(const o in this.replacedEnvVars)if(o===i||o.startsWith(`${i}:`)){const n=o.split(":"),{error:c,value:d}=w(e,n);(c||d!==this.replacedEnvVars[o].replaced)&&delete this.replacedEnvVars[o]}const{resolvedObj:s,unsetEnvVars:r,replacedValues:a}=U(e);for(const i of r)this.unsetEnvVars.add(i);Object.assign(this.replacedEnvVars,a),Object.assign(this.config,s)};getConfig=()=>this.config;getGlobalConfig=e=>this.config[e];getSearchFacets=()=>this.searchFacets;addRedirect=(e,t)=>{if(!y.instance().canAccessFeature("redirects")&&e!=="/")return;this.config.redirects||(this.config.redirects={});const a=l(e).toLowerCase();this.config.redirects[a]=t,a.endsWith("*")&&K(this.config.wildcardRedirectsTree,a)};getRedirect=e=>{const t=l(e).toLowerCase();return x(t,this.config.redirects,this.config.wildcardRedirectsTree)};createSharedData=async(e,t,s)=>{if(s&&this.#e[e]===s)return e;const r=JSON.stringify(t),a=s??L(r);return this.#e[e]===a||(this.#e[e]=a,await B(e,r,this.outdir),this.queueEvent("shared-data-updated",e)),e};addRouteSharedData=(e,t,s)=>{const r=M(e),a=this.routesSharedData.get(r)||{};a[t]=s,this.routesSharedData.set(r,a),p.verbose(`Adding shared data to ${e}, ${t}, ${s}`)};getRouteSharedDataByFsPath=e=>{const t=this.routesByFsPath.get(e);return t?this.routesSharedData.get(t)||{}:{}};addRoute=e=>{const s={...J(e.fsPath,this.config.metadataGlobs),...e.metadata||{}};this.newRoutes.push({...e,metadata:s}),p.verbose("Created route %s",e.slug)};addRouteSharedDataToAllLocales=(e,t,s)=>{const r=[f,...this.lifecycleContext?.fs.localeFolders||[]].map(a=>({code:a,name:a}));for(const a of r){const i=C(e,f,a.code,r);this.addRouteSharedData(i,t,s)}};addApiRoute=e=>{this.apiRoutes.push(e),p.verbose("Created API route %s",e.slug)};addMiddleware=e=>{this.middleware.push(e),p.verbose("Created middleware %s",e.id)};getRouteByFsPath=e=>{const t=this.routesByFsPath.get(e);return t?this.getRouteBySlug(t):void 0};getRouteBySlug=(e,t={})=>{const{followRedirect:s=!0}=t,r=this.getRedirect(e);return s&&r?this.routesBySlug.get(l(r.to)):this.routesBySlug.get(e)};slugHasRouteOrRedirect=e=>{const t=l(e);if(this.routesBySlug.has(t))return!0;const s=this.getRedirect(e);if(!s)return!1;if(!k(s.to))return!0;const r=l(s.to);return this.routesBySlug.has(r)};getRoutesByTemplateId=e=>this.newRoutes.filter(t=>t.templateId===e);getAllRoutesForLocale=(e=f)=>{const t=Array.from(this.routesBySlug.values()),s=e.toLowerCase();return t.filter(r=>e===f?!H(r.fsPath):r.slug.startsWith(`/${s}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=e=>this.templates.get(e);getRequestHandler=e=>this.apiRoutesRequestHandlers.get(e);createTemplate=(e,t)=>(this.templates.set(e,t),e);addBrowserPlugin=e=>{this.browserPlugins.add(e)};createRequestHandler=(e,t)=>(this.apiRoutesRequestHandlers.set(e,t),e);registerServerPropsGetter=(e,t)=>(this.serverPropsGetters.set(e,t),e);registerPagePropsGetter=(e,t)=>{this.pagePropsGetters.set(e,t)};async writeRouteStaticData(e,t){const s=await this.resolveRouteStaticData(e,t,!1);s&&N(e.slug,s,this.outdir)}async resolveRouteStaticData(e,t,s){if(this.serverMode)return I(e.slug,this.outdir);const r={...this,contentDir:this.contentDir,parseMarkdoc:(d,h)=>this.parseMarkdoc(d,h,{routeSlugs:[e.slug]})},a=await e.getStaticData?.(e,r)||{},i=new Set(this.routesDynamicComponents.get(e.slug)),o=this.routesSharedData.get(e.slug)||{};for(const d of Object.values(o)){const h=this.sharedDataMarkdocComponents.get(d);h&&h.forEach(u=>i.add(u));const m=this.sharedDataDeps.get(d);m&&m.forEach(u=>this.addRouteSharedData(e.slug,u,u))}const n=this.getGlobalConfig("seo"),c=a?.frontmatter||{};return{...a,frontmatter:{...c,seo:{...c?.seo,title:c?.seo?.title||await e.getNavText?.()}},props:{...a.props,dynamicMarkdocComponents:Array.from(i),metadata:{...a?.props?.metadata,...e.metadata},seo:{title:P,...n,...a.props?.seo},compilationErrors:this.compilationErrors},lastModified:s||!e.fsPath?null:await this.lifecycleContext?.fs.getLastModified(e.fsPath)}}addSsrComponents(e,t){if(!e?.length)return;const s=typeof e[0]=="string"?e.join(""):G(e);s&&(t==="head"?this.ssr.headTags.push(s):t==="preBody"?this.ssr.preBodyTags.push(s):this.ssr.postBodyTags.push(s))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};async toJson(){const e=[];for(const[s,r]of Object.entries(R))switch(r){case"map":const a=Array.from(this[s].entries());e.push([s,a]);break;case"object":s==="config"&&e.push([s,await this.getConfigWithEnvPlaceholders()]),e.push([s,this[s]]);break;default:throw new Error("Invalid format")}const t=Object.fromEntries(e);return t[v]=F("PLAN_GATES"),t}static fromJson(e,t){const s=new E(t);for(const[a,i]of Object.entries(R))switch(i){case"map":s[a]=new Map(e[a]);break;case"object":if(a==="config"){s.setGlobalConfig(e[a]);break}s[a]=e[a];break;default:throw new Error("Invalid format")}s.config[g]=z(s.config[g]||{});const r=e[v];return r&&_("PLAN_GATES",r),s}async getConfigWithEnvPlaceholders(){const e=JSON.parse(JSON.stringify(this.config));for(const t in this.replacedEnvVars){const{original:s}=this.replacedEnvVars[t],r=t.split(":"),a=r.pop(),{error:i,value:o}=w(e,r);if(i||!T(o)&&!Array.isArray(o)){await S.panicOnBuild(`Failed to replace env var with env name for ${t}`);continue}o[a]=s}return e}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const e=Array.from(this.unsetEnvVars).filter(s=>!$.includes(s));if(e.length===0)return;const t=`Failed to resolve config. The following environment variables are not set: ${e.join(", ")}`;await S.panicOnBuildContentError(t)}}function z(b){return O(b,e=>A.Ast.fromJSON(JSON.stringify(e)))}export{g as MARKDOC_PARTIALS_DATA_KEY,Ee as MARKDOC_PARTIALS_DEPS_KEY,E as Store,be as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
1
+ import A from"@markdoc/markdoc";import{getPathnameForLocale as C}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as u}from"../constants/common.js";import{DEFAULT_TITLE as P}from"./constants/common.js";import{GATED_MARKDOC_TAGS as D}from"./constants/entitlements.js";import{isObject as T}from"../utils/guards/is-object.js";import{mapObject as O}from"../utils/object/map-object.js";import{getValueDeep as w}from"../utils/object/get-value-deep.js";import{removeTrailingSlash as M}from"../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as f}from"../utils/path/normalize-route-slug.js";import{isLocalLink as k}from"../utils/path/is-local-link.js";import{reporter as S}from"./tools/notifiers/reporter.js";import{logger as p}from"./tools/notifiers/logger.js";import{sha1 as L}from"./utils/crypto/sha1.js";import{writeEnvVariable as _}from"./utils/envs/write-env-variable.js";import{readEnvVariable as F}from"./utils/envs/read-env-variable.js";import{writeSharedData as B}from"./utils/index.js";import{renderComponents as G}from"./ssr/render.js";import{readStaticData as I,writeStaticData as N}from"./utils/static-data.js";import{parseAndResolveMarkdoc as V}from"./plugins/markdown/compiler.js";import{getMarkdocOptions as j}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as y}from"./entitlements/entitlements-provider.js";import{isL10nPath as H}from"./fs/utils/is-l10n-path.js";import{resolveMetadataGlobs as J}from"./utils/globs.js";import{replaceEnvVariablesDeep as U}from"./utils/envs/replace-env-variables-deep.js";import{findRedirect as x}from"./utils/redirects/find-redirect.js";import{addWildcardRedirectToTree as K}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as q}from"../cli/telemetry/helpers/trace-step.js";const R={routesBySlug:"map",apiRoutes:"object",middleware:"object",routesByFsPath:"map",routesSharedData:"map",globalData:"object",config:"object",ssr:"object",searchFacets:"map"},g="markdown/partials",Ee="markdown/partials-deps",v="PLAN_GATES",$=["OAUTH_CLIENT_ID","OAUTH_CLIENT_SECRET","ORG_ID"],be="userDefinedApiFunctions";class E{routesBySlug=new Map;replacedEnvVars={};unsetEnvVars=new Set;lifecycleContext;newRoutes=[];#e={};routesByFsPath=new Map;apiRoutes=[];middleware=[];routesSharedData=new Map;sharedDataDeps=new Map;sharedDataMarkdocComponents=new Map;routesDynamicComponents=new Map;ssr={preBodyTags:[],postBodyTags:[],headTags:[]};searchFacets=new Map;searchEngine;templates=new Map;browserPlugins=new Set;apiRoutesRequestHandlers=new Map;serverPropsGetters=new Map;pagePropsGetters=new Map;listeners=new Map;globalData={};#s=void 0;config={configFilePath:"",redirects:{},wildcardRedirectsTree:{},rbac:{},directoryPermissions:{},devLogin:!1,ssoDirect:{}};#r;serverMode;serverOutDir;outdir;buildRevision=0;hasSitemap=!1;compilationErrors=[];#a;userCodeReady;#o=Promise.resolve();#i;#n=Promise.resolve();#c;#t=new Map;constructor({outdir:e,contentDir:t,serverMode:s=!1,serverOutDir:r}){this.#r=t,this.outdir=e,this.serverMode=s,this.serverOutDir=r,this.userCodeReady=new Promise(a=>{this.#a=a})}on(e,t){const s=this.listeners.get(e);s?s.add(t):this.listeners.set(e,new Set([t]))}queueEvent=(e,t,...s)=>{this.#t.set(e+String(t),[e,t,...s])};runListeners=(e,t,...s)=>{for(const r of this.listeners.get(e)||new Set)t?r(t,...s):r(...s)};startPluginsRun(){this.clear(),this.#o=new Promise(e=>{this.#i=e})}waitForPluginsLifecycle(){return Promise.all([this.#o,this.#n])}finishPluginsRun(){this.#i?.();for(const e of this.#t.values())this.runListeners(...e);this.#t.clear()}startEsbuildRun(){this.#n=new Promise(e=>{this.#c=e})}finishEsbuildRun(){this.#c?.()}get contentDir(){if(this.serverMode)throw new Error("contentDir should not be used in server mode");return this.#r}markUserCodeReady(){this.#a?.(!0)}async reloadMarkdocOptions(){await q("build.reload_markdoc_options",async()=>{const e=y.instance(),t=await j(this.serverOutDir),s=Object.fromEntries(Object.entries(t.tags).filter(([r])=>D[r]!=null?e.canAccessFeature(D[r]):!0));this.#s={...t,tags:s}})}get markdocOptions(){return{...this.#s,partials:this.getGlobalConfig(g),themeConfig:this.config.markdown}}setGlobalData=e=>{const t=this.globalData,s={...this.globalData,...e};this.globalData=s,JSON.stringify(s)!==JSON.stringify(t)&&this.queueEvent("global-data-updated",void 0,s)};getGlobalData=()=>this.globalData;parseMarkdoc=async(e,t,s)=>{const{data:{info:r,ast:a},compoundHash:i}=await V(e,this.markdocOptions,{actions:this,context:t});for(const o of r.sharedDataDeps||[]){for(const n of s?.routeSlugs||[])this.addRouteSharedData(n,o,o);for(const n of s?.sharedDataIds||[]){const c=this.sharedDataDeps.get(n)||new Set;c.add(o),this.sharedDataDeps.set(n,c)}}for(const o of r.dynamicMarkdocComponents||[]){for(const n of s?.routeSlugs||[]){const c=this.routesDynamicComponents.get(n)||new Set;c.add(o),this.routesDynamicComponents.set(n,c)}for(const n of s?.sharedDataIds||[]){const c=this.sharedDataMarkdocComponents.get(n)||new Set;c.add(o),this.sharedDataMarkdocComponents.set(n,c)}}return{info:r,ast:a,compoundHash:i}};async loadOpenApiDefinitions(e){return(await e.cache.load(".","load-oas-docs")).data}async loadAsyncApiDefinitions(e){return(await e.cache.load(".","asyncapi-docs")).data}setSearchEngine(e){this.searchEngine=e}setSearchFacets=e=>{this.searchFacets=e};setGlobalConfig=e=>{const t=Object.keys(e);for(const i of t)for(const o in this.replacedEnvVars)if(o===i||o.startsWith(`${i}:`)){const n=o.split(":"),{error:c,value:d}=w(e,n);(c||d!==this.replacedEnvVars[o].replaced)&&delete this.replacedEnvVars[o]}const{resolvedObj:s,unsetEnvVars:r,replacedValues:a}=U(e);for(const i of r)this.unsetEnvVars.add(i);Object.assign(this.replacedEnvVars,a),Object.assign(this.config,s)};getConfig=()=>this.config;getGlobalConfig=e=>this.config[e];getSearchFacets=()=>this.searchFacets;addRedirect=(e,t)=>{if(!y.instance().canAccessFeature("redirects")&&e!=="/")return;this.config.redirects||(this.config.redirects={});const a=f(e).toLowerCase();this.config.redirects[a]=t,a.endsWith("*")&&K(this.config.wildcardRedirectsTree,a)};getRedirect=e=>{const t=f(e).toLowerCase();return x(t,this.config.redirects,this.config.wildcardRedirectsTree)};createSharedData=async(e,t,s)=>{if(s&&this.#e[e]===s)return e;const r=JSON.stringify(t),a=s??L(r);return this.#e[e]===a||(this.#e[e]=a,await B(e,r,this.outdir),this.queueEvent("shared-data-updated",e)),e};addRouteSharedData=(e,t,s)=>{const r=M(e),a=this.routesSharedData.get(r)||{};a[t]=s,this.routesSharedData.set(r,a),p.verbose(`Adding shared data to ${e}, ${t}, ${s}`)};getRouteSharedDataByFsPath=e=>{const t=this.routesByFsPath.get(e);return t?this.routesSharedData.get(t)||{}:{}};addRoute=e=>{const s={...J(e.fsPath,this.config.metadataGlobs),...e.metadata||{}};this.newRoutes.push({...e,metadata:s}),p.verbose("Created route %s",e.slug)};addRouteSharedDataToAllLocales=(e,t,s)=>{const r=[u,...this.lifecycleContext?.fs.localeFolders||[]].map(a=>({code:a,name:a}));for(const a of r){const i=C(e,u,a.code,r);this.addRouteSharedData(i,t,s)}};addApiRoute=e=>{this.apiRoutes.push(e),p.verbose("Created API route %s",e.slug)};addMiddleware=e=>{this.middleware.push(e),p.verbose("Created middleware %s",e.id)};getRouteByFsPath=e=>{const t=this.routesByFsPath.get(e);return t?this.getRouteBySlug(t):void 0};getRouteBySlug=(e,t={})=>{const{followRedirect:s=!0}=t,r=this.getRedirect(e);return s&&r?this.routesBySlug.get(f(r.to)):this.routesBySlug.get(e)};slugHasRouteOrRedirect=e=>{if(this.routesBySlug.has(e))return!0;const t=this.getRedirect(e);if(!t)return!1;if(!k(t.to))return!0;const s=f(t.to);return this.routesBySlug.has(s)};getRoutesByTemplateId=e=>this.newRoutes.filter(t=>t.templateId===e);getAllRoutesForLocale=(e=u)=>{const t=Array.from(this.routesBySlug.values()),s=e.toLowerCase();return t.filter(r=>e===u?!H(r.fsPath):r.slug.startsWith(`/${s}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=e=>this.templates.get(e);getRequestHandler=e=>this.apiRoutesRequestHandlers.get(e);createTemplate=(e,t)=>(this.templates.set(e,t),e);addBrowserPlugin=e=>{this.browserPlugins.add(e)};createRequestHandler=(e,t)=>(this.apiRoutesRequestHandlers.set(e,t),e);registerServerPropsGetter=(e,t)=>(this.serverPropsGetters.set(e,t),e);registerPagePropsGetter=(e,t)=>{this.pagePropsGetters.set(e,t)};async writeRouteStaticData(e,t){const s=await this.resolveRouteStaticData(e,t,!1);s&&N(e.slug,s,this.outdir)}async resolveRouteStaticData(e,t,s){if(this.serverMode)return I(e.slug,this.outdir);const r={...this,contentDir:this.contentDir,parseMarkdoc:(d,l)=>this.parseMarkdoc(d,l,{routeSlugs:[e.slug]})},a=await e.getStaticData?.(e,r)||{},i=new Set(this.routesDynamicComponents.get(e.slug)),o=this.routesSharedData.get(e.slug)||{};for(const d of Object.values(o)){const l=this.sharedDataMarkdocComponents.get(d);l&&l.forEach(h=>i.add(h));const m=this.sharedDataDeps.get(d);m&&m.forEach(h=>this.addRouteSharedData(e.slug,h,h))}const n=this.getGlobalConfig("seo"),c=a?.frontmatter||{};return{...a,frontmatter:{...c,seo:{...c?.seo,title:c?.seo?.title||await e.getNavText?.()}},props:{...a.props,dynamicMarkdocComponents:Array.from(i),metadata:{...a?.props?.metadata,...e.metadata},seo:{title:P,...n,...a.props?.seo},compilationErrors:this.compilationErrors},lastModified:s||!e.fsPath?null:await this.lifecycleContext?.fs.getLastModified(e.fsPath)}}addSsrComponents(e,t){if(!e?.length)return;const s=typeof e[0]=="string"?e.join(""):G(e);s&&(t==="head"?this.ssr.headTags.push(s):t==="preBody"?this.ssr.preBodyTags.push(s):this.ssr.postBodyTags.push(s))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};async toJson(){const e=[];for(const[s,r]of Object.entries(R))switch(r){case"map":const a=Array.from(this[s].entries());e.push([s,a]);break;case"object":s==="config"&&e.push([s,await this.getConfigWithEnvPlaceholders()]),e.push([s,this[s]]);break;default:throw new Error("Invalid format")}const t=Object.fromEntries(e);return t[v]=F("PLAN_GATES"),t}static fromJson(e,t){const s=new E(t);for(const[a,i]of Object.entries(R))switch(i){case"map":s[a]=new Map(e[a]);break;case"object":if(a==="config"){s.setGlobalConfig(e[a]);break}s[a]=e[a];break;default:throw new Error("Invalid format")}s.config[g]=W(s.config[g]||{});const r=e[v];return r&&_("PLAN_GATES",r),s}async getConfigWithEnvPlaceholders(){const e=JSON.parse(JSON.stringify(this.config));for(const t in this.replacedEnvVars){const{original:s}=this.replacedEnvVars[t],r=t.split(":"),a=r.pop(),{error:i,value:o}=w(e,r);if(i||!T(o)&&!Array.isArray(o)){await S.panicOnBuild(`Failed to replace env var with env name for ${t}`);continue}o[a]=s}return e}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const e=Array.from(this.unsetEnvVars).filter(s=>!$.includes(s));if(e.length===0)return;const t=`Failed to resolve config. The following environment variables are not set: ${e.join(", ")}`;await S.panicOnBuildContentError(t)}}function W(b){return O(b,e=>A.Ast.fromJSON(JSON.stringify(e)))}export{g as MARKDOC_PARTIALS_DATA_KEY,Ee as MARKDOC_PARTIALS_DEPS_KEY,E as Store,be as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
@@ -15,6 +15,8 @@ export declare enum LogLevel {
15
15
  VERBOSE = "VERBOSE",
16
16
  HTTP = "HTTP"
17
17
  }
18
+ export declare function shouldLog(level: LogLevel, minLevel: LogLevel): boolean;
19
+ export declare function parseLogLevel(levelStr: string | undefined): LogLevel | undefined;
18
20
  declare const formatter: {
19
21
  format(log: LogData): string;
20
22
  interpolate(pattern: string, ...args: any[]): string;
@@ -1,3 +1,3 @@
1
- import*as O from"node:path";import{isProductionMode as R}from"../../utils/envs/is-production-mode.js";import{maskEmail as T}from"./helpers/privacy/mask-email.js";import{maskSubject as E}from"./helpers/privacy/mask-subject.js";import{removePii as $}from"./helpers/privacy/remove-pii.js";import{removePiiFromUrl as A}from"./helpers/privacy/remove-pii-from-url.js";import{red as P,green as x,bold as w,blue as p,gray as n,yellow as b,cyan as F}from"./helpers/colors.js";var s;(function(e){e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.SUCCESS="SUCCESS",e.VERBOSE="VERBOSE",e.HTTP="HTTP"})(s||(s={}));const N={[s.INFO]:p,[s.SUCCESS]:x,[s.WARN]:b,[s.ERROR]:P,[s.HTTP]:F,[s.VERBOSE]:n},C={"%ap":e=>p(O.resolve(e)),"%rp":e=>p(O.relative(process.cwd(),e)),"%s":e=>e?.toString(),"%c":e=>p(e)},v={format(e){switch(process.env.PORTAL_LOG_FORMAT){case"JSON":return H(e);default:return I(e)}},interpolate(e,...c){const i=Object.keys(C).map(t=>`(${t})`).join("|"),a=new RegExp(i,"g");let o,m=e;for(;(o=a.exec(e))!==null;){o.index===a.lastIndex&&a.lastIndex++;const t=c.shift();if(t===void 0)break;const r=o[0];m=m.replace(r,C[r](t))}return m}};var W=v;const I=e=>{const{level:c,message:i,duration:a,context:o}=e,m=R(),t=[N[c](w(`[${c.toLowerCase()}]`))];if(m&&t.push(n(`time="${j()}"`)),o){const{email:r,ipAddress:u,subject:l,method:d,pathname:f,statusCode:h,teams:S,apiFunction:g}=o;g&&t.push(p(`fn="${g}"`)),h&&t.push(y(h)),e.level===s.HTTP&&(d&&t.push(n(`method="${d}"`)),f&&t.push(n(`path="${A(f)}"`))),u&&t.push(n(`ip="${u}"`)),r&&t.push(n(`email="${T(r)}"`)),l&&t.push(n(`sub="${E(l)}"`)),S?.length&&t.push(n(`teams="${S.join(", ")}"`))}if(i){const r=m?`msg="${String($(i)).replaceAll?.('"','\\"')}"`:String(i);t.push(r)}return e.level===s.HTTP&&o?.userAgent&&t.push(n(`agent="${o.userAgent}"`)),a&&t.push(M(a)),t.join(" ")+`
2
- `},H=({context:e,message:c,...i})=>{const{method:a,pathname:o,statusCode:m,userAgent:t,subject:r,email:u,teams:l,apiFunction:d}=e||{},f={...i,email:u&&T(u),subject:r&&E(r),teams:l,apiFunction:d,...i.level===s.HTTP?{method:a,pathname:String(A(o)),statusCode:m,userAgent:t}:{message:String($(c))}};return R()&&(f.time=j()),JSON.stringify(f,["time","level","scope","message","duration","method","pathname","statusCode","userAgent","subject","ipAddress","email","apiFunction"])+`
3
- `},y=e=>(e%500<100?P:e%400<100?b:x)(`status="${e}"`),j=()=>{let e=new Date().getTimezoneOffset()*6e4;return new Date(Date.now()-e).toISOString().slice(0,-1)},M=e=>n(`dur="${Math.round(e)}ms"`);export{s as LogLevel,W as default};
1
+ import*as O from"node:path";import{isProductionMode as g}from"../../utils/envs/is-production-mode.js";import{maskEmail as T}from"./helpers/privacy/mask-email.js";import{maskSubject as E}from"./helpers/privacy/mask-subject.js";import{removePii as A}from"./helpers/privacy/remove-pii.js";import{removePiiFromUrl as P}from"./helpers/privacy/remove-pii-from-url.js";import{red as $,green as x,bold as j,blue as p,gray as i,yellow as C,cyan as w}from"./helpers/colors.js";var n;(function(e){e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.SUCCESS="SUCCESS",e.VERBOSE="VERBOSE",e.HTTP="HTTP"})(n||(n={}));const b={[n.VERBOSE]:0,[n.HTTP]:1,[n.INFO]:2,[n.SUCCESS]:2,[n.WARN]:3,[n.ERROR]:4};function W(e,s){return b[e]>=b[s]}function L(e){if(!e)return;const s=e.toUpperCase();if(s in n)return s}const F={[n.INFO]:p,[n.SUCCESS]:x,[n.WARN]:C,[n.ERROR]:$,[n.HTTP]:w,[n.VERBOSE]:i},I={"%ap":e=>p(O.resolve(e)),"%rp":e=>p(O.relative(process.cwd(),e)),"%s":e=>e?.toString(),"%c":e=>p(e)},v={format(e){switch(process.env.PORTAL_LOG_FORMAT){case"JSON":return U(e);default:return H(e)}},interpolate(e,...s){const a=Object.keys(I).map(t=>`(${t})`).join("|"),m=new RegExp(a,"g");let r,u=e;for(;(r=m.exec(e))!==null;){r.index===m.lastIndex&&m.lastIndex++;const t=s.shift();if(t===void 0)break;const o=r[0];u=u.replace(o,I[o](t))}return u}};var z=v;const H=e=>{const{level:s,message:a,duration:m,context:r}=e,u=g(),t=[F[s](j(`[${s.toLowerCase()}]`))];if(u&&t.push(i(`time="${N()}"`)),r){const{email:o,ipAddress:c,subject:l,method:d,pathname:f,statusCode:S,teams:h,apiFunction:R}=r;R&&t.push(p(`fn="${R}"`)),S&&t.push(y(S)),e.level===n.HTTP&&(d&&t.push(i(`method="${d}"`)),f&&t.push(i(`path="${P(f)}"`))),c&&t.push(i(`ip="${c}"`)),o&&t.push(i(`email="${T(o)}"`)),l&&t.push(i(`sub="${E(l)}"`)),h?.length&&t.push(i(`teams="${h.join(", ")}"`))}if(a){const o=u?`msg="${String(A(a)).replaceAll?.('"','\\"')}"`:String(a);t.push(o)}return e.level===n.HTTP&&r?.userAgent&&t.push(i(`agent="${r.userAgent}"`)),m&&t.push(M(m)),t.join(" ")+`
2
+ `},U=({context:e,message:s,...a})=>{const{method:m,pathname:r,statusCode:u,userAgent:t,subject:o,email:c,teams:l,apiFunction:d}=e||{},f={...a,email:c&&T(c),subject:o&&E(o),teams:l,apiFunction:d,...a.level===n.HTTP?{method:m,pathname:String(P(r)),statusCode:u,userAgent:t}:{message:String(A(s))}};return g()&&(f.time=N()),JSON.stringify(f,["time","level","scope","message","duration","method","pathname","statusCode","userAgent","subject","ipAddress","email","apiFunction"])+`
3
+ `},y=e=>(e%500<100?$:e%400<100?C:x)(`status="${e}"`),N=()=>{let e=new Date().getTimezoneOffset()*6e4;return new Date(Date.now()-e).toISOString().slice(0,-1)},M=e=>i(`dur="${Math.round(e)}ms"`);export{n as LogLevel,z as default,L as parseLogLevel,W as shouldLog};
@@ -12,34 +12,32 @@ export type LoggerContext = {
12
12
  apiFunction?: string;
13
13
  requestHandlerId?: string;
14
14
  };
15
- export type LoggerStickyState = {
16
- globalStickyLines: {
17
- id: string;
18
- content: string;
19
- }[];
20
- prevStickyLines: number;
15
+ type LoggerOptions = {
16
+ context?: LoggerContext;
17
+ forceNonInteractive?: boolean;
18
+ minLogLevel?: LogLevel;
21
19
  };
22
20
  export declare class Logger {
23
21
  #private;
24
- disableSticky: boolean;
25
- constructor(context?: LoggerContext);
26
- info(message: string, ...args: any[]): void;
27
- infoTime(timingId: symbol | string, message: string, ...args: any[]): {
22
+ constructor({ context, forceNonInteractive, minLogLevel }?: LoggerOptions);
23
+ shouldLog(level: LogLevel): boolean;
24
+ info(message: string, ...args: unknown[]): void;
25
+ infoTime(timingId: symbol | string, message: string, ...args: unknown[]): {
28
26
  message: string;
29
27
  timeMs: number;
30
28
  } | undefined;
31
- success(message: string, ...args: any[]): void;
32
- logSticky(id: string, message: string, ...args: any[]): void;
33
- successTime(timingId: symbol | string, message: string, ...args: any[]): {
29
+ success(message: string, ...args: unknown[]): void;
30
+ logInFooter(id: string, message: string, ...args: unknown[]): void;
31
+ successTime(timingId: symbol | string, message: string, ...args: unknown[]): {
34
32
  message: string;
35
33
  timeMs: number;
36
34
  } | undefined;
37
- warn(message: string, ...args: any[]): void;
38
- warnProd(message: string, ...args: any[]): void;
39
- error(message: string, ...args: any[]): void;
40
- contentError(message: string, ...args: any[]): void;
41
- verbose(message: string, ...args: any[]): void;
42
- verboseTime(timingId: symbol | string, message: string, ...args: any[]): {
35
+ warn(message: string, ...args: unknown[]): void;
36
+ warnProd(message: string, ...args: unknown[]): void;
37
+ error(message: string, ...args: unknown[]): void;
38
+ contentError(message: string, ...args: unknown[]): void;
39
+ verbose(message: string, ...args: unknown[]): void;
40
+ verboseTime(timingId: symbol | string, message: string, ...args: unknown[]): {
43
41
  message: string;
44
42
  timeMs: number;
45
43
  } | undefined;
@@ -50,28 +48,9 @@ export declare class Logger {
50
48
  startTiming(label?: string): symbol | string;
51
49
  updateContext(context: Partial<LoggerContext>): void;
52
50
  clearAllTimeouts(): void;
53
- setStickyState({ globalStickyLines, prevStickyLines, }: {
54
- globalStickyLines: {
55
- id: string;
56
- content: string;
57
- }[];
58
- prevStickyLines: number;
59
- }): void;
60
- getStickyState(): {
61
- globalStickyLines: {
62
- id: string;
63
- content: string;
64
- }[];
65
- prevStickyLines: number;
66
- };
67
- printSticky(): void;
68
- clearSticky(): void;
69
51
  isInteractive(): boolean;
70
- warnForRealFile(message: string, relativePath: string, fs: ContentFs, ...args: any[]): Promise<void>;
71
- patchConsole(): void;
72
- static getLogLevel(method: (typeof monkeyPatchedMethods)[number]): LogLevel;
52
+ warnForRealFile(message: string, relativePath: string, fs: ContentFs, ...args: unknown[]): void;
73
53
  }
74
54
  export declare const logger: Logger;
75
- declare const monkeyPatchedMethods: readonly ["log", "warn", "error", "info", "debug", "trace", "dir", "table", "assert"];
76
55
  export {};
77
56
  //# sourceMappingURL=logger.d.ts.map
@@ -1,6 +1,2 @@
1
- import*as c from"readline";import{Writable as d}from"stream";import{telemetry as m}from"../../telemetry/index.js";import{isProductionMode as u}from"../../utils/envs/is-production-mode.js";import{isDevelopMode as f}from"../../utils/envs/is-develop-mode.js";import{gray as S}from"./helpers/colors.js";import l,{LogLevel as i}from"./formatter.js";import{isVirtualFile as v}from"../../fs/utils/isVirtualFile.js";const g=[{id:"sep",content:`
2
- `},{id:"sep2",content:S("\u2500".repeat(Math.round(process.stderr.columns/2)))+`
3
- `},{id:"sep3",content:`
4
- `}];class h{#t=[];#s=0;#i;#c;#r=new Map;#o=new Map;disableSticky=!1;constructor(t){this.#i=t,this.#c=u()}info(t,...e){this.#e({level:i.INFO,message:t,args:e})}infoTime(t,e,...s){return this.#n(i.INFO,e,t,...s)}success(t,...e){this.#e({level:i.SUCCESS,message:t,args:e})}logSticky(t,e,...s){const o=this.#t.find(r=>r.id===t),n=l.interpolate(e,...s)+`
5
- `;if(!this.isInteractive()){this.#e({level:i.INFO,message:e,args:s});return}o?o.content=n:(this.#t.length===0&&this.#t.push(...g),this.#t.push({id:t,content:n}));for(let r=0;r<this.#s;r++)c.moveCursor(process.stderr,0,-1),c.clearLine(process.stderr,1);this.printSticky(),this.#s=this.#t.length}successTime(t,e,...s){return this.#n(i.SUCCESS,e,t,...s)}warn(t,...e){this.#e({level:i.WARN,message:t,args:e})}warnProd(t,...e){this.#c?this.warn(t,...e):this.verbose(t,...e)}error(t,...e){this.#e({level:i.ERROR,message:t,args:e})}contentError(t,...e){this.#e({level:i.ERROR,message:t,scope:"content",args:e})}verbose(t,...e){process.env.REPORTER_VERBOSE==="true"&&this.#e({level:i.VERBOSE,message:t,args:e})}verboseTime(t,e,...s){if(process.env.REPORTER_VERBOSE==="true")return this.#n(i.VERBOSE,e,t,...s)}httpTime(t){return this.#n(i.HTTP,"",t)}startTiming(t){const e=t||Symbol();this.#r.set(e,performance.now());const s=setTimeout(()=>{this.#r.delete(e),this.#o.delete(e)},500*1e3);return this.#o.set(e,s),e}updateContext(t){this.#i={...this.#i,...t}}clearAllTimeouts(){for(const t of this.#o.values())clearTimeout(t);this.#o.clear()}#n(t,e,s,...o){const n=this.#r.get(s);if(!n)return;const r=Math.round(performance.now()-n);return this.#r.delete(s),this.#e({level:t,message:e,duration:r,args:o}),{message:e,timeMs:r}}setStickyState({globalStickyLines:t,prevStickyLines:e}){this.#t=t,this.#s=e}getStickyState(){return{globalStickyLines:this.#t,prevStickyLines:this.#s}}printSticky(){this.#t.forEach(t=>{process.stderr.write(t.content)})}clearSticky(){if(this.isInteractive())for(let t=0;t<this.#s;t++)c.moveCursor(process.stderr,0,-1),c.clearLine(process.stderr,1)}#e({level:t,message:e,duration:s,scope:o,args:n}){!this.disableSticky&&this.isInteractive()&&this.clearSticky();let r=e&&l.interpolate(e,...n);r&&s!=null&&t!==i.VERBOSE&&m.sendTimingPerformedMessage({timeMs:s,message:r});const a={level:t,message:r,duration:s,scope:o,context:this.#i};process.stderr.write(l.format(a)),!this.disableSticky&&this.isInteractive()&&this.printSticky()}isInteractive(){return!!(process.stderr&&process.stderr.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env)&&f())}async warnForRealFile(t,e,s,...o){await v(e,s)||this.warn(t,e,...o)}patchConsole(){for(const t of y)console[t]=(...e)=>{!this.disableSticky&&this.isInteractive()&&this.clearSticky();const s=[],o=new d({write(a,E,p){s.push(a.toString()),p()}});new console.Console({stdout:o,stderr:o})[t](...e);let r="";t==="table"||t==="dir"?r=`
6
- ${s.join("").slice(0,-1)}`:r=s.join("").slice(0,-1),process.stderr.write(l.format({level:h.getLogLevel(t),context:this.#i,message:r})),!this.disableSticky&&this.isInteractive()&&this.printSticky()}}static getLogLevel(t){switch(t){case"error":return i.ERROR;case"warn":return i.WARN;case"debug":case"trace":return i.VERBOSE;case"info":case"log":case"dir":case"table":case"assert":return i.INFO;default:const e=t;throw new Error(`Unhandled method: ${e}`)}}}const M=new h,y=["log","warn","error","info","debug","trace","dir","table","assert"];export{h as Logger,M as logger};
1
+ import{telemetry as a}from"../../telemetry/index.js";import{isProductionMode as c}from"../../utils/envs/is-production-mode.js";import l,{LogLevel as r,shouldLog as h,parseLogLevel as u}from"./formatter.js";import{isVirtualFile as f}from"../../fs/utils/isVirtualFile.js";import{TerminalManager as p}from"./terminal-manager.js";import{isDevelopMode as g}from"../../utils/envs/is-develop-mode.js";class d{#e;#l;#i;#n;#r=new Map;#o=new Map;constructor({context:t,forceNonInteractive:e,minLogLevel:i}={}){this.#e=t,this.#l=c(),this.#i=new p(e),this.#n=i??u(process.env.REDOCLY_LOG_LEVEL)??(g()?r.INFO:r.HTTP)}shouldLog(t){return h(t,this.#n)}info(t,...e){this.#t({level:r.INFO,message:t,args:e})}infoTime(t,e,...i){return this.#s(r.INFO,e,t,...i)}success(t,...e){this.#t({level:r.SUCCESS,message:t,args:e})}logInFooter(t,e,...i){const o=l.interpolate(e,...i)+`
2
+ `;this.isInteractive()||this.#i.isFooterChanged(t,o)&&this.#t({level:r.INFO,message:e,args:i}),this.#i.updateFooter(t,o)}successTime(t,e,...i){return this.#s(r.SUCCESS,e,t,...i)}warn(t,...e){this.#t({level:r.WARN,message:t,args:e})}warnProd(t,...e){this.#l?this.warn(t,...e):this.verbose(t,...e)}error(t,...e){this.#t({level:r.ERROR,message:t,args:e})}contentError(t,...e){this.#t({level:r.ERROR,message:t,scope:"content",args:e})}verbose(t,...e){this.#t({level:r.VERBOSE,message:t,args:e})}verboseTime(t,e,...i){return this.#s(r.VERBOSE,e,t,...i)}httpTime(t){return this.#s(r.HTTP,"",t)}startTiming(t){const e=t||Symbol();this.#r.set(e,performance.now());const i=setTimeout(()=>{this.#r.delete(e),this.#o.delete(e)},500*1e3);return this.#o.set(e,i),e}updateContext(t){this.#e={...this.#e,...t}}clearAllTimeouts(){for(const t of this.#o.values())clearTimeout(t);this.#o.clear()}isInteractive(){return this.#i.isInteractive()}warnForRealFile(t,e,i,...o){f(e,i)||this.warn(t,e,...o)}#s(t,e,i,...o){const n=this.#r.get(i);if(!n)return;const s=Math.round(performance.now()-n);return this.#r.delete(i),this.#t({level:t,message:e,duration:s,args:o}),{message:e,timeMs:s}}#t({level:t,message:e,duration:i,scope:o,args:n}){if(!h(t,this.#n))return;let s=e&&l.interpolate(e,...n);s&&i!=null&&t!==r.VERBOSE&&a.sendTimingPerformedMessage({timeMs:i,message:s});const m={level:t,message:s,duration:i,scope:o,context:this.#e};process.stderr.write(l.format(m))}}const O=new d;export{d as Logger,O as logger};
@@ -1,12 +1,12 @@
1
- import{isBuildMode as h}from"../../utils/envs/is-build-mode.js";import{logger as o}from"../../tools/notifiers/logger.js";import P from"./formatter.js";import{blue as k,gray as p,red as c}from"./helpers/colors.js";import{isVirtualFile as b}from"../../fs/utils/isVirtualFile.js";import{telemetry as u}from"../../telemetry/index.js";import{shutdowner as f}from"../shutdowner.js";const a=30;class g{#r=[];#e=[];#o=new Map;#t=[];pushError(r,t,...e){const i=P.interpolate(r,...e);this.#r.push({severity:t,message:i,type:"ERROR"})}reportBrokenLink(r){this.#r.push(r)}reportCompilationError(r){const t=`${r.message}::${r.sourceFileRelativePath}::${r?.sourceFileLocation?.line}`;this.#o.has(t)||this.#o.set(t,r)}reportPageRenderError(r){this.#t.push(r)}async panicOnBuild(r,...t){r instanceof Error&&(r=r.message+`
2
- `+r.stack),h()?await this.panic(r,...t):this.pushError(r,"PANIC",...t)}async panicOnBuildContentErrorForRealFile(r,t,e,...i){await b(t,e)||await this.panicOnBuildContentError(r,...i)}async panicOnBuildContentError(r,...t){r instanceof Error&&(r=r.message+`
3
- `+r.stack),h()?await this.panicOnContentError(r,...t):this.pushError(r,"PANIC",...t)}async panic(r,...t){let e;r instanceof Error?(e=r,r=r.message+`
4
- `+r.stack):e=new Error(r),o.error(r,...t),u.sendCliErrorCaughtMessage({message:r}),await f.exitWithCode(1,e)}async panicOnContentError(r,...t){let e;r instanceof Error?(e=r,r=r.message+`
5
- `+r.stack):e=new Error(r),o.contentError(r,...t),u.sendCliErrorCaughtMessage({message:r,scope:"content"}),await f.exitWithCode(1,e)}reportMarkdocProblem(r){this.#e.push(r)}clearErrors(){this.#r=[]}clearMarkdocProblems(){this.#e=[]}clearEsbuildProblems(){this.#o.clear()}clearPageRenderProblems(){this.#t=[]}getCompilationProblem(r){return this.#o.get(r)}getCompilationProblems(){return[...this.#o.values()]}getPageRenderProblems(){return this.#t}getPageRenderProblem(r){return this.#t.find(t=>t.sourceFileRelativePath===r)}getProblems(){return[...this.#r,...this.getCompilationProblems(),...this.#e,...this.#t]}summary(r,t=0){const e=this.getProblems(),i=this.#e.filter(l=>l.type==="BROKEN_LINK").length,s=this.#r.filter(l=>l.type==="BROKEN_LINK").length,m=this.#e.length-i,E=this.#r.length-s+this.getCompilationProblems().length+this.#t.length;return o.logSticky("validate",e.length?c(" \u274C Status: %s markdoc errors, %s broken links, %s other errors"):" \u2705 Status: No errors found",m,i+s,E),t!==0&&o.logSticky("pages",` \u{1F4C4} Total pages: ${t}`),o.logSticky("timing",r),o.logSticky("validate-sep",""),o.isInteractive()&&(e.length?o.logSticky("actions","Press (e) to print all errors, (q) to quit"):o.logSticky("actions",p("Press (q) to quit"))),e}printErrors(r=[]){o.clearSticky(),o.disableSticky=!0;const t=this.#r.length,e=r.length?r:this.getProblems();let i=0;for(const s of e.slice(0,a))i>=t?o.contentError(c(`[${++i}] `)+d(s)):o.error(c(`[${++i}] `)+d(s));e.length>a&&o.error(`... and ${e.length-a} more errors`),o.printSticky(),o.disableSticky=!1}listenStdin(){if(!o.isInteractive())return;process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf8");const r=this.printErrors.bind(this);process.stdin.on("data",function(t){if(t===""&&process.exit(),t==="\x7F"){process.stdout.write("\b \b");return}if(t==="\r"){o.clearSticky(),process.stdout.write(`
6
- `),o.printSticky();return}if(t==="e"){r();return}t==="q"&&process.exit(0)})}}const B=new g;function d(n){const r=n.sourceFileLocation,t=r?`:${r.line}:${r.character??1}`:"";return n.message+(n.codeframe?`
1
+ import{isBuildMode as h}from"../../utils/envs/is-build-mode.js";import{logger as e}from"../../tools/notifiers/logger.js";import P from"./formatter.js";import{blue as g,gray as p,red as a}from"./helpers/colors.js";import{isVirtualFile as b}from"../../fs/utils/isVirtualFile.js";import{telemetry as u}from"../../telemetry/index.js";import{shutdowner as f}from"../shutdowner.js";const c=30;class C{#r=[];#o=[];#e=new Map;#t=[];pushError(r,t,...o){const n=P.interpolate(r,...o);this.#r.push({severity:t,message:n,type:"ERROR"})}reportBrokenLink(r){this.#r.push(r)}reportCompilationError(r){const t=`${r.message}::${r.sourceFileRelativePath}::${r?.sourceFileLocation?.line}`;this.#e.has(t)||this.#e.set(t,r)}reportPageRenderError(r){this.#t.push(r)}async panicOnBuild(r,...t){r instanceof Error&&(r=r.message+`
2
+ `+r.stack),h()?await this.panic(r,...t):this.pushError(r,"PANIC",...t)}async panicOnBuildContentErrorForRealFile(r,t,o,...n){b(t,o)||await this.panicOnBuildContentError(r,...n)}async panicOnBuildContentError(r,...t){r instanceof Error&&(r=r.message+`
3
+ `+r.stack),h()?await this.panicOnContentError(r,...t):this.pushError(r,"PANIC",...t)}async panic(r,...t){let o;r instanceof Error?(o=r,r=r.message+`
4
+ `+r.stack):o=new Error(r),e.error(r,...t),u.sendCliErrorCaughtMessage({message:r}),await f.exitWithCode(1,o)}async panicOnContentError(r,...t){let o;r instanceof Error?(o=r,r=r.message+`
5
+ `+r.stack):o=new Error(r),e.contentError(r,...t),u.sendCliErrorCaughtMessage({message:r,scope:"content"}),await f.exitWithCode(1,o)}reportMarkdocProblem(r){this.#o.push(r)}clearErrors(){this.#r=[]}clearMarkdocProblems(){this.#o=[]}clearEsbuildProblems(){this.#e.clear()}clearPageRenderProblems(){this.#t=[]}getCompilationProblem(r){return this.#e.get(r)}getCompilationProblems(){return[...this.#e.values()]}getPageRenderProblems(){return this.#t}getPageRenderProblem(r){return this.#t.find(t=>t.sourceFileRelativePath===r)}getProblems(){return[...this.#r,...this.getCompilationProblems(),...this.#o,...this.#t]}summary(r,t=0){const o=this.getProblems(),n=this.#o.filter(l=>l.type==="BROKEN_LINK").length,s=this.#r.filter(l=>l.type==="BROKEN_LINK").length,m=this.#o.length-n,E=this.#r.length-s+this.getCompilationProblems().length+this.#t.length;return e.logInFooter("validate",o.length?a(" \u274C Status: %s markdoc errors, %s broken links, %s other errors"):" \u2705 Status: No errors found",m,n+s,E),t!==0&&e.logInFooter("pages",` \u{1F4C4} Total pages: ${t}`),e.logInFooter("timing",r),e.logInFooter("validate-sep",""),e.isInteractive()&&(o.length?e.logInFooter("actions","Press (e) to print all errors, (q) to quit"):e.logInFooter("actions",p("Press (q) to quit"))),o}printErrors(r=[]){const t=this.#r.length,o=r.length?r:this.getProblems();let n=0;for(const s of o.slice(0,c))n>=t?e.contentError(a(`[${++n}] `)+d(s)):e.error(a(`[${++n}] `)+d(s));o.length>c&&e.error(`... and ${o.length-c} more errors`)}listenStdin(){if(!e.isInteractive())return;process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf8");const r=this.printErrors.bind(this);process.stdin.on("data",function(t){if(t===""&&process.exit(),t==="\x7F"){process.stdout.write("\b \b");return}if(t==="\r"){process.stdout.write(`
6
+ `);return}if(t==="e"){r();return}t==="q"&&process.exit(0)})}}const B=new C;function d(i){const r=i.sourceFileLocation,t=r?`:${r.line}:${r.character??1}`:"";return i.message+(i.codeframe?`
7
7
 
8
- `+n.codeframe+`
8
+ `+i.codeframe+`
9
9
 
10
10
  `:`
11
- `)+(n.sourceFileRelativePath?p(`at ${k("./"+n.sourceFileRelativePath)}${t}`)+`
12
- `:"")}export{g as Reporter,B as reporter};
11
+ `)+(i.sourceFileRelativePath?p(`at ${g("./"+i.sourceFileRelativePath)}${t}`)+`
12
+ `:"")}export{C as Reporter,B as reporter};
@@ -0,0 +1,8 @@
1
+ export declare class TerminalManager {
2
+ #private;
3
+ constructor(forceNonInteractive?: boolean);
4
+ isInteractive(): boolean;
5
+ isFooterChanged(id: string, content: string): boolean;
6
+ updateFooter(id: string, content: string): void;
7
+ }
8
+ //# sourceMappingURL=terminal-manager.d.ts.map
@@ -0,0 +1,5 @@
1
+ import{isDevelopMode as h}from"../../utils/envs/is-develop-mode.js";import{gray as p}from"./helpers/colors.js";const t="\x1B[",i=`${t}s`,o=`${t}u`,d=`${t}J`,a=c=>`${t}1;${c}r`,f=`${t}r`,w=`${t}?25h`,R=`${t}?25l`,l=()=>`${p("\u2500".repeat(process.stderr.columns||80))}
2
+
3
+ `,u=3;class I{#s=new Map;#r=process.stderr.rows;#e=0;#t=!1;#i=!1;constructor(s=!1){this.#i=s}isInteractive(){return!!(!this.#i&&process.stderr&&process.stderr.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env)&&h())}isFooterChanged(s,r){return this.#s.get(s)!==r}updateFooter(s,r){const e=!this.#s.has(s);this.#s.set(s,r),this.isInteractive()&&(e?this.#n():this.#c())}get#o(){if(this.#s.size===0)return 0;let s=u;for(const r of this.#s.values())s+=(r.match(/\n/g)||[]).length;return s}#c(){if(!this.isInteractive()||this.#s.size===0)return;this.#h();const s=this.#o,r=process.stderr.rows;if(!(s>r)){process.stderr.write(i),process.stderr.cursorTo(0,r-s+1),process.stderr.write(l());for(const e of this.#s.values())process.stderr.write(e);process.stderr.write(o)}}#n(s=0){if(!this.isInteractive())return;const r=process.stderr.rows;let e=this.#o;e>r&&(e=0);const n=e-this.#e;this.#e=e,n>0&&(process.stderr.write(i),process.stderr.write(`
4
+ `.repeat(n)),process.stderr.write(o)),process.stderr.write(i),process.stderr.write(d),s<0&&process.stderr.write(`
5
+ `.repeat(e)),process.stderr.write(a(r-e)),process.stderr.write(o),this.#c()}#h(){this.#t||(this.#t=!0,process.stderr.write(R),process.on("exit",this.#p),process.stderr.on("resize",this.#d))}#p=()=>{this.isInteractive()&&(process.stderr.write(f),process.stderr.write(`${t}${process.stderr.rows};1H`),process.stderr.write(w))};#d=()=>{const s=process.stderr.rows-this.#r;this.#r=process.stderr.rows,this.#n(s)}}export{I as TerminalManager};
@@ -4,9 +4,8 @@ import type { MarkdocError } from '../../types/index.js';
4
4
  export type FileInfo = {
5
5
  relativePath: string;
6
6
  realRelativePath: string;
7
- dirname: string;
8
- isVirtual?: boolean;
9
- hash?: string;
7
+ isVirtual: boolean;
8
+ hash: string | undefined;
10
9
  };
11
10
  /**
12
11
  * Information about fs acccess operations.
@@ -20,21 +19,17 @@ export type FileInfo = {
20
19
  */
21
20
  export type AccessRecord = {
22
21
  type: 'load';
23
- loaderKey: string;
24
- cacheKey: string;
22
+ loaderId: string;
23
+ resource: string;
25
24
  hash: string;
26
25
  } | {
27
- type: 'read' | 'exists' | 'readdir';
26
+ type: 'read' | 'exists';
28
27
  path: string;
29
28
  hash: string;
30
29
  } | {
31
30
  type: 'scan';
32
- path: string;
33
31
  hash: string;
34
32
  pattern?: RegExp;
35
- } | {
36
- type: 'dependencies';
37
- hash: string;
38
33
  };
39
34
  export type LoadResult<T> = {
40
35
  /**
@@ -1,5 +1,4 @@
1
1
  import type { ApiFunctionsBasicContext } from '../../types';
2
- import type { LoggerStickyState } from '../../tools/notifiers/logger.js';
3
2
  export type ApiRoutesWorkerParams = {
4
3
  maxResponseSizeMB?: number;
5
4
  slug: string;
@@ -22,7 +21,6 @@ export type ApiRoutesWorkerParams = {
22
21
  referrer: string;
23
22
  referrerPolicy: ReferrerPolicy;
24
23
  };
25
- loggerStickyState: LoggerStickyState;
26
24
  sqldRemoteDatabaseUrl?: string;
27
25
  sqldRemoteDatabaseAuthToken?: string;
28
26
  };
@@ -33,6 +31,5 @@ export type ApiRoutesWorkerResponse = {
33
31
  type: 'Buffer';
34
32
  data: number[];
35
33
  };
36
- loggerStickyState: LoggerStickyState;
37
34
  };
38
35
  //# sourceMappingURL=api-routes.d.ts.map
@@ -201,7 +201,6 @@ export type AfterRoutesCreatedLifecycleContext = LifecycleContext & {
201
201
  };
202
202
  export type MarkdownParseInput = {
203
203
  relativePath: string;
204
- cacheId?: string;
205
204
  isVirtual?: boolean;
206
205
  content?: string;
207
206
  };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Validates if a string is a valid ISO 8601 date-time string
3
+ */
4
+ export declare function isValidIsoDate(value: string): boolean;
5
+ //# sourceMappingURL=is-valid-iso-date.d.ts.map
@@ -0,0 +1 @@
1
+ function d(t){if(typeof t!="string")return!1;const e=new Date(t);return!isNaN(e.getTime())&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(t)}export{d as isValidIsoDate};
@@ -1 +1 @@
1
- import*as t from"path";import{cliCommandNames as o}from"../../constants/common.js";import{PUBLIC_STATIC_FOLDER as i}from"../constants/common.js";import{logger as n}from"../tools/notifiers/logger.js";import{blue as p,gray as m}from"../tools/notifiers/helpers/colors.js";import{loadEnvVariables as f}from"./envs/load-env-variables.js";import{copyFolderRecursiveSync as a}from"./fs.js";import{validateInstalledVersion as E}from"./validate-installed-version.js";import{PACKAGE_NAME as l}from"../../config/product-gates.js";import{PORTAL_VERSION as u}from"../version.js";function P(e){return e?"true":"false"}function R(e){return e?"true":"false"}function v(e){process.env.REPORTER_VERBOSE=P(e.verbose),process.env.INSPECT_MODE="inspect"in e?R(e.inspect):"false",e.pathPrefix&&(process.env.REDOCLY_PREFIX_PATHS=e.pathPrefix)}function O({contentDir:e,outdir:r}){a(t.join(e,i),t.join(r,i))}async function b(e,r,s){f(r["project-dir"]),process.env.REDOCLY_RUNNING_COMMAND=e;const c=e===o.DEVELOP?" Previewing with":"Building with";switch(n.logSticky("product",`${c} ${p(`${l}@${u}`)}`),n.logSticky("server",` \u{1F310} Preview URL: ${m("server starting...")}`),e){case o.DEVELOP:case o.BUILD:case o.PREPARE:v(r);break;default:break}await E(),O(s)}export{b as beforeCommand};
1
+ import*as i from"path";import{cliCommandNames as r}from"../../constants/common.js";import{PUBLIC_STATIC_FOLDER as t}from"../constants/common.js";import{logger as n}from"../tools/notifiers/logger.js";import{blue as s,gray as c}from"../tools/notifiers/helpers/colors.js";import{loadEnvVariables as f}from"./envs/load-env-variables.js";import{copyFolderRecursiveSync as l}from"./fs.js";import{validateInstalledVersion as a}from"./validate-installed-version.js";import{PACKAGE_NAME as E}from"../../config/product-gates.js";import{PORTAL_VERSION as P}from"../version.js";function u(e){return e?"true":"false"}function v(e){e["log-level"]&&(process.env.REDOCLY_LOG_LEVEL=String(e["log-level"])),process.env.INSPECT_MODE="inspect"in e?u(e.inspect):"false",e.pathPrefix&&(process.env.REDOCLY_PREFIX_PATHS=e.pathPrefix)}function L({contentDir:e,outdir:o}){l(i.join(e,t),i.join(o,t))}async function N(e,o,p){f(o["project-dir"]),process.env.REDOCLY_RUNNING_COMMAND=e;const m=e===r.DEVELOP?" Previewing with":"Building with";switch(n.logInFooter("product",`${m} ${s(`${E}@${P}`)}`),n.logInFooter("server",` \u{1F310} Preview URL: ${c("server starting...")}`),e){case r.DEVELOP:case r.BUILD:case r.PREPARE:v(o);break;default:break}await a(),L(p)}export{N as beforeCommand};
@@ -1 +1 @@
1
- function c(i){return"data"in i}function a(i){return"execute"in i}class o{#t=[];#e=null;#s;#i;constructor(t){this.#c(t),this.#s=t.batchSize,this.#i=t.batchProcessor}async addItem(t){return new Promise((s,h)=>{if(a(t)){const r={execute:async(...n)=>{try{const e=await t.execute(...n);return s(e),e}catch(e){throw console.error("Failed to execute item:",e),h(e),e}}};this.#t.push(r)}else if(c(t))this.#t.push(t),s(t.data);else{h(new Error("Invalid item type"));return}this.#h()})}#h(){this.#e||this.#t.length===0||this.#s&&this.#t.length<this.#s||(this.#e=this.#n().catch(t=>{console.error("Batch queue processing failed:",t)}).finally(()=>{this.#e=null,this.#t.length>0&&this.#h()}))}async#n(){for(;this.#t.length>=(this.#s??1);)await this.#r()}async processRemainingItems(){for(this.#e&&await this.#e;this.#t.length>0;)await this.#r()}async#r(){const t=this.#s??this.#t.length,s=this.#t.splice(0,t);s.length&&await this.#i(s)}#c(t){if(t.batchSize&&t.batchSize<=0)throw new Error("Batch size must be greater than 0")}get isProcessing(){return this.#e!==null}}export{o as BatchQueue,c as isDataItem,a as isExecutableItem};
1
+ import{logger as a}from"../tools/notifiers/logger.js";function c(i){return"data"in i}function o(i){return"execute"in i}class l{#t=[];#e=null;#s;#i;constructor(t){this.#a(t),this.#s=t.batchSize,this.#i=t.batchProcessor}async addItem(t){return new Promise((e,h)=>{if(o(t)){const r={execute:async(...n)=>{try{const s=await t.execute(...n);return e(s),s}catch(s){throw h(s),s}}};this.#t.push(r)}else if(c(t))this.#t.push(t),e(t.data);else{h(new Error("Invalid item type"));return}this.#h()})}#h(){this.#e||this.#t.length===0||this.#s&&this.#t.length<this.#s||(this.#e=this.#n().catch(t=>{a.error(`Batch queue processing failed: ${t.message}`)}).finally(()=>{this.#e=null,this.#t.length>0&&this.#h()}))}async#n(){for(;this.#t.length>=(this.#s??1);)await this.#r()}async processRemainingItems(){for(this.#e&&await this.#e;this.#t.length>0;)await this.#r()}async#r(){const t=this.#s??this.#t.length,e=this.#t.splice(0,t);e.length&&await this.#i(e)}#a(t){if(t.batchSize&&t.batchSize<=0)throw new Error("Batch size must be greater than 0")}get isProcessing(){return this.#e!==null}}export{l as BatchQueue,c as isDataItem,o as isExecutableItem};
@@ -3,12 +3,14 @@ import type { WildcardRedirectsTree } from '../../types';
3
3
  /**
4
4
  * Finds a matching redirect configuration for a given slug.
5
5
  *
6
- * - Normalizes the input `slug` by converting it to lowercase and applying route normalization.
6
+ * **IMPORTANT:** The `slug` parameter must be normalized before passing to this function.
7
+ * This function does NOT perform normalization internally.
8
+ *
7
9
  * - First checks for a direct match in the `redirects` configuration.
8
10
  * - If no direct match is found, searches for wildcard redirects (patterns ending with `*`).
9
11
  * - For wildcard matches, preserves the remaining path after the wildcard prefix if the redirect target also ends with `*`.
10
12
  *
11
- * @param slug - The URL slug to find a redirect for.
13
+ * @param slug - The normalized (lowercased) URL slug to find a redirect for.
12
14
  * @param redirects - The redirects configuration object.
13
15
  * @param wildcardRedirectsTree - The wildcard redirects converted to a tree structure to optimize the search.
14
16
  * @returns An object containing the redirect `to` URL and optional `type`, or `null` if no redirect is found.
@@ -1 +1 @@
1
- import{normalizeRouteSlug as a}from"../../../utils/path/normalize-route-slug.js";import{removeLeadingSlash as f}from"../../../utils/url/remove-leading-slash.js";function m(i,r,c){const t=a(i.toLowerCase()),e=r[t];if(e&&e.to)return{to:e.to,type:e.type};const n=s(t,c);if(n){let o=r[n]?.to;if(o){if(o.endsWith("*")){const d=n.split("*")[0],l=i.substring(d.length);o=o.replace(/\*$/,l)}return{...r[n],to:o}}}return null}function s(i,r){const c=f(i).split("/");let t=r;for(const e of c){if(!t[e])break;t=t[e]}return t["*"]||null}export{m as findRedirect};
1
+ import{removeLeadingSlash as f}from"../../../utils/url/remove-leading-slash.js";function p(e,i,o){e=e.toLowerCase();const t=i[e];if(t&&t.to)return{to:t.to,type:t.type};const r=a(e,o);if(r){let n=i[r]?.to;if(n){if(n.endsWith("*")){const c=r.split("*")[0],d=e.substring(c.length);n=n.replace(/\*$/,d)}return{...i[r],to:n}}}return null}function a(e,i){const o=f(e).split("/");let t=i;for(const r of o){if(!t[r])break;t=t[r]}return t["*"]||null}export{p as findRedirect};
@@ -1 +1 @@
1
- import i from"node:path";import{withPathPrefix as f}from"@redocly/theme/core/utils";import{PUBLIC_STATIC_FOLDER as p}from"../constants/common.js";import{isLocalLink as u}from"../../utils/path/is-local-link.js";import{copyStaticFile as F,FileNotFoundError as d}from"./fs.js";async function h(r,n,o){if(!u(r))return r;const t=r.startsWith("/")?i.posix.join(p,r):void 0;if(t&&await n.exists(t))return f(r);const c=r.startsWith("/")?r.slice(1):i.posix.join(i.dirname(o.fromFileRelativePath),r),m=await n.getFileInfo(c);if(!m)throw new d(`Cannot resolve asset path: ${r}`,r);return F(o.contentDir,m.realRelativePath,o.outdir)}export{h as resolveAssetPath};
1
+ import i from"node:path";import{withPathPrefix as f}from"@redocly/theme/core/utils";import{PUBLIC_STATIC_FOLDER as p}from"../constants/common.js";import{isLocalLink as u}from"../../utils/path/is-local-link.js";import{copyStaticFile as F,FileNotFoundError as d}from"./fs.js";async function h(r,n,o){if(!u(r))return r;const t=r.startsWith("/")?i.posix.join(p,r):void 0;if(t&&await n.exists(t))return f(r);const c=r.startsWith("/")?r.slice(1):i.posix.join(i.dirname(o.fromFileRelativePath),r),m=n.getFileInfo(c);if(!m)throw new d(`Cannot resolve asset path: ${r}`,r);return F(o.contentDir,m.realRelativePath,o.outdir)}export{h as resolveAssetPath};
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Options for validating a string parameter
3
+ */
4
+ type IsValidSanitizedStringOptions = {
5
+ /**
6
+ * Regular expression pattern that the string must match
7
+ */
8
+ pattern: RegExp;
9
+ /**
10
+ * Maximum allowed length (default: 1000)
11
+ */
12
+ maxLength?: number;
13
+ /**
14
+ * Whether empty strings are allowed (default: false)
15
+ */
16
+ allowEmpty?: boolean;
17
+ };
18
+ /**
19
+ * Validates if a string parameter is valid according to the provided options.
20
+ * Can be undefined/null or a string.
21
+ * If it's a string, it must match the provided pattern and length constraints.
22
+ *
23
+ * @param value - The string parameter from query string (can be undefined, null, or string)
24
+ * @param options - Validation options including pattern, maxLength, etc.
25
+ * @returns true if the value is valid (or undefined/null), false otherwise
26
+ */
27
+ export declare function isValidSanitizedString(value: string | undefined | null, options: IsValidSanitizedStringOptions): boolean;
28
+ export {};
29
+ //# sourceMappingURL=validate-and-sanitize-string.d.ts.map
@@ -0,0 +1 @@
1
+ function i(t,e){if(t==null)return!0;if(typeof t!="string")return!1;const r=t.trim();if(r==="")return e.allowEmpty??!1;const n=e.maxLength??1e3;return!(r.length>n||!e.pattern.test(r))}export{i as isValidSanitizedString};
@@ -67,6 +67,11 @@ export declare function createMcpAuthorizationCode(params: {
67
67
  ttlSec?: number;
68
68
  }): Promise<string>;
69
69
  export declare function verifyMcpAuthorizationCode(code: string): Promise<McpAuthorizationCodePayload>;
70
+ export declare function createMcpSessionResource(sessionId: string | null | undefined): {
71
+ id: string;
72
+ object: "mcp_session";
73
+ uri: string;
74
+ };
70
75
  export declare function rewritePreviewAuthRedirectUri(redirectUri: string): string;
71
76
  export declare function parsePreviewBranch(origin: string): string | undefined;
72
77
  export declare function buildLoginUrl(idpLoginParams: AuthProviderLoginParams, redirectOrigin: string, redirectTo: string | null, inviteCode?: string): {