@redocly/openapi-docs 3.23.0-next.2 → 3.23.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.
@@ -1 +1 @@
1
- import{Fragment as M,jsx as o,jsxs as z}from"react/jsx-runtime";import{lazy as H,memo as J,Suspense as K,useCallback as m,useRef as W,useState as w}from"react";import{useAtom as d,useAtomValue as p}from"jotai";import Q from"deepmerge";const X=H(async()=>import("@redocly/replay").then(e=>({default:e.ReplayOverlay})));import{Button as Y}from"@redocly/theme/components/Button/Button";import{useFocusTrap as Z,useModalScrollLock as $}from"@redocly/theme/core/openapi";import{RocketIcon as ee}from"@redocly/theme/icons/RocketIcon/RocketIcon";import{CircleDashIcon as te}from"@redocly/theme/icons/CircleDashIcon/CircleDashIcon";import{Portal as oe}from"@redocly/theme/components/Portal/Portal";import{useConfigureReplay as re}from"@redocly/theme/ext/use-configure-replay";import{globalOptionsAtom as ne,globalStoreAtom as ae}from"../../jotai/store.js";import{allOperationsAtom as se,replayStateAtom as ie}from"../../jotai/replay.js";import{allOperations as le,getDefaultOperationStore as me}from"../../jotai/operation.js";import{LOADING_STATE as n}from"../../constants.js";import{environmentAtom as pe,userClaimsAtom as ce}from"../../jotai/app.js";import{convertOperationToReplayValueForRedoc as ue}from"./utils.js";import{useTranslate as fe,useTelemetry as de}from"../../hooks/index.js";import{JsonPointer as ye}from"../../utils/index.js";import{getDefaultCollectorUrl as he}from"../../utils/telemetry.js";import{createTryItOpenEvent as Ie,createTryItSentEvent as Oe}from"../../events/index.js";import{joinWithSeparator as Re}from"../../services/history/helpers.js";import{HTTPSnippet as ge}from"../../services/code-samples/httpsnippet/index.js";function ve({operation:e,corsProxyUrl:V,fullOpenApi:y}){const h=fe(),q=de(),I=W(null),O=p(ne),{oAuth2RedirectURI:E,routingBasePath:c}=O,R=p(se),{parser:g,options:{events:a}}=p(ae),v=p(ce),[s,N]=w(!1),[l,A]=d(ie),[u,S]=d(le),[[,j],T]=d(pe),{config:b,refresh:D}=re({userClaims:v,info:g?.definition.info,operation:{name:e.name,path:e.path,operationId:e.operationId||"",href:e.href,method:e.httpVerb},servers:e.servers},s);Z(I),$(s);const x=m(()=>D(),[D]),G=m(({operations:t,environment:i,environments:f})=>{const k=t.reduce((L,r)=>{r.requestValues.body=r.requestValues.body instanceof URLSearchParams?Object.fromEntries(r.requestValues.body.entries()):r.requestValues.body;const{path:B,method:F}=r.apiPath,P=ye.compile(["paths",B,F]);return L[P]=Q(me(P),r),L},{});S({...u,...k}),T({environment:i,environments:f})},[u,S,T]),C=()=>{if(l!==n.LOADING){if(!s&&(q.sendTryItOpenedMessage([{id:"tryItButton",object:"button",uri:"urn:redocly:redoc:ui:button:tryItButton"}]),a?.tryItOpen&&e)){const t=Ie({operation:e});a.tryItOpen(t)}N(!s)}l===n.NOT_LOADED&&A(n.LOADING)},U=m(t=>{if(a?.tryItSent&&e){const i=Oe({operation:e,isSuccess:t});a.tryItSent(i)}},[a,e]),_=m(t=>{if(!t)return;const i=R.find(f=>f.operationId===t);return Re(c,i?.href)},[R,c]);return y?z(M,{children:[o(Y,{onClick:C,variant:"primary",iconPosition:"left",icon:l===n.LOADING?o(te,{}):o(ee,{}),children:l===n.LOADING?h("openapi.loading","Loading..."):h("openapi.tryIt","Try it")}),s&&o(K,{children:o(oe,{mountId:"api-content",children:o("div",{ref:I,children:o(X,{activeOperationId:e.operationId||e.pointer,api:y,onRequestChange:G,onClose:C,onLoad:()=>A(n.LOADED),settings:{corsProxyUrl:V,selectedEnvironment:j,apiId:g?.definition.info?.["x-metadata"]?.apiId,oAuth2RedirectURI:E,disableCollectionsTab:!0,storageKey:c,telemetry:{tracerName:"try-it",collectorUrl:he()},HTTPSnippet:ge,convertOperationToReplayValue:ue(v,b,O,u),dynamicReplayValues:b,getOperationUrl:_,onRequestReset:x},onRequestSent:U})})})})]}):null}const He=J(ve);export{He as Replay};
1
+ import{Fragment as K,jsx as o,jsxs as W}from"react/jsx-runtime";import{lazy as w,memo as Q,Suspense as X,useCallback as d,useMemo as O,useRef as Y,useState as Z}from"react";import{useAtom as g,useAtomValue as y}from"jotai";import $ from"deepmerge";const ee=w(async()=>import("@redocly/replay").then(e=>({default:e.ReplayOverlay})));import{Button as te}from"@redocly/theme/components/Button/Button";import{useFocusTrap as oe,useModalScrollLock as re}from"@redocly/theme/core/openapi";import{RocketIcon as ne}from"@redocly/theme/icons/RocketIcon/RocketIcon";import{CircleDashIcon as se}from"@redocly/theme/icons/CircleDashIcon/CircleDashIcon";import{Portal as ae}from"@redocly/theme/components/Portal/Portal";import{useConfigureReplay as ie}from"@redocly/theme/ext/use-configure-replay";import{globalOptionsAtom as le,globalStoreAtom as me}from"../../jotai/store.js";import{allOperationsAtom as ce,replayStateAtom as pe}from"../../jotai/replay.js";import{allOperations as fe,getDefaultOperationStore as ue}from"../../jotai/operation.js";import{LOADING_STATE as n}from"../../constants.js";import{environmentAtom as de,userClaimsAtom as ye}from"../../jotai/app.js";import{convertOperationToReplayValueForRedoc as he}from"./utils.js";import{useTranslate as Ie,useTelemetry as Oe}from"../../hooks/index.js";import{JsonPointer as ge}from"../../utils/index.js";import{getDefaultCollectorUrl as Re}from"../../utils/telemetry.js";import{createTryItOpenEvent as ve,createTryItSentEvent as Se}from"../../events/index.js";import{joinWithSeparator as Ae}from"../../services/history/helpers.js";import{HTTPSnippet as Te}from"../../services/code-samples/httpsnippet/index.js";function be({operation:e,corsProxyUrl:R,fullOpenApi:v}){const S=Ie(),_=Oe(),A=Y(null),h=y(le),{oAuth2RedirectURI:T,routingBasePath:l}=h,b=y(ce),{parser:m,options:{events:s}}=y(me),c=y(ye),[a,k]=Z(!1),[p,C]=g(pe),[f,D]=g(fe),[[,L],V]=g(de),B=O(()=>({userClaims:c,info:m?.definition.info,operation:{name:e.name,path:e.path,operationId:e.operationId||"",href:e.href,method:e.httpVerb},servers:e.servers}),[c,m?.definition.info,e.name,e.path,e.operationId,e.href,e.httpVerb,e.servers]),{config:u,refresh:P}=ie(B,a),q=d(()=>P(),[P]),E=d(t=>{if(!t)return;const i=b.find(I=>I.operationId===t);return Ae(l,i?.href)},[b,l]),N=O(()=>he(c,u,h,f),[c,u,h,f]),F=O(()=>({corsProxyUrl:R,selectedEnvironment:L,apiId:m?.definition.info?.["x-metadata"]?.apiId,oAuth2RedirectURI:T,disableCollectionsTab:!0,storageKey:l,telemetry:{tracerName:"try-it",collectorUrl:Re()},HTTPSnippet:Te,convertOperationToReplayValue:N,dynamicReplayValues:u,getOperationUrl:E,onRequestReset:q}),[R,L,m?.definition.info,T,l,N,u,E,q]);oe(A),re(a);const U=d(({operations:t,environment:i,environments:I})=>{const z=t.reduce((x,r)=>{r.requestValues.body=r.requestValues.body instanceof URLSearchParams?Object.fromEntries(r.requestValues.body.entries()):r.requestValues.body;const{path:H,method:J}=r.apiPath,G=ge.compile(["paths",H,J]);return x[G]=$(ue(G),r),x},{});D({...f,...z}),V({environment:i,environments:I})},[f,D,V]),j=()=>{if(p!==n.LOADING){if(!a&&(_.sendTryItOpenedMessage([{id:"tryItButton",object:"button",uri:"urn:redocly:redoc:ui:button:tryItButton"}]),s?.tryItOpen&&e)){const t=ve({operation:e});s.tryItOpen(t)}k(!a)}p===n.NOT_LOADED&&C(n.LOADING)},M=d(t=>{if(s?.tryItSent&&e){const i=Se({operation:e,isSuccess:t});s.tryItSent(i)}},[s,e]);return v?W(K,{children:[o(te,{onClick:j,variant:"primary",iconPosition:"left",icon:p===n.LOADING?o(se,{}):o(ne,{}),children:p===n.LOADING?S("openapi.loading","Loading..."):S("openapi.tryIt","Try it")}),a&&o(X,{children:o(ae,{mountId:"api-content",children:o("div",{ref:A,children:o(ee,{activeOperationId:e.operationId||e.pointer,api:v,onRequestChange:U,onClose:j,onLoad:()=>C(n.LOADED),settings:F,onRequestSent:M})})})})]}):null}const we=Q(be);export{we as Replay};
@@ -1,5 +1,5 @@
1
1
  import type { OperationModel, SecurityCredentials, FieldModel } from '../models/types.js';
2
- import type { ConfigureRequestValues, ConfigureServerRequestValues, SecurityDetails } from '@redocly/theme/ext/configure';
2
+ import { isDirectConfigureRequestValues, type ConfigureRequestValues, type ConfigureServerRequestValues, type SecurityDetails } from '@redocly/theme/ext/configure';
3
3
  export declare function updateOperationWithRequestValues(operation: OperationModel, userDefinedRequestValues: ConfigureRequestValues | ConfigureServerRequestValues): void;
4
4
  export declare function updateParametersWithUserValues(param: FieldModel, userDefinedRequestValues?: ConfigureRequestValues | ConfigureServerRequestValues): void;
5
5
  export declare function updateRequestBodyWithUserValues(operation: OperationModel, userDefinedRequestValues: ConfigureRequestValues, serverUrl?: string): OperationModel | undefined;
@@ -7,6 +7,7 @@ export declare function updateSecurityWithUserValues(operation: OperationModel,
7
7
  export declare function updateOperationWithServerUserValues(operation: OperationModel, serverRequestValues: ConfigureServerRequestValues): void;
8
8
  export declare function updateEnvVariablesWithUserValues(operation: OperationModel, environmentValues?: Record<string, string>, serverUrl?: string): void;
9
9
  export declare function updateServerVariablesWithUserValues(operation: OperationModel, serverVariables?: Record<string, string>, serverUrl?: string): void;
10
- export declare function isDirectRequestValues(value: any): value is ConfigureRequestValues;
10
+ /** @deprecated Use `isDirectConfigureRequestValues` from `@redocly/theme/ext/configure`. */
11
+ export declare const isDirectRequestValues: typeof isDirectConfigureRequestValues;
11
12
  export declare function updateObjectProperties(original: any, updates: any): any;
12
13
  export declare function createSecurityUpdates(scheme: any, securityValues: Record<string, SecurityDetails>): SecurityCredentials;
@@ -1 +1 @@
1
- import{isObject as k}from"@redocly/theme/core/openapi";function p(e,r){Object.keys(r).length!==0&&(h(r)?(b(e,r),y(e,r.security),d(e,r.envVariables),v(e,r.serverVariables)):j(e,r))}function O(e,r){if(!r)return;const{in:s,name:t}=e;if(h(r)){const a=r,c={header:a.headers,query:a.query,path:a.path,cookie:a.cookie};s&&c[s]?.[t]&&(e.example=c[s][t])}else Object.entries(r).forEach(([a,c])=>{const f=c;if(!f)return;const n={header:f.headers,query:f.query,path:f.path,cookie:f.cookie};s&&n[s]?.[t]&&(e.serverValues||(e.serverValues={}),e.serverValues[a]={example:n[s][t]})})}function b(e,r,s){if(!e.requestBody||!r?.body)return;const t=e.requestBody.content;if(!t?.mediaTypes)return;const a=(c,f)=>{c[f]&&Object.keys(c[f]).forEach(n=>{const o=c[f]?.[n]?.value;let l;if(k(o)?l=u(o,r.body):l=r.body,!!l)if(s){const i=c[f][n];i.serverValues||(i.serverValues={}),i.serverValues[s]={value:l,rawValue:l},c[f][n]={...i,mime:c.name}}else c[f][n]={value:l,rawValue:l,mime:c.name}})};for(const c of t.mediaTypes)a(c,"examples"),a(c,"formExamples");return e}function y(e,r,s){!r||!e.security.length||e.security.forEach(t=>{s?t.schemes.forEach(a=>{a.serverValues||(a.serverValues={});const c=V(a,r);a.serverValues[s]=c}):t.schemes.forEach(a=>{const c=V(a,r);Object.assign(a,c)})})}function j(e,r){e.servers.forEach(s=>{if(r[s.url]){const t=r[s.url];t&&(b(e,t,s.url),y(e,t.security,s.url),d(e,t.envVariables,s.url),v(e,t.serverVariables,s.url))}})}function d(e,r,s){!r||Object.keys(r).length===0||(e.envVariables||(e.envVariables={}),s?(e.envVariables.serverValues||(e.envVariables.serverValues={}),e.envVariables.serverValues[s]={...e.envVariables.serverValues[s],...r}):e.envVariables.values={...e.envVariables.values,...r})}function v(e,r,s){if(!(!r||Object.keys(r).length===0))if(s){const t=e.servers.find(a=>a.url===s);if(t){t.variables||(t.variables={});for(const[a,c]of Object.entries(r))t.variables[a]&&(t.variables[a].default=c)}}else e.servers.forEach(t=>{t.variables||(t.variables={});for(const[a,c]of Object.entries(r))t.variables[a]&&(t.variables[a].default=c)})}function h(e){return!e||typeof e!="object"?!1:"headers"in e||"body"in e||"query"in e||"path"in e||"cookie"in e||"security"in e||"envVariables"in e||"serverVariables"in e}function u(e,r){if(!e||typeof e!="object")return r;if(Array.isArray(e)&&Array.isArray(r)){if(e.length>0&&typeof e[0]=="object"&&e[0]!==null){const t=Object.keys(e[0]),a=r.filter(c=>typeof c!="object"||c===null?!1:t.some(f=>f in c)&&Object.keys(c).every(f=>t.includes(f)));return a.length>0?a:e}return r}const s=Array.isArray(e)?[...e]:{...e};for(const[t,a]of Object.entries(r))t in e&&(Array.isArray(e[t])||typeof a=="object"&&a!==null&&typeof e[t]=="object"?s[t]=u(e[t],a):s[t]=a);return s}function V(e,r){const s=r?.[e.id]||r?.default||{},t={"x-defaultAccessToken":s.token?.access_token,"x-defaultTokenType":s.token?.token_type||"Bearer","x-defaultClientId":s.client_id,"x-defaultClientSecret":s.client_secret,scopes:s.scopes||e.scopes};return e.type==="http"&&e.scheme==="basic"?(t["x-defaultUsername"]=s.username,t["x-defaultPassword"]=s.password,delete t["x-defaultAccessToken"],delete t["x-defaultTokenType"]):e.type==="oauth2"&&!s.token?.access_token&&(delete t["x-defaultAccessToken"],delete t["x-defaultTokenType"]),t}export{V as createSecurityUpdates,h as isDirectRequestValues,d as updateEnvVariablesWithUserValues,u as updateObjectProperties,p as updateOperationWithRequestValues,j as updateOperationWithServerUserValues,O as updateParametersWithUserValues,b as updateRequestBodyWithUserValues,y as updateSecurityWithUserValues,v as updateServerVariablesWithUserValues};
1
+ import{isDirectConfigureRequestValues as o}from"@redocly/theme/ext/configure";import{isObject as k}from"@redocly/theme/core/openapi";function O(e,r){Object.keys(r).length!==0&&(o(r)?(v(e,r),y(e,r.security),d(e,r.envVariables),V(e,r.serverVariables)):x(e,r))}function A(e,r){if(!r)return;const{in:s,name:t}=e;if(o(r)){const a=r,c={header:a.headers,query:a.query,path:a.path,cookie:a.cookie};s&&c[s]?.[t]&&(e.example=c[s][t])}else Object.entries(r).forEach(([a,c])=>{const l=c;if(!l)return;const f={header:l.headers,query:l.query,path:l.path,cookie:l.cookie};s&&f[s]?.[t]&&(e.serverValues||(e.serverValues={}),e.serverValues[a]={example:f[s][t]})})}function v(e,r,s){if(!e.requestBody||!r?.body)return;const t=e.requestBody.content;if(!t?.mediaTypes)return;const a=(c,l)=>{c[l]&&Object.keys(c[l]).forEach(f=>{const b=c[l]?.[f]?.value;let u;if(k(b)?u=i(b,r.body):u=r.body,!!u)if(s){const n=c[l][f];n.serverValues||(n.serverValues={}),n.serverValues[s]={value:u,rawValue:u},c[l][f]={...n,mime:c.name}}else c[l][f]={value:u,rawValue:u,mime:c.name}})};for(const c of t.mediaTypes)a(c,"examples"),a(c,"formExamples");return e}function y(e,r,s){!r||!e.security.length||e.security.forEach(t=>{s?t.schemes.forEach(a=>{a.serverValues||(a.serverValues={});const c=h(a,r);a.serverValues[s]=c}):t.schemes.forEach(a=>{const c=h(a,r);Object.assign(a,c)})})}function x(e,r){e.servers.forEach(s=>{if(r[s.url]){const t=r[s.url];t&&(v(e,t,s.url),y(e,t.security,s.url),d(e,t.envVariables,s.url),V(e,t.serverVariables,s.url))}})}function d(e,r,s){!r||Object.keys(r).length===0||(e.envVariables||(e.envVariables={}),s?(e.envVariables.serverValues||(e.envVariables.serverValues={}),e.envVariables.serverValues[s]={...e.envVariables.serverValues[s],...r}):e.envVariables.values={...e.envVariables.values,...r})}function V(e,r,s){if(!(!r||Object.keys(r).length===0))if(s){const t=e.servers.find(a=>a.url===s);if(t){t.variables||(t.variables={});for(const[a,c]of Object.entries(r))t.variables[a]&&(t.variables[a].default=c)}}else e.servers.forEach(t=>{t.variables||(t.variables={});for(const[a,c]of Object.entries(r))t.variables[a]&&(t.variables[a].default=c)})}const E=o;function i(e,r){if(!e||typeof e!="object")return r;if(Array.isArray(e)&&Array.isArray(r)){if(e.length>0&&typeof e[0]=="object"&&e[0]!==null){const t=Object.keys(e[0]),a=r.filter(c=>typeof c!="object"||c===null?!1:t.some(l=>l in c)&&Object.keys(c).every(l=>t.includes(l)));return a.length>0?a:e}return r}const s=Array.isArray(e)?[...e]:{...e};for(const[t,a]of Object.entries(r))t in e&&(Array.isArray(e[t])||typeof a=="object"&&a!==null&&typeof e[t]=="object"?s[t]=i(e[t],a):s[t]=a);return s}function h(e,r){const s=r?.[e.id]||r?.default||{},t={"x-defaultAccessToken":s.token?.access_token,"x-defaultTokenType":s.token?.token_type||"Bearer","x-defaultClientId":s.client_id,"x-defaultClientSecret":s.client_secret,scopes:s.scopes||e.scopes};return e.type==="http"&&e.scheme==="basic"?(t["x-defaultUsername"]=s.username,t["x-defaultPassword"]=s.password,delete t["x-defaultAccessToken"],delete t["x-defaultTokenType"]):e.type==="oauth2"&&!s.token?.access_token&&(delete t["x-defaultAccessToken"],delete t["x-defaultTokenType"]),t}export{h as createSecurityUpdates,E as isDirectRequestValues,d as updateEnvVariablesWithUserValues,i as updateObjectProperties,O as updateOperationWithRequestValues,x as updateOperationWithServerUserValues,A as updateParametersWithUserValues,v as updateRequestBodyWithUserValues,y as updateSecurityWithUserValues,V as updateServerVariablesWithUserValues};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/openapi-docs",
3
- "version": "3.23.0-next.2",
3
+ "version": "3.23.0-next.4",
4
4
  "description": "Redocly OpenAPI Docs",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -24,7 +24,7 @@
24
24
  "@markdoc/markdoc": "0.5.2",
25
25
  "@redocly/openapi-core": "2.32.1",
26
26
  "deepmerge": "^4.2.2",
27
- "dompurify": "3.4.0",
27
+ "dompurify": "3.4.10",
28
28
  "fast-deep-equal": "^3.1.3",
29
29
  "fast-xml-parser": "5.7.3",
30
30
  "jotai": "^2.12.5",
@@ -41,7 +41,7 @@
41
41
  "web-vitals": "3.3.1",
42
42
  "@redocly/config": "0.49.0",
43
43
  "@redocly/redoc-opentelemetry": "0.2.1",
44
- "@redocly/replay": "0.26.0-next.2"
44
+ "@redocly/replay": "0.26.0-next.4"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@shikijs/transformers": "3.21.0",
@@ -57,7 +57,7 @@
57
57
  "@vitest/coverage-v8": "4.1.8",
58
58
  "esbuild": "0.28.1",
59
59
  "jest-styled-components": "7.2.0",
60
- "js-yaml": "4.1.1",
60
+ "js-yaml": "4.2.0",
61
61
  "json-schema": "0.4.0",
62
62
  "outdent": "0.8.0",
63
63
  "path-browserify": "1.0.1",
@@ -71,7 +71,7 @@
71
71
  "url": "~0.11.0",
72
72
  "vite": "7.3.3",
73
73
  "vitest": "4.1.8",
74
- "@redocly/theme": "0.67.0-next.1"
74
+ "@redocly/theme": "0.67.0-next.3"
75
75
  },
76
76
  "scripts": {
77
77
  "start": "pnpm run copy-highlight-hook && vite",