@redocly/openapi-docs 3.0.0-alpha.85 → 3.0.0-alpha.87

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,4 +1,4 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,a){void 0===a&&(a=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,a,o)}:function(e,r,t,a){void 0===a&&(a=t),e[a]=r[t]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&__createBinding(r,e,t);return __setModuleDefault(r,e),r},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ServersDropdown=void 0;const react_1=__importStar(require("react")),styled_components_1=__importDefault(require("styled-components")),theme_1=require("@redocly/theme"),jotai_1=require("jotai"),react_hook_form_1=require("react-hook-form"),store_1=require("../../../jotai/store"),utils_1=require("../../../utils"),form_1=require("../../common/form"),utils_2=require("../utils"),ServerVariable_1=__importDefault(require("../ServerVariable")),styled_1=require("../styled"),events_1=require("../../../events");function ServersDropdownComponent({operation:e,onChange:r}){var t;const{control:a,watch:o}=(0,react_hook_form_1.useFormContext)(),{events:l}=(0,jotai_1.useAtomValue)(store_1.globalOptionsAtom),{servers:n}=e,i=o("server");(0,theme_1.useMount)((()=>{const e=(0,utils_1.fromSessionStorage)("serverUrl"),t=n.findIndex((r=>r.url===e)),a=(0,utils_2.getServerWithVariables)(n,t<0?0:t);r(a)}));const s=(0,react_1.useCallback)((({serverUrl:t=""})=>{var a;const o=n.find((e=>e.url===t)),i=(0,utils_2.getDefaultOrStoredVariables)(o);r({url:t,variables:i}),(0,utils_1.toSessionStorage)("serverUrl",t);const s=(0,events_1.createServerSwitchEvent)({operation:e,serverUrl:t});null===(a=l.targetServerSwitch)||void 0===a||a.call(l,s)}),[r,l,e,n]),u=(0,react_1.useMemo)((()=>n.map(((e,r)=>({idx:r,serverUrl:e.url,value:`\n ${(0,utils_2.expandDefaultServerVariables)((0,utils_2.expandVariables)(e.url,e.variables),e.variables)}\n - ${(0,utils_1.normalizeText)(e.description)||"Default"}\n `})))),[n]),_=Object.keys((null===(t=n.find((({url:e})=>e===(null==i?void 0:i.url))))||void 0===t?void 0:t.variables)||{});return react_1.default.createElement(ServerDropdownWrap,{"data-cy":"console-target-server"},react_1.default.createElement(form_1.FormLabel,{htmlFor:"server"},"Target server: "),react_1.default.createElement(form_1.FormControl,null,react_1.default.createElement(react_hook_form_1.Controller,{control:a,name:"server",render:({field:{value:e}})=>{var r;const t=null===(r=u.find((({serverUrl:r})=>r===(null==e?void 0:e.url))))||void 0===r?void 0:r.value;return react_1.default.createElement(styled_1.TryItDropdown,{variant:"dark",value:t,options:u,fullWidth:!0,onChange:s})}})),null==_?void 0:_.map((e=>{var t;const a=null===(t=null==i?void 0:i.variables)||void 0===t?void 0:t[e];return react_1.default.createElement(ServerVariable_1.default,{key:e,name:e,value:i.variables[e],defaultValue:a.default,onChange:t=>((e,t)=>{const a=t||""===t?t:(0,utils_2.getDefaultOrStoredVariables)(i)[e],o=Object.assign(Object.assign({},i.variables),{[e]:a});(0,utils_2.updateVariablesStorage)(e,a),r(Object.assign(Object.assign({},i),{variables:o}))})(e,t),variableEnum:a.enum,description:a.description})})))}exports.ServersDropdown=(0,react_1.memo)(ServersDropdownComponent);const ServerDropdownWrap=styled_components_1.default.div`
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var a=Object.getOwnPropertyDescriptor(r,t);a&&!("get"in a?!r.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,a)}:function(e,r,t,o){void 0===o&&(o=t),e[o]=r[t]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&__createBinding(r,e,t);return __setModuleDefault(r,e),r},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ServersDropdown=void 0;const react_1=__importStar(require("react")),styled_components_1=__importDefault(require("styled-components")),theme_1=require("@redocly/theme"),jotai_1=require("jotai"),react_hook_form_1=require("react-hook-form"),store_1=require("../../../jotai/store"),utils_1=require("../../../utils"),form_1=require("../../common/form"),utils_2=require("../utils"),ServerVariable_1=__importDefault(require("../ServerVariable")),styled_1=require("../styled"),events_1=require("../../../events");function ServersDropdownComponent({operation:e,onChange:r}){var t;const{control:o,watch:a}=(0,react_hook_form_1.useFormContext)(),{events:l}=(0,jotai_1.useAtomValue)(store_1.globalOptionsAtom),{servers:n}=e,i=a("server");(0,theme_1.useMount)((()=>{const e=(0,utils_1.fromSessionStorage)("serverUrl"),t=n.findIndex((r=>r.url===e)),o=(0,utils_2.getServerWithVariables)(n,t<0?0:t);r(o)}));const s=(0,react_1.useCallback)((({serverUrl:t=""})=>{var o;const a=n.find((e=>e.url===t)),i=(0,utils_2.getDefaultOrStoredVariables)(a);r({url:t,variables:i}),(0,utils_1.toSessionStorage)("serverUrl",t);const s=(0,events_1.createServerSwitchEvent)({operation:e,serverUrl:t});null===(o=l.targetServerSwitch)||void 0===o||o.call(l,s)}),[r,l,e,n]),u=(0,react_1.useMemo)((()=>n.map(((e,r)=>{const t=(0,utils_2.getDefaultOrStoredVariables)(e);return{idx:r,serverUrl:e.url,value:`\n ${(0,utils_2.expandDefaultServerVariables)((0,utils_2.expandVariables)(e.url,t),e.variables)}\n - ${(0,utils_1.normalizeText)(e.description)||"Default"}\n `}}))),[n]),_=Object.keys((null===(t=n.find((({url:e})=>e===(null==i?void 0:i.url))))||void 0===t?void 0:t.variables)||{});return react_1.default.createElement(ServerDropdownWrap,{"data-cy":"console-target-server"},react_1.default.createElement(form_1.FormLabel,{htmlFor:"server"},"Target server: "),react_1.default.createElement(form_1.FormControl,null,react_1.default.createElement(react_hook_form_1.Controller,{control:o,name:"server",render:({field:{value:e}})=>{var r;const t=null===(r=u.find((({serverUrl:r})=>r===(null==e?void 0:e.url))))||void 0===r?void 0:r.value;return react_1.default.createElement(styled_1.TryItDropdown,{variant:"dark",value:t,options:u,fullWidth:!0,onChange:s})}})),null==_?void 0:_.map((e=>{var t;const o=null===(t=null==i?void 0:i.variables)||void 0===t?void 0:t[e];return react_1.default.createElement(ServerVariable_1.default,{key:e,name:e,value:i.variables[e],defaultValue:o.default,onChange:t=>((e,t)=>{const o=t||""===t?t:(0,utils_2.getDefaultOrStoredVariables)(i)[e],a=Object.assign(Object.assign({},i.variables),{[e]:o});(0,utils_2.updateVariablesStorage)(e,o),r(Object.assign(Object.assign({},i),{variables:a}))})(e,t),variableEnum:o.enum,description:o.description})})))}exports.ServersDropdown=(0,react_1.memo)(ServersDropdownComponent);const ServerDropdownWrap=styled_components_1.default.div`
2
2
  margin-bottom: 20px;
3
3
  `;
4
4
  //# sourceMappingURL=ServersDropdown.js.map
@@ -7,7 +7,7 @@ export declare function updateStorage(state: GenericObject): void;
7
7
  export declare const getParameters: (parameters: FieldModel[], type: string) => GenericObject;
8
8
  export declare function getServerWithVariables(operationServers: OpenAPIServer[], activeIndex?: number): Server;
9
9
  export declare function getInitialServerWithVariables(operationServers: OpenAPIServer[]): Server;
10
- export declare function expandVariables(url: string, variables?: GenericObject): string;
10
+ export declare function expandVariables(url: string, variables?: Record<string, string>): string;
11
11
  export declare function expandDefaultServerVariables(url: string, variables?: GenericObject): string;
12
12
  export declare function getDefaultOrStoredVariables(server?: OpenAPIServer): ServerVariables;
13
13
  export declare function updateVariablesStorage(name: string, value: string): void;
@@ -1,4 +1,4 @@
1
- import React,{memo,useMemo,useCallback}from"react";import styled from"styled-components";import{useMount}from"@redocly/theme";import{useAtomValue}from"jotai";import{Controller,useFormContext}from"react-hook-form";import{globalOptionsAtom}from"../../../jotai/store";import{fromSessionStorage,normalizeText,toSessionStorage}from"../../../utils";import{FormControl,FormLabel}from"../../common/form";import{expandDefaultServerVariables,expandVariables,getServerWithVariables,getDefaultOrStoredVariables,updateVariablesStorage}from"../utils";import ServerVariable from"../ServerVariable";import{TryItDropdown}from"../styled";import{createServerSwitchEvent}from"../../../events";function ServersDropdownComponent({operation:e,onChange:r}){var o;const{control:t,watch:a}=useFormContext(),{events:l}=useAtomValue(globalOptionsAtom),{servers:n}=e,s=a("server");useMount((()=>{const e=fromSessionStorage("serverUrl"),o=n.findIndex((r=>r.url===e)),t=getServerWithVariables(n,o<0?0:o);r(t)}));const i=useCallback((({serverUrl:o=""})=>{var t;const a=n.find((e=>e.url===o)),s=getDefaultOrStoredVariables(a);r({url:o,variables:s}),toSessionStorage("serverUrl",o);const i=createServerSwitchEvent({operation:e,serverUrl:o});null===(t=l.targetServerSwitch)||void 0===t||t.call(l,i)}),[r,l,e,n]),m=useMemo((()=>n.map(((e,r)=>({idx:r,serverUrl:e.url,value:`\n ${expandDefaultServerVariables(expandVariables(e.url,e.variables),e.variables)}\n - ${normalizeText(e.description)||"Default"}\n `})))),[n]),v=Object.keys((null===(o=n.find((({url:e})=>e===(null==s?void 0:s.url))))||void 0===o?void 0:o.variables)||{});return React.createElement(ServerDropdownWrap,{"data-cy":"console-target-server"},React.createElement(FormLabel,{htmlFor:"server"},"Target server: "),React.createElement(FormControl,null,React.createElement(Controller,{control:t,name:"server",render:({field:{value:e}})=>{var r;const o=null===(r=m.find((({serverUrl:r})=>r===(null==e?void 0:e.url))))||void 0===r?void 0:r.value;return React.createElement(TryItDropdown,{variant:"dark",value:o,options:m,fullWidth:!0,onChange:i})}})),null==v?void 0:v.map((e=>{var o;const t=null===(o=null==s?void 0:s.variables)||void 0===o?void 0:o[e];return React.createElement(ServerVariable,{key:e,name:e,value:s.variables[e],defaultValue:t.default,onChange:o=>((e,o)=>{const t=o||""===o?o:getDefaultOrStoredVariables(s)[e],a=Object.assign(Object.assign({},s.variables),{[e]:t});updateVariablesStorage(e,t),r(Object.assign(Object.assign({},s),{variables:a}))})(e,o),variableEnum:t.enum,description:t.description})})))}export const ServersDropdown=memo(ServersDropdownComponent);const ServerDropdownWrap=styled.div`
1
+ import React,{memo,useMemo,useCallback}from"react";import styled from"styled-components";import{useMount}from"@redocly/theme";import{useAtomValue}from"jotai";import{Controller,useFormContext}from"react-hook-form";import{globalOptionsAtom}from"../../../jotai/store";import{fromSessionStorage,normalizeText,toSessionStorage}from"../../../utils";import{FormControl,FormLabel}from"../../common/form";import{expandDefaultServerVariables,expandVariables,getServerWithVariables,getDefaultOrStoredVariables,updateVariablesStorage}from"../utils";import ServerVariable from"../ServerVariable";import{TryItDropdown}from"../styled";import{createServerSwitchEvent}from"../../../events";function ServersDropdownComponent({operation:e,onChange:r}){var o;const{control:t,watch:a}=useFormContext(),{events:l}=useAtomValue(globalOptionsAtom),{servers:n}=e,s=a("server");useMount((()=>{const e=fromSessionStorage("serverUrl"),o=n.findIndex((r=>r.url===e)),t=getServerWithVariables(n,o<0?0:o);r(t)}));const i=useCallback((({serverUrl:o=""})=>{var t;const a=n.find((e=>e.url===o)),s=getDefaultOrStoredVariables(a);r({url:o,variables:s}),toSessionStorage("serverUrl",o);const i=createServerSwitchEvent({operation:e,serverUrl:o});null===(t=l.targetServerSwitch)||void 0===t||t.call(l,i)}),[r,l,e,n]),m=useMemo((()=>n.map(((e,r)=>{const o=getDefaultOrStoredVariables(e);return{idx:r,serverUrl:e.url,value:`\n ${expandDefaultServerVariables(expandVariables(e.url,o),e.variables)}\n - ${normalizeText(e.description)||"Default"}\n `}}))),[n]),v=Object.keys((null===(o=n.find((({url:e})=>e===(null==s?void 0:s.url))))||void 0===o?void 0:o.variables)||{});return React.createElement(ServerDropdownWrap,{"data-cy":"console-target-server"},React.createElement(FormLabel,{htmlFor:"server"},"Target server: "),React.createElement(FormControl,null,React.createElement(Controller,{control:t,name:"server",render:({field:{value:e}})=>{var r;const o=null===(r=m.find((({serverUrl:r})=>r===(null==e?void 0:e.url))))||void 0===r?void 0:r.value;return React.createElement(TryItDropdown,{variant:"dark",value:o,options:m,fullWidth:!0,onChange:i})}})),null==v?void 0:v.map((e=>{var o;const t=null===(o=null==s?void 0:s.variables)||void 0===o?void 0:o[e];return React.createElement(ServerVariable,{key:e,name:e,value:s.variables[e],defaultValue:t.default,onChange:o=>((e,o)=>{const t=o||""===o?o:getDefaultOrStoredVariables(s)[e],a=Object.assign(Object.assign({},s.variables),{[e]:t});updateVariablesStorage(e,t),r(Object.assign(Object.assign({},s),{variables:a}))})(e,o),variableEnum:t.enum,description:t.description})})))}export const ServersDropdown=memo(ServersDropdownComponent);const ServerDropdownWrap=styled.div`
2
2
  margin-bottom: 20px;
3
3
  `;
4
4
  //# sourceMappingURL=ServersDropdown.js.map
@@ -7,7 +7,7 @@ export declare function updateStorage(state: GenericObject): void;
7
7
  export declare const getParameters: (parameters: FieldModel[], type: string) => GenericObject;
8
8
  export declare function getServerWithVariables(operationServers: OpenAPIServer[], activeIndex?: number): Server;
9
9
  export declare function getInitialServerWithVariables(operationServers: OpenAPIServer[]): Server;
10
- export declare function expandVariables(url: string, variables?: GenericObject): string;
10
+ export declare function expandVariables(url: string, variables?: Record<string, string>): string;
11
11
  export declare function expandDefaultServerVariables(url: string, variables?: GenericObject): string;
12
12
  export declare function getDefaultOrStoredVariables(server?: OpenAPIServer): ServerVariables;
13
13
  export declare function updateVariablesStorage(name: string, value: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/openapi-docs",
3
- "version": "3.0.0-alpha.85",
3
+ "version": "3.0.0-alpha.87",
4
4
  "description": "Redocly OpenAPI Docs",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",
@@ -23,19 +23,20 @@
23
23
  "styled-components": "^4.1.1 || ^5.3.11"
24
24
  },
25
25
  "dependencies": {
26
- "@markdoc/markdoc": "0.4.0",
27
- "@redocly/openapi-core": "^1.4.0",
28
- "@redocly/vscode-json-languageservice": "3.4.9",
29
- "@uiw/react-codemirror": "^4.21.20",
30
- "@uiw/codemirror-theme-material": "^4.21.20",
31
26
  "@codemirror/lang-json": "^6.0.1",
32
27
  "@codemirror/lint": "^6.4.2",
28
+ "@codemirror/state": "^6.4.1",
33
29
  "@lezer/highlight": "^1.1.6",
30
+ "@markdoc/markdoc": "0.4.0",
31
+ "@redocly/openapi-core": "1.10.3",
32
+ "@redocly/vscode-json-languageservice": "3.4.9",
33
+ "@uiw/codemirror-theme-material": "^4.21.20",
34
+ "@uiw/react-codemirror": "^4.21.24",
34
35
  "deepmerge": "^4.2.2",
35
36
  "dompurify": "^2.0.12",
36
37
  "fast-deep-equal": "^3.1.3",
37
38
  "hotkeys-js": "^3.7.6",
38
- "react-hook-form": "^7.47.0",
39
+ "jotai": "^2.4.2",
39
40
  "json-pointer": "^0.6.2",
40
41
  "lunr": "^2.3.8",
41
42
  "mark.js": "^8.11.1",
@@ -43,9 +44,9 @@
43
44
  "path-browserify": "^1.0.1",
44
45
  "perfect-scrollbar": "^1.5.5",
45
46
  "prismjs": "^1.22.0",
47
+ "react-hook-form": "^7.47.0",
46
48
  "react-router-dom": "^6.21.1",
47
49
  "react-tabs": "^6.0.2",
48
- "jotai": "^2.4.2",
49
50
  "slugify": "^1.4.4",
50
51
  "stickyfill": "^1.1.1",
51
52
  "stringify-object": "^3.3.0",
@@ -94,11 +95,12 @@
94
95
  "react": "18.2.0",
95
96
  "react-dom": "18.2.0",
96
97
  "react-is": "18.2.0",
98
+ "rimraf": "5.0.5",
97
99
  "string-replace-loader": "3.1.0",
98
100
  "style-loader": "1.3.0",
99
101
  "styled-components": "5.3.11",
100
102
  "terser": "5.16.3",
101
- "ts-jest": "29.1.1",
103
+ "ts-jest": "29.1.2",
102
104
  "ts-node": "10.9.1",
103
105
  "typescript": "5.2.2",
104
106
  "unfetch": "4.2.0",
@@ -107,7 +109,7 @@
107
109
  "webpack-cli": "5.1.4",
108
110
  "webpack-dev-server": "4.15.1",
109
111
  "workerize-loader": "github:redocly/workerize-loader#webpack-5-dist",
110
- "@redocly/theme": "0.33.3"
112
+ "@redocly/theme": "0.35.0"
111
113
  },
112
114
  "scripts": {
113
115
  "start": "webpack serve --mode=development --hot",
@@ -119,14 +121,14 @@
119
121
  "test:coverage": "jest --coverage",
120
122
  "test:coverage:html": "jest --coverage --coverageReporters html",
121
123
  "ts:check": "tsc --noEmit --skipLibCheck",
122
- "clean": "rm -rf bin dist lib lib-esm redocly-static",
124
+ "clean": "rimraf bin dist lib lib-esm redocly-static",
123
125
  "compile:lib": "npm run compile:es5 && npm run compile:esm && npm run bundle-worker",
124
- "compile:es5": "rm -rf lib && tsc -p tsconfig.lib.json && node scripts/minify.js lib",
125
- "compile:esm": "rm -rf lib-esm && tsc -p tsconfig.lib-esm.json && node scripts/minify.js lib-esm",
126
+ "compile:es5": "rimraf lib && tsc -p tsconfig.lib.json && node scripts/minify.js lib",
127
+ "compile:esm": "rimraf lib-esm && tsc -p tsconfig.lib-esm.json && node scripts/minify.js lib-esm",
126
128
  "bundle-worker": "webpack --config webpack.config.worker.js --mode=production",
127
129
  "publish:cdn": "scripts/publish-cdn.sh",
128
130
  "clear:cache": "scripts/clear-cache.sh",
129
- "pack:sourcemaps": "rm -rf openapi-docs.sourcemaps.tag.gz && find lib lib-esm -name \"*.js.map\" | xargs tar -czvf openapi-docs.sourcemaps.tar.gz",
131
+ "pack:sourcemaps": "rimraf openapi-docs.sourcemaps.tag.gz && find lib lib-esm -name \"*.js.map\" | xargs tar -czvf openapi-docs.sourcemaps.tar.gz",
130
132
  "stats": "webpack --json --profile --mode=production -p > stats.json && npx webpack-bundle-analyzer stats.json",
131
133
  "list:licenses": "node ./scripts/list-licenses.js",
132
134
  "license:check": "npx license-checker --production --onlyAllow 'MIT;ISC;Apache-2.0;Apache;CC0-1.0;BSD;BSD-2-Clause;BSD-3-Clause;UNKNOWN' --summary",