@speclynx/apidom-datamodel 2.1.0 → 2.2.0
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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.2.0](https://github.com/speclynx/apidom/compare/v2.1.0...v2.2.0) (2026-01-19)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **json-path:** integrate @swaggerexpert/jsonpath as JSONPath engine ([#25](https://github.com/speclynx/apidom/issues/25)) ([40f9279](https://github.com/speclynx/apidom/commit/40f92793ab9d2ab82ba5a4431f82c186031b661f))
|
|
11
|
+
|
|
6
12
|
# [2.1.0](https://github.com/speclynx/apidom/compare/v2.0.1...v2.1.0) (2026-01-17)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @speclynx/apidom-datamodel
|
|
@@ -1141,7 +1141,8 @@ class Element {
|
|
|
1141
1141
|
* Checks deep equality with another value.
|
|
1142
1142
|
*/
|
|
1143
1143
|
equals(value) {
|
|
1144
|
-
|
|
1144
|
+
const compareTo = value instanceof Element ? value.toValue() : value;
|
|
1145
|
+
return (0,ramda__WEBPACK_IMPORTED_MODULE_0__["default"])(this.toValue(), compareTo);
|
|
1145
1146
|
}
|
|
1146
1147
|
|
|
1147
1148
|
// ============================================================
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.apidomDatamodel=t():e.apidomDatamodel=t()}(self,()=>(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function r(e){return function t(r){return 0===arguments.length||n(r)?t:e.apply(this,arguments)}}function s(e){return function t(s,i){switch(arguments.length){case 0:return t;case 1:return n(s)?t:r(function(t){return e(s,t)});default:return n(s)&&n(i)?t:n(s)?r(function(t){return e(t,i)}):n(i)?r(function(t){return e(s,t)}):e(s,i)}}}function i(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}function o(e,t,n){for(var r=0,s=n.length;r<s;){if(e(t,n[r]))return!0;r+=1}return!1}function a(e,t){return Object.prototype.hasOwnProperty.call(t,e)}e.r(t),e.d(t,{AnnotationElement:()=>ke,ArrayElement:()=>I,BooleanElement:()=>L,CloneError:()=>fe,CollectionElement:()=>D,CommentElement:()=>Oe,DeepCloneError:()=>me,Element:()=>O,JSONSerialiser:()=>P,KeyValuePair:()=>E,LinkElement:()=>F,MemberElement:()=>K,Namespace:()=>Q,NullElement:()=>x,NumberElement:()=>z,ObjectElement:()=>R,ObjectSlice:()=>w,ParseResultElement:()=>je,RefElement:()=>N,ShallowCloneError:()=>pe,SourceMapElement:()=>V,StringElement:()=>j,cloneDeep:()=>be,cloneShallow:()=>Ee,hasElementSourceMap:()=>se,includesClasses:()=>oe,includesSymbols:()=>ie,isAnnotationElement:()=>Se,isArrayElement:()=>ee,isBooleanElement:()=>Z,isCommentElement:()=>Ce,isElement:()=>$,isLinkElement:()=>Ae,isMemberElement:()=>ne,isNullElement:()=>Y,isNumberElement:()=>X,isObjectElement:()=>te,isParseResultElement:()=>Ve,isPrimitiveElement:()=>re,isRefElement:()=>Me,isSourceMapElement:()=>Pe,isStringElement:()=>H,refract:()=>we});const c="function"==typeof Object.is?Object.is:function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t};var u=Object.prototype.toString;const l=function(){return"[object Arguments]"===u.call(arguments)?function(e){return"[object Arguments]"===u.call(e)}:function(e){return a("callee",e)}}();var h=!{toString:null}.propertyIsEnumerable("toString"),f=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],m=function(){return arguments.propertyIsEnumerable("length")}(),p=function(e,t){for(var n=0;n<e.length;){if(e[n]===t)return!0;n+=1}return!1};const y="function"!=typeof Object.keys||m?r(function(e){if(Object(e)!==e)return[];var t,n,r=[],s=m&&l(e);for(t in e)!a(t,e)||s&&"length"===t||(r[r.length]=t);if(h)for(n=f.length-1;n>=0;)a(t=f[n],e)&&!p(r,t)&&(r[r.length]=t),n-=1;return r}):r(function(e){return Object(e)!==e?[]:Object.keys(e)});const d=r(function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});function b(e,t,n,r){var s=i(e);function a(e,t){return g(e,t,n.slice(),r.slice())}return!o(function(e,t){return!o(a,t,e)},i(t),s)}function g(e,t,n,r){if(c(e,t))return!0;var s,i,o=d(e);if(o!==d(t))return!1;if("function"==typeof e["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e);if("function"==typeof e.equals||"function"==typeof t.equals)return"function"==typeof e.equals&&e.equals(t)&&"function"==typeof t.equals&&t.equals(e);switch(o){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===(s=e.constructor,null==(i=String(s).match(/^function (\w*)/))?"":i[1]))return e===t;break;case"Boolean":case"Number":case"String":if(typeof e!=typeof t||!c(e.valueOf(),t.valueOf()))return!1;break;case"Date":if(!c(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(e.source!==t.source||e.global!==t.global||e.ignoreCase!==t.ignoreCase||e.multiline!==t.multiline||e.sticky!==t.sticky||e.unicode!==t.unicode)return!1}for(var u=n.length-1;u>=0;){if(n[u]===e)return r[u]===t;u-=1}switch(o){case"Map":return e.size===t.size&&b(e.entries(),t.entries(),n.concat([e]),r.concat([t]));case"Set":return e.size===t.size&&b(e.values(),t.values(),n.concat([e]),r.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var l=y(e);if(l.length!==y(t).length)return!1;var h=n.concat([e]),f=r.concat([t]);for(u=l.length-1;u>=0;){var m=l[u];if(!a(m,t)||!g(t[m],e[m],h,f))return!1;u-=1}return!0}const v=s(function(e,t){return g(e,t,[],[])});const E=class{key;value;constructor(e,t){this.key=e,this.value=t}toValue(){return{key:this.key?.toValue(),value:this.value?.toValue()}}};class _{elements;constructor(e){this.elements=e??[]}toValue(){return this.elements.map(e=>({key:e.key?.toValue(),value:e.value?.toValue()}))}map(e,t){return this.elements.map(n=>{const r=n.value,s=n.key;if(void 0===r||void 0===s)throw new Error("MemberElement must have both key and value");return void 0!==t?e.call(t,r,s,n):e(r,s,n)})}filter(e,t){const n=this.elements.filter(n=>{const r=n.value,s=n.key;return void 0!==r&&void 0!==s&&(void 0!==t?e.call(t,r,s,n):e(r,s,n))});return new _(n)}reject(e,t){const n=[];for(const r of this.elements){const s=r.value,i=r.key;void 0!==s&&void 0!==i&&(e.call(t,s,i,r)||n.push(r))}return new _(n)}forEach(e,t){this.elements.forEach((n,r)=>{const s=n.value,i=n.key;void 0!==s&&void 0!==i&&(void 0!==t?e.call(t,s,i,n,r):e(s,i,n,r))})}find(e,t){return this.elements.find(n=>{const r=n.value,s=n.key;return void 0!==r&&void 0!==s&&(void 0!==t?e.call(t,r,s,n):e(r,s,n))})}keys(){return this.elements.map(e=>e.key?.toValue()).filter(e=>void 0!==e)}values(){return this.elements.map(e=>e.value?.toValue()).filter(e=>void 0!==e)}get length(){return this.elements.length}get isEmpty(){return 0===this.length}get first(){return this.elements[0]}get(e){return this.elements[e]}push(e){return this.elements.push(e),this}includesKey(e){return this.elements.some(t=>t.key?.equals(e))}[Symbol.iterator](){return this.elements[Symbol.iterator]()}}const w=_;class k{parent;startLine;startCharacter;startOffset;endLine;endCharacter;endOffset;_storedElement="element";_content;_meta;_attributes;constructor(e,t,n){void 0!==t&&(this.meta=t),void 0!==n&&(this.attributes=n),void 0!==e&&(this.content=e)}get element(){return this._storedElement}set element(e){this._storedElement=e}get content(){return this._content}set content(e){if(e instanceof k)this._content=e;else if(null!=e&&"string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e&&"bigint"!=typeof e&&"symbol"!=typeof e)if(e instanceof E)this._content=e;else if(e instanceof w)this._content=e.elements;else if(Array.isArray(e))this._content=e.map(e=>this.refract(e));else{if("object"!=typeof e)throw new Error("Cannot set content to value of type "+typeof e);this._content=Object.entries(e).map(([e,t])=>new this.MemberElement(e,t))}else this._content=e}get meta(){if(!this._meta){if(this.isFrozen){const e=new this.ObjectElement;return e.freeze(),e}this._meta=new this.ObjectElement}return this._meta}set meta(e){e instanceof k?this._meta=e:this.meta.set(e??{})}get attributes(){if(!this._attributes){if(this.isFrozen){const e=new this.ObjectElement;return e.freeze(),e}this._attributes=new this.ObjectElement}return this._attributes}set attributes(e){e instanceof k?this._attributes=e:this.attributes.set(e??{})}get id(){return this.getMetaProperty("id","")}set id(e){this.setMetaProperty("id",e)}get classes(){return this.getMetaProperty("classes",[])}set classes(e){this.setMetaProperty("classes",e)}get links(){return this.getMetaProperty("links",[])}set links(e){this.setMetaProperty("links",e)}get children(){const{_content:e}=this;if(Array.isArray(e))return e;if(e instanceof E){const t=[];return e.key&&t.push(e.key),e.value&&t.push(e.value),t}return e instanceof k?[e]:[]}get isFrozen(){return Object.isFrozen(this)}freeze(){if(!this.isFrozen){this._meta&&(this._meta.parent=this,this._meta.freeze()),this._attributes&&(this._attributes.parent=this,this._attributes.freeze());for(const e of this.children)e.parent=this,e.freeze();Array.isArray(this._content)&&Object.freeze(this._content),Object.freeze(this)}}toValue(){const{_content:e}=this;return e instanceof k||e instanceof E?e.toValue():Array.isArray(e)?e.map(e=>e.toValue()):e}equals(e){return v(this.toValue(),e)}primitive(){}set(e){return this.content=e,this}toRef(e){const t=this.id.toValue();if(""===t)throw new Error("Cannot create reference to an element without an ID");const n=new this.RefElement(t);return"string"==typeof e&&(n.path=this.refract(e)),n}getMetaProperty(e,t){if(!this.meta.hasKey(e)){if(this.isFrozen){const e=this.refract(t);return e.freeze(),e}this.meta.set(e,t)}return this.meta.get(e)}setMetaProperty(e,t){this.meta.set(e,t)}hasMetaProperty(e){return!this.isMetaEmpty&&this.meta.hasKey(e)}get isMetaEmpty(){return void 0===this._meta||this.meta.isEmpty}getAttributesProperty(e,t){if(!this.hasAttributesProperty(e)){if(this.isFrozen){const e=this.refract(t);return e.freeze(),e}this.attributes.set(e,t)}return this.attributes.get(e)}setAttributesProperty(e,t){this.attributes.set(e,t)}hasAttributesProperty(e){return!this.isAttributesEmpty&&this.attributes.hasKey(e)}get isAttributesEmpty(){return void 0===this._attributes||this.attributes.isEmpty}}const O=k;const j=class extends O{constructor(e,t,n){super(e,t,n),this.element="string"}primitive(){return"string"}get length(){return this.content?.length??0}};class A extends j{constructor(e,t,n){super(e,t,n),this.element="sourceMap"}static transfer(e,t){t.startLine=e.startLine,t.startCharacter=e.startCharacter,t.startOffset=e.startOffset,t.endLine=e.endLine,t.endCharacter=e.endCharacter,t.endOffset=e.endOffset}static from(e){const{startLine:t,startCharacter:n,startOffset:r,endLine:s,endCharacter:i,endOffset:o}=e;if("number"!=typeof t||"number"!=typeof n||"number"!=typeof r||"number"!=typeof s||"number"!=typeof i||"number"!=typeof o)return;const a="sm1:"+[t,n,r,s,i,o].map(S).join("");const c=new A(a);return c.startLine=t,c.startCharacter=n,c.startOffset=r,c.endLine=s,c.endCharacter=i,c.endOffset=o,c}applyTo(e){this.content&&([e.startLine,e.startCharacter,e.startOffset,e.endLine,e.endCharacter,e.endOffset]=function(e){const t=e.startsWith("sm1:")?e.slice(4):e,n=[];let r=0;for(let e=0;e<6;e++){const e=C(t,r);n.push(e.value),r=e.next}return n}(this.content))}}const M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function S(e){let t=e>>>0,n="";do{let e=31&t;t>>>=5,0!==t&&(e|=32),n+=M[e]}while(0!==t);return n}function C(e,t=0){let n=0,r=0,s=t;for(;;){const t=e[s++],i=M.indexOf(t);if(-1===i)throw new Error(`Invalid Base64 VLQ char: ${t}`);if(n|=(31&i)<<r,r+=5,!!!(32&i))break}return{value:n>>>0,next:s}}const V=A;const P=class{namespace;constructor(e){this.namespace=e||new this.Namespace}serialise(e){if(!(e instanceof this.namespace.elements.Element))throw new TypeError(`Given element \`${e}\` is not an Element instance`);const t={element:e.element};if(e.isMetaEmpty||(t.meta=this.serialiseObject(e.meta)),e.isAttributesEmpty||(t.attributes=this.serialiseObject(e.attributes)),!(e instanceof V)){const n=V.from(e);n&&(t.meta||(t.meta={}),t.meta.__mappings__=this.serialise(n))}const n=this.serialiseContent(e.content);return void 0!==n&&(t.content=n),t}deserialise(e){if(!e.element)throw new Error("Given value is not an object containing an element name");const t=new(this.namespace.getElementClass(e.element));let n;t.element!==e.element&&(t.element=e.element);let r=e.meta;if(e.meta?.__mappings__){const{__mappings__:t,...s}=e.meta;n=t,r=Object.keys(s).length>0?s:void 0}if(r&&this.deserialiseObject(r,t.meta),n){this.deserialise(n).applyTo(t)}e.attributes&&this.deserialiseObject(e.attributes,t.attributes);const s=this.deserialiseContent(e.content);return void 0===s&&null!==t.content||(t.content=s),t}serialiseContent(e){if(e instanceof this.namespace.elements.Element)return this.serialise(e);if(e instanceof this.namespace.KeyValuePair){const t=e,n={key:this.serialise(t.key)};return t.value&&(n.value=this.serialise(t.value)),n}if(e&&Array.isArray(e)){if(0===e.length)return;return e.map(e=>this.serialise(e))}return e}deserialiseContent(e){if(e){if(e.element)return this.deserialise(e);if(e.key){const t=new this.namespace.KeyValuePair(this.deserialise(e.key));return e.value&&(t.value=this.deserialise(e.value)),t}if(Array.isArray(e))return e.map(e=>this.deserialise(e))}return e}serialiseObject(e){const t={};if(e.forEach((e,n)=>{e&&(t[n.toValue()]=this.serialise(e))}),0!==Object.keys(t).length)return t}deserialiseObject(e,t){Object.keys(e).forEach(n=>{t.set(n,this.deserialise(e[n]))})}};const x=class extends O{constructor(e,t,n){super(e??null,t,n),this.element="null"}primitive(){return"null"}set(e){throw new Error("Cannot set the value of null")}};const z=class extends O{constructor(e,t,n){super(e,t,n),this.element="number"}primitive(){return"number"}};const L=class extends O{constructor(e,t,n){super(e,t,n),this.element="boolean"}primitive(){return"boolean"}};class q extends O{constructor(e,t,n){super(e||[],t,n)}get length(){return this._content.length}get isEmpty(){return 0===this.length}get first(){return this._content[0]}get second(){return this._content[1]}get last(){return this._content.at(-1)}push(...e){for(const t of e)this._content.push(this.refract(t));return this}shift(){return this._content.shift()}unshift(e){this._content.unshift(this.refract(e))}includes(e){return this._content.some(t=>t.equals(e))}findElements(e,t){const n=t||{},r=!!n.recursive,s=void 0===n.results?[]:n.results;for(let t=0;t<this._content.length;t+=1){const n=this._content[t],i=n;r&&"function"==typeof i.findElements&&i.findElements(e,{results:s,recursive:r}),e(n,t,void 0)&&s.push(n)}return s}find(e){const t=this.findElements(e,{recursive:!0});return new this.ArrayElement(t)}findByElement(e){return this.find(t=>t.element===e)}findByClass(e){return this.find(t=>{const n=t.classes;return"function"==typeof n.includes&&n.includes(e)})}getById(e){return this.find(t=>t.id.toValue()===e).first}concat(e){return new(0,this.constructor)(this._content.concat(e._content))}[Symbol.iterator](){return this._content[Symbol.iterator]()}}const D=q;const I=class extends D{constructor(e,t,n){super(e||[],t,n),this.element="array"}primitive(){return"array"}get(e){return this._content[e]}getValue(e){const t=this.get(e);if(t)return t.toValue()}set(e,t){return"number"==typeof e&&void 0!==t?this._content[e]=this.refract(t):this.content=e,this}remove(e){return this._content.splice(e,1)[0]??null}map(e,t){return this._content.map(e,t)}flatMap(e,t){return this._content.flatMap(e,t)}compactMap(e,t){const n=[];for(const r of this._content){const s=e.call(t,r);s&&n.push(s)}return n}filter(e,t){const n=this._content.filter(e,t);return new this.constructor(n)}reject(e,t){const n=[];for(const r of this._content)e.call(t,r)||n.push(r);return new this.constructor(n)}reduce(e,t){let n,r;void 0!==t?(n=0,r=this.refract(t)):(n=1,r=this.first);for(let t=n;t<this.length;t+=1){const n=e(r,this._content[t],t,this);r=void 0===n?n:this.refract(n)}return r}forEach(e,t){this._content.forEach((n,r)=>{e.call(t,n,r)})}empty(){return new this.constructor([])}};const K=class extends O{constructor(e,t,n,r){super(new E,n,r),this.element="member",void 0!==e&&(this.key=e),arguments.length>=2&&(this.value=t)}primitive(){return"member"}get key(){return this._content.key}set key(e){this._content.key=this.refract(e)}get value(){return this._content.value}set value(e){this._content.value=void 0===e?void 0:this.refract(e)}};const R=class extends D{constructor(e,t,n){super(e||[],t,n),this.element="object"}primitive(){return"object"}toValue(){return this._content.reduce((e,t)=>(e[t.key.toValue()]=t.value?t.value.toValue():void 0,e),{})}get(e){const t=this.getMember(e);if(t)return t.value}getValue(e){const t=this.get(e);if(t)return t.toValue()}getMember(e){if(void 0!==e)return this._content.find(t=>t.key.toValue()===e)}remove(e){let t=null;return this.content=this._content.filter(n=>n.key.toValue()!==e||(t=n,!1)),t}getKey(e){const t=this.getMember(e);if(t)return t.key}set(e,t){if("string"==typeof e){const n=this.getMember(e);n?n.value=t:this._content.push(new K(e,t))}else if("object"==typeof e&&!Array.isArray(e))for(const t of Object.keys(e))this.set(t,e[t]);return this}keys(){return this._content.map(e=>e.key.toValue())}values(){return this._content.map(e=>e.value.toValue())}hasKey(e){return this._content.some(t=>t.key.equals(e))}items(){return this._content.map(e=>[e.key.toValue(),e.value.toValue()])}map(e,t){return this._content.map(n=>e.call(t,n.value,n.key,n))}compactMap(e,t){const n=[];return this.forEach((r,s,i)=>{const o=e.call(t,r,s,i);o&&n.push(o)}),n}filter(e,t){return new w(this._content).filter(e,t)}reject(e,t){const n=[];for(const r of this._content)e.call(t,r.value,r.key,r)||n.push(r);return new w(n)}forEach(e,t){this._content.forEach(n=>e.call(t,n.value,n.key,n))}reduce(e,t){let n,r;void 0!==t?(n=0,r=this.refract(t)):(n=1,r=this._content[0]?.value);for(let t=n;t<this._content.length;t+=1){const n=this._content[t],s=e(r,n.value,n.key,n,this);r=void 0===s?s:this.refract(s)}return r}empty(){return new this.constructor([])}};const N=class extends O{constructor(e,t,n){super(e||[],t,n),this.element="ref",this.path||(this.path="element")}get path(){if(this.hasAttributesProperty("path"))return this.attributes.get("path")}set path(e){this.attributes.set("path",e)}};const F=class extends O{constructor(e,t,n){super(e||[],t,n),this.element="link"}get relation(){if(this.hasAttributesProperty("relation"))return this.attributes.get("relation")}set relation(e){this.attributes.set("relation",e)}get href(){if(this.hasAttributesProperty("href"))return this.attributes.get("href")}set href(e){this.attributes.set("href",e)}},B=e=>null===e,T=e=>"string"==typeof e,U=e=>"number"==typeof e,W=e=>"boolean"==typeof e,G=e=>null!==e&&"object"==typeof e;class J{elementMap={};elementDetection=[];Element;KeyValuePair;_elements;_attributeElementKeys=[];_attributeElementArrayKeys=[];constructor(e){this.Element=O,this.KeyValuePair=E,e&&e.noDefault||this.useDefault()}use(e){return e.namespace&&e.namespace({base:this}),e.load&&e.load({base:this}),this}useDefault(){return this.register("null",x).register("string",j).register("number",z).register("boolean",L).register("array",I).register("object",R).register("member",K).register("ref",N).register("link",F).register("sourceMap",V),this.detect(B,x,!1).detect(T,j,!1).detect(U,z,!1).detect(W,L,!1).detect(Array.isArray,I,!1).detect(G,R,!1),this}register(e,t){return this._elements=void 0,this.elementMap[e]=t,this}unregister(e){return this._elements=void 0,delete this.elementMap[e],this}detect(e,t,n){return void 0===n||n?this.elementDetection.unshift([e,t]):this.elementDetection.push([e,t]),this}toElement(e){if(e instanceof this.Element)return e;let t;for(const[n,r]of this.elementDetection)if(n(e)){t=new r(e);break}return t}getElementClass(e){const t=this.elementMap[e];return void 0===t?this.Element:t}fromRefract(e){return this.serialiser.deserialise(e)}toRefract(e){return this.serialiser.serialise(e)}get elements(){return void 0===this._elements&&(this._elements={Element:this.Element},Object.keys(this.elementMap).forEach(e=>{const t=e[0].toUpperCase()+e.substring(1);this._elements[t]=this.elementMap[e]})),this._elements}get serialiser(){return new P(this)}}P.prototype.Namespace=J;const Q=J,$=e=>e instanceof O,H=e=>e instanceof j,X=e=>e instanceof z,Y=e=>e instanceof x,Z=e=>e instanceof L,ee=e=>e instanceof I,te=e=>e instanceof R,ne=e=>e instanceof K,re=e=>te(e)&&"object"===e.element||ee(e)&&"array"===e.element||Z(e)&&"boolean"===e.element||X(e)&&"number"===e.element||H(e)&&"string"===e.element||Y(e)&&"null"===e.element||ne(e)&&"member"===e.element,se=e=>"number"==typeof e.startLine&&"number"==typeof e.startCharacter&&"number"==typeof e.startOffset&&"number"==typeof e.endLine&&"number"==typeof e.endCharacter&&"number"==typeof e.endOffset,ie=(e,t)=>{if(0===t.length)return!0;if(!e.hasAttributesProperty("symbols"))return!1;const n=e.attributes.get("symbols");return!!ee(n)&&t.every(e=>n.includes(e))},oe=(e,t)=>0===t.length||!!$(e)&&(!e.isMetaEmpty&&(!!e.hasMetaProperty("classes")&&t.every(t=>e.classes.includes(t))));class ae extends AggregateError{constructor(e,t,n){super(e,t,n),this.name=this.constructor.name,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}const ce=ae;class ue extends Error{static[Symbol.hasInstance](e){return super[Symbol.hasInstance](e)||Function.prototype[Symbol.hasInstance].call(ce,e)}constructor(e,t){super(e,t),this.name=this.constructor.name,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}const le=ue;const he=class extends le{constructor(e,t){if(super(e,t),null!=t&&"object"==typeof t){const{cause:e,...n}=t;Object.assign(this,n)}}};const fe=class extends he{value;constructor(e,t){super(e,t),void 0!==t&&(this.value=t.value)}};const me=class extends fe{};const pe=class extends fe{},ye=(e,t)=>{const{visited:n=new WeakMap}=t,r={...t,visited:n};if(n.has(e))return n.get(e);const s=ve(e);n.set(e,s);const{content:i}=e;return Array.isArray(i)?s.content=i.map(e=>ye(e,r)):$(i)?s.content=ye(i,r):s.content=i instanceof E?de(i,r):i,s},de=(e,t)=>{const{visited:n=new WeakMap}=t,r={...t,visited:n};if(n.has(e))return n.get(e);const{key:s,value:i}=e,o=void 0!==s?ye(s,r):void 0,a=void 0!==i?ye(i,r):void 0,c=new E(o,a);return n.set(e,c),c},be=(e,t={})=>{if(e instanceof E)return de(e,t);if(e instanceof w)return((e,t)=>{const{visited:n=new WeakMap}=t,r={...t,visited:n};if(n.has(e))return n.get(e);const s=[...e].map(e=>ye(e,r)),i=new w(s);return n.set(e,i),i})(e,t);if($(e))return ye(e,t);throw new me("Value provided to cloneDeep function couldn't be cloned",{value:e})};be.safe=e=>{try{return be(e)}catch{return e}};const ge=e=>{const{key:t,value:n}=e;return new E(t,n)},ve=e=>{const t=new(0,e.constructor);t.element=e.element,e.isMetaEmpty||(t.meta=be(e.meta)),e.isAttributesEmpty||(t.attributes=be(e.attributes)),se(e)&&V.transfer(e,t);const{content:n}=e;return $(n)?t.content=ve(n):Array.isArray(n)?t.content=[...n]:t.content=n instanceof E?ge(n):n,t},Ee=e=>{if(e instanceof E)return ge(e);if(e instanceof w)return(e=>{const t=[...e];return new w(t)})(e);if($(e))return ve(e);throw new pe("Value provided to cloneShallow function couldn't be cloned",{value:e})};function _e(e){return void 0===e?new x:we(e)}function we(e){if(e instanceof O)return e;if("string"==typeof e)return new j(e);if("number"==typeof e)return new z(e);if("boolean"==typeof e)return new L(e);if(null===e)return new x;if(Array.isArray(e))return new I(e.map(_e));if("object"==typeof e)return new R(e);throw new Error("Cannot refract value of type "+typeof e)}Ee.safe=e=>{try{return Ee(e)}catch{return e}},O.prototype.ObjectElement=R,O.prototype.ArrayElement=I,O.prototype.RefElement=N,O.prototype.MemberElement=K,O.prototype.refract=we;const ke=class extends j{constructor(e,t,n){super(e,t,n),this.element="annotation"}get code(){if(this.hasAttributesProperty("code"))return this.attributes.get("code")}set code(e){this.attributes.set("code",e)}};const Oe=class extends j{constructor(e,t,n){super(e,t,n),this.element="comment"}};const je=class extends I{constructor(e,t,n){super(e,t,n),this.element="parseResult"}get api(){return this.filter(e=>oe(e,["api"])).first}get results(){return this.filter(e=>oe(e,["result"]))}get result(){return this.results.first}get annotations(){return this.filter(e=>"annotation"===e.element)}get warnings(){return this.filter(e=>"annotation"===e.element&&oe(e,["warning"]))}get errors(){return this.filter(e=>"annotation"===e.element&&oe(e,["error"]))}get isEmpty(){return 0===this.reject(e=>"annotation"===e.element).length}replaceResult(e){const{result:t}=this;if(void 0===t)return!1;const n=this._content,r=n.findIndex(e=>e===t);return-1!==r&&(n[r]=e,!0)}},Ae=e=>e instanceof F,Me=e=>e instanceof N,Se=e=>e instanceof ke,Ce=e=>e instanceof Oe,Ve=e=>e instanceof je,Pe=e=>e instanceof V;return t})());
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.apidomDatamodel=t():e.apidomDatamodel=t()}(self,()=>(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function r(e){return function t(r){return 0===arguments.length||n(r)?t:e.apply(this,arguments)}}function s(e){return function t(s,i){switch(arguments.length){case 0:return t;case 1:return n(s)?t:r(function(t){return e(s,t)});default:return n(s)&&n(i)?t:n(s)?r(function(t){return e(t,i)}):n(i)?r(function(t){return e(s,t)}):e(s,i)}}}function i(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}function o(e,t,n){for(var r=0,s=n.length;r<s;){if(e(t,n[r]))return!0;r+=1}return!1}function a(e,t){return Object.prototype.hasOwnProperty.call(t,e)}e.r(t),e.d(t,{AnnotationElement:()=>ke,ArrayElement:()=>I,BooleanElement:()=>L,CloneError:()=>fe,CollectionElement:()=>D,CommentElement:()=>Oe,DeepCloneError:()=>me,Element:()=>O,JSONSerialiser:()=>P,KeyValuePair:()=>E,LinkElement:()=>F,MemberElement:()=>K,Namespace:()=>Q,NullElement:()=>x,NumberElement:()=>z,ObjectElement:()=>R,ObjectSlice:()=>w,ParseResultElement:()=>je,RefElement:()=>N,ShallowCloneError:()=>pe,SourceMapElement:()=>C,StringElement:()=>j,cloneDeep:()=>be,cloneShallow:()=>Ee,hasElementSourceMap:()=>se,includesClasses:()=>oe,includesSymbols:()=>ie,isAnnotationElement:()=>Se,isArrayElement:()=>ee,isBooleanElement:()=>Z,isCommentElement:()=>Ve,isElement:()=>$,isLinkElement:()=>Ae,isMemberElement:()=>ne,isNullElement:()=>Y,isNumberElement:()=>X,isObjectElement:()=>te,isParseResultElement:()=>Ce,isPrimitiveElement:()=>re,isRefElement:()=>Me,isSourceMapElement:()=>Pe,isStringElement:()=>H,refract:()=>we});const c="function"==typeof Object.is?Object.is:function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t};var u=Object.prototype.toString;const l=function(){return"[object Arguments]"===u.call(arguments)?function(e){return"[object Arguments]"===u.call(e)}:function(e){return a("callee",e)}}();var h=!{toString:null}.propertyIsEnumerable("toString"),f=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],m=function(){return arguments.propertyIsEnumerable("length")}(),p=function(e,t){for(var n=0;n<e.length;){if(e[n]===t)return!0;n+=1}return!1};const y="function"!=typeof Object.keys||m?r(function(e){if(Object(e)!==e)return[];var t,n,r=[],s=m&&l(e);for(t in e)!a(t,e)||s&&"length"===t||(r[r.length]=t);if(h)for(n=f.length-1;n>=0;)a(t=f[n],e)&&!p(r,t)&&(r[r.length]=t),n-=1;return r}):r(function(e){return Object(e)!==e?[]:Object.keys(e)});const d=r(function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});function b(e,t,n,r){var s=i(e);function a(e,t){return g(e,t,n.slice(),r.slice())}return!o(function(e,t){return!o(a,t,e)},i(t),s)}function g(e,t,n,r){if(c(e,t))return!0;var s,i,o=d(e);if(o!==d(t))return!1;if("function"==typeof e["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e);if("function"==typeof e.equals||"function"==typeof t.equals)return"function"==typeof e.equals&&e.equals(t)&&"function"==typeof t.equals&&t.equals(e);switch(o){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===(s=e.constructor,null==(i=String(s).match(/^function (\w*)/))?"":i[1]))return e===t;break;case"Boolean":case"Number":case"String":if(typeof e!=typeof t||!c(e.valueOf(),t.valueOf()))return!1;break;case"Date":if(!c(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(e.source!==t.source||e.global!==t.global||e.ignoreCase!==t.ignoreCase||e.multiline!==t.multiline||e.sticky!==t.sticky||e.unicode!==t.unicode)return!1}for(var u=n.length-1;u>=0;){if(n[u]===e)return r[u]===t;u-=1}switch(o){case"Map":return e.size===t.size&&b(e.entries(),t.entries(),n.concat([e]),r.concat([t]));case"Set":return e.size===t.size&&b(e.values(),t.values(),n.concat([e]),r.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var l=y(e);if(l.length!==y(t).length)return!1;var h=n.concat([e]),f=r.concat([t]);for(u=l.length-1;u>=0;){var m=l[u];if(!a(m,t)||!g(t[m],e[m],h,f))return!1;u-=1}return!0}const v=s(function(e,t){return g(e,t,[],[])});const E=class{key;value;constructor(e,t){this.key=e,this.value=t}toValue(){return{key:this.key?.toValue(),value:this.value?.toValue()}}};class _{elements;constructor(e){this.elements=e??[]}toValue(){return this.elements.map(e=>({key:e.key?.toValue(),value:e.value?.toValue()}))}map(e,t){return this.elements.map(n=>{const r=n.value,s=n.key;if(void 0===r||void 0===s)throw new Error("MemberElement must have both key and value");return void 0!==t?e.call(t,r,s,n):e(r,s,n)})}filter(e,t){const n=this.elements.filter(n=>{const r=n.value,s=n.key;return void 0!==r&&void 0!==s&&(void 0!==t?e.call(t,r,s,n):e(r,s,n))});return new _(n)}reject(e,t){const n=[];for(const r of this.elements){const s=r.value,i=r.key;void 0!==s&&void 0!==i&&(e.call(t,s,i,r)||n.push(r))}return new _(n)}forEach(e,t){this.elements.forEach((n,r)=>{const s=n.value,i=n.key;void 0!==s&&void 0!==i&&(void 0!==t?e.call(t,s,i,n,r):e(s,i,n,r))})}find(e,t){return this.elements.find(n=>{const r=n.value,s=n.key;return void 0!==r&&void 0!==s&&(void 0!==t?e.call(t,r,s,n):e(r,s,n))})}keys(){return this.elements.map(e=>e.key?.toValue()).filter(e=>void 0!==e)}values(){return this.elements.map(e=>e.value?.toValue()).filter(e=>void 0!==e)}get length(){return this.elements.length}get isEmpty(){return 0===this.length}get first(){return this.elements[0]}get(e){return this.elements[e]}push(e){return this.elements.push(e),this}includesKey(e){return this.elements.some(t=>t.key?.equals(e))}[Symbol.iterator](){return this.elements[Symbol.iterator]()}}const w=_;class k{parent;startLine;startCharacter;startOffset;endLine;endCharacter;endOffset;_storedElement="element";_content;_meta;_attributes;constructor(e,t,n){void 0!==t&&(this.meta=t),void 0!==n&&(this.attributes=n),void 0!==e&&(this.content=e)}get element(){return this._storedElement}set element(e){this._storedElement=e}get content(){return this._content}set content(e){if(e instanceof k)this._content=e;else if(null!=e&&"string"!=typeof e&&"number"!=typeof e&&"boolean"!=typeof e&&"bigint"!=typeof e&&"symbol"!=typeof e)if(e instanceof E)this._content=e;else if(e instanceof w)this._content=e.elements;else if(Array.isArray(e))this._content=e.map(e=>this.refract(e));else{if("object"!=typeof e)throw new Error("Cannot set content to value of type "+typeof e);this._content=Object.entries(e).map(([e,t])=>new this.MemberElement(e,t))}else this._content=e}get meta(){if(!this._meta){if(this.isFrozen){const e=new this.ObjectElement;return e.freeze(),e}this._meta=new this.ObjectElement}return this._meta}set meta(e){e instanceof k?this._meta=e:this.meta.set(e??{})}get attributes(){if(!this._attributes){if(this.isFrozen){const e=new this.ObjectElement;return e.freeze(),e}this._attributes=new this.ObjectElement}return this._attributes}set attributes(e){e instanceof k?this._attributes=e:this.attributes.set(e??{})}get id(){return this.getMetaProperty("id","")}set id(e){this.setMetaProperty("id",e)}get classes(){return this.getMetaProperty("classes",[])}set classes(e){this.setMetaProperty("classes",e)}get links(){return this.getMetaProperty("links",[])}set links(e){this.setMetaProperty("links",e)}get children(){const{_content:e}=this;if(Array.isArray(e))return e;if(e instanceof E){const t=[];return e.key&&t.push(e.key),e.value&&t.push(e.value),t}return e instanceof k?[e]:[]}get isFrozen(){return Object.isFrozen(this)}freeze(){if(!this.isFrozen){this._meta&&(this._meta.parent=this,this._meta.freeze()),this._attributes&&(this._attributes.parent=this,this._attributes.freeze());for(const e of this.children)e.parent=this,e.freeze();Array.isArray(this._content)&&Object.freeze(this._content),Object.freeze(this)}}toValue(){const{_content:e}=this;return e instanceof k||e instanceof E?e.toValue():Array.isArray(e)?e.map(e=>e.toValue()):e}equals(e){const t=e instanceof k?e.toValue():e;return v(this.toValue(),t)}primitive(){}set(e){return this.content=e,this}toRef(e){const t=this.id.toValue();if(""===t)throw new Error("Cannot create reference to an element without an ID");const n=new this.RefElement(t);return"string"==typeof e&&(n.path=this.refract(e)),n}getMetaProperty(e,t){if(!this.meta.hasKey(e)){if(this.isFrozen){const e=this.refract(t);return e.freeze(),e}this.meta.set(e,t)}return this.meta.get(e)}setMetaProperty(e,t){this.meta.set(e,t)}hasMetaProperty(e){return!this.isMetaEmpty&&this.meta.hasKey(e)}get isMetaEmpty(){return void 0===this._meta||this.meta.isEmpty}getAttributesProperty(e,t){if(!this.hasAttributesProperty(e)){if(this.isFrozen){const e=this.refract(t);return e.freeze(),e}this.attributes.set(e,t)}return this.attributes.get(e)}setAttributesProperty(e,t){this.attributes.set(e,t)}hasAttributesProperty(e){return!this.isAttributesEmpty&&this.attributes.hasKey(e)}get isAttributesEmpty(){return void 0===this._attributes||this.attributes.isEmpty}}const O=k;const j=class extends O{constructor(e,t,n){super(e,t,n),this.element="string"}primitive(){return"string"}get length(){return this.content?.length??0}};class A extends j{constructor(e,t,n){super(e,t,n),this.element="sourceMap"}static transfer(e,t){t.startLine=e.startLine,t.startCharacter=e.startCharacter,t.startOffset=e.startOffset,t.endLine=e.endLine,t.endCharacter=e.endCharacter,t.endOffset=e.endOffset}static from(e){const{startLine:t,startCharacter:n,startOffset:r,endLine:s,endCharacter:i,endOffset:o}=e;if("number"!=typeof t||"number"!=typeof n||"number"!=typeof r||"number"!=typeof s||"number"!=typeof i||"number"!=typeof o)return;const a="sm1:"+[t,n,r,s,i,o].map(S).join("");const c=new A(a);return c.startLine=t,c.startCharacter=n,c.startOffset=r,c.endLine=s,c.endCharacter=i,c.endOffset=o,c}applyTo(e){this.content&&([e.startLine,e.startCharacter,e.startOffset,e.endLine,e.endCharacter,e.endOffset]=function(e){const t=e.startsWith("sm1:")?e.slice(4):e,n=[];let r=0;for(let e=0;e<6;e++){const e=V(t,r);n.push(e.value),r=e.next}return n}(this.content))}}const M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function S(e){let t=e>>>0,n="";do{let e=31&t;t>>>=5,0!==t&&(e|=32),n+=M[e]}while(0!==t);return n}function V(e,t=0){let n=0,r=0,s=t;for(;;){const t=e[s++],i=M.indexOf(t);if(-1===i)throw new Error(`Invalid Base64 VLQ char: ${t}`);if(n|=(31&i)<<r,r+=5,!!!(32&i))break}return{value:n>>>0,next:s}}const C=A;const P=class{namespace;constructor(e){this.namespace=e||new this.Namespace}serialise(e){if(!(e instanceof this.namespace.elements.Element))throw new TypeError(`Given element \`${e}\` is not an Element instance`);const t={element:e.element};if(e.isMetaEmpty||(t.meta=this.serialiseObject(e.meta)),e.isAttributesEmpty||(t.attributes=this.serialiseObject(e.attributes)),!(e instanceof C)){const n=C.from(e);n&&(t.meta||(t.meta={}),t.meta.__mappings__=this.serialise(n))}const n=this.serialiseContent(e.content);return void 0!==n&&(t.content=n),t}deserialise(e){if(!e.element)throw new Error("Given value is not an object containing an element name");const t=new(this.namespace.getElementClass(e.element));let n;t.element!==e.element&&(t.element=e.element);let r=e.meta;if(e.meta?.__mappings__){const{__mappings__:t,...s}=e.meta;n=t,r=Object.keys(s).length>0?s:void 0}if(r&&this.deserialiseObject(r,t.meta),n){this.deserialise(n).applyTo(t)}e.attributes&&this.deserialiseObject(e.attributes,t.attributes);const s=this.deserialiseContent(e.content);return void 0===s&&null!==t.content||(t.content=s),t}serialiseContent(e){if(e instanceof this.namespace.elements.Element)return this.serialise(e);if(e instanceof this.namespace.KeyValuePair){const t=e,n={key:this.serialise(t.key)};return t.value&&(n.value=this.serialise(t.value)),n}if(e&&Array.isArray(e)){if(0===e.length)return;return e.map(e=>this.serialise(e))}return e}deserialiseContent(e){if(e){if(e.element)return this.deserialise(e);if(e.key){const t=new this.namespace.KeyValuePair(this.deserialise(e.key));return e.value&&(t.value=this.deserialise(e.value)),t}if(Array.isArray(e))return e.map(e=>this.deserialise(e))}return e}serialiseObject(e){const t={};if(e.forEach((e,n)=>{e&&(t[n.toValue()]=this.serialise(e))}),0!==Object.keys(t).length)return t}deserialiseObject(e,t){Object.keys(e).forEach(n=>{t.set(n,this.deserialise(e[n]))})}};const x=class extends O{constructor(e,t,n){super(e??null,t,n),this.element="null"}primitive(){return"null"}set(e){throw new Error("Cannot set the value of null")}};const z=class extends O{constructor(e,t,n){super(e,t,n),this.element="number"}primitive(){return"number"}};const L=class extends O{constructor(e,t,n){super(e,t,n),this.element="boolean"}primitive(){return"boolean"}};class q extends O{constructor(e,t,n){super(e||[],t,n)}get length(){return this._content.length}get isEmpty(){return 0===this.length}get first(){return this._content[0]}get second(){return this._content[1]}get last(){return this._content.at(-1)}push(...e){for(const t of e)this._content.push(this.refract(t));return this}shift(){return this._content.shift()}unshift(e){this._content.unshift(this.refract(e))}includes(e){return this._content.some(t=>t.equals(e))}findElements(e,t){const n=t||{},r=!!n.recursive,s=void 0===n.results?[]:n.results;for(let t=0;t<this._content.length;t+=1){const n=this._content[t],i=n;r&&"function"==typeof i.findElements&&i.findElements(e,{results:s,recursive:r}),e(n,t,void 0)&&s.push(n)}return s}find(e){const t=this.findElements(e,{recursive:!0});return new this.ArrayElement(t)}findByElement(e){return this.find(t=>t.element===e)}findByClass(e){return this.find(t=>{const n=t.classes;return"function"==typeof n.includes&&n.includes(e)})}getById(e){return this.find(t=>t.id.toValue()===e).first}concat(e){return new(0,this.constructor)(this._content.concat(e._content))}[Symbol.iterator](){return this._content[Symbol.iterator]()}}const D=q;const I=class extends D{constructor(e,t,n){super(e||[],t,n),this.element="array"}primitive(){return"array"}get(e){return this._content[e]}getValue(e){const t=this.get(e);if(t)return t.toValue()}set(e,t){return"number"==typeof e&&void 0!==t?this._content[e]=this.refract(t):this.content=e,this}remove(e){return this._content.splice(e,1)[0]??null}map(e,t){return this._content.map(e,t)}flatMap(e,t){return this._content.flatMap(e,t)}compactMap(e,t){const n=[];for(const r of this._content){const s=e.call(t,r);s&&n.push(s)}return n}filter(e,t){const n=this._content.filter(e,t);return new this.constructor(n)}reject(e,t){const n=[];for(const r of this._content)e.call(t,r)||n.push(r);return new this.constructor(n)}reduce(e,t){let n,r;void 0!==t?(n=0,r=this.refract(t)):(n=1,r=this.first);for(let t=n;t<this.length;t+=1){const n=e(r,this._content[t],t,this);r=void 0===n?n:this.refract(n)}return r}forEach(e,t){this._content.forEach((n,r)=>{e.call(t,n,r)})}empty(){return new this.constructor([])}};const K=class extends O{constructor(e,t,n,r){super(new E,n,r),this.element="member",void 0!==e&&(this.key=e),arguments.length>=2&&(this.value=t)}primitive(){return"member"}get key(){return this._content.key}set key(e){this._content.key=this.refract(e)}get value(){return this._content.value}set value(e){this._content.value=void 0===e?void 0:this.refract(e)}};const R=class extends D{constructor(e,t,n){super(e||[],t,n),this.element="object"}primitive(){return"object"}toValue(){return this._content.reduce((e,t)=>(e[t.key.toValue()]=t.value?t.value.toValue():void 0,e),{})}get(e){const t=this.getMember(e);if(t)return t.value}getValue(e){const t=this.get(e);if(t)return t.toValue()}getMember(e){if(void 0!==e)return this._content.find(t=>t.key.toValue()===e)}remove(e){let t=null;return this.content=this._content.filter(n=>n.key.toValue()!==e||(t=n,!1)),t}getKey(e){const t=this.getMember(e);if(t)return t.key}set(e,t){if("string"==typeof e){const n=this.getMember(e);n?n.value=t:this._content.push(new K(e,t))}else if("object"==typeof e&&!Array.isArray(e))for(const t of Object.keys(e))this.set(t,e[t]);return this}keys(){return this._content.map(e=>e.key.toValue())}values(){return this._content.map(e=>e.value.toValue())}hasKey(e){return this._content.some(t=>t.key.equals(e))}items(){return this._content.map(e=>[e.key.toValue(),e.value.toValue()])}map(e,t){return this._content.map(n=>e.call(t,n.value,n.key,n))}compactMap(e,t){const n=[];return this.forEach((r,s,i)=>{const o=e.call(t,r,s,i);o&&n.push(o)}),n}filter(e,t){return new w(this._content).filter(e,t)}reject(e,t){const n=[];for(const r of this._content)e.call(t,r.value,r.key,r)||n.push(r);return new w(n)}forEach(e,t){this._content.forEach(n=>e.call(t,n.value,n.key,n))}reduce(e,t){let n,r;void 0!==t?(n=0,r=this.refract(t)):(n=1,r=this._content[0]?.value);for(let t=n;t<this._content.length;t+=1){const n=this._content[t],s=e(r,n.value,n.key,n,this);r=void 0===s?s:this.refract(s)}return r}empty(){return new this.constructor([])}};const N=class extends O{constructor(e,t,n){super(e||[],t,n),this.element="ref",this.path||(this.path="element")}get path(){if(this.hasAttributesProperty("path"))return this.attributes.get("path")}set path(e){this.attributes.set("path",e)}};const F=class extends O{constructor(e,t,n){super(e||[],t,n),this.element="link"}get relation(){if(this.hasAttributesProperty("relation"))return this.attributes.get("relation")}set relation(e){this.attributes.set("relation",e)}get href(){if(this.hasAttributesProperty("href"))return this.attributes.get("href")}set href(e){this.attributes.set("href",e)}},B=e=>null===e,T=e=>"string"==typeof e,U=e=>"number"==typeof e,W=e=>"boolean"==typeof e,G=e=>null!==e&&"object"==typeof e;class J{elementMap={};elementDetection=[];Element;KeyValuePair;_elements;_attributeElementKeys=[];_attributeElementArrayKeys=[];constructor(e){this.Element=O,this.KeyValuePair=E,e&&e.noDefault||this.useDefault()}use(e){return e.namespace&&e.namespace({base:this}),e.load&&e.load({base:this}),this}useDefault(){return this.register("null",x).register("string",j).register("number",z).register("boolean",L).register("array",I).register("object",R).register("member",K).register("ref",N).register("link",F).register("sourceMap",C),this.detect(B,x,!1).detect(T,j,!1).detect(U,z,!1).detect(W,L,!1).detect(Array.isArray,I,!1).detect(G,R,!1),this}register(e,t){return this._elements=void 0,this.elementMap[e]=t,this}unregister(e){return this._elements=void 0,delete this.elementMap[e],this}detect(e,t,n){return void 0===n||n?this.elementDetection.unshift([e,t]):this.elementDetection.push([e,t]),this}toElement(e){if(e instanceof this.Element)return e;let t;for(const[n,r]of this.elementDetection)if(n(e)){t=new r(e);break}return t}getElementClass(e){const t=this.elementMap[e];return void 0===t?this.Element:t}fromRefract(e){return this.serialiser.deserialise(e)}toRefract(e){return this.serialiser.serialise(e)}get elements(){return void 0===this._elements&&(this._elements={Element:this.Element},Object.keys(this.elementMap).forEach(e=>{const t=e[0].toUpperCase()+e.substring(1);this._elements[t]=this.elementMap[e]})),this._elements}get serialiser(){return new P(this)}}P.prototype.Namespace=J;const Q=J,$=e=>e instanceof O,H=e=>e instanceof j,X=e=>e instanceof z,Y=e=>e instanceof x,Z=e=>e instanceof L,ee=e=>e instanceof I,te=e=>e instanceof R,ne=e=>e instanceof K,re=e=>te(e)&&"object"===e.element||ee(e)&&"array"===e.element||Z(e)&&"boolean"===e.element||X(e)&&"number"===e.element||H(e)&&"string"===e.element||Y(e)&&"null"===e.element||ne(e)&&"member"===e.element,se=e=>"number"==typeof e.startLine&&"number"==typeof e.startCharacter&&"number"==typeof e.startOffset&&"number"==typeof e.endLine&&"number"==typeof e.endCharacter&&"number"==typeof e.endOffset,ie=(e,t)=>{if(0===t.length)return!0;if(!e.hasAttributesProperty("symbols"))return!1;const n=e.attributes.get("symbols");return!!ee(n)&&t.every(e=>n.includes(e))},oe=(e,t)=>0===t.length||!!$(e)&&(!e.isMetaEmpty&&(!!e.hasMetaProperty("classes")&&t.every(t=>e.classes.includes(t))));class ae extends AggregateError{constructor(e,t,n){super(e,t,n),this.name=this.constructor.name,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}const ce=ae;class ue extends Error{static[Symbol.hasInstance](e){return super[Symbol.hasInstance](e)||Function.prototype[Symbol.hasInstance].call(ce,e)}constructor(e,t){super(e,t),this.name=this.constructor.name,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}const le=ue;const he=class extends le{constructor(e,t){if(super(e,t),null!=t&&"object"==typeof t){const{cause:e,...n}=t;Object.assign(this,n)}}};const fe=class extends he{value;constructor(e,t){super(e,t),void 0!==t&&(this.value=t.value)}};const me=class extends fe{};const pe=class extends fe{},ye=(e,t)=>{const{visited:n=new WeakMap}=t,r={...t,visited:n};if(n.has(e))return n.get(e);const s=ve(e);n.set(e,s);const{content:i}=e;return Array.isArray(i)?s.content=i.map(e=>ye(e,r)):$(i)?s.content=ye(i,r):s.content=i instanceof E?de(i,r):i,s},de=(e,t)=>{const{visited:n=new WeakMap}=t,r={...t,visited:n};if(n.has(e))return n.get(e);const{key:s,value:i}=e,o=void 0!==s?ye(s,r):void 0,a=void 0!==i?ye(i,r):void 0,c=new E(o,a);return n.set(e,c),c},be=(e,t={})=>{if(e instanceof E)return de(e,t);if(e instanceof w)return((e,t)=>{const{visited:n=new WeakMap}=t,r={...t,visited:n};if(n.has(e))return n.get(e);const s=[...e].map(e=>ye(e,r)),i=new w(s);return n.set(e,i),i})(e,t);if($(e))return ye(e,t);throw new me("Value provided to cloneDeep function couldn't be cloned",{value:e})};be.safe=e=>{try{return be(e)}catch{return e}};const ge=e=>{const{key:t,value:n}=e;return new E(t,n)},ve=e=>{const t=new(0,e.constructor);t.element=e.element,e.isMetaEmpty||(t.meta=be(e.meta)),e.isAttributesEmpty||(t.attributes=be(e.attributes)),se(e)&&C.transfer(e,t);const{content:n}=e;return $(n)?t.content=ve(n):Array.isArray(n)?t.content=[...n]:t.content=n instanceof E?ge(n):n,t},Ee=e=>{if(e instanceof E)return ge(e);if(e instanceof w)return(e=>{const t=[...e];return new w(t)})(e);if($(e))return ve(e);throw new pe("Value provided to cloneShallow function couldn't be cloned",{value:e})};function _e(e){return void 0===e?new x:we(e)}function we(e){if(e instanceof O)return e;if("string"==typeof e)return new j(e);if("number"==typeof e)return new z(e);if("boolean"==typeof e)return new L(e);if(null===e)return new x;if(Array.isArray(e))return new I(e.map(_e));if("object"==typeof e)return new R(e);throw new Error("Cannot refract value of type "+typeof e)}Ee.safe=e=>{try{return Ee(e)}catch{return e}},O.prototype.ObjectElement=R,O.prototype.ArrayElement=I,O.prototype.RefElement=N,O.prototype.MemberElement=K,O.prototype.refract=we;const ke=class extends j{constructor(e,t,n){super(e,t,n),this.element="annotation"}get code(){if(this.hasAttributesProperty("code"))return this.attributes.get("code")}set code(e){this.attributes.set("code",e)}};const Oe=class extends j{constructor(e,t,n){super(e,t,n),this.element="comment"}};const je=class extends I{constructor(e,t,n){super(e,t,n),this.element="parseResult"}get api(){return this.filter(e=>oe(e,["api"])).first}get results(){return this.filter(e=>oe(e,["result"]))}get result(){return this.results.first}get annotations(){return this.filter(e=>"annotation"===e.element)}get warnings(){return this.filter(e=>"annotation"===e.element&&oe(e,["warning"]))}get errors(){return this.filter(e=>"annotation"===e.element&&oe(e,["error"]))}get isEmpty(){return 0===this.reject(e=>"annotation"===e.element).length}replaceResult(e){const{result:t}=this;if(void 0===t)return!1;const n=this._content,r=n.findIndex(e=>e===t);return-1!==r&&(n[r]=e,!0)}},Ae=e=>e instanceof F,Me=e=>e instanceof N,Se=e=>e instanceof ke,Ve=e=>e instanceof Oe,Ce=e=>e instanceof je,Pe=e=>e instanceof C;return t})());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-datamodel",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Data model primitives for ApiDOM.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@babel/runtime-corejs3": "^7.28.4",
|
|
42
|
-
"@speclynx/apidom-error": "^2.
|
|
42
|
+
"@speclynx/apidom-error": "^2.2.0",
|
|
43
43
|
"ramda": "~0.32.0"
|
|
44
44
|
},
|
|
45
45
|
"files": [
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"README.md",
|
|
53
53
|
"CHANGELOG.md"
|
|
54
54
|
],
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "a3bfd57f83437ee123f2ef3175aedf30dd860b67"
|
|
56
56
|
}
|
|
@@ -356,7 +356,8 @@ class Element {
|
|
|
356
356
|
* Checks deep equality with another value.
|
|
357
357
|
*/
|
|
358
358
|
equals(value) {
|
|
359
|
-
|
|
359
|
+
const compareTo = value instanceof Element ? value.toValue() : value;
|
|
360
|
+
return (0, _ramda.equals)(this.toValue(), compareTo);
|
|
360
361
|
}
|
|
361
362
|
|
|
362
363
|
// ============================================================
|
|
@@ -350,7 +350,8 @@ class Element {
|
|
|
350
350
|
* Checks deep equality with another value.
|
|
351
351
|
*/
|
|
352
352
|
equals(value) {
|
|
353
|
-
|
|
353
|
+
const compareTo = value instanceof Element ? value.toValue() : value;
|
|
354
|
+
return equals(this.toValue(), compareTo);
|
|
354
355
|
}
|
|
355
356
|
|
|
356
357
|
// ============================================================
|