@redocly/api-docs 0.1.0-next.3 → 0.1.0-next.4
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/.tsbuildinfo +1 -1
- package/lib/adapters/openapi/items/operation/content.d.ts +9 -0
- package/lib/adapters/openapi/items/operation/content.js +1 -1
- package/lib/adapters/utils/markdoc.js +1 -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 +19 -19
- package/lib/components/ItemContent/sections/ParametersSection.js +2 -2
- package/lib/components/ItemContent/sections/ResponsesSection.js +8 -8
- package/lib/components/Schema/hooks/useSchemaFieldDeepLink.js +1 -1
- package/lib/components/markdoc/Heading.d.ts +1 -1
- package/lib/components/markdoc/Heading.js +3 -3
- package/lib/components/markdoc/defaultMarkdocConfig.js +1 -1
- package/lib/components/panels/ExampleItem/CallbackPayloadItem.js +2 -2
- package/lib/hooks/useApiDocsScroll.js +1 -1
- package/lib/hooks/useDeepLinkSection.d.ts +11 -4
- package/lib/hooks/useDeepLinkSection.js +1 -1
- package/lib/jotai/app.d.ts +0 -3
- package/lib/jotai/app.js +1 -1
- package/lib/jotai/itemStore.d.ts +1 -0
- package/lib/jotai/itemStore.js +1 -1
- package/lib/utils/deep-link.d.ts +22 -0
- package/lib/utils/deep-link.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import type { ApiItemContent } from '../../../../types/content.js';
|
|
2
2
|
import type { OperationInfo } from '../../../../types/openapi.js';
|
|
3
|
+
/**
|
|
4
|
+
* Callback ids in the legacy openapi-docs shape, `<name>/<verb>`, so links shared from it
|
|
5
|
+
* still resolve. One entry is emitted per url expression, so that pair can repeat within an
|
|
6
|
+
* operation — later duplicates take a `~<n>` suffix, which legacy lacked and collided on.
|
|
7
|
+
*
|
|
8
|
+
* The separator is deliberately not `/`: an id must never be a path-segment prefix of a
|
|
9
|
+
* sibling's, or hash matching would treat `<name>/<verb>` as also naming `<name>/<verb>~1`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createCallbackIdFactory(): (name: string, httpVerb: string) => string;
|
|
3
12
|
export declare function buildItemContent(operationInfo: OperationInfo, pageSlug: string): ApiItemContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as ee}from"@redocly/config";import{contentType as je,itemVariant as Ne,nodeTypes as u,panelKind as le,schemaKind as H}from"../../../../types/common.js";import{readRbacScope as T,rbacProp as O,registerExample as te,registerSchema as K,resolveContent as pe,resolveRef as D}from"../../../helpers.js";import{applyIgnoreNamedSchemasDeep as Te}from"../../utils/applyIgnoreNamedSchemasDeep.js";import{isStatusCode as Pe}from"../../../../utils/status-code.js";import{parseMarkdown as F}from"../../../utils/parseMarkdown.js";import{extractDescriptionSegments as $e,resolveMarkdocHeadingIds as me}from"../../../utils/markdoc.js";import{getExtensionsForDisplay as ue}from"../../../../utils/extract-extensions.js";import{openApiContext as _}from"../../buildContext.js";import{buildCodeSampleSource as De}from"../../build-code-sample-source.js";import{mergeInMockServer as Be,pickOperationServers as He}from"../../utils/merge-mock-server.js";import{normalizePath as Ke,toRelativePath as Ee}from"../../../../utils/url.js";import{encodeJsonPointerSegment as B}from"../../../../utils/refPointer.js";import{hasOpenApiExampleValue as ge,resolveOpenApiExampleValue as ye}from"../../resolve-openapi-example-value.js";const se="request",ke="responses";function it(e,n){const{options:i,storeCtx:c,basePath:s}=_.get(),t=e.summary||e.operationId||e.pathName||"Unknown Operation",r=[],{feedback:y}=i,d=e.isWebhook||!1,p=[{nodeType:u.HEADER,level:2,label:t,badges:e["x-badges"],isWebhook:d,deprecated:e.deprecated,showPageActions:!0}],o=ue(e,i.showExtensions);Object.keys(o).length>0&&p.push({nodeType:u.EXTENSIONS,extensions:o}),r.push({nodeType:u.CONTAINER,children:p,panels:[]});const m=i.ignoreNamedSchemas,f=e["x-codeSamples"]?.map(({lang:a,label:x,source:h})=>({lang:a,label:x,source:h})),S=He(e.servers,c?.document?.servers),E=Be(S.filter(a=>typeof a?.url=="string"),i.mockServer).map(a=>{const x=T(a);return{url:a.url??"",name:a.name,description:typeof a.description=="string"?a.description:void 0,...a.isMockServer&&{isMockServer:!0},variables:a.variables&&Object.keys(a.variables).length>0?Object.fromEntries(Object.entries(a.variables).map(([h,M])=>[h,{default:M.default}])):void 0,...O(x)}}),b=Oe(e,m),R=Ee(n,s);let l=[];e.description&&(me(e.description,R,se),l=$e(e.description,i));const A=l.some(a=>a.kind==="schemaDefinition"),g=b.find(a=>a.nodeType===u.ITEM&&a.variant==="body"),v=Fe(e,m,d,R||void 0),j=g?.schemaId,q=g?.mediaTypes,N=g?.mediaTypeSchemas,$=T(g),C=[{children:[{kind:le.CODE_SAMPLE,source:v,definitionSamples:f?.length?f:void 0,isWebhook:d,hideReplay:e["x-hideReplay"]===!0,servers:E?.length?E:void 0,schemaId:j,exampleIds:g?.exampleIds,mediaTypes:q,mediaTypeSchemas:N,examples:g?.exampleIds?.map(()=>({}))??[]}],...O($)}];if(b.length>0||l.length>0)if(A){r.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:se}],panels:[]});for(const a of l)a.kind==="schemaDefinition"?r.push(a.node):r.push({nodeType:u.CONTAINER,children:[a.node],panels:[]});r.push({nodeType:u.CONTAINER,children:[...b],panels:C})}else r.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:se},...l.map(a=>a.node),...b],panels:C});else r.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:se},{nodeType:u.EMPTY_MESSAGE,label:"No request data",labelTranslationKey:"noRequestData"}],panels:C});if(e.responses){const a=Re(e,i,R,m);if(a){const x=a.responses?.some(k=>k.schemaId||(k.exampleIds?.length??0)>0),h=a?.responses?.map(k=>{const re=k[ee];return{code:k.code,schemaId:k.schemaId,exampleIds:k.exampleIds,mediaTypes:k.mediaTypes,mediaTypeContent:k.mediaTypeContent,...O(re)}}),M=[];x&&M.push({children:[{kind:le.RESPONSE,headerTitle:"Response",responseCodes:h,examples:[]}]});const U=T(e.responses);r.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Responses",labelTranslationKey:"responses",deepLinkSuffix:"responses"},a],panels:M.length>0?M:[],...O(U)})}}if(Array.isArray(e.callbacks)&&e.callbacks.length>0){r.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Callbacks",labelTranslationKey:"callbacks",deepLinkSuffix:"callbacks"}],panels:[]});let a=0;for(const x of e.callbacks)if(x.operations)for(const h of x.operations){const M=h.httpVerb??"post",U=`${x.name}/${M}/${a}`,k={pointer:e.pointer+"/callbacks/"+x.name+"/"+M,pathName:h.pathName??x.url??"",httpVerb:M,summary:h.summary,deprecated:h.deprecated,isWebhook:!1,isAdditionalOperation:!1,tags:[],parameters:h.parameters,requestBody:h.requestBody,responses:h.responses,servers:h.servers,security:h.security},re=Oe(k,m),he=Re(k,i,`${R}/callbacks/${U}`,m),oe=[...re];he&&oe.push(he);const ie=h.externalDocs,fe=ue(h,i.showExtensions),Ae={httpVerb:M,pathName:k.pathName,summary:k.summary,operationId:typeof h.operationId=="string"?h.operationId:void 0,description:h.description?F(h.description,i):void 0,deprecated:k.deprecated,callbackName:x.name,callbackId:U,externalDocs:ie?{url:ie.url,description:ie.description}:void 0,extensions:Object.keys(fe).length>0?fe:void 0,contentChildren:oe.length>0?oe:void 0},be=[];if(h.requestBody&&"content"in h.requestBody){const ce=c?.document??{},qe=D(ce,h.requestBody,m)??h.requestBody,ae=pe(ce,qe,m);if(ae){const xe=Object.keys(ae);let X=!1;const de={};for(const[W,P]of Object.entries(ae)){let Q;if(P.schema){const V=P.schema;Q=K(c.schemaStore,c.hashIndex,{kind:H.JSON_SCHEMA,data:V})}const G=`${k.pointer}/requestBody/content/${B(W)}`.replace(/^\//,""),L=[];if(P.example!==void 0){const V=te(c.exampleStore,{value:P.example,id:`${G}/example`});L.push(V),X=!0}if(P.examples)for(const[V,Ie]of Object.entries(P.examples)){const Z=D(ce,Ie,m);if(Z&&ge(Z)){const Me=te(c.exampleStore,{value:ye(Z),summary:Z.summary??V,id:`${G}/examples/${B(V)}`});L.push(Me),X=!0}}de[W]={schemaId:Q,exampleIds:L.length>0?L:void 0},Q&&(X=!0)}const Se=h["x-codeSamples"];if(X||(Se?.length??0)>0){const W=h.servers?.filter(P=>P.url).map(({url:P,name:Q,description:G,variables:L})=>({url:P,name:Q,description:G,variables:L}));be.push({children:[{kind:le.CALLBACK_PAYLOAD,callbackName:U,path:k.pathName,httpVerb:M,servers:W?.length?W:void 0,definitionSamples:Se,mediaTypes:xe.length>0?xe:void 0,mediaTypeSchemas:Object.keys(de).length>0?de:void 0,examples:[]}]})}}}const ve=T(x);r.push({nodeType:u.CONTAINER,children:[{nodeType:u.ITEM,variant:"callback",callback:Ae,pointer:e.pointer+"/callbacks"}],panels:be,...O(ve)}),a++}}y?.hide!==!0&&r.push({nodeType:u.CONTAINER,children:[{nodeType:u.FEEDBACK,pageSlug:Ke(Ee(n,s))}],panels:[]});const w=b.some(a=>{const x=a;return x.variant==="body"&&((x.exampleIds?.length??0)>0||!!x.schemaId)})||(f?.length??0)>0;return{contentType:je.ITEM,itemVariant:Ne.HTTP_ITEM,seo:e["x-seo"],meta:{sourceId:e.operationId,name:t,deprecated:e.deprecated,isWebhook:e.isWebhook||!1,pointer:e.pointer,hasSamples:w},children:r}}function _e(e,n,i){const c=D(n,e,i)??e,{$ref:s,...t}=e,r=typeof s=="string"?{...c,...t}:c;return Te(r,i)}function Y(e,n,i){if(!e||typeof e!="object")return;const c=e,s=D(n,c,i)??c;return Te(s,i)}function we(e,n,i){if(!e||typeof e!="object")return;const c=T(e),s={},t=[];for(const[r,y]of Object.entries(e)){if(r===ee)continue;const d=D(n,y,i)??y,p=d.content,o=p?p[Object.keys(p)[0]]:void 0,m=d.schema??o?.schema??o?.itemSchema,f=Y(m,n,i);if(!f)continue;const S=Ce(d.examples,n,i),E=T(y)??T(d)??c;s[r]={...f,...d.description!==void 0&&{description:d.description},...d.example!==void 0&&{example:d.example},...S&&{examples:S},...O(E)},d.required&&t.push(r)}if(Object.keys(s).length!==0)return{type:"object",properties:s,...t.length>0?{required:t}:{}}}function Le(e){if(typeof e=="string"||e&&typeof e=="object"&&"$$mdtype"in e||Array.isArray(e)&&e.length>0&&e.every(n=>!!n&&typeof n=="object"&&"$$mdtype"in n))return e}function z(e,n){const{storeCtx:i,options:c}=_.get(),s=i.document;return e.map(t=>{const r=t.schema;let y={};if(r&&typeof r=="object")y=r;else if(t.content&&typeof t.content=="object"){const S=t.content,E=Object.keys(S)[0],b=E?S[E]?.schema:void 0;b&&typeof b=="object"&&(y=b)}const d=K(i.schemaStore,i.hashIndex,{kind:H.JSON_SCHEMA,data:y}),p=t["x-badges"],o=y["x-badges"],m=Array.isArray(p)?p:Array.isArray(o)?o:void 0,f=ue(t,c.showExtensions);return{name:String(t.name??""),in:typeof t.in=="string"?t.in:void 0,schemaId:d,description:Le(t.description),required:t.required===!0?!0:void 0,deprecated:t.deprecated===!0?!0:void 0,example:t.example,examples:Ce(t.examples,s,n),...m?.length?{badges:m}:{},...Object.keys(f).length?{extensions:f}:{},...O(T(t))}})}function Ce(e,n,i){if(!e||typeof e!="object")return;const c={};for(const[s,t]of Object.entries(e)){if(!t||typeof t!="object")continue;const r=D(n,t,i)??t;if(!ge(r))continue;const y=ye(r);c[s]={...typeof r.summary=="string"&&{summary:r.summary},...typeof r.description=="string"&&{description:r.description},...y!==void 0&&{value:typeof y=="string"?y:JSON.stringify(y)}}}return Object.keys(c).length>0?c:void 0}function Oe(e,n){const{storeCtx:i,options:c}=_.get(),s=[],t=i.document,r=Ve(e);if(r&&s.push(r),e.parameters&&Array.isArray(e.parameters)){const d=e.parameters.map(l=>_e(l,t,n)),p=d.filter(l=>l.in==="header"),o=d.filter(l=>l.in==="query"),m=d.filter(l=>l.in==="path"),f=d.filter(l=>l.in==="cookie"),S=d.filter(l=>l.in==="querystring"),E=S.filter(l=>!l.content||typeof l.content!="object"),b=S.filter(l=>l.content&&typeof l.content=="object"),R=S.length>0;m.length>0&&s.push({nodeType:u.ITEM,variant:"path",label:"Path",labelTranslationKey:"path",parameters:z(m,n),pointer:e.pointer+"/parameters"}),o.length>0&&!R&&s.push({nodeType:u.ITEM,variant:"query",label:"Query",labelTranslationKey:"query",parameters:z(o,n),pointer:e.pointer+"/parameters"}),E.length>0&&s.push({nodeType:u.ITEM,variant:"querystring",label:"Query String",labelTranslationKey:"querystring",parameters:z(E,n),pointer:e.pointer+"/parameters"});for(const l of b){const A=l.content,g=Object.keys(A),v={};for(const $ of g){const C=A[$];if(!C)continue;let I;const J=C.itemSchema,w=C.schema??J,a=Y(w,t,n);a&&(I=K(i.schemaStore,i.hashIndex,{kind:H.JSON_SCHEMA,data:a}));const x=ne(C,n);v[$]={schemaId:I,exampleIds:x,...O(T(w))}}const j=g[0],q=j?v[j]:void 0,N=F(l.description,c);s.push({nodeType:u.ITEM,variant:"querystring-body",label:String(l.name??""),required:l.required===!0?!0:void 0,mediaTypes:g.length>0?g:void 0,mediaTypeSchemas:Object.keys(v).length>0?v:void 0,schemaId:q?.schemaId,exampleIds:q?.exampleIds,pointer:e.pointer+"/parameters",...N!==void 0?{description:N}:{},...O(T(l))})}f.length>0&&s.push({nodeType:u.ITEM,variant:"cookies",label:"Cookies",labelTranslationKey:"cookie",parameters:z(f,n),pointer:e.pointer+"/parameters"}),p.length>0&&s.push({nodeType:u.ITEM,variant:"headers",label:"Headers",labelTranslationKey:"header",parameters:z(p,n),pointer:e.pointer+"/parameters"})}if(e.requestBody){const y=D(t,e.requestBody,n)??e.requestBody,d=pe(t,y,n),p=d?Object.keys(d):void 0;let o,m,f;if(d&&p){f={};for(const l of p){const A=d[l];if(!A)continue;let g;const v=A.itemSchema,j=A.schema??v,q=Y(j,t,n);q&&(g=K(i.schemaStore,i.hashIndex,{kind:H.JSON_SCHEMA,data:q}));const N=ne(A,n,`${e.pointer}/requestBody/content/${B(l)}`);f[l]={schemaId:g,exampleIds:N,...O(T(j))}}const b=p[0],R=b?f[b]:void 0;o=R?.schemaId,m=R?.exampleIds}const S=F(y.description,c),E=T(e.requestBody)??T(y);s.push({nodeType:u.ITEM,variant:"body",label:"Request Body",labelTranslationKey:"body",required:y.required,mediaTypes:p,mediaTypeSchemas:f,schemaId:o,exampleIds:m,pointer:e.pointer+"/requestBody",...S!==void 0?{description:S}:{},...O(E)})}return s}function Re(e,n,i,c){if(!e.responses)return;const{storeCtx:s}=_.get(),t=s?.document??{},r=e.responses,d=Object.entries(r).filter(([p])=>Pe(p)).map(([p,o])=>{const m=D(t,o,c)??o;let f=T(o)??T(m);const S=pe(t,m,c),E=S?Object.keys(S):[],b=E[0],R=b&&S?S[b]:void 0;let l,A,g,v;if(S&&E.length>0){v={};for(const C of E){const I=S[C];if(!I)continue;let J;const w=I.itemSchema,a=I.schema??w,x=Y(a,t,c);x&&(J=K(s.schemaStore,s.hashIndex,{kind:H.JSON_SCHEMA,data:x}));const h=ne(I,c,`${e.pointer}/responses/${B(p)}/content/${B(C)}`);v[C]={schemaId:J,exampleIds:h,...O(T(a))}}const $=b?v[b]:void 0;l=$?.schemaId,A=$?.exampleIds}else if(R){const $=R.itemSchema,C=R.schema??$,I=Y(C,t,c);I&&(f=f??T(C),l=K(s.schemaStore,s.hashIndex,{kind:H.JSON_SCHEMA,data:I})),A=ne(R,c,b?`${e.pointer}/responses/${B(p)}/content/${B(b)}`:void 0)}const j=we(m.headers,t,c);j&&(g=K(s.schemaStore,s.hashIndex,{kind:H.JSON_SCHEMA,data:j}));let q;m.description&&(q=F(m.description,n),me(q??[],i,`${ke}/${p}`));const N=m["x-summary"]?F(m["x-summary"],n):void 0;return N&&me(N,i,`${ke}/${p}/summary`),{code:p,summary:N,description:q,mediaType:b,mediaTypes:E.length>0?E:void 0,mediaTypeContent:v,schemaId:l,exampleIds:A,headers:m.headers,headerSchemaId:g,...O(f)}});return{nodeType:u.ITEM,variant:"responses",responses:d,pointer:e.pointer+"/responses"}}function ne(e,n,i){const{storeCtx:c}=_.get(),s=[],t=c.document,r=i?.replace(/^\//,"");if(e.example!==void 0){const y=te(c.exampleStore,{value:e.example,...r&&{id:`${r}/example`}});s.push(y)}if(e.examples&&typeof e.examples=="object"){const y=T(e.examples);for(const[d,p]of Object.entries(e.examples)){if(d===ee||!p||typeof p!="object")continue;const o=D(t,p,n)??p,m=T(p)??T(o)??y,f=te(c.exampleStore,{value:ye(o),key:d,summary:typeof o.summary=="string"?o.summary:d,description:typeof o.description=="string"?o.description:void 0,externalValue:typeof o.externalValue=="string"?o.externalValue:void 0,...O(m),...r&&{id:`${r}/examples/${B(d)}`}});s.push(f)}}return s.length>0?s:void 0}function Ve(e){const{storeCtx:n,options:i}=_.get();if(!e.security||!Array.isArray(e.security)||e.security.length===0)return;const c=e.security.map(s=>{const t=Object.entries(s);if(t.length===0)return null;const r=n?.document?.components?.securitySchemes,y=t.map(([d,p])=>{const o=n?.securitySchemeStore[d],m=T(r?.[d])??o?.[ee];return{name:d,scopes:Array.isArray(p)?p:void 0,type:o?.type,scheme:o?.scheme,bearerFormat:o?.bearerFormat,in:o?.in,paramName:o?.paramName,description:o?.description?F(o.description,i):o?.description,openIdConnectUrl:o?.openIdConnectUrl,oauth2MetadataUrl:o?.oauth2MetadataUrl,deprecated:o?.deprecated,flows:o?.flows,...O(m)}}).filter(d=>d.name);return y.length>0?{schemes:y}:null}).filter(s=>s!==null);if(c.length!==0)return{nodeType:u.SECURITY,requirements:c}}function Fe(e,n,i,c){const{storeCtx:s,options:t}=_.get();if(!s)throw new Error("OpenAPI store context is not initialized");return De(e,s,t,n,i,c)}export{it as buildItemContent};
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as ee}from"@redocly/config";import{contentType as Ne,itemVariant as $e,nodeTypes as u,panelKind as me,schemaKind as H}from"../../../../types/common.js";import{readRbacScope as T,rbacProp as R,registerExample as te,registerSchema as _,resolveContent as ue,resolveRef as D}from"../../../helpers.js";import{applyIgnoreNamedSchemasDeep as Ee}from"../../utils/applyIgnoreNamedSchemasDeep.js";import{isStatusCode as Pe}from"../../../../utils/status-code.js";import{parseMarkdown as V}from"../../../utils/parseMarkdown.js";import{extractDescriptionSegments as De,resolveMarkdocHeadingIds as se}from"../../../utils/markdoc.js";import{getExtensionsForDisplay as ye}from"../../../../utils/extract-extensions.js";import{openApiContext as K}from"../../buildContext.js";import{buildCodeSampleSource as Be}from"../../build-code-sample-source.js";import{mergeInMockServer as He,pickOperationServers as _e}from"../../utils/merge-mock-server.js";import{normalizePath as Ke,toRelativePath as ge}from"../../../../utils/url.js";import{encodeJsonPointerSegment as B}from"../../../../utils/refPointer.js";import{hasOpenApiExampleValue as ke,resolveOpenApiExampleValue as he}from"../../resolve-openapi-example-value.js";const ne="request",Ce="responses",we="callbacks";function Le(){const e=new Map;return(r,o)=>{const n=`${r}/${o}`,t=e.get(n)??0;return e.set(n,t+1),t===0?n:`${n}~${t}`}}function dt(e,r){const{options:o,storeCtx:n,basePath:t}=K.get(),s=e.summary||e.operationId||e.pathName||"Unknown Operation",c=[],{feedback:y}=o,a=e.isWebhook||!1,p=[{nodeType:u.HEADER,level:2,label:s,badges:e["x-badges"],isWebhook:a,deprecated:e.deprecated,showPageActions:!0}],i=ye(e,o.showExtensions);Object.keys(i).length>0&&p.push({nodeType:u.EXTENSIONS,extensions:i}),c.push({nodeType:u.CONTAINER,children:p,panels:[]});const m=o.ignoreNamedSchemas,f=e["x-codeSamples"]?.map(({lang:d,label:x,source:h})=>({lang:d,label:x,source:h})),S=_e(e.servers,n?.document?.servers),E=He(S.filter(d=>typeof d?.url=="string"),o.mockServer).map(d=>{const x=T(d);return{url:d.url??"",name:d.name,description:typeof d.description=="string"?d.description:void 0,...d.isMockServer&&{isMockServer:!0},variables:d.variables&&Object.keys(d.variables).length>0?Object.fromEntries(Object.entries(d.variables).map(([h,M])=>[h,{default:M.default}])):void 0,...R(x)}}),b=Re(e,m),C=ge(r,t);let l=[];e.description&&(se(e.description,C,ne),l=De(e.description,o));const A=l.some(d=>d.kind==="schemaDefinition"),g=b.find(d=>d.nodeType===u.ITEM&&d.variant==="body"),v=We(e,m,a,C||void 0),j=g?.schemaId,I=g?.mediaTypes,N=g?.mediaTypeSchemas,P=T(g),O=[{children:[{kind:me.CODE_SAMPLE,source:v,definitionSamples:f?.length?f:void 0,isWebhook:a,hideReplay:e["x-hideReplay"]===!0,servers:E?.length?E:void 0,schemaId:j,exampleIds:g?.exampleIds,mediaTypes:I,mediaTypeSchemas:N,examples:g?.exampleIds?.map(()=>({}))??[]}],...R(P)}];if(b.length>0||l.length>0)if(A){c.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:ne}],panels:[]});for(const d of l)d.kind==="schemaDefinition"?c.push(d.node):c.push({nodeType:u.CONTAINER,children:[d.node],panels:[]});c.push({nodeType:u.CONTAINER,children:[...b],panels:O})}else c.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:ne},...l.map(d=>d.node),...b],panels:O});else c.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:ne},{nodeType:u.EMPTY_MESSAGE,label:"No request data",labelTranslationKey:"noRequestData"}],panels:O});if(e.responses){const d=Ae(e,o,C,m);if(d){const x=d.responses?.some(k=>k.schemaId||(k.exampleIds?.length??0)>0),h=d?.responses?.map(k=>{const oe=k[ee];return{code:k.code,schemaId:k.schemaId,exampleIds:k.exampleIds,mediaTypes:k.mediaTypes,mediaTypeContent:k.mediaTypeContent,...R(oe)}}),M=[];x&&M.push({children:[{kind:me.RESPONSE,headerTitle:"Response",responseCodes:h,examples:[]}]});const L=T(e.responses);c.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Responses",labelTranslationKey:"responses",deepLinkSuffix:"responses"},d],panels:M.length>0?M:[],...R(L)})}}if(Array.isArray(e.callbacks)&&e.callbacks.length>0){c.push({nodeType:u.CONTAINER,children:[{nodeType:u.HEADER,level:4,label:"Callbacks",labelTranslationKey:"callbacks",deepLinkSuffix:"callbacks"}],panels:[]});const d=Le();for(const x of e.callbacks)if(x.operations)for(const h of x.operations){const M=h.httpVerb??"post",L=d(x.name,M),k={pointer:e.pointer+"/callbacks/"+x.name+"/"+M,pathName:h.pathName??x.url??"",httpVerb:M,summary:h.summary,deprecated:h.deprecated,isWebhook:!1,isAdditionalOperation:!1,tags:[],parameters:h.parameters,requestBody:h.requestBody,responses:h.responses,servers:h.servers,security:h.security},oe=Re(k,m),fe=Ae(k,o,`${C}/callbacks/${L}`,m),ce=[...oe];fe&&ce.push(fe);const ie=h.externalDocs,be=ye(h,o.showExtensions);let ae;h.description&&(ae=V(h.description,o),se(ae??[],C,`${we}/${L}`));const ve={httpVerb:M,pathName:k.pathName,summary:k.summary,operationId:typeof h.operationId=="string"?h.operationId:void 0,description:ae,deprecated:k.deprecated,callbackName:x.name,callbackId:L,externalDocs:ie?{url:ie.url,description:ie.description}:void 0,extensions:Object.keys(be).length>0?be:void 0,contentChildren:ce.length>0?ce:void 0},xe=[];if(h.requestBody&&"content"in h.requestBody){const de=n?.document??{},qe=D(de,h.requestBody,m)??h.requestBody,le=ue(de,qe,m);if(le){const Se=Object.keys(le);let z=!1;const pe={};for(const[W,$]of Object.entries(le)){let Q;if($.schema){const U=$.schema;Q=_(n.schemaStore,n.hashIndex,{kind:H.JSON_SCHEMA,data:U})}const G=`${k.pointer}/requestBody/content/${B(W)}`.replace(/^\//,""),F=[];if($.example!==void 0){const U=te(n.exampleStore,{value:$.example,id:`${G}/example`});F.push(U),z=!0}if($.examples)for(const[U,Me]of Object.entries($.examples)){const Z=D(de,Me,m);if(Z&&ke(Z)){const je=te(n.exampleStore,{value:he(Z),summary:Z.summary??U,id:`${G}/examples/${B(U)}`});F.push(je),z=!0}}pe[W]={schemaId:Q,exampleIds:F.length>0?F:void 0},Q&&(z=!0)}const Te=h["x-codeSamples"];if(z||(Te?.length??0)>0){const W=h.servers?.filter($=>$.url).map(({url:$,name:Q,description:G,variables:F})=>({url:$,name:Q,description:G,variables:F}));xe.push({children:[{kind:me.CALLBACK_PAYLOAD,callbackName:L,path:k.pathName,httpVerb:M,servers:W?.length?W:void 0,definitionSamples:Te,mediaTypes:Se.length>0?Se:void 0,mediaTypeSchemas:Object.keys(pe).length>0?pe:void 0,examples:[]}]})}}}const Ie=T(x);c.push({nodeType:u.CONTAINER,children:[{nodeType:u.ITEM,variant:"callback",callback:ve,pointer:e.pointer+"/callbacks"}],panels:xe,...R(Ie)})}}y?.hide!==!0&&c.push({nodeType:u.CONTAINER,children:[{nodeType:u.FEEDBACK,pageSlug:Ke(ge(r,t))}],panels:[]});const w=b.some(d=>{const x=d;return x.variant==="body"&&((x.exampleIds?.length??0)>0||!!x.schemaId)})||(f?.length??0)>0;return{contentType:Ne.ITEM,itemVariant:$e.HTTP_ITEM,seo:e["x-seo"],meta:{sourceId:e.operationId,name:s,deprecated:e.deprecated,isWebhook:e.isWebhook||!1,pointer:e.pointer,hasSamples:w},children:c}}function Fe(e,r,o){const n=D(r,e,o)??e,{$ref:t,...s}=e,c=typeof t=="string"?{...n,...s}:n;return Ee(c,o)}function X(e,r,o){if(!e||typeof e!="object")return;const n=e,t=D(r,n,o)??n;return Ee(t,o)}function Ue(e,r,o){if(!e||typeof e!="object")return;const n=T(e),t={},s=[];for(const[c,y]of Object.entries(e)){if(c===ee)continue;const a=D(r,y,o)??y,p=a.content,i=p?p[Object.keys(p)[0]]:void 0,m=a.schema??i?.schema??i?.itemSchema,f=X(m,r,o);if(!f)continue;const S=Oe(a.examples,r,o),E=T(y)??T(a)??n;t[c]={...f,...a.description!==void 0&&{description:a.description},...a.example!==void 0&&{example:a.example},...S&&{examples:S},...R(E)},a.required&&s.push(c)}if(Object.keys(t).length!==0)return{type:"object",properties:t,...s.length>0?{required:s}:{}}}function Ve(e){if(typeof e=="string"||e&&typeof e=="object"&&"$$mdtype"in e||Array.isArray(e)&&e.length>0&&e.every(r=>!!r&&typeof r=="object"&&"$$mdtype"in r))return e}function Y(e,r){const{storeCtx:o,options:n}=K.get(),t=o.document;return e.map(s=>{const c=s.schema;let y={};if(c&&typeof c=="object")y=c;else if(s.content&&typeof s.content=="object"){const S=s.content,E=Object.keys(S)[0],b=E?S[E]?.schema:void 0;b&&typeof b=="object"&&(y=b)}const a=_(o.schemaStore,o.hashIndex,{kind:H.JSON_SCHEMA,data:y}),p=s["x-badges"],i=y["x-badges"],m=Array.isArray(p)?p:Array.isArray(i)?i:void 0,f=ye(s,n.showExtensions);return{name:String(s.name??""),in:typeof s.in=="string"?s.in:void 0,schemaId:a,description:Ve(s.description),required:s.required===!0?!0:void 0,deprecated:s.deprecated===!0?!0:void 0,example:s.example,examples:Oe(s.examples,t,r),...m?.length?{badges:m}:{},...Object.keys(f).length?{extensions:f}:{},...R(T(s))}})}function Oe(e,r,o){if(!e||typeof e!="object")return;const n={};for(const[t,s]of Object.entries(e)){if(!s||typeof s!="object")continue;const c=D(r,s,o)??s;if(!ke(c))continue;const y=he(c);n[t]={...typeof c.summary=="string"&&{summary:c.summary},...typeof c.description=="string"&&{description:c.description},...y!==void 0&&{value:typeof y=="string"?y:JSON.stringify(y)}}}return Object.keys(n).length>0?n:void 0}function Re(e,r){const{storeCtx:o,options:n}=K.get(),t=[],s=o.document,c=Je(e);if(c&&t.push(c),e.parameters&&Array.isArray(e.parameters)){const a=e.parameters.map(l=>Fe(l,s,r)),p=a.filter(l=>l.in==="header"),i=a.filter(l=>l.in==="query"),m=a.filter(l=>l.in==="path"),f=a.filter(l=>l.in==="cookie"),S=a.filter(l=>l.in==="querystring"),E=S.filter(l=>!l.content||typeof l.content!="object"),b=S.filter(l=>l.content&&typeof l.content=="object"),C=S.length>0;m.length>0&&t.push({nodeType:u.ITEM,variant:"path",label:"Path",labelTranslationKey:"path",parameters:Y(m,r),pointer:e.pointer+"/parameters"}),i.length>0&&!C&&t.push({nodeType:u.ITEM,variant:"query",label:"Query",labelTranslationKey:"query",parameters:Y(i,r),pointer:e.pointer+"/parameters"}),E.length>0&&t.push({nodeType:u.ITEM,variant:"querystring",label:"Query String",labelTranslationKey:"querystring",parameters:Y(E,r),pointer:e.pointer+"/parameters"});for(const l of b){const A=l.content,g=Object.keys(A),v={};for(const P of g){const O=A[P];if(!O)continue;let q;const J=O.itemSchema,w=O.schema??J,d=X(w,s,r);d&&(q=_(o.schemaStore,o.hashIndex,{kind:H.JSON_SCHEMA,data:d}));const x=re(O,r);v[P]={schemaId:q,exampleIds:x,...R(T(w))}}const j=g[0],I=j?v[j]:void 0,N=V(l.description,n);t.push({nodeType:u.ITEM,variant:"querystring-body",label:String(l.name??""),required:l.required===!0?!0:void 0,mediaTypes:g.length>0?g:void 0,mediaTypeSchemas:Object.keys(v).length>0?v:void 0,schemaId:I?.schemaId,exampleIds:I?.exampleIds,pointer:e.pointer+"/parameters",...N!==void 0?{description:N}:{},...R(T(l))})}f.length>0&&t.push({nodeType:u.ITEM,variant:"cookies",label:"Cookies",labelTranslationKey:"cookie",parameters:Y(f,r),pointer:e.pointer+"/parameters"}),p.length>0&&t.push({nodeType:u.ITEM,variant:"headers",label:"Headers",labelTranslationKey:"header",parameters:Y(p,r),pointer:e.pointer+"/parameters"})}if(e.requestBody){const y=D(s,e.requestBody,r)??e.requestBody,a=ue(s,y,r),p=a?Object.keys(a):void 0;let i,m,f;if(a&&p){f={};for(const l of p){const A=a[l];if(!A)continue;let g;const v=A.itemSchema,j=A.schema??v,I=X(j,s,r);I&&(g=_(o.schemaStore,o.hashIndex,{kind:H.JSON_SCHEMA,data:I}));const N=re(A,r,`${e.pointer}/requestBody/content/${B(l)}`);f[l]={schemaId:g,exampleIds:N,...R(T(j))}}const b=p[0],C=b?f[b]:void 0;i=C?.schemaId,m=C?.exampleIds}const S=V(y.description,n),E=T(e.requestBody)??T(y);t.push({nodeType:u.ITEM,variant:"body",label:"Request Body",labelTranslationKey:"body",required:y.required,mediaTypes:p,mediaTypeSchemas:f,schemaId:i,exampleIds:m,pointer:e.pointer+"/requestBody",...S!==void 0?{description:S}:{},...R(E)})}return t}function Ae(e,r,o,n){if(!e.responses)return;const{storeCtx:t}=K.get(),s=t?.document??{},c=e.responses,a=Object.entries(c).filter(([p])=>Pe(p)).map(([p,i])=>{const m=D(s,i,n)??i;let f=T(i)??T(m);const S=ue(s,m,n),E=S?Object.keys(S):[],b=E[0],C=b&&S?S[b]:void 0;let l,A,g,v;if(S&&E.length>0){v={};for(const O of E){const q=S[O];if(!q)continue;let J;const w=q.itemSchema,d=q.schema??w,x=X(d,s,n);x&&(J=_(t.schemaStore,t.hashIndex,{kind:H.JSON_SCHEMA,data:x}));const h=re(q,n,`${e.pointer}/responses/${B(p)}/content/${B(O)}`);v[O]={schemaId:J,exampleIds:h,...R(T(d))}}const P=b?v[b]:void 0;l=P?.schemaId,A=P?.exampleIds}else if(C){const P=C.itemSchema,O=C.schema??P,q=X(O,s,n);q&&(f=f??T(O),l=_(t.schemaStore,t.hashIndex,{kind:H.JSON_SCHEMA,data:q})),A=re(C,n,b?`${e.pointer}/responses/${B(p)}/content/${B(b)}`:void 0)}const j=Ue(m.headers,s,n);j&&(g=_(t.schemaStore,t.hashIndex,{kind:H.JSON_SCHEMA,data:j}));let I;m.description&&(I=V(m.description,r),se(I??[],o,`${Ce}/${p}`));const N=m["x-summary"]?V(m["x-summary"],r):void 0;return N&&se(N,o,`${Ce}/${p}/summary`),{code:p,summary:N,description:I,mediaType:b,mediaTypes:E.length>0?E:void 0,mediaTypeContent:v,schemaId:l,exampleIds:A,headers:m.headers,headerSchemaId:g,...R(f)}});return{nodeType:u.ITEM,variant:"responses",responses:a,pointer:e.pointer+"/responses"}}function re(e,r,o){const{storeCtx:n}=K.get(),t=[],s=n.document,c=o?.replace(/^\//,"");if(e.example!==void 0){const y=te(n.exampleStore,{value:e.example,...c&&{id:`${c}/example`}});t.push(y)}if(e.examples&&typeof e.examples=="object"){const y=T(e.examples);for(const[a,p]of Object.entries(e.examples)){if(a===ee||!p||typeof p!="object")continue;const i=D(s,p,r)??p,m=T(p)??T(i)??y,f=te(n.exampleStore,{value:he(i),key:a,summary:typeof i.summary=="string"?i.summary:a,description:typeof i.description=="string"?i.description:void 0,externalValue:typeof i.externalValue=="string"?i.externalValue:void 0,...R(m),...c&&{id:`${c}/examples/${B(a)}`}});t.push(f)}}return t.length>0?t:void 0}function Je(e){const{storeCtx:r,options:o}=K.get();if(!e.security||!Array.isArray(e.security)||e.security.length===0)return;const n=e.security.map(t=>{const s=Object.entries(t);if(s.length===0)return null;const c=r?.document?.components?.securitySchemes,y=s.map(([a,p])=>{const i=r?.securitySchemeStore[a],m=T(c?.[a])??i?.[ee];return{name:a,scopes:Array.isArray(p)?p:void 0,type:i?.type,scheme:i?.scheme,bearerFormat:i?.bearerFormat,in:i?.in,paramName:i?.paramName,description:i?.description?V(i.description,o):i?.description,openIdConnectUrl:i?.openIdConnectUrl,oauth2MetadataUrl:i?.oauth2MetadataUrl,deprecated:i?.deprecated,flows:i?.flows,...R(m)}}).filter(a=>a.name);return y.length>0?{schemes:y}:null}).filter(t=>t!==null);if(n.length!==0)return{nodeType:u.SECURITY,requirements:n}}function We(e,r,o,n){const{storeCtx:t,options:s}=K.get();if(!t)throw new Error("OpenAPI store context is not initialized");return Be(e,t,s,r,o,n)}export{dt as buildItemContent,Le as createCallbackIdFactory};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{contentType as D,itemVariant as R,nodeTypes as l}from"../../types/common.js";import{safeSlugify as x}from"../../utils/string.js";import{parseMarkdown as p}from"./parseMarkdown.js";import{isPlainText as
|
|
1
|
+
import{contentType as D,itemVariant as R,nodeTypes as l}from"../../types/common.js";import{safeSlugify as x}from"../../utils/string.js";import{parseMarkdown as p}from"./parseMarkdown.js";import{isPlainText as k}from"./isPlainText.js";import{joinWithSeparator as a}from"../../utils/url.js";import{buildDeepLinkUrl as v}from"../../utils/deep-link.js";import{getDOMPurify as N}from"./dompurify.js";function O(t){return t.type==="tag"&&t.tag==="schemaDefinition"}const E=/^[ \t]{0,3}#{1,6}[ \t]/m;function b(t){const r=t.search(E);return r===-1?t:t.slice(0,r)}function X(t,r){if(typeof t=="string"){const n=b(t).trim();if(k(n))return n}const e=p(t,r);if(!e)return;if(typeof e=="string")return e;if(Array.isArray(e)){const n=e.findIndex(o=>o.type==="heading");return n===-1?e:e.slice(0,n)}if(!e.children||!Array.isArray(e.children))return;const i=e.children.findIndex(n=>n.type==="heading");return i===-1?[e]:(e.children=e.children.slice(0,i),[e])}function Y(t,r,{sliceAtFirstHeading:e=!1}={}){if(typeof t=="string"&&e){const f=b(t).trim();if(k(f))return[{kind:"markdoc",node:{nodeType:l.MARKDOC,content:f}}]}const i=p(t,r);if(!i)return[];if(typeof i=="string")return[{kind:"markdoc",node:{nodeType:l.MARKDOC,content:i}}];let n=Array.isArray(i)?i:i.children??[];if(e){const f=n.findIndex(d=>d.type==="heading");f!==-1&&(n=n.slice(0,f))}const o=[];let c=[];const u=()=>{c.length>0&&(o.push({kind:"markdoc",node:{nodeType:l.MARKDOC,content:c}}),c=[])};for(const f of n)O(f)?(u(),o.push({kind:"schemaDefinition",node:{nodeType:l.MARKDOC,content:[f]}})):c.push(f);return u(),o}function L(t,r,e){const i=t.toLowerCase(),n=i.startsWith("section/")?i.slice(8):i,o=r.toLowerCase();let c=n!==o?n:"";return e&&(c=a(e,c)),c}function $(t,r,e){if(typeof t=="string")return;const i=n=>{if(n.type==="heading"&&n.attributes?.level){const o=n.attributes.id?n.attributes.id.toLowerCase():x(m(n).trim()).toLowerCase();if(o){const c=L(o,r,e);n.attributes.id=a(r,c).toLowerCase(),n.attributes.deepLinkHash=v("",r,c)}}for(const o of n.children??[])i(o)};if(Array.isArray(t))for(const n of t)i(n);else i(t)}function _(t,r,e,i){const n=p(t,r);if(!n)return[];if(typeof n=="string")return[];const o=[];let c;const u=(s,h,w=o,y,A)=>{s=K(s);const I=A!==void 0;let g;y.attributes.id?g=y.attributes.id:I||i?g=x(s):g=`section/${x(s)}`;const T=a(I?A:e,g).toLowerCase();y.attributes.id=T;const C={id:T,name:s,level:h,items:[],ast:[y]};return w.push(C),C},f=s=>{if(typeof s?.attributes?.content=="string")return s.attributes.content;if(s?.children)return f(s.children[0])},d=s=>{const h=f(s)||"";s.type==="heading"&&s.attributes?.level===1?c=u(h,s.attributes.level,void 0,s):s.attributes?.level?u(h,s.attributes.level,c?.items,s,c?.id):c?.items?.length?c.items[c.items.length-1]?.ast?.push(s):o.length&&o[o.length-1]?.ast?.push(s)};if(Array.isArray(n))for(const s of n)d(s);else if(n.children)for(const s of n.children)d(s);return o}function H({heading:t,basePath:r}){const e=t.items.length>0,i=a(r,t.id).toLowerCase(),n=e?t.items.map(o=>H({heading:o,basePath:r})):[];return{type:e?"group":"link",label:t.name,link:i,routeSlug:i,items:e?n:void 0,content:W(t)}}function J(t,r,e){const i=[],n=[];for(const o of _(t,e,"")){const{item:c,children:u}=M(o,r);i.push(c),n.push(...u)}return{sectionItems:i,sectionChildren:n}}function M(t,r){const e=a(r,t.id),i=t.items.length>0,n=t.ast?.length?[z(t.ast,a(r,t.id))]:[],o=[];for(const u of t.items){const{item:f,children:d}=M(u,r);o.push(f);const s=a(r,u.id);n.push({nodeType:l.OVERVIEW_SECTION_WRAPPER,children:d,sectionId:s})}return{item:{type:i?"group":"link",label:t.name,link:e,routeSlug:e,items:i?o:void 0,content:null},children:n}}function Q(t){return typeof t=="string"?t.trim():Array.isArray(t)?t.map(r=>m(r)).filter(Boolean).join(" ").trim():m(t).trim()}function S(t,r=50){if(typeof t=="string"){const o=t.split(/\n[ \t]*\n/)[0].replace(/\s+/g," ").trim();return o?o.substring(0,r):void 0}const i=(Array.isArray(t)?t:t.children??[t])[0];if(!i)return;const n=m(i);return n?n.substring(0,r):void 0}function Z(t,r){if(!t)return;const e=p(t,r);if(!e)return;const i=S(e);return i?i.length===50?i+"\u2026":i:void 0}function tt(t,r){if(!t)return;const e=p(t,r);if(e)return S(e,Number.POSITIVE_INFINITY)}function m(t){const r=[];function e(i){typeof i.attributes?.content=="string"&&r.push(i.attributes.content);for(const n of i.children??[])e(n)}return e(t),r.join("")}function et(t){return typeof t=="string"?t.trim():(Array.isArray(t)?t:[t]).map(e=>m(e)).join("").trim()}function K(t){return t.replace(/&#(\d+);/g,(r,e)=>String.fromCharCode(parseInt(e,10))).replace(/"/g,'"').replace(/&/g,"&")}function nt(t,r){const{unstable_hooks:e,sanitize:i}=r??{};return e?.sanitize?e.sanitize(t):i?N().sanitize(t):t}function W(t){const r=[];return t.ast&&t.ast.length>0&&r.push({nodeType:l.MARKDOC,content:t.ast}),{contentType:D.ITEM,itemVariant:R.MARKDOWN,meta:{name:t.name},children:[{nodeType:l.CONTAINER,children:r,panels:[]}]}}function z(t,r){return{nodeType:l.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:l.MARKDOC,content:t}],sectionId:r}}export{H as buildMarkdownSectionItem,et as collectMarkdownPlainText,J as collectMarkdownSections,X as extractContentUntilFirstHeading,Y as extractDescriptionSegments,S as extractFirstParagraphText,Q as extractFullText,_ as extractMarkdownSections,tt as extractSeoDescriptionText,Z as extractSummaryText,L as resolveMarkdocHeadingDeepSuffix,$ as resolveMarkdocHeadingIds,nt as sanitizeMarkdownSource,K as unescapeHTMLChars};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as d,useMemo as
|
|
1
|
+
import{useContext as d,useMemo as l}from"react";import{useAtomValue as p}from"jotai";import{exampleStoreAtom as h,generatedExampleAtom as x,buildExampleAtomKey as S}from"../../jotai/examples.js";import{convertSampleToString as g}from"../../services/code-samples/index.js";import{isSequentialMediaType as A}from"../../utils/media-type.js";import{schemaStoreAtom as C}from"../../jotai/schema.js";import{buildOpenApiSectionSuffix as E,extractDeepLinkParamFromHash as L,hashIsForItem as b,hashIsInsideCallback as k,hashIsOutsideCallbacks as v,hashToElementId as I}from"../../utils/deep-link.js";import{ItemIdContext as D,useCallbackScope as P}from"../../hooks/useDeepLinkSection.js";import{useUrlHash as w}from"../../hooks/useUrlHash.js";import{routingBasePathAtom as y}from"../../jotai/store.js";import{useDeepLinkUrl as B}from"../../hooks/useDeepLinkSection.js";import{toRelativePath as F}from"../../utils/url.js";function H(e){const t=p(h);return!e||e.length===0?[]:e.map(o=>t[o]).filter(Boolean)}function N(e,t,o,n){const i=H(t),a=d(D)??"",r=n?.toLowerCase(),s=e?S(e,o,n,a):"",f=p(x(s)),u=p(C);if(i.length>0){if(r&&A(r)){const m=e?u[e]?.data:void 0;return i.map(c=>typeof c.value=="string"?c.value:g(c.value,r,m))}return i.map(m=>m.value)}return f!==void 0?[f]:[]}function Q(e,t){const o=l(()=>e?E("response",t,e):"",[e,t]);return B(o)}function W(e,t,o){const n=w(),i=p(y),a=P();return l(()=>{if(!e)return;const r=I(n),s=F(e,i).toLowerCase();if(!b(r,s)||!(a?k(r,s,a):v(r,s)))return;const u=L(n,o);if(u)return t?.find(m=>m.toLowerCase()===u)},[n,e,t,o,i,a])}export{H as useExampleEntries,W as useKeyFromHash,N as useResolvedExamples,Q as useResponseSectionDeepLink};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{jsx as t,jsxs as
|
|
1
|
+
import{jsx as t,jsxs as v}from"react/jsx-runtime";import{useMemo as p,memo as x}from"react";import{styled as d}from"styled-components";import{useAtom as T,useAtomValue as S}from"jotai";import{Markdown as b}from"../../common/Markdown.js";import{schemaEntryAtom as k}from"../../../jotai/schema.js";import{activeMediaTypeAtom as g}from"../../../jotai/app.js";import{SchemaView as M}from"../../Schema/SchemaView.js";import{buildOpenApiSectionSuffix as q,getDeepLinkId as A}from"../../../utils/deep-link.js";import{DeepLinkSectionContext as B,useCallbackScope as D,useDeepLinkUrl as j}from"../../../hooks/useDeepLinkSection.js";import{BodyMimeTypeField as I}from"./BodyMimeTypeField.js";function L({node:e}){const i=e.mediaTypeSchemas?Object.keys(e.mediaTypeSchemas):e.mediaTypes,[r,l]=T(g),o=r&&i?.includes(r)?r:i?.[0],s=e.mediaTypeSchemas?.[o??""]?.schemaId??e.schemaId,y=S(k(s??"")),u=i&&i.length>0,a=i&&i.length>1,n=e.variant==="body"||e.variant==="querystring-body",f=p(()=>q("request","body"),[]),c=j(f),m=D(),h=p(()=>({t:"request",cb:m,ct:a?o:void 0}),[m,a,o]);return v(C,{id:A(c),children:[u&&i&&t(I,{mediaTypes:i,value:o,onChange:l,deepLink:c,required:e.required}),e.description?t(E,{children:t(b,{source:e.description})}):null,y&&t(B.Provider,{value:h,children:t(M,{schemaId:s,expandByDefault:!0,level:1,skipReadOnly:n,skipWriteOnly:!n})})]})}const C=d.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
|
-
`,
|
|
4
|
+
`,E=d.div`
|
|
5
5
|
font-size: var(--font-size-base);
|
|
6
6
|
line-height: var(--line-height-base);
|
|
7
7
|
color: var(--text-color-description);
|
|
@@ -10,4 +10,4 @@ import{jsx as t,jsxs as h}from"react/jsx-runtime";import{useMemo as c,memo as v}
|
|
|
10
10
|
margin-top: var(--spacing-xxs);
|
|
11
11
|
margin-bottom: 0;
|
|
12
12
|
}
|
|
13
|
-
`,
|
|
13
|
+
`,J=x(L);export{J as BodySection};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import{Fragment as
|
|
1
|
+
import{Fragment as O,jsx as e,jsxs as n}from"react/jsx-runtime";import{useCallback as H,useContext as P,useEffect as j,useRef as B}from"react";import{styled as r}from"styled-components";import{useAtomValue as W,useSetAtom as q}from"jotai";import{Panel as K}from"@redocly/theme/components/Panel/Panel";import{PanelHeader as M}from"@redocly/theme/components/Panel/PanelHeader";import{PanelHeaderTitle as V}from"@redocly/theme/components/Panel/PanelHeaderTitle";import{TextBadge as F,StyledBadge as U}from"../../common/Badge.js";import{DeepLinkAnchor as T,deepLinkHoverReveal as $,DEEP_LINK_ANCHOR_ATTR as J}from"../../common/DeepLinkAnchor.js";import{ItemContentRenderer as A}from"../ItemContentRenderer.js";import{nodeTypes as D}from"../../../types/common.js";import{itemStoreAtom as Q,itemStoreFieldAtom as G}from"../../../jotai/itemStore.js";import{CallbackScopeContext as X,ItemIdContext as Y,useDeepLinkUrl as S,useHashItemId as Z}from"../../../hooks/useDeepLinkSection.js";import{useSpecTranslate as ee}from"../../../hooks/useTranslate.js";import{useUrlHash as te}from"../../../hooks/useUrlHash.js";import{buildOpenApiSectionSuffix as re,CALLBACKS_SECTION as oe,CALLBACK_REQUEST_SECTION as ae,CALLBACK_RESPONSE_SECTION as ne,getDeepLinkId as L,hashTargetsCallback as ie}from"../../../utils/deep-link.js";import{Markdown as le}from"../../common/Markdown.js";import{collectMarkdownPlainText as se}from"../../../adapters/utils/markdoc.js";function ce(o){return{delete:"del",options:"opts"}[o]||o}function de(o){return o.target instanceof Element&&o.target.closest("a")!==null}function pe({operation:o,callbackId:a,isExpanded:p,onToggle:h}){const{httpVerb:s,pathName:g,summary:f,operationId:m,description:l,deprecated:b,contentChildren:c,externalDocs:d,extensions:u}=o,v=f||m||l&&se(l).substring(0,50)||g||"<no summary>",x=re(oe,a),k=S(x),z=B(null),C=S(`${x}/${ae}`),y=S(`${x}/${ne}`),I=ee(),E=I("callbackRequest","Callback Request"),w=I("callbackResponse","Callback Response"),N=I("badges.deprecated","deprecated");return e(he,{header:({expanded:t,toggle:i})=>n(ge,{ref:z,expanded:t,toggle:R=>{de(R)||(i?.(R),h(a))},id:L(k),children:[k&&e(T,{to:k,label:`link to ${v}`}),n(me,{children:[e(fe,{type:"button","aria-expanded":t,"aria-label":v,children:e(ue,{$expanded:t,"aria-hidden":"true"})}),n(be,{children:[e(ve,{$deprecated:b,children:v}),e(xe,{color:s,children:ce(s)}),b?e(U,{$deprecated:!0,children:N}):null]})]})]}),expanded:p,className:"panel-response-callback",children:n(ke,{children:[l&&e(ye,{children:e(le,{source:l})}),d&&e(Ie,{href:d.url,target:"_blank",rel:"noopener noreferrer",children:d.description||d.url}),u&&Object.keys(u).length>0&&e(Te,{children:Object.entries(u).map(([t,i])=>n(Se,{children:[n("strong",{children:[t,":"]})," ",typeof i=="string"?i:JSON.stringify(i)]},t))}),c&&c.length>0&&n(X.Provider,{value:a,children:[n(_,{id:L(C),children:[C&&e(T,{to:C,label:`link to ${E}`}),E]}),c.filter(t=>t.nodeType===D.ITEM&&t.variant!=="responses").map((t,i)=>e(A,{node:t},i)),c.filter(t=>t.nodeType===D.ITEM&&t.variant==="responses").map((t,i)=>n("div",{children:[n(_,{id:L(y),children:[y&&e(T,{to:y,label:`link to ${w}`}),w]}),e(A,{node:t})]},`resp-${i}`))]}),e(Ce,{})]})})}function Me({node:o}){const a=o.callback,p=P(Y)??"",h=W(G({itemId:p,key:"selectedCallback"})),s=q(Q(p)),g=te(),f=Z(),m=a?.callbackId,l=ie(g,f,m)?m:void 0;j(()=>{l&&s({selectedCallback:l})},[l,s]);const b=H(c=>{s(d=>({selectedCallback:d.selectedCallback===c?"":c}))},[s]);return a?e("div",{children:e(pe,{operation:a,callbackId:a.callbackId,isExpanded:h===a.callbackId,onToggle:b},a.callbackId)}):e(O,{})}const me=r.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
gap: var(--spacing-xs);
|
|
5
5
|
max-width: calc(100% - 9px - var(--spacing-unit));
|
|
6
6
|
justify-content: flex-start;
|
|
7
|
-
`,
|
|
7
|
+
`,be=r.div`
|
|
8
8
|
flex: 1;
|
|
9
9
|
min-width: 0;
|
|
10
10
|
line-height: var(--line-height-base);
|
|
11
|
-
`,
|
|
11
|
+
`,he=r(K)`
|
|
12
12
|
border-bottom: 1px solid var(--border-color-primary);
|
|
13
13
|
border-radius: 0;
|
|
14
14
|
&:not(:last-child) {
|
|
15
15
|
margin-bottom: 0;
|
|
16
16
|
}
|
|
17
|
-
`,
|
|
17
|
+
`,ge=r(M)`
|
|
18
18
|
padding: var(--spacing-sm) 0 var(--spacing-sm) calc(var(--spacing-unit) / 2);
|
|
19
19
|
margin: 0;
|
|
20
20
|
border-radius: 0;
|
|
21
21
|
line-height: var(--line-height-base);
|
|
22
22
|
position: relative;
|
|
23
23
|
|
|
24
|
-
& > [${
|
|
24
|
+
& > [${J}] {
|
|
25
25
|
position: absolute;
|
|
26
26
|
top: 0;
|
|
27
27
|
bottom: 0;
|
|
28
28
|
left: 0;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
${
|
|
32
|
-
`,
|
|
31
|
+
${$}
|
|
32
|
+
`,fe=r.button`
|
|
33
33
|
background: none;
|
|
34
34
|
border: none;
|
|
35
35
|
cursor: pointer;
|
|
@@ -41,7 +41,7 @@ import{Fragment as D,jsx as e,jsxs as n}from"react/jsx-runtime";import{useCallba
|
|
|
41
41
|
font-size: var(--font-size-base);
|
|
42
42
|
font-family: var(--font-family-base);
|
|
43
43
|
line-height: var(--line-height-base);
|
|
44
|
-
`,
|
|
44
|
+
`,ue=r.span`
|
|
45
45
|
position: relative;
|
|
46
46
|
display: inline-block;
|
|
47
47
|
flex: none;
|
|
@@ -72,30 +72,30 @@ import{Fragment as D,jsx as e,jsxs as n}from"react/jsx-runtime";import{useCallba
|
|
|
72
72
|
height: var(--spacing-xs);
|
|
73
73
|
opacity: ${({$expanded:o})=>o?0:1};
|
|
74
74
|
}
|
|
75
|
-
`,
|
|
75
|
+
`,ve=r(V)`
|
|
76
76
|
text-decoration: ${({$deprecated:o})=>o?"line-through":"none"};
|
|
77
77
|
display: inline;
|
|
78
78
|
margin: 0 4px 0 0;
|
|
79
79
|
color: var(--panel-response-callback-heading-text-color);
|
|
80
80
|
font-weight: var(--font-weight-medium);
|
|
81
81
|
word-break: break-all;
|
|
82
|
-
`,
|
|
82
|
+
`,xe=r(F)`
|
|
83
83
|
white-space: nowrap;
|
|
84
84
|
vertical-align: middle;
|
|
85
|
-
`,
|
|
85
|
+
`,ke=r.div`
|
|
86
86
|
position: relative;
|
|
87
87
|
.property:last-child {
|
|
88
88
|
border-bottom: none;
|
|
89
89
|
padding-bottom: 0;
|
|
90
90
|
}
|
|
91
|
-
`,
|
|
91
|
+
`,Ce=r.div`
|
|
92
92
|
position: absolute;
|
|
93
93
|
height: calc(100% + 15px);
|
|
94
94
|
border-left: 1px solid var(--border-color-primary);
|
|
95
95
|
top: -15px;
|
|
96
96
|
left: -13px;
|
|
97
97
|
z-index: 0;
|
|
98
|
-
`,
|
|
98
|
+
`,ye=r.div`
|
|
99
99
|
font-size: var(--font-size-base);
|
|
100
100
|
line-height: var(--line-height-base);
|
|
101
101
|
color: var(--text-color-primary);
|
|
@@ -107,17 +107,17 @@ import{Fragment as D,jsx as e,jsxs as n}from"react/jsx-runtime";import{useCallba
|
|
|
107
107
|
p:last-of-type {
|
|
108
108
|
margin-bottom: 0;
|
|
109
109
|
}
|
|
110
|
-
`,
|
|
110
|
+
`,Ie=r.a`
|
|
111
111
|
display: inline-block;
|
|
112
112
|
font-size: var(--font-size-sm);
|
|
113
113
|
color: var(--link-text-color);
|
|
114
114
|
margin-bottom: var(--spacing-sm);
|
|
115
|
-
`,
|
|
115
|
+
`,Te=r.div`
|
|
116
116
|
font-size: var(--font-size-sm);
|
|
117
117
|
margin-bottom: var(--spacing-sm);
|
|
118
|
-
`,
|
|
118
|
+
`,Se=r.div`
|
|
119
119
|
padding: var(--spacing-xxs) 0;
|
|
120
|
-
`,
|
|
120
|
+
`,_=r.h4`
|
|
121
121
|
position: relative;
|
|
122
122
|
font-size: var(--h4-font-size);
|
|
123
123
|
font-weight: var(--h4-font-weight);
|
|
@@ -127,5 +127,5 @@ import{Fragment as D,jsx as e,jsxs as n}from"react/jsx-runtime";import{useCallba
|
|
|
127
127
|
display: flex;
|
|
128
128
|
align-items: center;
|
|
129
129
|
margin: var(--spacing-sm) 0 var(--spacing-xs) 0;
|
|
130
|
-
${
|
|
131
|
-
`;export{
|
|
130
|
+
${$}
|
|
131
|
+
`;export{Me as CallbacksSection};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Fragment as a,jsx as r}from"react/jsx-runtime";import{useMemo as
|
|
1
|
+
import{Fragment as a,jsx as r}from"react/jsx-runtime";import{useMemo as m}from"react";import{styled as l}from"styled-components";import{useAtomValue as d}from"jotai";import{SchemaView as p}from"../../Schema/SchemaView.js";import{schemaEntryAtom as u}from"../../../jotai/schema.js";import{DeepLinkSectionContext as f,useCallbackScope as x}from"../../../hooks/useDeepLinkSection.js";import{serializeParameterValue as h}from"../../../utils/serialize-parameter.js";import{tryDecodeURIComponent as g}from"../../../utils/string.js";function L({node:e}){const t=e.parameters,o=e.variant,n=x(),s=m(()=>({t:"request",in:o,cb:n}),[o,n]);return!t||t.length===0?r(a,{}):r(f.Provider,{value:s,children:r(b,{children:t.map((i,c)=>r(S,{param:i},`${i.name}-${c}`))})})}function y(e){if(e.in)return t=>g(h(e,t))}function S({param:e}){const o=d(u(e.schemaId))?.data,n={...e.deprecated!==void 0?{deprecated:e.deprecated}:{},...e.description!=null?{description:e.description}:{}},s={...e.example!=null?{example:e.example}:{},...e.examples?{examples:e.examples}:{}},i={allOf:[n,o,s],...e.badges?.length?{"x-badges":e.badges}:{},...e.extensions},c={type:"object",required:e.required?[e.name]:[],properties:{[e.name]:i}};return r(p,{schema:c,level:1,exampleSerializer:y(e)})}const b=l.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
|
-
`;export{
|
|
4
|
+
`;export{L as ParametersSection,y as getParameterExampleSerializer};
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import{Fragment as
|
|
1
|
+
import{Fragment as z,jsx as e,jsxs as a}from"react/jsx-runtime";import{useContext as W,useEffect as _,useMemo as C}from"react";import{styled as s}from"styled-components";import{useAtom as O,useAtomValue as V,useSetAtom as $}from"jotai";import{SchemaView as f}from"../../Schema/SchemaView.js";import{Markdown as T}from"../../common/Markdown.js";import{DeepLinkAnchor as E,deepLinkHoverReveal as K}from"../../common/DeepLinkAnchor.js";import{getDeepLinkId as D}from"../../../utils/deep-link.js";import{BodyMimeTypeField as P}from"./BodyMimeTypeField.js";import{activeMediaTypeAtom as U}from"../../../jotai/app.js";import{itemStoreAtom as q,itemStoreFieldAtom as G}from"../../../jotai/itemStore.js";import{DeepLinkSectionContext as J,ItemIdContext as N,useCallbackScope as Q}from"../../../hooks/useDeepLinkSection.js";import{useSpecTranslate as X}from"../../../hooks/useTranslate.js";import{isRecord as Y}from"../../../adapters/helpers.js";import{useKeyFromHash as Z,useResponseSectionDeepLink as L}from"../hooks.js";function ke({node:A}){const o=A.responses,u=X(),c=W(N),M=V(G({itemId:c??"",key:"activeResponseCode"})),v=$(q(c??"")),B=C(()=>o?.map(h=>h.code),[o]),i=Z(c??void 0,B,"c"),n=M||i||o?.[0]?.code||"";_(()=>{i&&v({activeResponseCode:i})},[i,v]);const y=L(n,"body"),d=L(n,"headers"),{mediaTypes:F,mediaType:g,mediaTypeContent:p,schemaId:H,summary:x,description:k,headers:I,headerSchemaId:m}=o?.find(h=>h.code===n)??o?.[0]??{},t=p?Object.keys(p):F??(g?[g]:[]),[l,j]=O(U),r=l&&t.includes(l)?l:t[0],S=p?.[r]?.schemaId??H,b=Q(),w=C(()=>({t:"response",c:n,cb:b,ct:t.length>1?r:void 0}),[n,b,t.length,r]);return!o||o.length===0?e(z,{}):e(ee,{children:a(oe,{children:[x&&e(R,{children:e(T,{source:x})}),k&&e(R,{children:e(T,{source:k})}),a(J.Provider,{value:w,children:[(m||Y(I))&&a(ne,{children:[a(te,{id:D(d),children:[d&&e(E,{to:d,label:`link to ${u("header","Headers")}`}),e(se,{children:u("header","Headers")})]}),m?e(f,{schemaId:m,expandByDefault:!0,level:1}):e(f,{schema:I,expandByDefault:!0,level:1})]}),t.length>0&&e(P,{headingId:D(y),mediaTypes:t,value:r,onChange:j,deepLink:y}),S&&e(f,{schemaId:S,expandByDefault:!0,level:1,skipWriteOnly:!0})]})]})})}const ee=s.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
gap: var(--spacing-xs);
|
|
5
|
-
`,
|
|
5
|
+
`,oe=s.div`
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-direction: column;
|
|
8
|
-
`,
|
|
8
|
+
`,R=s.div`
|
|
9
9
|
font-size: var(--font-size-base);
|
|
10
10
|
line-height: var(--line-height-base);
|
|
11
11
|
color: var(--text-color-description);
|
|
12
|
-
`,
|
|
12
|
+
`,te=s.span`
|
|
13
13
|
position: relative;
|
|
14
14
|
display: flex;
|
|
15
15
|
align-items: center;
|
|
16
16
|
margin-top: var(--spacing-md);
|
|
17
17
|
padding: var(--spacing-xxs) 0;
|
|
18
|
-
${
|
|
19
|
-
`,
|
|
18
|
+
${K}
|
|
19
|
+
`,se=s.span`
|
|
20
20
|
font-weight: var(--font-weight-semibold);
|
|
21
21
|
font-size: 18px;
|
|
22
22
|
line-height: var(--line-height-lg);
|
|
23
23
|
color: var(--text-color-primary);
|
|
24
|
-
`,
|
|
24
|
+
`,ne=s.div`
|
|
25
25
|
&:not(:last-child) {
|
|
26
26
|
margin-bottom: var(--spacing-lg);
|
|
27
27
|
}
|
|
28
|
-
`;export{
|
|
28
|
+
`;export{ke as ResponsesSection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as t,useMemo as o}from"react";import{useAtomValue as c}from"jotai";import{buildAsyncApiSuffix as f,buildOpenApiFieldSuffix as r}from"../../../utils/deep-link.js";import{DeepLinkSectionContext as u,ItemIdContext as m,useFieldDeepLinkUrl as s}from"../../../hooks/useDeepLinkSection.js";import{expandableSectionAtom as a}from"../../../jotai/itemStore.js";function p(e,n){if(!e)return"";if(e.pathOnly)return n?r({path:n}):"";if(e.asyncSection){let i=f({section:e.asyncSection,messageKey:e.messageKey,subsection:e.t});return n&&(i+=`&path=${n}`),i}return r({t:e.t,in:e.in,c:e.c,cb:e.cb,ct:e.ct,path:n})}function A(e){const n=t(u),i=o(()=>p(n,e),[n,e]);return s(i)}function S(){const e=t(u);return o(()=>p(e,""),[e])}function F(){const e=t(m)??"",n=S();return c(a(e,n))}export{p as buildSchemaFieldSuffix,A as useSchemaFieldDeepLink,S as useSectionBaselineKey,F as useSectionExpandBaseline};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { JSX, PropsWithChildren } from 'react';
|
|
2
2
|
declare function HeadingComponent({ level, id, children, deepLinkHash, 'data-source': dataSource, 'data-hash': dataHash, className, }: PropsWithChildren<{
|
|
3
3
|
level: number;
|
|
4
|
-
id
|
|
4
|
+
id?: string;
|
|
5
5
|
deepLinkHash?: string;
|
|
6
6
|
'data-source'?: string;
|
|
7
7
|
'data-hash'?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as a,jsxs as l}from"react/jsx-runtime";import{createElement as c,memo as f}from"react";import{styled as h}from"styled-components";import{useAtomValue as g}from"jotai";import{concatClassNames as u}from"@redocly/theme/core/utils";import{HEADING_ANCHOR_CLASS as A,MARKDOWN_CLASS_NAME as H}from"@redocly/theme/core/constants";import{DeepLinkAnchor as N,deepLinkHoverReveal as C}from"../common/DeepLinkAnchor.js";import{joinWithSeparator as x}from"../../utils/url.js";import{routingBasePathAtom as _}from"../../jotai/store.js";import{useNavigationUrlNormalizer as j}from"../../hooks/useNormalizeUrl.js";function v({level:t,id:e,children:r,deepLinkHash:n,"data-source":i,"data-hash":m,className:s}){const p=g(_),d=j(),o=e?.toLowerCase();return c(`h${t}`,{id:o,className:u(A,H,s),"data-component-name":"Markdoc/Heading/Heading","data-source":i,"data-hash":m},l(L,{children:[o&&a(N,{to:d(x(p,n??o)),label:`link to ${e}`}),a("span",{children:r})]}))}const L=h.div`
|
|
2
2
|
position: relative;
|
|
3
3
|
display: flex;
|
|
4
4
|
align-items: center;
|
|
5
|
-
${
|
|
6
|
-
`,
|
|
5
|
+
${C}
|
|
6
|
+
`,B=f(v);export{B as Heading};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"@markdoc/markdoc";import{html as
|
|
1
|
+
import r from"@markdoc/markdoc";import{html as m}from"@redocly/theme/markdoc/tags/html";import{MARKDOWN_CLASS_NAME as u}from"@redocly/theme/core/constants";import{safeSlugify as f}from"../../utils/string.js";import{mcpTagSchemas as p}from"./tags/mcp-tag-schemas.js";import{schemaDefinitionTag as c}from"./tags/schema-definition-tag.js";function l(e){const t=i(e).trim();return t?`section/${f(t)}`:void 0}const y={html:m.schema,schemaDefinition:c,...p};function i(e){return e.map(t=>typeof t=="string"?t:r.Tag.isTag(t)?i(t.children):"").join("")}function s(e){return e.map(t=>r.Tag.isTag(t)?t.name==="th"?new r.Tag("th",{...t.attributes,"data-label":i(t.children)},t.children):new r.Tag(t.name,t.attributes,s(t.children)):t)}const N={table:{transform(e,t){const n=e.transformAttributes(t),a=e.transformChildren(t);return new r.Tag("div",{className:"md-table-wrapper"},[new r.Tag("table",{...n,className:u},s(a))])}},heading:{children:["inline"],attributes:{id:{type:String},level:{type:Number,required:!0,default:1},deepLinkHash:{type:String}},transform(e,t){const n=e.transformAttributes(t),a=e.transformChildren(t),o=typeof n.id=="string"?n.id:l(a);return new r.Tag("Heading",{...n,id:o,level:e.attributes.level===1?2:e.attributes.level},a)}}};export{N as apiDocsMarkdocNodes,y as apiDocsMarkdocTags,l as getMarkdownHeaderId};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{Fragment as
|
|
1
|
+
import{Fragment as N,jsx as e,jsxs as y}from"react/jsx-runtime";import{useState as u,useContext as L,useEffect as _,useMemo as g,useCallback as B}from"react";import{styled as F}from"styled-components";import{useAtomValue as K}from"jotai";import{CodeBlockPanel as V,StyledCodeBlock as H}from"../styled.js";import{useResolvedExamples as Y,useExampleEntries as $}from"../../ItemContent/hooks.js";import{useBodySamplingSchemaId as O,useMediaTypeContent as R}from"./hooks.js";import{ExampleSelector as U,MediaTypeSelector as W,PayloadDisplay as q}from"./selectors.js";import{StyledPanelHeader as z}from"./styled.js";import{ServerDropdown as G}from"./ServerDropdown.js";import{LanguageDropdown as J}from"../LanguageItem/LanguageDropdown.js";import{itemStoreFieldAtom as Q}from"../../../jotai/itemStore.js";import{ItemIdContext as X}from"../../../hooks/useDeepLinkSection.js";import{getSyntaxHighlightLang as Z}from"../../../utils/languages.js";import{useSpecTranslate as ee}from"../../../hooks/useTranslate.js";import{useCopyCodeTelemetry as ae}from"../../../hooks/useCopyCodeTelemetry.js";const m="payload",te=F.div`
|
|
2
2
|
min-width: 0;
|
|
3
3
|
overflow: hidden;
|
|
4
4
|
flex: 1 1 auto;
|
|
5
|
-
`;function
|
|
5
|
+
`;function Se({node:a}){const x=ee(),h=L(X)??"",S=K(Q({itemId:h,key:"selectedCallback"})),p=a.callbackName,t=a.definitionSamples,C=p!=null&&S===p,{mediaTypes:b,activeMediaType:l,effectiveSchemaId:v,effectiveExampleIds:s,onMediaTypeChange:k}=R(a),E=O(v,l),d=Y(E,s,"response",l),I=$(s),[i,f]=u(0),[n,T]=u(m);_(()=>f(0),[s,l]);const D=d[i]??d[0],P=I[i]?.description,M=g(()=>{const o=[{key:m,lang:"json",title:"Payload"}];if(t)for(const c of t){const A=`x-${c.lang}`;o.push({key:A,lang:c.lang,title:c.label||c.lang})}return o},[t]),r=g(()=>{if(!(n===m||!t))return t.find(o=>`x-${o.lang}`===n)},[n,t]),j=ae("response"),w=B(o=>T(o),[]);return C?e(V,{className:"panel-callback-samples",header:()=>y(z,{isExpandable:!1,children:[e(te,{children:e(G,{servers:a.servers??[],method:(a.httpVerb??"post").toUpperCase(),path:a.path??"Callback"})}),e(J,{activeTab:n,samples:M,onChange:w})]}),isExpandable:!1,children:r?e(H,{lang:Z(r.lang),source:r.source,header:{className:"code-block-header",controls:{copy:{onClick:j(r.lang)}}}}):y(N,{children:[e(W,{mediaTypes:b,value:l,onChange:k,label:x("contentType","Payload media type")}),e(U,{exampleIds:s,selectedIdx:i,onSelect:f}),e(q,{payload:D,emptyMessage:"// No callback payload",mediaType:l,description:P})]})}):null}export{Se as CallbackPayloadItem};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as
|
|
1
|
+
import{useEffect as h,useLayoutEffect as m}from"react";import{useLocation as y,useNavigate as T}from"react-router";import{IS_BROWSER as g}from"@redocly/theme/core/openapi";import{SECTION_ATTR as w}from"../constants/openapi.js";import{hashToElementId as S,resolveLegacyHashToRoute as v,stripArrayMarkers as L,stripCallbacksSegment as b}from"../utils/deep-link.js";import{USER_SCROLL_INTENT_EVENTS as H,WHEEL_INTENT_THRESHOLD_PX as _,createScrollIntentTracker as A}from"./useUserScrollIntent.js";function M({activeRoute:t,routeIndex:n,basePath:e,isHydrated:r}){const i=y(),u=T(),l=t?.path;h(()=>{if(!g||!("scrollRestoration"in window.history))return;const c=window.history.scrollRestoration;return window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration=c}},[]),m(()=>{if(!g)return;const{hash:c}=i,s=c?S(c):"";if(s&&!p(s)){const a=v(c,e,n);if(a&&a!==i.pathname){u(a,{replace:!0});return}}if(!(!s&&!l))return N(C(s,l))},[i,l,r,u,e,n])}function C(t,n){if(!t)return()=>R(n);let e=!1;return()=>{const r=p(t);return r?(e=!0,r):e?null:R(n)}}const k=_;function N(t){let n=t();if(n?.scrollIntoView({block:"start"}),typeof ResizeObserver>"u")return()=>{};const e=document.documentElement,r=new AbortController;let i=n?n.getBoundingClientRect().top:0,u=e.scrollHeight;function l(o){n=o,o.scrollIntoView({block:"start"}),i=o.getBoundingClientRect().top,u=e.scrollHeight}const c=new ResizeObserver(()=>{const o=t();o&&l(o)});c.observe(document.body);function s(){n&&(Math.abs(n.getBoundingClientRect().top-i)<=k||(e.scrollHeight===u?f():l(n)))}const a=A();function E(o){a(o)&&f()}function f(){c.disconnect(),r.abort()}const d={capture:!0,passive:!0,signal:r.signal};window.addEventListener("scroll",s,d);for(const o of H)window.addEventListener(o,E,d);return f}function p(t){if(!t)return null;const n=t.split("&")[0],e=n===t?[t]:[t,n];for(const r of e){const i=document.getElementById(r)??O(r);if(i)return i}return null}function O(t){return I(t)??B(t)}function I(t){if(t.includes("[]"))return null;for(const n of document.querySelectorAll('[id*="[]"]'))if(L(n.id)===t)return n;return null}function B(t){if(t.includes("/callbacks/"))return null;for(const n of document.querySelectorAll('[id*="/callbacks/"]'))if(b(n.id)===t)return n;return null}function R(t){if(!t)return null;const n=t.replace(/["\\]/g,"\\$&");return document.querySelector(`[${w}="${n}"]`)}export{M as useApiDocsScroll};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { DeepLinkSectionData } from '../jotai/itemStore.js';
|
|
2
2
|
export declare const ItemIdContext: import("react").Context<string | undefined>;
|
|
3
|
+
/** Callback id of the enclosing callback panel, if any. See
|
|
4
|
+
* `brain/legacy-deep-link-back-compat.md` § Callbacks for the id formats. */
|
|
5
|
+
export declare const CallbackScopeContext: import("react").Context<string | undefined>;
|
|
6
|
+
export declare function useCallbackScope(): string | undefined;
|
|
7
|
+
export declare function useHashItemId(): string;
|
|
3
8
|
/** Marks an `ItemIdContext` value as a synthetic per-mount id (not a route
|
|
4
9
|
* path). Pluggable components (e.g. `RedocSchema`) provide one purely so the
|
|
5
10
|
* oneOf/discriminator switchers can key itemStore state — deep-link building
|
|
@@ -9,8 +14,10 @@ export declare const SYNTHETIC_ITEM_ID_PREFIX = "synthetic-item:";
|
|
|
9
14
|
* it comes from `ItemIdContext` separately. `null` means "no section". */
|
|
10
15
|
export type DeepLinkSectionValue = Omit<DeepLinkSectionData, 'id'>;
|
|
11
16
|
export declare const DeepLinkSectionContext: import("react").Context<DeepLinkSectionValue | null>;
|
|
12
|
-
/** Build a normalized deep-link URL for the current item using its
|
|
13
|
-
* `ItemIdContext` and the given suffix.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
17
|
+
/** Build a normalized deep-link URL for a *section* of the current item, using its
|
|
18
|
+
* `ItemIdContext` and the given suffix. Inside a callback the suffix is prefixed with
|
|
19
|
+
* `callbacks/<callbackId>` so the section cannot collide with the parent operation's.
|
|
20
|
+
* Returns `''` when no item is in scope (e.g. rendered outside a page wrapper) or when the
|
|
21
|
+
* itemId is a synthetic per-mount id (see {@link SYNTHETIC_ITEM_ID_PREFIX}). */
|
|
16
22
|
export declare function useDeepLinkUrl(suffix: string): string;
|
|
23
|
+
export declare function useFieldDeepLinkUrl(suffix: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as
|
|
1
|
+
import{createContext as i,useContext as u,useMemo as c}from"react";import{useAtomValue as p}from"jotai";import{routingBasePathAtom as a}from"../jotai/store.js";import{buildDeepLinkUrl as I,buildOpenApiSectionSuffix as C,CALLBACKS_SECTION as S}from"../utils/deep-link.js";import{joinWithSeparator as h,toRelativePath as m}from"../utils/url.js";import{useNavigationUrlNormalizer as L}from"./useNormalizeUrl.js";const l=i(void 0),k=i(void 0);function D(){return u(k)}function P(){const t=u(l),e=p(a);return c(()=>t?m(t,e).toLowerCase():"",[t,e])}const U="synthetic-item:",T=i(null);function f(t,e){const o=u(l),r=D(),n=p(a),s=L();return c(()=>{if(!o||o.startsWith(U))return"";const d=n?m(o,n):o,x=e&&r?h(C(S,r),t):t;return s(I(n,d,x))},[o,r,e,n,t,s])}function _(t){return f(t,!0)}function v(t){return f(t,!1)}export{k as CallbackScopeContext,T as DeepLinkSectionContext,l as ItemIdContext,U as SYNTHETIC_ITEM_ID_PREFIX,D as useCallbackScope,_ as useDeepLinkUrl,v as useFieldDeepLinkUrl,P as useHashItemId};
|
package/lib/jotai/app.d.ts
CHANGED
|
@@ -49,9 +49,6 @@ export declare const allowedEnvironmentsAtom: import("jotai").WritableAtom<strin
|
|
|
49
49
|
export declare const appSessionStore: import("jotai").WritableAtom<AppSessionStore, [typeof import("jotai/utils").RESET | AppSessionStore | ((prev: AppSessionStore) => typeof import("jotai/utils").RESET | AppSessionStore)], void>;
|
|
50
50
|
export declare const collapsedSidebarAtom: import("jotai").WritableAtom<boolean, boolean[], void>;
|
|
51
51
|
export declare const languageAtom: import("jotai").WritableAtom<LanguageAtom, [string], void>;
|
|
52
|
-
export declare const selectedCallbackAtom: import("jotai").PrimitiveAtom<string | null> & {
|
|
53
|
-
init: string | null;
|
|
54
|
-
};
|
|
55
52
|
export declare const selectedSecuritySchemeIdxAtom: import("jotai").PrimitiveAtom<number> & {
|
|
56
53
|
init: number;
|
|
57
54
|
};
|
package/lib/jotai/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{atom as r}from"jotai";import{atomWithStorage as v,createJSONStorage as A}from"jotai/utils";import{LayoutVariant as
|
|
1
|
+
import{atom as r}from"jotai";import{atomWithStorage as v,createJSONStorage as A}from"jotai/utils";import{LayoutVariant as y}from"@redocly/config";import{getCookie as x,removeCookie as k,setCookie as C}from"../utils/cookies.js";import{mergeEnvData as l,IS_BROWSER as E}from"../utils/environments.js";import{keepReadingSectionAnchored as N}from"../utils/scroll-anchoring.js";import{safeJsonParse as g}from"../utils/string.js";import{fromSessionStorage as O,toSessionStorage as b}from"../utils/session-storage.js";import{DEFAULT_LAYOUT as V}from"../options/constants.js";import{globalOptionsAtom as I}from"./store.js";const d={activeMimeName:"",layout:V,language:"",environment:"",environments:{},userClaims:{},allowedEnvironments:null},L={getItem:e=>{const o=g(x(e,globalThis.redoclyCookieStorage?.getStore?.())),t=g(O(e));return{...d,...t,...o}},setItem:(e,o)=>{const{environments:t,...n}=o,a={environments:t};C(e,JSON.stringify(n)),b(e,JSON.stringify(a))},removeItem:e=>{k(e),sessionStorage.removeItem(e)}},s=v("redoc.appStore",d,L),U=r(e=>{const o=e(s);return l(o.environments,{})}),W=r(e=>{const o=e(s),t=l(o.environments,{}),n=o.environment,a=Object.keys(t).find(c=>t[c]?.server===n),i=t[n]?n:a??Object.keys(t)[0];let m=t[i]||{};return!m.server&&a&&(m={...t[a],...m}),[m,i||""]},(e,o,{environment:t,environments:n})=>{const a=e(s);o(s,{...a,environment:t||a.environment,environments:l(a.environments||{},n)})}),_=r(e=>e(s).environment),p=r(e=>e(s).activeMimeName,(e,o,t)=>{const n=e(s);o(s,{...n,activeMimeName:t})}),S=r(void 0),q=r(e=>e(S)??(e(p)||void 0),(e,o,t)=>{o(S,void 0),(t??"")!==e(p)&&N(),o(p,t??"")}),B=r(e=>e(s).layout,(e,o,t=y.STACKED)=>{const n=e(s);o(s,{...n,layout:t})}),P=r(e=>e(s).userClaims,(e,o,t)=>{const n=e(s);o(s,{...n,userClaims:t})}),Y=r(e=>e(s).allowedEnvironments,(e,o,t)=>{const n=e(s);o(s,{...n,allowedEnvironments:t})}),u=v("redoc.appSessionStore",{collapsedSidebar:!1,unsupportedFeatureScreen:!1},E?A(()=>sessionStorage):void 0),z=r(e=>e(u).collapsedSidebar,(e,o,t)=>{const n=e(u);o(u,{...n,collapsedSidebar:t})}),G=r(e=>{const o=e(I),{codeSamples:t}=o;if(!t?.languages)return{languages:[],activeLanguage:e(s).language||""};const n=t.languages.map(({key:i,label:m,lang:c},f)=>({key:i,lang:c,title:m,order:f})),a=e(s).language||n[0]?.key;return{languages:n,activeLanguage:n.find(({key:i})=>i===a)?.key||n[0]?.key}},(e,o,t)=>{const n=e(s);o(s,{...n,language:t})}),H=r(0),Q=r({}),X=r(null),Z=r([]);export{q as activeMediaTypeAtom,p as activeMimeNameAtom,X as activeScrollSectionAtom,Y as allowedEnvironmentsAtom,u as appSessionStore,s as appStore,z as collapsedSidebarAtom,W as environmentAtom,U as environmentsAtom,G as languageAtom,B as layoutAtom,S as mediaTypeOverrideAtom,Q as requestValuesAtom,_ as savedEnvironmentNameAtom,H as selectedSecuritySchemeIdxAtom,P as userClaimsAtom,Z as visitedChannelsAtom};
|
package/lib/jotai/itemStore.d.ts
CHANGED
package/lib/jotai/itemStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{atom as p}from"jotai";import{selectAtom as m}from"jotai/utils";import{atomFamily as c}from"jotai-family";import{keepReadingSectionAnchored as
|
|
1
|
+
import{atom as p}from"jotai";import{selectAtom as m}from"jotai/utils";import{atomFamily as c}from"jotai-family";import{keepReadingSectionAnchored as x}from"../utils/scroll-anchoring.js";const O=Object.freeze({activeDiscriminator:Object.freeze({}),activeOneOf:Object.freeze({}),activeResponseCode:"",activeMessageKey:"",selectedCallback:"",expandableSections:Object.freeze({}),collapsibles:Object.freeze({})});function u(){return O}const l=p({}),y=["activeResponseCode","activeMessageKey","activeOneOf","activeDiscriminator"],f=c(e=>p(t=>t(l)[e]??u(),(t,n,o)=>{const i=t(l),r=i[e]??u(),a=typeof o=="function"?o(r):o;y.some(s=>s in a&&a[s]!==r[s])&&x(),n(l,{...i,[e]:{...r,...a}})})),A=c(e=>m(f(e.itemId),t=>t[e.key]),(e,t)=>e.itemId===t.itemId&&e.key===t.key);function S(e){return A(e)}function j(e,t){const n=e?.length?e.join("/"):"";return n?`${n}/${t}`:t}function R(e){return S({itemId:e,key:"activeDiscriminator"})}function D(e){return S({itemId:e,key:"activeOneOf"})}const b=c(e=>m(f(e.itemId),t=>t.expandableSections[e.key]),(e,t)=>e.itemId===t.itemId&&e.key===t.key);function F(e,t){return b({itemId:e,key:t})}const d="#";function K(e,t){return`${e}${d}${t}`}function T(e){const t=e.indexOf(d);return t===-1?e:e.slice(0,t)}const v=c(e=>m(f(e),t=>Object.keys(t.expandableSections),(t,n)=>t.length===n.length&&t.every((o,i)=>o===n[i])));function _(e){return v(e)}export{R as activeDiscriminatorSelectAtom,D as activeOneOfSelectAtom,K as buildCollapsibleEntryKey,j as buildVariantStateKey,T as collapsibleEntrySection,F as expandableSectionAtom,_ as expandableSectionKeysAtom,f as itemStoreAtom,S as itemStoreFieldAtom};
|
package/lib/utils/deep-link.d.ts
CHANGED
|
@@ -136,6 +136,28 @@ export declare function variantMarkersOnly(fieldParentsName: string[] | undefine
|
|
|
136
136
|
* The search is case-insensitive and values are returned lowercased.
|
|
137
137
|
*/
|
|
138
138
|
export declare function extractDeepLinkParamFromHash(hash: string, key: 'c' | 'm'): string | undefined;
|
|
139
|
+
/** Section name owning a callback's suffixes: `callbacks/<callbackId>[/…]`. */
|
|
140
|
+
export declare const CALLBACKS_SECTION = "callbacks";
|
|
141
|
+
/** Sub-section anchors a callback owns. Emitted by `CallbacksSection` and matched here, so
|
|
142
|
+
* the spelling is a contract — legacy openapi-docs links use these exact names. */
|
|
143
|
+
export declare const CALLBACK_REQUEST_SECTION = "callback-request";
|
|
144
|
+
export declare const CALLBACK_RESPONSE_SECTION = "callback-response";
|
|
145
|
+
export declare function stripCallbacksSegment(id: string): string;
|
|
146
|
+
/** Whether a hash id addresses the given item at all — it, or anything beneath it. */
|
|
147
|
+
export declare function hashIsForItem(hashId: string, itemId: string): boolean;
|
|
148
|
+
/** `itemId` must be in hash shape (basePath-free, lowercased); two operations can hold a
|
|
149
|
+
* callback with the same id, so the item has to match before the callback does. Any missing
|
|
150
|
+
* argument answers `false`, so callers needn't pre-check. */
|
|
151
|
+
export declare function hashTargetsCallback(hash: string, itemId: string, callbackId: string | undefined): boolean;
|
|
152
|
+
/** Whether a hash id addresses something inside the given callback.
|
|
153
|
+
* `hashId` and `itemId` are expected lowercased, as `hashToElementId` returns them. */
|
|
154
|
+
export declare function hashIsInsideCallback(hashId: string, itemId: string, callbackId: string): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Whether a hash id addresses the operation level, outside every callback. Only the part of
|
|
157
|
+
* the hash *after* the item id is examined, so an operation or tag whose own slug contains a
|
|
158
|
+
* marker (`/callback-response`) can't be mistaken for one either.
|
|
159
|
+
*/
|
|
160
|
+
export declare function hashIsOutsideCallbacks(hashId: string, itemId: string): boolean;
|
|
139
161
|
/**
|
|
140
162
|
* Detect legacy openapi hash patterns and return normalized suffix.
|
|
141
163
|
* Matches: #tag/..., #operation/..., #paths/...
|