@redocly/framework 1.0.0-next.12 → 1.0.0-next.14
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/README.md +0 -1
- package/dist/bundler/build/dependency-pack.js +1 -1
- package/dist/bundler/build/output-metadata.js +1 -1
- package/dist/bundler/build/run.js +1 -1
- package/dist/bundler/build/theme-global-stylesheets.js +1 -1
- package/dist/bundler/build/vite-config.js +2 -2
- package/dist/bundler/dev/dev-content-build.js +1 -1
- package/dist/bundler/dev/routes/dev-problems-route.js +1 -1
- package/dist/bundler/dev/routes/source-sync-route.js +1 -1
- package/dist/bundler/dev/run.js +1 -1
- package/dist/bundler/dev/runtime-app.js +1 -1
- package/dist/bundler/dev/vite-chunk-url.js +1 -1
- package/dist/bundler/user-markdoc-schema.js +1 -1
- package/dist/bundler/vite-config.base.js +5 -5
- package/dist/cli/api-docs-build-event.js +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/commands/build.js +1 -1
- package/dist/cli/commands/dev.js +1 -1
- package/dist/cli/commands/ingest.js +1 -1
- package/dist/cli/commands/translate.js +1 -1
- package/dist/cli/problems-output.js +3 -3
- package/dist/cli/validate-react-pages.js +1 -1
- package/dist/client/UnversionedVersionButton.js +1 -1
- package/dist/client/VersionPicker.js +343 -0
- package/dist/client/ai-search/use-ai-search.js +1 -1
- package/dist/client/analytics-page-view.js +1 -1
- package/dist/client/app.js +2 -2
- package/dist/client/classic-webview-sync.js +1 -1
- package/dist/client/client-entry.js +1 -1
- package/dist/client/contexts.js +1 -1
- package/dist/client/feedback.js +1 -1
- package/dist/client/history-mount.js +6 -5
- package/dist/client/l10n/ssr-l10n.js +1 -1
- package/dist/client/l10n/use-l10n-config.js +1 -1
- package/dist/client/products.js +1 -1
- package/dist/client/review/ReviewBar.js +31 -31
- package/dist/client/review/login-url.js +1 -1
- package/dist/client/review/use-review.js +1 -1
- package/dist/client/revisions-history.js +1 -1
- package/dist/client/sidebar/SidebarDataProvider.js +1 -1
- package/dist/client/sidebar/drilldown.js +1 -1
- package/dist/client/ssr.js +1 -1
- package/dist/client/telemetry/config.js +1 -1
- package/dist/client/theme-logo.js +1 -1
- package/dist/client/use-entity-revisions.js +1 -1
- package/dist/client/use-page-versions.js +1 -1
- package/dist/client/use-search.js +1 -1
- package/dist/client/webmcp/tools/shared.js +1 -1
- package/dist/client/webmcp/tools/site-tools.js +1 -1
- package/dist/client/webmcp/use-webmcp-tools.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-state.js +1 -1
- package/dist/content-layer/context.d.ts +6 -0
- package/dist/content-layer/context.js +1 -1
- package/dist/content-layer/database/assets.js +1 -1
- package/dist/content-layer/database/blobs.js +1 -1
- package/dist/content-layer/database/entities.d.ts +2 -0
- package/dist/content-layer/database/entities.js +1 -1
- package/dist/content-layer/database/entity-store.js +1 -1
- package/dist/content-layer/database/files.js +1 -1
- package/dist/content-layer/database/finalize.js +1 -1
- package/dist/content-layer/database/invalidation.js +26 -26
- package/dist/content-layer/database/link-refs.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/problems.js +1 -1
- package/dist/content-layer/database/reset.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/database/search-vocab.js +2 -2
- package/dist/content-layer/database/static-files.js +1 -1
- package/dist/content-layer/ingest/extract-all-phase.js +1 -1
- package/dist/content-layer/ingest/finalize-phase.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/hash.js +1 -1
- package/dist/content-layer/ingest/hook-inputs.js +1 -1
- package/dist/content-layer/ingest/l10n-warnings.js +1 -1
- package/dist/content-layer/ingest/markdoc-schema-problem.js +1 -1
- package/dist/content-layer/ingest/normalize-artifacts.js +1 -1
- package/dist/content-layer/ingest/run.js +1 -1
- package/dist/content-layer/ingest/scan.js +1 -1
- package/dist/content-layer/ingest/search-sync.js +1 -1
- package/dist/content-layer/ingest/sync.js +1 -1
- package/dist/content-layer/link-checker/config-links.js +1 -1
- package/dist/content-layer/link-checker/delta.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/link-checker/node-ref.js +1 -1
- package/dist/content-layer/link-checker/run-build.js +1 -1
- package/dist/content-layer/link-checker/validate.js +1 -1
- package/dist/content-layer/loaders/context.js +1 -1
- package/dist/content-layer/markdown/client/JsonSchemaTag.js +1 -1
- package/dist/content-layer/markdown/client/markdown-text.js +1 -1
- package/dist/content-layer/markdown/constants/builtin-tags.js +1 -1
- package/dist/content-layer/markdown/nodes/fence.js +1 -1
- package/dist/content-layer/markdown/nodes/heading.js +1 -1
- package/dist/content-layer/markdown/nodes/table.js +1 -1
- package/dist/content-layer/markdown/resolve/ast.d.ts +2 -0
- package/dist/content-layer/markdown/resolve/ast.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/file-reference.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/partial.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/svg-content.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc.js +1 -1
- package/dist/content-layer/markdown/resolve/references.js +1 -1
- package/dist/content-layer/markdown/search/to-markdown.js +3 -3
- package/dist/content-layer/markdown/search/to-sections.js +1 -1
- package/dist/content-layer/markdown/search/to-text.js +5 -5
- package/dist/content-layer/markdown/server/render.js +1 -1
- package/dist/content-layer/markdown/service.js +1 -1
- package/dist/content-layer/markdown/tags/variant.js +1 -1
- package/dist/content-layer/markdown/utils/collect-anchors.js +1 -1
- package/dist/content-layer/markdown/utils/first-heading.js +1 -1
- package/dist/content-layer/markdown/utils/parse-cache.d.ts +5 -1
- package/dist/content-layer/markdown/utils/parse-cache.js +1 -1
- package/dist/content-layer/materialization/asset-reconcile.js +1 -1
- package/dist/content-layer/materialization/entity.js +1 -1
- package/dist/content-layer/materialization/materializer.js +1 -1
- package/dist/content-layer/materialization/static-files.js +1 -1
- package/dist/content-layer/plugins/execute.js +1 -1
- package/dist/content-layer/plugins/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/client/template.js +2 -2
- 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 +4 -1
- 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 +12 -10
- 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-docs/server/search-documents.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/spec-download.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.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/logo.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/products.js +1 -1
- package/dist/content-layer/plugins/internal/assets/index.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/client/use-catalog-classic.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/resolve-items.js +1 -1
- package/dist/content-layer/plugins/internal/index.js +1 -1
- package/dist/content-layer/plugins/internal/l10n/index.js +1 -1
- package/dist/content-layer/plugins/internal/l10n/translations-loader.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/client/template.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/app-data.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/ignored-routes.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/agent-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/auth.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/config-gate.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/custom-tools.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/call-api.js +2 -2
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-handler.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/site-branding.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +6 -6
- package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +3 -3
- 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 +4 -4
- package/dist/content-layer/plugins/internal/mcp/server/handler.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/mcp-telemetry.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/client-metadata.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/discovery.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/register.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/token.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/server-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/server-info.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/skills-resources.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/pages-navigation.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/pages.js +2 -2
- package/dist/content-layer/plugins/internal/mcp/server/tools/schemas.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/search.js +2 -2
- 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/mcp/setup-page.js +1 -1
- package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
- package/dist/content-layer/plugins/internal/react-page/index.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/client/template.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/bundle.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/index.js +2 -2
- package/dist/content-layer/plugins/internal/skills/index.js +1 -1
- package/dist/content-layer/plugins/internal/skills/server/routes.js +1 -1
- package/dist/content-layer/plugins/io.js +1 -1
- package/dist/content-layer/plugins/project/load.js +2 -2
- package/dist/content-layer/plugins/source-file.js +1 -1
- package/dist/content-layer/plugins/utils/link-access.js +1 -1
- package/dist/content-layer/plugins/utils/route-index.js +1 -1
- package/dist/content-layer/revisions/delete.js +1 -1
- package/dist/content-layer/revisions/read.js +1 -1
- package/dist/content-layer/search/engine/core/search-engine.js +1 -1
- package/dist/content-layer/search/postings/postings-store.js +1 -1
- package/dist/content-layer/server/database.js +1 -1
- package/dist/content-layer/static/registry.js +1 -1
- package/dist/content-layer/templates/template-set.js +1 -1
- package/dist/content-layer/versions/redirect.js +1 -1
- package/dist/content-layer/versions/resolve.js +1 -1
- package/dist/server/app.js +3 -3
- package/dist/server/ask-ai/feature-gate.js +1 -1
- package/dist/server/ask-ai/route.js +1 -1
- package/dist/server/auth/middleware.js +1 -1
- package/dist/server/auth/request.js +1 -1
- package/dist/server/auth/routes.js +1 -1
- package/dist/server/content.js +12 -12
- package/dist/server/cors-proxy/handler.js +1 -1
- package/dist/server/feedback/route.js +1 -1
- package/dist/server/lambda-entry.js +1 -1
- package/dist/server/manifest-assets.js +4 -4
- package/dist/server/node-entry.js +1 -1
- package/dist/server/page-handlers.js +2 -2
- package/dist/server/plugin-context.js +1 -1
- package/dist/server/rbac/content-asset-access.js +1 -1
- package/dist/server/runtime-config.js +1 -1
- package/dist/server/search/route.js +1 -1
- package/dist/server/seo-tags.js +2 -2
- package/dist/server/sitemap.js +1 -1
- package/dist/server/static-files/serve.js +1 -1
- package/dist/server/subprocess/child-entry.js +1 -1
- package/dist/server/subprocess/host.js +1 -1
- package/dist/server/template-ids.js +1 -1
- package/dist/shared/constants/system-routes.js +1 -1
- package/dist/shared/rbac/engine.js +0 -0
- package/dist/shared/rbac/l10n-rules.js +1 -1
- package/dist/shared/rbac/route-scope.js +1 -1
- package/dist/shared/rbac/team-templates.js +1 -1
- package/dist/shared/types/config.d.ts +2 -1
- package/dist/shared/utils/l10n.js +1 -1
- package/dist/shared/utils/routes/file-path-to-route-slug.js +1 -1
- package/package.json +4 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toJsonObject as e,toJsonValue as t}from"./database/utils/json.js";import{
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{contentIgnoreMatcherOf as e}from"./ingest/scan.js";import{normalizeBatchSize as t}from"./database/connection.js";import{createContentOriginKey as n}from"./plugins/utils/origin-key.js";import{loadPersistedContentStateEntities as r,loadPersistedContentStateSummary as i}from"./database/files.js";import{comparePrimarySlug as a}from"../shared/utils/routes/compare-primary-slug.js";async function o(t){if(!t.context.state){let n=await i(t.database);t.context.state=l(n,e(t.context.config))}return t.context.state}async function s(e){let n=e.keys!==void 0&&e.keys.length<=t(void 0)?e.keys:void 0,i=u(await r(e.database,n));if(n===void 0){e.state.entitiesByKey=i;return}for(let[t,n]of i)e.state.entitiesByKey.set(t,n)}function c(e,t){for(let[n,r]of e.filesByPath)t(n)&&(e.filesByPath.delete(n),e.ignoredFilesByPath.set(n,r));for(let[n,r]of e.ignoredFilesByPath)t(n)||(e.ignoredFilesByPath.delete(n),e.filesByPath.set(n,r))}function l(e,t){let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map;for(let n of e.files)(t(n.path)?i:r).set(n.path,n);let o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map,c=/* @__PURE__ */ new Map,l=u(e.entities);for(let t of e.routes){let e=n(t.originPluginId,t.originFilePath),r=o.get(e)??[];if(r.push(t),o.set(e,r),s.set(t.slug,t),t.originFilePath===null)continue;let i=c.get(t.originFilePath);(i===void 0||a(t.slug,i)<0)&&c.set(t.originFilePath,t.slug)}return{wildcardShadows:/* @__PURE__ */ new Set,filePluginsByPath:e.filePluginsByPath,filesByPath:r,ignoredFilesByPath:i,primaryRouteByFilePath:c,routeBySlug:s,routesByOriginKey:o,entitiesByKey:l}}function u(e){return new Map(e.map(e=>[e.key,{id:e.id,key:e.key,kind:e.kind,type:e.type,metadata:e.metadata,dataHash:e.dataHash,pluginId:e.pluginId,loaderId:e.loaderId,loaderArgs:e.loaderArgs,status:e.status,isSystem:e.isSystem===1}]))}export{o as loadContentLayerState,c as partitionIgnoredFiles,s as reloadContentLayerEntities};
|
|
@@ -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 = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createNodePlatform as e}from"../platform/node/create.js";import{createLogger as t}from"../shared/logger.js";import{createEmptyRealmConfig as n}from"./config.js";import{createContentPluginIO as r}from"./plugins/io.js";import{createContentPluginRegistry as i}from"./plugins/registry.js";import{resolve as a}from"node:path";function o(o){let s=a(o.contentDir),c=o.platform??e(),l=o.pluginRegistry??i(o.plugins??[],o.logger),u=o.config??n();return{config:u,siteConfig:u,configFilePath:o.configFilePath??null,configHash:null,configRefs:[],configLoaded:o.configLoaded??o.config!==void 0,contentDir:s,currentFileIndex:o.currentFileIndex,logger:o.logger??t(),platform:c,pluginIO:o.pluginIO??r(c.fs),pluginRegistry:l,state:o.state}}function s(e){return e.context?(e.currentFileIndex!==void 0&&(e.context.currentFileIndex=e.currentFileIndex),e.context):o({contentDir:e.contentDir,currentFileIndex:e.currentFileIndex,logger:e.logger,plugins:e.plugins})}export{o as createContentLayerContext,s as resolveContentLayerContext};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{assetRefs as e,assets as t}from"./schema.js";import{runWithSqliteBusyRetry as n}from"./connection.js";import{and as r,eq as i,inArray as a,sql as o}from"drizzle-orm";async function s(e,n){if(n.length===0)return[];let o=/* @__PURE__ */ new Set;for(let a of n){let n=await e.select({filename:t.filename}).from(t).where(r(i(t.path,a.path),i(t.hash,a.hash)));for(let e of n)e.filename!==a.filename&&o.add(e.filename)}await e.insert(t).values([...n]).onConflictDoNothing();for(let a of n)await e.update(t).set({filename:a.filename}).where(r(i(t.path,a.path),i(t.hash,a.hash)));if(o.size===0)return[];let s=await e.select({filename:t.filename}).from(t).where(a(t.filename,[...o]));for(let e of s)o.delete(e.filename);return[...o]}async function c(t,n){await t.delete(e).where(i(e.entityId,n.entityId)),n.refs.length!==0&&await t.insert(e).values(n.refs.map(e=>({...e,entityId:n.entityId})))}async function l(e){return(await e.db.selectDistinct({path:t.path}).from(t)).map(e=>e.path)}async function u(e){return e.db.select({path:t.path,hash:t.hash,kind:t.kind,filename:t.filename}).from(t)}async function d(e,r){return n(async()=>{let n=await e.db.delete(t).where(o`(${t.path}, ${t.hash}) NOT IN (SELECT DISTINCT path, hash FROM asset_refs)`).returning(),r=new Set(n.map(e=>e.filename));if(r.size>0){let n=await e.db.select({filename:t.filename}).from(t).where(a(t.filename,[...r]));for(let e of n)r.delete(e.filename)}return{removed:n,orphanedFilenames:[...r]}},{logger:r?.logger,operation:`gc orphan assets`})}export{d as garbageCollectOrphanAssets,l as listAssetSourcePaths,u as listRegisteredAssets,c as replaceAssetRefsForEntityTx,s as upsertAssetsTx};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{blobRefs as e,blobs as t}from"./schema.js";import{runWithSqliteBusyRetry as n}from"./connection.js";import{eq as r,sql as i}from"drizzle-orm";async function a(e,r,i){await n(()=>e.db.insert(t).values({...r,createdAt:Date.now()}).onConflictDoNothing(),{logger:i?.logger,operation:`upsert blob`})}async function o(e,n){let[i]=await e.db.select().from(t).where(r(t.key,n)).limit(1);return i??null}async function s(e,t){let n=await o(e,t.blobKey);if(!n)throw Error(`Blob not found: ${t.blobKey}`);return t.format===`json`?JSON.parse(n.content):t.format===`text`?n.content:Buffer.from(n.content,`base64`)}async function c(t,n){await t.delete(e).where(r(e.entityId,n.entityId)),n.blobKeys.length!==0&&await t.insert(e).values(n.blobKeys.map(e=>({blobKey:e,entityId:n.entityId})))}async function l(e,t){return{removed:(await n(()=>e.db.run(i`DELETE FROM blobs WHERE key NOT IN (SELECT DISTINCT blob_key FROM blob_refs)`),{logger:t?.logger,operation:`gc orphan blobs`})).rowsAffected??0}}export{l as garbageCollectOrphanBlobs,o as getBlob,c as replaceBlobRefsForEntityTx,s as resolveDataRef,a as upsertBlob};
|
|
@@ -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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hashJsonValue as e,toStableJsonString as t}from"./utils/json.js";import{compareStrings as n}from"../../shared/utils/compare-strings.js";import{
|
|
1
|
+
import{hashJsonValue as e,toStableJsonString as t}from"./utils/json.js";import{compareStrings as n}from"../../shared/utils/compare-strings.js";import{entities as r}from"./schema.js";import{replaceDataRefMarkers as i}from"../materialization/data-ref.js";import{MaterializationError as a}from"../problems/problem-error.js";import{resolveDataRef as o}from"./blobs.js";import{listEntityRevisions as s}from"../revisions/list.js";import{selectEntityRowForRead as c}from"../revisions/read.js";import{and as l,eq as u,inArray as d}from"drizzle-orm";function f(e){let{database:t,state:d}=e,f=typeof e.revisionAsOf==`number`?e.revisionAsOf:null,p=async n=>{if(e.onEntityRead?.(n),f!==null){let e=await c(t.db,n,f);return e?S(e):null}let i=d?.entitiesByKey.get(n);if(i)return S(i);if(d)return null;let[a]=await t.db.select(x()).from(r).where(l(u(r.key,n),u(r.isCurrent,1))).limit(1);return a?S(a):null},g=e=>i(e,e=>o(t,e)),_=async(n,i)=>{let o=d?.entitiesByKey.get(n),[s]=f===null?d&&!o?[]:await t.db.select({status:r.status,data:r.data,dataHash:r.dataHash,type:r.type,metadata:r.metadata,isCurrent:r.isCurrent}).from(r).where(l(u(r.key,n),u(r.isCurrent,1))).limit(1):[await c(t.db,n,f)??void 0];if(!s)throw e.onEntityRead?.(n),Error(`Entity "${n}" is not registered.`);let p;if(s.status===`ready`&&s.data!==null||s.isCurrent!==1)p=s.data,d&&s.isCurrent===1&&f===null&&m(d,n,s);else if(e.materialize)try{p=await e.materialize(n)}catch(t){if(e.onEntityRead?.(n,!0),!i||!(t instanceof a))throw t;return s.data===null?void 0:g(s.data)}else throw Error(`Missing precomputed entity data for "${n}". Rebuild the content entity data before starting the production runtime.`);return e.onEntityRead?.(n),g(p)};return{get:p,async listRevisions(n){for(let t of n)e.onEntityRead?.(t);return s(t.db,n)},async list(i={}){let a=(d?[...d.entitiesByKey.values()].filter(e=>y(e,i)):await t.db.select(x()).from(r).where(l(u(r.isCurrent,1),i.type===void 0?void 0:u(r.type,i.type),i.pluginId===void 0?void 0:u(r.pluginId,i.pluginId)))).map(S).sort((e,t)=>n(e.key,t.key));return e.record?.({kind:`entity-type`,argument:h(i),resultHash:v(a.map(e=>e.key))}),a},load:async e=>await _(e,!1),tryLoad:async e=>await _(e,!0)}}async function p(e,t,n){let[i]=await e.db.select({status:r.status,dataHash:r.dataHash,type:r.type,metadata:r.metadata}).from(r).where(l(u(r.key,n),u(r.isCurrent,1))).limit(1);i&&m(t,n,i)}function m(e,t,n){let r=e.entitiesByKey.get(t);r&&Object.assign(r,{status:n.status,dataHash:n.dataHash,type:n.type,metadata:n.metadata})}function h(e){return t({...e.type===void 0?{}:{type:e.type},...e.pluginId===void 0?{}:{pluginId:e.pluginId}})}function g(t,n){let r=t.entitiesByKey.get(n);return e(r?[r.id,r.kind,r.type,r.metadata,r.dataHash,r.status]:`absent`)}function _(e,t){let r=JSON.parse(t),i=[];for(let t of e.entitiesByKey.values())y(t,r)&&i.push(t.key);return v(i.sort(n))}function v(t){return e([...t])}function y(e,t){return(t.type===void 0||e.type===t.type)&&(t.pluginId===void 0||e.pluginId===t.pluginId)}async function b(e,t){return t.length===0?[]:e.db.select({key:r.key,metadata:r.metadata}).from(r).where(l(d(r.key,[...t]),u(r.isCurrent,1)))}function x(){return{id:r.id,key:r.key,kind:r.kind,type:r.type,metadata:r.metadata,pluginId:r.pluginId,loaderId:r.loaderId,loaderArgs:r.loaderArgs,status:r.status,dataHash:r.dataHash,isSystem:r.isSystem}}function S(e){return{id:e.id,key:e.key,kind:e.kind,type:e.type,metadata:e.metadata,pluginId:e.pluginId,loaderId:e.loaderId,loaderArgs:e.loaderArgs,status:e.status,dataHash:e.dataHash,isSystem:e.isSystem===!0||e.isSystem===1}}export{f as createEntityStore,_ as hashEntityListMembership,g as hashEntityRead,b as loadCurrentEntityMetadata,p as refreshStateEntity};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{entities as e,entityDeps as t,filePlugins as n,files as r,originDeps as i,routeDeps as a,routes as o,searchDocuments as s}from"./schema.js";import{batchValues as c,normalizeBatchSize as l,runWithSqliteBusyRetry as u}from"./connection.js";import{deleteProblemsForFilesTx as d}from"./problems.js";import{garbageCollectOrphanedEntitiesInTransaction as f}from"./invalidation.js";import{deleteLinkRowsForFilesTx as p}from"./link-refs.js";import{and as m,eq as h,inArray as g,sql as _}from"drizzle-orm";async function v(e){return e.db.select({hash:r.hash,id:r.id,lastModifiedAt:r.lastModifiedAt,manifestVersion:r.manifestVersion,path:r.path}).from(r).orderBy(r.path)}async function y(e,t){let n=/* @__PURE__ */ new Map;for(let i of c(t,500)){let t=await e.db.select({manifest:r.manifest,path:r.path}).from(r).where(g(r.path,i));for(let e of t)n.set(e.path,JSON.parse(e.manifest))}return n}async function b(e){let t=await e.db.select({fileId:n.fileId,filePath:r.path,pluginId:n.pluginId,pluginVersion:n.pluginVersion}).from(n).innerJoin(r,h(n.fileId,r.id)).orderBy(r.path,n.pluginId),i=/* @__PURE__ */ new Map;for(let e of t){let t=i.get(e.filePath)??[];t.push({fileId:e.fileId,pluginId:e.pluginId,pluginVersion:e.pluginVersion}),i.set(e.filePath,t)}return i}async function x(e){let[t,n,i,a]=await Promise.all([v(e),e.db.select({metadata:o.metadata,originFileId:o.sourceId,originFilePath:r.path,originPluginId:o.pluginId,routeId:o.routeId,sidebarSubtreeEntityKey:o.sidebarSubtreeEntityKey,wildcardPrefix:o.wildcardPrefix,slug:o.slug,requestedSlug:o.requestedSlug,slugType:o.slugType,template:o.template,versionGroup:o.versionGroup,version:o.version,locale:o.locale,isFallback:o.isFallback,canonicalSlug:o.canonicalSlug}).from(o).leftJoin(r,h(o.sourceId,r.id)).orderBy(r.path,o.pluginId,o.routeId),S(e),b(e)]);return{entities:i,filePluginsByPath:a,files:t,routes:n}}async function S(t,n){return t.db.select({id:e.id,isSystem:e.isSystem,key:e.key,kind:e.kind,type:e.type,metadata:e.metadata,dataHash:e.dataHash,loaderArgs:e.loaderArgs,loaderId:e.loaderId,pluginId:e.pluginId,status:e.status}).from(e).where(n===void 0?h(e.isCurrent,1):m(g(e.key,[...n]),h(e.isCurrent,1))).orderBy(e.key)}async function C(e,s){let m=l(s.batchSize);return s.upserts.length===0&&s.removedPaths.length===0?[]:u(()=>e.db.transaction(async e=>{let l=[];for(let t of c(s.upserts,m)){let n=await e.insert(r).values(t).onConflictDoUpdate({target:r.path,set:{hash:_.raw(`excluded.hash`),manifest:_.raw(`excluded.manifest`),manifestVersion:_.raw(`excluded.manifest_v`),lastModifiedAt:_.raw(`excluded.last_modified_at`)}}).returning({id:r.id,path:r.path,hash:r.hash,lastModifiedAt:r.lastModifiedAt,manifestVersion:r.manifestVersion});l.push(...n)}if(s.removedPaths.length>0){let l=(await e.select({id:r.id}).from(r).where(g(r.path,s.removedPaths))).map(e=>e.id);if(l.length>0){for(let r of c(l,m))await e.delete(t).where(g(t.originFileId,r)),await e.delete(i).where(g(i.originFileId,r)),await e.delete(a).where(g(a.originFileId,r)),await e.delete(o).where(g(o.sourceId,r)),await e.delete(n).where(g(n.fileId,r)),await d(e,r,m),await p(e,r,m);for(let t of c(l,m))await e.delete(r).where(g(r.id,t));await f(e)}}return l}),{logger:s.logger,operation:`persist content file state`})}async function w(e,t,n){t.length!==0&&await u(()=>e.db.transaction(async e=>{for(let n of t)await e.update(r).set({lastModifiedAt:n.lastModifiedAt}).where(h(r.path,n.path))}),{logger:n,operation:`refresh file last-modified`})}async function T(e){let[t,n]=await Promise.all([e.db.select({filePath:r.path,slug:o.slug,metadata:o.metadata}).from(o).innerJoin(r,h(o.sourceId,r.id)),e.db.select({slug:s.routeSlug,title:s.title}).from(s).where(g(s.docKey,[`page`,`overview`]))]),i=new Map(n.map(e=>[e.slug,e.title])),a=/* @__PURE__ */ new Map;for(let{filePath:e,slug:n,metadata:r}of t){let t=a.get(e);if(t!==void 0&&t.slug.length<=n.length)continue;let o=i.get(n)||r.title;a.set(e,typeof o==`string`&&o?{slug:n,title:o}:{slug:n})}return a}export{T as listRoutePagesByFile,y as loadFileManifestsByPaths,S as loadPersistedContentStateEntities,x as loadPersistedContentStateSummary,v as loadStoredContentFiles,C as persistContentFileState,w as refreshFileLastModified};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isJsonObject as e,toJsonObject as t,toStableJsonString as n}from"./utils/json.js";import{compareStrings as r}from"../../shared/utils/compare-strings.js";import{
|
|
1
|
+
import{isJsonObject as e,toJsonObject as t,toStableJsonString as n}from"./utils/json.js";import{compareStrings as r}from"../../shared/utils/compare-strings.js";import{entities as i,entityDeps as a,originDeps as o,pluginHookState as s,routeDeps as c,routeQueryDeps as l,routes as u,staticFiles as d}from"./schema.js";import{batchValues as f,normalizeBatchSize as p,runWithSqliteBusyRetry as m}from"./connection.js";import{deleteProblemsForPluginHookTx as h,insertProblemsTx as g,replaceGlobalProblemsForKeysTx as _}from"./problems.js";import{generateEntityId as v}from"./entities.js";import{writePluginHookState as y}from"./plugin-hook-state.js";import{replaceRouteQueryDepsTx as b}from"./route-query-deps.js";import{upsertEntityDescriptors as x}from"./origins.js";import{inArray as S,notInArray as C,sql as w}from"drizzle-orm";async function T(e,t,n){t.length!==0&&await m(()=>e.db.transaction(async e=>{for(let n of t)await E(e,n)}),{logger:n?.logger,operation:`register system entities`})}async function E(e,t){let[r]=await e.select({id:i.id,kind:i.kind,pluginId:i.pluginId,loaderId:i.loaderId,loaderArgs:i.loaderArgs}).from(i).where(w`${i.key} = ${t.key} and ${i.isCurrent} = 1`).limit(1),a=t.fragmentUpdates?D(r?.loaderArgs??null,t.loaderArgs,t.fragmentUpdates):t.loaderArgs,o=!r||r.kind!==t.kind||r.pluginId!==t.pluginId||r.loaderId!==t.loaderId||n(r.loaderArgs??null)!==n(a??null);await e.insert(i).values({id:r?.id??v(),key:t.key,kind:t.kind,type:t.type,metadata:t.metadata,pluginId:t.pluginId,loaderId:t.loaderId,loaderArgs:a,status:`stale`,data:null,markdoc:null,isSystem:1}).onConflictDoUpdate({target:i.id,set:{kind:w.raw(`excluded.kind`),pluginId:w.raw(`excluded.plugin_id`),loaderId:w.raw(`excluded.loader_id`),loaderArgs:w.raw(`excluded.loader_args`),isSystem:w.raw(`excluded.is_system`)}}),(t.shouldInvalidateValue||o)&&await e.update(i).set({status:`stale`,invalidationSeq:w`${i.invalidationSeq} + 1`}).where(w`${i.key} = ${t.key} and ${i.isCurrent} = 1`)}function D(n,i,a){let o=e(n)&&e(n.fragments)?n.fragments:{},s={};for(let[t,n]of Object.entries(o))e(n)&&typeof n.owner==`string`&&!a.has(n.owner)&&(s[t]=n);for(let[e,t]of a)for(let[n,r]of Object.entries(t??{}))s[n]={owner:e,value:r};let c=t(Object.fromEntries(Object.keys(s).sort(r).map(e=>[e,s[e]])));return{...e(i)?i:{},fragments:c}}function O(t){let n=/* @__PURE__ */ new Set,r=e(t)&&e(t.fragments)?t.fragments:{};for(let t of Object.values(r))e(t)&&typeof t.owner==`string`&&`value`in t&&n.add(t.owner);return n}async function k(e,t){let n=p(t.batchSize);await m(()=>e.db.transaction(async e=>{await e.delete(o).where(w`${o.originPluginId} = ${t.originPluginId} and ${o.originFileId} is null and ${o.hook} = 'finalize'`);for(let r of f(t.dependencies,n))r.length!==0&&await e.insert(o).values(r.map(e=>({accessType:e.accessType,originFileId:null,originPluginId:t.originPluginId,hook:`finalize`,source:e.source,path:e.path,valueHash:e.valueHash})));await b(e,{originPluginId:t.originPluginId,hook:`finalize`,entityId:null,dependencies:t.routeQueries}),await y(e,{pluginId:t.originPluginId,hook:`finalize`,fingerprint:t.fingerprint})}),{logger:t.logger,operation:`replace finalize reads`})}async function A(e,t,n){let r=t.map(e=>`${e.hook}:${e.pluginId}`),i=e=>t.filter(t=>t.hook===e).map(e=>e.pluginId),f=i(`extractAll`),p=i(`finalize`),h=(e,t)=>C(w`${t} || ':' || ${e}`,r),g=e=>w`${e.originFileId} is null and ${e.hook} in ('extractAll', 'finalize') and ${h(e.originPluginId,e.hook)}`;return m(()=>e.db.transaction(async e=>[await e.delete(o).where(g(o)).returning({id:o.id}),await e.delete(a).where(g(a)).returning({id:a.id}),await e.delete(c).where(g(c)).returning({id:c.id}),await e.delete(l).where(w`${l.entityId} is null and ${l.hook} in ('extractAll', 'finalize') and ${h(l.originPluginId,l.hook)}`).returning({id:l.id}),await e.delete(u).where(w`${u.sourceId} is null and ${u.isFallback} = 0 and ${C(u.pluginId,f)}`).returning({id:u.id}),await e.delete(d).where(C(d.ownerPluginId,p)).returning({id:d.path}),await e.delete(s).where(h(s.pluginId,s.hook)).returning({id:s.pluginId})].some(e=>e.length>0)),{logger:n?.logger,operation:`reconcile plugin-scoped rows`})}async function j(e,t){let n=[...t],r=w`${c.originFileId} is null`;return e.db.select({routeSlug:c.routeSlug,key:c.key,originPluginId:c.originPluginId}).from(c).where(n.length===0?r:w`${r} and not (${c.hook} = 'finalize' and ${S(c.originPluginId,n)})`)}async function M(e,t){let n=p(t.batchSize);await m(()=>e.db.transaction(async e=>{await P(e,t.originPluginId),await F(e,t,n)}),{logger:t.logger,operation:`replace finalize artifacts`})}async function N(e,t){await m(()=>e.db.transaction(async e=>{await h(e,t.pluginIds,`finalize`),await g(e,t.pluginProblems),await _(e,`finalize`,t.globalKeys,t.globalProblems)}),{logger:t.logger,operation:`replace finalize problems`})}async function P(e,t){await e.delete(c).where(w`${c.originFileId} is null and ${c.originPluginId} = ${t} and ${c.hook} = 'finalize'`),await e.delete(a).where(w`${a.originFileId} is null and ${a.originPluginId} = ${t} and ${a.hook} = 'finalize'`)}async function F(e,t,n){let r=await x(e,t.entities,n);for(let r of f(t.routeDependencies,n))r.length!==0&&await e.insert(c).values(r.map(e=>({args:e.args,dependencyType:e.dependencyType,key:e.key,originFileId:null,originPluginId:t.originPluginId,hook:`finalize`,routeSlug:e.routeSlug,target:e.target}))).onConflictDoNothing();if(t.entities.length!==0)for(let n of t.entities){let i=r.get(n.key);if(!i)throw Error(`Missing entity row for key "${n.key}".`);await e.insert(a).values({dependencyRef:t.originPluginId,dependencyType:`origin`,entityId:i,originFileId:null,originPluginId:t.originPluginId,hook:`finalize`}).onConflictDoNothing()}}export{O as collectAppDataFragmentOwnerIds,j as loadPluginScopedRouteDepOwners,A as reconcilePluginScopedRows,T as registerSystemEntities,M as replaceFinalizeArtifacts,N as replaceFinalizeProblems,k as replaceFinalizeReads};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{delocalizeL10nPath as e}from"../../shared/utils/l10n.js";import{assetRefs as t,entities as n,entityDeps as r,files as i,linkRefs as a,loaderConfigDeps as o,originDeps as s,pageMarkdown as c,problems as l,searchDocuments as u,searchFragmentParents as d,searchFragmentPostings as f,searchFragmentUsages as p,searchFragments as m,searchPostings as h}from"./schema.js";import{compileGlob as g,hashGlobMatches as _,matchGlob as v}from"../plugins/utils/glob.js";import{hashContentConfigDependency as y}from"../config-deps.js";import{runWithSqliteBusyRetry as b}from"./connection.js";import{createRouteQueryEvaluator as x,isRouteQueryStale as S}from"../plugins/utils/route-index.js";import{APP_DATA_ENTITY_KEY as C}from"../../shared/constants/app-data.js";import{refreshTermDocCounts as w,selectTermIdsOfDocuments as T,selectTermIdsOfFragments as E}from"./search-vocab.js";import{RETRYABLE_PROBLEM_CODES as D}from"../problems/codes.js";import{and as O,eq as k,inArray as A,sql as j}from"drizzle-orm";async function M(e){return await e.db.select({accessType:s.accessType,originFileId:s.originFileId,originFilePath:i.path,originPluginId:s.originPluginId,hook:s.hook,path:s.path,source:s.source,valueHash:s.valueHash}).from(s).leftJoin(i,k(s.originFileId,i.id)).orderBy(i.path,s.originPluginId,s.path,s.accessType)}function N(e,t){let n=/* @__PURE__ */ new Map,r=L(t);for(let t of e){if(t.source!==`config`||t.originFileId===null||t.originFilePath===null||r(t)===t.valueHash)continue;let e=`${t.originPluginId}:${t.originFilePath}`;n.has(e)||n.set(e,t)}return R([...n.values()])}function P(e,t){let n=/* @__PURE__ */ new Map;for(let r of e){if(r.source===`config`||r.originFileId===null||r.originFilePath===null||F(r,t)===r.valueHash)continue;let e=`${r.originPluginId}:${r.originFilePath}`;n.has(e)||n.set(e,r)}return R([...n.values()])}function F(e,t){if(e.source===`glob`)return _(v(t.filesByPath.keys(),e.path));let n=t.filesByPath.get(e.path)??t.ignoredFilesByPath?.get(e.path);return e.accessType===`presence`?n?`present`:`absent`:n?.hash??null}function I(e,t,n){let r=/* @__PURE__ */ new Set,i=L(n.config);for(let a of e)a.originFileId!==null||a.hook!==t||r.has(a.originPluginId)||(a.source===`config`?i(a):F(a,n))!==a.valueHash&&r.add(a.originPluginId);return r}function L(e){let t=/* @__PURE__ */ new Map;return n=>{let r=`${n.accessType}\u0000${n.path}`,i=t.get(r);return i===void 0&&(i=y(e,n),t.set(r,i)),i}}function R(e){return e.sort((e,t)=>{let n=e.originFilePath.localeCompare(t.originFilePath);return n===0?e.originPluginId.localeCompare(t.originPluginId):n})}async function z(e,t){let r=await e.db.select({accessType:o.accessType,path:o.path,key:n.key,valueHash:o.valueHash}).from(o).innerJoin(n,k(o.entityId,n.id)).orderBy(n.key,o.path,o.accessType),i=/* @__PURE__ */ new Set;for(let e of r)y(t.config,e)!==e.valueHash&&i.add(e.key);let a=await U(e,{logger:t.logger,reason:`config dependency invalidation`,keys:[...i]});return a.invalidatedKeys.length>0&&t.logger?.debug(`Propagated config dependency invalidation`,{invalidatedKeys:a.invalidatedKeys.length}),a}async function B(e,t={}){let r=await e.db.selectDistinct({key:n.key}).from(l).innerJoin(n,k(l.entityId,n.id)).where(O(k(l.scope,`entity`),A(l.code,[...D]),k(n.isCurrent,1)));return U(e,{logger:t.logger,reason:`retryable problem invalidation`,keys:r.map(e=>e.key)})}async function V(e,t){let r=x(t.state,t.config).memoized(),i=/* @__PURE__ */ new Set;for(let e of t.rows)e.entityId===null||e.hook===`searchable`||i.has(e.entityId)||S(r,e)&&i.add(e.entityId);if(i.size===0)return{invalidatedKeys:[]};let a=await e.db.select({key:n.key}).from(n).where(A(n.id,[...i]));return U(e,{logger:t.logger,reason:`route query invalidation`,keys:a.map(e=>e.key)})}async function H(i,a){if(a.changedFilePaths.length===0)return{invalidatedKeys:[]};let o=/* @__PURE__ */ new Set,s=await i.db.select({key:n.key}).from(n).innerJoin(r,k(r.entityId,n.id)).where(j`${r.dependencyType} in ('file','origin') and ${r.dependencyRef} in ${a.changedFilePaths}`);for(let e of s)o.has(e.key)||o.add(e.key);let c=[...new Set(a.changedFilePaths.map(e).filter(e=>e!==void 0))];if(c.length>0){let e=await i.db.select({key:n.key}).from(n).innerJoin(t,k(t.entityId,n.id)).where(A(t.path,c));for(let t of e)o.add(t.key)}let l=a.membershipChangedPaths??[];if(l.length>0){let e=await i.db.select({key:n.key,pattern:r.dependencyRef}).from(n).innerJoin(r,k(r.entityId,n.id)).where(k(r.dependencyType,`glob`));for(let t of e){let e=g(t.pattern);l.some(e)&&o.add(t.key)}}let u=await U(i,{logger:a.logger,reason:`file dependency invalidation`,keys:[...o]});return u.invalidatedKeys.length>0&&a.logger?.debug(`Propagated entity invalidation`,{changedFilePaths:a.changedFilePaths.length,invalidatedKeys:u.invalidatedKeys.length}),u}async function U(e,t){let i=new Set(t.keys),a=new Set(i),o=[...i];for(;o.length>0;){let t=o;o=[];let i=await e.db.select({key:n.key}).from(n).innerJoin(r,k(r.entityId,n.id)).where(j`${r.dependencyType} = 'entity' and ${r.dependencyRef} in ${t}`);for(let e of i)a.has(e.key)||(a.add(e.key),o.push(e.key))}let s=t.markKeys===!1?[...a].filter(e=>!i.has(e)):[...a];return s.length===0?{invalidatedKeys:[]}:(await b(()=>e.db.update(n).set({status:`stale`,invalidationSeq:j`${n.invalidationSeq} + 1`}).where(O(A(n.key,s),k(n.isCurrent,1))),{logger:t.logger,operation:t.reason}),{invalidatedKeys:s})}async function W(e,t){return b(()=>e.db.transaction(e=>G(e)),{logger:t,operation:`garbage collect orphaned entities`})}async function G(e){let t=j`(${n.isSystem} = 0 or ${n.key} <> ${C}) and ${n.isCurrent} = 1 and not exists (
|
|
2
2
|
select 1
|
|
3
|
-
from ${
|
|
4
|
-
where ${
|
|
5
|
-
and ${
|
|
6
|
-
)`,[
|
|
7
|
-
select 1 from ${
|
|
8
|
-
where live.key = ${
|
|
9
|
-
)`),{removedOrphans:
|
|
10
|
-
select ${
|
|
11
|
-
)`);let
|
|
12
|
-
where ${
|
|
13
|
-
select ${
|
|
14
|
-
)`,
|
|
15
|
-
where ${
|
|
16
|
-
select ${
|
|
17
|
-
)`,
|
|
18
|
-
select ${
|
|
19
|
-
)`),await e.delete(
|
|
20
|
-
select ${
|
|
21
|
-
)`),await e.delete(
|
|
22
|
-
select ${
|
|
23
|
-
)`);let
|
|
24
|
-
select ${
|
|
25
|
-
)`;await e.delete(
|
|
26
|
-
select ${
|
|
27
|
-
)`),await e.delete(
|
|
3
|
+
from ${r}
|
|
4
|
+
where ${r.entityId} = ${n.id}
|
|
5
|
+
and ${r.dependencyType} = 'origin'
|
|
6
|
+
)`,[i]=await e.select({id:n.id}).from(n).where(t).limit(1);return i!==void 0&&await K(e,t),await e.delete(n).where(j`${n.isCurrent} = 0 and not exists (
|
|
7
|
+
select 1 from ${n} as live
|
|
8
|
+
where live.key = ${n.key} and live.is_current = 1
|
|
9
|
+
)`),{removedOrphans:i!==void 0}}async function K(e,t){await e.delete(o).where(j`${o.entityId} in (
|
|
10
|
+
select ${n.id} from ${n} where ${t}
|
|
11
|
+
)`);let r=j`select ${u.id} from ${u}
|
|
12
|
+
where ${u.entityKey} in (
|
|
13
|
+
select ${n.key} from ${n} where ${t}
|
|
14
|
+
)`,i=j`select ${m.id} from ${m}
|
|
15
|
+
where ${m.entityKey} in (
|
|
16
|
+
select ${n.key} from ${n} where ${t}
|
|
17
|
+
)`,s=[...await T(e,r),...await E(e,i)];await e.delete(h).where(j`${h.docId} in (${r})`),await e.delete(f).where(j`${f.fragmentId} in (${i})`),await e.delete(d).where(j`${d.docId} in (${r})`),await e.delete(p).where(j`${p.fragmentId} in (${i})`),await e.delete(m).where(j`${m.id} in (${i})`),await w(e,s),await e.delete(u).where(j`${u.entityKey} in (
|
|
18
|
+
select ${n.key} from ${n} where ${t}
|
|
19
|
+
)`),await e.delete(c).where(j`${c.entityKey} in (
|
|
20
|
+
select ${n.key} from ${n} where ${t}
|
|
21
|
+
)`),await e.delete(l).where(j`${l.scope} = 'entity' and ${l.entityId} in (
|
|
22
|
+
select ${n.id} from ${n} where ${t}
|
|
23
|
+
)`);let g=j`${a.entityId} in (
|
|
24
|
+
select ${n.id} from ${n} where ${t}
|
|
25
|
+
)`;await e.delete(l).where(j`${l.scope} = 'link' and ${l.linkRefId} in (
|
|
26
|
+
select ${a.id} from ${a} where ${g}
|
|
27
|
+
)`),await e.delete(a).where(g),await e.delete(n).where(t)}export{N as computeDirtyConfigOrigins,P as computeDirtyFileOrigins,I as computeDirtyPluginScopedOrigins,W as garbageCollectOrphanedEntities,G as garbageCollectOrphanedEntitiesInTransaction,M as loadOriginDependencyRows,z as propagateConfigDependencyInvalidation,H as propagateEntityInvalidation,U as propagateEntityInvalidationFromKeys,B as propagateRetryableProblemInvalidation,V as propagateRouteQueryInvalidation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{linkRefs as e,targetInventories as t}from"./schema.js";import{batchValues as n}from"./connection.js";import{deleteProblemsForLinkRefsTx as r}from"./problems.js";import{and as i,eq as a,inArray as o,isNull as s}from"drizzle-orm";async function c(t,n,r=500){await d(t,(await t.select({id:e.id}).from(e).where(a(e.entityId,n.entityId))).map(e=>e.id),n.drafts,e=>({entityId:n.entityId,originFileId:n.originFileId,originPluginId:n.originPluginId,filePath:e.filePath??n.filePath,kind:e.kind,raw:e.raw,targetKind:e.targetKind,target:e.target,fragment:e.fragment,title:e.title??null,range:e.range??null,data:e.data??null}),r)}async function l(t,n,r=500){await d(t,(await t.select({id:e.id}).from(e).where(i(a(e.originPluginId,n.originPluginId),s(e.entityId)))).map(e=>e.id),n.drafts,e=>({entityId:null,originFileId:null,originPluginId:n.originPluginId,filePath:e.filePath??n.filePath,kind:e.kind,raw:e.raw,targetKind:e.targetKind,target:e.target,fragment:e.fragment,title:e.title??null,range:e.range??null,data:e.data??null}),r)}async function u(t,n){let[r]=await t.db.select({id:e.id}).from(e).where(i(a(e.originPluginId,n),s(e.entityId))).limit(1);return r!==void 0}async function d(t,i,a,s,c){i.length>0&&(await r(t,i,c),await t.delete(e).where(o(e.id,i)));for(let r of n(a,c))await t.insert(e).values(r.map(s))}async function f(e,n){await e.delete(t).where(i(a(t.fileId,n.fileId),a(t.originPluginId,n.originPluginId),a(t.kind,n.draft.kind))),(n.draft.kind!==`subpath`||n.draft.targets.length!==0)&&await e.insert(t).values({fileId:n.fileId,originPluginId:n.originPluginId,kind:n.draft.kind,exhaustive:n.draft.exhaustive,targets:n.draft.targets})}async function p(e,r,i=500){for(let a of n(r,i))await e.delete(t).where(o(t.fileId,a));await m(e,r,i)}async function m(t,a,c=500){for(let l of n(a,c)){let n=await t.select({id:e.id}).from(e).where(i(o(e.originFileId,l),s(e.entityId)));if(n.length===0)continue;let a=n.map(e=>e.id);await r(t,a,c),await t.delete(e).where(o(e.id,a))}}export{p as deleteLinkRowsForFilesTx,m as deleteOriginLinkRefsForFilesTx,u as hasPluginLinkRefs,c as replaceLinkRefsForEntityTx,l as replacePluginLinkRefsTx,f as upsertTargetInventoryTx};
|
|
@@ -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{
|
|
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{deleteProblemsForFilesTx as d,deleteProblemsForPluginHookTx as f,insertProblemsTx as p,problemRow as m,replaceGlobalProblemsForKeysTx as h}from"./problems.js";import{generateEntityId as g}from"./entities.js";import{garbageCollectOrphanedEntitiesInTransaction as _}from"./invalidation.js";import{deleteOriginLinkRefsForFilesTx as v}from"./link-refs.js";import{cutEntityRevisionTx as y}from"../revisions/cut.js";import{detectMarkdocPayloadFlag as b}from"../markdown/server/render.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??[],f=c?.extractAllFailures??[],g=c?.globalProblems,v=c?.fallbackRoutes,y=(v?.removedSlugs.length??0)+(v?.added.length??0);if(t.length===0&&d.length===0&&f.length===0&&g===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:f,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,...f.map(e=>m(e.problem,{scope:`origin`,originFileId:null,originPluginId:e.pluginId,hook:`extractAll`}))];await p(e,y,b),g&&await h(e,g.source,g.keys,g.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 _(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 d(e,t.fileIds,t.batchSize),await v(e,t.fileIds,t.batchSize),await f(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(m(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 d=Date.now(),f=[];for(let t of o.values()){let r=u.get(t.key),i=r?.id??g();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),p=r?.revisionCreatedAt??d;t.kind===`inline`&&r&&(r.dataHash??null)!==c&&(a?.trackedKeys.has(t.key)&&await y(n,{current:r,max:a.max}),p=Math.max(d,r.revisionCreatedAt+1)),f.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:b(JSON.stringify(s)),dataHash:c,isSystem:+!!t.isSystem,version:t.version,isCurrent:1,revisionCreatedAt:p})}for(let e of c(f,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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{linkRefs as e,problems as t}from"./schema.js";import{batchValues as n}from"./connection.js";import{asc as r,count as i,inArray as a,notInArray as o,sql as s}from"drizzle-orm";function c(e,t){return{scope:t.scope,originFileId:t.scope===`origin`?t.originFileId:null,originPluginId:t.scope===`origin`?t.originPluginId:null,hook:t.scope===`origin`?t.hook:null,entityId:t.scope===`entity`?t.entityId:null,linkRefId:t.scope===`link`?t.linkRefId:null,source:t.scope===`global`?t.source:null,key:t.scope===`global`?t.key??null:null,code:e.code,category:e.category,severity:e.severity,message:e.message,filePath:e.location?.filePath??null,range:e.location?.range??null,snippet:e.location?.snippet??null,data:e.data??null}}async function l(e,r,i=500){for(let a of n(r,i))await e.insert(t).values(a)}async function u(e,r,i=500){for(let o of n(r,i))await e.delete(t).where(s`${t.scope} = 'origin' and ${a(t.originFileId,o)}`)}async function d(e,n,r){n.length!==0&&await e.delete(t).where(s`${t.scope} = 'origin' and ${t.originFileId} is null and ${t.hook} = ${r} and ${a(t.originPluginId,[...n])}`)}async function f(e,r,i,o=500){if(i.length!==0&&r.size!==0){for(let c of n([...r.keys()],o))await e.delete(t).where(s`${t.scope} = 'entity' and ${a(t.entityId,c)} and ${a(t.code,[...i])}`);await l(e,[...r.values()].flat(),o)}}async function p(e,n,r,i){await e.delete(t).where(r.length===0?s`${t.scope} = 'entity' and ${t.entityId} = ${n}`:s`${t.scope} = 'entity' and ${t.entityId} = ${n} and ${o(t.code,[...r])}`),await l(e,i)}async function m(e,n){let[r]=await e.db.select({id:t.id}).from(t).where(s`${t.scope} = 'global' and ${t.source} = ${n}`).limit(1);return r!==void 0}async function h(e,n,r){await e.delete(t).where(s`${t.scope} = 'global' and ${t.source} = ${n}`),await l(e,r)}async function g(e,n,r,i){r.length>0&&await e.delete(t).where(s`${t.scope} = 'global' and ${t.source} = ${n} and ${a(t.key,[...r])}`),await l(e,i)}async function _(e,r,i=500){for(let o of n(r,i))await e.delete(t).where(s`${t.scope} = 'link' and ${a(t.linkRefId,o)}`)}async function v(n){await n.delete(t).where(s`${t.scope} = 'link' and ${t.linkRefId} not in (select ${e.id} from ${e})`)}async function y(e,n,r=500){await e.delete(t).where(s`${t.scope} = 'link'`),await l(e,n,r)}async function b(e,n){return e.db.select().from(t).where(s`${t.scope} = 'global' and ${t.source} = ${n}`)}async function x(e,n){return e.db.select().from(t).where(s`${t.scope} = 'entity' and ${t.entityId} = ${n}`).orderBy(r(t.id))}async function S(e,n={}){let i=e.db.select().from(t).orderBy(r(t.filePath),r(t.linkRefId),r(t.id));return n.limit===void 0?i:i.limit(n.limit)}async function C(e){let n=await e.db.select({severity:t.severity,code:t.code,count:i()}).from(t).groupBy(t.severity,t.code),r=0,a=0,o={},s={};for(let e of n)e.severity===`error`?(r+=e.count,s[e.code]=(s[e.code]??0)+e.count):a+=e.count,o[e.code]=(o[e.code]??0)+e.count;return{errors:r,warnings:a,byCode:o,errorsByCode:s}}function w(e){let t=0,n=0;for(let r of e)r.severity===`error`?t+=1:n+=1;return{errors:t,warnings:n}}export{v as deleteOrphanedLinkProblemsTx,u as deleteProblemsForFilesTx,_ as deleteProblemsForLinkRefsTx,d as deleteProblemsForPluginHookTx,m as hasGlobalProblemsForSource,l as insertProblemsTx,b as listGlobalProblems,S as listProblems,x as listProblemsForEntity,c as problemRow,y as replaceAllLinkProblemsTx,p as replaceEntityProblemsExceptCodesTx,f as replaceEntityProblemsForCodesBatchTx,g as replaceGlobalProblemsForKeysTx,h as replaceGlobalProblemsForSourceTx,w as summarizeProblems,C as summarizeStoredProblems};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{assetRefs as e,assets as t,blobRefs as n,blobs as r,entities as i,entityDeps as a,filePlugins as o,files as s,linkCheckCheckpoint as c,linkRefs as l,loaderConfigDeps as u,originDeps as d,pageMarkdown as f,pluginHookState as p,problems as m,reactPageChecks as h,routeDeps as g,routes as _,searchDocuments as v,searchFragmentParents as y,searchFragmentPostings as b,searchFragmentUsages as x,searchFragments as S,searchPostings as C,searchVocab as w,staticFiles as T,targetInventories as E}from"./schema.js";import{runWithSqliteBusyRetry as D}from"./connection.js";import{ne as O}from"drizzle-orm";async function k(e){let[t]=await e.db.select({id:s.id}).from(s).where(O(s.manifestVersion,6)).limit(1);return t!==void 0}async function A(O,k){await D(()=>O.db.transaction(async D=>{await D.delete(m),await D.delete(c),await D.delete(l),await D.delete(E),await D.delete(a),await D.delete(u),await D.delete(n),await D.delete(e),await D.delete(o),await D.delete(d),await D.delete(g),await D.delete(_),await D.delete(i),await D.delete(s),await D.delete(r),await D.delete(t),await D.delete(T),await D.delete(C),await D.delete(b),await D.delete(y),await D.delete(x),await D.delete(S),await D.delete(w),await D.delete(v),await D.delete(f),await D.delete(p),await D.delete(h)}),{logger:k?.logger,operation:`reset content database`})}export{k as hasStaleManifestVersion,A as resetContentDatabase};
|
|
@@ -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{
|
|
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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
+ (select count(*) from ${
|
|
1
|
+
import{searchFragmentPostings as e,searchPostings as t,searchVocab as n}from"./schema.js";import{batchValues as r,normalizeBatchSize as i}from"./connection.js";import{and as a,eq as o,inArray as s,sql as c}from"drizzle-orm";async function l(e,n){return(await e.selectDistinct({termId:t.termId}).from(t).where(c`${t.docId} in (${n})`)).map(e=>e.termId)}async function u(t,n){return(await t.selectDistinct({termId:e.termId}).from(e).where(c`${e.fragmentId} in (${n})`)).map(e=>e.termId)}async function d(l,u){let d=[...new Set(u)];for(let u of r(d,i(void 0)))await l.update(n).set({docCount:c`(select count(distinct ${t.docId}) from ${t} where ${t.termId} = ${n.id})
|
|
2
|
+
+ (select count(*) from ${e} where ${e.termId} = ${n.id})`}).where(s(n.id,u)),await l.delete(n).where(a(s(n.id,u),o(n.docCount,0)))}export{d as refreshTermDocCounts,l as selectTermIdsOfDocuments,u as selectTermIdsOfFragments};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{staticFiles as e}from"./schema.js";import{batchValues as t,normalizeBatchSize as n}from"./connection.js";import{replaceGlobalProblemsForKeysTx as r}from"./problems.js";import{eq as i,inArray as a}from"drizzle-orm";async function o(t){return t.db.select().from(e).orderBy(e.path)}async function s(t,n){n.length!==0&&await t.db.transaction(async t=>{for(let r of n)await t.update(e).set({hash:r.hash,size:r.size}).where(i(e.path,r.path))})}async function c(i,o){(o.ownerPluginIds.length!==0||o.problems!==void 0)&&await i.db.transaction(async i=>{if(o.ownerPluginIds.length>0){await i.delete(e).where(a(e.ownerPluginId,[...o.ownerPluginIds]));for(let r of t(o.rows,n(void 0)))r.length>0&&await i.insert(e).values(r)}o.problems&&await r(i,`static`,o.problems.keys,o.problems.newProblems)})}export{o as listStaticFileRecords,c as replaceStaticFileRows,s as updateStaticFileBodies};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createRecordingPluginIO as e}from"../plugins/io.js";import{createTrackedRedoclyConfig as t}from"../config-deps.js";import{dedupeFileDependencies as n}from"../plugins/execute.js";import{dedupeRouteQueryDependencies as r}from"../plugins/utils/route-index.js";import"../plugins/index.js";import{extractAllFailedProblem as i}from"../problems/producers.js";import{buildHookSourceFiles as a,createHookEntityStore as o,resolvePluginHookTriggers as s}from"./hook-inputs.js";import{routeKeepsSlug as c}from"./slugger/drop-colliding-routes.js";import{normalizePluginArtifacts as l}from"./normalize-artifacts.js";import{applyOriginRoutesToWorkingState as u,removeOriginFromWorkingState as d}from"./working-state.js";async function f(c){let f=[],p=[],m=c.materializer.state,h=c.context.pluginRegistry.listExtractAllPlugins();if(h.length===0)return{pending:f,failures:p};let g=s(`extractAll`,c.context,m,c.originRows,c.routeQueryRows,c.hookState),_=c.context.pluginRegistry.list().map(e=>e.id);for(let s of h){if(!g.shouldRun(s)||!s.content?.extractAll)continue;let h=c.logger.child(`content-layer:plugin:${s.id}`),v=t(c.context.config),y=[],b=[],x=e=>b.push(e),S=await a(g.matchedPathsOf(s),c.files,{database:c.database,workingState:m}),C;try{C=await s.content.extractAll({files:S,io:e(c.context.platform.fs,c.context.contentDir,()=>m.filesByPath.keys(),e=>y.push(e)),config:v.config,entities:o(c.database,c.materializer,x),logger:h})}catch(e){let t=e instanceof Error?e:Error(String(e));h.warn(`Content plugin extractAll failed`,{plugin:s.id,error:t.message}),p.push({pluginId:s.id,problem:i({pluginId:s.id,message:t.message})});continue}let w=l({context:c.context,filePath:null,pluginId:s.id,routeDrafts:C?.routes??[],standaloneEntities:C?.entities??[]});d(m,_,s.id,null),u(m,_,s.id,null,w.routes),f.push({pluginId:s.id,inputsHash:g.fingerprintOf(s),routes:w.routes,routeDependencies:w.routeDependencies,entities:w.entities,originDependencies:[...v.collectDependencies().map(e=>Object.assign(e,{source:`config`})),...n(y)],routeQueries:r(b)})}return{pending:f,failures:p}}function p(e,t){if(t.size!==0)for(let n of e){n.routes=n.routes.filter(e=>c(t,n.pluginId,null,e));let e=new Set(n.routes.map(e=>`${e.routeId}\u0000${e.requestedSlug}`));n.routeDependencies=n.routeDependencies.filter(t=>e.has(`${t.routeId}\u0000${t.routeSlug}`))}}export{p as dropCollidingExtractAllRoutes,f as runExtractAllPhase};
|