@redocly/api-docs 0.2.0-next.6 → 0.2.0-next.8
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 +2 -2
- package/lib/RedocStandalone.js +1 -1
- package/lib/RedoclyApiDocs.js +1 -1
- package/lib/RedoclyApiDocsStandalone.d.ts +2 -2
- package/lib/RedoclyApiDocsStandalone.js +3 -3
- package/lib/adapters/graphql/group/utils.js +1 -1
- package/lib/adapters/openapi/configure/resolve-request-values.js +1 -1
- package/lib/adapters/openapi/items/operation/content.js +1 -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.js +1 -1
- 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/views/DiscriminatorPropertyRow.js +1 -1
- package/lib/components/Schema/views/Examples.js +1 -1
- package/lib/components/Security/SecurityFlowDetail.js +1 -1
- package/lib/components/common/DeepLinkAnchor.js +9 -9
- package/lib/components/markdoc/SchemaDefinition.js +1 -1
- package/lib/components/panels/ExampleItem/ResponseExampleItem.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/styled.js +1 -1
- 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/withStoreProvider.d.ts +2 -0
- package/lib/hoc/withStoreProvider.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/useLicense.js +1 -1
- package/lib/hooks/useLicenseGate.d.ts +6 -0
- package/lib/hooks/useLicenseGate.js +1 -0
- package/lib/hooks/useUrlHash.d.ts +3 -2
- package/lib/hooks/useUrlHash.js +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -1
- package/lib/jotai/store.d.ts +4 -0
- package/lib/jotai/store.js +1 -1
- package/lib/options/helpers.d.ts +0 -1
- package/lib/options/helpers.js +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/services/code-samples/replay/from-openapi-document.d.ts +8 -1
- 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/license/check.d.ts +1 -0
- package/lib/services/license/check.js +1 -1
- package/lib/services/search/indexer.js +1 -1
- 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.js +2 -2
- package/lib/types/content.d.ts +2 -2
- package/lib/types/options.d.ts +0 -6
- package/lib/utils/compose.d.ts +1 -0
- package/lib/utils/x-logo.d.ts +1 -1
- package/lib/utils/x-logo.js +1 -1
- package/package.json +11 -12
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import{styled as t,css as
|
|
1
|
+
import{styled as t,css as n}from"styled-components";import{Button as r}from"@redocly/theme/components/Button/Button";import{DropdownMenu as o}from"@redocly/theme/components/Dropdown/DropdownMenu";import{DropdownMenuItem as a}from"@redocly/theme/components/Dropdown/DropdownMenuItem";import{ITEM_WIDTH as s}from"./constants.js";const i="var(--spacing-unit)",f=t(o)`
|
|
2
2
|
position: absolute;
|
|
3
3
|
right: 0;
|
|
4
|
-
`,
|
|
4
|
+
`,u=t.span`
|
|
5
5
|
display: flex;
|
|
6
6
|
justify-content: space-between;
|
|
7
7
|
align-items: center;
|
|
8
|
+
padding-top: ${i};
|
|
8
9
|
`,x=t.span`
|
|
9
10
|
max-width: 150px;
|
|
10
11
|
text-overflow: ellipsis;
|
|
@@ -14,14 +15,14 @@ import{styled as t,css as i}from"styled-components";import{Button as n}from"@red
|
|
|
14
15
|
font-size: var(--font-size-base);
|
|
15
16
|
line-height: var(--line-height-base);
|
|
16
17
|
font-weight: ${({$active:e})=>e?"var(--font-weight-medium)":"var(--font-weight-regular)"};
|
|
17
|
-
`,
|
|
18
|
+
`,l=t.span`
|
|
18
19
|
width: 100%;
|
|
19
20
|
display: inherit;
|
|
20
21
|
gap: inherit;
|
|
21
22
|
flex-direction: inherit;
|
|
22
23
|
justify-content: inherit;
|
|
23
24
|
align-items: inherit;
|
|
24
|
-
`,
|
|
25
|
+
`,v=t.span`
|
|
25
26
|
width: 24px;
|
|
26
27
|
height: 24px;
|
|
27
28
|
display: flex;
|
|
@@ -29,15 +30,15 @@ import{styled as t,css as i}from"styled-components";import{Button as n}from"@red
|
|
|
29
30
|
justify-content: center;
|
|
30
31
|
flex-shrink: 0;
|
|
31
32
|
overflow: hidden;
|
|
32
|
-
`,
|
|
33
|
+
`,m=t.div`
|
|
33
34
|
display: flex;
|
|
34
35
|
justify-content: ${({$justifyContent:e="start"})=>e};
|
|
35
36
|
align-items: center;
|
|
36
37
|
width: 100%;
|
|
37
|
-
`,
|
|
38
|
+
`,w=t.button`
|
|
38
39
|
background: none;
|
|
39
40
|
border: none;
|
|
40
|
-
width: ${
|
|
41
|
+
width: ${s}px;
|
|
41
42
|
flex-shrink: 0;
|
|
42
43
|
display: flex;
|
|
43
44
|
align-items: center;
|
|
@@ -52,12 +53,14 @@ import{styled as t,css as i}from"styled-components";import{Button as n}from"@red
|
|
|
52
53
|
|
|
53
54
|
&:hover {
|
|
54
55
|
color: var(--text-color-primary);
|
|
56
|
+
background-color: var(--layer-color-hover);
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
${({$active:e})=>e&&
|
|
59
|
+
${({$active:e})=>e&&n`
|
|
58
60
|
&::before {
|
|
59
61
|
position: absolute;
|
|
60
|
-
top: calc(-1 *
|
|
62
|
+
top: calc(-1 * ${i} - 1px);
|
|
63
|
+
left: 0;
|
|
61
64
|
border-top: 3px solid var(--text-color-primary);
|
|
62
65
|
width: 100%;
|
|
63
66
|
content: '';
|
|
@@ -65,7 +68,7 @@ import{styled as t,css as i}from"styled-components";import{Button as n}from"@red
|
|
|
65
68
|
border-bottom-right-radius: calc(var(--border-radius) / 2);
|
|
66
69
|
}
|
|
67
70
|
`}
|
|
68
|
-
`,
|
|
71
|
+
`,b=t(a)`
|
|
69
72
|
display: flex;
|
|
70
73
|
justify-content: space-between;
|
|
71
74
|
align-items: center;
|
|
@@ -75,22 +78,22 @@ import{styled as t,css as i}from"styled-components";import{Button as n}from"@red
|
|
|
75
78
|
width: ${({$width:e=204})=>e}px;
|
|
76
79
|
fill: var(--menu-content-color-active);
|
|
77
80
|
|
|
78
|
-
${
|
|
81
|
+
${l} {
|
|
79
82
|
width: auto;
|
|
80
83
|
justify-content: flex-start;
|
|
81
84
|
}
|
|
82
|
-
`,
|
|
85
|
+
`,y=t(r)`
|
|
83
86
|
display: inline-flex;
|
|
84
87
|
|
|
85
88
|
line-height: var(--line-height-base);
|
|
86
89
|
font-size: var(--font-size-base);
|
|
87
90
|
font-weight: var(--font-weight-medium);
|
|
88
91
|
cursor: pointer;
|
|
89
|
-
`,
|
|
92
|
+
`,L=t.span`
|
|
90
93
|
display: inline-flex;
|
|
91
94
|
align-items: center;
|
|
92
95
|
line-height: var(--line-height-base);
|
|
93
96
|
font-size: var(--font-size-base);
|
|
94
97
|
font-weight: var(--font-weight-regular);
|
|
95
98
|
color: var(--text-color-secondary);
|
|
96
|
-
`;export{
|
|
99
|
+
`;export{u as Container,y as DropdownTriggerButton,v as LanguageIcon,m as LanguageListContainer,w as LanguageListItem,x as LanguageTitle,l as LanguageTitleContainer,f as RightAlignedDropdownMenu,L as StaticLanguageLabel,b as StyledDropdownMenuItem};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{Fragment as
|
|
1
|
+
import{Fragment as r,jsx as a}from"react/jsx-runtime";import{styled as t}from"styled-components";import{CodeBlock as l}from"@redocly/theme/components/CodeBlock/CodeBlock";import{useSpecTranslate as s}from"../../hooks/useTranslate.js";import{CodeBlockPanel as m,StyledJsonViewer as c}from"./styled.js";const i={"openapi.mcp.inputExample":"Input example","openapi.mcp.outputExample":"Output example","openapi.mcp.argumentsExample":"Arguments example","openapi.mcp.exampleTitle":"Resource content"},d=t(l)`
|
|
2
2
|
border: none;
|
|
3
3
|
padding: 0 8px;
|
|
4
4
|
margin-bottom: 0;
|
|
5
5
|
--code-block-padding: var(--spacing-xs) 0 var(--spacing-xs) var(--spacing-sm);
|
|
6
|
-
`;function
|
|
6
|
+
`;function I({node:n}){const p=s();return a(r,{children:n.children.map((e,o)=>a(m,{className:"panel-response-samples",header:p(e.headerTitleTranslationKey,i[e.headerTitleTranslationKey]),isExpandable:!1,children:e.language?a(d,{source:String(e.data),header:{title:e.language,controls:{copy:{}}}}):a(c,{data:e.data,expandLevel:Number.POSITIVE_INFINITY})},o))})}export{I as McpExamplePanelItem};
|
|
@@ -5,7 +5,7 @@ import{styled as o}from"styled-components";import{Panel as e}from"@redocly/theme
|
|
|
5
5
|
`,c=o(e)`
|
|
6
6
|
[data-component-name='Panel/PanelHeader'],
|
|
7
7
|
[data-component-name='Panel/PanelBody'] {
|
|
8
|
-
padding: var(--spacing-sm);
|
|
8
|
+
padding: var(--spacing-sm) var(--spacing-md);
|
|
9
9
|
}
|
|
10
10
|
`,l=o(a)`
|
|
11
11
|
border: none;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{useId as l,useMemo as u}from"react";import{useAtomValue as
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{useId as l,useMemo as u}from"react";import{useAtomValue as c}from"jotai";import{panelKind as a}from"../../types/common.js";import{exampleStoreAtom as I}from"../../jotai/examples.js";import{responseCodesContainingKey as R}from"../../services/code-samples/example-key.js";import{ResponseExampleItem as E}from"../panels/ExampleItem/ResponseExampleItem.js";import{ContentWrapper as S}from"../common/ContentWrapper.js";import{ItemIdContext as x,SYNTHETIC_ITEM_ID_PREFIX as C}from"../../hooks/useDeepLinkSection.js";function N({responseCodes:e,exampleKey:n,schemaId:t}){const m=c(I),s=`${C}${l()}`,i=u(()=>{const o=R(e,n,f=>m[f]);return o.length===1?o:e},[e,n,m]),p=t===void 0?i:i.map(o=>o.schemaId?o:{...o,schemaId:t}),d={kind:a.RESPONSE,responseCodes:p,examples:[],...e.length===0&&t!==void 0&&{schemaId:t},...n!==void 0&&{exampleKey:n}};return r(x.Provider,{value:s,children:r(S,{children:r(E,{node:d})})})}export{N as RedocResponseSamples};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fragment as i,jsx as r,jsxs as a}from"react/jsx-runtime";import{useLicenseGate as m}from"../hooks/useLicenseGate.js";function x(t){return function(e){const{gatedItems:s,overlay:n}=m(e.items??[]);return a(i,{children:[n,r(t,{...e,items:s})]})}}export{x as withLicenseGate};
|
|
@@ -10,6 +10,8 @@ type WithStoreProviderProps = {
|
|
|
10
10
|
options: RawApiDocsOptions;
|
|
11
11
|
layout?: LayoutVariant;
|
|
12
12
|
basePath?: string;
|
|
13
|
+
definition?: Record<string, unknown> | string;
|
|
14
|
+
definitionUrl?: string;
|
|
13
15
|
};
|
|
14
16
|
export type StoreProviderProps = {
|
|
15
17
|
options?: RawApiDocsOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as p}from"react/jsx-runtime";import{memo as
|
|
1
|
+
import{jsx as p}from"react/jsx-runtime";import{memo as E,useMemo as v,useEffect as j}from"react";import{createStore as O,Provider as P,useStore as N,getDefaultStore as _}from"jotai";import{LayoutVariant as k}from"@redocly/config";import{createStoreContext as M,toRecord as T}from"../adapters/helpers.js";import{populateOpenApiStore as F}from"../adapters/openapi/store.js";import{DEFAULT_MAX_DISPLAYED_ENUM_VALUES as V}from"../options/constants.js";import{normalizeOptions as w}from"../options/normalizeOptions.js";import{globalStoreAtom as h}from"../jotai/store.js";import{appStore as C,environmentAtom as z,layoutAtom as y}from"../jotai/app.js";import{userClaimsAtom as g}from"../jotai/app.js";import{buildServerEnvValues as I}from"../services/code-samples/server-env.js";const q={ignoreNamedSchemas:["java.io.ObjectStreamField"],maxDisplayedEnumValues:V};function L(e,o){const t={...q,...e,basePath:o};return w(t)}const U=new WeakSet;function b(e){U.has(e)||(U.add(e),e.sub(C,()=>{}))}function D(e,o){if(!o?.servers?.length)return;b(e);const t=I(o.servers),i=e.get(C).environments??{},s={};for(const[n,a]of Object.entries(t)){const m=i[n],r=m?Object.fromEntries(Object.entries(a).filter(([d])=>!(d in m))):a;Object.keys(r).length>0&&(s[n]=r)}Object.keys(s).length!==0&&e.set(z,{environments:s})}function re(e){const o=E(t=>{const{items:i,options:s,store:n,layout:a,basePath:m="",definition:r,definitionUrl:d}=t,x=N(),c=x!==_()?x:void 0,u=v(()=>L(s,m),[s,m]),S=a??u.layout;j(()=>{if(c){const l=c.get(h);D(c,n??l.store),c.set(y,S),c.set(g,u.userClaims??{}),c.set(h,{items:i,store:n??l.store,options:u,definition:r??l.definition,definitionUrl:d??l.definitionUrl,replayDefinition:l.replayDefinition})}},[S,u,c,i,n,r,d]);const A=v(()=>{if(c)return null;const l={items:i,store:n,options:u,definition:r,definitionUrl:d,replayDefinition:null},f=O();return f.set(h,l),b(f),f.set(y,S),u.userClaims&&f.set(g,u.userClaims),D(f,n),f},[c,i,n,u,S]);return c||!A?p(e,{...t}):p(P,{store:A,children:p(e,{...t})})});return o.displayName=`WithStoreProvider(${G(e)})`,o}function G(e){return e.displayName||e.name||"Component"}function K(e,o){const t=M(T(e));return F(e,t,o),{schemaStore:t.schemaStore,exampleStore:t.exampleStore,securitySchemeStore:t.securitySchemeStore,mcp:t.document["x-mcp"],schemaCatalogLink:t.document["x-schema-catalog-link"]}}const oe=E(function({children:o,definition:t,apiStore:i,options:s}){const n=v(()=>{const a=L({specType:"openapi",...s},s?.basePath??"");let m;if(i)m=i;else if(t)m=K(t,a);else throw new Error("StoreProvider requires either apiStore or definition");const r=O();return r.set(h,{items:[],store:m,options:a,replayDefinition:null}),b(r),r.set(y,k.STACKED),a.userClaims&&r.set(g,a.userClaims),D(r,m),r},[i,t,s]);return p(P,{store:n,children:o})});export{oe as StoreProvider,re as withStoreProvider};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SliceContentKind, SpecSliceScope } from '../services/spec-slice/index.js';
|
|
2
|
+
type CopySpecSlice = {
|
|
3
|
+
getText: () => Promise<string>;
|
|
4
|
+
contentKind: SliceContentKind;
|
|
5
|
+
scope: SpecSliceScope;
|
|
6
|
+
specUrl?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function useCopySpecSlice(pageSlug: string): CopySpecSlice | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useMemo as a}from"react";import{useAtomValue as r}from"jotai";import{apiSpecType as d}from"../types/common.js";import{definitionAtom as l,definitionUrlAtom as y,routingBasePathAtom as h,specTypeAtom as A}from"../jotai/store.js";import{routeIndexAtom as P}from"../jotai/routes.js";import{buildSpecSlice as S,resolveSpecSliceScope as g}from"../services/spec-slice/index.js";function x(t,n,i){const e=n.toLowerCase(),o=t.routeIndexByPath.get(n)??t.routeIndexByPath.get(e);return o!==void 0?t.allRoutes[o]:e===i.toLowerCase()?t.rootPage:void 0}function R(t){const n=r(l),i=r(y),e=r(P),o=r(A),m=r(h);return a(()=>{if(!n||!e)return null;const c=x(e,t,m??""),p=c?e.tagByPath.get(c.path)?.items.map(s=>s.content):void 0,u=g(o,c?.content,c?.label,p);if(!u)return null;const f=o===d.GRAPHQL?"graphql":"yaml";return{getText:async()=>{const s=await S(o,n,u);if(s===void 0)throw new Error(`Copy for LLM: no content produced for "${t}"`);return s},contentKind:f,scope:u,specUrl:i}},[n,i,e,o,m,t])}export{R as useCopySpecSlice};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as i,useContext as u,useMemo as c}from"react";import{useAtomValue as
|
|
1
|
+
import{createContext as i,useContext as u,useMemo as c}from"react";import{useAtomValue as m}from"jotai";import{routingBasePathAtom as p}from"../jotai/store.js";import{buildDeepLinkUrl as I,buildOpenApiSectionSuffix as x,CALLBACKS_SECTION as C}from"../utils/deep-link.js";import{joinWithSeparator as S,toElementId as h,toRelativePath as L}from"../utils/url.js";import{useNavigationUrlNormalizer as k}from"./useNormalizeUrl.js";const a=i(void 0),D=i(void 0);function U(){return u(D)}function T(){const t=u(a),e=m(p);return c(()=>t?(h(t,e)??"").toLowerCase():"",[t,e])}const g="synthetic-item:",_=i(null);function l(t,e){const o=u(a),r=U(),n=m(p),s=k();return c(()=>{if(!o||o.startsWith(g))return"";const f=n?L(o,n):o,d=e&&r?S(x(C,r),t):t;return s(I(n,f,d))},[o,r,e,n,t,s])}function v(t){return l(t,!0)}function z(t){return l(t,!1)}export{D as CallbackScopeContext,_ as DeepLinkSectionContext,a as ItemIdContext,g as SYNTHETIC_ITEM_ID_PREFIX,U as useCallbackScope,v as useDeepLinkUrl,z as useFieldDeepLinkUrl,T as useHashItemId};
|
package/lib/hooks/useLicense.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as
|
|
1
|
+
import{useState as a,useEffect as l}from"react";import r,{isLicenseBypassed as u}from"../services/license/check.js";function p(e){const[n,i]=a(u()?{valid:!0,allowed:!0}:null);l(()=>{async function o(){const s=await r(e);i(s)}o()},[e]);const t=n===null;return{licenseInfo:n??{},isValid:n!==null&&c(n),isPending:t}}function c(e){return!!e.valid&&!!e.allowed&&!e.expired||!!e.local}export{p as useLicense};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{useAtomValue as t}from"jotai";import{licenseKeyAtom as m}from"../jotai/store.js";import{useLicense as c}from"./useLicense.js";import{LicenseOverlay as l}from"../components/LicenseOverlay.js";function d(o){const s=t(m),{isValid:e,licenseInfo:i,isPending:n}=c(s);return{gatedItems:e?o:[],overlay:!n&&!e?r(l,{licenseInfo:i}):null}}export{d as useLicenseGate};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
type Options = {
|
|
2
2
|
trackSilentReplaces?: boolean;
|
|
3
3
|
};
|
|
4
|
-
/** Current
|
|
5
|
-
*
|
|
4
|
+
/** Current URL hash. Under Redoc standalone's hash router (`#/route#deep-link`) only the
|
|
5
|
+
* trailing deep-link part, or `''` when the fragment holds a route alone. Ignores scroll-spy's
|
|
6
|
+
* silent hash clears (so hash-driven state survives) unless `trackSilentReplaces` is set. */
|
|
6
7
|
export declare function useUrlHash(options?: Options): string;
|
|
7
8
|
export {};
|
package/lib/hooks/useUrlHash.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useSyncExternalStore as
|
|
1
|
+
import{useSyncExternalStore as o}from"react";import{URL_REPLACE_EVENT as s}from"./useRouterHashBridge.js";function r(e){return t=>{if(typeof window>"u")return()=>{};for(const n of e)window.addEventListener(n,t);return()=>{for(const n of e)window.removeEventListener(n,t)}}}const i=r(["hashchange","popstate"]),a=r(["hashchange","popstate",s]);function c(){if(typeof window>"u")return"";const e=window.location.hash;if(!e.startsWith("#/"))return e;const t=e.indexOf("#",1);return t===-1?"":e.slice(t)}function f(){return""}function p(e){return o(e?.trackSilentReplaces?a:i,c,f)}export{p as useUrlHash};
|
package/lib/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export { extractFullText } from './adapters/utils/markdoc.js';
|
|
|
15
15
|
export { normalizeOptions } from './options/normalizeOptions.js';
|
|
16
16
|
export { excludeMockServers } from './adapters/openapi/utils/merge-mock-server.js';
|
|
17
17
|
export { appendUndeclaredConfigureParameters } from './services/code-samples/replay/merge-configure-into-source.js';
|
|
18
|
-
export { isGraphqlDocsSidebarHidden } from './options/helpers.js';
|
|
19
18
|
export { findFirstBinding } from './adapters/asyncapi/build/utils.js';
|
|
20
19
|
export { resolveRequestValues, applyRequestValuesToOperationInfo, type ResolveRequestValuesParams, } from './adapters/openapi/configure/index.js';
|
|
21
20
|
export { updateObjectProperties, isDirectRequestValues, getEffectiveRequestValues, createSecurityUpdates, mergeSecurityIntoScheme, applyServerVariableDefaults, type SchemeForCredentials, } from './adapters/openapi/configure/merge-utils.js';
|
|
@@ -24,6 +23,7 @@ export type { ConfigureRequestValues, ConfigureServerRequestValues, SecurityDeta
|
|
|
24
23
|
export { MarkdownAdapterProvider, useMarkdownAdapter, type MarkdownAdapter, type MarkdownParser, type MarkdownRenderer, } from './contexts/markdownAdapter.js';
|
|
25
24
|
export { markdocParser } from './components/markdoc/markdocParser.js';
|
|
26
25
|
export { createMarkdocAdapter } from './components/markdoc/markdocAdapter.js';
|
|
26
|
+
export { adapterToMarkdownParser } from './components/Replay/adapterToMarkdownParser.js';
|
|
27
27
|
export { parseMarkdown, type ParseMarkdownOptions } from './adapters/utils/parseMarkdown.js';
|
|
28
28
|
export { isPlainText } from './adapters/utils/isPlainText.js';
|
|
29
29
|
export { buildMarkdocOptions } from './components/markdoc/buildMarkdocOptions.js';
|
|
@@ -54,6 +54,8 @@ export { schemaDefinitionTag } from './components/markdoc/tags/schema-definition
|
|
|
54
54
|
export { withReplayPrefetch, useOpenApiDefinition } from './hoc/withReplayPrefetch.js';
|
|
55
55
|
export { mergeEnvData } from './utils/environments.js';
|
|
56
56
|
export { buildReplayPredefinedEnvValues } from './services/code-samples/replay/replay-predefined-env.js';
|
|
57
|
+
export { createDocumentReplayConverter } from './services/code-samples/replay/from-openapi-document.js';
|
|
58
|
+
export { ReplayCodeSampleHTTPSnippet } from './services/code-samples/replay/har-to-code-sample-har.js';
|
|
57
59
|
export { encodeJsonPointerSegment } from './utils/refPointer.js';
|
|
58
60
|
export { JsonPointer } from './adapters/openapi/utils/JsonPointer.js';
|
|
59
61
|
export { langFromMime, encodeExampleForMediaType } from './utils/media-type.js';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./types/common.js";import{buildItems as t,buildNavItems as p}from"./adapters/build.js";import{buildGraphqlStoreFromSdl as m}from"./adapters/graphql/buildStoreFromSdl.js";import{simplifyAstStructure as
|
|
1
|
+
export*from"./types/common.js";import{buildItems as t,buildNavItems as p}from"./adapters/build.js";import{buildGraphqlStoreFromSdl as m}from"./adapters/graphql/buildStoreFromSdl.js";import{simplifyAstStructure as f}from"./adapters/utils/simplifyAstStructure.js";import{extractFullText as s}from"./adapters/utils/markdoc.js";import{normalizeOptions as n}from"./options/normalizeOptions.js";import{excludeMockServers as c}from"./adapters/openapi/utils/merge-mock-server.js";import{appendUndeclaredConfigureParameters as S}from"./services/code-samples/replay/merge-configure-into-source.js";import{findFirstBinding as y}from"./adapters/asyncapi/build/utils.js";import{resolveRequestValues as D,applyRequestValuesToOperationInfo as P}from"./adapters/openapi/configure/index.js";import{updateObjectProperties as M,isDirectRequestValues as v,getEffectiveRequestValues as k,createSecurityUpdates as A,mergeSecurityIntoScheme as E,applyServerVariableDefaults as b}from"./adapters/openapi/configure/merge-utils.js";import{MarkdownAdapterProvider as O,useMarkdownAdapter as I}from"./contexts/markdownAdapter.js";import{markdocParser as V}from"./components/markdoc/markdocParser.js";import{createMarkdocAdapter as w}from"./components/markdoc/markdocAdapter.js";import{adapterToMarkdownParser as N}from"./components/Replay/adapterToMarkdownParser.js";import{parseMarkdown as B}from"./adapters/utils/parseMarkdown.js";import{isPlainText as H}from"./adapters/utils/isPlainText.js";import{buildMarkdocOptions as J}from"./components/markdoc/buildMarkdocOptions.js";import{apiDocsMarkdocTags as Y,apiDocsMarkdocNodes as j}from"./components/markdoc/defaultMarkdocConfig.js";import{apiDocsMarkdocComponents as K}from"./components/markdoc/apiDocsMarkdocComponents.js";import{RedoclyApiDocs as W}from"./RedoclyApiDocs.js";import{RedoclyApiDocsStandalone as Z}from"./RedoclyApiDocsStandalone.js";import{ApiDocsSearchIndexer as ee}from"./services/search/indexer.js";import{RedocTelemetry as oe}from"./telemetry/RedocTelemetry.js";import{Replay as pe,EmbeddedReplay as ae}from"./components/Replay/index.js";import{REPLAY_TRY_IT_LOADING_STATE as de}from"./services/code-samples/index.js";import{findExampleIdByKey as ie}from"./services/code-samples/example-key.js";import{RedocSchema as xe,RedocExample as ne,RedocResponseSamples as le,RedocCodeSample as ce}from"./components/pluggable/index.js";import{StoreProvider as Se}from"./hoc/withStoreProvider.js";import{GraphQLTypeViewByName as ye}from"./components/graphql/GraphQLTypeView.js";import{mcpTagSchemas as De}from"./components/markdoc/tags/mcp-tag-schemas.js";import{schemaDefinitionTag as ge}from"./components/markdoc/tags/schema-definition-tag.js";import{withReplayPrefetch as ve,useOpenApiDefinition as ke}from"./hoc/withReplayPrefetch.js";import{mergeEnvData as Ee}from"./utils/environments.js";import{buildReplayPredefinedEnvValues as he}from"./services/code-samples/replay/replay-predefined-env.js";import{createDocumentReplayConverter as Ie}from"./services/code-samples/replay/from-openapi-document.js";import{ReplayCodeSampleHTTPSnippet as Ve}from"./services/code-samples/replay/har-to-code-sample-har.js";import{encodeJsonPointerSegment as we}from"./utils/refPointer.js";import{JsonPointer as Ne}from"./adapters/openapi/utils/JsonPointer.js";import{langFromMime as Be,encodeExampleForMediaType as Ge}from"./utils/media-type.js";import{isOperationName as Le,HTTP_METHODS as Je}from"./utils/http-methods.js";import{convertSampleToString as Ye}from"./services/code-samples/convertSampleToString.js";import{resolveOperationSampleContext as ze,buildCodeSamples as Ke,getRequestBodySamples as Qe,getResponseSamples as We}from"./services/operation-samples/index.js";export{ee as ApiDocsSearchIndexer,ae as EmbeddedReplay,ye as GraphQLTypeViewByName,Je as HTTP_METHODS,Ne as JsonPointer,O as MarkdownAdapterProvider,de as REPLAY_TRY_IT_LOADING_STATE,ce as RedocCodeSample,ne as RedocExample,le as RedocResponseSamples,xe as RedocSchema,oe as RedocTelemetry,W as RedoclyApiDocs,Z as RedoclyApiDocsStandalone,pe as Replay,Ve as ReplayCodeSampleHTTPSnippet,Se as StoreProvider,N as adapterToMarkdownParser,K as apiDocsMarkdocComponents,j as apiDocsMarkdocNodes,Y as apiDocsMarkdocTags,S as appendUndeclaredConfigureParameters,P as applyRequestValuesToOperationInfo,b as applyServerVariableDefaults,Ke as buildCodeSamples,m as buildGraphqlStoreFromSdl,t as buildItems,J as buildMarkdocOptions,p as buildNavItems,he as buildReplayPredefinedEnvValues,Ye as convertSampleToString,Ie as createDocumentReplayConverter,w as createMarkdocAdapter,A as createSecurityUpdates,Ge as encodeExampleForMediaType,we as encodeJsonPointerSegment,c as excludeMockServers,s as extractFullText,ie as findExampleIdByKey,y as findFirstBinding,k as getEffectiveRequestValues,Qe as getRequestBodySamples,We as getResponseSamples,v as isDirectRequestValues,Le as isOperationName,H as isPlainText,Be as langFromMime,V as markdocParser,De as mcpTagSchemas,Ee as mergeEnvData,E as mergeSecurityIntoScheme,n as normalizeOptions,B as parseMarkdown,ze as resolveOperationSampleContext,D as resolveRequestValues,ge as schemaDefinitionTag,f as simplifyAstStructure,M as updateObjectProperties,I as useMarkdownAdapter,ke as useOpenApiDefinition,ve as withReplayPrefetch};
|
package/lib/jotai/store.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type GlobalStoreAtom = {
|
|
|
6
6
|
items: ApiItem[];
|
|
7
7
|
store: ApiStore;
|
|
8
8
|
options: ApiDocsOptions;
|
|
9
|
+
definition?: Record<string, unknown> | string;
|
|
10
|
+
definitionUrl?: string;
|
|
9
11
|
replayDefinition: OpenAPIDefinition | null;
|
|
10
12
|
};
|
|
11
13
|
export declare const globalStoreAtom: import("jotai").PrimitiveAtom<GlobalStoreAtom> & {
|
|
@@ -19,6 +21,8 @@ export declare const specTypeAtom: import("jotai").Atom<ApiSpecType>;
|
|
|
19
21
|
export declare const routingBasePathAtom: import("jotai").Atom<string>;
|
|
20
22
|
export declare const licenseKeyAtom: import("jotai").Atom<string | undefined>;
|
|
21
23
|
export declare const storeAtom: import("jotai").Atom<ApiStore>;
|
|
24
|
+
export declare const definitionAtom: import("jotai").Atom<string | Record<string, unknown> | undefined>;
|
|
25
|
+
export declare const definitionUrlAtom: import("jotai").Atom<string | undefined>;
|
|
22
26
|
export declare const replayDefinitionAtom: import("jotai").Atom<OpenAPIDefinition | null>;
|
|
23
27
|
export declare const setReplayDefinitionAtom: import("jotai").WritableAtom<null, [value: OpenAPIDefinition | null], void> & {
|
|
24
28
|
init: null;
|
package/lib/jotai/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{atom as o}from"jotai";const m={schemaStore:{},exampleStore:{},securitySchemeStore:{}},e=o({items:[],store:m,options:{},replayDefinition:null}),
|
|
1
|
+
import{atom as o}from"jotai";const m={schemaStore:{},exampleStore:{},securitySchemeStore:{}},e=o({items:[],store:m,options:{},replayDefinition:null}),a=o(t=>t(e).items),l=o(t=>{const i={};function s(p){for(const n of p){const r=n.content?.meta?.name;n.httpVerb==="schema"&&r&&n.routeSlug&&(i[r]=n.routeSlug),"items"in n&&Array.isArray(n.items)&&s(n.items)}}return s(t(e).items),i}),f=o(t=>t(e).options),A=o(t=>t(e).options.specType),x=o(t=>t(e).options.basePath),y=o(t=>t(e).options.licenseKey),u=o(t=>t(e).store??m),S=o(t=>t(e).definition),g=o(t=>t(e).definitionUrl),h=o(t=>t(e).replayDefinition),D=o(null,(t,i,s)=>{i(e,{...t(e),replayDefinition:s})});export{S as definitionAtom,g as definitionUrlAtom,a as globalItemsAtom,f as globalOptionsAtom,e as globalStoreAtom,y as licenseKeyAtom,h as replayDefinitionAtom,x as routingBasePathAtom,l as schemaDefinitionSlugMapAtom,D as setReplayDefinitionAtom,A as specTypeAtom,u as storeAtom};
|
package/lib/options/helpers.d.ts
CHANGED
|
@@ -23,4 +23,3 @@ export declare function normalizeDownloadUrls(downloadUrls: {
|
|
|
23
23
|
url: string;
|
|
24
24
|
}[];
|
|
25
25
|
export declare function normalizeLayout(layout: RawApiDocsOptions['layout']): LayoutVariant;
|
|
26
|
-
export declare function isGraphqlDocsSidebarHidden(options: Pick<RawApiDocsOptions, 'specType' | 'sidebar'>): boolean;
|
package/lib/options/helpers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LayoutVariant as
|
|
1
|
+
import{LayoutVariant as i}from"@redocly/config";import{apiSpecType as o}from"../types/common.js";import{DEFAULT_LAYOUT as f}from"./constants.js";import{DEFAULT_LANGUAGES as p,getLangKey as s}from"../utils/languages.js";function d(r,t){return r===void 0?t??!1:typeof r=="string"?r!=="false":r}function A(r,t=0){return typeof r=="string"?parseInt(r,10):typeof r=="number"?r:t}function u(r,t=0){return typeof r=="string"?parseInt(r,10):typeof r=="number"?Math.ceil(r):t}function x(r,t){return r===void 0?t:r==="all"?1/0:u(r,t)}function h(r){let t=r;return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t.startsWith("/")||(t="/"+t),t}function E(r){if(typeof r>"u")return!1;if(r==="")return!0;if(typeof r!="string")return r;switch(r){case"true":return!0;case"false":return!1;default:return r.split(",").map(t=>t.trim()).filter(Boolean)}}function a(r){return/^-?\d+(\.\d+)?$/.test(r)}function T(r){return typeof r=="number"?()=>r:typeof r=="string"&&a(r)?()=>parseFloat(r):typeof r=="function"?()=>{const t=r();return typeof t=="number"?t:0}:()=>0}function L(r){const t=typeof r=="object"&&r!==null?r:{},n=t.languages??p.map(({label:e})=>({lang:e}));return{...t,languages:n.map(e=>({...e,key:s(e),label:e.label??e.lang}))}}function S(r){return Array.isArray(r)?r:typeof r=="string"?r.split(",").map(t=>t.trim()):[]}function b(r,t){return r.map(n=>({...n,title:n.title??m(n.url,t)}))}function m(r,t){const n=r.split("?")[0].split(/[\\/]/).pop();if(n&&["yaml","json","gql","graphql"].some(e=>n.includes(e)))return n;switch(t){case o.OPENAPI:return"openapi.yaml";case o.ASYNCAPI:return"asyncapi.yaml";case o.GRAPHQL:return"graphql.gql";default:return"description.json"}}function N(r){return r===void 0?f:r===i.STACKED?i.STACKED:i.THREE_PANEL}export{d as argValueToBoolean,x as argValueToExpandLevel,u as argValueToInt,A as argValueToNumber,L as normalizeCodeSamples,b as normalizeDownloadUrls,S as normalizeIgnoreNamedSchemas,N as normalizeLayout,h as normalizePath,T as normalizeScrollYOffset,E as normalizeShowExtensions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{addTrailingSlash as r}from"@redocly/theme/core/openapi";import{WindowReferenceOptions as
|
|
1
|
+
import{addTrailingSlash as r}from"@redocly/theme/core/openapi";import{WindowReferenceOptions as t}from"../constants/openapi.js";import{argValueToBoolean as a,argValueToExpandLevel as n,argValueToInt as s,argValueToNumber as m,normalizeCodeSamples as d,normalizeDownloadUrls as p,normalizeIgnoreNamedSchemas as S,normalizeLayout as E,normalizePath as c,normalizeScrollYOffset as u,normalizeShowExtensions as h}from"./helpers.js";import{ASYNCAPI_DEFAULT_JSON_SAMPLES_DEPTH as _,DEFAULT_FEEDBACK as L,DEFAULT_MAX_DISPLAYED_ENUM_VALUES as f,GENERATED_SAMPLES_MAX_DEPTH_DEFAULT as P,GRAPHQL_DEFAULT_FIELD_EXPAND_LEVEL as A,GRAPHQL_DEFAULT_JSON_SAMPLES_DEPTH as D,GRAPHQL_DEFAULT_SAMPLES_MAX_INLINE_ARGS as T,JSON_SAMPLES_EXPAND_LEVEL_DEFAULT as i,MOCK_SERVER_DEFAULT_DESCRIPTION as I,MOCK_SERVER_DEFAULT_POSITION as R,DEFAULT_ROUTING_BASE_PATH as x}from"./constants.js";import{apiSpecType as N}from"../types/common.js";import{EDITION_OPTION_OVERRIDES as k}from"./editionOverrides.js";function v(l){const e={...l,...k},o=e.basePath||e.routingBasePath;return{specType:e.specType,licenseKey:e.licenseKey,metadata:e.metadata??{},downloadUrls:p(e.downloadUrls??[],e.specType),userClaims:e.userClaims,dynamicRequestValues:e.dynamicRequestValues,schemaDefinitionsTagName:e.schemaDefinitionsTagName,corsProxyUrl:e.corsProxyUrl?r(e.corsProxyUrl):void 0,jsonSamplesExpandLevel:n(e.jsonSamplesExpandLevel,i)??i,generatedSamplesMaxDepth:s(e.generatedSamplesMaxDepth,P),hideDownloadButtons:a(e.hideDownloadButtons,!1),hideInfoMetadata:a(e.hideInfoMetadata,!1),hideLoading:a(e.hideLoading,!1),hideSchemaTitles:a(e.hideSchemaTitles,!1),hideSchemaPattern:a(e.hideSchemaPattern,!1),maxDisplayedEnumValues:m(e.maxDisplayedEnumValues,f),mockServer:e.mockServer?.url?{url:e.mockServer.url,position:e.mockServer.position||R,description:e.mockServer.description||I}:void 0,hideReplay:a(e.hideReplay,!1),oAuth2RedirectURI:e.oAuth2RedirectURI,onlyRequiredInSamples:a(e.onlyRequiredInSamples,!1),[t.ON_DEEP_LINK_CLICK]:e.onDeepLinkClick??null,basePath:o?c(o):x,schemasExpansionLevel:n(e.schemasExpansionLevel),feedback:e.feedback??L,sortRequiredPropsFirst:a(e.sortRequiredPropsFirst??e.requiredPropsFirst,!1),scrollYOffset:u(e.scrollYOffset),showExtensions:h(e.showExtensions),sanitize:a(e.sanitize,!1),skipBundle:a(e.skipBundle,!1),ignoreNamedSchemas:new Set(S(e.ignoreNamedSchemas)),markdocOptions:e.markdocOptions,markdownParser:e.markdownParser,codeSamples:d(e.codeSamples),layout:E(e.layout),events:e.events??{},unstable_hooks:e.unstable_hooks??{},unstable_skipSamples:a(e.unstable_skipSamples,!1),unstable_externalCodeSamples:e.unstable_externalCodeSamples??[],hidePropertiesPrefix:a(e?.hidePropertiesPrefix,!1),showSchemaCatalogLinks:a(e?.showSchemaCatalogLinks,!1),jsonSamplesDepth:s(e.jsonSamplesDepth,e.specType===N.ASYNCAPI?_:D),samplesMaxInlineArgs:s(e.samplesMaxInlineArgs,T),fieldExpandLevel:s(e.fieldExpandLevel,A),menu:e.menu,showBuiltInScalars:e.showBuiltInScalars,showBuiltInDirectives:e.showBuiltInDirectives,info:e.info,markdown:e.markdown,apiLogo:e.apiLogo,protocol:e.protocol}}export{v as normalizeOptions};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n({scrollYOffset:e}){const t=e?.()??0;if(!(t<=0))return{"--navbar-height":`${t}px`,"--navbar-stack-height":`${t}px`}}export{n as getStandaloneLayoutStyle};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { OperationInfo } from '../../../types/openapi.js';
|
|
2
|
-
import type { ApiDocsOptions } from '../../../types/options.js';
|
|
2
|
+
import type { ApiDocsOptions, RawApiDocsOptions } from '../../../types/options.js';
|
|
3
3
|
import type { StoreContext } from '../../../types/store.js';
|
|
4
4
|
import type { CodeSampleSource } from '../source.js';
|
|
5
|
+
import type { ReplayNormalizedOpenAPIOperation } from './replay-types.js';
|
|
5
6
|
import type { OpenAPIDefinition } from '../../../types/openapi.js';
|
|
6
7
|
/** Hook to apply adapter-time `configure()` results to a fallback-built `OperationInfo`. */
|
|
7
8
|
export type ApplyConfigureToOperationInfo = (operationInfo: OperationInfo, storeCtx: StoreContext, doc: OpenAPIDefinition) => void;
|
|
@@ -10,3 +11,9 @@ export type ApplyConfigureToOperationInfo = (operationInfo: OperationInfo, store
|
|
|
10
11
|
* Fallback path used by the Replay overlay when the prebuilt source map misses.
|
|
11
12
|
*/
|
|
12
13
|
export declare function buildCodeSampleSourceFromDocument(pathName: string, method: string, doc: OpenAPIDefinition, options: ApiDocsOptions, applyConfigure?: ApplyConfigureToOperationInfo): CodeSampleSource | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Build a Replay `convertOperationToReplayValue` for hosts that have no api-docs store —
|
|
16
|
+
* the standalone Replay desktop app. Resolvers are read back from the store context that
|
|
17
|
+
* {@link buildCodeSampleSourceFromDocument} just populated, so schema and example ids match.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createDocumentReplayConverter(rawOptions: RawApiDocsOptions): (path: string, method: string, document: unknown) => ReplayNormalizedOpenAPIOperation | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createStoreContext as
|
|
1
|
+
import{createStoreContext as O,toRecord as b}from"../../../adapters/helpers.js";import{populateOpenApiStore as R}from"../../../adapters/openapi/store.js";import{buildCodeSampleSource as v}from"../../../adapters/openapi/build-code-sample-source.js";import{normalizeOptions as $}from"../../../options/normalizeOptions.js";import{createCodeSampleResolvers as q}from"../resolvers.js";import{toReplayOperation as j}from"./replay-adapter.js";function w(t,e){if(!t.length&&!e?.length||!t.length)return e;if(!e?.length)return t;const n=new Set(e.map(i=>{const o=i;return`${o.in}:${o.name}`})),s=[...e];for(const i of t){const o=i,r=`${o.in}:${o.name}`;n.has(r)||s.push(i)}return s}let y=null;function C(t,e){if(y?.doc===t)return y.ctx;const n=O(b(t));return R(t,n,e),y={doc:t,ctx:n},n}function I(t,e,n,s,i){const o=n.paths;if(!o||typeof o!="object")return;const r=o[t];if(!r||typeof r!="object")return;const u=e.toLowerCase(),f=r;let p=u,c=f[u],d=!1;if(!c&&u==="query"&&f["x-query"]&&(c=f["x-query"],p="x-query"),!c&&u!=="query"&&r.additionalOperations){const l=r.additionalOperations,m=e in l?e:Object.keys(l).find(g=>g.toLowerCase()===u);m&&(c=l[m],p=m,d=!0)}if(!c||typeof c!="object")return;const a=c,S=r.parameters??[],h={pointer:d?`/paths/${t}/additionalOperations/${p}`:`/paths/${t}/${p}`,pathName:t,httpVerb:e.toUpperCase(),operationId:a.operationId,summary:typeof a.summary=="string"?a.summary:void 0,isWebhook:!1,isAdditionalOperation:d,tags:[],parameters:w(S,a.parameters),requestBody:a.requestBody,servers:a.servers??r.servers,security:a.security},x=C(n,s);return i?.(h,x,n),v(h,x,s.ignoreNamedSchemas,void 0,void 0,s)}function F(t){const e=$(t);return(n,s,i)=>{if(!i||typeof i!="object")return;const o=i;try{const r=I(n,s,o,e);if(!r)return;const u=C(o,e);return j(r,q(u.schemaStore,u.exampleStore,e))}catch(r){console.error("[Replay] createDocumentReplayConverter error:",r);return}}}export{I as buildCodeSampleSourceFromDocument,F as createDocumentReplayConverter};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { buildCodeSampleSourceFromDocument } from './from-openapi-document.js';
|
|
1
|
+
export { buildCodeSampleSourceFromDocument, createDocumentReplayConverter, } from './from-openapi-document.js';
|
|
2
2
|
export { REPLAY_TRY_IT_LOADING_STATE, type ReplayTryItLoadingState, } from '../constants/try-it-loading-state.js';
|
|
3
3
|
export { createReplayOverlayConverter } from './overlay-converter.js';
|
|
4
4
|
export { createReplayConverter, toReplayOperation } from './replay-adapter.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildCodeSampleSourceFromDocument as o}from"./from-openapi-document.js";import{REPLAY_TRY_IT_LOADING_STATE as
|
|
1
|
+
import{buildCodeSampleSourceFromDocument as o,createDocumentReplayConverter as a}from"./from-openapi-document.js";import{REPLAY_TRY_IT_LOADING_STATE as t}from"../constants/try-it-loading-state.js";import{createReplayOverlayConverter as l}from"./overlay-converter.js";import{createReplayConverter as R,toReplayOperation as f}from"./replay-adapter.js";import{handleReplayParamChange as y}from"./replay-handler.js";import{pickRuntimeConfigureRequestValues as c}from"./merge-configure-into-source.js";import{ReplayCodeSampleHTTPSnippet as T,replayHarToCodeSampleHar as i}from"./har-to-code-sample-har.js";export{t as REPLAY_TRY_IT_LOADING_STATE,T as ReplayCodeSampleHTTPSnippet,o as buildCodeSampleSourceFromDocument,a as createDocumentReplayConverter,R as createReplayConverter,l as createReplayOverlayConverter,y as handleReplayParamChange,c as pickRuntimeConfigureRequestValues,i as replayHarToCodeSampleHar,f as toReplayOperation};
|
|
@@ -10,5 +10,6 @@ export type LicenseInfo = {
|
|
|
10
10
|
cryptoMissing?: boolean;
|
|
11
11
|
};
|
|
12
12
|
export declare function isHostAllowed(hostname: string, hosts: string[] | boolean | undefined): boolean;
|
|
13
|
+
export declare function isLicenseBypassed(): boolean;
|
|
13
14
|
export declare function parseLicense(key?: string): Promise<LicenseInfo>;
|
|
14
15
|
export default parseLicense;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a="MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMHjNir5fXx/ZXoaEeXQ5XyxbNJ4YJYczoCRdSkL6NLzw1FHnng5Vfcgk5+bvox9QRYRbuk84mA4f2NhywDbXKECAwEAAQ==",o=typeof window<"u"&&(window.crypto||window.msCrypto)||void 0;function u(e){return"then"in e?e:new Promise(t=>{e.oncomplete=n=>{t(n.target.result)}})}function f(e){const t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let i=0,r=e.length;i<r;i++)n[i]=e.charCodeAt(i);return t}function
|
|
1
|
+
const a="MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMHjNir5fXx/ZXoaEeXQ5XyxbNJ4YJYczoCRdSkL6NLzw1FHnng5Vfcgk5+bvox9QRYRbuk84mA4f2NhywDbXKECAwEAAQ==",o=typeof window<"u"&&(window.crypto||window.msCrypto)||void 0;function u(e){return"then"in e?e:new Promise(t=>{e.oncomplete=n=>{t(n.target.result)}})}function f(e){const t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let i=0,r=e.length;i<r;i++)n[i]=e.charCodeAt(i);return t}function c(e){if(typeof TextEncoder<"u")return new TextEncoder().encode(e);const t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}function l(){const e=f(atob(typeof REDOCLY_PUBLIC_KEY<"u"?REDOCLY_PUBLIC_KEY:a));return u(o.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!0,["verify"]))}async function s(e,t){return u(o.subtle.verify({name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},await l(),f(atob(t)),c(e)))}function d(e,t){return t===!0?!0:Array.isArray(t)&&typeof window<"u"?e==="localhost"||e==="127.0.0.1"||e.endsWith(".localhost")||t.find(n=>n===e||e.endsWith("."+n))?!0:!!t.find(n=>{if(n.indexOf("*")!==n.lastIndexOf("*"))return!1;const[i,r]=n.split("*");return!!r&&e.startsWith(i)&&e.endsWith(r)&&r.split(".").length>2}):!1}function p(){return process.env.REDOCLY_FIRST_PARTY==="true"||process.env.NODE_ENV==="development"}async function w(e){if(p())return{valid:!0,allowed:!0};const t=window.location.hostname;if(!e)return t==="localhost"||t==="127.0.0.1"||t.endsWith(".localhost")?{local:!0}:{};const[n,i]=e.split(".");let r;try{if(!await s(atob(n),i))return{valid:!1};r=JSON.parse(atob(n))}catch{return{valid:!1,cryptoMissing:!0}}return r.valid=!0,(!r.e||Date.now()/1e3>r.e)&&(r.expired=!0),r.allowed=d(t,r.h),r}var y=w;export{y as default,d as isHostAllowed,p as isLicenseBypassed,w as parseLicense};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as f}from"@redocly/config";import{nodeTypes as P,contentType as S,schemaKind as E}from"../../types/common.js";import{extractFullText as y}from"../../adapters/utils/markdoc.js";import{appendArraySuffix as D,appendVariantSuffix as g,buildGraphqlSuffix as O,buildOpenApiSectionSuffix as j,makeDeepLink as I}from"../../utils/deep-link.js";const V=10,R="message payload",w="message headers",x=200;function _(k){return k.length>x?`${k.slice(0,x)}\u2026`:k}class G{#a=[];#r;#i;#s;#o;constructor(e,n,t){this.#r=e,this.#i=n,this.#s=t}addItem(e){if(!(!e.link||!e.content))try{switch(e.content.contentType){case S.OVERVIEW:this.#d(e,this.#r);break;case S.GROUP:case S.ITEM:this.#d(e,e.link);break}}catch(n){console.error(`Cannot add item to api-docs search indexer [${e.label}, ${e.link}]:`,n.message)}}#d(e,n){if(!e.content)return;const t=n.startsWith(this.#r+"/")?n.slice(this.#r.length+1):n.split("/").slice(-2).join("/"),r=e.content.children,i=this.#l(r),o=this.#y(r,t),s=e,a={id:n,url:n,title:e.label??"",text:i,path:[],deprecated:e.content.meta?.deprecated,..."httpVerb"in e&&e.httpVerb?{httpMethod:e.httpVerb}:{},..."httpPath"in e&&e.httpPath?{httpPath:e.httpPath}:{},..."badges"in e&&Array.isArray(e.badges)&&e.badges.length?{badges:e.badges}:{},..."isAdditionalOperation"in e&&e.isAdditionalOperation?{isAdditionalOperation:!0}:{},[f]:s[f],...o.length&&{parameters:o}};this.#a.push(a)}#l(e){const n=[],t=r=>{for(const i of r)if(i.nodeType===P.MARKDOC){const o=i;if(this.#h(o.content))continue;const s=y(o.content);s&&n.push(s)}else(i.nodeType===P.CONTAINER||i.nodeType===P.OVERVIEW_SECTION_WRAPPER)&&t(i.children)};return t(e),n.join(" ").trim()}#h(e){let n=!1,t=!1;const r=o=>{o.type==="code"&&o.attributes?.content?n=!0:o.type==="text"&&o.attributes?.content&&(t=!0);for(const s of o.children??[])r(s)},i=Array.isArray(e)?e:[e];for(const o of i)r(o);return n&&!t}#y(e,n){const t={},r=new Set,i=o=>{for(const s of o)if(s.nodeType===P.ITEM){const a=s;if(a[f])continue;this.#m(a,t,n),this.#S(a,t,r,n)}else if(s.nodeType===P.CONTAINER){const a=s;if(a[f])continue;i(a.children)}else s.nodeType===P.OVERVIEW_SECTION_WRAPPER&&i(s.children)};return i(e),Object.values(t)}#m(e,n,t){if(e.parameters?.length)for(const r of e.parameters){if(r[f])continue;const i=this.#g(e.variant),o=this.#k(e.variant),s=r.description?y(r.description):"",a=this.#$(r.schemaId),d={name:r.name,description:s,place:i,mediaType:void 0,type:a,required:r.required??!1,deepLink:this.#c(t,"request",o,void 0,void 0,[r.name]),example:void 0,enum:void 0};n[this.#t(d)]=d}}#t(e){return[...Array.isArray(e.path)?e.path:[],e.name.toString()].join(".")+e.description+e.place}#c(e,n,t,r,i,o){if(!e)return"";const s=o.join("/"),a=[`t=${n}`];return t&&a.push(`in=${t}`),i&&a.push(`c=${i}`),r&&a.push(`ct=${r}`),s&&a.push(`path=${s}`),`/${e}#${e}/${a.join("&")}`.toLowerCase()}#P(e,n,t,r){if(!e)return"";let i="messages";n&&(i+=`&m=${n}`),i+=`&t=${t}`;const o=r.join("/");return o&&(i+=`&path=${o}`),`/${e}#${e}/${i}`.toLowerCase()}#k(e){switch(e){case"query":return"query";case"path":return"path";case"headers":return"header";case"cookies":return"cookie";default:return}}#g(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"}}#$(e){const n=this.#i?.[e];if(!n||n.kind!==E.JSON_SCHEMA)return"unknown";const t=n.data,r=this.#p(t);return this.#f(r)}#f(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"}#S(e,n,t,r){const i=this.#A(e);if(e.graphqlSchema&&Array.isArray(e.graphqlSchema)){this.#I(e.graphqlSchema,i,n,e,r);return}const o=!!this.#i&&!!this.#s;o&&this.#O(e,i,n,t,r);for(const s of e.responses??[])s[f]||(this.#T(s,n,r),o&&this.#b(s,n,r));if(o)for(const s of e.messages??[])s[f]||this.#q(s,n,r)}#O(e,n,t,r,i){const o=n.startsWith("response");if(e.mediaTypeSchemas){const s=Object.entries(e.mediaTypeSchemas),a=s.find(([,d])=>!d[f]);if(a){const[d,c]=a;c.schemaId&&this.#n(c.schemaId,n,d,s.length>1,o,t,[],r,i)}}else e.schemaId&&this.#n(e.schemaId,n,void 0,!1,o,t,[],r,i)}#T(e,n,t){const r=e.description?y(e.description):"",o=[e.summary?y(e.summary):"",r].filter(Boolean).join(" ").trim();if(!o)return;const s={name:e.code,description:o,place:`response ${e.code}`,mediaType:void 0,type:"unknown",required:!1,deepLink:t?I(t,j("response",void 0,e.code)):void 0,example:void 0,enum:void 0};n[this.#t(s)]=s}#b(e,n,t){const r=`response ${e.code} fields`,i=new Set;if(e.mediaTypeContent){const o=Object.entries(e.mediaTypeContent),s=o.find(([,a])=>!a[f]);if(s){const[a,d]=s;d.schemaId&&this.#n(d.schemaId,r,a,o.length>1,!0,n,[],i,t)}}else e.schemaId&&this.#n(e.schemaId,r,e.mediaType,!1,!0,n,[],i,t)}#q(e,n,t){const r=e.description?y(e.description):"",i=e.summary??"",o={name:e.name,description:(r+i).trim(),place:"message",mediaType:void 0,type:"unknown",required:!1,example:void 0,enum:void 0};n[this.#t(o)]=o,this.#o=e.name;const s=new Set;e.schemaId&&this.#n(e.schemaId,R,e.contentType,!1,!1,n,[],s,t),e.headerSchemaId&&this.#n(e.headerSchemaId,w,void 0,!1,!1,n,[],s,t),this.#o=void 0}#A(e){switch(e.variant){case"body":return"request fields";case"responses":return"response fields";case"graphql-fields":return"fields";case"graphql-args":return"arguments";case"return-type":return"return type fields";default:return e.variant??"fields"}}#E(e){return e.variant!=="graphql-args"?e.graphqlTypeName:e.graphqlFieldName?e.graphqlFieldName:e.graphqlTypeName?`@${e.graphqlTypeName}`:void 0}#I(e,n,t,r,i){const o=r.variant==="graphql-args",s=this.#E(r),a=d=>i&&s?I(i,d):void 0;for(const d of e){const c=d.description?y(d.description):"",u=`${s}.${d.name}`,l={name:d.name,description:c,place:n,mediaType:void 0,path:[],type:d.type??"unknown",required:!1,deepLink:a(o?O({t:"argument",path:u,arg:d.name}):O({t:"field",path:u})),example:void 0,enum:void 0};if(t[this.#t(l)]=l,d.args?.length)for(const p of d.args){const m=p.description?y(p.description):"",h={name:p.name,description:m,place:"arguments",mediaType:void 0,path:[d.name],type:p.type??"unknown",required:!1,deepLink:a(O({t:"argument",path:`${u}.${p.name}`,arg:p.name})),example:void 0,enum:void 0};t[this.#t(h)]=h}}}#n(e,n,t,r,i,o,s,a,d=""){const c=this.#i?.[e];if(!c||c.kind!==E.JSON_SCHEMA||c[f])return;const u=c.data,l=r?t:void 0;this.#u(u,n,t,l,i,o,{path:s,linkPath:[...s],depth:0},a,d)}#R(e){const n=e.match(/^response (\d+)/);return n?n[1]:void 0}#p(e){if(e.allOf){const n={};for(const t of e.allOf){const r=t.$ref?this.#e(t.$ref):t;if(r){const i=n.properties,o=n.required;Object.assign(n,r),(i||r.properties)&&(n.properties={...i||{},...r.properties||{}}),(o||r.required)&&(n.required=[...o||[],...r.required||[]])}}return delete n.allOf,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}#e(e){if(!e.startsWith("#/"))return;const n=e.slice(2).split("/");let t=this.#s;for(const r of n){if(t==null||typeof t!="object")return;t=t[r]}return t!=null&&typeof t=="object"?t:void 0}#u(e,n,t,r,i,o,s,a,d=""){if(s.depth>V||e[f])return;const c=(p,m)=>this.#u(p,n,t,r,i,o,m,a,d);if(e.$ref){this.#w(e.$ref,c,s,a);return}if(e.allOf){c(this.#x(e,a),s);return}const u=e.discriminator??e["x-discriminator"];if(u?.propertyName&&!s.inDiscriminatorVariant){this.#W(e,u,c,s);return}const l=e.oneOf??e.anyOf;if(l){this.#C(e,l,c,s,a);return}if(e.if&&(e.then||e.else)){this.#L(e,c,s);return}e.properties&&this.#D(e,c,{place:n,mediaType:t,deepLinkContentType:r,isResponse:i,paramsMap:o,frame:s,visited:a,slug:d}),this.#v(e,c,s,a)}#w(e,n,t,r){if(r.has(e))return;r.add(e);const i=this.#e(e);i&&n(i,t)}#x(e,n){const t={};for(const r of e.allOf??[]){let i=r;if(r.$ref){if(n.has(r.$ref))continue;n.add(r.$ref),i=this.#e(r.$ref)}if(i){const o=t.properties,s=t.required;Object.assign(t,i),(o||i.properties)&&(t.properties={...o||{},...i.properties||{}}),(s||i.required)&&(t.required=[...s||[],...i.required||[]])}}return delete t.allOf,t}#C(e,n,t,r,i){e.properties&&t({...e,oneOf:void 0,anyOf:void 0},{...r,linkPath:g(r.linkPath,"&oneof=0")}),n.forEach((o,s)=>{if(o.$ref){if(i.has(o.$ref))return;i.add(o.$ref)}const a=o.$ref?this.#e(o.$ref):o;a&&t(a,{...r,linkPath:g(r.linkPath,`&oneof=${s}`),depth:r.depth+1})})}#L(e,n,t){const{if:r,then:i,else:o,...s}=e;[{allOf:[s,i??{},r??{}]},{allOf:[s,o??{}]}].forEach((d,c)=>{n(d,{...t,linkPath:g(t.linkPath,`&oneof=${c}`),depth:t.depth+1})})}#D(e,n,t){const{isResponse:r,paramsMap:i,frame:o,visited:s}=t,a=e.required||[],d=this.#R(t.place),c=r?"response":"request",u=t.place===R?"payload":t.place===w?"headers":void 0,l={requiredList:a,responseCode:d,type:c,asyncSubsection:u,...t};for(const[p,m]of Object.entries(e.properties??{})){if(m[f])continue;const h=this.#j(m,s);if(!h)continue;const C=this.#V(h,s),$=this.#p(h);if(!this.#_(h,$,r))continue;const T=p===o.discriminatorPropertyName,L=[...o.path,p],b=this.#F(p,T,o),q=this.#M(p,h,$,b,l),A=this.#t(q);i[A]==null&&(i[A]=q,!C&&!T&&n($,{path:L,linkPath:b,depth:o.depth+1}))}}#j(e,n){if(!e.$ref)return e;if(!n.has(e.$ref))return n.add(e.$ref),this.#e(e.$ref)}#V(e,n){if(!e.allOf)return!1;let t=!1;for(const r of e.allOf)r.$ref?n.has(r.$ref)||(n.add(r.$ref),t=!0):t=!0;return!t}#_(e,n,t){return!(e[f]||n[f]||n.readOnly&&!t||n.writeOnly&&t||e.additionalProperties!==void 0&&!e.properties)}#F(e,n,t){return[...n&&t.discriminatorLinkPath?t.discriminatorLinkPath:t.linkPath,e]}#M(e,n,t,r,i){const o=n.description??t.description,s=o?y(o):"",a=n.example??t.example,d=a!==void 0?_(typeof a=="string"?a:JSON.stringify(a)):void 0,c=Array.isArray(t.enum)&&t.enum.length?t.enum:void 0;return{name:e,description:s,place:i.place,mediaType:i.mediaType,path:i.frame.path,type:this.#f(t),required:i.requiredList.includes(e),deepLink:i.asyncSubsection?this.#P(i.slug,this.#o,i.asyncSubsection,r):this.#c(i.slug,i.type,void 0,i.deepLinkContentType,i.responseCode,r),example:d,enum:c}}#v(e,n,t,r){if(!e.items||typeof e.items!="object"||Array.isArray(e.items))return;if(e.items.$ref){if(r.has(e.items.$ref))return;r.add(e.items.$ref)}const i=e.items.$ref?this.#e(e.items.$ref):e.items;i&&n(i,{...t,linkPath:D(t.linkPath),depth:t.depth+1})}#W(e,n,t,r){const i=this.#G(e,n),o=s=>({...r,linkPath:g(r.linkPath,`&d=${s}`),inDiscriminatorVariant:!0,discriminatorPropertyName:n.propertyName,discriminatorLinkPath:r.linkPath});e.properties&&t({...e,discriminator:void 0,"x-discriminator":void 0,oneOf:void 0,anyOf:void 0},i.length?o(0):r),i.forEach((s,a)=>{t(s,{...o(a),depth:r.depth+1})})}#G(e,n){const t=e.oneOf??e.anyOf??[],r=Object.values(n.mapping??{});if(r.length===0)return t;const i=s=>t.find(a=>a.$ref===s||a["x-original-ref"]===s)??this.#e(s)??{},o=r.filter(s=>s!==n.defaultMapping).map(i);return n.defaultMapping&&o.push(i(n.defaultMapping)),o}getResult(){return this.#a}}export{G as ApiDocsSearchIndexer};
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as f}from"@redocly/config";import{nodeTypes as P,contentType as S,schemaKind as E}from"../../types/common.js";import{extractFullText as y}from"../../adapters/utils/markdoc.js";import{toElementId as D}from"../../utils/url.js";import{appendArraySuffix as j,appendVariantSuffix as $,buildGraphqlSuffix as O,buildOpenApiSectionSuffix as V,makeDeepLink as I}from"../../utils/deep-link.js";const _=10,R="message payload",w="message headers",x=200;function F(k){return k.length>x?`${k.slice(0,x)}\u2026`:k}class H{#a=[];#i;#r;#s;#o;constructor(e,n,t){this.#i=e,this.#r=n,this.#s=t}addItem(e){if(!(!e.link||!e.content))try{switch(e.content.contentType){case S.OVERVIEW:this.#d(e,this.#i);break;case S.GROUP:case S.ITEM:this.#d(e,e.link);break}}catch(n){console.error(`Cannot add item to api-docs search indexer [${e.label}, ${e.link}]:`,n.message)}}#d(e,n){if(!e.content)return;const t=D(n,this.#i)??"",r=e.content.children,i=this.#l(r),o=this.#y(r,t),s=e,a={id:n,url:n,title:e.label??"",text:i,path:[],deprecated:e.content.meta?.deprecated,..."httpVerb"in e&&e.httpVerb?{httpMethod:e.httpVerb}:{},..."httpPath"in e&&e.httpPath?{httpPath:e.httpPath}:{},..."badges"in e&&Array.isArray(e.badges)&&e.badges.length?{badges:e.badges}:{},..."isAdditionalOperation"in e&&e.isAdditionalOperation?{isAdditionalOperation:!0}:{},[f]:s[f],...o.length&&{parameters:o}};this.#a.push(a)}#l(e){const n=[],t=r=>{for(const i of r)if(i.nodeType===P.MARKDOC){const o=i;if(this.#h(o.content))continue;const s=y(o.content);s&&n.push(s)}else(i.nodeType===P.CONTAINER||i.nodeType===P.OVERVIEW_SECTION_WRAPPER)&&t(i.children)};return t(e),n.join(" ").trim()}#h(e){let n=!1,t=!1;const r=o=>{o.type==="code"&&o.attributes?.content?n=!0:o.type==="text"&&o.attributes?.content&&(t=!0);for(const s of o.children??[])r(s)},i=Array.isArray(e)?e:[e];for(const o of i)r(o);return n&&!t}#y(e,n){const t={},r=new Set,i=o=>{for(const s of o)if(s.nodeType===P.ITEM){const a=s;if(a[f])continue;this.#m(a,t,n),this.#S(a,t,r,n)}else if(s.nodeType===P.CONTAINER){const a=s;if(a[f])continue;i(a.children)}else s.nodeType===P.OVERVIEW_SECTION_WRAPPER&&i(s.children)};return i(e),Object.values(t)}#m(e,n,t){if(e.parameters?.length)for(const r of e.parameters){if(r[f])continue;const i=this.#$(e.variant),o=this.#k(e.variant),s=r.description?y(r.description):"",a=this.#g(r.schemaId),d={name:r.name,description:s,place:i,mediaType:void 0,type:a,required:r.required??!1,deepLink:this.#c(t,"request",o,void 0,void 0,[r.name]),example:void 0,enum:void 0};n[this.#t(d)]=d}}#t(e){return[...Array.isArray(e.path)?e.path:[],e.name.toString()].join(".")+e.description+e.place}#c(e,n,t,r,i,o){if(!e)return"";const s=o.join("/"),a=[`t=${n}`];return t&&a.push(`in=${t}`),i&&a.push(`c=${i}`),r&&a.push(`ct=${r}`),s&&a.push(`path=${s}`),`/${e}#${e}/${a.join("&")}`.toLowerCase()}#P(e,n,t,r){if(!e)return"";let i="messages";n&&(i+=`&m=${n}`),i+=`&t=${t}`;const o=r.join("/");return o&&(i+=`&path=${o}`),`/${e}#${e}/${i}`.toLowerCase()}#k(e){switch(e){case"query":return"query";case"path":return"path";case"headers":return"header";case"cookies":return"cookie";default:return}}#$(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"}}#g(e){const n=this.#r?.[e];if(!n||n.kind!==E.JSON_SCHEMA)return"unknown";const t=n.data,r=this.#p(t);return this.#f(r)}#f(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"}#S(e,n,t,r){const i=this.#A(e);if(e.graphqlSchema&&Array.isArray(e.graphqlSchema)){this.#I(e.graphqlSchema,i,n,e,r);return}const o=!!this.#r&&!!this.#s;o&&this.#O(e,i,n,t,r);for(const s of e.responses??[])s[f]||(this.#T(s,n,r),o&&this.#b(s,n,r));if(o)for(const s of e.messages??[])s[f]||this.#q(s,n,r)}#O(e,n,t,r,i){const o=n.startsWith("response");if(e.mediaTypeSchemas){const s=Object.entries(e.mediaTypeSchemas),a=s.find(([,d])=>!d[f]);if(a){const[d,c]=a;c.schemaId&&this.#n(c.schemaId,n,d,s.length>1,o,t,[],r,i)}}else e.schemaId&&this.#n(e.schemaId,n,void 0,!1,o,t,[],r,i)}#T(e,n,t){const r=e.description?y(e.description):"",o=[e.summary?y(e.summary):"",r].filter(Boolean).join(" ").trim();if(!o)return;const s={name:e.code,description:o,place:`response ${e.code}`,mediaType:void 0,type:"unknown",required:!1,deepLink:t?I(t,V("response",void 0,e.code)):void 0,example:void 0,enum:void 0};n[this.#t(s)]=s}#b(e,n,t){const r=`response ${e.code} fields`,i=new Set;if(e.mediaTypeContent){const o=Object.entries(e.mediaTypeContent),s=o.find(([,a])=>!a[f]);if(s){const[a,d]=s;d.schemaId&&this.#n(d.schemaId,r,a,o.length>1,!0,n,[],i,t)}}else e.schemaId&&this.#n(e.schemaId,r,e.mediaType,!1,!0,n,[],i,t)}#q(e,n,t){const r=e.description?y(e.description):"",i=e.summary??"",o={name:e.name,description:(r+i).trim(),place:"message",mediaType:void 0,type:"unknown",required:!1,example:void 0,enum:void 0};n[this.#t(o)]=o,this.#o=e.name;const s=new Set;e.schemaId&&this.#n(e.schemaId,R,e.contentType,!1,!1,n,[],s,t),e.headerSchemaId&&this.#n(e.headerSchemaId,w,void 0,!1,!1,n,[],s,t),this.#o=void 0}#A(e){switch(e.variant){case"body":return"request fields";case"responses":return"response fields";case"graphql-fields":return"fields";case"graphql-args":return"arguments";case"return-type":return"return type fields";default:return e.variant??"fields"}}#E(e){return e.variant!=="graphql-args"?e.graphqlTypeName:e.graphqlFieldName?e.graphqlFieldName:e.graphqlTypeName?`@${e.graphqlTypeName}`:void 0}#I(e,n,t,r,i){const o=r.variant==="graphql-args",s=this.#E(r),a=d=>i&&s?I(i,d):void 0;for(const d of e){const c=d.description?y(d.description):"",u=`${s}.${d.name}`,l={name:d.name,description:c,place:n,mediaType:void 0,path:[],type:d.type??"unknown",required:!1,deepLink:a(o?O({t:"argument",path:u,arg:d.name}):O({t:"field",path:u})),example:void 0,enum:void 0};if(t[this.#t(l)]=l,d.args?.length)for(const p of d.args){const m=p.description?y(p.description):"",h={name:p.name,description:m,place:"arguments",mediaType:void 0,path:[d.name],type:p.type??"unknown",required:!1,deepLink:a(O({t:"argument",path:`${u}.${p.name}`,arg:p.name})),example:void 0,enum:void 0};t[this.#t(h)]=h}}}#n(e,n,t,r,i,o,s,a,d=""){const c=this.#r?.[e];if(!c||c.kind!==E.JSON_SCHEMA||c[f])return;const u=c.data,l=r?t:void 0;this.#u(u,n,t,l,i,o,{path:s,linkPath:[...s],depth:0},a,d)}#R(e){const n=e.match(/^response (\d+)/);return n?n[1]:void 0}#p(e){if(e.allOf){const n={};for(const t of e.allOf){const r=t.$ref?this.#e(t.$ref):t;if(r){const i=n.properties,o=n.required;Object.assign(n,r),(i||r.properties)&&(n.properties={...i||{},...r.properties||{}}),(o||r.required)&&(n.required=[...o||[],...r.required||[]])}}return delete n.allOf,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}#e(e){if(!e.startsWith("#/"))return;const n=e.slice(2).split("/");let t=this.#s;for(const r of n){if(t==null||typeof t!="object")return;t=t[r]}return t!=null&&typeof t=="object"?t:void 0}#u(e,n,t,r,i,o,s,a,d=""){if(s.depth>_||e[f])return;const c=(p,m)=>this.#u(p,n,t,r,i,o,m,a,d);if(e.$ref){this.#w(e.$ref,c,s,a);return}if(e.allOf){c(this.#x(e,a),s);return}const u=e.discriminator??e["x-discriminator"];if(u?.propertyName&&!s.inDiscriminatorVariant){this.#W(e,u,c,s);return}const l=e.oneOf??e.anyOf;if(l){this.#C(e,l,c,s,a);return}if(e.if&&(e.then||e.else)){this.#L(e,c,s);return}e.properties&&this.#D(e,c,{place:n,mediaType:t,deepLinkContentType:r,isResponse:i,paramsMap:o,frame:s,visited:a,slug:d}),this.#v(e,c,s,a)}#w(e,n,t,r){if(r.has(e))return;r.add(e);const i=this.#e(e);i&&n(i,t)}#x(e,n){const t={};for(const r of e.allOf??[]){let i=r;if(r.$ref){if(n.has(r.$ref))continue;n.add(r.$ref),i=this.#e(r.$ref)}if(i){const o=t.properties,s=t.required;Object.assign(t,i),(o||i.properties)&&(t.properties={...o||{},...i.properties||{}}),(s||i.required)&&(t.required=[...s||[],...i.required||[]])}}return delete t.allOf,t}#C(e,n,t,r,i){e.properties&&t({...e,oneOf:void 0,anyOf:void 0},{...r,linkPath:$(r.linkPath,"&oneof=0")}),n.forEach((o,s)=>{if(o.$ref){if(i.has(o.$ref))return;i.add(o.$ref)}const a=o.$ref?this.#e(o.$ref):o;a&&t(a,{...r,linkPath:$(r.linkPath,`&oneof=${s}`),depth:r.depth+1})})}#L(e,n,t){const{if:r,then:i,else:o,...s}=e;[{allOf:[s,i??{},r??{}]},{allOf:[s,o??{}]}].forEach((d,c)=>{n(d,{...t,linkPath:$(t.linkPath,`&oneof=${c}`),depth:t.depth+1})})}#D(e,n,t){const{isResponse:r,paramsMap:i,frame:o,visited:s}=t,a=e.required||[],d=this.#R(t.place),c=r?"response":"request",u=t.place===R?"payload":t.place===w?"headers":void 0,l={requiredList:a,responseCode:d,type:c,asyncSubsection:u,...t};for(const[p,m]of Object.entries(e.properties??{})){if(m[f])continue;const h=this.#j(m,s);if(!h)continue;const C=this.#V(h,s),g=this.#p(h);if(!this.#_(h,g,r))continue;const T=p===o.discriminatorPropertyName,L=[...o.path,p],b=this.#F(p,T,o),q=this.#M(p,h,g,b,l),A=this.#t(q);i[A]==null&&(i[A]=q,!C&&!T&&n(g,{path:L,linkPath:b,depth:o.depth+1}))}}#j(e,n){if(!e.$ref)return e;if(!n.has(e.$ref))return n.add(e.$ref),this.#e(e.$ref)}#V(e,n){if(!e.allOf)return!1;let t=!1;for(const r of e.allOf)r.$ref?n.has(r.$ref)||(n.add(r.$ref),t=!0):t=!0;return!t}#_(e,n,t){return!(e[f]||n[f]||n.readOnly&&!t||n.writeOnly&&t||e.additionalProperties!==void 0&&!e.properties)}#F(e,n,t){return[...n&&t.discriminatorLinkPath?t.discriminatorLinkPath:t.linkPath,e]}#M(e,n,t,r,i){const o=n.description??t.description,s=o?y(o):"",a=n.example??t.example,d=a!==void 0?F(typeof a=="string"?a:JSON.stringify(a)):void 0,c=Array.isArray(t.enum)&&t.enum.length?t.enum:void 0;return{name:e,description:s,place:i.place,mediaType:i.mediaType,path:i.frame.path,type:this.#f(t),required:i.requiredList.includes(e),deepLink:i.asyncSubsection?this.#P(i.slug,this.#o,i.asyncSubsection,r):this.#c(i.slug,i.type,void 0,i.deepLinkContentType,i.responseCode,r),example:d,enum:c}}#v(e,n,t,r){if(!e.items||typeof e.items!="object"||Array.isArray(e.items))return;if(e.items.$ref){if(r.has(e.items.$ref))return;r.add(e.items.$ref)}const i=e.items.$ref?this.#e(e.items.$ref):e.items;i&&n(i,{...t,linkPath:j(t.linkPath),depth:t.depth+1})}#W(e,n,t,r){const i=this.#G(e,n),o=s=>({...r,linkPath:$(r.linkPath,`&d=${s}`),inDiscriminatorVariant:!0,discriminatorPropertyName:n.propertyName,discriminatorLinkPath:r.linkPath});e.properties&&t({...e,discriminator:void 0,"x-discriminator":void 0,oneOf:void 0,anyOf:void 0},i.length?o(0):r),i.forEach((s,a)=>{t(s,{...o(a),depth:r.depth+1})})}#G(e,n){const t=e.oneOf??e.anyOf??[],r=Object.values(n.mapping??{});if(r.length===0)return t;const i=s=>t.find(a=>a.$ref===s||a["x-original-ref"]===s)??this.#e(s)??{},o=r.filter(s=>s!==n.defaultMapping).map(i);return n.defaultMapping&&o.push(i(n.defaultMapping)),o}getResult(){return this.#a}}export{H as ApiDocsSearchIndexer};
|
|
@@ -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};
|