@redocly/revel 0.137.0 → 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 (120) hide show
  1. package/CHANGELOG.md +32 -2
  2. package/dist/bin.js +1 -1
  3. package/dist/cli/eject/themeOperations.js +1 -1
  4. package/dist/cli/generate/generate-tag.js +1 -1
  5. package/dist/cli/generate/generate.js +1 -1
  6. package/dist/client/app/hooks/catalog/useCatalog.d.ts +1 -2
  7. package/dist/client/app/l10n/hooks/useL10n.js +1 -1
  8. package/dist/client/app/l10n/index.js +1 -1
  9. package/dist/client/app/search/sse-parser.d.ts +5 -2
  10. package/dist/client/app/search/sse-parser.js +2 -2
  11. package/dist/client/constants/ai-search.d.ts +8 -0
  12. package/dist/client/constants/ai-search.js +1 -1
  13. package/dist/constants/l10n/langs/ar.js +1 -1
  14. package/dist/constants/l10n/langs/de.js +1 -1
  15. package/dist/constants/l10n/langs/en.js +1 -1
  16. package/dist/constants/l10n/langs/es.js +1 -1
  17. package/dist/constants/l10n/langs/fr.js +1 -1
  18. package/dist/constants/l10n/langs/hi.js +1 -1
  19. package/dist/constants/l10n/langs/it.js +1 -1
  20. package/dist/constants/l10n/langs/ja.js +1 -1
  21. package/dist/constants/l10n/langs/ko.js +1 -1
  22. package/dist/constants/l10n/langs/pl.js +1 -1
  23. package/dist/constants/l10n/langs/pt-BR.js +1 -1
  24. package/dist/constants/l10n/langs/pt.js +1 -1
  25. package/dist/constants/l10n/langs/ru.js +1 -1
  26. package/dist/constants/l10n/langs/uk.js +1 -1
  27. package/dist/constants/l10n/langs/zh.js +1 -1
  28. package/dist/markdoc/helpers/guards/is-example-node.d.ts +2 -1
  29. package/dist/markdoc/helpers/guards/is-example-node.js +1 -1
  30. package/dist/markdoc/nodes/fence/index.js +1 -1
  31. package/dist/server/constants/entitlements.d.ts +1 -2
  32. package/dist/server/esbuild/plugins/styled-components-ssr.js +1 -1
  33. package/dist/server/esbuild/plugins/themes-resolver.js +2 -2
  34. package/dist/server/fs/cache.js +1 -1
  35. package/dist/server/fs/fs.js +1 -1
  36. package/dist/server/fs/utils/remove-l10n-prefix.js +1 -1
  37. package/dist/server/persistence/file-hashes/repositories/file-hashes-repository.d.ts +1 -2
  38. package/dist/server/persistence/file-hashes/services/file-hashes-service.d.ts +1 -2
  39. package/dist/server/plugins/analytics/rudderstack/browser-hooks.js +1 -1
  40. package/dist/server/plugins/analytics/segment/browser-hooks.js +1 -1
  41. package/dist/server/plugins/analytics/segment/build-script.js +3 -3
  42. package/dist/server/plugins/api-docs/loader.d.ts +2 -3
  43. package/dist/server/plugins/api-docs/options.d.ts +1 -1
  44. package/dist/server/plugins/api-docs/search/get-ai-search-documents.d.ts +1 -1
  45. package/dist/server/plugins/api-docs/utils/decorators.js +1 -1
  46. package/dist/server/plugins/api-functions/index.js +1 -1
  47. package/dist/server/plugins/catalog-entities/database/repositories/entities/entities-write-repository.js +1 -1
  48. package/dist/server/plugins/catalog-entities/types/extractors.d.ts +1 -2
  49. package/dist/server/plugins/catalog-entities/utils/openapi-component-content-extractor.d.ts +1 -2
  50. package/dist/server/plugins/catalog-entities/utils/openapi-schema-resolver.d.ts +1 -2
  51. package/dist/server/plugins/config-parser/format-error.js +4 -4
  52. package/dist/server/plugins/l10n/index.js +1 -1
  53. package/dist/server/plugins/lifecycle.js +2 -2
  54. package/dist/server/plugins/markdown/attribute-resolvers/resolve-link.js +1 -1
  55. package/dist/server/plugins/markdown/attribute-resolvers/resolve-svg-content.js +1 -1
  56. package/dist/server/plugins/markdown/compiler.js +1 -1
  57. package/dist/server/plugins/markdown/errors.js +1 -1
  58. package/dist/server/plugins/markdown/markdoc/reparse-example-fences.d.ts +7 -0
  59. package/dist/server/plugins/markdown/markdoc/reparse-example-fences.js +1 -0
  60. package/dist/server/plugins/markdown/markdoc/resolve-raw-partials.js +1 -1
  61. package/dist/server/plugins/markdown/runtime-transform.js +1 -1
  62. package/dist/server/plugins/markdown/search/to-markdown.js +20 -20
  63. package/dist/server/plugins/mcp/codemode/code-execution-telemetry.d.ts +7 -2
  64. package/dist/server/plugins/mcp/codemode/code-execution-telemetry.js +1 -1
  65. package/dist/server/plugins/mcp/codemode/invoke-tool.js +1 -1
  66. package/dist/server/plugins/mcp/codemode/sandbox/unknown-tool-hint.d.ts +5 -1
  67. package/dist/server/plugins/mcp/codemode/sandbox/unknown-tool-hint.js +2 -2
  68. package/dist/server/plugins/mcp/codemode/tools/execute.js +1 -1
  69. package/dist/server/plugins/mcp/codemode/tools/tool-errors.d.ts +4 -0
  70. package/dist/server/plugins/mcp/codemode/tools/tool-errors.js +1 -1
  71. package/dist/server/plugins/mcp/constants.d.ts +1 -0
  72. package/dist/server/plugins/mcp/constants.js +1 -1
  73. package/dist/server/plugins/mcp/docs-mcp/tool-schemas.d.ts +1 -0
  74. package/dist/server/plugins/mcp/docs-mcp/tool-schemas.js +1 -1
  75. package/dist/server/plugins/mcp/docs-mcp/tools/core/submit-feedback.d.ts +7 -0
  76. package/dist/server/plugins/mcp/docs-mcp/tools/core/submit-feedback.js +3 -0
  77. package/dist/server/plugins/mcp/docs-mcp/tools/core/types.d.ts +6 -0
  78. package/dist/server/plugins/mcp/docs-mcp/tools/index.d.ts +1 -0
  79. package/dist/server/plugins/mcp/docs-mcp/tools/index.js +1 -1
  80. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-endpoint-info.js +1 -1
  81. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-endpoints.js +1 -1
  82. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-full-api-description.js +1 -1
  83. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-security-schemes.js +1 -1
  84. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/list-apis.js +1 -1
  85. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/load-api-description.d.ts +16 -4
  86. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/load-api-description.js +1 -1
  87. package/dist/server/plugins/mcp/docs-mcp/utils/api-name-matching.d.ts +6 -1
  88. package/dist/server/plugins/mcp/docs-mcp/utils/api-name-matching.js +1 -1
  89. package/dist/server/plugins/mcp/docs-mcp/utils/api-titles.d.ts +8 -0
  90. package/dist/server/plugins/mcp/docs-mcp/utils/api-titles.js +1 -1
  91. package/dist/server/plugins/mcp/handlers/docs-mcp-handler.js +1 -1
  92. package/dist/server/plugins/mcp/index.js +1 -1
  93. package/dist/server/plugins/nav-utils.js +1 -1
  94. package/dist/server/plugins/search/llmstxt/is-included-in-llms-txt.d.ts +1 -2
  95. package/dist/server/sandbox/constants/host-functions.d.ts +3 -0
  96. package/dist/server/sandbox/constants/host-functions.js +1 -1
  97. package/dist/server/sandbox/constants/sandbox.d.ts +10 -0
  98. package/dist/server/sandbox/constants/sandbox.js +1 -1
  99. package/dist/server/sandbox/sandbox.js +3 -3
  100. package/dist/server/sandbox/types.d.ts +3 -0
  101. package/dist/server/sandbox/utils/read-result.d.ts +8 -0
  102. package/dist/server/sandbox/utils/read-result.js +1 -0
  103. package/dist/server/sandbox/utils/setup-host-functions.js +3 -3
  104. package/dist/server/ssr/index.js +1 -1
  105. package/dist/server/store.d.ts +1 -1
  106. package/dist/server/store.js +1 -1
  107. package/dist/server/tools/notifiers/helpers/privacy/remove-pii.js +1 -1
  108. package/dist/server/types/plugins/common.d.ts +1 -2
  109. package/dist/server/utils/rbac.js +1 -1
  110. package/dist/server/web-server/routes/catalog/helpers/create-entity-update-schema.d.ts +1 -1
  111. package/dist/server/web-server/routes/catalog/helpers/create-entity-update-schema.js +1 -1
  112. package/dist/server/web-server/routes/feedback.d.ts +3 -1
  113. package/dist/server/web-server/routes/feedback.js +1 -1
  114. package/dist/server/web-server/routes/mcp-routes/mcp-oauth.js +1 -1
  115. package/dist/server/web-server/routes/otel/otel.js +1 -1
  116. package/dist/server/web-server/utils/legacy-openapi-redirects.js +1 -1
  117. package/dist/types/global-data.d.ts +1 -2
  118. package/dist/utils/slugger.js +1 -1
  119. package/dist/utils/url/sanitize-redirect-pathname.js +1 -1
  120. package/package.json +4 -4
@@ -1 +1 @@
1
- import{LRUCache as H}from"lru-cache";import{sha1 as M}from"../utils/crypto/sha1.js";import{envConfig as S}from"../config/env-config.js";import{NestedMap as x}from"./utils/nested-map.js";import{trackAccessStore as w}from"./utils/async-storage.js";import{isLoaderCacheEnabled as k}from"./utils/is-loader-cache-enabled.js";import{LoadError as v}from"./load-error.js";import{createLifecycleContext as D}from"../plugins/lifecycle.js";function f(y,t){return y+":"+t}class J{fs;errors=new Map;#t=new Map;#i=new Map;#e=new Map;#s=new Map;#a=new x;#r;#o={};#n=new Map;constructor(t){this.fs=t,this.#r=D(t,this),this.#f()}#c(t){let e=this.#t.get(t);return e||(e=new H({max:S.isBuildMode?1e3:1e6}),this.#t.set(t,e)),e}async load(t,e,i){let s,h;typeof e=="string"?(s=e,h=this.#o[e]):(s=e.name,h=e.loader);const a=f(s,t);if(this.#n.has(a))return this.#n.get(a);const n=i?.join(""),r=n!==void 0?n.length>30?M(n):n:void 0,c=w.getStore()??[],F=!this.#h(t,s,r),p=this.#c(s),g=p.get(t);if(F&&g)return c.push({type:"load",loaderId:s,resource:t,hash:g.compoundHash}),g;const d=Promise.withResolvers();this.#n.set(a,d.promise),r!==void 0&&this.#e.set(a,r);const{status:L,value:l}=await this.#p(t,s,async()=>{let m;const I=w.getStore()||[],u=[],P=o=>u.push(o);try{m=await h(t,this.#r,P),u.length>0?this.errors.set(a,u):this.errors.delete(a)}catch(o){const R=p.get(t)?.data,E=s==="redocly-config"||s==="nearest-redocly-config"?!1:(await this.load(t,"is-ignored")).data;if(!(o instanceof v)&&!E&&this.errors.set(a,[o]),!R)return{status:"error",value:o instanceof v?o:new v(o.message,{cause:o,loaderId:s})};m=R}const C=M(t+(r??"")+I.map(o=>o.hash).join(""));return c.push({type:"load",loaderId:s,resource:t,hash:C}),{status:"success",value:{data:m,compoundHash:C}}});return L==="error"?d.reject(l):(this.#l(t),k(s)&&p.set(t,l),this.#i.set(a,l.compoundHash),d.resolve(l)),this.#n.delete(a),d.promise}setLoaders(t){this.#o={...this.#o,...t}}delete(t,e){if(e){const i=f(e,t);this.#d(t,e),this.errors.delete(i),this.#i.delete(i),this.#e.delete(i);const s=this.#s.get(t);if(s){for(const h of s)this.delete(h,e);this.#s.delete(t)}this.#a.delete(e,t)}else for(const i of this.#t.keys())this.delete(t,i)}#d(t,e){const i=this.#t.get(e);i&&i.delete(t)}#l(t){const[e,i]=t.split("#");if(!i)return;const s=this.#s.get(e);s?s.add(t):this.#s.set(e,new Set([t]))}#f(){this.fs.watch(async t=>{for(const e of t)e.event==="unlink"&&this.delete(e.path)})}#h(t,e,i){const s=f(e,t);return i!==void 0&&this.#e.get(s)!==i?!0:(this.#a.get(e,t)??[]).some(n=>{switch(n.type){case"load":const r=f(n.loaderId,n.resource);return this.#i.get(r)!==n.hash||this.#h(n.resource,n.loaderId,this.#e.get(r));case"read":return n.hash!==this.fs.getFileInfo(n.path)?.hash;case"exists":const c=this.fs.getFileInfo(n.path);return n.hash!==(c&&!c.isVirtual?"t":"f");case"scan":return n.hash!==this.fs.getPatternScanHash(n.pattern)}})}#p(t,e,i){const s=[];return this.#a.set(e,t,s),w.run(s,i)}}export{J as Cache};
1
+ import{LRUCache as H}from"lru-cache";import{sha1 as M}from"../utils/crypto/sha1.js";import{envConfig as S}from"../config/env-config.js";import{NestedMap as x}from"./utils/nested-map.js";import{trackAccessStore as u}from"./utils/async-storage.js";import{isLoaderCacheEnabled as k}from"./utils/is-loader-cache-enabled.js";import{LoadError as w}from"./load-error.js";import{createLifecycleContext as D}from"../plugins/lifecycle.js";function l(v,t){return v+":"+t}class J{fs;errors=new Map;#t=new Map;#i=new Map;#e=new Map;#s=new Map;#a=new x;#r;#o={};#n=new Map;constructor(t){this.fs=t,this.#r=D(t,this),this.#f()}#c(t){let e=this.#t.get(t);return e||(e=new H({max:S.isBuildMode?1e3:1e6}),this.#t.set(t,e)),e}async load(t,e,i){let s,h;typeof e=="string"?(s=e,h=this.#o[e]):(s=e.name,h=e.loader);const a=l(s,t);if(this.#n.has(a))return this.#n.get(a);const n=i?.join(""),o=n!==void 0?n.length>30?M(n):n:void 0,y=u.getStore()??[],F=!this.#h(t,s,o),f=this.#c(s),p=f.get(t);if(F&&p)return y.push({type:"load",loaderId:s,resource:t,hash:p.compoundHash}),p;const c=Promise.withResolvers();this.#n.set(a,c.promise),o!==void 0&&this.#e.set(a,o);const{status:L,value:d}=await this.#p(t,s,async()=>{let g;const I=u.getStore()||[],m=[],P=r=>m.push(r);try{g=await h(t,this.#r,P),m.length>0?this.errors.set(a,m):this.errors.delete(a)}catch(r){const R=f.get(t)?.data,E=s==="redocly-config"||s==="nearest-redocly-config"?!1:(await this.load(t,"is-ignored")).data;if(!(r instanceof w)&&!E&&this.errors.set(a,[r]),!R)return{status:"error",value:r instanceof w?r:new w(r.message,{cause:r,loaderId:s})};g=R}const C=M(t+(o??"")+I.map(r=>r.hash).join(""));return y.push({type:"load",loaderId:s,resource:t,hash:C}),{status:"success",value:{data:g,compoundHash:C}}});return L==="error"?c.reject(d):(this.#l(t),k(s)&&f.set(t,d),this.#i.set(a,d.compoundHash),c.resolve(d)),this.#n.delete(a),c.promise}setLoaders(t){this.#o={...this.#o,...t}}delete(t,e){if(e){const i=l(e,t);this.#d(t,e),this.errors.delete(i),this.#i.delete(i),this.#e.delete(i);const s=this.#s.get(t);if(s){for(const h of s)this.delete(h,e);this.#s.delete(t)}this.#a.delete(e,t)}else for(const i of this.#t.keys())this.delete(t,i)}#d(t,e){const i=this.#t.get(e);i&&i.delete(t)}#l(t){const[e,i]=t.split("#");if(!i)return;const s=this.#s.get(e);s?s.add(t):this.#s.set(e,new Set([t]))}#f(){this.fs.watch(async t=>{for(const e of t)e.event==="unlink"&&this.delete(e.path)})}#h(t,e,i){const s=l(e,t);return i!==void 0&&this.#e.get(s)!==i?!0:(this.#a.get(e,t)??[]).some(n=>{switch(n.type){case"load":{const o=l(n.loaderId,n.resource);return this.#i.get(o)!==n.hash||this.#h(n.resource,n.loaderId,this.#e.get(o))}case"read":return n.hash!==this.fs.getFileInfo(n.path)?.hash;case"exists":{const o=this.fs.getFileInfo(n.path);return n.hash!==(o&&!o.isVirtual?"t":"f")}case"scan":return n.hash!==this.fs.getPatternScanHash(n.pattern)}})}#p(t,e,i){const s=[];return this.#a.set(e,t,s),u.run(s,i)}}export{J as Cache};
@@ -1 +1 @@
1
- import*as f from"chokidar";import h from"path";import*as p from"node:fs/promises";import{createHash as l}from"node:crypto";import{slash as o}from"../../utils/path/slash.js";import{logger as c}from"../tools/notifiers/logger.js";import{sha1 as m}from"../utils/crypto/sha1.js";import{USER_THEME_ALIAS as u,USER_SKILLS_ALIAS as g,USER_SKILL_FILENAME as w}from"../../constants/common.js";import{debouncedEmit as L}from"./utils/debounced-emit.js";import{trackAccessStore as r}from"./utils/async-storage.js";import{removeBom as S}from"./utils/string-utils.js";const E=`${g}(/.*)?`,y=w.replace(".","\\."),v=new RegExp(`^(${E}|${y})$`);class j{cwd;ignored;filesList=new Map;watcher;#t=new Map;#e=[];constructor(t,e=[]){this.cwd=t,this.ignored=e,this.watcher=this.#i()}get ready(){return this.watcher.then(()=>!0)}getFileInfo(t){return this.filesList.get(t)}watch(t){this.#e.push(t)}async dispose(){(await this.watcher).close()}exists(t){const e=this.filesList.has(t);return r.getStore()?.push({type:"exists",path:t,hash:e?"t":"f"}),e}async read(t,e="utf-8"){try{let i=await p.readFile(h.join(this.cwd,t),e);i=S(i);const s=m(i);r.getStore()?.push({type:"read",path:t,hash:s});const a=this.filesList.get(t);return a&&(a.hash=s),i}catch(i){throw r.getStore()?.push({type:"read",path:t,hash:"error"}),i}}scan(t){const e=[],i=l("sha1");this.filesList.forEach(a=>{(!t||t.test(a.relativePath))&&(e.push(a),i.update(a.relativePath))});const s=i.digest("base64");return this.#t.set(t,s),r.getStore()?.push({type:"scan",hash:s,pattern:t}),e}emitCodeUpdated(){this.emit({event:"code-updated"})}addVirtualFile(t,e){this.filesList.set(t,{relativePath:t,realRelativePath:e.realRelativePath,hash:e.hash,isVirtual:!0}),r.getStore()?.push({type:"read",path:t,hash:e.hash??""})}getPatternScanHash(t){return this.#t.get(t)}#s(t){return v.test(t)}emit=L(async t=>{for(const e of t)if(!("path"in e&&this.#s(e.path)))switch(e.event){case"add":this.filesList.set(e.path,{relativePath:e.path,realRelativePath:e.path,hash:void 0,isVirtual:!1});for(const s of this.#t.keys())s&&s.test(e.path)&&this.#t.set(s,void 0),s||this.#t.set(s,void 0);break;case"change":const i=this.filesList.get(e.path);i&&(i.hash=void 0);break;case"unlink":this.filesList.delete(e.path);for(const s of this.#t.keys())s&&s.test(e.path)&&this.#t.delete(s),s||this.#t.delete(s);break}for(const e of this.#e)await e(t)});async#i(){return c.startTiming("init-fs"),new Promise((t,e)=>{const i=f.watch(this.cwd,{usePolling:!1,ignoreInitial:!0,ignored:[new RegExp(`(/.git/|/node_modules/|${u})`),h.join(this.cwd,"public"),h.join(this.cwd,"README.md"),...this.ignored]});i.on("ready",()=>{this.filesList=this.#a(i.getWatched()),t(i),c.infoTime("init-fs","File system scan completed")}).on("error",e).on("add",(s,a)=>{this.emit({event:"add",path:o(h.relative(this.cwd,s)),stats:a})}).on("change",(s,a)=>{this.emit({event:"change",path:o(h.relative(this.cwd,s)),stats:a})}).on("unlink",s=>{this.emit({event:"unlink",path:o(h.relative(this.cwd,s))})})})}#a(t){const e=new Map;for(const i of Object.keys(t))for(const s of t[i]){const a=h.join(i,s);if(t[a])continue;const d=o(h.dirname(h.relative(this.cwd,a))),n=h.posix.join(d,s);this.#s(n)||e.set(n,{relativePath:n,realRelativePath:n,isVirtual:!1,hash:void 0})}return e}}export{j as Fs};
1
+ import*as f from"chokidar";import h from"path";import*as p from"node:fs/promises";import{createHash as l}from"node:crypto";import{slash as o}from"../../utils/path/slash.js";import{logger as c}from"../tools/notifiers/logger.js";import{sha1 as m}from"../utils/crypto/sha1.js";import{USER_THEME_ALIAS as u,USER_SKILLS_ALIAS as g,USER_SKILL_FILENAME as w}from"../../constants/common.js";import{debouncedEmit as L}from"./utils/debounced-emit.js";import{trackAccessStore as r}from"./utils/async-storage.js";import{removeBom as S}from"./utils/string-utils.js";const E=`${g}(/.*)?`,y=w.replace(".","\\."),v=new RegExp(`^(${E}|${y})$`);class j{cwd;ignored;filesList=new Map;watcher;#t=new Map;#e=[];constructor(t,e=[]){this.cwd=t,this.ignored=e,this.watcher=this.#i()}get ready(){return this.watcher.then(()=>!0)}getFileInfo(t){return this.filesList.get(t)}watch(t){this.#e.push(t)}async dispose(){(await this.watcher).close()}exists(t){const e=this.filesList.has(t);return r.getStore()?.push({type:"exists",path:t,hash:e?"t":"f"}),e}async read(t,e="utf-8"){try{let s=await p.readFile(h.join(this.cwd,t),e);s=S(s);const i=m(s);r.getStore()?.push({type:"read",path:t,hash:i});const a=this.filesList.get(t);return a&&(a.hash=i),s}catch(s){throw r.getStore()?.push({type:"read",path:t,hash:"error"}),s}}scan(t){const e=[],s=l("sha1");this.filesList.forEach(a=>{(!t||t.test(a.relativePath))&&(e.push(a),s.update(a.relativePath))});const i=s.digest("base64");return this.#t.set(t,i),r.getStore()?.push({type:"scan",hash:i,pattern:t}),e}emitCodeUpdated(){this.emit({event:"code-updated"})}addVirtualFile(t,e){this.filesList.set(t,{relativePath:t,realRelativePath:e.realRelativePath,hash:e.hash,isVirtual:!0}),r.getStore()?.push({type:"read",path:t,hash:e.hash??""})}getPatternScanHash(t){return this.#t.get(t)}#s(t){return v.test(t)}emit=L(async t=>{for(const e of t)if(!("path"in e&&this.#s(e.path)))switch(e.event){case"add":this.filesList.set(e.path,{relativePath:e.path,realRelativePath:e.path,hash:void 0,isVirtual:!1});for(const s of this.#t.keys())s&&s.test(e.path)&&this.#t.set(s,void 0),s||this.#t.set(s,void 0);break;case"change":{const s=this.filesList.get(e.path);s&&(s.hash=void 0);break}case"unlink":this.filesList.delete(e.path);for(const s of this.#t.keys())s&&s.test(e.path)&&this.#t.delete(s),s||this.#t.delete(s);break}for(const e of this.#e)await e(t)});async#i(){return c.startTiming("init-fs"),new Promise((t,e)=>{const s=f.watch(this.cwd,{usePolling:!1,ignoreInitial:!0,ignored:[new RegExp(`(/.git/|/node_modules/|${u})`),h.join(this.cwd,"public"),h.join(this.cwd,"README.md"),...this.ignored]});s.on("ready",()=>{this.filesList=this.#a(s.getWatched()),t(s),c.infoTime("init-fs","File system scan completed")}).on("error",e).on("add",(i,a)=>{this.emit({event:"add",path:o(h.relative(this.cwd,i)),stats:a})}).on("change",(i,a)=>{this.emit({event:"change",path:o(h.relative(this.cwd,i)),stats:a})}).on("unlink",i=>{this.emit({event:"unlink",path:o(h.relative(this.cwd,i))})})})}#a(t){const e=new Map;for(const s of Object.keys(t))for(const i of t[s]){const a=h.join(s,i);if(t[a])continue;const d=o(h.dirname(h.relative(this.cwd,a))),n=h.posix.join(d,i);this.#s(n)||e.set(n,{relativePath:n,realRelativePath:n,isVirtual:!1,hash:void 0})}return e}}export{j as Fs};
@@ -1 +1 @@
1
- function n(e){return e.replace(/^((\/|)(@i18n|@l10n)\/[^\/]+)\//,"")}export{n as removeL10nPrefix};
1
+ function n(e){return e.replace(/^((\/|)(@i18n|@l10n)\/[^/]+)\//,"")}export{n as removeL10nPrefix};
@@ -1,6 +1,5 @@
1
- import type { FileHashReadModelSchema } from '../types.js';
1
+ import type { FileHashReadModelSchema, FileHashStatus, UpsertFileHashParams } from '../types.js';
2
2
  import type { Filter } from '../../../providers/database/pagination/types.js';
3
- import type { FileHashStatus, UpsertFileHashParams } from '../types.js';
4
3
  import type { DatabaseConnection, RepositoryInstanceOptions } from '../../../providers/database/types.js';
5
4
  import { BaseRepository } from '../../../providers/database/base-repository.js';
6
5
  export declare class FileHashesRepository extends BaseRepository {
@@ -1,7 +1,6 @@
1
1
  import type { ServiceInstanceOptions } from '../../../providers/database/types.js';
2
2
  import type { Filter } from '../../../providers/database/pagination/types.js';
3
- import type { FileHashStatus, UpsertFileHashParams } from '../types.js';
4
- import type { FileHashReadModelSchema } from '../types.js';
3
+ import type { FileHashStatus, UpsertFileHashParams, FileHashReadModelSchema } from '../types.js';
5
4
  import { FileHashesRepository } from '../repositories/file-hashes-repository.js';
6
5
  export declare class FileHashesService {
7
6
  #private;
@@ -1 +1 @@
1
- const a=(n,i)=>{const d=i?.analytics?.rudderstack;if(!d)return;const{trackPage:t}=d;function e(){t!==!1&&window.rudderanalytics?.page(document.title)}window.rudderSnippetLoaded===!1?window.rudderSnippetLoading===!0?window.rudderSnippetLoadedCallback=function(){e()}:n.prevLocation?(window.rudderSnippetLoadedCallback=void 0,window.rudderSnippetLoader(function(){e()})):window.rudderSnippetLoadedCallback=function(){e()}:e()};export{a as onRouteChange};
1
+ const r=(n,i)=>{const d=i?.analytics?.rudderstack;if(!d)return;const{trackPage:t}=d;function e(){t===!0&&window.rudderanalytics?.page(document.title)}window.rudderSnippetLoaded===!1?window.rudderSnippetLoading===!0?window.rudderSnippetLoadedCallback=function(){e()}:n.prevLocation?(window.rudderSnippetLoadedCallback=void 0,window.rudderSnippetLoader(function(){e()})):window.rudderSnippetLoadedCallback=function(){e()}:e()};export{r as onRouteChange};
@@ -1 +1 @@
1
- const a=(t,o)=>{const e=o?.analytics?.segment;if(!e||e?.trackPage===!1)return;function n(){window.segmentPageviewCaller?.(!!t.prevLocation)}window.portalPluginSegmentSnippetLoader?window.portalPluginSegmentSnippetLoader(n):n()};export{a as onRouteChange};
1
+ const o=(n,t)=>{if(t?.analytics?.segment?.trackPage!==!0)return;function e(){window.segmentPageviewCaller?.(!!n.prevLocation)}window.portalPluginSegmentSnippetLoader?window.portalPluginSegmentSnippetLoader(e):e()};export{o as onRouteChange};
@@ -1,8 +1,8 @@
1
- import c from"react";const d=n=>{const{writeKey:t,trackPage:a,host:i="https://cdn.segment.io",includeTitleInPageCall:r=!0}=n,l=`(function () {
1
+ import c from"react";const d=n=>{const{writeKey:t,trackPage:a,host:i="https://cdn.segment.io",includeTitleInPageCall:r=!1}=n,l=`(function () {
2
2
  let segmentPageviewCalledAlready = false;
3
3
  window.segmentPageviewCaller = function (force) {
4
4
 
5
- ${a!==!1?"":"return;"}
5
+ ${a===!0?"":"return;"}
6
6
 
7
7
  if (!window.analytics) {
8
8
  return
@@ -15,7 +15,7 @@ import c from"react";const d=n=>{const{writeKey:t,trackPage:a,host:i="https://cd
15
15
  };
16
16
  })();`;let e=`(function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="${i}/analytics.js/v1/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};analytics._writeKey="${t}";analytics.SNIPPET_VERSION="4.15.3";
17
17
  analytics.load('${t}');
18
- `;a!==!1&&(e+="window.segmentPageviewCaller();"),e+="}})();";const s=`
18
+ `;a===!0&&(e+="window.segmentPageviewCaller();"),e+="}})();";const s=`
19
19
  (function () {
20
20
  ${l}
21
21
  ${e}
@@ -1,8 +1,7 @@
1
- import type { OpenAPIDefinition, AsyncApiDefinition, ApiSpecType } from '@redocly/api-docs';
1
+ import { type ASTNode, type DocumentNode } from 'graphql';
2
+ import type { OpenAPIDefinition, AsyncApiDefinition, ApiSpecType, RawApiDocsOptions } from '@redocly/api-docs';
2
3
  import type { Node as MarkdocNode } from '@markdoc/markdoc';
3
- import type { ASTNode, DocumentNode } from 'graphql';
4
4
  import type { LifecycleContext } from '../../types';
5
- import type { RawApiDocsOptions } from '@redocly/api-docs';
6
5
  import type { RedoclyConfig } from '@redocly/config';
7
6
  export type MarkdocChunk = {
8
7
  node: Record<string, unknown> & {
@@ -1,4 +1,4 @@
1
- import type { ApiSpecType, OpenAPIDefinition, AsyncApiDefinition, DownloadUrl, RawApiDocsOptions } from '@redocly/api-docs';
1
+ import { type ApiSpecType, type OpenAPIDefinition, type AsyncApiDefinition, type DownloadUrl, type RawApiDocsOptions } from '@redocly/api-docs';
2
2
  import type { DocumentNode } from 'graphql';
3
3
  export type DocumentBuildContext = {
4
4
  rootConfig: Record<string, unknown> | null;
@@ -1,5 +1,5 @@
1
+ import { type ApiItem, type ApiDocsMetadata, type ApiStore, type ApiSpecType, type OpenAPIDefinition, type AsyncApiDefinition } from '@redocly/api-docs';
1
2
  import type { SearchFacet } from '@redocly/theme/core/types';
2
- import type { ApiItem, ApiDocsMetadata, ApiStore, ApiSpecType, OpenAPIDefinition, AsyncApiDefinition } from '@redocly/api-docs';
3
3
  import type { AfterRoutesCreatedActions, AfterRoutesCreatedLifecycleContext, PageRouteDetails } from '../../../types';
4
4
  import type { MarkdocTagSchema } from '@redocly/theme/markdoc/tags/types';
5
5
  import type { AiDocumentsStore } from '../../../plugins/search/types.js';
@@ -1 +1 @@
1
- import b from"node:path";import{REDOCLY_TEAMS_RBAC as p}from"@redocly/config";import{slash as k}from"../../../../utils/path/slash.js";function f(t,r,a){if(!r)throw new Error("Visitor required");if(t){t.description&&r(t,"description",a.location.absolutePointer+"/description",a);for(const o in t["x-enumDescriptions"])r(t["x-enumDescriptions"],o,a.location.absolutePointer+"/x-enumDescriptions/"+o,a)}}const x=/^[a-zA-Z0-9\s\-,.!\?:;'"()/]+$/,d=/^\s*(?:[-+*]\s|\d+[.)]\s)/m;function g(t){return x.test(t)&&!d.test(t)}const s=({outputRelativePath:t,cwd:r})=>{const a=function(e,m,l,u){const{node:n}=u.resolve(e[m]);if(!n||typeof n!="string"||g(n))return;const i=u.getVisitorData();i.markdocChunks=i.markdocChunks||[],i.markdocChunks.push({node:e,pointer:k(b.relative(r,l)),markdown:n,relativePath:t,key:m})};return{any:{leave(o,e){f(o,a,e)}},ref:{leave(o,e){f(o,a,e)}}}},c=()=>{const t={};return{Tag:{enter(r){r?.["x-rbac"]&&(t[String(r.name)]=r["x-rbac"])}},any:{leave(r,a){if((a.type.name==="Operation"||a.type.name==="Webhook")&&"tags"in r&&Array.isArray(r.tags))for(const o of r.tags)t[o]&&(r["x-rbac"]=r["x-rbac"]||t[o]);r?.["x-rbac"]&&(r[p]=r["x-rbac"],delete r["x-rbac"])}},ref:{leave(r){r?.["x-rbac"]&&(r[p]=r["x-rbac"],delete r["x-rbac"])}}}};function D(t,r,a){const o={id:"markdown",decorators:{oas2:{markdown:s,rbac:c},oas3:{markdown:s,rbac:c},async3:{markdown:s,rbac:c}}};return{...t,decorators:{"markdown/rbac":"on","markdown/markdown":{outputRelativePath:r,cwd:a},...t.decorators||{}},plugins:[...t.plugins||[],o]}}export{s as MarkdownParserDecorator,c as RbacDecorator,D as injectDecoratorIntoConfig,g as isPlainNonMarkdownText};
1
+ import b from"node:path";import{REDOCLY_TEAMS_RBAC as p}from"@redocly/config";import{slash as k}from"../../../../utils/path/slash.js";function f(t,r,a){if(!r)throw new Error("Visitor required");if(t){t.description&&r(t,"description",a.location.absolutePointer+"/description",a);for(const o in t["x-enumDescriptions"])r(t["x-enumDescriptions"],o,a.location.absolutePointer+"/x-enumDescriptions/"+o,a)}}const x=/^[a-zA-Z0-9\s\-,.!?:;'"()/]+$/,d=/^\s*(?:[-+*]\s|\d+[.)]\s)/m;function g(t){return x.test(t)&&!d.test(t)}const s=({outputRelativePath:t,cwd:r})=>{const a=function(e,m,l,u){const{node:n}=u.resolve(e[m]);if(!n||typeof n!="string"||g(n))return;const i=u.getVisitorData();i.markdocChunks=i.markdocChunks||[],i.markdocChunks.push({node:e,pointer:k(b.relative(r,l)),markdown:n,relativePath:t,key:m})};return{any:{leave(o,e){f(o,a,e)}},ref:{leave(o,e){f(o,a,e)}}}},c=()=>{const t={};return{Tag:{enter(r){r?.["x-rbac"]&&(t[String(r.name)]=r["x-rbac"])}},any:{leave(r,a){if((a.type.name==="Operation"||a.type.name==="Webhook")&&"tags"in r&&Array.isArray(r.tags))for(const o of r.tags)t[o]&&(r["x-rbac"]=r["x-rbac"]||t[o]);r?.["x-rbac"]&&(r[p]=r["x-rbac"],delete r["x-rbac"])}},ref:{leave(r){r?.["x-rbac"]&&(r[p]=r["x-rbac"],delete r["x-rbac"])}}}};function D(t,r,a){const o={id:"markdown",decorators:{oas2:{markdown:s,rbac:c},oas3:{markdown:s,rbac:c},async3:{markdown:s,rbac:c}}};return{...t,decorators:{"markdown/rbac":"on","markdown/markdown":{outputRelativePath:r,cwd:a},...t.decorators||{}},plugins:[...t.plugins||[],o]}}export{s as MarkdownParserDecorator,c as RbacDecorator,D as injectDecoratorIntoConfig,g as isPlainNonMarkdownText};
@@ -1 +1 @@
1
- import{join as c}from"path";import{transformSync as l}from"esbuild";import{REDOCLY_ROUTE_RBAC as p}from"@redocly/config";import{removeTrailingSlash as d}from"../../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as m}from"../../../utils/url/remove-leading-slash.js";import{logger as u}from"../../tools/notifiers/logger.js";import{envConfig as g}from"../../config/env-config.js";import{USER_DEFINED_API_FUNCTIONS_COUNTER_KEY as h}from"../../../server/store.js";import{parseRouteFsPathForHono as F}from"./helpers/parse-route-fs-path-for-hono.js";import{telemetryTraceStep as A}from"../../../cli/telemetry/helpers/trace-step.js";const f="api-functions",P=/\bexport\s+default\b|\bexport\s*\{[^}]*\b(?:default\s*[,}]|\w+\s+as\s+default\b)/;async function E(t,o){let r;try{r=await o.fs.read(t),l(r,{loader:t.endsWith(".js")?"js":"ts"})}catch(e){const a=e instanceof Error?e.message:String(e);return u.warn(`Skipping API function ${t} because it cannot be parsed: ${a}`),!1}if(!P.test(r)){const e=`API function ${t} does not export a default function. Add 'export default function (request, context) { ... }' to define an API function.`;return g.isDevelopMode?(u.warn(e),!0):(u.warn(`Skipping ${e}`),!1)}return!0}function R(t){return m(d(t))}function I(t){return`^${R(t)}`}function b(t){const o=t.map(I);return o.push(".*@api"),new RegExp(`(${o.join("|")})/.*.(ts|js)$`)}async function H(){return{id:"ApiFunctions",requiredEntitlements:["apiFunctions"],async processContent(t,o){await A("com.redocly.build.plugin.apiFunctions",async r=>{const e=await o.getConfig();r?.setAttribute("config",JSON.stringify(e.apiFunctions||{}));const a=b(e.apiFunctions?.folders||[]),s=[];for(const n of o.fs.scan(a)){if(n.isVirtual)continue;const i=F(n.relativePath);i&&await E(n.relativePath,o)&&s.push({requestHandlerId:`${f}:${i.handler}`,fullPath:c(t.contentDir,i.handler),slug:i.path,httpMethod:i.method,fsPath:n.relativePath})}t.clearRequestHandlersByPrefix(`${f}:`);for(const n of s)t.createRequestHandler(n.requestHandlerId,n.fullPath),t.addApiRoute({requestHandlerId:n.requestHandlerId,slug:n.slug,fsPath:n.fsPath,httpMethod:n.httpMethod,[p]:{fsPath:n.fsPath,slug:n.slug}});r?.setAttribute("definedApiFunctions",String(s.length)),t.setGlobalConfig({[h]:s.length})})}}}export{f as API_FUNCTIONS_REQUEST_HANDLER_ID,H as apiFunctionsPlugin};
1
+ import{join as c}from"path";import{transformSync as l}from"esbuild";import{REDOCLY_ROUTE_RBAC as p}from"@redocly/config";import{removeTrailingSlash as d}from"../../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as m}from"../../../utils/url/remove-leading-slash.js";import{logger as u}from"../../tools/notifiers/logger.js";import{envConfig as g}from"../../config/env-config.js";import{USER_DEFINED_API_FUNCTIONS_COUNTER_KEY as h}from"../../../server/store.js";import{parseRouteFsPathForHono as F}from"./helpers/parse-route-fs-path-for-hono.js";import{telemetryTraceStep as A}from"../../../cli/telemetry/helpers/trace-step.js";const f="api-functions",P=/\bexport\s+default\b|\bexport\s*\{[^}]*\b(?:default\s*[,}]|\w+\s+as\s+default\b)/;async function E(t,o){let r;try{r=await o.fs.read(t),l(r,{loader:t.endsWith(".js")?"js":"ts"})}catch(e){const a=e instanceof Error?e.message:String(e);return u.warn(`Skipping API function ${t} because it cannot be parsed: ${a}`),!1}if(!P.test(r)){const e=`API function ${t} does not export a default function. Add 'export default function (request, context) { ... }' to define an API function.`;return g.isDevelopMode?(u.warn(e),!0):(u.warn(`Skipping ${e}`),!1)}return!0}function R(t){return m(d(t))}function I(t){return`^${R(t)}`}function b(t){const o=t.map(I);return o.push(".*@api"),new RegExp(`(${o.join("|")})/.*\\.(ts|js)$`)}async function H(){return{id:"ApiFunctions",requiredEntitlements:["apiFunctions"],async processContent(t,o){await A("com.redocly.build.plugin.apiFunctions",async r=>{const e=await o.getConfig();r?.setAttribute("config",JSON.stringify(e.apiFunctions||{}));const a=b(e.apiFunctions?.folders||[]),s=[];for(const n of o.fs.scan(a)){if(n.isVirtual)continue;const i=F(n.relativePath);i&&await E(n.relativePath,o)&&s.push({requestHandlerId:`${f}:${i.handler}`,fullPath:c(t.contentDir,i.handler),slug:i.path,httpMethod:i.method,fsPath:n.relativePath})}t.clearRequestHandlersByPrefix(`${f}:`);for(const n of s)t.createRequestHandler(n.requestHandlerId,n.fullPath),t.addApiRoute({requestHandlerId:n.requestHandlerId,slug:n.slug,fsPath:n.fsPath,httpMethod:n.httpMethod,[p]:{fsPath:n.fsPath,slug:n.slug}});r?.setAttribute("definedApiFunctions",String(s.length)),t.setGlobalConfig({[h]:s.length})})}}}export{f as API_FUNCTIONS_REQUEST_HANDLER_ID,H as apiFunctionsPlugin};
@@ -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,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 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};
@@ -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,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};
@@ -1 +1 @@
1
- import{executeMcpTool as c}from"../workers/execute-mcp-tool.js";async function a(t,r,o,u){const e=await c({toolName:t,args:r,context:o,extra:u});if(e.isError)throw new Error(n(e));return e.structuredContent!==void 0?e.structuredContent:i(n(e))}function n(t){return t.content.filter(r=>r.type==="text").map(r=>r.text).join("")}function i(t){try{return JSON.parse(t)}catch{return t}}export{a as invokeTool};
1
+ import{executeMcpTool as i}from"../workers/execute-mcp-tool.js";import{ToolResultError as c}from"./tools/tool-errors.js";async function p(t,r,o,u){const e=await i({toolName:t,args:r,context:o,extra:u});if(e.isError)throw new c(n(e));return e.structuredContent!==void 0?e.structuredContent:s(n(e))}function n(t){return t.content.filter(r=>r.type==="text").map(r=>r.text).join("")}function s(t){try{return JSON.parse(t)}catch{return t}}export{p as invokeTool};
@@ -1,8 +1,12 @@
1
1
  import type { GuestPosition } from '../../../../sandbox/types.js';
2
+ export type GuestErrorDescription = {
3
+ message: string;
4
+ unknownTool?: string;
5
+ };
2
6
  /**
3
7
  * Turns a guest error into the message the model reads. A call on a tool the sandbox does not
4
8
  * hold names that tool and lists the available ones; every other error keeps its message and
5
9
  * gains the line it was thrown on.
6
10
  */
7
- export declare function describeGuestError(code: string, message: string, position: GuestPosition | undefined, availableTools: string[]): string;
11
+ export declare function describeGuestError(code: string, message: string, position: GuestPosition | undefined, availableTools: string[]): GuestErrorDescription;
8
12
  //# sourceMappingURL=unknown-tool-hint.d.ts.map
@@ -1,2 +1,2 @@
1
- import{TOOLS_BRIDGE_GLOBAL_NAME as c}from"../constants.js";const i="not a function",d=new RegExp(`(?:^|[^\\w$.])${c}\\s*(?:(?:\\?\\.|\\.)\\s*([A-Za-z_$][\\w$]*)|(?:\\?\\.)?\\s*\\[\\s*(['"])([^'"]*)\\2\\s*\\])\\s*(?:\\?\\.)?\\s*$`);function $(o,t,n,e){const u=n&&E(o,n);if(!n||u===void 0)return t;const f=t===i?l(o.slice(0,u),e):void 0;return f===void 0?`${t} (line ${n.line})`:`Unknown tool "${f}". Available tools: ${e.join(", ")}`}function l(o,t){const n=d.exec(o),e=n?.[1]??n?.[3];return e!==void 0&&!t.includes(e)?e:void 0}function E(o,{line:t,column:n}){const e=o.split(`
2
- `);if(t>e.length)return;const f=e.slice(0,t-1).reduce((r,s)=>r+s.length+1,0)+n-1;return f<=o.length?f:void 0}export{$ as describeGuestError};
1
+ import{TOOLS_BRIDGE_GLOBAL_NAME as c}from"../constants.js";const i="not a function",d=new RegExp(`(?:^|[^\\w$.])${c}\\s*(?:(?:\\?\\.|\\.)\\s*([A-Za-z_$][\\w$]*)|(?:\\?\\.)?\\s*\\[\\s*(['"])([^'"]*)\\2\\s*\\])\\s*(?:\\?\\.)?\\s*$`);function $(o,t,n,e){const f=n&&E(o,n);if(!n||f===void 0)return{message:t};const s=t===i?l(o.slice(0,f),e):void 0;return s===void 0?{message:`${t} (line ${n.line})`}:{message:`Unknown tool "${s}". Available tools: ${e.join(", ")}`,unknownTool:s}}function l(o,t){const n=d.exec(o),e=n?.[1]??n?.[3];return e!==void 0&&!t.includes(e)?e:void 0}function E(o,{line:t,column:n}){const e=o.split(`
2
+ `);if(t>e.length)return;const s=e.slice(0,t-1).reduce((u,r)=>u+r.length+1,0)+n-1;return s<=o.length?s:void 0}export{$ as describeGuestError};