@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 @@
|
|
|
1
|
+
import{parametersExtractor as e}from"./parameters.js";import{graphqlExtractor as o}from"./graphql.js";import{namedRowsExtractor as a}from"./named-rows.js";import{bodyExtractor as x}from"./body.js";import{responsesExtractor as c}from"./responses.js";import{messagesExtractor as m}from"./asyncapi.js";import{examplesExtractor as s}from"./examples.js";const p=[e,o,a,x,c,m,s];function F(r){return p.filter(t=>t.matches(r))}import{extractCallback as R}from"./callbacks.js";import{extractHeadingSections as u}from"./heading-sections.js";import{extractChannelAddress as b,extractMessageBindingFields as y,extractServerFields as C}from"./asyncapi.js";import{extractMcpFields as k}from"./mcp.js";import{extractInfoMetadataRows as v,extractPanelRows as A}from"./panels.js";import{extractSecurityRows as H}from"./security.js";import{extractSchemaPageFields as j}from"./schema-page.js";export{R as extractCallback,b as extractChannelAddress,u as extractHeadingSections,v as extractInfoMetadataRows,k as extractMcpFields,y as extractMessageBindingFields,A as extractPanelRows,j as extractSchemaPageFields,H as extractSecurityRows,C as extractServerFields,p as extractors,F as extractorsFor};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { OperationParameter } from '@redocly/theme/core/openapi';
|
|
2
|
+
import type { ApiItem } from '../../../../types/store.js';
|
|
3
|
+
import type { ExtractContext } from './context.js';
|
|
4
|
+
type McpFields = {
|
|
5
|
+
text: string;
|
|
6
|
+
parameters: OperationParameter[];
|
|
7
|
+
};
|
|
8
|
+
export declare function extractMcpFields(item: ApiItem, document: Record<string, unknown> | undefined, ctx: ExtractContext): McpFields | undefined;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{buildPromptArgumentsSchema as d}from"../../../../components/Mcp/utils.js";import{MCP_INPUT_SCHEMA_PLACE as l,MCP_OUTPUT_SCHEMA_PLACE as P,MCP_PROMPT_ARGUMENTS_PLACE as M}from"../places.js";import{describe as _}from"./context.js";const C=new Set(["tool","rsrc","prompt"]);function h(i,a,s){const n="httpVerb"in i?i.httpVerb:void 0,r=i.content?.meta?.name;if(!n||!C.has(n)||typeof r!="string")return;const c=a?.["x-mcp"],u={},p=e=>typeof e=="string"?_(s,e):"",m=(e,t,f)=>{e&&typeof e=="object"&&s.walker.extractSchemaNodeFields(e,{place:t,paramsMap:u,slug:s.slug,linkType:f})};let o="";if(n==="tool"){const e=c?.tools?.find(t=>t.name===r);if(!e)return;o=p(e.description),m(e.inputSchema,l,"input-schema"),m(e.outputSchema,P,"output-schema")}else if(n==="rsrc"){const e=c?.resources?.find(t=>t.name===r);if(!e)return;o=[p(e.description),e.uri,e.mimeType].filter(Boolean).join(" ")}else{const e=c?.prompts?.find(t=>t.name===r);if(!e)return;o=p(e.description),m(d(e.arguments??[]),M,"arguments")}return{text:o,parameters:Object.values(u)}}export{h as extractMcpFields};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Node } from '@markdoc/markdoc';
|
|
2
|
+
import type { ExtractContext, Extractor } from './context.js';
|
|
3
|
+
export type NamedRow = {
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string | Node | Node[];
|
|
6
|
+
type?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const namedRowsExtractor: Extractor;
|
|
9
|
+
export declare function addNamedRows(rows: NamedRow[], place: string, suffix: string, ctx: ExtractContext): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{makeDeepLink as p}from"../../../../utils/deep-link.js";import{makeParam as i}from"../param.js";import{fieldsPlaceOf as n,scopedPlace as c}from"../places.js";import{addRow as l,describe as d}from"./context.js";const t=e=>(e??[]).map(a=>({name:a})),m={values:e=>e.values??[],"possible-types":e=>t(e.graphqlTypeNames),implements:e=>t(e.graphqlInterfaceNames),"implemented-by":e=>t(e.graphqlTypeNames)},g={matches:e=>e.variant in m,extract(e,a){const r=m[e.variant]?.(e)??[];f(r,c(n(e.variant),a.scope.callbackId),e.variant,a)}};function f(e,a,r,o){for(const s of e)l(o,i({name:s.name,description:d(o,s.description),place:a,type:s.type??"",deepLink:o.slug?p(o.slug,r):void 0}))}export{f as addNamedRows,g as namedRowsExtractor};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContainerNode, InfoMetadataNode, ServersPanelItem } from '../../../../types/content.js';
|
|
2
|
+
import type { ExtractContext } from './context.js';
|
|
3
|
+
type ServerVariables = ServersPanelItem['servers'][number]['variables'];
|
|
4
|
+
/** One row per server variable, on the overview page only, so a variable leads to the servers panel there. */
|
|
5
|
+
export declare function extractServerVariableRows(variables: ServerVariables, ctx: ExtractContext): void;
|
|
6
|
+
/** Rows for the side panels of a page: servers, and the info attributes (contact, license, terms). */
|
|
7
|
+
export declare function extractPanelRows(container: ContainerNode, ctx: ExtractContext): void;
|
|
8
|
+
/** One row per key/value of the overview's `x-metadata` table. */
|
|
9
|
+
export declare function extractInfoMetadataRows(node: InfoMetadataNode, ctx: ExtractContext): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hasRbacScope as f}from"../../../../adapters/rbac.js";import{panelKind as l}from"../../../../types/common.js";import{makeParam as a}from"../param.js";import{METADATA_PLACE as m,OVERVIEW_PLACE as s,SERVER_PLACE as u,SERVER_VARIABLES_PLACE as d}from"../places.js";import{addRow as t,describe as p}from"./context.js";function E(i,n){if(n.isOverview)for(const[r,o]of Object.entries(i??{}))t(n,a({name:r,description:[p(n,o.description),o.default?`default ${o.default}`:"",o.enum?.length?`enum: ${o.enum.join(", ")}`:""].filter(Boolean).join(" "),place:d,type:"unknown"}))}function v(i,n){for(const r of i.panels??[])for(const o of r.children??[])switch(o.kind){case l.SERVERS:for(const e of o.servers){const c=e;c.isMockServer||f(c)||(t(n,a({name:e.name??e.url,description:[e.name?e.url:"",p(n,e.description)].filter(Boolean).join(" "),place:u,type:"unknown"})),E(e.variables,n))}break;case l.ATTRIBUTE:{const e=o;t(n,a({name:e.title??e.label,description:e.value,place:s,type:"unknown"}));break}case l.EXTERNAL_LINK:{const e=o;t(n,a({name:e.title??e.label,description:[e.title?e.label:"",e.url].filter(Boolean).join(" "),place:s,type:"unknown"}));break}case l.EMAIL:{const e=o;t(n,a({name:e.title??e.label,description:e.email,place:s,type:"unknown"}));break}}}function L(i,n){for(const r of i.rows)t(n,a({name:r.key,description:r.value,place:m,type:"unknown"}))}export{L as extractInfoMetadataRows,v as extractPanelRows,E as extractServerVariableRows};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hasRbacScope as t}from"../../../../adapters/rbac.js";import{buildFieldDeepLink as o}from"../deep-links.js";import{makeParam as s}from"../param.js";import{parameterPlaceOf as p,scopedPlace as i}from"../places.js";import{addRow as m,describe as n}from"./context.js";const c=new Set(["query","path","headers","cookies","querystring","parameters"]);function d(e){return c.has(e??"")?e:void 0}const k={matches:e=>!!e.parameters?.length,extract(e,r){for(const a of e.parameters??[])t(a)||m(r,s({name:a.name,description:n(r,a.description),place:i(p(e.variant),r.scope.callbackId),type:r.walker.resolveParameterType(a.schemaId),required:a.required??!1,deepLink:o({slug:r.slug,type:"request",in:d(e.variant),fieldPath:[a.name],scope:r.scope})}))}};export{k as parametersExtractor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hasRbacScope as p}from"../../../../adapters/rbac.js";import{buildOpenApiSectionSuffix as r,makeDeepLink as m,CALLBACKS_SECTION as l}from"../../../../utils/deep-link.js";import{makeParam as f}from"../param.js";import{responseFieldsPlace as u,responseHeadersPlace as h,responseSectionPlace as I,scopedPlace as d}from"../places.js";import{addRow as S,describe as t}from"./context.js";import{extractHeadingSections as k}from"./heading-sections.js";const C={matches:a=>!!a.responses?.length,extract(a,e){for(const o of a.responses??[])p(o)||(g(o,e),e.hasSchemas&&y(o,e))}};function g(a,e){a.description&&typeof a.description!="string"&&k(a.description,e);const o=[t(e,a.summary),t(e,a.description)].filter(Boolean).join(" ").trim();if(!o)return;const i=r("response",void 0,a.code),n=e.scope.callbackId?`${r(l,e.scope.callbackId)}/${i}`:i;S(e,f({name:a.code,description:o,place:d(I(a.code),e.scope.callbackId),type:"unknown",deepLink:e.slug?m(e.slug,n):void 0}))}function y(a,e){const o=d(u(a.code),e.scope.callbackId),i=a.mediaTypeContent?Object.entries(a.mediaTypeContent).filter(([,s])=>!p(s)&&s.schemaId).map(([s,c])=>[s,c.schemaId]):a.schemaId?[[a.mediaType,a.schemaId]]:[],n=i.length>1;for(const[s,c]of i)e.walker.extractSchemaFields({schemaId:c,place:o,paramsMap:e.paramsMap,slug:e.slug,mediaType:s,hasMultipleMediaTypes:n,isResponse:!0},e.scope);if(a.headerSchemaId){const[s]=i[0]??[];e.walker.extractSchemaFields({schemaId:a.headerSchemaId,place:d(h(a.code),e.scope.callbackId),paramsMap:e.paramsMap,slug:e.slug,mediaType:s,hasMultipleMediaTypes:n,isResponse:!0},e.scope)}}export{C as responsesExtractor};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { OperationParameter } from '@redocly/theme/core/openapi';
|
|
2
|
+
import type { SchemaEntry } from '../../../../types/store.js';
|
|
3
|
+
import type { ExtractContext } from './context.js';
|
|
4
|
+
type SchemaPageFields = {
|
|
5
|
+
parameters: OperationParameter[];
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function extractSchemaPageFields(schemaName: string, schemaStore: Record<string, SchemaEntry> | undefined, ctx: ExtractContext): SchemaPageFields;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{schemaKind as i}from"../../../../types/common.js";import{SCHEMA_FIELDS_PLACE as m}from"../places.js";import{describe as n}from"./context.js";function h(s,c,e){const a=`components/schemas/${s}`,r=c?.[a];if(!r||r.kind!==i.JSON_SCHEMA)return{parameters:[],description:""};const t={};e.walker.extractSchemaFields({schemaId:a,place:m,paramsMap:t,slug:e.slug},{pathOnly:!0});const o=e.walker.resolveEffectiveSchema(r.data);return{parameters:Object.values(t),description:n(e,o.description)}}export{h as extractSchemaPageFields};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SecurityNode } from '../../../../types/content.js';
|
|
2
|
+
import type { ExtractContext } from './context.js';
|
|
3
|
+
/** One row per security scheme the operation accepts: name plus the short type line and scopes. */
|
|
4
|
+
export declare function extractSecurityRows(node: SecurityNode, ctx: ExtractContext): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hasRbacScope as m}from"../../../../adapters/rbac.js";import{makeParam as t}from"../param.js";import{SECURITY_PLACE as i}from"../places.js";import{addRow as a}from"./context.js";function u(o,r){for(const n of o.requirements)for(const e of n.schemes)m(e)||a(r,t({name:e.name,description:[e.type,e.scheme,e.bearerFormat,e.in?`in ${e.in}`:"",e.paramName,e.scopes?.length?`scopes: ${e.scopes.join(", ")}`:""].filter(Boolean).join(" "),place:i,type:"unknown"}))}export{u as extractSecurityRows};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ApiItem, ExampleEntry, SchemaEntry } from '../../../types/store.js';
|
|
2
|
+
import type { SearchDocument } from '../types.js';
|
|
3
|
+
import type { DescriptionFormatter } from './context.js';
|
|
4
|
+
export type SearchIndexerOptions = {
|
|
5
|
+
formatDescription?: DescriptionFormatter;
|
|
6
|
+
/** Enables example rows (the example selector labels); without it they are skipped. */
|
|
7
|
+
exampleStore?: Record<string, ExampleEntry>;
|
|
8
|
+
};
|
|
9
|
+
export declare class ApiDocsSearchIndexer {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(basePath: string, schemaStore?: Record<string, SchemaEntry>, document?: Record<string, unknown>, options?: SearchIndexerOptions);
|
|
12
|
+
addItem(item: ApiItem, ancestors?: string[]): void;
|
|
13
|
+
getResult(): SearchDocument[];
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hasRbacScope as b,rbacProp as S,readRbacScope as u}from"../../../adapters/rbac.js";import{nodeTypes as c,contentType as h,itemVariant as g}from"../../../types/common.js";import{extractFullText as y}from"../../../adapters/utils/markdoc.js";import{toElementId as E}from"../../../utils/url.js";import{SchemaWalker as R}from"./schema-walker.js";import{extractText as A}from"./text.js";import{extractorsFor as I,extractCallback as P,extractChannelAddress as k,extractInfoMetadataRows as O,extractHeadingSections as D,extractMessageBindingFields as M,extractMcpFields as V,extractPanelRows as w,extractSecurityRows as C,extractServerFields as F,extractSchemaPageFields as N}from"./extractors/index.js";class G{#r=[];#t;#e;#a;#n;#o;#i;constructor(t,n,o,s={}){this.#t=t,this.#e=n,this.#a=o,this.#n=s.formatDescription??y,this.#o=s.exampleStore,this.#i=new R({schemaStore:n,document:o,formatDescription:this.#n})}addItem(t,n=[]){if(!(!t.link||!t.content))try{switch(t.content.contentType){case h.OVERVIEW:this.#s(t,this.#t,n);break;case h.GROUP:case h.ITEM:this.#s(t,t.link,n);break}}catch(o){console.error(`Cannot add item to api-docs search indexer [${t.label}, ${t.link}]:`,o.message)}}getResult(){return this.#r}#c(t,n){return{slug:t,scope:{},paramsMap:{},visited:new Set,walker:this.#i,formatDescription:this.#n,hasSchemas:!!this.#e&&!!this.#a,exampleStore:this.#o,isOverview:n}}#s(t,n,o=[]){if(!t.content)return;const s=E(n,this.#t)??"",r=t.content.children,a=this.#c(s,t.content.contentType===h.OVERVIEW);let e=A(r),i=this.#h(r,a);const d=t.content.meta?.name,f=t.content.itemVariant===g.SCHEMA&&typeof d=="string";if(f){const p=N(d,this.#e,a);i=[...i,...p.parameters],p.description&&(e=[e,p.description].filter(Boolean).join(" "))}const l=V(t,this.#a,a);l&&(i=[...i,...l.parameters],e=[e,l.text].filter(Boolean).join(" "));const m=t,x="httpPath"in t&&t.httpPath?t.httpPath:k(r),T={id:n,url:n,title:t.label??"",text:e,path:o,deprecated:t.content.meta?.deprecated,..."httpVerb"in t&&t.httpVerb?{httpMethod:t.httpVerb}:{},...x?{httpPath:x}:{},..."badges"in t&&Array.isArray(t.badges)&&t.badges.length?{badges:t.badges}:{},..."isAdditionalOperation"in t&&t.isAdditionalOperation?{isAdditionalOperation:!0}:{},...f?{isSchemaDefinition:!0}:{},...S(u(m)),...i.length&&{parameters:i}};this.#r.push(T)}#h(t,n){const o=(s,r)=>{for(const a of s)if(a.nodeType===c.ITEM){const e=a;if(b(e))continue;if(e.variant==="callback"&&e.callback){P(e.callback,r,o);continue}for(const i of I(e))i.extract(e,r)}else if(a.nodeType===c.MARKDOC)D(a.content,r);else if(a.nodeType===c.SECURITY)C(a,r);else if(a.nodeType===c.INFO_METADATA)O(a,r);else if(a.nodeType===c.CONTAINER){const e=a;if(b(e))continue;M(e,r),o(e.children,r),F(e,r),w(e,r)}else a.nodeType===c.OVERVIEW_SECTION_WRAPPER&&o(a.children,r)};return o(t,n),Object.values(n.paramsMap)}}export{G as ApiDocsSearchIndexer};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OperationParameter } from '@redocly/theme/core/openapi';
|
|
2
|
+
export declare function makeParam(fields: Partial<OperationParameter> & {
|
|
3
|
+
name: string | string[];
|
|
4
|
+
place: string;
|
|
5
|
+
}): OperationParameter;
|
|
6
|
+
export declare function truncateIndexedExample(example: string): string;
|
|
7
|
+
export declare function getParameterId(param: OperationParameter, callbackId?: string, messageKey?: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r=200;function i(e){return{description:"",mediaType:void 0,type:"",required:!1,example:void 0,enum:void 0,...e}}function E(e){return e.length>200?`${e.slice(0,200)}\u2026`:e}function d(e,n,t){return[...Array.isArray(e.path)?e.path:[],e.name.toString()].join(".")+e.description+e.place+(n??"")+(t??"")}export{d as getParameterId,i as makeParam,E as truncateIndexedExample};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AsyncMessageSubsection } from './context.js';
|
|
2
|
+
/**
|
|
3
|
+
* The `place` grammar — every label the indexer stamps on a row. A place is shown in the
|
|
4
|
+
* result row, keyed into the dedup id, and parsed back (`responseCodeOf`,
|
|
5
|
+
* `asyncSubsectionOf`, `isDescriptionPlace`), so every literal lives here.
|
|
6
|
+
*/
|
|
7
|
+
export declare const REQUEST_FIELDS_PLACE = "request fields";
|
|
8
|
+
export declare const REQUEST_BODY_PLACE = "request body";
|
|
9
|
+
export declare const SCHEMA_FIELDS_PLACE = "schema fields";
|
|
10
|
+
export declare const DESCRIPTION_PLACE = "description";
|
|
11
|
+
export declare const CALLBACK_PLACE = "callback";
|
|
12
|
+
export declare const MESSAGE_PLACE = "message";
|
|
13
|
+
export declare const MESSAGE_PAYLOAD_PLACE = "message payload";
|
|
14
|
+
export declare const MESSAGE_HEADERS_PLACE = "message headers";
|
|
15
|
+
export declare const MESSAGE_BINDINGS_PLACE = "message bindings";
|
|
16
|
+
export declare const SERVER_PLACE = "server";
|
|
17
|
+
export declare const SERVER_VARIABLES_PLACE = "server variables";
|
|
18
|
+
export declare const OVERVIEW_PLACE = "overview";
|
|
19
|
+
export declare const METADATA_PLACE = "metadata";
|
|
20
|
+
export declare const SECURITY_PLACE = "security";
|
|
21
|
+
export declare const REQUEST_EXAMPLES_PLACE = "request examples";
|
|
22
|
+
export declare const MESSAGE_EXAMPLES_PLACE = "message examples";
|
|
23
|
+
export declare const GRAPHQL_ARGUMENTS_PLACE = "arguments";
|
|
24
|
+
export declare const MCP_INPUT_SCHEMA_PLACE = "input schema";
|
|
25
|
+
export declare const MCP_OUTPUT_SCHEMA_PLACE = "output schema";
|
|
26
|
+
export declare const MCP_PROMPT_ARGUMENTS_PLACE = "arguments";
|
|
27
|
+
/** Place of a top-level parameter, by its content-node variant. */
|
|
28
|
+
export declare function parameterPlaceOf(variant: string | undefined): string;
|
|
29
|
+
/** Place of schema/graphql field rows, by their content-node variant. */
|
|
30
|
+
export declare function fieldsPlaceOf(variant: string | undefined): string;
|
|
31
|
+
export declare function responseSectionPlace(code: string): string;
|
|
32
|
+
export declare function responseFieldsPlace(code: string): string;
|
|
33
|
+
export declare function responseHeadersPlace(code: string): string;
|
|
34
|
+
export declare function responseExamplesPlace(code: string): string;
|
|
35
|
+
/** Prefixes places produced inside a callback so search entries read as the callback's. */
|
|
36
|
+
export declare function scopedPlace(place: string, callbackId?: string): string;
|
|
37
|
+
export declare function responseCodeOf(place: string): string | undefined;
|
|
38
|
+
export declare function asyncSubsectionOf(place: string): AsyncMessageSubsection | undefined;
|
|
39
|
+
/** Markdown-heading rows: `description`, or `callback description` inside a callback. */
|
|
40
|
+
export declare function isDescriptionPlace(place: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s="request fields",E="request body",u="schema fields",t="description",n="callback",i="message",o="message payload",a="message headers",c="message bindings",A="server",P="server variables",d="overview",l="metadata",_="security",x="request examples",S="message examples",p="arguments",C="input schema",m="output schema",L="arguments";function f(e){switch(e){case"query":return"query parameters";case"path":return"path parameters";case"headers":return"header parameters";case"cookies":return"cookie parameters";case"parameters":return"channel parameters";default:return e?`${e} parameters`:"parameters"}}function h(e){switch(e){case"body":return s;case"responses":return"response fields";case"graphql-fields":return"fields";case"graphql-args":return p;case"return-type":return"return type fields";case"possible-types":return"possible types";case"implemented-by":return"implemented by";default:return e??"fields"}}function M(e){return`response ${e}`}function R(e){return`response ${e} fields`}function y(e){return`response ${e} headers`}function T(e){return`response ${e} examples`}function g(e,r){return r?`${n} ${e}`:e}function b(e){const r=e.match(/(?:^|\s)response (\S+) /);return r?r[1]:void 0}function I(e){switch(e){case o:return"payload";case a:return"headers";case c:return"bindings";default:return}}function O(e){return e.endsWith(t)}export{n as CALLBACK_PLACE,t as DESCRIPTION_PLACE,p as GRAPHQL_ARGUMENTS_PLACE,C as MCP_INPUT_SCHEMA_PLACE,m as MCP_OUTPUT_SCHEMA_PLACE,L as MCP_PROMPT_ARGUMENTS_PLACE,c as MESSAGE_BINDINGS_PLACE,S as MESSAGE_EXAMPLES_PLACE,a as MESSAGE_HEADERS_PLACE,o as MESSAGE_PAYLOAD_PLACE,i as MESSAGE_PLACE,l as METADATA_PLACE,d as OVERVIEW_PLACE,E as REQUEST_BODY_PLACE,x as REQUEST_EXAMPLES_PLACE,s as REQUEST_FIELDS_PLACE,u as SCHEMA_FIELDS_PLACE,_ as SECURITY_PLACE,A as SERVER_PLACE,P as SERVER_VARIABLES_PLACE,I as asyncSubsectionOf,h as fieldsPlaceOf,O as isDescriptionPlace,f as parameterPlaceOf,b as responseCodeOf,T as responseExamplesPlace,R as responseFieldsPlace,y as responseHeadersPlace,M as responseSectionPlace,g as scopedPlace};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { OperationParameter } from '@redocly/theme/core/openapi';
|
|
2
|
+
import type { SchemaEntry } from '../../../types/store.js';
|
|
3
|
+
import type { SchemaNode } from '../../../types/schema.js';
|
|
4
|
+
import type { DescriptionFormatter, WalkScope } from './context.js';
|
|
5
|
+
export type SchemaFieldsArgs = {
|
|
6
|
+
schemaId: string;
|
|
7
|
+
place: string;
|
|
8
|
+
paramsMap: Record<string, OperationParameter>;
|
|
9
|
+
slug: string;
|
|
10
|
+
mediaType?: string;
|
|
11
|
+
hasMultipleMediaTypes?: boolean;
|
|
12
|
+
isResponse?: boolean;
|
|
13
|
+
linkType?: string;
|
|
14
|
+
visited?: Set<string>;
|
|
15
|
+
};
|
|
16
|
+
/** Walks raw JSON schemas from the schema store into flat `OperationParameter` rows. */
|
|
17
|
+
export declare class SchemaWalker {
|
|
18
|
+
#private;
|
|
19
|
+
constructor(deps: {
|
|
20
|
+
schemaStore?: Record<string, SchemaEntry>;
|
|
21
|
+
document?: Record<string, unknown>;
|
|
22
|
+
formatDescription: DescriptionFormatter;
|
|
23
|
+
});
|
|
24
|
+
extractSchemaFields({ schemaId, ...args }: SchemaFieldsArgs, scope?: WalkScope): void;
|
|
25
|
+
/** Walks a schema that is not in the store (MCP input/output schemas, prompt arguments). */
|
|
26
|
+
extractSchemaNodeFields(schema: SchemaNode, { place, paramsMap, slug, mediaType, hasMultipleMediaTypes, isResponse, linkType, visited, }: Omit<SchemaFieldsArgs, 'schemaId'>, scope?: WalkScope): void;
|
|
27
|
+
resolveParameterType(schemaId: string): string;
|
|
28
|
+
resolveEffectiveSchema(schema: SchemaNode): SchemaNode;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hasRbacScope as h}from"../../../adapters/rbac.js";import{schemaKind as m}from"../../../types/common.js";import{appendArraySuffix as L,appendVariantSuffix as k}from"../../../utils/deep-link.js";import{buildAsyncMessageDeepLink as D,buildFieldDeepLink as E}from"./deep-links.js";import{getParameterId as M,truncateIndexedExample as N}from"./param.js";import{asyncSubsectionOf as q,responseCodeOf as C}from"./places.js";const v=10;class H{#t;#i;#n;constructor(e){this.#t=e.schemaStore,this.#i=e.document,this.#n=e.formatDescription}extractSchemaFields({schemaId:e,...n},t={}){const i=this.#t?.[e];!i||i.kind!==m.JSON_SCHEMA||h(i)||this.extractSchemaNodeFields(i.data,n,t)}extractSchemaNodeFields(e,{place:n,paramsMap:t,slug:i,mediaType:r,hasMultipleMediaTypes:s=!1,isResponse:o=!1,linkType:p,visited:a=new Set},l={}){this.#s(e,{path:[],linkPath:[],depth:0},{place:n,mediaType:r,deepLinkContentType:s?r:void 0,isResponse:o,linkType:p,paramsMap:t,visited:a,slug:i,scope:l})}resolveParameterType(e){const n=this.#t?.[e];if(!n||n.kind!==m.JSON_SCHEMA)return"unknown";const t=n.data,i=this.resolveEffectiveSchema(t);return this.#r(i)}resolveEffectiveSchema(e){if(e.allOf){const n=this.#o(e.allOf);return e.description&&(n.description=e.description),n}if(e.$ref){const n=this.#e(e.$ref);if(n){const t={...n};return e.description&&(t.description=e.description),t}}return e}#r(e){return Array.isArray(e.type)?e.type.join(" | "):e.type?e.type:e.properties||e.additionalProperties?"object":e.items?"array":e.enum?"string":"any"}#e(e){if(!e.startsWith("#/"))return;const n=e.slice(2).split("/");let t=this.#i;for(const i of n){if(t==null||typeof t!="object")return;t=t[i]}return t!=null&&typeof t=="object"?t:void 0}#s(e,n,t){if(n.depth>v||h(e))return;const i=(o,p)=>this.#s(o,p,t);if(e.$ref){this.#p(e.$ref,i,n,t.visited);return}if(e.allOf){i(this.#o(e.allOf,t.visited),n);return}const r=e.discriminator??e["x-discriminator"];if(r?.propertyName&&!n.inDiscriminatorVariant){this.#P(e,r,i,n);return}const s=e.oneOf??e.anyOf;if(s){this.#f(e,s,i,n,t.visited);return}if(e.if&&(e.then||e.else)){this.#d(e,i,n);return}e.properties&&this.#a(e,i,n,t),this.#k(e,i,n,t.visited)}#p(e,n,t,i){if(i.has(e))return;i.add(e);const r=this.#e(e);r&&n(r,t)}#o(e,n){const t={};for(const i of e){let r=i;if(i.$ref){if(n){if(n.has(i.$ref))continue;n.add(i.$ref)}r=this.#e(i.$ref)}if(!r)continue;const s=t.properties,o=t.required;Object.assign(t,r),(s||r.properties)&&(t.properties={...s||{},...r.properties||{}}),(o||r.required)&&(t.required=[...o||[],...r.required||[]])}return delete t.allOf,t}#f(e,n,t,i,r){e.properties&&t({...e,oneOf:void 0,anyOf:void 0},{...i,linkPath:k(i.linkPath,"&oneof=0")}),n.forEach((s,o)=>{if(s.$ref){if(r.has(s.$ref))return;r.add(s.$ref)}const p=s.$ref?this.#e(s.$ref):s;p&&t(p,{...i,linkPath:k(i.linkPath,`&oneof=${o}`),depth:i.depth+1})})}#d(e,n,t){const{if:i,then:r,else:s,...o}=e;[{allOf:[o,r??{},i??{}]},{allOf:[o,s??{}]}].forEach((a,l)=>{n(a,{...t,linkPath:k(t.linkPath,`&oneof=${l}`),depth:t.depth+1})})}#a(e,n,t,i){const{isResponse:r,paramsMap:s,visited:o,scope:p}=i,a=e.required||[],l=C(i.place),f=i.linkType??(r?"response":"request"),y=q(i.place);for(const[c,u]of Object.entries(e.properties??{})){if(h(u))continue;const d=this.#l(u,o);if(!d)continue;const P=this.#u(d,o),O=this.resolveEffectiveSchema(d);if(!this.#c(d,O,r,p.pathOnly))continue;const A=d.additionalProperties!==void 0&&!d.properties,$=c===t.discriminatorPropertyName,w=[...t.path,c],S=this.#h(c,$,t),g=this.#y(c,d,O,S,{requiredList:a,responseCode:l,type:f,asyncSubsection:y,frame:t,ctx:i}),b=M(g,p.callbackId,p.messageKey);s[b]==null&&(s[b]=g,!P&&!$&&!A&&n(O,{path:w,linkPath:S,depth:t.depth+1}))}}#l(e,n){if(!e.$ref)return e;if(!n.has(e.$ref))return n.add(e.$ref),this.#e(e.$ref)}#u(e,n){if(!e.allOf)return!1;let t=!1;for(const i of e.allOf)i.$ref?n.has(i.$ref)||(n.add(i.$ref),t=!0):t=!0;return!t}#c(e,n,t,i){if(h(e)||h(n))return!1;const r=!i;return!(r&&n.readOnly&&!t||r&&n.writeOnly&&t)}#h(e,n,t){return[...n&&t.discriminatorLinkPath?t.discriminatorLinkPath:t.linkPath,e]}#y(e,n,t,i,r){const{requiredList:s,responseCode:o,type:p,asyncSubsection:a,frame:l,ctx:f}=r,y=n.description??t.description,c=y?this.#n(y):"",u=n.example??t.example,d=u!==void 0?N(typeof u=="string"?u:JSON.stringify(u)):void 0,P=Array.isArray(t.enum)&&t.enum.length?t.enum:void 0;return{name:e,description:c,place:f.place,mediaType:f.mediaType,path:l.path,type:this.#r(t),required:s.includes(e),deepLink:a?D(f.slug,f.scope.messageKey,a,i):E({slug:f.slug,type:p,contentType:f.deepLinkContentType,responseCode:o,fieldPath:i,scope:f.scope}),example:d,enum:P}}#k(e,n,t,i){if(!e.items||typeof e.items!="object"||Array.isArray(e.items))return;if(e.items.$ref){if(i.has(e.items.$ref))return;i.add(e.items.$ref)}const r=e.items.$ref?this.#e(e.items.$ref):e.items;r&&n(r,{...t,linkPath:L(t.linkPath),depth:t.depth+1})}#P(e,n,t,i){const r=this.#O(e,n),s=o=>({...i,linkPath:k(i.linkPath,`&d=${o}`),inDiscriminatorVariant:!0,discriminatorPropertyName:n.propertyName,discriminatorLinkPath:i.linkPath});e.properties&&t({...e,discriminator:void 0,"x-discriminator":void 0,oneOf:void 0,anyOf:void 0},r.length?s(0):i),r.forEach((o,p)=>{t(o,{...s(p),depth:i.depth+1})})}#O(e,n){const t=e.oneOf??e.anyOf??[],i=Object.values(n.mapping??{});if(i.length===0)return t;const r=o=>t.find(p=>p.$ref===o||p["x-original-ref"]===o)??this.#e(o)??{},s=i.filter(o=>o!==n.defaultMapping).map(r);return n.defaultMapping&&s.push(r(n.defaultMapping)),s}}export{H as SchemaWalker};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{nodeTypes as s}from"../../../types/common.js";import{extractFullText as f}from"../../../adapters/utils/markdoc.js";function p(n){const r=[],o=i=>{for(const e of i)if(e.nodeType===s.MARKDOC){const t=e;if(l(t.content))continue;const c=f(t.content);c&&r.push(c)}else(e.nodeType===s.CONTAINER||e.nodeType===s.OVERVIEW_SECTION_WRAPPER)&&o(e.children)};return o(n),r.join(" ").trim()}function l(n){let r=!1,o=!1;const i=t=>{t.type==="code"&&t.attributes?.content?r=!0:t.type==="text"&&t.attributes?.content&&(o=!0);for(const c of t.children??[])i(c)},e=Array.isArray(n)?n:[n];for(const t of e)i(t);return r&&!o}export{p as extractText};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { OperationParameter, ParameterHighlight } from '@redocly/theme/core/openapi';
|
|
2
|
+
import type { ItemBadge } from '@redocly/config';
|
|
3
|
+
import type { REDOCLY_TEAMS_RBAC } from '@redocly/config';
|
|
4
|
+
export type SearchDocument = {
|
|
5
|
+
[REDOCLY_TEAMS_RBAC]?: Record<string, string>;
|
|
6
|
+
id: string;
|
|
7
|
+
url: string;
|
|
8
|
+
title: string | string[];
|
|
9
|
+
text: string | string[];
|
|
10
|
+
path?: string[];
|
|
11
|
+
httpMethod?: string;
|
|
12
|
+
httpPath?: string | string[];
|
|
13
|
+
isAdditionalOperation?: boolean;
|
|
14
|
+
isSchemaDefinition?: boolean;
|
|
15
|
+
deprecated?: boolean;
|
|
16
|
+
security?: string[];
|
|
17
|
+
parameters?: OperationParameter[];
|
|
18
|
+
badges?: ItemBadge[];
|
|
19
|
+
};
|
|
20
|
+
export type SearchItemData = {
|
|
21
|
+
document: SearchDocument;
|
|
22
|
+
highlight: Record<string, string> & {
|
|
23
|
+
parameters?: ParameterHighlight[];
|
|
24
|
+
path?: string[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type { OperationParameter, ParameterHighlight } from '@redocly/theme/core/openapi';
|
|
28
|
+
export type { ItemBadge } from '@redocly/config';
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SliceContentKind, SpecSliceScope } from './types.js';
|
|
2
|
+
export declare const ASSISTANT_LINK_BASES: {
|
|
3
|
+
readonly chatgpt: 'https://chatgpt.com';
|
|
4
|
+
readonly claude: 'https://claude.ai/new';
|
|
5
|
+
};
|
|
6
|
+
export declare const MAX_ASSISTANT_URL_LENGTH = 8000;
|
|
7
|
+
export declare function buildInlinePromptLink(baseUrl: string, content: string, contentKind?: SliceContentKind): string | undefined;
|
|
8
|
+
export declare function describeSliceScope(scope: SpecSliceScope): string | undefined;
|
|
9
|
+
export declare function buildFetchSpecPromptLink(baseUrl: string, specUrl: string, scope: SpecSliceScope): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const c={chatgpt:"https://chatgpt.com",claude:"https://claude.ai/new"},i=8e3,s={yaml:`Read the yaml and answer questions based on the content.
|
|
2
|
+
|
|
3
|
+
`,graphql:`Read the GraphQL SDL and answer questions based on the content.
|
|
4
|
+
|
|
5
|
+
`};function u(e,a,r="yaml"){const t=new URL(e);t.searchParams.set("q",`${s[r]}${a}`);const n=t.toString();return n.length<=i?n:void 0}function h(e){switch(e.kind){case"operation":return`the ${e.httpVerb.toUpperCase()} ${e.pathName} operation`;case"tag":return`the "${e.tagName}" operations`;case"schema":return`the ${e.name} schema`;case"channel":return`the "${e.channelId}" channel`;case"async-operation":return`the "${e.operationId}" operation`;case"graphql-operation":return`the ${e.name} ${e.operationType}`;case"graphql-type":return`the ${e.name} type`;case"graphql-directive":return`the @${e.name} directive`;case"graphql-group":return e.label?`the "${e.label}" section`:void 0;default:return}}function d(e,a,r){const t=h(r),n=t?`answer questions about ${t}`:"answer questions based on the content",o=new URL(e);return o.searchParams.set("q",`Read ${a} and ${n}.`),o.toString()}export{c as ASSISTANT_LINK_BASES,i as MAX_ASSISTANT_URL_LENGTH,d as buildFetchSpecPromptLink,u as buildInlinePromptLink,h as describeSliceScope};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SpecSliceScope } from './types.js';
|
|
2
|
+
export declare function scopeFromAsyncApiPointer(pointer: string): SpecSliceScope | undefined;
|
|
3
|
+
export declare function extractAsyncApiSlice(document: Record<string, unknown>, scope: SpecSliceScope): {
|
|
4
|
+
document: Record<string, unknown>;
|
|
5
|
+
} | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isRecord as i,resolveJsonPointer as O}from"../../adapters/helpers.js";import{collectComponentClosure as C,buildComponentsFromClosure as b}from"./component-closure.js";import{cloneStrip as I}from"./clone-strip.js";import{parsePointerTokens as h}from"./openapi-slice.js";function A(n){return typeof n.asyncapi=="string"&&n.asyncapi.startsWith("3.")}const v=["asyncapi","id","info","defaultContentType","servers"];function x(n){const e=h(n);if(!(e.length<2)){if(e[0]==="channels")return{kind:"channel",channelId:e[1]};if(e[0]==="operations")return{kind:"async-operation",operationId:e[1]}}}function F(n,e){if(!A(n))return;if(e.kind==="document")return{document:I(n,new Map)};const t=S(n,e);if(!t)return;const{keptChannels:p,keptOperations:f}=t,s={};for(const o of v)n[o]!==void 0&&(s[o]=n[o]);const u=i(n.channels)?n.channels:{},a=i(n.operations)?n.operations:{},r={};for(const[o,d]of Object.entries(u))p.has(o)&&(r[o]=d);const c={};for(const[o,d]of Object.entries(a))f.has(o)&&(c[o]=d);s.channels=r,Object.keys(c).length&&(s.operations=c);const l=C(n,[s],o=>{if(o.startsWith("#/servers/"))return n.servers!==void 0;const d=h(o);return d[0]==="channels"?p.has(d[1]):d[0]==="operations"?f.has(d[1]):!1}),y=b(n,l.keep);return y&&(s.components=y),{document:I(s,l.inlineTargets)}}function g(n){if(!i(n)||!i(n.channel))return;const e=n.channel.$ref;if(typeof e!="string")return;const t=h(e);return t[0]==="channels"&&t.length>=2?t[1]:void 0}function R(n,e){return!i(n)||!Array.isArray(n.tags)?!1:n.tags.some(t=>i(t)&&t.name===e)}function S(n,e){const t=i(n.channels)?n.channels:{},p=i(n.operations)?n.operations:{},f=new Set,s=new Set,u=a=>{for(const[r,c]of Object.entries(p))g(c)===a&&s.add(r)};switch(e.kind){case"channel":{if(!(e.channelId in t))return;f.add(e.channelId),u(e.channelId);break}case"async-operation":{const a=p[e.operationId];if(!i(a))return;s.add(e.operationId);const r=g(a);r&&r in t&&f.add(r);break}case"tag":{for(const[a,r]of Object.entries(t))R(r,e.tagName)&&(f.add(a),u(a));if(f.size===0)return;break}default:return}for(const a of s){const r=p[a];if(!i(r))continue;const c=T(n,r.reply),k=i(c?.channel)?c.channel.$ref:void 0;if(typeof k!="string")continue;const l=h(k);l[0]==="channels"&&l[1]&&l[1]in t&&f.add(l[1])}return{keptChannels:f,keptOperations:s}}function T(n,e){if(i(e)){if(typeof e.$ref=="string"&&e.$ref.startsWith("#/")){const t=O(n,e.$ref);return i(t)?t:void 0}return e}}export{F as extractAsyncApiSlice,x as scopeFromAsyncApiPointer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cloneStrip(value: unknown, inlineTargets: ReadonlyMap<string, unknown>): unknown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as E,REDOCLY_ROUTE_RBAC as S}from"@redocly/config";import{isRecord as l}from"../../adapters/helpers.js";const h=new Set([E,S,"x-circular-ref","x-original-ref"]);function w(p,a){const r=new WeakSet,s=new Set,c=e=>{if(Array.isArray(e)){if(r.has(e))throw new Error("spec-slice: circular object graph in the source document");r.add(e);const t=e.map(c);return r.delete(e),t}if(!l(e))return e;if(r.has(e))throw new Error("spec-slice: circular object graph in the source document");const i=typeof e.$ref=="string"?e.$ref:void 0;if(i&&a.has(i)){if(s.has(i))return{};s.add(i),r.add(e);const t=c(a.get(i));s.delete(i);const n={};for(const[f,u]of Object.entries(e))f==="$ref"||h.has(f)||u===void 0||(n[f]=c(u));return r.delete(e),l(t)?{...t,...n}:t}r.add(e);const o={};for(const[t,n]of Object.entries(e))h.has(t)||n===void 0||(o[t]=c(n));return r.delete(e),o};return c(p)}export{w as cloneStrip};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type ComponentClosure = {
|
|
2
|
+
keep: Map<string, Set<string>>;
|
|
3
|
+
inlineTargets: Map<string, unknown>;
|
|
4
|
+
};
|
|
5
|
+
export declare function collectComponentClosure(document: Record<string, unknown>, seeds: unknown[], retainRef?: (ref: string) => boolean): ComponentClosure;
|
|
6
|
+
export declare function buildComponentsFromClosure(document: Record<string, unknown>, keep: Map<string, Set<string>>): Record<string, unknown> | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isRecord as r,resolveJsonPointer as N}from"../../adapters/helpers.js";import{encodeJsonPointerSegment as b}from"../../utils/refPointer.js";const O="#/components/";function $(a){return a.replace(/~1/g,"/").replace(/~0/g,"~")}function w(a,d,g){const u=new Map,p=new Map,f=[...d],h=new WeakSet;let c;const y=()=>{if(c)return c;c=new Map;const e=r(a.components)?a.components.schemas:void 0;if(r(e)){const n=`${O}schemas/`;for(const[o,t]of Object.entries(e))if(!(!r(t)||!Array.isArray(t.allOf)))for(const s of t.allOf){if(!r(s)||typeof s.$ref!="string"||!s.$ref.startsWith(n))continue;const i=$(s.$ref.slice(n.length)),m=e[i];if(!r(m)||!(m.discriminator||m["x-discriminator"]))continue;const k=c.get(i)??[];k.push(o),c.set(i,k)}}return c},l=(e,n)=>{const o=$(n);let t=u.get(e);if(t||(t=new Set,u.set(e,t)),t.has(o))return;const s=`${O}${e}/${n}`,i=N(a,s);if(i&&(t.add(o),f.push(i),e==="schemas"&&(i.discriminator||i["x-discriminator"])))for(const m of y().get(o)??[])l("schemas",b(m))},j=e=>{if(e.startsWith(O)){const[n,o]=e.slice(O.length).split("/");if(n&&o){l(n,o);return}}if(!g?.(e)&&e.startsWith("#/")){if(p.has(e))return;const n=N(a,e);if(!n)return;p.set(e,n),f.push(n);return}};for(;f.length;){const e=f.pop();if(Array.isArray(e)){f.push(...e);continue}if(!r(e)||h.has(e))continue;h.add(e);for(const[t,s]of Object.entries(e)){if(t==="$ref"&&typeof s=="string"){j(s);continue}if(t==="security"&&Array.isArray(s)){for(const i of s)if(r(i))for(const m of Object.keys(i))l("securitySchemes",b(m))}f.push(s)}const n=e.discriminator??e["x-discriminator"],o=r(n)?n.mapping:void 0;if(r(o))for(const t of Object.values(o))typeof t=="string"&&(t.startsWith("#/")?j(t):l("schemas",b(t)))}return{keep:u,inlineTargets:p}}function x(a,d){const g=a.components;if(!r(g)||d.size===0)return;const u={};for(const[p,f]of Object.entries(g)){const h=d.get(p);if(!h?.size||!r(f))continue;const c={};for(const[y,l]of Object.entries(f))h.has(y)&&(c[y]=l);Object.keys(c).length&&(u[p]=c)}return Object.keys(u).length?u:void 0}export{x as buildComponentsFromClosure,w as collectComponentClosure};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Kind as t,OperationTypeNode as O,parse as g,print as F,visit as Y}from"graphql";const C=new Set([t.SCALAR_TYPE_DEFINITION,t.OBJECT_TYPE_DEFINITION,t.INTERFACE_TYPE_DEFINITION,t.UNION_TYPE_DEFINITION,t.ENUM_TYPE_DEFINITION,t.INPUT_OBJECT_TYPE_DEFINITION]),A=new Set([t.SCALAR_TYPE_EXTENSION,t.OBJECT_TYPE_EXTENSION,t.INTERFACE_TYPE_EXTENSION,t.UNION_TYPE_EXTENSION,t.ENUM_TYPE_EXTENSION,t.INPUT_OBJECT_TYPE_EXTENSION]);function S(o){return C.has(o.kind)}function v(o){return A.has(o.kind)}const P={query:O.QUERY,mutation:O.MUTATION,subscription:O.SUBSCRIPTION},M=["query","mutation","subscription"],k={query:"Query",mutation:"Mutation",subscription:"Subscription"};function R(o){const i={typeDefs:new Map,typeExts:new Map,directiveDefs:new Map,schemaExts:[]};for(const n of o.definitions)if(S(n))i.typeDefs.set(n.name.value,n);else if(v(n)){const r=n.name.value,s=i.typeExts.get(r)??[];s.push(n),i.typeExts.set(r,s)}else n.kind===t.DIRECTIVE_DEFINITION?i.directiveDefs.set(n.name.value,n):n.kind===t.SCHEMA_DEFINITION?i.schemaDef=n:n.kind===t.SCHEMA_EXTENSION&&i.schemaExts.push(n);return i}function x(o){const i={typeNames:[],directiveNames:[],operationFields:new Map},n=r=>{if(r.kind==="graphql-type")i.typeNames.push(r.name);else if(r.kind==="graphql-directive")i.directiveNames.push(r.name);else{const s=i.operationFields.get(r.operationType)??[];s.push(r.name),i.operationFields.set(r.operationType,s)}};if(o.kind==="graphql-type"||o.kind==="graphql-directive"||o.kind==="graphql-operation")return n(o),i;if(o.kind==="graphql-group")return o.members.forEach(n),i}function w(o,i){const n=P[i];for(const r of[o.schemaDef,...o.schemaExts])for(const s of r?.operationTypes??[])if(s.operation===n)return s.type.name.value;return k[i]}function q(o,i,n){const r=[],s=new Set,c=[i,...o.typeExts.get(i.name.value)??[]];for(const d of c)if(!(d.kind!==t.OBJECT_TYPE_DEFINITION&&d.kind!==t.OBJECT_TYPE_EXTENSION))for(const T of d.fields??[]){const a=T.name.value;n.has(a)&&!s.has(a)&&(s.add(a),r.push(T))}return r}function B(o,i){const n=x(i);if(!n)return;let r;try{r=g(o,{noLocation:!0})}catch{return}const s=R(r),c=new Map,d=[];let T=!1;for(const e of M){const f=n.operationFields.get(e);if(!f?.length)continue;const E=w(s,e),I=s.typeDefs.get(E);if(I?.kind!==t.OBJECT_TYPE_DEFINITION)continue;const _=q(s,I,new Set(f));if(!_.length)continue;const y=c.get(E);c.set(E,{kind:t.OBJECT_TYPE_DEFINITION,name:I.name,description:I.description,directives:I.directives,fields:y?[...y.fields??[],..._]:_}),d.push({kind:t.OPERATION_TYPE_DEFINITION,operation:P[e],type:{kind:t.NAMED_TYPE,name:{kind:t.NAME,value:E}}}),E!==k[e]&&(T=!0)}const a=d.length&&(s.schemaDef||T)?{kind:t.SCHEMA_DEFINITION,description:s.schemaDef?.description,directives:s.schemaDef?.directives,operationTypes:d}:void 0,p=new Set,l=new Set,N=[],h=e=>{if(p.has(e))return;const f=s.typeDefs.get(e);if(!f)return;p.add(e);const E=c.get(e);if(E){N.push(E);return}N.push(f,...s.typeExts.get(e)??[])},D=e=>{if(l.has(e))return;const f=s.directiveDefs.get(e);f&&(l.add(e),N.push(f))};a&&N.push(a);for(const e of c.keys())h(e);for(const e of n.typeNames)h(e);for(const e of n.directiveNames)D(e);if(p.size===0&&l.size===0)return;for(;N.length;){const e=N.pop();e&&Y(e,{NamedType(f){h(f.name.value)},Directive(f){D(f.name.value)}})}const u=[];let m=!1;for(const e of r.definitions)if(e.kind===t.SCHEMA_DEFINITION)a&&(u.push(a),m=!0);else if(S(e)){const f=e.name.value;p.has(f)&&u.push(c.get(f)??e)}else if(v(e)){const f=e.name.value;p.has(f)&&!c.has(f)&&u.push(e)}else e.kind===t.DIRECTIVE_DEFINITION&&l.has(e.name.value)&&u.push(e);if(a&&!m&&u.unshift(a),u.length!==0)return F({kind:t.DOCUMENT,definitions:u})}export{B as extractGraphqlSlice};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ApiSpecType } from '../../types/common.js';
|
|
2
|
+
import type { SpecSliceScope } from './types.js';
|
|
3
|
+
export { resolveSpecSliceScope } from './resolve-scope.js';
|
|
4
|
+
export { ASSISTANT_LINK_BASES, buildInlinePromptLink, buildFetchSpecPromptLink, } from './assistant-links.js';
|
|
5
|
+
export type { SliceContentKind, SpecSliceScope } from './types.js';
|
|
6
|
+
export declare function buildSpecSlice(specType: ApiSpecType, document: unknown, scope: SpecSliceScope): Promise<string | undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dump as n}from"js-yaml";import{isRecord as f}from"../../adapters/helpers.js";import{apiSpecType as t}from"../../types/common.js";import{extractOpenApiSlice as c}from"./openapi-slice.js";import{extractAsyncApiSlice as p}from"./asyncapi-slice.js";import{resolveSpecSliceScope as x}from"./resolve-scope.js";import{ASSISTANT_LINK_BASES as h,buildInlinePromptLink as I,buildFetchSpecPromptLink as y}from"./assistant-links.js";async function s(o,e,i){switch(o){case t.GRAPHQL:{if(typeof e!="string")return;if(i.kind==="document")return e;const{extractGraphqlSlice:r}=await import("./graphql-slice.js");return r(e,i)}case t.OPENAPI:{if(f(e)){const r=c(e,i);if(r)return n(r.document,{noRefs:!0,lineWidth:-1})}return}case t.ASYNCAPI:{if(f(e)){const r=p(e,i);if(r)return n(r.document,{noRefs:!0,lineWidth:-1})}return}default:return}}export{h as ASSISTANT_LINK_BASES,y as buildFetchSpecPromptLink,I as buildInlinePromptLink,s as buildSpecSlice,x as resolveSpecSliceScope};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SpecSliceScope } from './types.js';
|
|
2
|
+
export declare function parsePointerTokens(pointer: string): string[];
|
|
3
|
+
export declare function operationScopeFromPointer(pointer: string, isWebhook: boolean | undefined): SpecSliceScope | undefined;
|
|
4
|
+
export declare function extractOpenApiSlice(document: Record<string, unknown>, scope: SpecSliceScope): {
|
|
5
|
+
document: Record<string, unknown>;
|
|
6
|
+
} | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isRecord as f}from"../../adapters/helpers.js";import{resolvePathItemRef as A}from"../../adapters/openapi/utils/resolvePathItemRef.js";import{JsonPointer as O}from"../../adapters/openapi/utils/JsonPointer.js";import{isOperationName as v}from"../../utils/http-methods.js";import{encodeJsonPointerSegment as w}from"../../utils/refPointer.js";import{DEFAULT_WEBHOOKS_TAG_NAME as x}from"../../constants/openapi.js";import{collectComponentClosure as S,buildComponentsFromClosure as T}from"./component-closure.js";import{cloneStrip as g}from"./clone-strip.js";const N=["openapi","info","jsonSchemaDialect","externalDocs","servers","security"];function I(e){const n=e.startsWith("/")||e.startsWith("#")?e:`/${e}`;try{return O.parse(n)}catch{return[]}}function L(e,n){const r=I(e);if(!(r.length<3||r[0]!=="paths"))return{kind:"operation",pathName:r[1],httpVerb:r[2],source:n?"webhooks":"paths"}}function W(e,n){if(typeof e.openapi!="string")return;if(n.kind==="document")return{document:g(e,new Map)};const r=M(e,n);if(!r)return;const{draft:s,extraSeeds:o=[]}=r,i=S(e,[s,...o]),t=T(e,i.keep);return t&&(s.components=t),{document:g(s,i.inlineTargets)}}function M(e,n){const r={};for(const p of N)e[p]!==void 0&&(r[p]=e[p]);if(n.kind==="schema"){const p=f(e.components)?e.components.schemas:void 0;if(!f(p)||!(n.name in p))return;r.paths={};const d={$ref:`#/components/schemas/${w(n.name)}`};return{draft:r,extraSeeds:[d]}}const s=e["x-webhooks"]?"x-webhooks":"webhooks",o=e["x-webhooks"]??e.webhooks;let i,t;if(n.kind==="operation"){i=new Map,t=new Map;const p=n.source==="webhooks"?o:e.paths,d=P(e,p,n.pathName,n.httpVerb);if(!d)return;(n.source==="webhooks"?t:i).set(n.pathName,d)}else if(n.kind==="tag"){if(i=k(e,e.paths,n.tagName,!1),t=k(e,o,n.tagName,!0),i.size===0&&t.size===0)return}else return;const a=new Set;for(const p of[...i.values(),...t.values()])for(const{operation:d}of p.operations){const l=d.tags;if(Array.isArray(l))for(const h of l)typeof h=="string"&&a.add(h)}const c=K(e,a);c.length&&(r.tags=c);const u=_(e,a);return u.length&&(r["x-tagGroups"]=u),r.paths=b(i),t.size&&(r[s]=b(t)),{draft:r}}function m(e,n){if(f(n))try{const r=A(e,n,e.openapi);return f(r)?r:void 0}catch{return}}function P(e,n,r,s){if(!f(n))return;const o=m(e,n[r]);if(!o)return;const i=o[s];if(f(i))return{pathItem:o,operations:[{operation:i,verbKey:s,isAdditional:!1}]};if(s==="query"&&f(o["x-query"]))return{pathItem:o,operations:[{operation:o["x-query"],verbKey:"x-query",isAdditional:!1}]};const t=f(o.additionalOperations)?o.additionalOperations[s]:void 0;if(f(t))return{pathItem:o,operations:[{operation:t,verbKey:s,isAdditional:!0}]}}function y(e,n,r){return(Array.isArray(e.tags)?e.tags:[r?x:""]).includes(n)}function k(e,n,r,s){const o=new Map;if(!f(n))return o;for(const i of Object.keys(n)){const t=m(e,n[i]);if(!t)continue;const a=[];for(const[c,u]of Object.entries(t))!v(c)||!f(u)||y(u,r,s)&&a.push({operation:u,verbKey:c,isAdditional:!1});if(f(t.additionalOperations))for(const[c,u]of Object.entries(t.additionalOperations))f(u)&&y(u,r,s)&&a.push({operation:u,verbKey:c,isAdditional:!0});a.length&&o.set(i,{pathItem:t,operations:a})}return o}const E=["summary","description","parameters","servers"];function b(e){const n={};for(const[r,{pathItem:s,operations:o}]of e){const i={};for(const a of E)s[a]!==void 0&&(i[a]=s[a]);const t={};for(const{operation:a,verbKey:c,isAdditional:u}of o)u?t[c]=a:i[c]=a;Object.keys(t).length&&(i.additionalOperations=t),n[r]=i}return n}function K(e,n){const r=Array.isArray(e.tags)?e.tags:[],s=new Map;for(const t of r)f(t)&&typeof t.name=="string"&&s.set(t.name,t);const o=new Set,i=t=>{if(o.has(t))return;const a=s.get(t);a&&(o.add(t),typeof a.parent=="string"&&i(a.parent))};for(const t of n)i(t);return r.filter(t=>f(t)&&o.has(t.name))}function _(e,n){const r=e["x-tagGroups"];if(!Array.isArray(r))return[];const s=[];for(const o of r){if(!f(o)||!Array.isArray(o.tags))continue;const i=o.tags.filter(t=>typeof t=="string"&&n.has(t));i.length&&s.push({...o,tags:i})}return s}export{W as extractOpenApiSlice,L as operationScopeFromPointer,I as parsePointerTokens};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ApiItemContent } from '../../types/store.js';
|
|
2
|
+
import type { ApiSpecType } from '../../types/common.js';
|
|
3
|
+
import type { SpecSliceScope } from './types.js';
|
|
4
|
+
export declare function resolveSpecSliceScope(specType: ApiSpecType, content: ApiItemContent | null | undefined, label: string | undefined, groupMemberContents?: Array<ApiItemContent | null | undefined>): SpecSliceScope | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{apiSpecType as u,contentType as t,itemVariant as i}from"../../types/common.js";import{BUILT_IN_DIRECTIVES as m,BUILT_IN_SCALARS as s}from"../../adapters/graphql/utils/constants.js";import{operationScopeFromPointer as T}from"./openapi-slice.js";import{scopeFromAsyncApiPointer as A}from"./asyncapi-slice.js";function V(e,r,n,p){if(r){if(r.contentType===t.OVERVIEW)return{kind:"document"};switch(e){case u.OPENAPI:return I(r);case u.ASYNCAPI:return S(r,n);case u.GRAPHQL:return r.contentType===t.GROUP?N(n,p):d(r);default:return}}}function I(e){if(e.contentType===t.GROUP){const r=e.meta?.name;return typeof r=="string"?{kind:"tag",tagName:r}:void 0}if(e.contentType===t.ITEM){if(e.itemVariant===i.HTTP_ITEM&&e.meta?.pointer)return T(e.meta.pointer,e.meta.isWebhook);if(e.itemVariant===i.SCHEMA&&e.meta?.name)return{kind:"schema",name:e.meta.name}}}const E={[i.QUERY]:"query",[i.MUTATION]:"mutation",[i.SUBSCRIPTION]:"subscription"},c=new Set([i.OBJECT,i.INTERFACE,i.INPUT,i.UNION,i.ENUM,i.SCALAR]);function d(e){if(e.contentType!==t.ITEM||!e.itemVariant)return;const r=e.meta?.name;if(typeof r!="string"||!r)return;const n=E[e.itemVariant];if(n)return{kind:"graphql-operation",operationType:n,name:r};if(c.has(e.itemVariant))return s.has(r)?void 0:{kind:"graphql-type",name:r};if(e.itemVariant===i.DIRECTIVE)return m.has(r)?void 0:{kind:"graphql-directive",name:r}}function N(e,r){if(!r?.length)return;const n=[],p=new Set;for(const o of r){const a=o?d(o):void 0;if(!a)continue;const f=`${a.kind}/${"operationType"in a?a.operationType:""}/${a.name}`;p.has(f)||(p.add(f),n.push(a))}return n.length?{kind:"graphql-group",label:e,members:n}:void 0}function S(e,r){if(e.contentType===t.GROUP)return r?{kind:"tag",tagName:r}:void 0;if(e.contentType===t.ITEM&&(e.itemVariant===i.CHANNEL||e.itemVariant===i.CHANNEL_OPERATION)&&e.meta?.pointer)return A(e.meta.pointer)}export{V as resolveSpecSliceScope};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type GraphqlOperationType = 'query' | 'mutation' | 'subscription';
|
|
2
|
+
export type GraphqlItemScope = {
|
|
3
|
+
kind: 'graphql-operation';
|
|
4
|
+
operationType: GraphqlOperationType;
|
|
5
|
+
name: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'graphql-type';
|
|
8
|
+
name: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'graphql-directive';
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
export type SpecSliceScope = {
|
|
14
|
+
kind: 'document';
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'tag';
|
|
17
|
+
tagName: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'operation';
|
|
20
|
+
pathName: string;
|
|
21
|
+
httpVerb: string;
|
|
22
|
+
source: 'paths' | 'webhooks';
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'schema';
|
|
25
|
+
name: string;
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'channel';
|
|
28
|
+
channelId: string;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'async-operation';
|
|
31
|
+
operationId: string;
|
|
32
|
+
} | GraphqlItemScope | {
|
|
33
|
+
kind: 'graphql-group';
|
|
34
|
+
label?: string;
|
|
35
|
+
members: GraphqlItemScope[];
|
|
36
|
+
};
|
|
37
|
+
export type SliceContentKind = 'yaml' | 'graphql';
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RedocStandaloneProps } from './RedocStandalone.js';
|
|
2
|
+
import type { TypeOfUsage } from './telemetry/RedocTelemetry.js';
|
|
3
|
+
import { RedocStandalone } from './RedocStandalone.js';
|
|
4
|
+
export { RedocStandalone };
|
|
5
|
+
export type { RedocStandaloneProps };
|
|
6
|
+
export type InitOptions = NonNullable<RedocStandaloneProps['options']> & {
|
|
7
|
+
router?: 'hash' | 'history';
|
|
8
|
+
disableTelemetry?: boolean;
|
|
9
|
+
specType?: RedocStandaloneProps['specType'];
|
|
10
|
+
/** The Docker image sets `type-of-usage="docker"` on the `<redoc>` element. */
|
|
11
|
+
typeOfUsage?: TypeOfUsage;
|
|
12
|
+
basePath?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function init(definitionOrDefinitionUrl: string | Record<string, unknown>, options?: InitOptions, element?: Element | null): void;
|
|
15
|
+
/**
|
|
16
|
+
* Attaches to server-rendered markup instead of replacing it. The definition must be
|
|
17
|
+
* the same pre-bundled document the server pass rendered from.
|
|
18
|
+
*/
|
|
19
|
+
export declare function hydrate(definitionOrDefinitionUrl: string | Record<string, unknown>, options?: InitOptions, element?: Element | null): Promise<void>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createElement as f}from"react";import{createRoot as g,hydrateRoot as E}from"react-dom/client";import{HashRouter as R}from"react-router";import{RedocStandalone as y,prepareApiDocs as S}from"./RedocStandalone.js";import{RedoclyApiDocsStandalone as A}from"./RedoclyApiDocsStandalone.js";import{logoFromDefinition as T}from"./utils/x-logo.js";const C=["html","cli","react","docker"];function M(e,t){return C.includes(e)?e:t}function m(e){return typeof document<"u"?document.querySelector(e):null}function w(e){const t={};for(const o of Array.from(e.attributes))t[o.name]=o.value;return t}function U(e){const t=w(e),o={};for(const r in t){const s=r.replace(/-(.)/g,(n,c)=>c.toUpperCase());o[s]=t[r]}return o}function h(e,t,o,r){const{router:s,disableTelemetry:n,specType:c,typeOfUsage:i,basePath:p,...u}={...t,...U(o)};let l,a;return typeof e=="string"?c==="graphql"&&!H(e)?a=e:l=e:typeof e=="object"&&(a=e),{router:s,props:{definition:a,definitionUrl:l,specType:c,options:u,basePath:p,telemetryConfig:{typeOfUsage:M(i,r),...n!==void 0?{disabled:n===!0||String(n)==="true"}:{}}}}}function d(e,t){return t==="history"?e:f(R,null,e)}function b(e){if(e===null)throw new Error('"element" argument is not provided and <redoc> tag is not found on the page');return e}function q(e,t={},o=m("redoc")){const r=b(o),{router:s,props:n}=h(e,t,r,"html");g(r).render(d(f(y,n),s))}const v=/server rendered HTML didn't match the client|error while hydrating|Minified React error #(418|423)/;async function L(e,t={},o=m("redoc")){const r=b(o),{router:s,props:n}=h(e,t,r,"cli"),c=n.basePath??"/",i=await S({...n,basePath:c}),p=f(A,{items:i.items,store:i.store,basePath:c,options:i.options,logo:T(i.document),telemetryConfig:n.telemetryConfig,definition:i.document,definitionUrl:n.definitionUrl});if(r.childElementCount===0){g(r).render(d(p,s));return}E(r,d(p,s),{onRecoverableError:(u,l)=>{const a=u instanceof Error?u.message:String(u);v.test(a)||console.error(a,l)}})}function H(e){return!e.includes(`
|
|
2
|
+
`)&&/^[^\s]+$/.test(e)}function I(){const e=m("redoc");if(!e)return;const t=e.getAttribute("spec-url");t&&q(t,{},e)}I();export{y as RedocStandalone,L as hydrate,q as init};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ThemeDataTransferObject } from '@redocly/theme/core/openapi';
|
|
2
|
+
/** Theme config injected into the standalone render's `ThemeDataContext`; `undefined` keeps the theme defaults. */
|
|
3
|
+
export declare const STANDALONE_THEME_CONFIG: ThemeDataTransferObject['config'] | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=void 0;export{e as STANDALONE_THEME_CONFIG};
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { Telemetry } from '@redocly/redoc-opentelemetry';
|
|
2
2
|
import type { EventType, EventPayload } from '@redocly/redoc-opentelemetry';
|
|
3
3
|
export type SpecType = 'openapi' | 'asyncapi' | 'graphql';
|
|
4
|
+
export type TypeOfUsage = 'html' | 'cli' | 'react' | 'docker';
|
|
4
5
|
export interface RedocTelemetryConfig {
|
|
5
6
|
specType: SpecType;
|
|
6
7
|
collectorUrl?: string;
|
|
7
8
|
serviceName?: string;
|
|
8
9
|
disabled?: boolean;
|
|
9
10
|
serviceVersion?: string;
|
|
11
|
+
typeOfUsage?: TypeOfUsage;
|
|
10
12
|
}
|
|
11
13
|
export declare class RedocTelemetry extends Telemetry {
|
|
12
14
|
private specType;
|
|
15
|
+
readonly typeOfUsage: TypeOfUsage | undefined;
|
|
13
16
|
constructor(config: RedocTelemetryConfig);
|
|
14
17
|
send<T extends EventType>(event: T, data?: EventPayload<T>): void;
|
|
15
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Telemetry as
|
|
1
|
+
import{Telemetry as p}from"@redocly/redoc-opentelemetry";import o from"../../package.json"with{type:"json"};import{DEFAULT_SERVICE_NAME as t,TELEMETRY_DISABLED_BY_DEFAULT as c}from"./defaults.js";const E="https://otel.cloud.redocly.com/v1/traces";class n extends p{specType;typeOfUsage;constructor(e){super(),this.specType=e.specType,this.typeOfUsage=e.typeOfUsage,this.init({otel:{isProd:process.env.NODE_ENV==="production"||process.env.ENABLE_LOCAL_TELEMETRY==="true",serviceVersion:e.serviceVersion||`${o.name}@${o.version}`,version:"1.0.0",collectorTraceUrl:e.collectorUrl||E,serviceName:e.serviceName||t,tracerName:"client-telemetry"},disabled:e.disabled??c})}send(e,s){s&&Array.isArray(s)&&s.length>0&&(s=s.map(r=>r&&typeof r=="object"?{...r,specType:this.specType}:r)),super.send(e,s,{env:process.env.NODE_ENV})}}export{n as RedocTelemetry};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const E=!0,t="realm-ui";export{t as DEFAULT_SERVICE_NAME,E as TELEMETRY_DISABLED_BY_DEFAULT};
|
package/lib/types/asyncapi.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ENTITY_RELATION_TYPES } from '@redocly/config';
|
|
2
2
|
import type { Node } from '@markdoc/markdoc';
|
|
3
|
-
import type { ResolvedNavItem
|
|
3
|
+
import type { ResolvedNavItem } from '@redocly/config';
|
|
4
|
+
import type { REDOCLY_TEAMS_RBAC } from '@redocly/config';
|
|
4
5
|
import type { JSONSchema7 } from 'json-schema';
|
|
5
6
|
import type { Referenced, ObjectValues } from './common.js';
|
|
6
7
|
import type { ApiItem } from './store.js';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export type Languages = 'JavaScript' | 'Node.js' | 'curl' | 'Java8+Apache' | 'Java' | 'Python' | 'Go' | 'PHP' | 'C#' | 'C#+Newtonsoft' | 'Ruby' | 'R';
|
|
2
|
+
export interface BasicLanguageOptions {
|
|
3
|
+
indent?: string;
|
|
4
|
+
withImports?: boolean;
|
|
5
|
+
withComments?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface CodeSampleBasicConfig {
|
|
8
|
+
lang: Languages | 'Payload';
|
|
9
|
+
label: string;
|
|
10
|
+
key: string;
|
|
11
|
+
options?: BasicLanguageOptions;
|
|
12
|
+
}
|
|
13
|
+
export interface CurlCodeSampleConfig extends CodeSampleBasicConfig {
|
|
14
|
+
lang: 'curl';
|
|
15
|
+
options?: BasicLanguageOptions & {
|
|
16
|
+
binary?: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface JavaScriptCodeSampleConfig extends CodeSampleBasicConfig {
|
|
20
|
+
lang: 'JavaScript';
|
|
21
|
+
options?: BasicLanguageOptions & {
|
|
22
|
+
credentials?: 'omit' | 'same-origin' | 'include';
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface GoCodeSampleConfig extends CodeSampleBasicConfig {
|
|
26
|
+
lang: 'Go';
|
|
27
|
+
}
|
|
28
|
+
export interface NodeJsCodeSampleConfig extends CodeSampleBasicConfig {
|
|
29
|
+
lang: 'Node.js';
|
|
30
|
+
}
|
|
31
|
+
export interface PythonCodeSampleConfig extends CodeSampleBasicConfig {
|
|
32
|
+
lang: 'Python';
|
|
33
|
+
}
|
|
34
|
+
export interface Java8CodeSampleConfig extends CodeSampleBasicConfig {
|
|
35
|
+
lang: 'Java8+Apache';
|
|
36
|
+
}
|
|
37
|
+
export interface JavaCodeSampleConfig extends CodeSampleBasicConfig {
|
|
38
|
+
lang: 'Java';
|
|
39
|
+
}
|
|
40
|
+
export interface CSharpCodeSampleConfig extends CodeSampleBasicConfig {
|
|
41
|
+
lang: 'C#';
|
|
42
|
+
}
|
|
43
|
+
export interface CSharpNewtonsoftCodeSampleConfig extends CodeSampleBasicConfig {
|
|
44
|
+
lang: 'C#+Newtonsoft';
|
|
45
|
+
}
|
|
46
|
+
export interface PHPCodeSampleConfig extends CodeSampleBasicConfig {
|
|
47
|
+
lang: 'PHP';
|
|
48
|
+
}
|
|
49
|
+
export interface RubyCodeSampleConfig extends CodeSampleBasicConfig {
|
|
50
|
+
lang: 'Ruby';
|
|
51
|
+
}
|
|
52
|
+
export interface RCodeSampleConfig extends CodeSampleBasicConfig {
|
|
53
|
+
lang: 'R';
|
|
54
|
+
}
|
|
55
|
+
export interface PayloadCodeSampleConfig extends CodeSampleBasicConfig {
|
|
56
|
+
lang: 'Payload';
|
|
57
|
+
}
|
|
58
|
+
export interface CustomLanguageCodeSampleConfig extends Omit<CodeSampleBasicConfig, 'lang'> {
|
|
59
|
+
lang: string;
|
|
60
|
+
}
|
|
61
|
+
export type CodeSampleConfig = CurlCodeSampleConfig | JavaScriptCodeSampleConfig | NodeJsCodeSampleConfig | PythonCodeSampleConfig | Java8CodeSampleConfig | JavaCodeSampleConfig | CSharpCodeSampleConfig | CSharpNewtonsoftCodeSampleConfig | PHPCodeSampleConfig | GoCodeSampleConfig | RubyCodeSampleConfig | RCodeSampleConfig;
|
|
62
|
+
export interface CodeSamplesConfig {
|
|
63
|
+
languages: (CodeSampleConfig | PayloadCodeSampleConfig | CustomLanguageCodeSampleConfig)[];
|
|
64
|
+
skipOptionalParameters?: boolean;
|
|
65
|
+
withOAuth2Call?: boolean;
|
|
66
|
+
onSampleTabClick?: (label: string) => void;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
File without changes
|