@redocly/api-docs 0.2.0-next.1 → 0.2.0-next.10
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/lib/RedocStandalone.d.ts +38 -0
- package/lib/RedocStandalone.js +1 -0
- package/lib/RedoclyApiDocs.js +1 -1
- package/lib/RedoclyApiDocsStandalone.d.ts +2 -0
- package/lib/RedoclyApiDocsStandalone.js +3 -3
- package/lib/adapters/asyncapi/build/navigation.js +1 -1
- package/lib/adapters/asyncapi/items/channel/content.js +1 -1
- package/lib/adapters/asyncapi/items/channel/item.js +1 -1
- package/lib/adapters/asyncapi/items/operation/item.js +1 -1
- package/lib/adapters/asyncapi/items/overview/content.js +1 -1
- package/lib/adapters/graphql/group/utils.js +1 -1
- package/lib/adapters/graphql/utils/createApiItem.js +1 -1
- package/lib/adapters/helpers.d.ts +3 -10
- package/lib/adapters/helpers.js +1 -1
- package/lib/adapters/openapi/build/context.js +1 -1
- package/lib/adapters/openapi/build-code-sample-source.d.ts +1 -1
- package/lib/adapters/openapi/build-code-sample-source.js +1 -1
- package/lib/adapters/openapi/configure/merge-utils.d.ts +1 -1
- package/lib/adapters/openapi/configure/resolve-request-values.js +1 -1
- package/lib/adapters/openapi/group/item.d.ts +0 -3
- package/lib/adapters/openapi/group/item.js +1 -1
- package/lib/adapters/openapi/index.js +1 -1
- package/lib/adapters/openapi/items/operation/content.js +1 -1
- package/lib/adapters/openapi/items/operation/item.d.ts +2 -2
- package/lib/adapters/openapi/items/operation/item.js +1 -1
- package/lib/adapters/openapi/items/overview/content.js +1 -1
- package/lib/adapters/openapi/items/schema/item.js +1 -1
- package/lib/adapters/openapi/store.js +1 -1
- package/lib/adapters/openapi/utils/merge-mock-server.d.ts +2 -2
- package/lib/adapters/rbac.d.ts +14 -0
- package/lib/adapters/rbac.js +1 -0
- package/lib/adapters/utils/descriptionToMarkdown.d.ts +6 -0
- package/lib/adapters/utils/descriptionToMarkdown.js +11 -0
- package/lib/adapters/utils/markdoc.d.ts +8 -1
- package/lib/adapters/utils/markdoc.js +1 -1
- package/lib/components/ErrorBoundary.d.ts +4 -2
- package/lib/components/ErrorBoundary.js +55 -1
- package/lib/components/Header/HeaderItem.js +5 -5
- package/lib/components/Header/HeaderPageActions.d.ts +4 -0
- package/lib/components/Header/HeaderPageActions.js +1 -0
- package/lib/components/Header/PageActions.d.ts +4 -0
- package/lib/components/Header/PageActions.js +11 -0
- package/lib/components/ItemContent/hooks.d.ts +12 -1
- package/lib/components/ItemContent/hooks.js +1 -1
- package/lib/components/ItemContent/sections/BodySection.js +3 -3
- package/lib/components/ItemContent/sections/CallbacksSection.js +4 -4
- package/lib/components/ItemContent/sections/MessagesSection.js +17 -17
- package/lib/components/ItemContent/sections/ResponsesSection.js +7 -7
- package/lib/components/Mcp/McpPrompt.js +1 -1
- package/lib/components/Mcp/McpTool.js +1 -1
- package/lib/components/Mcp/utils.d.ts +1 -1
- package/lib/components/Mcp/utils.js +1 -1
- package/lib/components/Schema/SchemaDescription.js +1 -1
- package/lib/components/Schema/styled.js +5 -5
- package/lib/components/Schema/views/ArrayRenderer.js +1 -1
- package/lib/components/Schema/views/CollapsibleNestedFields.js +1 -1
- package/lib/components/Schema/views/DiscriminatorPropertyRow.js +1 -1
- package/lib/components/Schema/views/Examples.js +1 -1
- package/lib/components/Schema/views/SwitcherRenderer.js +1 -1
- package/lib/components/Search/index.d.ts +15 -0
- package/lib/components/Search/index.js +1 -0
- package/lib/components/Security/SecurityFlowDetail.js +1 -1
- package/lib/components/Security/styled.js +7 -7
- package/lib/components/StickySidebar/FloatingButton.d.ts +1 -0
- package/lib/components/StickySidebar/FloatingButton.js +32 -0
- package/lib/components/StickySidebar/RedoclyAttributionLogo.d.ts +5 -0
- package/lib/components/StickySidebar/RedoclyAttributionLogo.js +1 -0
- package/lib/components/StickySidebar/StickySidebar.js +33 -9
- package/lib/components/common/Breadcrumbs.js +2 -2
- package/lib/components/common/DeepLinkAnchor.js +9 -9
- package/lib/components/common/PanelItem.js +5 -5
- package/lib/components/common/ResponseCodeTabs.js +1 -1
- package/lib/components/common/Tag.js +1 -1
- package/lib/components/common/VendorExtensions.js +1 -1
- package/lib/components/common/ViewNested.js +2 -2
- package/lib/components/graphql/GraphQLFieldView.js +1 -1
- package/lib/components/graphql/RequiresScopesModal.js +3 -3
- package/lib/components/graphql/sections/GraphQLArgsSection.js +1 -1
- package/lib/components/markdoc/SchemaDefinition.js +1 -1
- package/lib/components/markdoc/html/html-jsx-attribute-mapping.d.ts +5 -0
- package/lib/components/markdoc/html/html-jsx-attribute-mapping.js +1 -0
- package/lib/components/markdoc/html/process-html-tokens.d.ts +1 -0
- package/lib/components/markdoc/html/process-html-tokens.js +1 -0
- package/lib/components/markdoc/markdocParser.d.ts +2 -0
- package/lib/components/markdoc/markdocParser.js +1 -1
- package/lib/components/panels/ExampleItem/CallbackPayloadItem.js +2 -2
- package/lib/components/panels/ExampleItem/CodeSampleItem.js +1 -1
- package/lib/components/panels/ExampleItem/PayloadExampleItem.js +2 -2
- package/lib/components/panels/ExampleItem/ResponseExampleItem.js +1 -1
- package/lib/components/panels/ExampleItem/SecuritySchemeSelector.d.ts +9 -0
- package/lib/components/panels/ExampleItem/SecuritySchemeSelector.js +1 -0
- package/lib/components/panels/ExampleItem/ServerDropdown.js +2 -2
- package/lib/components/panels/ExampleItem/generate-request-sample.d.ts +28 -0
- package/lib/components/panels/ExampleItem/generate-request-sample.js +1 -0
- package/lib/components/panels/ExampleItem/selectors.d.ts +5 -2
- package/lib/components/panels/ExampleItem/selectors.js +1 -1
- package/lib/components/panels/ExampleItem/styled.d.ts +2 -49
- package/lib/components/panels/ExampleItem/styled.js +11 -5
- package/lib/components/panels/ExampleItem/useActiveServer.d.ts +17 -0
- package/lib/components/panels/ExampleItem/useActiveServer.js +1 -0
- package/lib/components/panels/ExampleItem/useCodeSampleLanguages.d.ts +23 -0
- package/lib/components/panels/ExampleItem/useCodeSampleLanguages.js +1 -0
- package/lib/components/panels/ExampleItem/useReplayRequestState.d.ts +18 -0
- package/lib/components/panels/ExampleItem/useReplayRequestState.js +1 -0
- package/lib/components/panels/ExampleItem/useTryItFooter.d.ts +3 -0
- package/lib/components/panels/ExampleItem/useTryItFooter.js +7 -0
- package/lib/components/panels/GroupPanelItem.js +1 -1
- package/lib/components/panels/LanguageItem/LanguagePanelItem.js +5 -1
- package/lib/components/panels/LanguageItem/styled.js +17 -14
- package/lib/components/panels/McpExamplePanelItem.js +2 -2
- package/lib/components/panels/McpPanelItem.js +2 -2
- package/lib/components/panels/ServerItem/ServerItem.js +1 -1
- package/lib/components/panels/asyncapi/BrokerItem/BrokerModal.js +1 -1
- package/lib/components/panels/asyncapi/BrokerItem/BrokerPanelItem.js +1 -1
- package/lib/components/panels/asyncapi/MessageBindingItem/MessageBindingItem.js +1 -1
- package/lib/components/panels/shared-panel-styles.js +1 -1
- package/lib/components/panels/styled.js +1 -1
- package/lib/components/pluggable/RedocExample.js +5 -2
- package/lib/components/pluggable/RedocResponseSamples.js +1 -1
- package/lib/hoc/withLicenseGate.d.ts +5 -0
- package/lib/hoc/withLicenseGate.js +1 -0
- package/lib/hoc/withRouter.js +1 -1
- package/lib/hoc/withStoreProvider.d.ts +2 -0
- package/lib/hoc/withStoreProvider.js +1 -1
- package/lib/hooks/deepLinkHash.d.ts +5 -0
- package/lib/hooks/deepLinkHash.js +1 -0
- package/lib/hooks/useApiDocsScroll.js +1 -1
- package/lib/hooks/useCopySpecSlice.d.ts +9 -0
- package/lib/hooks/useCopySpecSlice.js +1 -0
- package/lib/hooks/useDeepLinkSection.js +1 -1
- package/lib/hooks/useInitialTelemetry.d.ts +2 -0
- package/lib/hooks/useInitialTelemetry.js +1 -0
- package/lib/hooks/useLicense.js +1 -1
- package/lib/hooks/useLicenseGate.d.ts +6 -0
- package/lib/hooks/useLicenseGate.js +1 -0
- package/lib/hooks/useRouterHashBridge.d.ts +4 -0
- package/lib/hooks/useRouterHashBridge.js +1 -1
- package/lib/hooks/useScrollSpyUrlSync.js +1 -1
- package/lib/hooks/useUrlHash.d.ts +3 -2
- package/lib/hooks/useUrlHash.js +1 -1
- package/lib/hooks/useUrlHashReassert.d.ts +2 -0
- package/lib/hooks/useUrlHashReassert.js +1 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +1 -1
- package/lib/jotai/app.d.ts +6 -0
- package/lib/jotai/app.js +1 -1
- package/lib/jotai/examples.js +1 -1
- package/lib/jotai/itemStore.d.ts +1 -0
- package/lib/jotai/itemStore.js +1 -1
- package/lib/jotai/store.d.ts +4 -0
- package/lib/jotai/store.js +1 -1
- package/lib/options/editionOverrides.d.ts +3 -0
- package/lib/options/editionOverrides.js +1 -0
- package/lib/options/helpers.d.ts +1 -2
- package/lib/options/helpers.js +1 -1
- package/lib/options/normalizeOptions.d.ts +1 -1
- package/lib/options/normalizeOptions.js +1 -1
- package/lib/options/standaloneLayoutVars.d.ts +3 -0
- package/lib/options/standaloneLayoutVars.js +1 -0
- package/lib/otel-semantic-conventions.d.ts +10 -0
- package/lib/otel-semantic-conventions.js +1 -0
- package/lib/pages/ItemPage.js +4 -2
- package/lib/pages/NotFoundPage.js +40 -1
- package/lib/services/code-samples/apply-env-variables.d.ts +8 -0
- package/lib/services/code-samples/apply-env-variables.js +1 -0
- package/lib/services/code-samples/builder.d.ts +8 -5
- package/lib/services/code-samples/builder.js +1 -1
- package/lib/services/code-samples/discriminator.d.ts +16 -10
- package/lib/services/code-samples/discriminator.js +1 -1
- package/lib/services/code-samples/generators/java8.js +2 -2
- package/lib/services/code-samples/language-availability.d.ts +4 -0
- package/lib/services/code-samples/language-availability.js +1 -0
- package/lib/services/code-samples/{replay/normalize-servers.d.ts → normalize-servers.d.ts} +1 -1
- package/lib/services/code-samples/normalize-servers.js +1 -0
- package/lib/services/code-samples/replay/embedded-replay-converter.d.ts +1 -1
- package/lib/services/code-samples/replay/embedded-replay-converter.js +1 -1
- package/lib/services/code-samples/replay/find-operation.d.ts +17 -0
- package/lib/services/code-samples/replay/find-operation.js +1 -0
- package/lib/services/code-samples/replay/from-openapi-document.d.ts +12 -2
- package/lib/services/code-samples/replay/from-openapi-document.js +1 -1
- package/lib/services/code-samples/replay/index.d.ts +1 -1
- package/lib/services/code-samples/replay/index.js +1 -1
- package/lib/services/code-samples/replay/overlay-converter.js +1 -1
- package/lib/services/code-samples/replay/parameter-descriptions.d.ts +7 -0
- package/lib/services/code-samples/replay/parameter-descriptions.js +1 -0
- package/lib/services/code-samples/replay/replay-adapter.d.ts +1 -1
- package/lib/services/code-samples/replay/replay-adapter.js +1 -1
- package/lib/services/code-samples/replay/replay-handler.js +1 -1
- package/lib/services/code-samples/replay/replay-predefined-env.d.ts +1 -2
- package/lib/services/code-samples/replay/replay-predefined-env.js +1 -1
- package/lib/services/code-samples/replay/schema-declared-value.d.ts +2 -0
- package/lib/services/code-samples/replay/schema-declared-value.js +1 -0
- package/lib/services/code-samples/resolvers.js +1 -1
- package/lib/services/code-samples/server-env.d.ts +3 -0
- package/lib/services/code-samples/server-env.js +1 -0
- package/lib/services/code-samples/source.d.ts +3 -3
- package/lib/services/license/check.d.ts +1 -0
- package/lib/services/license/check.js +1 -1
- package/lib/services/operation-samples/index.js +1 -1
- package/lib/services/schema/dialects/jsonSchema.d.ts +5 -1
- package/lib/services/schema/dialects/jsonSchema.js +1 -1
- package/lib/services/schema/propertyTreeBuilder.js +1 -1
- package/lib/services/search/index.d.ts +2 -0
- package/lib/services/search/index.js +1 -0
- package/lib/services/search/indexer/context.d.ts +8 -0
- package/lib/services/search/indexer/context.js +0 -0
- package/lib/services/search/indexer/deep-links.d.ts +12 -0
- package/lib/services/search/indexer/deep-links.js +1 -0
- package/lib/services/search/indexer/extractors/asyncapi.d.ts +8 -0
- package/lib/services/search/indexer/extractors/asyncapi.js +1 -0
- package/lib/services/search/indexer/extractors/body.d.ts +2 -0
- package/lib/services/search/indexer/extractors/body.js +1 -0
- package/lib/services/search/indexer/extractors/callbacks.d.ts +4 -0
- package/lib/services/search/indexer/extractors/callbacks.js +1 -0
- package/lib/services/search/indexer/extractors/context.d.ts +25 -0
- package/lib/services/search/indexer/extractors/context.js +1 -0
- package/lib/services/search/indexer/extractors/examples.d.ts +3 -0
- package/lib/services/search/indexer/extractors/examples.js +1 -0
- package/lib/services/search/indexer/extractors/graphql.d.ts +2 -0
- package/lib/services/search/indexer/extractors/graphql.js +1 -0
- package/lib/services/search/indexer/extractors/heading-sections.d.ts +3 -0
- package/lib/services/search/indexer/extractors/heading-sections.js +1 -0
- package/lib/services/search/indexer/extractors/index.d.ts +12 -0
- package/lib/services/search/indexer/extractors/index.js +1 -0
- package/lib/services/search/indexer/extractors/mcp.d.ts +9 -0
- package/lib/services/search/indexer/extractors/mcp.js +1 -0
- package/lib/services/search/indexer/extractors/named-rows.d.ts +9 -0
- package/lib/services/search/indexer/extractors/named-rows.js +1 -0
- package/lib/services/search/indexer/extractors/panels.d.ts +10 -0
- package/lib/services/search/indexer/extractors/panels.js +1 -0
- package/lib/services/search/indexer/extractors/parameters.d.ts +2 -0
- package/lib/services/search/indexer/extractors/parameters.js +1 -0
- package/lib/services/search/indexer/extractors/responses.d.ts +2 -0
- package/lib/services/search/indexer/extractors/responses.js +1 -0
- package/lib/services/search/indexer/extractors/schema-page.d.ts +9 -0
- package/lib/services/search/indexer/extractors/schema-page.js +1 -0
- package/lib/services/search/indexer/extractors/security.d.ts +4 -0
- package/lib/services/search/indexer/extractors/security.js +1 -0
- package/lib/services/search/indexer/index.d.ts +14 -0
- package/lib/services/search/indexer/index.js +1 -0
- package/lib/services/search/indexer/param.d.ts +7 -0
- package/lib/services/search/indexer/param.js +1 -0
- package/lib/services/search/indexer/places.d.ts +40 -0
- package/lib/services/search/indexer/places.js +1 -0
- package/lib/services/search/indexer/schema-walker.d.ts +29 -0
- package/lib/services/search/indexer/schema-walker.js +1 -0
- package/lib/services/search/indexer/text.d.ts +2 -0
- package/lib/services/search/indexer/text.js +1 -0
- package/lib/services/search/types.d.ts +28 -0
- package/lib/services/search/types.js +0 -0
- package/lib/services/spec-slice/assistant-links.d.ts +9 -0
- package/lib/services/spec-slice/assistant-links.js +5 -0
- package/lib/services/spec-slice/asyncapi-slice.d.ts +5 -0
- package/lib/services/spec-slice/asyncapi-slice.js +1 -0
- package/lib/services/spec-slice/clone-strip.d.ts +1 -0
- package/lib/services/spec-slice/clone-strip.js +1 -0
- package/lib/services/spec-slice/component-closure.d.ts +6 -0
- package/lib/services/spec-slice/component-closure.js +1 -0
- package/lib/services/spec-slice/graphql-slice.d.ts +2 -0
- package/lib/services/spec-slice/graphql-slice.js +1 -0
- package/lib/services/spec-slice/index.d.ts +6 -0
- package/lib/services/spec-slice/index.js +1 -0
- package/lib/services/spec-slice/openapi-slice.d.ts +6 -0
- package/lib/services/spec-slice/openapi-slice.js +1 -0
- package/lib/services/spec-slice/resolve-scope.d.ts +4 -0
- package/lib/services/spec-slice/resolve-scope.js +1 -0
- package/lib/services/spec-slice/types.d.ts +37 -0
- package/lib/services/spec-slice/types.js +0 -0
- package/lib/standalone.d.ts +19 -0
- package/lib/standalone.js +2 -0
- package/lib/standaloneThemeConfig.d.ts +3 -0
- package/lib/standaloneThemeConfig.js +1 -0
- package/lib/telemetry/RedocTelemetry.d.ts +3 -0
- package/lib/telemetry/RedocTelemetry.js +1 -1
- package/lib/telemetry/defaults.d.ts +2 -0
- package/lib/telemetry/defaults.js +1 -0
- package/lib/types/asyncapi.d.ts +2 -1
- package/lib/types/code-samples-config.d.ts +68 -0
- package/lib/types/code-samples-config.js +0 -0
- package/lib/types/common.d.ts +1 -2
- package/lib/types/content.d.ts +6 -4
- package/lib/types/edition-config.d.ts +4 -0
- package/lib/types/edition-config.js +0 -0
- package/lib/types/events.d.ts +2 -2
- package/lib/types/openapi.d.ts +3 -3
- package/lib/types/options.d.ts +24 -88
- package/lib/types/store.d.ts +3 -2
- package/lib/url-compat.d.ts +22 -0
- package/lib/url-compat.js +1 -0
- package/lib/utils/compose.d.ts +1 -0
- package/lib/utils/deep-link.d.ts +2 -1
- package/lib/utils/deep-link.js +1 -1
- package/lib/utils/extract-extensions.js +1 -1
- package/lib/utils/graphql-parse.d.ts +1 -0
- package/lib/utils/graphql-parse.js +1 -0
- package/lib/utils/scroll-anchoring.d.ts +2 -1
- package/lib/utils/x-logo.d.ts +13 -0
- package/lib/utils/x-logo.js +1 -0
- package/lib/yaml-compat.d.ts +7 -0
- package/lib/yaml-compat.js +1 -0
- package/package.json +36 -15
- package/lib/services/code-samples/replay/normalize-servers.js +0 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type { ApiItem, ApiStore } from './types/store.js';
|
|
3
|
+
import type { ApiSpecType } from './types/common.js';
|
|
4
|
+
import type { RawApiDocsOptions } from './types/options.js';
|
|
5
|
+
import type { RedocTelemetryConfig } from './telemetry/RedocTelemetry.js';
|
|
6
|
+
import type { MarkdownAdapter } from './contexts/markdownAdapter.js';
|
|
7
|
+
import type { RedoclyApiDocsStandaloneProps } from './RedoclyApiDocsStandalone.js';
|
|
8
|
+
type RedocStandaloneProps = {
|
|
9
|
+
/** Parsed definition object, or a GraphQL SDL string when `specType` is `graphql`. */
|
|
10
|
+
definition?: Record<string, unknown> | string;
|
|
11
|
+
/** URL to fetch the definition from. Ignored when `definition` is provided. */
|
|
12
|
+
definitionUrl?: string;
|
|
13
|
+
/** Detected automatically when omitted (`.graphql`/`.gql` URL or document shape). */
|
|
14
|
+
specType?: ApiSpecType;
|
|
15
|
+
options?: Partial<RawApiDocsOptions>;
|
|
16
|
+
basePath?: string;
|
|
17
|
+
logo?: RedoclyApiDocsStandaloneProps['logo'];
|
|
18
|
+
markdownAdapter?: MarkdownAdapter;
|
|
19
|
+
telemetryConfig?: Partial<RedocTelemetryConfig>;
|
|
20
|
+
onLoaded?: (error?: Error) => void;
|
|
21
|
+
/** Rendered while the definition is loading. */
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
};
|
|
24
|
+
type PreparedApiDocs = {
|
|
25
|
+
items: ApiItem[];
|
|
26
|
+
store: ApiStore;
|
|
27
|
+
options: RawApiDocsOptions;
|
|
28
|
+
specType: ApiSpecType;
|
|
29
|
+
/** Bundled definition, or the raw SDL string for GraphQL. */
|
|
30
|
+
document?: Record<string, unknown> | string;
|
|
31
|
+
};
|
|
32
|
+
export declare function detectSpecType({ definition, definitionUrl, specType, }: Pick<RedocStandaloneProps, 'definition' | 'definitionUrl' | 'specType'>): ApiSpecType | undefined;
|
|
33
|
+
declare function prepareApiDocs({ definition, definitionUrl, specType, options, basePath, }: Pick<RedocStandaloneProps, 'definition' | 'definitionUrl' | 'specType' | 'options' | 'basePath'>): Promise<PreparedApiDocs>;
|
|
34
|
+
/** Loads and bundles the definition, builds the item model, and renders `RedoclyApiDocsStandalone`. */
|
|
35
|
+
declare const RedocStandalone: ({ definition, definitionUrl, specType, options, basePath, logo, markdownAdapter, telemetryConfig, onLoaded, children, }: RedocStandaloneProps) => ReactElement | null;
|
|
36
|
+
export { RedocStandalone, prepareApiDocs };
|
|
37
|
+
export type { RedocStandaloneProps };
|
|
38
|
+
export default RedocStandalone;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as b,jsx as d,jsxs as x}from"react/jsx-runtime";import{useEffect as E,useMemo as L,useState as P}from"react";import{Loading as S}from"@redocly/theme/components/Loaders/Loading";import{RedoclyApiDocsStandalone as T}from"./RedoclyApiDocsStandalone.js";import{buildItems as k}from"./adapters/build.js";import{markdocParser as D}from"./components/markdoc/markdocParser.js";import{argValueToBoolean as w}from"./options/helpers.js";import{loadAndBundleDefinition as I}from"./utils/loadAndBundleSpec.js";import{logoFromDefinition as v}from"./utils/x-logo.js";import{apiSpecType as s}from"./types/common.js";const B=/\.(graphql|gql)([?#]|$)/i;function F({definition:e,definitionUrl:r,specType:o}){if(o)return o;if(typeof e=="string"||B.test(r??""))return s.GRAPHQL;if(e&&typeof e=="object")return"asyncapi"in e?s.ASYNCAPI:s.OPENAPI}function G(e){if(typeof e!="object"||e===null)throw new Error('"definition" must be an object when "skipBundle" is enabled');return e}async function H({definition:e,definitionUrl:r,specType:o,skipBundle:a}){if(e===void 0&&r===void 0)throw new Error('Either "definition" or "definitionUrl" must be provided');const n=F({definition:e,definitionUrl:r,specType:o});if(n===s.GRAPHQL){const p=typeof e=="string"?e:await(await fetch(r)).text(),{parse:i}=await import("./utils/graphql-parse.js");return{document:i(p),type:s.GRAPHQL,sdl:p}}const t=a?G(e):await I(e??r),c=n??(t&&typeof t=="object"&&"asyncapi"in t?s.ASYNCAPI:s.OPENAPI);return{document:t,type:c}}async function h({definition:e,definitionUrl:r,specType:o,options:a={},basePath:n="/"}){const t=await H({definition:e,definitionUrl:r,specType:o,skipBundle:w(a.skipBundle,!1)}),c={specType:t.type,metadata:{type:t.type},...a},{items:p,store:i}=await k({type:t.type,document:t.document,options:c,basePath:n,markdownParser:D});return{items:p,store:i,options:c,specType:t.type,document:t.type===s.GRAPHQL?t.sdl:t.document}}const j=({definition:e,definitionUrl:r,specType:o,options:a,basePath:n="/",logo:t,markdownAdapter:c,telemetryConfig:p,onLoaded:i,children:f})=>{const[u,y]=P(null),[g,A]=P(null),R=L(()=>({typeOfUsage:"react",...p}),[p]);return E(()=>{let m=!1;return y(null),A(null),h({definition:e,definitionUrl:r,specType:o,options:a,basePath:n}).then(l=>{m||(y(l),i?.())}).catch(l=>{m||(A(l),i?.(l))}),()=>{m=!0}},[e,r,o,n]),g?x("div",{role:"alert",style:{padding:"1em",fontFamily:"monospace",color:"#e53e3e"},children:["Failed to load API definition: ",g.message]}):u?d(T,{items:u.items,store:u.store,basePath:n,options:u.options,logo:t??v(u.document),markdownAdapter:c,telemetryConfig:R,definition:u.document,definitionUrl:r}):f!==void 0?d(b,{children:f}):w(a?.hideLoading,!1)?null:d(S,{color:"--loading-spinner-color"})};var z=j;export{j as RedocStandalone,z as default,F as detectSpecType,h as prepareApiDocs};
|
package/lib/RedoclyApiDocs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{Fragment as T,jsx as o,jsxs as f}from"react/jsx-runtime";import{memo as v,useMemo as S}from"react";import{useAtomValue as x}from"jotai";import{GlobalStyle as R}from"@redocly/theme/core/openapi";import{RedocTelemetry as b}from"./telemetry/RedocTelemetry.js";import{TelemetryContext as P}from"./contexts/telemetry.js";import{MarkdownAdapterProvider as A}from"./contexts/markdownAdapter.js";import{specTypeAtom as w}from"./jotai/store.js";import{useApiDocsRoutes as U}from"./hooks/useApiDocsRoutes.js";import{useVisitedChannelsTracker as C}from"./hooks/useVisitedChannelsTracker.js";import{useRouterHashBridge as D}from"./hooks/useRouterHashBridge.js";import{useScrollSpyUrlSync as V}from"./hooks/useScrollSpyUrlSync.js";import{useTelemetryPageMetrics as j}from"./hooks/useTelemetryPageMetrics.js";import{useInitialTelemetry as I}from"./hooks/useInitialTelemetry.js";import{EntryPage as k}from"./pages/EntryPage.js";import{ErrorBoundary as B}from"./components/ErrorBoundary.js";import{compose as M}from"./utils/compose.js";import{withRouter as N}from"./hoc/withRouter.js";import{withStoreProvider as O}from"./hoc/withStoreProvider.js";import{withLicenseGate as _}from"./hoc/withLicenseGate.js";import{withReplayPrefetch as E}from"./hoc/withReplayPrefetch.js";const d=e=>{const{items:t=[],basePath:m,markdownAdapter:y,telemetryConfig:r}=e,{routeIndex:g}=U(t,m),s=x(w),i=r?.specType,c=r?.collectorUrl,p=r?.serviceName,n=r?.serviceVersion,l=r?.disabled,a=r?.typeOfUsage,h=S(()=>new b({specType:i??s,collectorUrl:c,serviceName:p,serviceVersion:n,disabled:l,typeOfUsage:a}),[s,i,c,p,n,l,a]);return o(A,{value:y,children:f(P.Provider,{value:h,children:[o(F,{}),o(G,{routeIndex:g,basePath:m})]})})};function F(){return C(),D(),V(),null}const G=({routeIndex:e,basePath:t})=>(j(),I(),f(T,{children:[o(R,{}),o(B,{children:o(k,{routeIndex:e,basePath:t})})]})),u=M(O,N,v,e=>_(e),e=>E(e,{respectHideReplay:!0}))(d);var ne=u;export{u as RedoclyApiDocs,d as RedoclyApiDocsComponent,ne as default};
|
|
@@ -11,6 +11,8 @@ type RedoclyApiDocsStandaloneProps = {
|
|
|
11
11
|
logo?: RawLogo;
|
|
12
12
|
telemetryConfig?: Partial<RedocTelemetryConfig>;
|
|
13
13
|
markdownAdapter?: MarkdownAdapter;
|
|
14
|
+
definition?: Record<string, unknown> | string;
|
|
15
|
+
definitionUrl?: string;
|
|
14
16
|
};
|
|
15
17
|
declare const RedoclyApiDocsStandalone: import("react").FC<any>;
|
|
16
18
|
export { RedoclyApiDocsStandalone };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as o,jsxs as l}from"react/jsx-runtime";import{memo as S,useMemo as i}from"react";import{createMarkdocAdapter as x}from"./components/markdoc/markdocAdapter.js";import{styled as d}from"styled-components";import{useAtomValue as a}from"jotai";import{SidebarLogo as k}from"@redocly/theme/components/SidebarLogo/SidebarLogo";import{ThemeDataContext as A}from"@redocly/theme/core/openapi";import{RedoclyApiDocsComponent as w}from"./RedoclyApiDocs.js";import{SideMenu as L}from"./components/SideMenu/SideMenu.js";import{StickySidebar as C}from"./components/StickySidebar/StickySidebar.js";import{getStandaloneLayoutStyle as j}from"./options/standaloneLayoutVars.js";import{toSidebarLogo as z}from"./utils/logo.js";import{globalOptionsAtom as D,storeAtom as M}from"./jotai/store.js";import{collapsedSidebarAtom as T}from"./jotai/app.js";import{useLicenseGate as O}from"./hooks/useLicenseGate.js";import{compose as P}from"./utils/compose.js";import{withRouter as R}from"./hoc/withRouter.js";import{withStoreProvider as H}from"./hoc/withStoreProvider.js";import{useCodeHighlight as I}from"./hooks/useCodeHighlight.js";const _=({children:e})=>{const r=i(()=>({hooks:{useCodeHighlight:()=>({highlight:I})}}),[]);return o(A.Provider,{value:r,children:e})},c=P(H,R,S)(({items:e,basePath:r,logo:p,telemetryConfig:h,markdownAdapter:n})=>{const t=a(D),f=a(M),{gatedItems:m,overlay:g}=O(e),{markdocOptions:s}=t,b=i(()=>n??x(s),[n,s]),u=a(T),v=z(p)??t.apiLogo??f.logo,y=i(()=>j(t),[t]);return o(_,{children:l(G,{style:y,children:[g,l(C,{className:"menu-content",collapsedSidebar:u,children:[o(k,{dataTestId:"logo",...v}),o(L,{items:m})]}),o(N,{children:o(w,{items:m,basePath:r,markdownAdapter:b,telemetryConfig:h})})]})})}),G=d.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
position: relative;
|
|
4
4
|
min-height: 100vh;
|
|
@@ -20,7 +20,7 @@ import{Fragment as j,jsx as o,jsxs as f}from"react/jsx-runtime";import{memo as D
|
|
|
20
20
|
* {
|
|
21
21
|
box-sizing: border-box;
|
|
22
22
|
}
|
|
23
|
-
`,
|
|
23
|
+
`,N=d.div`
|
|
24
24
|
flex: 1;
|
|
25
25
|
min-width: 0;
|
|
26
|
-
`;var
|
|
26
|
+
`;var ao=c;export{c as RedoclyApiDocsStandalone,ao as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{combineUrls as I}from"@redocly/theme/core/openapi";import{contentType as w,nodeTypes as l}from"../../../types/common.js";import{asString as x,safeSlugify as u}from"../../../utils/string.js";import{buildMarkdownSectionItem as k,extractMarkdownSections as L,extractContentUntilFirstHeading as E,extractSummaryText as O}from"../../utils/markdoc.js";import{parseMarkdown as A}from"../../utils/parseMarkdown.js";import{readRbacScope as M,rbacProp as D}from"../../rbac.js";import{itemLabelsByProtocol as P}from"../utils/get-protocol-labels.js";import{buildTaggedChannelItem as R,buildUntaggedChannelItem as v}from"../items/channel/item.js";import{asyncApiContext as N}from"../buildContext.js";import{buildGroupItemsPanel as U}from"../panels/group.js";function q(){const n=N.get(),{document:a,basePath:m,channelToOperations:S,protocol:g,processContent:f}=n,T=a.channels||{},d=a.components?.tags||{},h=new Map;for(const[t,e]of Object.entries(S)){const o=T[t];if(!o)continue;const r=[];for(const s of o.tags??[]){const p=x(s?.name);p&&r.push(p)}const i=`${P(g,o.bindings).channel}s`;for(const s of r){const p=u(s).toLowerCase();n.groups[s]||(n.groups[s]=[]);const y=I(m,p,i,t).toLowerCase(),C=x(o.summary)??O(o.description,n.options);C&&n.channelSummaries.set(y,C),h.set(y,o),n.groups[s].push(R({channelId:t,channel:o,operationIds:e,tagName:s}))}r.length||n.items.push(v({channelId:t,channel:o,operationIds:e}))}if(f)for(const t of Object.keys(n.groups)){const e=d[t];for(const o of L(e?.description,n.options,u(t).toLowerCase()))n.groups[t].push(k({heading:o,basePath:m}))}const b=[...Object.keys(n.groups).map(t=>{const e=n.groups[t],o=I(m,u(t)).toLowerCase(),r=d[t],c=n.options,i=r?.externalDocs,s=E(r?.description,c);return{label:t,type:"group",link:o,routeSlug:o,items:e,content:f?{contentType:w.GROUP,children:[{nodeType:l.CONTAINER,children:[{nodeType:l.HEADER,level:2,label:t,showPageActions:!0},...s?[{nodeType:l.MARKDOC,content:s}]:[],...i?.url?[{nodeType:l.EXTERNAL_DOCS,url:i.url,description:A(i.description,c)??[]}]:[]],panels:[{children:[U({group:e,protocol:g,channelByLink:h,context:n})]}]}]}:null}}),...n.items];if(a["x-tagGroups"]&&a["x-tagGroups"].length>0){const t=[],e=new Map;return b.forEach(o=>{o.label&&e.set(o.label,o)}),a["x-tagGroups"].forEach(o=>{t.push({label:o.name,type:"separator",...D(M(o)),content:null}),o.tags.forEach(r=>{const c=e.get(r);c&&t.push(c)})}),t}return b}export{q as buildNavigationItems};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{combineUrls as w}from"@redocly/theme/core/openapi";import{asString as G,safeSlugify as se}from"../../../../utils/string.js";import{normalizePath as ne}from"../../../../utils/url.js";import{JsonPointer as te}from"../../../openapi/utils/JsonPointer.js";import{contentType as ae,itemVariant as oe,nodeTypes as c,panelKind as R,schemaKind as B}from"../../../../types/common.js";import{registerSchema as H,registerExample as ie}from"../../../helpers.js";import{readRbacScope as k,rbacProp as b,hasRbacScope as re,splitRbacSection as J}from"../../../rbac.js";import{parseMarkdown as A}from"../../../utils/parseMarkdown.js";import{componentLabelsByProtocol as le,itemLabelsByProtocol as ce}from"../../utils/get-protocol-labels.js";import{resolveInDoc as $}from"../../utils/resolveInDoc.js";import{getServerHost as O}from"../../utils/get-server-host.js";import{resolveAsyncApiSchema as z}from"../../utils/resolve-schema.js";import{getChannelLabel as Q}from"../../utils/get-channel-label.js";import{asyncApiContext as pe}from"../../buildContext.js";function de(S,n,f){const l={exchanges:[],queues:[]};if(!S.channels)return l;for(const[h,a]of Object.entries(S.channels)){if(!a?.messages?.[n])continue;const E=`${ce(f??null,a.bindings).channel}s`,i=a.tags?.map(D=>G(D?.name)).find(Boolean),p=i?se(i).toLowerCase():void 0,N=ne(p?w(p,E,h).toLowerCase():w(E,h).toLowerCase()),C={key:h,label:Q(a,h),link:N};a.bindings?.amqp?.is==="routingKey"?l.exchanges.push(C):l.queues.push(C)}return l}function Re(S,n,f,l,h){const{storeCtx:a}=pe.get(),L=[],E=Q(n,S),i=le({protocol:h??null,channelBindings:n.bindings}),p=[{nodeType:c.HEADER,level:2,label:E,badges:n["x-badges"],showPageActions:!0,protocolTag:{label:i.channel,color:i.channel.toLowerCase()}}],N=G(n.address);N&&p.push({nodeType:c.CHANNEL_ADDRESS,address:N});const C=A(n.summary,l);C&&p.push({nodeType:c.MARKDOC,content:C});const D=A(n.description,l);D&&p.push({nodeType:c.MARKDOC,content:D});const j=n.externalDocs;if(j?.url&&p.push({nodeType:c.EXTERNAL_DOCS,url:j.url,description:A(j.description,l)??[]}),n.parameters&&Object.keys(n.parameters).length>0){const{sectionRbac:d,entries:x}=J(n.parameters),g=x.map(([u,o])=>{const e=$(f,o)??o,m={type:e.location||"string"};e.enum&&(m.enum=e.enum),e.default!==void 0&&(m.default=e.default),e.description&&(m.description=e.description),e.examples?.length&&(m.examples=e.examples);const P=H(a.schemaStore,a.hashIndex,{kind:B.JSON_SCHEMA,data:m});return{name:u,in:"path",schemaId:P,description:e.description,...b(k(e))}});p.push({nodeType:c.HEADER,level:4,label:"Parameters",labelTranslationKey:"parameters",deepLinkSuffix:"parameters",...b(d)},{nodeType:c.ITEM,variant:"parameters",parameters:g,pointer:`channels/${S}/parameters`,...b(d)})}const M=[];if(f.servers&&n.servers){const d=n.servers.map(o=>$(f,o)).filter(o=>!!o&&!!O(o)),{sectionRbac:x,entries:g}=J(f.servers),u=g.filter(([,o])=>d.some(e=>O(e)===O(o)));u.length>0&&M.push({children:[{kind:R.BROKERS,panelLabel:i.servers,brokers:u.map(([o,e])=>({name:o,url:O(e),description:A(e.description,l)??[],protocol:e.protocol,protocolVersion:e.protocolVersion,pathname:e.pathname,title:e.title,summary:e.summary,tags:e.tags,externalDocs:e.externalDocs,bindings:e.bindings,variables:e.variables,...b(k(e)??x)}))}]})}if(n.bindings){const d=Object.entries(n.bindings);if(d.length>0){const[x,g]=d[0];M.push({title:i.channelBinding,children:[{kind:R.CHANNEL_BINDING,panelLabel:i.channelBinding,bindingKey:x,bindingValue:g}]})}}if(L.push({nodeType:c.CONTAINER,children:p,panels:M.length>0?M:void 0}),n.messages&&Object.keys(n.messages).length>0){const{sectionRbac:d,entries:x}=J(n.messages),g=[{nodeType:c.HEADER,level:4,label:"Messages",labelTranslationKey:"messages",deepLinkSuffix:"messages"}],u={},o=x.map(([t,y])=>{const s=$(f,y)??y;let I,U;const _=[],X=k(y)??k(s);if(a&&s.payload&&typeof s.payload=="object"){const r=z(s.payload);r&&(I=H(a.schemaStore,a.hashIndex,{kind:B.JSON_SCHEMA,data:r}))}if(a&&s.headers&&typeof s.headers=="object"){const r=z(s.headers);r&&(U=H(a.schemaStore,a.hashIndex,{kind:B.JSON_SCHEMA,data:r}))}if(a&&s.examples&&Array.isArray(s.examples)){for(const r of s.examples)if(r.payload){const K=ie(a.exampleStore,{value:r.payload,summary:r.summary||r.name});_.push(K)}}if(a&&s.bindings){const r=Object.entries(s.bindings);for(const[K,v]of r){if(!v||typeof v!="object")continue;let Y;if(K==="kafka"){const q=v.key;if(q&&typeof q=="object"){const ee=z(q);Y=H(a.schemaStore,a.hashIndex,{kind:B.JSON_SCHEMA,data:{type:"object",properties:{key:ee}}})}}u[t]={bindingKey:K,bindingValue:v,keySchemaId:Y,...b(X)};break}}const V=s.externalDocs,Z=V?.url?{url:V.url,description:A(V.description,l)??[]}:void 0;return{name:t,label:s.title||s.name||t,summary:typeof s.summary=="string"?s.summary:void 0,description:A(s.description,l),contentType:s.contentType,schemaId:I,headerSchemaId:U,exampleIds:_.length>0?_:void 0,payload:s.payload,payloadLabel:i.payload,headers:s.headers,externalDocs:Z,...b(X)}});g.push({nodeType:c.ITEM,variant:"messages",messages:o,pointer:`channels/${S}/messages`});const e=o.filter(t=>!re(t)),m=e.flatMap(t=>t.exampleIds??[]),P=e.find(t=>t.schemaId)?.schemaId,W=o.some(t=>t.schemaId||(t.exampleIds?.length??0)>0),F={};for(const t of o){const y=k(t);F[t.name]={schemaId:t.schemaId,exampleIds:t.exampleIds,...b(y)}}const T=[];if(W&&T.push({children:[{kind:R.PAYLOAD,panelLabel:i.payload,exampleIds:m.length>0?m:void 0,schemaId:P,examples:m.map(()=>({})),messagesByKey:F}]}),Object.keys(u).length>0&&T.push({title:"Message configuration",children:[{kind:R.MESSAGE_BINDING,bindingsByMessageKey:u}]}),h==="amqp"){const t={};let y=!1;for(const s of o){const I=de(f,s.name,h);(I.exchanges.length>0||I.queues.length>0)&&(t[s.name]=I,y=!0)}y&&T.push({children:[{kind:R.MESSAGE_REFERENCES,referencesByMessageKey:t}]})}L.push({nodeType:c.CONTAINER,children:g,panels:T.length>0?T:void 0,...b(d)})}return{contentType:ae.ITEM,itemVariant:oe.CHANNEL,meta:{name:E,pointer:te.compile(["channels",S]),protocolTag:{label:i.channel,color:i.channel.toLowerCase()}},seo:{title:E,description:G(n.description)},children:L}}export{Re as buildChannelContent,de as buildMessageReferencesGroups};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{combineUrls as v}from"@redocly/theme/core/openapi";import{asString as T,safeSlugify as U}from"../../../../utils/string.js";import{componentLabelsByProtocol as h,itemLabelsByProtocol as x}from"../../utils/get-protocol-labels.js";import{buildChannelContent as y}from"./content.js";import{buildOperationItem as P}from"../operation/item.js";import{asyncApiContext as k}from"../../buildContext.js";import{readRbacScope as B,rbacProp as O}from"../../../rbac.js";import{resolveItemSeo as V}from"../../../utils/seo.js";import{extractSeoDescriptionText as $}from"../../../utils/markdoc.js";import{getChannelLabel as G}from"../../utils/get-channel-label.js";function w(o,e,r){const n=G(o,e),s=$(o.description,r)??T(o.summary);return{label:n,seo:V(o,{title:n,description:s})}}function H(o,e,r){const n=o.filter(t=>e[t]?.action==="send"),s=o.filter(t=>e[t]?.action==="receive");return[...n,...s].map(t=>n[0]===t?{operationId:t,groupHeaderLabel:r.send}:s[0]===t?{operationId:t,groupHeaderLabel:r.receive}:{operationId:t})}function N({channelId:o,channel:e,operationIds:r,tagName:n}){const{document:s,basePath:i,options:t,protocol:l,processContent:a}=k.get(),d=s.operations||{},f=r.length>0,c=x(l??null,e.bindings),p=h({protocol:l??null,channelBindings:e.bindings}),m=`${c.channel}s`,b=U(n).toLowerCase(),L=v(i,b,m,o).toLowerCase(),C=H(r,d,{send:p.sendLabel,receive:p.receiveLabel}),{label:u,seo:S}=w(e,o,t);return{label:u,type:"group",link:L,routeSlug:L,badges:e?.["x-badges"]||[],httpVerb:c.channel,metadata:{seo:S},content:a?y(o,e,s,t,l):null,...O(B(e)),...f?{items:C.map(({operationId:g,groupHeaderLabel:D},A)=>P({operationId:g,operation:d[g],linkParts:[i,b,m,o,"operations",g],channelBindings:e.bindings,document:s,options:t,protocol:l,groupHeaderLabel:D,processContent:a,showDivider:A!==C.length-1}))}:{}}}function Q({channelId:o,channel:e,operationIds:r}){const{document:n,basePath:s,options:i,protocol:t,processContent:l}=k.get(),a=n.operations||{},d=r.length>0,f=x(t??null,e.bindings),c=h({protocol:t??null,channelBindings:e.bindings}),p=`${f.channel}s`,m=v(s,p,o).toLowerCase(),b=H(r,a,{send:c.sendLabel,receive:c.receiveLabel}),{label:L,seo:C}=w(e,o,i);return{label:L,type:"group",link:m,routeSlug:m,httpVerb:f.channel,badges:e?.["x-badges"]||[],metadata:{seo:C},...O(B(e)),content:l?y(o,e,n,i,t):null,...d?{items:b.map(({operationId:u,groupHeaderLabel:S},g)=>P({operationId:u,operation:a[u],linkParts:[s,p,o,"operations",u],channelBindings:e.bindings,document:n,options:i,protocol:t,groupHeaderLabel:S,processContent:l,showDivider:g!==b.length-1}))}:{}}}export{N as buildTaggedChannelItem,Q as buildUntaggedChannelItem};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{combineUrls as y}from"@redocly/theme/core/openapi";import{asString as e}from"../../../../utils/string.js";import{itemLabelsByProtocol as P}from"../../utils/get-protocol-labels.js";import{readRbacScope as k,rbacProp as L}from"../../../rbac.js";import{resolveItemSeo as C}from"../../../utils/seo.js";import{extractSeoDescriptionText as O}from"../../../utils/markdoc.js";import{buildOperationContent as h}from"./content.js";function U({operationId:o,operation:t,linkParts:l,channelBindings:c,document:n,options:m,protocol:s,groupHeaderLabel:a,processContent:b=!0,showDivider:f}){const u=P(s??null,c),[p,...d]=l;let r=p??"";for(const x of d)r=y(r,x);r=r.toLowerCase();const i=e(t.title)??e(t.summary)??o,S=O(t.description,m)??e(t.summary),g=C(t,{title:i,description:S});return{label:i,type:"link",link:r,routeSlug:r,httpVerb:u[t.action]||"",badges:t?.["x-badges"]||[],metadata:{seo:g},...L(k(t)),content:b?h(o,t,n,r,m,s,a,f):null}}export{U as buildOperationItem};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extractContentUntilFirstHeading as u}from"../../../utils/markdoc.js";import{parseMarkdown as T}from"../../../utils/parseMarkdown.js";import{contentType as h,nodeTypes as n}from"../../../../types/common.js";import{buildDownloadPanelContent as C}from"../../panels/download.js";import{buildOverviewPanelContent as R}from"../../panels/overview.js";import{buildBrokersPanelContent as v}from"../../panels/brokers.js";import{buildInfoMetadataContentNode as I}from"../../../utils/infoMetadata.js";function V({document:t,options:o,protocol:a,sectionChildren:p,basePath:s}){const e=t.info,c=u(e?.description,o),f=[C(o.downloadUrls??[]),R(e),...t.servers?[v(t.servers,a,o)]:[]],r={nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.HEADER,showPageActions:!0,level:1,label:`${e?.title??""} ${e?.version??""}`.trim()}],sectionId:s};c?.length&&r.children.push({nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.MARKDOC,content:c}],sectionId:s});const i=e?.externalDocs;if(i?.url){const m=T(i.description,o)??[];r.children.push({nodeType:n.EXTERNAL_DOCS,url:i.url,description:m})}const l=I(e,o.hideInfoMetadata)
|
|
1
|
+
import{extractContentUntilFirstHeading as u}from"../../../utils/markdoc.js";import{parseMarkdown as T}from"../../../utils/parseMarkdown.js";import{contentType as h,nodeTypes as n}from"../../../../types/common.js";import{buildDownloadPanelContent as C}from"../../panels/download.js";import{buildOverviewPanelContent as R}from"../../panels/overview.js";import{buildBrokersPanelContent as v}from"../../panels/brokers.js";import{buildInfoMetadataContentNode as I}from"../../../utils/infoMetadata.js";function V({document:t,options:o,protocol:a,sectionChildren:p,basePath:s}){const e=t.info,c=u(e?.description,o),f=[C(o.downloadUrls??[]),R(e),...t.servers?[v(t.servers,a,o)]:[]],r={nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.HEADER,showPageActions:!0,level:1,label:`${e?.title??""} ${e?.version??""}`.trim()}],sectionId:s};c?.length&&r.children.push({nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.MARKDOC,content:c}],sectionId:s});const i=e?.externalDocs;if(i?.url){const m=T(i.description,o)??[];r.children.push({nodeType:n.EXTERNAL_DOCS,url:i.url,description:m})}const d=[r],l=I(e,o.hideInfoMetadata);l&&d.push(l),d.push(...p);const E={nodeType:n.CONTAINER,panels:f,children:d};return{contentType:h.OVERVIEW,children:[E]}}export{V as buildOverviewContent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{contentType as
|
|
1
|
+
import{contentType as m,nodeTypes as l}from"../../../types/common.js";import{safeSlugify as p}from"../../../utils/string.js";import{joinWithSeparator as u}from"../../../utils/url.js";import{itemVariant as e}from"../../../types/common.js";import{DEFAULT_GROUP_LABELS as T}from"../utils/constants.js";import{buildGroupItemsPanelContent as E}from"../panels/group-items.js";import{graphqlContext as f}from"../buildContext.js";const A={[e.QUERY]:"queries",[e.MUTATION]:"mutations",[e.SUBSCRIPTION]:"subscriptions",[e.DIRECTIVE]:"directives",[e.OBJECT]:"objects",[e.INTERFACE]:"interfaces",[e.INPUT]:"inputs",[e.UNION]:"unions",[e.ENUM]:"enums",[e.SCALAR]:"scalars"};function d({typeGroup:t,items:r,label:i,parentPath:c}){const o=f.get(),n=i??(t?T[t]:"Overview"),s=i?void 0:t?A[t]:"info.title",a=u(c??o.basePath,p(n?.toLowerCase()));return{type:"group",label:n,labelTranslationKey:s,link:a,routeSlug:a,items:r,content:o.processContent?{contentType:m.GROUP,children:[{nodeType:l.CONTAINER,children:[{nodeType:l.HEADER,level:2,label:n,labelTranslationKey:s,showPageActions:!0}],panels:[E(r,o,t)]}]}:null}}export{d as createGroup};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{itemVariant as n}from"../../../types/common.js";import{safeSlugify as d}from"../../../utils/string.js";import{joinWithSeparator as f
|
|
1
|
+
import{itemVariant as n}from"../../../types/common.js";import{safeSlugify as d}from"../../../utils/string.js";import{joinWithSeparator as f}from"../../../utils/url.js";import{normalizePath as m,toRelativePath as C}from"../../../utils/url.js";import{shouldIncludeItem as a}from"../utils/shouldIncludeItem.js";import{appendGraphqlItemFeedback as s}from"./appendGraphqlItemFeedback.js";import{buildDirectiveContent as I}from"../items/directive/content.js";import{buildQueryContent as T}from"../items/query/content.js";import{buildMutationContent as b}from"../items/mutation/content.js";import{buildSubscriptionContent as N}from"../items/subscription/content.js";import{buildUnionContent as E}from"../items/union/content.js";import{buildEnumContent as p}from"../items/enum/content.js";import{buildScalarContent as h}from"../items/scalar/content.js";import{buildInputContent as P}from"../items/input/content.js";import{buildObjectContent as S}from"../items/object/content.js";import{buildInterfaceContent as U}from"../items/interface/content.js";import{graphqlContext as A}from"../buildContext.js";const R={[n.QUERY]:"queries",[n.MUTATION]:"mutations",[n.SUBSCRIPTION]:"subscriptions",[n.DIRECTIVE]:"directives",[n.OBJECT]:"objects",[n.INTERFACE]:"interfaces",[n.UNION]:"unions",[n.ENUM]:"enums",[n.INPUT]:"inputs",[n.SCALAR]:"scalars"};function z(t){const e=A.get(),r=`${t.variant}:${t.name}`;if(t.processedItems?.has(r)||(t.filter||t.menuCommonFilter)&&!a(t.name,t.filter,t.menuCommonFilter))return null;const o=t.parentPath?t.parentPath:f(e.basePath,R[t.variant]),u=f(o,d(t.name.toLowerCase())),l=t.label??t.name;if(t.processedItems?.add(r),!e.processContent)return{type:"link",label:l,link:u,routeSlug:u,...t.deprecated&&{deprecated:!0},content:null};let i=g({variant:t.variant,source:t.source,name:t.name,markdownOptions:e.options});e.options.feedback?.hide!==!0&&i&&(i=s(i,m(C(u,e.basePath))));const c=v(t.source);return c&&i?.meta&&(i.meta.position=c),{type:"link",label:l,link:u,routeSlug:u,...t.deprecated&&{deprecated:!0},content:i}}function g({variant:t,source:e,name:r,markdownOptions:o}){switch(t){case n.DIRECTIVE:return I(e,o);case n.QUERY:return T(e,r,o);case n.MUTATION:return b(e,r,o);case n.SUBSCRIPTION:return N(e,r,o);case n.UNION:return E(e,o);case n.ENUM:return p(e,o);case n.SCALAR:return h(e,o);case n.INPUT:return P(e,o);case n.OBJECT:return S(e,o);case n.INTERFACE:return U(e,o);default:return}}function v(t){const e=t?.astNode?.loc;if(e?.startToken)return{start:{lineNumber:e.startToken.line,column:e.startToken.column},end:e.endToken?{lineNumber:e.endToken.line,column:e.endToken.column}:void 0}}export{z as createApiItem};
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import { REDOCLY_TEAMS_RBAC } from '@redocly/config';
|
|
2
1
|
import type { SchemaEntry, ExampleEntry, SecuritySchemeEntry, StoreContext } from '../types/store.js';
|
|
3
2
|
import type { OpenAPIRef, Referenced } from '../types/common.js';
|
|
4
3
|
import type { OpenAPIMediaType, OpenAPIExample } from '../types/openapi.js';
|
|
4
|
+
export { readRbacScope, rbacProp, splitRbacSection } from './rbac.js';
|
|
5
5
|
export declare function resetStoreCounters(): void;
|
|
6
6
|
export declare function stableStringify(data: unknown, seen?: Set<unknown>): string;
|
|
7
7
|
export declare function registerSchema(schemaStore: Record<string, SchemaEntry>, hashIndex: Record<string, string>, entry: Omit<SchemaEntry, 'id'> & {
|
|
8
8
|
id?: string;
|
|
9
9
|
}): string;
|
|
10
|
-
|
|
11
|
-
export declare function
|
|
12
|
-
[REDOCLY_TEAMS_RBAC]?: Record<string, string>;
|
|
13
|
-
};
|
|
14
|
-
export declare function splitRbacSection<T>(map: Record<string, T> | undefined): {
|
|
15
|
-
sectionRbac: Record<string, string> | undefined;
|
|
16
|
-
entries: [string, T][];
|
|
17
|
-
};
|
|
10
|
+
/** Accepts a raw markdown string or a host-pre-parsed AST node; drops anything else. */
|
|
11
|
+
export declare function pickRenderableDescription(value: unknown): ExampleEntry['description'];
|
|
18
12
|
export declare function registerExample(exampleStore: Record<string, ExampleEntry>, entry: Omit<ExampleEntry, 'id'> & {
|
|
19
13
|
id?: string;
|
|
20
14
|
}): string;
|
|
@@ -44,4 +38,3 @@ type LegacyExampleHost = {
|
|
|
44
38
|
};
|
|
45
39
|
export declare function resolveContent(spec: Record<string, unknown>, info: LegacyExampleHost | null | undefined, ignoreNamedSchemas?: Set<string>): MediaTypesMap | undefined;
|
|
46
40
|
export declare function resolveJsonPointer(spec: Record<string, unknown>, ref: string): Record<string, unknown> | undefined;
|
|
47
|
-
export {};
|
package/lib/adapters/helpers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getDefinitionName as x}from"./openapi/utils/helpers.js";import{readRbacScope as d,rbacProp as l}from"./rbac.js";import{readRbacScope as D,rbacProp as _,splitRbacSection as w}from"./rbac.js";let p=0,m=0;function y(){p=0,m=0}function s(e,r){return e==null?String(e):typeof e!="object"?JSON.stringify(e):(r||(r=new Set),r.has(e)?'"[Circular]"':(r.add(e),Array.isArray(e)?"["+e.map(n=>s(n,r)).join(",")+"]":c(e)?"{"+Object.keys(e).sort().map(n=>JSON.stringify(n)+":"+s(e[n],r)).join(",")+"}":"{}"))}function C(e,r,t){const n=g(t);if(t.id&&e[t.id])return t.id;if(!t.id){const i=s(t.data),u=r[i];if(u)return u;const f=`schema_${p++}`;return e[f]={...n,id:f},r[i]=f,f}e[t.id]={...n,id:t.id};const o=s(t.data);return r[o]||(r[o]=t.id),t.id}function g(e){const r=d(e.data);return r?{...e,...l(r)}:e}function O(e){return typeof e=="string"||typeof e=="object"&&e!==null?e:void 0}function k(e,r){const t=r.id??`example_${m++}`;return e[t]||(e[t]={...r,id:t}),t}function A(e,r){return e[r.id]||(e[r.id]=r),r.id}function E(e){return{schemaStore:{},exampleStore:{},securitySchemeStore:{},hashIndex:{},document:e}}function c(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $(e){return c(e)?e:{}}function b(e,r,t){if(c(r)){if(typeof r.$ref=="string"){const n=r.$ref,o=x(n);return o&&t?.has(o)?{type:"object",title:o}:h(e,n)}return r}}function a(e){return c(e)&&typeof e.$ref=="string"}function N(e,r,t){const n=r?.content;if(!n)return;const o=a(n)?b(e,n,t):n;return S(o,r)}function S(e,r){if(!e)return e;const t=r["x-examples"];if(t){const o={...e};for(const i of Object.keys(t))o[i]={...o[i],examples:t[i]};return o}const n=r["x-example"];if(n){const o={...e};for(const i of Object.keys(n))o[i]={...o[i],example:n[i]};return o}return e}function h(e,r){if(!r.startsWith("#/"))return;const t=r.slice(2).split("/").map(o=>o.replace(/~1/g,"/").replace(/~0/g,"~"));let n=e;for(const o of t){if(!c(n))return;n=n[o]}return c(n)?n:void 0}export{E as createStoreContext,a as isOpenAPIRef,c as isRecord,O as pickRenderableDescription,_ as rbacProp,D as readRbacScope,k as registerExample,C as registerSchema,A as registerSecurityScheme,y as resetStoreCounters,N as resolveContent,h as resolveJsonPointer,b as resolveRef,w as splitRbacSection,s as stableStringify,$ as toRecord};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseMarkdown as M}from"../../utils/parseMarkdown.js";import{JsonPointer as
|
|
1
|
+
import{parseMarkdown as M}from"../../utils/parseMarkdown.js";import{JsonPointer as N}from"../utils/JsonPointer.js";import{DEFAULT_WEBHOOKS_TAG_NAME as B}from"../../../constants/openapi.js";import{SUPPORTED_MCP_TYPES as E}from"../constants.js";import{titleize as P}from"../utils/helpers.js";import{resolveRef as b,readRbacScope as S,rbacProp as v}from"../../helpers.js";import{resolvePathItemRef as C}from"../utils/resolvePathItemRef.js";import{HTTP_METHODS as R,isOperationName as q}from"../../../utils/http-methods.js";import{isRbacKey as _}from"../../rbac.js";function O(t){return t.kind==="badge"||t.kind==="audience"}function Z({document:t,options:e,basePath:a,storeCtx:c,processContent:p=!0}){const n=new Map;for(const r of t.tags||[]){const o=r;n.set(r.name,{tag:o,operations:[],description:r.description,children:[]})}for(const r of t.tags||[]){const o=r;o.parent&&!O(r)&&n.get(o.parent)?.children.push(r.name)}e?.schemaDefinitionsTagName&&$(n,e.schemaDefinitionsTagName);const i=(t.tags||[]).filter(O),s={document:t,options:e,basePath:a,tagsMap:n,collectedTagOrder:[],downloadUrls:e.downloadUrls,storeCtx:c,badgeTags:i,processContent:p};return A(t,s),L(t,s),s}function $(t,e){t.has(e)||t.set(e,{tag:{name:e},operations:[],children:[]})}function A(t,e){t.paths&&x(t.paths,!1,e);const a=t["x-webhooks"]||t.webhooks;a&&x(a,!0,e)}function L(t,e){const a=t["x-mcp"];if(a)for(const c of E){const p=a[c];if(p?.length)for(const n of p){const i=n.tags&&n.tags.length>0?n.tags:[P(c)];for(const s of i)e.tagsMap.has(s)||(e.tagsMap.set(s,{tag:{name:s},operations:[],children:[]}),e.collectedTagOrder.push(s))}}}function k(t,e){return{...e,summary:e.summary??t.summary,description:e.description??t.description,servers:e.servers??t.servers}}function x(t,e,a){const c=a.document,p=a.document.openapi;for(const[n,i]of Object.entries(t)){if(!i)continue;let s;try{s=C(c,i,p)}catch{console.warn(`[OpenAPI] Skipping path "${n}": failed to resolve path item $ref`);continue}if(!s)continue;const r=s.parameters??[];for(const f of Object.keys(s).filter(q)){const d=s[f];!d||typeof d!="object"||w(k(s,d),n,f,e,!1,a,r)}const o=s.additionalOperations;if(o)for(const[f,d]of Object.entries(o))w(k(s,d),n,f,e,!0,a,r)}}function j(t){return typeof t=="object"&&t!==null?t:{}}function H(t,e,a,c){if(!t.length&&!e?.length||!t.length)return e;if(!e?.length)return t;const p=new Set(e.map(i=>{const s=b(a,i,c)??i,r=j(s);return`${r.in}:${r.name}`})),n=[...e];for(const i of t){const s=b(a,i,c)??i,r=j(s),o=`${r.in}:${r.name}`;p.has(o)||n.push(i)}return n}function w(t,e,a,c,p,n,i=[]){const s=t.tags||(c?[B]:[""]),r=U(n.badgeTags,t,e,a,c,p,s,i,n);for(const o of s){let f=n.tagsMap.get(o);f||(f={tag:{name:o},operations:[],children:[]},n.tagsMap.set(o,f),n.collectedTagOrder.push(o)),!O(f.tag)&&(f.tag["x-traitTag"]||f.operations.push(r))}}function D(t){return t.toLowerCase()==="x-query"?"query":t}function U(t,e,a,c,p,n,i,s=[],r){const{options:o,storeCtx:f}=r,d=e.externalDocs,g=e["x-badges"]?.map(m=>({name:m.name,color:m.color,position:m.position}))??[];if(e.tags&&t.length>0)for(const m of e.tags){const l=t.find(u=>u.name===m);l&&g.push({name:l.summary??l.name,color:l.kind==="audience"?"grey":"blue",icon:l.kind==="audience"?"user-group":void 0,position:"after",description:typeof l.description=="string"?l.description:void 0})}return{...e,pointer:N.compile(["paths",a,c]),pathName:a,httpVerb:D(c),operationId:e.operationId,summary:e.summary,description:M(e.description,o),deprecated:e.deprecated,isWebhook:p,isAdditionalOperation:n,tags:i,parameters:H(s,e.parameters,f.document,o.ignoreNamedSchemas),requestBody:e.requestBody,responses:e.responses,servers:e.servers,security:e.security??r.document.security,callbacks:V(e.callbacks,f?.document??{},o.ignoreNamedSchemas),externalDocs:d?{url:d.url,description:d.description}:void 0,"x-seo":e?.["x-seo"],"x-badges":g.length>0?g:void 0}}function V(t,e,a){if(!t||typeof t!="object")return;const c=[];for(const[p,n]of Object.entries(t)){const i=b(e,n,a)??n;if(!i||typeof i!="object")continue;const s=S(i),r=i;for(const[o,f]of Object.entries(r)){if(_(o)||!f||typeof f!="object")continue;const d=f.servers,T=f.parameters,g=[];for(const[m,l]of Object.entries(f)){if(!R.has(m.toLowerCase())||!l||typeof l!="object")continue;const u=l,h={httpVerb:D(m.toLowerCase()),pathName:o,summary:u.summary,operationId:u.operationId,description:u.description,deprecated:u.deprecated,requestBody:u.requestBody,responses:u.responses,security:u.security,servers:u.servers??d,parameters:u.parameters??T,externalDocs:u.externalDocs};for(const[y,I]of Object.entries(u))y.startsWith("x-")&&!(y in h)&&(h[y]=I);g.push(h)}g.length>0?c.push({name:p,url:o,operations:g,...v(s)}):c.push({name:p,url:o,...v(s)})}}return c.length>0?c:void 0}export{Z as createBuildContext,V as normalizeCallbacks};
|
|
@@ -2,4 +2,4 @@ import type { OperationInfo } from '../../types/openapi.js';
|
|
|
2
2
|
import type { StoreContext } from '../../types/store.js';
|
|
3
3
|
import type { ApiDocsOptions } from '../../types/options.js';
|
|
4
4
|
import type { CodeSampleSource } from '../../services/code-samples/index.js';
|
|
5
|
-
export declare function buildCodeSampleSource(operationInfo: OperationInfo, storeCtx: StoreContext,
|
|
5
|
+
export declare function buildCodeSampleSource(operationInfo: OperationInfo, storeCtx: StoreContext, ignoreNamedSchemas?: Set<string>, isWebhook?: boolean, href?: string, options?: ApiDocsOptions): CodeSampleSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isRbacKey as w}from"../rbac.js";import{registerExample as O,pickRenderableDescription as M,registerSchema as R,resolveContent as P,resolveRef as V,readRbacScope as q,rbacProp as A}from"../helpers.js";import{panelKind as T,schemaKind as j}from"../../types/common.js";import{isStatusCode as U}from"../../utils/status-code.js";import{encodeJsonPointerSegment as B}from"../../utils/refPointer.js";import{applyIgnoreNamedSchemasDeep as C}from"./utils/applyIgnoreNamedSchemasDeep.js";import{pickOperationServers as K}from"./utils/merge-mock-server.js";import{mergeInMockServer as $}from"./utils/merge-mock-server.js";import{mergeSecurityIntoScheme as g}from"./configure/merge-utils.js";import{hasOpenApiExampleValue as F,resolveOpenApiExampleValue as E}from"./resolve-openapi-example-value.js";function L(r,n,a){const u=V(n,r,a)??r;return C(u,a)}function te(r,n,a,u,l,i){const s=n?.document??{},m=N(r,s,i),t=D(r,s,n,a),e=G(r,n),o=J(r,s,n,a),y=_(r),c=r.responses,p=c?Object.keys(c).filter(U):void 0,f=r.security;return{kind:T.CODE_SAMPLE,operationType:u?"webhook":"http",method:r.httpVerb?.toUpperCase()??"GET",path:r.pathName??"/",servers:m,parameters:t,security:e,requestBody:o,responseCodes:p,requestValues:y,pointer:r.pathName,...l&&{href:l},...r.operationId&&{openApiOperationId:r.operationId},...r.summary&&{summary:r.summary},...f&&f.length>1&&{securityGroups:f}}}function N(r,n,a){const u=n.servers;let l=K(r.servers,u);l=$(l.filter(s=>typeof s?.url=="string"),a?.mockServer);const i=l.map(s=>({url:s.url??"",name:s.name,description:typeof s.description=="string"?s.description:void 0,...s.isMockServer&&{isMockServer:!0},variables:s.variables&&Object.keys(s.variables).length>0?Object.fromEntries(Object.entries(s.variables).map(([m,t])=>[m,{default:t.default,enum:t.enum}])):void 0}));return i.length>0?i:[{url:"/"}]}function D(r,n,a,u){const i=(r.parameters??[]).map(t=>L(t,n,u)),s={path:[],query:[],querystring:[],header:[],cookie:[]},m=r.requestValues?.serverRequestValues;for(const t of i){const e=t.in;if(!e||!s[e])continue;const o=t.content,y=o?Object.keys(o)[0]:void 0,c=y&&o?o[y]?.schema:t.schema,p=c&&typeof c=="object"?V(n,c,u)??c:c;let f;p&&a&&(f=R(a.schemaStore,a.hashIndex,{kind:j.JSON_SCHEMA,data:p}));const S=p&&typeof p=="object"&&"example"in p?p.example:void 0;let v;if(t.examples&&typeof t.examples=="object")for(const d of Object.values(t.examples)){if(!d||typeof d!="object")continue;const x=V(n,d,u)??d;if(F(x)){v=E(x);break}}const b={};if(m&&t.name)for(const[d,x]of Object.entries(m)){const k=x?.[e==="querystring"?"queryString":e==="header"?"headers":e==="cookie"?"cookies":e]?.[t.name];k!=null&&(b[d]={example:k})}s[e].push({name:t.name??"",in:e,required:t.required,example:t.example??v??S,schemaId:f,serializationMime:y,style:t.style,explode:t.explode,...Object.keys(b).length>0&&{serverValues:b}})}return s}function G(r,n){const a=r.requestValues?.security,u=r.requestValues?.serverRequestValues,l=r.security,i=[];if(!l||!n)return i;for(const s of l){const m=Object.keys(s),t=m.map(e=>n.securitySchemeStore[e]).filter(Boolean).map(e=>{let o={id:e.id,type:e.type,name:e.paramName,in:e.in,scheme:e.scheme,bearerFormat:e.bearerFormat,openIdConnectUrl:e.openIdConnectUrl,flows:e.flows,"x-defaultClientId":e["x-defaultClientId"],"x-defaultAccessToken":e["x-defaultAccessToken"],"x-defaultTokenType":e["x-defaultTokenType"],"x-defaultClientSecret":e["x-defaultClientSecret"],"x-defaultUsername":e["x-defaultUsername"],"x-defaultPassword":e["x-defaultPassword"],serverValues:e.serverValues?{...e.serverValues}:void 0};if(a&&(o=g(o,a)),u)for(const[y,c]of Object.entries(u))c?.security&&(o=g(o,c.security,y));return o});if(t.length>0){const e=m.flatMap(o=>s[o]??[]);i.push({schemes:t,scopes:e})}}return i}function J(r,n,a,u){const l=r.requestBody,i=l?V(n,l,u)??l:void 0,s=P(n,i,u);if(!s||!a)return;const m={};for(const[t,e]of Object.entries(s)){let o;const y=e.itemSchema,c=e.schema??y;if(c){const S=V(n,c,u)??c;o=R(a.schemaStore,a.hashIndex,{kind:j.JSON_SCHEMA,data:S})}const p=r.pointer?`${r.pointer}/requestBody/content/${B(t)}`.replace(/^\//,""):void 0,f=[];if(e.example!==void 0&&f.push(O(a.exampleStore,{value:e.example,...p&&{id:`${p}/example`}})),e.examples){const S=q(e.examples);for(const[v,b]of Object.entries(e.examples)){if(w(v))continue;const d=V(n,b,u);if(d){const x=q(b)??q(d)??S,h=O(a.exampleStore,{value:E(d),key:v,summary:typeof d.summary=="string"?d.summary:v,description:M(d.description),externalValue:typeof d.externalValue=="string"?d.externalValue:void 0,...A(x),...p&&{id:`${p}/examples/${B(v)}`}});f.push(h)}}}m[t]={schemaId:o,...f.length>0&&{exampleIds:f}}}return m}function _(r){const n=r.requestValues?.serverRequestValues,a=r.requestValues?.envVariables;let u,l;if(a&&typeof a=="object")if("values"in a){const t=a;u=t.values,l=t.serverValues}else u=a;const i=r.requestValues?.body;let s;if(n)for(const[t,e]of Object.entries(n))e?.body!==void 0&&(s=s??{},s[t]=e.body),e?.envVariables&&(l=l??{},l[t]={...l[t],...e.envVariables});return u||l||r.requestValues?.security||i!==void 0||s?{...r.requestValues?.security&&{security:r.requestValues.security},...u&&{envVariables:u},...l&&{serverEnvVariables:l},...i!==void 0&&{body:i},...s&&{serverBody:s}}:void 0}export{te as buildCodeSampleSource};
|
|
@@ -21,7 +21,7 @@ export declare function mergeSecurityIntoScheme<S extends SchemeForCredentials>(
|
|
|
21
21
|
serverValues: Record<string, SecuritySchemeCredentials>;
|
|
22
22
|
};
|
|
23
23
|
export declare function applyServerVariableDefaults(servers: OpenAPIServer[] | undefined, serverVariables: Record<string, string> | undefined, targetServerUrl?: string): void;
|
|
24
|
-
/** Immutable variant of {@link applyServerVariableDefaults} for
|
|
24
|
+
/** Immutable variant of {@link applyServerVariableDefaults} for runtime callers that must not mutate. */
|
|
25
25
|
export declare function withServerVariableDefaults<T extends {
|
|
26
26
|
url: string;
|
|
27
27
|
variables?: Record<string, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{configure as
|
|
1
|
+
import{configure as p}from"@redocly/theme/ext/configure";import{getOperationData as f}from"../utils/operation.js";function d(n){const{operationInfo:e,info:r,servers:s,basePath:a,dynamicRequestValues:t}=n,{userClaims:i}=n;if(t!=null&&Object.keys(t).length>0)return t;const{slug:u}=f(e,a),c=e.summary||e.operationId||e.pathName||"Unknown Operation",l={userClaims:i,info:r,operation:{name:c,path:e.pathName??"",operationId:e.operationId,href:u,method:e.httpVerb??""},servers:s},o=(p(l)??{}).requestValues;return o!=null&&Object.keys(o).length>0?o:{}}export{d as resolveRequestValues};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { REDOCLY_TEAMS_RBAC } from '@redocly/config';
|
|
2
|
-
import type { RbacScopeItems } from '@redocly/config';
|
|
3
1
|
import type { ApiItem } from '../../../types/store.js';
|
|
4
2
|
import type { OpenAPIDefinition } from '../../../types/openapi.js';
|
|
5
3
|
export declare function addTagItems(document: OpenAPIDefinition, result: ApiItem[]): void;
|
|
6
4
|
export declare function processTagGroups(xTagGroups: Array<{
|
|
7
5
|
name: string;
|
|
8
6
|
tags: string[];
|
|
9
|
-
[REDOCLY_TEAMS_RBAC]?: RbacScopeItems;
|
|
10
7
|
}>, result: ApiItem[]): void;
|
|
11
8
|
export declare function processRootTags(tagOrder: string[], childTagNames: Set<string>, result: ApiItem[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{DEFAULT_WEBHOOKS_TAG_NAME as T,GROUP_DEPTH as D,MAX_NESTING_TAGS_LEVEL as E}from"../../../constants/openapi.js";import{encodeBackSlashes as N,safeSlugify as _}from"../../../utils/string.js";import{joinWithSeparator as v,toRelativePath as A}from"../../../utils/url.js";import{extractMarkdownSections as R,buildMarkdownSectionItem as L}from"../../utils/markdoc.js";import{readRbacScope as l,rbacProp as k}from"../../rbac.js";import{buildGroupContent as B}from"./content.js";import{addOperationItems as G}from"../items/operation/item.js";import{addSchemaDefinitionItems as W}from"../items/schema/item.js";import{addMcpItems as H}from"../items/mcp/item.js";import{openApiContext as p}from"../buildContext.js";function et(t,n){const s=p.get(),o=j(s.tagsMap),e=z(t),r=t["x-tagGroups"];o.size>0?w(e,o,n):r?.length?U(r,n):w(e,o,n)}function U(t,n){const s=p.get();for(const o of t){n.push({type:"separator",label:o.name,...k(l(o)),content:null});for(const e of o.tags||[]){const r=s.tagsMap.get(e);r&&C(e,r,n,[],void 0,l(o))}}}function w(t,n,s){const o=p.get(),e=new Set;for(const r of t)if(!n.has(r)){const a=o.tagsMap.get(r);a&&S(r,a,s,e)}}function O(t){return t.kind==="badge"||t.kind==="audience"}function x(t,n){return v(t,N(_(n).toLowerCase()))}function j(t){const n=new Set;for(const s of t.values()){const{tag:o}=s;o.parent&&!O(o)&&n.add(o.name)}return n}function z(t){const n=p.get(),s=(t.tags||[]).map(e=>e.name);s.includes(T)||s.push(T);const o=n.options.schemaDefinitionsTagName;o&&!s.includes(o)&&s.push(o);for(const e of n.collectedTagOrder)s.includes(e)||s.push(e);return s}function S(t,n,s,o,e=D,r,a){const i=p.get();if(o.has(t)||O(n.tag))return;if(e>E){console.warn("Tags exceed the maximum nesting level.");return}o.add(t);const d=x(r??i.basePath,t),f=l(n.tag)??a,m=[];for(const u of n.children){const c=i.tagsMap.get(u);c&&S(u,c,m,o,e+1,d,f)}C(t,n,s,m,d,a)}function F(t){const n=p.get(),s=[];let o=n.tagsMap.get(t)?.tag;for(;o?.parent;){const e=n.tagsMap.get(o.parent);if(!e)break;s.unshift({label:e.tag.summary||e.tag["x-displayName"]||e.tag.name}),o=e.tag}return s}function C(t,n,s,o,e,r){const a=p.get(),{tag:i,operations:d,description:f}=n,m=l(i)??r;if(t===""){G({operations:d,result:s});return}e||(e=x(a.basePath,t));const u=i.summary||i["x-displayName"]||t,c=[],h=[];W({tagName:t,tagSlug:e,result:c,groupItems:h});const I={tools:[],resources:[],prompts:[]};if(H({tagName:t,tagSlug:e,result:c,groupItems:I}),f&&a.processContent){const g=A(e,a.basePath);for(const P of R(f,a.options,g,!!t))c.push(L({heading:P,basePath:a.basePath}))}if(G({operations:d,result:c,basePath:e,parentRbac:m}),c.push(...o),t===T&&c.length===0)return;const y=F(t),M=n.children.map(g=>{const b=a.tagsMap.get(g)?.tag;return{displayName:b?.summary||b?.["x-displayName"]||g,summary:b?.summary,slug:x(e,g)}});s.push({type:"group",label:u,link:e,routeSlug:e,items:c,...k(m),content:a.processContent?B({tag:i,tagName:t,headerLabel:u,description:f,operations:d,schemasItems:h.length>0?h:void 0,mcpItems:I,tagSlug:e,basePath:a.basePath,breadcrumbs:y.length>0?y:void 0,childTags:M.length>0?M:void 0,markdownOptions:a.options,feedback:a.options.feedback}):null})}export{et as addTagItems,w as processRootTags,U as processTagGroups};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createStoreContext as s,toRecord as l}from"../helpers.js";import{populateOpenApiStore as p}from"./store.js";import{createBuildContext as u}from"./build/context.js";import{buildOverviewItems as
|
|
1
|
+
import{createStoreContext as s,toRecord as l}from"../helpers.js";import{populateOpenApiStore as p}from"./store.js";import{createBuildContext as u}from"./build/context.js";import{buildOverviewItems as S}from"./items/overview/item.js";import{addTagItems as f}from"./group/item.js";import{openApiContext as c}from"./buildContext.js";import{mergeInMockServer as v}from"./utils/merge-mock-server.js";import{toSidebarLogo as g}from"../../utils/logo.js";function x(){return new Promise(r=>setTimeout(r,0))}function d(r,t){let o=(r.servers??[]).filter(e=>typeof e?.url=="string");return o=v(o,t.mockServer),o.map(e=>({url:e.url,...e.name&&{name:e.name},...e.isMockServer&&{isMockServer:!0},...typeof e.description=="string"&&e.description&&{description:e.description},...e.variables&&Object.keys(e.variables).length>0&&{variables:e.variables}}))}async function M({document:r,basePath:t="/",options:i,processContent:o=!0}){const e=s(l(r));o&&(p(r,e,i),await x());const m=u({document:r,options:i,basePath:t,storeCtx:e,processContent:o}),n=d(r,i),a=g(r.info?.["x-logo"],r.info?.contact?.url);return c.run(m,()=>({items:b(),store:{schemaStore:e.schemaStore,exampleStore:e.exampleStore,securitySchemeStore:e.securitySchemeStore,mcp:e.document["x-mcp"],schemaCatalogLink:r["x-schema-catalog-link"],...n.length>0&&{servers:n},...a&&{logo:a}}}))}function b(){const r=c.get(),t=[...S(r.document)];return f(r.document,t),t}export{b as buildOpenApiItems,M as processOpenApiDocument};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as ee}from"@redocly/config";import{contentType as Ne,itemVariant as $e,nodeTypes as u,panelKind as me,schemaKind as H}from"../../../../types/common.js";import{readRbacScope as T,rbacProp as R,registerExample as te,registerSchema as _,resolveContent as ue,resolveRef as D}from"../../../helpers.js";import{applyIgnoreNamedSchemasDeep as Ee}from"../../utils/applyIgnoreNamedSchemasDeep.js";import{isStatusCode as Pe}from"../../../../utils/status-code.js";import{parseMarkdown as V}from"../../../utils/parseMarkdown.js";import{extractDescriptionSegments as De,resolveMarkdocHeadingIds as se}from"../../../utils/markdoc.js";import{getExtensionsForDisplay as ye}from"../../../../utils/extract-extensions.js";import{openApiContext as K}from"../../buildContext.js";import{buildCodeSampleSource as Be}from"../../build-code-sample-source.js";import{mergeInMockServer as He,pickOperationServers as _e}from"../../utils/merge-mock-server.js";import{normalizePath as Ke,toRelativePath as ge}from"../../../../utils/url.js";import{encodeJsonPointerSegment as B}from"../../../../utils/refPointer.js";import{hasOpenApiExampleValue as ke,resolveOpenApiExampleValue as he}from"../../resolve-openapi-example-value.js";const ne="request",Ce="responses",we="callbacks";function Le(){const e=new Map;return(r,o)=>{const n=`${r}/${o}`,t=e.get(n)??0;return e.set(n,t+1),t===0?n:`${n}~${t}`}}function dt(e,r){const{options:o,storeCtx:n,basePath:t}=K.get(),s=e.summary||e.operationId||e.pathName||"Unknown Operation",c=[],{feedback:y}=o,a=e.isWebhook||!1,p=[{nodeType:u.HEADER,level:2,label:s,badges:e["x-badges"],isWebhook:a,deprecated:e.deprecated,showPageActions:!0}],i=ye(e,o.showExtensions);Object.keys(i).length>0&&p.push({nodeType:u.EXTENSIONS,extensions:i}),c.push({nodeType:u.CONTAINER,children:p,panels:[]});const m=o.ignoreNamedSchemas,f=e["x-codeSamples"]?.map(({lang:d,label:x,source:h})=>({lang:d,label:x,source:h})),S=_e(e.servers,n?.document?.servers),E=He(S.filter(d=>typeof d?.url=="string"),o.mockServer).map(d=>{const x=T(d);return{url:d.url??"",name:d.name,description:typeof d.description=="string"?d.description:void 0,...d.isMockServer&&{isMockServer:!0},variables:d.variables&&Object.keys(d.variables).length>0?Object.fromEntries(Object.entries(d.variables).map(([h,M])=>[h,{default:M.default}])):void 0,...R(x)}}),b=Re(e,m),C=ge(r,t);let l=[];e.description&&(se(e.description,C,ne),l=De(e.description,o));const A=l.some(d=>d.kind==="schemaDefinition"),g=b.find(d=>d.nodeType===u.ITEM&&d.variant==="body"),v=We(e,m,a,C||void 0),j=g?.schemaId,I=g?.mediaTypes,N=g?.mediaTypeSchemas,P=T(g),O=[{children:[{kind:me.CODE_SAMPLE,source:v,definitionSamples:f?.length?f:void 0,isWebhook:a,hideReplay:e["x-hideReplay"]===!0,servers:E?.length?E:void 0,schemaId:j,exampleIds:g?.exampleIds,mediaTypes:I,mediaTypeSchemas:N,examples:g?.exampleIds?.map(()=>({}))??[]}],...R(P)}];if(b.length>0||l.length>0)if(A){c.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:ne}],panels:[]});for(const d of l)d.kind==="schemaDefinition"?c.push(d.node):c.push({nodeType:u.CONTAINER,children:[d.node],panels:[]});c.push({nodeType:u.CONTAINER,children:[...b],panels:O})}else c.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:ne},...l.map(d=>d.node),...b],panels:O});else c.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:ne},{nodeType:u.EMPTY_MESSAGE,label:"No request data",labelTranslationKey:"noRequestData"}],panels:O});if(e.responses){const d=Ae(e,o,C,m);if(d){const x=d.responses?.some(k=>k.schemaId||(k.exampleIds?.length??0)>0),h=d?.responses?.map(k=>{const oe=k[ee];return{code:k.code,schemaId:k.schemaId,exampleIds:k.exampleIds,mediaTypes:k.mediaTypes,mediaTypeContent:k.mediaTypeContent,...R(oe)}}),M=[];x&&M.push({children:[{kind:me.RESPONSE,headerTitle:"Response",responseCodes:h,examples:[]}]});const L=T(e.responses);c.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Responses",labelTranslationKey:"responses",deepLinkSuffix:"responses"},d],panels:M.length>0?M:[],...R(L)})}}if(Array.isArray(e.callbacks)&&e.callbacks.length>0){c.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Callbacks",labelTranslationKey:"callbacks",deepLinkSuffix:"callbacks"}],panels:[]});const d=Le();for(const x of e.callbacks)if(x.operations)for(const h of x.operations){const M=h.httpVerb??"post",L=d(x.name,M),k={pointer:e.pointer+"/callbacks/"+x.name+"/"+M,pathName:h.pathName??x.url??"",httpVerb:M,summary:h.summary,deprecated:h.deprecated,isWebhook:!1,isAdditionalOperation:!1,tags:[],parameters:h.parameters,requestBody:h.requestBody,responses:h.responses,servers:h.servers,security:h.security},oe=Re(k,m),fe=Ae(k,o,`${C}/callbacks/${L}`,m),ce=[...oe];fe&&ce.push(fe);const ie=h.externalDocs,be=ye(h,o.showExtensions);let ae;h.description&&(ae=V(h.description,o),se(ae??[],C,`${we}/${L}`));const ve={httpVerb:M,pathName:k.pathName,summary:k.summary,operationId:typeof h.operationId=="string"?h.operationId:void 0,description:ae,deprecated:k.deprecated,callbackName:x.name,callbackId:L,externalDocs:ie?{url:ie.url,description:ie.description}:void 0,extensions:Object.keys(be).length>0?be:void 0,contentChildren:ce.length>0?ce:void 0},xe=[];if(h.requestBody&&"content"in h.requestBody){const de=n?.document??{},qe=D(de,h.requestBody,m)??h.requestBody,le=ue(de,qe,m);if(le){const Se=Object.keys(le);let z=!1;const pe={};for(const[W,$]of Object.entries(le)){let Q;if($.schema){const U=$.schema;Q=_(n.schemaStore,n.hashIndex,{kind:H.JSON_SCHEMA,data:U})}const G=`${k.pointer}/requestBody/content/${B(W)}`.replace(/^\//,""),F=[];if($.example!==void 0){const U=te(n.exampleStore,{value:$.example,id:`${G}/example`});F.push(U),z=!0}if($.examples)for(const[U,Me]of Object.entries($.examples)){const Z=D(de,Me,m);if(Z&&ke(Z)){const je=te(n.exampleStore,{value:he(Z),summary:Z.summary??U,id:`${G}/examples/${B(U)}`});F.push(je),z=!0}}pe[W]={schemaId:Q,exampleIds:F.length>0?F:void 0},Q&&(z=!0)}const Te=h["x-codeSamples"];if(z||(Te?.length??0)>0){const W=h.servers?.filter($=>$.url).map(({url:$,name:Q,description:G,variables:F})=>({url:$,name:Q,description:G,variables:F}));xe.push({children:[{kind:me.CALLBACK_PAYLOAD,callbackName:L,path:k.pathName,httpVerb:M,servers:W?.length?W:void 0,definitionSamples:Te,mediaTypes:Se.length>0?Se:void 0,mediaTypeSchemas:Object.keys(pe).length>0?pe:void 0,examples:[]}]})}}}const Ie=T(x);c.push({nodeType:u.CONTAINER,children:[{nodeType:u.ITEM,variant:"callback",callback:ve,pointer:e.pointer+"/callbacks"}],panels:xe,...R(Ie)})}}y?.hide!==!0&&c.push({nodeType:u.CONTAINER,children:[{nodeType:u.FEEDBACK,pageSlug:Ke(ge(r,t))}],panels:[]});const w=b.some(d=>{const x=d;return x.variant==="body"&&((x.exampleIds?.length??0)>0||!!x.schemaId)})||(f?.length??0)>0;return{contentType:Ne.ITEM,itemVariant:$e.HTTP_ITEM,seo:e["x-seo"],meta:{sourceId:e.operationId,name:s,deprecated:e.deprecated,isWebhook:e.isWebhook||!1,pointer:e.pointer,hasSamples:w},children:c}}function Fe(e,r,o){const n=D(r,e,o)??e,{$ref:t,...s}=e,c=typeof t=="string"?{...n,...s}:n;return Ee(c,o)}function X(e,r,o){if(!e||typeof e!="object")return;const n=e,t=D(r,n,o)??n;return Ee(t,o)}function Ue(e,r,o){if(!e||typeof e!="object")return;const n=T(e),t={},s=[];for(const[c,y]of Object.entries(e)){if(c===ee)continue;const a=D(r,y,o)??y,p=a.content,i=p?p[Object.keys(p)[0]]:void 0,m=a.schema??i?.schema??i?.itemSchema,f=X(m,r,o);if(!f)continue;const S=Oe(a.examples,r,o),E=T(y)??T(a)??n;t[c]={...f,...a.description!==void 0&&{description:a.description},...a.example!==void 0&&{example:a.example},...S&&{examples:S},...R(E)},a.required&&s.push(c)}if(Object.keys(t).length!==0)return{type:"object",properties:t,...s.length>0?{required:s}:{}}}function Ve(e){if(typeof e=="string"||e&&typeof e=="object"&&"$$mdtype"in e||Array.isArray(e)&&e.length>0&&e.every(r=>!!r&&typeof r=="object"&&"$$mdtype"in r))return e}function Y(e,r){const{storeCtx:o,options:n}=K.get(),t=o.document;return e.map(s=>{const c=s.schema;let y={};if(c&&typeof c=="object")y=c;else if(s.content&&typeof s.content=="object"){const S=s.content,E=Object.keys(S)[0],b=E?S[E]?.schema:void 0;b&&typeof b=="object"&&(y=b)}const a=_(o.schemaStore,o.hashIndex,{kind:H.JSON_SCHEMA,data:y}),p=s["x-badges"],i=y["x-badges"],m=Array.isArray(p)?p:Array.isArray(i)?i:void 0,f=ye(s,n.showExtensions);return{name:String(s.name??""),in:typeof s.in=="string"?s.in:void 0,schemaId:a,description:Ve(s.description),required:s.required===!0?!0:void 0,deprecated:s.deprecated===!0?!0:void 0,example:s.example,examples:Oe(s.examples,t,r),...m?.length?{badges:m}:{},...Object.keys(f).length?{extensions:f}:{},...R(T(s))}})}function Oe(e,r,o){if(!e||typeof e!="object")return;const n={};for(const[t,s]of Object.entries(e)){if(!s||typeof s!="object")continue;const c=D(r,s,o)??s;if(!ke(c))continue;const y=he(c);n[t]={...typeof c.summary=="string"&&{summary:c.summary},...typeof c.description=="string"&&{description:c.description},...y!==void 0&&{value:typeof y=="string"?y:JSON.stringify(y)}}}return Object.keys(n).length>0?n:void 0}function Re(e,r){const{storeCtx:o,options:n}=K.get(),t=[],s=o.document,c=Je(e);if(c&&t.push(c),e.parameters&&Array.isArray(e.parameters)){const a=e.parameters.map(l=>Fe(l,s,r)),p=a.filter(l=>l.in==="header"),i=a.filter(l=>l.in==="query"),m=a.filter(l=>l.in==="path"),f=a.filter(l=>l.in==="cookie"),S=a.filter(l=>l.in==="querystring"),E=S.filter(l=>!l.content||typeof l.content!="object"),b=S.filter(l=>l.content&&typeof l.content=="object"),C=S.length>0;m.length>0&&t.push({nodeType:u.ITEM,variant:"path",label:"Path",labelTranslationKey:"path",parameters:Y(m,r),pointer:e.pointer+"/parameters"}),i.length>0&&!C&&t.push({nodeType:u.ITEM,variant:"query",label:"Query",labelTranslationKey:"query",parameters:Y(i,r),pointer:e.pointer+"/parameters"}),E.length>0&&t.push({nodeType:u.ITEM,variant:"querystring",label:"Query String",labelTranslationKey:"querystring",parameters:Y(E,r),pointer:e.pointer+"/parameters"});for(const l of b){const A=l.content,g=Object.keys(A),v={};for(const P of g){const O=A[P];if(!O)continue;let q;const J=O.itemSchema,w=O.schema??J,d=X(w,s,r);d&&(q=_(o.schemaStore,o.hashIndex,{kind:H.JSON_SCHEMA,data:d}));const x=re(O,r);v[P]={schemaId:q,exampleIds:x,...R(T(w))}}const j=g[0],I=j?v[j]:void 0,N=V(l.description,n);t.push({nodeType:u.ITEM,variant:"querystring-body",label:String(l.name??""),required:l.required===!0?!0:void 0,mediaTypes:g.length>0?g:void 0,mediaTypeSchemas:Object.keys(v).length>0?v:void 0,schemaId:I?.schemaId,exampleIds:I?.exampleIds,pointer:e.pointer+"/parameters",...N!==void 0?{description:N}:{},...R(T(l))})}f.length>0&&t.push({nodeType:u.ITEM,variant:"cookies",label:"Cookies",labelTranslationKey:"cookie",parameters:Y(f,r),pointer:e.pointer+"/parameters"}),p.length>0&&t.push({nodeType:u.ITEM,variant:"headers",label:"Headers",labelTranslationKey:"header",parameters:Y(p,r),pointer:e.pointer+"/parameters"})}if(e.requestBody){const y=D(s,e.requestBody,r)??e.requestBody,a=ue(s,y,r),p=a?Object.keys(a):void 0;let i,m,f;if(a&&p){f={};for(const l of p){const A=a[l];if(!A)continue;let g;const v=A.itemSchema,j=A.schema??v,I=X(j,s,r);I&&(g=_(o.schemaStore,o.hashIndex,{kind:H.JSON_SCHEMA,data:I}));const N=re(A,r,`${e.pointer}/requestBody/content/${B(l)}`);f[l]={schemaId:g,exampleIds:N,...R(T(j))}}const b=p[0],C=b?f[b]:void 0;i=C?.schemaId,m=C?.exampleIds}const S=V(y.description,n),E=T(e.requestBody)??T(y);t.push({nodeType:u.ITEM,variant:"body",label:"Request Body",labelTranslationKey:"body",required:y.required,mediaTypes:p,mediaTypeSchemas:f,schemaId:i,exampleIds:m,pointer:e.pointer+"/requestBody",...S!==void 0?{description:S}:{},...R(E)})}return t}function Ae(e,r,o,n){if(!e.responses)return;const{storeCtx:t}=K.get(),s=t?.document??{},c=e.responses,a=Object.entries(c).filter(([p])=>Pe(p)).map(([p,i])=>{const m=D(s,i,n)??i;let f=T(i)??T(m);const S=ue(s,m,n),E=S?Object.keys(S):[],b=E[0],C=b&&S?S[b]:void 0;let l,A,g,v;if(S&&E.length>0){v={};for(const O of E){const q=S[O];if(!q)continue;let J;const w=q.itemSchema,d=q.schema??w,x=X(d,s,n);x&&(J=_(t.schemaStore,t.hashIndex,{kind:H.JSON_SCHEMA,data:x}));const h=re(q,n,`${e.pointer}/responses/${B(p)}/content/${B(O)}`);v[O]={schemaId:J,exampleIds:h,...R(T(d))}}const P=b?v[b]:void 0;l=P?.schemaId,A=P?.exampleIds}else if(C){const P=C.itemSchema,O=C.schema??P,q=X(O,s,n);q&&(f=f??T(O),l=_(t.schemaStore,t.hashIndex,{kind:H.JSON_SCHEMA,data:q})),A=re(C,n,b?`${e.pointer}/responses/${B(p)}/content/${B(b)}`:void 0)}const j=Ue(m.headers,s,n);j&&(g=_(t.schemaStore,t.hashIndex,{kind:H.JSON_SCHEMA,data:j}));let I;m.description&&(I=V(m.description,r),se(I??[],o,`${Ce}/${p}`));const N=m["x-summary"]?V(m["x-summary"],r):void 0;return N&&se(N,o,`${Ce}/${p}/summary`),{code:p,summary:N,description:I,mediaType:b,mediaTypes:E.length>0?E:void 0,mediaTypeContent:v,schemaId:l,exampleIds:A,headers:m.headers,headerSchemaId:g,...R(f)}});return{nodeType:u.ITEM,variant:"responses",responses:a,pointer:e.pointer+"/responses"}}function re(e,r,o){const{storeCtx:n}=K.get(),t=[],s=n.document,c=o?.replace(/^\//,"");if(e.example!==void 0){const y=te(n.exampleStore,{value:e.example,...c&&{id:`${c}/example`}});t.push(y)}if(e.examples&&typeof e.examples=="object"){const y=T(e.examples);for(const[a,p]of Object.entries(e.examples)){if(a===ee||!p||typeof p!="object")continue;const i=D(s,p,r)??p,m=T(p)??T(i)??y,f=te(n.exampleStore,{value:he(i),key:a,summary:typeof i.summary=="string"?i.summary:a,description:typeof i.description=="string"?i.description:void 0,externalValue:typeof i.externalValue=="string"?i.externalValue:void 0,...R(m),...c&&{id:`${c}/examples/${B(a)}`}});t.push(f)}}return t.length>0?t:void 0}function Je(e){const{storeCtx:r,options:o}=K.get();if(!e.security||!Array.isArray(e.security)||e.security.length===0)return;const n=e.security.map(t=>{const s=Object.entries(t);if(s.length===0)return null;const c=r?.document?.components?.securitySchemes,y=s.map(([a,p])=>{const i=r?.securitySchemeStore[a],m=T(c?.[a])??i?.[ee];return{name:a,scopes:Array.isArray(p)?p:void 0,type:i?.type,scheme:i?.scheme,bearerFormat:i?.bearerFormat,in:i?.in,paramName:i?.paramName,description:i?.description?V(i.description,o):i?.description,openIdConnectUrl:i?.openIdConnectUrl,oauth2MetadataUrl:i?.oauth2MetadataUrl,deprecated:i?.deprecated,flows:i?.flows,...R(m)}}).filter(a=>a.name);return y.length>0?{schemes:y}:null}).filter(t=>t!==null);if(n.length!==0)return{nodeType:u.SECURITY,requirements:n}}function We(e,r,o,n){const{storeCtx:t,options:s}=K.get();if(!t)throw new Error("OpenAPI store context is not initialized");return Be(e,t,s,r,o,n)}export{dt as buildItemContent,Le as createCallbackIdFactory};
|
|
1
|
+
import{isRbacKey as ee}from"../../../rbac.js";import{contentType as me,itemVariant as ue,nodeTypes as h,panelKind as z,schemaKind as B}from"../../../../types/common.js";import{readRbacScope as E,rbacProp as O,registerExample as J,pickRenderableDescription as te,registerSchema as H,resolveContent as Y,resolveRef as N}from"../../../helpers.js";import{applyIgnoreNamedSchemasDeep as se}from"../../utils/applyIgnoreNamedSchemasDeep.js";import{isStatusCode as ye}from"../../../../utils/status-code.js";import{parseMarkdown as K}from"../../../utils/parseMarkdown.js";import{extractDescriptionSegments as he,isMarkdocAst as fe,resolveMarkdocHeadingIds as W}from"../../../utils/markdoc.js";import{getExtensionsForDisplay as G}from"../../../../utils/extract-extensions.js";import{openApiContext as M}from"../../buildContext.js";import{buildCodeSampleSource as be}from"../../build-code-sample-source.js";import{pickOperationServers as xe}from"../../utils/merge-mock-server.js";import{mergeInMockServer as Se}from"../../utils/merge-mock-server.js";import{normalizePath as Te}from"../../../../utils/url.js";import{toRelativePath as ne}from"../../../../utils/url.js";import{encodeJsonPointerSegment as D}from"../../../../utils/refPointer.js";import{hasOpenApiExampleValue as re,resolveOpenApiExampleValue as Z}from"../../resolve-openapi-example-value.js";const Q="request",oe="responses",ie="callbacks";function Ee(){const e=new Map;return(c,s)=>{const r=`${c}/${s}`,n=e.get(r)??0;return e.set(r,n+1),n===0?r:`${r}~${n}`}}function Je(e,c){const{options:s,storeCtx:r,basePath:n}=M.get(),t=e.summary||e.operationId||e.pathName||"Unknown Operation",i=[],{feedback:l}=s,o=e.isWebhook||!1,p=[{nodeType:h.HEADER,level:2,label:t,badges:e["x-badges"],isWebhook:o,deprecated:e.deprecated,showPageActions:!0}],a=G(e,s.showExtensions);Object.keys(a).length>0&&p.push({nodeType:h.EXTENSIONS,extensions:a}),i.push({nodeType:h.CONTAINER,children:p,panels:[]});const m=s.ignoreNamedSchemas,y=e["x-codeSamples"]?.map(({lang:u,label:I,source:L})=>({lang:u,label:I,source:L}));let b=xe(e.servers,r?.document?.servers).filter(u=>typeof u?.url=="string");b=Se(b,s.mockServer);const f=b.map(u=>{const I=E(u);return{url:u.url??"",name:u.name,description:typeof u.description=="string"?u.description:void 0,...u.isMockServer&&{isMockServer:!0},variables:u.variables&&Object.keys(u.variables).length>0?Object.fromEntries(Object.entries(u.variables).map(([L,V])=>[L,{default:V.default}])):void 0,...O(I)}}),x=ae(e,m),d=ne(c,n);let g=[];e.description&&(W(e.description,d,Q),g=he(e.description,s));const C=g.some(u=>u.kind==="schemaDefinition"),S=x.find(u=>u.nodeType===h.ITEM&&u.variant==="body"),q=ke(e,m,o,d||void 0),v=S?.schemaId,k=S?.mediaTypes,j=S?.mediaTypeSchemas,A=E(S),R=[{children:[{kind:z.CODE_SAMPLE,source:q,definitionSamples:y?.length?y:void 0,isWebhook:o,hideReplay:e["x-hideReplay"]===!0,servers:f?.length?f:void 0,schemaId:v,exampleIds:S?.exampleIds,mediaTypes:k,mediaTypeSchemas:j,examples:S?.exampleIds?.map(()=>({}))??[]}],...O(A)}];if(x.length>0||g.length>0)if(C){i.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:Q}],panels:[]});for(const u of g)u.kind==="schemaDefinition"?i.push(u.node):i.push({nodeType:h.CONTAINER,children:[u.node],panels:[]});i.push({nodeType:h.CONTAINER,children:[...x],panels:R})}else i.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:Q},...g.map(u=>u.node),...x],panels:R});else i.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:Q},{nodeType:h.EMPTY_MESSAGE,label:"No request data",labelTranslationKey:"noRequestData"}],panels:R});if(e.responses){const u=de(e,s,d,m);if(u){const I=u.responses?.some(P=>P.schemaId||(P.exampleIds?.length??0)>0),L=u?.responses?.map(P=>{const le=E(P);return{code:P.code,schemaId:P.schemaId,exampleIds:P.exampleIds,mediaTypes:P.mediaTypes,mediaTypeContent:P.mediaTypeContent,...O(le)}}),V=[];I&&V.push({children:[{kind:z.RESPONSE,responseCodes:L,examples:[]}]});const pe=E(e.responses);i.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Responses",labelTranslationKey:"responses",deepLinkSuffix:"responses"},u],panels:V.length>0?V:[],...O(pe)})}}Array.isArray(e.callbacks)&&e.callbacks.length>0&&i.push(...ge(e,d,m)),l?.hide!==!0&&i.push({nodeType:h.CONTAINER,children:[{nodeType:h.FEEDBACK,pageSlug:Te(ne(c,n))}],panels:[]});const $=x.some(u=>{const I=u;return I.variant==="body"&&((I.exampleIds?.length??0)>0||!!I.schemaId)})||(y?.length??0)>0;return{contentType:me.ITEM,itemVariant:ue.HTTP_ITEM,seo:e["x-seo"],meta:{sourceId:e.operationId,name:t,deprecated:e.deprecated,isWebhook:e.isWebhook||!1,pointer:e.pointer,hasSamples:$},children:i}}function ge(e,c,s){const r=[{nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Callbacks",labelTranslationKey:"callbacks",deepLinkSuffix:ie}],panels:[]}],n=Ee();for(const t of e.callbacks??[])if(t.operations)for(const i of t.operations){const l=i.httpVerb??"post",o=n(t.name,l);r.push(Ce(e,t,i,o,c,s))}return r}function Ce(e,c,s,r,n,t){const{options:i}=M.get(),l=s.httpVerb??"post",o={pointer:e.pointer+"/callbacks/"+c.name+"/"+l,pathName:s.pathName??c.url??"",httpVerb:l,summary:s.summary,deprecated:s.deprecated,isWebhook:!1,isAdditionalOperation:!1,tags:[],parameters:s.parameters,requestBody:s.requestBody,responses:s.responses,servers:s.servers,security:s.security},p=ae(o,t),a=de(o,i,`${n}/callbacks/${r}`,t),m=[...p];a&&m.push(a);const y=s.externalDocs,T=G(s,i.showExtensions);let b;s.description&&(b=K(s.description,i),W(b??[],n,`${ie}/${r}`));const f={httpVerb:l,pathName:o.pathName,summary:o.summary,operationId:typeof s.operationId=="string"?s.operationId:void 0,description:b,deprecated:o.deprecated,callbackName:c.name,callbackId:r,externalDocs:y?{url:y.url,description:y.description}:void 0,extensions:Object.keys(T).length>0?T:void 0,contentChildren:m.length>0?m:void 0},x=ve(s,o,r,t),d=E(c);return{nodeType:h.CONTAINER,children:[{nodeType:h.ITEM,variant:"callback",callback:f,pointer:e.pointer+"/callbacks"}],panels:x,...O(d)}}function ve(e,c,s,r){const{storeCtx:n}=M.get(),t=[];if(!e.requestBody||!("content"in e.requestBody))return t;const i=n?.document??{},l=N(i,e.requestBody,r)??e.requestBody,o=Y(i,l,r);if(!o)return t;const p=Object.keys(o);let a=!1;const m={};for(const[f,x]of Object.entries(o)){let d;if(x.schema){const S=x.schema;d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:S})}const g=`${c.pointer}/requestBody/content/${D(f)}`.replace(/^\//,""),C=[];if(x.example!==void 0){const S=J(n.exampleStore,{value:x.example,id:`${g}/example`});C.push(S),a=!0}if(x.examples)for(const[S,q]of Object.entries(x.examples)){const v=N(i,q,r);if(v&&re(v)){const k=J(n.exampleStore,{value:Z(v),summary:v.summary??S,description:te(v.description),id:`${g}/examples/${D(S)}`});C.push(k),a=!0}}m[f]={schemaId:d,exampleIds:C.length>0?C:void 0},d&&(a=!0)}const y=e["x-codeSamples"];if(!(a||(y?.length??0)>0))return t;const b=e.servers?.filter(f=>f.url).map(({url:f,name:x,description:d,variables:g})=>({url:f,name:x,description:d,variables:g}));return t.push({children:[{kind:z.CALLBACK_PAYLOAD,callbackName:s,path:c.pathName,httpVerb:c.httpVerb,servers:b?.length?b:void 0,definitionSamples:y,mediaTypes:p.length>0?p:void 0,mediaTypeSchemas:Object.keys(m).length>0?m:void 0,examples:[]}]}),t}function Oe(e,c,s){const r=N(c,e,s)??e,{$ref:n,...t}=e,i=typeof n=="string"?{...r,...t}:r;return se(i,s)}function F(e,c,s){if(!e||typeof e!="object")return;const r=e,n=N(c,r,s)??r;return se(n,s)}function Re(e,c,s){if(!e||typeof e!="object")return;const r=E(e),n={},t=[];for(const[i,l]of Object.entries(e)){if(ee(i))continue;const o=N(c,l,s)??l,p=o.content,a=p?p[Object.keys(p)[0]]:void 0,m=o.schema??a?.schema??a?.itemSchema,y=F(m,c,s);if(!y)continue;const T=ce(o.examples,c,s),b=E(l)??E(o)??r;n[i]={...y,...o.description!==void 0&&{description:o.description},...o.example!==void 0&&{example:o.example},...T&&{examples:T},...O(b)},o.required&&t.push(i)}if(Object.keys(n).length!==0)return{type:"object",properties:n,...t.length>0?{required:t}:{}}}function Ae(e){return typeof e=="string"||fe(e)?e:void 0}function U(e,c){const{storeCtx:s,options:r}=M.get(),n=s.document;return e.map(t=>{const i=t.schema;let l={};if(i&&typeof i=="object")l=i;else if(t.content&&typeof t.content=="object"){const T=t.content,b=Object.keys(T)[0],f=b?T[b]?.schema:void 0;f&&typeof f=="object"&&(l=f)}const o=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:l}),p=t["x-badges"],a=l["x-badges"],m=Array.isArray(p)?p:Array.isArray(a)?a:void 0,y=G(t,r.showExtensions);return{name:String(t.name??""),in:typeof t.in=="string"?t.in:void 0,schemaId:o,description:Ae(t.description),required:t.required===!0?!0:void 0,deprecated:t.deprecated===!0?!0:void 0,example:t.example,examples:ce(t.examples,n,c),...m?.length?{badges:m}:{},...Object.keys(y).length?{extensions:y}:{},...O(E(t))}})}function ce(e,c,s){if(!e||typeof e!="object")return;const r={};for(const[n,t]of Object.entries(e)){if(!t||typeof t!="object")continue;const i=N(c,t,s)??t;if(!re(i))continue;const l=Z(i);r[n]={...typeof i.summary=="string"&&{summary:i.summary},...typeof i.description=="string"&&{description:i.description},...l!==void 0&&{value:typeof l=="string"?l:JSON.stringify(l)}}}return Object.keys(r).length>0?r:void 0}function ae(e,c){const{storeCtx:s,options:r}=M.get(),n=[],t=s.document,i=qe(e);if(i&&n.push(i),e.parameters&&Array.isArray(e.parameters)){const o=e.parameters.map(d=>Oe(d,t,c)),p=o.filter(d=>d.in==="header"),a=o.filter(d=>d.in==="query"),m=o.filter(d=>d.in==="path"),y=o.filter(d=>d.in==="cookie"),T=o.filter(d=>d.in==="querystring"),b=T.filter(d=>!d.content||typeof d.content!="object"),f=T.filter(d=>d.content&&typeof d.content=="object"),x=T.length>0;m.length>0&&n.push({nodeType:h.ITEM,variant:"path",label:"Path",labelTranslationKey:"path",parameters:U(m,c),pointer:e.pointer+"/parameters"}),a.length>0&&!x&&n.push({nodeType:h.ITEM,variant:"query",label:"Query",labelTranslationKey:"query",parameters:U(a,c),pointer:e.pointer+"/parameters"}),b.length>0&&n.push({nodeType:h.ITEM,variant:"querystring",label:"Query String",labelTranslationKey:"querystring",parameters:U(b,c),pointer:e.pointer+"/parameters"});for(const d of f){const g=d.content,C=Object.keys(g),S={};for(const j of C){const A=g[j];if(!A)continue;let R;const _=A.itemSchema,w=A.schema??_,$=F(w,t,c);$&&(R=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:$}));const u=X(A,c);S[j]={schemaId:R,exampleIds:u,...O(E(w))}}const q=C[0],v=q?S[q]:void 0,k=K(d.description,r);n.push({nodeType:h.ITEM,variant:"querystring-body",label:String(d.name??""),required:d.required===!0?!0:void 0,mediaTypes:C.length>0?C:void 0,mediaTypeSchemas:Object.keys(S).length>0?S:void 0,schemaId:v?.schemaId,exampleIds:v?.exampleIds,pointer:e.pointer+"/parameters",...k!==void 0?{description:k}:{},...O(E(d))})}y.length>0&&n.push({nodeType:h.ITEM,variant:"cookies",label:"Cookies",labelTranslationKey:"cookie",parameters:U(y,c),pointer:e.pointer+"/parameters"}),p.length>0&&n.push({nodeType:h.ITEM,variant:"headers",label:"Headers",labelTranslationKey:"header",parameters:U(p,c),pointer:e.pointer+"/parameters"})}if(e.requestBody){const l=N(t,e.requestBody,c)??e.requestBody,o=Y(t,l,c),p=o?Object.keys(o):void 0;let a,m,y;if(o&&p){y={};for(const d of p){const g=o[d];if(!g)continue;let C;const S=g.itemSchema,q=g.schema??S,v=F(q,t,c);v&&(C=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:v}));const k=X(g,c,`${e.pointer}/requestBody/content/${D(d)}`);y[d]={schemaId:C,exampleIds:k,...O(E(q))}}const f=p[0],x=f?y[f]:void 0;a=x?.schemaId,m=x?.exampleIds}const T=K(l.description,r),b=E(e.requestBody)??E(l);n.push({nodeType:h.ITEM,variant:"body",label:"Request Body",labelTranslationKey:"body",required:l.required,mediaTypes:p,mediaTypeSchemas:y,schemaId:a,exampleIds:m,pointer:e.pointer+"/requestBody",...T!==void 0?{description:T}:{},...O(b)})}return n}function de(e,c,s,r){if(!e.responses)return;const{storeCtx:n}=M.get(),t=n?.document??{},i=e.responses,o=Object.entries(i).filter(([p])=>ye(p)).map(([p,a])=>{const m=N(t,a,r)??a;let y=E(a)??E(m);const T=Y(t,m,r),b=T?Object.keys(T):[],f=b[0],x=f&&T?T[f]:void 0;let d,g,C,S;if(T&&b.length>0){S={};for(const A of b){const R=T[A];if(!R)continue;let _;const w=R.itemSchema,$=R.schema??w,u=F($,t,r);u&&(_=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:u}));const I=X(R,r,`${e.pointer}/responses/${D(p)}/content/${D(A)}`);S[A]={schemaId:_,exampleIds:I,...O(E($))}}const j=f?S[f]:void 0;d=j?.schemaId,g=j?.exampleIds}else if(x){const j=x.itemSchema,A=x.schema??j,R=F(A,t,r);R&&(y=y??E(A),d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:R})),g=X(x,r,f?`${e.pointer}/responses/${D(p)}/content/${D(f)}`:void 0)}const q=Re(m.headers,t,r);q&&(C=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:q}));let v;m.description&&(v=K(m.description,c),W(v??[],s,`${oe}/${p}`));const k=m["x-summary"]?K(m["x-summary"],c):void 0;return k&&W(k,s,`${oe}/${p}/summary`),{code:p,summary:k,description:v,mediaType:f,mediaTypes:b.length>0?b:void 0,mediaTypeContent:S,schemaId:d,exampleIds:g,headers:m.headers,headerSchemaId:C,...O(y)}});return{nodeType:h.ITEM,variant:"responses",responses:o,pointer:e.pointer+"/responses"}}function X(e,c,s){const{storeCtx:r}=M.get(),n=[],t=r.document,i=s?.replace(/^\//,"");if(e.example!==void 0){const l=J(r.exampleStore,{value:e.example,...i&&{id:`${i}/example`}});n.push(l)}if(e.examples&&typeof e.examples=="object"){const l=E(e.examples);for(const[o,p]of Object.entries(e.examples)){if(ee(o)||!p||typeof p!="object")continue;const a=N(t,p,c)??p,m=E(p)??E(a)??l,y=J(r.exampleStore,{value:Z(a),key:o,summary:typeof a.summary=="string"?a.summary:o,description:te(a.description),externalValue:typeof a.externalValue=="string"?a.externalValue:void 0,...O(m),...i&&{id:`${i}/examples/${D(o)}`}});n.push(y)}}return n.length>0?n:void 0}function qe(e){const{storeCtx:c,options:s}=M.get();if(!e.security||!Array.isArray(e.security)||e.security.length===0)return;const r=e.security.map(n=>{const t=Object.entries(n);if(t.length===0)return null;const i=c?.document?.components?.securitySchemes,l=t.map(([o,p])=>{const a=c?.securitySchemeStore[o],m=E(i?.[o])??E(a);return{name:o,scopes:Array.isArray(p)?p:void 0,type:a?.type,scheme:a?.scheme,bearerFormat:a?.bearerFormat,in:a?.in,paramName:a?.paramName,description:a?.description?K(a.description,s):a?.description,openIdConnectUrl:a?.openIdConnectUrl,oauth2MetadataUrl:a?.oauth2MetadataUrl,deprecated:a?.deprecated,flows:a?.flows,...O(m)}}).filter(o=>o.name);return l.length>0?{schemes:l}:null}).filter(n=>n!==null);if(r.length!==0)return{nodeType:h.SECURITY,requirements:r}}function ke(e,c,s,r){const{storeCtx:n}=M.get(),{options:t}=M.get();if(!n)throw new Error("OpenAPI store context is not initialized");return be(e,n,c,s,r,t)}export{Je as buildItemContent,Ee as createCallbackIdFactory};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { REDOCLY_TEAMS_RBAC } from '@redocly/config';
|
|
2
1
|
import type { ApiItem } from '../../../../types/store.js';
|
|
3
2
|
import type { OperationInfo } from '../../../../types/openapi.js';
|
|
3
|
+
import { type RbacScope } from '../../../rbac.js';
|
|
4
4
|
export declare function addOperationItems({ operations, result, basePath: basePathOverride, parentRbac, }: {
|
|
5
5
|
operations: OperationInfo[];
|
|
6
6
|
result: ApiItem[];
|
|
7
7
|
basePath?: string;
|
|
8
|
-
parentRbac?:
|
|
8
|
+
parentRbac?: RbacScope;
|
|
9
9
|
}): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{WEBHOOKS_GROUP_TITLE as k}from"../../../../constants/openapi.js";import{buildItemContent as v}from"./content.js";import{getOperationData as O}from"../../utils/operation.js";import{resolveRequestValues as y,applyRequestValuesToOperationInfo as S}from"../../configure/index.js";import{openApiContext as d}from"../../buildContext.js";import{readRbacScope as I,rbacProp as R}from"../../../rbac.js";import{mergeInMockServer as w}from"../../utils/merge-mock-server.js";import{pickOperationServers as q}from"../../utils/merge-mock-server.js";function E({operations:t,result:o,basePath:a,parentRbac:r}){const{basePath:s}=d.get(),e=a??s,{regular:p,regularDeprecated:m,webhooks:n,webhooksDeprecated:c}=C(t);for(const i of[...p,...m])h(i,e,o,r);const f=n.length>0||c.length>0,u=p.length>0||m.length>0;f&&u&&o.push({type:"separator",label:k,variant:"secondary",content:null});for(const i of[...n,...c])h(i,e,o,r)}function C(t){const o=[],a=[],r=[],s=[];for(const e of t)e.isWebhook?(e.deprecated?s:r).push(e):(e.deprecated?a:o).push(e);return{regular:o,regularDeprecated:a,webhooks:r,webhooksDeprecated:s}}function h(t,o,a,r){const{document:s,options:e,processContent:p}=d.get();let n=q(t.servers,s.servers).filter(l=>typeof l?.url=="string");if(n=w(n,e.mockServer),p){const l=y({operationInfo:t,info:s.info??{},servers:n,basePath:o,userClaims:e.userClaims,dynamicRequestValues:e.dynamicRequestValues});l&&Object.keys(l).length>0&&S(t,l,n)}const{slug:c,badges:f,httpPath:u,seo:i,...b}=O(t,o),g={...b,type:"link",link:c,routeSlug:c,metadata:{...i?{seo:i}:{}},...R(I(t)??r),content:p?v(t,c):null};f&&Object.assign(g,{badges:f}),u&&Object.assign(g,{httpPath:u}),a.push(g)}export{E as addOperationItems};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{contentType as
|
|
1
|
+
import{contentType as M,nodeTypes as o}from"../../../../types/common.js";import{asString as y}from"../../../../utils/string.js";import{parseMarkdown as p}from"../../../utils/parseMarkdown.js";import{buildDownloadPanelContent as N}from"../../panels/download.js";import{buildOverviewPanelContent as x}from"../../panels/overview.js";import{buildInfoMetadataContentNode as V}from"../../../utils/infoMetadata.js";import{buildLanguagesPanelContent as W}from"../../panels/languages.js";import{mergeInMockServer as _}from"../../utils/merge-mock-server.js";import{buildMcpPanelContent as k}from"../../panels/mcp.js";import{buildServersPanelContent as L}from"../../panels/servers.js";function G({document:s,description:S,sectionChildren:g,options:n}){const{downloadUrls:m,hideDownloadButtons:D,basePath:u}=n,{hideInfoMetadata:I}=n,f=n.codeSamples?.languages??[],e=s.info;let r=y(e?.title)??"API Documentation";const h=e?.["x-seo"];r=y(h?.title)??r;const O=e?.version?`${r} (${e.version})`:r,t=[];!D&&m&&t.push(N(m)),t.push(x(e)),f.length&&t.push(W(f));const C=k(s);C&&t.push(C);let a=s.servers??[];a=_(a,n.mockServer);const R=a.map(i=>({...i,description:typeof i.description=="string"?i.description:void 0})),E=L(R);E&&t.push(E);const c={nodeType:o.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:o.HEADER,level:1,label:O,showPageActions:!0}],sectionId:u},v=p(e.summary,n);v&&c.children.push({nodeType:o.MARKDOC,content:v});const P=p(S,n);P&&c.children.push({nodeType:o.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:o.MARKDOC,content:P}],sectionId:u});const b=n,l=s.externalDocs||e?.externalDocs;if(l?.url){const i=p(l.description,b)??[];c.children.push({nodeType:o.EXTERNAL_DOCS,url:l.url,description:i})}const d=[c],T=V(e,I);T&&d.push(T),d.push(...g);const w={nodeType:o.CONTAINER,panels:t,children:d},A={name:r};return{contentType:M.OVERVIEW,seo:h,meta:A,children:[w]}}export{G as buildOverviewContent};
|