@redocly/revel 0.130.1 → 0.131.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -3
- package/dist/bin.js +1 -1
- package/dist/cli/develop.js +1 -1
- package/dist/cli/prepare/copy-env-files.js +1 -1
- package/dist/cli/prepare/index.js +1 -1
- package/dist/cli/telemetry/index.js +1 -1
- package/dist/client/App.js +1 -1
- package/dist/client/ErrorBoundary.js +1 -1
- package/dist/client/app/Sidebar/helpers/filter-out-versioned-items.js +1 -1
- package/dist/client/app/hooks/useRouteChangeTracker.js +1 -1
- package/dist/client/app/search/useAiSearch.js +1 -1
- package/dist/client/browser-entry.js +5 -5
- package/dist/client/providers/hooks.js +1 -1
- package/dist/client/runtime/loader.js +1 -1
- package/dist/config/env-config.d.ts +17 -0
- package/dist/config/env-config.js +1 -0
- package/dist/config/env-schema.d.ts +242 -0
- package/dist/config/env-schema.js +3 -0
- package/dist/config/env-schemas/api-urls.d.ts +24 -0
- package/dist/config/env-schemas/api-urls.js +1 -0
- package/dist/config/env-schemas/auth.d.ts +42 -0
- package/dist/config/env-schemas/auth.js +1 -0
- package/dist/config/env-schemas/catalog.d.ts +12 -0
- package/dist/config/env-schemas/catalog.js +1 -0
- package/dist/config/env-schemas/database.d.ts +15 -0
- package/dist/config/env-schemas/database.js +1 -0
- package/dist/config/env-schemas/environment-detection.d.ts +24 -0
- package/dist/config/env-schemas/environment-detection.js +1 -0
- package/dist/config/env-schemas/feature-flags.d.ts +24 -0
- package/dist/config/env-schemas/feature-flags.js +1 -0
- package/dist/config/env-schemas/organization-project.d.ts +27 -0
- package/dist/config/env-schemas/organization-project.js +1 -0
- package/dist/config/env-schemas/scorecards.d.ts +12 -0
- package/dist/config/env-schemas/scorecards.js +1 -0
- package/dist/config/env-schemas/search.d.ts +21 -0
- package/dist/config/env-schemas/search.js +1 -0
- package/dist/config/env-schemas/server-config.d.ts +51 -0
- package/dist/config/env-schemas/server-config.js +1 -0
- package/dist/config/env-schemas/site.d.ts +12 -0
- package/dist/config/env-schemas/site.js +1 -0
- package/dist/config/env-schemas/ssr.d.ts +18 -0
- package/dist/config/env-schemas/ssr.js +1 -0
- package/dist/config/env-schemas/telemetry.d.ts +15 -0
- package/dist/config/env-schemas/telemetry.js +1 -0
- package/dist/config/env-schemas/test.d.ts +22 -0
- package/dist/config/env-schemas/test.js +1 -0
- package/dist/constants/common.d.ts +1 -1
- package/dist/constants/common.js +1 -1
- package/dist/server/api-routes/import-api-routes-handlers.js +1 -1
- package/dist/server/api-routes/run-api-routes-worker.js +1 -1
- package/dist/server/constants/common.js +1 -1
- package/dist/server/entitlements/entitlements-provider.js +1 -1
- package/dist/server/esbuild/esbuild-logger.js +2 -2
- package/dist/server/esbuild/esbuild.js +2 -2
- package/dist/server/esbuild/plugins/assets-resolver.js +1 -1
- package/dist/server/esbuild/plugins/esbuild-compile-resolver.js +1 -1
- package/dist/server/esbuild/plugins/styled-components-ssr.js +1 -1
- package/dist/server/fs/last-modified-tracker.js +1 -1
- package/dist/server/fs/utils/is-loader-cache-enabled.js +1 -1
- package/dist/server/node-bundle-entry.js +1 -1
- package/dist/server/plugins/analytics/adobe/index.js +1 -1
- package/dist/server/plugins/analytics/amplitude/index.js +1 -1
- package/dist/server/plugins/analytics/fullstory/index.js +1 -1
- package/dist/server/plugins/analytics/ga/index.js +1 -1
- package/dist/server/plugins/analytics/gtm/browser-hooks.js +1 -1
- package/dist/server/plugins/analytics/gtm/index.js +1 -1
- package/dist/server/plugins/analytics/heap/index.js +1 -1
- package/dist/server/plugins/analytics/rudderstack/index.js +1 -1
- package/dist/server/plugins/analytics/segment/index.js +1 -1
- package/dist/server/plugins/catalog-entities/database/catalog-entities-service.d.ts +4 -52
- package/dist/server/plugins/catalog-entities/database/catalog-entities-service.js +1 -1
- package/dist/server/plugins/catalog-entities/database/mappers/create-entity-db-record.d.ts +1 -0
- package/dist/server/plugins/catalog-entities/database/mappers/create-entity-read-model.js +1 -1
- package/dist/server/plugins/catalog-entities/database/mappers/{create-entity-relation.d.ts → create-entity-relation-read-model.d.ts} +2 -2
- package/dist/server/plugins/catalog-entities/database/mappers/create-entity-relation-read-model.js +1 -0
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-read-repository.js +3 -3
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.d.ts +5 -31
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-write-repository.js +1 -1
- package/dist/server/plugins/catalog-entities/database/repositories/remote/catalog-entities-remote-repository.d.ts +3 -4
- package/dist/server/plugins/catalog-entities/database/repositories/remote/catalog-entities-remote-repository.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/asyncapi-entities-extractor.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/base.d.ts +2 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/base.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/openapi-entities-extractor.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/fs-entities-extractor.js +1 -1
- package/dist/server/plugins/catalog-entities/plugin.js +1 -1
- package/dist/server/plugins/catalog-entities/schemas/read-model-schemas.d.ts +25 -164
- package/dist/server/plugins/catalog-entities/schemas/read-model-schemas.js +0 -1
- package/dist/server/plugins/config-parser/loaders/utils/read-and-validate-config.js +1 -1
- package/dist/server/plugins/default-theme/index.js +1 -1
- package/dist/server/plugins/entitlements/index.js +1 -1
- package/dist/server/plugins/lifecycle.js +2 -2
- package/dist/server/plugins/markdown/markdoc/import-user-tags.js +1 -1
- package/dist/server/plugins/markdown/markdoc/plugins/render-mermaid.js +1 -1
- package/dist/server/plugins/mcp/auth/auth-handlers.js +1 -1
- package/dist/server/plugins/mcp/handlers/handle-mcp-request.js +1 -1
- package/dist/server/plugins/nav-utils.js +1 -1
- package/dist/server/plugins/openapi-docs/index.js +1 -1
- package/dist/server/plugins/scorecard-classic/index.js +1 -1
- package/dist/server/plugins/scorecards/plugin.js +1 -1
- package/dist/server/plugins/scorecards/workers/run-scorecards-worker.js +1 -1
- package/dist/server/plugins/search/ai-indexer/prepare-ai-search-documents.js +1 -1
- package/dist/server/plugins/search/documents/search-documents.js +1 -1
- package/dist/server/plugins/search/engines/flexsearch/index.js +1 -1
- package/dist/server/plugins/search/engines/typesense/index.js +1 -1
- package/dist/server/plugins/search/index.js +1 -1
- package/dist/server/plugins/search/llmstxt/index.js +5 -5
- package/dist/server/plugins/search/utils.js +1 -1
- package/dist/server/plugins/sidebars/index.js +2 -2
- package/dist/server/plugins/sso/index.js +1 -1
- package/dist/server/providers/database/base-repository.js +1 -1
- package/dist/server/providers/database/database-connection-factory.js +1 -1
- package/dist/server/providers/database/database-preconnect-service.js +1 -1
- package/dist/server/providers/database/databases/sqld-sqlite/drizzle.config.js +1 -1
- package/dist/server/ssr/render.js +1 -1
- package/dist/server/ssr/server-side-props/get-server-props-from-user-handler.js +1 -1
- package/dist/server/ssr/utils.js +8 -8
- package/dist/server/store.d.ts +4 -4
- package/dist/server/store.js +1 -1
- package/dist/server/telemetry/index.js +1 -1
- package/dist/server/tools/notifiers/formatter.js +3 -3
- package/dist/server/tools/notifiers/helpers/colors.js +1 -1
- package/dist/server/tools/notifiers/logger.js +2 -2
- package/dist/server/tools/notifiers/reporter.js +6 -6
- package/dist/server/tools/notifiers/terminal-manager.js +4 -4
- package/dist/server/utils/envs/load-env-variables.js +1 -1
- package/dist/server/utils/is-catalog-entities-enabled.js +1 -1
- package/dist/server/utils/is-scorecards-enabled.js +1 -1
- package/dist/server/utils/lifecycle-hooks.js +1 -1
- package/dist/server/utils/report-all-errors.js +1 -1
- package/dist/server/version.js +1 -1
- package/dist/server/web-server/handle-api-route-request.js +1 -1
- package/dist/server/web-server/http.js +2 -2
- package/dist/server/web-server/middleware/apiKeyMiddleware.js +1 -1
- package/dist/server/web-server/middleware/catalogAuthMiddleware.js +1 -1
- package/dist/server/web-server/middleware/corsMiddleware.js +1 -1
- package/dist/server/web-server/middleware/dynamic-middleware/dynamic-middleware.js +1 -1
- package/dist/server/web-server/middleware/idleTimeoutMiddleware.js +1 -1
- package/dist/server/web-server/routes/auth.js +1 -1
- package/dist/server/web-server/routes/catalog/catalog-relations.js +1 -1
- package/dist/server/web-server/routes/catalog/catalog.js +1 -1
- package/dist/server/web-server/routes/catalog/dto/read-entity-dto.d.ts +3 -0
- package/dist/server/web-server/routes/catalog/dto/read-entity-dto.js +0 -0
- package/dist/server/web-server/routes/catalog/helpers/create-entity-relation-update-schema.d.ts +43 -0
- package/dist/server/web-server/routes/catalog/helpers/create-entity-relation-update-schema.js +1 -0
- package/dist/server/web-server/routes/catalog/helpers/create-entity-schema.d.ts +6823 -0
- package/dist/server/web-server/routes/catalog/helpers/create-entity-schema.js +1 -0
- package/dist/server/web-server/routes/catalog/helpers/create-entity-update-schema.d.ts +1102 -0
- package/dist/server/web-server/routes/catalog/helpers/create-entity-update-schema.js +1 -0
- package/dist/server/web-server/routes/catalog/mappers/map-entity-read-model-schema-to-entity-read-dto.d.ts +4 -0
- package/dist/server/web-server/routes/catalog/mappers/map-entity-read-model-schema-to-entity-read-dto.js +1 -0
- package/dist/server/web-server/routes/catalog/parsers/entities/parse-entities.d.ts +4 -0
- package/dist/server/web-server/routes/catalog/parsers/entities/parse-entities.js +1 -0
- package/dist/server/web-server/routes/catalog/parsers/entities/parse-entity-update-data.d.ts +4 -0
- package/dist/server/web-server/routes/catalog/parsers/entities/parse-entity-update-data.js +1 -0
- package/dist/server/web-server/routes/catalog/parsers/entities/parse-entity.d.ts +4 -0
- package/dist/server/web-server/routes/catalog/parsers/entities/parse-entity.js +1 -0
- package/dist/server/web-server/routes/catalog/parsers/relations/parse-entities-relations.d.ts +13 -0
- package/dist/server/web-server/routes/catalog/parsers/relations/parse-entities-relations.js +1 -0
- package/dist/server/web-server/routes/catalog/parsers/relations/parse-entity-relation-update-data.d.ts +13 -0
- package/dist/server/web-server/routes/catalog/parsers/relations/parse-entity-relation-update-data.js +1 -0
- package/dist/server/web-server/routes/catalog/parsers/relations/parse-entity-relation.d.ts +13 -0
- package/dist/server/web-server/routes/catalog/parsers/relations/parse-entity-relation.js +1 -0
- package/dist/server/web-server/routes/dynamic-route.js +1 -1
- package/dist/server/web-server/routes/error.js +1 -1
- package/dist/server/web-server/routes/index.js +1 -1
- package/dist/server/web-server/routes/info.js +1 -1
- package/dist/server/web-server/routes/mcp-oauth.js +1 -1
- package/dist/server/web-server/routes/otel/otel.js +1 -1
- package/dist/server/web-server/routes/page-data.js +1 -1
- package/dist/server/web-server/routes/path-prefix-redirect.js +1 -1
- package/dist/server/workers/worker-pool.js +1 -1
- package/package.json +11 -10
- package/dist/server/plugins/catalog-entities/database/mappers/create-entity-relation.js +0 -1
- package/dist/server/plugins/catalog-entities/entities/validate-entity.d.ts +0 -8
- package/dist/server/plugins/catalog-entities/entities/validate-entity.js +0 -1
- package/dist/server/utils/envs/is-build-mode.d.ts +0 -2
- package/dist/server/utils/envs/is-build-mode.js +0 -1
- package/dist/server/utils/envs/is-develop-mode.d.ts +0 -7
- package/dist/server/utils/envs/is-develop-mode.js +0 -1
- package/dist/server/utils/envs/is-production-mode.d.ts +0 -10
- package/dist/server/utils/envs/is-production-mode.js +0 -1
- package/dist/utils/env/is-local-development.d.ts +0 -13
- package/dist/utils/env/is-local-development.js +0 -1
- package/dist/utils/env/is-production.d.ts +0 -13
- package/dist/utils/env/is-production.js +0 -1
- package/dist/utils/env/is-web-view.d.ts +0 -14
- package/dist/utils/env/is-web-view.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CATALOG_ENTITIES_FILES_REGEX as E,ENTITY_SCHEMA_EXCLUDED_FOLDERS as d}from"../../../../constants/plugins/catalog-entities.js";import{FileHashStatus as l,FileType as a}from"../../../../persistence/file-hashes/types.js";import{OPERATORS as u}from"../../../../providers/database/pagination/constants.js";import{promiseMapLimit as m}from"../../../../utils/async/promise-map-limit.js";import{VERSION_NOT_SPECIFIED as p}from"@redocly/theme/core/constants";import{
|
|
1
|
+
import{CATALOG_ENTITIES_FILES_REGEX as E,ENTITY_SCHEMA_EXCLUDED_FOLDERS as d}from"../../../../constants/plugins/catalog-entities.js";import{FileHashStatus as l,FileType as a}from"../../../../persistence/file-hashes/types.js";import{OPERATORS as u}from"../../../../providers/database/pagination/constants.js";import{promiseMapLimit as m}from"../../../../utils/async/promise-map-limit.js";import{VERSION_NOT_SPECIFIED as p}from"@redocly/theme/core/constants";import{parseEntities as h}from"../../../../web-server/routes/catalog/parsers/entities/parse-entities.js";import{envConfig as g}from"../../../../../config/env-config.js";import{extractFileContent as y}from"../../entities/extract-file-content.js";import{resolveEntityVersion as I}from"../../utils/resolve-entity-version.js";import{catalogDataCollector as f}from"../../utils/catalog-data-collector.js";const T=15;class ${#t;#e;#i;#r;#s;constructor({fileHashManager:e,context:t,catalogEntitiesService:i,catalogConfig:o,shouldCalculateEntities:s}){this.#t=e,this.#e=t,this.#i=i,this.#r=o,this.#s=s}async extract(e){try{if(e&&this.#o(e)){await this.#n(e);return}await this.#t.markAllAsOutdated(a.ENTITY_DEFINITION);const i=this.#e.fs.scan(E).filter(({relativePath:o})=>this.#o(o));i.length&&f.addExtractor("fs"),await m(i,T,async({relativePath:o})=>{await this.#n(o)}),await this.#f()}catch(t){this.#e.logger.error("Error extracting entities.",t)}}#o=e=>!!(e.match(E)&&!d.some(t=>e.includes(t)));#n=async e=>{try{const t=await y(e,this.#e);if(!t){this.#e.logger.warn(`Error extracting content from ${e}.`);return}const i=await this.#t.computeFileHash(t);if(!((await this.#t.getByPath(e))?.hash!==i||this.#s||g.FORCE_CATALOG_CACHE_REVALIDATE==="true")){f.increaseSkippedFilesCount(),await this.#t.upsert(a.ENTITY_DEFINITION,e,i,l.UP_TO_DATE);return}const r=this.#a(t.entities,e);if(!r)return;const n=await this.#i.getEntityKeysAndVersionsBySourceFile(e);await this.#c(r,e,i,n),await this.#l(n,e),f.increaseProcessedFilesCount(),await this.#t.upsert(a.ENTITY_DEFINITION,e,i,l.UP_TO_DATE)}catch(t){this.#e.logger.warn(`Error processing file "${e}". ${t instanceof Error?t.message:String(t)}.`)}};#a=(e,t)=>{try{return h(e,this.#r)}catch(i){return this.#e.logger.warn(`Error validating entities in "${t}". ${i instanceof Error?i.message:String(i)}.`),null}};#c=async(e,t,i,o)=>{for(const s of e)try{const r=I(s.version,t);if(!r.success){this.#e.logger.warn(`Entity "${s.key}" in file "${t}" has conflicting versions: file version "${r.fileVersion}" differs from folder version "${r.folderVersion}". Entity will not be created.`);continue}const n={...s,version:r.version};if(await this.#i.createEntityInLocalDatabase({entity:n,sourceFile:t,fileHash:i}),s.key){const c=r.version??p;o.delete(`${s.key}:${c}`)}}catch(r){const n=s.key??"unknown";this.#e.logger.warn(`Error processing entity "${n}" from "${t}". ${r instanceof Error?r.message:String(r)}.`)}};#l=async(e,t)=>{if(e.size===0)return;const i=Array.from(e).map(r=>{const[n,c]=r.split(":");return{key:n,version:c}}),o=Array.from(new Set(i.map(({key:r})=>r))),s=i.map(({key:r,version:n})=>({op:u.AND,conditions:[{field:"key",operator:"equal",value:r},{field:"version",operator:"equal",value:n}]}));await this.#i.deleteEntitiesInLocalDatabase({op:"AND",conditions:[{field:"key",operator:"in",value:o},{op:u.OR,conditions:s},{field:"source",operator:"equal",value:"file"},{field:"source_file",operator:"equal",value:t}]})};#f=async()=>{const e=await this.#t.getAllOutdated(a.ENTITY_DEFINITION);if(!e||e.length===0)return;const t=await this.#i.getEntities({paginationParams:{limit:1e3,filter:{op:"AND",conditions:[{field:"source_file",operator:"in",value:e.map(({filePath:i})=>i)},{field:"is_current",operator:"equal",value:!0}]}}});!t||t.items.length===0||(await this.#i.deleteEntitiesInLocalDatabase({field:"key",operator:"in",value:t.items.map(({key:i})=>i)}),await this.#t.deleteFileHashes({op:"AND",conditions:[{field:"file_type",operator:"equal",value:a.ENTITY_DEFINITION},{field:"status",operator:"equal",value:l.OUTDATED}]}))}}export{$ as FsEntitiesExtractor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FileType as
|
|
1
|
+
import{FileType as p}from"../../persistence/file-hashes/types.js";import{envConfig as P}from"../../../config/env-config.js";import{deepEqual as I}from"../../../utils/object/deep-equal.js";import{telemetryTraceStep as D}from"../../../cli/telemetry/helpers/trace-step.js";import{catalogDataCollector as O}from"./utils/catalog-data-collector.js";import{CATALOG_BASE_SLUG as m,CATALOG_FILTERS_CACHE_NAMESPACE as b,ENTITIES_MAP_GLOBAL_DATA_KEY as _}from"../../constants/plugins/catalog-entities.js";import{CacheService as v}from"../../persistence/cache/services/cache-service.js";import{getTemplatePath as f}from"./utils/get-template-path.js";import{getCompleteCatalogConfig as E}from"./get-complete-catalog-config.js";import{AsyncApiEntitiesExtractor as w}from"./extensions/extractors/api-description/asyncapi-entities-extractor.js";import{GraphqlEntitiesExtractor as R}from"./extensions/extractors/api-description/graphql-entities-extractor.js";import{FileHashesService as N}from"../../persistence/file-hashes/services/file-hashes-service.js";import{CatalogEntitiesService as L}from"./database/catalog-entities-service.js";import{ArazzoEntitiesExtractor as G}from"./extensions/extractors/api-description/arazzo-entities-extractor.js";import{FsEntitiesExtractor as x}from"./extensions/extractors/fs-entities-extractor.js";import{HashManager as F}from"./utils/hash-manager.js";import{OpenApiEntitiesExtractor as H}from"./extensions/extractors/api-description/openapi-entities-extractor.js";const B="catalog-entity-template",M="catalog-entity";let C=!0,d;async function Y(){return{id:"CatalogEntities",requiredEntitlements:["catalog"],async processContent(t,e){const a=await e.getConfig(),r=E(a.entitiesCatalog);if(!r.show)return;const{logger:s}=e,n=t.registerServerPropsGetter(M,f("../get-server-props.js")),g=t.createTemplate(B,f("../template/index.js"));t.addRoute({duplicateInAllLocales:!0,slug:m,fsPath:"",templateId:g,excludeFromSidebar:!0,hasClientRoutes:!0,serverPropsGetterIds:[n],getNavText:()=>Promise.resolve("Catalog"),getStaticData:async()=>({props:{catalogConfig:r}})});const[u]=Object.entries(r.catalogs??{}).find(([o,i])=>!i?.hide)||[];u&&t.addRedirect(m,{type:302,to:`${m}/${u}`}),s.info("Catalog Entities plugin finished")},async afterRoutesCreated(t,e){await D("build.plugin.catalog_entities",async a=>{const r=await e.getConfig(),s=E(r.entitiesCatalog);if(a?.setAttribute("config",JSON.stringify(s)),!s.show)return;const{logger:n}=e,g=C&&P.isDevelopMode,u=!I(d,r.rbac);d=r.rbac;const o=g||u,i=await L.getInstance({baseDbDir:t.serverOutDir,removeExisting:g,runOnlyLocalDatabase:!0,runWithPragmaWalWriteOptimization:!0}),A=await N.getInstance({baseDbDir:t.serverOutDir}),l=new F(A),T=[new x({fileHashManager:l,context:e,catalogEntitiesService:i,catalogConfig:s,shouldCalculateEntities:o}),new H({actions:t,context:e,catalogEntitiesService:i,fileHashManager:l,fileType:p.OPENAPI_DESCRIPTION,shouldCalculateEntities:o}),new w({actions:t,context:e,catalogEntitiesService:i,fileHashManager:l,fileType:p.ASYNCAPI_DESCRIPTION,shouldCalculateEntities:o}),new R({actions:t,context:e,catalogEntitiesService:i,fileHashManager:l,fileType:p.GRAPHQL_DESCRIPTION,shouldCalculateEntities:o}),new G({actions:t,context:e,catalogEntitiesService:i,fileHashManager:l,fileType:p.ARAZZO_DESCRIPTION,shouldCalculateEntities:o})];n.info("Starting entities extractors...");const y=n.startTiming();await i.transaction(async()=>{await Promise.all(T.map(async S=>S.extract()))});const h=i.getEntitySources();t.setGlobalData({[_]:h}),await(await v.getInstance({baseDbDir:t.serverOutDir})).deleteByNamespace(b),n.infoTime(y,"Entities extractors finished");const c=await O.getCatalogEntitiesData(i);a?.setAttribute("totalEntities",c.totalEntitiesCount),a?.setAttribute("entitiesCountByType",JSON.stringify(c.countOfEntitiesByType)),a?.setAttribute("totalFilesSkippedByHash",c.totalFilesSkippedByHash),a?.setAttribute("totalProcessedFiles",c.totalProcessedFiles),a?.setAttribute("extractors",c.extractors),C=!1})}}}var ot=Y;export{Y as catalogEntitiesPlugin,ot as default};
|
|
@@ -1,159 +1,23 @@
|
|
|
1
|
-
import type { FromSchema } from 'json-schema-to-ts';
|
|
2
1
|
import type { EntityLinkFileSchema, EntityContactFileSchema } from '@redocly/config';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
readonly targetKey: {
|
|
19
|
-
readonly type: "string";
|
|
20
|
-
};
|
|
21
|
-
readonly sourceVersion: {
|
|
22
|
-
readonly type: readonly ["string", "null"];
|
|
23
|
-
};
|
|
24
|
-
readonly sourceRevision: {
|
|
25
|
-
readonly type: readonly ["string", "null"];
|
|
26
|
-
};
|
|
27
|
-
readonly targetVersion: {
|
|
28
|
-
readonly type: readonly ["string", "null"];
|
|
29
|
-
};
|
|
30
|
-
readonly targetRevision: {
|
|
31
|
-
readonly type: readonly ["string", "null"];
|
|
32
|
-
};
|
|
33
|
-
readonly type: {
|
|
34
|
-
readonly type: "string";
|
|
35
|
-
};
|
|
36
|
-
readonly createdAt: {
|
|
37
|
-
readonly type: readonly ["string", "null"];
|
|
38
|
-
};
|
|
39
|
-
readonly updatedAt: {
|
|
40
|
-
readonly type: readonly ["string", "null"];
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
readonly required: readonly ["id", "organizationId", "projectId", "sourceKey", "targetKey", "type"];
|
|
44
|
-
readonly additionalProperties: false;
|
|
45
|
-
};
|
|
46
|
-
export declare const entityReadModelSchema: {
|
|
47
|
-
readonly type: "object";
|
|
48
|
-
readonly properties: {
|
|
49
|
-
readonly type: {
|
|
50
|
-
readonly type: "string";
|
|
51
|
-
};
|
|
52
|
-
readonly key: {
|
|
53
|
-
readonly type: "string";
|
|
54
|
-
};
|
|
55
|
-
readonly title: {
|
|
56
|
-
readonly type: "string";
|
|
57
|
-
};
|
|
58
|
-
readonly summary: {
|
|
59
|
-
readonly type: readonly ["string", "null"];
|
|
60
|
-
};
|
|
61
|
-
readonly tags: {
|
|
62
|
-
readonly type: readonly ["array", "null"];
|
|
63
|
-
readonly items: {
|
|
64
|
-
readonly type: "string";
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
readonly metadata: {
|
|
68
|
-
readonly type: readonly ["object", "null"];
|
|
69
|
-
readonly additionalProperties: true;
|
|
70
|
-
};
|
|
71
|
-
readonly git: {
|
|
72
|
-
readonly type: readonly ["array", "null"];
|
|
73
|
-
readonly items: {
|
|
74
|
-
readonly type: "string";
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
readonly contact: {
|
|
78
|
-
readonly type: readonly ["object", "null"];
|
|
79
|
-
};
|
|
80
|
-
readonly links: {
|
|
81
|
-
readonly type: readonly ["array", "null"];
|
|
82
|
-
readonly items: {
|
|
83
|
-
readonly type: "object";
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
readonly id: {
|
|
87
|
-
readonly type: "string";
|
|
88
|
-
};
|
|
89
|
-
readonly source: {
|
|
90
|
-
readonly type: "string";
|
|
91
|
-
};
|
|
92
|
-
readonly sourceFile: {
|
|
93
|
-
readonly type: readonly ["string", "null"];
|
|
94
|
-
};
|
|
95
|
-
readonly version: {
|
|
96
|
-
readonly type: readonly ["string", "null"];
|
|
97
|
-
};
|
|
98
|
-
readonly revision: {
|
|
99
|
-
readonly type: readonly ["string", "null"];
|
|
100
|
-
};
|
|
101
|
-
readonly hash: {
|
|
102
|
-
readonly type: readonly ["string", "null"];
|
|
103
|
-
};
|
|
104
|
-
readonly isCurrent: {
|
|
105
|
-
readonly type: readonly ["boolean", "null"];
|
|
106
|
-
};
|
|
107
|
-
readonly isDefaultVersion: {
|
|
108
|
-
readonly type: readonly ["boolean", "null"];
|
|
109
|
-
};
|
|
110
|
-
readonly createdAt: {
|
|
111
|
-
readonly type: readonly ["string", "null"];
|
|
112
|
-
};
|
|
113
|
-
readonly updatedAt: {
|
|
114
|
-
readonly type: readonly ["string", "null"];
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
readonly required: readonly ["type", "key", "title", "id", "source"];
|
|
118
|
-
readonly additionalProperties: false;
|
|
119
|
-
};
|
|
120
|
-
export declare const relatedEntitySchema: {
|
|
121
|
-
readonly type: "object";
|
|
122
|
-
readonly properties: {
|
|
123
|
-
readonly id: {
|
|
124
|
-
readonly type: "string";
|
|
125
|
-
};
|
|
126
|
-
readonly key: {
|
|
127
|
-
readonly type: "string";
|
|
128
|
-
};
|
|
129
|
-
readonly title: {
|
|
130
|
-
readonly type: "string";
|
|
131
|
-
};
|
|
132
|
-
readonly type: {
|
|
133
|
-
readonly type: "string";
|
|
134
|
-
};
|
|
135
|
-
readonly summary: {
|
|
136
|
-
readonly type: readonly ["string", "null"];
|
|
137
|
-
};
|
|
138
|
-
readonly source: {
|
|
139
|
-
readonly type: "string";
|
|
140
|
-
};
|
|
141
|
-
readonly sourceFile: {
|
|
142
|
-
readonly type: readonly ["string", "null"];
|
|
143
|
-
};
|
|
144
|
-
readonly createdAt: {
|
|
145
|
-
readonly type: readonly ["string", "null"];
|
|
146
|
-
};
|
|
147
|
-
readonly updatedAt: {
|
|
148
|
-
readonly type: readonly ["string", "null"];
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
readonly required: readonly ["id", "key", "title", "type", "source"];
|
|
152
|
-
readonly additionalProperties: false;
|
|
2
|
+
export type EntityRelationReadModelSchema = {
|
|
3
|
+
id: string;
|
|
4
|
+
organizationId: string;
|
|
5
|
+
projectId: string;
|
|
6
|
+
sourceKey: string;
|
|
7
|
+
targetKey: string;
|
|
8
|
+
sourceVersion?: string | null;
|
|
9
|
+
sourceRevision?: string | null;
|
|
10
|
+
targetVersion?: string | null;
|
|
11
|
+
targetRevision?: string | null;
|
|
12
|
+
type: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
object: 'catalogEntityRelation';
|
|
153
16
|
};
|
|
154
|
-
export type EntityRelationReadModelSchema = FromSchema<typeof entityRelationReadModelSchema>;
|
|
155
|
-
export type RelatedEntitySchema = FromSchema<typeof relatedEntitySchema>;
|
|
156
17
|
export type EntityReadModelSchema = {
|
|
18
|
+
id: string;
|
|
19
|
+
organizationId: string;
|
|
20
|
+
projectId: string;
|
|
157
21
|
type: string;
|
|
158
22
|
key: string;
|
|
159
23
|
title: string;
|
|
@@ -163,21 +27,18 @@ export type EntityReadModelSchema = {
|
|
|
163
27
|
git?: string[] | null;
|
|
164
28
|
contact?: EntityContactFileSchema | null;
|
|
165
29
|
links?: EntityLinkFileSchema[] | null;
|
|
166
|
-
id: string;
|
|
167
30
|
source: string;
|
|
168
31
|
sourceFile?: string | null;
|
|
169
|
-
version
|
|
32
|
+
version: string;
|
|
170
33
|
revision: string;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
isDeleted?: boolean | null;
|
|
175
|
-
createdAt?: string | null;
|
|
176
|
-
updatedAt?: string | null;
|
|
34
|
+
isCurrent: boolean;
|
|
35
|
+
isDefaultVersion: boolean;
|
|
36
|
+
isDeleted: boolean;
|
|
177
37
|
object: 'catalogEntity';
|
|
178
|
-
|
|
179
|
-
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
180
40
|
rbacTeams?: string[] | null;
|
|
41
|
+
hash?: string | null;
|
|
181
42
|
};
|
|
182
|
-
export type EntityRevisionSummary = Pick<EntityReadModelSchema, 'version' | 'revision' | 'isCurrent' | 'createdAt' | 'updatedAt' | 'isDefaultVersion'
|
|
43
|
+
export type EntityRevisionSummary = Pick<EntityReadModelSchema, 'version' | 'revision' | 'isCurrent' | 'createdAt' | 'updatedAt' | 'isDefaultVersion'>;
|
|
183
44
|
//# sourceMappingURL=read-model-schemas.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const t={type:"object",properties:{id:{type:"string"},organizationId:{type:"string"},projectId:{type:"string"},sourceKey:{type:"string"},targetKey:{type:"string"},sourceVersion:{type:["string","null"]},sourceRevision:{type:["string","null"]},targetVersion:{type:["string","null"]},targetRevision:{type:["string","null"]},type:{type:"string"},createdAt:{type:["string","null"]},updatedAt:{type:["string","null"]}},required:["id","organizationId","projectId","sourceKey","targetKey","type"],additionalProperties:!1},e={type:"object",properties:{type:{type:"string"},key:{type:"string"},title:{type:"string"},summary:{type:["string","null"]},tags:{type:["array","null"],items:{type:"string"}},metadata:{type:["object","null"],additionalProperties:!0},git:{type:["array","null"],items:{type:"string"}},contact:{type:["object","null"]},links:{type:["array","null"],items:{type:"object"}},id:{type:"string"},source:{type:"string"},sourceFile:{type:["string","null"]},version:{type:["string","null"]},revision:{type:["string","null"]},hash:{type:["string","null"]},isCurrent:{type:["boolean","null"]},isDefaultVersion:{type:["boolean","null"]},createdAt:{type:["string","null"]},updatedAt:{type:["string","null"]}},required:["type","key","title","id","source"],additionalProperties:!1},r={type:"object",properties:{id:{type:"string"},key:{type:"string"},title:{type:"string"},type:{type:"string"},summary:{type:["string","null"]},source:{type:"string"},sourceFile:{type:["string","null"]},createdAt:{type:["string","null"]},updatedAt:{type:["string","null"]}},required:["id","key","title","type","source"],additionalProperties:!1};export{e as entityReadModelSchema,t as entityRelationReadModelSchema,r as relatedEntitySchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import P from"path";import{lintConfig as C,loadConfig as T,createConfigTypes as A}from"@redocly/openapi-core";import{deepMerge as U}from"../../../../../utils/object/deep-merge.js";import{logger as l}from"../../../../tools/notifiers/logger.js";import{BRANCH_ENV_PREFIX as $}from"../../../../../constants/common.js";import{sanitizeBranchName as L}from"../../../../utils/envs/sanitize-branch-name.js";import{safeParsePartial as E}from"../../safe-parse.js";import{formatConfigProblem as q}from"../../format-error.js";import{ExternalResolver as x}from"../../../../fs/utils/external-ref-resolver.js";import{resolveMutuallyExclusiveProps as B}from"../../resolve-mutual-exclusion.js";function g(o,e,t,r){e in o&&o[e]&&typeof o[e]=="string"&&(/^https?:\/\/.*/.test(o[e])||r(new Error(`Invalid ${t} URL: "${o[e]}". ${t} must start with "http://" or "https://".`)))}function j(o,e){if("access"in o&&o.access&&typeof o.access=="object"){const t=o.access;g(t,"logoutReturnUrl","access.logoutReturnUrl",e),g(t,"residency","access.residency",e);const r=["requiresLogin","logoutReturnUrl","residency","sso","rbac"];for(const n of r)n in t&&t[n]!==void 0&&n in o&&o[n]!==void 0&&e(new Error(`Property '${n}' is defined both at root level and in 'access' object. Please use 'access.${n}' to define this configuration.`))}}async function X(o,e,t,r){const h=e.getFileInfo(o)?.realRelativePath||o;async function d(){const a=new x(e),u=P.join(e.cwd,h),i=await T({configPath:u,externalRefResolver:a}),p=await r(i.resolvedConfig);if(p===void 0)return i.resolvedConfig;const m=[...i.document?.source?await C({config:i,externalConfigTypes:A(p,i)}):[],...i.document?.source?B(i.resolvedConfig,i.document?.source):[]];if(m.length>0)for(const b of m)t(new Error(q(b,e.cwd)));return i.resolvedConfig}const c=await e.exists(o)?await d():{},R=M(c),w=await r(c);g(c,"residency","Residency",t),g(c,"logoutReturnUrl","Logout return URL",t),j(c,t);let f=w?E(w,c):c;const{env:y}=f;if(y){const{envConfig:a}=await import("../../../../../config/env-config.js"),u=a.redoclyEnv,i=y[u]||{},p=a.PUBLIC_REDOCLY_BRANCH_NAME||"",v=p?L(p):"",m=v&&y[`${$}${v}`]||{};f=U(f,m,i)}const s=N(f,R);if(s.imports&&s.imports.length>0){l.warn("The 'imports' property is deprecated. Please use 'plugins' property instead.");const a=new Set([...s.plugins||[],...s.imports.map(u=>P.posix.join(u,"plugin.js"))]);s.plugins=Array.from(a),delete s.imports}if(s.catalog&&(l.warn("The 'catalog' property is deprecated. Please use 'catalogClassic' property instead."),s.catalogClassic={...s.catalog},delete s.catalog),s.scorecard&&(l.warn("The 'scorecard' property is deprecated. Please use 'scorecardClassic' property instead."),s.scorecardClassic=s.scorecard,delete s.scorecard),s.search?.ai){l.warn("The 'search.ai' property is deprecated. Please use 'aiAssistant' property instead.");const a={...s.search?.ai,...s.aiAssistant,suggestions:s.aiAssistant?.suggestions?.length?s.aiAssistant.suggestions:s.search?.ai.suggestions||[]};s.aiAssistant=a,delete s.search.ai}return I(s)}function I(o){const e="access"in o?o.access:void 0;if(!e||typeof e!="object")return o;const t={...o},r=[{name:"requiresLogin",type:"boolean"},{name:"logoutReturnUrl",type:"string"},{name:"residency",type:"string"},{name:"sso",type:"string | string[]"},{name:"rbac",type:"object"}],n=[];for(const h of r){const d=h.name;d in t&&t[d]!==void 0&&!(d in e)&&n.push(d)}return n.length>0&&l.warn(`The following properties at root level are deprecated: ${n.join(", ")}. Please move them to the 'access' object.`),"requiresLogin"in e&&e.requiresLogin!==void 0&&(t.requiresLogin=e.requiresLogin),"logoutReturnUrl"in e&&e.logoutReturnUrl!==void 0&&(t.logoutReturnUrl=e.logoutReturnUrl),"residency"in e&&e.residency!==void 0&&(t.residency=e.residency),"sso"in e&&e.sso!==void 0&&(t.sso=e.sso),"rbac"in e&&e.rbac!==void 0&&(t.rbac=e.rbac),delete t.access,t}function M(o){if(!o.theme)return[];l.warn("The 'theme' property in redocly.yaml is deprecated. Please move all of the properties from 'theme' to the root of the config.");const e=[];for(const t of Object.keys(o.theme))o[t]==null?e.push(t):l.warn(`Detected both '${t}' and 'theme.${t}' properties in redocly.yaml. The 'theme.${t}' property will be ignored and needs to be removed or merged into the '${t}'.`);return e}function N(o,e){if(!o.theme||e.length===0)return o;const t={...o};for(const r of e)t[r]=o.theme[r];return delete t.theme,t}export{X as readAndValidateConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as c}from"@redocly/config";import{DEV_LOGIN_SLUG as
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as c}from"@redocly/config";import{DEV_LOGIN_SLUG as g,INVITE_SLUG as T,PUBLIC_RBAC_SCOPE_ITEM as m,UI_ACCESSIBLE_CONFIG_PROPS as P,CONFIG_FILE_NAME as n,DEFAULT_SSO_IDP_TITLE as _}from"../../../constants/common.js";import{envConfig as v}from"../../../config/env-config.js";import{getTemplatePath as s}from"./get-template-path.js";import{resolveLinksFromConfig as p}from"../nav-utils.js";import{resolveLogoConfig as F}from"./resolve-logo.js";import{extractTeamNames as E}from"./extract-team-names.js";import{resolveProductsConfig as O}from"./resolve-products-config.js";import{getExcludedFromLinkCheckerPatterns as y}from"../sidebars/utils.js";import{resolveEntitiesCatalogConfig as A}from"./resolve-catalog-entities.js";import{telemetryTraceStep as j}from"../../../cli/telemetry/helpers/trace-step.js";async function q(r){return{id:"Default Theme",async processContent(e){await j("build.plugin.default_theme",async()=>{const t=S(e),o=Object.keys(e.getConfig()?.ssoDirect||{}).length>0,a=e.createTemplate("invite",s("../../../../dist/client/app/pages/Invite/Invite.js"));if(e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,excludeFromSearch:!0,slug:T,[c]:m,fsPath:T,templateId:a}),r.devLogin&&o){const i={frontmatter:{},seo:{title:"Login page"},authIdps:f(t),rbac:{teams:E(e.getConfig().rbac)}},l=e.createTemplate("dev-login",s("../../../../dist/client/app/pages/DevLogin/DevLogin.js"));e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,excludeFromSearch:!0,slug:g,[c]:m,fsPath:g,templateId:l,getStaticData:async()=>({props:i})})}else if(t.length>1){const i={frontmatter:{},seo:{title:"Login page"},authIdps:f(t)},l=e.createTemplate("login",s("../../../../dist/client/app/pages/Login/Login.js"));e.addRoute({duplicateInAllLocales:!0,excludeFromSidebar:!0,slug:g,[c]:m,fsPath:g,templateId:l,getStaticData:async()=>({props:i})})}e.createTemplate("404",s("../../../../dist/client/app/pages/404/404.js")),e.createTemplate("403",s("../../../../dist/client/app/pages/403/403.js")),e.createTemplate("403OIDC",s("../../../../dist/client/app/pages/403/403OIDC.js")),v.isDevelopMode&&e.createTemplate("compilation-error",s("../../../../dist/client/app/pages/CompilationError/CompilationError.js"))})},async afterRoutesCreated(e,t){const{contentDir:o,outdir:a}=e,i=e.getConfig(),{navbar:l,footer:D,userMenu:u,search:I,breadcrumbs:C,products:b}=i,L=Object.keys(i?.ssoDirect||{}).length>0,d=y(i),h={navFile:n,excludedFromLinkCheckerPatterns:d};e.setGlobalData({...k(i),navbar:await p(l,o,e,t,h),footer:await p(D,o,e,t,h),breadcrumbs:{...C,prefixItems:await p(C?.prefixItems||[],o,e,t,{navFile:n,excludedFromLinkCheckerPatterns:d})},userMenu:{...u,hide:u?.hide??!L,menu:await p(u?.items,o,e,t,{navFile:n,excludedFromLinkCheckerPatterns:d})},logo:await F(i.logo,n,a,t.fs),auth:{idpsInfo:f(S(e)),devLogin:r.devLogin&&L},products:await O(b,e,t),search:{...I,suggestedPages:await p(I?.suggestedPages,o,e,t,{navFile:n,excludedFromLinkCheckerPatterns:d})},entitiesCatalog:await A(i.entitiesCatalog,n,a,t.fs),headScriptTags:void 0,linkTags:void 0,postBodyScriptTags:void 0,preBodyScriptTags:void 0})}}}function S(r){const e=r.getConfig().ssoDirect;return Object.entries(e||{}).map(([o,a])=>({idpId:o,type:a.type,title:a.title}))}function f(r){return v.LOCALHOST_LOGIN==="true"?r:r.filter(t=>t.title!==_)}function k(r){const e={};for(const t of P)r[t]&&(e[t]=r[t]);return e}export{q as defaultThemePlugin,k as pickUiAccessibleConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFileSync as P}from"node:fs";import T from"path";import{PAGE_COUNT_OUTPUT_FILE_NAME as y}from"../../constants/common.js";import{
|
|
1
|
+
import{writeFileSync as P}from"node:fs";import T from"path";import{PAGE_COUNT_OUTPUT_FILE_NAME as y}from"../../constants/common.js";import{envConfig as F}from"../../../config/env-config.js";import{logger as o}from"../../tools/notifiers/logger.js";import{isReactPage as S}from"../../utils/content/is-react-page.js";import{EntitlementsProvider as b}from"../../entitlements/entitlements-provider.js";import{getBilledPagesCount as O,isPathIgnored as R}from"../../utils/index.js";import{isGraphqlDoc as $}from"../graphql-docs/is-graphql-doc.js";import{isMarkdownPage as M}from"../markdown/is-markdown-page.js";import{isOpenapiDoc as k}from"../openapi-docs/is-openapi-doc.js";import{PRODUCT_NAME as l}from"../../../config/product-gates.js";import{isAsyncapiDoc as E}from"../asyncapi-docs/is-asyncapi-doc.js";import{telemetryTraceStep as _}from"../../../cli/telemetry/helpers/trace-step.js";async function z(){return{id:"entitlements",async afterRoutesCreated(w,u){await _("build.plugin.entitlements",async t=>{const i=b.instance(),n=[],r=[],s=[],a=[],p=[];for(const{relativePath:e}of u.fs.scan())R(e)||(M(e)?n.push(e):$(e)?s.push(e):S(e)?a.push(e):await k(e,u)?r.push(e):await E(e,u)&&p.push(e));const g=i.canAccessFeature("markdown");t?.setAttribute("totalMarkdownFiles",n.length.toString()),t?.setAttribute("isMarkdownSupported",(!!g).toString()),n.length>0&&!g&&o.warn(`The product you are using ("${l}") does not support Markdown pages. The following Markdown files were detected but will be ignored: ${n.map(()=>"%rp").join(", ")}`,...n);const c=i.canAccessFeature("openapi");t?.setAttribute("totalOpenApiFiles",r.length.toString()),t?.setAttribute("isOpenApiSupported",(!!c).toString()),r.length>0&&!c&&o.warn(`The product you are using ("${l}") does not support OpenAPI documents. The following files are ignored: ${r.map(()=>"%rp").join(", ")}`,...r);const d=i.canAccessFeature("asyncapi");t?.setAttribute("totalAsyncApiFiles",p.length.toString()),t?.setAttribute("isAsyncApiSupported",(!!d).toString()),p.length>0&&!d&&o.warn(`The product you are using ("${l}") does not support AsyncAPI documents. The following files are ignored: ${p.map(()=>"%rp").join(", ")}`,...p);const m=i.canAccessFeature("graphql");t?.setAttribute("totalGraphqlFiles",s.length.toString()),t?.setAttribute("isGraphqlSupported",(!!m).toString()),s.length>0&&!m&&o.warn(`The product you are using ("${l}") does not support GraphQL documents. The following files are ignored: ${s.map(()=>"%rp").join(", ")}`,...s);const f=i.canAccessFeature("reactPages");t?.setAttribute("totalReactFiles",a.length.toString()),t?.setAttribute("isReactPagesSupported",(!!f).toString()),a.length>0&&!f&&o.warn(`The product you are using ("${l}") does not support React pages. The following files are ignored: ${a.map(()=>"%rp").join(", ")}`,...a);const A=O(w.getAllRoutes());t?.setAttribute("totalBilledPages",A.toString());const h=F.REDOCLY_METADATA_OUTPUT_FOLDER;h&&(o.info("Save total pages..."),P(T.join(h,y),JSON.stringify({totalPages:A},null)))})}}}export{z as entitlementsPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
`+s.stack;ue.sendCliErrorCaughtMessage({message:u}),
|
|
1
|
+
import B from"@redocly/portal-plugin-mock-server";import x from"path";import{REDOCLY_ROUTE_RBAC as O}from"@redocly/config";import{combineUrls as v,withPathPrefix as N}from"@redocly/theme/core/utils";import{VERSION_SEPARATOR as L}from"../constants/common.js";import{removeTrailingSlash as F}from"../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as V}from"../../utils/url/remove-leading-slash.js";import{isTruthy as j}from"../../utils/guards/is-truthy.js";import{normalizeRouteSlug as T}from"../../utils/path/normalize-route-slug.js";import{slash as k}from"../../utils/path/slash.js";import{parsePathVersions as $}from"../../utils/path/parse-path-versions.js";import{reporter as E}from"../tools/notifiers/reporter.js";import{logger as P}from"../tools/notifiers/logger.js";import{envConfig as A}from"../../config/env-config.js";import{shaDirPathShort as z}from"../utils/crypto/sha-dir-path-short.js";import{customPagesPlugin as M}from"../../server/plugins/pages/index.js";import{openAPIDocsPlugin as q}from"../../server/plugins/openapi-docs/index.js";import{asyncAPIDocsPlugin as I}from"../../server/plugins/asyncapi-docs/index.js";import{configParserPlugin as U}from"./config-parser/index.js";import{markdownPlugin as G}from"./markdown/index.js";import{generateBrowserPluginsModule as W,generateClientRoutes as K,generateTemplatesModule as H}from"../esbuild/generate.js";import{graphqlDocsPlugin as Y}from"./graphql-docs/index.js";import{searchPlugin as J}from"./search/index.js";import{defaultThemePlugin as Q}from"./default-theme/index.js";import{apiKeyMgmtPlugin as X}from"./dev-onboarding/index.js";import{apiFunctionsPlugin as Z}from"./api-functions/index.js";import{scorecardClassicPlugin as ee}from"./scorecard-classic/index.js";import{lintPlugin as te}from"./lint/index.js";import{resolvePlugins as oe}from"../config/external-plugins.js";import{sidebarsPlugin as ie}from"./sidebars/index.js";import{l10nPlugin as ne}from"./l10n/index.js";import{analyticsPlugins as re}from"./analytics/index.js";import{sitemapPlugin as se}from"./sitemap/index.js";import{entitlementsPlugin as ae}from"./entitlements/index.js";import{getBilledPagesCount as le,slug as ce}from"../utils/index.js";import{telemetry as ue}from"../../cli/telemetry/index.js";import{telemetryTraceStep as b}from"../../cli/telemetry/helpers/trace-step.js";import{EntitlementsProvider as D}from"../entitlements/entitlements-provider.js";import{ssoPlugin as fe}from"./sso/index.js";import{Cache as me}from"../fs/cache.js";import{ContentFs as de}from"../fs/content-fs.js";import{findProductBySlug as ge}from"../utils/product.js";import{parseBaseName as pe}from"./utils.js";import{isRouteReserved as Pe}from"./get-reserved-routes.js";import{catalogClassicPlugin as he}from"./catalog-classic/index.js";import{arazzoDocsPlugin as ye}from"./arazzo-docs/index.js";const Ce=[U,fe,Q,ne,G,q,I,ye,ee,te,Z,M,Y,X,he,{importPath:"./catalog-entities/plugin.js",loadCondition:()=>A.NEW_CATALOG_ENABLED==="true"},{importPath:"./scorecards/plugin.js",loadCondition:()=>A.NEW_SCORECARDS_ENABLED==="true"},{importPath:"./mcp/index.js",loadCondition:()=>D.instance().canAccessFeature("mcp")},ie,se,ae,J,B,...re];async function pt(o,t=Ce){return await b("build.plugins_init",async()=>{const n=[],w=D.instance(),h={};for(const f of t){let a;if("loadCondition"in f){if(!f.loadCondition())continue;const e=await import(f.importPath);if(!e.default||typeof e.default!="function"){await E.panicOnBuild(`Dynamic plugin ${f.importPath} does not export a default export or it is not a function`);continue}a=e.default}else a=f;const d=await a(o);for(const[e,i]of Object.entries(d.loaders||{}))h[e]&&await E.panicOnBuild(`Duplicate loader with name ${e}`),h[e]=i;(!d.requiredEntitlements||d.requiredEntitlements?.every(e=>w.canAccessFeature(e)))&&n.push(d)}const s=new de(o.contentDir);await s.ready;const u=new me(s);return u.setLoaders(h),P.verbose("All plugins instantiated"),{pluginInstances:n,lifecycleContext:ve(s,u)}})}function _(o){P.verbose("Generating templates"),b("build.write_client_entries",()=>{H(o),W(o),K(o)})}async function we(o){const t=o.getAllRoutes();le(t)||await E.panicOnBuild("No routes created by plugins. Please check your project configuration.")}async function Pt(o,t,n,w={}){const h=D.instance();try{await b("build.plugins_run",async()=>{t.startPluginsRun();let s=[];await b("build.plugins_process_content",async a=>{for(const e of o){const i=P.startTiming();await e.processContent?.(t,n),P.verboseTime(i,`processContent for ${e.id}`)}s=(await oe(t.contentDir,t.config.plugins)).map(e=>e.lifecyclePlugin).filter(e=>j(e)&&(!e.requiredEntitlements||e.requiredEntitlements?.every(i=>h.canAccessFeature(i)))),n.cache.setLoaders(Object.fromEntries(s.flatMap(e=>Object.entries(e.loaders||{}))));for(const e of s){const i=P.startTiming();await e.processContent?.(t,n),P.verboseTime(i,`processContent for ${e.id}`)}a?.setAttribute("externalPluginsProcessed",s.length.toString())});const u=await Re(t,n),f=[...o,...s];_(t),A.isDevelopMode?await t.userCodeReady:t.buildRevision++,await b("build.plugins_after_routes_created",async()=>{for(const a of f){const d=P.startTiming();await a.afterRoutesCreated?.(t,u),P.verboseTime(d,`afterRoutesCreated for ${a.id}`)}}),await t.reportUnsetEnvVars(),await we(t),_(t)})}catch(s){const u="Unhandled error in plugin. "+s.message+`
|
|
2
|
+
`+s.stack;ue.sendCliErrorCaughtMessage({message:u}),w.failFast?await E.panic(u):await E.panicOnBuild(u)}finally{t.finishPluginsRun()}}async function Re(o,t){const{cache:n,fs:w}=t,h=await t.getConfig(),s=Object.values(h.products||{}),u=(await n.load("versions-config","versions-config")).data,f=(await n.load("content-slugs","content-slugs")).data;for(const{duplicateInAllLocales:e,slugSuffix:i,sharedData:y=[],redirectFrom:C=[],...l}of o.newRoutes){const c=T(l.slug?l.slug:a(l.fsPath)),g=F(i?v(c,i):c),r={...l,[O]:{slug:g,fsPath:l.fsPath},slug:g,baseSlug:c,versions:d(l.fsPath,i),product:ge(s,g,a)};Pe(g,h)&&await E.panicOnBuildContentError(`Route "${g}" is reserved and cannot be used. Please choose a different slug for "${l.fsPath}".`),o.routesByFsPath.set(r.fsPath,r.slug),o.routesBySlug.set(r.slug,r);for(const{key:p,id:m}of y)o.addRouteSharedData(r.slug,p,m);for(const p of C)o.addRedirect(p.from,{type:p.type,to:r.slug});if(e)for(const p of w.localeFolders){const m={...r,slug:"/"+p.toLowerCase()+r.slug};o.routesByFsPath.set(m.fsPath,m.slug),o.routesBySlug.set(m.slug,m);for(const{key:R,id:S}of y)o.addRouteSharedData(m.slug,R,S);for(const R of C){const S=v(w.localizationFolder,p,R.from);o.addRedirect(S,{type:R.type,to:m.slug})}}}return o.newRoutes=[],{...t,slugify:a};function a(e){const i=k(e).replace(new RegExp("^(@i18n|@l10n)\\/"),""),y=f.fileSlugs.get(i)||f.dirSlugs.get(F(i));if(y)return y;const{baseName:C,isIndexFile:l}=pe(e);let c=x.dirname(e.replace(new RegExp("^(@i18n|@l10n)\\/"),""));return c=c==="."?"/":c,v("/",ce(l?c:v(c,C)),"/")}function d(e,i=""){const y=$(e);if(!y?.versionName)return;const{versionFolderPath:C,filePathInVersion:l,versionName:c}=y,g=u.get(C);if(g)return g.versions.map(r=>{const p=g.defaultVersion===r.version,m=V(v(C,L+r.version,l)),R=a(m);return{version:r.version,label:r.name||r.version,link:T(v(R,i)),default:p,active:c===r.version,folderId:z(`${C}`)}})}}function ve(o,t){return{fs:o,cache:t,getConfig:async(n=".")=>(await t.load(n,"nearest-redocly-config",o.localeFolders)).data,isPathIgnored:async n=>(await t.load(n,"is-ignored")).data,withPathPrefix:N,logger:P}}export{Ce as INTERNAL_PLUGINS,ve as createLifecycleContext,pt as initPlugins,Pt as runPlugins,_ as writeClientEntries};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pathToFileURL as o}from"url";import{
|
|
1
|
+
import{pathToFileURL as o}from"url";import{envConfig as r}from"../../../../config/env-config.js";async function n(t){if(r.isRuntimeMode)return await import("@redocly-markdoc/schema");try{const e=r.isDevelopMode?"js":"mjs";return await import(o(`${t}/user-tags-entry.${e}`)+"?"+new Date)}catch(e){if(r.isDevelopMode)return{schema:{}};throw e}}export{n as importUserTags};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{nanoid as
|
|
1
|
+
import{nanoid as R}from"nanoid";import{envConfig as i}from"../../../../../config/env-config.js";import{logger as h}from"../../../../tools/notifiers/logger.js";import{sha as g}from"../../../../utils/crypto/sha.js";const s={};function c(t){if(t.toLowerCase().includes("gantt")&&!t.toLowerCase().includes("todaymarker off")){const o=new Date().toISOString().split("T")[0];return g(t+o)}return g(t)}async function O(t,d="default"){if(t.length===0)return[];const r=[];for(let e=0;e<t.length;e++){const n=c(t[e]);s[n]||r.push(t[e])}if(r.length){const e=i.REDOCLY_MERMAID_MICROSERVICE_URL||"https://api.redocly.com/mermaid",n=h.startTiming(),f=R(),m=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","x-request-id":i.REQUEST_ID||""},body:JSON.stringify({definitions:r,rayId:f,theme:d,organizationId:i.ORGANIZATION_ID})});if(m.status!==200)throw new Error(`Something went wrong during remote rendering. Please, save this Ray ID: ${f} and contact Redocly team.`);h.verboseTime(n,"Rendered mermaid diagrams (%s)",r.length);const l=await m.json();for(let a=0;a<r.length;a++){const p=c(r[a]);s[p]=l[a]}}const o=[];for(let e=0;e<t.length;e++){const n=c(t[e]);o.push(s[n])}return o}export{s as cache,c as generateDiagramHash,O as renderMermaid};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extractTokenFromAuthHeader as u}from"
|
|
1
|
+
import{extractTokenFromAuthHeader as u}from"../../../plugins/mcp/utils/jwt.js";import{getUserParamsFromCookies as d}from"../../../web-server/auth.js";import{DEFAULT_ANONYMOUS_VISITOR_TEAM as o,RBAC_ALL_OTHER_TEAMS as a,ServerRoutes as l}from"../../../../constants/common.js";import{withPathPrefix as h}from"@redocly/theme/core/utils";function c(e){return!e||typeof e!="object"||Object.keys(e).length===0?!1:!(e[o]&&e[o]!=="none"||e[a]&&e[a]!=="none")}function k(e,t){if(!t||Object.keys(t).length===0)return e;const r=t.content;if(r&&Object.keys(r).length>0&&Object.values(r).some(c))return!0;const s=t.teamFoldersBaseRoles;return c(s)?!0:e}async function R(e,t){const r=e.headers.get("Authorization");if(!r)return{isAuthenticated:!1};const s=u(r),i=t?.config?.ssoDirect||{},n=s?await d(i,{authorization:s,idp_access_token:s}):{};return s&&n&&n.isAuthenticated?{isAuthenticated:!0,isTokenValid:!0,currentUser:{teams:n.teams||[],email:n.email||"",claims:n,isAuthenticated:!0,idpAccessToken:n.idpAccessToken||void 0,idpId:n.idpId||void 0}}:{isAuthenticated:!1,isTokenValid:!1}}function O(e){return new Response(JSON.stringify({error:"unauthorized",message:"Authentication required"}),{status:401,headers:{"Content-Type":"application/json","WWW-Authenticate":`Bearer realm="${e}${l.MCP_OAUTH_PROTECTED_RESOURCE}${h("/mcp")}"`,"Access-Control-Allow-Origin":"*"}})}function _(){return new Response(JSON.stringify({error:"invalid_token",message:"Invalid or expired token"}),{status:401,headers:{"Content-Type":"application/json","WWW-Authenticate":'Bearer error="invalid_token", error_description="Invalid or expired token"',"Access-Control-Allow-Origin":"*"}})}export{_ as constructInvalidTokenResponse,O as constructUnauthorizedResponse,R as handleMcpAuth,k as shouldHandleMcpAuth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{withPathPrefix as
|
|
1
|
+
import{withPathPrefix as d}from"@redocly/theme/core/utils";import{importApiRoutesHandler as f}from"../../../api-routes/import-api-routes-handlers.js";import{enhanceContext as h}from"../../../api-routes/helpers/enhance-context.js";import{telemetry as A}from"../../../telemetry/index.js";import{KvService as D}from"../../../persistence/kv/services/kv-service.js";import{envConfig as o}from"../../../../config/env-config.js";async function y(a,s,t){const e=s.get("auth"),i=await t.resolveRouteStaticData(a)||{},r=d(a.slug),{requestHandlers:c}=await f(t.serverOutDir),p=c[a.requestHandlerId],m=(await p()).default,u=async()=>await D.getInstance({baseDbDir:t.serverOutDir,sqldRemoteDatabaseUrl:o.SQLD_REMOTE_DATABASE_URL,sqldRemoteDatabaseAuthToken:o.SQLD_REMOTE_DATABASE_AUTH_TOKEN}),l=h({honoCtx:s,ctx:{user:{teams:e.teams,email:e.claims.email,claims:e.claims,idpAccessToken:e.idpAccessToken,idpId:e.claims.idpId,isAuthenticated:e.isAuthenticated},config:t.config},telemetry:A,getKv:u}),n=await m(s.req.raw,l,{...i,props:{...i.props,routeSlug:r,outdir:t.outdir}});return n instanceof Response?n:typeof n=="string"?new Response(n,{headers:{"Content-Type":"text/plain"}}):new Response(JSON.stringify(n),{headers:{"Content-Type":"application/json"}})}export{y as handleMcpRequest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as v from"path";import{REDOCLY_ROUTE_RBAC as P,REDOCLY_TEAMS_RBAC as p}from"@redocly/config";import{VERSION_SEPARATOR as M}from"../constants/common.js";import{DEFAULT_LOCALE_PLACEHOLDER as _}from"../../constants/common.js";import{removeTrailingSlash as j}from"../../utils/url/remove-trailing-slash.js";import{isPrimitive as W}from"../../utils/guards/is-primitive.js";import{slash as w}from"../../utils/path/slash.js";import{isAbsoluteUrl as z}from"../../utils/url/is-absolute-url.js";import{normalizeRouteSlug as U}from"../../utils/path/normalize-route-slug.js";import{parsePathVersions as R}from"../../utils/path/parse-path-versions.js";import{logger as A}from"../tools/notifiers/logger.js";import{reporter as S}from"../tools/notifiers/reporter.js";import{shaDirPathShort as C}from"../utils/crypto/sha-dir-path-short.js";import{copyStaticFile as H,FileNotFoundError as E}from"../utils/fs.js";import{isIconPath as J,resolveAssetPath as Y}from"../utils/index.js";import{resolveSrcSet as G}from"../utils/resolve-src-set.js";import{isL10nPath as B}from"../fs/utils/is-l10n-path.js";import{getLocaleFromRelativePath as q}from"../fs/utils/get-locale-from-relative-path.js";async function D(e,s,n,t,a){if(!e)return;const f={...a,ignoreCustomSidebar:!0};if(W(e)){if(typeof e=="string"){const r=F(n.contentDir,s,a,e,t.fs);if(t.fs.exists(r)){if(n.getRouteByFsPath(r))return K({page:e},s,n,t,f);{const g=t.fs.getFileInfo(r);return g?H(n.contentDir,g.realRelativePath,n.outdir):void 0}}}return e}return Array.isArray(e)?I(N(e),s,n,t,f):Object.fromEntries(await Promise.all(Object.entries(e).map(async([r,l])=>[r,await D(l,s,n,t,a)])))}function N(e){return e.map(s=>({...s,items:s.items?N(s.items):void 0}))}async function I(e,s,n,t,a){if(Array.isArray(e))return(await Promise.all(e.map(f=>K(f,s,n,t,a)))).flatMap(f=>f)}async function y(e,s,n,t){let a,f;if(typeof e.icon=="object"){if("srcSet"in e.icon)try{a=await G(e.icon.srcSet,n.fs,{fromFileRelativePath:t.navFile,contentDir:s.contentDir,outdir:s.outdir})}catch(d){d instanceof E?await S.panicOnBuildContentError(`Cannot resolve "item.icon.srcSet" from ${t.navFile}: ${d.message}`):await S.panicOnBuild(`Cannot resolve "item.icon.srcSet" from ${t.navFile}: ${d.message}`)}}else if(typeof e.icon=="string")if(z(e.icon)||J(e.icon))try{f=await Y(e.icon,n.fs,{fromFileRelativePath:t.navFile,contentDir:s.contentDir,outdir:s.outdir})}catch(d){d instanceof E?await S.panicOnBuildContentError(`Cannot resolve "item.icon" from ${t.navFile}: file ${f} does not exist`):await S.panicOnBuild(`Cannot resolve "item.icon" from ${t.navFile}: ${d.message}`)}else f=e.icon;return{icon:f,srcSet:a}}function Q(e){return s=>{if(s.type==="link"||s.type==="group"){const n=s.metadata;return n?Object.entries(e).every(([t,a])=>Array.isArray(a)?a.some(f=>n[t]===f):n[t]===a):!1}return!0}}async function K(e,s,n,t,a){if(e?.directory&&e.items?.length)return{type:"error",label:`Can't have both "directory" and "items" in the nav item: ${JSON.stringify(e)}`};e?.directory&&e?.group&&(e={...e,directory:void 0,items:[{directory:e.directory}]});const f=e?.directory?F(n.contentDir,s,a,e.directory,t.fs):void 0;if(f!==void 0){const i=f===""?"":f+"/",{locale:u,ignoredRoutes:o}=a;let h=n.getAllRoutesForLocale(u).filter(c=>!o?.has(c.baseSlug||"")&&c.fsPath.startsWith(i)&&!c.excludeFromSidebar).sort((c,b)=>c.fsPath===b.fsPath?0:c.baseSlug.localeCompare(b.baseSlug,void 0,{numeric:!0}));const k=e.includeByMetadata?Q(e.includeByMetadata):Boolean;if(!h.length)return[];const $=(await Promise.all(h.map(async c=>{const b=c.versions?.find(x=>x.active),L=b&&{version:b.version,isDefault:b.default,versionFolderId:b.folderId},V=ee(v.posix.relative(f,c.fsPath)),O=c.getSidebar?.(c);return!a.ignoreCustomSidebar&&O?.length?{type:"group",fsPath:c.fsPath,metadata:c.metadata,link:c.slug,routeSlug:c.slug,label:await c.getNavText?.()||c.slug,[p]:c[p],[P]:c[P],sidebarItems:m(O,L,c[p],c[P]),...L,relativePathFromDirectory:v.relative(f,c.fsPath).replace(/@[^\/]+\//,"")}:{type:"link",fsPath:c.fsPath,metadata:c.metadata,[p]:c[p],[P]:c[P],label:await c.getNavText?.()||c.slug,link:c.slug,routeSlug:c.slug,...L,relativePathFromDirectory:V}}))).filter(k);return e.flatten?T($,a):Z($,a)}let d=typeof e=="string"?e:e?.page,r,l;if(d){if(d.includes("#")){const[i,u]=d.split("#");u?l=u:A.warn(`Invalid heading anchor format in sidebar: "${u}". Heading anchors should contain only alphanumeric characters, hyphens, and underscores.`),d=i}if(d=j(d),a.locale&&a.locale!==_){const i=U(v.join(a.locale.toLowerCase(),d));r=n.getRouteBySlug(i)}r||(r=n.getRouteBySlug(d)),r||(r=n.getRouteByFsPath(F(n.contentDir,s,a,d,t.fs)))}const g=r?.metadata;if(e?.$ref){let i=F(n.contentDir,s,a,e.$ref,t.fs);if(a.ref!==void 0&&(i=v.posix.join(a.ref,e.$ref)),!t.fs.exists(i))return await S.panicOnBuildContentError(`Failed to load ${i} file. Make sure sidebar $ref path is correct.`),[];const u=await t.cache.load(i,"yaml"),o=v.dirname(i);return await I(u.data,s,n,t,{...a,navFile:i,ref:o})||[]}if(!r){const i=a.excludedFromLinkCheckerPatterns?.catalog.some(o=>o.test(d||"")),u=a.excludedFromLinkCheckerPatterns?.apiFunctions.some(o=>o.test(d||e.href||""));(u||i)&&(e={...e,href:d||e.href,page:void 0,target:e.target??(u?"_blank":void 0)}),await X(e,a,t,s)}if(r&&!e.disconnect&&!a.ignoreCustomSidebar&&(l||r?.getSidebar)){const i=r.versions?.find(o=>o.active),u=i&&{version:i.version,isDefault:i.default,versionFolderId:i.folderId};if(l){let o=[];if(r.getSidebar&&(o=r.getSidebar(r,{...e,...await y(e,n,t,a)}),o&&o.length>0)){const h=o[0];h&&h.link&&(h.link=`${h.link}#${l}`)}if(!o||o.length===0){let h=e.group||e.label||l;o=[{type:"link",fsPath:r.fsPath,metadata:r.metadata,link:`${r.slug}#${l}`,routeSlug:r.slug,label:h,labelTranslationKey:e.labelTranslationKey,...await y(e,n,t,a),[p]:r[p],[P]:{slug:r.slug,fsPath:r.fsPath},...u}]}return m(o,u,r[p],r[P])}if(r?.getSidebar){const o=r.getSidebar(r,{...e,...await y(e,n,t,a)}),h=e.group&&o?.[0]?.routeSlug===r.slug?o.slice(1):o;return m(a.groupCustomSidebars||e.group?[{type:"group",fsPath:r.fsPath,link:r.slug,routeSlug:r.slug,label:e.group||e.label||await r.getNavText?.()||r.slug,items:h,labelTranslationKey:e.labelTranslationKey,metadata:g,...await y(e,n,t,a)}]:o,u,r[p],r[P])}}if(r&&!e.group){const i=l?`${r.slug}#${l}`:r.slug;let u=e.label||l||"";u||(u=await r.getNavText?.()||r.slug);const o=r.versions?.find(k=>k.active),h=o&&{version:o.version,isDefault:o.default,versionFolderId:o.folderId};return{type:"link",fsPath:r.fsPath,linkedSidebars:e.linkedSidebars,metadata:g,[p]:e?.rbac||r[p],[P]:{slug:r.slug,fsPath:r.fsPath},label:u,labelTranslationKey:e.labelTranslationKey,link:i,items:await I(e.items,s,n,t,a),separatorLine:e.separatorLine,linePosition:e.linePosition,routeSlug:e.disconnect?void 0:i,external:e.external,target:e.target,...await y(e,n,t,a),...h,additionalProps:e.additionalProps}}else if(e?.group){const i=r?.versions?.find(o=>o.active),u=R(a?.navFile);return{type:"group",fsPath:r?.fsPath,linkedSidebars:e.linkedSidebars,metadata:g,version:i?.version||u?.versionName,versionFolderId:i?.folderId||(u?.versionFolderPath?C(u.versionFolderPath):void 0),label:e.group,link:r?.slug,routeSlug:r?.slug,labelTranslationKey:e.groupTranslationKey,items:await I(e.items,s,n,t,a),expanded:e.expanded?e.expanded.toString():void 0,selectFirstItemOnExpand:e.selectFirstItemOnExpand,menuStyle:e.menuStyle,separatorLine:e.separatorLine,linePosition:e.linePosition,...await y(e,n,t,a),[p]:e?.rbac,[P]:{slug:r?.slug||"",fsPath:r?.fsPath||""},additionalProps:e.additionalProps}}else{if(e?.href||e?.label)return{type:"link",metadata:g,link:e.href||"",label:e?.label||e?.href||"",labelTranslationKey:e.labelTranslationKey,external:e.external,target:e.target,separatorLine:e.separatorLine,linePosition:e.linePosition,...await y(e,n,t,a),[p]:e?.rbac,additionalProps:e.additionalProps};if(e?.separator!=null||e?.separatorLine!=null){const i=R(a?.navFile);return{type:"separator",metadata:g,version:i?.versionName,versionFolderId:i?.versionFolderPath?C(i.versionFolderPath):void 0,label:e.separator,labelTranslationKey:e.separatorTranslationKey,separatorLine:e.separatorLine,linePosition:e.linePosition,...await y(e,n,t,a),[p]:e?.rbac,additionalProps:e.additionalProps}}else{const i=R(a?.navFile);return{type:"error",label:`Can't resolve page: ${JSON.stringify(e)}`,version:i?.versionName,versionFolderId:i?.versionFolderPath?C(i.versionFolderPath):void 0}}}}async function X(e,s,n,t){const{href:a,page:f}=e;if(a||!f)return;const d=F(n.fs.cwd,t,s,f,n.fs),r=n.fs.exists(d),l=await n.isPathIgnored(d),g=(r?"The page is ignored: ":"Can't resolve page: ")+f;(!r||l)&&S.reportBrokenLink({type:"BROKEN_LINK",brokenLinkType:"LINK",title:e.label||e.group||"",link:d,rawLink:f,message:g,sourceFileRelativePath:s.navFile,sourceFileLocation:{line:0}})}function F(e,s,n,t="",a){if(n.ref!==void 0)return w(v.relative(e,v.resolve(e,v.join(n.ref,t))));if(t.startsWith("/")){const f=B(s)?q(s):void 0,d=f?`${a.localizationFolder}/${f}/`:"",r=t.slice(1);return B(r)?r:d+w(r)}return w(v.relative(e,v.resolve(e,s,t)))}function Z(e,s){const n={};for(const r of e){const l=v.dirname(r.relativePathFromDirectory),g=r.version?M+r.version:"",i=v.basename(r.relativePathFromDirectory)+g;d(l,r,i)}const t=f(a(n));return T(t,s);function a(r){const l=[];for(const g of Object.keys(r)){const i=r[g];l.push({...i,items:i.items?a(i.items):void 0})}return l}function f(r){return r.sort((l,g)=>{const i=typeof l=="string"?l.toLowerCase():l.relativePathFromDirectory||l.label||"",u=typeof g=="string"?g.toLowerCase():g.relativePathFromDirectory||g.label||"";return i.startsWith("index.")?-1:u.startsWith("index.")?1:i.localeCompare(u,void 0,{numeric:!0})})}function d(r,l,g){r==="."&&(r="");const i=r.split("/").filter(Boolean);let u=n;for(const o of i){const h=o+(l?.version||"");u[h]||(u[h]={type:"group",version:l?.version,label:o,isDefault:l?.isDefault,versionFolderId:l.versionFolderId,items:{}}),u=u[h].items}u[g]=l}}function T(e,s){return e.flatMap(n=>n?.sidebarItems?s.groupCustomSidebars?{...n,items:n.sidebarItems,sidebarItems:void 0,relativePathFromDirectory:void 0}:n.sidebarItems:{...n,items:n.items?T(n.items,s):void 0})}function m(e,s,n,t){return e.map(a=>({...a,...s,[p]:a[p]||n,[P]:a[P]||t,items:a.type==="group"&&a.items?m(a.items,s,n):a.items}))}function ee(e){return e.replace(/@[^\/]+\//,"")}async function ye(e,s,n,t){const a=(e?.items||[]).filter(r=>r.linkedSidebars?.length).map(r=>({...r,items:void 0})),f=await D(a,s.contentDir,s,n,t),d=new Map;for(const r of f)if(r.linkedSidebars?.length)for(const l of r.linkedSidebars){if(d.has(l)){A.warn(`Only one navbar item can belong to sidebar. "${l}" on 'linkedSidebars' property on "${r.label}" will be ignored.`);continue}d.set(l,{label:r.label,link:r.link})}return d}export{ye as collectItemsLinkedToSidebars,N as normalizeItems,K as resolveItem,I as resolveItems,D as resolveLinksFromConfig};
|
|
1
|
+
import*as v from"path";import{REDOCLY_ROUTE_RBAC as b,REDOCLY_TEAMS_RBAC as p}from"@redocly/config";import{VERSION_SEPARATOR as M}from"../constants/common.js";import{DEFAULT_LOCALE_PLACEHOLDER as _}from"../../constants/common.js";import{removeTrailingSlash as j}from"../../utils/url/remove-trailing-slash.js";import{isPrimitive as W}from"../../utils/guards/is-primitive.js";import{slash as w}from"../../utils/path/slash.js";import{isAbsoluteUrl as z}from"../../utils/url/is-absolute-url.js";import{normalizeRouteSlug as U}from"../../utils/path/normalize-route-slug.js";import{parsePathVersions as R}from"../../utils/path/parse-path-versions.js";import{logger as A}from"../tools/notifiers/logger.js";import{reporter as S}from"../tools/notifiers/reporter.js";import{shaDirPathShort as C}from"../utils/crypto/sha-dir-path-short.js";import{copyStaticFile as H,FileNotFoundError as E}from"../utils/fs.js";import{isIconPath as J,resolveAssetPath as Y}from"../utils/index.js";import{resolveSrcSet as G}from"../utils/resolve-src-set.js";import{isL10nPath as B}from"../fs/utils/is-l10n-path.js";import{getLocaleFromRelativePath as q}from"../fs/utils/get-locale-from-relative-path.js";async function D(e,s,n,t,a){if(!e)return;const f={...a,ignoreCustomSidebar:!0};if(W(e)){if(typeof e=="string"){const r=F(n.contentDir,s,a,e,t.fs);if(t.fs.exists(r)){if(n.getRouteByFsPath(r))return K({page:e},s,n,t,f);{const g=t.fs.getFileInfo(r);return g?H(n.contentDir,g.realRelativePath,n.outdir):void 0}}}return e}return Array.isArray(e)?I(N(e),s,n,t,f):Object.fromEntries(await Promise.all(Object.entries(e).map(async([r,l])=>[r,await D(l,s,n,t,a)])))}function N(e){return e.map(s=>({...s,items:s.items?N(s.items):void 0}))}async function I(e,s,n,t,a){if(Array.isArray(e))return(await Promise.all(e.map(f=>K(f,s,n,t,a)))).flatMap(f=>f)}async function P(e,s,n,t){let a,f;if(typeof e.icon=="object"){if("srcSet"in e.icon)try{a=await G(e.icon.srcSet,n.fs,{fromFileRelativePath:t.navFile,contentDir:s.contentDir,outdir:s.outdir})}catch(d){d instanceof E?await S.panicOnBuildContentError(`Cannot resolve "item.icon.srcSet" from ${t.navFile}: ${d.message}`):await S.panicOnBuild(`Cannot resolve "item.icon.srcSet" from ${t.navFile}: ${d.message}`)}}else if(typeof e.icon=="string")if(z(e.icon)||J(e.icon))try{f=await Y(e.icon,n.fs,{fromFileRelativePath:t.navFile,contentDir:s.contentDir,outdir:s.outdir})}catch(d){d instanceof E?await S.panicOnBuildContentError(`Cannot resolve "item.icon" from ${t.navFile}: file ${f} does not exist`):await S.panicOnBuild(`Cannot resolve "item.icon" from ${t.navFile}: ${d.message}`)}else f=e.icon;return{icon:f,srcSet:a}}function Q(e){return s=>{if(s.type==="link"||s.type==="group"){const n=s.metadata;return n?Object.entries(e).every(([t,a])=>Array.isArray(a)?a.some(f=>n[t]===f):n[t]===a):!1}return!0}}async function K(e,s,n,t,a){if(e?.directory&&e.items?.length)return{type:"error",label:`Can't have both "directory" and "items" in the nav item: ${JSON.stringify(e)}`};e?.directory&&e?.group&&(e={...e,directory:void 0,items:[{directory:e.directory}]});const f=e?.directory?F(n.contentDir,s,a,e.directory,t.fs):void 0;if(f!==void 0){const i=f===""?"":f+"/",{locale:u,ignoredRoutes:o}=a;let h=n.getAllRoutesForLocale(u).filter(c=>!o?.has(c.baseSlug||"")&&c.fsPath.startsWith(i)&&!c.excludeFromSidebar).sort((c,y)=>c.fsPath===y.fsPath?0:c.baseSlug.localeCompare(y.baseSlug,void 0,{numeric:!0}));const m=e.includeByMetadata?Q(e.includeByMetadata):Boolean;if(!h.length)return[];const $=(await Promise.all(h.map(async c=>{const y=c.versions?.find(x=>x.active),L=y&&{version:y.version,isDefault:y.default,versionFolderId:y.folderId},V=ee(v.posix.relative(f,c.fsPath)),O=c.getSidebar?.(c);return!a.ignoreCustomSidebar&&O?.length?{type:"group",fsPath:c.fsPath,metadata:c.metadata,link:c.slug,routeSlug:c.slug,label:await c.getNavText?.()||c.slug,[p]:c[p],[b]:c[b],sidebarItems:k(O,L,c[p],c[b]),...L,relativePathFromDirectory:v.relative(f,c.fsPath).replace(/@[^\/]+\//,"")}:{type:"link",fsPath:c.fsPath,metadata:c.metadata,[p]:c[p],[b]:c[b],label:await c.getNavText?.()||c.slug,link:c.slug,routeSlug:c.slug,...L,relativePathFromDirectory:V}}))).filter(m);return e.flatten?T($,a):Z($,a)}let d=typeof e=="string"?e:e?.page,r,l;if(d){if(d.includes("#")){const[i,u]=d.split("#");u?l=u:A.warn(`Invalid heading anchor format in sidebar: "${u}". Heading anchors should contain only alphanumeric characters, hyphens, and underscores.`),d=i}if(d=j(d),a.locale&&a.locale!==_){const i=U(v.join(a.locale.toLowerCase(),d));r=n.getRouteBySlug(i)}r||(r=n.getRouteBySlug(d)),r||(r=n.getRouteByFsPath(F(n.contentDir,s,a,d,t.fs)))}const g=r?.metadata;if(e?.$ref){let i=F(n.contentDir,s,a,e.$ref,t.fs);if(a.ref!==void 0&&(i=v.posix.join(a.ref,e.$ref)),!t.fs.exists(i))return await S.panicOnBuildContentError(`Failed to load ${i} file. Make sure sidebar $ref path is correct.`),[];const u=await t.cache.load(i,"yaml"),o=v.dirname(i);return await I(u.data,s,n,t,{...a,navFile:i,ref:o})||[]}if(!r){const i=a.excludedFromLinkCheckerPatterns?.catalog.some(o=>o.test(d||"")),u=a.excludedFromLinkCheckerPatterns?.apiFunctions.some(o=>o.test(d||e.href||""));(u||i)&&(e={...e,href:d||e.href,page:void 0,target:e.target??(u?"_blank":void 0)}),await X(e,a,t,s)}if(r&&!e.disconnect&&!a.ignoreCustomSidebar&&(l||r?.getSidebar)){const i=r.versions?.find(o=>o.active),u=i&&{version:i.version,isDefault:i.default,versionFolderId:i.folderId};if(l){let o=[];if(r.getSidebar&&(o=r.getSidebar(r,{...e,...await P(e,n,t,a)}),o&&o.length>0)){const h=o[0];h&&h.link&&(h.link=`${h.link}#${l}`)}if(!o||o.length===0){let h=e.group||e.label||l;o=[{type:"link",fsPath:r.fsPath,metadata:r.metadata,link:`${r.slug}#${l}`,routeSlug:r.slug,label:h,labelTranslationKey:e.labelTranslationKey,...await P(e,n,t,a),[p]:r[p],[b]:{slug:r.slug,fsPath:r.fsPath},...u}]}return k(o,u,r[p],r[b])}if(r?.getSidebar){const o=r.getSidebar(r,{...e,...await P(e,n,t,a)}),h=e.group&&o?.[0]?.routeSlug===r.slug?o.slice(1):o;return k(a.groupCustomSidebars||e.group?[{type:"group",fsPath:r.fsPath,link:r.slug,routeSlug:r.slug,label:e.group||e.label||await r.getNavText?.()||r.slug,items:h,labelTranslationKey:e.labelTranslationKey,metadata:g,...await P(e,n,t,a)}]:o,u,r[p],r[b])}}if(r&&!e.group){const i=l?`${r.slug}#${l}`:r.slug;let u=e.label||l||"";u||(u=await r.getNavText?.()||r.slug);const o=r.versions?.find(m=>m.active),h=o&&{version:o.version,isDefault:o.default,versionFolderId:o.folderId};return{type:"link",fsPath:r.fsPath,linkedSidebars:e.linkedSidebars,metadata:g,[p]:e?.rbac||r[p],[b]:{slug:r.slug,fsPath:r.fsPath},label:u,labelTranslationKey:e.labelTranslationKey,link:i,items:await I(e.items,s,n,t,a),separatorLine:e.separatorLine,linePosition:e.linePosition,routeSlug:e.disconnect?void 0:i,external:e.external,target:e.target,badges:e.badges,...await P(e,n,t,a),...h,additionalProps:e.additionalProps}}else if(e?.group){const i=r?.versions?.find(o=>o.active),u=R(a?.navFile);return{type:"group",fsPath:r?.fsPath,linkedSidebars:e.linkedSidebars,metadata:g,version:i?.version||u?.versionName,versionFolderId:i?.folderId||(u?.versionFolderPath?C(u.versionFolderPath):void 0),label:e.group,link:r?.slug,routeSlug:r?.slug,badges:e.badges,labelTranslationKey:e.groupTranslationKey,items:await I(e.items,s,n,t,a),expanded:e.expanded?e.expanded.toString():void 0,selectFirstItemOnExpand:e.selectFirstItemOnExpand,menuStyle:e.menuStyle,separatorLine:e.separatorLine,linePosition:e.linePosition,...await P(e,n,t,a),[p]:e?.rbac,[b]:{slug:r?.slug||"",fsPath:r?.fsPath||""},additionalProps:e.additionalProps}}else{if(e?.href||e?.label)return{type:"link",metadata:g,link:e.href||"",label:e?.label||e?.href||"",labelTranslationKey:e.labelTranslationKey,external:e.external,target:e.target,separatorLine:e.separatorLine,linePosition:e.linePosition,badges:e.badges,...await P(e,n,t,a),[p]:e?.rbac,additionalProps:e.additionalProps};if(e?.separator!=null||e?.separatorLine!=null){const i=R(a?.navFile);return{type:"separator",metadata:g,version:i?.versionName,versionFolderId:i?.versionFolderPath?C(i.versionFolderPath):void 0,label:e.separator,labelTranslationKey:e.separatorTranslationKey,separatorLine:e.separatorLine,linePosition:e.linePosition,...await P(e,n,t,a),[p]:e?.rbac,additionalProps:e.additionalProps}}else{const i=R(a?.navFile);return{type:"error",label:`Can't resolve page: ${JSON.stringify(e)}`,version:i?.versionName,versionFolderId:i?.versionFolderPath?C(i.versionFolderPath):void 0}}}}async function X(e,s,n,t){const{href:a,page:f}=e;if(a||!f)return;const d=F(n.fs.cwd,t,s,f,n.fs),r=n.fs.exists(d),l=await n.isPathIgnored(d),g=(r?"The page is ignored: ":"Can't resolve page: ")+f;(!r||l)&&S.reportBrokenLink({type:"BROKEN_LINK",brokenLinkType:"LINK",title:e.label||e.group||"",link:d,rawLink:f,message:g,sourceFileRelativePath:s.navFile,sourceFileLocation:{line:0}})}function F(e,s,n,t="",a){if(n.ref!==void 0)return w(v.relative(e,v.resolve(e,v.join(n.ref,t))));if(t.startsWith("/")){const f=B(s)?q(s):void 0,d=f?`${a.localizationFolder}/${f}/`:"",r=t.slice(1);return B(r)?r:d+w(r)}return w(v.relative(e,v.resolve(e,s,t)))}function Z(e,s){const n={};for(const r of e){const l=v.dirname(r.relativePathFromDirectory),g=r.version?M+r.version:"",i=v.basename(r.relativePathFromDirectory)+g;d(l,r,i)}const t=f(a(n));return T(t,s);function a(r){const l=[];for(const g of Object.keys(r)){const i=r[g];l.push({...i,items:i.items?a(i.items):void 0})}return l}function f(r){return r.sort((l,g)=>{const i=typeof l=="string"?l.toLowerCase():l.relativePathFromDirectory||l.label||"",u=typeof g=="string"?g.toLowerCase():g.relativePathFromDirectory||g.label||"";return i.startsWith("index.")?-1:u.startsWith("index.")?1:i.localeCompare(u,void 0,{numeric:!0})})}function d(r,l,g){r==="."&&(r="");const i=r.split("/").filter(Boolean);let u=n;for(const o of i){const h=o+(l?.version||"");u[h]||(u[h]={type:"group",version:l?.version,label:o,isDefault:l?.isDefault,versionFolderId:l.versionFolderId,items:{}}),u=u[h].items}u[g]=l}}function T(e,s){return e.flatMap(n=>n?.sidebarItems?s.groupCustomSidebars?{...n,items:n.sidebarItems,sidebarItems:void 0,relativePathFromDirectory:void 0}:n.sidebarItems:{...n,items:n.items?T(n.items,s):void 0})}function k(e,s,n,t){return e.map(a=>({...a,...s,[p]:a[p]||n,[b]:a[b]||t,items:a.type==="group"&&a.items?k(a.items,s,n):a.items}))}function ee(e){return e.replace(/@[^\/]+\//,"")}async function Pe(e,s,n,t){const a=(e?.items||[]).filter(r=>r.linkedSidebars?.length).map(r=>({...r,items:void 0})),f=await D(a,s.contentDir,s,n,t),d=new Map;for(const r of f)if(r.linkedSidebars?.length)for(const l of r.linkedSidebars){if(d.has(l)){A.warn(`Only one navbar item can belong to sidebar. "${l}" on 'linkedSidebars' property on "${r.label}" will be ignored.`);continue}d.set(l,{label:r.label,link:r.link})}return d}export{Pe as collectItemsLinkedToSidebars,N as normalizeItems,K as resolveItem,I as resolveItems,D as resolveLinksFromConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{simplifyAstStructure as Z}from"@redocly/openapi-docs";import{REDOCLY_TEAMS_RBAC as D}from"@redocly/config";import{OPENAPI_DOCS_TEMPLATE_ID as $,PUBLIC_RBAC_SCOPE_ITEM as j}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as ee,PUBLIC_API_DEFINITIONS_FOLDER as te}from"../../constants/common.js";import{OPENAPI_CUSTOM_FIELDS_SERVER_PROPS_GETTER_ID as oe,OPENAPI_SHARED_DATA_PREFIX as U}from"../../constants/plugins/openapi-docs.js";import{
|
|
1
|
+
import{simplifyAstStructure as Z}from"@redocly/openapi-docs";import{REDOCLY_TEAMS_RBAC as D}from"@redocly/config";import{OPENAPI_DOCS_TEMPLATE_ID as $,PUBLIC_RBAC_SCOPE_ITEM as j}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as ee,PUBLIC_API_DEFINITIONS_FOLDER as te}from"../../constants/common.js";import{OPENAPI_CUSTOM_FIELDS_SERVER_PROPS_GETTER_ID as oe,OPENAPI_SHARED_DATA_PREFIX as U}from"../../constants/plugins/openapi-docs.js";import{envConfig as V}from"../../../config/env-config.js";import{searchResolver as ae}from"./search/search-resolver.js";import{convertOpenAPIDocs2Sidebar as re,shouldAddRoute as se}from"./utils.js";import{getTemplatePath as b}from"./get-template-path.js";import{storeDefinitionBundles as ne}from"./store-definition-bundles.js";import{definitionLoader as ie,definitionsLoader as pe}from"./load-definition.js";import{getAiDocumentsStore as de}from"./search/get-ai-search-documents.js";import{fromCurrentDir as ce}from"../../utils/paths.js";import{telemetryTraceStep as le}from"../../../cli/telemetry/helpers/trace-step.js";const w="openapi-spec-download";async function Ce(){let M=[],A={},L=new Set;return{id:"openapi",requiredEntitlements:["openapi"],loaders:{"load-oas-docs":pe,"load-oas":ie},processContent:async(e,p)=>{await le("build.plugin.openapi_docs",async u=>{e.createRequestHandler(w,ce(import.meta.url,"./spec-download.api.js")),e.addApiRoute({slug:te+"/*",requestHandlerId:w,httpMethod:"all",[D]:j,getStaticData:async()=>({props:{}})}),e.addApiRoute({slug:ee+"/*",requestHandlerId:w,httpMethod:"all",[D]:j,getStaticData:async()=>({props:{}})});const R=e.createTemplate($,b("./template/OpenAPIDocs.js")),a=e.registerServerPropsGetter($,b("./get-server-props.js")),s=e.registerServerPropsGetter(oe,b("./get-server-props-custom-fields.js")),d=await p.getConfig();u?.setAttribute("config",JSON.stringify(d.openapi||{}));const g=d.rules?.["custom-fields-schema"];A={};const m=await e.loadOpenApiDefinitions(p);M=m.map(({markdocChunks:r,relativePath:f,customOutputRelativeFile:i,isVirtual:n,realRelativePath:c})=>({chunks:r,relativePath:f,realRelativePath:c,isVirtual:i!=null||n})),ne(m,e.outdir);const S={};for(const r of m||[]){const{definition:f,config:i,relativePath:n,customOutputRelativeFile:c,contentItems:_,flatItems:k,parser:E,options:B,rawOptions:q,hash:J}=r,N=c||n,o=[],x={},{definition:Q}=E||{},{info:l}=Q||{},v=l?.["x-metadata"],C=!!i.openapi?.excludeFromSearch||!!i.theme?.openapi?.excludeFromSearch||!!d.openapi?.excludeFromSearch||!!d.theme?.openapi?.excludeFromSearch,G={title:l?.title,description:l?.description,summary:l?.summary,...i.metadata,...v},h={untagged:[],tagged:new Map};for(const t of k){const{id:O,href:I,operationDefinition:y}=t;if(y){const{tags:P}=y;if(P)for(const T of P)h.tagged.has(T)||h.tagged.set(T,[]),h.tagged.get(T)?.push(t);else h.untagged.push(t);V.isDevelopMode&&(x[`#${y.pointer}`]=t.href)}if(!se({item:t}))continue;const F=t,Y=F.type==="section"&&!!F.infoDefinition,z=I.split("#")[0]+"/",K=t?.operationDefinition?.[D];o.push({excludeFromSearch:C,slugSuffix:z,fsPath:N,metadata:{subType:"openapi-operation"},httpVerb:t?.httpVerb||"",path:n,templateId:R,[D]:K||i.rbac,getAiDocumentsStore:de({parser:E,options:B,info:l,tagOperations:h,openapiContentItem:F,metadata:G,relativePath:n,getSearchFacets:e.getSearchFacets,includeInLLMsTxt:Y,excludeFromSearch:C}),getStaticData:async P=>({props:{dynamicMarkdocComponents:["openapi"],baseSlug:P.baseSlug,seo:t["x-metadata"]?.seo||{title:t.name,description:t.description},itemId:O,disableAutoScroll:!0}})})}o[0]={...o[0],metadata:{type:"openapi",...G},hasClientRoutes:!0,getSidebar:(t,O)=>{const I=[];return re({contentItems:_,sidebarItems:I,routeSlug:t.slug,navItem:O}),I},getNavText:()=>l?.title,getSearchDocuments:ae(E,B,k,e.getSearchFacets,e.setSearchFacets,C)},v?.apiId&&(S[v.apiId]={slug:o[0]?.slug||""});const W=o[0];o[0]=o[o.length-1],o[o.length-1]=W;for(const t of o)e.addRoute({...t,serverPropsGetterIds:g?[a,s]:[a]});const X=V.isDevelopMode?n:void 0,H=`${U}${n}`;A[H]={fsPath:N,definition:f,options:q,sourcePath:X,routesMapping:x,hash:J};for(const t of o)e.addRoute({...t,sharedData:[{id:H,key:"openAPIDocsStore"}],serverPropsGetterIds:g?[a,s]:[a]})}e.setGlobalData({apiProducts:S})})},afterRoutesCreated:async(e,p)=>{const u=new Set;for(const{chunks:a,relativePath:s,isVirtual:d,realRelativePath:g}of M){const m=e.getAllRoutes().filter(r=>r.fsPath===s).map(r=>r.slug),S=(await p.cache.load(g,"load-oas")).compoundHash;await p.cache.load(s,{loader:async function(){for(const{node:f,markdown:i,key:n,relativePath:c}of a){const{ast:_}=await e.parseMarkdoc({content:i,relativePath:c,isVirtual:d},p,{sharedDataIds:[`${U}${c}`],routeSlugs:m});f[`x-parsed-md-${n}`]={result:Z(_)}}},name:"openapi-markdoc-inline-parser"},[S]);for(const{pointer:r}of a)u.add(r)}const R=L.difference(u);for(const a of R)p.cache.delete(a);L=u;for(const[a,s]of Object.entries(A))await e.createSharedData(a,{...s,baseSlug:e.getRouteByFsPath(s.fsPath)?.baseSlug},s.hash)}}}export{Ce as openAPIDocsPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFileSync as
|
|
1
|
+
import{writeFileSync as E}from"node:fs";import D from"path";import{SCORECARD_OUTPUT_FILE_NAME as b}from"../../constants/common.js";import{mapObject as T}from"../../../utils/object/map-object.js";import{envConfig as w}from"../../../config/env-config.js";import{removeLeadingSlash as A}from"../../../utils/url/remove-leading-slash.js";import{combineUrls as R}from"@redocly/theme/core/utils";import{logger as j}from"../../tools/notifiers/logger.js";import{getRouteSlugToCatalogSlugMap as F}from"../../utils/catalog-classic/get-route-slug-to-catalog-slug-map.js";import{deepEqual as I}from"../../../utils/object/deep-equal.js";import{ensureDir as N}from"../../utils/index.js";import{getTemplatePath as U}from"./get-template-path.js";import{getAllRuleNames as q}from"./lint.js";import{getScorecardConfig as L}from"./get-scorecard-config.js";import{CUSTOM_FIELDS_SERVER_PROPS_GETTER_ID as M}from"../catalog-classic/index.js";import{getScorecardSlug as k}from"./shared-utils.js";import{scorecardConfigLoader as W}from"./loaders/scorecard-config.js";import{scorecardLoader as B}from"./loaders/scorecard.js";import{computeScorecard as J}from"./compute-scorecard.js";import{telemetryTraceStep as $}from"../../../cli/telemetry/helpers/trace-step.js";const G="scorecardClassic";let u={},h={};async function ue({id:P,requiredEntitlements:_,loadersPrefix:v=""}){let p=null,y=null,O=!1;return{id:P??"scorecardClassic",requiredEntitlements:_??["scorecard"],loaders:{[`${v}scorecard-config`]:W,[`${v}scorecard`]:B},async processContent(r,l){await $("build.plugin.scorecard_classic",async S=>{const a=r.createTemplate(G,U("./template/index.js")),g=await l.getConfig(),m=L(g),f=g?.reunite??{},i=[()=>p===null,()=>!I(u,m),()=>!I(h,f)].some(e=>e());u=m,S?.setAttribute("config",JSON.stringify(u||{})),h=f;const n=g.catalogClassic??{},c=u.levels||[];if(c.length<1)throw Error("Invalid configuration of levels config");i&&(p=await J({actions:r,context:l,scorecardConfig:u,reuniteConfig:h}));const{data:{configs:t}}=await l.cache.load("",`${v}scorecard-config`),{perLevel:d,all:s}=q(t);y={levelNames:c.map(e=>e.name),rules:s,rulesPerLevel:d};for(const[e,o]of Object.entries(n)){const C=R(o.slug,"scorecard/");r.addRoute({duplicateInAllLocales:!0,slug:C,fsPath:R(o.slug,"scorecard/"),templateId:a,hasClientRoutes:!0,excludeFromSidebar:!0,serverPropsGetterIds:[M],sharedData:[{id:"scorecard",key:"scorecard"},{key:"catalog",id:"catalog-"+e}],getNavText:()=>Promise.resolve(o.title||"API design scorecard"),getStaticData:async()=>({props:{catalogId:e,catalogConfig:{...o,items:void 0},scorecardConfig:u,scorecardInfo:y}})})}})},afterRoutesCreated:async(r,l)=>{const S=await l.getConfig(),a=S.catalogClassic??{},g=L(S);if(Object.keys(a).length){const i=Object.keys(a).length>1?await F(r,l,a):null,n={};for(const[c,t]of Object.entries(p||{})){const d=r.getRouteByFsPath(c),s=d?.slug;if(s){if(d&&!g.ignoreMetadata){const e=i?i.get(s)??Object.values(a)[0].slug:Object.values(a)[0].slug,o=R(e,"scorecard/");d.metadata={...d.metadata,scorecardStatus:t.status,scorecardLevel:t.scorecardLevel,scorecardLevelIdx:t.scorecardLevelIdx,scorecardLevels:T(t.levels,C=>({uniqueErrors:C.uniqueErrors,uniqueWarnings:C.uniqueWarnings})),scoreCardSlug:o+"apis/"+encodeURIComponent(A(s))}}if(n[s]={...t,levels:T(t.levels,e=>({...e,problems:e.problems.map(o=>({ruleId:o.ruleId,severity:o.severity}))}))},!O){const e=D.resolve(r.outdir,"_scorecard",k(s));E(N(e),JSON.stringify(t))}}}await r.createSharedData("scorecard",n)}const m={};for(const[i,n]of Object.entries(p||{})){const c=r.getRouteByFsPath(i)?.slug;c&&(m[c]=n)}const f=w.REDOCLY_METADATA_OUTPUT_FOLDER;!O&&f&&(j.info("Writing scorecard data..."),E(D.join(f,b),JSON.stringify({scorecardData:m,...y}))),O=!0}}}export{ue as scorecardClassicPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SCORECARDS_BASE_SLUG as
|
|
1
|
+
import{envConfig as c}from"../../../config/env-config.js";import{SCORECARDS_BASE_SLUG as i,SCORECARDS_TEMPLATE_ID as n}from"../../constants/plugins/scorecards.js";import{getTemplatePath as d}from"./utils/get-template-path.js";import{telemetryTraceStep as l}from"../../../cli/telemetry/helpers/trace-step.js";async function u(){return{id:"Scorecards",requiredEntitlements:["scorecards"],async processContent(e,r){await l("build.plugin.scorecards",async s=>{if(c.NEW_SCORECARDS_ENABLED!=="true")return;const t=(await r.getConfig()).scorecards;s?.setAttribute("config",JSON.stringify(t));const{logger:o}=r;o.info("Scorecards plugin started");const a=e.createTemplate(n,d("../template/index.js"));e.addRoute({duplicateInAllLocales:!0,slug:i,fsPath:"",templateId:a,excludeFromSidebar:!0,hasClientRoutes:!0,getNavText:()=>Promise.resolve("Scorecards"),getStaticData:async()=>({props:{scorecardsConfig:t}})}),o.info("Scorecards plugin finished")})}}}var C=u;export{C as default,u as scorecardsPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SCORECARDS_WORKER_KEY as
|
|
1
|
+
import{SCORECARDS_WORKER_KEY as f,scorecardsWorker as m}from"../../../workers/scorecards-worker-pool.js";import{logger as e}from"../../../tools/notifiers/logger.js";import{envConfig as u}from"../../../../config/env-config.js";const o=5;async function n(s){const{baseDbDir:c,scorecardsConfig:a,attempt:t}=s;try{const r=await m.exec(f,[{baseDbDir:c,scorecardsConfig:a,pollingIntervalMs:parseInt(u.SCORECARDS_POLLING_INTERVAL_MS||"3000",10)}]);if(r.success)return e.info(`${r.message}`),Promise.resolve();e.error(`Execute Scorecards Worker: failed (attempt ${t}/${o}): ${r.error}`)}catch(r){const i=r instanceof Error?r.message:String(r);e.error(`Execute Scorecards Worker: failed (attempt ${t}/${o}): ${i}`)}return t<o?(e.info(`Execute Scorecards Worker: retrying... (attempt ${t+1}/${o})`),n({baseDbDir:c,scorecardsConfig:a,attempt:t+1})):(e.error(`Execute Scorecards Worker: failed. Scorecards Worker could not be started after all ${o} attempts`),Promise.resolve())}async function p(s,c){return e.info("Start Scorecards Worker: executing..."),n({baseDbDir:s,scorecardsConfig:c,attempt:1})}export{p as runScorecardsWorker};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import p from"node:path";import{existsSync as b}from"node:fs";import{writeFile as D,access as v,rm as N,constants as X}from"fs/promises";import{REDOCLY_ROUTE_RBAC as S,REDOCLY_TEAMS_RBAC as R}from"@redocly/config";import $ from"picomatch";import{DEFAULT_LOCALE_PLACEHOLDER as _}from"../../../../constants/common.js";import{AI_INDEX_EXPORT_FOLDER as j}from"../../../constants/plugins/search.js";import{LLMS_TXT_FILE_NAME as k}from"../../../constants/common.js";import{
|
|
1
|
+
import p from"node:path";import{existsSync as b}from"node:fs";import{writeFile as D,access as v,rm as N,constants as X}from"fs/promises";import{REDOCLY_ROUTE_RBAC as S,REDOCLY_TEAMS_RBAC as R}from"@redocly/config";import $ from"picomatch";import{DEFAULT_LOCALE_PLACEHOLDER as _}from"../../../../constants/common.js";import{AI_INDEX_EXPORT_FOLDER as j}from"../../../constants/plugins/search.js";import{LLMS_TXT_FILE_NAME as k}from"../../../constants/common.js";import{envConfig as B}from"../../../../config/env-config.js";import{logger as a}from"../../../tools/notifiers/logger.js";import{shaHexShort as G}from"../../../utils/crypto/sha-hex-short.js";import{promiseMapLimit as C}from"../../../utils/async/promise-map-limit.js";import{ensureDir as A}from"../../../utils/fs.js";import{isResourcePubliclyAccessible as H,extractTeamsFromScopeItems as U,getRbacTeamsListForResource as Y}from"../../../utils/rbac.js";import{validateLLMsTxtConfig as J,generateLLMsTxt as K,getLLMsTxtMdSlug as V}from"../llmstxt/index.js";const M=20,h="llms.txt:";async function pt(t,i,{aiSearchEnabled:e,llmstxtEnabled:r}){const s=p.join(t.outdir,k);if(!r){try{await v(s,X.W_OK),await N(s)}catch{}if(!e)return}e&&a.info("Preparing AI search documents..."),r&&a.info(`${h} Generating llms.txt files...`);const L=a.startTiming(),c=a.startTiming(),f=t.getGlobalConfig("seo"),l=f?.llmstxt,T=p.resolve(t.outdir,j),u=t.getConfig(),P=u.rbac??{},w=t.getAllRoutes(),F=u?.l10n?.defaultLocale||u?.i18n?.defaultLocale||_,I=(l?.excludeFiles||[]).map(o=>$(o)),d=[];if(await C(w,M,async o=>{if(o.excludeFromSearch)return;const O=await W(o,t),x=await q(o,O,i,t);if(x){if(r)for(const n of await x.getLLMsTxts()){if(I.some(m=>m(n.fsPath)))continue;const g=p.join(t.outdir,V(n.slug));A(g),await D(g,n.content),n.includeInLLMsTxt&&H(o,u)&&d.push(n)}if(e&&B.isBuildMode){const n=await x.getSearchDocuments();if(!n.length)return;const g=z(o,P),m=o.versions?.find(({active:E})=>E),y=m&&{folder:m.folderId,label:m.label,default:m.default};await Q(n,o.fsPath,g,T,F,y)}}}),e&&a.infoTime(c,"AI search documents prepared"),d.length)try{J(l);const o=await K(d,l,{title:f?.title,description:f?.description},i);A(s),await D(s,o),a.infoTime(L,`${h} files generated`)}catch(o){a.error(`${h} Failed to generate llms.txt file. ${o.message}`)}}async function W(t,i){return t.getStaticData?t.getStaticData(t,{...i,contentDir:i.contentDir,parseMarkdoc:(e,r,s)=>i.parseMarkdoc(e,r,s)}):{}}async function q(t,i,e,r){if(t.getAiDocumentsStore)return t.getAiDocumentsStore(t,{...i,[R]:t[R],[S]:t[S]},e,r)}function z(t,i){const e=U(t?.[R]);return e?.length?e:Y(t,i)}async function Q(t,i,e,r,s,L){await C(t,M,async c=>{const f=`${G(i+c.content)}.json`,l=A(p.join(r,f)),T=c.locale===_?s:c.locale;b(l)||await D(l,JSON.stringify({...c,rbacTeams:e||[],version:L,locale:T}),"utf-8")})}export{pt as prepareAiSearchDocuments};
|