@redocly/openapi-docs 3.0.0-alpha.11 → 3.0.0-alpha.12
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/bin/cli/commands/redocly-docs-cli.min.js +650 -417
- package/bin/cli/commands/redocly-docs-cli.min.js.LICENSE.txt +3 -3
- package/dist/console.redocly-reference-docs.min.js +138 -138
- package/dist/oauth2-redirect.js +2 -2
- package/dist/redocly-reference-docs.min.js +964 -699
- package/lib/components/Endpoint/types.d.ts +1 -1
- package/lib/components/Fields/types.d.ts +1 -1
- package/lib/components/Markdown/types.d.ts +1 -1
- package/lib/components/Responses/types.d.ts +1 -1
- package/lib/components/Search/types.d.ts +2 -2
- package/lib/components/common/CheckboxList.d.ts +1 -1
- package/lib/components/common/panels.js +0 -4
- package/lib/components/rightPanel/Console/types.d.ts +1 -1
- package/lib/events/types.d.ts +2 -2
- package/lib/models/RequestBody.d.ts +1 -1
- package/lib/models/Response.d.ts +1 -1
- package/lib/models/Schema.d.ts +1 -1
- package/lib/models/file-upload.d.ts +1 -1
- package/lib/models/types.d.ts +1 -1
- package/lib/services/MarkdownRenderer.js +1 -1
- package/lib/services/ProMenu.d.ts +3 -1
- package/lib/services/ProMenu.js +1 -1
- package/lib/services/ProStore.d.ts +2 -0
- package/lib/services/ProStore.js +1 -1
- package/lib/services/check.d.ts +1 -1
- package/lib/services/code-samples/generator.d.ts +1 -1
- package/lib/services/code-samples/httpsnippet/helpers/code-helpers.d.ts +1 -1
- package/lib/services/code-samples/httpsnippet/helpers/lodash-int.js +1 -1
- package/lib/services/code-samples/httpsnippet/index.d.ts +1 -1
- package/lib/services/code-samples/httpsnippet/targets/php/types.d.ts +2 -2
- package/lib/services/code-samples/types.d.ts +2 -2
- package/lib/services/labels/types.d.ts +1 -1
- package/lib/services/search/SearchStore.js +1 -1
- package/lib/services/search/types.d.ts +1 -1
- package/lib/services/types.d.ts +18 -16
- package/lib/types/open-api.d.ts +4 -4
- package/lib/types/security.d.ts +1 -1
- package/lib/utils/loadAndBundleSpec.js +1 -1
- package/lib/utils/media-css.d.ts +1 -1
- package/lib-esm/components/Endpoint/types.d.ts +1 -1
- package/lib-esm/components/Fields/types.d.ts +1 -1
- package/lib-esm/components/Markdown/types.d.ts +1 -1
- package/lib-esm/components/Responses/types.d.ts +1 -1
- package/lib-esm/components/Search/types.d.ts +2 -2
- package/lib-esm/components/common/CheckboxList.d.ts +1 -1
- package/lib-esm/components/common/panels.js +0 -4
- package/lib-esm/components/rightPanel/Console/types.d.ts +1 -1
- package/lib-esm/events/types.d.ts +2 -2
- package/lib-esm/models/RequestBody.d.ts +1 -1
- package/lib-esm/models/Response.d.ts +1 -1
- package/lib-esm/models/Schema.d.ts +1 -1
- package/lib-esm/models/file-upload.d.ts +1 -1
- package/lib-esm/models/types.d.ts +1 -1
- package/lib-esm/services/MarkdownRenderer.js +1 -1
- package/lib-esm/services/ProMenu.d.ts +3 -1
- package/lib-esm/services/ProMenu.js +1 -1
- package/lib-esm/services/ProStore.d.ts +2 -0
- package/lib-esm/services/ProStore.js +1 -1
- package/lib-esm/services/check.d.ts +1 -1
- package/lib-esm/services/code-samples/generator.d.ts +1 -1
- package/lib-esm/services/code-samples/httpsnippet/helpers/code-helpers.d.ts +1 -1
- package/lib-esm/services/code-samples/httpsnippet/helpers/lodash-int.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/index.d.ts +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/php/types.d.ts +2 -2
- package/lib-esm/services/code-samples/types.d.ts +2 -2
- package/lib-esm/services/labels/types.d.ts +1 -1
- package/lib-esm/services/search/SearchStore.js +1 -1
- package/lib-esm/services/search/types.d.ts +1 -1
- package/lib-esm/services/types.d.ts +18 -16
- package/lib-esm/types/open-api.d.ts +4 -4
- package/lib-esm/types/security.d.ts +1 -1
- package/lib-esm/utils/loadAndBundleSpec.js +1 -1
- package/lib-esm/utils/media-css.d.ts +1 -1
- package/package.json +10 -5
|
@@ -9,7 +9,7 @@ export interface ServerListProps extends Pick<OperationModel, 'servers' | 'path'
|
|
|
9
9
|
expandVariables: boolean;
|
|
10
10
|
hideHostname: boolean;
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export type EndpointSummaryProps = PanelHeaderProps & {
|
|
13
13
|
operation: OperationModel;
|
|
14
14
|
onToggleConsole: () => void;
|
|
15
15
|
showConsole: boolean;
|
|
@@ -6,7 +6,7 @@ export interface BaseMarkdownProps {
|
|
|
6
6
|
sanitize?: boolean;
|
|
7
7
|
source: string;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export type MarkdownProps = BaseMarkdownProps & StylingMarkdownProps & {
|
|
10
10
|
source: string;
|
|
11
11
|
className?: string;
|
|
12
12
|
'data-role'?: string;
|
|
@@ -7,7 +7,7 @@ export interface MenuItemProProps {
|
|
|
7
7
|
term: string;
|
|
8
8
|
history: HistoryService;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export type SearchResultExtended = {
|
|
11
11
|
index: number;
|
|
12
12
|
item: IMenuItem & {
|
|
13
13
|
path: string;
|
|
@@ -20,7 +20,7 @@ export declare type SearchResultExtended = {
|
|
|
20
20
|
}[];
|
|
21
21
|
count: number;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type SearchResult<T = GenericObject | undefined> = {
|
|
24
24
|
score: number;
|
|
25
25
|
meta: T;
|
|
26
26
|
};
|
|
@@ -2,7 +2,7 @@ import type { ProStore } from '../../../services';
|
|
|
2
2
|
import type { OperationModel } from '../../../models';
|
|
3
3
|
import type { SecurityDetails } from '../../../types';
|
|
4
4
|
import type { OpenApiResponseData } from '../types';
|
|
5
|
-
export
|
|
5
|
+
export type RequestAndResponseType = {
|
|
6
6
|
request: Record<string, unknown>;
|
|
7
7
|
response: OpenApiResponseData;
|
|
8
8
|
};
|
package/lib/events/types.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export interface CodeSamplesCopiedEvent extends AnalyticsEvent {
|
|
|
44
44
|
exampleId?: string;
|
|
45
45
|
exampleMimeType?: string;
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
type TryItOpenedEvent = AnalyticsEvent;
|
|
48
48
|
export interface PanelToggleEvent extends AnalyticsEvent {
|
|
49
49
|
panelType: 'request' | 'responses' | 'request-samples' | 'response-samples';
|
|
50
50
|
state: 'expanded' | 'collapsed';
|
|
@@ -53,7 +53,7 @@ export interface PanelToggleEvent extends AnalyticsEvent {
|
|
|
53
53
|
operationHttpVerb: string;
|
|
54
54
|
operationSummary?: string;
|
|
55
55
|
}
|
|
56
|
-
export
|
|
56
|
+
export type Events = {
|
|
57
57
|
codeSamplesLanguageSwitch?: (event: CodeSamplesLanguageSwitchedEvent) => void;
|
|
58
58
|
codeSamplesCopy?: (event: CodeSamplesCopiedEvent) => void;
|
|
59
59
|
tryItOpen?: (event: TryItOpenedEvent) => void;
|
|
@@ -2,7 +2,7 @@ import type { OpenAPIRequestBody, Referenced } from '../types';
|
|
|
2
2
|
import type { OpenAPIParser, Options } from '../services';
|
|
3
3
|
import type { OperationModel } from './Operation';
|
|
4
4
|
import { MediaContentModel } from './MediaContent';
|
|
5
|
-
|
|
5
|
+
type RequestBodyProps = {
|
|
6
6
|
parser: OpenAPIParser;
|
|
7
7
|
infoOrRef: Referenced<OpenAPIRequestBody>;
|
|
8
8
|
options: Options;
|
package/lib/models/Response.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { OperationModel } from './Operation';
|
|
|
4
4
|
import type { Options } from 'src/services/Options';
|
|
5
5
|
import { FieldModel } from './Field';
|
|
6
6
|
import { MediaContentModel } from './MediaContent';
|
|
7
|
-
|
|
7
|
+
type ResponseProps = {
|
|
8
8
|
parser: OpenAPIParser;
|
|
9
9
|
code: string;
|
|
10
10
|
defaultAsError: boolean;
|
package/lib/models/Schema.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { OperationModel } from './Operation';
|
|
|
4
4
|
import type { ResponseModel } from './Response';
|
|
5
5
|
import type { Options } from 'src/services/Options';
|
|
6
6
|
import { FieldModel } from './Field';
|
|
7
|
-
export
|
|
7
|
+
export type Deps = {
|
|
8
8
|
parentFieldFullPath?: string;
|
|
9
9
|
operation?: OperationModel;
|
|
10
10
|
type?: 'request' | 'response';
|
package/lib/models/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MarkdownRenderer=exports.buildComponentComment=void 0;const marked_1=require("marked"),utils_1=require("../utils"),constants_1=require("../constants"),renderer=new marked_1.marked.Renderer;function buildComponentComment(e){return`\x3c!-- ReDoc-Inject: <${e}> --\x3e`}marked_1.marked.setOptions({renderer:renderer,highlight:(e,n)=>(0,utils_1.highlight)(e,n)}),exports.buildComponentComment=buildComponentComment;class MarkdownRenderer{constructor(e){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"headings",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"currentTopHeading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headingSectionLevel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headingEnhanceRenderer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"originalHeadingRule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headingRule",{enumerable:!0,configurable:!0,writable:!0,value:(e,n,r,t)=>{var i,s;return 1===n?this.currentTopHeading=this.saveHeading(e,n):n<=this.headingSectionLevel&&this.saveHeading(e,n,null===(i=this.currentTopHeading)||void 0===i?void 0:i.items,null===(s=this.currentTopHeading)||void 0===s?void 0:s.id),this.originalHeadingRule(e,n,r,t)}}),this.headingEnhanceRenderer=new marked_1.marked.Renderer,this.parser=new marked_1.marked.Parser,this.originalHeadingRule=this.headingEnhanceRenderer.heading.bind(this.headingEnhanceRenderer),this.headingEnhanceRenderer.heading=this.headingRule,this.headingSectionLevel=(null==e?void 0:e.markdownHeadingsAnchorLevel)||2}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MarkdownRenderer=exports.buildComponentComment=void 0;const marked_1=require("marked"),utils_1=require("../utils"),constants_1=require("../constants"),renderer=new marked_1.marked.Renderer;function buildComponentComment(e){return`\x3c!-- ReDoc-Inject: <${e}> --\x3e`}marked_1.marked.setOptions({renderer:renderer,highlight:(e,n)=>(0,utils_1.highlight)(e,n)}),exports.buildComponentComment=buildComponentComment;class MarkdownRenderer{static containsComponent(e,n){return new RegExp(constants_1.COMPONENT_REGEXP.replace(/{component}/g,n),"gmi").test(e)}static getTextBeforeHading(e,n){const r=e.search(new RegExp(`^(>\\s+#+|#+)?\\s+${n}`,"m"));return r>-1?e.substring(0,r):e}constructor(e){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"headings",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"currentTopHeading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headingSectionLevel",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headingEnhanceRenderer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"originalHeadingRule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headingRule",{enumerable:!0,configurable:!0,writable:!0,value:(e,n,r,t)=>{var i,s;return 1===n?this.currentTopHeading=this.saveHeading(e,n):n<=this.headingSectionLevel&&this.saveHeading(e,n,null===(i=this.currentTopHeading)||void 0===i?void 0:i.items,null===(s=this.currentTopHeading)||void 0===s?void 0:s.id),this.originalHeadingRule(e,n,r,t)}}),this.headingEnhanceRenderer=new marked_1.marked.Renderer,this.parser=new marked_1.marked.Parser,this.originalHeadingRule=this.headingEnhanceRenderer.heading.bind(this.headingEnhanceRenderer),this.headingEnhanceRenderer.heading=this.headingRule,this.headingSectionLevel=(null==e?void 0:e.markdownHeadingsAnchorLevel)||2}saveHeading(e,n,r=this.headings,t){e=(0,utils_1.unescapeHTMLChars)(e);const i={id:t?`${t}/${(0,utils_1.safeSlugify)(e)}`:`section/${(0,utils_1.safeSlugify)(e)}`,name:e,level:n,items:[]};return r.push(i),i}flattenHeadings(e){if(void 0===e)return[];const n=[];for(const r of e)n.push(r),n.push(...this.flattenHeadings(r.items));return n}attachHeadingsDescriptions(e){const n=e=>new RegExp(`##?\\s+${e.name.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}`),r=this.flattenHeadings(this.headings);if(r.length<1)return;let t=r[0],i=n(t),s=e.search(i);for(let a=1;a<r.length;a++){const o=r[a],d=n(o),c=e.substr(s+1).search(d)+s+1;t.description=e.substring(s,c).replace(i,"").trim(),t=o,i=d,s=c}t.description=e.substring(s).replace(i,"").trim()}renderMd(e,n=!1){const r=n?{renderer:this.headingEnhanceRenderer}:void 0;return(0,marked_1.marked)(e.toString(),r)}extractHeadings(e){this.renderMd(e,!0),this.attachHeadingsDescriptions(e);const n=this.headings;return this.headings=[],n}renderMdWithComponents(e){const n=this.options&&this.options.allowedMdComponents;if(!n||0===Object.keys(n).length)return[this.renderMd(e)];const r=Object.keys(n).join("|"),t=new RegExp(constants_1.COMPONENT_REGEXP.replace(/{component}/g,r),"mig"),i=[],s=[];let a=t.exec(e),o=0;for(;a;){i.push(e.substring(o,a.index)),o=t.lastIndex;const r=n[a[1]||a[2]||a[5]],d=a[3]||a[6],c=a[4];r&&s.push({component:r.component,propsSelector:r.propsSelector,props:Object.assign(Object.assign(Object.assign({},parseProps(d)),r.props),{children:c})}),a=t.exec(e)}i.push(e.substring(o));const d=[];for(let e=0;e<i.length;e++){const n=i[e];n&&d.push(this.renderMd(n)),s[e]&&d.push(s[e])}return d}}function parseProps(e){if(!e)return{};const n=/([\w-]+)\s*=\s*(?:{([^}]+?)}|"([^"]+?)")/gim,r={};let t;for(;null!==(t=n.exec(e));)if(t[3])r[t[1]]=t[3];else if(t[2]){let e;try{e=JSON.parse(t[2])}catch(e){}r[t[1]]=e}return r}exports.MarkdownRenderer=MarkdownRenderer;
|
|
2
2
|
//# sourceMappingURL=MarkdownRenderer.js.map
|
|
@@ -2,10 +2,12 @@ import type { IMenuItem, ScrollService, HistoryService, MenuItemType, SpecStore
|
|
|
2
2
|
import type { Options } from './Options/types';
|
|
3
3
|
import type { SchemaModel } from '../models';
|
|
4
4
|
import { VersionedSpecStore } from './VersionedSpecStore';
|
|
5
|
-
export
|
|
5
|
+
export type ExtendedMenuItem = Omit<IMenuItem, 'type'> & {
|
|
6
6
|
type: MenuItemType | 'spec';
|
|
7
7
|
linkable?: boolean;
|
|
8
8
|
href?: string;
|
|
9
|
+
httpVerb?: string;
|
|
10
|
+
path?: string;
|
|
9
11
|
};
|
|
10
12
|
/**
|
|
11
13
|
* Stores all side-menu related information
|
package/lib/services/ProMenu.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __decorate=this&&this.__decorate||function(e,t,i,s){var n,o=arguments.length,r=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,i,r):n(t,i))||r);return o>3&&r&&Object.defineProperty(t,i,r),r};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProMenu=void 0;const mobx_1=require("mobx"),utils_1=require("../utils"),constants_1=require("../constants"),history_1=require("./history"),VersionedSpecStore_1=require("./VersionedSpecStore");class ProMenu{constructor(e,t,i,s){Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"history",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"flatItems",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activeRenderItemIdx",{enumerable:!0,configurable:!0,writable:!0,value:-1}),Object.defineProperty(this,"renderItems",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"activeItemIdx",{enumerable:!0,configurable:!0,writable:!0,value:-1}),Object.defineProperty(this,"sideBarOpened",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_unsubscribe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_hashUnsubscribe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"getItemById",{enumerable:!0,configurable:!0,writable:!0,value:e=>this.flatItems.find((t=>t.id===e))}),Object.defineProperty(this,"initOnHistory",{enumerable:!0,configurable:!0,writable:!0,value:(e=this.history.currentId)=>{const[t]=e.split(this.options.deepLinkPrefix);if(!t)return;const i=this.flatItems.find((e=>e.id===t));i&&(this.activate(i,!1,!1,!1,e),i.active=!1)}}),Object.defineProperty(this,"updateOnHistory",{enumerable:!0,configurable:!0,writable:!0,value:(e=this.history.currentId)=>{const[t]=e.split(this.options.deepLinkPrefix);if(!t)return;const i=this.flatItems.find((e=>e.id===t));i?this.activateAndScroll(i,!1,void 0,e):(this.scroll.prevOffsetY=0,this.scroll.scrollIntoViewBySelector(`[${constants_1.SECTION_ATTR}="${(0,utils_1.escapeHTMLAttrChars)(t)}"]`))}}),Object.defineProperty(this,"updateVersionOnHistory",{enumerable:!0,configurable:!0,writable:!0,value:e=>{if(!("versionsInfo"in this.definition))return;const[t]=e.split("/");let i=this.definition.versionsInfo.findIndex((e=>e.id===t));i<0&&(i=this.definition.versionsInfo.findIndex((e=>e.isDefault))),this.definition.activeVersionIdx!==i&&(this.definition.changeVersion(i<0?0:i),this.updateItemsByVersionChange(!1,e))}}),Object.defineProperty(this,"updateOnScroll",{enumerable:!0,configurable:!0,writable:!0,value:e=>{const t=e?1:-1;let i=this.activeItemIdx;for(;(-1!==i||e)&&!(i>=this.flatItems.length-1&&e);){if(e){let e=!1;const t=this.flatItems[i+1];switch(this.options.pagination){case"section":e=t&&("spec"===t.type||"group"===t.type||"tag"===t.type);break;case"item":e="section"!==(null==t?void 0:t.type)}const s=this.getElementAt(i+1);if(-1===i&&"tag"===this.flatItems[0].type&&(e=!1),this.scroll.isElementBellow(s)||e)break}else{const e=this.flatItems[i]&&this.flatItems[i].type,t="section"===this.options.pagination&&("spec"===e||"group"===e||"tag"===e)||"item"===this.options.pagination&&"section"!==e,s=this.getElementAt(i);if(this.scroll.isElementAbove(s)||t)break}i+=t}const s=this.flatItems[i];"none"===this.options.pagination||"section"===this.options.pagination?s&&s.active||this.activate(s,!0,!0,!1):s&&"section"===s.type&&(s.active||this.activate(s,!0,!0,!1))}}),(0,mobx_1.makeObservable)(this),this.items=e.contentItems,this.flatItems=(0,utils_1.flattenByProp)(this.items||[],"items"),this.flatItems.forEach(((e,t)=>e.absoluteIdx=t)),i.disableSidebar||this.subscribe(),this.flatItems.forEach(((e,t)=>normalizeItem(e,t,i.pagination,this.definition instanceof VersionedSpecStore_1.VersionedSpecStore,this.history))),this.renderItems=this.buildRenderItems(0),this.activeItemIdx=-1,this.activeRenderItemIdx=-1,this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&this.history.subscribe(this.updateVersionOnHistory)}static updateOnHistory(e=history_1.history.currentId,t){e&&t.scrollIntoViewBySelector(`[${constants_1.SECTION_ATTR}="${(0,utils_1.escapeHTMLAttrChars)(e)}"]`)}subscribe(){this._unsubscribe=this.scroll.subscribe(this.updateOnScroll),this._hashUnsubscribe=this.history.subscribe(this.updateOnHistory)}toggleSidebar(){this.sideBarOpened=!this.sideBarOpened}closeSidebar(){this.sideBarOpened=!1}getElementAt(e){const t=this.flatItems[e];return t&&(0,utils_1.querySelector)(`[${constants_1.SECTION_ATTR}="${(0,utils_1.escapeHTMLAttrChars)(t.id)}"]`)||null}getElementAtOrFirstChild(e){let t=this.flatItems[e];return t&&"group"===t.type&&(t=t.items[0]),t&&(0,utils_1.querySelector)(`[${constants_1.SECTION_ATTR}="${(0,utils_1.escapeHTMLAttrChars)(t.id)}"]`)||null}get activeItem(){return this.flatItems[this.activeItemIdx]||void 0}updateItemsByVersionChange(e,t){if(!("versionsInfo"in this.definition))return;const i=this.activeItem&&this.activeItem.active?this.activeItem.absoluteIdx:-1;t=t&&withoutVersion(t)||this.activeItem&&this.activeItem.active&&withoutVersion(this.activeItem.id)||"",this.deactivate(this.activeItem),this.items=this.definition.contentItems,this.flatItems=(0,utils_1.flattenByProp)(this.items||[],"items"),this.flatItems.forEach(((e,t)=>normalizeItem(e,t,this.options.pagination,this.definition instanceof VersionedSpecStore_1.VersionedSpecStore,this.history)));const s=t?(this.flatItems.find((e=>withoutVersion(e.id)===t))||{absoluteIdx:-1}).absoluteIdx:-1;if(-1!==s&&"none"!==this.options.pagination||(this.renderItems=this.buildRenderItems(0)),this.activeItemIdx=-1,-1!==s)this.activate(this.flatItems[s],e);else if(-1!==i)this.activateAndScroll(this.flatItems[0],e);else if(e){const e=this.definition.versionsInfo[this.definition.activeVersionIdx];if(!this.history.currentId&&e.isDefault)return;this.history.replace(e.id)}}buildRenderItems(e){if("none"===this.options.pagination)return this.items;let t=this.flatItems[e];if(t||(t=this.flatItems[0]),"spec"===t.type)return this.buildRenderItems(e+1);if("section"===t.type){const e=[],i=getParentOfType(t,"tag");if("section"===this.options.pagination&&i)return[i];if("item"===this.options.pagination&&i)return[Object.assign(Object.assign({},i),{items:getLeadingSectionItems(i)})];const s=getParentSpecItem(t),n=(null==s?void 0:s.items)||this.items;for(let t=0;t<n.length&&"section"===n[t].type;t++)e.push(n[t]);return e}switch(this.options.pagination){case"section":if(("operation"===t.type||"schema"===t.type)&&t.parent)return[t.parent];if("group"!==t.type)return[t];case"item":return"operation"===t.type||"schema"===t.type?[t]:[Object.assign(Object.assign({},t),{items:getLeadingSectionItems(t)})];default:return[]}}activateBase(e,t=!0,i=!1,s){var n,o,r,a,l;if((null===(n=this.activeItem)||void 0===n?void 0:n.id)===(null==e?void 0:e.id)&&!s)return t&&e&&this.history.replace(encodeURI(e.id),i),void(e&&!e.active&&e.activate());if(e&&"group"===e.type)return;if(this.deactivate(this.activeItem),!e)return void this.history.replace("",i);if(e.depth<=constants_1.GROUP_DEPTH)return;this.activeItemIdx=e.absoluteIdx,t&&this.history.replace(encodeURI(e.id),i),e.activate(),e.expand();const c=new URLSearchParams(s),d="request"===c.get("t"),u="response"===c.get("t"),h=c.get("c"),p=c.get("ct"),f=c.get("in"),m=c.get("path"),v=(null==m?void 0:m.split(this.options.deepLinkSeparator))||[],b=e;if(f){let e=b.parameters;for(const t of v){const i=null==e?void 0:e.find((e=>e.name===t));null==i||i.expand(),e=null===(o=null==i?void 0:i.schema)||void 0===o?void 0:o.fields}}else if(d){const e=null===(r=b.requestBody)||void 0===r?void 0:r.content;null===(a=b.activateMimeName)||void 0===a||a.call(b,p||b.activeMimeName),setTimeout((()=>{var t;return this.activateField(v,null===(t=null==e?void 0:e.active)||void 0===t?void 0:t.schema)}),0)}else if(u){const e=b.responses.find((e=>e.code===h));(null==e?void 0:e.expanded)||null==e||e.expand(),null===(l=b.activateMimeName)||void 0===l||l.call(b,p||b.activeMimeName),setTimeout((()=>{var t,i;return this.activateField(v,null===(i=null===(t=null==e?void 0:e.content)||void 0===t?void 0:t.active)||void 0===i?void 0:i.schema)}),0)}}activate(e,t=!0,i=!1,s=!0,n){if("none"===this.options.pagination)return this.activateBase(e,t,i,n),void(!e&&this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&this.history.replace(this.definition.currentVersionId,!0));if("group"!==(null==e?void 0:e.type)){if(e&&"item"===this.options.pagination&&"tag"===e.type&&!e.description){if(e.expanded)return void e.collapse();e.expand(),e=this.flatItems[e.absoluteIdx+1]}if(this.activateBase(e,e&&t,i,n),this.activeRenderItemIdx=e?e.absoluteIdx:this.activeRenderItemIdx,this.activeRenderItemIdx>=0){const e=this.buildRenderItems(this.activeRenderItemIdx);e.some(((e,t)=>e.id!==this.renderItems[t].id))&&(this.renderItems=e),this.renderItems[0]&&(this.activeRenderItemIdx=this.renderItems[0].absoluteIdx)}s&&setTimeout((()=>this.scrollToActive())),!e&&this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&this.history.replace(this.definition.currentVersionId,!0)}}activateField(e,t){var i;for(let s=0;s<e.length-1;s++){const n=e[s],o=s===e.length-1;if((null==t?void 0:t.hasType("array"))&&(null==t?void 0:t.items)&&(t=null==t?void 0:t.items),null==t?void 0:t.oneOf){const e=Number(n);if(isNaN(e))return;null==t||t.activateOneOf(e),t=null==t?void 0:t.oneOf[e];continue}(null==t?void 0:t.hasType("array"))&&(null==t?void 0:t.items)&&(t=null==t?void 0:t.items);const r=null===(i=null==t?void 0:t.fields)||void 0===i?void 0:i.find((e=>e.name===n));o||null==r||r.expand(),t=null==r?void 0:r.schema}}deactivate(e){if(void 0!==e)for(e.deactivate();void 0!==e;)e.collapse(),e=e.parent}activateAndScroll(e,t,i,s=""){const[,n]=s.split(this.options.deepLinkPrefix),o=e&&this.getItemById(e.id)||e;this.activate(o,t,i,!1,n),this.scrollToActive(n?s:""),o&&o.items.length||this.closeSidebar()}scrollToActive(e){e?setTimeout((()=>this.scroll.scrollIntoViewBySelector(`[${constants_1.SECTION_ATTR}="${(0,utils_1.escapeHTMLAttrChars)(e)}"]`)),0):this.scroll.scrollIntoView(this.getElementAt(this.activeItemIdx))}dispose(){var e,t;null===(e=this._unsubscribe)||void 0===e||e.call(this),null===(t=this._hashUnsubscribe)||void 0===t||t.call(this)}}function withoutVersion(e){return e.split("/").slice(1).join("/")}function getParentSpecItem(e){for(;e;){if("spec"===e.type)return e;e=e.parent}}function getParentOfType(e,t){if(e&&e.parent)return e.parent.type===t?e.parent:getParentOfType(e.parent,t)}function getLeadingSectionItems(e){const t=[];for(const i of e.items){if("section"!==i.type)break;t.push(i)}return t}function normalizeItem(e,t,i,s,n){if(e.absoluteIdx=t,"none"!==i){const t=getParentOfType(e,"tag");if(e.parent&&t&&!("_id_normalized"in e)){if(s){const[i,s]=e.id.split("/"),n=withoutVersion(e.id);if("operation"===e.type&&!s.startsWith("operation"))return;e.id=i+"/"+withoutVersion(t.id)+"/"+n}else{if("operation"===e.type&&!e.id.startsWith("operation"))return;e.id=t.id+"/"+e.id}e._id_normalized=!0}}"group"!==e.type&&(e.href=n.linkForId(e.id))}__decorate([mobx_1.observable],ProMenu.prototype,"flatItems",void 0),__decorate([mobx_1.observable],ProMenu.prototype,"items",void 0),__decorate([mobx_1.observable],ProMenu.prototype,"activeRenderItemIdx",void 0),__decorate([mobx_1.observable.ref],ProMenu.prototype,"renderItems",void 0),__decorate([mobx_1.observable],ProMenu.prototype,"activeItemIdx",void 0),__decorate([mobx_1.observable],ProMenu.prototype,"sideBarOpened",void 0),__decorate([mobx_1.action],ProMenu.prototype,"toggleSidebar",null),__decorate([mobx_1.action],ProMenu.prototype,"closeSidebar",null),__decorate([mobx_1.action],ProMenu.prototype,"activateBase",null),__decorate([mobx_1.action],ProMenu.prototype,"activate",null),__decorate([mobx_1.action.bound],ProMenu.prototype,"activateAndScroll",null),exports.ProMenu=ProMenu;
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(e,t,i,s){var n,o=arguments.length,r=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,i,r):n(t,i))||r);return o>3&&r&&Object.defineProperty(t,i,r),r};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProMenu=void 0;const mobx_1=require("mobx"),utils_1=require("../utils"),constants_1=require("../constants"),history_1=require("./history"),VersionedSpecStore_1=require("./VersionedSpecStore");class ProMenu{static updateOnHistory(e=history_1.history.currentId,t){e&&t.scrollIntoViewBySelector(`[${constants_1.SECTION_ATTR}="${(0,utils_1.escapeHTMLAttrChars)(e)}"]`)}constructor(e,t,i,s){Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"history",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"flatItems",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activeRenderItemIdx",{enumerable:!0,configurable:!0,writable:!0,value:-1}),Object.defineProperty(this,"renderItems",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"activeItemIdx",{enumerable:!0,configurable:!0,writable:!0,value:-1}),Object.defineProperty(this,"sideBarOpened",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_unsubscribe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_hashUnsubscribe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"getItemById",{enumerable:!0,configurable:!0,writable:!0,value:e=>this.flatItems.find((t=>t.id===e))}),Object.defineProperty(this,"initOnHistory",{enumerable:!0,configurable:!0,writable:!0,value:(e=this.history.currentId)=>{const[t]=e.split(this.options.deepLinkPrefix);if(!t)return;const i=this.flatItems.find((e=>e.id===t));i&&(this.activate(i,!1,!1,!1,e),i.active=!1)}}),Object.defineProperty(this,"updateOnHistory",{enumerable:!0,configurable:!0,writable:!0,value:(e=this.history.currentId)=>{const[t]=e.split(this.options.deepLinkPrefix);if(!t)return;const i=this.flatItems.find((e=>e.id===t));i?this.activateAndScroll(i,!1,void 0,e):(this.scroll.prevOffsetY=0,this.scroll.scrollIntoViewBySelector(`[${constants_1.SECTION_ATTR}="${(0,utils_1.escapeHTMLAttrChars)(t)}"]`))}}),Object.defineProperty(this,"updateVersionOnHistory",{enumerable:!0,configurable:!0,writable:!0,value:e=>{if(!("versionsInfo"in this.definition))return;const[t]=e.split("/");let i=this.definition.versionsInfo.findIndex((e=>e.id===t));i<0&&(i=this.definition.versionsInfo.findIndex((e=>e.isDefault))),this.definition.activeVersionIdx!==i&&(this.definition.changeVersion(i<0?0:i),this.updateItemsByVersionChange(!1,e))}}),Object.defineProperty(this,"updateOnScroll",{enumerable:!0,configurable:!0,writable:!0,value:e=>{const t=e?1:-1;let i=this.activeItemIdx;for(;(-1!==i||e)&&!(i>=this.flatItems.length-1&&e);){if(e){let e=!1;const t=this.flatItems[i+1];switch(this.options.pagination){case"section":e=t&&("spec"===t.type||"group"===t.type||"tag"===t.type);break;case"item":e="section"!==(null==t?void 0:t.type)}const s=this.getElementAt(i+1);if(-1===i&&"tag"===this.flatItems[0].type&&(e=!1),this.scroll.isElementBellow(s)||e)break}else{const e=this.flatItems[i]&&this.flatItems[i].type,t="section"===this.options.pagination&&("spec"===e||"group"===e||"tag"===e)||"item"===this.options.pagination&&"section"!==e,s=this.getElementAt(i);if(this.scroll.isElementAbove(s)||t)break}i+=t}const s=this.flatItems[i];"none"===this.options.pagination||"section"===this.options.pagination?s&&s.active||this.activate(s,!0,!0,!1):s&&"section"===s.type&&(s.active||this.activate(s,!0,!0,!1))}}),(0,mobx_1.makeObservable)(this),this.items=e.contentItems,this.flatItems=(0,utils_1.flattenByProp)(this.items||[],"items"),this.flatItems.forEach(((e,t)=>e.absoluteIdx=t)),i.disableSidebar||this.subscribe(),this.flatItems.forEach(((e,t)=>normalizeItem(e,t,i.pagination,this.definition instanceof VersionedSpecStore_1.VersionedSpecStore,this.history))),this.renderItems=this.buildRenderItems(0),this.activeItemIdx=-1,this.activeRenderItemIdx=-1,this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&this.history.subscribe(this.updateVersionOnHistory)}subscribe(){this._unsubscribe=this.scroll.subscribe(this.updateOnScroll),this._hashUnsubscribe=this.history.subscribe(this.updateOnHistory)}toggleSidebar(){this.sideBarOpened=!this.sideBarOpened}closeSidebar(){this.sideBarOpened=!1}getElementAt(e){const t=this.flatItems[e];return t&&(0,utils_1.querySelector)(`[${constants_1.SECTION_ATTR}="${(0,utils_1.escapeHTMLAttrChars)(t.id)}"]`)||null}getElementAtOrFirstChild(e){let t=this.flatItems[e];return t&&"group"===t.type&&(t=t.items[0]),t&&(0,utils_1.querySelector)(`[${constants_1.SECTION_ATTR}="${(0,utils_1.escapeHTMLAttrChars)(t.id)}"]`)||null}get activeItem(){return this.flatItems[this.activeItemIdx]||void 0}updateItemsByVersionChange(e,t){if(!("versionsInfo"in this.definition))return;const i=this.activeItem&&this.activeItem.active?this.activeItem.absoluteIdx:-1;t=t&&withoutVersion(t)||this.activeItem&&this.activeItem.active&&withoutVersion(this.activeItem.id)||"",this.deactivate(this.activeItem),this.items=this.definition.contentItems,this.flatItems=(0,utils_1.flattenByProp)(this.items||[],"items"),this.flatItems.forEach(((e,t)=>normalizeItem(e,t,this.options.pagination,this.definition instanceof VersionedSpecStore_1.VersionedSpecStore,this.history)));const s=t?(this.flatItems.find((e=>withoutVersion(e.id)===t))||{absoluteIdx:-1}).absoluteIdx:-1;if(-1!==s&&"none"!==this.options.pagination||(this.renderItems=this.buildRenderItems(0)),this.activeItemIdx=-1,-1!==s)this.activate(this.flatItems[s],e);else if(-1!==i)this.activateAndScroll(this.flatItems[0],e);else if(e){const e=this.definition.versionsInfo[this.definition.activeVersionIdx];if(!this.history.currentId&&e.isDefault)return;this.history.replace(e.id)}}buildRenderItems(e){if("none"===this.options.pagination)return this.items;let t=this.flatItems[e];if(t||(t=this.flatItems[0]),"spec"===t.type)return this.buildRenderItems(e+1);if("section"===t.type){const e=[],i=getParentOfType(t,"tag");if("section"===this.options.pagination&&i)return[i];if("item"===this.options.pagination&&i)return[Object.assign(Object.assign({},i),{items:getLeadingSectionItems(i)})];const s=getParentSpecItem(t),n=(null==s?void 0:s.items)||this.items;for(let t=0;t<n.length&&"section"===n[t].type;t++)e.push(n[t]);return e}switch(this.options.pagination){case"section":if(("operation"===t.type||"schema"===t.type)&&t.parent)return[t.parent];if("group"!==t.type)return[t];case"item":return"operation"===t.type||"schema"===t.type?[t]:[Object.assign(Object.assign({},t),{items:getLeadingSectionItems(t)})];default:return[]}}activateBase(e,t=!0,i=!1,s){var n,o,r,a,l;if((null===(n=this.activeItem)||void 0===n?void 0:n.id)===(null==e?void 0:e.id)&&!s)return t&&e&&this.history.replace(encodeURI(e.id),i),void(e&&!e.active&&e.activate());if(e&&"group"===e.type)return;if(this.deactivate(this.activeItem),!e)return void this.history.replace("",i);if(e.depth<=constants_1.GROUP_DEPTH)return;this.activeItemIdx=e.absoluteIdx,t&&this.history.replace(encodeURI(e.id),i),e.activate(),e.expand();const c=new URLSearchParams(s),d="request"===c.get("t"),u="response"===c.get("t"),h=c.get("c"),p=c.get("ct"),f=c.get("in"),m=c.get("path"),v=(null==m?void 0:m.split(this.options.deepLinkSeparator))||[],b=e;if(f){let e=b.parameters;for(const t of v){const i=null==e?void 0:e.find((e=>e.name===t));null==i||i.expand(),e=null===(o=null==i?void 0:i.schema)||void 0===o?void 0:o.fields}}else if(d){const e=null===(r=b.requestBody)||void 0===r?void 0:r.content;null===(a=b.activateMimeName)||void 0===a||a.call(b,p||b.activeMimeName),setTimeout((()=>{var t;return this.activateField(v,null===(t=null==e?void 0:e.active)||void 0===t?void 0:t.schema)}),0)}else if(u){const e=b.responses.find((e=>e.code===h));(null==e?void 0:e.expanded)||null==e||e.expand(),null===(l=b.activateMimeName)||void 0===l||l.call(b,p||b.activeMimeName),setTimeout((()=>{var t,i;return this.activateField(v,null===(i=null===(t=null==e?void 0:e.content)||void 0===t?void 0:t.active)||void 0===i?void 0:i.schema)}),0)}}activate(e,t=!0,i=!1,s=!0,n){if("none"===this.options.pagination)return this.activateBase(e,t,i,n),void(!e&&this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&this.history.replace(this.definition.currentVersionId,!0));if("group"!==(null==e?void 0:e.type)){if(e&&"item"===this.options.pagination&&"tag"===e.type&&!e.description){if(e.expanded)return void e.collapse();e.expand(),e=this.flatItems[e.absoluteIdx+1]}if(this.activateBase(e,e&&t,i,n),this.activeRenderItemIdx=e?e.absoluteIdx:this.activeRenderItemIdx,this.activeRenderItemIdx>=0){const e=this.buildRenderItems(this.activeRenderItemIdx);e.some(((e,t)=>e.id!==this.renderItems[t].id))&&(this.renderItems=e),this.renderItems[0]&&(this.activeRenderItemIdx=this.renderItems[0].absoluteIdx)}s&&setTimeout((()=>this.scrollToActive())),!e&&this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&this.history.replace(this.definition.currentVersionId,!0)}}activateField(e,t){var i;for(let s=0;s<e.length-1;s++){const n=e[s],o=s===e.length-1;if((null==t?void 0:t.hasType("array"))&&(null==t?void 0:t.items)&&(t=null==t?void 0:t.items),null==t?void 0:t.oneOf){const e=Number(n);if(isNaN(e))return;null==t||t.activateOneOf(e),t=null==t?void 0:t.oneOf[e];continue}(null==t?void 0:t.hasType("array"))&&(null==t?void 0:t.items)&&(t=null==t?void 0:t.items);const r=null===(i=null==t?void 0:t.fields)||void 0===i?void 0:i.find((e=>e.name===n));o||null==r||r.expand(),t=null==r?void 0:r.schema}}deactivate(e){if(void 0!==e)for(e.deactivate();void 0!==e;)e.collapse(),e=e.parent}activateAndScroll(e,t,i,s=""){const[,n]=s.split(this.options.deepLinkPrefix),o=e&&this.getItemById(e.id)||e;this.activate(o,t,i,!1,n),this.scrollToActive(n?s:""),o&&o.items.length||this.closeSidebar()}scrollToActive(e){e?setTimeout((()=>this.scroll.scrollIntoViewBySelector(`[${constants_1.SECTION_ATTR}="${(0,utils_1.escapeHTMLAttrChars)(e)}"]`)),0):this.scroll.scrollIntoView(this.getElementAt(this.activeItemIdx))}dispose(){var e,t;null===(e=this._unsubscribe)||void 0===e||e.call(this),null===(t=this._hashUnsubscribe)||void 0===t||t.call(this)}}function withoutVersion(e){return e.split("/").slice(1).join("/")}function getParentSpecItem(e){for(;e;){if("spec"===e.type)return e;e=e.parent}}function getParentOfType(e,t){if(e&&e.parent)return e.parent.type===t?e.parent:getParentOfType(e.parent,t)}function getLeadingSectionItems(e){const t=[];for(const i of e.items){if("section"!==i.type)break;t.push(i)}return t}function normalizeItem(e,t,i,s,n){if(e.absoluteIdx=t,"none"!==i){const t=getParentOfType(e,"tag");if(e.parent&&t&&!("_id_normalized"in e)){if(s){const[i,s]=e.id.split("/"),n=withoutVersion(e.id);if("operation"===e.type&&!s.startsWith("operation"))return;e.id=i+"/"+withoutVersion(t.id)+"/"+n}else{if("operation"===e.type&&!e.id.startsWith("operation"))return;e.id=t.id+"/"+e.id}e._id_normalized=!0}}"group"!==e.type&&(e.href=n.linkForId(e.id))}__decorate([mobx_1.observable],ProMenu.prototype,"flatItems",void 0),__decorate([mobx_1.observable],ProMenu.prototype,"items",void 0),__decorate([mobx_1.observable],ProMenu.prototype,"activeRenderItemIdx",void 0),__decorate([mobx_1.observable.ref],ProMenu.prototype,"renderItems",void 0),__decorate([mobx_1.observable],ProMenu.prototype,"activeItemIdx",void 0),__decorate([mobx_1.observable],ProMenu.prototype,"sideBarOpened",void 0),__decorate([mobx_1.action],ProMenu.prototype,"toggleSidebar",null),__decorate([mobx_1.action],ProMenu.prototype,"closeSidebar",null),__decorate([mobx_1.action],ProMenu.prototype,"activateBase",null),__decorate([mobx_1.action],ProMenu.prototype,"activate",null),__decorate([mobx_1.action.bound],ProMenu.prototype,"activateAndScroll",null),exports.ProMenu=ProMenu;
|
|
2
2
|
//# sourceMappingURL=ProMenu.js.map
|
|
@@ -39,6 +39,8 @@ export declare class NestingGroup implements IMenuItem {
|
|
|
39
39
|
expanded: boolean;
|
|
40
40
|
depth: number;
|
|
41
41
|
level: number;
|
|
42
|
+
httpVerb?: string;
|
|
43
|
+
path?: string;
|
|
42
44
|
constructor(id: string, items: ContentItemModel[], name?: string, linkable?: boolean);
|
|
43
45
|
activate(): void;
|
|
44
46
|
expand(): void;
|
package/lib/services/ProStore.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __decorate=this&&this.__decorate||function(e,t,i,o){var r,n=arguments.length,a=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(n<3?r(a):n>3?r(t,i,a):r(t,i))||a);return n>3&&a&&Object.defineProperty(t,i,a),a},__awaiter=this&&this.__awaiter||function(e,t,i,o){return new(i||(i=Promise))((function(r,n){function a(e){try{l(o.next(e))}catch(e){n(e)}}function s(e){try{l(o.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProStore=exports.NestingGroup=void 0;const mobx_1=require("mobx"),openapi_core_1=require("@redocly/openapi-core"),decko_1=require("decko"),SchemaDefinition_1=require("../components/SchemaDefinition/SchemaDefinition"),check_1=__importDefault(require("./check")),VersionedSpecStore_1=require("./VersionedSpecStore"),services_1=require("../services"),utils_1=require("../utils"),SecurityRequirement_1=require("../components/SecurityRequirement"),constants_1=require("../constants"),pluggable_1=require("../components/pluggable"),history_1=require("./history"),ProMenu_1=require("./ProMenu"),NormalizedOptions_1=require("./Options/NormalizedOptions"),search_1=require("./search"),global="undefined"==typeof window?{__REDOCLY_SEARCH_URL:void 0}:window;class NestingGroup{constructor(e,t,i,o){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"absoluteIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"linkable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"expanded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"depth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"level",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),(0,mobx_1.makeObservable)(this),this.id="section/"+e,this.type="nesting-group",this.name=i||"",this.level=1,this.depth=1,this.description="",this.parent=void 0,this.expanded=!1,this.items=t,this.linkable=!!o,t.forEach((e=>e.parent=this)),increaseDepthDeep(t)}activate(){this.active=!0}expand(){this.expanded=!0,this.parent&&this.parent.expand()}collapse(){this.expanded=!1}deactivate(){this.active=!1}}function increaseDepthDeep(e){Array.isArray(e)&&e.forEach((e=>{e.depth++,e.parent&&"group"===e.parent.type&&(e.depth=e.parent.depth),increaseDepthDeep(e.items)}))}__decorate([mobx_1.observable],NestingGroup.prototype,"active",void 0),__decorate([mobx_1.observable],NestingGroup.prototype,"expanded",void 0),__decorate([mobx_1.action],NestingGroup.prototype,"activate",null),__decorate([mobx_1.action],NestingGroup.prototype,"expand",null),__decorate([mobx_1.action],NestingGroup.prototype,"collapse",null),__decorate([mobx_1.action],NestingGroup.prototype,"deactivate",null),exports.NestingGroup=NestingGroup;class ProStore{constructor(e,t,i={},o=!0){Object.defineProperty(this,"rawOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"menu",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"marker",{enumerable:!0,configurable:!0,writable:!0,value:new services_1.MarkerService}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disposer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"search",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tryItOperation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showRightPanel",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"layout",{enumerable:!0,configurable:!0,writable:!0,value:constants_1.LayoutVariant.THREE_PANEL}),Object.defineProperty(this,"activeSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLoading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"l",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),(0,mobx_1.makeObservable)(this),this.initProOptions(i),utils_1.IS_BROWSER&&(this.l=(0,check_1.default)(i.licenseKey),this.l.then((e=>{e.valid&&e.allowed&&!e.expired||e.local||(this.menu.items=[],this.menu.flatItems=this.menu.flatItems.slice(0,1),this.menu.renderItems=[])})));const r="object"==typeof e&&"versions"in e,n=this.options.disableSidebar?new history_1.FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new history_1.PushStateHistoryService(this.options,r):new history_1.ProHashHistoryService(this.options,r);this.definition=r?new VersionedSpecStore_1.VersionedSpecStore(e,this.options,n.currentId.split("/")[0]):new services_1.SpecStore(e,t,this.options),i.downloadDefinitionUrl&&(this.definition.info.downloadFileName=""),this.scroll=new services_1.ScrollService(this.options),this.options.disableSidebar||ProMenu_1.ProMenu.updateOnHistory(n.currentId,this.scroll),this.menu=new ProMenu_1.ProMenu(this.definition,this.scroll,this.options,n),this.menu.initOnHistory(),this.options.disableSearch||this.initSearch(this.options,o),this.disposer=(0,mobx_1.observe)(this.menu,"none"===this.options.pagination?"activeItemIdx":"activeRenderItemIdx",(e=>{setTimeout((()=>this.updateMarkOnMenu(e.newValue)))})),(0,utils_1.setGlobalStore)(this)}initProOptions(e){e=deepClone(e),this.rawOptions=e,this.options=(0,NormalizedOptions_1.NormalizedOptions)(this.rawOptions,DEFAULT_OPTIONS)}initSearch(e,t){global.__REDOCLY_SEARCH_URL?this.search=new search_1.RemoteSearch(global.__REDOCLY_SEARCH_URL):this.search=new search_1.DeepSearchStore(e),t&&setTimeout((()=>{var e;return null===(e=this.search)||void 0===e?void 0:e.indexItems(this.menu.items)}),50),this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&(0,mobx_1.observe)(this.definition,"activeVersionIdx",(t=>{var i,o;const r=this.definition;null===(i=this.search)||void 0===i||i.dispose(),this.search=new search_1.DeepSearchStore(e);const n=r.versions[t.newValue]._searchIndexName;if(utils_1.IS_BROWSER&&n){const e=r.versions[t.newValue]._searchIndexName,i=new URL(window.location.href);i.pathname=joinURLs(this.options.routingBasePath,e),null===(o=this.search)||void 0===o||o.fromExternalJS(i.toString(),__redoc_state.searchIndexExport),this.observeAllAndRemark()}else setTimeout((()=>{var e;null===(e=this.search)||void 0===e||e.indexItems(this.menu.items)}),0)})),utils_1.IS_BROWSER&&this.observeAllAndRemark()}onDidMount(){if(this.menu.updateOnHistory(),this.updateMarkOnMenu(this.menu.activeItemIdx),this.layout=(0,utils_1.fromLocalStorage)("layoutVariant")||this.options.layout||this.layout,this.activeSampleLanguage=(0,utils_1.fromLocalStorage)("activeSampleLanguage")||this.options.defaultSampleLanguage,this.options.showRightPanelToggle){const e=(0,utils_1.fromSessionStorage)("showRightPanelToggleState");e&&(this.showRightPanel="true"===e)}}toggleRightPanel(e){this.showRightPanel=null!=e?e:!this.showRightPanel,(0,utils_1.toSessionStorage)("showRightPanelToggleState",JSON.stringify(this.showRightPanel))}toggleLayout(e=constants_1.LayoutVariant.THREE_PANEL){this.layout=e,(0,utils_1.toLocalStorage)("layoutVariant",e)}disableConsole(){this.options.showConsole=!1}enableConsole(){this.options.showConsole=!0}tryItOut(e){this.tryItOperation=e}setActiveSampleLanguage(e){if(this.activeSampleLanguage===e)return this.stopLoader();this.activeSampleLanguage=e,(0,utils_1.toLocalStorage)("activeSampleLanguage",e)}activateSampleLanguage(e){this.setActiveSampleLanguage(e)}startLoader(){this.isLoading||(this.isLoading=!0)}stopLoader(){this.isLoading&&(this.isLoading=!1)}dereferenceSpecForTryIt(e){var t,i,o,r;return __awaiter(this,void 0,void 0,(function*(){const n=this.definition.parser.definition,a=JSON.parse(JSON.stringify(n)),s=Object.assign(Object.assign({},getSpecVersionObj(a)),{components:a.components,paths:{[e.path]:{[e.httpVerb]:null===(i=null===(t=a.paths)||void 0===t?void 0:t[e.path])||void 0===i?void 0:i[e.httpVerb],parameters:null===(r=null===(o=a.paths)||void 0===o?void 0:o[e.path])||void 0===r?void 0:r.parameters}}}),l={config:new openapi_core_1.Config({}),doc:(0,utils_1.createParsedDocument)(s),dereference:!0};return yield(0,openapi_core_1.bundle)(l),a}))}observeAllAndRemark(){const e=t=>{for(const i of t)if("operation"===i.type){const e=i.responses;for(const t of e)(0,mobx_1.observe)(t,"expanded",(e=>this.remark(e)))}else"tag"===i.type&&e(i.items||[])};e(this.menu.renderItems),"none"!==this.options.pagination&&(0,mobx_1.observe)(this.menu,"renderItems",(()=>e(this.menu.renderItems)))}remark(e){e.newValue&&setTimeout((()=>this.marker.mark()),0)}static fromJS(e){var t;const i=new ProStore(e.definition.data,e.definition.url,e.options,!1);(0,utils_1.setGlobalStore)(i),i.menu.activeItemIdx=void 0!==e.menu.activeItemIdx?e.menu.activeItemIdx:-1,i.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&e.definition.activeVersionIdx&&(i.definition.activeVersionIdx=e.definition.activeVersionIdx||0);const o=i.menu.flatItems[i.menu.activeItemIdx];if(o&&i.menu.activate(o,!1),!i.options.disableSearch){const o=new URL(window.location.href);o.pathname=e.searchIndexPath&&e.searchIndexPath.startsWith("/")?e.searchIndexPath:o.pathname+(o.pathname.endsWith("/")?"":"/")+e.searchIndexPath,null===(t=i.search)||void 0===t||t.fromExternalJS(o.toString(),e.searchIndexExport)}return e.tryItOperationId&&(i.tryItOperation=i.menu.flatItems.find((t=>t.id===e.tryItOperationId))),setTimeout((()=>i.observeAllAndRemark()),0),i}toJS(){var e;return __awaiter(this,void 0,void 0,(function*(){return{menu:{activeItemIdx:this.menu.activeItemIdx},definition:this.definition instanceof VersionedSpecStore_1.VersionedSpecStore?{url:void 0,data:this.definition.toJS()}:{url:this.definition.parser.definitionUrl,data:this.definition.parser.definition},searchIndex:this.search?yield this.search.toJS():void 0,options:this.rawOptions,tryItOperationId:null===(e=this.tryItOperation)||void 0===e?void 0:e.id}}))}dispose(){this.scroll.dispose(),this.menu.dispose(),this.search&&this.search.dispose(),this.disposer()}updateMarkOnMenu(e){const t=Math.max(0,e),i=Math.min(this.menu.flatItems.length,t+5),o=[];for(let e=t;e<i;e++){const t=this.menu.getElementAt(e);t&&(t&&o.push(t))}if("item"===this.options.pagination){const{parent:t}=this.menu.flatItems[e]||{};if(null==t?void 0:t.absoluteIdx){const e=this.menu.getElementAt(t.absoluteIdx);e&&o.push(e)}}this.marker.addOnly(o),this.marker.mark()}}__decorate([mobx_1.observable],ProStore.prototype,"search",void 0),__decorate([mobx_1.observable],ProStore.prototype,"tryItOperation",void 0),__decorate([mobx_1.observable],ProStore.prototype,"showRightPanel",void 0),__decorate([mobx_1.observable],ProStore.prototype,"layout",void 0),__decorate([mobx_1.observable],ProStore.prototype,"activeSampleLanguage",void 0),__decorate([mobx_1.observable],ProStore.prototype,"isLoading",void 0),__decorate([mobx_1.action],ProStore.prototype,"onDidMount",null),__decorate([mobx_1.action],ProStore.prototype,"toggleRightPanel",null),__decorate([mobx_1.action],ProStore.prototype,"toggleLayout",null),__decorate([mobx_1.action],ProStore.prototype,"disableConsole",null),__decorate([mobx_1.action],ProStore.prototype,"enableConsole",null),__decorate([mobx_1.action],ProStore.prototype,"tryItOut",null),__decorate([mobx_1.action],ProStore.prototype,"setActiveSampleLanguage",null),__decorate([decko_1.bind,(0,decko_1.debounce)(500)],ProStore.prototype,"activateSampleLanguage",null),__decorate([mobx_1.action],ProStore.prototype,"startLoader",null),__decorate([mobx_1.action],ProStore.prototype,"stopLoader",null),exports.ProStore=ProStore;const DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],breakpoints:constants_1.defaultTheme.breakpoints,showAtBreakpoint:constants_1.defaultTheme.showAtBreakpoint,allowedMdComponents:{RedocResponse:{component:pluggable_1.RedocResponse,propsSelector:e=>({store:e})},PullRight:{component:pluggable_1.PullRight,propsSelector:()=>({})},[utils_1.SCHEMA_DEFINITION_JSX_NAME]:{component:SchemaDefinition_1.SchemaDefinition,propsSelector:e=>({parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel})},[utils_1.SECURITY_DEFINITIONS_COMPONENT_NAME]:{component:SecurityRequirement_1.SecurityDefs,propsSelector:e=>({securitySchemes:e.definition.securitySchemes})},[utils_1.SECURITY_DEFINITIONS_JSX_NAME]:{component:SecurityRequirement_1.SecurityDefs,propsSelector:e=>({securitySchemes:e.definition.securitySchemes})}}};function joinURLs(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),t.startsWith("/")&&(t=t.substring(1)),`${e}/${t}`}function getSpecVersionObj(e){return e.openapi?{openapi:e.openapi}:e.swagger?{swagger:e.swagger}:void 0}function deepClone(e){if("object"!=typeof e||null===e)return e;const t=Array.isArray(e)?[]:{};for(const i in e){const o=e[i];t[i]=deepClone(o)}return t}
|
|
1
|
+
"use strict";var __decorate=this&&this.__decorate||function(e,t,i,o){var r,n=arguments.length,a=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,o);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(n<3?r(a):n>3?r(t,i,a):r(t,i))||a);return n>3&&a&&Object.defineProperty(t,i,a),a},__awaiter=this&&this.__awaiter||function(e,t,i,o){return new(i||(i=Promise))((function(r,n){function a(e){try{l(o.next(e))}catch(e){n(e)}}function s(e){try{l(o.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProStore=exports.NestingGroup=void 0;const mobx_1=require("mobx"),openapi_core_1=require("@redocly/openapi-core"),decko_1=require("decko"),SchemaDefinition_1=require("../components/SchemaDefinition/SchemaDefinition"),check_1=__importDefault(require("./check")),VersionedSpecStore_1=require("./VersionedSpecStore"),services_1=require("../services"),utils_1=require("../utils"),SecurityRequirement_1=require("../components/SecurityRequirement"),constants_1=require("../constants"),pluggable_1=require("../components/pluggable"),history_1=require("./history"),ProMenu_1=require("./ProMenu"),NormalizedOptions_1=require("./Options/NormalizedOptions"),search_1=require("./search"),global="undefined"==typeof window?{__REDOCLY_SEARCH_URL:void 0}:window;class NestingGroup{constructor(e,t,i,o){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"absoluteIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"linkable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"expanded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"depth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"level",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"httpVerb",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"path",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),(0,mobx_1.makeObservable)(this),this.id="section/"+e,this.type="nesting-group",this.name=i||"",this.level=1,this.depth=1,this.description="",this.parent=void 0,this.expanded=!1,this.items=t,this.linkable=!!o,t.forEach((e=>e.parent=this)),increaseDepthDeep(t)}activate(){this.active=!0}expand(){this.expanded=!0,this.parent&&this.parent.expand()}collapse(){this.expanded=!1}deactivate(){this.active=!1}}function increaseDepthDeep(e){Array.isArray(e)&&e.forEach((e=>{e.depth++,e.parent&&"group"===e.parent.type&&(e.depth=e.parent.depth),increaseDepthDeep(e.items)}))}__decorate([mobx_1.observable],NestingGroup.prototype,"active",void 0),__decorate([mobx_1.observable],NestingGroup.prototype,"expanded",void 0),__decorate([mobx_1.action],NestingGroup.prototype,"activate",null),__decorate([mobx_1.action],NestingGroup.prototype,"expand",null),__decorate([mobx_1.action],NestingGroup.prototype,"collapse",null),__decorate([mobx_1.action],NestingGroup.prototype,"deactivate",null),exports.NestingGroup=NestingGroup;class ProStore{constructor(e,t,i={},o=!0){Object.defineProperty(this,"rawOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"menu",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"marker",{enumerable:!0,configurable:!0,writable:!0,value:new services_1.MarkerService}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disposer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"search",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tryItOperation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showRightPanel",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"layout",{enumerable:!0,configurable:!0,writable:!0,value:constants_1.LayoutVariant.THREE_PANEL}),Object.defineProperty(this,"activeSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLoading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"l",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),(0,mobx_1.makeObservable)(this),this.initProOptions(i),utils_1.IS_BROWSER&&(this.l=(0,check_1.default)(i.licenseKey),this.l.then((e=>{e.valid&&e.allowed&&!e.expired||e.local||(this.menu.items=[],this.menu.flatItems=this.menu.flatItems.slice(0,1),this.menu.renderItems=[])})));const r="object"==typeof e&&"versions"in e,n=this.options.disableSidebar?new history_1.FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new history_1.PushStateHistoryService(this.options,r):new history_1.ProHashHistoryService(this.options,r);this.definition=r?new VersionedSpecStore_1.VersionedSpecStore(e,this.options,n.currentId.split("/")[0]):new services_1.SpecStore(e,t,this.options),i.downloadDefinitionUrl&&(this.definition.info.downloadFileName=""),this.scroll=new services_1.ScrollService(this.options),this.options.disableSidebar||ProMenu_1.ProMenu.updateOnHistory(n.currentId,this.scroll),this.menu=new ProMenu_1.ProMenu(this.definition,this.scroll,this.options,n),this.menu.initOnHistory(),this.options.disableSearch||this.initSearch(this.options,o),this.disposer=(0,mobx_1.observe)(this.menu,"none"===this.options.pagination?"activeItemIdx":"activeRenderItemIdx",(e=>{setTimeout((()=>this.updateMarkOnMenu(e.newValue)))})),(0,utils_1.setGlobalStore)(this)}initProOptions(e){e=deepClone(e),this.rawOptions=e,this.options=(0,NormalizedOptions_1.NormalizedOptions)(this.rawOptions,DEFAULT_OPTIONS)}initSearch(e,t){global.__REDOCLY_SEARCH_URL?this.search=new search_1.RemoteSearch(global.__REDOCLY_SEARCH_URL):this.search=new search_1.DeepSearchStore(e),t&&setTimeout((()=>{var e;return null===(e=this.search)||void 0===e?void 0:e.indexItems(this.menu.items)}),50),this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&(0,mobx_1.observe)(this.definition,"activeVersionIdx",(t=>{var i,o;const r=this.definition;null===(i=this.search)||void 0===i||i.dispose(),this.search=new search_1.DeepSearchStore(e);const n=r.versions[t.newValue]._searchIndexName;if(utils_1.IS_BROWSER&&n){const e=r.versions[t.newValue]._searchIndexName,i=new URL(window.location.href);i.pathname=joinURLs(this.options.routingBasePath,e),null===(o=this.search)||void 0===o||o.fromExternalJS(i.toString(),__redoc_state.searchIndexExport),this.observeAllAndRemark()}else setTimeout((()=>{var e;null===(e=this.search)||void 0===e||e.indexItems(this.menu.items)}),0)})),utils_1.IS_BROWSER&&this.observeAllAndRemark()}onDidMount(){if(this.menu.updateOnHistory(),this.updateMarkOnMenu(this.menu.activeItemIdx),this.layout=(0,utils_1.fromLocalStorage)("layoutVariant")||this.options.layout||this.layout,this.activeSampleLanguage=(0,utils_1.fromLocalStorage)("activeSampleLanguage")||this.options.defaultSampleLanguage,this.options.showRightPanelToggle){const e=(0,utils_1.fromSessionStorage)("showRightPanelToggleState");e&&(this.showRightPanel="true"===e)}}toggleRightPanel(e){this.showRightPanel=null!=e?e:!this.showRightPanel,(0,utils_1.toSessionStorage)("showRightPanelToggleState",JSON.stringify(this.showRightPanel))}toggleLayout(e=constants_1.LayoutVariant.THREE_PANEL){this.layout=e,(0,utils_1.toLocalStorage)("layoutVariant",e)}disableConsole(){this.options.showConsole=!1}enableConsole(){this.options.showConsole=!0}tryItOut(e){this.tryItOperation=e}setActiveSampleLanguage(e){if(this.activeSampleLanguage===e)return this.stopLoader();this.activeSampleLanguage=e,(0,utils_1.toLocalStorage)("activeSampleLanguage",e)}activateSampleLanguage(e){this.setActiveSampleLanguage(e)}startLoader(){this.isLoading||(this.isLoading=!0)}stopLoader(){this.isLoading&&(this.isLoading=!1)}dereferenceSpecForTryIt(e){var t,i,o,r;return __awaiter(this,void 0,void 0,(function*(){const n=this.definition.parser.definition,a=JSON.parse(JSON.stringify(n)),s=Object.assign(Object.assign({},getSpecVersionObj(a)),{components:a.components,paths:{[e.path]:{[e.httpVerb]:null===(i=null===(t=a.paths)||void 0===t?void 0:t[e.path])||void 0===i?void 0:i[e.httpVerb],parameters:null===(r=null===(o=a.paths)||void 0===o?void 0:o[e.path])||void 0===r?void 0:r.parameters}}}),l={config:new openapi_core_1.Config({}),doc:(0,utils_1.createParsedDocument)(s),dereference:!0};return yield(0,openapi_core_1.bundle)(l),a}))}observeAllAndRemark(){const e=t=>{for(const i of t)if("operation"===i.type){const e=i.responses;for(const t of e)(0,mobx_1.observe)(t,"expanded",(e=>this.remark(e)))}else"tag"===i.type&&e(i.items||[])};e(this.menu.renderItems),"none"!==this.options.pagination&&(0,mobx_1.observe)(this.menu,"renderItems",(()=>e(this.menu.renderItems)))}remark(e){e.newValue&&setTimeout((()=>this.marker.mark()),0)}static fromJS(e){var t;const i=new ProStore(e.definition.data,e.definition.url,e.options,!1);(0,utils_1.setGlobalStore)(i),i.menu.activeItemIdx=void 0!==e.menu.activeItemIdx?e.menu.activeItemIdx:-1,i.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&e.definition.activeVersionIdx&&(i.definition.activeVersionIdx=e.definition.activeVersionIdx||0);const o=i.menu.flatItems[i.menu.activeItemIdx];if(o&&i.menu.activate(o,!1),!i.options.disableSearch){const o=new URL(window.location.href);o.pathname=e.searchIndexPath&&e.searchIndexPath.startsWith("/")?e.searchIndexPath:o.pathname+(o.pathname.endsWith("/")?"":"/")+e.searchIndexPath,null===(t=i.search)||void 0===t||t.fromExternalJS(o.toString(),e.searchIndexExport)}return e.tryItOperationId&&(i.tryItOperation=i.menu.flatItems.find((t=>t.id===e.tryItOperationId))),setTimeout((()=>i.observeAllAndRemark()),0),i}toJS(){var e;return __awaiter(this,void 0,void 0,(function*(){return{menu:{activeItemIdx:this.menu.activeItemIdx},definition:this.definition instanceof VersionedSpecStore_1.VersionedSpecStore?{url:void 0,data:this.definition.toJS()}:{url:this.definition.parser.definitionUrl,data:this.definition.parser.definition},searchIndex:this.search?yield this.search.toJS():void 0,options:this.rawOptions,tryItOperationId:null===(e=this.tryItOperation)||void 0===e?void 0:e.id}}))}dispose(){this.scroll.dispose(),this.menu.dispose(),this.search&&this.search.dispose(),this.disposer()}updateMarkOnMenu(e){const t=Math.max(0,e),i=Math.min(this.menu.flatItems.length,t+5),o=[];for(let e=t;e<i;e++){const t=this.menu.getElementAt(e);t&&(t&&o.push(t))}if("item"===this.options.pagination){const{parent:t}=this.menu.flatItems[e]||{};if(null==t?void 0:t.absoluteIdx){const e=this.menu.getElementAt(t.absoluteIdx);e&&o.push(e)}}this.marker.addOnly(o),this.marker.mark()}}__decorate([mobx_1.observable],ProStore.prototype,"search",void 0),__decorate([mobx_1.observable],ProStore.prototype,"tryItOperation",void 0),__decorate([mobx_1.observable],ProStore.prototype,"showRightPanel",void 0),__decorate([mobx_1.observable],ProStore.prototype,"layout",void 0),__decorate([mobx_1.observable],ProStore.prototype,"activeSampleLanguage",void 0),__decorate([mobx_1.observable],ProStore.prototype,"isLoading",void 0),__decorate([mobx_1.action],ProStore.prototype,"onDidMount",null),__decorate([mobx_1.action],ProStore.prototype,"toggleRightPanel",null),__decorate([mobx_1.action],ProStore.prototype,"toggleLayout",null),__decorate([mobx_1.action],ProStore.prototype,"disableConsole",null),__decorate([mobx_1.action],ProStore.prototype,"enableConsole",null),__decorate([mobx_1.action],ProStore.prototype,"tryItOut",null),__decorate([mobx_1.action],ProStore.prototype,"setActiveSampleLanguage",null),__decorate([decko_1.bind,(0,decko_1.debounce)(500)],ProStore.prototype,"activateSampleLanguage",null),__decorate([mobx_1.action],ProStore.prototype,"startLoader",null),__decorate([mobx_1.action],ProStore.prototype,"stopLoader",null),exports.ProStore=ProStore;const DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],breakpoints:constants_1.defaultTheme.breakpoints,showAtBreakpoint:constants_1.defaultTheme.showAtBreakpoint,allowedMdComponents:{RedocResponse:{component:pluggable_1.RedocResponse,propsSelector:e=>({store:e})},PullRight:{component:pluggable_1.PullRight,propsSelector:()=>({})},[utils_1.SCHEMA_DEFINITION_JSX_NAME]:{component:SchemaDefinition_1.SchemaDefinition,propsSelector:e=>({parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel})},[utils_1.SECURITY_DEFINITIONS_COMPONENT_NAME]:{component:SecurityRequirement_1.SecurityDefs,propsSelector:e=>({securitySchemes:e.definition.securitySchemes})},[utils_1.SECURITY_DEFINITIONS_JSX_NAME]:{component:SecurityRequirement_1.SecurityDefs,propsSelector:e=>({securitySchemes:e.definition.securitySchemes})}}};function joinURLs(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),t.startsWith("/")&&(t=t.substring(1)),`${e}/${t}`}function getSpecVersionObj(e){return e.openapi?{openapi:e.openapi}:e.swagger?{swagger:e.swagger}:void 0}function deepClone(e){if("object"!=typeof e||null===e)return e;const t=Array.isArray(e)?[]:{};for(const i in e){const o=e[i];t[i]=deepClone(o)}return t}
|
|
2
2
|
//# sourceMappingURL=ProStore.js.map
|
package/lib/services/check.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { OperationModel } from '../../models';
|
|
|
2
2
|
import type * as HAR from './har';
|
|
3
3
|
import type { Languages } from './types';
|
|
4
4
|
import type { ServerVariables } from '../../types';
|
|
5
|
-
export
|
|
5
|
+
export type CustomHAR = HAR.Request & {
|
|
6
6
|
securityOAuth2ExtraCalls?: HAR.Request[];
|
|
7
7
|
basicAuth?: {
|
|
8
8
|
username: string;
|
|
@@ -9,7 +9,7 @@ export declare function addIndentation(str: string, { level, indent, firstLine }
|
|
|
9
9
|
indent?: string | undefined;
|
|
10
10
|
firstLine?: boolean | undefined;
|
|
11
11
|
}): string;
|
|
12
|
-
export
|
|
12
|
+
export type CodeOperand = {
|
|
13
13
|
type: 'string';
|
|
14
14
|
value: string;
|
|
15
15
|
} | {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.startCase=exports.snakeCase=exports.lowerCase=exports.camelCase=void 0;const rsAstralRange="\\ud800-\\udfff",rsComboMarksRange="\\u0300-\\u036f",reComboHalfMarksRange="\\ufe20-\\ufe2f",rsComboSymbolsRange="\\u20d0-\\u20ff",rsComboMarksExtendedRange="\\u1ab0-\\u1aff",rsComboMarksSupplementRange="\\u1dc0-\\u1dff",rsComboRange="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff",rsDingbatRange="\\u2700-\\u27bf",rsLowerRange="a-z\\xdf-\\xf6\\xf8-\\xff",rsMathOpRange="\\xac\\xb1\\xd7\\xf7",rsNonCharRange="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",rsPunctuationRange="\\u2000-\\u206f",rsSpaceRange=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",rsUpperRange="A-Z\\xc0-\\xd6\\xd8-\\xde",rsVarRange="\\ufe0e\\ufe0f",rsBreakRange=rsMathOpRange+rsNonCharRange+"\\u2000-\\u206f"+rsSpaceRange,reQuotes=/['\u2019]/g,rsApos="['’]",rsBreak=`[${rsBreakRange}]`,rsCombo=`[${rsComboRange}]`,rsDigit="\\d",rsDingbat
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.startCase=exports.snakeCase=exports.lowerCase=exports.camelCase=void 0;const rsAstralRange="\\ud800-\\udfff",rsComboMarksRange="\\u0300-\\u036f",reComboHalfMarksRange="\\ufe20-\\ufe2f",rsComboSymbolsRange="\\u20d0-\\u20ff",rsComboMarksExtendedRange="\\u1ab0-\\u1aff",rsComboMarksSupplementRange="\\u1dc0-\\u1dff",rsComboRange="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff",rsDingbatRange="\\u2700-\\u27bf",rsLowerRange="a-z\\xdf-\\xf6\\xf8-\\xff",rsMathOpRange="\\xac\\xb1\\xd7\\xf7",rsNonCharRange="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",rsPunctuationRange="\\u2000-\\u206f",rsSpaceRange=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",rsUpperRange="A-Z\\xc0-\\xd6\\xd8-\\xde",rsVarRange="\\ufe0e\\ufe0f",rsBreakRange=rsMathOpRange+rsNonCharRange+"\\u2000-\\u206f"+rsSpaceRange,reQuotes=/['\u2019]/g,rsApos="['’]",rsBreak=`[${rsBreakRange}]`,rsCombo=`[${rsComboRange}]`,rsDigit="\\d",rsDingbat=`[${rsDingbatRange}]`,rsLower=`[${rsLowerRange}]`,rsMisc=`[^${rsAstralRange}${rsBreakRange+"\\d"+rsDingbatRange+rsLowerRange+rsUpperRange}]`,rsFitz="\\ud83c[\\udffb-\\udfff]",rsModifier=`(?:${rsCombo}|${rsFitz})`,rsNonAstral=`[^${rsAstralRange}]`,rsRegional="(?:\\ud83c[\\udde6-\\uddff]){2}",rsSurrPair="[\\ud800-\\udbff][\\udc00-\\udfff]",rsUpper=`[${rsUpperRange}]`,rsZWJ="\\u200d",rsMiscLower=`(?:${rsLower}|${rsMisc})`,rsMiscUpper=`(?:${rsUpper}|${rsMisc})`,rsOptContrLower="(?:['’](?:d|ll|m|re|s|t|ve))?",rsOptContrUpper="(?:['’](?:D|LL|M|RE|S|T|VE))?",reOptMod=`${rsModifier}?`,rsOptVar=`[${rsVarRange}]?`,rsOptJoin=`(?:${rsZWJ}(?:${[rsNonAstral,rsRegional,rsSurrPair].join("|")})${rsOptVar+reOptMod})*`,rsOrdLower="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",rsOrdUpper="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",rsSeq=rsOptVar+reOptMod+rsOptJoin,rsEmoji=`(?:${[rsDingbat,rsRegional,rsSurrPair].join("|")})${rsSeq}`,reUnicodeWords=RegExp([`${rsUpper}?${rsLower}+${rsOptContrLower}(?=${[rsBreak,rsUpper,"$"].join("|")})`,`${rsMiscUpper}+${rsOptContrUpper}(?=${[rsBreak,rsUpper+rsMiscLower,"$"].join("|")})`,`${rsUpper}?${rsMiscLower}+${rsOptContrLower}`,`${rsUpper}+${rsOptContrUpper}`,rsOrdUpper,rsOrdLower,"\\d+",rsEmoji].join("|"),"g"),unicodeWords=r=>r.match(reUnicodeWords),reHasUnicode=RegExp(`[${rsZWJ+rsAstralRange+rsComboRange+rsVarRange}]`),hasUnicode=r=>reHasUnicode.test(r),rsAstral=`[${rsAstralRange}]`,rsNonAstralCombo=`${rsNonAstral}${rsCombo}?`,rsSymbol=`(?:${[rsNonAstralCombo,rsCombo,rsRegional,rsSurrPair,rsAstral].join("|")})`,reUnicode=RegExp(`${rsFitz}(?=${rsFitz})|${rsSymbol+rsSeq}`,"g"),unicodeToArray=r=>r.match(reUnicode)||[],asciiToArray=r=>r.split(""),getTag=r=>{const e=Object.prototype.toString;return null==r?void 0===r?"[object Undefined]":"[object Null]":e.call(r)},isSymbol=r=>{const e=typeof r;return"symbol"==e||"object"===e&&null!=r&&"[object Symbol]"==getTag(r)},INFINITY=1/0,toString=r=>{if(null==r)return"";if("string"==typeof r)return r;if(Array.isArray(r))return`${r.map((r=>null==r?r:toString(r)))}`;if(isSymbol(r))return r.toString();const e=`${r}`;return"0"==e&&1/r==-Infinity?"-0":e},hasUnicodeWord=RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/),reAsciiWord=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,asciiWords=r=>r.match(reAsciiWord),slice=(r,e,s)=>{let o=null==r?0:r.length;if(!o)return[];(e=null==e?0:e)<0&&(e=-e>o?0:o+e),(s=(s=void 0===s?o:s)>o?o:s)<0&&(s+=o),o=e>s?0:s-e>>>0,e>>>=0;let a=-1;const t=new Array(o);for(;++a<o;)t[a]=r[a+e];return t},words=r=>(hasUnicodeWord(r)?unicodeWords(r):asciiWords(r))||[],castSlice=(r,e)=>{const{length:s}=r;return!e&&s>=s?r:slice(r,e,s)},stringToArray=r=>hasUnicode(r)?unicodeToArray(r):asciiToArray(r),createCaseFirst=r=>e=>{if(!e)return"";const s=hasUnicode(e)?stringToArray(e):void 0,o=s?s[0]:e[0],a=s?castSlice(s,1).join(""):e.slice(1);return o[r]()+a},upperFirst=createCaseFirst("toUpperCase"),camelCase=r=>words(toString(r).replace(/['\u2019]/g,"")).reduce(((r,e,s)=>(e=e.toLowerCase(),r+(s?upperFirst(e):e))),"");exports.camelCase=camelCase;const lowerCase=r=>words(toString(r).replace(reQuotes,"")).reduce(((r,e,s)=>r+(s?" ":"")+e.toLowerCase()),"");exports.lowerCase=lowerCase;const snakeCase=r=>words(toString(r).replace(/['\u2019]/g,"")).reduce(((r,e,s)=>r+(s?"_":"")+e.toLowerCase()),"");exports.snakeCase=snakeCase;const startCase=r=>words(`${r}`.replace(/['\u2019]/g,"")).reduce(((r,e,s)=>r+(s?" ":"")+upperFirst(e)),"");exports.startCase=startCase;
|
|
2
2
|
//# sourceMappingURL=lodash-int.js.map
|
|
@@ -3,7 +3,7 @@ import type { PostData } from '../har';
|
|
|
3
3
|
interface ParsedUrlQueryInput {
|
|
4
4
|
[key: string]: string | number | boolean | string[] | number[] | boolean[] | undefined | null;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
6
|
+
export type KeyValueAreStrings = {
|
|
7
7
|
[key in string]: string;
|
|
8
8
|
};
|
|
9
9
|
export interface SnippetRequest extends CustomHAR {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Languages = 'JavaScript' | 'Node.js' | 'curl' | 'Java8+Apache' | 'Java' | 'Python' | 'Go' | 'PHP' | 'C#' | 'Ruby' | 'R';
|
|
2
2
|
export interface BasicLanguageOptions {
|
|
3
3
|
indent?: string;
|
|
4
4
|
withImports?: boolean;
|
|
@@ -48,7 +48,7 @@ export interface RubyCodeSampleConfig extends CodeSampleBasicConfig {
|
|
|
48
48
|
export interface RCodeSampleConfig extends CodeSampleBasicConfig {
|
|
49
49
|
lang: 'R';
|
|
50
50
|
}
|
|
51
|
-
export
|
|
51
|
+
export type CodeSampleConfig = cURULCodeSampleConfig | JavaScriptCodeSampleConfig | NodeJsCodeSampleConfig | PythonCodeSampleConfig | Java8CodeSampleConfig | JavaCodeSampleConfig | CSharpCodeSampleConfig | PHPCodeSampleConfig | GoCodeSampleConfig | RubyCodeSampleConfig | RCodeSampleConfig;
|
|
52
52
|
/**
|
|
53
53
|
* Code Samples Generator rules
|
|
54
54
|
* - Reference docs always displays all user custom x-code-samples
|