@redocly/replay 0.5.8 → 0.5.9

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/dist/replay.cjs CHANGED
@@ -2522,7 +2522,7 @@ Please report this to https://github.com/markedjs/marked.`,e.silent)return"<p>An
2522
2522
  display: flex;
2523
2523
  height: 100vh;
2524
2524
  background-color: var(--bg-color);
2525
- `;function die(t){const e=qT(t),n=Ev(t),r=XU(t),i=LU(t),o=t.request.get().body.activeExampleName,s=t.request.get().body.type,a=Iv(t);return{requestValues:{cookie:r,header:e,query:i,body:n},activeExampleName:o,activeMimeName:s,environment:(a==null?void 0:a.name)||(a==null?void 0:a.url),activeSecuritySchemeIds:t.request.security.get().selectedSecuritySchemeId.split("_"),environments:Object.fromEntries(Object.entries(t.environments.get()).map(([,l])=>[l.name,{...Object.fromEntries(l.variables.map(({name:c,value:u})=>[c,u])),server:l.url||""}]))}}function hie(t,e){const{servers:n,parameters:r}=t,i=r.filter(s=>s.in==="path"),o=pie(t);return n.map(s=>{const a=s.url,l=s.description||a,c=s.variables||{},u=Object.entries(c).map(([m,g])=>{const x=dl.getEnvironmentVariableByName(l,m,br.Server);return{id:crypto.randomUUID(),name:m,value:(x==null?void 0:x.value)||g.default,type:br.Server,canBeRemoved:!1,canBeEdited:!0,readonlyName:!0}}),f=i.map(({name:m})=>{const g=dl.getEnvironmentVariableByName(l,m,br.Path);return{id:crypto.randomUUID(),name:m,value:(g==null?void 0:g.value)||"",type:br.Path,canBeRemoved:!1,canBeEdited:!0,readonlyName:!0}}),d=o.map(m=>{const g=dl.getEnvironmentVariableByName(l,m.name,br.Security);return{...m,value:(g==null?void 0:g.value)||m.value}}),h=dl.getEnvironmentByName(l),p=(h==null?void 0:h.variables.filter(m=>m.type===br.UserCreated))||[];return{id:crypto.randomUUID(),name:l,url:a,state:yr.Normal,canBeRemoved:!1,canBeEdited:!1,variables:gie([...p,{id:crypto.randomUUID(),name:"server",value:qd(a),type:br.ServerUrl,canBeRemoved:!1,canBeEdited:!1},...u,...f,...d],e==null?void 0:e[l])}})}function pie(t){var i;const e=[],n=((i=t.security)==null?void 0:i.flat())||[],r=new Set;return n.forEach(o=>{const s=Rv(o);if(r.has(s))return;const a=o.id;r.add(s),(s===te.BasicAuth||s===te.DigestAuth)&&(e.push(Kr(a+M.SecurityVariablesEnvSuffix.Username,!1)),e.push(Kr(a+M.SecurityVariablesEnvSuffix.Password))),s===te.JWT&&e.push(Kr(a+M.SecurityVariablesEnvSuffix.JWTToken)),s===te.APIKey&&e.push(Kr(a+M.SecurityVariablesEnvSuffix.APIKey)),s===te.OAuth2&&(e.push(Kr(a+M.SecurityVariablesEnvSuffix.Token)),jv(o).forEach(c=>{e.push(Kr(a+M.SecurityVariablesEnvSuffix.ClientId)),c!==ce.Implicit&&e.push(Kr(a+M.SecurityVariablesEnvSuffix.ClientSecret))})),s===te.OpenIDConnect&&(e.push(Kr(a+M.SecurityVariablesEnvSuffix.Token)),e.push(Kr(a+M.SecurityVariablesEnvSuffix.ClientId)),e.push(Kr(a+M.SecurityVariablesEnvSuffix.ClientSecret)))}),e}function Kr(t,e){return{id:crypto.randomUUID(),name:t,value:"",type:br.Security,canBeRemoved:!1,canBeEdited:!0,isSecret:e===void 0?!0:e}}function gie(t,e){return e?t.map(n=>{const r=e[n.name];return r!==void 0?{...n,canBeRemoved:!1,value:n.type===br.ServerUrl?qd(r):r}:n}):t}function mie(t){const{operation:e,request:n}=t,r=n.body;$v(e.get({noproxy:!0}))[r.type.get({noproxy:!0})]||r.set(l$(e.get({noproxy:!0})))}function Hv({value:t,disableDraft:e,...n}){const r=De(),{updateTransaction:i}=nh(),{operation:o,corsProxyUrl:s,environments:a,operationUrl:l,mockServer:c,selectedEnvironmentId:u,apiId:f,oAuth2RedirectURI:d,definitionUrl:h,disableCollectionsTab:p}=r;return _.useEffect(()=>{const m=n.operationUrl&&!e?C$.getByKey(n.operationUrl):null;if(t){const g=Ft(t),x=hie(g,n.predefinedEnvValues),v=x.find(({name:S,url:b})=>b===(n==null?void 0:n.environment)||S===(n==null?void 0:n.environment));o.set(g),a.set(x),v&&u.set(v.id);const y=m||Tv(g);i({request:y,response:null},null)}s.set(n.corsProxyUrl??kU),l.set(n.operationUrl),c.set(n.mockServer),f.set(n.apiId),d.set(n.oAuth2RedirectURI),h.set(n.definitionUrl),p.set(n.disableCollectionsTab),zT(r),mie(r)},[t]),r}function Oie(t){return Hv(t),O.jsx(_.StrictMode,{children:O.jsx(ZR,{})})}function vie({onClose:t,onLoad:e,onRequestChange:n,...r}){const i=_.useRef(null),{sendEvent:o}=gt(),s=De(),a=Hv(r),l=_.useCallback(()=>{var u;if(n){const f=a.isLinked.get(),d=die(a);n(f?d:{requestValues:{}})}o("replay_closed",{operationName:(u=r.value)==null?void 0:u.name}),t(),s.set(vc())},[t,n,a,r.value,o,s]);_.useEffect(()=>{var u;e==null||e(),o("replay_opened",{operationName:(u=r.value)==null?void 0:u.name})},[]),_.useEffect(()=>{i.current&&i.current.focus()},[]);const c=u=>{u.key==="Enter"&&(u.preventDefault(),l())};return O.jsx(_.StrictMode,{children:O.jsxs(FP,{onClick:l,children:[O.jsx(yie,{onClick:l,role:"button",onKeyDown:c,tabIndex:0,ref:i,autoFocus:!0,children:O.jsx(bie,{})}),O.jsx(xie,{})]})})}const xie=$(ZR)`
2525
+ `;function die(t){const e=qT(t),n=Ev(t),r=XU(t),i=LU(t),o=t.request.get().body.activeExampleName,s=t.request.get().body.type,a=Iv(t);return{requestValues:{cookie:r,header:e,query:i,body:n},activeExampleName:o,activeMimeName:s,environment:(a==null?void 0:a.name)||(a==null?void 0:a.url),activeSecuritySchemeIds:t.request.security.get().selectedSecuritySchemeId.split("_"),environments:Object.fromEntries(Object.entries(t.environments.get()).map(([,l])=>[l.name,{...Object.fromEntries(l.variables.map(({name:c,value:u})=>[c,u])),server:l.url||""}]))}}function hie(t,e){const{servers:n,parameters:r}=t,i=r.filter(s=>s.in==="path"),o=pie(t);return n.map(s=>{const a=s.url,l=s.description||a,c=s.variables||{},u=Object.entries(c).map(([m,g])=>{const x=dl.getEnvironmentVariableByName(l,m,br.Server);return{id:crypto.randomUUID(),name:m,value:(x==null?void 0:x.value)||g.default||"",type:br.Server,canBeRemoved:!1,canBeEdited:!0,readonlyName:!0}}),f=i.map(({name:m})=>{const g=dl.getEnvironmentVariableByName(l,m,br.Path);return{id:crypto.randomUUID(),name:m,value:(g==null?void 0:g.value)||"",type:br.Path,canBeRemoved:!1,canBeEdited:!0,readonlyName:!0}}),d=o.map(m=>{const g=dl.getEnvironmentVariableByName(l,m.name,br.Security);return{...m,value:(g==null?void 0:g.value)||m.value||""}}),h=dl.getEnvironmentByName(l),p=(h==null?void 0:h.variables.filter(m=>m.type===br.UserCreated))||[];return{id:crypto.randomUUID(),name:l,url:a,state:yr.Normal,canBeRemoved:!1,canBeEdited:!1,variables:gie([...p,{id:crypto.randomUUID(),name:"server",value:qd(a),type:br.ServerUrl,canBeRemoved:!1,canBeEdited:!1},...u,...f,...d],e==null?void 0:e[l])}})}function pie(t){var i;const e=[],n=((i=t.security)==null?void 0:i.flat())||[],r=new Set;return n.forEach(o=>{const s=Rv(o);if(r.has(s))return;const a=o.id;r.add(s),(s===te.BasicAuth||s===te.DigestAuth)&&(e.push(Kr(a+M.SecurityVariablesEnvSuffix.Username,!1)),e.push(Kr(a+M.SecurityVariablesEnvSuffix.Password))),s===te.JWT&&e.push(Kr(a+M.SecurityVariablesEnvSuffix.JWTToken)),s===te.APIKey&&e.push(Kr(a+M.SecurityVariablesEnvSuffix.APIKey)),s===te.OAuth2&&(e.push(Kr(a+M.SecurityVariablesEnvSuffix.Token)),jv(o).forEach(c=>{e.push(Kr(a+M.SecurityVariablesEnvSuffix.ClientId)),c!==ce.Implicit&&e.push(Kr(a+M.SecurityVariablesEnvSuffix.ClientSecret))})),s===te.OpenIDConnect&&(e.push(Kr(a+M.SecurityVariablesEnvSuffix.Token)),e.push(Kr(a+M.SecurityVariablesEnvSuffix.ClientId)),e.push(Kr(a+M.SecurityVariablesEnvSuffix.ClientSecret)))}),e}function Kr(t,e){return{id:crypto.randomUUID(),name:t,value:"",type:br.Security,canBeRemoved:!1,canBeEdited:!0,isSecret:e===void 0?!0:e}}function gie(t,e){return e?t.map(n=>{const r=e[n.name];return r!==void 0?{...n,canBeRemoved:!1,value:n.type===br.ServerUrl?qd(r):r}:n}):t}function mie(t){const{operation:e,request:n}=t,r=n.body;$v(e.get({noproxy:!0}))[r.type.get({noproxy:!0})]||r.set(l$(e.get({noproxy:!0})))}function Hv({value:t,disableDraft:e,...n}){const r=De(),{updateTransaction:i}=nh(),{operation:o,corsProxyUrl:s,environments:a,operationUrl:l,mockServer:c,selectedEnvironmentId:u,apiId:f,oAuth2RedirectURI:d,definitionUrl:h,disableCollectionsTab:p}=r;return _.useEffect(()=>{const m=n.operationUrl&&!e?C$.getByKey(n.operationUrl):null;if(t){const g=Ft(t),x=hie(g,n.predefinedEnvValues),v=x.find(({name:S,url:b})=>b===(n==null?void 0:n.environment)||S===(n==null?void 0:n.environment));o.set(g),a.set(x),v&&u.set(v.id);const y=m||Tv(g);i({request:y,response:null},null)}s.set(n.corsProxyUrl??kU),l.set(n.operationUrl),c.set(n.mockServer),f.set(n.apiId),d.set(n.oAuth2RedirectURI),h.set(n.definitionUrl),p.set(n.disableCollectionsTab),zT(r),mie(r)},[t]),r}function Oie(t){return Hv(t),O.jsx(_.StrictMode,{children:O.jsx(ZR,{})})}function vie({onClose:t,onLoad:e,onRequestChange:n,...r}){const i=_.useRef(null),{sendEvent:o}=gt(),s=De(),a=Hv(r),l=_.useCallback(()=>{var u;if(n){const f=a.isLinked.get(),d=die(a);n(f?d:{requestValues:{}})}o("replay_closed",{operationName:(u=r.value)==null?void 0:u.name}),t(),s.set(vc())},[t,n,a,r.value,o,s]);_.useEffect(()=>{var u;e==null||e(),o("replay_opened",{operationName:(u=r.value)==null?void 0:u.name})},[]),_.useEffect(()=>{i.current&&i.current.focus()},[]);const c=u=>{u.key==="Enter"&&(u.preventDefault(),l())};return O.jsx(_.StrictMode,{children:O.jsxs(FP,{onClick:l,children:[O.jsx(yie,{onClick:l,role:"button",onKeyDown:c,tabIndex:0,ref:i,autoFocus:!0,children:O.jsx(bie,{})}),O.jsx(xie,{})]})})}const xie=$(ZR)`
2526
2526
  width: 80vw;
2527
2527
  `,yie=$.div`
2528
2528
  display: flex;
package/dist/replay.js CHANGED
@@ -59636,7 +59636,7 @@ function Woe(t, e) {
59636
59636
  return {
59637
59637
  id: crypto.randomUUID(),
59638
59638
  name: m,
59639
- value: (x == null ? void 0 : x.value) || g.default,
59639
+ value: (x == null ? void 0 : x.value) || g.default || "",
59640
59640
  type: Er.Server,
59641
59641
  canBeRemoved: !1,
59642
59642
  canBeEdited: !0,
@@ -59665,7 +59665,7 @@ function Woe(t, e) {
59665
59665
  );
59666
59666
  return {
59667
59667
  ...m,
59668
- value: (g == null ? void 0 : g.value) || m.value
59668
+ value: (g == null ? void 0 : g.value) || m.value || ""
59669
59669
  };
59670
59670
  }), h = Il.getEnvironmentByName(l), p = (h == null ? void 0 : h.variables.filter(
59671
59671
  (m) => m.type === Er.UserCreated
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/replay",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "type": "module",
5
5
  "main": "./dist/replay.cjs",
6
6
  "module": "./dist/replay.js",