@redocly/framework 1.0.0-next.11 → 1.0.0-next.13
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.
- package/dist/bundler/dev/routes/source-sync-route.js +1 -1
- package/dist/bundler/dev/runtime-app.js +1 -1
- package/dist/bundler/dev/vite-config.js +1 -1
- package/dist/cli/problems-output.js +3 -3
- package/dist/client/UnversionedVersionButton.js +1 -1
- package/dist/client/VersionPicker.js +343 -0
- package/dist/client/ai-search/citations.js +3 -3
- package/dist/client/app.js +2 -2
- package/dist/client/classic-webview-sync.js +1 -0
- package/dist/client/client-entry.js +1 -1
- package/dist/client/history-mount.js +6 -5
- package/dist/client/page-sync.js +1 -0
- package/dist/client/review/ReviewBar.js +31 -31
- package/dist/client/review/login-url.js +1 -1
- package/dist/client/revisions-history.js +1 -1
- package/dist/content-layer/config-schema.js +1 -1
- package/dist/content-layer/config.d.ts +8 -0
- package/dist/content-layer/config.js +1 -1
- package/dist/content-layer/context.d.ts +6 -0
- package/dist/content-layer/database/entities.d.ts +2 -0
- package/dist/content-layer/database/entities.js +1 -1
- package/dist/content-layer/database/origins.d.ts +2 -1
- package/dist/content-layer/database/origins.js +1 -1
- package/dist/content-layer/database/route-query-deps.d.ts +19 -3
- package/dist/content-layer/database/route-query-deps.js +1 -1
- package/dist/content-layer/ingest/git-last-modified.d.ts +20 -0
- package/dist/content-layer/ingest/git-last-modified.js +5 -4
- package/dist/content-layer/ingest/run.js +1 -1
- package/dist/content-layer/link-checker/fingerprint.js +1 -1
- package/dist/content-layer/link-checker/load-view.js +1 -1
- package/dist/content-layer/markdown/client/markdown-text.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/build-definition.d.ts +2 -0
- package/dist/content-layer/plugins/internal/api-docs/server/build-definition.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/markdown-copy.js +11 -9
- package/dist/content-layer/plugins/internal/api-docs/server/options.d.ts +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/options.js +1 -1
- package/dist/content-layer/plugins/internal/api-functions/server/dispatch.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/index.d.ts +1 -1
- package/dist/content-layer/plugins/internal/app-data/index.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/constants.d.ts +4 -3
- package/dist/content-layer/plugins/internal/mcp/constants.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/content-tools.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/constants.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/execute-schema.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/prompts.js +8 -8
- package/dist/content-layer/plugins/internal/mcp/server/gateway/subject.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/tool-list.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/tools.js +3 -3
- package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/authorize.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/callback.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/error-reporting.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/rate-limit.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/server-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/workflows/resolve-workflows.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/workflows/schemas.js +2 -1
- package/dist/content-layer/plugins/internal/mcp/server/workflows/tools.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/client/template.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/index.js +1 -1
- package/dist/content-layer/plugins/internal/versions/index.js +1 -1
- package/dist/content-layer/plugins/utils/route-index.js +1 -1
- package/dist/content-layer/server/database.js +1 -1
- package/dist/content-layer/versions/group-info.d.ts +2 -1
- package/dist/content-layer/versions/group-info.js +1 -1
- package/dist/server/app.js +1 -1
- package/dist/server/auth/runtime.js +1 -1
- package/dist/server/content.js +7 -7
- package/dist/server/lambda-entry.js +1 -1
- package/dist/server/node-entry.js +1 -1
- package/dist/server/search/route.js +1 -1
- package/dist/server/telemetry/mock-server-events.js +1 -1
- package/dist/server/telemetry/sender.js +1 -1
- package/dist/server/wait-until.js +1 -0
- package/dist/shared/constants/review.d.ts +2 -0
- package/dist/shared/constants/review.js +1 -1
- package/dist/shared/constants/system-routes.d.ts +1 -1
- package/dist/shared/constants/system-routes.js +1 -1
- package/dist/shared/types/config.d.ts +2 -1
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{normalizeRouteSlug as e}from"../shared/utils/routes/normalize-route-slug.js";function t(t,i){let{document:a}=t,o=0,s=t;for(let e of[`scrollTo`,`scroll`,`scrollBy`]){let n=s[e];s[e]=(...e)=>{o=Date.now()+150,n.apply(t,e)}}let c=null;t.addEventListener(`scroll`,()=>{Date.now()<o||!a.querySelector(`:hover`)||t.scrollY!==c&&(c=null,i.onScroll(n(t)))},{passive:!0});let l=null,u=()=>{let{pathname:n,search:r,hash:a}=t.location,o=e(n);o!==l&&(l=o,i.onUrlChange(`${n}${r}${a}`))};return t.navigation?.addEventListener(`currententrychange`,u),u(),{scrollTo(e){let n=r(t,e);n!==void 0&&(t.scrollTo({top:n,behavior:`instant`}),c=t.scrollY)}}}function n(e){let t=a(e.document),n=e.scrollY+t,r=i(e),o=r[0];if(!o||n<o.offset)return{sequenceNumber:-1,percentScrolled:0};let s=0;r.forEach(({offset:e},t)=>{n>=e&&(s=t)});let c=r[s];if(!c||c.height<=0)return{sequenceNumber:-1,percentScrolled:0};let l=Math.round((n-c.offset)/c.height*100);return{sequenceNumber:s,percentScrolled:Math.max(0,Math.min(100,l))}}function r(e,t){if(t.sequenceNumber===-1)return 0;let n=i(e)[t.sequenceNumber];if(!n)return;let r=a(e.document);return Math.round(n.offset-r+n.height*(t.percentScrolled/100))}function i(e){let t=[...e.document.querySelectorAll(`main[data-component-name="Markdown/Markdown"]`)].find(e=>!e.closest(`[data-component-name="Banner/Banner"]`));if(!t)return[];let n=t=>t.offsetTop-(parseFloat(e.getComputedStyle(t).marginTop)||0),r=n(t),i=r+t.offsetHeight,a=[...t.querySelectorAll(`[data-component-name="Markdoc/Heading/Heading"]`)];if(a.length===0&&(a=[...t.querySelectorAll(`h1, h2, h3, h4, h5, h6`)]),a.length===0)return[{offset:r,height:t.offsetHeight}];let o=[r,...a.map(n)],s=[];return o.forEach((e,t)=>{let n=(o[t+1]??i)-e;n>0&&s.push({offset:e,height:n})}),s}function a(e){return e.querySelector(`nav`)?.offsetHeight??0}export{t as attachPageSync};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../use-bar-position.js";import{changedPageNavigation as n,filterChangedPages as r,isSamePage as i}from"./changed-pages.js";import{reviewLoginUrl as a}from"./login-url.js";import{reviewTimeline as o}from"./timeline.js";import{useReview as s}from"./use-review.js";import{createContext as c,useCallback as l,useContext as u,useEffect as d,useRef as f,useState as p}from"react";import m,{css as h,keyframes as g}from"styled-components";import{Button as _}from"@redocly/theme/components/Button/Button";import{breakpoints as v,hiddenWhileMobileMenuOpen as y}from"@redocly/theme/core/utils";import{Fragment as b,jsx as x,jsxs as S}from"react/jsx-runtime";import{useTimeAgo as C}from"@redocly/theme/core/hooks";import{DraggableIcon as ee}from"@redocly/theme/icons/DraggableIcon/DraggableIcon";import{Spinner as te}from"@redocly/theme/icons/Spinner/Spinner";import{Link as w}from"@redocly/theme/components/Link/Link";import{linkCss as T}from"@redocly/theme/components/Markdown/styles/links";import{Segmented as E}from"@redocly/theme/components/Segmented/Segmented";import{Tag as D}from"@redocly/theme/components/Tag/Tag";import{Tooltip as O}from"@redocly/theme/components/Tooltip/Tooltip";import{ChatIcon as ne}from"@redocly/theme/icons/ChatIcon/ChatIcon";import{CheckmarkIcon as re}from"@redocly/theme/icons/CheckmarkIcon/CheckmarkIcon";import{CloseIcon as k}from"@redocly/theme/icons/CloseIcon/CloseIcon";import{ChevronLeftIcon as A}from"@redocly/theme/icons/ChevronLeftIcon/ChevronLeftIcon";import{ChevronRightIcon as ie}from"@redocly/theme/icons/ChevronRightIcon/ChevronRightIcon";import{MinimizeIcon as ae}from"@redocly/theme/icons/MinimizeIcon/MinimizeIcon";import{SearchIcon as oe}from"@redocly/theme/icons/SearchIcon/SearchIcon";import{TrashCanIcon as j}from"@redocly/theme/icons/TrashCanIcon/TrashCanIcon";import{WarningAltIcon as se}from"@redocly/theme/icons/WarningAltIcon/WarningAltIcon";const M=`realm.review-bar-used`,N=[{value:`all`,label:`All`},{value:`modified`,label:`Modified`},{value:`added`,label:`Added`},{value:`removed`,label:`Removed`}],P=/Mac|iPhone|iPad/.test(navigator.platform)?`⌘ Enter`:`Ctrl Enter`,F={added:`Added`,modified:`Modified`,removed:`Removed`},I={APPROVED:`approved`,REQUESTED_CHANGES:`requested changes on`,COMMENTED:`commented on`},L=c(`middle`);function ce(){try{return localStorage.getItem(M)===`1`}catch{return!1}}function R(){try{localStorage.setItem(M,`1`)}catch{}}function z({children:e,...t}){let n=u(L);return/* @__PURE__ */ x(O,{...t,placement:`top`,fallbackPlacements:[],arrowPosition:n===`middle`?`center`:n,children:e})}function B(){let n=u(e),{state:r,error:o,submitting:c,addComment:f,deleteComment:m}=s(),[h,g]=p(null),{barRef:v,slot:y,dragging:C,style:w,onDragStart:T}=t({storageKey:`realm.review-bar-slot`,defaultSlot:`middle`,frozen:h!==null}),[E,D]=p(!1),[O,A]=p(!1),[ie,oe]=p(0),[j,M]=p(ce),N=l(()=>{let e=v.current?.getBoundingClientRect().width;!e||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?M(!0):g(e)},[v]);if(d(()=>{if(j||h!==null||E||O)return;let e=e=>{e.target instanceof Node&&v.current?.contains(e.target)||N()};return window.addEventListener(`wheel`,e,{passive:!0}),window.addEventListener(`touchmove`,e,{passive:!0}),()=>{window.removeEventListener(`wheel`,e),window.removeEventListener(`touchmove`,e)}},[j,h,E,O,v,N]),d(()=>{if(!E&&!O)return;let e=e=>{e.key===`Escape`&&(O?A(!1):D(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E,O]),window.self!==window.top)return null;let P=n?.slug??`/`,F=n?.auth?.loginUrl,I=r?.signedIn?r.pullRequest:null,B=E&&I!==null,V=I?.pageComments.filter(e=>!e.replyToId&&!e.isResolved&&i(e.pageSlug,P)).length??0,H=/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(z,{tip:`Drag to move`,disabled:C,children:/* @__PURE__ */ x(xe,{type:`button`,"aria-label":`Drag the review bar`,onPointerDown:T,$dragging:C,children:/* @__PURE__ */ x(ee,{size:`16px`,color:`var(--icon-color-secondary)`})})}),r===null&&!o&&/* @__PURE__ */ x(q,{children:/* @__PURE__ */ x(te,{size:`16px`,color:`var(--icon-color-secondary)`})}),r?.signedIn===!1&&F&&/* @__PURE__ */ x(_,{variant:`primary`,onClick:()=>{R(),window.location.assign(a(F,n?.path??`/`))},children:`Log in to review`}),r?.signedIn&&!I&&/* @__PURE__ */ x(Y,{children:`No open pull request`}),I&&/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ S(K,{children:[/* @__PURE__ */ x(z,{tip:`${I.title} — open in Platform`,children:/* @__PURE__ */ S(_,{variant:`text`,to:I.url,external:!0,children:[`#`,I.number]})}),/* @__PURE__ */ x(J,{})]}),/* @__PURE__ */ x(ue,{pullRequest:I,currentSlug:P,open:O,onToggle:()=>{R(),oe(v.current?.getBoundingClientRect().top??0),A(e=>!e)}}),B?/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(ye,{}),/* @__PURE__ */ x(z,{tip:`Close`,children:/* @__PURE__ */ x(_,{variant:`text`,icon:/* @__PURE__ */ x(k,{color:`currentColor`}),"aria-label":`Close the review`,onClick:()=>D(!1)})})]}):/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(J,{}),/* @__PURE__ */ x(z,{tip:I.decision===`APPROVED`?`You approved`:I.decision===`REQUESTED_CHANGES`?`You requested changes`:`Comment on pages, then finish your review in Platform`,children:/* @__PURE__ */ S(_,{variant:`primary`,"aria-expanded":!1,onClick:()=>{R(),A(!1),D(!0)},icon:I.decision===`APPROVED`?/* @__PURE__ */ x(re,{color:`currentColor`}):I.decision===`REQUESTED_CHANGES`?/* @__PURE__ */ x(k,{color:`currentColor`}):void 0,children:[`Review`,V>0&&/* @__PURE__ */ S(Ie,{"aria-label":`${V} open comments on this page`,children:[/* @__PURE__ */ x(ne,{size:`12px`,color:`currentColor`}),V]})]})})]})]}),o&&/* @__PURE__ */ x(z,{tip:o,children:/* @__PURE__ */ x(q,{role:`alert`,"aria-label":o,children:/* @__PURE__ */ x(se,{size:`16px`,color:`var(--color-error-base)`})})}),!B&&/* @__PURE__ */ x(z,{tip:`Collapse`,children:/* @__PURE__ */ x(_,{variant:`text`,icon:/* @__PURE__ */ x(ae,{color:`currentColor`}),"aria-label":`Collapse the review bar`,onClick:()=>{R(),A(!1),N()}})})]}),U=o??(r?.signedIn===!1?`Log in to review`:r?.signedIn&&!I?`No open pull request`:`Review`),W=/* @__PURE__ */ x(z,{tip:U,children:/* @__PURE__ */ S(ge,{type:`button`,"aria-label":U,"aria-expanded":!1,onClick:()=>{R(),M(!1)},children:[/* @__PURE__ */ x(ne,{size:`18px`,color:`var(--icon-color-primary)`}),o?/* @__PURE__ */ x(G,{role:`alert`,$tone:`error`}):r?.signedIn===!1&&F?/* @__PURE__ */ x(G,{$tone:`info`}):V>0?/* @__PURE__ */ x(_e,{children:V}):null]})});return/* @__PURE__ */ x(L.Provider,{value:y,children:/* @__PURE__ */ S(he,{ref:v,style:h===null?w:{...w,"--review-bar-collapse-from":`${h}px`},$dragging:C,$expanded:B,$collapsed:j,$collapsing:h!==null,onAnimationEnd:e=>{e.target===e.currentTarget&&h!==null&&(g(null),M(!0))},"data-testid":`review-bar`,children:[j?W:B?/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(ve,{children:H}),/* @__PURE__ */ x(be,{children:/* @__PURE__ */ x(le,{pullRequest:I,currentSlug:P,submitting:c,onComment:e=>f({pageSlug:P,text:e}),onDelete:m})})]}):H,!j&&O&&I&&/* @__PURE__ */ x(Ce,{$slot:y,style:{maxHeight:`min(50vh, calc(${ie}px - 2 * var(--spacing-xs)))`},children:/* @__PURE__ */ x(de,{pages:I.changedPages??[],currentSlug:P,onOpen:()=>A(!1)})})]})})}function le({pullRequest:e,currentSlug:t,submitting:n,onComment:r,onDelete:i}){let a=e.pageComments.filter(e=>e.isPending).length;return/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(V,{pullRequest:e,currentSlug:t,submitting:n,onSubmit:r,onDelete:i}),/* @__PURE__ */ S(Fe,{children:[/* @__PURE__ */ x($,{children:a===0?`Comments are posted when you finish your review.`:`${a} pending ${a===1?`comment`:`comments`}`}),e.url&&/* @__PURE__ */ x(z,{tip:`Approve or request changes in Platform`,children:/* @__PURE__ */ x(_,{variant:`primary`,to:`${e.url}/review?finishReview=true`,external:!0,children:`Finish review`})})]})]})}function V({pullRequest:e,currentSlug:t,submitting:n,onSubmit:r,onDelete:a}){let[s,c]=p(``),[l,u]=p(!1),m=f(null),h=!n&&s.trim()!==``,g=o(e).filter(e=>l||e.kind===`comment`&&i(e.comment.pageSlug,t));d(()=>{m.current?.scrollTo({top:m.current.scrollHeight})},[g.length]);let v=n=>{if(i(n,t))return/* @__PURE__ */ x(Xe,{children:`this page`});let r=e.changedPages?.find(e=>i(e.slug,n));return/* @__PURE__ */ x(Ze,{to:n,languageInsensitive:!0,children:r?.name||n})};return/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(Re,{children:/* @__PURE__ */ x(E,{size:`small`,value:l,onChange:({value:e})=>u(e),options:[{value:!1,label:`This page`},{value:!0,label:`All pages`}]})}),g.length===0?/* @__PURE__ */ x(ze,{children:l?`No reviews or comments yet.`:`No comments on this page yet.`}):/* @__PURE__ */ x(Be,{ref:m,children:g.map(e=>e.kind===`review`?/* @__PURE__ */ x(H,{author:e.review.author,createdAt:e.review.createdAt,action:/* @__PURE__ */ S(b,{children:[I[e.review.status],` `,/* @__PURE__ */ x(Xe,{children:`the pull request`})]}),text:e.review.comment},e.review.id):/* @__PURE__ */ x(H,{author:e.comment.author,createdAt:e.comment.createdAt,action:/* @__PURE__ */ S(b,{children:[`commented on `,v(e.comment.pageSlug)]}),text:e.comment.comment,tag:e.comment.isPending?/* @__PURE__ */ x(D,{children:`Pending`}):e.comment.isResolved&&/* @__PURE__ */ x(D,{children:`Resolved`}),aside:e.comment.isPending&&/* @__PURE__ */ x(z,{tip:`Delete pending comment`,children:/* @__PURE__ */ x(_,{variant:`text`,size:`small`,icon:/* @__PURE__ */ x(j,{color:`currentColor`}),"aria-label":`Delete pending comment`,disabled:n,onClick:()=>void a(e.comment.id)})}),children:e.replies.length>0&&/* @__PURE__ */ x(Ve,{children:e.replies.map(e=>/* @__PURE__ */ x(H,{author:e.author,createdAt:e.createdAt,action:`replied`,text:e.comment},e.id))})},e.comment.id))}),/* @__PURE__ */ x(we,{onSubmit:async e=>{e.preventDefault(),h&&await r(s.trim())&&c(``)},children:/* @__PURE__ */ S(Te,{children:[/* @__PURE__ */ x(Ee,{autoFocus:!0,rows:2,placeholder:`Comment on this page`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),/* @__PURE__ */ S(De,{children:[/* @__PURE__ */ x($,{children:P}),/* @__PURE__ */ x(_,{type:`submit`,size:`small`,disabled:!h,children:`Comment`})]})]})})]})}function H({author:e,createdAt:t,action:n,text:r,tag:i,aside:a,children:o}){let{format:s}=C();return/* @__PURE__ */ S(He,{children:[e.avatarUrl?/* @__PURE__ */ x(We,{src:e.avatarUrl,alt:``}):/* @__PURE__ */ x(Ge,{"aria-hidden":!0,children:U(e.name)}),/* @__PURE__ */ S(Ke,{children:[/* @__PURE__ */ S(qe,{children:[/* @__PURE__ */ x(`strong`,{children:e.name||`Someone`}),/* @__PURE__ */ x(Je,{dateTime:t,children:s(new Date(t))}),i]}),/* @__PURE__ */ x(Ye,{children:n}),r&&/* @__PURE__ */ x(Qe,{children:r}),o]}),a]})}function U(e){return e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)||`?`}function ue({pullRequest:e,currentSlug:t,open:r,onToggle:i}){if(e.changedPages===null)return/* @__PURE__ */ x(z,{tip:`Platform has not compared this preview with production yet`,children:/* @__PURE__ */ x(Y,{children:`…`})});if(e.changedPages.length===0)return/* @__PURE__ */ x(z,{tip:`No page content changed; navigation, styles, or config can still differ`,children:/* @__PURE__ */ x(Y,{children:`No changed pages`})});let{openable:a,index:o,previous:s,next:c}=n(e.changedPages,t);return/* @__PURE__ */ S(Se,{children:[/* @__PURE__ */ x(z,{tip:s?`Previous: ${s.name||s.slug}`:``,disabled:!s,children:/* @__PURE__ */ x(_,{variant:`text`,icon:/* @__PURE__ */ x(A,{color:`currentColor`}),to:s?.slug,languageInsensitive:!0,disabled:!s,"aria-label":`Previous changed page`})}),/* @__PURE__ */ x(z,{tip:`Changed pages`,disabled:r,children:/* @__PURE__ */ x(_,{variant:`text`,onClick:i,"aria-expanded":r,children:o>=0?`${o+1}/${a.length}`:`${a.length} changed`})}),/* @__PURE__ */ x(z,{tip:c?`Next: ${c.name||c.slug}`:``,disabled:!c,children:/* @__PURE__ */ x(_,{variant:`text`,icon:/* @__PURE__ */ x(ie,{color:`currentColor`}),to:c?.slug,languageInsensitive:!0,disabled:!c,"aria-label":`Next changed page`})})]})}function de({pages:e,currentSlug:t,onOpen:a}){let[o,s]=p(``),[c,l]=p(`all`),u=e.length>5,m=r(e,c,o),h=m.slice(0,500),[g,_]=p(()=>Math.max(h.findIndex(e=>i(e.slug,t)),0)),v=f(null),{openable:y,index:C}=n(e,t);return d(()=>{v.current?.querySelector(`[data-active]`)?.scrollIntoView({block:`nearest`})},[g,o,c]),/* @__PURE__ */ S(b,{children:[u&&/* @__PURE__ */ S(Oe,{children:[/* @__PURE__ */ S(ke,{children:[/* @__PURE__ */ x(oe,{size:`16px`,color:`var(--icon-color-secondary)`}),/* @__PURE__ */ x(Ae,{autoFocus:!0,"aria-label":`Search changed pages`,placeholder:`Search ${e.length} changed pages`,value:o,onChange:e=>{s(e.target.value),_(0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;_(e=>Math.min(Math.max(e+t,0),h.length-1))}else e.key===`Enter`&&(e.preventDefault(),v.current?.querySelector(`[data-active] a`)?.click())}})]}),/* @__PURE__ */ x(je,{children:/* @__PURE__ */ x(E,{size:`small`,value:c,onChange:({value:e})=>{l(e),_(0)},options:N.map(({value:t,label:n})=>({value:t,label:n,element:/* @__PURE__ */ S(b,{children:[n,` `,/* @__PURE__ */ x(Me,{children:r(e,t,``).length})]})}))})})]}),/* @__PURE__ */ S($e,{ref:v,children:[h.map((e,n)=>{let r=i(e.slug,t),o=/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ S(nt,{children:[/* @__PURE__ */ x(rt,{children:e.name||e.slug}),e.name&&e.name!==e.slug&&/* @__PURE__ */ x(it,{children:e.slug})]}),r?/* @__PURE__ */ x(at,{children:`Current`}):!u&&e.mode&&/* @__PURE__ */ x(at,{children:F[e.mode]})]});return/* @__PURE__ */ x(`li`,{"data-active":u&&n===g?``:void 0,children:e.mode===`removed`?/* @__PURE__ */ x(ot,{children:o}):/* @__PURE__ */ x(tt,{to:e.slug,languageInsensitive:!0,onClick:a,$current:r,children:o})},e.slug)}),h.length===0&&/* @__PURE__ */ x(Le,{children:`No changed pages match.`})]}),m.length>h.length&&/* @__PURE__ */ S(Le,{children:[`Showing `,h.length,` of `,m.length,` changed pages. Search to narrow them down.`]}),u&&/* @__PURE__ */ S(Ne,{children:[/* @__PURE__ */ x(`span`,{children:C>=0?`Page ${C+1} of ${y.length}`:`${y.length} changed pages`}),/* @__PURE__ */ x(K,{children:/* @__PURE__ */ S(Pe,{children:[/* @__PURE__ */ x(Q,{children:`↑`}),` `,/* @__PURE__ */ x(Q,{children:`↓`}),` to move · `,/* @__PURE__ */ x(Q,{children:`Enter`}),` to open`]})})]})]})}const W=g`
|
|
1
|
+
import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../use-bar-position.js";import{changedPageNavigation as n,filterChangedPages as r,isSamePage as i}from"./changed-pages.js";import{reviewLoginUrl as a}from"./login-url.js";import{reviewTimeline as o}from"./timeline.js";import{useReview as s}from"./use-review.js";import{createContext as c,useCallback as l,useContext as u,useEffect as d,useRef as f,useState as p}from"react";import m,{css as h,keyframes as g}from"styled-components";import{Button as _}from"@redocly/theme/components/Button/Button";import{breakpoints as v,hiddenWhileMobileMenuOpen as y}from"@redocly/theme/core/utils";import{Fragment as b,jsx as x,jsxs as S}from"react/jsx-runtime";import{useTimeAgo as C}from"@redocly/theme/core/hooks";import{Link as w}from"@redocly/theme/components/Link/Link";import{CheckmarkIcon as ee}from"@redocly/theme/icons/CheckmarkIcon/CheckmarkIcon";import{ChevronRightIcon as T}from"@redocly/theme/icons/ChevronRightIcon/ChevronRightIcon";import{SearchIcon as E}from"@redocly/theme/icons/SearchIcon/SearchIcon";import{DraggableIcon as te}from"@redocly/theme/icons/DraggableIcon/DraggableIcon";import{Spinner as ne}from"@redocly/theme/icons/Spinner/Spinner";import{linkCss as D}from"@redocly/theme/components/Markdown/styles/links";import{Segmented as O}from"@redocly/theme/components/Segmented/Segmented";import{Tag as k}from"@redocly/theme/components/Tag/Tag";import{Tooltip as A}from"@redocly/theme/components/Tooltip/Tooltip";import{ChatIcon as j}from"@redocly/theme/icons/ChatIcon/ChatIcon";import{CloseIcon as M}from"@redocly/theme/icons/CloseIcon/CloseIcon";import{ChevronLeftIcon as N}from"@redocly/theme/icons/ChevronLeftIcon/ChevronLeftIcon";import{MinimizeIcon as re}from"@redocly/theme/icons/MinimizeIcon/MinimizeIcon";import{TrashCanIcon as P}from"@redocly/theme/icons/TrashCanIcon/TrashCanIcon";import{WarningAltIcon as ie}from"@redocly/theme/icons/WarningAltIcon/WarningAltIcon";const F=`realm.review-bar-used`,I=[{value:`all`,label:`All`},{value:`modified`,label:`Modified`},{value:`added`,label:`Added`},{value:`removed`,label:`Removed`}],L=/Mac|iPhone|iPad/.test(navigator.platform)?`⌘ Enter`:`Ctrl Enter`,R={added:`Added`,modified:`Modified`,removed:`Removed`},z={APPROVED:`approved`,REQUESTED_CHANGES:`requested changes on`,COMMENTED:`commented on`},B=c(`middle`);function ae(){try{return localStorage.getItem(F)===`1`}catch{return!1}}function V(){try{localStorage.setItem(F,`1`)}catch{}}function H({children:e,...t}){let n=u(B);return/* @__PURE__ */ x(A,{...t,placement:`top`,fallbackPlacements:[],arrowPosition:n===`middle`?`center`:n,children:e})}function U(){let n=u(e),{state:r,error:o,submitting:c,addComment:f,deleteComment:m}=s(),[h,g]=p(null),{barRef:v,slot:y,dragging:C,style:w,onDragStart:T}=t({storageKey:`realm.review-bar-slot`,defaultSlot:`left`,frozen:h!==null}),[E,D]=p(!1),[O,k]=p(!1),[A,N]=p(0),[P,F]=p(ae),I=l(()=>{let e=v.current?.getBoundingClientRect().width;!e||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?F(!0):g(e)},[v]);if(d(()=>{if(P||h!==null||E||O)return;let e=e=>{e.target instanceof Node&&v.current?.contains(e.target)||I()};return window.addEventListener(`wheel`,e,{passive:!0}),window.addEventListener(`touchmove`,e,{passive:!0}),()=>{window.removeEventListener(`wheel`,e),window.removeEventListener(`touchmove`,e)}},[P,h,E,O,v,I]),d(()=>{if(!E&&!O)return;let e=e=>{e.key===`Escape`&&(O?k(!1):D(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E,O]),window.self!==window.top)return null;let L=n?.slug??`/`,R=r?.signedIn?r.pullRequest:null,z=E&&R!==null,U=R?.pageComments.filter(e=>!e.replyToId&&!e.isResolved&&i(e.pageSlug,L)).length??0,W=/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(H,{tip:`Drag to move`,disabled:C,children:/* @__PURE__ */ x(ye,{type:`button`,"aria-label":`Drag the review bar`,onPointerDown:T,$dragging:C,children:/* @__PURE__ */ x(te,{size:`16px`,color:`var(--icon-color-secondary)`})})}),r===null&&!o&&/* @__PURE__ */ x(Y,{children:/* @__PURE__ */ x(ne,{size:`16px`,color:`var(--icon-color-secondary)`})}),r?.signedIn===!1&&/* @__PURE__ */ x(_,{variant:`primary`,onClick:()=>{V(),window.location.assign(a(n?.path??`/`))},children:`Log in to review`}),r?.signedIn&&!R&&/* @__PURE__ */ x(Z,{children:`No open pull request`}),R&&/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ S(J,{children:[/* @__PURE__ */ x(H,{tip:`${R.title} — open in Platform`,children:/* @__PURE__ */ S(_,{variant:`text`,to:R.url,external:!0,children:[`#`,R.number]})}),/* @__PURE__ */ x(X,{})]}),/* @__PURE__ */ x(se,{pullRequest:R,currentSlug:L,open:O,onToggle:()=>{V(),N(v.current?.getBoundingClientRect().top??0),k(e=>!e)}}),z?/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(_e,{}),/* @__PURE__ */ x(H,{tip:`Close`,children:/* @__PURE__ */ x(_,{variant:`text`,icon:/* @__PURE__ */ x(M,{color:`currentColor`}),"aria-label":`Close the review`,onClick:()=>D(!1)})})]}):/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(X,{}),/* @__PURE__ */ x(H,{tip:R.decision===`APPROVED`?`You approved`:R.decision===`REQUESTED_CHANGES`?`You requested changes`:`Comment on pages, then finish your review in Platform`,children:/* @__PURE__ */ S(_,{variant:`primary`,"aria-expanded":!1,onClick:()=>{V(),k(!1),D(!0)},icon:R.decision===`APPROVED`?/* @__PURE__ */ x(ee,{color:`currentColor`}):R.decision===`REQUESTED_CHANGES`?/* @__PURE__ */ x(M,{color:`currentColor`}):void 0,children:[`Review`,U>0&&/* @__PURE__ */ S(Ie,{"aria-label":`${U} open comments on this page`,children:[/* @__PURE__ */ x(j,{size:`12px`,color:`currentColor`}),U]})]})})]})]}),o&&/* @__PURE__ */ x(H,{tip:o,children:/* @__PURE__ */ x(Y,{role:`alert`,"aria-label":o,children:/* @__PURE__ */ x(ie,{size:`16px`,color:`var(--color-error-base)`})})}),!z&&/* @__PURE__ */ x(H,{tip:`Collapse`,children:/* @__PURE__ */ x(_,{variant:`text`,icon:/* @__PURE__ */ x(re,{color:`currentColor`}),"aria-label":`Collapse the review bar`,onClick:()=>{V(),k(!1),I()}})})]}),G=o??(r?.signedIn===!1?`Log in to review`:r?.signedIn&&!R?`No open pull request`:`Review`),K=/* @__PURE__ */ x(H,{tip:G,children:/* @__PURE__ */ S(me,{type:`button`,"aria-label":G,"aria-expanded":!1,onClick:()=>{V(),F(!1)},children:[/* @__PURE__ */ x(j,{size:`18px`,color:`var(--icon-color-primary)`}),o?/* @__PURE__ */ x(q,{role:`alert`,$tone:`error`}):r?.signedIn===!1?/* @__PURE__ */ x(q,{$tone:`info`}):U>0?/* @__PURE__ */ x(he,{children:U}):null]})});return/* @__PURE__ */ x(B.Provider,{value:y,children:/* @__PURE__ */ S(pe,{ref:v,style:h===null?w:{...w,"--review-bar-collapse-from":`${h}px`},$dragging:C,$expanded:z,$collapsed:P,$collapsing:h!==null,onAnimationEnd:e=>{e.target===e.currentTarget&&h!==null&&(g(null),F(!0))},"data-testid":`review-bar`,children:[P?K:z?/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(ge,{children:W}),/* @__PURE__ */ x(ve,{children:/* @__PURE__ */ x(oe,{pullRequest:R,currentSlug:L,submitting:c,onComment:e=>f({pageSlug:L,text:e}),onDelete:m})})]}):W,!P&&O&&R&&/* @__PURE__ */ x(xe,{$slot:y,style:{maxHeight:`min(50vh, calc(${A}px - 2 * var(--spacing-xs)))`},children:/* @__PURE__ */ x(ce,{pages:R.changedPages??[],currentSlug:L,onOpen:()=>k(!1)})})]})})}function oe({pullRequest:e,currentSlug:t,submitting:n,onComment:r,onDelete:i}){let a=e.pageComments.filter(e=>e.isPending).length;return/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(W,{pullRequest:e,currentSlug:t,submitting:n,onSubmit:r,onDelete:i}),/* @__PURE__ */ S(Fe,{children:[/* @__PURE__ */ x($,{children:a===0?`Comments are posted when you finish your review.`:`${a} pending ${a===1?`comment`:`comments`}`}),e.url&&/* @__PURE__ */ x(H,{tip:`Approve or request changes in Platform`,children:/* @__PURE__ */ x(_,{variant:`primary`,to:`${e.url}/review?finishReview=true`,external:!0,children:`Finish review`})})]})]})}function W({pullRequest:e,currentSlug:t,submitting:n,onSubmit:r,onDelete:a}){let[s,c]=p(``),[l,u]=p(!1),m=f(null),h=!n&&s.trim()!==``,g=o(e).filter(e=>l||e.kind===`comment`&&i(e.comment.pageSlug,t));d(()=>{m.current?.scrollTo({top:m.current.scrollHeight})},[g.length]);let v=n=>{if(i(n,t))return/* @__PURE__ */ x(Xe,{children:`this page`});let r=e.changedPages?.find(e=>i(e.slug,n));return/* @__PURE__ */ x(Ze,{to:n,languageInsensitive:!0,children:r?.name||n})};return/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(Re,{children:/* @__PURE__ */ x(O,{size:`small`,value:l,onChange:({value:e})=>u(e),options:[{value:!1,label:`This page`},{value:!0,label:`All pages`}]})}),g.length===0?/* @__PURE__ */ x(ze,{children:l?`No reviews or comments yet.`:`No comments on this page yet.`}):/* @__PURE__ */ x(Be,{ref:m,children:g.map(e=>e.kind===`review`?/* @__PURE__ */ x(G,{author:e.review.author,createdAt:e.review.createdAt,action:/* @__PURE__ */ S(b,{children:[z[e.review.status],` `,/* @__PURE__ */ x(Xe,{children:`the pull request`})]}),text:e.review.comment},e.review.id):/* @__PURE__ */ x(G,{author:e.comment.author,createdAt:e.comment.createdAt,action:/* @__PURE__ */ S(b,{children:[`commented on `,v(e.comment.pageSlug)]}),text:e.comment.comment,tag:e.comment.isPending?/* @__PURE__ */ x(k,{children:`Pending`}):e.comment.isResolved&&/* @__PURE__ */ x(k,{children:`Resolved`}),aside:e.comment.isPending&&/* @__PURE__ */ x(H,{tip:`Delete pending comment`,children:/* @__PURE__ */ x(_,{variant:`text`,size:`small`,icon:/* @__PURE__ */ x(P,{color:`currentColor`}),"aria-label":`Delete pending comment`,disabled:n,onClick:()=>void a(e.comment.id)})}),children:e.replies.length>0&&/* @__PURE__ */ x(Ve,{children:e.replies.map(e=>/* @__PURE__ */ x(G,{author:e.author,createdAt:e.createdAt,action:`replied`,text:e.comment},e.id))})},e.comment.id))}),/* @__PURE__ */ x(Se,{onSubmit:async e=>{e.preventDefault(),h&&await r(s.trim())&&c(``)},children:/* @__PURE__ */ S(Te,{children:[/* @__PURE__ */ x(Ee,{autoFocus:!0,rows:2,placeholder:`Comment on this page`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),/* @__PURE__ */ S(De,{children:[/* @__PURE__ */ x($,{children:L}),/* @__PURE__ */ x(_,{type:`submit`,size:`small`,disabled:!h,children:`Comment`})]})]})})]})}function G({author:e,createdAt:t,action:n,text:r,tag:i,aside:a,children:o}){let{format:s}=C();return/* @__PURE__ */ S(He,{children:[e.avatarUrl?/* @__PURE__ */ x(We,{src:e.avatarUrl,alt:``}):/* @__PURE__ */ x(Ge,{"aria-hidden":!0,children:K(e.name)}),/* @__PURE__ */ S(Ke,{children:[/* @__PURE__ */ S(qe,{children:[/* @__PURE__ */ x(`strong`,{children:e.name||`Someone`}),/* @__PURE__ */ x(Je,{dateTime:t,children:s(new Date(t))}),i]}),/* @__PURE__ */ x(Ye,{children:n}),r&&/* @__PURE__ */ x(Qe,{children:r}),o]}),a]})}function K(e){return e.split(/\s+/).filter(Boolean).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)||`?`}function se({pullRequest:e,currentSlug:t,open:r,onToggle:i}){if(e.changedPages===null)return/* @__PURE__ */ x(H,{tip:`Platform has not compared this preview with production yet`,children:/* @__PURE__ */ x(Z,{children:`…`})});if(e.changedPages.length===0)return/* @__PURE__ */ x(H,{tip:`No page content changed; navigation, styles, or config can still differ`,children:/* @__PURE__ */ x(Z,{children:`No changed pages`})});let{openable:a,index:o,previous:s,next:c}=n(e.changedPages,t);return/* @__PURE__ */ S(be,{children:[/* @__PURE__ */ x(H,{tip:s?`Previous: ${s.name||s.slug}`:``,disabled:!s,children:/* @__PURE__ */ x(_,{variant:`text`,icon:/* @__PURE__ */ x(N,{color:`currentColor`}),to:s?.slug,languageInsensitive:!0,disabled:!s,"aria-label":`Previous changed page`})}),/* @__PURE__ */ x(H,{tip:`Changed pages`,disabled:r,children:/* @__PURE__ */ x(_,{variant:`text`,onClick:i,"aria-expanded":r,children:o>=0?`${o+1}/${a.length}`:`${a.length} changed`})}),/* @__PURE__ */ x(H,{tip:c?`Next: ${c.name||c.slug}`:``,disabled:!c,children:/* @__PURE__ */ x(_,{variant:`text`,icon:/* @__PURE__ */ x(T,{color:`currentColor`}),to:c?.slug,languageInsensitive:!0,disabled:!c,"aria-label":`Next changed page`})})]})}function ce({pages:e,currentSlug:t,onOpen:a}){let[o,s]=p(``),[c,l]=p(`all`),u=e.length>5,m=r(e,c,o),h=m.slice(0,500),[g,_]=p(()=>Math.max(h.findIndex(e=>i(e.slug,t)),0)),v=f(null),{openable:y,index:C}=n(e,t);return d(()=>{v.current?.querySelector(`[data-active]`)?.scrollIntoView({block:`nearest`})},[g,o,c]),/* @__PURE__ */ S(b,{children:[u&&/* @__PURE__ */ S(Oe,{children:[/* @__PURE__ */ S(ke,{children:[/* @__PURE__ */ x(E,{size:`16px`,color:`var(--icon-color-secondary)`}),/* @__PURE__ */ x(Ae,{autoFocus:!0,"aria-label":`Search changed pages`,placeholder:`Search ${e.length} changed pages`,value:o,onChange:e=>{s(e.target.value),_(0)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;_(e=>Math.min(Math.max(e+t,0),h.length-1))}else e.key===`Enter`&&(e.preventDefault(),v.current?.querySelector(`[data-active] a`)?.click())}})]}),/* @__PURE__ */ x(je,{children:/* @__PURE__ */ x(O,{size:`small`,value:c,onChange:({value:e})=>{l(e),_(0)},options:I.map(({value:t,label:n})=>({value:t,label:n,element:/* @__PURE__ */ S(b,{children:[n,` `,/* @__PURE__ */ x(Me,{children:r(e,t,``).length})]})}))})})]}),/* @__PURE__ */ S($e,{ref:v,children:[h.map((e,n)=>{let r=i(e.slug,t),o=/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ S(nt,{children:[/* @__PURE__ */ x(rt,{children:e.name||e.slug}),e.name&&e.name!==e.slug&&/* @__PURE__ */ x(it,{children:e.slug})]}),r?/* @__PURE__ */ x(at,{children:`Current`}):!u&&e.mode&&/* @__PURE__ */ x(at,{children:R[e.mode]})]});return/* @__PURE__ */ x(`li`,{"data-active":u&&n===g?``:void 0,children:e.mode===`removed`?/* @__PURE__ */ x(ot,{children:o}):/* @__PURE__ */ x(tt,{to:e.slug,languageInsensitive:!0,onClick:a,$current:r,children:o})},e.slug)}),h.length===0&&/* @__PURE__ */ x(Le,{children:`No changed pages match.`})]}),m.length>h.length&&/* @__PURE__ */ S(Le,{children:[`Showing `,h.length,` of `,m.length,` changed pages. Search to narrow them down.`]}),u&&/* @__PURE__ */ S(Ne,{children:[/* @__PURE__ */ x(`span`,{children:C>=0?`Page ${C+1} of ${y.length}`:`${y.length} changed pages`}),/* @__PURE__ */ x(J,{children:/* @__PURE__ */ S(Pe,{children:[/* @__PURE__ */ x(Q,{children:`↑`}),` `,/* @__PURE__ */ x(Q,{children:`↓`}),` to move · `,/* @__PURE__ */ x(Q,{children:`Enter`}),` to open`]})})]})]})}const le=g`
|
|
2
2
|
from {
|
|
3
3
|
opacity: 0;
|
|
4
4
|
}
|
|
5
|
-
`,
|
|
5
|
+
`,ue=g`
|
|
6
6
|
to {
|
|
7
7
|
opacity: 0;
|
|
8
8
|
}
|
|
9
|
-
`,
|
|
9
|
+
`,de=g`
|
|
10
10
|
from {
|
|
11
11
|
width: var(--review-bar-collapse-from);
|
|
12
12
|
}
|
|
@@ -14,12 +14,12 @@ import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../
|
|
|
14
14
|
width: var(--ai-assistant-button-icon-size);
|
|
15
15
|
border-radius: calc(var(--ai-assistant-button-icon-size) / 2);
|
|
16
16
|
}
|
|
17
|
-
`,
|
|
17
|
+
`,fe=g`
|
|
18
18
|
from {
|
|
19
19
|
opacity: 0;
|
|
20
20
|
transform: scale(0.6);
|
|
21
21
|
}
|
|
22
|
-
`,
|
|
22
|
+
`,pe=m.div`
|
|
23
23
|
position: fixed;
|
|
24
24
|
bottom: var(--ai-assistant-button-bottom);
|
|
25
25
|
display: inline-flex;
|
|
@@ -42,7 +42,7 @@ import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../
|
|
|
42
42
|
|
|
43
43
|
@media (prefers-reduced-motion: no-preference) {
|
|
44
44
|
& > * {
|
|
45
|
-
animation: ${
|
|
45
|
+
animation: ${le} 160ms ease-out;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -71,14 +71,14 @@ import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../
|
|
|
71
71
|
overflow: hidden;
|
|
72
72
|
|
|
73
73
|
@media (prefers-reduced-motion: no-preference) {
|
|
74
|
-
animation: ${
|
|
74
|
+
animation: ${de} 220ms ease-in-out forwards;
|
|
75
75
|
|
|
76
76
|
& > * {
|
|
77
|
-
animation: ${
|
|
77
|
+
animation: ${ue} 120ms ease-in forwards;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
`}
|
|
81
|
-
`,
|
|
81
|
+
`,me=m.button`
|
|
82
82
|
position: relative;
|
|
83
83
|
display: inline-flex;
|
|
84
84
|
flex: 1;
|
|
@@ -91,13 +91,13 @@ import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../
|
|
|
91
91
|
cursor: pointer;
|
|
92
92
|
|
|
93
93
|
@media (prefers-reduced-motion: no-preference) {
|
|
94
|
-
animation: ${
|
|
94
|
+
animation: ${fe} 180ms ease-out;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
&:hover {
|
|
98
98
|
background: var(--bg-color-hover);
|
|
99
99
|
}
|
|
100
|
-
`,
|
|
100
|
+
`,q=m.span`
|
|
101
101
|
position: absolute;
|
|
102
102
|
top: var(--spacing-xs);
|
|
103
103
|
right: var(--spacing-xs);
|
|
@@ -106,7 +106,7 @@ import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../
|
|
|
106
106
|
border-radius: 50%;
|
|
107
107
|
background: ${({$tone:e})=>e===`error`?`var(--color-error-base)`:`var(--color-info-base)`};
|
|
108
108
|
box-shadow: 0 0 0 2px var(--bg-color-raised);
|
|
109
|
-
`,
|
|
109
|
+
`,he=m.span`
|
|
110
110
|
position: absolute;
|
|
111
111
|
top: calc(-1 * var(--spacing-xxs));
|
|
112
112
|
right: calc(-1 * var(--spacing-xxs));
|
|
@@ -119,27 +119,27 @@ import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../
|
|
|
119
119
|
font-size: var(--font-size-sm);
|
|
120
120
|
line-height: 16px;
|
|
121
121
|
text-align: center;
|
|
122
|
-
`,
|
|
122
|
+
`,ge=m.div`
|
|
123
123
|
display: flex;
|
|
124
124
|
align-items: center;
|
|
125
125
|
gap: var(--spacing-xxs);
|
|
126
126
|
white-space: nowrap;
|
|
127
|
-
`,
|
|
127
|
+
`,_e=m.span`
|
|
128
128
|
flex: 1;
|
|
129
|
-
`,
|
|
129
|
+
`,ve=m.div`
|
|
130
130
|
display: flex;
|
|
131
131
|
flex-direction: column;
|
|
132
132
|
min-height: 0;
|
|
133
133
|
border-top: 1px solid var(--border-color-secondary);
|
|
134
134
|
user-select: text;
|
|
135
135
|
cursor: auto;
|
|
136
|
-
`,
|
|
136
|
+
`,J=m.span`
|
|
137
137
|
display: contents;
|
|
138
138
|
|
|
139
139
|
@media screen and (max-width: ${v.small}) {
|
|
140
140
|
display: none;
|
|
141
141
|
}
|
|
142
|
-
`,
|
|
142
|
+
`,ye=m.button`
|
|
143
143
|
display: inline-flex;
|
|
144
144
|
align-items: center;
|
|
145
145
|
align-self: stretch;
|
|
@@ -148,21 +148,21 @@ import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../
|
|
|
148
148
|
background: transparent;
|
|
149
149
|
touch-action: none;
|
|
150
150
|
cursor: ${({$dragging:e})=>e?`grabbing`:`grab`};
|
|
151
|
-
`,
|
|
151
|
+
`,Y=m.span`
|
|
152
152
|
display: inline-flex;
|
|
153
153
|
padding: 0 var(--spacing-xs);
|
|
154
|
-
`,
|
|
154
|
+
`,be=m.span`
|
|
155
155
|
display: inline-flex;
|
|
156
156
|
align-items: center;
|
|
157
|
-
`,
|
|
157
|
+
`,X=m.span`
|
|
158
158
|
align-self: stretch;
|
|
159
159
|
width: 1px;
|
|
160
160
|
margin: var(--spacing-xs) 0;
|
|
161
161
|
background: var(--border-color-secondary);
|
|
162
|
-
`,
|
|
162
|
+
`,Z=m.span`
|
|
163
163
|
padding: 0 var(--spacing-xs);
|
|
164
164
|
color: var(--text-color-description);
|
|
165
|
-
`,
|
|
165
|
+
`,xe=m.div`
|
|
166
166
|
position: absolute;
|
|
167
167
|
display: flex;
|
|
168
168
|
flex-direction: column;
|
|
@@ -178,10 +178,10 @@ import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../
|
|
|
178
178
|
white-space: normal;
|
|
179
179
|
user-select: text;
|
|
180
180
|
cursor: auto;
|
|
181
|
-
`,
|
|
181
|
+
`,Se=m.form`
|
|
182
182
|
padding: var(--spacing-xs);
|
|
183
183
|
border-top: 1px solid var(--border-color-secondary);
|
|
184
|
-
`,
|
|
184
|
+
`,Ce=h`
|
|
185
185
|
border: 1px solid var(--input-border-color);
|
|
186
186
|
border-radius: var(--input-border-radius);
|
|
187
187
|
background: var(--input-bg-color);
|
|
@@ -194,7 +194,7 @@ import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../
|
|
|
194
194
|
border-color: var(--text-color-disabled);
|
|
195
195
|
box-shadow: 0 0 0 2px var(--border-color-secondary);
|
|
196
196
|
}
|
|
197
|
-
`,
|
|
197
|
+
`,we=h`
|
|
198
198
|
border: 0;
|
|
199
199
|
outline: none;
|
|
200
200
|
background: transparent;
|
|
@@ -205,12 +205,12 @@ import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../
|
|
|
205
205
|
color: var(--input-content-placeholder-color);
|
|
206
206
|
}
|
|
207
207
|
`,Te=m.div`
|
|
208
|
-
${
|
|
208
|
+
${Ce}
|
|
209
209
|
display: flex;
|
|
210
210
|
flex-direction: column;
|
|
211
211
|
padding: var(--spacing-xxs) var(--spacing-xs);
|
|
212
212
|
`,Ee=m.textarea`
|
|
213
|
-
${
|
|
213
|
+
${we}
|
|
214
214
|
box-sizing: border-box;
|
|
215
215
|
width: 100%;
|
|
216
216
|
padding: var(--spacing-xxs);
|
|
@@ -227,13 +227,13 @@ import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../
|
|
|
227
227
|
padding: var(--spacing-xs);
|
|
228
228
|
border-bottom: 1px solid var(--border-color-secondary);
|
|
229
229
|
`,ke=m.label`
|
|
230
|
-
${
|
|
230
|
+
${Ce}
|
|
231
231
|
display: flex;
|
|
232
232
|
align-items: center;
|
|
233
233
|
gap: var(--spacing-xs);
|
|
234
234
|
padding: var(--spacing-xxs) var(--spacing-sm);
|
|
235
235
|
`,Ae=m.input`
|
|
236
|
-
${
|
|
236
|
+
${we}
|
|
237
237
|
flex: 1;
|
|
238
238
|
min-width: 0;
|
|
239
239
|
padding: 0;
|
|
@@ -351,7 +351,7 @@ import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../
|
|
|
351
351
|
color: var(--text-color-primary);
|
|
352
352
|
font-weight: var(--font-weight-medium);
|
|
353
353
|
`,Ze=m(w)`
|
|
354
|
-
${
|
|
354
|
+
${D}
|
|
355
355
|
`,Qe=m.p`
|
|
356
356
|
margin: var(--spacing-xxs) 0 0;
|
|
357
357
|
color: var(--text-color-primary);
|
|
@@ -412,4 +412,4 @@ import{PageContext as e}from"../contexts.js";import{useBarPosition as t}from"../
|
|
|
412
412
|
${rt} {
|
|
413
413
|
text-decoration: line-through;
|
|
414
414
|
}
|
|
415
|
-
`;export{
|
|
415
|
+
`;export{U as ReviewBar};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PLATFORM_LOGIN_PARAM as
|
|
1
|
+
import{IDP_LOGIN_ROUTE_PATH as e,PLATFORM_LOGIN_PARAM as t}from"../../shared/constants/review.js";import{withPathPrefix as n}from"../../shared/path-prefix.js";function r(r){return n(`${e}?redirectTo=${encodeURIComponent(r)}&${t}=true`)}export{r as reviewLoginUrl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{delocalizeRouteSlug as e,toLocaleSlug as t}from"../shared/utils/l10n.js";import{stripPathPrefix as n,withPathPrefix as r}from"../shared/path-prefix.js";import{SIDEBAR_ROUTE_DEP_KEY as i}from"../shared/constants/route-deps.js";import{LoaderDataContext as a,PageContext as o}from"./contexts.js";import{useL10nConfig as s}from"./l10n/use-l10n-config.js";import{
|
|
1
|
+
import{delocalizeRouteSlug as e,toLocaleSlug as t}from"../shared/utils/l10n.js";import{stripPathPrefix as n,withPathPrefix as r}from"../shared/path-prefix.js";import{SIDEBAR_ROUTE_DEP_KEY as i}from"../shared/constants/route-deps.js";import{LoaderDataContext as a,PageContext as o}from"./contexts.js";import{useL10nConfig as s}from"./l10n/use-l10n-config.js";import{useTranslate as c}from"./l10n/use-translate.js";import{normalizePageSlug as l}from"./utils/routes/normalize-page-slug.js";import{HistoryMount as u}from"./history-mount.js";import{VersionPicker as d}from"./VersionPicker.js";import{selectEntityRevisions as f}from"./use-entity-revisions.js";import{selectPageVersions as p}from"./use-page-versions.js";import{flattenTabItems as m,isTabbedSidebar as h}from"./sidebar/navigation-tabs.js";import{pageLoader as g}from"./app.js";import{DEFAULT_LOCALE_PLACEHOLDER as _,VERSION_NOT_SPECIFIED as v}from"@redocly/theme/core/constants";import{useContext as y,useEffect as b,useRef as x}from"react";import{useLocation as S,useNavigate as C}from"react-router";import{buildRevisionUrl as w,transformRevisionsToVersionHistory as T}from"@redocly/theme/core/utils";import{jsx as E}from"react/jsx-runtime";async function D(e,n,a,o,s=``){let c=new URL(r(t(n,s)),window.location.origin),l=await g({request:new Request(c)});if(l instanceof Response)return t(n,s);let u=l.loaderData[i],d=h(u)?m(u.tabs):u,f=p(d,{...a,slug:o});return t(f.find(t=>t.version===e)?.link??n,s)}function O({pageVersion:r,pageVersions:i}){let p=y(a),m=y(o),{key:h,pathname:g,search:O}=S(),k=C(),{entityKey:A,items:j}=f(p),{currentLocale:M,defaultLocale:N}=s(),{translate:P}=c(),F=x(null);if(b(()=>()=>{F.current=null},[h]),!A||j.length===0)return null;let I=new URLSearchParams(O),L=I.get(`revision`),R=I.get(`version`)??r??j.find(e=>e.isCurrent)?.version??null,z=R??v,B=T({revisions:j,currentRevisionDate:L??void 0,currentVersion:R,locale:M&&M!==_?M:`en-US`}).map(e=>{let t=e.version===z,n=e.link??i.find(t=>t.version===e.version)?.link,r=n??g;return{version:e.version,label:e.version===v?P(`versionPicker.unversioned`,`All versions`):e.label??e.version,link:r,isActive:t,revisions:(e.revisions??[]).map(i=>{let a=i.isCurrent===!0;return{name:i.name,date:i.date,link:a?r:w(r,i.revisionDate,n?void 0:e.version)??r,isCurrent:a,isActive:t&&(L?i.revisionDate===L:a)}})}});return B.length<2&&(B[0]?.revisions.length??0)<2?null:/* @__PURE__ */ E(u,{children:/* @__PURE__ */ E(d,{versions:B,fallbackLabel:R??void 0,onSelect:(i,a)=>{let o=j.find(e=>e.version===a.version&&e.versionLink!==void 0)?.versionLink;if(o===void 0)return;i.preventDefault();let s=M===N?``:M,c=t=>s&&e(t,s)||t,u=c(l(o)),d=c(l(n(window.location.pathname)??window.location.pathname)),f=a.version===r?Promise.resolve(t(d,s)):D(a.version,u,m,d,s).catch(()=>t(u,s)),{search:p}=new URL(a.link,window.location.origin),h={};F.current=h,f.then(e=>{F.current===h&&k(`${e}${p}`)})}})})}export{O as PageRevisionsHistory,D as resolveVersionSwitch};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as e}from"../shared/utils/is-object.js";import{interpolateEnvVariables as t,productConfigOverrideSchema as n,rootRedoclyConfigSchema as r}from"@redocly/config";const i=r.properties,a={type:`string`,pattern:`\\S`},o={...i.apis.additionalProperties,required:[`root`]},s={...i.scripts.properties.head.items,required:[`src`]},c=i.redirects.additionalProperties,l=
|
|
1
|
+
import{isObject as e}from"../shared/utils/is-object.js";import{interpolateEnvVariables as t,productConfigOverrideSchema as n,rootRedoclyConfigSchema as r}from"@redocly/config";const i=r.properties,a={type:`string`,pattern:`\\S`},o={...i.apis.additionalProperties,required:[`root`]},s={...i.scripts.properties.head.items,required:[`src`]},c=i.redirects.additionalProperties,l={type:`object`,additionalProperties:o},u={...i.scripts,properties:{head:{type:`array`,items:s},body:{type:`array`,items:s}}},d={...i.redirects,propertyNames:a,additionalProperties:{...c,properties:{...c.properties,to:a},required:[`to`]}},f={type:`object`,properties:{include:{type:`array`,items:{type:`string`,minLength:1}},max:{type:`integer`,minimum:1}},additionalProperties:!1},p={type:`object`,properties:{anchors:{type:`object`,properties:{hide:{type:`boolean`},severity:{type:`string`,enum:[`error`,`warning`]}},additionalProperties:!1}},additionalProperties:!1};function m(e){return{...r,properties:{...e,...i,apis:l,linkChecker:p,redirects:d,revisions:f,scripts:u},additionalProperties:!0}}m({});const h={...n,properties:{...n.properties,apis:l,asyncapi:i.asyncapi,graphql:i.graphql,grpc:i.grpc}},g={type:`object`,properties:{banner:i.banner}},_=Symbol(`drop`);function v(n,r,i={}){let{env:a}=i,o={problems:[],resolve:a?e=>t(e,a).value:e=>e},s=y(n,structuredClone(r),``,o);return{value:e(s)?s:{},problems:o.problems}}function y(t,n,r,i){if(t===!0)return n;if(t===!1)return A(i,r,`is not allowed`);let a=x(t,b(n,i));if(a!==void 0)return A(i,r,a);let o=n;return e(n)?o=S(t,n,r,i):Array.isArray(n)&&(o=w(t,n,r,i)),o!==_&&t.oneOf&&(o=T(t.oneOf,t.discriminator,n,o,r,i)),o!==_&&t.not!==void 0&&E(t.not,o,i)&&i.problems.push({code:`configuration/invalid`,message:`${j(r)} ${k(t.not)}.`}),o}function b(e,t){return typeof e==`string`?t.resolve(e):e}function x(e,t){if(e.type!==void 0&&!D(t,e.type))return`must be ${e.type}`;if(e.enum&&!e.enum.some(e=>O(e,t)))return`must be one of: ${e.enum.join(`, `)}`;if(e.const!==void 0&&!O(e.const,t))return`must be ${JSON.stringify(e.const)}`;if(typeof t==`string`){if(e.minLength!==void 0&&t.length<e.minLength)return e.minLength===1?`must not be empty`:`must have at least ${e.minLength} characters`;if(e.pattern!==void 0&&!new RegExp(e.pattern,`u`).test(t))return e.pattern===`\\S`?`must not be empty`:`must match the pattern ${e.pattern}`}if(typeof t==`number`&&e.minimum!==void 0&&t<e.minimum)return`must be at least ${e.minimum}`}function S(e,t,n,r){let i=[];for(let[a,o]of Object.entries(t)){let t=M(n,a);if(e.propertyNames!==void 0&&!E(e.propertyNames,a,r)){A(r,t,`has an invalid name`);continue}let s=C(e,a);if(s===void 0){r.problems.push({code:`configuration/ignored`,message:`\`${t}\` is not a known option and is ignored.`}),i.push([a,o]);continue}let c=y(s,o,t,r);c!==_&&i.push([a,c])}let a=Object.fromEntries(i),o=e.required??[],s=o.find(e=>!Object.hasOwn(t,e));if(s!==void 0)return A(r,n,`must have required property '${s}'`);if(e.minProperties!==void 0){if(Object.keys(t).length<e.minProperties)return A(r,n,e.minProperties===1?`must not be empty`:`must have at least ${e.minProperties} properties`);if(Object.keys(a).length<e.minProperties)return _}return o.every(e=>Object.hasOwn(a,e))?a:_}function C(e,t){if(e.properties&&Object.hasOwn(e.properties,t))return e.properties[t];for(let[n,r]of Object.entries(e.patternProperties??{}))if(new RegExp(n,`u`).test(t))return r;return e.additionalProperties===!1?void 0:e.additionalProperties??!0}function w(e,t,n,r){let{items:i}=e,a=i===void 0?t:t.flatMap((e,t)=>{let a=y(i,e,M(n,t),r);return a===_?[]:[a]});if(e.minItems!==void 0){if(t.length<e.minItems)return A(r,n,e.minItems===1?`must not be empty`:`must have at least ${e.minItems} items`);if(a.length<e.minItems)return _}return e.uniqueItems&&new Set(t.map(e=>JSON.stringify(e))).size<t.length?A(r,n,`must not have duplicate items`):a}function T(t,n,r,i,a,o){if(n){let r=n.propertyName,s=e(i)?b(i[r],o):void 0,c=t.find(e=>{let t=typeof e==`object`?e.properties?.[r]:void 0;return s!==void 0&&typeof t==`object`&&t.const===s});return c===void 0?A(o,a,`has an invalid value`):y(c,i,a,o)}let s=e=>t.filter(t=>E(t,e,o)).length;return s(r)===1?s(i)===1?i:_:A(o,a,`has an invalid value`)}function E(e,t,n){let r={problems:[],resolve:n.resolve};return y(e,t,``,r),r.problems.length===0}function D(t,n){switch(n){case`object`:return e(t);case`array`:return Array.isArray(t);case`integer`:return Number.isInteger(t);case`number`:return typeof t==`number`&&Number.isFinite(t);default:return typeof t===n}}function O(e,t){return JSON.stringify(e)===JSON.stringify(t)}function k(e){let t=typeof e==`object`?e.required:void 0;return t?`must not set both ${t.map(e=>`\`${e}\``).join(` and `)}`:`has a value that is not allowed`}function A(e,t,n){return e.problems.push({code:`configuration/invalid`,message:`${j(t)} ${n} and is ignored.`}),_}function j(e){return e===``?`The config`:`\`${e}\``}function M(e,t){return typeof t==`number`?`${e}[${t}]`:e===``?t:/^[A-Za-z_$][\w$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}export{h as NESTED_CONFIG_SCHEMA,g as PAGE_BANNER_SCHEMA,m as realmConfigSchema,v as sanitizeConfig};
|
|
@@ -92,4 +92,12 @@ export declare function normalizeRedoclyConfig(config: Record<string, unknown>,
|
|
|
92
92
|
pluginSchemas?: Readonly<Record<string, ConfigSchema>>;
|
|
93
93
|
report?: (problem: ProblemDraft) => void;
|
|
94
94
|
}): RealmConfig;
|
|
95
|
+
/**
|
|
96
|
+
* `grpc.importPaths` of the config in the content-relative folder `configDir`: the content-relative
|
|
97
|
+
* folders a parse reads, and the entries, as written, that leave the content root.
|
|
98
|
+
*/
|
|
99
|
+
export declare function resolveGrpcImportPaths(importPaths: string | string[], configDir: string): {
|
|
100
|
+
folders: string[];
|
|
101
|
+
outside: string[];
|
|
102
|
+
};
|
|
95
103
|
export declare function createEmptyRealmConfig(): RealmConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toJsonObject as e,toJsonValue as t}from"./database/utils/json.js";import{hashContentBytes as n}from"../shared/utils/content-hash.js";import{getProcessEnv as r,getPublicEnv as i,resolveRedoclyEnvironment as a,sanitizeBranchName as o}from"../shared/public-env.js";import{isClosedToAnonymous as s,parseRbacConfigData as c}from"../shared/rbac/engine.js";import{readProjectEnv as l}from"../shared/project-env.js";import{listL10nDirs as u,resolveLocaleContext as d}from"../shared/utils/l10n.js";import{expandConfigRbacForL10n as f}from"../shared/rbac/l10n-rules.js";import{expandConfigRbacTeamTemplates as p,listTeamDirs as m,teamTemplatePrefixes as
|
|
1
|
+
import{toJsonObject as e,toJsonValue as t}from"./database/utils/json.js";import{hashContentBytes as n}from"../shared/utils/content-hash.js";import{getProcessEnv as r,getPublicEnv as i,resolveRedoclyEnvironment as a,sanitizeBranchName as o}from"../shared/public-env.js";import{isClosedToAnonymous as s,parseRbacConfigData as c}from"../shared/rbac/engine.js";import{readProjectEnv as l}from"../shared/project-env.js";import{listL10nDirs as u,resolveLocaleContext as d}from"../shared/utils/l10n.js";import{expandConfigRbacForL10n as f}from"../shared/rbac/l10n-rules.js";import{expandConfigRbacTeamTemplates as p,listTeamDirs as m,teamTemplatePrefixes as h}from"../shared/rbac/team-templates.js";import{resolveContentPath as g}from"../shared/utils/resolve-content-path.js";import{resolveConfigRedirects as _}from"./config-redirects.js";import{NESTED_CONFIG_SCHEMA as v,realmConfigSchema as y,sanitizeConfig as b}from"./config-schema.js";import{hashEffectiveConfig as x,resolveSiteConfig as ee}from"./database/site-config.js";import{applyEnforcedAccess as S}from"./enforced-access.js";import{applyPlanGates as C}from"./plan-gates.js";import{posix as w,resolve as T}from"node:path";import E from"js-yaml";import{interpolateEnvVariables as D}from"@redocly/config";const O=[`redocly.yaml`,`redocly.yml`],k=`redocly.yaml`;async function A(e,t,i={}){let a=await le(e,t),o=r();if(!a){let e=[],t=j(S(C($(),o,t=>e.push({code:`configuration/ignored`,message:t})),o),o);return{absolutePath:null,config:t,siteConfig:t,path:null,hash:null,refs:[],problems:e}}let s=await t.readBinaryFile(a.absolutePath),c=[],d=[],f=[],p=L(new TextDecoder().decode(s),a.path),g=[],_=l(o),v={contentDir:e,fs:t,env:_,refs:f,warnings:c,errors:d},y=Q(await te(await B(await R(p,{...v,deprecations:g}),``,v),v)),b={filePath:a.path},x=[],w=G(y.access)?y.access.rbac:void 0,T=q(y,{dirLocales:await u(e,t),teamDirs:await m(e,t,h(G(w)?w:{})),env:_,pluginSchemas:i,report:e=>x.push({...e,location:b})}),E=j(S(C(T,o,e=>x.push({code:`configuration/ignored`,message:e,location:b})),o),o),{config:D,unsetVars:O}=ee(E,_);for(let e of O)c.push(`The config references process.env.${e}, which is not set.`);let k=[...c.map(e=>({code:`configuration/ignored`,message:e,location:b})),...[...new Set(g)].map(e=>({code:`configuration/deprecated`,message:e,location:b})),...d.map(e=>({code:`configuration/invalid`,severity:`error`,message:e,location:b})),...x];return{...a,config:D,siteConfig:E,hash:await n(s),refs:f,problems:k}}function j(e,t){let{grpcDocsEnabled:n,...r}=e;return t.REDOCLY_EXP_GRPC_DOCS_ENABLED===`true`?{...r,grpcDocsEnabled:!0}:r}function M(e,t){return x(e)!==t}async function N(e){if(e.context.configLoaded&&e.force!==!0)return{absolutePath:e.context.configFilePath?T(e.context.contentDir,e.context.configFilePath):null,config:e.context.config,siteConfig:e.context.siteConfig,path:e.context.configFilePath,hash:e.context.configHash,refs:e.context.configRefs,problems:[]};let t=Object.fromEntries(e.context.pluginRegistry.list().flatMap(e=>e.configSchema?[[e.id,e.configSchema]]:[])),n=await A(e.context.contentDir,e.context.platform.fs,t);return e.context.config=n.config,e.context.siteConfig=n.siteConfig,e.context.configFilePath=n.path,e.context.configHash=n.hash,e.context.configRefs=n.refs,e.context.configLoaded=!0,n}function P(e,t){let n=D(L(e,t),l(r())).value,{value:i,problems:a}=b(v,n);a.push(...Y(i,w.dirname(t)));for(let e of a)e.location={filePath:t};return{config:i,problems:a}}function F(e){return e.endsWith(`/${k}`)}async function I(e){let t=[];for(let n of e.paths)try{let r=await e.fs.readFile(T(e.contentDir,n));t.push(...P(r,n).problems)}catch(e){let r=e instanceof Error?e.message:String(e);t.push({code:`configuration/invalid`,message:`The config cannot be read: ${r}`,location:{filePath:n}})}return t}function L(t,n){let r=E.load(t);if(r==null)return{};try{return e(r)}catch(e){throw Error(`Expected ${n} to contain a YAML object.`,{cause:e})}}async function R(e,t){let{env:n,...r}=e;if(!G(n))return e;let i=t.env.PUBLIC_REDOCLY_BRANCH_NAME,s=[...i?[`branch.${o(i)}`]:[],a(t.env.REDOCLY_ENV)],c=e=>t.deprecations.push(e),l=X(r,c);for(let e of s){let r=await z(n[e],e,t);r&&(l=W(l,X(r,c)))}return l}async function z(e,t,n){if(!G(e))return null;if(typeof e.$ref!=`string`)return e;let{$ref:r,...i}=e,a=`env.${t}`,o=V(await H(r,a,n),i,a,n);return G(o)?o:null}async function B(e,t,n){if(Array.isArray(e))return Promise.all(e.map((e,r)=>B(e,`${t}[${r}]`,n)));if(!G(e))return e;if(typeof e.$ref==`string`){let{$ref:r,...i}=e;return V(await H(r,t,n),await B(i,t,n),t,n)}let r={};for(let[i,a]of Object.entries(e))r[i]=await B(a,t===``?i:`${t}.${i}`,n);return r}function V(e,t,n,r){if(Object.keys(t).length===0)return e;if(G(e))return{...e,...t};if(e==null)return t;let i=Array.isArray(e)?`list`:`scalar`;return r.warnings.push(`${n===``?`The config`:n} has keys next to a $ref to a ${i}; only the referenced file applies.`),e}function H(e,n,r){return U(e,`${n} $ref`,r,e=>t(E.load(e)))}async function U(e,t,r,i,a=`warning`){let o=a===`error`?r.errors:r.warnings,s=g(e,O[0]);if(s===null)return o.push(`${t} "${e}" escapes the content root.`),null;try{let e=await r.fs.readBinaryFile(T(r.contentDir,s));return r.refs.push({path:s,hash:await n(e)}),i(new TextDecoder().decode(e))}catch(n){let r=n instanceof Error?n.message:String(n);return o.push(`Cannot read ${t} "${e}": ${r}`),null}}async function te(e,t){let{seo:n}=e;if(!G(n)||!G(n.llmstxt)||!G(n.llmstxt.details))return e;let{path:r,...i}=n.llmstxt.details;if(typeof r!=`string`)return e;let a=null;i.content===void 0?a=await U(D(r,t.env).value,`seo.llmstxt.details.path`,t,e=>e,`error`):t.errors.push(`seo.llmstxt.details.path and seo.llmstxt.details.content are mutually exclusive; the path is ignored.`);let o={...n.llmstxt,details:a===null?i:{...i,path:r,content:a}};return{...e,seo:{...n,llmstxt:o}}}function W(e,t){let n={...e};for(let[e,r]of Object.entries(t)){if(e===`__proto__`||e===`constructor`||e===`prototype`)continue;let t=n[e];n[e]=G(t)&&G(r)?W(t,r):r}return n}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ne=[`hide`,`name`,`ignore`,`publicEndpoint`],K=`redocly.apigee`,re=[`requiresLogin`,`rbac`,`sso`,`idps`,`logoutReturnUrl`,`residency`];function q(e,t={}){let n=t.report??(()=>{}),r=t.dirLocales??[],a=X(e,e=>n({code:`configuration/deprecated`,message:e}));G(a.mcp)&&a.mcp.docs!==void 0&&n({code:`configuration/deprecated`,message:`The 'mcp.docs' property is deprecated. Use the 'mcp' properties instead.`});let o=b(y(t.pluginSchemas??{}),a,{env:t.env});for(let e of o.problems)n(e);let{redirects:s,access:c,...l}=f(p(ie(o.value,t.env),t.teamDirs??{},n),r),u={...l,publicEnv:i()};c&&(u.access=ce(c,n));let m=_(s,d(l.l10n,r));m&&(u.redirects=m);for(let e of Y(u,``))n(e);return u}function J(e,t){let n=[],r=[];for(let i of typeof e==`string`?[e]:e){let e=w.join(t,i);e===`..`||e.startsWith(`../`)?r.push(i):n.push(e)}return{folders:n,outside:r}}function Y(e,t){return[[`grpc.importPaths`,e.grpc?.importPaths],...Object.entries(e.apis??{}).map(([e,t])=>[`apis.${e}.grpc.importPaths`,t.grpc?.importPaths])].flatMap(([e,n])=>n===void 0?[]:J(n,t).outside.map(t=>({code:`configuration/ignored`,message:`\`${e}\` folder \`${t}\` is outside the content root and is ignored.`})))}function ie(e,t){if(!t)return e;let n={...e};for(let r of[`access`,`l10n`,`redirects`])r in e&&(n[r]=D(e[r],t).value);return n}function X(e,t){return ae(se(oe(Q(e),t)),t)}function ae(e,t){let{developerOnboarding:n}=e;if(!G(n)||!Array.isArray(n.adapters))return e;let r=n.adapters.find(e=>G(e)&&(e.type===`APIGEE_X`||e.type===`APIGEE_EDGE`));if(!G(r)||(t(`The Apigee adapter in 'developerOnboarding' is deprecated. Add the Apigee plugin and move the adapter to 'redocly.apigee'.`),e[K]!==void 0))return e;let{type:i,ignoreApiProducts:a,allowApiProductsOutsideCatalog:o,...s}=r,c={};return a!==void 0&&(c.exclude=a),o!==void 0&&(c.allowOutsideCatalog=o),{...e,[K]:{...s,apiProducts:c}}}function oe(e,t){let n=e;e.reunite!==void 0&&(t(`The 'reunite' property is deprecated. Use 'platform' instead.`),e.platform!==void 0&&e.platform!==null&&t(`Both 'platform' and 'reunite' are set. 'reunite' is ignored, so remove it.`),n=Z(e));let{access:r}=n;return G(r)&&G(r.rbac)&&r.rbac.reunite!==void 0&&(t(`The 'access.rbac.reunite' property is deprecated. Use 'access.rbac.platform' instead.`),n={...n,access:{...r,rbac:Z(r.rbac)}}),n}function Z(e){let{reunite:t,...n}=e;return{...n,platform:e.platform??t}}function se(e){let{mcp:t}=e;if(!G(t))return e;let{docs:n,...r}=t;if(!G(n))return e;let i={...n};for(let e of ne){let t=n[e];delete i[e],t!==void 0&&(r[e]===void 0||r[e]===null||e===`hide`&&t===!0)&&(r[e]=t)}return{...e,mcp:{...r,docs:i}}}function Q(e){let t=re.map(t=>[t,e[t]]).filter(([,e])=>e!==void 0);if(t.length===0)return e;let n={...e},r=G(e.access)?{...e.access}:{};for(let[e,i]of t)delete n[e],(r[e]===void 0||r[e]===null)&&(r[e]=i);return{...n,access:r}}function ce(e,t){let n=e.rbac?c(e.rbac,e=>t({code:`configuration/invalid`,message:e})):null;return n?(e.requiresLogin===!0&&t({code:`configuration/ignored`,message:`access.requiresLogin is ignored because access.rbac is also configured — the two are mutually exclusive. Remove one.`}),{...e,requiresLogin:s(n)}):e}async function le(e,t){for(let n of O){let r=T(e,n);if(await t.exists(r))return{absolutePath:r,path:n}}return null}function $(){return q({})}export{k as NESTED_CONFIG_FILENAME,O as REDOCLY_CONFIG_FILENAMES,$ as createEmptyRealmConfig,W as deepMergeConfig,M as isConfigChanged,F as isNestedConfigPath,N as loadContentLayerConfig,A as loadRedoclyConfig,q as normalizeRedoclyConfig,P as parseNestedConfig,I as readNestedConfigProblems,J as resolveGrpcImportPaths};
|
|
@@ -2,9 +2,11 @@ import type { Platform } from '../platform/types/platform.js';
|
|
|
2
2
|
import { type Logger } from '../shared/logger.js';
|
|
3
3
|
import { type ConfigFileRef, type RealmConfig } from './config.js';
|
|
4
4
|
import type { CurrentContentFileIndex } from './ingest/current-files.js';
|
|
5
|
+
import type { GitLastModified } from './ingest/git-last-modified.js';
|
|
5
6
|
import { type ContentPluginRegistry } from './plugins/registry.js';
|
|
6
7
|
import type { ContentPluginIO } from './plugins/types/io.js';
|
|
7
8
|
import type { ContentPlugin } from './plugins/types/plugin.js';
|
|
9
|
+
import type { RouteQueryRowsSnapshot } from './database/route-query-deps.js';
|
|
8
10
|
import type { ContentLayerState } from './context-state.js';
|
|
9
11
|
export type ContentLayerContext = {
|
|
10
12
|
config: RealmConfig;
|
|
@@ -16,10 +18,14 @@ export type ContentLayerContext = {
|
|
|
16
18
|
configLoaded: boolean;
|
|
17
19
|
contentDir: string;
|
|
18
20
|
currentFileIndex?: CurrentContentFileIndex;
|
|
21
|
+
/** The commit dates the last ingest read; the next ingest reuses them while HEAD stays. */
|
|
22
|
+
gitLastModified?: GitLastModified;
|
|
19
23
|
logger: Logger;
|
|
20
24
|
platform: Platform;
|
|
21
25
|
pluginIO: ContentPluginIO;
|
|
22
26
|
pluginRegistry: ContentPluginRegistry;
|
|
27
|
+
/** The stored route queries the last ingest read; the next ingest reuses them while the table is unchanged. */
|
|
28
|
+
routeQueryRows?: RouteQueryRowsSnapshot;
|
|
23
29
|
state?: ContentLayerState;
|
|
24
30
|
};
|
|
25
31
|
export type CreateContentLayerContextOptions = {
|
|
@@ -2,4 +2,6 @@ import type { ContentLayerDatabase } from './connection.js';
|
|
|
2
2
|
import { type EntityRecord } from './schema.js';
|
|
3
3
|
export declare const generateEntityId: (size?: number) => string;
|
|
4
4
|
export declare function loadEntityRecordByKey(database: ContentLayerDatabase, key: string): Promise<EntityRecord | null>;
|
|
5
|
+
/** The slug that `/` redirects to on a site without a `/` page; null when the site has none. */
|
|
6
|
+
export declare function loadSiteStart(database: ContentLayerDatabase): Promise<string | null>;
|
|
5
7
|
export declare function loadStaleEntityRecords(database: ContentLayerDatabase): Promise<EntityRecord[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{entities as e}from"./schema.js";import{and as
|
|
1
|
+
import{entities as e}from"./schema.js";import{SITE_START_ENTITY_KEY as t}from"../../shared/constants/site-start.js";import{and as n,eq as r}from"drizzle-orm";import{customAlphabet as i}from"nanoid";const a=i(`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,26);async function o(t,i){let[a]=await t.db.select().from(e).where(n(r(e.key,i),r(e.isCurrent,1))).limit(1);return a??null}async function s(i){let[a]=await i.db.select({data:e.data}).from(e).where(n(r(e.key,t),r(e.isCurrent,1))).limit(1);return typeof a?.data==`string`?a.data:null}async function c(t){return t.db.select().from(e).where(n(r(e.status,`stale`),r(e.isCurrent,1))).orderBy(e.key)}export{a as generateEntityId,o as loadEntityRecordByKey,s as loadSiteStart,c as loadStaleEntityRecords};
|
|
@@ -12,7 +12,8 @@ export type EntityRuntimeDep = EntityInvalidationDep | {
|
|
|
12
12
|
/**
|
|
13
13
|
* Replaces an entity's runtime (`file`/`entity`/`glob`) deps, reusing its `origin`
|
|
14
14
|
* dep row's file id. A system entity has no origin dep by construction, so its
|
|
15
|
-
* rows persist file-anchor-free (NULL origin file id, plugin-scoped).
|
|
15
|
+
* rows persist file-anchor-free (NULL origin file id, plugin-scoped). Writes nothing
|
|
16
|
+
* when the entity already has exactly these deps.
|
|
16
17
|
*/
|
|
17
18
|
export declare function replaceEntityRuntimeDeps(tx: DatabaseTransaction, options: {
|
|
18
19
|
entityId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hashJsonValue as e}from"./utils/json.js";import{entities as t,entityDeps as n,filePlugins as r,linkRefs as i,originDeps as a,routeDeps as o,routes as s}from"./schema.js";import{batchValues as c,normalizeBatchSize as l,runWithSqliteBusyRetry as u}from"./connection.js";import{generateEntityId as d}from"./entities.js";import{garbageCollectOrphanedEntitiesInTransaction as f}from"./invalidation.js";import{deleteProblemsForFilesTx as p,deleteProblemsForPluginHookTx as m,insertProblemsTx as h,problemRow as g,replaceGlobalProblemsForKeysTx as _}from"./problems.js";import{deleteOriginLinkRefsForFilesTx as v}from"./link-refs.js";import{detectMarkdocPayloadFlag as y}from"../markdown/server/render.js";import{cutEntityRevisionTx as b}from"../revisions/cut.js";import{writePluginHookState as x}from"./plugin-hook-state.js";import{replaceRouteQueryDepsTx as S}from"./route-query-deps.js";import{and as C,eq as w,inArray as T,sql as E}from"drizzle-orm";async function D(e,t){let[r]=await e.select({originFileId:n.originFileId}).from(n).where(E`${n.entityId} = ${t.entityId} and ${n.dependencyType} = 'origin'`).limit(1);if(
|
|
1
|
+
import{hashJsonValue as e}from"./utils/json.js";import{entities as t,entityDeps as n,filePlugins as r,linkRefs as i,originDeps as a,routeDeps as o,routes as s}from"./schema.js";import{batchValues as c,normalizeBatchSize as l,runWithSqliteBusyRetry as u}from"./connection.js";import{generateEntityId as d}from"./entities.js";import{garbageCollectOrphanedEntitiesInTransaction as f}from"./invalidation.js";import{deleteProblemsForFilesTx as p,deleteProblemsForPluginHookTx as m,insertProblemsTx as h,problemRow as g,replaceGlobalProblemsForKeysTx as _}from"./problems.js";import{deleteOriginLinkRefsForFilesTx as v}from"./link-refs.js";import{detectMarkdocPayloadFlag as y}from"../markdown/server/render.js";import{cutEntityRevisionTx as b}from"../revisions/cut.js";import{writePluginHookState as x}from"./plugin-hook-state.js";import{replaceRouteQueryDepsTx as S}from"./route-query-deps.js";import{and as C,eq as w,inArray as T,sql as E}from"drizzle-orm";async function D(e,t){let[r]=await e.select({originFileId:n.originFileId}).from(n).where(E`${n.entityId} = ${t.entityId} and ${n.dependencyType} = 'origin'`).limit(1);if(t.deps.length>0&&!r&&!t.isSystem)throw Error(`replaceEntityRuntimeDeps: entity ${t.entityId} has no origin dep row.`);let i=/* @__PURE__ */ new Set,a=[];for(let e of t.deps){let n=e.kind===`file`?e.path:e.kind===`glob`?e.pattern:e.key,o=`${e.kind} ${n}`;i.has(o)||(i.add(o),a.push({entityId:t.entityId,originFileId:r?.originFileId??null,originPluginId:t.originPluginId,hook:`loader`,dependencyType:e.kind,dependencyRef:n}))}let o=E`${n.entityId} = ${t.entityId} and ${n.dependencyType} in ('file','entity','glob')`,s=await e.select({type:n.dependencyType,ref:n.dependencyRef}).from(n).where(o);if(!(s.length===a.length&&s.every(e=>i.has(`${e.type} ${e.ref}`)))){await e.delete(n).where(o);for(let t of c(a,500))await e.insert(n).values(t)}}async function O(e,t,c){let d=c?.extractAllOrigins??[],p=c?.extractAllFailures??[],m=c?.globalProblems,v=c?.fallbackRoutes,y=(v?.removedSlugs.length??0)+(v?.added.length??0);if(t.length===0&&d.length===0&&p.length===0&&m===void 0&&y===0)return;let b=l(c?.batchSize);await u(()=>e.db.transaction(async e=>{await k(e,{fileIds:t.map(e=>e.fileId),extractAllOrigins:d,extractAllFailures:p,fallbackRoutes:v,batchSize:b}),await F(A(t),b,t=>e.insert(r).values(t));let l=j(t,d,v);await F(l.routes,b,t=>e.insert(s).values(t)),await F(l.routeDeps,b,t=>e.insert(o).values(t));let u=await I(e,l.entityDescriptors,b,c?.revisions);await F(l.originDeps,b,t=>e.insert(a).values(t)),await F(l.linkRefs,b,t=>e.insert(i).values(t));let y=[...l.problems,...p.map(e=>g(e.problem,{scope:`origin`,originFileId:null,originPluginId:e.pluginId,hook:`extractAll`}))];await h(e,y,b),m&&await _(e,m.source,m.keys,m.newProblems),l.entityDescriptors.length>0&&await F(P(l.entityOrigins,u),b,t=>e.insert(n).values(t));for(let t of d)await S(e,{originPluginId:t.originPluginId,hook:`extractAll`,entityId:null,dependencies:t.routeQueries}),await x(e,{pluginId:t.originPluginId,hook:`extractAll`,fingerprint:t.fingerprint});await f(e)}),{logger:c?.logger,operation:`bulk sync origins`})}async function k(e,t){for(let i of c(t.fileIds,t.batchSize))await e.delete(r).where(T(r.fileId,i)),await e.delete(o).where(T(o.originFileId,i)),await e.delete(s).where(T(s.sourceId,i)),await e.delete(n).where(T(n.originFileId,i)),await e.delete(a).where(T(a.originFileId,i));await p(e,t.fileIds,t.batchSize),await v(e,t.fileIds,t.batchSize),await m(e,[...t.extractAllOrigins.map(e=>e.originPluginId),...t.extractAllFailures.map(e=>e.pluginId)],`extractAll`);let i=t.extractAllOrigins.map(e=>e.originPluginId);for(let r of c(i,t.batchSize))await e.delete(o).where(E`${o.originFileId} is null and ${o.hook} = 'extractAll' and ${T(o.originPluginId,r)}`),await e.delete(s).where(E`${s.sourceId} is null and ${T(s.pluginId,r)}`),await e.delete(n).where(E`${n.originFileId} is null and ${n.hook} = 'extractAll' and ${T(n.originPluginId,r)}`),await e.delete(a).where(E`${a.originFileId} is null and ${a.hook} = 'extractAll' and ${T(a.originPluginId,r)}`);if(t.fallbackRoutes){let{pluginId:n,removedSlugs:r,added:i}=t.fallbackRoutes,a=[.../* @__PURE__ */ new Set([...r,...i.map(e=>e.slug)])];for(let r of c(a,t.batchSize))await e.delete(s).where(E`${s.sourceId} is null and ${s.pluginId} = ${n} and ${T(s.slug,r)}`)}}function A(e){let t=[];for(let n of e)for(let e of n.plugins)t.push({fileId:n.fileId,pluginId:e.id,pluginVersion:e.version});return t}function j(e,t,n){let r={routes:[],routeDeps:[],originDeps:[],entityDescriptors:[],entityOrigins:[],problems:[],linkRefs:[]};for(let t of e)for(let e of t.origins)N(e,r);for(let e of t)N(e,r);for(let e of n?.added??[])r.routes.push(M(e,null));return r}function M(e,t){return{metadata:e.metadata,pluginId:e.pluginId,routeId:e.routeId,sidebarSubtreeEntityKey:e.sidebarSubtreeEntityKey,wildcardPrefix:e.wildcardPrefix??!1,slug:e.slug,requestedSlug:e.requestedSlug,slugType:e.slugType,sourceId:t,template:e.template,versionGroup:e.versionGroup,version:e.version,locale:e.locale,isFallback:e.isFallback,canonicalSlug:e.canonicalSlug}}function N(e,t){for(let n of e.routes)t.routes.push(M(n,e.originFileId));for(let n of e.routeDependencies)t.routeDeps.push({args:n.args,dependencyType:n.dependencyType,key:n.key,originFileId:e.originFileId,originPluginId:e.originPluginId,hook:e.hook,routeSlug:n.routeSlug,target:n.target});for(let n of e.originDependencies)t.originDeps.push({accessType:n.accessType,originFileId:e.originFileId,originPluginId:e.originPluginId,hook:e.hook,source:n.source,path:n.path,valueHash:n.valueHash});for(let n of e.problems)t.problems.push(g(n,{scope:`origin`,originFileId:e.originFileId,originPluginId:e.originPluginId,hook:e.hook}));e.entities.length>0&&(t.entityDescriptors.push(...e.entities),t.entityOrigins.push({originFileId:e.originFileId,originFilePath:e.originFilePath,originPluginId:e.originPluginId,hook:e.hook,descriptors:e.entities}));for(let n of e.linkRefs??[]){let r=n.filePath??e.originFilePath;r!==null&&t.linkRefs.push({entityId:null,originFileId:e.originFileId,originPluginId:e.originPluginId,filePath:r,kind:n.kind,raw:n.raw,targetKind:n.targetKind,target:n.target,fragment:n.fragment,title:n.title??null,range:n.range??null})}}function P(e,t){let n=[];for(let r of e)for(let e of r.descriptors){let i=t.get(e.key);if(!i)throw Error(`bulkSyncOrigins: missing entity id for key "${e.key}" after upsert.`);n.push({dependencyRef:r.originFilePath??r.originPluginId,dependencyType:`origin`,entityId:i,originFileId:r.originFileId,originPluginId:r.originPluginId,hook:r.hook})}return n}async function F(e,t,n){for(let r of c(e,t))r.length>0&&await n(r)}async function I(n,r,i=500,a){if(r.length===0)return/* @__PURE__ */ new Map;let o=/* @__PURE__ */ new Map;for(let e of r)o.set(e.key,e);let s=[...o.keys()],l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map;for(let e of c(s,i)){let r=await n.select({id:t.id,key:t.key,kind:t.kind,type:t.type,metadata:t.metadata,pluginId:t.pluginId,loaderId:t.loaderId,loaderArgs:t.loaderArgs,data:t.data,markdoc:t.markdoc,dataHash:t.dataHash,version:t.version,revisionCreatedAt:t.revisionCreatedAt}).from(t).where(C(T(t.key,e),w(t.isCurrent,1)));for(let e of r)l.set(e.key,e.id),u.set(e.key,e)}let f=Date.now(),p=[];for(let t of o.values()){let r=u.get(t.key),i=r?.id??d();l.set(t.key,i);let o=t.kind===`inline`?`ready`:t.shouldInvalidateValue||!r?`stale`:`ready`,s=t.kind===`inline`?t.value:null,c=s===null?null:e(s),m=r?.revisionCreatedAt??f;t.kind===`inline`&&r&&(r.dataHash??null)!==c&&(a?.trackedKeys.has(t.key)&&await b(n,{current:r,max:a.max}),m=Math.max(f,r.revisionCreatedAt+1)),p.push({id:i,key:t.key,kind:t.kind,type:t.type,metadata:t.metadata,pluginId:t.pluginId,loaderId:t.loaderId,loaderArgs:t.loaderArgs,status:o,data:s,markdoc:s===null?null:y(JSON.stringify(s)),dataHash:c,isSystem:+!!t.isSystem,version:t.version,isCurrent:1,revisionCreatedAt:m})}for(let e of c(p,i))e.length!==0&&await n.insert(t).values(e).onConflictDoUpdate({target:t.id,set:{kind:E.raw(`excluded.kind`),type:E.raw(`excluded.type`),metadata:E.raw(`CASE WHEN excluded.kind = 'inline' OR excluded.status = 'stale' THEN excluded.metadata ELSE entities.metadata END`),pluginId:E.raw(`excluded.plugin_id`),loaderId:E.raw(`excluded.loader_id`),loaderArgs:E.raw(`excluded.loader_args`),status:E.raw(`CASE WHEN excluded.kind = 'inline' OR excluded.status = 'stale' THEN excluded.status ELSE entities.status END`),data:E.raw(`CASE WHEN excluded.kind = 'inline' THEN excluded.data ELSE entities.data END`),markdoc:E.raw(`CASE WHEN excluded.kind = 'inline' THEN excluded.markdoc ELSE entities.markdoc END`),dataHash:E.raw(`CASE WHEN excluded.kind = 'inline' THEN excluded.data_hash ELSE entities.data_hash END`),isSystem:E.raw(`excluded.is_system`),version:E.raw(`excluded.version`),revisionCreatedAt:E.raw(`excluded.revision_created_at`),invalidationSeq:E`case when excluded.status = 'stale' then ${t.invalidationSeq} + 1 else ${t.invalidationSeq} end`}});return l}export{O as bulkSyncOrigins,D as replaceEntityRuntimeDeps,I as upsertEntityDescriptors};
|
|
@@ -7,15 +7,31 @@ export type RouteQueryDependencyRow = RouteQueryDependency & {
|
|
|
7
7
|
hook: PluginHook;
|
|
8
8
|
entityId: string | null;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/** Every stored row, with the row count and the highest id of the table when they were read. */
|
|
11
|
+
export type RouteQueryRowsSnapshot = {
|
|
12
|
+
rowCount: number;
|
|
13
|
+
maxId: number;
|
|
14
|
+
rows: readonly RouteQueryDependencyRow[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Every row, both scopes. Loaded once per ingest and shared by the finalize trigger and the
|
|
18
|
+
* loader-entity staleness pass. Returns `previous` when the table has not changed since.
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadRouteQueryDependencyRows(database: ContentLayerDatabase, previous?: RouteQueryRowsSnapshot): Promise<RouteQueryRowsSnapshot>;
|
|
21
|
+
/**
|
|
22
|
+
* Replaces the rows of one `(plugin, hook[, entity])` scope, inside the reader's own output
|
|
23
|
+
* transaction. Writes nothing when the scope already holds exactly `dependencies`.
|
|
24
|
+
*/
|
|
12
25
|
export declare function replaceRouteQueryDepsTx(tx: DatabaseTransaction, options: {
|
|
13
26
|
originPluginId: string;
|
|
14
27
|
hook: PluginHook;
|
|
15
28
|
entityId: string | null;
|
|
16
29
|
dependencies: readonly RouteQueryDependency[];
|
|
17
30
|
}): Promise<void>;
|
|
18
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Replaces the rows of many `(plugin, hook, entity)` scopes at once, in a few statements.
|
|
33
|
+
* Writes nothing for a scope that already holds exactly its `dependencies`.
|
|
34
|
+
*/
|
|
19
35
|
export declare function replaceEntityRouteQueryDepsTx(tx: DatabaseTransaction, options: {
|
|
20
36
|
hook: PluginHook;
|
|
21
37
|
scopes: readonly {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{routeQueryDeps as e}from"./schema.js";import{batchValues as t,normalizeBatchSize as n}from"./connection.js";import{and as r,
|
|
1
|
+
import{routeQueryDeps as e}from"./schema.js";import{batchValues as t,normalizeBatchSize as n}from"./connection.js";import{and as r,count as i,eq as a,inArray as o,isNull as s,max as c}from"drizzle-orm";async function l(t,n){let[r]=await t.db.select({rowCount:i(),maxId:c(e.id)}).from(e),a=r?.rowCount??0,o=r?.maxId??0;return n!==void 0&&n.rowCount===a&&n.maxId===o?n:{rowCount:a,maxId:o,rows:await t.db.select({originPluginId:e.originPluginId,hook:e.hook,entityId:e.entityId,kind:e.kind,argument:e.argument,resultHash:e.resultHash}).from(e).orderBy(e.originPluginId,e.hook,e.entityId)}}async function u(i,o){let c=r(a(e.originPluginId,o.originPluginId),a(e.hook,o.hook),o.entityId===null?s(e.entityId):a(e.entityId,o.entityId));if(!d(await i.select({kind:e.kind,argument:e.argument,resultHash:e.resultHash}).from(e).where(c),o.dependencies)){await i.delete(e).where(c);for(let r of t(o.dependencies,n(void 0)))await i.insert(e).values(r.map(e=>({originPluginId:o.originPluginId,hook:o.hook,entityId:o.entityId,kind:e.kind,argument:e.argument,resultHash:e.resultHash})))}}function d(e,t){if(e.length!==t.length)return!1;let n=new Map(t.map(e=>[`${e.kind}\u0000${e.argument}`,e.resultHash]));return n.size===t.length&&e.every(e=>n.get(`${e.kind}\u0000${e.argument}`)===e.resultHash)}async function f(i,s){let c=n(void 0),l=t=>r(a(e.hook,s.hook),o(e.entityId,t)),u=/* @__PURE__ */ new Map;for(let n of t(s.scopes.map(e=>e.entityId),c)){let t=await i.select({entityId:e.entityId,kind:e.kind,argument:e.argument,resultHash:e.resultHash}).from(e).where(l(n));for(let{entityId:e,...n}of t){if(e===null)continue;let t=u.get(e)??[];t.push(n),u.set(e,t)}}let f=s.scopes.filter(e=>!d(u.get(e.entityId)??[],e.dependencies));for(let n of t(f.map(e=>e.entityId),c))await i.delete(e).where(l(n));let p=f.flatMap(e=>e.dependencies.map(t=>({originPluginId:e.originPluginId,hook:s.hook,entityId:e.entityId,kind:t.kind,argument:t.argument,resultHash:t.resultHash})));for(let n of t(p,c))await i.insert(e).values(n)}export{l as loadRouteQueryDependencyRows,f as replaceEntityRouteQueryDepsTx,u as replaceRouteQueryDepsTx};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Logger } from '../../shared/logger.js';
|
|
2
|
+
/** Content-relative path -> ISO date of the newest commit that touched it. */
|
|
3
|
+
export type GitLastModifiedIndex = ReadonlyMap<string, string>;
|
|
4
|
+
/**
|
|
5
|
+
* The dates and the HEAD commit they were read at. `head` is null when git or the full history
|
|
6
|
+
* could not be read: the next read does not reuse such a result.
|
|
7
|
+
*/
|
|
8
|
+
export type GitLastModified = {
|
|
9
|
+
head: string | null;
|
|
10
|
+
index: GitLastModifiedIndex;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Commit dates for every tracked file under `contentDir`, from one `git log` walk.
|
|
14
|
+
*
|
|
15
|
+
* Returns an empty index when git is unavailable, the directory is not a repository, it has
|
|
16
|
+
* no commit, or the platform has no subprocesses (the browser engine's `node:child_process`
|
|
17
|
+
* shim throws on call) — callers treat a missing entry as "no date". Returns `previous`
|
|
18
|
+
* unchanged when HEAD is still the commit it was read at.
|
|
19
|
+
*/
|
|
20
|
+
export declare function readGitLastModified(contentDir: string, logger?: Logger, previous?: GitLastModified): Promise<GitLastModified>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import{spawn as e}from"node:child_process";const t
|
|
2
|
-
`)
|
|
3
|
-
`)
|
|
4
|
-
`)
|
|
1
|
+
import{spawn as e}from"node:child_process";const t={head:null,index:/* @__PURE__ */ new Map};function n(t,n){return new Promise((r,i)=>{let a=e(`git`,[...n],{cwd:t,stdio:[`ignore`,`pipe`,`ignore`]}),o=``;a.stdout.setEncoding(`utf8`),a.stdout.on(`data`,e=>{o+=e}),a.on(`error`,i),a.on(`close`,e=>e===0?r(o):i(/* @__PURE__ */ Error(`git ${n[0]} exited ${e}`)))})}async function r(r,i,a){let o,s,c;try{let[e=``,t=``]=(await n(r,[`rev-parse`,`--show-prefix`,`HEAD`])).split(`
|
|
2
|
+
`);if(o=e.trim(),s=t.trim(),a?.head===s)return a;c=new Set((await n(r,[`ls-files`,`--`,`.`])).split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(Boolean))}catch(e){return i?.debug(`Skipping git last-modified lookup`,{error:String(e)}),t}return c.size===0?{head:s,index:/* @__PURE__ */ new Map}:new Promise(t=>{let n=/* @__PURE__ */ new Map,a=e(`git`,[`log`,`--raw`,`--no-renames`,`--no-merges`,`--pretty=format:%at`,`--`,`.`],{cwd:r,stdio:[`ignore`,`pipe`,`pipe`]}),l=0,u=``,d=``,f=!1,p=e=>{if(f)return;u+=e;let t=u.split(`
|
|
4
|
+
`);u=t.pop()??``;for(let e of t){let t=e.trim();if(!t)continue;if(!t.startsWith(`:`)){l=Number(t);continue}let r=t.split(` `),i=r[r.length-1];if(i===void 0)continue;let s=o&&i.startsWith(o)?i.slice(o.length):i;if(c.delete(s)&&(n.set(s,(/* @__PURE__ */ new Date(l*1e3)).toISOString()),c.size===0)){f=!0,a.kill();return}}};a.stdout.setEncoding(`utf8`),a.stdout.on(`data`,p),a.stderr.setEncoding(`utf8`),a.stderr.on(`data`,e=>{d+=e}),a.on(`close`,e=>{p(`
|
|
5
|
+
`),e!==0&&!f&&i?.warn(`Could not read the full git history, some last updated dates can be wrong`,{stderr:d.trim()}),t({head:e===0||f?s:null,index:n})}),a.on(`error`,()=>t({head:null,index:n}))})}export{r as readGitLastModified};
|