api-smart-diff
Advanced tools
Comparing version 0.2.6 to 0.2.7
@@ -1,2 +0,16 @@ | ||
/*! api-smart-diff@0.2.6 */ | ||
var ApiSmartDiff=function(r){var n={};function a(e){if(n[e])return n[e].exports;var t=n[e]={i:e,l:!1,exports:{}};return r[e].call(t.exports,t,t.exports,a),t.l=!0,t.exports}return a.m=r,a.c=n,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)a.d(r,n,function(e){return t[e]}.bind(null,n));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=0)}([function(_,e,t){"use strict";t.r(e),t.d(e,"messageTraitsRules",function(){return R}),t.d(e,"messageRules",function(){return M}),t.d(e,"asyncApi2Rules",function(){return k}),t.d(e,"openapi3Rules",function(){return C}),t.d(e,"jsonSchemaRules",function(){return x}),t.d(e,"DIFF_META_KEY",function(){return n}),t.d(e,"DiffAction",function(){return p}),t.d(e,"ClassifierType",function(){return r}),t.d(e,"breaking",function(){return a}),t.d(e,"nonBreaking",function(){return s}),t.d(e,"unclassified",function(){return i}),t.d(e,"annotation",function(){return o}),t.d(e,"allNonBreaking",function(){return c}),t.d(e,"allBreaking",function(){return f}),t.d(e,"onlyAddBreaking",function(){return u}),t.d(e,"addNonBreaking",function(){return l}),t.d(e,"allUnclassified",function(){return d}),t.d(e,"allAnnotation",function(){return m}),t.d(e,"apiDiff",function(){return J}),t.d(e,"apiMerge",function(){return H}),t.d(e,"findExternalRefs",function(){return g});const n="$diff";var p,r;(t=p=p||{}).add="add",t.remove="remove",t.replace="replace",(e=r=r||{}).breaking="breaking",e.nonBreaking="non-breaking",e.annotation="annotation",e.unclassified="unclassified";const{breaking:a,nonBreaking:s,unclassified:i,annotation:o}=r,c=[s,s,s],f=[a,a,a],u=[a,s,s],l=[s,a,a],d=[i,i,i],m=[o,o,o],y=e=>e?a:s,h=(e,t)=>y(t),b=e=>Array.isArray(e)?"array":null==typeof e?"null":typeof e,g=e=>{if("object"!=typeof e)return[];let t=new Set;if("array"===b(e))for(const n of e)"object"==typeof n&&(t=new Set([...t,...g(n)]));else for(const a of Object.keys(e)){var r;"$ref"===a?([r]=e[a].split("#"),r&&t.add(r)):"object"==typeof e[a]&&(t=new Set([...t,...g(e[a])]))}return[...t]},v=[a,s,(e,t)=>y(t<e)],O=[a,s,(e,t)=>y(e<t)],j=[h,s,h],w=[h,s,h],T=[a,s,(e,t)=>!(e%t)?s:a],x=(e=d)=>({"/":e,"/title":m,"/multipleOf":T,"/maximum":v,"/exclusiveMaximum":j,"/minimum":O,"/exclusiveMinimum":j,"/maxLength":v,"/minLength":O,"/pattern":[a,s,a],"/maxItems":v,"/minItems":O,"/uniqueItems":w,"/maxProperties":v,"/minProperties":O,"/required":{"/":u,"/*":[a,s,a]},"/enum":{"/":[a,s,a],"/*":[s,a,a]},"/type":[a,s,a],"/not":{"/":[a,s,a],"/*":()=>x(f)},"/allOf":{"/":[a,s,a],"/*":()=>x(f)},"/oneOf":{"/":[a,s,a],"/*":()=>x(l)},"/anyOf":{"/":[a,s,a],"/*":()=>x(l)},"/items":()=>x(l),"/properties":{"/":[a,s,a],"/*":()=>x(l)},"/additionalProperties":()=>x([a,a,h]),"/description":m,"/format":[a,s,a],"/default":[s,a,a],"/nullable":w,"/discriminator":{"/":d,"/propertyName":d,"/mapping":d},"/readOnly":w,"/writeOnly":w,"/example":m,"/externalDocs":m,"/deprecated":w,"/xml":{"/":d,"/name":d,"/namespace":d,"/prefix":d,"/attribute":d,"/wrapped":d}});var t={"/":l,"/location":l,"/description":m},e={"/summary":m,"/tags":m,"/externalDocs":m,"/bindings":d},S=Object.assign({"/":l,"/*":l,"/operationId":l,"/description":m},e);const R=Object.assign({"/":l,"/*":l,"/headers":d,"/correlationId":t,"/schemaFormat":f,"/contentType":l,"/name":c,"/title":c,"/examples":m},e),M=Object.assign({"/":f,"/headers":d,"/correlationId":t,"/schemaFormat":f,"/contentType":l,"/name":c,"/title":c,"/description":c,"/examples":m,"/traits":R,"/payload":x(f)},e);t=Object.assign({"/":l,"/operationId":l,"/description":m,"/traits":S,"/message":M},e),S={"/":l,"/version":l,"/termsOfService":l,"/license":{"/":l,"/name":f,"/url":u},"/title":m,"/description":m,"/contact":{"/":m,"/name":m,"/url":m,"/email":m}},e={"/":l,"/*":{"/":l,"/url":l,"/description":m,"/protocol":f,"/protocolVersion":f,"/variables":{"/":l,"/*":{"/":l,"/enum":{"/":l,"/*":l},"/default":f,"/description":m,"/examples":m}},"/security":{"/":f,"/*":f},"/bindings":d}},t={"/":l,"/description":c,"/bindings":d,"/subscribe":t,"/publish":t,"/parameters":{"/":f,"/*":{"/":l,"/description":c,"/schema":x(f),"/location":f}}};const k={"/asyncapi":l,"/id":m,"/defaultContentType":f,"/info":S,"/servers":e,"/channels":{"/":l,"/*":t},"/components":c,"/tags":m,"/externalDocs":m};var S={"/":[s,a,a],"/*":{"/":[s,a,a],"/url":[s,a,a],"/description":m,"/variables":{"/":[s,a,a],"/*":{"/":[s,a,a],"/enum":{"/":[s,a,a],"/*":[s,a,a]},"/default":[a,a,a],"/description":m}}}},e={"/":[s,a,a],"/*":{"/":[s,a,a],"/name":[s,a,a],"/in":[s,a,a],"/description":m,"/required":[a,s,h],"/deprecated":[a,s,h]}},t={"/":[s,a,a],"/*":{"/":[s,a,a],"/description":m,"/required":[a,s,h],"/deprecated":[a,s,h]}},A={"/":[s,s,s],"/*":{"/contentType":[s,a,a],"/headers":t,"/style":[s,a,a],"/explode":[s,a,a],"/allowReserved":[s,a,a]}},A={"/":[s,a,a],"/*":{"/":[s,a,a],"/schema":x(f),"/example":m,"/examples":m,"/encoding":A}},P={"/":[s,a,a],"/*":{"/":[s,a,a],"/description":m,"/content":A,"/required":[a,s,(e,t)=>t?a:s]}},A={"/":[s,a,a],"/*":{"/":[s,a,a],"/description":m,"/headers":t,"/content":A}},D={"/":[a,s,i],"/*":[a,s,i]},q={"/":[s,a,a],"/tags":m,"/summary":m,"/description":m,"/externalDocs":m,"/operationId":[s,a,a],"/parameters":e,"/requestBody":P,"/responses":A,"/deprecated":[a,s,h],"/security":D,"/servers":S};const C={"/openapi":[s,a,a],"/info":{"/":[s,a,a],"/title":m,"/description":m,"/termsOfService":m,"/contact":m,"/licence":{"/":[s,a,a],"/name":[a,a,a],"/url":[a,s,s]},"/version":m},"/servers":S,"/paths":{"/":[s,a,a],"/*":{"/":[s,a,a],"/summary":m,"/description":m,"/*":q,"/servers":S,"/parameters":e}},"/components":{"/":[s,s,s],"/schemas":{"/":[s,a,a],"/*":x(l)},"/responses":{"/":[s,a,a],"/*":A},"/parameters":{"/":[s,a,a],"/*":e},"/examples":m,"/requestBodies":{"/":[s,a,a],"/*":P},"/headers":t,"/securitySchemes":{"/":[a,s,a],"/*":{"/":[a,s,a],"/type":[a,s,a],"/description":m,"/name":[a,s,a],"/in":[a,s,a],"/scheme":[a,s,a],"/bearerFormat":m,"/flows":[a,s,a],"/openIdConnectUrl":m}}},"/security":D,"/tags":m,"/externalDocs":m};var E=function(e,t){var r={};for(a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,a=Object.getOwnPropertySymbols(e);n<a.length;n++)t.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(r[a[n]]=e[a[n]]);return r};const K=(e,t,r={})=>{let n=e;r=new Map(Object.entries(r));for(const a of(e=>{var[,...e]=e.split("/").map(e=>e.replace(new RegExp("~1","g"),"/"));return e})(t)){if(void 0===(n="array"===b(n)?n[+a]:n[a]))break;n=$(n,e,new Set,r)}return n},$=(e,t,r,n)=>{if(e.hasOwnProperty("$ref")){const i=e["$ref"],o=E(e,["$ref"]);if(r.has(i))return e;var[a,s]=i.split("#");if(a){if(!n.has(a))return e;t=n.get(a)}e=Object.assign(Object.assign({},o),K(t,s,n)),r.add(i),n.set(i,e)}return e},L=(e,t)=>{let r=e;for(var n of[...t,""]){if(r.hasOwnProperty("/"+n)&&"number"!=typeof n||(n="*"),!r.hasOwnProperty("/"+n))return d;{const a=r["/"+n];if(Array.isArray(a))return a;r="function"==typeof a?a():a}}return d},B=(e,t={})=>{const r=e;const n=L(t,e.path)[["add","remove","replace"].indexOf(e.action)];return r.type="function"==typeof n?n(e.before,e.after):n,r};class N{constructor(e,t,r){this.before=e,this.after=t,this.beforeRefs=new Set,this.afterRefs=new Set,this.beforeCache=new Map,this.afterCache=new Map,this.findFirstDiff=!1,this.rules="string"==typeof r.rules?this.getBaseRules(r.rules):r.rules,this.trimStrings=r.trimStrings,this.caseSensitive=r.caseSensitive,this.strictArrays=r.strictArrays,this.circularRef=r.circularRef||!1,this.arrayMeta=r.arrayMeta||!1;var n=r.externalRefs||{};for(const a of Object.keys(n))this.beforeCache.set(a,n[a]),this.afterCache.set(a,n[a])}getBaseRules(e){switch(e){case"OpenApi3":return C;case"AsyncApi2":return k;case"JsonSchema":return x()}}}class U extends N{constructor(e,t,r){super(e,t,r),this._formatMeta=e=>Object.assign({type:e.type,action:e.action},e.action===p.replace?{replaced:e.before}:{}),this.formatMeta=r.formatMeta||(e=>this._formatMeta(e)),this.metaKey=r.metaKey||n}}const J=(e,t,r)=>I(e,t,new N(e,t,r)),I=(e,t,r,n=[])=>{var a;if(b(e)!==b(t))return a={path:n,before:e,after:t,action:p.replace},[B(a,r.rules)];switch(b(e)){case"object":return Y(e,t,r,n);case"array":return G(e,t,r,n);default:"string"===b(e)&&(e=V(e,r),t=V(t,r));var s={path:n,before:e,after:t,action:p.replace};return e!==t?[B(s,r.rules)]:[]}},V=(e,t)=>(e=t.trimStrings?e.trim():e,e=t.caseSensitive?e:e.toLowerCase()),Y=(e,t,r,n)=>{const a=[];var s,i="#"+("/"+n.map(e=>String(e).replace(new RegExp("/","g"),"~1")).join("/"));r.beforeRefs.add(i),r.afterRefs.add(i);const o=$(e,r.before,r.beforeRefs,r.beforeCache),c=$(t,r.after,r.afterRefs,r.afterCache);for(const f of new Set([...Object.keys(o),...Object.keys(c)]))if("symbol"!=typeof f)if(o.hasOwnProperty(f)?c.hasOwnProperty(f)?a.push(...I(o[f],c[f],r,[...n,f])):(s={path:[...n,f],before:o[f],action:p.remove},a.push(B(s,r.rules))):(s={path:[...n,f],after:c[f],action:p.add},a.push(B(s,r.rules))),r.findFirstDiff&&a.length)break;return e.$ref&&r.beforeRefs.delete(e.$ref),t.$ref&&r.afterRefs.delete(t.$ref),r.beforeRefs.delete(i),r.afterRefs.delete(i),a},z=(t,r,n)=>{for(let e=0;e<r.length;e++){n.findFirstDiff=!0;var a=I(t,r[e],n);if(n.findFirstDiff=!1,!a.length)return e}return-1},G=(t,r,n,a)=>{const s=[],i=[...r];for(let e=0;e<t.length;e++){var o,c;if(n.strictArrays?e>=r.length?(o={path:[...a,e],before:t[e],action:p.remove},s.push(B(o,n.rules))):s.push(...I(t[e],r[e],n,[...a,e])):0<=(o=z(t[e],i,n))?i.splice(o,1):(c={path:[...a,e],before:t[e],action:p.remove},s.push(B(c,n.rules))),n.findFirstDiff&&s.length)break}n.strictArrays&&i.splice(0,t.length);for(let e=0;e<i.length;e++){var f={path:[...a,t.length+e],after:i[e],action:p.add};s.push(B(f,n.rules))}return s},H=(e,t,r)=>{var[e]=F(e,t,new U(e,t,r),[]);return e},F=(e,t,r,n=[])=>{var a,s;if(b(e)!==b(t))return a={path:n,before:e,after:t,action:p.replace},[t,r.formatMeta(B(a,r.rules))];switch(b(e)){case"object":return W(e,t,r,n);case"array":return X(e,t,r,n);default:if("string"==typeof e&&(e=Q(e,r),t=Q(t,r)),e!==t)return s={path:n,before:e,after:t,action:p.replace},[t,r.formatMeta(B(s,r.rules))]}return[t]},Q=(e,t)=>(e=t.trimStrings?e.trim():e,e=t.caseSensitive?e:e.toLowerCase()),W=(e,t,r,n)=>{const a={},s={},i=$(e,r.before,r.beforeRefs,r.beforeCache),o=$(t,r.after,r.afterRefs,r.afterCache);var c,f;for(const u of new Set([...Object.keys(i),...Object.keys(o)]))"symbol"!=typeof u&&(i.hasOwnProperty(u)?o.hasOwnProperty(u)?([c,f]=F(i[u],o[u],r,[...n,u]),a[u]=c,f&&(s[u]=f)):(c={path:[...n,u],before:i[u],action:p.remove},a[u]=i[u],s[u]=r.formatMeta(B(c,r.rules))):(f={path:[...n,u],after:o[u],action:p.add},a[u]=o[u],s[u]=r.formatMeta(B(f,r.rules))));return e.$ref&&r.beforeRefs.delete(e.$ref),t.$ref&&r.afterRefs.delete(t.$ref),Object.keys(s).length&&(a[r.metaKey]=s),[a]},X=(r,t,n,a)=>{const s={},i=[],o=[...t];for(let e=0;e<r.length;e++){var c,f,u;n.strictArrays?e>=t.length?(c={path:[...a,e],before:r[e],action:p.remove},i[e]=r[e],s[e]=n.formatMeta(B(c,n.rules))):([c,f]=F(r[e],t[e],n,[...a,e]),i[e]=c,f&&(s[e]=f)):(f=z(r[e],o,n),i[e]=r[e],0<=f?o.splice(f,1):(u={path:[...a,e],before:r[e],action:p.remove},s[e]=n.formatMeta(B(u,n.rules))))}n.strictArrays&&o.splice(0,r.length);for(let e=r.length,t=0;e<r.length+o.length;e++,t++){i[e]=o[t];var l={path:[...a,e],after:o[t],action:p.add};s[e]=n.formatMeta(B(l,n.rules))}return n.arrayMeta&&Object.keys(s).length&&(i[n.metaKey]=s),n.arrayMeta||!Object.keys(i).length?[i]:[i,{array:s}]}}]); | ||
/*! api-smart-diff@0.2.7 */ | ||
var ApiSmartDiff=function(r){var n={};function a(e){if(n[e])return n[e].exports;var t=n[e]={i:e,l:!1,exports:{}};return r[e].call(t.exports,t,t.exports,a),t.l=!0,t.exports}return a.m=r,a.c=n,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)a.d(r,n,function(e){return t[e]}.bind(null,n));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=0)}([function(_,e,t){"use strict";t.r(e),t.d(e,"messageTraitsRules",function(){return R}),t.d(e,"messageRules",function(){return M}),t.d(e,"asyncApi2Rules",function(){return k}),t.d(e,"openapi3Rules",function(){return C}),t.d(e,"jsonSchemaRules",function(){return x}),t.d(e,"DIFF_META_KEY",function(){return n}),t.d(e,"DiffAction",function(){return p}),t.d(e,"ClassifierType",function(){return r}),t.d(e,"breaking",function(){return a}),t.d(e,"nonBreaking",function(){return s}),t.d(e,"unclassified",function(){return i}),t.d(e,"annotation",function(){return o}),t.d(e,"allNonBreaking",function(){return c}),t.d(e,"allBreaking",function(){return f}),t.d(e,"onlyAddBreaking",function(){return u}),t.d(e,"addNonBreaking",function(){return l}),t.d(e,"allUnclassified",function(){return d}),t.d(e,"allAnnotation",function(){return m}),t.d(e,"apiDiff",function(){return U}),t.d(e,"apiMerge",function(){return G}),t.d(e,"findExternalRefs",function(){return g});const n="$diff";var p,r;(t=p=p||{}).add="add",t.remove="remove",t.replace="replace",(e=r=r||{}).breaking="breaking",e.nonBreaking="non-breaking",e.annotation="annotation",e.unclassified="unclassified";const{breaking:a,nonBreaking:s,unclassified:i,annotation:o}=r,c=[s,s,s],f=[a,a,a],u=[a,s,s],l=[s,a,a],d=[i,i,i],m=[o,o,o],y=e=>e?a:s,h=(e,t)=>y(t),b=e=>Array.isArray(e)?"array":null==typeof e?"null":typeof e,g=e=>{if("object"!=typeof e)return[];let t=new Set;if("array"===b(e))for(const n of e)"object"==typeof n&&(t=new Set([...t,...g(n)]));else for(const a of Object.keys(e)){var r;"$ref"===a?([r]=e[a].split("#"),r&&t.add(r)):"object"==typeof e[a]&&(t=new Set([...t,...g(e[a])]))}return[...t]},v=[a,s,(e,t)=>y(t<e)],O=[a,s,(e,t)=>y(e<t)],j=[h,s,h],w=[h,s,h],T=[a,s,(e,t)=>!(e%t)?s:a],x=(e=d)=>({"/":e,"/title":m,"/multipleOf":T,"/maximum":v,"/exclusiveMaximum":j,"/minimum":O,"/exclusiveMinimum":j,"/maxLength":v,"/minLength":O,"/pattern":[a,s,a],"/maxItems":v,"/minItems":O,"/uniqueItems":w,"/maxProperties":v,"/minProperties":O,"/required":{"/":u,"/*":[a,s,a]},"/enum":{"/":[a,s,a],"/*":[s,a,a]},"/type":[a,s,a],"/not":{"/":[a,s,a],"/*":()=>x(f)},"/allOf":{"/":[a,s,a],"/*":()=>x(f)},"/oneOf":{"/":[a,s,a],"/*":()=>x(l)},"/anyOf":{"/":[a,s,a],"/*":()=>x(l)},"/items":()=>x(l),"/properties":{"/":[a,s,a],"/*":()=>x(l)},"/additionalProperties":()=>x([a,a,h]),"/description":m,"/format":[a,s,a],"/default":[s,a,a],"/nullable":w,"/discriminator":{"/":d,"/propertyName":d,"/mapping":d},"/readOnly":w,"/writeOnly":w,"/example":m,"/externalDocs":m,"/deprecated":w,"/xml":{"/":d,"/name":d,"/namespace":d,"/prefix":d,"/attribute":d,"/wrapped":d}});var t={"/":l,"/location":l,"/description":m},e={"/summary":m,"/tags":m,"/externalDocs":m,"/bindings":d},S=Object.assign({"/":l,"/*":l,"/operationId":l,"/description":m},e);const R=Object.assign({"/":l,"/*":l,"/headers":d,"/correlationId":t,"/schemaFormat":f,"/contentType":l,"/name":c,"/title":c,"/examples":m},e),M=Object.assign({"/":f,"/headers":d,"/correlationId":t,"/schemaFormat":f,"/contentType":l,"/name":c,"/title":c,"/description":c,"/examples":m,"/traits":R,"/payload":x(f)},e);t=Object.assign({"/":l,"/operationId":l,"/description":m,"/traits":S,"/message":M},e),S={"/":l,"/version":l,"/termsOfService":l,"/license":{"/":l,"/name":f,"/url":u},"/title":m,"/description":m,"/contact":{"/":m,"/name":m,"/url":m,"/email":m}},e={"/":l,"/*":{"/":l,"/url":l,"/description":m,"/protocol":f,"/protocolVersion":f,"/variables":{"/":l,"/*":{"/":l,"/enum":{"/":l,"/*":l},"/default":f,"/description":m,"/examples":m}},"/security":{"/":f,"/*":f},"/bindings":d}},t={"/":l,"/description":c,"/bindings":d,"/subscribe":t,"/publish":t,"/parameters":{"/":f,"/*":{"/":l,"/description":c,"/schema":x(f),"/location":f}}};const k={"/asyncapi":l,"/id":m,"/defaultContentType":f,"/info":S,"/servers":e,"/channels":{"/":l,"/*":t},"/components":c,"/tags":m,"/externalDocs":m};var S={"/":[s,a,a],"/*":{"/":[s,a,a],"/url":[s,a,a],"/description":m,"/variables":{"/":[s,a,a],"/*":{"/":[s,a,a],"/enum":{"/":[s,a,a],"/*":[s,a,a]},"/default":[a,a,a],"/description":m}}}},e={"/":[s,a,a],"/*":{"/":[s,a,a],"/name":[s,a,a],"/in":[s,a,a],"/description":m,"/required":[a,s,h],"/deprecated":[a,s,h]}},t={"/":[s,a,a],"/*":{"/":[s,a,a],"/description":m,"/required":[a,s,h],"/deprecated":[a,s,h]}},A={"/":[s,s,s],"/*":{"/contentType":[s,a,a],"/headers":t,"/style":[s,a,a],"/explode":[s,a,a],"/allowReserved":[s,a,a]}},A={"/":[s,a,a],"/*":{"/":[s,a,a],"/schema":x(f),"/example":m,"/examples":m,"/encoding":A}},P={"/":[s,a,a],"/*":{"/":[s,a,a],"/description":m,"/content":A,"/required":[a,s,(e,t)=>t?a:s]}},A={"/":[s,a,a],"/*":{"/":[s,a,a],"/description":m,"/headers":t,"/content":A}},D={"/":[a,s,i],"/*":[a,s,i]},q={"/":[s,a,a],"/tags":m,"/summary":m,"/description":m,"/externalDocs":m,"/operationId":[s,a,a],"/parameters":e,"/requestBody":P,"/responses":A,"/deprecated":[a,s,h],"/security":D,"/servers":S};const C={"/openapi":[s,a,a],"/info":{"/":[s,a,a],"/title":m,"/description":m,"/termsOfService":m,"/contact":m,"/licence":{"/":[s,a,a],"/name":[a,a,a],"/url":[a,s,s]},"/version":m},"/servers":S,"/paths":{"/":[s,a,a],"/*":{"/":[s,a,a],"/summary":m,"/description":m,"/*":q,"/servers":S,"/parameters":e}},"/components":{"/":[s,s,s],"/schemas":{"/":[s,a,a],"/*":x(l)},"/responses":{"/":[s,a,a],"/*":A},"/parameters":{"/":[s,a,a],"/*":e},"/examples":m,"/requestBodies":{"/":[s,a,a],"/*":P},"/headers":t,"/securitySchemes":{"/":[a,s,a],"/*":{"/":[a,s,a],"/type":[a,s,a],"/description":m,"/name":[a,s,a],"/in":[a,s,a],"/scheme":[a,s,a],"/bearerFormat":m,"/flows":[a,s,a],"/openIdConnectUrl":m}}},"/security":D,"/tags":m,"/externalDocs":m}; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */const E=(e,t,r={})=>{let n=e;r=new Map(Object.entries(r));for(const a of(e=>{var[,...e]=e.split("/").map(e=>e.replace(new RegExp("~1","g"),"/"));return e})(t)){if(void 0===(n="array"===b(n)?n[+a]:n[a]))break;n=$(n,e,new Set,r)}return n},$=(e,t,r,n)=>{if(e.hasOwnProperty("$ref")){const i=e["$ref"],o=function(e,t){var r={};for(a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,a=Object.getOwnPropertySymbols(e);n<a.length;n++)t.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(r[a[n]]=e[a[n]]);return r}(e,["$ref"]);if(r.has(i))return e;var[a,s]=i.split("#");if(a){if(!n.has(a))return e;t=n.get(a)}e=Object.assign(Object.assign({},o),E(t,s,n)),r.add(i),n.set(i,e)}return e},K=(e,t)=>{let r=e;for(var n of[...t,""]){if(r.hasOwnProperty("/"+n)&&"number"!=typeof n||(n="*"),!r.hasOwnProperty("/"+n))return d;{const a=r["/"+n];if(Array.isArray(a))return a;r="function"==typeof a?a():a}}return d},B=(e,t={})=>{const r=e;const n=K(t,e.path)[["add","remove","replace"].indexOf(e.action)];return r.type="function"==typeof n?n(e.before,e.after):n,r};class L{constructor(e,t,r){this.before=e,this.after=t,this.beforeRefs=new Set,this.afterRefs=new Set,this.beforeCache=new Map,this.afterCache=new Map,this.findFirstDiff=!1,this.rules="string"==typeof r.rules?this.getBaseRules(r.rules):r.rules,this.trimStrings=r.trimStrings,this.caseSensitive=r.caseSensitive,this.strictArrays=r.strictArrays,this.circularRef=r.circularRef||!1,this.arrayMeta=r.arrayMeta||!1;var n=r.externalRefs||{};for(const a of Object.keys(n))this.beforeCache.set(a,n[a]),this.afterCache.set(a,n[a])}getBaseRules(e){switch(e){case"OpenApi3":return C;case"AsyncApi2":return k;case"JsonSchema":return x()}}}class N extends L{constructor(e,t,r){super(e,t,r),this._formatMeta=e=>Object.assign({type:e.type,action:e.action},e.action===p.replace?{replaced:e.before}:{}),this.formatMeta=r.formatMeta||(e=>this._formatMeta(e)),this.metaKey=r.metaKey||n}}const U=(e,t,r)=>I(e,t,new L(e,t,r)),I=(e,t,r,n=[])=>{var a;if(b(e)!==b(t))return a={path:n,before:e,after:t,action:p.replace},[B(a,r.rules)];switch(b(e)){case"object":return V(e,t,r,n);case"array":return z(e,t,r,n);default:"string"===b(e)&&(e=J(e,r),t=J(t,r));var s={path:n,before:e,after:t,action:p.replace};return e!==t?[B(s,r.rules)]:[]}},J=(e,t)=>(e=t.trimStrings?e.trim():e,e=t.caseSensitive?e:e.toLowerCase()),V=(e,t,r,n)=>{const a=[];var s,i="#"+("/"+n.map(e=>String(e).replace(new RegExp("/","g"),"~1")).join("/"));r.beforeRefs.add(i),r.afterRefs.add(i);const o=$(e,r.before,r.beforeRefs,r.beforeCache),c=$(t,r.after,r.afterRefs,r.afterCache);for(const f of new Set([...Object.keys(o),...Object.keys(c)]))if("symbol"!=typeof f)if(o.hasOwnProperty(f)?c.hasOwnProperty(f)?a.push(...I(o[f],c[f],r,[...n,f])):(s={path:[...n,f],before:o[f],action:p.remove},a.push(B(s,r.rules))):(s={path:[...n,f],after:c[f],action:p.add},a.push(B(s,r.rules))),r.findFirstDiff&&a.length)break;return e.$ref&&r.beforeRefs.delete(e.$ref),t.$ref&&r.afterRefs.delete(t.$ref),r.beforeRefs.delete(i),r.afterRefs.delete(i),a},Y=(t,r,n)=>{for(let e=0;e<r.length;e++){n.findFirstDiff=!0;var a=I(t,r[e],n);if(n.findFirstDiff=!1,!a.length)return e}return-1},z=(t,r,n,a)=>{const s=[],i=[...r];for(let e=0;e<t.length;e++){var o,c;if(n.strictArrays?e>=r.length?(o={path:[...a,e],before:t[e],action:p.remove},s.push(B(o,n.rules))):s.push(...I(t[e],r[e],n,[...a,e])):0<=(o=Y(t[e],i,n))?i.splice(o,1):(c={path:[...a,e],before:t[e],action:p.remove},s.push(B(c,n.rules))),n.findFirstDiff&&s.length)break}n.strictArrays&&i.splice(0,t.length);for(let e=0;e<i.length;e++){var f={path:[...a,t.length+e],after:i[e],action:p.add};s.push(B(f,n.rules))}return s},G=(e,t,r)=>{var[e]=F(e,t,new N(e,t,r),[]);return e},F=(e,t,r,n=[])=>{var a,s;if(b(e)!==b(t))return a={path:n,before:e,after:t,action:p.replace},[t,r.formatMeta(B(a,r.rules))];switch(b(e)){case"object":return Q(e,t,r,n);case"array":return W(e,t,r,n);default:if("string"==typeof e&&(e=H(e,r),t=H(t,r)),e!==t)return s={path:n,before:e,after:t,action:p.replace},[t,r.formatMeta(B(s,r.rules))]}return[t]},H=(e,t)=>(e=t.trimStrings?e.trim():e,e=t.caseSensitive?e:e.toLowerCase()),Q=(e,t,r,n)=>{const a={},s={},i=$(e,r.before,r.beforeRefs,r.beforeCache),o=$(t,r.after,r.afterRefs,r.afterCache);var c,f;for(const u of new Set([...Object.keys(i),...Object.keys(o)]))"symbol"!=typeof u&&(i.hasOwnProperty(u)?o.hasOwnProperty(u)?([c,f]=F(i[u],o[u],r,[...n,u]),a[u]=c,f&&(s[u]=f)):(c={path:[...n,u],before:i[u],action:p.remove},a[u]=i[u],s[u]=r.formatMeta(B(c,r.rules))):(f={path:[...n,u],after:o[u],action:p.add},a[u]=o[u],s[u]=r.formatMeta(B(f,r.rules))));return e.$ref&&r.beforeRefs.delete(e.$ref),t.$ref&&r.afterRefs.delete(t.$ref),Object.keys(s).length&&(a[r.metaKey]=s),[a]},W=(r,t,n,a)=>{const s={},i=[],o=[...t];for(let e=0;e<r.length;e++){var c,f,u;n.strictArrays?e>=t.length?(c={path:[...a,e],before:r[e],action:p.remove},i[e]=r[e],s[e]=n.formatMeta(B(c,n.rules))):([c,f]=F(r[e],t[e],n,[...a,e]),i[e]=c,f&&(s[e]=f)):(f=Y(r[e],o,n),i[e]=r[e],0<=f?o.splice(f,1):(u={path:[...a,e],before:r[e],action:p.remove},s[e]=n.formatMeta(B(u,n.rules))))}n.strictArrays&&o.splice(0,r.length);for(let e=r.length,t=0;e<r.length+o.length;e++,t++){i[e]=o[t];var l={path:[...a,e],after:o[t],action:p.add};s[e]=n.formatMeta(B(l,n.rules))}return n.arrayMeta&&Object.keys(s).length&&(i[n.metaKey]=s),n.arrayMeta||!Object.keys(i).length?[i]:[i,{array:s}]}}]); |
{ | ||
"name": "api-smart-diff", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "Generate the diff between two API specifications (OpenAPI, AsyncAPI, JsonSchema)", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"module": "dist/esm/index.js", | ||
"main": "dist/cjs/index.js", | ||
"types": "dist/cjs/index.d.ts", | ||
"files": [ | ||
@@ -12,6 +13,6 @@ "dist", | ||
"browser": { | ||
"./dist/index.js": "./browser/api-smart-diff.js" | ||
"./dist/cjs/index.js": "./browser/api-smart-diff.js" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"build": "tsc && tsc --module commonjs --outDir dist/cjs", | ||
"test": "jest --verbose", | ||
@@ -18,0 +19,0 @@ "test:coverage": "jest --verbose --coverage", |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
258454
57
3175
1