Socket
Socket
Sign inDemoInstall

@har-sdk/editor

Package Overview
Dependencies
37
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.5.5 to 1.5.6

2

dist/bundle.esm5.js

@@ -1,2 +0,2 @@

import e from"json-pointer";import{SpecImporter as r}from"@har-sdk/core";import{dump as t}from"js-yaml";import s from"jsonpath";import a from"@apidevtools/json-schema-ref-parser";var o,n;function i(e){return Object.values(o).includes(null==e?void 0:e.toUpperCase())}!function(e){e.GET="GET",e.PUT="PUT",e.POST="POST",e.DELETE="DELETE",e.OPTIONS="OPTIONS",e.HEAD="HEAD",e.PATCH="PATCH",e.TRACE="TRACE"}(o||(o={})),function(e){e.PATH="path",e.QUERY="query",e.HEADER="header",e.BODY="body"}(n||(n={}));class c{constructor(e){this.doc=e}parse(r){const t=e.parse(r).pop(),s=e.get(this.doc,r),a=this.parseParameters(r),o=this.createOperationObjectsParser();return{path:t,jsonPointer:r,children:Object.keys(s).filter(i).map((r=>o.parse(e.compile(["paths",t,r])))),...(null==a?void 0:a.length)?{parameters:a}:{}}}parseParameters(e){return this.createParametersObjectParser().parse(`${e}/parameters`)||[]}}class d{parse(r){const t=[...this.createParametersObjectParser().parse(`${r}/parameters`)||[]],s=e.parse(r),a=s.pop();return{path:s.pop(),method:a.toUpperCase(),jsonPointer:r,...(null==t?void 0:t.length)?{parameters:t}:{}}}}class l{constructor(e,r){this.doc=e,this.dereferencedDoc=r}parse(r){var t;const s=e.has(this.doc,r)?e.get(this.doc,r):void 0;return null!==(t=null==s?void 0:s.map(((e,t)=>this.parseParameter(`${r}/${t}`,e))))&&void 0!==t?t:[]}getParameterObject(r,t){return t.$ref?e.get(this.dereferencedDoc,r):t}parseParameter(e,r){const t=this.getParameterObject(e,r),s=this.getParameterValue(t);return{paramType:"location",name:t.name,...null!=s?{value:s}:{},valueJsonPointer:this.getValueJsonPointer(e),location:t.in}}}class h extends l{constructor(e,r){super(e,r)}parse(r){var t;const s=e.has(this.doc,r)?e.get(this.doc,r):void 0;return null!==(t=null==s?void 0:s.flatMap(((e,t)=>{const s=`${r}/${t}`,a=this.getParameterObject(s,e);return"body"===a.in?this.parseBodyParameter(s,a):[this.parseParameter(s,a)]})))&&void 0!==t?t:[]}getParameterValue(e){var r,t;return null!==(r=e.default)&&void 0!==r?r:null===(t=e.items)||void 0===t?void 0:t.default}getValueJsonPointer(e){return`${e}/default`}parseParameter(e,r){return super.parseParameter(e,{...r,in:"formData"===r.in?n.BODY:r.in})}parseBodyParameter(r,t){var s;const a=e.get(this.doc,e.compile(e.parse(r).slice(0,-2))).consumes||["application/json"],o=null===(s=t.schema)||void 0===s?void 0:s.default;return a.map((e=>({paramType:"requestBody",bodyType:e,...null!=o?{value:o}:{},valueJsonPointer:this.getValueJsonPointer(`${r}/schema`)})))}}class u extends d{constructor(e,r){super(),this.doc=e,this.dereferencedDoc=r}createParametersObjectParser(){return new h(this.doc,this.dereferencedDoc)}}class p extends c{constructor(e,r){super(e),this.doc=e,this.dereferencedDoc=r}createParametersObjectParser(){return new h(this.doc,this.dereferencedDoc)}createOperationObjectsParser(){return new u(this.doc,this.dereferencedDoc)}}class m extends class{get doc(){if(!this._doc)throw new Error('You have to call "setup" to initialize the document');return this._doc}get format(){if(!this._doc)throw new Error('You have to call "setup" to initialize the document');return this._format}get tree(){if(!this._tree)throw new Error('You have to call "parse" to initialize the tree');return this._tree}set tree(e){this._tree=e}stringify(){return"yaml"===this.format?t(this.doc):JSON.stringify(this.doc)}async load(e,t,s){const a=new r,o=await a.import(e,s);if(this._doc=null==o?void 0:o.doc,this._format=null==o?void 0:o.format,!o)throw new Error(t)}}{setParameterValue(r,t){return e.set(this.doc,r,t),s.apply(this.tree,'$..[?(@.valueJsonPointer=="'+r+'")]',(e=>({...e,value:t}))),this.tree}removeNode(r){return e.remove(this.doc,r),s.apply(this.tree,'$..[?(@.jsonPointer=="'+r+'")]',(()=>{})),this.parse()}}class v extends m{setParameterValue(r,t){let s;return e.has(this.doc,r)||(s=this.getRefJsonPointer(r)),s&&e.set(this.doc,s,e.get(this.dereferencedDoc,s)),e.set(this.dereferencedDoc,r,t),super.setParameterValue(r,t)}removeNode(r){return e.remove(this.dereferencedDoc,r),super.removeNode(r)}async load(e,r,t){await super.load(e,r,t),this.dereferencedDoc=await(new a).dereference(JSON.parse(JSON.stringify(this.doc)),{resolve:{file:!1,http:!1}})}createRootNode(r){const t=this.createPathItemObjectParser();return{parameters:r,jsonPointer:"/",path:"/",name:this.doc.info.title,children:Object.keys(this.doc.paths).map((r=>t.parse(e.compile(["paths",r]))))}}getRefJsonPointer(r){const t=e.parse(r);for(;t.length;)if(t.pop(),e.has(this.doc,e.compile([...t,"$ref"])))return e.compile(t)}}class P extends v{setup(e,r){return this.load(e,"Bad Swagger/OpenAPI V2 specification",r)}parse(){return this.tree=this.createRootNode([{paramType:"variable",name:"host",valueJsonPointer:"/host",value:this.doc.host}]),this.tree}createPathItemObjectParser(){return new p(this.doc,this.dereferencedDoc)}}class f extends l{constructor(e,r){super(e,r)}getParameterValue(e){var r;return null!==(r=e.example)&&void 0!==r?r:e.schema.default}getValueJsonPointer(e){return`${e}/example`}}class y{constructor(e,r){this.doc=e,this.dereferencedDoc=r}parse(r){let t=e.has(this.doc,r)?e.get(this.doc,r):void 0;if(!t)return;t.$ref&&(t=e.get(this.dereferencedDoc,r));const s=t.content;return Object.entries(s).map((([e,t])=>this.parseRequestBodyContentEntry(r,e,t)))}parseRequestBodyContentEntry(r,t,s){var a,o,n;const i=null!==(a=s.example)&&void 0!==a?a:null===(n=null===(o=s.examples)||void 0===o?void 0:o[0])||void 0===n?void 0:n.value;return{paramType:"requestBody",bodyType:t,...null!=i?{value:i}:{},valueJsonPointer:`${r}${e.compile(["content",t,"example"])}`}}}class g extends d{constructor(e,r){super(),this.doc=e,this.dereferencedDoc=r}parse(e){const r=super.parse(e),t=[...r.parameters||[],...new y(this.doc,this.dereferencedDoc).parse(`${e}/requestBody`)||[]];return{...r,...(null==t?void 0:t.length)?{parameters:t}:{}}}createParametersObjectParser(){return new f(this.doc,this.dereferencedDoc)}}class O extends c{constructor(e,r){super(e),this.doc=e,this.dereferencedDoc=r}parseParameters(r){var t;const s=[],a=e.parse(r).pop(),o=e.get(this.doc,r);if(null===(t=o.servers)||void 0===t?void 0:t.length){const r={paramType:"variable",name:"servers",valueJsonPointer:e.compile(["paths",a,"servers"]),value:o.servers};s.push(r)}return[...super.parseParameters(r),...s]}createParametersObjectParser(){return new f(this.doc,this.dereferencedDoc)}createOperationObjectsParser(){return new g(this.doc,this.dereferencedDoc)}}class j extends v{setup(e,r){return this.load(e,"Bad OpenAPI V3 specification",r)}parse(){return this.tree=this.createRootNode([{paramType:"variable",name:"servers",valueJsonPointer:"/servers",value:this.doc.servers?this.doc.servers:[]}]),this.tree}createPathItemObjectParser(){return new O(this.doc,this.dereferencedDoc)}}class w{constructor(e){this.doc=e}parse(r){const t=e.has(this.doc,r)?e.get(this.doc,r):void 0;return t?Array.isArray(t)?t:t.split("\n").map((e=>{const[r,t]=e.split(": ",2);return{key:r,value:null!=t?t:""}})):[]}}class ${constructor(e){this.doc=e}parse(r){const t=e.has(this.doc,r)?e.get(this.doc,r):void 0;if(t)switch(t.mode){case"raw":return[this.createRequestBodyParam(`${r}/raw`)];case"file":return[this.createRequestBodyParam(`${r}/file`)];case"graphql":return[this.createRequestBodyParam(`${r}/graphql`)];case"urlencoded":return this.createBodyLocationParams(`${r}/urlencoded`,t.urlencoded);case"formdata":return this.createBodyLocationParams(`${r}/formdata`,t.formdata)}}createRequestBodyParam(r,t){var s;const a=e.get(this.doc,r),o=e.compile([...e.parse(r).slice(0,-2),"header"]),n=new w(this.doc).parse(o);return{bodyType:t||(null===(s=n.find((e=>"content-type"===e.key.toLowerCase())))||void 0===s?void 0:s.value)||"application/json",value:a,paramType:"requestBody",valueJsonPointer:r}}createBodyLocationParams(e,r){return r.map(((r,t)=>({paramType:"location",location:n.BODY,valueJsonPointer:`${e}/${t}/value`,name:r.key,value:r.value})))}}class b{constructor(e){this.doc=e}parse(r){if(!e.has(this.doc,r))return;return e.get(this.doc,r).map(((e,t)=>({paramType:"variable",name:e.key,value:e.value,valueJsonPointer:`${r}/${t}/value`})))}}class D{constructor(e){this.doc=e}parse(e){const r=new b(this.doc);return[r.parse(`${e}/variable`),r.parse(`${e}/request/url/variable`),r.parse(`${e}/request/url/query`),new $(this.doc).parse(`${e}/request/body`)].flat().filter((e=>!!e))}}class T{parse(e){if("string"==typeof e)return e;if(e.raw)return e.raw;return`${Array.isArray(e.host)?e.host.join("."):e.host||""}/${"string"==typeof e.path?e.path:this.getPathFromArray(e.path)}`}getGroupPath(e){const r=e.map((e=>{var r;return(null===(r=e.children)||void 0===r?void 0:r.length)?this.getGroupPath(e.children):e.path}));return this.getLongestCommonPath(r)}getPathFromArray(e){return e.map((e=>{var r;return"string"==typeof e?e:null!==(r=e.value)&&void 0!==r?r:""})).join("/")}getLongestCommonPath(e){let r=e[0].split("/");for(let t=1;t<e.length;++t){const s=e[t].split("/");let a=0;for(;a<r.length&&a<s.length&&s[a]===r[a];)++a;r=r.slice(0,a)}return r.join("/")}}class B extends m{constructor(){super(...arguments),this.postmanUrlParser=new T}setup(e,r){return this.load(e,"Bad Postman collection",r)}parse(){const e=new b(this.doc).parse("/variable");return this.tree={jsonPointer:"/",path:"/",name:this.doc.info.name,children:this.createNodes(this.doc,""),...(null==e?void 0:e.length)?{parameters:e}:{}},this.tree}createNodes(e,r){return e.item.flatMap(((e,t)=>{const s=`${r}/item/${t.toString(10)}`,a=new D(this.doc).parse(s);if(this.isItemGroup(e))return[this.createGroupNode(e,s,a)];const o=this.createSingleNode(e,s,a);return o?[o]:[]}))}isItemGroup(e){return Array.isArray(e.item)}createGroupNode(e,r,t){const s=this.createNodes(e,r);return{jsonPointer:r,path:this.postmanUrlParser.getGroupPath(s),children:s,...(null==t?void 0:t.length)?{parameters:t}:{}}}createSingleNode(e,r,t){return{jsonPointer:r,path:this.postmanUrlParser.parse(e.request.url),method:e.request.method.toUpperCase(),...(null==t?void 0:t.length)?{parameters:t}:{}}}}export{o as HttpMethod,P as OasV2Editor,j as OasV3Editor,n as ParamLocation,B as PostmanEditor,i as isHttpMethod};
import e from"json-pointer";import{SpecImporter as r}from"@har-sdk/core";import{dump as t}from"js-yaml";import s from"jsonpath";import a from"@apidevtools/json-schema-ref-parser";var o,n;function i(e){return Object.values(o).includes(null==e?void 0:e.toUpperCase())}!function(e){e.GET="GET",e.PUT="PUT",e.POST="POST",e.DELETE="DELETE",e.OPTIONS="OPTIONS",e.HEAD="HEAD",e.PATCH="PATCH",e.TRACE="TRACE"}(o||(o={})),function(e){e.PATH="path",e.QUERY="query",e.HEADER="header",e.BODY="body"}(n||(n={}));class c{constructor(e){this.doc=e}parse(r){const t=e.parse(r).pop(),s=e.get(this.doc,r),a=this.parseParameters(r),o=this.createOperationObjectsParser();return{path:t,jsonPointer:r,children:Object.keys(s).filter(i).map((r=>o.parse(e.compile(["paths",t,r])))),...(null==a?void 0:a.length)?{parameters:a}:{}}}parseParameters(e){return this.createParametersObjectParser().parse(`${e}/parameters`)||[]}}class d{parse(r){const t=[...this.createParametersObjectParser().parse(`${r}/parameters`)||[]],s=e.parse(r),a=s.pop();return{path:s.pop(),method:a.toUpperCase(),jsonPointer:r,...(null==t?void 0:t.length)?{parameters:t}:{}}}}class l{constructor(e,r){this.doc=e,this.dereferencedDoc=r}parse(r){var t;const s=e.has(this.doc,r)?e.get(this.doc,r):void 0;return null!==(t=null==s?void 0:s.map(((e,t)=>this.parseParameter(`${r}/${t}`,e))))&&void 0!==t?t:[]}getParameterObject(r,t){return t.$ref?e.get(this.dereferencedDoc,r):t}parseParameter(e,r){const t=this.getParameterObject(e,r),s=this.getParameterValue(t);return{paramType:"location",name:t.name,...null!=s?{value:s}:{},valueJsonPointer:this.getValueJsonPointer(e),location:t.in}}}class h extends l{constructor(e,r){super(e,r)}parse(r){var t;const s=e.has(this.doc,r)?e.get(this.doc,r):void 0;return null!==(t=null==s?void 0:s.flatMap(((e,t)=>{const s=`${r}/${t}`,a=this.getParameterObject(s,e);return"body"===a.in?this.parseBodyParameter(s,a):[this.parseParameter(s,a)]})))&&void 0!==t?t:[]}getParameterValue(e){var r,t;return null!==(r=e.default)&&void 0!==r?r:null===(t=e.items)||void 0===t?void 0:t.default}getValueJsonPointer(e){return`${e}/default`}parseParameter(e,r){return super.parseParameter(e,{...r,in:"formData"===r.in?n.BODY:r.in})}parseBodyParameter(r,t){var s;const a=e.get(this.doc,e.compile(e.parse(r).slice(0,-2))).consumes||["application/json"],o=null===(s=t.schema)||void 0===s?void 0:s.default;return a.map((e=>({paramType:"requestBody",bodyType:e,...null!=o?{value:o}:{},valueJsonPointer:this.getValueJsonPointer(`${r}/schema`)})))}}class u extends d{constructor(e,r){super(),this.doc=e,this.dereferencedDoc=r}createParametersObjectParser(){return new h(this.doc,this.dereferencedDoc)}}class p extends c{constructor(e,r){super(e),this.doc=e,this.dereferencedDoc=r}createParametersObjectParser(){return new h(this.doc,this.dereferencedDoc)}createOperationObjectsParser(){return new u(this.doc,this.dereferencedDoc)}}class m extends class{get doc(){if(!this._doc)throw new Error('You have to call "setup" to initialize the document');return this._doc}get format(){if(!this._doc)throw new Error('You have to call "setup" to initialize the document');return this._format}get tree(){if(!this._tree)throw new Error('You have to call "parse" to initialize the tree');return this._tree}set tree(e){this._tree=e}stringify(){return"yaml"===this.format?t(this.doc):JSON.stringify(this.doc)}async load(e,t,s){const a=new r,o=await a.import(e,s);if(this._doc=null==o?void 0:o.doc,this._format=null==o?void 0:o.format,!o)throw new Error(t)}}{setParameterValue(r,t){return e.set(this.doc,r,t),s.apply(this.tree,'$..[?(@.valueJsonPointer=="'+r+'")]',(e=>({...e,value:t}))),this.tree}removeNode(r){return e.remove(this.doc,r),s.apply(this.tree,'$..[?(@.jsonPointer=="'+r+'")]',(()=>{})),this.parse()}}class v extends m{setParameterValue(r,t){let s;return e.has(this.doc,r)||(s=this.getRefJsonPointer(r)),s&&e.set(this.doc,s,e.get(this.dereferencedDoc,s)),e.set(this.dereferencedDoc,r,t),super.setParameterValue(r,t)}removeNode(r){return e.remove(this.dereferencedDoc,r),super.removeNode(r)}async load(e,r,t){await super.load(e,r,t),this.dereferencedDoc=await(new a).dereference(JSON.parse(JSON.stringify(this.doc)),{resolve:{file:!1,http:!1}})}createRootNode(r){const t=this.createPathItemObjectParser();return{parameters:r,jsonPointer:"/",path:"/",name:this.doc.info.title,children:Object.keys(this.doc.paths).map((r=>t.parse(e.compile(["paths",r]))))}}getRefJsonPointer(r){const t=e.parse(r);for(;t.length;)if(t.pop(),e.has(this.doc,e.compile([...t,"$ref"])))return e.compile(t)}}class P extends v{setup(e,r){return this.load(e,"Bad Swagger/OpenAPI V2 specification",r)}parse(){return this.tree=this.createRootNode([{paramType:"variable",name:"host",valueJsonPointer:"/host",value:this.doc.host}]),this.tree}createPathItemObjectParser(){return new p(this.doc,this.dereferencedDoc)}}class f extends l{constructor(e,r){super(e,r)}getParameterValue(e){var r,t;return null!==(t=null!==(r=e.example)&&void 0!==r?r:e.schema.example)&&void 0!==t?t:e.schema.default}getValueJsonPointer(e){return`${e}/example`}}class y{constructor(e,r){this.doc=e,this.dereferencedDoc=r}parse(r){let t=e.has(this.doc,r)?e.get(this.doc,r):void 0;if(!t)return;t.$ref&&(t=e.get(this.dereferencedDoc,r));const s=t.content;return Object.entries(s).map((([e,t])=>this.parseRequestBodyContentEntry(r,e,t)))}parseRequestBodyContentEntry(r,t,s){var a,o,n;const i=null!==(a=s.example)&&void 0!==a?a:null===(n=null===(o=s.examples)||void 0===o?void 0:o[0])||void 0===n?void 0:n.value;return{paramType:"requestBody",bodyType:t,...null!=i?{value:i}:{},valueJsonPointer:`${r}${e.compile(["content",t,"example"])}`}}}class g extends d{constructor(e,r){super(),this.doc=e,this.dereferencedDoc=r}parse(e){const r=super.parse(e),t=[...r.parameters||[],...new y(this.doc,this.dereferencedDoc).parse(`${e}/requestBody`)||[]];return{...r,...(null==t?void 0:t.length)?{parameters:t}:{}}}createParametersObjectParser(){return new f(this.doc,this.dereferencedDoc)}}class O extends c{constructor(e,r){super(e),this.doc=e,this.dereferencedDoc=r}parseParameters(r){var t;const s=[],a=e.parse(r).pop(),o=e.get(this.doc,r);if(null===(t=o.servers)||void 0===t?void 0:t.length){const r={paramType:"variable",name:"servers",valueJsonPointer:e.compile(["paths",a,"servers"]),value:o.servers};s.push(r)}return[...super.parseParameters(r),...s]}createParametersObjectParser(){return new f(this.doc,this.dereferencedDoc)}createOperationObjectsParser(){return new g(this.doc,this.dereferencedDoc)}}class j extends v{setup(e,r){return this.load(e,"Bad OpenAPI V3 specification",r)}parse(){return this.tree=this.createRootNode([{paramType:"variable",name:"servers",valueJsonPointer:"/servers",value:this.doc.servers?this.doc.servers:[]}]),this.tree}createPathItemObjectParser(){return new O(this.doc,this.dereferencedDoc)}}class w{constructor(e){this.doc=e}parse(r){const t=e.has(this.doc,r)?e.get(this.doc,r):void 0;return t?Array.isArray(t)?t:t.split("\n").map((e=>{const[r,t]=e.split(": ",2);return{key:r,value:null!=t?t:""}})):[]}}class ${constructor(e){this.doc=e}parse(r){const t=e.has(this.doc,r)?e.get(this.doc,r):void 0;if(t)switch(t.mode){case"raw":return[this.createRequestBodyParam(`${r}/raw`)];case"file":return[this.createRequestBodyParam(`${r}/file`)];case"graphql":return[this.createRequestBodyParam(`${r}/graphql`)];case"urlencoded":return this.createBodyLocationParams(`${r}/urlencoded`,t.urlencoded);case"formdata":return this.createBodyLocationParams(`${r}/formdata`,t.formdata)}}createRequestBodyParam(r,t){var s;const a=e.get(this.doc,r),o=e.compile([...e.parse(r).slice(0,-2),"header"]),n=new w(this.doc).parse(o);return{bodyType:t||(null===(s=n.find((e=>"content-type"===e.key.toLowerCase())))||void 0===s?void 0:s.value)||"application/json",value:a,paramType:"requestBody",valueJsonPointer:r}}createBodyLocationParams(e,r){return r.map(((r,t)=>({paramType:"location",location:n.BODY,valueJsonPointer:`${e}/${t}/value`,name:r.key,value:r.value})))}}class b{constructor(e){this.doc=e}parse(r){if(!e.has(this.doc,r))return;return e.get(this.doc,r).map(((e,t)=>({paramType:"variable",name:e.key,value:e.value,valueJsonPointer:`${r}/${t}/value`})))}}class D{constructor(e){this.doc=e}parse(e){const r=new b(this.doc);return[r.parse(`${e}/variable`),r.parse(`${e}/request/url/variable`),r.parse(`${e}/request/url/query`),new $(this.doc).parse(`${e}/request/body`)].flat().filter((e=>!!e))}}class T{parse(e){if("string"==typeof e)return e;if(e.raw)return e.raw;return`${Array.isArray(e.host)?e.host.join("."):e.host||""}/${"string"==typeof e.path?e.path:this.getPathFromArray(e.path)}`}getGroupPath(e){const r=e.map((e=>{var r;return(null===(r=e.children)||void 0===r?void 0:r.length)?this.getGroupPath(e.children):e.path}));return this.getLongestCommonPath(r)}getPathFromArray(e){return e.map((e=>{var r;return"string"==typeof e?e:null!==(r=e.value)&&void 0!==r?r:""})).join("/")}getLongestCommonPath(e){let r=e[0].split("/");for(let t=1;t<e.length;++t){const s=e[t].split("/");let a=0;for(;a<r.length&&a<s.length&&s[a]===r[a];)++a;r=r.slice(0,a)}return r.join("/")}}class B extends m{constructor(){super(...arguments),this.postmanUrlParser=new T}setup(e,r){return this.load(e,"Bad Postman collection",r)}parse(){const e=new b(this.doc).parse("/variable");return this.tree={jsonPointer:"/",path:"/",name:this.doc.info.name,children:this.createNodes(this.doc,""),...(null==e?void 0:e.length)?{parameters:e}:{}},this.tree}createNodes(e,r){return e.item.flatMap(((e,t)=>{const s=`${r}/item/${t.toString(10)}`,a=new D(this.doc).parse(s);if(this.isItemGroup(e))return[this.createGroupNode(e,s,a)];const o=this.createSingleNode(e,s,a);return o?[o]:[]}))}isItemGroup(e){return Array.isArray(e.item)}createGroupNode(e,r,t){const s=this.createNodes(e,r);return{jsonPointer:r,path:this.postmanUrlParser.getGroupPath(s),children:s,...(null==t?void 0:t.length)?{parameters:t}:{}}}createSingleNode(e,r,t){return{jsonPointer:r,path:this.postmanUrlParser.parse(e.request.url),method:e.request.method.toUpperCase(),...(null==t?void 0:t.length)?{parameters:t}:{}}}}export{o as HttpMethod,P as OasV2Editor,j as OasV3Editor,n as ParamLocation,B as PostmanEditor,i as isHttpMethod};
//# sourceMappingURL=bundle.esm5.js.map

@@ -1,2 +0,2 @@

var e,t;e=this,t=function(e,t,r,a,s,o){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i,c,d=n(t),l=n(s),u=n(o);function h(t){return Object.values(e.HttpMethod).includes(null==t?void 0:t.toUpperCase())}e.HttpMethod=void 0,(i=e.HttpMethod||(e.HttpMethod={})).GET="GET",i.PUT="PUT",i.POST="POST",i.DELETE="DELETE",i.OPTIONS="OPTIONS",i.HEAD="HEAD",i.PATCH="PATCH",i.TRACE="TRACE",e.ParamLocation=void 0,(c=e.ParamLocation||(e.ParamLocation={})).PATH="path",c.QUERY="query",c.HEADER="header",c.BODY="body";class p{constructor(e){this.doc=e}parse(e){const t=d.default.parse(e).pop(),r=d.default.get(this.doc,e),a=this.parseParameters(e),s=this.createOperationObjectsParser();return{path:t,jsonPointer:e,children:Object.keys(r).filter(h).map((e=>s.parse(d.default.compile(["paths",t,e])))),...(null==a?void 0:a.length)?{parameters:a}:{}}}parseParameters(e){return this.createParametersObjectParser().parse(`${e}/parameters`)||[]}}class m{parse(e){const t=[...this.createParametersObjectParser().parse(`${e}/parameters`)||[]],r=d.default.parse(e),a=r.pop();return{path:r.pop(),method:a.toUpperCase(),jsonPointer:e,...(null==t?void 0:t.length)?{parameters:t}:{}}}}class f{constructor(e,t){this.doc=e,this.dereferencedDoc=t}parse(e){var t;const r=d.default.has(this.doc,e)?d.default.get(this.doc,e):void 0;return null!==(t=null==r?void 0:r.map(((t,r)=>this.parseParameter(`${e}/${r}`,t))))&&void 0!==t?t:[]}getParameterObject(e,t){return t.$ref?d.default.get(this.dereferencedDoc,e):t}parseParameter(e,t){const r=this.getParameterObject(e,t),a=this.getParameterValue(r);return{paramType:"location",name:r.name,...null!=a?{value:a}:{},valueJsonPointer:this.getValueJsonPointer(e),location:r.in}}}class v extends f{constructor(e,t){super(e,t)}parse(e){var t;const r=d.default.has(this.doc,e)?d.default.get(this.doc,e):void 0;return null!==(t=null==r?void 0:r.flatMap(((t,r)=>{const a=`${e}/${r}`,s=this.getParameterObject(a,t);return"body"===s.in?this.parseBodyParameter(a,s):[this.parseParameter(a,s)]})))&&void 0!==t?t:[]}getParameterValue(e){var t,r;return null!==(t=e.default)&&void 0!==t?t:null===(r=e.items)||void 0===r?void 0:r.default}getValueJsonPointer(e){return`${e}/default`}parseParameter(t,r){return super.parseParameter(t,{...r,in:"formData"===r.in?e.ParamLocation.BODY:r.in})}parseBodyParameter(e,t){var r;const a=d.default.get(this.doc,d.default.compile(d.default.parse(e).slice(0,-2))).consumes||["application/json"],s=null===(r=t.schema)||void 0===r?void 0:r.default;return a.map((t=>({paramType:"requestBody",bodyType:t,...null!=s?{value:s}:{},valueJsonPointer:this.getValueJsonPointer(`${e}/schema`)})))}}class P extends m{constructor(e,t){super(),this.doc=e,this.dereferencedDoc=t}createParametersObjectParser(){return new v(this.doc,this.dereferencedDoc)}}class y extends p{constructor(e,t){super(e),this.doc=e,this.dereferencedDoc=t}createParametersObjectParser(){return new v(this.doc,this.dereferencedDoc)}createOperationObjectsParser(){return new P(this.doc,this.dereferencedDoc)}}class g extends class{get doc(){if(!this._doc)throw new Error('You have to call "setup" to initialize the document');return this._doc}get format(){if(!this._doc)throw new Error('You have to call "setup" to initialize the document');return this._format}get tree(){if(!this._tree)throw new Error('You have to call "parse" to initialize the tree');return this._tree}set tree(e){this._tree=e}stringify(){return"yaml"===this.format?a.dump(this.doc):JSON.stringify(this.doc)}async load(e,t,a){const s=new r.SpecImporter,o=await s.import(e,a);if(this._doc=null==o?void 0:o.doc,this._format=null==o?void 0:o.format,!o)throw new Error(t)}}{setParameterValue(e,t){return d.default.set(this.doc,e,t),l.default.apply(this.tree,'$..[?(@.valueJsonPointer=="'+e+'")]',(e=>({...e,value:t}))),this.tree}removeNode(e){return d.default.remove(this.doc,e),l.default.apply(this.tree,'$..[?(@.jsonPointer=="'+e+'")]',(()=>{})),this.parse()}}class j extends g{setParameterValue(e,t){let r;return d.default.has(this.doc,e)||(r=this.getRefJsonPointer(e)),r&&d.default.set(this.doc,r,d.default.get(this.dereferencedDoc,r)),d.default.set(this.dereferencedDoc,e,t),super.setParameterValue(e,t)}removeNode(e){return d.default.remove(this.dereferencedDoc,e),super.removeNode(e)}async load(e,t,r){await super.load(e,t,r),this.dereferencedDoc=await(new u.default).dereference(JSON.parse(JSON.stringify(this.doc)),{resolve:{file:!1,http:!1}})}createRootNode(e){const t=this.createPathItemObjectParser();return{parameters:e,jsonPointer:"/",path:"/",name:this.doc.info.title,children:Object.keys(this.doc.paths).map((e=>t.parse(d.default.compile(["paths",e]))))}}getRefJsonPointer(e){const t=d.default.parse(e);for(;t.length;)if(t.pop(),d.default.has(this.doc,d.default.compile([...t,"$ref"])))return d.default.compile(t)}}class O extends f{constructor(e,t){super(e,t)}getParameterValue(e){var t;return null!==(t=e.example)&&void 0!==t?t:e.schema.default}getValueJsonPointer(e){return`${e}/example`}}class b{constructor(e,t){this.doc=e,this.dereferencedDoc=t}parse(e){let t=d.default.has(this.doc,e)?d.default.get(this.doc,e):void 0;if(!t)return;t.$ref&&(t=d.default.get(this.dereferencedDoc,e));const r=t.content;return Object.entries(r).map((([t,r])=>this.parseRequestBodyContentEntry(e,t,r)))}parseRequestBodyContentEntry(e,t,r){var a,s,o;const n=null!==(a=r.example)&&void 0!==a?a:null===(o=null===(s=r.examples)||void 0===s?void 0:s[0])||void 0===o?void 0:o.value;return{paramType:"requestBody",bodyType:t,...null!=n?{value:n}:{},valueJsonPointer:`${e}${d.default.compile(["content",t,"example"])}`}}}class w extends m{constructor(e,t){super(),this.doc=e,this.dereferencedDoc=t}parse(e){const t=super.parse(e),r=[...t.parameters||[],...new b(this.doc,this.dereferencedDoc).parse(`${e}/requestBody`)||[]];return{...t,...(null==r?void 0:r.length)?{parameters:r}:{}}}createParametersObjectParser(){return new O(this.doc,this.dereferencedDoc)}}class $ extends p{constructor(e,t){super(e),this.doc=e,this.dereferencedDoc=t}parseParameters(e){var t;const r=[],a=d.default.parse(e).pop(),s=d.default.get(this.doc,e);if(null===(t=s.servers)||void 0===t?void 0:t.length){const e={paramType:"variable",name:"servers",valueJsonPointer:d.default.compile(["paths",a,"servers"]),value:s.servers};r.push(e)}return[...super.parseParameters(e),...r]}createParametersObjectParser(){return new O(this.doc,this.dereferencedDoc)}createOperationObjectsParser(){return new w(this.doc,this.dereferencedDoc)}}class D{constructor(e){this.doc=e}parse(e){const t=d.default.has(this.doc,e)?d.default.get(this.doc,e):void 0;return t?Array.isArray(t)?t:t.split("\n").map((e=>{const[t,r]=e.split(": ",2);return{key:t,value:null!=r?r:""}})):[]}}class T{constructor(e){this.doc=e}parse(e){const t=d.default.has(this.doc,e)?d.default.get(this.doc,e):void 0;if(t)switch(t.mode){case"raw":return[this.createRequestBodyParam(`${e}/raw`)];case"file":return[this.createRequestBodyParam(`${e}/file`)];case"graphql":return[this.createRequestBodyParam(`${e}/graphql`)];case"urlencoded":return this.createBodyLocationParams(`${e}/urlencoded`,t.urlencoded);case"formdata":return this.createBodyLocationParams(`${e}/formdata`,t.formdata)}}createRequestBodyParam(e,t){var r;const a=d.default.get(this.doc,e),s=d.default.compile([...d.default.parse(e).slice(0,-2),"header"]),o=new D(this.doc).parse(s);return{bodyType:t||(null===(r=o.find((e=>"content-type"===e.key.toLowerCase())))||void 0===r?void 0:r.value)||"application/json",value:a,paramType:"requestBody",valueJsonPointer:e}}createBodyLocationParams(t,r){return r.map(((r,a)=>({paramType:"location",location:e.ParamLocation.BODY,valueJsonPointer:`${t}/${a}/value`,name:r.key,value:r.value})))}}class q{constructor(e){this.doc=e}parse(e){if(d.default.has(this.doc,e))return d.default.get(this.doc,e).map(((t,r)=>({paramType:"variable",name:t.key,value:t.value,valueJsonPointer:`${e}/${r}/value`})))}}class E{constructor(e){this.doc=e}parse(e){const t=new q(this.doc);return[t.parse(`${e}/variable`),t.parse(`${e}/request/url/variable`),t.parse(`${e}/request/url/query`),new T(this.doc).parse(`${e}/request/body`)].flat().filter((e=>!!e))}}class B{parse(e){return"string"==typeof e?e:e.raw?e.raw:`${Array.isArray(e.host)?e.host.join("."):e.host||""}/${"string"==typeof e.path?e.path:this.getPathFromArray(e.path)}`}getGroupPath(e){const t=e.map((e=>{var t;return(null===(t=e.children)||void 0===t?void 0:t.length)?this.getGroupPath(e.children):e.path}));return this.getLongestCommonPath(t)}getPathFromArray(e){return e.map((e=>{var t;return"string"==typeof e?e:null!==(t=e.value)&&void 0!==t?t:""})).join("/")}getLongestCommonPath(e){let t=e[0].split("/");for(let r=1;r<e.length;++r){const a=e[r].split("/");let s=0;for(;s<t.length&&s<a.length&&a[s]===t[s];)++s;t=t.slice(0,s)}return t.join("/")}}e.OasV2Editor=class extends j{setup(e,t){return this.load(e,"Bad Swagger/OpenAPI V2 specification",t)}parse(){return this.tree=this.createRootNode([{paramType:"variable",name:"host",valueJsonPointer:"/host",value:this.doc.host}]),this.tree}createPathItemObjectParser(){return new y(this.doc,this.dereferencedDoc)}},e.OasV3Editor=class extends j{setup(e,t){return this.load(e,"Bad OpenAPI V3 specification",t)}parse(){return this.tree=this.createRootNode([{paramType:"variable",name:"servers",valueJsonPointer:"/servers",value:this.doc.servers?this.doc.servers:[]}]),this.tree}createPathItemObjectParser(){return new $(this.doc,this.dereferencedDoc)}},e.PostmanEditor=class extends g{constructor(){super(...arguments),this.postmanUrlParser=new B}setup(e,t){return this.load(e,"Bad Postman collection",t)}parse(){const e=new q(this.doc).parse("/variable");return this.tree={jsonPointer:"/",path:"/",name:this.doc.info.name,children:this.createNodes(this.doc,""),...(null==e?void 0:e.length)?{parameters:e}:{}},this.tree}createNodes(e,t){return e.item.flatMap(((e,r)=>{const a=`${t}/item/${r.toString(10)}`,s=new E(this.doc).parse(a);if(this.isItemGroup(e))return[this.createGroupNode(e,a,s)];const o=this.createSingleNode(e,a,s);return o?[o]:[]}))}isItemGroup(e){return Array.isArray(e.item)}createGroupNode(e,t,r){const a=this.createNodes(e,t);return{jsonPointer:t,path:this.postmanUrlParser.getGroupPath(a),children:a,...(null==r?void 0:r.length)?{parameters:r}:{}}}createSingleNode(e,t,r){return{jsonPointer:t,path:this.postmanUrlParser.parse(e.request.url),method:e.request.method.toUpperCase(),...(null==r?void 0:r.length)?{parameters:r}:{}}}},e.isHttpMethod=h},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("json-pointer"),require("@har-sdk/core"),require("js-yaml"),require("jsonpath"),require("@apidevtools/json-schema-ref-parser")):"function"==typeof define&&define.amd?define(["exports","json-pointer","@har-sdk/core","js-yaml","jsonpath","@apidevtools/json-schema-ref-parser"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@har-sdk/editor"]={},e.jsonPointer,e.core,e.jsYaml,e.jsonPath,e.$RefParser);
var e,t;e=this,t=function(e,t,r,a,s,o){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i,c,d=n(t),l=n(s),u=n(o);function h(t){return Object.values(e.HttpMethod).includes(null==t?void 0:t.toUpperCase())}e.HttpMethod=void 0,(i=e.HttpMethod||(e.HttpMethod={})).GET="GET",i.PUT="PUT",i.POST="POST",i.DELETE="DELETE",i.OPTIONS="OPTIONS",i.HEAD="HEAD",i.PATCH="PATCH",i.TRACE="TRACE",e.ParamLocation=void 0,(c=e.ParamLocation||(e.ParamLocation={})).PATH="path",c.QUERY="query",c.HEADER="header",c.BODY="body";class p{constructor(e){this.doc=e}parse(e){const t=d.default.parse(e).pop(),r=d.default.get(this.doc,e),a=this.parseParameters(e),s=this.createOperationObjectsParser();return{path:t,jsonPointer:e,children:Object.keys(r).filter(h).map((e=>s.parse(d.default.compile(["paths",t,e])))),...(null==a?void 0:a.length)?{parameters:a}:{}}}parseParameters(e){return this.createParametersObjectParser().parse(`${e}/parameters`)||[]}}class m{parse(e){const t=[...this.createParametersObjectParser().parse(`${e}/parameters`)||[]],r=d.default.parse(e),a=r.pop();return{path:r.pop(),method:a.toUpperCase(),jsonPointer:e,...(null==t?void 0:t.length)?{parameters:t}:{}}}}class f{constructor(e,t){this.doc=e,this.dereferencedDoc=t}parse(e){var t;const r=d.default.has(this.doc,e)?d.default.get(this.doc,e):void 0;return null!==(t=null==r?void 0:r.map(((t,r)=>this.parseParameter(`${e}/${r}`,t))))&&void 0!==t?t:[]}getParameterObject(e,t){return t.$ref?d.default.get(this.dereferencedDoc,e):t}parseParameter(e,t){const r=this.getParameterObject(e,t),a=this.getParameterValue(r);return{paramType:"location",name:r.name,...null!=a?{value:a}:{},valueJsonPointer:this.getValueJsonPointer(e),location:r.in}}}class v extends f{constructor(e,t){super(e,t)}parse(e){var t;const r=d.default.has(this.doc,e)?d.default.get(this.doc,e):void 0;return null!==(t=null==r?void 0:r.flatMap(((t,r)=>{const a=`${e}/${r}`,s=this.getParameterObject(a,t);return"body"===s.in?this.parseBodyParameter(a,s):[this.parseParameter(a,s)]})))&&void 0!==t?t:[]}getParameterValue(e){var t,r;return null!==(t=e.default)&&void 0!==t?t:null===(r=e.items)||void 0===r?void 0:r.default}getValueJsonPointer(e){return`${e}/default`}parseParameter(t,r){return super.parseParameter(t,{...r,in:"formData"===r.in?e.ParamLocation.BODY:r.in})}parseBodyParameter(e,t){var r;const a=d.default.get(this.doc,d.default.compile(d.default.parse(e).slice(0,-2))).consumes||["application/json"],s=null===(r=t.schema)||void 0===r?void 0:r.default;return a.map((t=>({paramType:"requestBody",bodyType:t,...null!=s?{value:s}:{},valueJsonPointer:this.getValueJsonPointer(`${e}/schema`)})))}}class P extends m{constructor(e,t){super(),this.doc=e,this.dereferencedDoc=t}createParametersObjectParser(){return new v(this.doc,this.dereferencedDoc)}}class y extends p{constructor(e,t){super(e),this.doc=e,this.dereferencedDoc=t}createParametersObjectParser(){return new v(this.doc,this.dereferencedDoc)}createOperationObjectsParser(){return new P(this.doc,this.dereferencedDoc)}}class g extends class{get doc(){if(!this._doc)throw new Error('You have to call "setup" to initialize the document');return this._doc}get format(){if(!this._doc)throw new Error('You have to call "setup" to initialize the document');return this._format}get tree(){if(!this._tree)throw new Error('You have to call "parse" to initialize the tree');return this._tree}set tree(e){this._tree=e}stringify(){return"yaml"===this.format?a.dump(this.doc):JSON.stringify(this.doc)}async load(e,t,a){const s=new r.SpecImporter,o=await s.import(e,a);if(this._doc=null==o?void 0:o.doc,this._format=null==o?void 0:o.format,!o)throw new Error(t)}}{setParameterValue(e,t){return d.default.set(this.doc,e,t),l.default.apply(this.tree,'$..[?(@.valueJsonPointer=="'+e+'")]',(e=>({...e,value:t}))),this.tree}removeNode(e){return d.default.remove(this.doc,e),l.default.apply(this.tree,'$..[?(@.jsonPointer=="'+e+'")]',(()=>{})),this.parse()}}class j extends g{setParameterValue(e,t){let r;return d.default.has(this.doc,e)||(r=this.getRefJsonPointer(e)),r&&d.default.set(this.doc,r,d.default.get(this.dereferencedDoc,r)),d.default.set(this.dereferencedDoc,e,t),super.setParameterValue(e,t)}removeNode(e){return d.default.remove(this.dereferencedDoc,e),super.removeNode(e)}async load(e,t,r){await super.load(e,t,r),this.dereferencedDoc=await(new u.default).dereference(JSON.parse(JSON.stringify(this.doc)),{resolve:{file:!1,http:!1}})}createRootNode(e){const t=this.createPathItemObjectParser();return{parameters:e,jsonPointer:"/",path:"/",name:this.doc.info.title,children:Object.keys(this.doc.paths).map((e=>t.parse(d.default.compile(["paths",e]))))}}getRefJsonPointer(e){const t=d.default.parse(e);for(;t.length;)if(t.pop(),d.default.has(this.doc,d.default.compile([...t,"$ref"])))return d.default.compile(t)}}class O extends f{constructor(e,t){super(e,t)}getParameterValue(e){var t,r;return null!==(r=null!==(t=e.example)&&void 0!==t?t:e.schema.example)&&void 0!==r?r:e.schema.default}getValueJsonPointer(e){return`${e}/example`}}class b{constructor(e,t){this.doc=e,this.dereferencedDoc=t}parse(e){let t=d.default.has(this.doc,e)?d.default.get(this.doc,e):void 0;if(!t)return;t.$ref&&(t=d.default.get(this.dereferencedDoc,e));const r=t.content;return Object.entries(r).map((([t,r])=>this.parseRequestBodyContentEntry(e,t,r)))}parseRequestBodyContentEntry(e,t,r){var a,s,o;const n=null!==(a=r.example)&&void 0!==a?a:null===(o=null===(s=r.examples)||void 0===s?void 0:s[0])||void 0===o?void 0:o.value;return{paramType:"requestBody",bodyType:t,...null!=n?{value:n}:{},valueJsonPointer:`${e}${d.default.compile(["content",t,"example"])}`}}}class w extends m{constructor(e,t){super(),this.doc=e,this.dereferencedDoc=t}parse(e){const t=super.parse(e),r=[...t.parameters||[],...new b(this.doc,this.dereferencedDoc).parse(`${e}/requestBody`)||[]];return{...t,...(null==r?void 0:r.length)?{parameters:r}:{}}}createParametersObjectParser(){return new O(this.doc,this.dereferencedDoc)}}class $ extends p{constructor(e,t){super(e),this.doc=e,this.dereferencedDoc=t}parseParameters(e){var t;const r=[],a=d.default.parse(e).pop(),s=d.default.get(this.doc,e);if(null===(t=s.servers)||void 0===t?void 0:t.length){const e={paramType:"variable",name:"servers",valueJsonPointer:d.default.compile(["paths",a,"servers"]),value:s.servers};r.push(e)}return[...super.parseParameters(e),...r]}createParametersObjectParser(){return new O(this.doc,this.dereferencedDoc)}createOperationObjectsParser(){return new w(this.doc,this.dereferencedDoc)}}class D{constructor(e){this.doc=e}parse(e){const t=d.default.has(this.doc,e)?d.default.get(this.doc,e):void 0;return t?Array.isArray(t)?t:t.split("\n").map((e=>{const[t,r]=e.split(": ",2);return{key:t,value:null!=r?r:""}})):[]}}class T{constructor(e){this.doc=e}parse(e){const t=d.default.has(this.doc,e)?d.default.get(this.doc,e):void 0;if(t)switch(t.mode){case"raw":return[this.createRequestBodyParam(`${e}/raw`)];case"file":return[this.createRequestBodyParam(`${e}/file`)];case"graphql":return[this.createRequestBodyParam(`${e}/graphql`)];case"urlencoded":return this.createBodyLocationParams(`${e}/urlencoded`,t.urlencoded);case"formdata":return this.createBodyLocationParams(`${e}/formdata`,t.formdata)}}createRequestBodyParam(e,t){var r;const a=d.default.get(this.doc,e),s=d.default.compile([...d.default.parse(e).slice(0,-2),"header"]),o=new D(this.doc).parse(s);return{bodyType:t||(null===(r=o.find((e=>"content-type"===e.key.toLowerCase())))||void 0===r?void 0:r.value)||"application/json",value:a,paramType:"requestBody",valueJsonPointer:e}}createBodyLocationParams(t,r){return r.map(((r,a)=>({paramType:"location",location:e.ParamLocation.BODY,valueJsonPointer:`${t}/${a}/value`,name:r.key,value:r.value})))}}class q{constructor(e){this.doc=e}parse(e){if(d.default.has(this.doc,e))return d.default.get(this.doc,e).map(((t,r)=>({paramType:"variable",name:t.key,value:t.value,valueJsonPointer:`${e}/${r}/value`})))}}class E{constructor(e){this.doc=e}parse(e){const t=new q(this.doc);return[t.parse(`${e}/variable`),t.parse(`${e}/request/url/variable`),t.parse(`${e}/request/url/query`),new T(this.doc).parse(`${e}/request/body`)].flat().filter((e=>!!e))}}class B{parse(e){return"string"==typeof e?e:e.raw?e.raw:`${Array.isArray(e.host)?e.host.join("."):e.host||""}/${"string"==typeof e.path?e.path:this.getPathFromArray(e.path)}`}getGroupPath(e){const t=e.map((e=>{var t;return(null===(t=e.children)||void 0===t?void 0:t.length)?this.getGroupPath(e.children):e.path}));return this.getLongestCommonPath(t)}getPathFromArray(e){return e.map((e=>{var t;return"string"==typeof e?e:null!==(t=e.value)&&void 0!==t?t:""})).join("/")}getLongestCommonPath(e){let t=e[0].split("/");for(let r=1;r<e.length;++r){const a=e[r].split("/");let s=0;for(;s<t.length&&s<a.length&&a[s]===t[s];)++s;t=t.slice(0,s)}return t.join("/")}}e.OasV2Editor=class extends j{setup(e,t){return this.load(e,"Bad Swagger/OpenAPI V2 specification",t)}parse(){return this.tree=this.createRootNode([{paramType:"variable",name:"host",valueJsonPointer:"/host",value:this.doc.host}]),this.tree}createPathItemObjectParser(){return new y(this.doc,this.dereferencedDoc)}},e.OasV3Editor=class extends j{setup(e,t){return this.load(e,"Bad OpenAPI V3 specification",t)}parse(){return this.tree=this.createRootNode([{paramType:"variable",name:"servers",valueJsonPointer:"/servers",value:this.doc.servers?this.doc.servers:[]}]),this.tree}createPathItemObjectParser(){return new $(this.doc,this.dereferencedDoc)}},e.PostmanEditor=class extends g{constructor(){super(...arguments),this.postmanUrlParser=new B}setup(e,t){return this.load(e,"Bad Postman collection",t)}parse(){const e=new q(this.doc).parse("/variable");return this.tree={jsonPointer:"/",path:"/",name:this.doc.info.name,children:this.createNodes(this.doc,""),...(null==e?void 0:e.length)?{parameters:e}:{}},this.tree}createNodes(e,t){return e.item.flatMap(((e,r)=>{const a=`${t}/item/${r.toString(10)}`,s=new E(this.doc).parse(a);if(this.isItemGroup(e))return[this.createGroupNode(e,a,s)];const o=this.createSingleNode(e,a,s);return o?[o]:[]}))}isItemGroup(e){return Array.isArray(e.item)}createGroupNode(e,t,r){const a=this.createNodes(e,t);return{jsonPointer:t,path:this.postmanUrlParser.getGroupPath(a),children:a,...(null==r?void 0:r.length)?{parameters:r}:{}}}createSingleNode(e,t,r){return{jsonPointer:t,path:this.postmanUrlParser.parse(e.request.url),method:e.request.method.toUpperCase(),...(null==r?void 0:r.length)?{parameters:r}:{}}}},e.isHttpMethod=h},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("json-pointer"),require("@har-sdk/core"),require("js-yaml"),require("jsonpath"),require("@apidevtools/json-schema-ref-parser")):"function"==typeof define&&define.amd?define(["exports","json-pointer","@har-sdk/core","js-yaml","jsonpath","@apidevtools/json-schema-ref-parser"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@har-sdk/editor"]={},e.jsonPointer,e.core,e.jsYaml,e.jsonPath,e.$RefParser);
//# sourceMappingURL=bundle.umd.js.map

@@ -7,4 +7,4 @@ import { BaseOasParameterObjectsParser } from '../BaseOasParameterObjectsParser';

getParameterValue(paramObj) {
var _a;
return ((_a = paramObj.example) !== null && _a !== void 0 ? _a : paramObj.schema.default);
var _a, _b;
return ((_b = (_a = paramObj.example) !== null && _a !== void 0 ? _a : paramObj.schema.example) !== null && _b !== void 0 ? _b : paramObj.schema.default);
}

@@ -11,0 +11,0 @@ getValueJsonPointer(paramPointer) {

{
"name": "@har-sdk/editor",
"version": "1.5.5",
"version": "1.5.6",
"private": false,

@@ -43,4 +43,4 @@ "repository": {

"format": "prettier --ignore-path ../../.prettierignore --check **/*.ts",
"test": "cross-env NODE_ENV=test mocha tests/**/*.spec.ts",
"coverage": "nyc npm t -- --reporter xunit --reporter-options output=.mocha/testspec.xunit.xml"
"test": "cross-env NODE_ENV=test jest",
"coverage": "cross-env NODE_ENV=test jest --coverage"
},

@@ -47,0 +47,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc