@redocly/redoc 0.129.0-next.2 → 0.129.0-next.3
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 +36 -0
- package/dist/bin.js +1 -1
- package/dist/cli/develop.d.ts +1 -1
- package/dist/cli/develop.js +1 -1
- package/dist/cli/prepare/analytics/collectors/get-file-extensions-usage.js +1 -1
- package/dist/cli/prepare/analytics/collectors/get-frontmatter-usage.js +1 -1
- package/dist/cli/prepare/analytics/collectors/get-markdoc-usage.js +1 -1
- package/dist/cli/prepare/analytics/collectors/get-nested-configs-usage.js +1 -1
- package/dist/cli/prepare/analytics/collectors/get-refs-usage.js +1 -1
- package/dist/cli/prepare/index.d.ts +1 -1
- package/dist/cli/translations/collect-config-translations.js +1 -1
- package/dist/cli/translations/update-translations.js +1 -1
- package/dist/client/TestProvider.js +1 -1
- package/dist/client/app/Sidebar/RequestAccessButton.js +2 -2
- package/dist/client/app/Sidebar/Sidebar.js +7 -2
- package/dist/client/app/Sidebar/useSidebarItems.d.ts +1 -0
- package/dist/client/app/Sidebar/useSidebarItems.js +1 -1
- package/dist/client/app/hooks/catalog/useFetchCatalogEntities.js +1 -1
- package/dist/client/app/hooks/catalog/useFetchCatalogEntitiesRelations.js +1 -1
- package/dist/client/app/hooks/catalog/useFetchCatalogEntityRevisions.d.ts +10 -0
- package/dist/client/app/hooks/catalog/useFetchCatalogEntityRevisions.js +1 -0
- package/dist/client/app/hooks/index.d.ts +1 -0
- package/dist/client/app/hooks/index.js +1 -1
- package/dist/client/app/hooks/useLoginUrl.js +1 -1
- package/dist/client/app/pages/DevLogin/DevLogin.js +1 -1
- package/dist/client/app/pages/Login/Login.js +1 -1
- package/dist/client/app/utils/loadAndNavigate.js +1 -1
- package/dist/client/browser-entry.js +2 -2
- package/dist/client/providers/page-data/hooks.d.ts +2 -1
- package/dist/client/providers/page-data/hooks.js +1 -1
- package/dist/client/providers/theme/ThemeDataProvider.js +1 -1
- package/dist/client/runtime/loader.js +1 -1
- package/dist/client/utils/catalog/inject-catalog-items.d.ts +1 -1
- package/dist/client/utils/catalog/inject-catalog-items.js +1 -1
- package/dist/constants/common.d.ts +0 -4
- package/dist/constants/common.js +1 -1
- package/dist/constants/l10n/langs/ar.js +1 -1
- package/dist/constants/l10n/langs/de.js +1 -1
- package/dist/constants/l10n/langs/en.js +1 -1
- package/dist/constants/l10n/langs/es.js +1 -1
- package/dist/constants/l10n/langs/fr.js +1 -1
- package/dist/constants/l10n/langs/hi.js +1 -1
- package/dist/constants/l10n/langs/it.js +1 -1
- package/dist/constants/l10n/langs/ja.js +1 -1
- package/dist/constants/l10n/langs/ko.js +1 -1
- package/dist/constants/l10n/langs/pl.js +1 -1
- package/dist/constants/l10n/langs/pt-BR.js +1 -1
- package/dist/constants/l10n/langs/pt.js +1 -1
- package/dist/constants/l10n/langs/ru.js +1 -1
- package/dist/constants/l10n/langs/uk.js +1 -1
- package/dist/constants/l10n/langs/zh.js +1 -1
- package/dist/server/api-routes/execute-api-route.d.ts +0 -7
- package/dist/server/api-routes/execute-api-route.js +1 -1
- package/dist/server/api-routes/helpers/setup-logger.d.ts +2 -2
- package/dist/server/api-routes/helpers/setup-logger.js +1 -1
- package/dist/server/api-routes/run-api-routes-worker.js +1 -1
- package/dist/server/fs/cache.d.ts +1 -2
- package/dist/server/fs/cache.js +1 -1
- package/dist/server/fs/content-fs.d.ts +9 -4
- package/dist/server/fs/content-fs.js +1 -1
- package/dist/server/fs/fs.d.ts +6 -6
- package/dist/server/fs/fs.js +1 -3
- package/dist/server/fs/load-error.d.ts +2 -2
- package/dist/server/fs/load-error.js +1 -1
- package/dist/server/fs/utils/async-storage.d.ts +0 -8
- package/dist/server/fs/utils/async-storage.js +1 -1
- package/dist/server/fs/utils/isVirtualFile.d.ts +1 -1
- package/dist/server/fs/utils/isVirtualFile.js +1 -1
- package/dist/server/plugins/api-functions/index.js +1 -1
- package/dist/server/plugins/arazzo-docs/arazzo-doc-loader.d.ts +1 -1
- package/dist/server/plugins/arazzo-docs/arazzo-doc-loader.js +2 -2
- package/dist/server/plugins/arazzo-docs/index.d.ts +1 -1
- package/dist/server/plugins/arazzo-docs/index.js +1 -1
- package/dist/server/plugins/asyncapi-docs/asyncapi-doc-loader.d.ts +1 -1
- package/dist/server/plugins/asyncapi-docs/asyncapi-doc-loader.js +2 -2
- package/dist/server/plugins/asyncapi-docs/index.d.ts +1 -1
- package/dist/server/plugins/asyncapi-docs/index.js +1 -1
- package/dist/server/plugins/asyncapi-docs/is-asyncapi-doc.js +1 -1
- package/dist/server/plugins/catalog-entities/database/catalog-entities-service.d.ts +23 -18
- package/dist/server/plugins/catalog-entities/database/catalog-entities-service.js +1 -1
- package/dist/server/plugins/catalog-entities/database/mappers/create-bff-entity.js +1 -1
- package/dist/server/plugins/catalog-entities/database/mappers/create-bff-related-entity.d.ts +9 -0
- package/dist/server/plugins/catalog-entities/database/mappers/create-bff-related-entity.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-db-record.js +1 -1
- 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-db-record-from-dto.js +1 -1
- package/dist/server/plugins/catalog-entities/database/mappers/create-entity-relation-db-record-from-file-schema.js +1 -1
- package/dist/server/plugins/catalog-entities/database/mappers/create-entity-relation.js +1 -1
- package/dist/server/plugins/catalog-entities/database/mappers/map-entity-relation-row.d.ts +12 -0
- package/dist/server/plugins/catalog-entities/database/mappers/map-entity-relation-row.js +1 -0
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-read-repository.d.ts +15 -4
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-read-repository.js +67 -55
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.d.ts +21 -15
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.js +1 -1
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-write-repository.d.ts +16 -3
- 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/local/catalog-entities-relations-repository.d.ts +17 -0
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-relations-repository.js +1 -0
- package/dist/server/plugins/catalog-entities/database/repositories/utils.d.ts +4 -4
- package/dist/server/plugins/catalog-entities/database/repositories/utils.js +1 -1
- package/dist/server/plugins/catalog-entities/entities/{extract-entities-content.d.ts → extract-file-content.d.ts} +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/arazzo-entities-extractor.d.ts +2 -2
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/arazzo-entities-extractor.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/asyncapi-entities-extractor.d.ts +2 -2
- 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 -2
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/base.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/graphql-entities-extractor.d.ts +2 -2
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/graphql-entities-extractor.js +2 -2
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/openapi-entities-extractor.d.ts +2 -2
- 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/get-server-props.d.ts +1 -2
- package/dist/server/plugins/catalog-entities/get-server-props.js +1 -1
- package/dist/server/plugins/catalog-entities/schemas/database-schemas.d.ts +64 -0
- package/dist/server/plugins/catalog-entities/schemas/database-schemas.js +1 -1
- package/dist/server/plugins/catalog-entities/schemas/dto-schemas.d.ts +6 -12
- package/dist/server/plugins/catalog-entities/schemas/dto-schemas.js +1 -1
- package/dist/server/plugins/catalog-entities/schemas/read-model-schemas.d.ts +4 -8
- package/dist/server/plugins/catalog-entities/schemas/read-model-schemas.js +1 -1
- package/dist/server/plugins/catalog-entities/utils/catalog-data-collector.js +1 -1
- package/dist/server/plugins/catalog-entities/utils/read-string.d.ts +7 -0
- package/dist/server/plugins/catalog-entities/utils/read-string.js +1 -0
- package/dist/server/plugins/config-parser/loaders/content-slugs-loader.js +1 -1
- package/dist/server/plugins/config-parser/loaders/nearest-redocly-config-loader.js +1 -1
- package/dist/server/plugins/config-parser/loaders/utils/read-and-validate-config.js +1 -1
- package/dist/server/plugins/config-parser/loaders/yaml-parser.js +1 -1
- package/dist/server/plugins/default-theme/resolve-products-config.js +1 -1
- package/dist/server/plugins/ensure-frontmatter-theme-compatibility.js +1 -1
- package/dist/server/plugins/entitlements/index.js +1 -1
- package/dist/server/plugins/graphql-docs/index.js +1 -1
- package/dist/server/plugins/l10n/index.js +1 -1
- package/dist/server/plugins/lifecycle.js +2 -2
- package/dist/server/plugins/markdown/attribute-resolvers/code-walkthrough/filesets-resolver.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-code-snippet-from-file.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-link.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-link.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-open-api-ref.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-parsed-yaml.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-raw-content.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-svg-content.js +1 -1
- package/dist/server/plugins/markdown/compiler.js +1 -1
- package/dist/server/plugins/markdown/get-server-props.js +1 -1
- package/dist/server/plugins/markdown/index.js +1 -1
- package/dist/server/plugins/markdown/markdoc/partials.js +1 -1
- package/dist/server/plugins/markdown/markdoc/resolve-raw-partials.js +1 -1
- package/dist/server/plugins/markdown/markdown-static-data-loader.js +1 -1
- package/dist/server/plugins/mcp/auth/auth-handlers.d.ts +1 -1
- package/dist/server/plugins/mcp/auth/auth-handlers.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/get-endpoint-info.d.ts +7 -2
- package/dist/server/plugins/mcp/docs-mcp/tools/get-endpoint-info.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/get-endpoints.d.ts +7 -2
- package/dist/server/plugins/mcp/docs-mcp/tools/get-endpoints.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/get-full-api-description.d.ts +7 -2
- package/dist/server/plugins/mcp/docs-mcp/tools/get-full-api-description.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/get-security-schemes.d.ts +7 -2
- package/dist/server/plugins/mcp/docs-mcp/tools/get-security-schemes.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/index.d.ts +4 -3
- package/dist/server/plugins/mcp/docs-mcp/tools/index.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/list-apis.d.ts +5 -2
- package/dist/server/plugins/mcp/docs-mcp/tools/list-apis.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/utils.d.ts +6 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/utils.js +6 -6
- package/dist/server/plugins/mcp/docs-mcp/tools/whoami.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/utils.d.ts +3 -3
- package/dist/server/plugins/mcp/docs-mcp/utils.js +1 -1
- package/dist/server/plugins/mcp/handlers/docs-mcp-handler.js +1 -1
- package/dist/server/plugins/mcp/index.js +1 -1
- package/dist/server/plugins/mcp/servers/docs-server.d.ts +10 -3
- package/dist/server/plugins/mcp/servers/docs-server.js +1 -1
- package/dist/server/plugins/mcp/types.d.ts +26 -2
- package/dist/server/plugins/mcp/utils.d.ts +9 -8
- package/dist/server/plugins/mcp/utils.js +1 -1
- package/dist/server/plugins/mcp/workers/run-api-routes-worker.js +1 -1
- package/dist/server/plugins/nav-utils.js +1 -1
- package/dist/server/plugins/openapi-docs/decorators.d.ts +3 -2
- package/dist/server/plugins/openapi-docs/decorators.js +1 -1
- package/dist/server/plugins/openapi-docs/index.d.ts +2 -2
- package/dist/server/plugins/openapi-docs/index.js +1 -1
- package/dist/server/plugins/openapi-docs/is-openapi-doc.js +1 -1
- package/dist/server/plugins/openapi-docs/load-definition.d.ts +1 -1
- package/dist/server/plugins/openapi-docs/load-definition.js +3 -3
- package/dist/server/plugins/pages/index.js +1 -1
- package/dist/server/plugins/search/llmstxt/index.js +5 -5
- package/dist/server/plugins/sidebars/index.js +3 -3
- package/dist/server/plugins/utils.js +1 -1
- package/dist/server/providers/database/databases/catalog-sqlite/schemas/entities-relations-table.d.ts +25 -46
- package/dist/server/providers/database/databases/catalog-sqlite/schemas/entities-relations-table.js +1 -1
- package/dist/server/providers/database/databases/catalog-sqlite/schemas/entities-table.d.ts +20 -3
- package/dist/server/providers/database/databases/catalog-sqlite/schemas/entities-table.js +1 -1
- package/dist/server/providers/database/pagination/combined-filters.d.ts +4 -1
- package/dist/server/providers/database/pagination/combined-filters.js +1 -1
- package/dist/server/providers/database/pagination/filter.d.ts +1 -0
- package/dist/server/providers/database/pagination/filter.js +1 -1
- package/dist/server/providers/database/pagination/index.d.ts +4 -1
- package/dist/server/store.js +1 -1
- package/dist/server/tools/notifiers/formatter.d.ts +2 -0
- package/dist/server/tools/notifiers/formatter.js +3 -3
- package/dist/server/tools/notifiers/logger.d.ts +18 -39
- package/dist/server/tools/notifiers/logger.js +2 -6
- package/dist/server/tools/notifiers/reporter.js +9 -9
- package/dist/server/tools/notifiers/terminal-manager.d.ts +8 -0
- package/dist/server/tools/notifiers/terminal-manager.js +5 -0
- package/dist/server/types/fs.d.ts +5 -10
- package/dist/server/types/plugins/api-routes.d.ts +0 -3
- package/dist/server/types/plugins/common.d.ts +0 -1
- package/dist/server/utils/is-valid-iso-date.d.ts +5 -0
- package/dist/server/utils/is-valid-iso-date.js +1 -0
- package/dist/server/utils/lifecycle-hooks.js +1 -1
- package/dist/server/utils/queue.js +1 -1
- package/dist/server/utils/redirects/find-redirect.d.ts +4 -2
- package/dist/server/utils/redirects/find-redirect.js +1 -1
- package/dist/server/utils/resolve-asset-path.js +1 -1
- package/dist/server/utils/validate-and-sanitize-string.d.ts +29 -0
- package/dist/server/utils/validate-and-sanitize-string.js +1 -0
- package/dist/server/web-server/auth.d.ts +5 -0
- package/dist/server/web-server/auth.js +3 -3
- package/dist/server/web-server/http.js +2 -2
- package/dist/server/web-server/middleware/loggerMiddleware.js +1 -1
- package/dist/server/web-server/routes/auth.js +1 -1
- package/dist/server/web-server/routes/catalog/bff-catalog-related-entities.js +1 -1
- package/dist/server/web-server/routes/catalog/bff-catalog.js +1 -1
- package/dist/server/web-server/routes/catalog/catalog-relations.js +1 -1
- package/dist/server/web-server/routes/mcp-oauth.js +1 -1
- package/dist/server/web-server/routes/search.js +1 -1
- package/dist/server/web-server/utils/get-redirect-login-url.js +1 -1
- package/dist/utils/auth/build-login-url.d.ts +1 -3
- package/dist/utils/auth/build-login-url.js +1 -1
- package/dist/utils/env/is-local-development.d.ts +13 -0
- package/dist/utils/env/is-local-development.js +1 -0
- package/dist/utils/env/is-production.d.ts +13 -0
- package/dist/utils/env/is-production.js +1 -0
- package/dist/utils/env/is-web-view.d.ts +14 -0
- package/dist/utils/env/is-web-view.js +1 -0
- package/dist/utils/path/remove-fragment.d.ts +16 -0
- package/dist/utils/path/remove-fragment.js +1 -0
- package/package.json +10 -10
- package/dist/server/web-server/routes/otel/types.d.ts +0 -61
- package/dist/server/web-server/routes/otel/types.js +0 -1
- /package/dist/server/plugins/catalog-entities/entities/{extract-entities-content.js → extract-file-content.js} +0 -0
|
@@ -6,9 +6,9 @@ type Params = BaseApiEntitiesExtractorParams;
|
|
|
6
6
|
export declare class ArazzoEntitiesExtractor extends BaseApiEntitiesExtractor<BundledDefinition> {
|
|
7
7
|
#private;
|
|
8
8
|
constructor(params: Params);
|
|
9
|
-
mapApiDescriptionToEntity(description: BundledDefinition): EntityFileSchema;
|
|
9
|
+
mapApiDescriptionToEntity(description: BundledDefinition, version: string): EntityFileSchema;
|
|
10
10
|
loadApiDescriptions(): Promise<BundledDefinition[]>;
|
|
11
|
-
processApiDescription(description: BundledDefinition): Promise<
|
|
11
|
+
processApiDescription(description: BundledDefinition, revision: string, version: string, entitiesToRemoveFromFile: Set<string>): Promise<void>;
|
|
12
12
|
resolveSourceDescriptionUrl(url: string, baseRelativePath: string): string | null;
|
|
13
13
|
}
|
|
14
14
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import u from"node:path";import{removeLeadingSlash as m}from"@redocly/theme/core/utils";import{toKebabCase as y}from"../../../../../../utils/string/to-kebab-case.js";import{promiseMapLimit as f}from"../../../../../utils/async/promise-map-limit.js";import{removeMarkdocTags as d}from"../../../../markdown/markdoc/helpers/remove-markdoc-tags.js";import{BaseApiEntitiesExtractor as w}from"./base.js";const g=15;class k extends w{constructor(t){super("arazzo",t)}mapApiDescriptionToEntity(t,o){const r=m(t.realRelativePath),c=t.document.info.title,e=r.replace(/\.[^.]+$/,""),n=y(e.replace(/[\\/]/g,"-")),a=t.document["x-redocly-catalog-key"],i=typeof a=="string"&&a.trim()?y(a.trim()):n;return{type:this.type,key:i,title:c,summary:t.document.info.description?d(t.document.info.description):null,tags:["arazzo"],metadata:{specType:this.specType,descriptionFile:r},version:o}}async loadApiDescriptions(){return(await this.context.cache.load(".","arazzo-docs")).data}async processApiDescription(t,o,r,c){if(!this.#t(t)){this.context.logger.warn(`Skipping Arazzo description without source descriptions: ${t.realRelativePath}`);return}const e=this.mapApiDescriptionToEntity(t,r);await this.catalogEntitiesService.createEntityInLocalDatabase({entity:e,sourceFile:t.realRelativePath,fileHash:t.hash,isRootEntity:!0,revision:o}),c.delete(`${e.key}:${r}`),await this.#e(t,e.key,e.version,r,o,c);const n=t.document.sourceDescriptions||[];await f(n,g,async a=>{if(!(a.type!=="openapi"||!a.url))try{const i=this.resolveSourceDescriptionUrl(a.url,t.realRelativePath);if(!i){!a.url.startsWith("http://")&&!a.url.startsWith("https://")&&this.context.logger.warn(`Could not resolve URL to local path: ${a.url}`);return}const l=await this.context.cache.load(i,"load-oas");if(!(l.data&&Array.isArray(l.data)&&l.data.length>0)){this.context.logger.warn(`No OpenAPI definition found at path: ${i}`);return}const s=l.data[0],p=y(m(s.realRelativePath).replace(/\.[^.]+$/,"").replace(/[\\/]/g,"-"));await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:e.key,type:"relatesTo",targetKey:p,fileHash:t.hash}),await this.#r(t,a.name,s,e.key,p,e.version,o)}catch(i){this.context.logger.warn(`Failed to create relation to OpenAPI source "${a.url}": ${i instanceof Error?i.message:"Unknown error"}`)}})}#t=t=>!!t?.document?.sourceDescriptions&&t.document.sourceDescriptions.length>0;#e=async(t,o,r,c,e,n)=>{try{const a=t.document.components?.inputs,i=a?Object.entries(a):[],l=[];for(const[h,s]of i)l.push(async()=>{const p=await this.#a({schemaName:h,schema:s,description:t,parentKey:o,parentVersion:r,parentRevision:e});n.delete(`${p.entityKey}:${c}`),p.result==="created"&&await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:o,type:"uses",targetKey:p.entityKey,fileHash:t.hash,sourceVersion:r,targetVersion:r,sourceRevision:e,targetRevision:e})});if(l.length===0)return;await f(l,g,h=>h())}catch(a){this.context.logger.warn(`Failed to create data schema entities for Arazzo description: ${a instanceof Error?a.message:"Unknown error"}`)}};#a=async({schemaName:t,schema:o,description:r,parentKey:c,parentVersion:e,parentRevision:n})=>{const a={type:"data-schema",key:`${c}-${y(t)}`,title:t,summary:o.description||o.title||null,tags:["arazzo"],metadata:{specType:this.specType,descriptionFile:r.realRelativePath,schema:"{}"},version:e};return await this.catalogEntitiesService.createEntityInLocalDatabase({entity:a,sourceFile:r.realRelativePath,fileHash:r.hash,revision:n})};#r=async(t,o,r,c,e,n,a)=>{const i=t.document.workflows||[];if(i.length===0)return;const l=new Set;for(const h of i)for(const s of h.steps||[]){if(!s.operationId)continue;const p=s.operationId.startsWith(`${o}.`)?s.operationId.substring(`${o}.`.length):s.operationId;p&&l.add(p)}l.size!==0&&await f(Array.from(l),g,async h=>{try{const s=`${e}-${y(h)}`;await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:c,type:"uses",targetKey:s,fileHash:t.hash,sourceVersion:n,targetVersion:n,sourceRevision:a,targetRevision:a})}catch(s){this.context.logger.warn(`Failed to create relation to operation "${h}": ${s instanceof Error?s.message:"Unknown error"}`)}})};resolveSourceDescriptionUrl(t,o){try{const r=t.trim(),c=r.startsWith("@")?r.slice(1):r,[e]=c.split("#");if(e.startsWith("http://")||e.startsWith("https://"))return null;if(e.startsWith("/"))return m(u.posix.normalize(e));const n=u.posix.dirname(o);return e.startsWith(n+"/")?u.posix.normalize(e):u.posix.normalize(u.posix.join(n,e))}catch{return this.context.logger.warn(`Failed to resolve URL: ${t}`),null}}}export{k as ArazzoEntitiesExtractor};
|
|
@@ -6,9 +6,9 @@ type Params = BaseApiEntitiesExtractorParams;
|
|
|
6
6
|
export declare class AsyncApiEntitiesExtractor extends BaseApiEntitiesExtractor<BundledDefinition> {
|
|
7
7
|
#private;
|
|
8
8
|
constructor(params: Params);
|
|
9
|
-
mapApiDescriptionToEntity(description: BundledDefinition): EntityFileSchema;
|
|
9
|
+
mapApiDescriptionToEntity(description: BundledDefinition, version: string): EntityFileSchema;
|
|
10
10
|
loadApiDescriptions(): Promise<BundledDefinition[]>;
|
|
11
|
-
processApiDescription(description: BundledDefinition): Promise<
|
|
11
|
+
processApiDescription(description: BundledDefinition, revision: string, version: string, entitiesToRemoveFromFile: Set<string>): Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=asyncapi-entities-extractor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{removeLeadingSlash as
|
|
1
|
+
import{removeLeadingSlash as $}from"@redocly/theme/core/utils";import{toKebabCase as h}from"../../../../../../utils/string/to-kebab-case.js";import{promiseMapLimit as p}from"../../../../../utils/async/promise-map-limit.js";import{promiseMapLimitWithStatus as g}from"../../../../../utils/async/promise-map-limit-with-status.js";import{removeMarkdocTags as d}from"../../../../markdown/markdoc/helpers/remove-markdoc-tags.js";import{BaseApiEntitiesExtractor as R}from"./base.js";import{extractPartsFromComponentsRef as y}from"../../../utils/extract-parts-from-components-ref.js";import{validateEntityRelation as E}from"../../../entities/validate-entity.js";import{extractPartsFromChannelsMessageRef as w}from"../../../utils/extract-parts-from-channels-message-ref.js";const f=15;class k extends R{constructor(e){super("asyncapi",e)}mapApiDescriptionToEntity(e,a){const s=$(e.realRelativePath),n=e.document.info.title,t=s.replace(/\.[^.]+$/,""),r=h(t.replace(/[\\/]/g,"-")),o=e.document["x-redocly-catalog-key"],c=typeof o=="string"&&o.trim()?h(o.trim()):r;return{type:this.type,key:c,title:n,summary:d(e.document.info.description),tags:e.document.info.tags?.map(i=>i.name),metadata:{specType:this.specType,descriptionFile:s},version:a}}async loadApiDescriptions(){return(await this.context.cache.load(".","asyncapi-docs")).data}async processApiDescription(e,a,s,n){const t=this.mapApiDescriptionToEntity(e,s);await this.catalogEntitiesService.createEntityInLocalDatabase({entity:t,sourceFile:e.realRelativePath,fileHash:e.hash,isRootEntity:!0,revision:a}),n.delete(`${t.key}:${s}`);const r=this.#a(e),[o,c]=await Promise.allSettled([this.#s(e,t.key,t.version,s,a,n),this.#r(r,e,t.key,t.version,s,a,n)]);o.status!=="fulfilled"&&this.context.logger.error("Schema processing failed:",o.reason),c.status!=="fulfilled"&&this.context.logger.error("Operation processing failed:",c.reason)}#a=e=>{const a=e.documentWithReferences.operations;return a?Object.entries(a).map(([s,n])=>({operationName:s,operation:n})):[]};#s=async(e,a,s,n,t,r)=>{const o=e.document.components?.schemas;if(!o)return;const c=Object.entries(o);if(c.length===0)return;const i=await g(c,f,async([l,m])=>{const u=await this.#n({schemaName:l,schema:m,description:e,parentKey:a,parentVersion:s,parentRevision:t});r.delete(`${u.entityKey}:${n}`),u.result==="created"&&await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:a,type:"uses",targetKey:u.entityKey,fileHash:e.hash,sourceVersion:s,targetVersion:s,sourceRevision:t,targetRevision:t})},this.context.logger);i.count.failed>0&&this.context.logger.warn(`Schema processing completed with ${i.count.failed} failures out of ${c.length} schemas for ${e.realRelativePath}`)};#n=async({schemaName:e,schema:a,description:s,parentKey:n,parentVersion:t,parentRevision:r})=>{const o=`${n}-${h(e)}`,c="title"in a?a.title??a.description:null,i=JSON.stringify(a),l={type:"data-schema",key:o,title:e,summary:c,tags:[],metadata:{specType:this.specType,schema:i},version:t};return await this.catalogEntitiesService.createEntityInLocalDatabase({entity:l,sourceFile:s.realRelativePath,fileHash:s.hash,revision:r})};#r=async(e,a,s,n,t,r,o)=>{if(!e.length)return;const c=await g(e,f,async({operationName:i,operation:l})=>{const m=await this.#c(l,i,a,s,n,r);m&&o.delete(`${m}:${t}`)},this.context.logger);c.count.failed>0&&this.context.logger.warn(`Operation processing completed with ${c.count.failed} failures out of ${e.length} operations for ${a.realRelativePath}`)};#c=async(e,a,s,n,t,r)=>{const o=await this.#o(e.messages??[],s,n),c=await this.#i(a,e,o,s,n,t,r);return c.result==="created"&&await this.#l({apiOperationKey:c.entityKey,operation:e,descriptionUniqueKey:n,description:s,descriptionVersion:t,parentRevision:r}),c.entityKey??null};#o=async(e,a,s)=>{if(!e||e.length===0)return[];const n=new Set;for(const t of e){let r=null;if("$ref"in t){const o=t.$ref.startsWith("#/channels/")?this.#e(t.$ref,a):t.$ref;if(o){const c=y(o);if(c?.componentName&&c.componentType==="messages"){const i=a.documentWithReferences.components?.messages[c.componentName];i?.payload&&"$ref"in i.payload&&i.payload.$ref&&(r=i.payload.$ref)}}}else t.payload&&"$ref"in t.payload&&t.payload.$ref&&(r=t.payload.$ref);if(r){const o=y(r);o?.componentName&&o.componentType==="schemas"&&n.add(`${s}-${h(o.componentName)}`)}}return Array.from(n)};#i=async(e,a,s,n,t,r,o)=>{const c={type:"api-operation",key:`${t}-${h(e)}`,title:a.title||e,summary:a.summary??"",tags:a.tags?.map(l=>l.name)??[],metadata:{method:a.action==="send"?"PUBLISH":"SUBSCRIBE",path:a.channel.address??"",payload:a.action==="receive"?s:[],responses:a.action==="send"?s:[]},version:r};return await this.catalogEntitiesService.createEntityInLocalDatabase({entity:c,sourceFile:n.realRelativePath,fileHash:n.hash,revision:o})};#l=async({apiOperationKey:e,operation:a,descriptionUniqueKey:s,description:n,descriptionVersion:t,parentRevision:r})=>(await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:e,type:"partOf",targetKey:s,fileHash:n.hash,sourceVersion:t,targetVersion:t,sourceRevision:r,targetRevision:r}),await this.#h(a,e,t,r),!Array.isArray(a.messages)||!a.messages?.length?[]:await this.#m(a.messages,e,n,s,t,r));#h=async(e,a,s,n)=>{e["x-catalog-relations"]?.length&&await p(e["x-catalog-relations"],f,async t=>{try{E(t),await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:a,type:t.type,targetKey:t.key,sourceVersion:s,targetVersion:s,sourceRevision:n,targetRevision:n})}catch(r){this.context.logger.warn(`Error creating entity relation for operation ${a} based on custom property: ${r instanceof Error?r.message:"Unknown error"}`)}})};#m=async(e,a,s,n,t,r)=>e.length===0?[]:(await p(e,f,async c=>await this.#y(c,a,s,n,t,r)??"")).filter(c=>!!c);#y=async(e,a,s,n,t,r)=>"$ref"in e?this.#f(e,a,s,n,t,r):e.payload?this.#u(e,a,s,n,t,r):null;#f=async(e,a,s,n,t,r)=>{const o=e.$ref.startsWith("#/channels/")?this.#e(e.$ref,s):e.$ref;if(!o)return null;const c=y(o);if(!c||!c.componentName||c.componentType!=="messages")return null;const i=s.documentWithReferences.components?.messages[c.componentName];return!i?.payload||!("$ref"in i.payload)||!i.payload.$ref?null:this.#t(i.payload.$ref,a,s,n,t,r)};#e=(e,a)=>{const s=w(e);if(!s||!s.channelName||!s.messageName)return null;const n=a.documentWithReferences.channels?.[s.channelName];if(!n?.messages)return null;const t=n.messages[s.messageName];return!t||!("$ref"in t)||typeof t.$ref!="string"||!t.$ref.startsWith("#/components/messages/")?null:t.$ref};#u=async(e,a,s,n,t,r)=>!e.payload||!("$ref"in e.payload)||!e.payload.$ref?null:this.#t(e.payload.$ref,a,s,n,t,r);#t=async(e,a,s,n,t,r)=>{const o=y(e);if(!o||!o.componentName||o.componentType!=="schemas")return null;const c=`${n}-${h(o.componentName)}`;return await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:a,type:"uses",targetKey:c,fileHash:s.hash,sourceVersion:t,targetVersion:t,sourceRevision:r,targetRevision:r}),c}}export{k as AsyncApiEntitiesExtractor};
|
package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/base.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare abstract class BaseApiEntitiesExtractor<BundledApiDefinition exte
|
|
|
18
18
|
constructor(specType: SpecType, params: BaseApiEntitiesExtractorParams);
|
|
19
19
|
extract(): Promise<void>;
|
|
20
20
|
protected abstract loadApiDescriptions(): Promise<BundledApiDefinition[]>;
|
|
21
|
-
protected abstract mapApiDescriptionToEntity(definition: BundledApiDefinition): EntityFileSchema;
|
|
22
|
-
protected abstract processApiDescription(definition: BundledApiDefinition): Promise<
|
|
21
|
+
protected abstract mapApiDescriptionToEntity(definition: BundledApiDefinition, version: string): EntityFileSchema;
|
|
22
|
+
protected abstract processApiDescription(definition: BundledApiDefinition, revision: string, version: string, entitiesToRemoveFromFile: Set<string>): Promise<void>;
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FileHashStatus as
|
|
1
|
+
import{FileHashStatus as c}from"../../../../../persistence/file-hashes/types.js";import{promiseMapLimit as v}from"../../../../../utils/async/promise-map-limit.js";import{OPERATORS as u}from"../../../../../providers/database/pagination/constants.js";import{VERSION_NOT_SPECIFIED as f}from"@redocly/theme/core/constants";import{resolveEntityVersion as g}from"../../../utils/resolve-entity-version.js";import{catalogDataCollector as h}from"../../../utils/catalog-data-collector.js";const E=3;class D{type="api-description";specType;fileType;actions;context;catalogEntitiesService;fileHashManager;entitySources={};#e;constructor(t,e){this.specType=t,this.fileType=e.fileType,this.actions=e.actions,this.context=e.context,this.catalogEntitiesService=e.catalogEntitiesService,this.fileHashManager=e.fileHashManager,this.#e=e.shouldCalculateEntities??!1}async extract(){const t=await this.loadApiDescriptions();await this.fileHashManager.markAllAsOutdated(this.fileType),t.length&&h.addExtractor(this.specType),await v(t,E,async e=>{try{if(e.isVirtual||!e.hash)return;if(!((await this.fileHashManager.getByPath(e.realRelativePath))?.hash!==e.hash||this.#e||process.env.FORCE_CATALOG_CACHE_REVALIDATE==="true")){h.increaseSkippedFilesCount(),await this.fileHashManager.upsert(this.fileType,e.realRelativePath,e.hash,c.UP_TO_DATE);return}const a=await this.catalogEntitiesService.getEntityKeysAndVersionsBySourceFile(e.realRelativePath),o=new Date().toISOString(),n=this.#a(e);await this.processApiDescription(e,o,n,a),await this.#i(a,e.realRelativePath,o,e.hash),h.increaseProcessedFilesCount(),await this.fileHashManager.upsert(this.fileType,e.realRelativePath,e.hash,c.UP_TO_DATE)}catch(i){this.context.logger.warn(`Error extracting entities from ${this.specType} description: ${e.realRelativePath}`),this.context.logger.warn(i)}}),await this.#t()}#t=async()=>{const t=await this.fileHashManager.getAllOutdated(this.fileType);if(!t||t.length===0)return;const e=await this.catalogEntitiesService.getEntities({limit:1e3,filter:{op:"AND",conditions:[{field:"source_file",operator:"in",value:t.map(({filePath:i})=>i)},{field:"is_current",operator:"equal",value:!0}]}});e&&e.items.length>0&&await this.catalogEntitiesService.deleteEntitiesInLocalDatabase({field:"key",operator:"in",value:e.items.map(({key:i})=>i)}),await this.fileHashManager.deleteFileHashes({op:"AND",conditions:[{field:"file_type",operator:"equal",value:this.fileType},{field:"status",operator:"equal",value:c.OUTDATED}]})};#i=async(t,e,i,r)=>{if(t.size===0)return;const a=Array.from(t).map(s=>{const[l,p]=s.split(":");return{key:l,version:p}}),o=Array.from(new Set(a.map(({key:s})=>s))),n=a.map(({key:s,version:l})=>({op:u.AND,conditions:[{field:"key",operator:"equal",value:s},{field:"version",operator:"equal",value:l}]}));await this.catalogEntitiesService.softDeleteEntitiesInLocalDatabase({revision:i,fileHash:r,filter:{op:"AND",conditions:[{field:"key",operator:"in",value:o},{op:u.OR,conditions:n},{field:"source",operator:"equal",value:"file"},{field:"source_file",operator:"equal",value:e}]}})};#a(t){const e=t.document?.info?.version??t.definition?.info?.version??null,i=g(e,t.realRelativePath);return i.success?i.version??f:f}}export{D as BaseApiEntitiesExtractor};
|
|
@@ -13,8 +13,8 @@ export declare class GraphqlEntitiesExtractor extends BaseApiEntitiesExtractor<G
|
|
|
13
13
|
#private;
|
|
14
14
|
constructor(params: BaseApiEntitiesExtractorParams);
|
|
15
15
|
loadApiDescriptions(): Promise<GraphqlBundledDefinition[]>;
|
|
16
|
-
mapApiDescriptionToEntity(description: GraphqlBundledDefinition): EntityFileSchema;
|
|
17
|
-
processApiDescription(description: GraphqlBundledDefinition): Promise<
|
|
16
|
+
mapApiDescriptionToEntity(description: GraphqlBundledDefinition, version: string): EntityFileSchema;
|
|
17
|
+
processApiDescription(description: GraphqlBundledDefinition, revision: string, version: string, entitiesToRemoveFromFile: Set<string>): Promise<void>;
|
|
18
18
|
}
|
|
19
19
|
export {};
|
|
20
20
|
//# sourceMappingURL=graphql-entities-extractor.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{buildSchema as
|
|
1
|
+
import{buildSchema as R,isObjectType as g,isScalarType as O,isEnumType as D,isInterfaceType as S,isUnionType as w,isInputObjectType as E,getNamedType as u,printType as L}from"graphql";import{removeLeadingSlash as v}from"@redocly/theme/core/utils";import{toKebabCase as m}from"../../../../../../utils/string/to-kebab-case.js";import{capitalize as A}from"../../../../../../utils/string/capitalize.js";import{promiseMapLimit as T}from"../../../../../utils/async/promise-map-limit.js";import{promiseMapLimitWithStatus as b}from"../../../../../utils/async/promise-map-limit-with-status.js";import{sha1 as j}from"../../../../../utils/crypto/sha1.js";import{removeMarkdocTags as K}from"../../../../markdown/markdoc/helpers/remove-markdoc-tags.js";import{BaseApiEntitiesExtractor as N}from"./base.js";const $=15,I=15,F=new Set(["String","ID","Int","Float","Boolean","DateTime","Date","Time","URL","URI","JSON","JSONObject","BigInt","BigDecimal"]);class Q extends N{#t;constructor(t){super("graphql",t),this.#t=t.context.logger}async loadApiDescriptions(){const t=[];for(const{relativePath:e}of this.context.fs.scan(/(\.gql|\.graphql)$/))try{if(e.includes("@l10n")||await this.context.isPathIgnored(e))continue;const a=await this.context.cache.load(e,"graphql-doc");if(!a.data)continue;const{content:n,metadata:r}=a.data,s=R(n),o=j(n);t.push({realRelativePath:e,relativePath:e,isVirtual:!1,hash:o,schema:s,content:n,metadata:r})}catch(a){this.#t.warn(`Failed to load GraphQL schema from ${e}: ${a instanceof Error?a.message:"Unknown error"}`)}return t}mapApiDescriptionToEntity(t,e){const a=v(t.realRelativePath),n=t.relativePath.replace(/\.(gql|graphql)$/,""),r=this.#s(n.split("/").pop()||"GraphQL Schema"),s=a.replace(/\.(gql|graphql)$/,""),o=m(s.replace(/[\\/]/g,"-")),p=this.#c(t.metadata?.tags),c=t.metadata?.["x-redocly-catalog-key"],i=typeof c=="string"&&c.trim()?m(c.trim()):o;return{type:this.type,key:i,title:r,summary:t.metadata?.description||null,tags:p.concat("graphql"),metadata:{specType:this.specType,descriptionFile:a},version:e}}async processApiDescription(t,e,a,n){const{schema:r}=t;if(!r)return;const s=this.mapApiDescriptionToEntity(t,a);await this.catalogEntitiesService.createEntityInLocalDatabase({entity:s,sourceFile:t.realRelativePath,fileHash:t.hash,isRootEntity:!0,revision:e}),n.delete(`${s.key}:${a}`),await Promise.all([this.#a(t,s.key,s.version,a,e,n),this.#y(t,s.key,s.version,a,e,n)])}#a=async(t,e,a,n,r,s)=>{const{schema:o}=t,p=o.getTypeMap(),c=this.#r(o),i=Object.entries(p).filter(([h])=>!h.startsWith("__")&&!F.has(h)&&!c.has(h));if(i.length===0)return;const l=await b(i,I,async([h,y])=>{const f=await this.#l({typeName:h,type:y,description:t,parentKey:e,parentVersion:a,parentRevision:r});s.delete(`${f.entityKey}:${n}`),f.result==="created"&&await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:e,type:"uses",targetKey:f.entityKey,fileHash:t.hash,sourceVersion:a,targetVersion:a,sourceRevision:r,targetRevision:r})},this.#t);l.count.failed>0&&this.#t.warn(`Schema processing completed with ${l.count.failed} failures out of ${i.length} types for ${t.realRelativePath}`),await this.#h({description:t,descriptionUniqueKey:e,userTypes:i,parentRevision:r})};#s=t=>{const e=t.replace(/[^A-Za-z0-9]+/g," ").trim();return e?e.split(" ").map(a=>a&&A(a)).join(" "):"GraphQL Schema"};#e=(t,e)=>`${e}-${m(t)}`;#n=t=>g(t)?"object":S(t)?"interface":w(t)?"union":D(t)?"enum":E(t)?"input":O(t)?"scalar":"unknown";#r=t=>{const e=new Set,a=t.getQueryType();a&&e.add(a.name);const n=t.getMutationType();n&&e.add(n.name);const r=t.getSubscriptionType();return r&&e.add(r.name),e};#i(t){const e=[],a=t.getQueryType();if(a){const s=a.getFields();for(const[o,p]of Object.entries(s))e.push({fieldName:o,field:p,operationType:"QUERY",rootTypeName:a.name})}const n=t.getMutationType();if(n){const s=n.getFields();for(const[o,p]of Object.entries(s))e.push({fieldName:o,field:p,operationType:"MUTATION",rootTypeName:n.name})}const r=t.getSubscriptionType();if(r){const s=r.getFields();for(const[o,p]of Object.entries(s))e.push({fieldName:o,field:p,operationType:"SUBSCRIBE",rootTypeName:r.name})}return e}#o=(t,e)=>{const a=[];if(t.args)for(const s of t.args){const o=u(s.type);o&&!o.name.startsWith("__")&&a.push(this.#e(o.name,e))}const n=[],r=u(t.type);return r&&!r.name.startsWith("__")&&n.push(this.#e(r.name,e)),{inputTypes:a,returnTypes:n}};#c=t=>{if(Array.isArray(t))return t.map(e=>String(e)).map(e=>e.trim()).filter(e=>e.length>0);if(typeof t=="string"){const e=t.trim();return e?[e]:[]}return[]};#l=async({typeName:t,type:e,description:a,parentKey:n,parentVersion:r,parentRevision:s})=>{const o=this.#e(t,n),p=e.description??null,c=this.#n(e),i={type:"data-schema",key:o,title:t,summary:p,tags:["graphql"],metadata:{specType:this.specType,typeKind:c,sdl:this.#p(e,a.schema)},version:r};return await this.catalogEntitiesService.createEntityInLocalDatabase({entity:i,sourceFile:a.realRelativePath,fileHash:a.hash,revision:s})};#p=(t,e)=>{const a=new Set,n=[],r=new Set(["String","ID","Int","Float","Boolean"]),s=c=>{if(!c)return;const i=c.name;if(i.startsWith("__")||r.has(i)||a.has(i))return;const l=e.getType(i);l&&(a.add(i),n.push(l))};for(s(t);n.length>0;){const c=n.pop();if(g(c)){for(const l of c.getInterfaces?.()??[])s(l);const i=c.getFields();for(const l of Object.values(i)){s(u(l.type));for(const h of l.args??[])s(u(h.type))}}else if(S(c)){const i=c.getFields();for(const l of Object.values(i))s(u(l.type))}else if(w(c))for(const i of c.getTypes())s(i);else if(E(c)){const i=c.getFields();for(const l of Object.values(i))s(u(l.type))}}const o=[t.name,...[...a].filter(c=>c!==t.name)],p=[];for(const c of o){const i=e.getType(c);i&&p.push(L(i))}return p.join(`
|
|
2
2
|
|
|
3
|
-
`)};#h=async({description:t,descriptionUniqueKey:e,userTypes:a})=>{const
|
|
3
|
+
`)};#h=async({description:t,descriptionUniqueKey:e,userTypes:a,parentRevision:n})=>{const r=a.filter(([,s])=>g(s));r.length!==0&&await T(r,I,async([s,o])=>{const c=o.getInterfaces?.()??[];if(!c.length)return;const i=this.#e(s,e);await T([...c],5,async l=>{const h=this.#e(l.name,e);try{await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:i,type:"implements",targetKey:h,fileHash:t.hash,sourceRevision:n,targetRevision:n})}catch(y){this.#t.warn(`Failed to create 'implements' relation ${i} -> ${h}: ${y instanceof Error?y.message:"Unknown error"}`)}})})};#y=async(t,e,a,n,r,s)=>{const{schema:o}=t,p=this.#i(o);if(p.length===0)return;const i=(await b(p,$,async({fieldName:l,field:h,operationType:y,rootTypeName:f})=>{const d=await this.#f(l,h,y,f,t,e,a,r);d&&s.delete(`${d}:${n}`)},this.#t)).count.failed;i>0&&this.#t.warn(`Operation extraction completed with ${i} failures out of ${p.length} operations for ${e}`)};#f=async(t,e,a,n,r,s,o,p)=>{const{inputTypes:c,returnTypes:i}=this.#o(e,s),l=await this.#u({fieldName:t,field:e,operationType:a,rootTypeName:n,inputTypes:c,returnTypes:i,description:r,descriptionUniqueKey:s,descriptionVersion:o,parentRevision:p});return l.result==="created"&&await this.#m({apiOperationKey:l.entityKey,inputTypes:c,returnTypes:i,descriptionUniqueKey:s,description:r,descriptionVersion:o,parentRevision:p}),l.entityKey??null};#u=async({fieldName:t,field:e,operationType:a,rootTypeName:n,inputTypes:r,returnTypes:s,description:o,descriptionUniqueKey:p,descriptionVersion:c,parentRevision:i})=>{const l=t,y={type:"api-operation",key:`${p}-${m(`${a.toLowerCase()}-${t}`)}`,title:l,summary:e.description?K(e.description):null,tags:["graphql"],metadata:{method:a,path:`${n}.${t}`,payload:r,responses:s},version:c};return await this.catalogEntitiesService.createEntityInLocalDatabase({entity:y,sourceFile:o.realRelativePath,fileHash:o.hash,revision:i})};#m=async({apiOperationKey:t,inputTypes:e,returnTypes:a,descriptionUniqueKey:n,description:r,descriptionVersion:s,parentRevision:o})=>{await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:t,type:"partOf",targetKey:n,fileHash:r.hash,sourceVersion:s,targetVersion:s,sourceRevision:o,targetRevision:o});const p=[...new Set(e)],c=[...new Set(a)],i=[...p.map(l=>({key:l,relationType:"uses"})),...c.map(l=>({key:l,relationType:"returns"}))];await T(i,$,async({key:l,relationType:h})=>{try{await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:t,type:h,targetKey:l,fileHash:r.hash,sourceVersion:s,targetVersion:s,sourceRevision:o,targetRevision:o})}catch(y){this.#t.warn(`Failed to create relation between operation ${t} and type ${l} (${h}): ${y instanceof Error?y.message:"Unknown error"}`)}})}}export{Q as GraphqlEntitiesExtractor};
|
|
@@ -6,7 +6,7 @@ export declare class OpenApiEntitiesExtractor extends BaseApiEntitiesExtractor<B
|
|
|
6
6
|
#private;
|
|
7
7
|
constructor(params: BaseApiEntitiesExtractorParams);
|
|
8
8
|
loadApiDescriptions(): Promise<BundledDefinition[]>;
|
|
9
|
-
mapApiDescriptionToEntity(description: BundledDefinition): EntityFileSchema;
|
|
10
|
-
processApiDescription(description: BundledDefinition): Promise<
|
|
9
|
+
mapApiDescriptionToEntity(description: BundledDefinition, version: string): EntityFileSchema;
|
|
10
|
+
processApiDescription(description: BundledDefinition, revision: string, version: string, entitiesToRemoveFromFile: Set<string>): Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=openapi-entities-extractor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{removeLeadingSlash as
|
|
1
|
+
import{removeLeadingSlash as S}from"@redocly/theme/core/utils";import{toKebabCase as p}from"../../../../../../utils/string/to-kebab-case.js";import{promiseMapLimit as u}from"../../../../../utils/async/promise-map-limit.js";import{promiseMapLimitWithStatus as O}from"../../../../../utils/async/promise-map-limit-with-status.js";import{removeMarkdocTags as g}from"../../../../markdown/markdoc/helpers/remove-markdoc-tags.js";import{BaseApiEntitiesExtractor as d}from"./base.js";import{OpenapiSchemaResolver as $}from"../../../utils/openapi-schema-resolver.js";import{extractPartsFromComponentsRef as N}from"../../../utils/extract-parts-from-components-ref.js";import{validateEntityRelation as x}from"../../../entities/validate-entity.js";import{isValidTagName as E}from"../../../utils/is-valid-tag-name.js";const v=["get","post","put","delete","patch"],w=15,R=15;class F extends d{#e;constructor(e){super("openapi",e),this.#e=e.context.logger}async loadApiDescriptions(){return await this.actions.loadOpenApiDefinitions(this.context)}mapApiDescriptionToEntity(e,o){const s=S(e.realRelativePath),n=e.definition.info.title,t=s.replace(/\.[^.]+$/,""),a=p(t.replace(/[\\/]/g,"-")),r=e.definition["x-redocly-catalog-key"],i=typeof r=="string"&&r.trim()?p(r.trim()):a;return{type:this.type,key:i,title:n,summary:g(e.definition.info.description),tags:e.definition.tags?.filter(c=>c.name&&E(c.name)).map(c=>c.name),metadata:{specType:this.specType,descriptionFile:s},version:o}}async processApiDescription(e,o,s,n){if($.clearSchemaCache(),!e?.definition?.paths)return;const t=this.mapApiDescriptionToEntity(e,s);await this.catalogEntitiesService.createEntityInLocalDatabase({entity:t,sourceFile:e.realRelativePath,fileHash:e.hash,isRootEntity:!0,revision:o}),n.delete(`${t.key}:${s}`),await this.#n(e,t.key,t.version,s,o,n);const a=this.#s(e.definition.paths);if(a.length!==0){const i=(await O(a,w,async({operation:c,path:h,method:l})=>{if(!c.operationId)return;const f=await this.#r(c,h,l,e,t.key,t.version,o);f&&n.delete(`${f}:${s}`)},this.#e)).count.failed;i>0&&this.#e.warn(`Extraction completed with ${i} failures out of ${a.length} operations for ${t.key}`)}}#s(e){return Object.entries(e).flatMap(([o,s])=>v.filter(n=>s[n]).map(n=>{const t=s[n];if(!t)throw new Error(`Operation not found for method ${n} on path ${o}`);return{operation:t,path:o,method:n.toUpperCase()}}))}async#n(e,o,s,n,t,a){const r=e.definition.components?.schemas;if(!r)return;const i=Object.entries(r);i.length!==0&&await u(i,R,async([c,h])=>{const l=await this.#o({schemaName:c,schema:h,description:e,parentKey:o,parentVersion:s,parentRevision:t});a.delete(`${l.entityKey}:${n}`),l.result==="created"&&await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:o,sourceVersion:s,sourceRevision:t,type:"uses",targetKey:l.entityKey,targetVersion:s,targetRevision:t,fileHash:e.hash})})}async#o({schemaName:e,schema:o,description:s,parentKey:n,parentVersion:t,parentRevision:a}){const r=$.resolveSchemaRefs(o,s),i=JSON.stringify(r),c={type:"data-schema",key:`${n}-${p(e)}`,title:e,summary:r.description??r.title??null,tags:[],metadata:{specType:this.specType,schema:i},version:t};return await this.catalogEntitiesService.createEntityInLocalDatabase({entity:c,sourceFile:s.realRelativePath,fileHash:s.hash,revision:a})}async#r(e,o,s,n,t,a,r){const i=await Promise.all([this.#h(e.requestBody??null,n),this.#m(e.responses??{},n)]),c=i[0].schemaNames,h=i[1].schemaNames;i[0].errors.length>0&&this.#e.warn(`Schema extraction errors for operation ${e.operationId}: ${i[0].errors.join(", ")}`),i[1].errors.length>0&&this.#e.warn(`Response schema extraction errors for operation ${e.operationId}: ${i[1].errors.join(", ")}`);const l=c.map(y=>`${t}-${p(y)}`),f=h.map(y=>`${t}-${p(y)}`),m=await this.#p({path:o,method:s,operation:e,requestBodySchemasKeys:l,responseSchemasKeys:f,description:n,parentKey:t,parentVersion:a,parentRevision:r});return m.result==="created"&&await Promise.all([this.#i(c,e.operationId??"",n.hash,t,a,r),this.#c(h,e.operationId??"",n.hash,t,a,r),this.#f({apiOperationKey:m.entityKey,operationRelations:e["x-catalog-relations"],descriptionUniqueKey:t,description:n,parentVersion:a,parentRevision:r})]),m.entityKey??null}async#i(e,o,s,n,t,a){return e.length===0||!o?[]:await this.#a(e,o,s,n,t,a)}async#c(e,o,s,n,t,a){return e.length===0||!o?[]:await this.#a(e,o,s,n,t,a)}#h(e,o){const s=[],n=[];try{if(e&&"content"in e&&e.content)for(const t of Object.values(e.content)){if(!t.schema?.$ref)continue;const a=this.#t(t.schema.$ref);a?.componentType==="schemas"&&a.componentName&&s.push(a.componentName)}if(e&&e.$ref){const t=this.#t(e.$ref);if(t?.componentType==="requestBodies"&&t.componentName){const a=o.definition.components?.requestBodies?.[t.componentName];if(a&&"content"in a)for(const r of Object.values(a.content??{})){if(!r.schema?.$ref)continue;const i=this.#t(r.schema.$ref);i?.componentType==="schemas"&&i.componentName&&s.push(i.componentName)}}}}catch(t){n.push(`Failed to extract request body schemas: ${t instanceof Error?t.message:"Unknown error"}`)}return{schemaNames:[...new Set(s)],errors:n}}#m(e,o){const s=[],n=[];try{for(const t of Object.values(e)){if(t&&"content"in t&&t.content)for(const a of Object.values(t.content)){if(!a.schema?.$ref)continue;const r=this.#t(a.schema.$ref);r?.componentType==="schemas"&&r.componentName&&s.push(r.componentName)}if(t&&t.$ref){const a=this.#t(t.$ref);if(a?.componentType==="responses"&&a.componentName){const r=o.definition.components?.responses?.[a.componentName];if(r&&"content"in r)for(const i of Object.values(r.content??{})){if(!i.schema?.$ref)continue;const c=this.#t(i.schema.$ref);c?.componentType==="schemas"&&c.componentName&&s.push(c.componentName)}}}}}catch(t){n.push(`Failed to extract response schemas: ${t instanceof Error?t.message:"Unknown error"}`)}return{schemaNames:[...new Set(s)],errors:n}}#t(e){try{return N(e)}catch{return{componentType:"",componentName:null}}}async#a(e,o,s,n,t,a){return e.length===0?[]:await u(e,R,async r=>await this.#l({operationId:o,schemaName:r,descriptionHash:s,parentKey:n,parentVersion:t,parentRevision:a}))}async#l({operationId:e,schemaName:o,descriptionHash:s,parentKey:n,parentVersion:t,parentRevision:a}){const r=`${n}-${p(o)}`;try{return await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:`${n}-${p(e)}`,type:"uses",targetKey:r,fileHash:s,sourceVersion:t,targetVersion:t,sourceRevision:a,targetRevision:a}),r}catch(i){throw this.#e.error(`Failed to create relation between operation ${e} and schema ${o}: ${i instanceof Error?i.message:"Unknown error"}`),i}}async#p({path:e,method:o,operation:s,requestBodySchemasKeys:n,responseSchemasKeys:t,description:a,parentKey:r,parentVersion:i,parentRevision:c}){const h=`${s.operationId}`,f={type:"api-operation",key:`${r}-${p(h)}`,title:h,summary:g(s.summary),tags:s.tags?.filter(m=>E(m)),metadata:{path:e,method:o,payload:n,responses:t},version:i};try{return await this.catalogEntitiesService.createEntityInLocalDatabase({entity:f,sourceFile:a.realRelativePath,fileHash:a.hash,revision:c})}catch(m){throw this.#e.error(`Failed to create API operation entity for ${h}: ${m instanceof Error?m.message:"Unknown error"}`),m}}async#f({apiOperationKey:e,operationRelations:o,descriptionUniqueKey:s,description:n,parentVersion:t,parentRevision:a}){try{await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:e,type:"partOf",targetKey:s,fileHash:n.hash,sourceVersion:t,targetVersion:t,sourceRevision:a,targetRevision:a}),await this.#y(e,o,t,a)}catch(r){this.#e.error(`Failed to create API operation relations for ${e}: ${r instanceof Error?r.message:"Unknown error"}`)}}async#y(e,o,s,n){o?.length&&await u(o,w,async t=>{try{x(t),await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:e,type:t.type,targetKey:t.key,sourceVersion:s,targetVersion:s,sourceRevision:n,targetRevision:n})}catch(a){this.context.logger.warn(`Error creating entity relation for operation ${e} based on custom property: ${a instanceof Error?a.message:"Unknown error"}`)}})}}export{F as OpenApiEntitiesExtractor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CATALOG_ENTITIES_FILES_REGEX as
|
|
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 h}from"../../../../utils/async/promise-map-limit.js";import{VERSION_NOT_SPECIFIED as m}from"@redocly/theme/core/constants";import{extractFileContent as p}from"../../entities/extract-file-content.js";import{resolveEntityVersion as g}from"../../utils/resolve-entity-version.js";import{parseAndValidateEntities as y}from"../../entities/validate-entity.js";import{catalogDataCollector as f}from"../../utils/catalog-data-collector.js";const I=15;class v{#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 h(i,I,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 p(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||process.env.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 y(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=g(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??m;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({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{v as FsEntitiesExtractor};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { BffCatalogEntity, BffCatalogEntityList, BffCatalogRelatedEntity, BffCatalogRelatedEntityList, CatalogSwitcherItem, CatalogViewMode } from '@redocly/theme/core/types';
|
|
1
|
+
import type { BffCatalogEntity, BffCatalogEntityList, BffCatalogRelatedEntity, BffCatalogRelatedEntityList, CatalogSwitcherItem, CatalogViewMode, CatalogFiltersWithCounts } from '@redocly/theme/core/types';
|
|
2
2
|
import type { EntitiesCatalogConfig, CatalogEntityConfig } from '@redocly/config';
|
|
3
3
|
import type { GetServerPropsFn } from '../../types/plugins/common';
|
|
4
|
-
import type { CatalogFiltersWithCounts } from '@redocly/theme/core/types';
|
|
5
4
|
export type ServerSideProps = {
|
|
6
5
|
status: 'success';
|
|
7
6
|
entitiesTypes: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sha1 as
|
|
1
|
+
import{sha1 as b}from"../../utils/crypto/sha1.js";import{isValidSanitizedString as E}from"../../utils/validate-and-sanitize-string";import{CatalogEntitiesService as h}from"./database/catalog-entities-service.js";import{createPaginationParamsValidator as F}from"../../providers/database/pagination/schemas";import{parseSearch as A}from"../../providers/database/pagination/search";import{OPERATORS as C}from"../../providers/database/pagination/constants.js";import{CacheService as I}from"../../persistence/cache/services/cache-service.js";import{CATALOG_FILTERS_CACHE_NAMESPACE as w,CATALOG_FILTERS_CACHE_TTL_IN_SECONDS as D}from"../../constants/plugins/catalog-entities.js";import{isValidIsoDate as T}from"../../utils/is-valid-iso-date.js";const Z={all:"all",domains:"domain",services:"service",teams:"team",users:"user","api-descriptions":"api-description","data-schemas":"data-schema"},R={team:{field:"type",operator:"equal",value:"user"},"api-description":{field:"type",operator:"equal",value:"api-operation"}},V=async({entitiesTypes:e,serverOutDir:s,catalogConfig:t,queries:a={}})=>{const n=await h.getInstance({baseDbDir:s}),c=K.concat("domains","owners"),r=F(c).parse(a),p=t.excludes?.map(i=>i.key)??[],d=e.filter(i=>i!=="all"),l=k(d,p);return r.filter?r.filter={op:C.AND,conditions:[r.filter,l]}:r.filter=l,await n.getEntitiesWithRelations({sort:[{field:"type",order:"ASC"}],limit:10,...r})},_=async(e,s,t)=>{const a=await h.getInstance({baseDbDir:s});let n=null;const c=t?.revision;c&&T(c)&&(n=c);const r=t?.version;if(!E(r,{pattern:/^[a-zA-Z0-9._-]+$/,maxLength:100,allowEmpty:!0}))return null;const p=await a.getEntityWithRelationsByKey(e,{revision:n,version:r});if(!p)return null;const d=p.type==="data-schema"?await a.getRelatedEntities(e,{limit:1,filter:{field:"type",operator:"equal",value:"api-description"}}).then(f=>f.items?.[0]??null):null,l=R[p.type]??void 0,u=q(l,r,n),i=await a.getRelatedEntities(e,{limit:10,sort:[{field:"title",order:"ASC"}],filter:u,search:t?.search?A(t?.search,["key","type","title","summary"]):void 0});return{status:"success",entity:p,relatedEntity:d,relations:i}},N=e=>{const s=JSON.stringify({entitiesTypes:e.entitiesTypes.sort(),filtersConfig:e.filtersConfig});return b(s)},P=async({serverOutDir:e,entitiesTypes:s,filtersConfig:t})=>{if(!t||t.length===0)return{};const a=N({entitiesTypes:s,filtersConfig:t}),n=await I.getInstance({baseDbDir:e}),c=await n.get({key:a,namespace:w});if(c)return c;const r=await h.getInstance({baseDbDir:e}),p=[],d=new Map;for(const i of t)!i.options||i.options.length===0?p.push(i.property):d.set(i.property,i.options);const l=await r.getCatalogFilters({entitiesTypes:s,emptyFilters:p}),u={};for(const i of t){const f=d.get(i.property);if(!f){const o=l[i.property];u[i.property]=o&&o.length>0?o:[];continue}const y=(await r.getCatalogFilters({entitiesTypes:s,emptyFilters:[i.property]}))[i.property];if(!y){u[i.property]=[];continue}const g=new Map;for(const o of y){const m=o.value.toLowerCase().trim();g.set(m,{originalValue:o.value,count:o.count})}u[i.property]=f.map(o=>{const m=o.toLowerCase().trim(),S=g.get(m);return{value:S?.originalValue??o,count:S?.count??0}}).filter(o=>o.count>0).sort((o,m)=>o.value.localeCompare(m.value))}return await n.set({key:a,value:u,namespace:w,ttlInSeconds:D}),u},L=async(e,{props:s},t,{serverOutDir:a,getRouteSharedDataByFsPath:n})=>{const c=s?.catalogConfig||{};if(!e.params||!s?.catalogConfig)return{status:"notFound"};const[r,p,d]=e.params;if(!r)return{status:"notFound"};const l=O(c,r),u=l?.includes?.map(g=>g.type)??[];if(!l)return{status:"notFound"};if(!d&&p!=="entities"){if(l.hide)return{status:"notFound"};const g=await P({entitiesTypes:u,serverOutDir:a,filtersConfig:l.filters}),o=e.queries?.viewMode??"table";return{status:"success",catalogSwitcherItems:M(c,l),entitiesTypes:u,entities:await V({entitiesTypes:u,serverOutDir:a,catalogConfig:l,queries:e.queries}),catalogConfig:l,filters:g,initialViewMode:o}}const i=await _(d,a,e.queries),f=i?.entity.sourceFile,v=i?.entity.type==="api-description",y=f&&v&&n(f)||{};return i?{status:"success",entity:i.entity,relatedEntity:i.relatedEntity,relations:i.relations,entitiesCatalogConfig:c,catalogConfig:l,sharedDataIds:y}:{status:"notFound"}},O=(e,s)=>Object.values(e.catalogs??{}).find(t=>t&&typeof t=="object"&&"slug"in t&&t.slug===s),M=(e,s)=>Object.values(e.catalogs??{}).filter(t=>!t?.hide).map(t=>({labelTranslationKey:t?.catalogSwitcherLabelTranslationKey??t?.slug??"",slug:t?.slug??"",selected:t?.slug===s.slug})).sort((t,a)=>t.slug.localeCompare(a.slug)),k=(e,s)=>({op:"AND",conditions:[...e.length?[{field:"type",operator:"in",value:e}]:[],...s.length?[{field:"key",operator:"in",value:s,modifier:"not"}]:[]]}),q=(e,s,t)=>{let a=e;if(s!==void 0){const n={field:"version",operator:"equal",value:s};a=a?{op:C.AND,conditions:[a,n]}:n}if(t){const n={field:"revision",operator:"equal",value:t};a=a?{op:C.AND,conditions:[a,n]}:n}return a},K=["type","key","title","summary","tags","metadata","metadata.*","git","contact","links","id","source","sourceFile","createdAt","updatedAt"];var $=L;export{$ as default};
|
|
@@ -126,6 +126,9 @@ export declare const entityDatabaseSchema: {
|
|
|
126
126
|
readonly is_default_version: {
|
|
127
127
|
readonly type: readonly ["boolean", "null"];
|
|
128
128
|
};
|
|
129
|
+
readonly is_deleted: {
|
|
130
|
+
readonly type: readonly ["boolean", "null"];
|
|
131
|
+
};
|
|
129
132
|
};
|
|
130
133
|
readonly required: readonly ["id", "organization_id", "project_id", "key", "type", "title", "created_at", "updated_at", "source"];
|
|
131
134
|
readonly additionalProperties: false;
|
|
@@ -177,7 +180,68 @@ export declare const relatedEntityDatabaseSchema: {
|
|
|
177
180
|
readonly required: readonly ["id", "key", "title", "type", "source"];
|
|
178
181
|
readonly additionalProperties: false;
|
|
179
182
|
};
|
|
183
|
+
/**
|
|
184
|
+
* Schema for "query rows" coming from SQL/drizzle selects (joins/unions), normalized to a stable
|
|
185
|
+
* snake_case shape in mappers before validating.
|
|
186
|
+
*/
|
|
187
|
+
export declare const relatedEntityQueryRowDatabaseSchema: {
|
|
188
|
+
readonly type: "object";
|
|
189
|
+
readonly properties: {
|
|
190
|
+
readonly id: {
|
|
191
|
+
readonly type: "string";
|
|
192
|
+
readonly minLength: 1;
|
|
193
|
+
};
|
|
194
|
+
readonly key: {
|
|
195
|
+
readonly type: "string";
|
|
196
|
+
readonly minLength: 1;
|
|
197
|
+
};
|
|
198
|
+
readonly title: {
|
|
199
|
+
readonly type: "string";
|
|
200
|
+
readonly minLength: 1;
|
|
201
|
+
};
|
|
202
|
+
readonly type: {
|
|
203
|
+
readonly type: "string";
|
|
204
|
+
readonly minLength: 1;
|
|
205
|
+
};
|
|
206
|
+
readonly summary: {
|
|
207
|
+
readonly type: readonly ["string", "null"];
|
|
208
|
+
};
|
|
209
|
+
readonly source: {
|
|
210
|
+
readonly type: "string";
|
|
211
|
+
readonly minLength: 1;
|
|
212
|
+
};
|
|
213
|
+
readonly source_file: {
|
|
214
|
+
readonly type: readonly ["string", "null"];
|
|
215
|
+
};
|
|
216
|
+
readonly created_at: {
|
|
217
|
+
readonly type: readonly ["string", "null"];
|
|
218
|
+
};
|
|
219
|
+
readonly updated_at: {
|
|
220
|
+
readonly type: readonly ["string", "null"];
|
|
221
|
+
};
|
|
222
|
+
readonly metadata: {
|
|
223
|
+
readonly type: readonly ["string", "object", "null"];
|
|
224
|
+
};
|
|
225
|
+
readonly version: {
|
|
226
|
+
readonly type: readonly ["string", "null"];
|
|
227
|
+
};
|
|
228
|
+
readonly revision: {
|
|
229
|
+
readonly type: readonly ["string", "null"];
|
|
230
|
+
};
|
|
231
|
+
readonly direction: {
|
|
232
|
+
readonly type: "string";
|
|
233
|
+
readonly enum: readonly ["outgoing", "incoming"];
|
|
234
|
+
};
|
|
235
|
+
readonly relation_field: {
|
|
236
|
+
readonly type: "string";
|
|
237
|
+
readonly minLength: 1;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
readonly required: readonly ["id", "key", "title", "type", "source", "direction", "relation_field"];
|
|
241
|
+
readonly additionalProperties: false;
|
|
242
|
+
};
|
|
180
243
|
export type EntityRelationDto = FromSchema<typeof entityRelationDatabaseSchema>;
|
|
181
244
|
export type EntityDto = FromSchema<typeof entityDatabaseSchema>;
|
|
182
245
|
export type RelatedEntityDto = FromSchema<typeof relatedEntityDatabaseSchema>;
|
|
246
|
+
export type RelatedEntityQueryRowDto = FromSchema<typeof relatedEntityQueryRowDatabaseSchema>;
|
|
183
247
|
//# sourceMappingURL=database-schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ENTITY_RELATION_TYPES as t}from"@redocly/config";const
|
|
1
|
+
import{ENTITY_RELATION_TYPES as t}from"@redocly/config";const i={type:"object",properties:{id:{type:"string"},organization_id:{type:"string"},project_id:{type:"string"},source_key:{type:"string"},source_id:{type:["string","null"]},source_version:{type:["string","null"]},source_revision:{type:["string","null"]},source_to_target_relation:{type:"string"},target_key:{type:"string"},target_id:{type:["string","null"]},target_version:{type:["string","null"]},target_revision:{type:["string","null"]},target_to_source_relation:{type:"string"},source_file:{type:["string","null"]},file_hash:{type:["string","null"]},created_at:{type:"string"},updated_at:{type:"string"}},required:["id","organization_id","project_id","source_key","source_to_target_relation","target_key","target_to_source_relation","created_at","updated_at"],additionalProperties:!1},n={type:"object",properties:{id:{type:"string"},organization_id:{type:"string"},project_id:{type:"string"},key:{type:"string"},type:{type:"string"},title:{type:"string"},summary:{type:["string","null"]},tags:{type:["string","null"]},metadata:{type:["string","null"]},git:{type:["string","null"]},contact:{type:["string","null"]},links:{type:["string","null"]},created_at:{type:"string"},updated_at:{type:"string"},source:{type:"string"},source_file:{type:["string","null"]},file_hash:{type:["string","null"]},version:{type:["string","null"]},revision:{type:["string","null"]},hash:{type:["string","null"]},is_current:{type:["boolean","null"]},is_default_version:{type:["boolean","null"]},is_deleted:{type:["boolean","null"]}},required:["id","organization_id","project_id","key","type","title","created_at","updated_at","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"},relation_role:{type:["string","null"]},relation_type:{type:["string","null"],enum:t},source_file:{type:["string","null"]},created_at:{type:["string","null"]},updated_at:{type:["string","null"]},metadata:{type:["string","null"]},version:{type:["string","null"]}},required:["id","key","title","type","source"],additionalProperties:!1},s={type:"object",properties:{id:{type:"string",minLength:1},key:{type:"string",minLength:1},title:{type:"string",minLength:1},type:{type:"string",minLength:1},summary:{type:["string","null"]},source:{type:"string",minLength:1},source_file:{type:["string","null"]},created_at:{type:["string","null"]},updated_at:{type:["string","null"]},metadata:{type:["string","object","null"]},version:{type:["string","null"]},revision:{type:["string","null"]},direction:{type:"string",enum:["outgoing","incoming"]},relation_field:{type:"string",minLength:1}},required:["id","key","title","type","source","direction","relation_field"],additionalProperties:!1};export{n as entityDatabaseSchema,i as entityRelationDatabaseSchema,r as relatedEntityDatabaseSchema,s as relatedEntityQueryRowDatabaseSchema};
|
|
@@ -17,18 +17,12 @@ export declare const entityRelationDtoSchema: {
|
|
|
17
17
|
readonly minLength: 2;
|
|
18
18
|
readonly maxLength: 150;
|
|
19
19
|
};
|
|
20
|
-
readonly sourceId: {
|
|
21
|
-
readonly type: readonly ["string", "null"];
|
|
22
|
-
};
|
|
23
20
|
readonly sourceVersion: {
|
|
24
21
|
readonly type: readonly ["string", "null"];
|
|
25
22
|
};
|
|
26
23
|
readonly sourceRevision: {
|
|
27
24
|
readonly type: readonly ["string", "null"];
|
|
28
25
|
};
|
|
29
|
-
readonly targetId: {
|
|
30
|
-
readonly type: readonly ["string", "null"];
|
|
31
|
-
};
|
|
32
26
|
readonly targetVersion: {
|
|
33
27
|
readonly type: readonly ["string", "null"];
|
|
34
28
|
};
|
|
@@ -41,6 +35,9 @@ export declare const entityRelationDtoSchema: {
|
|
|
41
35
|
readonly fileHash: {
|
|
42
36
|
readonly type: readonly ["string", "null"];
|
|
43
37
|
};
|
|
38
|
+
readonly isDeleted: {
|
|
39
|
+
readonly type: readonly ["boolean", "null"];
|
|
40
|
+
};
|
|
44
41
|
};
|
|
45
42
|
readonly required: readonly ["type", "sourceKey", "targetKey"];
|
|
46
43
|
readonly additionalProperties: false;
|
|
@@ -64,18 +61,12 @@ export declare const entitiesRelationsDtoSchema: {
|
|
|
64
61
|
readonly minLength: 2;
|
|
65
62
|
readonly maxLength: 150;
|
|
66
63
|
};
|
|
67
|
-
readonly sourceId: {
|
|
68
|
-
readonly type: readonly ["string", "null"];
|
|
69
|
-
};
|
|
70
64
|
readonly sourceVersion: {
|
|
71
65
|
readonly type: readonly ["string", "null"];
|
|
72
66
|
};
|
|
73
67
|
readonly sourceRevision: {
|
|
74
68
|
readonly type: readonly ["string", "null"];
|
|
75
69
|
};
|
|
76
|
-
readonly targetId: {
|
|
77
|
-
readonly type: readonly ["string", "null"];
|
|
78
|
-
};
|
|
79
70
|
readonly targetVersion: {
|
|
80
71
|
readonly type: readonly ["string", "null"];
|
|
81
72
|
};
|
|
@@ -88,6 +79,9 @@ export declare const entitiesRelationsDtoSchema: {
|
|
|
88
79
|
readonly fileHash: {
|
|
89
80
|
readonly type: readonly ["string", "null"];
|
|
90
81
|
};
|
|
82
|
+
readonly isDeleted: {
|
|
83
|
+
readonly type: readonly ["boolean", "null"];
|
|
84
|
+
};
|
|
91
85
|
};
|
|
92
86
|
readonly required: readonly ["type", "sourceKey", "targetKey"];
|
|
93
87
|
readonly additionalProperties: false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ENTITY_RELATION_TYPES as e}from"@redocly/config";const t={type:"object",properties:{type:{type:"string",enum:e},sourceKey:{type:"string",minLength:2,maxLength:150},targetKey:{type:"string",minLength:2,maxLength:150},
|
|
1
|
+
import{ENTITY_RELATION_TYPES as e}from"@redocly/config";const t={type:"object",properties:{type:{type:"string",enum:e},sourceKey:{type:"string",minLength:2,maxLength:150},targetKey:{type:"string",minLength:2,maxLength:150},sourceVersion:{type:["string","null"]},sourceRevision:{type:["string","null"]},targetVersion:{type:["string","null"]},targetRevision:{type:["string","null"]},sourceFile:{type:["string","null"]},fileHash:{type:["string","null"]},isDeleted:{type:["boolean","null"]}},required:["type","sourceKey","targetKey"],additionalProperties:!1},i={type:"array",items:t};export{i as entitiesRelationsDtoSchema,t as entityRelationDtoSchema};
|
|
@@ -18,12 +18,6 @@ export declare const entityRelationReadModelSchema: {
|
|
|
18
18
|
readonly targetKey: {
|
|
19
19
|
readonly type: "string";
|
|
20
20
|
};
|
|
21
|
-
readonly sourceId: {
|
|
22
|
-
readonly type: "string";
|
|
23
|
-
};
|
|
24
|
-
readonly targetId: {
|
|
25
|
-
readonly type: "string";
|
|
26
|
-
};
|
|
27
21
|
readonly sourceVersion: {
|
|
28
22
|
readonly type: readonly ["string", "null"];
|
|
29
23
|
};
|
|
@@ -46,7 +40,7 @@ export declare const entityRelationReadModelSchema: {
|
|
|
46
40
|
readonly type: readonly ["string", "null"];
|
|
47
41
|
};
|
|
48
42
|
};
|
|
49
|
-
readonly required: readonly ["id", "organizationId", "projectId", "sourceKey", "targetKey", "
|
|
43
|
+
readonly required: readonly ["id", "organizationId", "projectId", "sourceKey", "targetKey", "type"];
|
|
50
44
|
readonly additionalProperties: false;
|
|
51
45
|
};
|
|
52
46
|
export declare const entityReadModelSchema: {
|
|
@@ -173,14 +167,16 @@ export type EntityReadModelSchema = {
|
|
|
173
167
|
source: string;
|
|
174
168
|
sourceFile?: string | null;
|
|
175
169
|
version?: string | null;
|
|
176
|
-
revision
|
|
170
|
+
revision: string;
|
|
177
171
|
hash?: string | null;
|
|
178
172
|
isCurrent?: boolean | null;
|
|
179
173
|
isDefaultVersion?: boolean | null;
|
|
174
|
+
isDeleted?: boolean | null;
|
|
180
175
|
createdAt?: string | null;
|
|
181
176
|
updatedAt?: string | null;
|
|
182
177
|
object: 'catalogEntity';
|
|
183
178
|
domains?: RelatedEntitySchema[];
|
|
184
179
|
owners?: RelatedEntitySchema[];
|
|
185
180
|
};
|
|
181
|
+
export type EntityRevisionSummary = Pick<EntityReadModelSchema, 'version' | 'revision' | 'isCurrent' | 'createdAt' | 'updatedAt' | 'isDefaultVersion' | 'isDeleted'>;
|
|
186
182
|
//# sourceMappingURL=read-model-schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t={type:"object",properties:{id:{type:"string"},organizationId:{type:"string"},projectId:{type:"string"},sourceKey:{type:"string"},targetKey:{type:"string"},
|
|
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
|
-
const i="error";class
|
|
1
|
+
const i="error";class n{#t=new Set;#e;#s;#i=0;#o=0;addExtractor(t){this.#t.add(t)}increaseSkippedFilesCount(){this.#i++}increaseProcessedFilesCount(){this.#o++}async getCatalogEntitiesData(t){this.#e=this.#a(t),this.#s=this.#n(t);const[s,e]=await Promise.allSettled([this.#e,this.#s]);return{totalEntitiesCount:s.status==="fulfilled"?s.value:i,countOfEntitiesByType:e.status==="fulfilled"?e.value:i,extractors:Array.from(this.#t),totalFilesSkippedByHash:this.#i,totalProcessedFiles:this.#o}}async#a(t){return(await t.getEntities({limit:1,filter:{field:"is_deleted",operator:"equal",value:!1}})).page.total}async#n(t){return(await t.getEntitiesCountByTypes()).reduce((e,{type:o,count:a})=>(e[o]=a,e),{})}}const r=new n;export{n as CatalogDataCollector,r as catalogDataCollector};
|