@redocly/realm 0.137.0-next.9 → 0.138.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/CHANGELOG.md +248 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/cli/build/index.js +1 -1
  4. package/dist/cli/eject/themeOperations.js +1 -1
  5. package/dist/cli/generate/generate-tag.js +1 -1
  6. package/dist/cli/generate/generate.js +1 -1
  7. package/dist/client/app/Sidebar/useActions.js +1 -1
  8. package/dist/client/app/Sidebar/useSidebarItems.js +1 -1
  9. package/dist/client/app/hooks/catalog/useCatalog.d.ts +1 -2
  10. package/dist/client/app/hooks/catalog/useCatalogClassic.js +1 -1
  11. package/dist/client/app/hooks/catalog/useCatalogFilter.js +1 -1
  12. package/dist/client/app/l10n/hooks/useL10n.js +1 -1
  13. package/dist/client/app/l10n/index.js +1 -1
  14. package/dist/client/app/search/sse-parser.d.ts +5 -2
  15. package/dist/client/app/search/sse-parser.js +2 -2
  16. package/dist/client/app/search/useFacets.js +1 -1
  17. package/dist/client/app/seo/SeoTags.js +1 -1
  18. package/dist/client/app/utils/loadAndNavigate.js +1 -1
  19. package/dist/client/constants/ai-search.d.ts +8 -0
  20. package/dist/client/constants/ai-search.js +1 -1
  21. package/dist/constants/l10n/langs/ar.js +1 -1
  22. package/dist/constants/l10n/langs/de.js +1 -1
  23. package/dist/constants/l10n/langs/en.js +1 -1
  24. package/dist/constants/l10n/langs/es.js +1 -1
  25. package/dist/constants/l10n/langs/fr.js +1 -1
  26. package/dist/constants/l10n/langs/hi.js +1 -1
  27. package/dist/constants/l10n/langs/it.js +1 -1
  28. package/dist/constants/l10n/langs/ja.js +1 -1
  29. package/dist/constants/l10n/langs/ko.js +1 -1
  30. package/dist/constants/l10n/langs/pl.js +1 -1
  31. package/dist/constants/l10n/langs/pt-BR.js +1 -1
  32. package/dist/constants/l10n/langs/pt.js +1 -1
  33. package/dist/constants/l10n/langs/ru.js +1 -1
  34. package/dist/constants/l10n/langs/uk.js +1 -1
  35. package/dist/constants/l10n/langs/zh.js +1 -1
  36. package/dist/markdoc/helpers/guards/is-example-node.d.ts +2 -1
  37. package/dist/markdoc/helpers/guards/is-example-node.js +1 -1
  38. package/dist/markdoc/nodes/fence/index.js +1 -1
  39. package/dist/server/config/env-config.d.ts +2 -0
  40. package/dist/server/config/env-schema.d.ts +5 -0
  41. package/dist/server/config/env-schemas/feature-flags.d.ts +4 -0
  42. package/dist/server/config/env-schemas/feature-flags.js +1 -1
  43. package/dist/server/constants/entitlements.d.ts +1 -2
  44. package/dist/server/constants/plugins/search.js +1 -1
  45. package/dist/server/esbuild/esbuild-logger.d.ts +2 -2
  46. package/dist/server/esbuild/esbuild-logger.js +3 -3
  47. package/dist/server/esbuild/plugins/styled-components-ssr.js +1 -1
  48. package/dist/server/esbuild/plugins/themes-resolver.js +2 -2
  49. package/dist/server/fs/cache.js +1 -1
  50. package/dist/server/fs/fs.js +1 -1
  51. package/dist/server/fs/utils/remove-l10n-prefix.js +1 -1
  52. package/dist/server/persistence/file-hashes/repositories/file-hashes-repository.d.ts +1 -2
  53. package/dist/server/persistence/file-hashes/services/file-hashes-service.d.ts +1 -2
  54. package/dist/server/plugins/analytics/rudderstack/browser-hooks.js +1 -1
  55. package/dist/server/plugins/analytics/segment/browser-hooks.js +1 -1
  56. package/dist/server/plugins/analytics/segment/build-script.js +3 -3
  57. package/dist/server/plugins/api-docs/loader.d.ts +2 -3
  58. package/dist/server/plugins/api-docs/options.d.ts +1 -1
  59. package/dist/server/plugins/api-docs/options.js +1 -1
  60. package/dist/server/plugins/api-docs/search/create-indexer.d.ts +5 -0
  61. package/dist/server/plugins/api-docs/search/create-indexer.js +1 -0
  62. package/dist/server/plugins/api-docs/search/get-ai-search-documents.d.ts +2 -2
  63. package/dist/server/plugins/api-docs/search/get-ai-search-documents.js +41 -41
  64. package/dist/server/plugins/api-docs/search/search-resolver.js +1 -1
  65. package/dist/server/plugins/api-docs/utils/decorators.js +1 -1
  66. package/dist/server/plugins/api-functions/index.js +1 -1
  67. package/dist/server/plugins/catalog-entities/database/repositories/common/revision-repository.js +1 -1
  68. package/dist/server/plugins/catalog-entities/database/repositories/common/version-repository.js +1 -1
  69. package/dist/server/plugins/catalog-entities/database/repositories/entities/entities-write-repository.js +1 -1
  70. package/dist/server/plugins/catalog-entities/database/repositories/utils/normalize-revision-flags.js +1 -1
  71. package/dist/server/plugins/catalog-entities/types/extractors.d.ts +1 -2
  72. package/dist/server/plugins/catalog-entities/utils/openapi-component-content-extractor.d.ts +1 -2
  73. package/dist/server/plugins/catalog-entities/utils/openapi-schema-resolver.d.ts +1 -2
  74. package/dist/server/plugins/config-parser/format-error.js +4 -4
  75. package/dist/server/plugins/config-parser/loaders/content-slugs-loader.js +1 -1
  76. package/dist/server/plugins/config-parser/loaders/versions-config-loader.js +1 -1
  77. package/dist/server/plugins/dev-onboarding/template/components/EditAppDescriptionDialog.js +1 -1
  78. package/dist/server/plugins/dev-onboarding/template/components/EditAppDialog.js +1 -1
  79. package/dist/server/plugins/dev-onboarding/template/components/EditCallbackUrlDialog.js +1 -1
  80. package/dist/server/plugins/l10n/index.js +1 -1
  81. package/dist/server/plugins/lifecycle.js +2 -2
  82. package/dist/server/plugins/markdown/attribute-resolvers/resolve-link.js +1 -1
  83. package/dist/server/plugins/markdown/attribute-resolvers/resolve-svg-content.js +1 -1
  84. package/dist/server/plugins/markdown/compiler.js +1 -1
  85. package/dist/server/plugins/markdown/errors.js +1 -1
  86. package/dist/server/plugins/markdown/is-partial.js +1 -1
  87. package/dist/server/plugins/markdown/markdoc/reparse-example-fences.d.ts +7 -0
  88. package/dist/server/plugins/markdown/markdoc/reparse-example-fences.js +1 -0
  89. package/dist/server/plugins/markdown/markdoc/resolve-raw-partials.js +1 -1
  90. package/dist/server/plugins/markdown/runtime-transform.js +1 -1
  91. package/dist/server/plugins/markdown/search/to-markdown.js +20 -20
  92. package/dist/server/plugins/mcp/codemode/capabilities/fetch/index.js +5 -4
  93. package/dist/server/plugins/mcp/codemode/capabilities/types.d.ts +5 -2
  94. package/dist/server/plugins/mcp/codemode/capabilities/utils.js +4 -4
  95. package/dist/server/plugins/mcp/codemode/code-execution-audit.js +1 -1
  96. package/dist/server/plugins/mcp/codemode/code-execution-telemetry.d.ts +7 -2
  97. package/dist/server/plugins/mcp/codemode/code-execution-telemetry.js +1 -1
  98. package/dist/server/plugins/mcp/codemode/invoke-tool.js +1 -1
  99. package/dist/server/plugins/mcp/codemode/prompts.d.ts +1 -1
  100. package/dist/server/plugins/mcp/codemode/prompts.js +7 -6
  101. package/dist/server/plugins/mcp/codemode/sandbox/create-sandbox-setup.d.ts +2 -2
  102. package/dist/server/plugins/mcp/codemode/sandbox/create-sandbox-setup.js +1 -11
  103. package/dist/server/plugins/mcp/codemode/sandbox/polyfills/console.d.ts +2 -0
  104. package/dist/server/plugins/mcp/codemode/sandbox/polyfills/console.js +7 -0
  105. package/dist/server/plugins/mcp/codemode/sandbox/polyfills/index.d.ts +1 -0
  106. package/dist/server/plugins/mcp/codemode/sandbox/polyfills/index.js +2 -2
  107. package/dist/server/plugins/mcp/codemode/sandbox/tool-input-validator.d.ts +5 -0
  108. package/dist/server/plugins/mcp/codemode/sandbox/tool-input-validator.js +1 -0
  109. package/dist/server/plugins/mcp/codemode/sandbox/unknown-tool-hint.d.ts +12 -0
  110. package/dist/server/plugins/mcp/codemode/sandbox/unknown-tool-hint.js +2 -0
  111. package/dist/server/plugins/mcp/codemode/tools/describe-tools.js +3 -1
  112. package/dist/server/plugins/mcp/codemode/tools/execute.js +1 -1
  113. package/dist/server/plugins/mcp/codemode/tools/manage-credentials.d.ts +2 -2
  114. package/dist/server/plugins/mcp/codemode/tools/manage-credentials.js +2 -2
  115. package/dist/server/plugins/mcp/codemode/tools/tool-errors.d.ts +4 -0
  116. package/dist/server/plugins/mcp/codemode/tools/tool-errors.js +1 -1
  117. package/dist/server/plugins/mcp/constants.d.ts +1 -0
  118. package/dist/server/plugins/mcp/constants.js +1 -1
  119. package/dist/server/plugins/mcp/docs-mcp/tool-schemas.d.ts +1 -0
  120. package/dist/server/plugins/mcp/docs-mcp/tool-schemas.js +1 -1
  121. package/dist/server/plugins/mcp/docs-mcp/tools/core/create-anonymous-session.js +1 -1
  122. package/dist/server/plugins/mcp/docs-mcp/tools/core/search.js +2 -2
  123. package/dist/server/plugins/mcp/docs-mcp/tools/core/submit-feedback.d.ts +7 -0
  124. package/dist/server/plugins/mcp/docs-mcp/tools/core/submit-feedback.js +3 -0
  125. package/dist/server/plugins/mcp/docs-mcp/tools/core/types.d.ts +8 -2
  126. package/dist/server/plugins/mcp/docs-mcp/tools/graphql/get-graphql-type.js +5 -5
  127. package/dist/server/plugins/mcp/docs-mcp/tools/graphql/types.d.ts +2 -1
  128. package/dist/server/plugins/mcp/docs-mcp/tools/index.d.ts +1 -0
  129. package/dist/server/plugins/mcp/docs-mcp/tools/index.js +1 -1
  130. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-endpoint-info.js +1 -1
  131. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-endpoints.js +1 -1
  132. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-full-api-description.js +1 -1
  133. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-security-schemes.js +1 -1
  134. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/list-apis.js +1 -1
  135. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/load-api-description.d.ts +17 -3
  136. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/load-api-description.js +1 -1
  137. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/types.d.ts +6 -2
  138. package/dist/server/plugins/mcp/docs-mcp/utils/api-name-matching.d.ts +6 -1
  139. package/dist/server/plugins/mcp/docs-mcp/utils/api-name-matching.js +1 -1
  140. package/dist/server/plugins/mcp/docs-mcp/utils/api-titles.d.ts +14 -0
  141. package/dist/server/plugins/mcp/docs-mcp/utils/api-titles.js +1 -0
  142. package/dist/server/plugins/mcp/gateway-mcp/elicitation.d.ts +11 -0
  143. package/dist/server/plugins/mcp/gateway-mcp/elicitation.js +5 -5
  144. package/dist/server/plugins/mcp/gateway-mcp/fetch/ssrf-guard.js +1 -1
  145. package/dist/server/plugins/mcp/gateway-mcp/fetch/url-placeholders.d.ts +5 -0
  146. package/dist/server/plugins/mcp/gateway-mcp/fetch/url-placeholders.js +1 -0
  147. package/dist/server/plugins/mcp/handlers/docs-mcp-handler.js +1 -1
  148. package/dist/server/plugins/mcp/index.js +1 -1
  149. package/dist/server/plugins/mcp/servers/docs-server.js +1 -1
  150. package/dist/server/plugins/mcp/servers/mcp-server.js +3 -3
  151. package/dist/server/plugins/mcp/types.d.ts +1 -0
  152. package/dist/server/plugins/mcp/utils/available-sandbox-tools.js +1 -1
  153. package/dist/server/plugins/mcp/workers/execute-mcp-tool.js +1 -1
  154. package/dist/server/plugins/nav-utils.js +1 -1
  155. package/dist/server/plugins/search/ai-indexer/prepare-semantic-documents.js +1 -1
  156. package/dist/server/plugins/search/engines/flexsearch/index.js +1 -1
  157. package/dist/server/plugins/search/engines/flexsearch/search-index.d.ts +8 -4
  158. package/dist/server/plugins/search/engines/flexsearch/search-index.js +1 -1
  159. package/dist/server/plugins/search/llmstxt/create-llms-txt-generator.js +1 -1
  160. package/dist/server/plugins/search/llmstxt/index.d.ts +3 -1
  161. package/dist/server/plugins/search/llmstxt/index.js +9 -9
  162. package/dist/server/plugins/search/llmstxt/is-included-in-llms-txt.d.ts +1 -2
  163. package/dist/server/sandbox/constants/host-functions.d.ts +3 -0
  164. package/dist/server/sandbox/constants/host-functions.js +1 -1
  165. package/dist/server/sandbox/constants/sandbox.d.ts +10 -0
  166. package/dist/server/sandbox/constants/sandbox.js +1 -1
  167. package/dist/server/sandbox/sandbox.js +3 -3
  168. package/dist/server/sandbox/types.d.ts +12 -0
  169. package/dist/server/sandbox/utils/execution-budget.js +1 -1
  170. package/dist/server/sandbox/utils/read-result.d.ts +8 -0
  171. package/dist/server/sandbox/utils/read-result.js +1 -0
  172. package/dist/server/sandbox/utils/return-last-expression.d.ts +6 -0
  173. package/dist/server/sandbox/utils/return-last-expression.js +1 -0
  174. package/dist/server/sandbox/utils/returns-from-top-level.d.ts +1 -2
  175. package/dist/server/sandbox/utils/returns-from-top-level.js +1 -1
  176. package/dist/server/sandbox/utils/setup-host-functions.d.ts +1 -0
  177. package/dist/server/sandbox/utils/setup-host-functions.js +3 -3
  178. package/dist/server/ssr/index.js +1 -1
  179. package/dist/server/ssr/render.js +1 -1
  180. package/dist/server/store.d.ts +1 -1
  181. package/dist/server/store.js +1 -1
  182. package/dist/server/tools/notifiers/helpers/privacy/remove-pii.js +1 -1
  183. package/dist/server/types/plugins/common.d.ts +1 -2
  184. package/dist/server/types/plugins/search.d.ts +7 -2
  185. package/dist/server/utils/globs.d.ts +4 -0
  186. package/dist/server/utils/globs.js +1 -1
  187. package/dist/server/utils/rbac.js +1 -1
  188. package/dist/server/utils/search/highlight-text-for-search.js +1 -1
  189. package/dist/server/web-server/middleware/ensureSearchData.js +1 -1
  190. package/dist/server/web-server/routes/catalog/helpers/create-entity-update-schema.d.ts +1 -1
  191. package/dist/server/web-server/routes/catalog/helpers/create-entity-update-schema.js +1 -1
  192. package/dist/server/web-server/routes/dynamic-route.js +1 -1
  193. package/dist/server/web-server/routes/feedback.d.ts +3 -1
  194. package/dist/server/web-server/routes/feedback.js +1 -1
  195. package/dist/server/web-server/routes/mcp-routes/mcp-oauth.js +1 -1
  196. package/dist/server/web-server/routes/mcp-routes/mcp-server-card.js +1 -1
  197. package/dist/server/web-server/routes/otel/otel.js +1 -1
  198. package/dist/server/web-server/utils/legacy-openapi-redirects.js +1 -1
  199. package/dist/types/global-data.d.ts +1 -2
  200. package/dist/utils/slugger.js +1 -1
  201. package/dist/utils/url/sanitize-redirect-pathname.js +1 -1
  202. package/dist/{server/plugins/catalog-entities/utils/version-compare.d.ts → utils/version/compare-versions.d.ts} +1 -16
  203. package/dist/utils/version/compare-versions.js +1 -0
  204. package/package.json +11 -10
  205. package/dist/server/plugins/api-docs/search/search-indexer.d.ts +0 -9
  206. package/dist/server/plugins/api-docs/search/search-indexer.js +0 -1
  207. package/dist/server/plugins/catalog-entities/utils/version-compare.js +0 -1
@@ -1 +1 @@
1
- import{and as v,eq as c,isNull as E,or as x,sql as I}from"drizzle-orm";import{VERSION_NOT_SPECIFIED as V}from"@redocly/theme/core/constants";import{sha1 as F}from"../../../../../utils/crypto/sha1.js";import{envConfig as K}from"../../../../../config/env-config.js";import{entitiesTable as i}from"../../../../../providers/database/databases/sqlite-db/schemas/entities-table.js";import{convertFilterToWhereCondition as O}from"../../../../../providers/database/pagination/filter.js";import{entitiesRelationsTable as a}from"../../../../../providers/database/databases/sqlite-db/schemas/entities-relations-table.js";import{promiseMapLimit as p}from"../../../../../utils/async/promise-map-limit.js";import{RevisionRepository as z}from"../common/revision-repository.js";import{VersionRepository as H}from"../common/version-repository.js";import{EntityAttributesWriteRepository as P}from"../entityAttributes/entity-attributes-write-repository.js";import{createEntityDbRecord as W}from"../../mappers/create-entity-db-record.js";import{createEntityReadModel as k}from"../../mappers/create-entity-read-model.js";import{createEntityRelationDbRecordFromFileSchema as j}from"../../mappers/create-entity-relation-db-record-from-file-schema.js";import{createEntityRelationDbRecordFromDto as G}from"../../mappers/create-entity-relation-db-record-from-dto.js";import{EntitiesReadRepository as M}from"./entities-read-repository.js";import{RelationsReadRepository as U}from"../relations/relations-read-repository.js";import{RelationsWriteRepository as $}from"../relations/relations-write-repository.js";const m=15;class de{#e;#t;#n;#o;#i;#s;#a;#l;#r;constructor(e,s,r){this.#e=e,this.#i=s,this.#s=r,this.#t=new z(e),this.#n=new H(e),this.#o=new P(e),this.#a=new M(e),this.#l=new U(e),this.#r=new $(e,s,r)}async createEntity({entity:e,source:s,fileHash:r,sourceFile:o,isRootEntity:t,isDeleted:n,rbacTeams:u,errorOnSkip:d=!1,revision:h}){const{relations:l=[],...f}=e,y=F(JSON.stringify(f)),g=e.version??V,C=h??new Date().toISOString(),L=await this.#t.shouldSkipRevisionCreation(e.key,g,y,t,n);Array.isArray(u)&&await this.#o.upsertEntityAttributes({entityKey:e.key,rbacTeams:u,organizationId:this.#i,projectId:this.#s});const D=K.isDevelopMode&&!K.REDOCLY_INTERNAL_DEV;if(l?.length&&!D&&await this.#r.createEntityRelations(l.map(N=>({...N,sourceKey:e.key,targetKey:N.key,sourceFile:o??null,fileHash:r??null}))),L){if(d)throw new Error("Entity validation failed: entity already exists");return null}const{shouldSetNewCurrentRevision:R,hasCurrentRevision:_}=await this.#t.getCurrentRevisionInfo({key:e.key,version:g,revision:C}),w=W({entity:{...e,revision:C,hash:y,isCurrent:R,isDefaultVersion:R,isDeleted:n,version:g},organizationId:this.#i,projectId:this.#s,source:s,sourceFile:o??null,fileHash:r??null}),{key:A,...T}=w;if(R&&_&&(await this.#t.markAllRevisionsAsNotCurrent(A),await this.#n.markAllVersionsAsNotDefault(A)),D)return await this.#u(w,l);const S=await this.#e.client.insert(i).values(w).onConflictDoUpdate({target:[i.key,i.source,i.revision,i.version],set:T}).returning();return S.length?k(S[0]):null}async updateEntity(e,s){const{shouldSetNewCurrentRevision:r,hasCurrentRevision:o}=await this.#t.getCurrentRevisionInfo({key:s.key,version:e.version??s.version??V,revision:s.revision});r&&o&&(await this.#t.markAllRevisionsAsNotCurrent(s.key),await this.#n.markAllVersionsAsNotDefault(s.key));const t=W({entity:{...s,...e,hash:F(JSON.stringify({...s,...e})),isCurrent:r,isDefaultVersion:r,createdAt:s.createdAt??void 0},organizationId:this.#i,projectId:this.#s,source:"remote",sourceFile:null,fileHash:null}),{key:n,source:u,scorecardsStatus:d,...h}=t,l=await this.#e.client.insert(i).values(t).onConflictDoUpdate({target:[i.key,i.source,i.revision,i.version],set:{...h,scorecardsStatus:I`CASE WHEN ${i.scorecardsStatus} = 'CALCULATING' THEN 'CANCELLED' ELSE 'OUTDATED' END`}}).returning();return l.length?k(l[0]):null}async setEntitiesAsOutdated(e){const s=O(e);await this.#e.client.update(i).set({scorecardsStatus:"OUTDATED"}).where(s)}async#u(e,s){const{key:r,source:o,version:t,...n}=e,h=await this.#e.client.select({id:i.id}).from(i).where(v(c(i.key,r),t?c(i.version,t):E(i.version))).limit(1).get()!=null?await this.#e.client.update(i).set(n).where(v(c(i.key,r),t?c(i.version,t):E(i.version))).returning():await this.#e.client.insert(i).values(e).onConflictDoUpdate({target:[i.key,i.source,i.revision,i.version],set:n}).returning(),l=s?.map(f=>{const y=j({relation:f,sourceFile:e.sourceFile??"",fileHash:e.fileHash??"",sourceKey:e.key,sourceVersion:e.version??null,sourceRevision:e.revision??null,organizationId:this.#i,projectId:this.#s});return this.#e.client.insert(a).values(y).onConflictDoUpdate({target:[a.sourceKey,a.targetKey,a.sourceVersion,a.targetVersion,a.sourceRevision,a.targetRevision,a.sourceToTargetRelation],set:y}).run()})??[];return await p(l,m,async f=>f),k(h[0])}async softDeleteEntitiesWithRelations({filter:e,revision:s,fileHash:r}){const t={op:"AND",conditions:[e,{field:"is_deleted",operator:"equal",value:!1}]};for(;;){const n=await this.#a.getEntities({paginationParams:{filter:t,limit:500}});if(n.items.length===0)break;const u=await this.#c({entities:n.items,revision:s,fileHash:r});await this.#d(u,s)}}async deleteEntity(e){return await this.#r.deleteEntityRelationsOnEntityRemoval(e),await this.#e.client.delete(i).where(c(i.id,e.id)),await this.#t.ensureDefaultAndCurrentRevisionForKey(e.key),e.id}async deleteEntities(e){const s=O(e);if(!s)return!1;const r=await this.#e.client.delete(i).where(s).returning({key:i.key,source:i.source,isCurrent:i.isCurrent,isDefaultVersion:i.isDefaultVersion,version:i.version});if(r.length===0)return!0;const o=r.reduce((t,n)=>((n.isCurrent||n.isDefaultVersion)&&t.add(n.key),t),new Set);if(o.size===0)return!0;await p(Array.from(o),m,async t=>this.#t.ensureDefaultAndCurrentRevisionForKey(t));for(const t of r)await this.#e.client.delete(a).where(x(v(c(a.sourceKey,t.key),...t.version?[c(a.sourceVersion,t.version)]:[E(a.sourceVersion)]),v(c(a.targetKey,t.key),...t.version?[c(a.targetVersion,t.version)]:[E(a.targetVersion)])));return!0}async updateEntityScorecardsStatus(e,s){return(await this.#e.client.update(i).set({scorecardsStatus:s}).where(c(i.id,e)).returning()).length>0}async updateEntityScorecardsStatusIfCalculating(e,s){return(await this.#e.client.update(i).set({scorecardsStatus:s}).where(I`${i.id} = ${e} AND ${i.scorecardsStatus} = 'CALCULATING'`).returning()).length>0}async#c({entities:e,revision:s,fileHash:r}){return(await p(e,m,async t=>{const n={type:t.type,key:t.key,title:t.title,summary:t.summary??void 0,tags:t.tags??void 0,metadata:t.metadata??void 0,git:t.git??void 0,contact:t.contact??void 0,links:t.links??void 0,version:t.version??void 0};return this.createEntity({entity:n,sourceFile:t.sourceFile??"",fileHash:r,isDeleted:!0,errorOnSkip:!1,source:t.source,revision:s})})).filter(t=>t!==null)}async#d(e,s){if(e.length===0)return!0;const r=await p(e,m,async o=>(await this.#l.getRelationsForEntity(o.key,o.version,s)).map(n=>{if(!n)return null;const u=n.direction,d=n.sourceToTargetRelation,h=n.targetKey,l=u==="outgoing"?o.key:h,f=u==="outgoing"?h:o.key,y=u==="outgoing"?d:d.startsWith("reverse:")?d.slice(8):d;return!y||!l||!f?null:G({type:y,sourceKey:l,targetKey:f,sourceVersion:o.version,targetVersion:o.version,sourceRevision:s,targetRevision:s,isDeleted:!0},this.#i,this.#s)}).filter(n=>n!==null));return await p(r.flat(),m,async o=>this.#r.upsertEntityRelation(o)),!0}}export{de as EntitiesWriteRepository};
1
+ import{and as w,eq as c,isNull as k,or as x,sql as V}from"drizzle-orm";import{VERSION_NOT_SPECIFIED as F}from"@redocly/theme/core/constants";import{sha1 as K}from"../../../../../utils/crypto/sha1.js";import{envConfig as O}from"../../../../../config/env-config.js";import{entitiesTable as t}from"../../../../../providers/database/databases/sqlite-db/schemas/entities-table.js";import{convertFilterToWhereCondition as W}from"../../../../../providers/database/pagination/filter.js";import{entitiesRelationsTable as a}from"../../../../../providers/database/databases/sqlite-db/schemas/entities-relations-table.js";import{promiseMapLimit as v}from"../../../../../utils/async/promise-map-limit.js";import{RevisionRepository as z}from"../common/revision-repository.js";import{VersionRepository as H}from"../common/version-repository.js";import{EntityAttributesWriteRepository as P}from"../entityAttributes/entity-attributes-write-repository.js";import{createEntityDbRecord as L}from"../../mappers/create-entity-db-record.js";import{createEntityReadModel as A}from"../../mappers/create-entity-read-model.js";import{createEntityRelationDbRecordFromFileSchema as U}from"../../mappers/create-entity-relation-db-record-from-file-schema.js";import{createEntityRelationDbRecordFromDto as j}from"../../mappers/create-entity-relation-db-record-from-dto.js";import{EntitiesReadRepository as G}from"./entities-read-repository.js";import{RelationsReadRepository as M}from"../relations/relations-read-repository.js";import{RelationsWriteRepository as $}from"../relations/relations-write-repository.js";const g=15;class de{#e;#t;#n;#o;#i;#s;#a;#l;#r;constructor(e,s,n){this.#e=e,this.#i=s,this.#s=n,this.#t=new z(e),this.#n=new H(e),this.#o=new P(e),this.#a=new G(e),this.#l=new M(e),this.#r=new $(e,s,n)}async createEntity({entity:e,source:s,fileHash:n,sourceFile:o,isRootEntity:i,isDeleted:r,rbacTeams:l,errorOnSkip:d=!1,revision:h}){const{relations:u=[],...f}=e,p=K(JSON.stringify(f)),E=e.version??F,R=h??new Date().toISOString(),C=await this.#t.shouldSkipRevisionCreation(e.key,E,p,i,r);Array.isArray(l)&&await this.#o.upsertEntityAttributes({entityKey:e.key,rbacTeams:l,organizationId:this.#i,projectId:this.#s});const m=O.isDevelopMode&&!O.REDOCLY_INTERNAL_DEV;if(u?.length&&!m&&await this.#r.createEntityRelations(u.map(I=>({...I,sourceKey:e.key,targetKey:I.key,sourceFile:o??null,fileHash:n??null}))),C){if(d)throw new Error("Entity validation failed: entity already exists");return null}const{shouldSetNewCurrentRevision:y,hasCurrentRevision:_}=await this.#t.getCurrentRevisionInfo({key:e.key,version:E,revision:R}),D=L({entity:{...e,revision:R,hash:p,isCurrent:y,isDefaultVersion:y,isDeleted:r,version:E},organizationId:this.#i,projectId:this.#s,source:s,sourceFile:o??null,fileHash:n??null}),{key:S,...T}=D;if(y&&_&&(await this.#t.markAllRevisionsAsNotCurrent(S),await this.#n.markAllVersionsAsNotDefault(S)),m)return await this.#u(D,u,y);const N=await this.#e.client.insert(t).values(D).onConflictDoUpdate({target:[t.key,t.source,t.revision,t.version],set:T}).returning();return N.length?A(N[0]):null}async updateEntity(e,s){const{shouldSetNewCurrentRevision:n,hasCurrentRevision:o}=await this.#t.getCurrentRevisionInfo({key:s.key,version:e.version??s.version??F,revision:s.revision});n&&o&&(await this.#t.markAllRevisionsAsNotCurrent(s.key),await this.#n.markAllVersionsAsNotDefault(s.key));const i=L({entity:{...s,...e,hash:K(JSON.stringify({...s,...e})),isCurrent:n,isDefaultVersion:n,createdAt:s.createdAt??void 0},organizationId:this.#i,projectId:this.#s,source:"remote",sourceFile:null,fileHash:null}),{key:r,source:l,scorecardsStatus:d,...h}=i,u=await this.#e.client.insert(t).values(i).onConflictDoUpdate({target:[t.key,t.source,t.revision,t.version],set:{...h,scorecardsStatus:V`CASE WHEN ${t.scorecardsStatus} = 'CALCULATING' THEN 'CANCELLED' ELSE 'OUTDATED' END`}}).returning();return u.length?A(u[0]):null}async setEntitiesAsOutdated(e){const s=W(e);await this.#e.client.update(t).set({scorecardsStatus:"OUTDATED"}).where(s)}async#u(e,s,n){const{key:o,source:i,version:r,...l}=e,{isCurrent:d,isDefaultVersion:h,...u}=l,f=n?l:u,R=await this.#e.client.select({id:t.id}).from(t).where(w(c(t.key,o),r?c(t.version,r):k(t.version))).limit(1).get()!=null?await this.#e.client.update(t).set(f).where(w(c(t.key,o),r?c(t.version,r):k(t.version))).returning():await this.#e.client.insert(t).values(e).onConflictDoUpdate({target:[t.key,t.source,t.revision,t.version],set:f}).returning(),C=s?.map(m=>{const y=U({relation:m,sourceFile:e.sourceFile??"",fileHash:e.fileHash??"",sourceKey:e.key,sourceVersion:e.version??null,sourceRevision:e.revision??null,organizationId:this.#i,projectId:this.#s});return this.#e.client.insert(a).values(y).onConflictDoUpdate({target:[a.sourceKey,a.targetKey,a.sourceVersion,a.targetVersion,a.sourceRevision,a.targetRevision,a.sourceToTargetRelation],set:y}).run()})??[];return await v(C,g,async m=>m),A(R[0])}async softDeleteEntitiesWithRelations({filter:e,revision:s,fileHash:n}){const i={op:"AND",conditions:[e,{field:"is_deleted",operator:"equal",value:!1}]};for(;;){const r=await this.#a.getEntities({paginationParams:{filter:i,limit:500}});if(r.items.length===0)break;const l=await this.#c({entities:r.items,revision:s,fileHash:n});await this.#d(l,s)}}async deleteEntity(e){return await this.#r.deleteEntityRelationsOnEntityRemoval(e),await this.#e.client.delete(t).where(c(t.id,e.id)),await this.#t.ensureDefaultAndCurrentRevisionForKey(e.key),e.id}async deleteEntities(e){const s=W(e);if(!s)return!1;const n=await this.#e.client.delete(t).where(s).returning({key:t.key,source:t.source,isCurrent:t.isCurrent,isDefaultVersion:t.isDefaultVersion,version:t.version});if(n.length===0)return!0;const o=n.reduce((i,r)=>((r.isCurrent||r.isDefaultVersion)&&i.add(r.key),i),new Set);if(o.size===0)return!0;await v(Array.from(o),g,async i=>this.#t.ensureDefaultAndCurrentRevisionForKey(i));for(const i of n)await this.#e.client.delete(a).where(x(w(c(a.sourceKey,i.key),...i.version?[c(a.sourceVersion,i.version)]:[k(a.sourceVersion)]),w(c(a.targetKey,i.key),...i.version?[c(a.targetVersion,i.version)]:[k(a.targetVersion)])));return!0}async updateEntityScorecardsStatus(e,s){return(await this.#e.client.update(t).set({scorecardsStatus:s}).where(c(t.id,e)).returning()).length>0}async updateEntityScorecardsStatusIfCalculating(e,s){return(await this.#e.client.update(t).set({scorecardsStatus:s}).where(V`${t.id} = ${e} AND ${t.scorecardsStatus} = 'CALCULATING'`).returning()).length>0}async#c({entities:e,revision:s,fileHash:n}){return(await v(e,g,async i=>{const r={type:i.type,key:i.key,title:i.title,summary:i.summary??void 0,tags:i.tags??void 0,metadata:i.metadata??void 0,git:i.git??void 0,contact:i.contact??void 0,links:i.links??void 0,version:i.version??void 0};return this.createEntity({entity:r,sourceFile:i.sourceFile??"",fileHash:n,isDeleted:!0,errorOnSkip:!1,source:i.source,revision:s})})).filter(i=>i!==null)}async#d(e,s){if(e.length===0)return!0;const n=await v(e,g,async o=>(await this.#l.getRelationsForEntity(o.key,o.version,s)).map(r=>{if(!r)return null;const l=r.direction,d=r.sourceToTargetRelation,h=r.targetKey,u=l==="outgoing"?o.key:h,f=l==="outgoing"?h:o.key,p=l==="outgoing"?d:d.startsWith("reverse:")?d.slice(8):d;return!p||!u||!f?null:j({type:p,sourceKey:u,targetKey:f,sourceVersion:o.version,targetVersion:o.version,sourceRevision:s,targetRevision:s,isDeleted:!0},this.#i,this.#s)}).filter(r=>r!==null));return await v(n.flat(),g,async o=>this.#r.upsertEntityRelation(o)),!0}}export{de as EntitiesWriteRepository};
@@ -1 +1 @@
1
- import{VERSION_NOT_SPECIFIED as t}from"@redocly/theme/core/constants";import{compareVersionsDescending as f}from"../../../utils/version-compare.js";function s(n){return!n||n===t}function c(n,i){const e=s(n.version),r=s(i.version);if(e&&!r)return 1;if(!e&&r)return-1;const o=f(n.version??"",i.version??"");return o!==0?o:(i.revision??"").localeCompare(n.revision??"")}function a(n){const i=n.filter(e=>e.isCurrent||e.isDefaultVersion);if(!(i.length<=1)){i.sort(c);for(let e=1;e<i.length;e++)i[e].isCurrent=!1,i[e].isDefaultVersion=!1}}export{a as normalizeRevisionFlags};
1
+ import{VERSION_NOT_SPECIFIED as t}from"@redocly/theme/core/constants";import{compareVersions as f}from"../../../../../../utils/version/compare-versions.js";function s(r){return!r||r===t}function c(r,i){const e=s(r.version),o=s(i.version);if(e&&!o)return 1;if(!e&&o)return-1;const n=f(i.version??"",r.version??"");return n!==0?n:(i.revision??"").localeCompare(r.revision??"")}function a(r){const i=r.filter(e=>e.isCurrent||e.isDefaultVersion);if(!(i.length<=1)){i.sort(c);for(let e=1;e<i.length;e++)i[e].isCurrent=!1,i[e].isDefaultVersion=!1}}export{a as normalizeRevisionFlags};
@@ -1,6 +1,5 @@
1
1
  import type { ApiDescriptionMetadataSchema } from '@redocly/config';
2
- import type { AfterRoutesCreatedActions } from '../../../types/plugins/common';
3
- import type { AfterRoutesCreatedLifecycleContext } from '../../../types/plugins/common';
2
+ import type { AfterRoutesCreatedActions, AfterRoutesCreatedLifecycleContext } from '../../../types/plugins/common';
4
3
  import type { CatalogEntitiesService } from '../database/catalog-entities-service.js';
5
4
  import type { FileType } from '../../../persistence/file-hashes/types.js';
6
5
  import type { HashManager } from '../utils/hash-manager.js';
@@ -1,5 +1,4 @@
1
- import type { OpenAPIDefinition } from '@redocly/api-docs';
2
- import type { OpenAPIMediaType, OpenAPIOperation, OpenAPIPath, OpenAPIRequestBody, OpenAPIResponse } from '@redocly/api-docs';
1
+ import type { OpenAPIDefinition, OpenAPIMediaType, OpenAPIOperation, OpenAPIPath, OpenAPIRequestBody, OpenAPIResponse } from '@redocly/api-docs';
3
2
  import type { Logger } from '../../../tools/notifiers/logger.js';
4
3
  export declare class OpenapiComponentContentExtractor {
5
4
  #private;
@@ -1,6 +1,5 @@
1
1
  import type { Referenced } from '@redocly/openapi-core';
2
- import type { OpenAPIDefinition } from '@redocly/api-docs';
3
- import type { OpenAPISchema } from '@redocly/api-docs';
2
+ import type { OpenAPIDefinition, OpenAPISchema } from '@redocly/api-docs';
4
3
  export declare class OpenapiSchemaResolver {
5
4
  #private;
6
5
  static resolveSchemaRefs(schema: Referenced<OpenAPISchema>, root: OpenAPIDefinition, visitedRefs?: Set<string>): OpenAPISchema;
@@ -1,6 +1,6 @@
1
- import{getLineColLocation as u,isAbsoluteUrl as m}from"@redocly/openapi-core";import{getCodeframe as g}from"@redocly/openapi-core";import l from"node:path";import{gray as i}from"../../tools/notifiers/helpers/colors.js";function d(a,s){return`Config validation error:
1
+ import{getLineColLocation as u,isAbsoluteUrl as g,getCodeframe as l}from"@redocly/openapi-core";import m from"node:path";import{gray as i}from"../../tools/notifiers/helpers/colors.js";function L(a,s){return`Config validation error:
2
2
 
3
- `+c(a);function c(o){const t=o.location[0];if(!t)return o.message;if(!t.source){const n=t.pointer??"";return`${o.message}${n?` at ${n}`:""}`}const e=t.source?.absoluteRef,r=e&&m(e)?e:e?l.relative(s,e):"config";try{if(typeof t.source.getAst!="function"){const $=t.pointer?i(`at ${t.pointer}`):"";return`${r} ${$}
3
+ `+c(a);function c(o){const t=o.location[0];if(!t)return o.message;if(!t.source){const n=t.pointer??"";return`${o.message}${n?` at ${n}`:""}`}const e=t.source?.absoluteRef,r=e&&g(e)?e:e?m.relative(s,e):"config";try{if(typeof t.source.getAst!="function"){const $=t.pointer?i(`at ${t.pointer}`):"";return`${r} ${$}
4
4
 
5
5
  ${o.message}
6
6
 
@@ -8,10 +8,10 @@ ${o.message}
8
8
 
9
9
  ${o.message}
10
10
 
11
- `+g(n,!0)+`
11
+ `+l(n,!0)+`
12
12
 
13
13
  `}catch{const n=t.pointer?i(`at ${t.pointer}`):"";return`${r} ${n}
14
14
 
15
15
  ${o.message}
16
16
 
17
- `}}}export{d as formatConfigProblem};
17
+ `}}}export{L as formatConfigProblem};
@@ -1 +1 @@
1
- import d from"path";import{combineUrls as c}from"@redocly/theme/core/utils";import{VERSION_SEPARATOR as p}from"../../../constants/common.js";import{removeTrailingSlash as h}from"../../../../utils/url/remove-trailing-slash.js";import{slash as V}from"../../../../utils/path/slash.js";import{logger as w}from"../../../tools/notifiers/logger.js";import{getDefaultVersionByPath as D}from"./versions-config-loader.js";import{GithubSlugger as E,slug as S}from"../../../utils/index.js";import{parseBaseName as F}from"../../utils.js";const I=new Set([".jpg",".jpeg",".png",".gif",".webp",".svg",".ico",".avif",".mp3",".wav",".ogg",".m4a",".mp4",".avi",".mov",".webm",".pdf",".doc",".docx",".zip",".rar",".gz",".ttf",".woff",".woff2"]),A=async(i,{fs:e,cache:n})=>{const a=w.startTiming(),r=(await n.load("versions-config","versions-config")).data,t=new Map,l=new Map,o=new Set,s={pageVsPage:0,dirVsDir:0},g=new E;l.set(".","/"),l.set("/","/");const f=e.scan().sort((u,m)=>m.relativePath.localeCompare(u.relativePath));for(const{relativePath:u}of f){if(I.has(d.posix.extname(u)))continue;const{data:m}=await n.load(u,"is-ignored");if(m)continue;const b=V(u).replace(new RegExp("^(@i18n|@l10n)\\/"),""),v=D(u,r);N(b,{defaultVersion:v,fileSlugs:t,dirSlugs:l,allFileSlugsList:o,githubSlugger:g,collisions:s})}return w.verboseTime(a,"Calculated slugs. Number of file paths processed: "+f.length),{fileSlugs:t,dirSlugs:l,collisions:s}};function N(i,e){const n=e.fileSlugs.get(i);if(n)return n;let a=d.posix.dirname(i);const r=z(a,e)||"",{baseName:t,isIndexFile:l}=F(i),o=e.dirSlugs.has(d.posix.join(a,t));let s;if(!l&&o){const g=S(c(r,t));e.allFileSlugsList.has(g)||(s=g)}if(!s){const g=l?e.dirSlugs.get(a):void 0;if(g)s=g;else{const f=c(r,t),u=S(f);s=e.githubSlugger.slug(f),s!==u&&e.collisions.pageVsPage++}}s=h(s),e.fileSlugs.set(i,s),e.allFileSlugsList.add(s)}function z(i,e){if(e.dirSlugs.has(i))return e.dirSlugs.get(i);const n=h(d.posix.normalize(i)).split("/");let a="/",r="";for(const t of n){r=d.posix.join(r,t);const l=T(t,e.defaultVersion);let o=e.dirSlugs.get(r);if(!o){const s=c("/",a,l),g=S(s);o=e.githubSlugger.slug(s),o!==g&&e.collisions.dirVsDir++}o.endsWith("/")||(o=o+"/"),e.dirSlugs.set(r,o),a=o}return e.dirSlugs.get(i)}function T(i,e){if(!i.startsWith(p))return i;const n=i.substring(p.length);return n===e?"":n}export{I as IGNORED_EXTS,A as contentSlugsLoader};
1
+ import f from"path";import{combineUrls as S}from"@redocly/theme/core/utils";import{VERSION_SEPARATOR as b}from"../../../constants/common.js";import{removeTrailingSlash as v}from"../../../../utils/url/remove-trailing-slash.js";import{slash as E}from"../../../../utils/path/slash.js";import{logger as m}from"../../../tools/notifiers/logger.js";import{getDefaultVersionByPath as I}from"./versions-config-loader.js";import{GithubSlugger as N,slug as h}from"../../../utils/index.js";import{isPartial as z}from"../../markdown/is-partial.js";import{parseBaseName as T}from"../../utils.js";const j=new Set([".jpg",".jpeg",".png",".gif",".webp",".svg",".ico",".avif",".mp3",".wav",".ogg",".m4a",".mp4",".avi",".mov",".webm",".pdf",".doc",".docx",".zip",".rar",".gz",".ttf",".woff",".woff2"]),U=async(i,{fs:s,cache:r,getConfig:l})=>{const t=m.startTiming(),g=(await r.load("versions-config","versions-config")).data,{markdown:u}=await l(),o=u?.partialsFolders??[],e=new Map,n=new Map,c=new Set,d={pageVsPage:0,dirVsDir:0},D=new N;n.set(".","/"),n.set("/","/");const w=s.scan().sort((a,p)=>p.relativePath.localeCompare(a.relativePath));for(const{relativePath:a}of w){if(j.has(f.posix.extname(a)))continue;const{data:p}=await r.load(a,"is-ignored");if(p||f.posix.extname(a)===".md"&&z(a,o))continue;const F=E(a).replace(new RegExp("^(@i18n|@l10n)\\/"),""),V=I(a,g);y(F,{defaultVersion:V,fileSlugs:e,dirSlugs:n,allFileSlugsList:c,githubSlugger:D,collisions:d})}return m.verboseTime(t,"Calculated slugs. Number of file paths processed: "+w.length),{fileSlugs:e,dirSlugs:n,collisions:d}};function y(i,s){const r=s.fileSlugs.get(i);if(r)return r;let l=f.posix.dirname(i);const t=L(l,s)||"",{baseName:g,isIndexFile:u}=T(i),o=s.dirSlugs.has(f.posix.join(l,g));let e;if(!u&&o){const n=h(S(t,g));s.allFileSlugsList.has(n)||(e=n)}if(!e){const n=u?s.dirSlugs.get(l):void 0;if(n)e=n;else{const c=S(t,g),d=h(c);e=s.githubSlugger.slug(c),e!==d&&(s.collisions.pageVsPage++,m.verbose("File slug collision: %s wanted %s, assigned %s",i,d,e))}}e=v(e),s.fileSlugs.set(i,e),s.allFileSlugsList.add(e)}function L(i,s){if(s.dirSlugs.has(i))return s.dirSlugs.get(i);const r=v(f.posix.normalize(i)).split("/");let l="/",t="";for(const g of r){t=f.posix.join(t,g);const u=P(g,s.defaultVersion);let o=s.dirSlugs.get(t);if(!o){const e=S("/",l,u),n=h(e);o=s.githubSlugger.slug(e),o!==n&&(s.collisions.dirVsDir++,m.verbose("Directory slug collision: %s wanted %s, assigned %s",t,n,o))}o.endsWith("/")||(o=o+"/"),s.dirSlugs.set(t,o),l=o}return s.dirSlugs.get(i)}function P(i,s){if(!i.startsWith(b))return i;const r=i.substring(b.length);return r===s?"":r}export{j as IGNORED_EXTS,U as contentSlugsLoader};
@@ -1 +1 @@
1
- import v from"path";import{I18N_DIR_NAME as c,L10N_DIR_NAME as p,RESERVED_DIR_NAMES as m,VERSIONED_FOLDER_REGEXP_MATCH as P}from"../../../constants/common.js";import{parsePathVersions as l}from"../../../../utils/path/parse-path-versions.js";import{reporter as u}from"../../../tools/notifiers/reporter.js";import{logger as V}from"../../../tools/notifiers/logger.js";const _=async(r,{cache:i,fs:s})=>{const e=new Map,t=await s.scan();await y(t);for(const{relativePath:n}of t){if(v.posix.basename(n)==="versions.yaml"){await g(n,e,i);continue}const o=l(n);if(o==null)continue;const a=e.get(o.versionFolderPath)||{versionedFiles:new Map,versions:[]},f=a.versionedFiles.get(o.filePathInVersion)||new Set,d={version:o.versionName};f.add(d.version),!a.hasVersionsConfig&&a.versions.findIndex(h=>h.version===o.versionName)===-1&&a.versions.push(d),a.versionedFiles.set(o.filePathInVersion,f),e.set(o.versionFolderPath,a)}return F(e)};async function g(r,i,s){let e=v.posix.dirname(r);e==="."?e="/":e=e.endsWith("/")?e:e+"/",e.startsWith(c+"/")&&(e=e.slice(c.length+1)),e.startsWith(p+"/")&&(e=e.slice(p.length+1));const n=(await s.load(r,"yaml")).data;n.versions&&!Array.isArray(n.versions)?(await u.panicOnBuild(`Property 'versions' must be an array at %rp. Got '${typeof n.versions}'.`,r),n.versions=[]):(!n.versions||n.versions.length===0)&&V.warn("Property 'versions' is empty at %rp. This is likely a mistake.",r);const o=i.get(e)||{versionedFiles:new Map,versions:[]};o.hasVersionsConfig=!0,o.versions=n.versions||[],n.default&&(o.defaultVersion=n.default),i.set(e,o)}async function y(r){const i=new Set;for(const{relativePath:s}of r){const e=l(s);if(!(e?.versionFolderPath&&m.includes(e?.versionFolderPath))){if(e?.versionFolderPath==null){(s.match(P)?.length||0)>1&&await u.panicOnBuild(`Nested versions are not supported. Detected nested versions in path: "${s}".`);continue}i.has(e.versionFolderPath)||i.add(e.versionFolderPath)}}}function F(r){for(let[i,s]of r){const e=s.hasVersionsConfig?s.versions:s.versions.sort((n,o)=>n.version.localeCompare(o.version)),t=s.defaultVersion||e[e.length-1]?.version;r.set(i,{...s,versions:e,defaultVersion:t})}return r}function N(r,i){const s=l(r);return s==null?null:i.get(s.versionFolderPath)?.defaultVersion}export{N as getDefaultVersionByPath,_ as versionsConfigLoader};
1
+ import v from"path";import{I18N_DIR_NAME as c,L10N_DIR_NAME as p,RESERVED_DIR_NAMES as m,VERSIONED_FOLDER_REGEXP_MATCH as V}from"../../../constants/common.js";import{parsePathVersions as l}from"../../../../utils/path/parse-path-versions.js";import{compareVersions as P}from"../../../../utils/version/compare-versions.js";import{reporter as h}from"../../../tools/notifiers/reporter.js";import{logger as g}from"../../../tools/notifiers/logger.js";const R=async(r,{cache:i,fs:s})=>{const e=new Map,a=await s.scan();await F(a);for(const{relativePath:n}of a){if(v.posix.basename(n)==="versions.yaml"){await y(n,e,i);continue}const o=l(n);if(o==null)continue;const t=e.get(o.versionFolderPath)||{versionedFiles:new Map,versions:[]},f=t.versionedFiles.get(o.filePathInVersion)||new Set,d={version:o.versionName};f.add(d.version),!t.hasVersionsConfig&&t.versions.findIndex(u=>u.version===o.versionName)===-1&&t.versions.push(d),t.versionedFiles.set(o.filePathInVersion,f),e.set(o.versionFolderPath,t)}return w(e)};async function y(r,i,s){let e=v.posix.dirname(r);e==="."?e="/":e=e.endsWith("/")?e:e+"/",e.startsWith(c+"/")&&(e=e.slice(c.length+1)),e.startsWith(p+"/")&&(e=e.slice(p.length+1));const n=(await s.load(r,"yaml")).data;n.versions&&!Array.isArray(n.versions)?(await h.panicOnBuild(`Property 'versions' must be an array at %rp. Got '${typeof n.versions}'.`,r),n.versions=[]):(!n.versions||n.versions.length===0)&&g.warn("Property 'versions' is empty at %rp. This is likely a mistake.",r);const o=i.get(e)||{versionedFiles:new Map,versions:[]};o.hasVersionsConfig=!0,o.versions=n.versions||[],n.default&&(o.defaultVersion=n.default),i.set(e,o)}async function F(r){const i=new Set;for(const{relativePath:s}of r){const e=l(s);if(!(e?.versionFolderPath&&m.includes(e?.versionFolderPath))){if(e?.versionFolderPath==null){(s.match(V)?.length||0)>1&&await h.panicOnBuild(`Nested versions are not supported. Detected nested versions in path: "${s}".`);continue}i.has(e.versionFolderPath)||i.add(e.versionFolderPath)}}}function w(r){for(let[i,s]of r){const e=s.hasVersionsConfig?s.versions:s.versions.sort((o,t)=>P(t.version,o.version)),a=s.hasVersionsConfig?e[e.length-1]:e[0],n=s.defaultVersion||a?.version;r.set(i,{...s,versions:e,defaultVersion:n})}return r}function A(r,i){const s=l(r);return s==null?null:i.get(s.versionFolderPath)?.defaultVersion}export{A as getDefaultVersionByPath,R as versionsConfigLoader};
@@ -1 +1 @@
1
- import*as e from"react";import{useMutation as h,useQueryClient as P}from"@tanstack/react-query";import{useParams as D}from"react-router";import{Button as k}from"@redocly/theme/components/Button/Button";import{H2 as A}from"@redocly/theme/components/Typography/H2";import{Admonition as S}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{useTranslate as T}from"../../../../../client/app/hooks";import{Dialog as w}from"./Dialog";import{ButtonWithLoading as I}from"./ButtonWithLoading";import{ButtonsContainer as K}from"./RollAPIKey";import{DialogInputMultiline as O,DialogRow as R,DialogRowContent as x}from"./DialogStyledComponents";import{MAX_DESCRIPTION_LENGTH as p,CharacterCounter as B}from"./CharacterCounter";const G=u=>{const{id:o}=D(),{initialDescription:g,open:y,onOpen:f,onClose:s}=u,t=g||"",{translate:a}=T(),[n,i]=e.useState(t);e.useEffect(()=>{i(t)},[t]);const c=async()=>{await C(),s()},E=l=>{l.key==="Enter"&&!r&&c()},d=()=>{s(),i(t)},v=P(),{mutateAsync:C,isPending:r,error:m}=h({mutationKey:["UPDATE_APP"+o],mutationFn:()=>fetch(`/api/api-keys/apps/${o}`,{method:"PUT",body:JSON.stringify({description:n})}),onSettled:()=>{v.invalidateQueries({queryKey:["APP:"+o]}),i(n)}});return e.createElement(w,{open:y,onClose:d,onOpen:f},e.createElement(e.Fragment,null,e.createElement(A,{"data-translation-key":"dev.edit.description.dialog.title"},a("dev.edit.description.dialog.title","Change description")),e.createElement(R,null,e.createElement(x,null,e.createElement(O,{maxLength:p,value:n,onChange:l=>i(l.target.value),onKeyPress:E,rows:6,cols:60}))),e.createElement(B,null,n.length,"/",p),m&&e.createElement(S,{type:"danger"},m.message," "),e.createElement(K,null,e.createElement(k,{onClick:d,"data-translation-key":"dev.edit.description.dialog.cancel",variant:"text",size:"large"},a("dev.edit.description.dialog.cancel","Cancel")),e.createElement(I,{variant:"primary",loading:r,onClick:c,disabled:r,"data-translation-key":"dev.edit.description.dialog.save"},a("dev.edit.description.dialog.save","Save changes")))))};export{G as EditAppDescriptionDialog};
1
+ import*as e from"react";import{useMutation as E,useQueryClient as C}from"@tanstack/react-query";import{useParams as f}from"react-router";import{Button as v}from"@redocly/theme/components/Button/Button";import{H2 as D}from"@redocly/theme/components/Typography/H2";import{Admonition as h}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{useTranslate as P}from"../../../../../client/app/hooks";import{Dialog as A}from"./Dialog";import{ButtonWithLoading as k}from"./ButtonWithLoading";import{ButtonsContainer as S}from"./RollAPIKey";import{DialogInputMultiline as T,DialogRow as w,DialogRowContent as K}from"./DialogStyledComponents";import{MAX_DESCRIPTION_LENGTH as d,CharacterCounter as O}from"./CharacterCounter";const Q=o=>{const{initialDescription:n,open:a,onOpen:i,onClose:t}=o;return e.createElement(A,{open:a,onClose:t,onOpen:i},e.createElement(R,{initialDescription:n,onClose:t}))},R=o=>{const{id:n}=f(),{initialDescription:a,onClose:i}=o,{translate:t}=P(),[r,p]=e.useState(a||""),c=async()=>{await y(),i()},u=s=>{s.key==="Enter"&&!l&&c()},g=C(),{mutateAsync:y,isPending:l,error:m}=E({mutationKey:["UPDATE_APP"+n],mutationFn:()=>fetch(`/api/api-keys/apps/${n}`,{method:"PUT",body:JSON.stringify({description:r})}),onSettled:()=>{g.invalidateQueries({queryKey:["APP:"+n]})}});return e.createElement(e.Fragment,null,e.createElement(D,{"data-translation-key":"dev.edit.description.dialog.title"},t("dev.edit.description.dialog.title","Change description")),e.createElement(w,null,e.createElement(K,null,e.createElement(T,{maxLength:d,value:r,onChange:s=>p(s.target.value),onKeyPress:u,rows:6,cols:60}))),e.createElement(O,null,r.length,"/",d),m&&e.createElement(h,{type:"danger"},m.message," "),e.createElement(S,null,e.createElement(v,{onClick:i,"data-translation-key":"dev.edit.description.dialog.cancel",variant:"text",size:"large"},t("dev.edit.description.dialog.cancel","Cancel")),e.createElement(k,{variant:"primary",loading:l,onClick:c,disabled:l,"data-translation-key":"dev.edit.description.dialog.save"},t("dev.edit.description.dialog.save","Save changes"))))};export{Q as EditAppDescriptionDialog};
@@ -1 +1 @@
1
- import*as e from"react";import{useMutation as A,useQueryClient as D}from"@tanstack/react-query";import{useParams as S}from"react-router";import{Button as N}from"@redocly/theme/components/Button/Button";import{H2 as w}from"@redocly/theme/components/Typography/H2";import{Admonition as I}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{useTranslate as K}from"../../../../../client/app/hooks";import{Dialog as O}from"./Dialog";import{ButtonWithLoading as R}from"./ButtonWithLoading";import{ButtonsContainer as B}from"./RollAPIKey";import{DialogInput as T,DialogRow as $,DialogRowContent as b}from"./DialogStyledComponents";const M=e.forwardRef((g,f)=>{const{id:o}=S(),{appName:y,appDisplayName:v}=g,t=v||y||"",[a,n]=e.useState(t),[E,m]=e.useState(!1),h=s=>n(s.target.value),{translate:i}=K(),p=async()=>{await k(),l()},C=s=>{s.key==="Enter"&&!r&&u&&p()},d=()=>{m(!0)};e.useImperativeHandle(f,()=>({open:d}));const l=()=>{m(!1),n(t)};e.useEffect(()=>{n(t)},[t]);const P=D(),{mutateAsync:k,isPending:r,error:c}=A({mutationKey:["UPDATE_APP"+o],mutationFn:()=>fetch(`/api/api-keys/apps/${o}`,{method:"PUT",body:JSON.stringify({name:a})}),onSettled:()=>{P.invalidateQueries({queryKey:["APPS","APP:"+o]}),n(a)}}),u=/^(?!\s*$).{1,100}$/gi.test(a);return e.createElement(O,{open:E,onClose:l,onOpen:d},e.createElement(e.Fragment,null,e.createElement(w,{"data-translation-key":"dev.edit.app.dialog.title"},i("dev.edit.app.dialog.title","Change display name")),e.createElement($,null,e.createElement(b,null,e.createElement(T,{value:a,onChange:h,onKeyPress:C}))),c&&e.createElement(I,{type:"danger"},c.message," "),e.createElement(B,null,e.createElement(N,{onClick:l,"data-translation-key":"dev.edit.app.dialog.cancel",variant:"text",size:"large"},i("dev.edit.app.dialog.cancel","Cancel")),e.createElement(R,{variant:"primary",loading:r,onClick:p,disabled:r||!u,"data-translation-key":"dev.edit.app.dialog.save"},i("dev.edit.app.dialog.save","Save changes")))))});export{M as EditAppDialog};
1
+ import*as e from"react";import{useMutation as v,useQueryClient as E}from"@tanstack/react-query";import{useParams as C}from"react-router";import{Button as h}from"@redocly/theme/components/Button/Button";import{H2 as P}from"@redocly/theme/components/Typography/H2";import{Admonition as A}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{useTranslate as k}from"../../../../../client/app/hooks";import{Dialog as D}from"./Dialog";import{ButtonWithLoading as N}from"./ButtonWithLoading";import{ButtonsContainer as S}from"./RollAPIKey";import{DialogInput as w,DialogRow as K,DialogRowContent as O}from"./DialogStyledComponents";const U=e.forwardRef((l,a)=>{const{appName:s,appDisplayName:o}=l,[n,i]=e.useState(!1),r=()=>{i(!0)},t=()=>{i(!1)};return e.useImperativeHandle(a,()=>({open:r})),e.createElement(D,{open:n,onClose:t,onOpen:r},e.createElement(R,{initialName:o||s||"",onClose:t}))}),R=l=>{const{id:a}=C(),{initialName:s,onClose:o}=l,[n,i]=e.useState(s),r=p=>i(p.target.value),{translate:t}=k(),d=async()=>{await f(),o()},g=p=>{p.key==="Enter"&&!m&&u&&d()},y=E(),{mutateAsync:f,isPending:m,error:c}=v({mutationKey:["UPDATE_APP"+a],mutationFn:()=>fetch(`/api/api-keys/apps/${a}`,{method:"PUT",body:JSON.stringify({name:n})}),onSettled:()=>{y.invalidateQueries({queryKey:["APPS","APP:"+a]})}}),u=/^(?!\s*$).{1,100}$/gi.test(n);return e.createElement(e.Fragment,null,e.createElement(P,{"data-translation-key":"dev.edit.app.dialog.title"},t("dev.edit.app.dialog.title","Change display name")),e.createElement(K,null,e.createElement(O,null,e.createElement(w,{value:n,onChange:r,onKeyPress:g}))),c&&e.createElement(A,{type:"danger"},c.message," "),e.createElement(S,null,e.createElement(h,{onClick:o,"data-translation-key":"dev.edit.app.dialog.cancel",variant:"text",size:"large"},t("dev.edit.app.dialog.cancel","Cancel")),e.createElement(N,{variant:"primary",loading:m,onClick:d,disabled:m||!u,"data-translation-key":"dev.edit.app.dialog.save"},t("dev.edit.app.dialog.save","Save changes"))))};export{U as EditAppDialog};
@@ -1 +1 @@
1
- import*as e from"react";import{useMutation as b,useQueryClient as U}from"@tanstack/react-query";import{useParams as C}from"react-router";import{Button as E}from"@redocly/theme/components/Button/Button";import{H2 as w}from"@redocly/theme/components/Typography/H2";import{Admonition as P}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{useTranslate as D}from"../../../../../client/app/hooks";import{Dialog as R}from"./Dialog";import{ButtonWithLoading as S}from"./ButtonWithLoading";import{ButtonsContainer as A}from"./RollAPIKey";import{DialogHelperText as T,DialogInputMultiline as x,DialogRow as K,DialogRowContent as j}from"./DialogStyledComponents";const z=p=>{const{id:o}=C(),{initialCallbackUrl:u,open:g,onOpen:k,onClose:s}=p,l=u||"",{translate:a}=D(),[r,n]=e.useState(l);e.useEffect(()=>{n(l)},[l]);const c=async()=>{await f(),s()},y=t=>{t.key==="Enter"&&!i&&c()},d=()=>{s(),n(l)},h=U(),{mutateAsync:f,isPending:i,error:m}=b({mutationKey:["UPDATE_APP"+o],mutationFn:async()=>{const t=await fetch(`/api/api-keys/apps/${o}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({callbackUrl:r})});if(!t.ok){const v=await t.json().catch(()=>null);throw new Error(v?.error||`Request failed with status ${t.status}`)}return t.json()},onSettled:()=>{h.invalidateQueries({queryKey:["APP:"+o]}),n(r)}});return e.createElement(R,{open:g,onClose:d,onOpen:k},e.createElement(e.Fragment,null,e.createElement(w,{"data-translation-key":"dev.edit.callbackUrls.dialog.title"},a("dev.edit.callbackUrls.dialog.title","Change callback URLs")),e.createElement(K,null,e.createElement(j,null,e.createElement(x,{value:r,onChange:t=>n(t.target.value),onKeyPress:y,placeholder:a("dev.edit.callbackUrls.dialog.placeholder","https://example.com/callback"),rows:3}),e.createElement(T,{"data-translation-key":"dev.edit.callbackUrls.dialog.hint"},a("dev.edit.callbackUrls.dialog.hint","Separate multiple URLs with a comma")))),m&&e.createElement(P,{type:"danger"},m.message," "),e.createElement(A,null,e.createElement(E,{onClick:d,"data-translation-key":"dev.edit.callbackUrls.dialog.cancel",variant:"text",size:"large"},a("dev.edit.callbackUrls.dialog.cancel","Cancel")),e.createElement(S,{variant:"primary",loading:i,onClick:c,disabled:i,"data-translation-key":"dev.edit.callbackUrls.dialog.save"},a("dev.edit.callbackUrls.dialog.save","Save changes")))))};export{z as EditCallbackUrlDialog};
1
+ import*as e from"react";import{useMutation as y,useQueryClient as b}from"@tanstack/react-query";import{useParams as C}from"react-router";import{Button as U}from"@redocly/theme/components/Button/Button";import{H2 as h}from"@redocly/theme/components/Typography/H2";import{Admonition as v}from"@redocly/theme/markdoc/components/Admonition/Admonition";import{useTranslate as E}from"../../../../../client/app/hooks";import{Dialog as f}from"./Dialog";import{ButtonWithLoading as w}from"./ButtonWithLoading";import{ButtonsContainer as P}from"./RollAPIKey";import{DialogHelperText as D,DialogInputMultiline as R,DialogRow as S,DialogRowContent as A}from"./DialogStyledComponents";const Q=o=>{const{initialCallbackUrl:l,open:r,onOpen:n,onClose:a}=o;return e.createElement(f,{open:r,onClose:a,onOpen:n},e.createElement(T,{initialCallbackUrl:l,onClose:a}))},T=o=>{const{id:l}=C(),{initialCallbackUrl:r,onClose:n}=o,{translate:a}=E(),[c,m]=e.useState(r||""),s=async()=>{await g(),n()},p=t=>{t.key==="Enter"&&!i&&s()},u=b(),{mutateAsync:g,isPending:i,error:d}=y({mutationKey:["UPDATE_APP"+l],mutationFn:async()=>{const t=await fetch(`/api/api-keys/apps/${l}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({callbackUrl:c})});if(!t.ok){const k=await t.json().catch(()=>null);throw new Error(k?.error||`Request failed with status ${t.status}`)}return t.json()},onSettled:()=>{u.invalidateQueries({queryKey:["APP:"+l]})}});return e.createElement(e.Fragment,null,e.createElement(h,{"data-translation-key":"dev.edit.callbackUrls.dialog.title"},a("dev.edit.callbackUrls.dialog.title","Change callback URLs")),e.createElement(S,null,e.createElement(A,null,e.createElement(R,{value:c,onChange:t=>m(t.target.value),onKeyPress:p,placeholder:a("dev.edit.callbackUrls.dialog.placeholder","https://example.com/callback"),rows:3}),e.createElement(D,{"data-translation-key":"dev.edit.callbackUrls.dialog.hint"},a("dev.edit.callbackUrls.dialog.hint","Separate multiple URLs with a comma")))),d&&e.createElement(v,{type:"danger"},d.message," "),e.createElement(P,null,e.createElement(U,{onClick:n,"data-translation-key":"dev.edit.callbackUrls.dialog.cancel",variant:"text",size:"large"},a("dev.edit.callbackUrls.dialog.cancel","Cancel")),e.createElement(w,{variant:"primary",loading:i,onClick:s,disabled:i,"data-translation-key":"dev.edit.callbackUrls.dialog.save"},a("dev.edit.callbackUrls.dialog.save","Save changes"))))};export{Q as EditCallbackUrlDialog};
@@ -1 +1 @@
1
- import g from"path";import{DEFAULT_LOCALE_PLACEHOLDER as d,TRANSLATIONS_FILE_NAME as h}from"../../../constants/common.js";import{I18N_DIR_NAME as y,L10N_DIR_NAME as A}from"../../constants/common.js";import{logger as m}from"../../tools/notifiers/logger.js";import{reporter as w}from"../../tools/notifiers/reporter.js";import{EntitlementsProvider as O}from"../../entitlements/entitlements-provider.js";import{isL10nPath as E}from"../../fs/utils/is-l10n-path.js";import{isOpenapiDoc as I}from"../api-docs/utils/is-api-doc.js";import{telemetryTraceStep as N}from"../../../cli/telemetry/helpers/trace-step.js";async function $(){return{id:"l10n",async processContent(n,i){await N("com.redocly.build.plugin.l10n",async a=>{const{fs:t,cache:c,getConfig:r}=i,e={},p=O.instance(),l=await r();a?.setAttribute("config",JSON.stringify(l.l10n||{}));const s=l.l10n?.defaultLocale||d;if(p.canAccessFeature("l10n")){await F(i);for(const{relativePath:o}of t.scan(/(^|.*[\/\\])translations\.yaml$/)){const u=await c.load(o,"yaml"),L=P(o)||s;e[L]={translation:u.data||{}}}}e[s]={translation:{...e[s]?.translation||{}}};const f=l.l10n?.locales||[d,...t.localeFolders].map(o=>({code:o.toLowerCase(),name:o}));a?.setAttribute("locales",JSON.stringify(f)),n.setGlobalData({l10n:{translations:e,defaultLocale:s,locales:f.map(o=>({code:o.code,name:o.name||o.code}))}})})}}}function P(n){return n.indexOf("/")>0?n.split("/")[1]:void 0}async function F(n){const i=n.fs.scan();for(const{isVirtual:a,realRelativePath:t}of i){if(a)continue;if(E(t)&&t.endsWith(".page.tsx")&&await w.panicOnBuild(`The file %rp is not allowed in ${A} or ${y} folders`,t),g.posix.basename(t)===h){const r=/^(?:@(i18n|l10n)[\/\\][^\/\\]+[\/\\])?translations\.yaml$/.test(t),e=await I(t,n);!r&&!e&&m.warn("The file %rp is in the wrong location. Make sure it is located in the root directory or in the locale root directory.",t),r&&e&&m.warn("It looks like the file %rp might be an OpenAPI definition and is located in a location reserved for translation files. Please rename it or move to another directory if it is not a translations file",t)}}}export{$ as l10nPlugin};
1
+ import g from"path";import{DEFAULT_LOCALE_PLACEHOLDER as d,TRANSLATIONS_FILE_NAME as h}from"../../../constants/common.js";import{I18N_DIR_NAME as y,L10N_DIR_NAME as A}from"../../constants/common.js";import{logger as m}from"../../tools/notifiers/logger.js";import{reporter as w}from"../../tools/notifiers/reporter.js";import{EntitlementsProvider as O}from"../../entitlements/entitlements-provider.js";import{isL10nPath as E}from"../../fs/utils/is-l10n-path.js";import{isOpenapiDoc as I}from"../api-docs/utils/is-api-doc.js";import{telemetryTraceStep as N}from"../../../cli/telemetry/helpers/trace-step.js";async function $(){return{id:"l10n",async processContent(n,i){await N("com.redocly.build.plugin.l10n",async a=>{const{fs:t,cache:c,getConfig:r}=i,e={},p=O.instance(),l=await r();a?.setAttribute("config",JSON.stringify(l.l10n||{}));const s=l.l10n?.defaultLocale||d;if(p.canAccessFeature("l10n")){await F(i);for(const{relativePath:o}of t.scan(/(^|.*[/\\])translations\.yaml$/)){const u=await c.load(o,"yaml"),L=P(o)||s;e[L]={translation:u.data||{}}}}e[s]={translation:{...e[s]?.translation||{}}};const f=l.l10n?.locales||[d,...t.localeFolders].map(o=>({code:o.toLowerCase(),name:o}));a?.setAttribute("locales",JSON.stringify(f)),n.setGlobalData({l10n:{translations:e,defaultLocale:s,locales:f.map(o=>({code:o.code,name:o.name||o.code}))}})})}}}function P(n){return n.indexOf("/")>0?n.split("/")[1]:void 0}async function F(n){const i=n.fs.scan();for(const{isVirtual:a,realRelativePath:t}of i){if(a)continue;if(E(t)&&t.endsWith(".page.tsx")&&await w.panicOnBuild(`The file %rp is not allowed in ${A} or ${y} folders`,t),g.posix.basename(t)===h){const r=/^(?:@(i18n|l10n)[/\\][^/\\]+[/\\])?translations\.yaml$/.test(t),e=await I(t,n);!r&&!e&&m.warn("The file %rp is in the wrong location. Make sure it is located in the root directory or in the locale root directory.",t),r&&e&&m.warn("It looks like the file %rp might be an OpenAPI definition and is located in a location reserved for translation files. Please rename it or move to another directory if it is not a translations file",t)}}}export{$ as l10nPlugin};
@@ -1,2 +1,2 @@
1
- import B from"@redocly/portal-plugin-mock-server";import{REDOCLY_ROUTE_RBAC as x}from"@redocly/config";import{combineUrls as E,withPathPrefix as L}from"@redocly/theme/core/utils";import{VERSION_SEPARATOR as k}from"../constants/common.js";import{removeTrailingSlash as N}from"../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as j}from"../../utils/url/remove-leading-slash.js";import{isTruthy as $}from"../../utils/guards/is-truthy.js";import{normalizeRouteSlug as D}from"../../utils/path/normalize-route-slug.js";import{parsePathVersions as V}from"../../utils/path/parse-path-versions.js";import{reporter as v}from"../tools/notifiers/reporter.js";import{logger as P}from"../tools/notifiers/logger.js";import{envConfig as S}from"../config/env-config.js";import{shaDirPathShort as M}from"../utils/crypto/sha-dir-path-short.js";import{writeServerRebuildTrigger as _}from"../esbuild/generate.js";import{customPagesPlugin as q}from"../../server/plugins/pages/index.js";import{apiDocsPlugin as z}from"../../server/plugins/api-docs/index.js";import{configParserPlugin as H}from"./config-parser/index.js";import{createSlugify as U}from"./create-slugify.js";import{markdownPlugin as G}from"./markdown/index.js";import{generateBrowserPluginsModule as I,generateClientRoutes as W,generateTemplatesModule as K}from"../esbuild/generate.js";import{searchPlugin as Y}from"./search/index.js";import{skillsPlugin as J}from"./skills/index.js";import{defaultThemePlugin as Q}from"./default-theme/index.js";import{apiKeyMgmtPlugin as X}from"./dev-onboarding/index.js";import{apiFunctionsPlugin as Z}from"./api-functions/index.js";import{scorecardClassicPlugin as ee}from"./scorecard-classic/index.js";import{lintPlugin as te}from"./lint/index.js";import{resolveExternalPlugins as oe}from"../external-plugins/resolve-external-plugins.js";import{sidebarsPlugin as ie}from"./sidebars/index.js";import{l10nPlugin as re}from"./l10n/index.js";import{validateRedirects as ne}from"../utils/redirects/validate-redirects.js";import{analyticsPlugins as se}from"./analytics/index.js";import{sitemapPlugin as ae}from"./sitemap/index.js";import{entitlementsPlugin as le}from"./entitlements/index.js";import{getBilledPagesCount as ce}from"../utils/index.js";import{telemetry as ue}from"../../cli/telemetry/index.js";import{telemetryTraceStep as b}from"../../cli/telemetry/helpers/trace-step.js";import{EntitlementsProvider as A}from"../entitlements/entitlements-provider.js";import{enforceLoginPlugin as fe}from"./enforce-login/index.js";import{ssoPlugin as me}from"./sso/index.js";import{Cache as de}from"../fs/cache.js";import{ContentFs as ge}from"../fs/content-fs.js";import{findProductBySlug as pe}from"../utils/product.js";import{isRouteReserved as Pe}from"./get-reserved-routes.js";import{catalogClassicPlugin as ye}from"./catalog-classic/index.js";import{arazzoDocsPlugin as he}from"./arazzo-docs/index.js";const Re=[H,fe,me,Q,re,G,z,he,ee,te,Z,q,X,ye,{importPath:"./catalog-entities/plugin.js",loadCondition:()=>S.NEW_CATALOG_ENABLED??!1},{importPath:"./scorecards/plugin.js",loadCondition:()=>S.NEW_SCORECARDS_ENABLED??!1},{importPath:"./mcp/index.js",loadCondition:()=>A.instance().canAccessFeature("mcp")},ie,ae,le,Y,J,B,...se];async function pt(t,e=Re){return await b("com.redocly.build.pluginsInit",async()=>{const r=[],R=A.instance(),y={};for(const s of e){let u;if("loadCondition"in s){if(!s.loadCondition())continue;const i=await import(s.importPath);if(!i.default||typeof i.default!="function"){await v.panicOnBuild(`Dynamic plugin ${s.importPath} does not export a default export or it is not a function`);continue}u=i.default}else u=s;const h=await u(t);for(const[i,f]of Object.entries(h.loaders||{}))y[i]&&await v.panicOnBuild(`Duplicate loader with name ${i}`),y[i]=f;(!h.requiredEntitlements||h.requiredEntitlements?.every(i=>R.canAccessFeature(i)))&&r.push(h)}const l=new ge(t.contentDir);await l.ready;const c=new de(l);return c.setLoaders(y),P.verbose("All plugins instantiated"),{pluginInstances:r,lifecycleContext:we(l,c)}})}function O(t){P.verbose("Generating templates"),b("com.redocly.build.writeClientEntries",()=>{K(t),I(t),W(t)})}async function Ce(t){const e=t.getAllRoutes();ce(e)||await v.panicOnBuild("No routes created by plugins. Please check your project configuration.")}async function Pt(t,e,r,R={}){const y=A.instance();try{await b("com.redocly.build.pluginsRun",async()=>{e.startPluginsRun();const l=S.isDevelopMode&&e.buildRevision>0,c=l?F(e):"";let s=[];await b("com.redocly.build.pluginsProcessContent",async i=>{for(const o of t){const a=P.startTiming();await o.processContent?.(e,r),P.verboseTime(a,`processContent for ${o.id}`)}s=(await oe(e.contentDir,e.config.plugins)).map(o=>o.lifecyclePlugin).filter(o=>$(o)&&(!o.requiredEntitlements||o.requiredEntitlements?.every(a=>y.canAccessFeature(a)))),r.cache.setLoaders(Object.fromEntries(s.flatMap(o=>Object.entries(o.loaders||{}))));for(const o of s){const a=P.startTiming();await o.processContent?.(e,r),P.verboseTime(a,`processContent for ${o.id}`)}i?.setAttribute("externalPluginsProcessed",s.length.toString())});const u=await ve(e,r),h=[...t,...s];O(e),S.isDevelopMode?await e.userCodeReady:e.buildRevision++,await b("com.redocly.build.pluginsAfterRoutesCreated",async()=>{for(const i of h){const f=P.startTiming();await i.afterRoutesCreated?.(e,u),P.verboseTime(f,`afterRoutesCreated for ${i.id}`)}}),ne(e),await e.reportUnsetEnvVars(),await Ce(e),O(e),l&&c!==F(e)&&(e.markRequestHandlersEntryOutdated(),_(e.serverOutDir))})}catch(l){const c="Unhandled error in plugin. "+l.message+`
2
- `+l.stack;ue.sendCliErrorCaughtMessage([{id:"cli",object:"error",uri:"urn:redocly:realm:cli:error:cli",message:c}]),R.failFast?await v.panic(c):await v.panicOnBuild(c)}finally{e.finishPluginsRun()}}async function ve(t,e){const{cache:r,fs:R}=e,y=await e.getConfig(),l=Object.values(y.products||{}),c=(await r.load("versions-config","versions-config")).data,s=(await r.load("content-slugs","content-slugs")).data,u=U(s);for(const{duplicateInAllLocales:i,slugSuffix:f,sharedData:o=[],redirectFrom:a=[],...d}of t.newRoutes){const w=D(d.slug?d.slug:u(d.fsPath)),g=N(f?E(w,f):w),n={...d,[x]:{slug:g,fsPath:d.fsPath},slug:g,baseSlug:w,versions:h(d.fsPath,f),product:pe(l,g,u)};Pe(g,y)&&await v.panicOnBuildContentError(`Route "${g}" is reserved and cannot be used. Please choose a different slug for "${d.fsPath}".`),t.routesByFsPath.set(n.fsPath,n.slug),t.routesBySlug.set(n.slug,n);for(const{key:p,id:m}of o)t.addRouteSharedData(n.slug,p,m);for(const p of a)t.addRedirect(p.from,{type:p.type,to:n.slug});if(i)for(const p of R.localeFolders){const m={...n,slug:"/"+p.toLowerCase()+n.slug};t.routesByFsPath.set(m.fsPath,m.slug),t.routesBySlug.set(m.slug,m);for(const{key:C,id:T}of o)t.addRouteSharedData(m.slug,C,T);for(const C of a){const T=E(R.localizationFolder,p,C.from);t.addRedirect(T,{type:C.type,to:m.slug},{trackOriginalSource:!1})}}}return t.newRoutes=[],{...e,slugify:u};function h(i,f=""){const o=V(i);if(!o?.versionName)return;const{versionFolderPath:a,filePathInVersion:d,versionName:w}=o,g=c.get(a);if(g)return g.versions.map(n=>{const p=g.defaultVersion===n.version,m=j(E(a,k+n.version,d)),C=u(m);return{version:n.version,label:n.name||n.version,link:D(E(C,f)),default:p,active:w===n.version,folderId:M(`${a}`)}})}}function we(t,e){return{fs:t,cache:e,getConfig:async(r=".")=>(await e.load(r,"nearest-redocly-config",t.localeFolders)).data,isPathIgnored:async r=>(await e.load(r,"is-ignored")).data,withPathPrefix:L,logger:P}}function F(t){return[...t.apiRoutesRequestHandlers.keys(),...t.getMcpTools().map(e=>`${e.name}:${e.importPath}`)].sort().join(",")}export{Re as INTERNAL_PLUGINS,we as createLifecycleContext,pt as initPlugins,Pt as runPlugins,O as writeClientEntries};
1
+ import B from"@redocly/portal-plugin-mock-server";import{REDOCLY_ROUTE_RBAC as x}from"@redocly/config";import{combineUrls as E,withPathPrefix as L}from"@redocly/theme/core/utils";import{VERSION_SEPARATOR as k}from"../constants/common.js";import{removeTrailingSlash as N}from"../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as j}from"../../utils/url/remove-leading-slash.js";import{isTruthy as $}from"../../utils/guards/is-truthy.js";import{normalizeRouteSlug as D}from"../../utils/path/normalize-route-slug.js";import{parsePathVersions as V}from"../../utils/path/parse-path-versions.js";import{reporter as v}from"../tools/notifiers/reporter.js";import{logger as P}from"../tools/notifiers/logger.js";import{envConfig as S}from"../config/env-config.js";import{shaDirPathShort as M}from"../utils/crypto/sha-dir-path-short.js";import{writeServerRebuildTrigger as _,generateBrowserPluginsModule as q,generateClientRoutes as z,generateTemplatesModule as H}from"../esbuild/generate.js";import{customPagesPlugin as U}from"../../server/plugins/pages/index.js";import{apiDocsPlugin as G}from"../../server/plugins/api-docs/index.js";import{configParserPlugin as I}from"./config-parser/index.js";import{createSlugify as W}from"./create-slugify.js";import{markdownPlugin as K}from"./markdown/index.js";import{searchPlugin as Y}from"./search/index.js";import{skillsPlugin as J}from"./skills/index.js";import{defaultThemePlugin as Q}from"./default-theme/index.js";import{apiKeyMgmtPlugin as X}from"./dev-onboarding/index.js";import{apiFunctionsPlugin as Z}from"./api-functions/index.js";import{scorecardClassicPlugin as ee}from"./scorecard-classic/index.js";import{lintPlugin as te}from"./lint/index.js";import{resolveExternalPlugins as oe}from"../external-plugins/resolve-external-plugins.js";import{sidebarsPlugin as ie}from"./sidebars/index.js";import{l10nPlugin as re}from"./l10n/index.js";import{validateRedirects as ne}from"../utils/redirects/validate-redirects.js";import{analyticsPlugins as se}from"./analytics/index.js";import{sitemapPlugin as ae}from"./sitemap/index.js";import{entitlementsPlugin as le}from"./entitlements/index.js";import{getBilledPagesCount as ce}from"../utils/index.js";import{telemetry as ue}from"../../cli/telemetry/index.js";import{telemetryTraceStep as b}from"../../cli/telemetry/helpers/trace-step.js";import{EntitlementsProvider as A}from"../entitlements/entitlements-provider.js";import{enforceLoginPlugin as fe}from"./enforce-login/index.js";import{ssoPlugin as me}from"./sso/index.js";import{Cache as de}from"../fs/cache.js";import{ContentFs as ge}from"../fs/content-fs.js";import{findProductBySlug as pe}from"../utils/product.js";import{isRouteReserved as Pe}from"./get-reserved-routes.js";import{catalogClassicPlugin as ye}from"./catalog-classic/index.js";import{arazzoDocsPlugin as he}from"./arazzo-docs/index.js";const Re=[I,fe,me,Q,re,K,G,he,ee,te,Z,U,X,ye,{importPath:"./catalog-entities/plugin.js",loadCondition:()=>S.NEW_CATALOG_ENABLED??!1},{importPath:"./scorecards/plugin.js",loadCondition:()=>S.NEW_SCORECARDS_ENABLED??!1},{importPath:"./mcp/index.js",loadCondition:()=>A.instance().canAccessFeature("mcp")},ie,ae,le,Y,J,B,...se];async function gt(t,e=Re){return await b("com.redocly.build.pluginsInit",async()=>{const r=[],R=A.instance(),y={};for(const s of e){let u;if("loadCondition"in s){if(!s.loadCondition())continue;const i=await import(s.importPath);if(!i.default||typeof i.default!="function"){await v.panicOnBuild(`Dynamic plugin ${s.importPath} does not export a default export or it is not a function`);continue}u=i.default}else u=s;const h=await u(t);for(const[i,f]of Object.entries(h.loaders||{}))y[i]&&await v.panicOnBuild(`Duplicate loader with name ${i}`),y[i]=f;(!h.requiredEntitlements||h.requiredEntitlements?.every(i=>R.canAccessFeature(i)))&&r.push(h)}const l=new ge(t.contentDir);await l.ready;const c=new de(l);return c.setLoaders(y),P.verbose("All plugins instantiated"),{pluginInstances:r,lifecycleContext:we(l,c)}})}function O(t){P.verbose("Generating templates"),b("com.redocly.build.writeClientEntries",()=>{H(t),q(t),z(t)})}async function Ce(t){const e=t.getAllRoutes();ce(e)||await v.panicOnBuild("No routes created by plugins. Please check your project configuration.")}async function pt(t,e,r,R={}){const y=A.instance();try{await b("com.redocly.build.pluginsRun",async()=>{e.startPluginsRun();const l=S.isDevelopMode&&e.buildRevision>0,c=l?F(e):"";let s=[];await b("com.redocly.build.pluginsProcessContent",async i=>{for(const o of t){const a=P.startTiming();await o.processContent?.(e,r),P.verboseTime(a,`processContent for ${o.id}`)}s=(await oe(e.contentDir,e.config.plugins)).map(o=>o.lifecyclePlugin).filter(o=>$(o)&&(!o.requiredEntitlements||o.requiredEntitlements?.every(a=>y.canAccessFeature(a)))),r.cache.setLoaders(Object.fromEntries(s.flatMap(o=>Object.entries(o.loaders||{}))));for(const o of s){const a=P.startTiming();await o.processContent?.(e,r),P.verboseTime(a,`processContent for ${o.id}`)}i?.setAttribute("externalPluginsProcessed",s.length.toString())});const u=await ve(e,r),h=[...t,...s];O(e),S.isDevelopMode?await e.userCodeReady:e.buildRevision++,await b("com.redocly.build.pluginsAfterRoutesCreated",async()=>{for(const i of h){const f=P.startTiming();await i.afterRoutesCreated?.(e,u),P.verboseTime(f,`afterRoutesCreated for ${i.id}`)}}),ne(e),await e.reportUnsetEnvVars(),await Ce(e),O(e),l&&c!==F(e)&&(e.markRequestHandlersEntryOutdated(),_(e.serverOutDir))})}catch(l){const c="Unhandled error in plugin. "+l.message+`
2
+ `+l.stack;ue.sendCliErrorCaughtMessage([{id:"cli",object:"error",uri:"urn:redocly:realm:cli:error:cli",message:c}]),R.failFast?await v.panic(c):await v.panicOnBuild(c)}finally{e.finishPluginsRun()}}async function ve(t,e){const{cache:r,fs:R}=e,y=await e.getConfig(),l=Object.values(y.products||{}),c=(await r.load("versions-config","versions-config")).data,s=(await r.load("content-slugs","content-slugs")).data,u=W(s);for(const{duplicateInAllLocales:i,slugSuffix:f,sharedData:o=[],redirectFrom:a=[],...d}of t.newRoutes){const w=D(d.slug?d.slug:u(d.fsPath)),g=N(f?E(w,f):w),n={...d,[x]:{slug:g,fsPath:d.fsPath},slug:g,baseSlug:w,versions:h(d.fsPath,f),product:pe(l,g,u)};Pe(g,y)&&await v.panicOnBuildContentError(`Route "${g}" is reserved and cannot be used. Please choose a different slug for "${d.fsPath}".`),t.routesByFsPath.set(n.fsPath,n.slug),t.routesBySlug.set(n.slug,n);for(const{key:p,id:m}of o)t.addRouteSharedData(n.slug,p,m);for(const p of a)t.addRedirect(p.from,{type:p.type,to:n.slug});if(i)for(const p of R.localeFolders){const m={...n,slug:"/"+p.toLowerCase()+n.slug};t.routesByFsPath.set(m.fsPath,m.slug),t.routesBySlug.set(m.slug,m);for(const{key:C,id:T}of o)t.addRouteSharedData(m.slug,C,T);for(const C of a){const T=E(R.localizationFolder,p,C.from);t.addRedirect(T,{type:C.type,to:m.slug},{trackOriginalSource:!1})}}}return t.newRoutes=[],{...e,slugify:u};function h(i,f=""){const o=V(i);if(!o?.versionName)return;const{versionFolderPath:a,filePathInVersion:d,versionName:w}=o,g=c.get(a);if(g)return g.versions.map(n=>{const p=g.defaultVersion===n.version,m=j(E(a,k+n.version,d)),C=u(m);return{version:n.version,label:n.name||n.version,link:D(E(C,f)),default:p,active:w===n.version,folderId:M(`${a}`)}})}}function we(t,e){return{fs:t,cache:e,getConfig:async(r=".")=>(await e.load(r,"nearest-redocly-config",t.localeFolders)).data,isPathIgnored:async r=>(await e.load(r,"is-ignored")).data,withPathPrefix:L,logger:P}}function F(t){return[...t.apiRoutesRequestHandlers.keys(),...t.getMcpTools().map(e=>`${e.name}:${e.importPath}`)].sort().join(",")}export{Re as INTERNAL_PLUGINS,we as createLifecycleContext,gt as initPlugins,pt as runPlugins,O as writeClientEntries};
@@ -1 +1 @@
1
- import o from"node:path";import{ASYNC_API_DOCS_TEMPLATE_ID as T,GRAPHQL_TEMPLATE_ID as v,OPENAPI_DOCS_TEMPLATE_ID as y}from"../../../../constants/common.js";import{isLocalLink as D}from"../../../../utils/path/is-local-link.js";import{normalizeRouteSlug as h}from"../../../../utils/path/normalize-route-slug.js";import{removeFragment as F}from"../../../../utils/path/remove-fragment.js";import{getInnerText as M}from"../../../../markdoc/helpers/get-inner-text.js";import{getNodeAttribute as U}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as p}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{isAuthRoutePath as W}from"../../../../utils/auth/is-auth-route-path.js";import{isApiDownloadLink as j}from"../../../utils/is-api-download-link.js";import{MdResolveError as g}from"./md-resolve-error.js";import{getLinkOriginalAttrName as B}from"./utils.js";import{isOpenApiURL as $}from"../../api-docs/utils/is-api-doc.js";import{parseBaseName as C}from"../../utils.js";import{isMarkdownPage as V}from"../is-markdown-page.js";import{copyStaticFile as b}from"../../../utils/fs.js";async function at(i,s,E,{actions:k,context:f}){const{contentDir:d,outdir:S,getRouteByFsPath:w,hasRouteOrRedirectBySlug:A}=k,L=B(s),e=i[L]||U(i,s);if(i[L]=e,!D(e)||j(e)||W(e))return;const[z,t="",R,P]=/^([^\?#]+)?([^#]+)?(.+)?/.exec(e)||[],c=i.type==="image"?"IMAGE":"LINK",u=String(i.attributes.title||i.attributes.alt||M([i])||""),n=F(E);if(i.type!=="image"){const{isOpenapiDetected:r,isOpenapiValid:m}=await $(t,n,k,f);if(r&&!m)throw new g(`OpenAPI route ${e} does not exist`,{rawLink:e,link:t,title:u,brokenLinkType:c})}if(o.extname(t)===""){if(t.startsWith("/")){if(!A(h(t)))throw new g(`Route ${t} does not exist`,{rawLink:e,link:t,title:u,brokenLinkType:c});p(i,s,t+(R||"")+(P||""))}if(!e.startsWith("#")&&!t.startsWith("/")&&V(n)){const r=w(n)?.slug;if(!r)return;const{isIndexFile:m}=C(n),x=m?h(o.posix.join(r,t)):h(o.posix.join(r,"../",t));if(!A(h(x)))throw new g(`Route ${t} does not exist`,{rawLink:e,link:x,title:u,brokenLinkType:c});p(i,s,x+(R||"")+(P||""))}return}const a=t.startsWith("/")?t.substring(1):o.posix.join(o.posix.dirname(n),decodeURI(t)),_=t.startsWith("/")?o.posix.join("static",t.substring(1)):"",I=f.fs.exists(a),O=f.fs.exists(_),l=w(a);if(!I&&!l&&!O)throw p(i,s,"#"),new g(`File ${a} does not exist`,{rawLink:e,link:a,title:u,brokenLinkType:c});if(l){const r=[y,v,T].includes(l.templateId);p(i,s,(r?l.baseSlug:l.slug)+(P||""))}else if(I){const r=f.fs.getFileInfo(a);if(!r||r.isVirtual)return;const m=await b(d,r.realRelativePath,S);p(i,s,m)}}export{at as resolveLink};
1
+ import o from"node:path";import{ASYNC_API_DOCS_TEMPLATE_ID as T,GRAPHQL_TEMPLATE_ID as v,OPENAPI_DOCS_TEMPLATE_ID as y}from"../../../../constants/common.js";import{isLocalLink as D}from"../../../../utils/path/is-local-link.js";import{normalizeRouteSlug as h}from"../../../../utils/path/normalize-route-slug.js";import{removeFragment as F}from"../../../../utils/path/remove-fragment.js";import{getInnerText as M}from"../../../../markdoc/helpers/get-inner-text.js";import{getNodeAttribute as U}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as p}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{isAuthRoutePath as W}from"../../../../utils/auth/is-auth-route-path.js";import{isApiDownloadLink as j}from"../../../utils/is-api-download-link.js";import{MdResolveError as g}from"./md-resolve-error.js";import{getLinkOriginalAttrName as B}from"./utils.js";import{isOpenApiURL as $}from"../../api-docs/utils/is-api-doc.js";import{parseBaseName as C}from"../../utils.js";import{isMarkdownPage as V}from"../is-markdown-page.js";import{copyStaticFile as b}from"../../../utils/fs.js";async function at(i,s,E,{actions:k,context:f}){const{contentDir:d,outdir:S,getRouteByFsPath:w,hasRouteOrRedirectBySlug:A}=k,L=B(s),e=i[L]||U(i,s);if(i[L]=e,!D(e)||j(e)||W(e))return;const[z,t="",R,P]=/^([^?#]+)?([^#]+)?(.+)?/.exec(e)||[],c=i.type==="image"?"IMAGE":"LINK",u=String(i.attributes.title||i.attributes.alt||M([i])||""),n=F(E);if(i.type!=="image"){const{isOpenapiDetected:r,isOpenapiValid:m}=await $(t,n,k,f);if(r&&!m)throw new g(`OpenAPI route ${e} does not exist`,{rawLink:e,link:t,title:u,brokenLinkType:c})}if(o.extname(t)===""){if(t.startsWith("/")){if(!A(h(t)))throw new g(`Route ${t} does not exist`,{rawLink:e,link:t,title:u,brokenLinkType:c});p(i,s,t+(R||"")+(P||""))}if(!e.startsWith("#")&&!t.startsWith("/")&&V(n)){const r=w(n)?.slug;if(!r)return;const{isIndexFile:m}=C(n),x=m?h(o.posix.join(r,t)):h(o.posix.join(r,"../",t));if(!A(h(x)))throw new g(`Route ${t} does not exist`,{rawLink:e,link:x,title:u,brokenLinkType:c});p(i,s,x+(R||"")+(P||""))}return}const a=t.startsWith("/")?t.substring(1):o.posix.join(o.posix.dirname(n),decodeURI(t)),_=t.startsWith("/")?o.posix.join("static",t.substring(1)):"",I=f.fs.exists(a),O=f.fs.exists(_),l=w(a);if(!I&&!l&&!O)throw p(i,s,"#"),new g(`File ${a} does not exist`,{rawLink:e,link:a,title:u,brokenLinkType:c});if(l){const r=[y,v,T].includes(l.templateId);p(i,s,(r?l.baseSlug:l.slug)+(P||""))}else if(I){const r=f.fs.getFileInfo(a);if(!r||r.isVirtual)return;const m=await b(d,r.realRelativePath,S);p(i,s,m)}}export{at as resolveLink};
@@ -1 +1 @@
1
- import{getNodeAttribute as m}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as l}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{optimize as p}from"../../../../compiled/svgo/svgo-node.js";import{slug as c}from"../../../utils/index.js";import{MdResolveError as d}from"./md-resolve-error.js";import{resolvePathInMarkdown as u}from"../resolve-path-in-markdown.js";async function b(o,r,n,{context:i,actions:s}){const e=m(o,r),a=s.contentDir;if(e){const t=u(e,n,a);if(!i.fs.exists(t))throw new d(`File ${t} does not exist`,{rawLink:e});let f=p(await i.fs.read(t),{plugins:[{name:"prefixIds",params:{prefix:c(t).replaceAll(/[\/\.]/g,"-")}}]}).data;l(o,r+"RawContent",f)}}export{b as resolveSvgContent};
1
+ import{getNodeAttribute as m}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as l}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{optimize as p}from"../../../../compiled/svgo/svgo-node.js";import{slug as c}from"../../../utils/index.js";import{MdResolveError as d}from"./md-resolve-error.js";import{resolvePathInMarkdown as u}from"../resolve-path-in-markdown.js";async function b(o,r,n,{context:i,actions:s}){const e=m(o,r),a=s.contentDir;if(e){const t=u(e,n,a);if(!i.fs.exists(t))throw new d(`File ${t} does not exist`,{rawLink:e});let f=p(await i.fs.read(t),{plugins:[{name:"prefixIds",params:{prefix:c(t).replaceAll(/[/.]/g,"-")}}]}).data;l(o,r+"RawContent",f)}}export{b as resolveSvgContent};
@@ -1 +1 @@
1
- import M from"@markdoc/markdoc";import*as S from"path";import{GATED_MARKDOC_TAGS as O}from"../../constants/entitlements.js";import{logger as F}from"../../tools/notifiers/logger.js";import{reporter as N}from"../../tools/notifiers/reporter.js";import{sha1 as G}from"../../utils/crypto/sha1.js";import{formatMarkdocError as H}from"./errors.js";import{extractFirstHeading as j,visit as K}from"./markdoc/plugins/utils.js";import{attributeResolvers as y}from"./attribute-resolvers/index.js";import{MdResolveError as $}from"./attribute-resolvers/md-resolve-error.js";import{processHtmlTokens as U}from"./html/process-html-tokens.js";import{resolveRawPartials as W}from"./markdoc/resolve-raw-partials.js";import{EntitlementsProvider as Y}from"../../entitlements/entitlements-provider.js";import{MARKDOC_PARTIALS_DEPS_KEY as B}from"../../constants/common.js";import{getLinkOriginalAttrName as V}from"./attribute-resolvers/utils.js";const q="EMPTY";async function C(a,s,e){const n=Y.instance(),{actions:m}=e,{relativePath:i,resolveErrors:E}=a,k=new Set,g=new Set,b=new Set,c=new Set,u={},f=new Set,w={},_={};function R(t,P){const D=P||q;t[D]=(t[D]||0)+1}const A=[];return a.resolveErrors.length=0,K(a.ast,t=>{const P=D();A.push(P.then(r=>{r?.sharedDataIds&&r.sharedDataIds.forEach(d=>k.add(d))}).catch(z));async function D(){const r=[];switch(t.type){case"fence":R(w,t.attributes.language);break;case"link":case"image":await y.nativeMdLink(t,t.type==="link"?"href":"src",i,e);break;case"tag":if(!t.tag)break;const d=s?.tags?.[t.tag];if(!d){O[t.tag]&&!n.canAccessFeature(O[t.tag])&&(t.errors.push({level:"warning",id:"invalid-tag",message:`Undefined tag: ${t.tag}`}),t.tag="",t.type="error",t.attributes={});break}const v=t.tag==="html"?t.attributes.name:t.tag;if((t.tag==="html"?f:c).add(v),u[v]=(u[v]||0)+1,v==="code-snippet"&&R(w,t.attributes.language),d.attributes?.__idx&&(t.attributes.__idx=u[t.tag]),d.dynamicComponentLib&&g.add(d.dynamicComponentLib),!d.attributes)break;if(v==="partial"&&t.attributes?.file){const o=V("file"),l=t[o]||t.attributes.file,h=l.startsWith("/")?l.slice(1):S.posix.normalize(S.posix.join(S.posix.dirname(i),l));b.add(h);const p=(m.getGlobalConfig(B)||{})[h];if(p?.dynamicComponents)for(const L of p.dynamicComponents)g.add(L);if(p?.sharedDataDeps)for(const L of p.sharedDataDeps)k.add(L)}for(const[o,l]of Object.entries(d.attributes)){const h=l.type;if(h&&(h.resolver||l.resolver)){const T=y[h.resolver||l.resolver],p=await T?.(t,o,i,e);p?.sharedDataId&&r.push(p.sharedDataId)}}if(v==="code-walkthrough")for(const o of t.attributes.resolvedFilesets||[])for(const l of o.files||[])R(_,l.language);const I=t.attributes?.attrs;if(I&&t.tag==="html")for(const o of Object.keys(I))o==="src"||o==="srcSet"?await y.htmlSourceAttribute(t,o,i,e):o==="href"&&await y.htmlHref(t,o,i,e);break}return{sharedDataIds:r}}async function z(r){if(!(r instanceof $)){await N.panicOnBuild(r.message);return}E.push(H({type:"resolve_link",meta:{...r.meta,link:r.meta.link??r.meta.rawLink},lines:t.lines,location:t.location,error:{id:"",level:"error",message:r.message,location:t.location}},a.relativePath,a.rawContent))}}),await Promise.all(A),a.sharedDataDeps=k,a.dynamicMarkdocComponents=g,a.validatedAtRevision<m.buildRevision&&(a.markdocErrors=M.validate(a.ast,s).map(t=>H(t,i,a.rawContent)),a.validatedAtRevision=m.buildRevision),{sharedDataDeps:a.sharedDataDeps,dynamicMarkdocComponents:Array.from(a.dynamicMarkdocComponents?.values()??[]),partials:Array.from(b),tagList:Array.from(c),htmlTagsList:Array.from(f),tagOccurrence:u,codeSnippetLanguages:w,codeWalkthroughLanguages:_}}const x=new M.Tokenizer({html:!0,allowIndentation:!0,allowComments:!0});x.parser.block.ruler.getRules("reference").length=0;function J(a,s){const e=x.tokenize(s),n=U(e);return{ast:M.parse(n,{file:a,slots:!0}),rawContent:s,resolveErrors:[],markdocErrors:[],relativePath:a,sharedDataDeps:void 0,validatedAtRevision:-1}}async function dt(a,s){const{data:e}=await s.cache.load(a,"markdown-ast");return j(e.ast)}async function gt(a,s){N.clearMarkdocProblems();const e=a.getAllRoutes();let n=0;const m=F.isInteractive();for(const i of e)await a.resolveRouteStaticData(i,s,!0),n++,m&&n%100===0&&F.logInFooter("validate",` \u{1F50D} Status: validating markdoc (${n}/${e.length})`)}async function ut(a,s,e,n){const m=a.content?G(a.content):"";return await e.context.cache.load(n||a.relativePath,{loader:E,name:"markdown-inline-parser"},[m,String(e.actions.buildRevision)]);async function E(k,g,b){let c;if(a.content){const f=await g.getConfig(),w=await W(a.content,a.relativePath,f.markdown?.partialsFolders,g);c=J(a.relativePath,w)}else c=(await g.cache.load(a.relativePath,"markdown-ast")).data;let u={};if(e.actions.buildRevision!==0&&(u=await C(c,s,e)),!a.isVirtual){for(const f of c.markdocErrors)b(f);for(const f of c.resolveErrors)b(f)}return{ast:c.ast,info:u}}}export{dt as extractMdFirstHeading,J as getAst,ut as parseAndResolveMarkdoc,C as resolveAndValidateMarkdoc,gt as validateAllMarkdowns};
1
+ import P from"@markdoc/markdoc";import*as S from"path";import{GATED_MARKDOC_TAGS as F}from"../../constants/entitlements.js";import{logger as N}from"../../tools/notifiers/logger.js";import{reporter as H}from"../../tools/notifiers/reporter.js";import{sha1 as U}from"../../utils/crypto/sha1.js";import{formatMarkdocError as z}from"./errors.js";import{extractFirstHeading as W,visit as G}from"./markdoc/plugins/utils.js";import{attributeResolvers as E}from"./attribute-resolvers/index.js";import{MdResolveError as Y}from"./attribute-resolvers/md-resolve-error.js";import{processHtmlTokens as B}from"./html/process-html-tokens.js";import{resolveRawPartials as V}from"./markdoc/resolve-raw-partials.js";import{exampleContentTrees as q,reparseExampleFences as C}from"./markdoc/reparse-example-fences.js";import{EntitlementsProvider as J}from"../../entitlements/entitlements-provider.js";import{MARKDOC_PARTIALS_DEPS_KEY as Q}from"../../constants/common.js";import{getLinkOriginalAttrName as X}from"./attribute-resolvers/utils.js";const Z="EMPTY";async function tt(a,r,e){const i=J.instance(),{actions:n}=e,{relativePath:c,resolveErrors:R}=a,y=new Set,g=new Set,w=new Set,l=new Set,p={},f=new Set,b={},_={};function L(t,o){const D=o||Z;t[D]=(t[D]||0)+1}const T=[];a.resolveErrors.length=0;const I=q(a.ast),A=t=>{const o=D();T.push(o.then(k=>{k?.sharedDataIds&&k.sharedDataIds.forEach(d=>y.add(d))}).catch($(t)));async function D(){const k=[];switch(t.type){case"fence":L(b,t.attributes.language);break;case"link":case"image":await E.nativeMdLink(t,t.type==="link"?"href":"src",c,e);break;case"tag":{if(!t.tag)break;const d=r?.tags?.[t.tag];if(!d){F[t.tag]&&!i.canAccessFeature(F[t.tag])&&(t.errors.push({level:"warning",id:"invalid-tag",message:`Undefined tag: ${t.tag}`}),t.tag="",t.type="error",t.attributes={});break}const v=t.tag==="html"?t.attributes.name:t.tag;if((t.tag==="html"?f:l).add(v),p[v]=(p[v]||0)+1,v==="code-snippet"&&L(b,t.attributes.language),d.attributes?.__idx&&(t.attributes.__idx=p[t.tag]),d.dynamicComponentLib&&g.add(d.dynamicComponentLib),!d.attributes)break;if(v==="partial"&&t.attributes?.file){const s=X("file"),m=t[s]||t.attributes.file,h=m.startsWith("/")?m.slice(1):S.posix.normalize(S.posix.join(S.posix.dirname(c),m));w.add(h);const u=(n.getGlobalConfig(Q)||{})[h];if(u?.dynamicComponents)for(const M of u.dynamicComponents)g.add(M);if(u?.sharedDataDeps)for(const M of u.sharedDataDeps)y.add(M)}for(const[s,m]of Object.entries(d.attributes)){const h=m.type;if(h&&(h.resolver||m.resolver)){const x=E[h.resolver||m.resolver],u=await x?.(t,s,c,e);u?.sharedDataId&&k.push(u.sharedDataId)}}if(v==="code-walkthrough")for(const s of t.attributes.resolvedFilesets||[])for(const m of s.files||[])L(_,m.language);const O=t.attributes?.attrs;if(O&&t.tag==="html")for(const s of Object.keys(O))s==="src"||s==="srcSet"?await E.htmlSourceAttribute(t,s,c,e):s==="href"&&await E.htmlHref(t,s,c,e);break}}return{sharedDataIds:k}}};function $(t){return async o=>{if(!(o instanceof Y)){await H.panicOnBuild(o.message);return}R.push(z({type:"resolve_link",meta:{...o.meta,link:o.meta.link??o.meta.rawLink},lines:t.lines,location:t.location,error:{id:"",level:"error",message:o.message,location:t.location}},a.relativePath,a.rawContent))}}G(a.ast,A);for(const t of I)G(t,o=>{o.type==="tag"&&A(o)});return await Promise.all(T),a.sharedDataDeps=y,a.dynamicMarkdocComponents=g,a.validatedAtRevision<n.buildRevision&&(a.markdocErrors=[a.ast,...I].flatMap(t=>P.validate(t,r)).map(t=>z(t,c,a.rawContent)),a.validatedAtRevision=n.buildRevision),{sharedDataDeps:a.sharedDataDeps,dynamicMarkdocComponents:Array.from(a.dynamicMarkdocComponents?.values()??[]),partials:Array.from(w),tagList:Array.from(l),htmlTagsList:Array.from(f),tagOccurrence:p,codeSnippetLanguages:b,codeWalkthroughLanguages:_}}const j=new P.Tokenizer({html:!0,allowIndentation:!0,allowComments:!0});j.parser.block.ruler.getRules("reference").length=0;function K(a,r){const e=j.tokenize(a),i=B(e);return P.parse(i,r)}function at(a,r){const e=K(r,{file:a,slots:!0});return C(e,n=>K(n,{file:a})),{ast:e,rawContent:r,resolveErrors:[],markdocErrors:[],relativePath:a,sharedDataDeps:void 0,validatedAtRevision:-1}}async function wt(a,r){const{data:e}=await r.cache.load(a,"markdown-ast");return W(e.ast)}async function bt(a,r){H.clearMarkdocProblems();const e=a.getAllRoutes();let i=0;const n=N.isInteractive();for(const c of e)await a.resolveRouteStaticData(c,r,!0),i++,n&&i%100===0&&N.logInFooter("validate",` \u{1F50D} Status: validating markdoc (${i}/${e.length})`)}async function kt(a,r,e,i){const n=a.content?U(a.content):"";return await e.context.cache.load(i||a.relativePath,{loader:R,name:"markdown-inline-parser"},[n,String(e.actions.buildRevision)]);async function R(y,g,w){let l;if(a.content){const f=await g.getConfig(),b=await V(a.content,a.relativePath,f.markdown?.partialsFolders,g);l=at(a.relativePath,b)}else l=(await g.cache.load(a.relativePath,"markdown-ast")).data;let p={};if(e.actions.buildRevision!==0&&(p=await tt(l,r,e)),!a.isVirtual){for(const f of l.markdocErrors)w(f);for(const f of l.resolveErrors)w(f)}return{ast:l.ast,info:p}}}export{wt as extractMdFirstHeading,at as getAst,kt as parseAndResolveMarkdoc,tt as resolveAndValidateMarkdoc,bt as validateAllMarkdowns};
@@ -1,2 +1,2 @@
1
1
  import l from"node:path";import{MARKDOC_ERROR_TYPES as s}from"../../../constants/common.js";import{slash as m}from"../../../utils/path/slash.js";import{getCodeframe as f}from"../../utils/codeframes/codeframes.js";function L(e,r,n){const{frame:t,start:a}=f(h(e,n),!0);return{type:e.meta?e.meta?.brokenLinkType?"BROKEN_LINK":"RESOLVE":"MARKDOC",brokenLinkType:e.meta?.brokenLinkType,codeframe:t,message:e.error.message,sourceFileRelativePath:r,sourceFileLocation:a,...e.meta}}function o(e,r,n){const t=e?.line??r?.line??n?.line,a=e?.character??r?.character??n?.character;return{line:t!==void 0?t+1:0,character:a!==void 0?a+1:void 0}}function h(e,r){const n=o(e.location?.start,e.error.location?.start,{line:e.lines[0]}),t=o(e.location?.end,e.error.location?.end,{line:e.lines[1]});t.line--;const a=r.split(`
2
- `);switch(e.type){case"resolve_link":const c=e.meta?.rawLink;let i=n.line;for(;i<t.line&&!(a[i-1].indexOf(c)>-1);)i++;if(n.line=i,i<1)break;n.character=n.character??a[i-1].indexOf(c)+1,t.line=i,t.character=t.character??n.character+c.length;break;default:n.character=n.character??1,t.character=t.character??(a[t.line-1]?.length||0)+1}return{start:n,end:t,lines:a}}function R(e,r,n){const t=l.relative(n,e.location[0]?.source.absoluteRef),c=m(t)===r?"":e.location[0]?.pointer;return`${e.message.replaceAll(n+"/","")} in ${t}${c?` at ${c}`:""}`}function E(e){return"type"in e&&s.includes(e.type)}export{R as formatBundleFromMarkdocError,L as formatMarkdocError,E as isMarkdocError,h as normalizeErrorLocation};
2
+ `);switch(e.type){case"resolve_link":{const c=e.meta?.rawLink;let i=n.line;for(;i<t.line&&!(a[i-1].indexOf(c)>-1);)i++;if(n.line=i,i<1)break;n.character=n.character??a[i-1].indexOf(c)+1,t.line=i,t.character=t.character??n.character+c.length;break}default:n.character=n.character??1,t.character=t.character??(a[t.line-1]?.length||0)+1}return{start:n,end:t,lines:a}}function R(e,r,n){const t=l.relative(n,e.location[0]?.source.absoluteRef),c=m(t)===r?"":e.location[0]?.pointer;return`${e.message.replaceAll(n+"/","")} in ${t}${c?` at ${c}`:""}`}function E(e){return"type"in e&&s.includes(e.type)}export{R as formatBundleFromMarkdocError,L as formatMarkdocError,E as isMarkdocError,h as normalizeErrorLocation};
@@ -1 +1 @@
1
- import a from"path";import{pathMatchesGlobPattern as i}from"../../utils/globs.js";const p=(r,o)=>o.some(t=>{const e=a.posix.normalize(t);return i(r,e)});export{p as isPartial};
1
+ import c from"path";import{compileGlobMatcher as n}from"../../utils/globs.js";const m=new WeakMap,i=(o,e)=>{if(e.length===0)return!1;let t=m.get(e);return t||(t=n(e.map(r=>c.posix.normalize(r))),m.set(e,t)),t(o)};export{i as isPartial};
@@ -0,0 +1,7 @@
1
+ import type { Node } from '@markdoc/markdoc';
2
+ type ParseMarkdownFn = (content: string) => Node;
3
+ /** Parse each `{% markdoc-example %}` fence body onto the fence, out of the page tree. */
4
+ export declare function reparseExampleFences(ast: Node, parseMarkdown: ParseMarkdownFn): void;
5
+ export declare function exampleContentTrees(ast: Node): Node[];
6
+ export {};
7
+ //# sourceMappingURL=reparse-example-fences.d.ts.map
@@ -0,0 +1 @@
1
+ import{EXAMPLE_CONTENT_ATTRIBUTE as s}from"@redocly/theme/core/constants";import{isExampleNode as l}from"../../../../markdoc/helpers/guards/is-example-node.js";import{isFenceNode as a}from"../../../../markdoc/helpers/guards/is-fence-node.js";const u="no-inline-annotations";function p(o,n){for(const e of c(o)){if(!e.children.length)continue;const{content:t}=e.attributes;if(typeof t!="string")continue;const i=n(t),f=(e.lines[0]??0)+1;for(const r of i.children)m(r,f);e.children=[],e.slots={},e.errors=e.errors.filter(r=>r.id!==u),e.attributes[s]=i,p(i,n)}}function d(o){const n=[];for(const e of c(o)){const t=e.attributes[s];t&&n.push(t,...d(t))}return n}function*c(o){for(const n of o.walk()){if(!l(n))continue;const[e]=n.children;a(e)&&(yield e)}}function m(o,n){for(const e of[o,...o.walk()]){e.lines=e.lines.map(i=>i+n);const{location:t}=e;t&&(typeof t.start?.line=="number"&&(t.start.line+=n),typeof t.end?.line=="number"&&(t.end.line+=n))}}export{d as exampleContentTrees,p as reparseExampleFences};
@@ -1,2 +1,2 @@
1
- import p from"node:path";import _ from"is-glob";import{slash as $}from"../../../../utils/path/slash.js";import{reporter as d}from"../../../tools/notifiers/reporter.js";import{convertGlobToRegex as h}from"../../../utils/index.js";import{formatMarkdocError as k}from"../errors.js";import{isPartial as E}from"../is-partial.js";const b=/\{\% ?raw-partial file="([^"]+)" ?\/?\%\}/gm,y=async(t,a,i=[],o,l=[a])=>{for(const s of i){const r=_(s)?h(s):new RegExp(`^${s}/`);await o.fs.scan(r)}const n=[],f=t.replace(b,(s,r)=>(n.push(u(s,r)),"_$redocly$"+(n.length-1)+"$")),w=await Promise.all(n);return f.replace(/_\$redocly\$(\d+)\$/g,(s,r)=>w[+r]);async function u(s,r){const e=r.startsWith("/")?r.slice(1):$(p.relative(o.fs.cwd,p.resolve(o.fs.cwd,p.dirname(a),r)));if(l.includes(e)){const c=[...l,e];return await d.panicOnBuildContentError(`Circular reference chain detected when processing raw partials: ${c.map(()=>"%rp").join(" -> ")}`,...c),""}const m=!o.fs.exists(e),g=!e.endsWith(".md")||await o.isPathIgnored(e)||!E(e,i);if(m||g){const R={type:"resolve_link",lines:[1,t.split(`
1
+ import p from"node:path";import _ from"is-glob";import{slash as $}from"../../../../utils/path/slash.js";import{reporter as d}from"../../../tools/notifiers/reporter.js";import{convertGlobToRegex as h}from"../../../utils/index.js";import{formatMarkdocError as k}from"../errors.js";import{isPartial as E}from"../is-partial.js";const b=/\{% ?raw-partial file="([^"]+)" ?\/?%\}/gm,y=async(t,a,i=[],o,l=[a])=>{for(const s of i){const r=_(s)?h(s):new RegExp(`^${s}/`);await o.fs.scan(r)}const n=[],f=t.replace(b,(s,r)=>(n.push(u(s,r)),"_$redocly$"+(n.length-1)+"$")),w=await Promise.all(n);return f.replace(/_\$redocly\$(\d+)\$/g,(s,r)=>w[+r]);async function u(s,r){const e=r.startsWith("/")?r.slice(1):$(p.relative(o.fs.cwd,p.resolve(o.fs.cwd,p.dirname(a),r)));if(l.includes(e)){const c=[...l,e];return await d.panicOnBuildContentError(`Circular reference chain detected when processing raw partials: ${c.map(()=>"%rp").join(" -> ")}`,...c),""}const m=!o.fs.exists(e),g=!e.endsWith(".md")||await o.isPathIgnored(e)||!E(e,i);if(m||g){const R={type:"resolve_link",lines:[1,t.split(`
2
2
  `).length],meta:{rawLink:r,link:e},error:{id:"error",level:"error",message:m?"Raw partial file does not exist":"Could not resolve raw partial. Starting with 0.73.0 version all partials should be placed in partials folders"}};return d.reportMarkdocProblem(k(R,a,t)),""}const v=await o.fs.read(e);return await y(v,e,i,o,[...l,e])}};export{y as resolveRawPartials};
@@ -1 +1 @@
1
- import b from"@markdoc/markdoc";import{isTag as f}from"../../../markdoc/helpers/guards/is-tag.js";import{slugger as l}from"../../utils/index.js";import{getMarkdocOptions as h}from"./markdoc/markdoc-options.js";import{visit as k,getHeadingData as D,getNumberedItemHeadingData as H}from"./markdoc/plugins/utils.js";import{renderDiagramsWithVariants as v}from"./markdoc/plugins/render-diagrams.js";import{deepStringify as y}from"./markdoc/utils/deep-stringify.js";import{stringifyTagChildrenObjects as T}from"./utils/stringify-tag-children-objects.js";async function _(p,t,g){const u=await h(g),e=[],a=[],s=y(t.variables?.pageProps),{headers:w,...c}=t.variables||{};l.reset();const o=b.transform(p,{...u,...t,variables:{...c,pageProps:s}});let m=0;k(o,r=>{if(f(r)){switch(r.name){case"Heading":r.attributes.__idx=m,m++;const n=D(r);n&&e.push(n);break;case"NumberedItem":const d=H(r);d&&e.push(d);break;case"Diagram":a.push({tag:r,input:{type:r.attributes.diagramType,source:r.attributes.diagramSource}});break}T(r)}});const i=await v(a.map(r=>r.input));for(let r=0;r<a.length;r++)a[r].tag.attributes.diagramError=i[r].error,a[r].tag.attributes.diagramHtml=i[r].light,a[r].tag.attributes.diagramHtmlDark=i[r].dark;return{headings:e,renderableAst:o,pageProps:s}}export{_ as transformMdAst};
1
+ import c from"@markdoc/markdoc";import{isTag as b}from"../../../markdoc/helpers/guards/is-tag.js";import{slugger as f}from"../../utils/index.js";import{getMarkdocOptions as l}from"./markdoc/markdoc-options.js";import{visit as h,getHeadingData as k,getNumberedItemHeadingData as D}from"./markdoc/plugins/utils.js";import{renderDiagramsWithVariants as H}from"./markdoc/plugins/render-diagrams.js";import{deepStringify as v}from"./markdoc/utils/deep-stringify.js";import{stringifyTagChildrenObjects as y}from"./utils/stringify-tag-children-objects.js";async function S(d,e,p){const g=await l(p),i=[],a=[],o=v(e.variables?.pageProps),{headers:T,...u}=e.variables||{};f.reset();const m=c.transform(d,{...g,...e,variables:{...u,pageProps:o}});let n=0;h(m,r=>{if(b(r)){switch(r.name){case"Heading":{r.attributes.__idx=n,n++;const t=k(r);t&&i.push(t);break}case"NumberedItem":{const t=D(r);t&&i.push(t);break}case"Diagram":a.push({tag:r,input:{type:r.attributes.diagramType,source:r.attributes.diagramSource}});break}y(r)}});const s=await H(a.map(r=>r.input));for(let r=0;r<a.length;r++)a[r].tag.attributes.diagramError=s[r].error,a[r].tag.attributes.diagramHtml=s[r].light,a[r].tag.attributes.diagramHtmlDark=s[r].dark;return{headings:i,renderableAst:m,pageProps:o}}export{S as transformMdAst};
@@ -1,29 +1,29 @@
1
- import{isPrimitive as S}from"../../../../utils/guards/is-primitive.js";import{getNodeAttribute as c}from"../../../../markdoc/helpers/get-node-attribute.js";import{getVariable as v}from"../../../../markdoc/helpers/get-variable.js";import{isTag as A}from"../../../../markdoc/helpers/guards/is-tag.js";import{isNode as C}from"../../../../markdoc/helpers/guards/is-node.js";import{isConditionalNode as N}from"../../../../markdoc/helpers/guards/is-conditional-node.js";import{isVariable as y}from"../../../../markdoc/helpers/guards/is-variable.js";import{isExampleNode as B}from"../../../../markdoc/helpers/guards/is-example-node.js";import{isFenceNode as E}from"../../../../markdoc/helpers/guards/is-fence-node.js";function a(s,n={}){const r=[];for(const e of s){if(S(e)){const i=n.isTrim?m(String(e)):String(e);i&&r.push(i)}else if(C(e))switch(e.type){case"text":r.push(a([c(e,"content")],n));break;case"code":r.push(`\`${a([c(e,"content")],n)}\``);break;case"blockquote":r.push(`> ${a(e.children,n)}
2
- `);break;case"fence":const i=c(e,"process")===!1;r.push(g(e,n,i));break;case"list":const h=c(e,"ordered")||!1,l=c(e,"marker"),d=e.children.map((t,o)=>`${" ".repeat((n?.indent??0)*2)}${h?o+1:""}${l} ${a([t],{...n??{},indent:(n?.indent??0)+1})}`);r.push(`${d.join("")}
3
- `);break;case"item":r.push(e.children.map(t=>`${a([t],n).trimEnd()}
4
- `).join(""));break;case"thead":const u=e.children.map(t=>a([t],n));r.push(`${u}| ${" --- |".repeat(e.children?.[0]?.children.length)}
5
- `);break;case"tr":const f=e.children.map(t=>a([t],n));r.push(`| ${f.join(" | ")} |
6
- `);break;case"em":r.push(`*${a(e.children,n)}*`);break;case"strong":r.push(`**${a(e.children,n)}**`);break;case"softbreak":case"hardbreak":r.push(`
7
- `);break;case"hr":r.push(`
1
+ import{isPrimitive as m}from"../../../../utils/guards/is-primitive.js";import{getNodeAttribute as c}from"../../../../markdoc/helpers/get-node-attribute.js";import{getVariable as f}from"../../../../markdoc/helpers/get-variable.js";import{isTag as $}from"../../../../markdoc/helpers/guards/is-tag.js";import{isNode as g}from"../../../../markdoc/helpers/guards/is-node.js";import{isConditionalNode as p}from"../../../../markdoc/helpers/guards/is-conditional-node.js";import{isVariable as k}from"../../../../markdoc/helpers/guards/is-variable.js";import{isExampleNode as b}from"../../../../markdoc/helpers/guards/is-example-node.js";import{isFenceNode as T}from"../../../../markdoc/helpers/guards/is-fence-node.js";function a(s,r={}){const t=[];for(const e of s){if(m(e)){const n=r.isTrim?d(String(e)):String(e);n&&t.push(n)}else if(g(e))switch(e.type){case"text":t.push(a([c(e,"content")],r));break;case"code":t.push(`\`${a([c(e,"content")],r)}\``);break;case"blockquote":t.push(`> ${a(e.children,r)}
2
+ `);break;case"fence":{const n=c(e,"process")===!1;t.push(u(e,r,n));break}case"list":{const n=c(e,"ordered")||!1,i=c(e,"marker"),l=e.children.map((o,h)=>`${" ".repeat((r?.indent??0)*2)}${n?h+1:""}${i} ${a([o],{...r??{},indent:(r?.indent??0)+1})}`);t.push(`${l.join("")}
3
+ `);break}case"item":t.push(e.children.map(n=>`${a([n],r).trimEnd()}
4
+ `).join(""));break;case"thead":{const n=e.children.map(i=>a([i],r));t.push(`${n}| ${" --- |".repeat(e.children?.[0]?.children.length)}
5
+ `);break}case"tr":{const n=e.children.map(i=>a([i],r));t.push(`| ${n.join(" | ")} |
6
+ `);break}case"em":t.push(`*${a(e.children,r)}*`);break;case"strong":t.push(`**${a(e.children,r)}**`);break;case"softbreak":case"hardbreak":t.push(`
7
+ `);break;case"hr":t.push(`
8
8
 
9
9
  ---
10
10
 
11
- `);break;case"heading":const p=c(e,"level")??0;r.push(`${"#".repeat(p)} ${a(e.children,n)}
12
- `);break;case"image":const k=c(e,"alt")||"",b=c(e,"src")||"";r.push(`![${k}](${b})`);break;case"link":const T=c(e,"href")||"";r.push(`[${a(e.children,n)}](${T})`);break;case"paragraph":case"table":r.push(`${a(e.children,n)}
13
- `);break;case"tag":if(N(e)&&n.skipConditionals)continue;if(B(e)){r.push(...e.children.map(t=>{if(E(t)){const o=c(t,"process")!==!0;return g(t,n,o)}return a([t],n)}));continue}if(e.tag==="code-snippet"){const t=c(e,"rawContent");if(t){const o=c(e,"language"),$=c(e,"title"),j=`
14
- \`\`\`${`${o||""}${$?`${o?" ":""}${$}`:""}`}
15
- ${t.trimEnd()}
11
+ `);break;case"heading":{const n=c(e,"level")??0;t.push(`${"#".repeat(n)} ${a(e.children,r)}
12
+ `);break}case"image":{const n=c(e,"alt")||"",i=c(e,"src")||"";t.push(`![${n}](${i})`);break}case"link":{const n=c(e,"href")||"";t.push(`[${a(e.children,r)}](${n})`);break}case"paragraph":case"table":t.push(`${a(e.children,r)}
13
+ `);break;case"tag":if(p(e)&&r.skipConditionals)continue;if(b(e)){t.push(...e.children.map(n=>{if(T(n)){const i=c(n,"process")!==!0;return u(n,r,i)}return a([n],r)}));continue}if(e.tag==="code-snippet"){const n=c(e,"rawContent");if(n){const i=c(e,"language"),l=c(e,"title"),h=`
14
+ \`\`\`${`${i||""}${l?`${i?" ":""}${l}`:""}`}
15
+ ${n.trimEnd()}
16
16
  \`\`\`
17
- `;r.push(j)}continue}if(e.tag==="json-example"){const t=w(e);t&&r.push(t);continue}if(e.tag==="json-schema"){const t=x(e);t&&r.push(t);continue}if(n.renderTag){const t=n.renderTag(e,{getBody:()=>a(e.children,n)});if(t!==void 0){r.push(t);continue}}r.push(`${a(e.children,n)}`);break;default:r.push(a(e.children,n));break}else A(e)&&r.push(a(e.children,n));y(e)&&r.push(a([v(e,n.variables)],n))}return n.isTrim?m(r.map(e=>m(e)).join("")):r.join("")}function m(s){return s.replace(/^[ \t\r\f]+|[ \t\r\f]+$/g,"")}function g(s,n={},r=!1){const e=c(s,"title"),i=c(s,"language"),h=`${i||""}${e?`${i?" ":""}${e}`:""}`,l=r?(c(s,"content")||"").trimEnd():a(s.children,n).trimEnd();return`
18
- \`\`\`${h}
17
+ `;t.push(h)}continue}if(e.tag==="json-example"){const n=j(e);n&&t.push(n);continue}if(e.tag==="json-schema"){const n=S(e);n&&t.push(n);continue}if(r.renderTag){const n=r.renderTag(e,{getBody:()=>a(e.children,r)});if(n!==void 0){t.push(n);continue}}t.push(`${a(e.children,r)}`);break;default:t.push(a(e.children,r));break}else $(e)&&t.push(a(e.children,r));k(e)&&t.push(a([f(e,r.variables)],r))}return r.isTrim?d(t.map(e=>d(e)).join("")):t.join("")}function d(s){return s.replace(/^[ \t\r\f]+|[ \t\r\f]+$/g,"")}function u(s,r={},t=!1){const e=c(s,"title"),n=c(s,"language"),i=`${n||""}${e?`${n?" ":""}${e}`:""}`,l=t?(c(s,"content")||"").trimEnd():a(s.children,r).trimEnd();return`
18
+ \`\`\`${i}
19
19
  ${l}
20
20
  \`\`\`
21
- `}function w(s){const n=c(s,"json")??c(s,"valueResolved")??c(s,"schemaResolved"),r=c(s,"title");return n===null?null:`
22
- \`\`\`${`json${r?` ${r}`:""}`}
23
- ${JSON.stringify(n,null,2)}
21
+ `}function j(s){const r=c(s,"json")??c(s,"valueResolved")??c(s,"schemaResolved"),t=c(s,"title");return r===null?null:`
22
+ \`\`\`${`json${t?` ${t}`:""}`}
23
+ ${JSON.stringify(r,null,2)}
24
24
  \`\`\`
25
- `}function x(s){const n=c(s,"schemaResolved");if(n===null)return null;const r=c(s,"title"),{components:e,openapi:i,...h}=n,{__root:l,...d}=e?.schemas||{},u=l?{...l,...Object.keys(d).length>0?{components:{schemas:d}}:{},...h}:n;return`
26
- \`\`\`${`json${r?` ${r}`:""}`}
27
- ${JSON.stringify(u,null,2)}
25
+ `}function S(s){const r=c(s,"schemaResolved");if(r===null)return null;const t=c(s,"title"),{components:e,openapi:n,...i}=r,{__root:l,...o}=e?.schemas||{},h=l?{...l,...Object.keys(o).length>0?{components:{schemas:o}}:{},...i}:r;return`
26
+ \`\`\`${`json${t?` ${t}`:""}`}
27
+ ${JSON.stringify(h,null,2)}
28
28
  \`\`\`
29
29
  `}export{a as toMarkdown};
@@ -1,4 +1,5 @@
1
- import{getCallableApis as n,isFetchCapable as o}from"../../../gateway-mcp/callable-apis.js";import{FETCH_TOOL_NAME as i}from"../../constants.js";const c=["```ts","/**"," * Call a documented API. Only the callable APIs' documented hosts are reachable."," * Responses cap at 1 MiB and redirects are not followed."," */","declare function fetch(url: string | URL, init?: {"," method?: string;"," /** `content-type` is set automatically for URLSearchParams/FormData unless you set one. */"," headers?: Record<string, string>;"," /** string \xB7 URLSearchParams (\u2192 application/x-www-form-urlencoded) \xB7 FormData (\u2192 multipart/form-data) */"," body?: string | URLSearchParams | FormData;"," /** Security scheme name (from the operation's `security` or `getSecuritySchemes`) whose credential to send. Omit to let the server choose. */"," securityScheme?: string;","}): Promise<{"," status: number;"," statusText: string;"," ok: boolean;"," headers: { get(name: string): string | null };"," json(): Promise<unknown>;"," text(): Promise<string>;","}>;","```"].join(`
2
- `),l=["Example - list the paid invoices of a billing API:","","```ts","const { items } = await tools.listApis({ filter: 'billing' });","const [api] = items;",`if (!api) return { error: 'no API matches "billing"' };`,"const { endpoints } = await tools.getEndpoints({ name: api.name });","const ep = endpoints.find((e) => e.method === 'GET' && e.path.includes('invoices'));","const info = await tools.getEndpointInfo({ name: api.name, path: ep.path, method: ep.method });","const url = new URL((info.servers?.[0]?.url ?? '') + ep.path);","// Every name below comes from `info.endpoint.parameters` - read them first, never guess them.","url.searchParams.set('filter', 'status:paid');","url.searchParams.set('sort', '-createdTime');","url.searchParams.set('limit', '100');","try {"," const res = await fetch(url, { method: ep.method });"," return res.ok ? await res.json() : { status: res.status, error: await res.text() };","} catch (error) {"," return { error: error instanceof Error ? error.message : String(error), endpointId: info };","}","```"].join(`
3
- `);function m(s){const t=new Map;for(const{name:e,version:r}of s){if(!e)continue;const a=t.get(e)??[];r&&a.push(r),t.set(e,a)}return[...t.entries()].map(([e,r])=>r.length>1?`${e} (${r.map(a=>`v${a}`).join(", ")})`:e).join(", ")}const p={id:i,purpose:"Call the documented APIs over HTTP",isActive:o,annotations:{readOnlyHint:!1,destructiveHint:!0,openWorldHint:!0},renderSection(s){const t=m(n(s));return["## `fetch` \u2014 call the documented APIs","",c,"","Always call `getEndpointInfo` before `fetch` for the exact URL, required parameters, and body shape. Put filtering, sorting, and paging in the query parameters, and keep sandbox JS for what the endpoint cannot express. Never guess.","","When an operation accepts more than one security scheme, pass `securityScheme` with the scheme name the user holds a credential for; without it the server picks one, and a mismatched credential fails upstream.","",`Callable APIs (their documented hosts are reachable via \`fetch\`): ${t}`,"",l].join(`
4
- `)}};export{c as FETCH_DECLARATION,p as fetchCapability};
1
+ import{getCallableApis as n,isFetchCapable as o}from"../../../gateway-mcp/callable-apis.js";import{FETCH_TOOL_NAME as i}from"../../constants.js";const l=["```ts","/**"," * Call a documented API. Only the callable APIs' documented hosts are reachable."," * Responses cap at 1 MiB and redirects are not followed."," */","declare function fetch(url: string | URL, init?: {"," method?: string;"," /** `content-type` is set automatically for URLSearchParams/FormData unless you set one. */"," headers?: Record<string, string>;"," /** string \xB7 URLSearchParams (\u2192 application/x-www-form-urlencoded) \xB7 FormData (\u2192 multipart/form-data) */"," body?: string | URLSearchParams | FormData;"," /** Security scheme name (from the operation's `security` or `getSecuritySchemes`) whose credential to send. Omit to let the server choose. */"," securityScheme?: string;","}): Promise<{"," status: number;"," statusText: string;"," ok: boolean;"," headers: { get(name: string): string | null };"," json(): Promise<unknown>;"," text(): Promise<string>;","}>;","```"].join(`
2
+ `),c=["listApis","getEndpoints","getEndpointInfo"],h=["Example - list the paid invoices of a billing API:","","```ts","const { items } = await tools.listApis({ filter: 'billing' });","const [api] = items;",`if (!api) return { error: 'no API matches "billing"' };`,"const { endpoints } = await tools.getEndpoints({ name: api.name });","const ep = endpoints.find((e) => e.method === 'GET' && e.path.includes('invoices'));","const info = await tools.getEndpointInfo({ name: api.name, path: ep.path, method: ep.method });","// Replace every `{placeholder}` first.","const url = new URL((info.servers?.[0]?.url ?? '') + ep.path);","// Every name below comes from `info.endpoint.parameters` - read them first, never guess them.","url.searchParams.set('filter', 'status:paid');","url.searchParams.set('sort', '-createdTime');","url.searchParams.set('limit', '100');","try {"," const res = await fetch(url, { method: ep.method });"," return res.ok ? await res.json() : { status: res.status, error: await res.text() };","} catch (error) {"," return { error: error instanceof Error ? error.message : String(error), endpointId: info };","}","```"].join(`
3
+ `),p=["Example - call an endpoint you already read:","","```ts","// Call `getEndpointInfo` first for the server URL, the path, and the parameter names.","// Replace every `{placeholder}` first.","const url = new URL('https://api.example.com/invoices');","url.searchParams.set('filter', 'status:paid');","try {"," const res = await fetch(url, { method: 'GET' });"," return res.ok ? await res.json() : { status: res.status, error: await res.text() };","} catch (error) {"," return { error: error instanceof Error ? error.message : String(error) };","}","```"].join(`
4
+ `);function m(r){return c.every(t=>r.includes(t))?h:p}function d(r){const t=new Map;for(const{name:e,version:a}of r){if(!e)continue;const s=t.get(e)??[];a&&s.push(a),t.set(e,s)}return[...t.entries()].map(([e,a])=>a.length>1?`${e} (${a.map(s=>`v${s}`).join(", ")})`:e).join(", ")}const g={id:i,purpose:"Call the documented APIs over HTTP",isActive:o,annotations:{readOnlyHint:!1,destructiveHint:!0,openWorldHint:!0},renderSection(r,t){const e=d(n(r));return["## `fetch` \u2014 call the documented APIs","",l,"","Always call `getEndpointInfo` before `fetch` for the exact URL, required parameters, and body shape. Put filtering, sorting, and paging in the query parameters, and keep sandbox JS for what the endpoint cannot express. Never guess.","","A `servers[].url` or an endpoint path can hold `{placeholders}`. Replace every one before you call `fetch`. Use the server variable `default`. Ask the user when the `default` only repeats the variable name, such as `{organizationId}`.","","When an operation accepts more than one security scheme, pass `securityScheme` with the scheme name the user holds a credential for; without it the server picks one, and a mismatched credential fails upstream.","",`Callable APIs (their documented hosts are reachable via \`fetch\`): ${e}`,"",m(t)].join(`
5
+ `)}};export{l as FETCH_DECLARATION,g as fetchCapability};
@@ -8,7 +8,10 @@ export type SandboxCapability = {
8
8
  isActive(context: McpToolContext): boolean;
9
9
  /** How this capability changes `execute`'s MCP annotations when active. */
10
10
  annotations: Partial<ToolAnnotations>;
11
- /** The self-contained `describe-tools` section for this capability: heading, TS declaration, guidance, and example. */
12
- renderSection(context: McpToolContext): string;
11
+ /**
12
+ * The self-contained `describe-tools` section for this capability: heading, TS declaration,
13
+ * guidance, and an example built only from `describedToolNames`.
14
+ */
15
+ renderSection(context: McpToolContext, describedToolNames: string[]): string;
13
16
  };
14
17
  //# sourceMappingURL=types.d.ts.map
@@ -1,7 +1,7 @@
1
- import{buildToolTypeDeclarations as i}from"../build-tool-type-declarations.js";import{EXECUTE_BASE_ANNOTATIONS as E}from"../tools/execute-schema.js";import{EXECUTE_ARGS_NOTE as p,PLAIN_EXECUTE_EXAMPLE as s,USAGE_NOTES as u}from"../prompts.js";import{FETCH_TOOL_NAME as c}from"../constants.js";import{ALL_CAPABILITIES as A}from"./registry.js";function S(o){return A.filter(n=>n.isActive(o))}function l(o){return o.reduce((n,e)=>({...n,...e.annotations}),{...E})}function N(o,n,e){const t=[];o.length>0&&t.push(`## Sandbox tools
1
+ import{buildToolTypeDeclarations as c,sanitizeToolName as p}from"../build-tool-type-declarations.js";import{EXECUTE_BASE_ANNOTATIONS as u}from"../tools/execute-schema.js";import{buildExecuteExample as m,EXECUTE_ARGS_NOTE as a,USAGE_NOTES as E}from"../prompts.js";import{FETCH_TOOL_NAME as f}from"../constants.js";import{ALL_CAPABILITIES as A}from"./registry.js";function S(n){return A.filter(e=>e.isActive(n))}function _(n){return n.reduce((e,i)=>({...e,...i.annotations}),{...u})}function x(n,e,i){const r=n.map(o=>p(o.name)),t=[];if(n.length>0){const o=c(n),s=o.includes("OpenApi")?`
2
2
 
3
- ${i(o)}
3
+ ${E}`:"";t.push(`## Sandbox tools
4
4
 
5
- ${u}`),t.push(p),o.length>0&&!n.some(r=>r.id===c)&&t.push(s);for(const r of n)t.push(r.renderSection(e));return t.join(`
5
+ ${o}${s}`)}t.push(a),n.length>0&&!e.some(o=>o.id===f)&&t.push(m(r));for(const o of e)t.push(o.renderSection(i,r));return t.join(`
6
6
 
7
- `)}export{l as composeExecuteAnnotations,S as getActiveCapabilities,N as renderDescribeToolsOutput};
7
+ `)}export{_ as composeExecuteAnnotations,S as getActiveCapabilities,x as renderDescribeToolsOutput};
@@ -1 +1 @@
1
- import{auditInput as e,logAuditRecord as l}from"../audit/audit-log.js";function h({audit:o,code:t,description:c,sessionHandle:n,toolNames:d,fetchBudget:i,fetchCapable:s}){l("Record code execution input",{code_sha256:o.sha256,code_length:o.length,flags:o.flags,session_handle:n,description:e(c),tools:[...d].sort().join(","),fetch_capable:s,fetch_budget:i,code:e(t)})}export{h as logCodeExecutionAudit};
1
+ import{auditInput as t,auditSha256 as h,logAuditRecord as a}from"../audit/audit-log.js";function g({audit:e,code:c,description:d,sessionHandle:o,toolNames:i,fetchBudget:n,fetchCapable:u}){a("Record code execution input",{code_sha256:e.sha256,code_length:e.length,flags:e.flags,subject_sha256:o?h(o):void 0,description:t(d),tools:[...i].sort().join(","),fetch_capable:u,fetch_budget:n,code:t(c)})}export{g as logCodeExecutionAudit};
@@ -1,13 +1,18 @@
1
+ import { telemetry } from '../../../telemetry/index.js';
1
2
  import type { CodeAudit } from './code-audit.js';
3
+ type CodeExecutedData = Parameters<typeof telemetry.sendMcpCodeExecutedMessage>[0][number];
4
+ export type McpCodeFailureReason = NonNullable<CodeExecutedData['failure_reason']>;
2
5
  type CodeExecutedEvent = {
3
6
  audit: CodeAudit;
4
7
  fetchCount: number;
5
- outcome: 'ok' | 'error';
8
+ outcome: CodeExecutedData['outcome'];
6
9
  durationMs: number;
10
+ failureReason?: McpCodeFailureReason;
11
+ failedTool?: string;
7
12
  client?: string;
8
13
  clientVersion?: string;
9
14
  };
10
15
  /** Audit record for one sandbox run. Carries the code fingerprint, never the code. */
11
- export declare function reportCodeExecuted({ audit, fetchCount, outcome, durationMs, client, clientVersion, }: CodeExecutedEvent): void;
16
+ export declare function reportCodeExecuted({ audit, fetchCount, outcome, durationMs, failureReason, failedTool, client, clientVersion, }: CodeExecutedEvent): void;
12
17
  export {};
13
18
  //# sourceMappingURL=code-execution-telemetry.d.ts.map
@@ -1 +1 @@
1
- import{telemetry as f}from"../../../telemetry/index.js";import{logger as g}from"../../../tools/notifiers/logger.js";import{McpServerType as l}from"../constants.js";import{serverAttributes as n}from"../utils/telemetry-attributes.js";function $({audit:e,fetchCount:o,outcome:r,durationMs:t,client:c,clientVersion:s}){try{f.sendMcpCodeExecutedMessage([{...n(l.Docs),code_sha256:e.sha256,code_length:e.length,fetch_count:o,outcome:r,flags:e.flags,duration_ms:t,client:c,client_version:s}])}catch{}g.info(`Gateway MCP code executed [${e.sha256.slice(0,12)}] outcome=${r} codeLength=${e.length} fetchCount=${o}`+(e.flags?` flags=${e.flags}`:"")+` durationMs=${t}`)}export{$ as reportCodeExecuted};
1
+ import{telemetry as l}from"../../../telemetry/index.js";import{logger as n}from"../../../tools/notifiers/logger.js";import{McpServerType as m}from"../constants.js";import{serverAttributes as h}from"../utils/telemetry-attributes.js";function d({audit:e,fetchCount:t,outcome:c,durationMs:s,failureReason:o,failedTool:r,client:f,clientVersion:g}){try{l.sendMcpCodeExecutedMessage([{...h(m.Docs),code_sha256:e.sha256,code_length:e.length,fetch_count:t,outcome:c,flags:e.flags,duration_ms:s,failure_reason:o,failed_tool:r,client:f,client_version:g}])}catch{}n.info(`Gateway MCP code executed [${e.sha256.slice(0,12)}] outcome=${c} codeLength=${e.length} fetchCount=${t}`+(e.flags?` flags=${e.flags}`:"")+` durationMs=${s}`+(o?` failureReason=${o}`:"")+(r?` failedTool=${r}`:""))}export{d as reportCodeExecuted};