@redocly/realm 0.131.0-next.5 → 0.131.0-next.7
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 +50 -0
- package/dist/cli/stats/collectors/openapi.js +1 -1
- package/dist/cli/telemetry/index.js +1 -1
- package/dist/client/App.js +1 -1
- package/dist/client/app/hooks/useAutoScroll.js +1 -1
- package/dist/client/app/hooks/utils/pathname-matches-active-section.d.ts +6 -0
- package/dist/client/app/hooks/utils/pathname-matches-active-section.js +1 -0
- package/dist/client/app/markdoc/custom-components/html-script.js +1 -0
- package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.js +1 -0
- package/dist/client/app/markdoc/custom-components/openapi/openapi-response-sample.js +1 -0
- package/dist/client/app/markdoc/custom-components/openapi/replay-openapi.js +1 -0
- package/dist/client/app/markdoc/hooks/use-store.js +1 -0
- package/dist/{server/plugins/asyncapi-docs/template → client/templates/asyncapi-docs}/helpers.d.ts +3 -3
- package/dist/client/templates/asyncapi-docs/helpers.js +1 -0
- package/dist/{server/plugins/asyncapi-docs/template/AsyncApiDocs.d.ts → client/templates/asyncapi-docs/template.d.ts} +1 -1
- package/dist/client/templates/asyncapi-docs/template.js +11 -0
- package/dist/client/templates/openapi-docs/helpers.js +5 -0
- package/dist/{server/plugins/openapi-docs/template/OpenAPIDocs.d.ts → client/templates/openapi-docs/template.d.ts} +1 -1
- package/dist/{server/plugins/openapi-docs/template/OpenAPIDocs.js → client/templates/openapi-docs/template.js} +1 -1
- package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/get-inner-text.d.ts +1 -1
- package/dist/markdoc/helpers/get-inner-text.js +2 -0
- package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/get-variable.d.ts +2 -2
- package/dist/markdoc/helpers/get-variable.js +1 -0
- package/dist/markdoc/nodes/fence/index.js +1 -0
- package/dist/markdoc/nodes/heading.js +1 -0
- package/dist/{server/plugins/markdown/markdoc → markdoc}/tags/index.d.ts +6 -6
- package/dist/markdoc/tags/json-example.d.ts +3 -0
- package/dist/markdoc/tags/json-schema.d.ts +3 -0
- package/dist/markdoc/tags/openapi-code-sample.d.ts +3 -0
- package/dist/markdoc/tags/openapi-example.d.ts +3 -0
- package/dist/markdoc/tags/openapi-response-sample.d.ts +3 -0
- package/dist/markdoc/tags/replay-openapi.d.ts +3 -0
- package/dist/markdoc/types.d.ts +8 -0
- package/dist/markdoc/types.js +0 -0
- package/dist/server/config/env-schema.d.ts +6 -3
- package/dist/server/config/env-schemas/database.d.ts +1 -1
- package/dist/server/config/env-schemas/database.js +1 -1
- package/dist/server/config/env-schemas/organization-project.d.ts +3 -0
- package/dist/server/config/env-schemas/organization-project.js +1 -1
- package/dist/server/plugins/asyncapi-docs/index.js +1 -1
- package/dist/server/plugins/catalog-entities/database/repositories/local/catalog-entities-local-repository.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.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/graphql-entities-extractor.js +1 -1
- package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/openapi-entities-extractor.js +1 -1
- 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-html-href.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-html-source-attribute.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-image-src-set.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-image-src.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-json-example-ref.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-json-schema-ref.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-link.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-native-md-link.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-nav-links.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-relative-or-cdn-icon.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-relative-path.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-sample-from-json-schema.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-svg-content.js +1 -1
- package/dist/server/plugins/markdown/markdoc/markdoc-options.js +1 -1
- package/dist/server/plugins/markdown/markdoc/partials.js +1 -1
- package/dist/server/plugins/markdown/markdoc/plugins/headings.js +1 -1
- package/dist/server/plugins/markdown/markdoc/plugins/utils.js +1 -1
- package/dist/server/plugins/markdown/runtime-transform.js +1 -1
- package/dist/server/plugins/markdown/search/get-ai-search-documents.js +1 -1
- package/dist/server/plugins/markdown/search/get-search-documents.js +2 -2
- package/dist/server/plugins/markdown/search/nodes/section-node.js +1 -1
- package/dist/server/plugins/markdown/search/search-resolver.js +1 -1
- package/dist/server/plugins/markdown/search/to-markdown.js +1 -1
- package/dist/server/plugins/markdown/search/walk-sections.js +1 -1
- package/dist/server/plugins/markdown/utils/stringify-tag-children-objects.js +1 -1
- package/dist/server/plugins/openapi-docs/index.js +1 -1
- package/dist/server/plugins/openapi-docs/search-indexer.js +1 -1
- package/dist/server/plugins/scorecard-classic/lint.js +1 -1
- package/dist/server/plugins/scorecards/database/scorecards-config-service.js +1 -1
- package/dist/server/plugins/sidebars/index.js +2 -2
- package/dist/server/ssr/render.js +1 -1
- package/dist/server/store.js +1 -1
- package/dist/server/telemetry/index.js +1 -1
- package/dist/server/types/plugins/markdown.d.ts +0 -7
- package/dist/server/utils/fs.js +1 -1
- package/dist/server/utils/index.d.ts +2 -2
- package/dist/server/utils/index.js +1 -1
- package/dist/{server/utils → utils}/slugger.d.ts +13 -0
- package/package.json +6 -6
- package/dist/server/plugins/asyncapi-docs/template/AsyncApiDocs.js +0 -11
- package/dist/server/plugins/asyncapi-docs/template/helpers.js +0 -1
- package/dist/server/plugins/markdown/markdoc/custom-components/html-script.js +0 -1
- package/dist/server/plugins/markdown/markdoc/custom-components/openapi/openapi-code-sample.js +0 -1
- package/dist/server/plugins/markdown/markdoc/custom-components/openapi/openapi-response-sample.js +0 -1
- package/dist/server/plugins/markdown/markdoc/custom-components/openapi/replay-openapi.js +0 -1
- package/dist/server/plugins/markdown/markdoc/helpers/get-inner-text.js +0 -2
- package/dist/server/plugins/markdown/markdoc/helpers/get-variable.js +0 -1
- package/dist/server/plugins/markdown/markdoc/hooks/use-store.js +0 -1
- package/dist/server/plugins/markdown/markdoc/nodes/fence/index.js +0 -1
- package/dist/server/plugins/markdown/markdoc/nodes/heading.js +0 -1
- package/dist/server/plugins/markdown/markdoc/tags/json-example.d.ts +0 -3
- package/dist/server/plugins/markdown/markdoc/tags/json-schema.d.ts +0 -3
- package/dist/server/plugins/markdown/markdoc/tags/openapi-code-sample.d.ts +0 -3
- package/dist/server/plugins/markdown/markdoc/tags/openapi-example.d.ts +0 -3
- package/dist/server/plugins/markdown/markdoc/tags/openapi-response-sample.d.ts +0 -3
- package/dist/server/plugins/markdown/markdoc/tags/replay-openapi.d.ts +0 -3
- package/dist/server/plugins/openapi-docs/template/helpers.js +0 -5
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/html-script.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/index.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/index.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/explain-step.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/explain-step.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/get-operation-info-by-id.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/get-operation-info-by-id.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/get-operation-info-by-pointer.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/get-operation-info-by-pointer.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/get-operation.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/get-operation.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/index.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/index.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/types/index.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/types/index.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/types/operation-identifier.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/types/operation-identifier.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/types/operation-info.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/types/operation-info.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/types/operation-parameters.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/get-operation/types/operation-parameters.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/index.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/index.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/json-example.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/json-example.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/json-schema.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/json-schema.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/openapi-code-sample.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/openapi-example.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/openapi-example.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/openapi-response-sample.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/replay-openapi.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/step-by-step-wrapper.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/openapi/step-by-step-wrapper.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/styled.elements.d.ts +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/custom-components/styled.elements.js +0 -0
- /package/dist/{server/plugins/markdown → client/app}/markdoc/hooks/use-store.d.ts +0 -0
- /package/dist/{server/plugins/openapi-docs/template → client/templates/openapi-docs}/helpers.d.ts +0 -0
- /package/dist/{server/plugins/openapi-docs/template → client/templates/openapi-docs}/mock-server-config.d.ts +0 -0
- /package/dist/{server/plugins/openapi-docs/template → client/templates/openapi-docs}/mock-server-config.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/definition-path.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/definition-path.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/index.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/index.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/json-example-ref.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/json-example-ref.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/json-schema-ref.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/json-schema-ref.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/parsed-yaml.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/parsed-yaml.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/raw-content.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/raw-content.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/sample-from-json-schema.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/attributes/sample-from-json-schema.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/extract-rbac-from-condition-node.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/extract-rbac-from-condition-node.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/get-node-attribute.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/get-node-attribute.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-code-node.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-code-node.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-conditional-node.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-conditional-node.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-content-node.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-content-node.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-example-node.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-example-node.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-fence-node.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-fence-node.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-function.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-function.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-list-node.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-list-node.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-node.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-node.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-string-node.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-string-node.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-tag.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-tag.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-text-node.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-text-node.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-variable.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/guards/is-variable.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/remove-markdoc-tags.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/remove-markdoc-tags.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/set-node-attribute-value.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/helpers/set-node-attribute-value.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/nodes/fence/escape-html.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/nodes/fence/escape-html.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/nodes/fence/index.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/nodes/gfm-list-item.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/nodes/gfm-list-item.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/nodes/heading.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/nodes/index.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/nodes/index.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/nodes/table.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/nodes/table.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/nodes/text.d.ts +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/nodes/text.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/tags/index.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/tags/json-example.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/tags/json-schema.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/tags/openapi-code-sample.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/tags/openapi-example.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/tags/openapi-response-sample.js +0 -0
- /package/dist/{server/plugins/markdown/markdoc → markdoc}/tags/replay-openapi.js +0 -0
- /package/dist/{server/utils → utils}/conflict-resolvers.d.ts +0 -0
- /package/dist/{server/utils → utils}/conflict-resolvers.js +0 -0
- /package/dist/{server/utils → utils}/slugger.js +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{buildSchema as O,isObjectType as T,isScalarType as D,isEnumType as v,isInterfaceType as w,isUnionType as E,isInputObjectType as b,getNamedType as u,printType as L}from"graphql";import{removeLeadingSlash as A}from"@redocly/theme/core/utils";import{toKebabCase as g}from"../../../../../../utils/string/to-kebab-case.js";import{capitalize as j}from"../../../../../../utils/string/capitalize.js";import{promiseMapLimit as d}from"../../../../../utils/async/promise-map-limit.js";import{promiseMapLimitWithStatus as $}from"../../../../../utils/async/promise-map-limit-with-status.js";import{sha1 as K}from"../../../../../utils/crypto/sha1.js";import{removeMarkdocTags as F}from"
|
|
1
|
+
import{buildSchema as O,isObjectType as T,isScalarType as D,isEnumType as v,isInterfaceType as w,isUnionType as E,isInputObjectType as b,getNamedType as u,printType as L}from"graphql";import{removeLeadingSlash as A}from"@redocly/theme/core/utils";import{toKebabCase as g}from"../../../../../../utils/string/to-kebab-case.js";import{capitalize as j}from"../../../../../../utils/string/capitalize.js";import{promiseMapLimit as d}from"../../../../../utils/async/promise-map-limit.js";import{promiseMapLimitWithStatus as $}from"../../../../../utils/async/promise-map-limit-with-status.js";import{sha1 as K}from"../../../../../utils/crypto/sha1.js";import{removeMarkdocTags as F}from"../../../../../../markdoc/helpers/remove-markdoc-tags.js";import{BaseApiEntitiesExtractor as N}from"./base.js";const R=15,I=15,P=new Set(["String","ID","Int","Float","Boolean","DateTime","Date","Time","URL","URI","JSON","JSONObject","BigInt","BigDecimal"]);class U 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:i,metadata:r}=a.data,s=O(i),n=K(i);t.push({realRelativePath:e,relativePath:e,isVirtual:!1,hash:n,schema:s,content:i,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=A(t.realRelativePath),i=t.relativePath.replace(/\.(gql|graphql)$/,""),r=this.#s(i.split("/").pop()||"GraphQL Schema"),s=a.replace(/\.(gql|graphql)$/,""),n=g(s.replace(/[\\/]/g,"-")),p=this.#c(t.metadata?.tags),o=t.metadata?.["x-redocly-catalog-key"],l=typeof o=="string"&&o.trim()?g(o.trim()):n;return{type:this.type,key:l,title:r,summary:t.metadata?.description||null,tags:p.concat("graphql"),metadata:{specType:this.specType,descriptionFile:a},version:e}}async processApiDescription(t,e,a,i){const{schema:r}=t;if(!r)return;const s=this.getRbacTeamsForDefinition(t.relativePath),n=this.mapApiDescriptionToEntity(t,a);await this.catalogEntitiesService.createEntityInLocalDatabase({entity:n,sourceFile:t.realRelativePath,fileHash:t.hash,isRootEntity:!0,revision:e,rbacTeams:s}),i.delete(`${n.key}:${a}`),await Promise.all([this.#a(t,n.key,n.version,a,e,i,s),this.#y(t,n.key,n.version,a,e,i,s)])}#a=async(t,e,a,i,r,s,n)=>{const{schema:p}=t,o=p.getTypeMap(),l=this.#i(p),c=Object.entries(o).filter(([y])=>!y.startsWith("__")&&!P.has(y)&&!l.has(y));if(c.length===0)return;const h=await $(c,I,async([y,m])=>{const f=await this.#l({typeName:y,type:m,description:t,parentKey:e,parentVersion:a,parentRevision:r,rbacTeams:n});s.delete(`${f.entityKey}:${i}`),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);h.count.failed>0&&this.#t.warn(`Schema processing completed with ${h.count.failed} failures out of ${c.length} types for ${t.realRelativePath}`),await this.#h({description:t,descriptionUniqueKey:e,userTypes:c,parentRevision:r})};#s=t=>{const e=t.replace(/[^A-Za-z0-9]+/g," ").trim();return e?e.split(" ").map(a=>a&&j(a)).join(" "):"GraphQL Schema"};#e=(t,e)=>`${e}-${g(t)}`;#n=t=>T(t)?"object":w(t)?"interface":E(t)?"union":v(t)?"enum":b(t)?"input":D(t)?"scalar":"unknown";#i=t=>{const e=new Set,a=t.getQueryType();a&&e.add(a.name);const i=t.getMutationType();i&&e.add(i.name);const r=t.getSubscriptionType();return r&&e.add(r.name),e};#r(t){const e=[],a=t.getQueryType();if(a){const s=a.getFields();for(const[n,p]of Object.entries(s))e.push({fieldName:n,field:p,operationType:"QUERY",rootTypeName:a.name})}const i=t.getMutationType();if(i){const s=i.getFields();for(const[n,p]of Object.entries(s))e.push({fieldName:n,field:p,operationType:"MUTATION",rootTypeName:i.name})}const r=t.getSubscriptionType();if(r){const s=r.getFields();for(const[n,p]of Object.entries(s))e.push({fieldName:n,field:p,operationType:"SUBSCRIBE",rootTypeName:r.name})}return e}#o=(t,e)=>{const a=[];if(t.args)for(const s of t.args){const n=u(s.type);n&&!n.name.startsWith("__")&&a.push(this.#e(n.name,e))}const i=[],r=u(t.type);return r&&!r.name.startsWith("__")&&i.push(this.#e(r.name,e)),{inputTypes:a,returnTypes:i}};#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:i,parentVersion:r,parentRevision:s,rbacTeams:n})=>{const p=this.#e(t,i),o=e.description??null,l=this.#n(e),c={type:"data-schema",key:p,title:t,summary:o,tags:["graphql"],metadata:{specType:this.specType,typeKind:l,sdl:this.#p(e,a.schema)},version:r};return await this.catalogEntitiesService.createEntityInLocalDatabase({entity:c,sourceFile:a.realRelativePath,fileHash:a.hash,revision:s,rbacTeams:n})};#p=(t,e)=>{const a=new Set,i=[],r=new Set(["String","ID","Int","Float","Boolean"]),s=o=>{if(!o)return;const l=o.name;if(l.startsWith("__")||r.has(l)||a.has(l))return;const c=e.getType(l);c&&(a.add(l),i.push(c))};for(s(t);i.length>0;){const o=i.pop();if(T(o)){for(const c of o.getInterfaces?.()??[])s(c);const l=o.getFields();for(const c of Object.values(l)){s(u(c.type));for(const h of c.args??[])s(u(h.type))}}else if(w(o)){const l=o.getFields();for(const c of Object.values(l))s(u(c.type))}else if(E(o))for(const l of o.getTypes())s(l);else if(b(o)){const l=o.getFields();for(const c of Object.values(l))s(u(c.type))}}const n=[t.name,...[...a].filter(o=>o!==t.name)],p=[];for(const o of n){const l=e.getType(o);l&&p.push(L(l))}return p.join(`
|
|
2
2
|
|
|
3
3
|
`)};#h=async({description:t,descriptionUniqueKey:e,userTypes:a,parentRevision:i})=>{const r=a.filter(([,s])=>T(s));r.length!==0&&await d(r,I,async([s,n])=>{const o=n.getInterfaces?.()??[];if(!o.length)return;const l=this.#e(s,e);await d([...o],5,async c=>{const h=this.#e(c.name,e);try{await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:l,type:"implements",targetKey:h,fileHash:t.hash,sourceRevision:i,targetRevision:i})}catch(y){this.#t.warn(`Failed to create 'implements' relation ${l} -> ${h}: ${y instanceof Error?y.message:"Unknown error"}`)}})})};#y=async(t,e,a,i,r,s,n)=>{const{schema:p}=t,o=this.#r(p);if(o.length===0)return;const c=(await $(o,R,async({fieldName:h,field:y,operationType:m,rootTypeName:f})=>{const S=await this.#f(h,y,m,f,t,e,a,r,n);S&&s.delete(`${S}:${i}`)},this.#t)).count.failed;c>0&&this.#t.warn(`Operation extraction completed with ${c} failures out of ${o.length} operations for ${e}`)};#f=async(t,e,a,i,r,s,n,p,o)=>{const{inputTypes:l,returnTypes:c}=this.#o(e,s),h=await this.#u({fieldName:t,field:e,operationType:a,rootTypeName:i,inputTypes:l,returnTypes:c,description:r,descriptionUniqueKey:s,descriptionVersion:n,parentRevision:p,rbacTeams:o});return h.result==="created"&&await this.#m({apiOperationKey:h.entityKey,inputTypes:l,returnTypes:c,descriptionUniqueKey:s,description:r,descriptionVersion:n,parentRevision:p}),h.entityKey??null};#u=async({fieldName:t,field:e,operationType:a,rootTypeName:i,inputTypes:r,returnTypes:s,description:n,descriptionUniqueKey:p,descriptionVersion:o,parentRevision:l,rbacTeams:c})=>{const h=t,m={type:"api-operation",key:`${p}-${g(`${a.toLowerCase()}-${t}`)}`,title:h,summary:e.description?F(e.description):null,tags:["graphql"],metadata:{method:a,path:`${i}.${t}`,payload:r,responses:s},version:o};return await this.catalogEntitiesService.createEntityInLocalDatabase({entity:m,sourceFile:n.realRelativePath,fileHash:n.hash,revision:l,rbacTeams:c})};#m=async({apiOperationKey:t,inputTypes:e,returnTypes:a,descriptionUniqueKey:i,description:r,descriptionVersion:s,parentRevision:n})=>{await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:t,type:"partOf",targetKey:i,fileHash:r.hash,sourceVersion:s,targetVersion:s,sourceRevision:n,targetRevision:n});const p=[...new Set(e)],o=[...new Set(a)],l=[...p.map(c=>({key:c,relationType:"uses"})),...o.map(c=>({key:c,relationType:"returns"}))];await d(l,R,async({key:c,relationType:h})=>{try{await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:t,type:h,targetKey:c,fileHash:r.hash,sourceVersion:s,targetVersion:s,sourceRevision:n,targetRevision:n})}catch(y){this.#t.warn(`Failed to create relation between operation ${t} and type ${c} (${h}): ${y instanceof Error?y.message:"Unknown error"}`)}})}}export{U as GraphqlEntitiesExtractor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as $}from"@redocly/config";import{removeLeadingSlash as x}from"@redocly/theme/core/utils";import{toKebabCase as p}from"../../../../../../utils/string/to-kebab-case.js";import{promiseMapLimit as E}from"../../../../../utils/async/promise-map-limit.js";import{promiseMapLimitWithStatus as T}from"../../../../../utils/async/promise-map-limit-with-status.js";import{extractTeamsFromScopeItems as R}from"../../../../../utils/rbac.js";import{removeMarkdocTags as w}from"
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as $}from"@redocly/config";import{removeLeadingSlash as x}from"@redocly/theme/core/utils";import{toKebabCase as p}from"../../../../../../utils/string/to-kebab-case.js";import{promiseMapLimit as E}from"../../../../../utils/async/promise-map-limit.js";import{promiseMapLimitWithStatus as T}from"../../../../../utils/async/promise-map-limit-with-status.js";import{extractTeamsFromScopeItems as R}from"../../../../../utils/rbac.js";import{removeMarkdocTags as w}from"../../../../../../markdoc/helpers/remove-markdoc-tags.js";import{BaseApiEntitiesExtractor as N}from"./base.js";import{OpenapiSchemaResolver as S}from"../../../utils/openapi-schema-resolver.js";import{extractPartsFromComponentsRef as v}from"../../../utils/extract-parts-from-components-ref.js";import{isValidTagName as O}from"../../../utils/is-valid-tag-name.js";const A=["get","post","put","delete","patch"],b=15,d=15;class _ extends N{#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=x(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:w(e.definition.info.description),tags:e.definition.tags?.filter(c=>c.name&&O(c.name)).map(c=>c.name),metadata:{specType:this.specType,descriptionFile:s},version:o}}async processApiDescription(e,o,s,n){if(S.clearSchemaCache(),!e?.definition?.paths)return;const t=this.getRbacTeamsForDefinition(e.relativePath),a=this.mapApiDescriptionToEntity(e,s);await this.catalogEntitiesService.createEntityInLocalDatabase({entity:a,sourceFile:e.realRelativePath,fileHash:e.hash,isRootEntity:!0,revision:o,rbacTeams:t}),n.delete(`${a.key}:${s}`),await this.#n(e,a.key,a.version,s,o,n,t);const r=this.#s(e.definition.paths);if(r.length!==0){const c=(await T(r,b,async({operation:h,path:m,method:l})=>{if(!h.operationId)return;const f=await this.#r(h,m,l,e,a.key,a.version,o,t);f&&n.delete(`${f}:${s}`)},this.#e)).count.failed;c>0&&this.#e.warn(`Extraction completed with ${c} failures out of ${r.length} operations for ${a.key}`)}}#s(e){return Object.entries(e).flatMap(([o,s])=>A.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,r){const i=e.definition.components?.schemas;if(!i)return;const c=Object.entries(i);c.length!==0&&await E(c,d,async([h,m])=>{const l=await this.#o({schemaName:h,schema:m,description:e,parentKey:o,parentVersion:s,parentRevision:t,rbacTeams:r});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,rbacTeams:r}){const i=S.resolveSchemaRefs(o,s),c=JSON.stringify(i),h=i[$]?R(i[$]):r,m=R(i["x-rbac"]),l={type:"data-schema",key:`${n}-${p(e)}`,title:e,summary:i.description??i.title??null,tags:[],metadata:{specType:this.specType,schema:c},version:t};return await this.catalogEntitiesService.createEntityInLocalDatabase({entity:l,sourceFile:s.realRelativePath,fileHash:s.hash,revision:a,rbacTeams:m.length?m:h})}async#r(e,o,s,n,t,a,r,i){const c=await Promise.all([this.#m(e.requestBody??null,n),this.#h(e.responses??{},n)]),h=c[0].schemaNames,m=c[1].schemaNames;c[0].errors.length>0&&this.#e.warn(`Schema extraction errors for operation ${e.operationId}: ${c[0].errors.join(", ")}`),c[1].errors.length>0&&this.#e.warn(`Response schema extraction errors for operation ${e.operationId}: ${c[1].errors.join(", ")}`);const l=h.map(g=>`${t}-${p(g)}`),f=m.map(g=>`${t}-${p(g)}`),y=await this.#p({path:o,method:s,operation:e,requestBodySchemasKeys:l,responseSchemasKeys:f,description:n,parentKey:t,parentVersion:a,parentRevision:r,rbacTeams:i});return y.result==="created"&&await Promise.all([this.#i(h,e.operationId??"",n.hash,t,a,r),this.#c(m,e.operationId??"",n.hash,t,a,r),this.#f({apiOperationKey:y.entityKey,operationRelations:e["x-catalog-relations"],descriptionUniqueKey:t,description:n,parentVersion:a,parentRevision:r})]),y.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)}#m(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}}#h(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 v(e)}catch{return{componentType:"",componentName:null}}}async#a(e,o,s,n,t,a){return e.length===0?[]:await E(e,d,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,rbacTeams:h}){const m=`${s.operationId}`,l=`${r}-${p(m)}`,f=s[$]?R(s[$]):h,y=R(s["x-rbac"]),g={type:"api-operation",key:l,title:m,summary:w(s.summary),tags:s.tags?.filter(u=>O(u)),metadata:{path:e,method:o,payload:n,responses:t},version:i};try{return await this.catalogEntitiesService.createEntityInLocalDatabase({entity:g,sourceFile:a.realRelativePath,fileHash:a.hash,revision:c,rbacTeams:y.length>0?y:f})}catch(u){throw this.#e.error(`Failed to create API operation entity for ${m}: ${u instanceof Error?u.message:"Unknown error"}`),u}}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 E(o,b,async t=>{try{this.validateEntityRelationFileSchema(t),await this.catalogEntitiesService.createEntityRelationInLocalDatabase({sourceKey:e,type:t.type,targetKey:t.key,sourceVersion:s,targetVersion:"",sourceRevision:n,targetRevision:""})}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{_ as OpenApiEntitiesExtractor};
|
package/dist/server/plugins/markdown/attribute-resolvers/code-walkthrough/filesets-resolver.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import c from"node:path";import v from"is-glob";import m from"picomatch";import{
|
|
1
|
+
import c from"node:path";import v from"is-glob";import m from"picomatch";import{getNodeAttribute as h}from"../../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as d}from"../../../../../markdoc/helpers/set-node-attribute-value.js";import{parseFileChunks as b}from"./file-chunk-parser.js";import{readFileContent as g}from"../../read-file-content.js";import{resolvePathInMarkdown as x}from"../../resolve-path-in-markdown.js";import{removeL10nPrefix as P}from"../../../../fs/utils/remove-l10n-prefix.js";import{mapFileExtensionToLanguage as k}from"./map-file-extension-to-language.js";async function V(a,f,p,u){const{actions:{contentDir:F},context:{fs:i}}=u,n=h(a,f);if(!Array.isArray(n))d(a,"resolvedFilesets",[]);else{const w=await Promise.all(n.map(async e=>{const s=Array.isArray(e.files)?e.files:[],o=Array.isArray(e.downloadAssociatedFiles)?e.downloadAssociatedFiles:[],r=await Promise.all(s.map(l)),t=await Promise.all(o.map(l));return{...e,files:r.flat(),downloadAssociatedFiles:t.flat()}}));d(a,"resolvedFilesets",w.filter(e=>!!e));async function l(e){const s=x(e,P(p),F),o=await A(s);return(await Promise.all(o.map(y))).filter(t=>t!==null)}async function A(e){if(!v(e))return[e];const{base:s}=m.scan(e);return i.scan(new RegExp(s)).filter(({isVirtual:t})=>!t).map(({realRelativePath:t})=>t).filter(t=>m(e)(t))}async function y(e){const s=await g(e,i);if(s==null)return null;const{root:o,metadata:r}=await b(s,e);return{path:e,content:o,metadata:r,basename:c.basename(e),language:k(c.extname(e))}}}}export{V as resolveCodeWalkthroughFilesets};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import c from"node:path";import{slash as L}from"../../../../utils/path/slash.js";import{reporter as F}from"../../../tools/notifiers/reporter.js";import{getNodeAttribute as n}from"
|
|
1
|
+
import c from"node:path";import{slash as L}from"../../../../utils/path/slash.js";import{reporter as F}from"../../../tools/notifiers/reporter.js";import{getNodeAttribute as n}from"../../../../markdoc/helpers/get-node-attribute.js";import{MdResolveError as h}from"./md-resolve-error.js";async function V(i,w,b,{actions:{contentDir:m},context:u}){const o=n(i,w);if(!o)return;const r=o.startsWith("/")?o.slice(1):L(c.relative(m,c.resolve(m,c.dirname(b),o)));if(!u.fs.exists(r)){await F.panicOnBuildContentError(`Code snippet file ${r} does not exist`);return}let e=await u.fs.read(r);const d=n(i,"after"),p=n(i,"before"),y=n(i,"from"),C=n(i,"to"),v=n(i,"prefix")||"",s=y??d,f=C??p,g=d!==null,x=p!==null,E=(typeof s=="number"?Math.max(s||0,1):1)+(g?1:0);let a=(typeof f=="number"?f:1/0)-(x?1:0);if(typeof s=="string"){let t=e.indexOf(s);if(t===-1)throw new h(`Cannot find start text "${s}" in snippet file`,{rawLink:r});for(;e[t]!==`
|
|
2
2
|
`&&t>0;)t--;typeof a=="number"&&(a-=e.slice(0,t-1).split(`
|
|
3
3
|
`).length),e=e.slice(t+1)}if(typeof f=="string"){let t=e.indexOf(f);if(t===-1)throw new h(`Cannot find end text "${p}" in snippet file`,{rawLink:r});e[t-1]===`
|
|
4
4
|
`&&t--,e=e.slice(0,t)}const l=e.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{withPathPrefix as m,withoutPathPrefix as p}from"@redocly/theme/core/utils";import{isLocalLink as u}from"../../../../utils/path/is-local-link.js";import{getNodeAttribute as s}from"
|
|
1
|
+
import{withPathPrefix as m,withoutPathPrefix as p}from"@redocly/theme/core/utils";import{isLocalLink as u}from"../../../../utils/path/is-local-link.js";import{getNodeAttribute as s}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as l}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{resolveLink as a}from"./resolve-link.js";async function H(r,t="href",n,c){const i=s(r,"attrs")||{},e=i[t];if(!e)return;const h=p(e);l(r,t,h),await a(r,t,n,c);const o=s(r,t);if(delete r.attributes[t],!o)return;let f=o;!o.startsWith("#")&&u(o)&&(f=m(o)),l(r,"attrs",{...i,[t]:f})}export{H as resolveHtmlHref};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import S from"node:path";import{normalizeRouteSlug as v}from"../../../../utils/path/normalize-route-slug.js";import{reporter as a}from"../../../tools/notifiers/reporter.js";import{getNodeAttribute as m}from"
|
|
1
|
+
import S from"node:path";import{normalizeRouteSlug as v}from"../../../../utils/path/normalize-route-slug.js";import{reporter as a}from"../../../tools/notifiers/reporter.js";import{getNodeAttribute as m}from"../../../../markdoc/helpers/get-node-attribute.js";import{FileNotFoundError as u,resolveAssetPath as w,resolveSrcSet as h}from"../../../utils/index.js";import{MdResolveError as $}from"./md-resolve-error.js";import{getLinkOriginalAttrName as A}from"./utils.js";async function B(e,o,s,{actions:{contentDir:n,outdir:l,getRouteBySlug:p},context:c}){const i=m(e,"attrs")?.[o],g=m(e,"name");if(!i)return;const f=A(o),t=e[f]||i;if(!(g==="iframe"&&p(v(t)))){if(e[f]=t,o==="src"){if(!S.extname(t))return;try{const r=await w(t,c.fs,{fromFileRelativePath:s,contentDir:n,outdir:l});e.attributes.attrs[o]=r}catch(r){if(r instanceof u)throw new $(`File ${t} does not exist`,{rawLink:t,link:t});await a.panicOnBuild(`Cannot resolve %rp: ${r.message}`,t)}}if(o==="srcSet")try{const r=await h(i,c.fs,{fromFileRelativePath:s,contentDir:n,outdir:l});e.attributes.attrs[o]=r}catch(r){r instanceof u?await a.panicOnBuildContentError(`Cannot resolve 'srcSet' attribute: ${i}: ${r.message}`):await a.panicOnBuild(`Cannot resolve 'srcSet' attribute: ${i}: ${r.message}`)}}}export{B as resolveHtmlSourceAttribute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{reporter as c}from"../../../tools/notifiers/reporter.js";import{getNodeAttribute as a}from"
|
|
1
|
+
import{reporter as c}from"../../../tools/notifiers/reporter.js";import{getNodeAttribute as a}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as m}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{FileNotFoundError as p,resolveSrcSet as u}from"../../../utils/index.js";import{getLinkOriginalAttrName as g}from"./utils.js";import{MdResolveError as v}from"./md-resolve-error.js";async function k(r,e,l,{actions:{contentDir:n,outdir:s},context:f}){if(a(r,e)){const i=g(e),o=r[i]||a(r,e);if(r[i]=o,!o)return;try{const t=await u(o,f.fs,{fromFileRelativePath:l,contentDir:n,outdir:s});m(r,e,t)}catch(t){if(t instanceof p)throw new v(`File ${t.filePath} does not exist`,{rawLink:t.filePath,link:t.filePath});await c.panicOnBuild(`Cannot resolve 'srcSet' attribute: ${t.message}`)}}}export{k as resolveImageSrcSet};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{reporter as m}from"../../../tools/notifiers/reporter.js";import{getNodeAttribute as n}from"
|
|
1
|
+
import{reporter as m}from"../../../tools/notifiers/reporter.js";import{getNodeAttribute as n}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as c}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{FileNotFoundError as p,resolveAssetPath as g}from"../../../utils/index.js";import{MdResolveError as u}from"./md-resolve-error.js";import{getLinkOriginalAttrName as v}from"./utils.js";async function x(t,o,s,{actions:{contentDir:a,outdir:l},context:f}){if(n(t,o)){const i=v(o),r=t[i]||n(t,o);if(typeof r!="string"||(t[i]=r,!r))return;try{const e=await g(r,f.fs,{fromFileRelativePath:s,contentDir:a,outdir:l});c(t,o,e)}catch(e){if(e instanceof p)throw new u(`File ${r} does not exist`,{rawLink:r,link:r});await m.panicOnBuild(`Cannot resolve %rp: ${e.message}`,r)}}}export{x as resolveImageSrc};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{JsonPointer as w}from"@redocly/openapi-docs";import{isObject as d}from"../../../../utils/guards/is-object.js";import{getNodeAttribute as u}from"
|
|
1
|
+
import{JsonPointer as w}from"@redocly/openapi-docs";import{isObject as d}from"../../../../utils/guards/is-object.js";import{getNodeAttribute as u}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as s}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{MdResolveError as p}from"./md-resolve-error.js";import{resolvePathInMarkdown as $}from"../resolve-path-in-markdown.js";async function b(e,o,m,{context:n,actions:h}){const r=u(e,o);try{if(!d(r)||typeof r.$ref!="string"){try{JSON.stringify(r)}catch(i){throw new Error(`Invalid JSON value: ${i.message}`)}s(e,o+"Resolved",r);return}const[t,f]=r.$ref.split("#");if(!t)throw new Error(`Invalid $ref. Path to file is required: ${r.$ref}`);const l=$(t,m,h.contentDir),c=await n.fs.getFileInfo(l);if(!c)throw new Error(`Invalid $ref. No such file: ${l}`);let a;try{a=(await n.cache.load(c.realRelativePath,"yaml")).data}catch(i){throw new Error(`Invalid file format. File must be valid json or yaml: ${l} ${i?.message||""}`)}if(!f){s(e,o+"Resolved",a);return}const v=w.get(a,f);s(e,o+"Resolved",v)}catch(t){throw s(e,o+"ResolvedErrors",[t.message]),new p(t.message,{rawLink:""})}}export{b as resolveJsonExampleRef};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import a from"node:path";import{getNodeAttribute as u}from"
|
|
1
|
+
import a from"node:path";import{getNodeAttribute as u}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as f}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{formatBundleFromMarkdocError as b}from"../errors.js";import{MdResolveError as d}from"./md-resolve-error.js";import{dereferenceJsonSchemaRefs as h}from"./helpers/dereference-json-schema-refs.js";async function k(o,r,e,{context:c,actions:i}){const l=u(o,r),t=i.contentDir,p=a.resolve(t,e),s=await h({schemaOrRef:l,filePath:p,fs:c.fs});f(o,r+"Resolved",s?.oas);const n=s?.problems[0];if(!n)return{};const m=b(n,e,t);throw f(o,r+"ResolvedErrors",[m]),new d(m,{rawLink:""})}export{k as resolveJsonSchemaRef};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"node:path";import{ASYNC_API_DOCS_TEMPLATE_ID as F,GRAPHQL_SPEC_SLUG as T,GRAPHQL_TEMPLATE_ID as d,OPENAPI_DOCS_TEMPLATE_ID as v}from"../../../../constants/common.js";import{isLocalLink as U}from"../../../../utils/path/is-local-link.js";import{normalizeRouteSlug as P}from"../../../../utils/path/normalize-route-slug.js";import{removeFragment as y}from"../../../../utils/path/remove-fragment.js";import{PUBLIC_API_DEFINITIONS_FOLDER as C,DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as M}from"../../../constants/common.js";import{getInnerText as N}from"
|
|
1
|
+
import o from"node:path";import{ASYNC_API_DOCS_TEMPLATE_ID as F,GRAPHQL_SPEC_SLUG as T,GRAPHQL_TEMPLATE_ID as d,OPENAPI_DOCS_TEMPLATE_ID as v}from"../../../../constants/common.js";import{isLocalLink as U}from"../../../../utils/path/is-local-link.js";import{normalizeRouteSlug as P}from"../../../../utils/path/normalize-route-slug.js";import{removeFragment as y}from"../../../../utils/path/remove-fragment.js";import{PUBLIC_API_DEFINITIONS_FOLDER as C,DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as M}from"../../../constants/common.js";import{getInnerText as N}from"../../../../markdoc/helpers/get-inner-text.js";import{getNodeAttribute as W}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as p}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{MdResolveError as g}from"./md-resolve-error.js";import{getLinkOriginalAttrName as B}from"./utils.js";import{isOpenApiURL as j}from"../../openapi-docs/is-openapi-doc.js";import{parseBaseName as G}from"../../utils.js";import{isMarkdownPage as $}from"../is-markdown-page.js";import{copyStaticFile as H}from"../../../utils/fs.js";const V=i=>[C,M,T].some(r=>i.startsWith(r));async function lt(i,r,k,{actions:L,context:c}){const{contentDir:w,outdir:D,getRouteByFsPath:A,slugHasRouteOrRedirect:E}=L,_=B(r),s=i[_]||W(i,r);if(i[_]=s,!U(s)||V(s))return;const[b,t="",R,h]=/^([^\?#]+)?([^#]+)?(.+)?/.exec(s)||[],f=i.type==="image"?"IMAGE":"LINK",u=String(i.attributes.title||i.attributes.alt||N([i])||""),n=y(k);if(i.type!=="image"){const{isOpenapiDetected:e,isOpenapiValid:m}=await j(t,n,L,c);if(e&&!m)throw new g(`OpenAPI route ${s} does not exist`,{rawLink:s,link:t,title:u,brokenLinkType:f})}if(o.extname(t)===""){if(t.startsWith("/")){if(!E(P(t)))throw new g(`Route ${t} does not exist`,{rawLink:s,link:t,title:u,brokenLinkType:f});p(i,r,t+(R||"")+(h||""))}if(!s.startsWith("#")&&!t.startsWith("/")&&$(n)){const e=A(n)?.slug;if(!e)return;const{isIndexFile:m}=G(n),I=m?P(o.posix.join(e,t)):P(o.posix.join(e,"../",t));if(!E(P(I)))throw new g(`Route ${t} does not exist`,{rawLink:s,link:I,title:u,brokenLinkType:f});p(i,r,I+(R||"")+(h||""))}return}const a=t.startsWith("/")?t.substring(1):o.posix.join(o.posix.dirname(n),decodeURI(t)),O=t.startsWith("/")?o.posix.join("static",t.substring(1)):"",x=c.fs.exists(a),S=c.fs.exists(O),l=A(a);if(!x&&!l&&!S)throw p(i,r,"#"),new g(`File ${a} does not exist`,{rawLink:s,link:a,title:u,brokenLinkType:f});if(l){const e=[v,d,F].includes(l.templateId);p(i,r,(e?l.baseSlug:l.slug)+(h||""))}else if(x){const e=c.fs.getFileInfo(a);if(!e||e.isVirtual)return;const m=await H(w,e.realRelativePath,D);p(i,r,m)}}export{lt as resolveLink};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getPathPrefix as s,withPathPrefix as n}from"@redocly/theme/core/utils";import{isLocalLink as m}from"../../../../utils/path/is-local-link.js";import{getNodeAttribute as a}from"
|
|
1
|
+
import{getPathPrefix as s,withPathPrefix as n}from"@redocly/theme/core/utils";import{isLocalLink as m}from"../../../../utils/path/is-local-link.js";import{getNodeAttribute as a}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as p}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{resolveLink as h}from"./resolve-link.js";async function x(r,i,e,f){await h(r,i,e,f);const o=s();if(!o)return;const t=a(r,i);!t||t==="#"||!m(t)||t.startsWith(o)||p(r,i,t.startsWith("#")?t:n(t))}export{x as resolveNativeMdLink};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import n from"node:path";import{getNodeAttribute as f}from"
|
|
1
|
+
import n from"node:path";import{getNodeAttribute as f}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as p}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{getLinkOriginalAttrName as a}from"./utils.js";import{resolveLinksFromConfig as v}from"../../nav-utils.js";async function L(o,r,t,{context:s,actions:i}){const e=a(r),m=o[e]||f(o,r);o[e]=m;const l=await v(m,n.dirname(n.resolve(i.contentDir,t)),i,s,{navFile:t});p(o,r,l)}export{L as resolveNavLinks};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import f from"node:path";import{OPENAPI_SHARED_DATA_PREFIX as p}from"../../../constants/plugins/openapi-docs.js";import{getNodeAttribute as A}from"
|
|
1
|
+
import f from"node:path";import{OPENAPI_SHARED_DATA_PREFIX as p}from"../../../constants/plugins/openapi-docs.js";import{getNodeAttribute as A}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as w}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{isOpenapiDoc as d}from"../../openapi-docs/is-openapi-doc.js";import{MdResolveError as a}from"./md-resolve-error.js";import{getLinkOriginalAttrName as g}from"./utils.js";async function O(r,t,e,{context:n}){const s=g(t);let o=r[s]||A(r,t);if(o||await d(e,n)&&(o=f.basename(e)),r[s]=o,!o)return;const i=f.posix.join(f.posix.dirname(e),o),m=p+i;if(w(r,t,m),!n.fs.exists(i))throw new a(`Definition file ${i} does not exist`,{rawLink:i});if(await n.isPathIgnored(i))throw new a(`Definition file ${i} is ignored in config`,{rawLink:i});return{sharedDataId:m}}export{O as resolveOpenApiRef};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getNodeAttribute as m}from"
|
|
1
|
+
import{getNodeAttribute as m}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as c}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{MdResolveError as f}from"./md-resolve-error.js";import{resolvePathInMarkdown as l}from"../resolve-path-in-markdown.js";async function p(t,r,a,{context:o}){const s=m(t,r);if(s){const e=l(s,a,o.fs.cwd);if(!o.fs.exists(e))throw new f(`Schema file ${e} does not exist`,{rawLink:e});const i=(await o.cache.load(e,"yaml")).data;c(t,r+"Resolved",i)}}export{p as resolveParsedYaml};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getNodeAttribute as m}from"
|
|
1
|
+
import{getNodeAttribute as m}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as c}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{readFileContent as l}from"../read-file-content.js";import{resolvePathInMarkdown as w}from"../resolve-path-in-markdown.js";import{MdResolveError as p}from"./md-resolve-error.js";async function R(o,e,i,{context:r,actions:s}){const n=m(o,e),a=s.contentDir;if(n){const t=w(n,i,a);if(!r.fs.exists(t))throw new p(`File ${t} does not exist`,{rawLink:t});const f=await l(t,r.fs);c(o,e+"RawContent",f)}}export{R as resolveRawContent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getNodeAttribute as s}from"
|
|
1
|
+
import{getNodeAttribute as s}from"../../../../markdoc/helpers/get-node-attribute.js";import{resolveLink as m}from"./resolve-link.js";import{resolveSvgContent as g}from"./resolve-svg-content.js";import{isIconPath as l}from"../../../utils/index.js";import{getLinkOriginalAttrName as p}from"./utils.js";async function k(i,r,t,{context:e,actions:n}){const f=p(r),o=i[f]||s(i,r);!o||typeof o!="string"||(o.endsWith(".svg")?await g(i,r,t,{context:e,actions:n}):l(o)&&await m(i,r,t,{context:e,actions:n}))}export{k as resolveRelativeOrCdnIcon};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"node:path";import{slash as g}from"../../../../utils/path/slash.js";import{getNodeAttribute as h}from"
|
|
1
|
+
import e from"node:path";import{slash as g}from"../../../../utils/path/slash.js";import{getNodeAttribute as h}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as v}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{isL10nPath as m}from"../../../fs/utils/is-l10n-path.js";import{getLocaleFromRelativePath as A}from"../../../fs/utils/get-locale-from-relative-path.js";import{getLinkOriginalAttrName as d}from"./utils.js";async function R(o,i,r,n){const s=h(o,i);if(!s)return;const l=n.actions.contentDir,a=d(i),t=o[a]||s;o[a]=t;const c=m(r)?A(r):void 0,f=n.context.fs,p=c&&!m(t.slice(1))?`${f.localizationFolder}/${c}/`:"",u=t.startsWith("/")?p+t.slice(1):g(e.relative(l,e.resolve(l,e.dirname(r),t)));v(o,i,u)}export{R as resolveRelativePath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import S from"node:path";import{getNodeAttribute as f}from"
|
|
1
|
+
import S from"node:path";import{getNodeAttribute as f}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as i}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{MdResolveError as a}from"./md-resolve-error.js";import{generateSampleFromSchema as g}from"./helpers/generate-sample-from-schema.js";import{formatBundleFromMarkdocError as k}from"../errors.js";import{dereferenceJsonSchemaRefs as E}from"./helpers/dereference-json-schema-refs.js";async function y(o,e,r,{context:p,actions:l}){const h=f(o,e),t=l.contentDir,d=S.resolve(t,r),s=await E({schemaOrRef:h,filePath:d,fs:p.fs});if(!s)return;const{schema:u,problems:w,oas:b}=s,m=w[0];if(m){const c=k(m,r,t);throw i(o,e+"ResolvedErrors",[c]),new a(c,{rawLink:""})}const R=f(o,"mode"),{value:v,error:n}=g(u,{mode:R,spec:b});if(i(o,e+"Resolved",v),n)throw new a(n,{rawLink:""})}export{y as resolveSampleFromJsonSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getNodeAttribute as m}from"
|
|
1
|
+
import{getNodeAttribute as m}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as l}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{optimize as p}from"../../../../compiled/svgo/svgo-node.js";import{slug as c}from"../../../utils/index.js";import{MdResolveError as d}from"./md-resolve-error.js";import{resolvePathInMarkdown as u}from"../resolve-path-in-markdown.js";async function b(o,r,n,{context:i,actions:s}){const e=m(o,r),a=s.contentDir;if(e){const t=u(e,n,a);if(!i.fs.exists(t))throw new d(`File ${t} does not exist`,{rawLink:e});let f=p(await i.fs.read(t),{plugins:[{name:"prefixIds",params:{prefix:c(t).replaceAll(/[\/\.]/g,"-")}}]}).data;l(o,r+"RawContent",f)}}export{b as resolveSvgContent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import f from"@markdoc/markdoc";import*as g from"@redocly/theme/markdoc/default";import{reporter as p}from"../../../tools/notifiers/reporter.js";import
|
|
1
|
+
import f from"@markdoc/markdoc";import*as g from"@redocly/theme/markdoc/default";import{reporter as p}from"../../../tools/notifiers/reporter.js";import*as u from"../../../../markdoc/nodes/index.js";import d from"../../../../markdoc/tags/index.js";import{includes as l}from"./functions/includes.js";import{importUserTags as h}from"./import-user-tags.js";import{concat as O}from"./functions/concat.js";const y=g.tags;function b(o){return Object.fromEntries(Object.entries(o).map(([r,e])=>[e.tagName||r,e]))}function T(o){const{tags:r,functions:e={},...n}=o,a={...r,...n};let i=Object.entries(a);const s=[],t=[];for(const[c,m]of i)c in f.nodes?s.push([c,m]):t.push([c,m]);return{nodes:Object.fromEntries(s),tags:Object.fromEntries(t),functions:e}}async function D(o="../../../esbuild/cache/server/",r=""){let e;try{e=(await h(o)).schema}catch(t){throw t.code==="ERR_MODULE_NOT_FOUND"?(p.printErrors(),new Error("Please fix the errors above and try again.")):t}const{tags:n={},nodes:a={},functions:i={}}=T(e),s={tags:{schemaDefinition:{render:"SchemaDefinition",attributes:{schemaRef:{type:String},exampleRef:{type:String},showReadOnly:{type:Boolean},showWriteOnly:{type:Boolean}}}}};return{nodes:{...u,...a},tags:{...d,...y,...b(n),...s.tags},functions:{...f.functions,...i,includes:l,concat:O}}}export{D as getMarkdocOptions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as f from"path";import{MARKDOC_PARTIALS_DATA_KEY as D,MARKDOC_PARTIALS_DEPS_KEY as A}from"../../../store.js";import{isPartial as y}from"../is-partial.js";function h(t,s){return Promise.all(t.map(s)).then(i=>t.filter((o,n)=>i[n]))}async function b(t,s){const{markdown:i}=await t.getConfig(),o=i?.partialsFolders??[],n=await h(t.fs.scan(/\.md$/),async a=>!(!f.posix.basename(a.relativePath).endsWith(".md")||await t.isPathIgnored(a.relativePath)||!y(a.relativePath,o)));s.setGlobalConfig({[D]:Object.fromEntries(n.map(a=>[a.relativePath,{}]))});const p={},m={};for(const a of n){const{ast:e,info:r}=await s.parseMarkdoc(a,t);p[a.relativePath]=e;const l=Array.isArray(r.dynamicMarkdocComponents)?r.dynamicMarkdocComponents:[],c=r.sharedDataDeps instanceof Set?Array.from(r.sharedDataDeps):Array.isArray(r.sharedDataDeps)?r.sharedDataDeps:[],d=Array.isArray(r.partials)?r.partials:[];m[a.relativePath]={dynamicComponents:new Set(l),sharedDataDeps:new Set(c),partials:new Set(d)}}return s.setGlobalConfig({[A]:Object.fromEntries(Object.entries(m).map(([a,e])=>[a,{dynamicComponents:Array.from(e.dynamicComponents),sharedDataDeps:Array.from(e.sharedDataDeps),partials:Array.from(e.partials)}]))}),p}export{b as prepareMarkdocPartials};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getNodeAttribute as r}from"
|
|
1
|
+
import{getNodeAttribute as r}from"../../../../../markdoc/helpers/get-node-attribute.js";import{getInnerText as i}from"../../../../../markdoc/helpers/get-inner-text.js";function u(t){const e=r(t,"level");if(e)return{value:i(t.children),id:r(t,"id"),depth:e}}export{u as getHeadingData};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isNode as l}from"
|
|
1
|
+
import{isNode as l}from"../../../../../markdoc/helpers/guards/is-node.js";import{isStringNode as s}from"../../../../../markdoc/helpers/guards/is-string-node.js";import{getNodeAttribute as c}from"../../../../../markdoc/helpers/get-node-attribute.js";import{getInnerText as a}from"../../../../../markdoc/helpers/get-inner-text.js";function p(t){const r=c(t,"level");if(r)return{value:a(t.children),id:c(t,"id"),depth:r}}function h(t){let r;return f(t,i=>{if(l(i)&&i.type==="heading")return r=p(i)?.value,o}),r}const o=Symbol("Exit visitor");function f(t,r){if(!t)return;const i=r(t);if(i===o)return i;for(const e of t.children){if(!e||s(e))continue;const n=f(e,r);if(n===o)return n}const u=t.slots||{};for(const e of Object.values(u)){if(!e||s(e))continue;const n=f(e,r);if(n===o)return n}}export{o as EXIT,h as extractFirstHeading,p as getHeadingData,f as visit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import u from"@markdoc/markdoc";import{isTag as b}from"
|
|
1
|
+
import u from"@markdoc/markdoc";import{isTag as b}from"../../../markdoc/helpers/guards/is-tag.js";import{slugger as g}from"../../utils/index.js";import{getMarkdocOptions as l}from"./markdoc/markdoc-options.js";import{visit as h,getHeadingData as k}from"./markdoc/plugins/utils.js";import{renderMermaid as v}from"./markdoc/plugins/render-mermaid.js";import{deepStringify as M}from"./markdoc/utils/deep-stringify.js";import{stringifyTagChildrenObjects as w}from"./utils/stringify-tag-children-objects.js";async function _(d,e,p){const c=await l(p),t=[],a=[],i=M(e.variables?.pageProps),{headers:y,...f}=e.variables||{};g.reset();const s=u.transform(d,{...c,...e,variables:{...f,pageProps:i}});let o=0;h(s,r=>{if(b(r)){switch(r.name){case"Heading":r.attributes.__idx=o,o++;const n=k(r);n&&t.push(n);break;case"Mermaid":a.push({tag:r,source:r.attributes.diagramSource});break}w(r)}});const m=await v(a.map(r=>r.source));for(let r=0;r<m.length;r++)a[r].tag.attributes.diagramHtml=m[r];return{headings:t,renderableAst:s,pageProps:i}}export{_ as transformMdAst};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _ from"@markdoc/markdoc";import D from"node:path";import{AI_SEARCH_CHUNK_SIZE as E,AI_SEARCH_DOCUMENT_CHUNK_SIZE as M}from"../../../constants/plugins/search.js";import{slugger as P}from"
|
|
1
|
+
import _ from"@markdoc/markdoc";import D from"node:path";import{AI_SEARCH_CHUNK_SIZE as E,AI_SEARCH_DOCUMENT_CHUNK_SIZE as M}from"../../../constants/plugins/search.js";import{slugger as P}from"../../../../utils/slugger.js";import{toMarkdown as U}from"./to-markdown.js";import{AstToSearchNodeTransformer as b}from"./walk-sections.js";import{getLocaleFromRelativePath as x}from"../../../fs/utils/get-locale-from-relative-path.js";import{HeadingNode as I}from"./nodes/heading-node.js";import{extractDocumentSearchFacets as y}from"./search-facets.js";import{formatDocumentMetadata as L}from"../../search/utils.js";import{TagNode as H}from"./nodes/tag-node.js";import{MARKDOC_PARTIALS_DATA_KEY as K}from"../../../store.js";const N=Symbol(),W=(n,c)=>async(e,r,u,s)=>{if(c?.excludeFromSearch)return;P.reset();const i=await e.getNavText?.()||D.basename(e.fsPath),p=_.Ast.fromJSON(r.ast),m=new b({partials:s.getGlobalConfig(K)||{},getInnerContent:U,ast:p,skipConditionals:!0}),f=Array.from(m.transform());return{async getLLMsTxts(){const o=c?.seo,g=o&&typeof o=="object"&&"description"in o?String(o.description):void 0,C=f.map(t=>t.content).filter(Boolean).join(`
|
|
2
2
|
`).trim();return[{title:i,description:g,slug:e.slug,fsPath:e.fsPath,content:C,includeInLLMsTxt:!0}]},async getSearchDocuments(){return j(e,f,n,i)}}};function j(n,c,e,r){const u=n.slug,s=new Map,i=n.metadata||{},p=y(i,e),m=L(i),f=m?`Metadata:
|
|
3
3
|
${m}
|
|
4
4
|
`:"";let o=[];for(const t of c)if(t instanceof I){o.splice(t.attributes.level-1,6);const a=t.attributes.level>2,l=o[o.length-1]?.title,S=o[o.length-1]?.url,A=a&&l?l:w(r,t),T=a&&S?S:t.getUrl(u),d={title:A,content:"",url:T,level:t.attributes.level,toc:o.map(v=>h(v.section)).join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{SEARCH_DOCUMENT_METADATA_KEY as p}from"../../../constants/plugins/search.js";import{
|
|
2
|
-
`," "],s=u.some(n=>c.endsWith(n)),a=u.some(n=>e.startsWith(n));return c+(!s&&!a?" ":"")+e}function v(c,e,u,s,a,d={},n){const g=new Map(Array.from({length:6},(t,m)=>[m,""])),i=new Map;let h=null;s=s??{},
|
|
1
|
+
import{SEARCH_DOCUMENT_METADATA_KEY as p}from"../../../constants/plugins/search.js";import{slugger as E}from"../../../../utils/slugger.js";import{TagNode as U}from"./nodes/tag-node.js";import{TextNode as M}from"./nodes/text-node.js";import{MdSearchDocument as A}from"./md-search-document.js";import{HeadingNode as N}from"./nodes/heading-node.js";const T=Symbol();function _(c,e){if(!c)return e;if(!e)return c;const u=[" ",`
|
|
2
|
+
`," "],s=u.some(n=>c.endsWith(n)),a=u.some(n=>e.startsWith(n));return c+(!s&&!a?" ":"")+e}function v(c,e,u,s,a,d={},n){const g=new Map(Array.from({length:6},(t,m)=>[m,""])),i=new Map;let h=null;s=s??{},E.reset();for(const t of c.transform()){const m=t.getUrl(e),f={...s};if(t.rbacTeam&&(f[t.rbacTeam.toLowerCase()]="read"),t instanceof M){const o=t.parentNode?.id,r=o?`${m}#${o}`:T,l=i.get(r)??new A(u,e,[],d,f,a);l.text=_(l.text,t.content),l.facets=d,i.set(r,l);continue}if(t instanceof U){const o=`${m}#${t.id}`,r=new A(t.content,t.getUrl(e),t.getPath(g),d,f,a);i.set(o,r);continue}if(t instanceof N){g.set(t.attributes.level,t.content);const o=new A(t.content,t.getUrl(e),t.getPath(g),d,f,a),r=`${m}#${t.id}`;i.set(r,o),h===null&&(h=o)}}const D=Array.from(i.values()),S=h??D[0];if(S&&n?.includes&&(S[p].curated=!0,S[p].includes=n.includes),n?.excludes)for(const t of D)t[p].curated=!0,t[p].excludes=n.excludes;return D}export{v as getSearchDocuments};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getInnerText as o}from"
|
|
1
|
+
import{getInnerText as o}from"../../../../../markdoc/helpers/get-inner-text.js";import{slugger as c}from"../../../../../utils/slugger.js";class a{#t;#e;#r;#n;constructor(t){const{node:r,content:n,rbacTeam:s,parentNode:i}=t;this.#t=r,this.#e=n,this.#r=i,this.#n=s}get attributes(){return this.#t.attributes}get content(){return this.#e}get node(){return this.#t}get id(){throw new Error("SectionNode needs an id mixin applied")}get parentNode(){return this.#r}get rbacTeam(){return this.#n}}function h(e){let t=0;return class extends e{#t=++t;get id(){return this.#t}}}function g(e){return class extends e{#t;constructor(...t){super(...t);const r=this;this.#t=c.slug(o(r.node.children),{replaceDots:!0,replaceSlashes:!0})}get id(){return this.#t}}}export{a as SectionNode,h as WithCounterId,g as WithSlugId};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import p from"@markdoc/markdoc";import{REDOCLY_ROUTE_RBAC as l,REDOCLY_TEAMS_RBAC as A}from"@redocly/config";import{
|
|
1
|
+
import p from"@markdoc/markdoc";import{REDOCLY_ROUTE_RBAC as l,REDOCLY_TEAMS_RBAC as A}from"@redocly/config";import{getInnerText as h}from"../../../../markdoc/helpers/get-inner-text.js";import{getSearchDocuments as T}from"./get-search-documents.js";import{AstToSearchNodeTransformer as R}from"./walk-sections.js";import{setDocumentSearchFacets as S,extractDocumentSearchFacets as C}from"./search-facets.js";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../../store.js";import{normalizeFrontmatterKeywords as _}from"../../helpers/normalize-frontmatter-keywords.js";function K(e,m,o,c){return async(t,r,a)=>{if(e?.excludeFromSearch)return[];const i=p.Ast.fromJSON(r.ast),f=new R({ast:i,getInnerContent:h,partials:a.getGlobalConfig(D)||{}}),u=t.metadata||{},n=C(u,o);S(n,o,c);const d=e?.seo?.title||m,{result:s}=_(e?.keywords);return T(f,t.slug,d,r[A],r[l],n,s||void 0)}}export{K as searchResolver};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{isPrimitive as w}from"../../../../utils/guards/is-primitive.js";import{getNodeAttribute as t}from"
|
|
1
|
+
import{isPrimitive as w}from"../../../../utils/guards/is-primitive.js";import{getNodeAttribute as t}from"../../../../markdoc/helpers/get-node-attribute.js";import{getVariable as C}from"../../../../markdoc/helpers/get-variable.js";import{isTag as E}from"../../../../markdoc/helpers/guards/is-tag.js";import{isNode as N}from"../../../../markdoc/helpers/guards/is-node.js";import{isConditionalNode as v}from"../../../../markdoc/helpers/guards/is-conditional-node.js";import{isVariable as A}from"../../../../markdoc/helpers/guards/is-variable.js";import{isExampleNode as S}from"../../../../markdoc/helpers/guards/is-example-node.js";import{isFenceNode as x}from"../../../../markdoc/helpers/guards/is-fence-node.js";function a(s,r={}){const n=[];for(const e of s){if(w(e)){const i=r.isTrim?u(String(e)):String(e);i&&n.push(i)}else if(N(e))switch(e.type){case"text":n.push(a([t(e,"content")],r));break;case"code":n.push(`\`${a([t(e,"content")],r)}\``);break;case"blockquote":n.push(`> ${a(e.children,r)}
|
|
2
2
|
`);break;case"fence":const i=t(e,"process")===!1;n.push(o(e,r,i));break;case"list":const h=t(e,"ordered")||!1,d=t(e,"marker"),f=e.children.map((c,l)=>`${" ".repeat((r?.indent??0)*2)}${h?l+1:""}${d} ${a([c],{...r??{},indent:(r?.indent??0)+1})}`);n.push(`${f.join("")}
|
|
3
3
|
`);break;case"item":n.push(e.children.map(c=>`${a([c],r).trimEnd()}
|
|
4
4
|
`).join(""));break;case"thead":const $=e.children.map(c=>a([c],r));n.push(`${$}| ${" --- |".repeat(e.children?.[0]?.children.length)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logger as a}from"../../../tools/notifiers/logger.js";import{
|
|
1
|
+
import{logger as a}from"../../../tools/notifiers/logger.js";import{isNode as f}from"../../../../markdoc/helpers/guards/is-node.js";import{isConditionalNode as u}from"../../../../markdoc/helpers/guards/is-conditional-node.js";import{isContentNode as y}from"../../../../markdoc/helpers/guards/is-content-node.js";import{getNodeAttribute as h}from"../../../../markdoc/helpers/get-node-attribute.js";import{extractRbacFromCondition as N}from"../../../../markdoc/helpers/extract-rbac-from-condition-node.js";import{TextNode as e}from"./nodes/text-node.js";import{TAG_TITLE_ATTRIBUTES as T,TagNode as n}from"./nodes/tag-node.js";import{HeadingNode as p}from"./nodes/heading-node.js";class C{#t;#o;#i;#s;constructor({ast:i,partials:t,skipConditionals:r=!1,getInnerContent:s}){if(this.#t=i,this.#o=t,this.#i=r,this.#s=s,!this.#t||!f(this.#t))throw new Error("ast is not a valid Markdoc Node.")}*transform(){yield*this.#l(this.#t,{parentNode:null})}*#l(i,t,r=this.#s){if(!(!i||!f(i))){if(u(i)){if(this.#i)return;const s=N(i);s!==null&&(yield*this.#r(i,{...t,rbacTeam:s},r));return}if(y(i)){yield new e({node:i,content:r([i],{skipConditionals:this.#i}),...t});return}if(i.type==="heading"){yield new p({node:i,content:r([i],{skipConditionals:this.#i}),rbacTeam:t?.rbacTeam});return}if(i.type==="tag"){yield*this.#c(i,t,r);return}yield*this.#r(i,t,r)}}*#c(i,t,r=this.#s){switch(i.tag){case"partial":{const s=i.attributes.file,o=i.attributes.variables??{};if(s&&this.#o[s]){yield*this.#l(this.#o[s],t,(l,c)=>r(l,{...c,variables:o}));return}a.warn(`Could not create search indexes for partial \u201C${s}\u201D: file not found`);return}case"cards":case"tabs":case"code-walkthrough":{yield*this.#r(i,t,r);return}case"markdoc-example":{const s=r([i],{skipConditionals:this.#i});yield new e({node:i,content:s,...t});return}case"code-snippet":{const s=h(i,"title"),o=r([i],{skipConditionals:this.#i});if(s){const l=new n({node:i,content:s,...t});t={...t,parentNode:l},yield l}o&&(yield new e({node:i,content:o,...t}));return}default:{const s=T.find(c=>c in i.attributes),o=(s&&h(i,s))??"",l=typeof o=="string"?o:r([o]);if(l){const c=new n({node:i,content:l,...t});t={...t,parentNode:c},yield c}yield*this.#r(i,t,r);return}}}*#r(i,t,r=this.#s){for(const s of[...Object.values(i.slots),...i.children])for(const o of this.#l(s,t,r))o instanceof p&&(t={...t,parentNode:o}),yield o}}export{C as AstToSearchNodeTransformer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isTag as e}from"
|
|
1
|
+
import{isTag as e}from"../../../../markdoc/helpers/guards/is-tag.js";function f(n){!n||!Array.isArray(n?.children)||n.children.forEach((r,i)=>{if(!(typeof r!="object"||r===null)){if(e(r)){f(r);return}n.children[i]=JSON.stringify(r,null,2)}})}export{f as stringifyTagChildrenObjects};
|
|
@@ -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{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=[],
|
|
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=[],R={},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 A=e.createTemplate($,b("../../../client/templates/openapi-docs/template.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"];R={};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:A,[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}`;R[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 A=L.difference(u);for(const a of A)p.cache.delete(a);L=u;for(const[a,s]of Object.entries(R))await e.createSharedData(a,{...s,baseSlug:e.getRouteByFsPath(s.fsPath)?.baseSlug},s.hash)}}}export{Ce as openAPIDocsPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as g from"@redocly/openapi-docs";import{REDOCLY_TEAMS_RBAC as d}from"@redocly/config";import{combineUrls as l}from"@redocly/theme/core/utils";import{SEARCH_DOCUMENT_METADATA_KEY as y}from"../../constants/plugins/search.js";import{removeMarkdownLinks as c,stripFormatting as a}from"./utils.js";import{normalizeFrontmatterKeywords as x}from"../helpers/normalize-frontmatter-keywords.js";const u=g.default||g;class T{#n=[];#r;#s;#e;#i;constructor(e,t,n){this.#r=e,this.#s=t,this.#e=n}addItem(e){const{result:t}=x(e.keywords||e.operationDefinition?.keywords);t?.excludes&&e.type==="section"&&e.id===""&&(this.#i=t.excludes);try{let n;switch(e.type){case"tag":n=this.#c(e);break;case"operation":const o=this.getOperation(e);n=this.#d(o,e[d]);break;case"section":n=this.#p(e);break;case"rsrc":case"prompt":case"tool":n=this.#o(e);break}if(!n)return;const s=[...new Set([...t?.excludes?t.excludes:[],...this.#i?this.#i:[]])];return(t||s.length)&&(n[y]={curated:!0,...t,excludes:s}),this.#n.push(n),n}catch(n){console.error("Cannot add item to search indexer",n.message)}}addInfo(e,t){const n=this.#e,s={id:n,url:n,text:a(c(e.description||"")),title:a(`${e.title} (${e.version})`),metadata:t};return this.#n.push(s),s}#o(e){const t=l(this.#e,e.href);return{id:t,url:t,text:a(c(e.description||"")),title:e.name}}getResult(){return this.#n}getOperation(e){return u.getOperation(this.#r,e.operationDefinition,e.parent,{...this.#s,internal_skipSamples:!0},e.href)}#a(e){return
|
|
1
|
+
import*as g from"@redocly/openapi-docs";import{REDOCLY_TEAMS_RBAC as d}from"@redocly/config";import{combineUrls as l}from"@redocly/theme/core/utils";import{SEARCH_DOCUMENT_METADATA_KEY as y}from"../../constants/plugins/search.js";import{removeMarkdownLinks as c,stripFormatting as a}from"./utils.js";import{normalizeFrontmatterKeywords as x}from"../helpers/normalize-frontmatter-keywords.js";const u=g.default||g;class T{#n=[];#r;#s;#e;#i;constructor(e,t,n){this.#r=e,this.#s=t,this.#e=n}addItem(e){const{result:t}=x(e.keywords||e.operationDefinition?.keywords);t?.excludes&&e.type==="section"&&e.id===""&&(this.#i=t.excludes);try{let n;switch(e.type){case"tag":n=this.#c(e);break;case"operation":const o=this.getOperation(e);n=this.#d(o,e[d]);break;case"section":n=this.#p(e);break;case"rsrc":case"prompt":case"tool":n=this.#o(e);break}if(!n)return;const s=[...new Set([...t?.excludes?t.excludes:[],...this.#i?this.#i:[]])];return(t||s.length)&&(n[y]={curated:!0,...t,excludes:s}),this.#n.push(n),n}catch(n){console.error("Cannot add item to search indexer",n.message)}}addInfo(e,t){const n=this.#e,s={id:n,url:n,text:a(c(e.description||"")),title:a(`${e.title} (${e.version})`),metadata:t};return this.#n.push(s),s}#o(e){const t=l(this.#e,e.href);return{id:t,url:t,text:a(c(e.description||"")),title:e.name}}getResult(){return this.#n}getOperation(e){return u.getOperation(this.#r,e.operationDefinition,e.parent,{...this.#s,internal_skipSamples:!0},e.href)}#a(e){return[...e.path||[],e.name.toString()].join(".")+e.description+e.place}#d(e,t){if(e.type!=="operation")return;let n={};for(let i of e.parameters){if(i[d])continue;const r=i.schema?.example||i.example,p={name:i.name,description:a(c(i.description)),place:i.in+" parameters",mediaType:void 0,type:i.schema?.type.toString()||"unknown",deepLink:u.generateDeepLink(i),[d]:i[d],required:i.required,example:r?JSON.stringify(r):void 0,enum:i.schema?.enum?.length?i.schema.enum:void 0};n[this.#a(p)]=p}this.#t(n,e.requestBody?.content?.mediaTypes[0]?.schema,e.requestBody?.content?.mediaTypes[0]?.name,"request fields",!1);for(let i of e.responses){const r=`response ${i.code} fields`;this.#t(n,i.content?.mediaTypes[0]?.schema,i.content?.mediaTypes[0]?.name,r,!0)}let s=l(this.#e,e.href);return{id:s,url:s,title:a(e.name),text:a(c(e.description||"")),httpMethod:e.httpVerb,httpPath:e.path,deprecated:e.deprecated,isAdditionalOperation:e.isAdditionalOperation,security:e.security.map(i=>i.schemes.map(r=>r.id)).flat().filter(Boolean),parameters:Object.values(n),badges:e.badges.length?e.badges:void 0,[d]:t}}#t(e,t,n,s,o,i=[]){if(!(!t||t.isCircular)){if(t?.fields)for(let r of t.fields){if(t[d]||r.kind==="additionalProperties"||r.schema?.readOnly&&!o||r.schema?.writeOnly&&o)continue;const p=r.schema?.example||r.example,h=r.schema?.enum,m={name:r.name,description:a(r.description),place:s,mediaType:n,path:i,deepLink:u.generateDeepLink(r),type:r.schema?.type.toString()||"unknown",required:r.required||t.schema.required?.includes(r.name)||!1,example:p?JSON.stringify(p):void 0,enum:h?.length?h:void 0},f=this.#a(m);e[f]==null&&(e[f]=m,this.#t(e,r.schema,n,s,o,i.concat([r.name])))}t?.items&&this.#t(e,t.items,n,s,o,i)}}#c(e){const t=l(this.#e,e.href);return{id:t,url:t,text:a(c(e.description||"")),title:a(e.name)}}#p(e){const t=l(this.#e,e.href);return{id:t,url:t,text:a(c(e.description||"")),title:a(e.name)}}}export{T as SearchIndexer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as c from"path";import{lintDocument as g,getTotals as v,getLineColLocation as h,Source as y,getCodeframe as C}from"@redocly/openapi-core";import{slash as p}from"../../../utils/path/slash.js";import{getUniqueProblemsCount as P}from"./shared-utils.js";const b=20;async function j(a,r,t,o){const e=c.resolve(t.fs.cwd,a.relativePath),s=r.resolvedConfig.apis??{},l=Object.keys(s).find(n=>c.resolve(r.configPath?c.dirname(r.configPath):t.fs.cwd,s[n].root)===e),m={config:r.forAlias(l),base:c.dirname(e),document:{source:new y(e,a.content),parsed:a.parsed},externalRefResolver:o},f=await g(m),i=P(f);return{...v(f),uniqueErrors:i.errors,uniqueWarnings:i.warnings,problems:O(f,t.fs.cwd).filter(n=>!n.ignored)}}function E(a){const r=new Set,t={};for(const[o,e]of Object.entries(a)){const s=t[o]=t[o]||new Set,l=[e],m=e.resolvedConfig?.apis??{};for(const f of Object.keys(m)){const i=e.forAlias(f);i&&i!==e&&l.push(i)}for(const f of l){const i=Object.values(f.rules).flatMap(n=>Object.entries(n));for(const[n,u]of i)if(!(u==="off"||u?.severity==="off"))if(n==="assertions"){if(!Array.isArray(u))continue;for(const d of u)!d||d.severity==="off"||(s.add(d.assertionId),r.add(d.assertionId))}else r.add(n),s.add(n)}}return{perLevel:Object.fromEntries(Object.entries(t).map(([o,e])=>[o,Array.from(e)])),all:Array.from(r)}}function O(a,r){const t={};return a.map(o=>{const e=t[o.ruleId]||0;t[o.ruleId]=e+1;const s=o.location[0];if(e>b)return{...o,codeframe:`Code frame skipped due to too many errors of this type. Only first ${b} errors are shown.`,location:{...s,source:{absoluteRef:p(c.relative(r,s.source.absoluteRef))}},from:void 0};const l=h(s);return{...o,codeframe:C(l,!1),location:{...s,source:{absoluteRef:p(c.relative(r,s.source.absoluteRef))}},from:void 0}})}export{E as getAllRuleNames,j as lintDefinition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ulid as g}from"ulid";import{logger as r}from"../../../tools/notifiers/logger.js";import{DatabaseConnectionFactory as l}from"../../../providers/database/database-connection-factory.js";import{BaseRepository as d}from"../../../providers/database/base-repository.js";import{shaHex as h}from"../../../utils/crypto/sha-hex.js";import{hasOptionsChanged as m}from"../../../plugins/catalog-entities/utils/has-options-changed.js";import{slug as y}from"
|
|
1
|
+
import{ulid as g}from"ulid";import{logger as r}from"../../../tools/notifiers/logger.js";import{DatabaseConnectionFactory as l}from"../../../providers/database/database-connection-factory.js";import{BaseRepository as d}from"../../../providers/database/base-repository.js";import{shaHex as h}from"../../../utils/crypto/sha-hex.js";import{hasOptionsChanged as m}from"../../../plugins/catalog-entities/utils/has-options-changed.js";import{slug as y}from"../../../../utils/slugger.js";import{withTimestamp as f}from"../../../utils/time/with-timestamp.js";import{ScorecardsConfigLocalRepository as p}from"./repositories/local/scorecards-config-local-repository.js";class o extends d{static#i;static#e;#t;constructor(t){if(!t)throw new Error("Database connection is required for ScorecardsConfigService");super(t),this.#t=new p(this.databaseClient)}static async getInstance(t){const i=m(o.#e,t);if(!o.#i||i){const n=await l.create("main-local",t);if(!n)throw new Error("Failed to create db connection for scorecards config service");o.#i=new o(n),o.#e=t}return o.#i}async syncConfig(t,i){const n=new Set;(!Array.isArray(t)||t.length===0)&&r.verbose("No scorecard configs to sync"),r.verbose(`Starting scorecard config sync for ${t.length} config(s)`);for(const s of t)try{const e=s.key;if(!/^[a-z0-9-]+$/i.test(e)){r.error(`Skipping invalid scorecard config item: key "${e}" does not match kebab-case format (letters, numbers, and dashes only)`,{scorecard:s});continue}n.add(e);const a=this.#s(s),c=await this.#t.findActiveConfigByKey(e);if(c){if(c.configHash===a){r.verbose(`Config "${e}" unchanged, skipping update`);continue}r.verbose(`Updating config "${e}"`),await this.#r(c.id,s,a)}else r.verbose(`Inserting new config "${e}"`),await this.#n(e,s,a);i&&await i(e)}catch(e){r.error("Error processing scorecard config item:",{error:e.message??e,scorecard:s})}await this.#o(n),r.verbose("Sync scorecard configuration: success")}#s(t){const i=JSON.stringify({entities:t.entities,levels:t.levels});return h(i)}async#n(t,i,n){await this.#t.insertConfig(f({id:`sc_${g()}`,key:t,slug:y(t),name:i.name,description:i.description??null,entitiesFilter:JSON.stringify(i.entities),levels:JSON.stringify(i.levels),configHash:n,archivedAt:null}))}async#r(t,i,n){const s=f({entitiesFilter:JSON.stringify(i.entities),levels:JSON.stringify(i.levels),configHash:n,archivedAt:null},{fields:["updatedAt"]});await this.#t.updateConfigById(t,s)}async#o(t){const i=await this.#t.findAllActiveConfigs(),n=new Date().toISOString();for(const s of i)if(!t.has(s.key)){r.verbose(`Archiving removed config "${s.key}"`);try{await this.#t.archiveConfigById(s.id,n)}catch(e){r.error(`Error archiving config item "${s.key}":`,e.message??e)}}}}export{o as ScorecardsConfigService};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{writeFileSync as tt}from"node:fs";import*as u from"path";import et from"@markdoc/markdoc";import{withoutHash as ot}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as v,SIDEBAR_PREFIX as at,CONFIG_FILE_NAME as V}from"../../../constants/common.js";import{CATALOG_OUTPUT_FILE_NAME as rt}from"../../constants/common.js";import{findDeepFirst as M}from"../../../utils/tree/find-deep-first.js";import{isDefined as X}from"../../../utils/guards/is-defined.js";import{partition as it}from"../../../utils/array/partition.js";import{collectPropValueDeep as N}from"../../../utils/tree/collect-prop-value-deep.js";import{envConfig as nt}from"../../config/env-config.js";import{isLocalLink as st}from"../../../utils/path/is-local-link.js";import{normalizeRouteSlug as Y}from"../../../utils/path/normalize-route-slug.js";import{slash as lt}from"../../../utils/path/slash.js";import{parsePathVersions as ct}from"../../../utils/path/parse-path-versions.js";import{reporter as A}from"../../tools/notifiers/reporter.js";import{logger as x}from"../../tools/notifiers/logger.js";import{sha1 as ft}from"../../utils/crypto/sha1.js";import{
|
|
1
|
+
import{writeFileSync as tt}from"node:fs";import*as u from"path";import et from"@markdoc/markdoc";import{withoutHash as ot}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as v,SIDEBAR_PREFIX as at,CONFIG_FILE_NAME as V}from"../../../constants/common.js";import{CATALOG_OUTPUT_FILE_NAME as rt}from"../../constants/common.js";import{findDeepFirst as M}from"../../../utils/tree/find-deep-first.js";import{isDefined as X}from"../../../utils/guards/is-defined.js";import{partition as it}from"../../../utils/array/partition.js";import{collectPropValueDeep as N}from"../../../utils/tree/collect-prop-value-deep.js";import{envConfig as nt}from"../../config/env-config.js";import{isLocalLink as st}from"../../../utils/path/is-local-link.js";import{normalizeRouteSlug as Y}from"../../../utils/path/normalize-route-slug.js";import{slash as lt}from"../../../utils/path/slash.js";import{parsePathVersions as ct}from"../../../utils/path/parse-path-versions.js";import{reporter as A}from"../../tools/notifiers/reporter.js";import{logger as x}from"../../tools/notifiers/logger.js";import{sha1 as ft}from"../../utils/crypto/sha1.js";import{getInnerText as dt}from"../../../markdoc/helpers/get-inner-text.js";import{collectItemsLinkedToSidebars as ut,resolveItems as Z}from"../nav-utils.js";import{getExcludedFromLinkCheckerPatterns as mt,getSidebarReferences as gt,hasCircularDependency as pt}from"./utils.js";import{getLocaleFromRelativePath as ht}from"../../fs/utils/get-locale-from-relative-path.js";import{isSystemRouteSlug as St}from"../../utils/system-routes.js";import{ENTITIES_MAP_GLOBAL_DATA_KEY as yt}from"../../constants/plugins/catalog-entities.js";import{telemetryTraceStep as bt}from"../../../cli/telemetry/helpers/trace-step.js";const Ft=180,It=170,Ct=10;async function Jt({contentDir:l}){return{id:"sidebars",async afterRoutesCreated(o,i){await bt("build.plugin.sidebars",async()=>{const{cache:d,fs:c}=i,I=o.getConfig(),C=new Map,D=new Set,B=[v,...c.localeFolders],j=o.getGlobalData()[yt]||{},G=new Map;let L=c.scan(/sidebars.yaml$/).map(({relativePath:t})=>t).filter(t=>!wt(I.ignore??[],t)&&t);const $=await gt(i,l,L),q=it(L.filter(t=>!$.has(t)),t=>ct(t)?.versionFolderPath||t),_=mt(I),Q=await ut(I?.navbar,o,i,{navFile:V,excludedFromLinkCheckerPatterns:_});let P;const T=pt($);T&&Array.isArray(T)&&await A.panicOnBuildContentError(`Sidebar references have circular dependency. Please check your sidebar files.
|
|
2
2
|
Circular dependency chain: ${T.reverse().join(" -> ")}
|
|
3
|
-
`);for(const t of q){const m=(await Promise.all(t.map(async n=>{const e=(await d.load(n,"yaml")).data;if(!Array.isArray(e)){await A.panicOnBuildContentErrorForRealFile('Invalid sidebar contents at %rp, items should be an array, got "%s"',n,c,n,typeof e);return}return{items:e,sidebarRelativePath:n,locale:ht(n)}}))).filter(X),r=(await k(m))?.firstLink;P||(P=r)}const z=Object.entries(I?.catalogClassic??{});for(const t of B){for(const[e,s]of z)await W(e,s,t);const m={},r=new Set,n=o.getAllRoutesForLocale(t);for(const e of n)if(U(e)&&e.fsPath&&!r.has(e.fsPath)){r.add(e.fsPath);let f=u.posix.dirname(e.fsPath);const h=u.parse(f).root;do m[f]=(m[f]||0)+1,f=u.dirname(f);while(f&&f!="."&&h!=f)}for(const e of n){if(C.has(e.slug))continue;const s=U(e),f=u.dirname(e.fsPath),h=m[f]===1,g=vt(e.baseSlug||e.slug);s&&h?await k([{items:[{directory:f}],sidebarRelativePath:"sidebar.yaml_"+g,locale:t}]):e.getSidebar!==void 0&&await k([{items:[{page:e.fsPath}],sidebarRelativePath:"sidebar.yaml_"+g,locale:t}])}for(const[e,s]of z)await W(e,s,t,!0)}if(L.length===0)for(const t of B){x.verbose("Creating default sidebar");const m=t===v,r=`sidebars.yaml${m?"":"_"+t}`,n=m?"":`${c.localizationFolder}/${t}`,e=(await k([{items:[{directory:`./${n}`}],sidebarRelativePath:r,locale:t,ignoredRoutes:D}]))?.firstLink;P||(P=e)}if(!o.getRouteBySlug("/")&&!o.getConfig().redirects?.["/"]){const m=o.getAllRoutes().find(n=>!St(n.slug)),r=P?P.link:m?.baseSlug??null;if(r){const n=ot(r);o.addRedirect("/",{to:n,type:302}),x.info("Creating default redirect for index page => %s",n)}}const H=nt.REDOCLY_METADATA_OUTPUT_FOLDER;H&&(x.info("Writing catalog data..."),tt(u.join(H,rt),JSON.stringify(Object.fromEntries(G.entries()))));function U(t){return D.has(t.slug)||j[t.fsPath]}async function k(t){if(t.length===0)return;const r=(await Promise.all(t.map(async({items:g,locale:F,sidebarRelativePath:p,ignoredRoutes:R})=>{const a=await Z(g,u.dirname(u.join(l,p)),o,i,{locale:F,ignoredRoutes:R,navFile:p,excludedFromLinkCheckerPatterns:_});if(!a){await A.panicOnBuild("Failed to resolve sidebar configuration. Make sure %rp is valid",p);return}return a}))).flat().filter(X),n=N(r,"routeSlug"),e=t[0].sidebarRelativePath,s=J(e),f=new Set;for(const g of n){const F=o.getRouteBySlug(g)?.fsPath??"",p=j[F];p&&(Array.from(f).find(a=>a.key===p.key&&a.version===p.version)||f.add(p)),o.addRouteSharedData(g,"sidebar",s),C.set(Y(g),r)}const h=f.size===1?Array.from(f)[0]:void 0;return await o.createSharedData(s,{relatedNavbarItem:Q?.get(e),items:r,catalogEntity:h?{key:h.key,version:h.version}:void 0}),{firstLink:M(r,g=>!!g.link),resolved:r}}async function W(t,m,r,n=!1){const e=structuredClone(m);r&&r!==v&&e.items.forEach(a=>{a.directory=u.posix.join(c.localizationFolder||"",r,a.directory||"")});let s=await Z(e.items,l,o,i,{groupCustomSidebars:!0,locale:r,navFile:V,excludedFromLinkCheckerPatterns:_});if(s&&(s=Pt(s)),!s){await A.panicOnBuild(`Failed to resolve catalog configuration. Make sure catalog ${t} has valid config`);return}const f=r===v?"":"/"+r.toLowerCase(),h=r===v?"":`-${r}`,g=Y(u.posix.join(f,e.slug));if(n)for(const a of s){const S=M(a.items||[],b=>!!b.routeSlug);if(!S?.routeSlug)continue;const y=C.get(S.routeSlug);if(!y)continue;const O=N(y,"routeSlug"),E="current-catalog-info-"+a.routeSlug+h,w={catalog:{label:e.title,titleTranslationKey:e.titleTranslationKey,link:g,icon:e?.icon},item:{label:a.metadata?.title,link:a.link,icon:a.icon}};await o.createSharedData(E,w);for(const b of O)o.addRouteSharedData(b,"current-catalog-info",E),D.add(b);const K=M(y,b=>!!b.link&&!b.external&&st(b.link)&&(!a.version||b.version===a.version));K&&(a.sidebar=[{...K,items:void 0}])}const F={},p=new Set;for(const a of s){if(!(a.routeSlug||a.sidebar?.[0]?.routeSlug)||!a.fsPath||p.has(a.fsPath))continue;p.add(a.fsPath);const y=u.dirname(a.fsPath);F[y]=(F[y]||0)+1}if(n){const a=await o.createSharedData("catalog-"+t+h,s.flatMap(S=>{const y=u.dirname(S.fsPath??""),O=F[y]===1,E=w=>({...w,fsPath:O?y:w.fsPath??""});return S.type==="group"&&S.items?.every(w=>w.type==="group")?(S.items||[]).map(E):E(S)}));o.addRouteSharedData(g,"catalog",a),Dt(r,s,G,F)}const R=N(s,"routeSlug");for(const a of R)D.add(a)}})}}}function Dt(l,o,i,d){if(l===v)for(const c of o){const I=c.routeSlug||c.sidebar?.[0]?.routeSlug;if(!I||!c.fsPath)continue;const C=u.dirname(c.fsPath),D=d[C]===1;i.set(I,{rootFileFsPath:c.fsPath,fsPath:D?C:c.fsPath,metadata:c.metadata||{},title:c.metadata?.title||c.label||"Untitled",version:c.version||"latest"})}}function Pt(l){const o=i=>{if(!i)return i;const d=et.parse(i);return
|
|
3
|
+
`);for(const t of q){const m=(await Promise.all(t.map(async n=>{const e=(await d.load(n,"yaml")).data;if(!Array.isArray(e)){await A.panicOnBuildContentErrorForRealFile('Invalid sidebar contents at %rp, items should be an array, got "%s"',n,c,n,typeof e);return}return{items:e,sidebarRelativePath:n,locale:ht(n)}}))).filter(X),r=(await k(m))?.firstLink;P||(P=r)}const z=Object.entries(I?.catalogClassic??{});for(const t of B){for(const[e,s]of z)await W(e,s,t);const m={},r=new Set,n=o.getAllRoutesForLocale(t);for(const e of n)if(U(e)&&e.fsPath&&!r.has(e.fsPath)){r.add(e.fsPath);let f=u.posix.dirname(e.fsPath);const h=u.parse(f).root;do m[f]=(m[f]||0)+1,f=u.dirname(f);while(f&&f!="."&&h!=f)}for(const e of n){if(C.has(e.slug))continue;const s=U(e),f=u.dirname(e.fsPath),h=m[f]===1,g=vt(e.baseSlug||e.slug);s&&h?await k([{items:[{directory:f}],sidebarRelativePath:"sidebar.yaml_"+g,locale:t}]):e.getSidebar!==void 0&&await k([{items:[{page:e.fsPath}],sidebarRelativePath:"sidebar.yaml_"+g,locale:t}])}for(const[e,s]of z)await W(e,s,t,!0)}if(L.length===0)for(const t of B){x.verbose("Creating default sidebar");const m=t===v,r=`sidebars.yaml${m?"":"_"+t}`,n=m?"":`${c.localizationFolder}/${t}`,e=(await k([{items:[{directory:`./${n}`}],sidebarRelativePath:r,locale:t,ignoredRoutes:D}]))?.firstLink;P||(P=e)}if(!o.getRouteBySlug("/")&&!o.getConfig().redirects?.["/"]){const m=o.getAllRoutes().find(n=>!St(n.slug)),r=P?P.link:m?.baseSlug??null;if(r){const n=ot(r);o.addRedirect("/",{to:n,type:302}),x.info("Creating default redirect for index page => %s",n)}}const H=nt.REDOCLY_METADATA_OUTPUT_FOLDER;H&&(x.info("Writing catalog data..."),tt(u.join(H,rt),JSON.stringify(Object.fromEntries(G.entries()))));function U(t){return D.has(t.slug)||j[t.fsPath]}async function k(t){if(t.length===0)return;const r=(await Promise.all(t.map(async({items:g,locale:F,sidebarRelativePath:p,ignoredRoutes:R})=>{const a=await Z(g,u.dirname(u.join(l,p)),o,i,{locale:F,ignoredRoutes:R,navFile:p,excludedFromLinkCheckerPatterns:_});if(!a){await A.panicOnBuild("Failed to resolve sidebar configuration. Make sure %rp is valid",p);return}return a}))).flat().filter(X),n=N(r,"routeSlug"),e=t[0].sidebarRelativePath,s=J(e),f=new Set;for(const g of n){const F=o.getRouteBySlug(g)?.fsPath??"",p=j[F];p&&(Array.from(f).find(a=>a.key===p.key&&a.version===p.version)||f.add(p)),o.addRouteSharedData(g,"sidebar",s),C.set(Y(g),r)}const h=f.size===1?Array.from(f)[0]:void 0;return await o.createSharedData(s,{relatedNavbarItem:Q?.get(e),items:r,catalogEntity:h?{key:h.key,version:h.version}:void 0}),{firstLink:M(r,g=>!!g.link),resolved:r}}async function W(t,m,r,n=!1){const e=structuredClone(m);r&&r!==v&&e.items.forEach(a=>{a.directory=u.posix.join(c.localizationFolder||"",r,a.directory||"")});let s=await Z(e.items,l,o,i,{groupCustomSidebars:!0,locale:r,navFile:V,excludedFromLinkCheckerPatterns:_});if(s&&(s=Pt(s)),!s){await A.panicOnBuild(`Failed to resolve catalog configuration. Make sure catalog ${t} has valid config`);return}const f=r===v?"":"/"+r.toLowerCase(),h=r===v?"":`-${r}`,g=Y(u.posix.join(f,e.slug));if(n)for(const a of s){const S=M(a.items||[],b=>!!b.routeSlug);if(!S?.routeSlug)continue;const y=C.get(S.routeSlug);if(!y)continue;const O=N(y,"routeSlug"),E="current-catalog-info-"+a.routeSlug+h,w={catalog:{label:e.title,titleTranslationKey:e.titleTranslationKey,link:g,icon:e?.icon},item:{label:a.metadata?.title,link:a.link,icon:a.icon}};await o.createSharedData(E,w);for(const b of O)o.addRouteSharedData(b,"current-catalog-info",E),D.add(b);const K=M(y,b=>!!b.link&&!b.external&&st(b.link)&&(!a.version||b.version===a.version));K&&(a.sidebar=[{...K,items:void 0}])}const F={},p=new Set;for(const a of s){if(!(a.routeSlug||a.sidebar?.[0]?.routeSlug)||!a.fsPath||p.has(a.fsPath))continue;p.add(a.fsPath);const y=u.dirname(a.fsPath);F[y]=(F[y]||0)+1}if(n){const a=await o.createSharedData("catalog-"+t+h,s.flatMap(S=>{const y=u.dirname(S.fsPath??""),O=F[y]===1,E=w=>({...w,fsPath:O?y:w.fsPath??""});return S.type==="group"&&S.items?.every(w=>w.type==="group")?(S.items||[]).map(E):E(S)}));o.addRouteSharedData(g,"catalog",a),Dt(r,s,G,F)}const R=N(s,"routeSlug");for(const a of R)D.add(a)}})}}}function Dt(l,o,i,d){if(l===v)for(const c of o){const I=c.routeSlug||c.sidebar?.[0]?.routeSlug;if(!I||!c.fsPath)continue;const C=u.dirname(c.fsPath),D=d[C]===1;i.set(I,{rootFileFsPath:c.fsPath,fsPath:D?C:c.fsPath,metadata:c.metadata||{},title:c.metadata?.title||c.label||"Untitled",version:c.version||"latest"})}}function Pt(l){const o=i=>{if(!i)return i;const d=et.parse(i);return dt([d])};return l.map(i=>{const d={...i};return d.metadata?.description&&(d.metadata={...d.metadata,description:o(d.metadata.description)}),d})}function J(l){return at+lt(l)}async function qt(l,o,i){const d=u.posix.join(u.dirname(l),o);return await i.exists(d)?J(d):(await A.panicOnBuildContentErrorForRealFile("File %rp: Failed to create relative path for sidebars.yaml using %s",l,i,l,o),null)}function wt(l,o){const i=/\/?([a-zA-Z0-9-_]+\/)*sidebars?(-[a-zA-Z0-9-_]+)?\.yaml/;return l.filter(c=>i.test(c)).includes(o)}function vt(l){const o=l.replaceAll("/","_");if(o.length>Ft){const i=o.slice(0,It),d=ft(l).slice(0,Ct).replaceAll("/","_");return i+d}else return o}export{wt as isSidebarIgnored,Pt as removeMarkdownTags,qt as resolveSidebarId,Jt as sidebarsPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pathToFileURL as I}from"url";import{HelmetProvider as z}from"@dr.pogodin/react-helmet";import{renderToString as m}from"react-dom/server";import{StaticRouterProvider as G,createStaticHandler as J,createStaticRouter as K}from"react-router-dom/server.js";import r from"react";import{readFile as Q}from"fs/promises";import{join as V}from"path";import{withPathPrefix as l,getLocaleFromPathname as W,withoutPathPrefix as X,removeTrailingSlash as Y}from"@redocly/theme/core/utils";import{RUNTIME_RESOURCES_DIR as T}from"../constants/common.js";import{slash as Z}from"../../utils/path/slash.js";import{reporter as tt}from"../tools/notifiers/reporter.js";import{envConfig as p}from"../config/env-config.js";import{slug as et}from"
|
|
1
|
+
import{pathToFileURL as I}from"url";import{HelmetProvider as z}from"@dr.pogodin/react-helmet";import{renderToString as m}from"react-dom/server";import{StaticRouterProvider as G,createStaticHandler as J,createStaticRouter as K}from"react-router-dom/server.js";import r from"react";import{readFile as Q}from"fs/promises";import{join as V}from"path";import{withPathPrefix as l,getLocaleFromPathname as W,withoutPathPrefix as X,removeTrailingSlash as Y}from"@redocly/theme/core/utils";import{RUNTIME_RESOURCES_DIR as T}from"../constants/common.js";import{slash as Z}from"../../utils/path/slash.js";import{reporter as tt}from"../tools/notifiers/reporter.js";import{envConfig as p}from"../config/env-config.js";import{slug as et}from"../../utils/slugger.js";import{htmlTemplate as rt}from"./template.js";import{detectColorSchemaScript as ot,generatePreloadPageData as st}from"./utils.js";import"./hijack-console.js";import{getSitemapLinkTag as nt}from"./get-sitemap-link-tag.js";let g="";async function at(t){return p.isRuntimeMode?await import("../../client/server-entry.js"):await import(I(`${Z(t)}/server-entry.js`)+"?"+new Date)}async function vt(t){if(!p.isRuntimeMode){const e=tt.getCompilationProblems();if(e.length>0){const{renderCompilationError:n}=await import("./render-compilation-error.js");return n(e)}}const{Loader:u,App:R,routes:E,ServerStyleSheet:w,StyleSheetManager:C,ErrorDetails:y,initL10n:P}=await at(t.serverOutDir),{page:h,store:{globalData:S,hasSitemap:D},sharedData:v,ssrHref:b}=t,f=S?.l10n,i=W(X(h.slug),f?.defaultLocale,f?.locales),d=t.page.request?.url||"http://localhost/";await u.prepare({...h,slug:Y(new URL(d).pathname)},v,S,i),await P(i);const c=new w,{query:M,dataRoutes:x}=J([{Component:R,path:l("*"),children:E}]),s=await M(new Request(d));if(s instanceof Response)throw s;const B=K(x,s);try{globalThis.SSR_HOSTNAME=b,globalThis.SSR_USER_AGENT=t.userAgent,globalThis.SSR_OMIT_SUSPENSE=t.omitSuspense;const e={},n=m(r.createElement(z,{context:e},r.createElement(C,{sheet:c.instance},r.createElement(G,{router:B,context:s})))),L=D?nt():"",a=e.helmet,k=a?.title.toString()||"",_=t.store.globalData?.logo?.favicon,o=t.store.config,j=`<link rel="preload" as="fetch" crossorigin="anonymous" href="${l("/app-data.json")}" />`,H=st(t.page.slug),U=ot(o),A=t.page.product?.name?`product-${et(t.page.product.name)}`:"",$=t.store.ssr.headTags.join(""),F=t.store.ssr.postBodyTags.join(""),N=t.store.ssr.preBodyTags.join(""),O=`<link rel="stylesheet" href="${l(T)}/browser-entry.css" />`;!p.isDevelopMode&&!g&&(g=`<style>${await Q(V(t.outdir,T,"browser-entry.css"),"utf-8")}</style>`);const q={bodyHtml:n,linkTags:o.linkTags+c.getStyleTags()+(a?.link.toString()||""),title:k,favicon:_,headScriptTags:L+U+o.headScriptTags+$+(a?.script.toString()||"")+(a?.meta.toString()||""),preload:[j,H],postBodyScriptTags:o.postBodyScriptTags+F,preBodyScriptTags:o.preBodyScriptTags||""+N,lang:i,productClass:A,runtimeCss:g||O};return{html:rt(q),statusCode:200}}catch(e){return t.telemetry.sendSsrErrorCaughtMessage({message:e.message}),{html:m(r.createElement(y,{error:e})),statusCode:500,error:e}}finally{c.seal(),u.clear()}}function bt(t){return m(r.createElement(r.Fragment,null,...t))}export{vt as render,bt as renderComponents};
|