@blue-labs/language 1.34.0 → 1.35.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/dist/index.js +5 -5
- package/dist/index.mjs +113 -107
- package/dist/lib/utils/NodeTypes.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ss=Object.defineProperty;var rs=(r,e,t)=>e in r?ss(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var p=(r,e,t)=>rs(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("big.js"),c=require("@blue-labs/shared-utils"),u=require("zod"),ns=require("bs58"),C=require("radash"),is=require("js-sha256"),os=require("crypto"),ls=require("base32.js"),k=require("js-yaml"),lt=r=>r&&r.__esModule?r:{default:r},ae=lt(ns),Ee=lt(os);class w extends x{constructor(e){super(e)}}class T extends x{constructor(e){super(e)}}class as{static get(e,t,s,n=!0){if(c.isNullable(t)||!t.startsWith("/"))throw new Error(`Invalid path: ${t}`);if(t==="/"){const o=e.getValue();return n&&o!==void 0?o:e}const i=t.substring(1).split("/");return this.getRecursive(e,i,0,s,n)}static getRecursive(e,t,s,n,i){if(s===t.length-1&&!i)return this.getNodeForSegment(e,t[s],n,!1);if(s===t.length){const a=e.getValue();return i&&a!==void 0?a:e}const o=t[s],l=this.getNodeForSegment(e,o,n,!0);if(l)return this.getRecursive(l,t,s+1,n,i)}static getNodeForSegment(e,t,s,n){let i;const o=e.getProperties();if(o&&t in o)i=o[t];else switch(t){case"name":{const l=e.getName();i=new d().setValue(l??null);break}case"description":{const l=e.getDescription();i=new d().setValue(l??null);break}case"type":i=e.getType();break;case"itemType":i=e.getItemType();break;case"keyType":i=e.getKeyType();break;case"valueType":i=e.getValueType();break;case"value":{const l=e.getValue();i=new d().setValue(l??null);break}case"blueId":{const l=e.getBlueId();i=new d().setValue(l??null);break}case"blue":i=e.getBlue();break;case"items":{const l=e.getItems();i=new d().setItems(l);break}case"properties":{const l=e.getProperties();i=new d().setProperties(l);break}case"contracts":{const l=e.getContracts();i=new d().setContracts(l);break}default:{if(/^\d+$/.test(t)){const l=parseInt(t,10),a=e.getItems();a&&l>=0&&l<a.length?i=a[l]:i=void 0}else i=void 0;break}}if(i)return n&&s?this.link(i,s):i}static link(e,t){const s=t(e);return c.isNonNullable(s)?s:e}}const q="name",X="description",fe="type",ke="itemType",Ye="keyType",Je="valueType",Ne="value",Ke="items",_="blueId",Ge="blue",cs=[q,X,fe,ke,Ye,Je,Ne,Ke,_,Ge],us="Text",ds="Double",hs="Integer",ps="Boolean",fs="List",gs="Dictionary",We=[us,ds,hs,ps],at=[...We,fs,gs],Y="F92yo19rCcbBoBSpUA5LRxpfDejJDAaP1PRxxbWAraVP",J="68ryJtnmui4j5rCZWUnkZ3DChtmEb7Z9F8atn1mBSM3L",K="DHmxTkFbXePZHCHCYmQr2dSzcNLcryFVjXVHkdQrrZr8",G="EL6AjrbJsxTWRTPzY8WR8Y2zAMXRbydQj83PcZwuAHbo",ct="G8wmfjEqugPEEXByMYWJXiEdbLToPRWNQEekNxrxfQWB",ut="294NBTj2mFRL3RB4kDRUSckwGg7Kzj6T8CTAFeR1kcSA",dt=[Y,J,K,G],de=[...dt,ct,ut];Object.fromEntries(at.map((r,e)=>[r,de[e]]));const ys=Object.fromEntries(de.map((r,e)=>[r,at[e]])),E=class E{constructor(e){p(this,"name");p(this,"description");p(this,"type");p(this,"itemType");p(this,"keyType");p(this,"valueType");p(this,"value");p(this,"items");p(this,"properties");p(this,"blueId");p(this,"blue");p(this,"inlineValue",!1);this.name=e}getName(){return this.name}setName(e){return this.name=e,this}getDescription(){return this.description}setDescription(e){return this.description=e,this}getType(){return this.type}setType(e){return typeof e=="string"?this.type=new E().setValue(e).setInlineValue(!0):this.type=e,this}getItemType(){return this.itemType}setItemType(e){return typeof e=="string"?this.itemType=new E().setValue(e).setInlineValue(!0):this.itemType=e,this}getKeyType(){return this.keyType}setKeyType(e){return typeof e=="string"?this.keyType=new E().setValue(e).setInlineValue(!0):this.keyType=e,this}getValueType(){return this.valueType}setValueType(e){return typeof e=="string"?this.valueType=new E().setValue(e).setInlineValue(!0):this.valueType=e,this}getValue(){var t;const e=(t=this.type)==null?void 0:t.getBlueId();if(c.isNonNullable(e)&&c.isNonNullable(this.value)){if(e===K&&typeof this.value=="string")return new T(this.value);if(e===J&&typeof this.value=="string"){const s=new w(this.value),n=parseFloat(s.toString());return new w(n.toString())}else if(e===G&&typeof this.value=="string")return this.value.toLowerCase()==="true"}return this.value}setValue(e){return typeof e=="number"?e%1===0?this.value=new T(e.toString()):this.value=new w(e.toString()):this.value=e,this}getItems(){return this.items}setItems(e){return this.items=e,this}addItems(...e){return this.items||(this.items=[]),this.items.push(...e),this}getProperties(){return this.properties}setProperties(e){return this.properties=e,this}addProperty(e,t){return this.properties||(this.properties={}),this.properties[e]=t,this}removeProperty(e){return this.properties&&delete this.properties[e],this}getContractsProperty(){var e;return(e=this.properties)==null?void 0:e.contracts}getContracts(){var e;return(e=this.getContractsProperty())==null?void 0:e.getProperties()}setContracts(e){return c.isNullable(e)?this.removeProperty("contracts"):this.addProperty("contracts",new E().setProperties(e)),this}addContract(e,t){const s=this.getContractsProperty();return c.isNullable(s)?this.addProperty("contracts",new E().addProperty(e,t)):s.addProperty(e,t),this}removeContract(e){const t=this.getContractsProperty();if(t){t.removeProperty(e);const s=t.getProperties();s&&Object.keys(s).length===0&&this.removeProperty("contracts")}return this}getBlueId(){return this.blueId}setBlueId(e){return this.blueId=e,this}getBlue(){return this.blue}setBlue(e){return this.blue=e,this}isInlineValue(){return this.inlineValue}setInlineValue(e){return this.inlineValue=e,this}isResolved(){return!1}get(e,t){return as.get(this,e,t)}getAsNode(e){const t=this.get(e);if(t instanceof E)return t;throw new Error(`Value at path ${e} is not a BlueNode: ${t}`)}getAsInteger(e){const t=this.get(e);if(t instanceof T||t instanceof w)return t.toNumber();throw new Error(`Value at path ${e} is not a BigInteger or BigDecimal: ${t}`)}clone(){var t,s,n,i,o,l;const e=new E(this.name);return e.description=this.description,e.type=(t=this.type)==null?void 0:t.clone(),e.itemType=(s=this.itemType)==null?void 0:s.clone(),e.keyType=(n=this.keyType)==null?void 0:n.clone(),e.valueType=(i=this.valueType)==null?void 0:i.clone(),e.value=this.value,e.items=(o=this.items)==null?void 0:o.map(a=>a.clone()),this.properties&&(e.properties=Object.fromEntries(Object.entries(this.properties).map(([a,h])=>[a,h.clone()]))),e.blueId=this.blueId,e.blue=(l=this.blue)==null?void 0:l.clone(),e.inlineValue=this.inlineValue,e}toString(){return`BlueNode{name='${this.name}', description='${this.description}', type=${this.type}, itemType=${this.itemType}, keyType=${this.keyType}, valueType=${this.valueType}, value=${this.value}, items=${this.items}, properties=${this.properties}, blueId='${this.blueId}', blue=${this.blue}, inlineValue=${this.inlineValue}}`}};p(E,"INTEGER",new E("Integer"));let d=E;class Z{static isPotentialBlueId(e){if(!e||e.length===0||!this.BLUE_ID_PATTERN.test(e))return!1;const t=e.split("#"),s=t[0],n=s.length;if(n<this.MIN_BLUE_ID_LENGTH||n>this.MAX_BLUE_ID_LENGTH)return!1;try{if(ae.default.decode(s).length!==32)return!1}catch{return!1}if(t.length>1)try{if(Number(t[1])<0)return!1}catch{return!1}return!0}}p(Z,"MIN_BLUE_ID_LENGTH",41),p(Z,"MAX_BLUE_ID_LENGTH",45),p(Z,"BLUE_ID_PATTERN",/^[1-9A-HJ-NP-Za-km-z]{41,45}(?:#\d+)?$/);const ms=u.z.string().max(Z.MAX_BLUE_ID_LENGTH,{message:"Blue Id has a maximum length of 45 characters"}).min(Z.MIN_BLUE_ID_LENGTH,{message:"Blue Id has a minimum length of 41 characters"}).refine(r=>{try{return ae.default.decode(r),!0}catch{return!1}},{message:"Blue Id must be a valid Base58 string"}),Q=u.z.lazy(()=>u.z.record(u.z.unknown()).and(u.z.object({blueId:u.z.string().optional(),name:u.z.string().optional(),description:u.z.string().optional(),type:Q.optional(),value:u.z.union([u.z.string(),u.z.number(),u.z.boolean()]).optional().nullable(),items:u.z.array(Q).optional()}))),he=u.z.object({blueId:u.z.string().optional(),name:u.z.string().optional(),description:u.z.string().optional(),type:Q.optional()}),Is=he.extend({value:u.z.string().optional()}),bs=he.extend({value:u.z.number().optional()}),Ns=he.extend({value:u.z.boolean().optional()}),Ts=he.extend({items:u.z.array(u.z.string()).optional()}),vs=r=>Q.safeParse(r).success,ht=r=>c.isNonNullable(r)&&"blueId"in r&&c.isNonNullable(r.blueId),Bs=r=>c.isNonNullable(r)&&"name"in r&&c.isNonNullable(r.name),pt=r=>c.isNonNullable(r)&&"items"in r&&c.isNonNullable(r.items),ft=r=>c.isNonNullable(r)&&"type"in r&&c.isNonNullable(r.type),gt=r=>c.isNonNullable(r)&&"value"in r&&c.isNonNullable(r.value),ws=(r,e)=>r.required({type:!0}).safeParse(e).success,S=r=>r instanceof x,$=r=>S(r)&&r instanceof T,ge=r=>S(r)&&r instanceof w,Ps=u.z.lazy(()=>u.z.record(ce)),Ss=u.z.lazy(()=>u.z.union([u.z.array(ce),u.z.array(ce).readonly()])),ce=u.z.lazy(()=>u.z.union([c.jsonPrimitiveSchema,Ps,Ss,u.z.instanceof(x)])),He=r=>C.isObject(r)&&!C.isArray(r)&&!c.isReadonlyArray(r)&&!S(r),qe=r=>C.isArray(r)||c.isReadonlyArray(r),Es=r=>qe(r)||He(r)||S(r)||c.isJsonPrimitive(r);class y{static deserialize(e){return y.handleNode(e)}static handleNode(e){if(e===void 0)throw new Error("This is not a valid JSON-like value. Found 'undefined' as a value.");if(He(e)){const t=new d,s={};return Object.entries(e).forEach(([n,i])=>{switch(n){case q:if(i==null)t.setName(void 0);else{if(typeof i!="string")throw new Error(`The ${q} field must be a string.`);t.setName(i)}break;case X:if(i==null)t.setDescription(void 0);else{if(typeof i!="string")throw new Error(`The ${X} field must be a string.`);t.setDescription(i)}break;case fe:t.setType(y.handleNode(i));break;case ke:t.setItemType(y.handleNode(i));break;case Ye:t.setKeyType(y.handleNode(i));break;case Je:t.setValueType(y.handleNode(i));break;case Ne:t.setValue(y.handleValue(i));break;case _:if(typeof i!="string")throw new Error(`The ${_} field must be a string.`);t.setBlueId(i);break;case Ke:t.setItems(y.handleArray(i));break;case Ge:t.setBlue(y.handleNode(i));break;default:s[n]=y.handleNode(i);break}}),Object.keys(s).length>0&&t.setProperties(s),t}else{if(qe(e))return new d().setItems(y.handleArray(e));{const t=e;return new d().setValue(y.handleValue(t)).setInlineValue(!0)}}}static handleValue(e){if(e==null)return null;if(typeof e=="string")return e;if(typeof e=="number"||S(e))if($(e)||Number.isSafeInteger(e)){const t=new T(e.toString()),s=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER;return t.lt(s)?new T(s.toString()):t.gt(n)?new T(n.toString()):t}else{const t=parseFloat(e.toString());return new w(t.toString())}else if(typeof e=="boolean")return e;throw new Error(`Can't handle node: ${JSON.stringify(e)}`)}static handleArray(e){if(e!=null){if(C.isObject(e)&&!Array.isArray(e))return[y.handleNode(e)];if(Array.isArray(e))return e.map(y.handleNode);throw new Error("Expected an array node")}}}function As(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ae,nt;function Cs(){return nt||(nt=1,Ae=function r(e){if(typeof e=="number"&&isNaN(e))throw new Error("NaN is not allowed");if(typeof e=="number"&&!isFinite(e))throw new Error("Infinity is not allowed");return e===null||typeof e!="object"?JSON.stringify(e):e.toJSON instanceof Function?r(e.toJSON()):Array.isArray(e)?`[${e.reduce((n,i,o)=>`${n}${o===0?"":","}${r(i===void 0||typeof i=="symbol"?null:i)}`,"")}]`:`{${Object.keys(e).sort().reduce((s,n)=>{if(e[n]===void 0||typeof e[n]=="symbol")return s;const i=s.length===0?"":",";return`${s}${i}${r(n)}:${r(e[n])}`},"")}}`}),Ae}var Vs=Cs();const Ds=As(Vs);class yt{static canonicalize(e){return Ds(e)}}const Ce=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,me=class me{constructor(){p(this,"browserCrypto");this.browserCrypto=this.initBrowserCrypto()}static getInstance(){return this.instance||(this.instance=new me),this.instance}initBrowserCrypto(){return Ce?null:"crypto"in globalThis?globalThis.crypto:null}hasNodeCrypto(){return Ce&&!!Ee.default&&typeof Ee.default.createHash=="function"}getBrowserCrypto(){return this.browserCrypto}getNodeCrypto(){return Ce?Ee.default:null}};p(me,"instance");let Re=me;class mt{constructor(){p(this,"cryptoEnv",Re.getInstance())}applySync(e){const t=this.canonicalizeInput(e),s=this.cryptoEnv.hasNodeCrypto()?this.sha256Sync(t):this.sha256SyncBrowser(t);return ae.default.encode(new Uint8Array(s))}async apply(e){const t=this.canonicalizeInput(e),s=this.cryptoEnv.hasNodeCrypto()?this.sha256Sync(t):await this.sha256Async(t);return ae.default.encode(new Uint8Array(s))}canonicalizeInput(e){const t=yt.canonicalize(e);if(typeof t!="string")throw new Error("Canonized value must be a string");return t}sha256Sync(e){const t=this.cryptoEnv.getNodeCrypto();if(!t)throw new Error("Synchronous SHA-256 is not available in this environment");return t.createHash("sha256").update(e).digest()}sha256SyncBrowser(e){return is.sha256.arrayBuffer(e)}async sha256Async(e){if(this.cryptoEnv.hasNodeCrypto())return this.sha256Sync(e);const t=this.cryptoEnv.getBrowserCrypto();if(!t)throw new Error("crypto is not available in this environment");const n=new TextEncoder().encode(e);return t.subtle.digest("SHA-256",n)}}class b{static get(e,t="official"){var rt;const s=e.getValue(),n=this.handleValue(s);if(n!==void 0&&t==="simple")return n;const i=(rt=e.getItems())==null?void 0:rt.map(H=>b.get(H,t));if(i!==void 0&&t==="simple")return i;const o=e.getName(),l=e.getDescription();if(t==="original"&&o===void 0&&l===void 0){if(n!==void 0)return n;if(i!==void 0)return i}const a={};o!==void 0&&(a[q]=o),l!==void 0&&(a[X]=l);const h=e.getType();if(t==="official"&&s!==void 0&&h===void 0){const H=this.inferTypeBlueId(s);H!==null&&(a[fe]={[_]:H})}else h!==void 0&&(a[fe]=b.get(h,t));const I=e.getItemType();I!==void 0&&(a[ke]=b.get(I,t));const m=e.getKeyType();m!==void 0&&(a[Ye]=b.get(m,t));const f=e.getValueType();f!==void 0&&(a[Je]=b.get(f,t)),n!==void 0&&(a[Ne]=n),i!==void 0&&(a[Ke]=i);const g=e.getBlueId();g!==void 0&&(a[_]=g);const O=e.getBlue();O!==void 0&&(a[Ge]=O);const W=e.getProperties();return W!==void 0&&Object.entries(W).forEach(([H,ts])=>{a[H]=b.get(ts,t)}),a}static handleValue(e){if(S(e)){if($(e)){const t=new x(Number.MIN_SAFE_INTEGER.toString()),s=new x(Number.MAX_SAFE_INTEGER.toString());if(e.lt(t)||e.gt(s))return e.toString()}return e.toNumber()}return e}static inferTypeBlueId(e){return typeof e=="string"?Y:S(e)?$(e)?K:J:typeof e=="boolean"?G:null}}const Os=r=>c.isJsonPrimitive(r)&&c.isNonNullable(r),R=class R{constructor(e){p(this,"hashProvider");this.hashProvider=e}static calculateBlueId(e){if(Array.isArray(e)){const s=e.map(n=>b.get(n));return R.INSTANCE.calculate(s)}const t=b.get(e);return R.INSTANCE.calculate(t)}static calculateBlueIdSync(e){if(Array.isArray(e)){const s=e.map(n=>b.get(n));return R.INSTANCE.calculateSync(s)}const t=b.get(e);return R.INSTANCE.calculateSync(t)}calculate(e){const t=this.cleanStructure(e);if(t===void 0)throw new Error("Object after cleaning cannot be null or undefined.");return this.internalCalculate(t,!1)}calculateSync(e){const t=this.cleanStructure(e);if(t===void 0)throw new Error("Object after cleaning cannot be null or undefined.");return this.internalCalculate(t,!0)}internalCalculate(e,t){return Os(e)||S(e)?this.applyHash(e.toString(),t):Array.isArray(e)||c.isReadonlyArray(e)?this.calculateList(e,t):this.calculateMap(e,t)}calculateMap(e,t){if(e[_]!==void 0)return e[_];const n=Object.keys(e).map(o=>{const l=e[o];if([q,Ne,X].includes(o))return t?[o,l]:Promise.resolve([o,l]);{const a=this.internalCalculate(l,t);return t?[o,{blueId:a}]:Promise.resolve(a).then(h=>[o,{blueId:h}])}}),i=o=>{const l={};for(const[a,h]of o)l[a]=h;return this.applyHash(l,t)};return t?i(n):Promise.all(n).then(i)}calculateList(e,t){if(e.length===0)throw new Error("Cannot calculate BlueId for an empty list.");let s=this.internalCalculate(e[0],t);const n=(i,o)=>t?this.applyHash([{blueId:i},{blueId:o}],!0):Promise.all([i,o]).then(([l,a])=>this.applyHash([{blueId:l},{blueId:a}],!1));for(let i=1;i<e.length;i++){const o=this.internalCalculate(e[i],t);s=n(s,o)}return s}applyHash(e,t){return t?this.hashProvider.applySync(e):this.hashProvider.apply(e)}cleanStructure(e){if(e!=null){if(c.isJsonPrimitive(e)||S(e))return e;if(Array.isArray(e)||c.isReadonlyArray(e)){const t=e.map(s=>this.cleanStructure(s)).filter(c.isNonNullable);return t.length>0?t:void 0}else if(typeof e=="object"){const t={};for(const s in e){const n=this.cleanStructure(e[s]);n!=null&&(t[s]=n)}return Object.keys(t).length>0?t:void 0}else return e}}};p(R,"INSTANCE",new R(new mt));let N=R;class Ms{static convert(e){const t=ae.default.decode(e),s=new Uint8Array(2+t.length);s[0]=18,s[1]=32,s.set(t,2);const n=new Uint8Array(2+s.length);return n[0]=1,n[1]=85,n.set(s,2),"b"+new ls.Encoder({type:"rfc4648",lc:!0}).write(n).finalize().replace(/=/g,"")}}class D{static transform(e,t){const s=t(e.clone()),n=s.getType();n!==void 0&&s.setType(D.transform(n,t));const i=s.getItemType();i!==void 0&&s.setItemType(D.transform(i,t));const o=s.getKeyType();o!==void 0&&s.setKeyType(D.transform(o,t));const l=s.getValueType();l!==void 0&&s.setValueType(D.transform(l,t));const a=s.getItems();if(a!==void 0){const I=a.map(m=>D.transform(m,t));s.setItems(I)}const h=s.getProperties();if(h!==void 0){const I=Object.keys(h).reduce((m,f)=>(m[f]=D.transform(h[f],t),m),{});s.setProperties(I)}return s}}const L=r=>!!r&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof d),M=r=>r instanceof T||r instanceof w,Fs=r=>r.replace(/~1/g,"/").replace(/~0/g,"~");function se(r){if(r==="/")return[];if(!r.startsWith("/"))throw new Error(`Path must start with '/': ${r}`);return r.split("/").slice(1).map(Fs)}function ee(r){if(r==="-")return-1;const e=typeof r=="number"?r:parseInt(r,10);if(isNaN(e))throw new Error(`Invalid array index (NaN) from '${r}'`);if(!Number.isFinite(e))throw new Error(`Invalid array index '${r}' results in non-finite number ${e}`);return e}function It(r,e,t,s=!0){switch(e){case"name":return t?s?r.getName()??null:r:r.getName();case"description":return t?s?r.getDescription():r:r.getDescription();case"type":return r.getType();case"itemType":return r.getItemType();case"keyType":return r.getKeyType();case"valueType":return r.getValueType();case"value":return t?s?r.getValue()??null:r:r.getValue();case"blueId":return t?s?r.getBlueId()??null:r:r.getBlueId();case"blue":return r.getBlue();case"items":return r.getItems();case"properties":return r.getProperties();case"contracts":return r.getContracts();default:return}}function it(r,e,t=!0){if(r instanceof d){const s=It(r,e,!0,t);if(s!==void 0||["name","description","type","itemType","keyType","valueType","value","blueId","blue","items","properties","contracts"].includes(e))return s;if(/^-?\d+$/.test(e)&&e!=="-"){const i=r.getItems(),o=parseInt(e,10);return i&&o>=0&&o<i.length?i[o]:void 0}const n=r.getProperties();return n&&e in n?n[e]:void 0}if(Array.isArray(r)){if(e==="-")return;const s=ee(e);return s>=0&&s<r.length?r[s]:void 0}if(L(r))return r[e]}function re(r,e){if(e.length===0)return{parent:r,key:"value",actualTarget:r.getValue()??r};let t=r;for(let n=0;n<e.length-1;++n){const i=e[n],o=it(t,i);if(o===void 0)throw new Error(`Cannot resolve '/${e.slice(0,n+1).join("/")}'`);t=o}const s=e[e.length-1];if(t instanceof d){const n=it(t,s,!1);if((typeof n!="object"||n===null||M(n))&&!(n instanceof d)&&!Array.isArray(n)&&["name","description","value","blueId"].includes(s))return{parent:t,key:s,actualTarget:n}}return Array.isArray(t)&&s==="-"?{parent:t,key:"-"}:t instanceof d&&t.getItems()&&s==="-"?{parent:t,key:"-"}:{parent:t,key:Array.isArray(t)?ee(s):s}}function Xe(r,e){var t;if(r instanceof d){const s=e,n=It(r,s,!1);if(n!==void 0||["name","description","type","itemType","keyType","valueType","value","blueId","blue","items","properties","contracts"].includes(s))return n;if(typeof e=="number"||typeof e=="string"&&/^\d+$/.test(e)){const i=r.getItems(),o=typeof e=="number"?e:parseInt(e,10);if(i&&o>=0&&o<i.length)return i[o]}return(t=r.getProperties())==null?void 0:t[s]}return Array.isArray(r)||L(r)?r[e]:r}function B(r){if(r instanceof d)return r;if(r===null||typeof r=="string"||typeof r=="number"||typeof r=="boolean"||M(r))return y.deserialize(r);const e=je(r);return y.deserialize(e)}function je(r){if(r===void 0)return null;if(r===null||typeof r!="object")return r;if(Array.isArray(r))return r.map(je);const e={};for(const[t,s]of Object.entries(r))e[t]=je(s);return e}function Qe(r,e,t){if(r instanceof d){const s=e;switch(s){case"name":r.setName(t);return;case"description":r.setDescription(t);return;case"type":r.setType(t instanceof d||typeof t=="string"||t===void 0?t:B(t));return;case"itemType":r.setItemType(t instanceof d||typeof t=="string"||t===void 0?t:B(t));return;case"keyType":r.setKeyType(t instanceof d||typeof t=="string"||t===void 0?t:B(t));return;case"valueType":r.setValueType(t instanceof d||typeof t=="string"||t===void 0?t:B(t));return;case"value":{const n=t;r.setValue(n===void 0?null:n);return}case"blueId":r.setBlueId(t);return;case"blue":r.setBlue(t instanceof d||t===void 0?t:B(t));return;case"items":r.setItems(t);return;case"properties":r.setProperties(t);return;case"contracts":r.setContracts(t);return;default:{if(t===void 0){const n=r.getProperties();n&&s in n&&delete n[s]}else r.getProperties()||r.setProperties({}),r.addProperty(s,t instanceof d?t:B(t));return}}}Array.isArray(r)?r.splice(ee(e),1):L(r)&&(t===void 0?delete r[e]:r[e]=t)}function Rs(r,e,t,s){let n=-1;if(e!=="-"&&(n=typeof e=="number"?e:parseInt(e,10),isNaN(n)))throw new Error(`Invalid numeric key for BlueNode item operation: ${e}`);if(n<-1)throw new Error(`Invalid array index for BlueNode items: ${n}`);let i=r.getItems();if(i||(i=[],r.setItems(i)),!s&&n!==-1&&n>i.length)throw new Error(`ADD operation failed: Target array index '${n}' is greater than array length ${i.length}.`);if(e==="-")i.push(t);else if(s){if(n>=0)if(n<i.length)i[n]=t;else{for(let o=i.length;o<n;o++)i.push(y.deserialize(null));i.push(t)}}else i.splice(n,0,t)}function ye(r,e,t,s){if(Array.isArray(r)){const n=e==="-"?r.length:ee(e);if(!s&&n>r.length)throw new Error(`ADD operation failed: Target array index '${n}' is greater than array length ${r.length}. Path involving key '${e}'.`);if(n<0&&e!=="-")throw new Error(`Invalid negative array index: ${e}`);const i=B(t);if(s){if(n>=0&&n<r.length)r[n]=i;else if(n>=r.length){for(let o=r.length;o<n;o++)r.push(y.deserialize(null));r.push(i)}}else r.splice(n,0,i);return}if(r instanceof d){e==="-"||typeof e=="number"&&!isNaN(e)||typeof e=="string"&&/^\d+$/.test(e)?Rs(r,e,B(t),s):Qe(r,e,t);return}if(L(r)){r[e]=B(t);return}throw new Error(`Cannot insert into parent of type ${typeof r}`)}function js(r,e){if(Array.isArray(r)){const t=ee(e);t===-1&&e==="-"?r.length>0&&r.pop():t>=0&&t<r.length&&r.splice(t,1);return}if(r instanceof d){if(typeof e=="number"||typeof e=="string"&&/^-?\d+$/.test(e)){const t=r.getItems();if(t){const s=ee(e);s===-1&&e==="-"?t.length>0&&t.pop():s>=0&&s<t.length&&t.splice(s,1),t.length===0&&r.setItems(void 0);return}}Qe(r,e,void 0)}else L(r)&&delete r[e]}function xe(r){if(r instanceof d)return r.clone();if(Array.isArray(r))return r.map(t=>xe(t));if(L(r)){const e={};return Object.keys(r).forEach(t=>{e[t]=xe(r[t])}),e}return r}function U(r,e){if(r===e||r instanceof d&&(r.isInlineValue()||r.getValue()!==void 0)&&U(r.getValue()??null,e)||e instanceof d&&(e.isInlineValue()||e.getValue()!==void 0)&&U(r,e.getValue()??null))return!0;if(r instanceof d&&e instanceof d||M(r)&&M(e)||M(r)&&typeof e=="number"||typeof r=="number"&&M(e))return r.toString()===e.toString();if(Array.isArray(r)&&Array.isArray(e))return r.length===e.length&&r.every((t,s)=>U(t,e[s]));if(L(r)&&L(e)){const t=Object.keys(r),s=Object.keys(e);return t.length===s.length&&t.every(n=>U(r[n],e[n]))}return!1}function bt(r,e){const{parent:t,key:s}=re(r,se(e));return Xe(t,s)}function Nt(r,e,t){const s=se(e);if(s.length===0&&e==="/"){const o=B(t);r.setValue(o.getValue()??null),o.getItems()?r.setItems(o.getItems()):r.setItems(void 0);return}const{parent:n,key:i}=re(r,s);ye(n,i,t,!0)}function xs(r,e,t){const s=se(e);if(s.length===0&&e==="/"){if(r.getItems()&&Array.isArray(t)){const o=B(t);o.getItems()?(r.setItems(o.getItems()),r.setValue(null)):(r.setValue(o.getValue()??null),r.setItems(void 0))}else{const o=B(t);r.setValue(o.getValue()??null),o.getItems()&&r.setItems(o.getItems())}return!0}const{parent:n,key:i}=re(r,s);return ye(n,i,t,!1),!0}function $s(r,e,t){const s=se(e);if(s.length===0&&e==="/"){const l=B(t);return r.setValue(l.getValue()??null),l.getItems()?r.setItems(l.getItems()):r.setItems(void 0),!0}const{parent:n,key:i,actualTarget:o}=re(r,s);if(o!==void 0&&n instanceof d)Qe(n,i,t);else{const l=Xe(n,i),a=Array.isArray(n)||n instanceof d&&n.getItems()&&(typeof i=="number"||typeof i=="string"&&/^\d+$/.test(i));if(l===void 0){if(a)throw new Error(`REPLACE failed: Target array index '${i.toString()}' is out of bounds or does not exist at path '${e}'.`);ye(n,i,t,!0)}else ye(n,i,t,!0)}return!0}function Tt(r,e){const t=se(e);if(t.length===0&&e==="/")return r.setValue(null),r.setItems(void 0),r.setProperties(void 0),!0;const{parent:s,key:n}=re(r,t);return js(s,n),!0}function Ls(r,e,t){const s=xe(bt(r,e));return Nt(r,t,s),!0}function zs(r,e,t){const s=se(e),{parent:n,key:i}=re(r,s),o=Xe(n,i);if(o===void 0)throw new Error(`MOVE failed: 'from' location '${e}' does not exist.`);return Tt(r,e)?(Nt(r,t,o),!0):!1}function Us(r,e,t){const s=bt(r,e);let n=t;if(s instanceof d)if((t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"||M(t))&&(s.isInlineValue()||s.getValue()!==void 0)){if(!U(s.getValue()??null,t))throw new Error(`TEST failed at '${e}': Expected ${JSON.stringify(t)}, got ${JSON.stringify(s.getValue()??null)}`);return!0}else typeof t=="object"&&!(t instanceof d)&&(n=B(t));else if(M(s)&&typeof t=="number")s instanceof T?n=new T(t.toString()):s instanceof w&&(n=new w(t.toString()));else if((s===null||typeof s=="string"||typeof s=="number"||typeof s=="boolean")&&M(t)){const i=t;!U(s,i.toString())&&(typeof s=="number"&&parseFloat(i.toString()))}if(!U(s,n)){const i=s instanceof d?s.toString():JSON.stringify(s),o=n instanceof d?n.toString():JSON.stringify(n);throw new Error(`TEST failed at '${e}': Expected ${o}, got ${i}`)}return!0}function Zs(r,e){switch(e.op){case"add":return xs(r,e.path,e.val);case"replace":return $s(r,e.path,e.val);case"remove":return Tt(r,e.path);case"copy":return Ls(r,e.from,e.path);case"move":return zs(r,e.from,e.path);case"test":return Us(r,e.path,e.val)}}function _s(r,e,t=!1){const s=t?r:r.clone();return Zs(s,e),s}const Ve=Symbol.for("zod-schema-annotations");function ks(){if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global;if(typeof window<"u")return window;if(typeof self<"u")return self;throw new Error("Unable to locate global object")}function vt(){const r=ks();return Ve in r||(r[Ve]=new WeakMap),r[Ve]}function ne(r,e){const t=vt(),s=t.get(r)||{};return t.set(r,{...s,...e}),r}const V=r=>vt().get(r),Bt=r=>e=>{const t=V(e);return ne(e,{...t,blueDescription:r})},wt=r=>{const e=V(r);return c.isNonNullable(e)&&C.isString(e.blueDescription)?e.blueDescription:null},Ys=r=>Bt(r)(u.z.string().optional()),Js=u.z.union([u.z.string(),u.z.boolean()]),Pt=r=>e=>{const t=V(e);return ne(e,{...t,blueId:r})},St=r=>{const e=V(r),t=Js.safeParse(e==null?void 0:e.blueId);return t.success?t.data:null},Ks=r=>Pt(r??!0)(u.z.string()),Et=r=>e=>{const t=V(e);return ne(e,{...t,blueName:r})},At=r=>{const e=V(r);return c.isNonNullable(e)&&C.isString(e.blueName)?e.blueName:null},Gs=r=>{const e=u.z.string().optional();return Et(r)(e)},Ct=()=>r=>{const e=V(r);return ne(r,{...e,blueNode:!0})},Vt=r=>{const e=V(r);return c.isNonNullable(e)&&c.isNonNullable(e.blueNode)&&e.blueNode===!0?e.blueNode:null},et=r=>!!Vt(r),Ws=()=>{const r=u.z.instanceof(d);return Ct()(r)},$e="extendedFrom",Dt=({schema:r,baseSchema:e})=>{const t=V(r)||{};return ne(r,{...t,[$e]:e})},Ot=r=>{const e=V(r);return c.isNonNullable(e)&&e[$e]?e[$e]:null},tt=(r,e)=>{const t=Ot(r);return c.isNullable(t)?!1:(t==null?void 0:t._def)===(e==null?void 0:e._def)?!0:tt(t,e)},Hs=r=>new Proxy(r,{get(e,t,s){return t==="extend"?function(...n){const i=e.extend(...n);return Dt({schema:i,baseSchema:e})}:Reflect.get(e,t,s)}}),qs=u.z.object({value:u.z.array(u.z.string()).optional(),defaultValue:u.z.string().optional()}),Mt=r=>{const e=V(r),t=qs.passthrough().safeParse(e==null?void 0:e.typeBlueId);return t.success?t.data:null},Xs=r=>e=>{const t=V(e),s=typeof r=="string"?{value:[r]}:r,n=Hs(e);return ne(n,{...t,typeBlueId:{...(t==null?void 0:t.typeBlueId)||{},...s}})};class Te{static resolveBlueId(e){var i;const t=Mt(e);if(c.isNullable(t))return null;const s=t.defaultValue;if(c.isNonNullable(s))return s;const n=(i=t.value)==null?void 0:i[0];return c.isNonNullable(n)?n:Te.getRepositoryBlueId(t,e)}static getRepositoryBlueId(e,t){throw new Error("Not implemented")}}class A{static isTypeOf(e,t,s){var o;const n=Te.resolveBlueId(t),i=(o=e.getType())==null?void 0:o.getBlueId();if(c.isNullable(n)||c.isNullable(i))return!1;if(n===i)return!0;if(s!=null&&s.checkSchemaExtensions&&c.isNonNullable(s.typeSchemaResolver)){const l=s.typeSchemaResolver.resolveSchema(e);return A.checkSchemaExtension(l,t)}return!1}static checkSchemaExtension(e,t){if(!c.isNonNullable(e))return!1;const s=A.unwrapSchema(e),n=A.unwrapSchema(t);return tt(s,n)}static isWrapperType(e){return e instanceof u.ZodOptional||e instanceof u.ZodNullable||e instanceof u.ZodReadonly||e instanceof u.ZodBranded||e instanceof u.ZodEffects||e instanceof u.ZodLazy}static unwrapSchema(e){return et(e)?e:A.isWrapperType(e)?e instanceof u.ZodEffects?A.unwrapSchema(e.innerType()):e instanceof u.ZodLazy?A.unwrapSchema(e.schema):A.unwrapSchema(e.unwrap()):e}}class Ft{constructor(e){p(this,"blueIdMap",new Map);this.registerSchemas(e)}registerSchemas(e){for(const t of e)this.registerSchema(t)}registerSchema(e){const t=Te.resolveBlueId(e);if(c.isNonNullable(t)){if(this.blueIdMap.has(t))throw new Error(`Duplicate BlueId value: ${t}`);this.blueIdMap.set(t,e)}}resolveSchema(e){const t=this.getEffectiveBlueId(e);return c.isNullable(t)?null:this.blueIdMap.get(t)}getEffectiveBlueId(e){const t=e.getType();return c.isNonNullable(t)&&c.isNonNullable(t.getBlueId())?t.getBlueId():c.isNonNullable(t)?N.calculateBlueIdSync(t):null}getBlueIdMap(){return new Map(this.blueIdMap)}}const v={NAME:"name",DESCRIPTION:"description",TYPE:"type",BLUE_ID:"blue_id",KEY_TYPE:"key_type",VALUE_TYPE:"value_type",ITEM_TYPE:"item_type",VALUE:"value",PROPERTIES:"properties",BLUE:"blue",ITEMS:"items"};class ve{static isEmptyNode(e){return this.hasFieldsAndMayHaveFields(e)}static hasBlueIdOnly(e){return this.hasFieldsAndMayHaveFields(e,new Set([v.BLUE_ID]))}static hasItemsOnly(e){return this.hasFieldsAndMayHaveFields(e,new Set([v.ITEMS]))}static isValidValueNode(e){const t=e.getValue(),s=e.getProperties(),n=e.getItems();return c.isNonNullable(t)&&c.isNullable(s)&&c.isNullable(n)}static textNode(e){return new d().setType(new d().setBlueId(Y)).setValue(e)}static integerNode(e){const t=e instanceof T?e:new T(e.toString());return new d().setType(new d().setBlueId(K)).setValue(t)}static doubleNode(e){const t=e instanceof w?e:new w(e.toString());return new d().setType(new d().setBlueId(J)).setValue(t)}static booleanNode(e){return new d().setType(new d().setBlueId(G)).setValue(e)}static hasFieldsAndMayHaveFields(e,t=new Set,s=new Set){for(const n of Object.values(v)){const i=c.isNonNullable(this.getFieldValue(e,n));if(t.has(n)){if(!i)return!1}else if(!s.has(n)){if(i)return!1}}return!0}static getFieldValue(e,t){switch(t){case v.NAME:return e.getName();case v.TYPE:return e.getType();case v.VALUE:return e.getValue();case v.DESCRIPTION:return e.getDescription();case v.PROPERTIES:return e.getProperties();case v.BLUE:return e.getBlue();case v.ITEMS:return e.getItems();case v.KEY_TYPE:return e.getKeyType();case v.VALUE_TYPE:return e.getValueType();case v.ITEM_TYPE:return e.getItemType();case v.BLUE_ID:return e.getBlueId();default:throw new Error(`Unknown field: ${t}`)}}}class Be{}class ie{static convert(e){const t=new Le;return ie.traverseNode(e,"",t),t.build()}static traverseNode(e,t,s){if(!e)return;const n=e.getProperties(),i=e.getItems(),o=n!==void 0&&Object.keys(n).length>0,l=i!==void 0&&i.length>0;if(!o&&!l){s.addPath(t===""?"/":t);return}if(n)for(const[a,h]of Object.entries(n)){const I=`${t}/${a}`;ie.traverseNode(h,I,s)}if(i)for(let a=0;a<i.length;a++){const h=`${t}/${a}`;ie.traverseNode(i[a],h,s)}}}function ot(r,e){const t=r.split(e),s=[...t].reverse().findIndex(i=>i!==""),n=s===-1?0:t.length-s;return t.slice(0,n)}class we extends Be{constructor(t,s){super();p(this,"allowedPaths");p(this,"maxDepth");p(this,"currentPath",[]);this.allowedPaths=t,this.maxDepth=s}shouldExtendPathSegment(t){if(this.currentPath.length>=this.maxDepth)return!1;const s=this.normalizePath(this.getCurrentFullPath()+"/"+t);return this.isAllowedPath(s)}shouldMergePathSegment(t){return this.shouldExtendPathSegment(t)}isAllowedPath(t){for(const s of this.allowedPaths)if(this.matchesAllowedPath(s,t))return!0;return!1}matchesAllowedPath(t,s){const n=ot(t,"/"),i=ot(s,"/");if(i.length>n.length)return!1;for(let o=1;o<i.length;o++)if(n[o]!=="*"&&n[o]!==i[o])return!1;return!0}enterPathSegment(t){this.currentPath.push(t)}exitPathSegment(){this.currentPath.length>0&&this.currentPath.pop()}getCurrentFullPath(){return"/"+this.currentPath.join("/")}normalizePath(t){return"/"+t.split("/").filter(s=>s!=="").join("/")}static withMaxDepth(t){const s=new Le().setMaxDepth(t);for(let n=1;n<=t;n++){const i="/"+Array(n).fill("*").join("/");s.addPath(i)}return s.build()}static withSinglePath(t){return new Le().addPath(t).build()}static fromNode(t){return ie.convert(t)}}class Le{constructor(){p(this,"allowedPaths",new Set);p(this,"maxDepth",Number.MAX_SAFE_INTEGER)}addPath(e){return this.allowedPaths.add(e),this}setMaxDepth(e){return this.maxDepth=e,this}build(){return new we(this.allowedPaths,this.maxDepth)}}class Qs extends Be{shouldExtendPathSegment(){return!0}shouldMergePathSegment(){return!0}enterPathSegment(){}exitPathSegment(){}}class Pe extends Be{constructor(t){super();p(this,"limits");this.limits=t}shouldExtendPathSegment(t,s){return this.limits.every(n=>n.shouldExtendPathSegment(t,s))}shouldMergePathSegment(t,s){return this.limits.every(n=>n.shouldMergePathSegment(t,s))}enterPathSegment(t,s){this.limits.forEach(n=>{n.enterPathSegment(t,s)})}exitPathSegment(){this.limits.forEach(t=>{t.exitPathSegment()})}static of(...t){return new Pe(t)}}const z=new Qs;function De(r,e){const t=r.getType();if(t===void 0)return;const s=t.getBlueId();if(s!==void 0){if(de.includes(s)){const i=ys[s];return new d().setBlueId(s).setName(i)}const n=e.fetchByBlueId(s);if(!n||n.length===0)return;if(n.length>1)throw new Error(`Expected a single node for type with blueId '${s}', but found multiple.`);return n[0]}return t}function P(r,e,t){const s=N.calculateBlueIdSync(r),n=N.calculateBlueIdSync(e);if(s===n)return!0;if(s&&de.includes(s)){let o=e;for(;o!==void 0;){if(N.calculateBlueIdSync(o)===s)return!0;o=De(o,t)}return!1}let i=De(r,t);for(;i!==void 0;){if(N.calculateBlueIdSync(i)===n)return!0;i=De(i,t)}return!1}function er(r,e){return dt.some(t=>{const s=new d().setBlueId(t);return P(r,s,e)})}function tr(r,e){const t=new d().setBlueId(Y);return P(r,t,e)}function sr(r,e){const t=new d().setBlueId(K);return P(r,t,e)}function rr(r,e){const t=new d().setBlueId(J);return P(r,t,e)}function nr(r,e){const t=new d().setBlueId(G);return P(r,t,e)}function Rt(r){return(r==null?void 0:r.getBlueId())===ct}function jt(r){return(r==null?void 0:r.getBlueId())===ut}function ir(r,e){return We.some(t=>{const s=new d().setName(t);return P(r,s,e)})}function or(r,e){for(const t of We){const s=new d().setName(t);if(P(r,s,e))return t}throw new Error(`Cannot determine the basic type for node of type "${r.getName()||"unknown"}".`)}class lr{constructor(e){p(this,"blue");this.blue=e}matchesType(e,t,s=z){const n=t.getType();if(this.matchesImplicitStructure(e,n))return!0;const i=we.fromNode(t),o=Pe.of(s,i),l=this.extendAndResolve(e,o),a=this.blue.resolve(t,o);return this.verifyMatch(l,t,o)&&this.recursiveValueComparison(l,a)}extendAndResolve(e,t){const s=e.clone(),n=s.clone();this.blue.extend(n,t);const i=this.blue.resolve(n,t);return this.restoreMissingStructure(i,s),i}restoreMissingStructure(e,t){const s=t.getItems(),n=e.getItems();if(s&&s.length>0)if(!n||n.length===0)e.setItems(s.map(a=>a.clone()));else for(let a=0;a<Math.min(n.length,s.length);a++)this.restoreMissingStructure(n[a],s[a]);const i=t.getProperties();if(i){let a=e.getProperties();a||(a={},e.setProperties(a));for(const[h,I]of Object.entries(i)){const m=a[h];m===void 0?a[h]=I.clone():this.restoreMissingStructure(m,I)}}const o=t.getBlueId();e.getBlueId()===void 0&&o!==void 0&&e.setBlueId(o);const l=t.getValue();e.getValue()===void 0&&l!==void 0&&e.setValue(l)}verifyMatch(e,t,s){const n=t.getType();if(this.matchesImplicitStructure(e,n))return!0;const i=e.clone().setType(t.clone());try{this.blue.resolve(i,s)}catch{return!1}return!0}recursiveValueComparison(e,t){var m;const s=t.getType(),n=this.matchesImplicitStructure(e,s);if(s&&!n){const f=e.getType();if(!f||!P(f,s,this.blue.getNodeProvider()))return!1}const i=t.getBlueId();if(!n&&i!==void 0){const f=e.getBlueId(),g=(m=e.getType())==null?void 0:m.getBlueId();if(f!==void 0){if(i!==f)return!1}else if(g===void 0||i!==g)return!1}const o=t.getValue();if(o!==void 0){const f=e.getValue();if(f===void 0)return!1;if(S(f)&&S(o)){if(!f.eq(o))return!1}else if(f!==o)return!1}const l=t.getItems();if(l!==void 0){const f=e.getItems()??[];for(let g=0;g<l.length;g++)if(g<f.length){if(!this.recursiveValueComparison(f[g],l[g]))return!1}else if(this.hasValueInNestedStructure(l[g]))return!1}const a=t.getItemType();if(a!==void 0){const f=e.getItems()??[];for(const g of f)if(!this.recursiveValueComparison(g,a))return!1}const h=t.getProperties();if(h!==void 0){const f=e.getProperties()??{};for(const[g,O]of Object.entries(h))if(g in f){if(!this.recursiveValueComparison(f[g],O))return!1}else if(this.hasValueInNestedStructure(O))return!1}const I=t.getValueType();if(I!==void 0){const f=Object.values(e.getProperties()??{});for(const g of f)if(!this.recursiveValueComparison(g,I))return!1}return!0}hasValueInNestedStructure(e){if(e.getValue()!==void 0)return!0;const t=e.getItems();if(t!==void 0){for(const n of t)if(this.hasValueInNestedStructure(n))return!0}const s=e.getProperties();if(s!==void 0){for(const n of Object.values(s))if(this.hasValueInNestedStructure(n))return!0}return!1}matchesImplicitStructure(e,t){return t===void 0||e.getType()!==void 0?!1:Rt(t)?this.isImplicitListStructure(e):jt(t)?this.isImplicitDictionaryStructure(e):!1}isImplicitListStructure(e){return e.getItems()!==void 0&&e.getValue()===void 0}isImplicitDictionaryStructure(e){return e.getProperties()!==void 0&&e.getValue()===void 0}}const ar=r=>r instanceof u.ZodOptional||r instanceof u.ZodNullable||r instanceof u.ZodReadonly||r instanceof u.ZodBranded||r instanceof u.ZodEffects||r instanceof u.ZodLazy,cr=r=>r instanceof u.ZodString||r instanceof u.ZodNumber||r instanceof u.ZodBoolean||r instanceof u.ZodBigInt;class xt{static convertValue(e,t){var i;const s=(i=e.getType())==null?void 0:i.getBlueId(),n=e.getValue();return c.isNullable(n)?cr(t)&&ve.isValidValueNode(e)?this.getDefaultPrimitiveValue(t):n:Y===s?this.convertFromString(String(n),t):J===s||n instanceof w?this.convertFromBigDecimal(new w(n==null?void 0:n.toString()),t):K===s||n instanceof T?this.convertFromBigInteger(new T(n==null?void 0:n.toString()),t):G===s||typeof n=="boolean"?this.convertFromBoolean(!!n,t):this.convertFromString(String(n),t)}static convertFromString(e,t){if(!t||t instanceof u.ZodString||t instanceof u.ZodEnum||t instanceof u.ZodNativeEnum)return e;if(t instanceof u.ZodNumber)return Number(e);if(t instanceof u.ZodBoolean)return e.toLowerCase()==="true";if(t instanceof u.ZodBigInt)return BigInt(e);throw new Error(`Cannot convert String to ${t._def.typeName}`)}static convertFromBigDecimal(e,t){if(t instanceof u.ZodNumber)return e.toNumber();if(t instanceof u.ZodString)return e.toString();throw new Error(`Cannot convert Number to ${t._def.typeName}`)}static convertFromBigInteger(e,t){if(t instanceof u.ZodNumber)return e.toNumber();if(t instanceof u.ZodBigInt)return BigInt(e.toString());if(t instanceof u.ZodString)return e.toString();throw new Error(`Cannot convert Number to ${t._def.typeName}`)}static convertFromBoolean(e,t){if(!t||t instanceof u.ZodBoolean)return e;if(t instanceof u.ZodString)return e.toString();if(t instanceof u.ZodNumber)return Number(e);if(t instanceof u.ZodBigInt)return BigInt(e);throw new Error(`Cannot convert Boolean to ${t._def.typeName}`)}static getDefaultPrimitiveValue(e){if(!e)return null;if(e instanceof u.ZodNumber)return 0;if(e instanceof u.ZodBoolean)return!1;if(e instanceof u.ZodString)return"";throw new Error(`Unsupported primitive type: ${e._def.typeName}`)}}class ur{convert(e,t){return xt.convertValue(e,t)}}class dr{constructor(e){this.nodeToObjectConverter=e}convert(e,t){return this.convertFields(e,t)}convertFields(e,t){if(t instanceof u.ZodIntersection){const s=t._def.left,n=t._def.right,i=this.convert(e,s),o=this.convert(e,n);return{...i,...o}}if(t instanceof u.ZodUnion)throw new Error("Union not supported");if(t instanceof u.ZodObject)return Object.keys(t.shape).reduce((n,i)=>{const o=e.getProperties(),l=t.shape[i],a=St(l);if(c.isNonNullable(a)){const g=C.isString(a)?a:i,O=o==null?void 0:o[g],W=O?N.calculateBlueIdSync(O):void 0;return n[i]=W,n}const h=At(l);if(c.isNonNullable(h)){const g=o==null?void 0:o[h];return n[i]=g==null?void 0:g.getName(),n}const I=wt(l);if(c.isNonNullable(I)){const g=o==null?void 0:o[I];return n[i]=g==null?void 0:g.getDescription(),n}if(i==="name"){const g=e.getName();return n[i]=g,n}if(i==="description"){const g=e.getDescription();return n[i]=g,n}const m=o==null?void 0:o[i];if(c.isNullable(m))return n;const f=this.nodeToObjectConverter.convert(m,l);return n[i]=f,n},{});throw new Error("Unknown schema type, "+t._def.typeName)}}class hr{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const s=e.getItems();if(!s)return;const n=t.element;return s.map(o=>this.nodeToObjectConverter.convert(o,n))}}class pr{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const s=e.getItems();if(!s)return;const n=t._def.valueType,i=s.map(o=>this.nodeToObjectConverter.convert(o,n));return new Set(i)}}class fr{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const s=t.keySchema,n=t.valueSchema,i=new Map,o=e.getName();c.isNonNullable(o)&&i.set(q,o);const l=e.getDescription();c.isNonNullable(l)&&i.set(X,l);const a=e.getProperties();return c.isNonNullable(a)&&Object.entries(a).forEach(([h,I])=>{const m=new d().setValue(h);m.setType(new d().setBlueId(Y));const f=xt.convertValue(m,s),g=this.nodeToObjectConverter.convert(I,n);i.set(f,g)}),t instanceof u.ZodRecord?Object.fromEntries(i):i}}class gr{convert(e){return b.get(e)}}class yr{convert(e){return b.get(e)}}class mr{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const s=e.getItems();if(!s)return;const n=t.items;return s.map((o,l)=>this.nodeToObjectConverter.convert(o,n[l]))}}const Ir=u.z.union([u.z.literal("ZodString"),u.z.literal("ZodNumber"),u.z.literal("ZodBoolean"),u.z.literal("ZodBigInt"),u.z.literal("ZodArray"),u.z.literal("ZodSet"),u.z.literal("ZodMap"),u.z.literal("ZodRecord"),u.z.literal("ZodObject"),u.z.literal("ZodEnum"),u.z.literal("ZodNativeEnum"),u.z.literal("ZodUnknown"),u.z.literal("ZodAny"),u.z.literal("ZodTuple")]);class br{constructor(e){p(this,"converters",new Map);p(this,"complexObjectConverter");this.nodeToObjectConverter=e,this.registerConverters(),this.complexObjectConverter=new dr(this.nodeToObjectConverter)}registerConverters(){const e=new ur,t=new hr(this.nodeToObjectConverter),s=new mr(this.nodeToObjectConverter),n=new pr(this.nodeToObjectConverter),i=new fr(this.nodeToObjectConverter);this.converters.set("ZodString",e),this.converters.set("ZodNumber",e),this.converters.set("ZodBoolean",e),this.converters.set("ZodBigInt",e),this.converters.set("ZodEnum",e),this.converters.set("ZodNativeEnum",e),this.converters.set("ZodUnknown",new gr),this.converters.set("ZodAny",new yr),this.converters.set("ZodArray",t),this.converters.set("ZodTuple",s),this.converters.set("ZodSet",n),this.converters.set("ZodMap",i),this.converters.set("ZodRecord",i),this.converters.set("ZodObject",this.complexObjectConverter)}getConverter(e){const t=this.getSchemaTypeName(e);return this.converters.get(t)??this.complexObjectConverter}getSchemaTypeName(e){if(ar(e))return e instanceof u.ZodEffects?this.getSchemaTypeName(e.innerType()):e instanceof u.ZodLazy?this.getSchemaTypeName(e.schema):this.getSchemaTypeName(e.unwrap());const t=e._def.typeName;try{return Ir.parse(t)}catch{throw new Error(`Schema type name ${t} is not supported`)}}}class Nr{constructor(e){p(this,"converterFactory");this.typeSchemaResolver=e,this.converterFactory=new br(this)}convert(e,t){var o;const s=(o=this.typeSchemaResolver)==null?void 0:o.resolveSchema(e),n=A.unwrapSchema(t);if(et(n))return e;let i=n;return A.checkSchemaExtension(s,n)&&c.isNonNullable(s)&&(i=s),this.convertWithType(e,i)}convertWithType(e,t){return this.converterFactory.getConverter(t).convert(e,t)}}class pe{fetchFirstByBlueId(e){const t=this.fetchByBlueId(e);return t&&t.length>0?t[0]:null}}function Tr(r){return new class extends pe{fetchByBlueId(e){return r(e)}}}class vr extends pe{constructor(t){super();p(this,"nodeProviders");this.nodeProviders=t}fetchByBlueId(t){for(const s of this.nodeProviders){const n=s.fetchByBlueId(t);if(n&&n.length>0)return n}return[]}fetchFirstByBlueId(t){for(const s of this.nodeProviders){const n=s.fetchFirstByBlueId(t);if(n)return n}return null}getNodeProviders(){return this.nodeProviders}}const Oe=k.types.float.options,Br={...Oe,construct:r=>{const e=r.replace(/_/g,"").toLowerCase();if(!c.isPreciseNumberString(e))return new w(e);if(Oe.construct)return Oe.construct(r)}},wr=new k.Type("tag:yaml.org,2002:float",Br),Me=k.types.int.options,Pr={...Me,construct:r=>{let e=r;if(e.indexOf("_")!==-1&&(e=e.replace(/_/g,"")),!c.isPreciseNumberString(e))return new T(e);if(Me.construct)return Me.construct(r)}},Sr=new k.Type("tag:yaml.org,2002:int",Pr),$t=k.CORE_SCHEMA.extend({implicit:[wr,Sr]}),F=r=>{const e=k.load(r,{schema:$t});return e===void 0?void 0:e},Er=r=>k.dump(r,{schema:$t,replacer:(e,t)=>{if(S(t)){if($(t)){const s=new x(Number.MIN_SAFE_INTEGER.toString()),n=new x(Number.MAX_SAFE_INTEGER.toString());if(t.lt(s)||t.gt(n))return t.toString()}return t.toNumber()}return t}}),Lt=`- type:
|
|
1
|
+
"use strict";var ss=Object.defineProperty;var rs=(r,e,t)=>e in r?ss(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var p=(r,e,t)=>rs(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("big.js"),c=require("@blue-labs/shared-utils"),u=require("zod"),ns=require("bs58"),C=require("radash"),is=require("js-sha256"),os=require("crypto"),ls=require("base32.js"),k=require("js-yaml"),lt=r=>r&&r.__esModule?r:{default:r},ae=lt(ns),Ee=lt(os);class w extends x{constructor(e){super(e)}}class T extends x{constructor(e){super(e)}}class as{static get(e,t,s,n=!0){if(c.isNullable(t)||!t.startsWith("/"))throw new Error(`Invalid path: ${t}`);if(t==="/"){const o=e.getValue();return n&&o!==void 0?o:e}const i=t.substring(1).split("/");return this.getRecursive(e,i,0,s,n)}static getRecursive(e,t,s,n,i){if(s===t.length-1&&!i)return this.getNodeForSegment(e,t[s],n,!1);if(s===t.length){const a=e.getValue();return i&&a!==void 0?a:e}const o=t[s],l=this.getNodeForSegment(e,o,n,!0);if(l)return this.getRecursive(l,t,s+1,n,i)}static getNodeForSegment(e,t,s,n){let i;const o=e.getProperties();if(o&&t in o)i=o[t];else switch(t){case"name":{const l=e.getName();i=new d().setValue(l??null);break}case"description":{const l=e.getDescription();i=new d().setValue(l??null);break}case"type":i=e.getType();break;case"itemType":i=e.getItemType();break;case"keyType":i=e.getKeyType();break;case"valueType":i=e.getValueType();break;case"value":{const l=e.getValue();i=new d().setValue(l??null);break}case"blueId":{const l=e.getBlueId();i=new d().setValue(l??null);break}case"blue":i=e.getBlue();break;case"items":{const l=e.getItems();i=new d().setItems(l);break}case"properties":{const l=e.getProperties();i=new d().setProperties(l);break}case"contracts":{const l=e.getContracts();i=new d().setContracts(l);break}default:{if(/^\d+$/.test(t)){const l=parseInt(t,10),a=e.getItems();a&&l>=0&&l<a.length?i=a[l]:i=void 0}else i=void 0;break}}if(i)return n&&s?this.link(i,s):i}static link(e,t){const s=t(e);return c.isNonNullable(s)?s:e}}const q="name",X="description",fe="type",_e="itemType",ke="keyType",Ye="valueType",Ne="value",Je="items",_="blueId",Ke="blue",cs=[q,X,fe,_e,ke,Ye,Ne,Je,_,Ke],us="Text",ds="Double",hs="Integer",ps="Boolean",fs="List",gs="Dictionary",Ge=[us,ds,hs,ps],at=[...Ge,fs,gs],Y="F92yo19rCcbBoBSpUA5LRxpfDejJDAaP1PRxxbWAraVP",J="68ryJtnmui4j5rCZWUnkZ3DChtmEb7Z9F8atn1mBSM3L",K="DHmxTkFbXePZHCHCYmQr2dSzcNLcryFVjXVHkdQrrZr8",G="EL6AjrbJsxTWRTPzY8WR8Y2zAMXRbydQj83PcZwuAHbo",ct="G8wmfjEqugPEEXByMYWJXiEdbLToPRWNQEekNxrxfQWB",ut="294NBTj2mFRL3RB4kDRUSckwGg7Kzj6T8CTAFeR1kcSA",dt=[Y,J,K,G],de=[...dt,ct,ut];Object.fromEntries(at.map((r,e)=>[r,de[e]]));const ys=Object.fromEntries(de.map((r,e)=>[r,at[e]])),E=class E{constructor(e){p(this,"name");p(this,"description");p(this,"type");p(this,"itemType");p(this,"keyType");p(this,"valueType");p(this,"value");p(this,"items");p(this,"properties");p(this,"blueId");p(this,"blue");p(this,"inlineValue",!1);this.name=e}getName(){return this.name}setName(e){return this.name=e,this}getDescription(){return this.description}setDescription(e){return this.description=e,this}getType(){return this.type}setType(e){return typeof e=="string"?this.type=new E().setValue(e).setInlineValue(!0):this.type=e,this}getItemType(){return this.itemType}setItemType(e){return typeof e=="string"?this.itemType=new E().setValue(e).setInlineValue(!0):this.itemType=e,this}getKeyType(){return this.keyType}setKeyType(e){return typeof e=="string"?this.keyType=new E().setValue(e).setInlineValue(!0):this.keyType=e,this}getValueType(){return this.valueType}setValueType(e){return typeof e=="string"?this.valueType=new E().setValue(e).setInlineValue(!0):this.valueType=e,this}getValue(){var t;const e=(t=this.type)==null?void 0:t.getBlueId();if(c.isNonNullable(e)&&c.isNonNullable(this.value)){if(e===K&&typeof this.value=="string")return new T(this.value);if(e===J&&typeof this.value=="string"){const s=new w(this.value),n=parseFloat(s.toString());return new w(n.toString())}else if(e===G&&typeof this.value=="string")return this.value.toLowerCase()==="true"}return this.value}setValue(e){return typeof e=="number"?e%1===0?this.value=new T(e.toString()):this.value=new w(e.toString()):this.value=e,this}getItems(){return this.items}setItems(e){return this.items=e,this}addItems(...e){return this.items||(this.items=[]),this.items.push(...e),this}getProperties(){return this.properties}setProperties(e){return this.properties=e,this}addProperty(e,t){return this.properties||(this.properties={}),this.properties[e]=t,this}removeProperty(e){return this.properties&&delete this.properties[e],this}getContractsProperty(){var e;return(e=this.properties)==null?void 0:e.contracts}getContracts(){var e;return(e=this.getContractsProperty())==null?void 0:e.getProperties()}setContracts(e){return c.isNullable(e)?this.removeProperty("contracts"):this.addProperty("contracts",new E().setProperties(e)),this}addContract(e,t){const s=this.getContractsProperty();return c.isNullable(s)?this.addProperty("contracts",new E().addProperty(e,t)):s.addProperty(e,t),this}removeContract(e){const t=this.getContractsProperty();if(t){t.removeProperty(e);const s=t.getProperties();s&&Object.keys(s).length===0&&this.removeProperty("contracts")}return this}getBlueId(){return this.blueId}setBlueId(e){return this.blueId=e,this}getBlue(){return this.blue}setBlue(e){return this.blue=e,this}isInlineValue(){return this.inlineValue}setInlineValue(e){return this.inlineValue=e,this}isResolved(){return!1}get(e,t){return as.get(this,e,t)}getAsNode(e){const t=this.get(e);if(t instanceof E)return t;throw new Error(`Value at path ${e} is not a BlueNode: ${t}`)}getAsInteger(e){const t=this.get(e);if(t instanceof T||t instanceof w)return t.toNumber();throw new Error(`Value at path ${e} is not a BigInteger or BigDecimal: ${t}`)}clone(){var t,s,n,i,o,l;const e=new E(this.name);return e.description=this.description,e.type=(t=this.type)==null?void 0:t.clone(),e.itemType=(s=this.itemType)==null?void 0:s.clone(),e.keyType=(n=this.keyType)==null?void 0:n.clone(),e.valueType=(i=this.valueType)==null?void 0:i.clone(),e.value=this.value,e.items=(o=this.items)==null?void 0:o.map(a=>a.clone()),this.properties&&(e.properties=Object.fromEntries(Object.entries(this.properties).map(([a,h])=>[a,h.clone()]))),e.blueId=this.blueId,e.blue=(l=this.blue)==null?void 0:l.clone(),e.inlineValue=this.inlineValue,e}toString(){return`BlueNode{name='${this.name}', description='${this.description}', type=${this.type}, itemType=${this.itemType}, keyType=${this.keyType}, valueType=${this.valueType}, value=${this.value}, items=${this.items}, properties=${this.properties}, blueId='${this.blueId}', blue=${this.blue}, inlineValue=${this.inlineValue}}`}};p(E,"INTEGER",new E("Integer"));let d=E;class Z{static isPotentialBlueId(e){if(!e||e.length===0||!this.BLUE_ID_PATTERN.test(e))return!1;const t=e.split("#"),s=t[0],n=s.length;if(n<this.MIN_BLUE_ID_LENGTH||n>this.MAX_BLUE_ID_LENGTH)return!1;try{if(ae.default.decode(s).length!==32)return!1}catch{return!1}if(t.length>1)try{if(Number(t[1])<0)return!1}catch{return!1}return!0}}p(Z,"MIN_BLUE_ID_LENGTH",41),p(Z,"MAX_BLUE_ID_LENGTH",45),p(Z,"BLUE_ID_PATTERN",/^[1-9A-HJ-NP-Za-km-z]{41,45}(?:#\d+)?$/);const ms=u.z.string().max(Z.MAX_BLUE_ID_LENGTH,{message:"Blue Id has a maximum length of 45 characters"}).min(Z.MIN_BLUE_ID_LENGTH,{message:"Blue Id has a minimum length of 41 characters"}).refine(r=>{try{return ae.default.decode(r),!0}catch{return!1}},{message:"Blue Id must be a valid Base58 string"}),Q=u.z.lazy(()=>u.z.record(u.z.unknown()).and(u.z.object({blueId:u.z.string().optional(),name:u.z.string().optional(),description:u.z.string().optional(),type:Q.optional(),value:u.z.union([u.z.string(),u.z.number(),u.z.boolean()]).optional().nullable(),items:u.z.array(Q).optional()}))),he=u.z.object({blueId:u.z.string().optional(),name:u.z.string().optional(),description:u.z.string().optional(),type:Q.optional()}),Is=he.extend({value:u.z.string().optional()}),bs=he.extend({value:u.z.number().optional()}),Ns=he.extend({value:u.z.boolean().optional()}),Ts=he.extend({items:u.z.array(u.z.string()).optional()}),vs=r=>Q.safeParse(r).success,ht=r=>c.isNonNullable(r)&&"blueId"in r&&c.isNonNullable(r.blueId),Bs=r=>c.isNonNullable(r)&&"name"in r&&c.isNonNullable(r.name),pt=r=>c.isNonNullable(r)&&"items"in r&&c.isNonNullable(r.items),ft=r=>c.isNonNullable(r)&&"type"in r&&c.isNonNullable(r.type),gt=r=>c.isNonNullable(r)&&"value"in r&&c.isNonNullable(r.value),ws=(r,e)=>r.required({type:!0}).safeParse(e).success,P=r=>r instanceof x,$=r=>P(r)&&r instanceof T,ge=r=>P(r)&&r instanceof w,Ss=u.z.lazy(()=>u.z.record(ce)),Ps=u.z.lazy(()=>u.z.union([u.z.array(ce),u.z.array(ce).readonly()])),ce=u.z.lazy(()=>u.z.union([c.jsonPrimitiveSchema,Ss,Ps,u.z.instanceof(x)])),We=r=>C.isObject(r)&&!C.isArray(r)&&!c.isReadonlyArray(r)&&!P(r),He=r=>C.isArray(r)||c.isReadonlyArray(r),Es=r=>He(r)||We(r)||P(r)||c.isJsonPrimitive(r);class y{static deserialize(e){return y.handleNode(e)}static handleNode(e){if(e===void 0)throw new Error("This is not a valid JSON-like value. Found 'undefined' as a value.");if(We(e)){const t=new d,s={};return Object.entries(e).forEach(([n,i])=>{switch(n){case q:if(i==null)t.setName(void 0);else{if(typeof i!="string")throw new Error(`The ${q} field must be a string.`);t.setName(i)}break;case X:if(i==null)t.setDescription(void 0);else{if(typeof i!="string")throw new Error(`The ${X} field must be a string.`);t.setDescription(i)}break;case fe:t.setType(y.handleNode(i));break;case _e:t.setItemType(y.handleNode(i));break;case ke:t.setKeyType(y.handleNode(i));break;case Ye:t.setValueType(y.handleNode(i));break;case Ne:t.setValue(y.handleValue(i));break;case _:if(typeof i!="string")throw new Error(`The ${_} field must be a string.`);t.setBlueId(i);break;case Je:t.setItems(y.handleArray(i));break;case Ke:t.setBlue(y.handleNode(i));break;default:s[n]=y.handleNode(i);break}}),Object.keys(s).length>0&&t.setProperties(s),t}else{if(He(e))return new d().setItems(y.handleArray(e));{const t=e;return new d().setValue(y.handleValue(t)).setInlineValue(!0)}}}static handleValue(e){if(e==null)return null;if(typeof e=="string")return e;if(typeof e=="number"||P(e))if($(e)||Number.isSafeInteger(e)){const t=new T(e.toString()),s=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER;return t.lt(s)?new T(s.toString()):t.gt(n)?new T(n.toString()):t}else{const t=parseFloat(e.toString());return new w(t.toString())}else if(typeof e=="boolean")return e;throw new Error(`Can't handle node: ${JSON.stringify(e)}`)}static handleArray(e){if(e!=null){if(C.isObject(e)&&!Array.isArray(e))return[y.handleNode(e)];if(Array.isArray(e))return e.map(y.handleNode);throw new Error("Expected an array node")}}}function As(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ae,rt;function Cs(){return rt||(rt=1,Ae=function r(e){if(typeof e=="number"&&isNaN(e))throw new Error("NaN is not allowed");if(typeof e=="number"&&!isFinite(e))throw new Error("Infinity is not allowed");return e===null||typeof e!="object"?JSON.stringify(e):e.toJSON instanceof Function?r(e.toJSON()):Array.isArray(e)?`[${e.reduce((n,i,o)=>`${n}${o===0?"":","}${r(i===void 0||typeof i=="symbol"?null:i)}`,"")}]`:`{${Object.keys(e).sort().reduce((s,n)=>{if(e[n]===void 0||typeof e[n]=="symbol")return s;const i=s.length===0?"":",";return`${s}${i}${r(n)}:${r(e[n])}`},"")}}`}),Ae}var Vs=Cs();const Ds=As(Vs);class yt{static canonicalize(e){return Ds(e)}}const Ce=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,me=class me{constructor(){p(this,"browserCrypto");this.browserCrypto=this.initBrowserCrypto()}static getInstance(){return this.instance||(this.instance=new me),this.instance}initBrowserCrypto(){return Ce?null:"crypto"in globalThis?globalThis.crypto:null}hasNodeCrypto(){return Ce&&!!Ee.default&&typeof Ee.default.createHash=="function"}getBrowserCrypto(){return this.browserCrypto}getNodeCrypto(){return Ce?Ee.default:null}};p(me,"instance");let Fe=me;class mt{constructor(){p(this,"cryptoEnv",Fe.getInstance())}applySync(e){const t=this.canonicalizeInput(e),s=this.cryptoEnv.hasNodeCrypto()?this.sha256Sync(t):this.sha256SyncBrowser(t);return ae.default.encode(new Uint8Array(s))}async apply(e){const t=this.canonicalizeInput(e),s=this.cryptoEnv.hasNodeCrypto()?this.sha256Sync(t):await this.sha256Async(t);return ae.default.encode(new Uint8Array(s))}canonicalizeInput(e){const t=yt.canonicalize(e);if(typeof t!="string")throw new Error("Canonized value must be a string");return t}sha256Sync(e){const t=this.cryptoEnv.getNodeCrypto();if(!t)throw new Error("Synchronous SHA-256 is not available in this environment");return t.createHash("sha256").update(e).digest()}sha256SyncBrowser(e){return is.sha256.arrayBuffer(e)}async sha256Async(e){if(this.cryptoEnv.hasNodeCrypto())return this.sha256Sync(e);const t=this.cryptoEnv.getBrowserCrypto();if(!t)throw new Error("crypto is not available in this environment");const n=new TextEncoder().encode(e);return t.subtle.digest("SHA-256",n)}}class b{static get(e,t="official"){var st;const s=e.getValue(),n=this.handleValue(s);if(n!==void 0&&t==="simple")return n;const i=(st=e.getItems())==null?void 0:st.map(H=>b.get(H,t));if(i!==void 0&&t==="simple")return i;const o=e.getName(),l=e.getDescription();if(t==="original"&&o===void 0&&l===void 0){if(n!==void 0)return n;if(i!==void 0)return i}const a={};o!==void 0&&(a[q]=o),l!==void 0&&(a[X]=l);const h=e.getType();if(t==="official"&&s!==void 0&&h===void 0){const H=this.inferTypeBlueId(s);H!==null&&(a[fe]={[_]:H})}else h!==void 0&&(a[fe]=b.get(h,t));const I=e.getItemType();I!==void 0&&(a[_e]=b.get(I,t));const m=e.getKeyType();m!==void 0&&(a[ke]=b.get(m,t));const f=e.getValueType();f!==void 0&&(a[Ye]=b.get(f,t)),n!==void 0&&(a[Ne]=n),i!==void 0&&(a[Je]=i);const g=e.getBlueId();g!==void 0&&(a[_]=g);const O=e.getBlue();O!==void 0&&(a[Ke]=O);const W=e.getProperties();return W!==void 0&&Object.entries(W).forEach(([H,ts])=>{a[H]=b.get(ts,t)}),a}static handleValue(e){if(P(e)){if($(e)){const t=new x(Number.MIN_SAFE_INTEGER.toString()),s=new x(Number.MAX_SAFE_INTEGER.toString());if(e.lt(t)||e.gt(s))return e.toString()}return e.toNumber()}return e}static inferTypeBlueId(e){return typeof e=="string"?Y:P(e)?$(e)?K:J:typeof e=="boolean"?G:null}}const Os=r=>c.isJsonPrimitive(r)&&c.isNonNullable(r),R=class R{constructor(e){p(this,"hashProvider");this.hashProvider=e}static calculateBlueId(e){if(Array.isArray(e)){const s=e.map(n=>b.get(n));return R.INSTANCE.calculate(s)}const t=b.get(e);return R.INSTANCE.calculate(t)}static calculateBlueIdSync(e){if(Array.isArray(e)){const s=e.map(n=>b.get(n));return R.INSTANCE.calculateSync(s)}const t=b.get(e);return R.INSTANCE.calculateSync(t)}calculate(e){const t=this.cleanStructure(e);if(t===void 0)throw new Error("Object after cleaning cannot be null or undefined.");return this.internalCalculate(t,!1)}calculateSync(e){const t=this.cleanStructure(e);if(t===void 0)throw new Error("Object after cleaning cannot be null or undefined.");return this.internalCalculate(t,!0)}internalCalculate(e,t){return Os(e)||P(e)?this.applyHash(e.toString(),t):Array.isArray(e)||c.isReadonlyArray(e)?this.calculateList(e,t):this.calculateMap(e,t)}calculateMap(e,t){if(e[_]!==void 0)return e[_];const n=Object.keys(e).map(o=>{const l=e[o];if([q,Ne,X].includes(o))return t?[o,l]:Promise.resolve([o,l]);{const a=this.internalCalculate(l,t);return t?[o,{blueId:a}]:Promise.resolve(a).then(h=>[o,{blueId:h}])}}),i=o=>{const l={};for(const[a,h]of o)l[a]=h;return this.applyHash(l,t)};return t?i(n):Promise.all(n).then(i)}calculateList(e,t){if(e.length===0)throw new Error("Cannot calculate BlueId for an empty list.");let s=this.internalCalculate(e[0],t);const n=(i,o)=>t?this.applyHash([{blueId:i},{blueId:o}],!0):Promise.all([i,o]).then(([l,a])=>this.applyHash([{blueId:l},{blueId:a}],!1));for(let i=1;i<e.length;i++){const o=this.internalCalculate(e[i],t);s=n(s,o)}return s}applyHash(e,t){return t?this.hashProvider.applySync(e):this.hashProvider.apply(e)}cleanStructure(e){if(e!=null){if(c.isJsonPrimitive(e)||P(e))return e;if(Array.isArray(e)||c.isReadonlyArray(e)){const t=e.map(s=>this.cleanStructure(s)).filter(c.isNonNullable);return t.length>0?t:void 0}else if(typeof e=="object"){const t={};for(const s in e){const n=this.cleanStructure(e[s]);n!=null&&(t[s]=n)}return Object.keys(t).length>0?t:void 0}else return e}}};p(R,"INSTANCE",new R(new mt));let N=R;class Ms{static convert(e){const t=ae.default.decode(e),s=new Uint8Array(2+t.length);s[0]=18,s[1]=32,s.set(t,2);const n=new Uint8Array(2+s.length);return n[0]=1,n[1]=85,n.set(s,2),"b"+new ls.Encoder({type:"rfc4648",lc:!0}).write(n).finalize().replace(/=/g,"")}}class D{static transform(e,t){const s=t(e.clone()),n=s.getType();n!==void 0&&s.setType(D.transform(n,t));const i=s.getItemType();i!==void 0&&s.setItemType(D.transform(i,t));const o=s.getKeyType();o!==void 0&&s.setKeyType(D.transform(o,t));const l=s.getValueType();l!==void 0&&s.setValueType(D.transform(l,t));const a=s.getItems();if(a!==void 0){const I=a.map(m=>D.transform(m,t));s.setItems(I)}const h=s.getProperties();if(h!==void 0){const I=Object.keys(h).reduce((m,f)=>(m[f]=D.transform(h[f],t),m),{});s.setProperties(I)}return s}}const L=r=>!!r&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof d),M=r=>r instanceof T||r instanceof w,Fs=r=>r.replace(/~1/g,"/").replace(/~0/g,"~");function se(r){if(r==="/")return[];if(!r.startsWith("/"))throw new Error(`Path must start with '/': ${r}`);return r.split("/").slice(1).map(Fs)}function ee(r){if(r==="-")return-1;const e=typeof r=="number"?r:parseInt(r,10);if(isNaN(e))throw new Error(`Invalid array index (NaN) from '${r}'`);if(!Number.isFinite(e))throw new Error(`Invalid array index '${r}' results in non-finite number ${e}`);return e}function It(r,e,t,s=!0){switch(e){case"name":return t?s?r.getName()??null:r:r.getName();case"description":return t?s?r.getDescription():r:r.getDescription();case"type":return r.getType();case"itemType":return r.getItemType();case"keyType":return r.getKeyType();case"valueType":return r.getValueType();case"value":return t?s?r.getValue()??null:r:r.getValue();case"blueId":return t?s?r.getBlueId()??null:r:r.getBlueId();case"blue":return r.getBlue();case"items":return r.getItems();case"properties":return r.getProperties();case"contracts":return r.getContracts();default:return}}function nt(r,e,t=!0){if(r instanceof d){const s=It(r,e,!0,t);if(s!==void 0||["name","description","type","itemType","keyType","valueType","value","blueId","blue","items","properties","contracts"].includes(e))return s;if(/^-?\d+$/.test(e)&&e!=="-"){const i=r.getItems(),o=parseInt(e,10);return i&&o>=0&&o<i.length?i[o]:void 0}const n=r.getProperties();return n&&e in n?n[e]:void 0}if(Array.isArray(r)){if(e==="-")return;const s=ee(e);return s>=0&&s<r.length?r[s]:void 0}if(L(r))return r[e]}function re(r,e){if(e.length===0)return{parent:r,key:"value",actualTarget:r.getValue()??r};let t=r;for(let n=0;n<e.length-1;++n){const i=e[n],o=nt(t,i);if(o===void 0)throw new Error(`Cannot resolve '/${e.slice(0,n+1).join("/")}'`);t=o}const s=e[e.length-1];if(t instanceof d){const n=nt(t,s,!1);if((typeof n!="object"||n===null||M(n))&&!(n instanceof d)&&!Array.isArray(n)&&["name","description","value","blueId"].includes(s))return{parent:t,key:s,actualTarget:n}}return Array.isArray(t)&&s==="-"?{parent:t,key:"-"}:t instanceof d&&t.getItems()&&s==="-"?{parent:t,key:"-"}:{parent:t,key:Array.isArray(t)?ee(s):s}}function qe(r,e){var t;if(r instanceof d){const s=e,n=It(r,s,!1);if(n!==void 0||["name","description","type","itemType","keyType","valueType","value","blueId","blue","items","properties","contracts"].includes(s))return n;if(typeof e=="number"||typeof e=="string"&&/^\d+$/.test(e)){const i=r.getItems(),o=typeof e=="number"?e:parseInt(e,10);if(i&&o>=0&&o<i.length)return i[o]}return(t=r.getProperties())==null?void 0:t[s]}return Array.isArray(r)||L(r)?r[e]:r}function B(r){if(r instanceof d)return r;if(r===null||typeof r=="string"||typeof r=="number"||typeof r=="boolean"||M(r))return y.deserialize(r);const e=Re(r);return y.deserialize(e)}function Re(r){if(r===void 0)return null;if(r===null||typeof r!="object")return r;if(Array.isArray(r))return r.map(Re);const e={};for(const[t,s]of Object.entries(r))e[t]=Re(s);return e}function Xe(r,e,t){if(r instanceof d){const s=e;switch(s){case"name":r.setName(t);return;case"description":r.setDescription(t);return;case"type":r.setType(t instanceof d||typeof t=="string"||t===void 0?t:B(t));return;case"itemType":r.setItemType(t instanceof d||typeof t=="string"||t===void 0?t:B(t));return;case"keyType":r.setKeyType(t instanceof d||typeof t=="string"||t===void 0?t:B(t));return;case"valueType":r.setValueType(t instanceof d||typeof t=="string"||t===void 0?t:B(t));return;case"value":{const n=t;r.setValue(n===void 0?null:n);return}case"blueId":r.setBlueId(t);return;case"blue":r.setBlue(t instanceof d||t===void 0?t:B(t));return;case"items":r.setItems(t);return;case"properties":r.setProperties(t);return;case"contracts":r.setContracts(t);return;default:{if(t===void 0){const n=r.getProperties();n&&s in n&&delete n[s]}else r.getProperties()||r.setProperties({}),r.addProperty(s,t instanceof d?t:B(t));return}}}Array.isArray(r)?r.splice(ee(e),1):L(r)&&(t===void 0?delete r[e]:r[e]=t)}function Rs(r,e,t,s){let n=-1;if(e!=="-"&&(n=typeof e=="number"?e:parseInt(e,10),isNaN(n)))throw new Error(`Invalid numeric key for BlueNode item operation: ${e}`);if(n<-1)throw new Error(`Invalid array index for BlueNode items: ${n}`);let i=r.getItems();if(i||(i=[],r.setItems(i)),!s&&n!==-1&&n>i.length)throw new Error(`ADD operation failed: Target array index '${n}' is greater than array length ${i.length}.`);if(e==="-")i.push(t);else if(s){if(n>=0)if(n<i.length)i[n]=t;else{for(let o=i.length;o<n;o++)i.push(y.deserialize(null));i.push(t)}}else i.splice(n,0,t)}function ye(r,e,t,s){if(Array.isArray(r)){const n=e==="-"?r.length:ee(e);if(!s&&n>r.length)throw new Error(`ADD operation failed: Target array index '${n}' is greater than array length ${r.length}. Path involving key '${e}'.`);if(n<0&&e!=="-")throw new Error(`Invalid negative array index: ${e}`);const i=B(t);if(s){if(n>=0&&n<r.length)r[n]=i;else if(n>=r.length){for(let o=r.length;o<n;o++)r.push(y.deserialize(null));r.push(i)}}else r.splice(n,0,i);return}if(r instanceof d){e==="-"||typeof e=="number"&&!isNaN(e)||typeof e=="string"&&/^\d+$/.test(e)?Rs(r,e,B(t),s):Xe(r,e,t);return}if(L(r)){r[e]=B(t);return}throw new Error(`Cannot insert into parent of type ${typeof r}`)}function js(r,e){if(Array.isArray(r)){const t=ee(e);t===-1&&e==="-"?r.length>0&&r.pop():t>=0&&t<r.length&&r.splice(t,1);return}if(r instanceof d){if(typeof e=="number"||typeof e=="string"&&/^-?\d+$/.test(e)){const t=r.getItems();if(t){const s=ee(e);s===-1&&e==="-"?t.length>0&&t.pop():s>=0&&s<t.length&&t.splice(s,1),t.length===0&&r.setItems(void 0);return}}Xe(r,e,void 0)}else L(r)&&delete r[e]}function je(r){if(r instanceof d)return r.clone();if(Array.isArray(r))return r.map(t=>je(t));if(L(r)){const e={};return Object.keys(r).forEach(t=>{e[t]=je(r[t])}),e}return r}function U(r,e){if(r===e||r instanceof d&&(r.isInlineValue()||r.getValue()!==void 0)&&U(r.getValue()??null,e)||e instanceof d&&(e.isInlineValue()||e.getValue()!==void 0)&&U(r,e.getValue()??null))return!0;if(r instanceof d&&e instanceof d||M(r)&&M(e)||M(r)&&typeof e=="number"||typeof r=="number"&&M(e))return r.toString()===e.toString();if(Array.isArray(r)&&Array.isArray(e))return r.length===e.length&&r.every((t,s)=>U(t,e[s]));if(L(r)&&L(e)){const t=Object.keys(r),s=Object.keys(e);return t.length===s.length&&t.every(n=>U(r[n],e[n]))}return!1}function bt(r,e){const{parent:t,key:s}=re(r,se(e));return qe(t,s)}function Nt(r,e,t){const s=se(e);if(s.length===0&&e==="/"){const o=B(t);r.setValue(o.getValue()??null),o.getItems()?r.setItems(o.getItems()):r.setItems(void 0);return}const{parent:n,key:i}=re(r,s);ye(n,i,t,!0)}function xs(r,e,t){const s=se(e);if(s.length===0&&e==="/"){if(r.getItems()&&Array.isArray(t)){const o=B(t);o.getItems()?(r.setItems(o.getItems()),r.setValue(null)):(r.setValue(o.getValue()??null),r.setItems(void 0))}else{const o=B(t);r.setValue(o.getValue()??null),o.getItems()&&r.setItems(o.getItems())}return!0}const{parent:n,key:i}=re(r,s);return ye(n,i,t,!1),!0}function $s(r,e,t){const s=se(e);if(s.length===0&&e==="/"){const l=B(t);return r.setValue(l.getValue()??null),l.getItems()?r.setItems(l.getItems()):r.setItems(void 0),!0}const{parent:n,key:i,actualTarget:o}=re(r,s);if(o!==void 0&&n instanceof d)Xe(n,i,t);else{const l=qe(n,i),a=Array.isArray(n)||n instanceof d&&n.getItems()&&(typeof i=="number"||typeof i=="string"&&/^\d+$/.test(i));if(l===void 0){if(a)throw new Error(`REPLACE failed: Target array index '${i.toString()}' is out of bounds or does not exist at path '${e}'.`);ye(n,i,t,!0)}else ye(n,i,t,!0)}return!0}function Tt(r,e){const t=se(e);if(t.length===0&&e==="/")return r.setValue(null),r.setItems(void 0),r.setProperties(void 0),!0;const{parent:s,key:n}=re(r,t);return js(s,n),!0}function Ls(r,e,t){const s=je(bt(r,e));return Nt(r,t,s),!0}function zs(r,e,t){const s=se(e),{parent:n,key:i}=re(r,s),o=qe(n,i);if(o===void 0)throw new Error(`MOVE failed: 'from' location '${e}' does not exist.`);return Tt(r,e)?(Nt(r,t,o),!0):!1}function Us(r,e,t){const s=bt(r,e);let n=t;if(s instanceof d)if((t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"||M(t))&&(s.isInlineValue()||s.getValue()!==void 0)){if(!U(s.getValue()??null,t))throw new Error(`TEST failed at '${e}': Expected ${JSON.stringify(t)}, got ${JSON.stringify(s.getValue()??null)}`);return!0}else typeof t=="object"&&!(t instanceof d)&&(n=B(t));else if(M(s)&&typeof t=="number")s instanceof T?n=new T(t.toString()):s instanceof w&&(n=new w(t.toString()));else if((s===null||typeof s=="string"||typeof s=="number"||typeof s=="boolean")&&M(t)){const i=t;!U(s,i.toString())&&(typeof s=="number"&&parseFloat(i.toString()))}if(!U(s,n)){const i=s instanceof d?s.toString():JSON.stringify(s),o=n instanceof d?n.toString():JSON.stringify(n);throw new Error(`TEST failed at '${e}': Expected ${o}, got ${i}`)}return!0}function Zs(r,e){switch(e.op){case"add":return xs(r,e.path,e.val);case"replace":return $s(r,e.path,e.val);case"remove":return Tt(r,e.path);case"copy":return Ls(r,e.from,e.path);case"move":return zs(r,e.from,e.path);case"test":return Us(r,e.path,e.val)}}function _s(r,e,t=!1){const s=t?r:r.clone();return Zs(s,e),s}const Ve=Symbol.for("zod-schema-annotations");function ks(){if(typeof globalThis<"u")return globalThis;if(typeof global<"u")return global;if(typeof window<"u")return window;if(typeof self<"u")return self;throw new Error("Unable to locate global object")}function vt(){const r=ks();return Ve in r||(r[Ve]=new WeakMap),r[Ve]}function ne(r,e){const t=vt(),s=t.get(r)||{};return t.set(r,{...s,...e}),r}const V=r=>vt().get(r),Bt=r=>e=>{const t=V(e);return ne(e,{...t,blueDescription:r})},wt=r=>{const e=V(r);return c.isNonNullable(e)&&C.isString(e.blueDescription)?e.blueDescription:null},Ys=r=>Bt(r)(u.z.string().optional()),Js=u.z.union([u.z.string(),u.z.boolean()]),St=r=>e=>{const t=V(e);return ne(e,{...t,blueId:r})},Pt=r=>{const e=V(r),t=Js.safeParse(e==null?void 0:e.blueId);return t.success?t.data:null},Ks=r=>St(r??!0)(u.z.string()),Et=r=>e=>{const t=V(e);return ne(e,{...t,blueName:r})},At=r=>{const e=V(r);return c.isNonNullable(e)&&C.isString(e.blueName)?e.blueName:null},Gs=r=>{const e=u.z.string().optional();return Et(r)(e)},Ct=()=>r=>{const e=V(r);return ne(r,{...e,blueNode:!0})},Vt=r=>{const e=V(r);return c.isNonNullable(e)&&c.isNonNullable(e.blueNode)&&e.blueNode===!0?e.blueNode:null},Qe=r=>!!Vt(r),Ws=()=>{const r=u.z.instanceof(d);return Ct()(r)},xe="extendedFrom",Dt=({schema:r,baseSchema:e})=>{const t=V(r)||{};return ne(r,{...t,[xe]:e})},Ot=r=>{const e=V(r);return c.isNonNullable(e)&&e[xe]?e[xe]:null},et=(r,e)=>{const t=Ot(r);return c.isNullable(t)?!1:(t==null?void 0:t._def)===(e==null?void 0:e._def)?!0:et(t,e)},Hs=r=>new Proxy(r,{get(e,t,s){return t==="extend"?function(...n){const i=e.extend(...n);return Dt({schema:i,baseSchema:e})}:Reflect.get(e,t,s)}}),qs=u.z.object({value:u.z.array(u.z.string()).optional(),defaultValue:u.z.string().optional()}),Mt=r=>{const e=V(r),t=qs.passthrough().safeParse(e==null?void 0:e.typeBlueId);return t.success?t.data:null},Xs=r=>e=>{const t=V(e),s=typeof r=="string"?{value:[r]}:r,n=Hs(e);return ne(n,{...t,typeBlueId:{...(t==null?void 0:t.typeBlueId)||{},...s}})};class Te{static resolveBlueId(e){var i;const t=Mt(e);if(c.isNullable(t))return null;const s=t.defaultValue;if(c.isNonNullable(s))return s;const n=(i=t.value)==null?void 0:i[0];return c.isNonNullable(n)?n:Te.getRepositoryBlueId(t,e)}static getRepositoryBlueId(e,t){throw new Error("Not implemented")}}class A{static isTypeOf(e,t,s){var o;const n=Te.resolveBlueId(t),i=(o=e.getType())==null?void 0:o.getBlueId();if(c.isNullable(n)||c.isNullable(i))return!1;if(n===i)return!0;if(s!=null&&s.checkSchemaExtensions&&c.isNonNullable(s.typeSchemaResolver)){const l=s.typeSchemaResolver.resolveSchema(e);return A.checkSchemaExtension(l,t)}return!1}static checkSchemaExtension(e,t){if(!c.isNonNullable(e))return!1;const s=A.unwrapSchema(e),n=A.unwrapSchema(t);return et(s,n)}static isWrapperType(e){return e instanceof u.ZodOptional||e instanceof u.ZodNullable||e instanceof u.ZodReadonly||e instanceof u.ZodBranded||e instanceof u.ZodEffects||e instanceof u.ZodLazy}static unwrapSchema(e){return Qe(e)?e:A.isWrapperType(e)?e instanceof u.ZodEffects?A.unwrapSchema(e.innerType()):e instanceof u.ZodLazy?A.unwrapSchema(e.schema):A.unwrapSchema(e.unwrap()):e}}class Ft{constructor(e){p(this,"blueIdMap",new Map);this.registerSchemas(e)}registerSchemas(e){for(const t of e)this.registerSchema(t)}registerSchema(e){const t=Te.resolveBlueId(e);if(c.isNonNullable(t)){if(this.blueIdMap.has(t))throw new Error(`Duplicate BlueId value: ${t}`);this.blueIdMap.set(t,e)}}resolveSchema(e){const t=this.getEffectiveBlueId(e);return c.isNullable(t)?null:this.blueIdMap.get(t)}getEffectiveBlueId(e){const t=e.getType();return c.isNonNullable(t)&&c.isNonNullable(t.getBlueId())?t.getBlueId():c.isNonNullable(t)?N.calculateBlueIdSync(t):null}getBlueIdMap(){return new Map(this.blueIdMap)}}const v={NAME:"name",DESCRIPTION:"description",TYPE:"type",BLUE_ID:"blue_id",KEY_TYPE:"key_type",VALUE_TYPE:"value_type",ITEM_TYPE:"item_type",VALUE:"value",PROPERTIES:"properties",BLUE:"blue",ITEMS:"items"};class ve{static isEmptyNode(e){return this.hasFieldsAndMayHaveFields(e)}static hasBlueIdOnly(e){return this.hasFieldsAndMayHaveFields(e,new Set([v.BLUE_ID]))}static hasItemsOnly(e){return this.hasFieldsAndMayHaveFields(e,new Set([v.ITEMS]))}static isValidValueNode(e){const t=e.getValue(),s=e.getProperties(),n=e.getItems();return c.isNonNullable(t)&&c.isNullable(s)&&c.isNullable(n)}static textNode(e){return new d().setType(new d().setBlueId(Y)).setValue(e)}static integerNode(e){const t=e instanceof T?e:new T(e.toString());return new d().setType(new d().setBlueId(K)).setValue(t)}static doubleNode(e){const t=e instanceof w?e:new w(e.toString());return new d().setType(new d().setBlueId(J)).setValue(t)}static booleanNode(e){return new d().setType(new d().setBlueId(G)).setValue(e)}static hasFieldsAndMayHaveFields(e,t=new Set,s=new Set){for(const n of Object.values(v)){const i=c.isNonNullable(this.getFieldValue(e,n));if(t.has(n)){if(!i)return!1}else if(!s.has(n)){if(i)return!1}}return!0}static getFieldValue(e,t){switch(t){case v.NAME:return e.getName();case v.TYPE:return e.getType();case v.VALUE:return e.getValue();case v.DESCRIPTION:return e.getDescription();case v.PROPERTIES:return e.getProperties();case v.BLUE:return e.getBlue();case v.ITEMS:return e.getItems();case v.KEY_TYPE:return e.getKeyType();case v.VALUE_TYPE:return e.getValueType();case v.ITEM_TYPE:return e.getItemType();case v.BLUE_ID:return e.getBlueId();default:throw new Error(`Unknown field: ${t}`)}}}class Be{}class ie{static convert(e){const t=new $e;return ie.traverseNode(e,"",t),t.build()}static traverseNode(e,t,s){if(!e)return;const n=e.getProperties(),i=e.getItems(),o=n!==void 0&&Object.keys(n).length>0,l=i!==void 0&&i.length>0;if(!o&&!l){s.addPath(t===""?"/":t);return}if(n)for(const[a,h]of Object.entries(n)){const I=`${t}/${a}`;ie.traverseNode(h,I,s)}if(i)for(let a=0;a<i.length;a++){const h=`${t}/${a}`;ie.traverseNode(i[a],h,s)}}}function it(r,e){const t=r.split(e),s=[...t].reverse().findIndex(i=>i!==""),n=s===-1?0:t.length-s;return t.slice(0,n)}class we extends Be{constructor(t,s){super();p(this,"allowedPaths");p(this,"maxDepth");p(this,"currentPath",[]);this.allowedPaths=t,this.maxDepth=s}shouldExtendPathSegment(t){if(this.currentPath.length>=this.maxDepth)return!1;const s=this.normalizePath(this.getCurrentFullPath()+"/"+t);return this.isAllowedPath(s)}shouldMergePathSegment(t){return this.shouldExtendPathSegment(t)}isAllowedPath(t){for(const s of this.allowedPaths)if(this.matchesAllowedPath(s,t))return!0;return!1}matchesAllowedPath(t,s){const n=it(t,"/"),i=it(s,"/");if(i.length>n.length)return!1;for(let o=1;o<i.length;o++)if(n[o]!=="*"&&n[o]!==i[o])return!1;return!0}enterPathSegment(t){this.currentPath.push(t)}exitPathSegment(){this.currentPath.length>0&&this.currentPath.pop()}getCurrentFullPath(){return"/"+this.currentPath.join("/")}normalizePath(t){return"/"+t.split("/").filter(s=>s!=="").join("/")}static withMaxDepth(t){const s=new $e().setMaxDepth(t);for(let n=1;n<=t;n++){const i="/"+Array(n).fill("*").join("/");s.addPath(i)}return s.build()}static withSinglePath(t){return new $e().addPath(t).build()}static fromNode(t){return ie.convert(t)}}class $e{constructor(){p(this,"allowedPaths",new Set);p(this,"maxDepth",Number.MAX_SAFE_INTEGER)}addPath(e){return this.allowedPaths.add(e),this}setMaxDepth(e){return this.maxDepth=e,this}build(){return new we(this.allowedPaths,this.maxDepth)}}class Qs extends Be{shouldExtendPathSegment(){return!0}shouldMergePathSegment(){return!0}enterPathSegment(){}exitPathSegment(){}}class Se extends Be{constructor(t){super();p(this,"limits");this.limits=t}shouldExtendPathSegment(t,s){return this.limits.every(n=>n.shouldExtendPathSegment(t,s))}shouldMergePathSegment(t,s){return this.limits.every(n=>n.shouldMergePathSegment(t,s))}enterPathSegment(t,s){this.limits.forEach(n=>{n.enterPathSegment(t,s)})}exitPathSegment(){this.limits.forEach(t=>{t.exitPathSegment()})}static of(...t){return new Se(t)}}const z=new Qs;function ot(r,e){const t=r.getType();if(t===void 0)return;const s=t.getBlueId();if(s!==void 0){if(de.includes(s)){const i=ys[s];return new d().setBlueId(s).setName(i)}const n=e.fetchByBlueId(s);if(!n||n.length===0)return;if(n.length>1)throw new Error(`Expected a single node for type with blueId '${s}', but found multiple.`);return n[0]}return t}function S(r,e,t){const s=N.calculateBlueIdSync(r),n=N.calculateBlueIdSync(e);if(s===n)return!0;if(s&&de.includes(s)){let a=e;for(;a!==void 0;){if(N.calculateBlueIdSync(a)===s)return!0;a=ot(a,t)}return!1}let i=r;const o=r.getBlueId();if(o){const a=t.fetchByBlueId(o);a&&a.length===1&&(i=a[0])}let l=i;for(;l!==void 0;){if(N.calculateBlueIdSync(l)===n)return!0;l=ot(l,t)}return!1}function er(r,e){return dt.some(t=>{const s=new d().setBlueId(t);return S(r,s,e)})}function tr(r,e){const t=new d().setBlueId(Y);return S(r,t,e)}function sr(r,e){const t=new d().setBlueId(K);return S(r,t,e)}function rr(r,e){const t=new d().setBlueId(J);return S(r,t,e)}function nr(r,e){const t=new d().setBlueId(G);return S(r,t,e)}function Rt(r){return(r==null?void 0:r.getBlueId())===ct}function jt(r){return(r==null?void 0:r.getBlueId())===ut}function ir(r,e){return Ge.some(t=>{const s=new d().setName(t);return S(r,s,e)})}function or(r,e){for(const t of Ge){const s=new d().setName(t);if(S(r,s,e))return t}throw new Error(`Cannot determine the basic type for node of type "${r.getName()||"unknown"}".`)}class lr{constructor(e){p(this,"blue");this.blue=e}matchesType(e,t,s=z){const n=t.getType();if(this.matchesImplicitStructure(e,n))return!0;const i=we.fromNode(t),o=Se.of(s,i),l=this.extendAndResolve(e,o),a=this.blue.resolve(t,o);return this.verifyMatch(l,t,o)&&this.recursiveValueComparison(l,a)}extendAndResolve(e,t){const s=e.clone(),n=s.clone();this.blue.extend(n,t);const i=this.blue.resolve(n,t);return this.restoreMissingStructure(i,s),i}restoreMissingStructure(e,t){const s=t.getItems(),n=e.getItems();if(s&&s.length>0)if(!n||n.length===0)e.setItems(s.map(a=>a.clone()));else for(let a=0;a<Math.min(n.length,s.length);a++)this.restoreMissingStructure(n[a],s[a]);const i=t.getProperties();if(i){let a=e.getProperties();a||(a={},e.setProperties(a));for(const[h,I]of Object.entries(i)){const m=a[h];m===void 0?a[h]=I.clone():this.restoreMissingStructure(m,I)}}const o=t.getBlueId();e.getBlueId()===void 0&&o!==void 0&&e.setBlueId(o);const l=t.getValue();e.getValue()===void 0&&l!==void 0&&e.setValue(l)}verifyMatch(e,t,s){const n=t.getType();if(this.matchesImplicitStructure(e,n))return!0;const i=e.clone().setType(t.clone());try{this.blue.resolve(i,s)}catch{return!1}return!0}recursiveValueComparison(e,t){var m;const s=t.getType(),n=this.matchesImplicitStructure(e,s);if(s&&!n){const f=e.getType();if(!f||!S(f,s,this.blue.getNodeProvider()))return!1}const i=t.getBlueId();if(!n&&i!==void 0){const f=e.getBlueId(),g=(m=e.getType())==null?void 0:m.getBlueId();if(f!==void 0){if(i!==f)return!1}else if(g===void 0||i!==g)return!1}const o=t.getValue();if(o!==void 0){const f=e.getValue();if(f===void 0)return!1;if(P(f)&&P(o)){if(!f.eq(o))return!1}else if(f!==o)return!1}const l=t.getItems();if(l!==void 0){const f=e.getItems()??[];for(let g=0;g<l.length;g++)if(g<f.length){if(!this.recursiveValueComparison(f[g],l[g]))return!1}else if(this.hasValueInNestedStructure(l[g]))return!1}const a=t.getItemType();if(a!==void 0){const f=e.getItems()??[];for(const g of f)if(!this.recursiveValueComparison(g,a))return!1}const h=t.getProperties();if(h!==void 0){const f=e.getProperties()??{};for(const[g,O]of Object.entries(h))if(g in f){if(!this.recursiveValueComparison(f[g],O))return!1}else if(this.hasValueInNestedStructure(O))return!1}const I=t.getValueType();if(I!==void 0){const f=Object.values(e.getProperties()??{});for(const g of f)if(!this.recursiveValueComparison(g,I))return!1}return!0}hasValueInNestedStructure(e){if(e.getValue()!==void 0)return!0;const t=e.getItems();if(t!==void 0){for(const n of t)if(this.hasValueInNestedStructure(n))return!0}const s=e.getProperties();if(s!==void 0){for(const n of Object.values(s))if(this.hasValueInNestedStructure(n))return!0}return!1}matchesImplicitStructure(e,t){return t===void 0||e.getType()!==void 0?!1:Rt(t)?this.isImplicitListStructure(e):jt(t)?this.isImplicitDictionaryStructure(e):!1}isImplicitListStructure(e){return e.getItems()!==void 0&&e.getValue()===void 0}isImplicitDictionaryStructure(e){return e.getProperties()!==void 0&&e.getValue()===void 0}}const ar=r=>r instanceof u.ZodOptional||r instanceof u.ZodNullable||r instanceof u.ZodReadonly||r instanceof u.ZodBranded||r instanceof u.ZodEffects||r instanceof u.ZodLazy,cr=r=>r instanceof u.ZodString||r instanceof u.ZodNumber||r instanceof u.ZodBoolean||r instanceof u.ZodBigInt;class xt{static convertValue(e,t){var i;const s=(i=e.getType())==null?void 0:i.getBlueId(),n=e.getValue();return c.isNullable(n)?cr(t)&&ve.isValidValueNode(e)?this.getDefaultPrimitiveValue(t):n:Y===s?this.convertFromString(String(n),t):J===s||n instanceof w?this.convertFromBigDecimal(new w(n==null?void 0:n.toString()),t):K===s||n instanceof T?this.convertFromBigInteger(new T(n==null?void 0:n.toString()),t):G===s||typeof n=="boolean"?this.convertFromBoolean(!!n,t):this.convertFromString(String(n),t)}static convertFromString(e,t){if(!t||t instanceof u.ZodString||t instanceof u.ZodEnum||t instanceof u.ZodNativeEnum)return e;if(t instanceof u.ZodNumber)return Number(e);if(t instanceof u.ZodBoolean)return e.toLowerCase()==="true";if(t instanceof u.ZodBigInt)return BigInt(e);throw new Error(`Cannot convert String to ${t._def.typeName}`)}static convertFromBigDecimal(e,t){if(t instanceof u.ZodNumber)return e.toNumber();if(t instanceof u.ZodString)return e.toString();throw new Error(`Cannot convert Number to ${t._def.typeName}`)}static convertFromBigInteger(e,t){if(t instanceof u.ZodNumber)return e.toNumber();if(t instanceof u.ZodBigInt)return BigInt(e.toString());if(t instanceof u.ZodString)return e.toString();throw new Error(`Cannot convert Number to ${t._def.typeName}`)}static convertFromBoolean(e,t){if(!t||t instanceof u.ZodBoolean)return e;if(t instanceof u.ZodString)return e.toString();if(t instanceof u.ZodNumber)return Number(e);if(t instanceof u.ZodBigInt)return BigInt(e);throw new Error(`Cannot convert Boolean to ${t._def.typeName}`)}static getDefaultPrimitiveValue(e){if(!e)return null;if(e instanceof u.ZodNumber)return 0;if(e instanceof u.ZodBoolean)return!1;if(e instanceof u.ZodString)return"";throw new Error(`Unsupported primitive type: ${e._def.typeName}`)}}class ur{convert(e,t){return xt.convertValue(e,t)}}class dr{constructor(e){this.nodeToObjectConverter=e}convert(e,t){return this.convertFields(e,t)}convertFields(e,t){if(t instanceof u.ZodIntersection){const s=t._def.left,n=t._def.right,i=this.convert(e,s),o=this.convert(e,n);return{...i,...o}}if(t instanceof u.ZodUnion)throw new Error("Union not supported");if(t instanceof u.ZodObject)return Object.keys(t.shape).reduce((n,i)=>{const o=e.getProperties(),l=t.shape[i],a=Pt(l);if(c.isNonNullable(a)){const g=C.isString(a)?a:i,O=o==null?void 0:o[g],W=O?N.calculateBlueIdSync(O):void 0;return n[i]=W,n}const h=At(l);if(c.isNonNullable(h)){const g=o==null?void 0:o[h];return n[i]=g==null?void 0:g.getName(),n}const I=wt(l);if(c.isNonNullable(I)){const g=o==null?void 0:o[I];return n[i]=g==null?void 0:g.getDescription(),n}if(i==="name"){const g=e.getName();return n[i]=g,n}if(i==="description"){const g=e.getDescription();return n[i]=g,n}const m=o==null?void 0:o[i];if(c.isNullable(m))return n;const f=this.nodeToObjectConverter.convert(m,l);return n[i]=f,n},{});throw new Error("Unknown schema type, "+t._def.typeName)}}class hr{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const s=e.getItems();if(!s)return;const n=t.element;return s.map(o=>this.nodeToObjectConverter.convert(o,n))}}class pr{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const s=e.getItems();if(!s)return;const n=t._def.valueType,i=s.map(o=>this.nodeToObjectConverter.convert(o,n));return new Set(i)}}class fr{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const s=t.keySchema,n=t.valueSchema,i=new Map,o=e.getName();c.isNonNullable(o)&&i.set(q,o);const l=e.getDescription();c.isNonNullable(l)&&i.set(X,l);const a=e.getProperties();return c.isNonNullable(a)&&Object.entries(a).forEach(([h,I])=>{const m=new d().setValue(h);m.setType(new d().setBlueId(Y));const f=xt.convertValue(m,s),g=this.nodeToObjectConverter.convert(I,n);i.set(f,g)}),t instanceof u.ZodRecord?Object.fromEntries(i):i}}class gr{convert(e){return b.get(e)}}class yr{convert(e){return b.get(e)}}class mr{constructor(e){this.nodeToObjectConverter=e}convert(e,t){const s=e.getItems();if(!s)return;const n=t.items;return s.map((o,l)=>this.nodeToObjectConverter.convert(o,n[l]))}}const Ir=u.z.union([u.z.literal("ZodString"),u.z.literal("ZodNumber"),u.z.literal("ZodBoolean"),u.z.literal("ZodBigInt"),u.z.literal("ZodArray"),u.z.literal("ZodSet"),u.z.literal("ZodMap"),u.z.literal("ZodRecord"),u.z.literal("ZodObject"),u.z.literal("ZodEnum"),u.z.literal("ZodNativeEnum"),u.z.literal("ZodUnknown"),u.z.literal("ZodAny"),u.z.literal("ZodTuple")]);class br{constructor(e){p(this,"converters",new Map);p(this,"complexObjectConverter");this.nodeToObjectConverter=e,this.registerConverters(),this.complexObjectConverter=new dr(this.nodeToObjectConverter)}registerConverters(){const e=new ur,t=new hr(this.nodeToObjectConverter),s=new mr(this.nodeToObjectConverter),n=new pr(this.nodeToObjectConverter),i=new fr(this.nodeToObjectConverter);this.converters.set("ZodString",e),this.converters.set("ZodNumber",e),this.converters.set("ZodBoolean",e),this.converters.set("ZodBigInt",e),this.converters.set("ZodEnum",e),this.converters.set("ZodNativeEnum",e),this.converters.set("ZodUnknown",new gr),this.converters.set("ZodAny",new yr),this.converters.set("ZodArray",t),this.converters.set("ZodTuple",s),this.converters.set("ZodSet",n),this.converters.set("ZodMap",i),this.converters.set("ZodRecord",i),this.converters.set("ZodObject",this.complexObjectConverter)}getConverter(e){const t=this.getSchemaTypeName(e);return this.converters.get(t)??this.complexObjectConverter}getSchemaTypeName(e){if(ar(e))return e instanceof u.ZodEffects?this.getSchemaTypeName(e.innerType()):e instanceof u.ZodLazy?this.getSchemaTypeName(e.schema):this.getSchemaTypeName(e.unwrap());const t=e._def.typeName;try{return Ir.parse(t)}catch{throw new Error(`Schema type name ${t} is not supported`)}}}class Nr{constructor(e){p(this,"converterFactory");this.typeSchemaResolver=e,this.converterFactory=new br(this)}convert(e,t){var o;const s=(o=this.typeSchemaResolver)==null?void 0:o.resolveSchema(e),n=A.unwrapSchema(t);if(Qe(n))return e;let i=n;return A.checkSchemaExtension(s,n)&&c.isNonNullable(s)&&(i=s),this.convertWithType(e,i)}convertWithType(e,t){return this.converterFactory.getConverter(t).convert(e,t)}}class pe{fetchFirstByBlueId(e){const t=this.fetchByBlueId(e);return t&&t.length>0?t[0]:null}}function Tr(r){return new class extends pe{fetchByBlueId(e){return r(e)}}}class vr extends pe{constructor(t){super();p(this,"nodeProviders");this.nodeProviders=t}fetchByBlueId(t){for(const s of this.nodeProviders){const n=s.fetchByBlueId(t);if(n&&n.length>0)return n}return[]}fetchFirstByBlueId(t){for(const s of this.nodeProviders){const n=s.fetchFirstByBlueId(t);if(n)return n}return null}getNodeProviders(){return this.nodeProviders}}const De=k.types.float.options,Br={...De,construct:r=>{const e=r.replace(/_/g,"").toLowerCase();if(!c.isPreciseNumberString(e))return new w(e);if(De.construct)return De.construct(r)}},wr=new k.Type("tag:yaml.org,2002:float",Br),Oe=k.types.int.options,Sr={...Oe,construct:r=>{let e=r;if(e.indexOf("_")!==-1&&(e=e.replace(/_/g,"")),!c.isPreciseNumberString(e))return new T(e);if(Oe.construct)return Oe.construct(r)}},Pr=new k.Type("tag:yaml.org,2002:int",Sr),$t=k.CORE_SCHEMA.extend({implicit:[wr,Pr]}),F=r=>{const e=k.load(r,{schema:$t});return e===void 0?void 0:e},Er=r=>k.dump(r,{schema:$t,replacer:(e,t)=>{if(P(t)){if($(t)){const s=new x(Number.MIN_SAFE_INTEGER.toString()),n=new x(Number.MAX_SAFE_INTEGER.toString());if(t.lt(s)||t.gt(n))return t.toString()}return t.toNumber()}return t}}),Lt=`- type:
|
|
2
2
|
blueId: 27B7fuxQCS1VAptiCPc2RMkKoutP5qxkh3uDxZ7dr6Eo
|
|
3
3
|
mappings:
|
|
4
4
|
Text: F92yo19rCcbBoBSpUA5LRxpfDejJDAaP1PRxxbWAraVP
|
|
@@ -16,12 +16,12 @@ type:
|
|
|
16
16
|
description: This transformation infers type details for Text, Integer, Number and Boolean.`,Vr=`name: Replace Inline Types with BlueIds
|
|
17
17
|
type:
|
|
18
18
|
blueId: Ct1SGRGw1i47qjzm1ruiUdSZofeV6WevPTGuieVvbRS4
|
|
19
|
-
description: This transformation replaces`,Dr=[Lt,Ar,Cr,Vr];class Or extends pe{constructor(){super();p(this,"blueIdToNodesMap",new Map);this.load()}fetchByBlueId(t){return this.blueIdToNodesMap.get(t)||[]}load(){for(const t of Dr){const s=F(t);if(s===void 0){console.error(`This content file is not valid YAML: ${t}`);continue}if(Array.isArray(s)){const n=s.map(o=>y.deserialize(o)),i=N.calculateBlueIdSync(n);this.blueIdToNodesMap.set(i,n)}else{const n=y.deserialize(s),i=N.calculateBlueIdSync(n);this.blueIdToNodesMap.set(i,[n])}}}}const Ie=class Ie extends pe{constructor(){super();p(this,"nodeProvider");this.nodeProvider=new Or}fetchByBlueId(t){return this.nodeProvider.fetchByBlueId(t)}};p(Ie,"INSTANCE",new Ie);let
|
|
19
|
+
description: This transformation replaces`,Dr=[Lt,Ar,Cr,Vr];class Or extends pe{constructor(){super();p(this,"blueIdToNodesMap",new Map);this.load()}fetchByBlueId(t){return this.blueIdToNodesMap.get(t)||[]}load(){for(const t of Dr){const s=F(t);if(s===void 0){console.error(`This content file is not valid YAML: ${t}`);continue}if(Array.isArray(s)){const n=s.map(o=>y.deserialize(o)),i=N.calculateBlueIdSync(n);this.blueIdToNodesMap.set(i,n)}else{const n=y.deserialize(s),i=N.calculateBlueIdSync(n);this.blueIdToNodesMap.set(i,[n])}}}}const Ie=class Ie extends pe{constructor(){super();p(this,"nodeProvider");this.nodeProvider=new Or}fetchByBlueId(t){return this.nodeProvider.fetchByBlueId(t)}};p(Ie,"INSTANCE",new Ie);let Le=Ie;class Me{constructor(e,t,s){this.blueId=e,this.content=t,this.isMultipleDocuments=s}}class j{static parseAndCalculateBlueId(e,t){let s;try{const l=F(e);if(l===void 0)throw new Error;s=l}catch{throw new Error("Failed to parse content as YAML or JSON")}let n,i;const o=Array.isArray(s)&&s.length>1;if(o){const l=s.map(a=>{const h=y.deserialize(a);return t(h)});n=N.calculateBlueIdSync(l),i=l.map(a=>b.get(a))}else{const l=y.deserialize(s),a=t(l);n=N.calculateBlueIdSync(a),i=b.get(a)}return new Me(n,i,o)}static parseAndCalculateBlueIdForNode(e,t){const s=t(e),n=N.calculateBlueIdSync(s),i=b.get(s);return new Me(n,i,!1)}static parseAndCalculateBlueIdForNodeList(e,t){if(!e||e.length===0)throw new Error("List of nodes cannot be null or empty");const s=e.map(t),n=N.calculateBlueIdSync(s),i=s.map(l=>b.get(l)),o=e.length>1;return new Me(n,i,o)}static resolveThisReferences(e,t,s){return this.resolveThisReferencesRecursive(e,t,s)}static resolveThisReferencesRecursive(e,t,s){if(e&&typeof e=="object"&&!Array.isArray(e)){const n={};for(const[i,o]of Object.entries(e))typeof o=="string"?this.THIS_REFERENCE_PATTERN.test(o)?n[i]=this.resolveThisReference(o,t,s):n[i]=o:o&&typeof o=="object"?n[i]=this.resolveThisReferencesRecursive(o,t,s):n[i]=o;return n}else if(Array.isArray(e))return e.map(n=>typeof n=="string"?this.THIS_REFERENCE_PATTERN.test(n)?this.resolveThisReference(n,t,s):n:n&&typeof n=="object"?this.resolveThisReferencesRecursive(n,t,s):n);return e}static resolveThisReference(e,t,s){if(s){if(!e.startsWith("this#"))throw new Error("For multiple documents, 'this' references must include an index (e.g., 'this#0')");return t+e.substring(4)}else{if(e==="this")return t;throw new Error("For a single document, only 'this' is allowed as a reference, not 'this#<id>'")}}}p(j,"THIS_REFERENCE_PATTERN",/^this(#\d+)?$/);class Mr extends pe{fetchByBlueId(e){const t=e.split("#")[0],s=this.fetchContentByBlueId(t);if(s==null)return null;const n=Array.isArray(s)&&s.length>1,i=j.resolveThisReferences(s,t,n);if(e.includes("#")){const o=e.split("#");if(o.length>1){const l=parseInt(o[1]);if(Array.isArray(i)&&l<i.length){const a=i[l],h=y.deserialize(a);return h.setBlueId(e),[h]}else if(l===0){const a=y.deserialize(i);return a.setBlueId(e),[a]}else return null}}if(Array.isArray(i))return i.map(o=>y.deserialize(o));{const o=y.deserialize(i);return o.setBlueId(t),[o]}}}class zt extends Mr{constructor(){super(...arguments);p(this,"nameToBlueIdsMap",new Map)}findNodeByName(t){const s=this.nameToBlueIdsMap.get(t);if(!s)return;if(s.length>1)throw new Error(`Multiple nodes found with name: ${t}`);const n=this.fetchByBlueId(s[0]);return n&&n.length>0?n[0]:void 0}findAllNodesByName(t){const s=this.nameToBlueIdsMap.get(t);if(!s)return[];const n=[];for(const i of s){const o=this.fetchByBlueId(i);o&&n.push(...o)}return n}addToNameMap(t,s){this.nameToBlueIdsMap.set(t,[...this.nameToBlueIdsMap.get(t)||[],s])}}const Ut=r=>r instanceof d||Array.isArray(r)&&r.every(e=>e instanceof d)?r:C.isArray(r)?r.map(e=>y.deserialize(e)):y.deserialize(r),Zt=async r=>{const e=Ut(r);return N.calculateBlueId(e)},Fr=r=>{const e=Ut(r);return N.calculateBlueIdSync(e)},ze=async r=>{if(ht(r))return r;try{const e=ce.parse(r),t=await Zt(e);return{...r,blueId:t}}catch(e){throw new Error(`Failed enriching object with Blue ID: ${e}`)}},Rr=r=>r==null?void 0:r.items,jr=r=>r==null?void 0:r.value,xr=r=>c.isNullable(r)?{}:C.omit(r,cs),$r=r=>ft(r)?r.type.name??null:gt(r)?C.pascal(typeof r.value):pt(r)?"List":null,_t=r=>c.isNonNullable(r)&&Object.keys(C.omit(r,["blueId"])).length>0,Lr=r=>{try{const e=y.deserialize(r),t=b.get(e);return Q.parse(t)}catch(e){throw new Error(`Failed transforming JSON-like value to BlueObject: ${e}`)}},Ue=async r=>{const{resolveFunction:e,signal:t=new AbortController().signal,omitItems:s}=r,n=r.count??r.items.length;let i=await C.map(r.items,async l=>await ze(l));const o=Math.max((i==null?void 0:i.length)-n,0);for(let l=i.length-1;l>=o;l--)if(!_t(i[l])){const a=await e(i[l],{signal:t});if(Array.isArray(a))return Ue({...r,items:[...i.slice(0,l),...a,...i.slice(l+1)]});const h=await ze(a);if(s!=null&&s.includes(h.blueId))return Ue({...r,items:[...i.slice(0,l),...i.slice(l+1)]});i=[...i.slice(0,l),h,...i.slice(l+1)]}return i};function oe(r){try{const e=new URL(r);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}class zr{process(e){return D.transform(e,this.inferType.bind(this))}inferType(e){const t=e.getType(),s=e.getValue();return c.isNullable(t)&&c.isNonNullable(s)&&(typeof s=="string"?e.setType(new d().setBlueId(Y)):typeof s=="bigint"||$(s)?e.setType(new d().setBlueId(K)):ge(s)?e.setType(new d().setBlueId(J)):typeof s=="boolean"&&e.setType(new d().setBlueId(G))),e}}const le=class le{constructor(e){p(this,"mappings",new Map);if(e instanceof d){const s=e.getProperties();if(s&&s[le.MAPPINGS]){const i=s[le.MAPPINGS].getProperties();i&&Object.entries(i).forEach(([o,l])=>{const a=l.getValue();typeof a=="string"&&this.mappings.set(o,a)})}}else this.mappings=e}process(e){return D.transform(e,this.transformNode.bind(this))}transformNode(e){const t=e.clone();return this.transformTypeField(t,t.getType()),this.transformTypeField(t,t.getItemType()),this.transformTypeField(t,t.getKeyType()),this.transformTypeField(t,t.getValueType()),t}transformTypeField(e,t){if(t&&t.isInlineValue()&&t.getValue()!==void 0){const s=String(t.getValue());if(this.mappings.has(s)){const n=this.mappings.get(s);if(n){const i=new d().setBlueId(n);t===e.getType()?e.setType(i):t===e.getItemType()?e.setItemType(i):t===e.getKeyType()?e.setKeyType(i):t===e.getValueType()&&e.setValueType(i)}}}}};p(le,"MAPPINGS","mappings");let Ze=le;class Ur{process(e){return D.transform(e,this.validateNode.bind(this)),e}validateNode(e){return this.validateTypeField(e,e.getType(),"type"),this.validateTypeField(e,e.getItemType(),"itemType"),this.validateTypeField(e,e.getKeyType(),"keyType"),this.validateTypeField(e,e.getValueType(),"valueType"),e}validateTypeField(e,t,s){if(t&&t.isInlineValue()&&t.getValue()!==void 0){const n=String(t.getValue());throw new Error(`Unknown type "${n}" found in ${s} field. No BlueId mapping exists for this type.`)}}}class tt{constructor(e,t){p(this,"nodeProvider");p(this,"strategy");this.nodeProvider=ue.wrap(e),this.strategy=t||"THROW_EXCEPTION"}extend(e,t){this.extendNode(e,t,"")}extendNode(e,t,s,n=!1){if(!n){if(!t.shouldExtendPathSegment(s,e))return;t.enterPathSegment(s,e)}try{const i=e.getBlueId();if(i&&!de.includes(i)){const f=this.fetchNode(e);if(f&&f.length>0)if(f.length===1){const g=f[0];this.mergeNodes(e,g)}else{const g=f.map(W=>W.clone()),O=new d().setItems(g);this.mergeNodes(e,O)}}const o=e.getType();o&&this.extendNode(o,t,"type",!0);const l=e.getItemType();l&&this.extendNode(l,t,"itemType",!0);const a=e.getKeyType();a&&this.extendNode(a,t,"keyType",!0);const h=e.getValueType();h&&this.extendNode(h,t,"valueType",!0);const I=e.getProperties();I&&Object.entries(I).forEach(([f,g])=>{this.extendNode(g,t,f,!1)});const m=e.getItems();if(m&&m.length>0){this.reconstructList(m);for(let f=0;f<m.length;f++)this.extendNode(m[f],t,String(f),!1)}}finally{n||t.exitPathSegment()}}reconstructList(e){for(;e.length>0;){const t=e[0],s=t==null?void 0:t.getBlueId();if(!s)break;const n=this.nodeProvider.fetchByBlueId(s);if(!n||n.length===1)break;e.shift(),e.unshift(...n)}}fetchNode(e){const t=e.getBlueId();if(!t){if(this.strategy==="RETURN_EMPTY")return null;throw new Error(`No blueId found for node: ${e.getName()}`)}const s=this.nodeProvider.fetchByBlueId(t);if(!s||s.length===0){if(this.strategy==="RETURN_EMPTY")return null;throw new Error(`No content found for blueId: ${e.getBlueId()}`)}return s}mergeNodes(e,t){e.setName(t.getName()),e.setDescription(t.getDescription()),e.setType(t.getType()),e.setItemType(t.getItemType()),e.setKeyType(t.getKeyType()),e.setValueType(t.getValueType());const s=t.getValue();c.isNonNullable(s)&&e.setValue(s),e.setItems(t.getItems()),e.setProperties(t.getProperties())}}class kt{constructor(){p(this,"blueIdsCollections",[])}initialize(...e){this.blueIdsCollections=[...e]}registerBlueIds(...e){this.blueIdsCollections.push(...e)}generateMappingsYaml(e="27B7fuxQCS1VAptiCPc2RMkKoutP5qxkh3uDxZ7dr6Eo"){const t={};for(const n of this.blueIdsCollections)Object.assign(t,n);const s=Object.entries(t).map(([n,i])=>` ${n}: ${i}`).join(`
|
|
20
20
|
`);return`- type:
|
|
21
21
|
blueId: ${e}
|
|
22
22
|
mappings:
|
|
23
|
-
${s}`}getAllBlueIds(){const e={};for(const t of this.blueIdsCollections)Object.assign(e,t);return e}getAllBlueIdNames(){return Object.keys(this.getAllBlueIds())}clear(){this.blueIdsCollections=[]}getCollectionCount(){return this.blueIdsCollections.length}getTotalBlueIdCount(){return Object.keys(this.getAllBlueIds()).length}}const be=class be{constructor(e={}){p(this,"processorProvider");p(this,"nodeProvider");p(this,"defaultSimpleBlue",null);p(this,"blueIdsMappingGenerator");const{nodeProvider:t,processorProvider:s,blueIdsMappingGenerator:n}=e;if(!t)throw new Error("NodeProvider is required");this.nodeProvider=ue.wrap(t),this.processorProvider=s||be.getStandardProvider(),this.blueIdsMappingGenerator=n||new kt,this.loadDefaultSimpleBlue()}preprocess(e){return this.preprocessWithOptions(e,null)}preprocessWithDefaultBlue(e){return this.preprocessWithOptions(e,this.defaultSimpleBlue)}preprocessWithOptions(e,t){let s=e.clone(),n=s.getBlue();if(!n&&t&&(n=t.clone()),n){new
|
|
23
|
+
${s}`}getAllBlueIds(){const e={};for(const t of this.blueIdsCollections)Object.assign(e,t);return e}getAllBlueIdNames(){return Object.keys(this.getAllBlueIds())}clear(){this.blueIdsCollections=[]}getCollectionCount(){return this.blueIdsCollections.length}getTotalBlueIdCount(){return Object.keys(this.getAllBlueIds()).length}}const be=class be{constructor(e={}){p(this,"processorProvider");p(this,"nodeProvider");p(this,"defaultSimpleBlue",null);p(this,"blueIdsMappingGenerator");const{nodeProvider:t,processorProvider:s,blueIdsMappingGenerator:n}=e;if(!t)throw new Error("NodeProvider is required");this.nodeProvider=ue.wrap(t),this.processorProvider=s||be.getStandardProvider(),this.blueIdsMappingGenerator=n||new kt,this.loadDefaultSimpleBlue()}preprocess(e){return this.preprocessWithOptions(e,null)}preprocessWithDefaultBlue(e){return this.preprocessWithOptions(e,this.defaultSimpleBlue)}preprocessWithOptions(e,t){let s=e.clone(),n=s.getBlue();if(!n&&t&&(n=t.clone()),n){new tt(this.nodeProvider).extend(n,we.withSinglePath("/*"));const i=n.getItems();if(i&&i.length>0){for(const o of i){const l=this.processorProvider.getProcessor(o);if(l)s=l.process(s);else throw new Error(`No processor found for transformation: ${o}`)}s.setBlue(void 0)}s=new Ur().process(s)}return s}static getStandardProvider(){return{getProcessor(e){var i;const t="27B7fuxQCS1VAptiCPc2RMkKoutP5qxkh3uDxZ7dr6Eo",s="FGYuTXwaoSKfZmpTysLTLsb8WzSqf43384rKZDkXhxD4",n=(i=e.getType())==null?void 0:i.getBlueId();if(t===n)return new Ze(e);if(s===n)return new zr}}}enrichDefaultBlue(e){const t=this.blueIdsMappingGenerator.generateMappingsYaml();return`
|
|
24
24
|
${e}
|
|
25
25
|
${t}
|
|
26
|
-
`}loadDefaultSimpleBlue(){const e=this.enrichDefaultBlue(Lt);try{const t=F(e);if(t)this.defaultSimpleBlue=y.deserialize(t);else throw new Error("Failed to parse default Blue content")}catch(t){throw new Error(`Error loading default Blue: ${t}`)}}};p(be,"DEFAULT_BLUE_BLUE_ID","FREHAAGDZSzpnoTUoCQ86bBmxbVCULMjvx9JZM6fyqT1");let te=be;class Zr extends zt{constructor(t){super();p(this,"blueIdToContentMap",new Map);p(this,"blueIdToMultipleDocumentsMap",new Map);p(this,"preprocessor");const s=new te({nodeProvider:this});this.preprocessor=n=>s.preprocessWithDefaultBlue(n),this.loadRepositories(t)}loadRepositories(t){for(const s of t)if(s.contents)for(const[n,i]of Object.entries(s.contents))this.processContent(i,n)}processContent(t,s){Array.isArray(t)?this.processMultipleDocuments(t,s):this.processSingleDocument(t,s)}processSingleDocument(t,s){const n=y.deserialize(t),i=j.parseAndCalculateBlueIdForNode(n,this.preprocessor),o=s||i.blueId;this.blueIdToContentMap.set(o,i.content),this.blueIdToMultipleDocumentsMap.set(o,!1);const l=n.getName();l&&this.addToNameMap(l,o)}processMultipleDocuments(t,s){const n=t.map(l=>{const a=y.deserialize(l);return this.preprocessor(a)}),i=j.parseAndCalculateBlueIdForNodeList(n,l=>l),o=s||i.blueId;this.blueIdToContentMap.set(o,i.content),this.blueIdToMultipleDocumentsMap.set(o,!0),n.forEach((l,a)=>{const h=`${o}#${a}`,I=b.get(l),m=N.calculateBlueIdSync(l);this.blueIdToContentMap.set(m,I),this.blueIdToMultipleDocumentsMap.set(m,!1);const f=l.getName();f&&this.addToNameMap(f,h)})}fetchContentByBlueId(t){const s=this.blueIdToContentMap.get(t),n=this.blueIdToMultipleDocumentsMap.get(t);return s!==void 0&&n!==void 0?j.resolveThisReferences(s,t,n):null}getBlueIds(){return Array.from(this.blueIdToContentMap.keys())}hasBlueId(t){const s=t.split("#")[0];return this.blueIdToContentMap.has(s)}}class ue{static wrap(e,t){const s=[
|
|
27
|
-
${n.message}`):n}else throw oe(t)?new Error(`UrlContentFetcher not provided for URL: ${t}`):new Error(`Invalid blue value: ${t}`)}return e}getBlueNodeValue(e){const t=e.getBlue(),s=t==null?void 0:t.getValue();return s&&typeof s=="string"?s:null}handleAliasValue(e,t){return e.setBlue(new d().setBlueId(this.preprocessingAliases.get(t))),e}handleBlueId(e,t){return e.setBlue(new d().setBlueId(t)),e}async fetchFromUrl(e){if(!this.urlContentFetcher)throw new Error(`UrlContentFetcher not provided for URL: ${e}`);return await this.urlContentFetcher.fetchAndCache(e)}getPreprocessingAliases(){return new Map(this.preprocessingAliases)}setPreprocessingAliases(e){return this.preprocessingAliases=new Map(e),this}addPreprocessingAliases(e){return e.forEach((t,s)=>{this.preprocessingAliases.set(s,t)}),this}setUrlContentFetcher(e){return this.urlContentFetcher=e,this}getUrlContentFetcher(){return this.urlContentFetcher}}const kr={fetchUrl:async r=>{throw new Error(`You must provide a custom UrlFetchStrategy to fetch content from URL: ${r}`)}};class Yr{constructor(e){p(this,"cache",new Map);p(this,"fetchStrategy");p(this,"enabled",!1);p(this,"allowedDomains",[]);this.fetchStrategy=e||kr}validateUrl(e){if(!oe(e))throw new Error(`Invalid URL: ${e}`);return!0}isDomainAllowed(e){if(this.allowedDomains.length===0)return!0;try{const t=new URL(e);return this.allowedDomains.some(s=>t.hostname===s||t.hostname.endsWith(`.${s}`))}catch{return!1}}getFromCache(e){try{return this.validateUrl(e),this.cache.get(e)||[]}catch{return[]}}async fetchAndCache(e){if(this.validateUrl(e),!this.enabled)throw new Error("URL fetching is disabled. Enable it using the enableFetching method.");if(!this.isDomainAllowed(e))throw new Error(`Domain not allowed for URL: ${e}.`);let t;try{t=await this.fetchStrategy.fetchUrl(e)}catch(l){throw new Error(`Error fetching from URL: ${e}`,{cause:l})}const{data:s,contentType:n}=t;let i;if(n.includes("application/json")||n.includes("text/yaml")||n.includes("application/yaml")||n.includes("text/plain"))i=F(s);else throw new Error(`Unsupported content type from URL: ${n}`);if(i===void 0)throw new Error(`Failed to parse content from URL: ${e}`);let o;return Array.isArray(i)?o=i.map(l=>y.deserialize(l)):o=[y.deserialize(i)],this.cache.set(e,o),o}prefetchUrl(e,t){try{this.validateUrl(e),this.cache.set(e,t)}catch{}}clearCache(){this.cache.clear()}setFetchStrategy(e){return this.fetchStrategy=e,this}getFetchStrategy(){return this.fetchStrategy}enableFetching(){return this.enabled=!0,this.allowedDomains=[],this}enableFetchingForDomains(e){return this.enabled=!0,this.allowedDomains=[...e],this}disableFetching(){return this.enabled=!1,this}isFetchingEnabled(){return this.enabled}getAllowedDomains(){return[...this.allowedDomains]}allowDomain(e){return this.allowedDomains.includes(e)||this.allowedDomains.push(e),this}disallowDomain(e){return this.allowedDomains=this.allowedDomains.filter(t=>t!==e),this}clearAllowedDomains(){return this.allowedDomains=[],this}}class Yt{reverse(e){const t=new d;return this.reverseNode(t,e,e.getType()),t}reverseNode(e,t,s){this.isIdenticalToType(t,s)||(this.reverseBasicProperties(e,t,s),this.reverseTypeReferences(e,t,s),this.reverseItems(e,t,s),this.reverseProperties(e,t,s))}isIdenticalToType(e,t){return c.isNonNullable(e.getBlueId())&&c.isNonNullable(t==null?void 0:t.getBlueId())&&e.getBlueId()===t.getBlueId()}reverseBasicProperties(e,t,s){const n=t.getValue();c.isNonNullable(n)&&(c.isNullable(s)||c.isNullable(s.getValue()))&&e.setValue(n),c.isNonNullable(t.getName())&&(c.isNullable(s)||t.getName()!==s.getName())&&e.setName(t.getName()),c.isNonNullable(t.getDescription())&&(c.isNullable(s)||t.getDescription()!==s.getDescription())&&e.setDescription(t.getDescription()),c.isNonNullable(t.getBlueId())&&(c.isNullable(s)||t.getBlueId()!==s.getBlueId())&&e.setBlueId(t.getBlueId())}reverseTypeReferences(e,t,s){const n=(i,o)=>{const l=i(t),a=s?i(s):void 0,h=l==null?void 0:l.getBlueId();c.isNonNullable(h)&&(c.isNullable(a==null?void 0:a.getBlueId())||h!==a.getBlueId())&&o(e,new d().setBlueId(h))};n(i=>i.getType(),(i,o)=>i.setType(o)),n(i=>i.getItemType(),(i,o)=>i.setItemType(o)),n(i=>i.getKeyType(),(i,o)=>i.setKeyType(o)),n(i=>i.getValueType(),(i,o)=>i.setValueType(o))}reverseItems(e,t,s){const n=t.getItems();if(c.isNullable(n))return;const i=s==null?void 0:s.getItems(),o=[];if(c.isNonNullable(i)&&i.length>0){const a=N.calculateBlueIdSync(i);o.push(new d().setBlueId(a))}const l=(i==null?void 0:i.length)||0;for(let a=l;a<n.length;a++){const h=new d;this.reverseNode(h,n[a],void 0),o.push(h)}o.length>0&&e.setItems(o)}reverseProperties(e,t,s){const n=t.getProperties();if(c.isNullable(n))return;const i={};for(const[o,l]of Object.entries(n)){const a=this.getInheritedProperty(o,t,s),h=new d;this.reverseNode(h,l,a),ve.isEmptyNode(h)||(i[o]=h)}Object.keys(i).length>0&&e.setProperties(i)}getInheritedProperty(e,t,s){var o,l,a;const n=(o=s==null?void 0:s.getProperties())==null?void 0:o[e],i=(a=(l=t.getType())==null?void 0:l.getProperties())==null?void 0:a[e];if(!(c.isNullable(n)&&c.isNullable(i)))return c.isNullable(n)?i:c.isNullable(i)?n:this.mergeNodes(n,i)}mergeNodes(e,t){const s=e.clone(),n=t.getValue();c.isNonNullable(n)&&s.setValue(n);const i=t.getType();c.isNonNullable(i)&&s.setType(i.clone());const o=t.getItemType();c.isNonNullable(o)&&s.setItemType(o.clone());const l=t.getKeyType();c.isNonNullable(l)&&s.setKeyType(l.clone());const a=t.getValueType();c.isNonNullable(a)&&s.setValueType(a.clone());const h=t.getProperties();if(c.isNonNullable(h)){const m=s.getProperties()||{};for(const[f,g]of Object.entries(h))m[f]=g.clone();s.setProperties(m)}const I=t.getItems();return c.isNonNullable(I)&&s.setItems(I.map(m=>m.clone())),s}}class Se extends d{constructor(e){super(e.getName()),this.createFrom(e)}isResolved(){return!0}getMinimalNode(){return new Yt().reverse(this)}getMinimalBlueId(){const e=this.getMinimalNode();return N.calculateBlueIdSync(e)}clone(){const e=super.clone();return new Se(e)}createFrom(e){e.getName()!==this.getName()&&this.setName(e.getName()),this.setDescription(e.getDescription()).setType(e.getType()).setItemType(e.getItemType()).setKeyType(e.getKeyType()).setValueType(e.getValueType()).setItems(e.getItems()).setProperties(e.getProperties()).setBlueId(e.getBlueId()).setBlue(e.getBlue()).setInlineValue(e.isInlineValue());const t=e.getValue();t!==void 0&&this.setValue(t)}}class Jt{resolveWithoutLimits(e){return this.resolve(e,z)}}class Kt extends Jt{constructor(t,s){super();p(this,"mergingProcessor");p(this,"nodeProvider");this.mergingProcessor=t,this.nodeProvider=ue.wrap(s)}merge(t,s,n){if(c.isNonNullable(s.getBlue()))throw new Error('Document contains "blue" attribute. Preprocess document before merging.');let i=t;const o=s.getType();if(c.isNonNullable(o)){const l=o.clone();c.isNonNullable(l.getBlueId())&&new st(this.nodeProvider).extend(l,we.withSinglePath("/"));const a=this.resolve(l,n),h=s.clone().setType(a);return i=this.merge(i,l,n),this.mergeObject(i,h,n)}return this.mergeObject(i,s,n)}mergeObject(t,s,n){let i=this.mergingProcessor.process(t,s,this.nodeProvider);const o=s.getItems();c.isNonNullable(o)&&(i=this.mergeChildren(i,o,n));const l=s.getProperties();return c.isNonNullable(l)&&Object.entries(l).forEach(([a,h])=>{n.shouldMergePathSegment(a,h)&&(n.enterPathSegment(a,h),i=this.mergeProperty(i,a,h,n),n.exitPathSegment())}),c.isNonNullable(s.getBlueId())&&(i=i.clone().setBlueId(s.getBlueId())),this.mergingProcessor.postProcess&&(i=this.mergingProcessor.postProcess(i,s,this.nodeProvider)),i}mergeChildren(t,s,n){const i=t.getItems();if(c.isNullable(i)){const l=s.filter((a,h)=>n.shouldMergePathSegment(String(h),a)).map(a=>{n.enterPathSegment(String(s.indexOf(a)),a);const h=this.resolve(a,n);return n.exitPathSegment(),h});return t.clone().setItems(l)}else if(s.length<i.length)throw new Error(`Subtype of element must not have more items (${i.length}) than the element itself (${s.length}).`);const o=[...i];for(let l=0;l<s.length;l++){if(!n.shouldMergePathSegment(String(l),s[l]))continue;if(n.enterPathSegment(String(l),s[l]),l>=o.length){o.push(s[l]),n.exitPathSegment();continue}const a=N.calculateBlueIdSync(s[l]),h=N.calculateBlueIdSync(o[l]);if(a!==h)throw new Error(`Mismatched items at index ${l}: source item has blueId '${a}', but target item has blueId '${h}'.`);n.exitPathSegment()}return t.clone().setItems(o)}mergeProperty(t,s,n,i){const o=this.resolve(n,i),l=t.clone();c.isNullable(l.getProperties())&&l.setProperties({});const a=l.getProperties()[s];return a===void 0?l.getProperties()[s]=o:l.getProperties()[s]=this.mergeObject(a,o,i),l}resolve(t,s){const n=new d,o=this.merge(n,t,s).clone().setName(t.getName()).setDescription(t.getDescription()).setBlueId(t.getBlueId());return new Se(o)}}class Gt{constructor(e){p(this,"mergingProcessors");this.mergingProcessors=e}process(e,t,s){return this.mergingProcessors.reduce((n,i)=>i.process(n,t,s),e)}postProcess(e,t,s){return this.mergingProcessors.reduce((n,i)=>i.postProcess?i.postProcess(n,t,s):n,e)}}class Wt{process(e,t){const s=t.getValue();if(c.isNonNullable(s)){const n=e.getValue();if(c.isNullable(n))return e.clone().setValue(s);if(!Jr(s,n))throw new Error(`Node values conflict. Source node value: ${s}, target node value: ${n}`)}return e}}const Jr=(r,e)=>$(r)&&$(e)||ge(r)&&ge(e)?r.eq(e):r===e;class Ht{process(e,t,s){const n=e.getType(),i=t.getType();let o=e;if(n===void 0)o=e.clone().setType(i);else if(i!==void 0){if(!P(i,n,s)){const a=b.get(i),h=b.get(n);throw new Error(`The source type '${JSON.stringify(a)}' is not a subtype of the target type '${JSON.stringify(h)}'.`)}o=e.clone().setType(i)}return o}}class qt{process(e,t,s){if(t.getItemType()!==void 0&&!Rt(t.getType()))throw new Error("Source node with itemType must have a List type");const n=e.getItemType(),i=t.getItemType();let o=e;if(n===void 0)i!==void 0&&(o=e.clone().setItemType(i));else if(i!==void 0){if(!P(i,n,s)){const I=b.get(i),m=b.get(n);throw new Error(`The source item type '${JSON.stringify(I)}' is not a subtype of the target item type '${JSON.stringify(m)}'.`)}o=e.clone().setItemType(i)}const l=o.getItemType(),a=t.getItems();if(l!==void 0&&a!==void 0)for(const h of a){const I=h.getType();if(I!==void 0&&!P(I,l,s)){const m=b.get(I),f=b.get(l);throw new Error(`Item of type '${JSON.stringify(m)}' is not a subtype of the list's item type '${JSON.stringify(f)}'.`)}}return o}}class Xt{process(e,t,s){if((t.getKeyType()!==void 0||t.getValueType()!==void 0)&&!jt(t.getType()))throw new Error("Source node with keyType or valueType must have a Dictionary type");let n=this.processKeyType(e,t,s);n=this.processValueType(n,t,s);const i=n.getKeyType(),o=n.getValueType(),l=t.getProperties();return(i!==void 0||o!==void 0)&&l!==void 0&&Object.entries(l).forEach(([a,h])=>{i!==void 0&&this.validateKeyType(a,i,s),o!==void 0&&this.validateValueType(h,o,s)}),n}processKeyType(e,t,s){const n=e.getKeyType(),i=t.getKeyType();if(n===void 0){if(i!==void 0)return this.validateBasicKeyType(i,s),e.clone().setKeyType(i)}else if(i!==void 0){if(this.validateBasicKeyType(i,s),!P(i,n,s)){const l=b.get(i),a=b.get(n);throw new Error(`The source key type '${JSON.stringify(l)}' is not a subtype of the target key type '${JSON.stringify(a)}'.`)}return e.clone().setKeyType(i)}return e}processValueType(e,t,s){const n=e.getValueType(),i=t.getValueType();if(n===void 0){if(i!==void 0)return e.clone().setValueType(i)}else if(i!==void 0){if(!P(i,n,s)){const l=b.get(i),a=b.get(n);throw new Error(`The source value type '${JSON.stringify(l)}' is not a subtype of the target value type '${JSON.stringify(a)}'.`)}return e.clone().setValueType(i)}return e}validateBasicKeyType(e,t){if(!er(e,t))throw new Error("Dictionary key type must be a basic type")}validateKeyType(e,t,s){if(!tr(t,s))if(sr(t,s)){const n=Number.parseInt(e,10);if(Number.isNaN(n)||n.toString()!==e)throw new Error(`Key '${e}' is not a valid Integer.`)}else if(rr(t,s)){const n=Number.parseFloat(e);if(Number.isNaN(n))throw new Error(`Key '${e}' is not a valid Number.`)}else if(nr(t,s)){if(e.toLowerCase()!=="true"&&e.toLowerCase()!=="false")throw new Error(`Key '${e}' is not a valid Boolean.`)}else throw new Error(`Unsupported key type: ${t.getName()||"unknown"}`)}validateValueType(e,t,s){const n=e.getType();if(n!==void 0&&!P(n,t,s)){const i=b.get(n),o=b.get(t);throw new Error(`Value of type '${JSON.stringify(i)}' is not a subtype of the dictionary's value type '${JSON.stringify(o)}'.`)}}}class Qt{process(e){return e}postProcess(e,t,s){const n=e.getType();if(n!==void 0&&ir(n,s)){const i=e.getItems(),o=e.getProperties();if(i!==void 0&&i.length>0||o!==void 0&&Object.keys(o).length>0){const l=or(n,s),a=n.getName()||"unknown";throw new Error(`Node of type "${a}" (which extends basic type "${l}") must not have items, properties or contracts.`)}}return e}}class es{process(e,t){let s=e;const n=t.getName(),i=e.getName();n!==void 0&&i===void 0&&(s=s.clone().setName(n));const o=t.getDescription(),l=s.getDescription();return o!==void 0&&l===void 0&&(s=s.clone().setDescription(o)),s}}const Kr=Object.freeze(Object.defineProperty({__proto__:null,BasicTypesVerifier:Qt,DictionaryProcessor:Xt,ListProcessor:qt,MetadataPropagator:es,SequentialMergingProcessor:Gt,TypeAssigner:Ht,ValuePropagator:Wt},Symbol.toStringTag,{value:"Module"}));function Gr(){return new Gt([new Wt,new Ht,new qt,new Xt,new es,new Qt])}class Wr{constructor(e={}){p(this,"nodeProvider");p(this,"typeSchemaResolver");p(this,"blueDirectivePreprocessor");p(this,"urlContentFetcher");p(this,"blueIdsMappingGenerator");p(this,"globalLimits",z);p(this,"mergingProcessor");p(this,"repositories");p(this,"prepareForBlueIdCalculation",async e=>e instanceof d||Array.isArray(e)&&e.every(t=>t instanceof d)?e:Array.isArray(e)?await Promise.all(e.map(s=>this.jsonValueToNodeAsync(s))):this.jsonValueToNodeAsync(e));p(this,"calculateBlueId",async e=>{const t=await this.prepareForBlueIdCalculation(e);return N.calculateBlueId(t)});p(this,"prepareForBlueIdCalculationSync",e=>e instanceof d||Array.isArray(e)&&e.every(t=>t instanceof d)?e:Array.isArray(e)?e.map(t=>this.jsonValueToNode(t)):this.jsonValueToNode(e));var a;const{nodeProvider:t,typeSchemaResolver:s=null,urlFetchStrategy:n,repositories:i,mergingProcessor:o}=e;this.repositories=i;const l=Tr(()=>[]);if(this.nodeProvider=ue.wrap(t||l,i),this.typeSchemaResolver=s??new Ft([]),this.mergingProcessor=o??Gr(),this.urlContentFetcher=new Yr(n),this.blueDirectivePreprocessor=new _r(void 0,this.urlContentFetcher),this.blueIdsMappingGenerator=new kt,i)for(const{schemas:h,blueIds:I}of i)(a=this.typeSchemaResolver)==null||a.registerSchemas(h),this.blueIdsMappingGenerator.registerBlueIds(I)}nodeToJson(e,t="official"){return b.get(e,t)}nodeToSchemaOutput(e,t){return new Nr(this.typeSchemaResolver).convert(e,t)}resolve(e,t=z){const s=this.combineWithGlobalLimits(t);return new Kt(this.mergingProcessor,this.nodeProvider).resolve(e,s)}reverse(e){return new Yt().reverse(e)}extend(e,t){const s=this.combineWithGlobalLimits(t);new st(this.nodeProvider).extend(e,s)}jsonValueToNode(e){return this.preprocess(y.deserialize(e))}async jsonValueToNodeAsync(e){return this.preprocessAsync(y.deserialize(e))}yamlToNode(e){const t=F(e);if(!t)throw new Error("Failed to parse YAML to JSON");return this.jsonValueToNode(t)}async yamlToNodeAsync(e){const t=F(e);if(!t)throw new Error("Failed to parse YAML to JSON");return this.jsonValueToNodeAsync(t)}calculateBlueIdSync(e){const t=this.prepareForBlueIdCalculationSync(e);return N.calculateBlueIdSync(t)}addPreprocessingAliases(e){this.blueDirectivePreprocessor.addPreprocessingAliases(e)}preprocess(e){const t=this.blueDirectivePreprocessor.process(e);return new te({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).preprocessWithDefaultBlue(t)}async preprocessAsync(e){const t=await this.blueDirectivePreprocessor.processAsync(e);return new te({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).preprocessWithDefaultBlue(t)}transform(e,t){return D.transform(e,t)}getNodeProvider(){return this.nodeProvider}setNodeProvider(e){return this.nodeProvider=ue.wrap(e,this.repositories),this}getTypeSchemaResolver(){return this.typeSchemaResolver}setTypeSchemaResolver(e){return this.typeSchemaResolver=e,this}getUrlContentFetcher(){return this.urlContentFetcher}setUrlFetchStrategy(e){return this.urlContentFetcher.setFetchStrategy(e),this}enablePreprocessingDirectivesFetchForUrls(){return this.urlContentFetcher.enableFetching(),this}enablePreprocessingDirectivesFetchForDomains(e){return this.urlContentFetcher.enableFetchingForDomains(e),this}allowUrlFetchingForDomain(e){return this.urlContentFetcher.allowDomain(e),this}disallowUrlFetchingForDomain(e){return this.urlContentFetcher.disallowDomain(e),this}getAllowedUrlFetchingDomains(){return this.urlContentFetcher.getAllowedDomains()}disablePreprocessingDirectivesFetchForUrls(){return this.urlContentFetcher.disableFetching(),this}isPreprocessingDirectivesFetchForUrlsEnabled(){return this.urlContentFetcher.isFetchingEnabled()}getPreprocessingAliases(){return this.blueDirectivePreprocessor.getPreprocessingAliases()}setPreprocessingAliases(e){return this.blueDirectivePreprocessor.setPreprocessingAliases(e),this}registerBlueIds(...e){return this.blueIdsMappingGenerator.registerBlueIds(...e),this}getAllRegisteredBlueIds(){return this.blueIdsMappingGenerator.getAllBlueIds()}getAllBlueIdNames(){return this.blueIdsMappingGenerator.getAllBlueIdNames()}getBlueIdsMappingGenerator(){return this.blueIdsMappingGenerator}isTypeOf(e,t,s){return A.isTypeOf(e,t,{checkSchemaExtensions:s==null?void 0:s.checkSchemaExtensions,typeSchemaResolver:this.typeSchemaResolver})}isTypeOfNode(e,t){return new lr(this).matchesType(e,t,this.globalLimits)}setGlobalLimits(e){return this.globalLimits=e??z,this}getGlobalLimits(){return this.globalLimits}combineWithGlobalLimits(e){return this.globalLimits==z?e:e==z?this.globalLimits:Pe.of(this.globalLimits,e)}}class Hr extends zt{constructor(t=[]){super();p(this,"blueIdToContentMap",new Map);p(this,"blueIdToMultipleDocumentsMap",new Map);p(this,"preprocessor");const s=new te({nodeProvider:this});this.preprocessor=n=>s.preprocessWithDefaultBlue(n),t.forEach(n=>this.processNode(n))}processNode(t){ve.hasItemsOnly(t)?this.processNodeWithItems(t):this.processSingleNode(t)}processSingleNode(t){const s=j.parseAndCalculateBlueIdForNode(t,this.preprocessor);this.blueIdToContentMap.set(s.blueId,s.content),this.blueIdToMultipleDocumentsMap.set(s.blueId,s.isMultipleDocuments);const n=t.getName();n&&this.addToNameMap(n,s.blueId)}processNodeWithItems(t){const s=t.getItems();if(!s)return;this.processNodeList(s);const n=j.parseAndCalculateBlueIdForNodeList(s,this.preprocessor);this.blueIdToContentMap.set(n.blueId,n.content),this.blueIdToMultipleDocumentsMap.set(n.blueId,!0),s.forEach((i,o)=>{const l=i.getName();l&&this.addToNameMap(l,`${n.blueId}#${o}`)})}processNodeList(t){const s=N.calculateBlueIdSync(t),n=t.map(i=>b.get(i));this.blueIdToContentMap.set(s,n),this.blueIdToMultipleDocumentsMap.set(s,!0)}fetchContentByBlueId(t){const s=this.blueIdToContentMap.get(t),n=this.blueIdToMultipleDocumentsMap.get(t);return s!==void 0&&n!==void 0?j.resolveThisReferences(s,t,n):null}addSingleNodes(...t){t.forEach(s=>this.processNode(s))}addSingleDocs(...t){t.forEach(s=>{const n=F(s);if(n!==void 0){const i=y.deserialize(n);this.processNode(i)}})}getBlueIdByName(t){const s=this.nameToBlueIdsMap.get(t);if(!s||s.length===0)throw new Error(`No node with name "${t}"`);return s[0]}getNodeByName(t){const s=this.findNodeByName(t);if(!s)throw new Error(`No node with name "${t}"`);return s}addListAndItsItemsFromNodes(t){this.processNodeList(t),t.forEach(s=>this.processNode(s))}addListAndItsItemsFromDoc(t){const s=F(t);if(s!==void 0){const i=y.deserialize(s).getItems();i&&this.addListAndItsItems(i)}}addListAndItsItems(t){Array.isArray(t)?this.addListAndItsItemsFromNodes(t):this.addListAndItsItemsFromDoc(t)}addList(t){this.processNodeList(t)}}exports.Base58Sha256Provider=mt;exports.BasicNodeProvider=Hr;exports.Blue=Wr;exports.BlueIdCalculator=N;exports.BlueIdToCid=Ms;exports.BlueNode=d;exports.BlueNodeTypeSchema=A;exports.JsonCanonicalizer=yt;exports.Limits=Be;exports.Merger=Kt;exports.MergingProcessors=Kr;exports.NodeResolver=Jt;exports.Nodes=ve;exports.ResolvedBlueNode=Se;exports.TypeSchemaResolver=Ft;exports.applyBlueNodePatch=_s;exports.baseBlueObjectSchema=he;exports.blueDescriptionField=Ys;exports.blueIdField=Ks;exports.blueIdSchema=ms;exports.blueNameField=Gs;exports.blueNodeField=Ws;exports.blueObjectBooleanValueSchema=Ns;exports.blueObjectNumberValueSchema=bs;exports.blueObjectSchema=Q;exports.blueObjectStringListItemsSchema=Ts;exports.blueObjectStringValueSchema=Is;exports.calculateBlueId=Zt;exports.calculateBlueIdSync=Fr;exports.enrichWithBlueId=Ue;exports.getBlueDescriptionAnnotation=wt;exports.getBlueIdAnnotation=St;exports.getBlueNameAnnotation=At;exports.getBlueNodeAnnotation=Vt;exports.getBlueObjectItems=Rr;exports.getBlueObjectProperties=xr;exports.getBlueObjectTypeLabel=$r;exports.getBlueObjectValue=jr;exports.getExtendedFromSchemaAnnotation=Ot;exports.getTypeBlueIdAnnotation=Mt;exports.hasBlueObjectBlueIdDefined=ht;exports.hasBlueObjectItemsDefined=pt;exports.hasBlueObjectNameDefined=Bs;exports.hasBlueObjectTypeDefined=ft;exports.hasBlueObjectValueDefined=gt;exports.isBigDecimalNumber=ge;exports.isBigIntegerNumber=$;exports.isBigNumber=S;exports.isBlueNodeSchema=et;exports.isBlueObject=vs;exports.isBlueObjectResolved=_t;exports.isGivenBlueObjectTypeSchema=ws;exports.isJsonBlueArray=qe;exports.isJsonBlueObject=He;exports.isJsonBlueValue=Es;exports.isSchemaExtendedFrom=tt;exports.isUrl=oe;exports.jsonBlueValueSchema=ce;exports.normalizeToBlueObject=Lr;exports.resolveBlueObjectItems=Ze;exports.withBlueDescription=Bt;exports.withBlueId=Pt;exports.withBlueName=Et;exports.withBlueNode=Ct;exports.withExtendedFromSchema=Dt;exports.withTypeBlueId=Xs;exports.yamlBlueDump=Er;exports.yamlBlueParse=F;
|
|
26
|
+
`}loadDefaultSimpleBlue(){const e=this.enrichDefaultBlue(Lt);try{const t=F(e);if(t)this.defaultSimpleBlue=y.deserialize(t);else throw new Error("Failed to parse default Blue content")}catch(t){throw new Error(`Error loading default Blue: ${t}`)}}};p(be,"DEFAULT_BLUE_BLUE_ID","FREHAAGDZSzpnoTUoCQ86bBmxbVCULMjvx9JZM6fyqT1");let te=be;class Zr extends zt{constructor(t){super();p(this,"blueIdToContentMap",new Map);p(this,"blueIdToMultipleDocumentsMap",new Map);p(this,"preprocessor");const s=new te({nodeProvider:this});this.preprocessor=n=>s.preprocessWithDefaultBlue(n),this.loadRepositories(t)}loadRepositories(t){for(const s of t)if(s.contents)for(const[n,i]of Object.entries(s.contents))this.processContent(i,n)}processContent(t,s){Array.isArray(t)?this.processMultipleDocuments(t,s):this.processSingleDocument(t,s)}processSingleDocument(t,s){const n=y.deserialize(t),i=j.parseAndCalculateBlueIdForNode(n,this.preprocessor),o=s||i.blueId;this.blueIdToContentMap.set(o,i.content),this.blueIdToMultipleDocumentsMap.set(o,!1);const l=n.getName();l&&this.addToNameMap(l,o)}processMultipleDocuments(t,s){const n=t.map(l=>{const a=y.deserialize(l);return this.preprocessor(a)}),i=j.parseAndCalculateBlueIdForNodeList(n,l=>l),o=s||i.blueId;this.blueIdToContentMap.set(o,i.content),this.blueIdToMultipleDocumentsMap.set(o,!0),n.forEach((l,a)=>{const h=`${o}#${a}`,I=b.get(l),m=N.calculateBlueIdSync(l);this.blueIdToContentMap.set(m,I),this.blueIdToMultipleDocumentsMap.set(m,!1);const f=l.getName();f&&this.addToNameMap(f,h)})}fetchContentByBlueId(t){const s=this.blueIdToContentMap.get(t),n=this.blueIdToMultipleDocumentsMap.get(t);return s!==void 0&&n!==void 0?j.resolveThisReferences(s,t,n):null}getBlueIds(){return Array.from(this.blueIdToContentMap.keys())}hasBlueId(t){const s=t.split("#")[0];return this.blueIdToContentMap.has(s)}}class ue{static wrap(e,t){const s=[Le.INSTANCE];if(t&&t.length>0){const n=new Zr(t);s.push(n)}return s.push(e),new vr(s)}}class _r{constructor(e,t){p(this,"preprocessingAliases",new Map);p(this,"urlContentFetcher");e&&(this.preprocessingAliases=new Map(e)),this.urlContentFetcher=t}process(e){const t=this.getBlueNodeValue(e);if(t){const s=e.clone();if(this.preprocessingAliases.has(t))return this.handleAliasValue(s,t);if(Z.isPotentialBlueId(t))return this.handleBlueId(s,t);throw oe(t)?new Error(`URL '${t}' detected. Use the async version of this method to fetch the content.`):new Error(`Invalid blue value: ${t}`)}return e}async processAsync(e){const t=this.getBlueNodeValue(e);if(t){const s=e.clone();if(this.preprocessingAliases.has(t))return this.handleAliasValue(s,t);if(Z.isPotentialBlueId(t))return this.handleBlueId(s,t);if(oe(t)&&this.urlContentFetcher)try{const n=await this.fetchFromUrl(t);return n&&s.setBlue(new d().setItems(n)),s}catch(n){throw n instanceof Error?new Error(`Failed to fetch from URL '${t}'.
|
|
27
|
+
${n.message}`):n}else throw oe(t)?new Error(`UrlContentFetcher not provided for URL: ${t}`):new Error(`Invalid blue value: ${t}`)}return e}getBlueNodeValue(e){const t=e.getBlue(),s=t==null?void 0:t.getValue();return s&&typeof s=="string"?s:null}handleAliasValue(e,t){return e.setBlue(new d().setBlueId(this.preprocessingAliases.get(t))),e}handleBlueId(e,t){return e.setBlue(new d().setBlueId(t)),e}async fetchFromUrl(e){if(!this.urlContentFetcher)throw new Error(`UrlContentFetcher not provided for URL: ${e}`);return await this.urlContentFetcher.fetchAndCache(e)}getPreprocessingAliases(){return new Map(this.preprocessingAliases)}setPreprocessingAliases(e){return this.preprocessingAliases=new Map(e),this}addPreprocessingAliases(e){return e.forEach((t,s)=>{this.preprocessingAliases.set(s,t)}),this}setUrlContentFetcher(e){return this.urlContentFetcher=e,this}getUrlContentFetcher(){return this.urlContentFetcher}}const kr={fetchUrl:async r=>{throw new Error(`You must provide a custom UrlFetchStrategy to fetch content from URL: ${r}`)}};class Yr{constructor(e){p(this,"cache",new Map);p(this,"fetchStrategy");p(this,"enabled",!1);p(this,"allowedDomains",[]);this.fetchStrategy=e||kr}validateUrl(e){if(!oe(e))throw new Error(`Invalid URL: ${e}`);return!0}isDomainAllowed(e){if(this.allowedDomains.length===0)return!0;try{const t=new URL(e);return this.allowedDomains.some(s=>t.hostname===s||t.hostname.endsWith(`.${s}`))}catch{return!1}}getFromCache(e){try{return this.validateUrl(e),this.cache.get(e)||[]}catch{return[]}}async fetchAndCache(e){if(this.validateUrl(e),!this.enabled)throw new Error("URL fetching is disabled. Enable it using the enableFetching method.");if(!this.isDomainAllowed(e))throw new Error(`Domain not allowed for URL: ${e}.`);let t;try{t=await this.fetchStrategy.fetchUrl(e)}catch(l){throw new Error(`Error fetching from URL: ${e}`,{cause:l})}const{data:s,contentType:n}=t;let i;if(n.includes("application/json")||n.includes("text/yaml")||n.includes("application/yaml")||n.includes("text/plain"))i=F(s);else throw new Error(`Unsupported content type from URL: ${n}`);if(i===void 0)throw new Error(`Failed to parse content from URL: ${e}`);let o;return Array.isArray(i)?o=i.map(l=>y.deserialize(l)):o=[y.deserialize(i)],this.cache.set(e,o),o}prefetchUrl(e,t){try{this.validateUrl(e),this.cache.set(e,t)}catch{}}clearCache(){this.cache.clear()}setFetchStrategy(e){return this.fetchStrategy=e,this}getFetchStrategy(){return this.fetchStrategy}enableFetching(){return this.enabled=!0,this.allowedDomains=[],this}enableFetchingForDomains(e){return this.enabled=!0,this.allowedDomains=[...e],this}disableFetching(){return this.enabled=!1,this}isFetchingEnabled(){return this.enabled}getAllowedDomains(){return[...this.allowedDomains]}allowDomain(e){return this.allowedDomains.includes(e)||this.allowedDomains.push(e),this}disallowDomain(e){return this.allowedDomains=this.allowedDomains.filter(t=>t!==e),this}clearAllowedDomains(){return this.allowedDomains=[],this}}class Yt{reverse(e){const t=new d;return this.reverseNode(t,e,e.getType()),t}reverseNode(e,t,s){this.isIdenticalToType(t,s)||(this.reverseBasicProperties(e,t,s),this.reverseTypeReferences(e,t,s),this.reverseItems(e,t,s),this.reverseProperties(e,t,s))}isIdenticalToType(e,t){return c.isNonNullable(e.getBlueId())&&c.isNonNullable(t==null?void 0:t.getBlueId())&&e.getBlueId()===t.getBlueId()}reverseBasicProperties(e,t,s){const n=t.getValue();c.isNonNullable(n)&&(c.isNullable(s)||c.isNullable(s.getValue()))&&e.setValue(n),c.isNonNullable(t.getName())&&(c.isNullable(s)||t.getName()!==s.getName())&&e.setName(t.getName()),c.isNonNullable(t.getDescription())&&(c.isNullable(s)||t.getDescription()!==s.getDescription())&&e.setDescription(t.getDescription()),c.isNonNullable(t.getBlueId())&&(c.isNullable(s)||t.getBlueId()!==s.getBlueId())&&e.setBlueId(t.getBlueId())}reverseTypeReferences(e,t,s){const n=(i,o)=>{const l=i(t),a=s?i(s):void 0,h=l==null?void 0:l.getBlueId();c.isNonNullable(h)&&(c.isNullable(a==null?void 0:a.getBlueId())||h!==a.getBlueId())&&o(e,new d().setBlueId(h))};n(i=>i.getType(),(i,o)=>i.setType(o)),n(i=>i.getItemType(),(i,o)=>i.setItemType(o)),n(i=>i.getKeyType(),(i,o)=>i.setKeyType(o)),n(i=>i.getValueType(),(i,o)=>i.setValueType(o))}reverseItems(e,t,s){const n=t.getItems();if(c.isNullable(n))return;const i=s==null?void 0:s.getItems(),o=[];if(c.isNonNullable(i)&&i.length>0){const a=N.calculateBlueIdSync(i);o.push(new d().setBlueId(a))}const l=(i==null?void 0:i.length)||0;for(let a=l;a<n.length;a++){const h=new d;this.reverseNode(h,n[a],void 0),o.push(h)}o.length>0&&e.setItems(o)}reverseProperties(e,t,s){const n=t.getProperties();if(c.isNullable(n))return;const i={};for(const[o,l]of Object.entries(n)){const a=this.getInheritedProperty(o,t,s),h=new d;this.reverseNode(h,l,a),ve.isEmptyNode(h)||(i[o]=h)}Object.keys(i).length>0&&e.setProperties(i)}getInheritedProperty(e,t,s){var o,l,a;const n=(o=s==null?void 0:s.getProperties())==null?void 0:o[e],i=(a=(l=t.getType())==null?void 0:l.getProperties())==null?void 0:a[e];if(!(c.isNullable(n)&&c.isNullable(i)))return c.isNullable(n)?i:c.isNullable(i)?n:this.mergeNodes(n,i)}mergeNodes(e,t){const s=e.clone(),n=t.getValue();c.isNonNullable(n)&&s.setValue(n);const i=t.getType();c.isNonNullable(i)&&s.setType(i.clone());const o=t.getItemType();c.isNonNullable(o)&&s.setItemType(o.clone());const l=t.getKeyType();c.isNonNullable(l)&&s.setKeyType(l.clone());const a=t.getValueType();c.isNonNullable(a)&&s.setValueType(a.clone());const h=t.getProperties();if(c.isNonNullable(h)){const m=s.getProperties()||{};for(const[f,g]of Object.entries(h))m[f]=g.clone();s.setProperties(m)}const I=t.getItems();return c.isNonNullable(I)&&s.setItems(I.map(m=>m.clone())),s}}class Pe extends d{constructor(e){super(e.getName()),this.createFrom(e)}isResolved(){return!0}getMinimalNode(){return new Yt().reverse(this)}getMinimalBlueId(){const e=this.getMinimalNode();return N.calculateBlueIdSync(e)}clone(){const e=super.clone();return new Pe(e)}createFrom(e){e.getName()!==this.getName()&&this.setName(e.getName()),this.setDescription(e.getDescription()).setType(e.getType()).setItemType(e.getItemType()).setKeyType(e.getKeyType()).setValueType(e.getValueType()).setItems(e.getItems()).setProperties(e.getProperties()).setBlueId(e.getBlueId()).setBlue(e.getBlue()).setInlineValue(e.isInlineValue());const t=e.getValue();t!==void 0&&this.setValue(t)}}class Jt{resolveWithoutLimits(e){return this.resolve(e,z)}}class Kt extends Jt{constructor(t,s){super();p(this,"mergingProcessor");p(this,"nodeProvider");this.mergingProcessor=t,this.nodeProvider=ue.wrap(s)}merge(t,s,n){if(c.isNonNullable(s.getBlue()))throw new Error('Document contains "blue" attribute. Preprocess document before merging.');let i=t;const o=s.getType();if(c.isNonNullable(o)){const l=o.clone();c.isNonNullable(l.getBlueId())&&new tt(this.nodeProvider).extend(l,we.withSinglePath("/"));const a=this.resolve(l,n),h=s.clone().setType(a);return i=this.merge(i,l,n),this.mergeObject(i,h,n)}return this.mergeObject(i,s,n)}mergeObject(t,s,n){let i=this.mergingProcessor.process(t,s,this.nodeProvider);const o=s.getItems();c.isNonNullable(o)&&(i=this.mergeChildren(i,o,n));const l=s.getProperties();return c.isNonNullable(l)&&Object.entries(l).forEach(([a,h])=>{n.shouldMergePathSegment(a,h)&&(n.enterPathSegment(a,h),i=this.mergeProperty(i,a,h,n),n.exitPathSegment())}),c.isNonNullable(s.getBlueId())&&(i=i.clone().setBlueId(s.getBlueId())),this.mergingProcessor.postProcess&&(i=this.mergingProcessor.postProcess(i,s,this.nodeProvider)),i}mergeChildren(t,s,n){const i=t.getItems();if(c.isNullable(i)){const l=s.filter((a,h)=>n.shouldMergePathSegment(String(h),a)).map(a=>{n.enterPathSegment(String(s.indexOf(a)),a);const h=this.resolve(a,n);return n.exitPathSegment(),h});return t.clone().setItems(l)}else if(s.length<i.length)throw new Error(`Subtype of element must not have more items (${i.length}) than the element itself (${s.length}).`);const o=[...i];for(let l=0;l<s.length;l++){if(!n.shouldMergePathSegment(String(l),s[l]))continue;if(n.enterPathSegment(String(l),s[l]),l>=o.length){o.push(s[l]),n.exitPathSegment();continue}const a=N.calculateBlueIdSync(s[l]),h=N.calculateBlueIdSync(o[l]);if(a!==h)throw new Error(`Mismatched items at index ${l}: source item has blueId '${a}', but target item has blueId '${h}'.`);n.exitPathSegment()}return t.clone().setItems(o)}mergeProperty(t,s,n,i){const o=this.resolve(n,i),l=t.clone();c.isNullable(l.getProperties())&&l.setProperties({});const a=l.getProperties()[s];return a===void 0?l.getProperties()[s]=o:l.getProperties()[s]=this.mergeObject(a,o,i),l}resolve(t,s){const n=new d,o=this.merge(n,t,s).clone().setName(t.getName()).setDescription(t.getDescription()).setBlueId(t.getBlueId());return new Pe(o)}}class Gt{constructor(e){p(this,"mergingProcessors");this.mergingProcessors=e}process(e,t,s){return this.mergingProcessors.reduce((n,i)=>i.process(n,t,s),e)}postProcess(e,t,s){return this.mergingProcessors.reduce((n,i)=>i.postProcess?i.postProcess(n,t,s):n,e)}}class Wt{process(e,t){const s=t.getValue();if(c.isNonNullable(s)){const n=e.getValue();if(c.isNullable(n))return e.clone().setValue(s);if(!Jr(s,n))throw new Error(`Node values conflict. Source node value: ${s}, target node value: ${n}`)}return e}}const Jr=(r,e)=>$(r)&&$(e)||ge(r)&&ge(e)?r.eq(e):r===e;class Ht{process(e,t,s){const n=e.getType(),i=t.getType();let o=e;if(n===void 0)o=e.clone().setType(i);else if(i!==void 0){if(!S(i,n,s)){const a=b.get(i),h=b.get(n);throw new Error(`The source type '${JSON.stringify(a)}' is not a subtype of the target type '${JSON.stringify(h)}'.`)}o=e.clone().setType(i)}return o}}class qt{process(e,t,s){if(t.getItemType()!==void 0&&!Rt(t.getType()))throw new Error("Source node with itemType must have a List type");const n=e.getItemType(),i=t.getItemType();let o=e;if(n===void 0)i!==void 0&&(o=e.clone().setItemType(i));else if(i!==void 0){if(!S(i,n,s)){const I=b.get(i),m=b.get(n);throw new Error(`The source item type '${JSON.stringify(I)}' is not a subtype of the target item type '${JSON.stringify(m)}'.`)}o=e.clone().setItemType(i)}const l=o.getItemType(),a=t.getItems();if(l!==void 0&&a!==void 0)for(const h of a){const I=h.getType();if(I!==void 0&&!S(I,l,s)){const m=b.get(I),f=b.get(l);throw new Error(`Item of type '${JSON.stringify(m)}' is not a subtype of the list's item type '${JSON.stringify(f)}'.`)}}return o}}class Xt{process(e,t,s){if((t.getKeyType()!==void 0||t.getValueType()!==void 0)&&!jt(t.getType()))throw new Error("Source node with keyType or valueType must have a Dictionary type");let n=this.processKeyType(e,t,s);n=this.processValueType(n,t,s);const i=n.getKeyType(),o=n.getValueType(),l=t.getProperties();return(i!==void 0||o!==void 0)&&l!==void 0&&Object.entries(l).forEach(([a,h])=>{i!==void 0&&this.validateKeyType(a,i,s),o!==void 0&&this.validateValueType(h,o,s)}),n}processKeyType(e,t,s){const n=e.getKeyType(),i=t.getKeyType();if(n===void 0){if(i!==void 0)return this.validateBasicKeyType(i,s),e.clone().setKeyType(i)}else if(i!==void 0){if(this.validateBasicKeyType(i,s),!S(i,n,s)){const l=b.get(i),a=b.get(n);throw new Error(`The source key type '${JSON.stringify(l)}' is not a subtype of the target key type '${JSON.stringify(a)}'.`)}return e.clone().setKeyType(i)}return e}processValueType(e,t,s){const n=e.getValueType(),i=t.getValueType();if(n===void 0){if(i!==void 0)return e.clone().setValueType(i)}else if(i!==void 0){if(!S(i,n,s)){const l=b.get(i),a=b.get(n);throw new Error(`The source value type '${JSON.stringify(l)}' is not a subtype of the target value type '${JSON.stringify(a)}'.`)}return e.clone().setValueType(i)}return e}validateBasicKeyType(e,t){if(!er(e,t))throw new Error("Dictionary key type must be a basic type")}validateKeyType(e,t,s){if(!tr(t,s))if(sr(t,s)){const n=Number.parseInt(e,10);if(Number.isNaN(n)||n.toString()!==e)throw new Error(`Key '${e}' is not a valid Integer.`)}else if(rr(t,s)){const n=Number.parseFloat(e);if(Number.isNaN(n))throw new Error(`Key '${e}' is not a valid Number.`)}else if(nr(t,s)){if(e.toLowerCase()!=="true"&&e.toLowerCase()!=="false")throw new Error(`Key '${e}' is not a valid Boolean.`)}else throw new Error(`Unsupported key type: ${t.getName()||"unknown"}`)}validateValueType(e,t,s){const n=e.getType();if(n!==void 0&&!S(n,t,s)){const i=b.get(n),o=b.get(t);throw new Error(`Value of type '${JSON.stringify(i)}' is not a subtype of the dictionary's value type '${JSON.stringify(o)}'.`)}}}class Qt{process(e){return e}postProcess(e,t,s){const n=e.getType();if(n!==void 0&&ir(n,s)){const i=e.getItems(),o=e.getProperties();if(i!==void 0&&i.length>0||o!==void 0&&Object.keys(o).length>0){const l=or(n,s),a=n.getName()||"unknown";throw new Error(`Node of type "${a}" (which extends basic type "${l}") must not have items, properties or contracts.`)}}return e}}class es{process(e,t){let s=e;const n=t.getName(),i=e.getName();n!==void 0&&i===void 0&&(s=s.clone().setName(n));const o=t.getDescription(),l=s.getDescription();return o!==void 0&&l===void 0&&(s=s.clone().setDescription(o)),s}}const Kr=Object.freeze(Object.defineProperty({__proto__:null,BasicTypesVerifier:Qt,DictionaryProcessor:Xt,ListProcessor:qt,MetadataPropagator:es,SequentialMergingProcessor:Gt,TypeAssigner:Ht,ValuePropagator:Wt},Symbol.toStringTag,{value:"Module"}));function Gr(){return new Gt([new Wt,new Ht,new qt,new Xt,new es,new Qt])}class Wr{constructor(e={}){p(this,"nodeProvider");p(this,"typeSchemaResolver");p(this,"blueDirectivePreprocessor");p(this,"urlContentFetcher");p(this,"blueIdsMappingGenerator");p(this,"globalLimits",z);p(this,"mergingProcessor");p(this,"repositories");p(this,"prepareForBlueIdCalculation",async e=>e instanceof d||Array.isArray(e)&&e.every(t=>t instanceof d)?e:Array.isArray(e)?await Promise.all(e.map(s=>this.jsonValueToNodeAsync(s))):this.jsonValueToNodeAsync(e));p(this,"calculateBlueId",async e=>{const t=await this.prepareForBlueIdCalculation(e);return N.calculateBlueId(t)});p(this,"prepareForBlueIdCalculationSync",e=>e instanceof d||Array.isArray(e)&&e.every(t=>t instanceof d)?e:Array.isArray(e)?e.map(t=>this.jsonValueToNode(t)):this.jsonValueToNode(e));var a;const{nodeProvider:t,typeSchemaResolver:s=null,urlFetchStrategy:n,repositories:i,mergingProcessor:o}=e;this.repositories=i;const l=Tr(()=>[]);if(this.nodeProvider=ue.wrap(t||l,i),this.typeSchemaResolver=s??new Ft([]),this.mergingProcessor=o??Gr(),this.urlContentFetcher=new Yr(n),this.blueDirectivePreprocessor=new _r(void 0,this.urlContentFetcher),this.blueIdsMappingGenerator=new kt,i)for(const{schemas:h,blueIds:I}of i)(a=this.typeSchemaResolver)==null||a.registerSchemas(h),this.blueIdsMappingGenerator.registerBlueIds(I)}nodeToJson(e,t="official"){return b.get(e,t)}nodeToSchemaOutput(e,t){return new Nr(this.typeSchemaResolver).convert(e,t)}resolve(e,t=z){const s=this.combineWithGlobalLimits(t);return new Kt(this.mergingProcessor,this.nodeProvider).resolve(e,s)}reverse(e){return new Yt().reverse(e)}extend(e,t){const s=this.combineWithGlobalLimits(t);new tt(this.nodeProvider).extend(e,s)}jsonValueToNode(e){return this.preprocess(y.deserialize(e))}async jsonValueToNodeAsync(e){return this.preprocessAsync(y.deserialize(e))}yamlToNode(e){const t=F(e);if(!t)throw new Error("Failed to parse YAML to JSON");return this.jsonValueToNode(t)}async yamlToNodeAsync(e){const t=F(e);if(!t)throw new Error("Failed to parse YAML to JSON");return this.jsonValueToNodeAsync(t)}calculateBlueIdSync(e){const t=this.prepareForBlueIdCalculationSync(e);return N.calculateBlueIdSync(t)}addPreprocessingAliases(e){this.blueDirectivePreprocessor.addPreprocessingAliases(e)}preprocess(e){const t=this.blueDirectivePreprocessor.process(e);return new te({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).preprocessWithDefaultBlue(t)}async preprocessAsync(e){const t=await this.blueDirectivePreprocessor.processAsync(e);return new te({nodeProvider:this.nodeProvider,blueIdsMappingGenerator:this.blueIdsMappingGenerator}).preprocessWithDefaultBlue(t)}transform(e,t){return D.transform(e,t)}getNodeProvider(){return this.nodeProvider}setNodeProvider(e){return this.nodeProvider=ue.wrap(e,this.repositories),this}getTypeSchemaResolver(){return this.typeSchemaResolver}setTypeSchemaResolver(e){return this.typeSchemaResolver=e,this}getUrlContentFetcher(){return this.urlContentFetcher}setUrlFetchStrategy(e){return this.urlContentFetcher.setFetchStrategy(e),this}enablePreprocessingDirectivesFetchForUrls(){return this.urlContentFetcher.enableFetching(),this}enablePreprocessingDirectivesFetchForDomains(e){return this.urlContentFetcher.enableFetchingForDomains(e),this}allowUrlFetchingForDomain(e){return this.urlContentFetcher.allowDomain(e),this}disallowUrlFetchingForDomain(e){return this.urlContentFetcher.disallowDomain(e),this}getAllowedUrlFetchingDomains(){return this.urlContentFetcher.getAllowedDomains()}disablePreprocessingDirectivesFetchForUrls(){return this.urlContentFetcher.disableFetching(),this}isPreprocessingDirectivesFetchForUrlsEnabled(){return this.urlContentFetcher.isFetchingEnabled()}getPreprocessingAliases(){return this.blueDirectivePreprocessor.getPreprocessingAliases()}setPreprocessingAliases(e){return this.blueDirectivePreprocessor.setPreprocessingAliases(e),this}registerBlueIds(...e){return this.blueIdsMappingGenerator.registerBlueIds(...e),this}getAllRegisteredBlueIds(){return this.blueIdsMappingGenerator.getAllBlueIds()}getAllBlueIdNames(){return this.blueIdsMappingGenerator.getAllBlueIdNames()}getBlueIdsMappingGenerator(){return this.blueIdsMappingGenerator}isTypeOf(e,t,s){return A.isTypeOf(e,t,{checkSchemaExtensions:s==null?void 0:s.checkSchemaExtensions,typeSchemaResolver:this.typeSchemaResolver})}isTypeOfNode(e,t){return new lr(this).matchesType(e,t,this.globalLimits)}setGlobalLimits(e){return this.globalLimits=e??z,this}getGlobalLimits(){return this.globalLimits}combineWithGlobalLimits(e){return this.globalLimits==z?e:e==z?this.globalLimits:Se.of(this.globalLimits,e)}}class Hr extends zt{constructor(t=[]){super();p(this,"blueIdToContentMap",new Map);p(this,"blueIdToMultipleDocumentsMap",new Map);p(this,"preprocessor");const s=new te({nodeProvider:this});this.preprocessor=n=>s.preprocessWithDefaultBlue(n),t.forEach(n=>this.processNode(n))}processNode(t){ve.hasItemsOnly(t)?this.processNodeWithItems(t):this.processSingleNode(t)}processSingleNode(t){const s=j.parseAndCalculateBlueIdForNode(t,this.preprocessor);this.blueIdToContentMap.set(s.blueId,s.content),this.blueIdToMultipleDocumentsMap.set(s.blueId,s.isMultipleDocuments);const n=t.getName();n&&this.addToNameMap(n,s.blueId)}processNodeWithItems(t){const s=t.getItems();if(!s)return;this.processNodeList(s);const n=j.parseAndCalculateBlueIdForNodeList(s,this.preprocessor);this.blueIdToContentMap.set(n.blueId,n.content),this.blueIdToMultipleDocumentsMap.set(n.blueId,!0),s.forEach((i,o)=>{const l=i.getName();l&&this.addToNameMap(l,`${n.blueId}#${o}`)})}processNodeList(t){const s=N.calculateBlueIdSync(t),n=t.map(i=>b.get(i));this.blueIdToContentMap.set(s,n),this.blueIdToMultipleDocumentsMap.set(s,!0)}fetchContentByBlueId(t){const s=this.blueIdToContentMap.get(t),n=this.blueIdToMultipleDocumentsMap.get(t);return s!==void 0&&n!==void 0?j.resolveThisReferences(s,t,n):null}addSingleNodes(...t){t.forEach(s=>this.processNode(s))}addSingleDocs(...t){t.forEach(s=>{const n=F(s);if(n!==void 0){const i=y.deserialize(n);this.processNode(i)}})}getBlueIdByName(t){const s=this.nameToBlueIdsMap.get(t);if(!s||s.length===0)throw new Error(`No node with name "${t}"`);return s[0]}getNodeByName(t){const s=this.findNodeByName(t);if(!s)throw new Error(`No node with name "${t}"`);return s}addListAndItsItemsFromNodes(t){this.processNodeList(t),t.forEach(s=>this.processNode(s))}addListAndItsItemsFromDoc(t){const s=F(t);if(s!==void 0){const i=y.deserialize(s).getItems();i&&this.addListAndItsItems(i)}}addListAndItsItems(t){Array.isArray(t)?this.addListAndItsItemsFromNodes(t):this.addListAndItsItemsFromDoc(t)}addList(t){this.processNodeList(t)}}exports.Base58Sha256Provider=mt;exports.BasicNodeProvider=Hr;exports.Blue=Wr;exports.BlueIdCalculator=N;exports.BlueIdToCid=Ms;exports.BlueNode=d;exports.BlueNodeTypeSchema=A;exports.JsonCanonicalizer=yt;exports.Limits=Be;exports.Merger=Kt;exports.MergingProcessors=Kr;exports.NodeResolver=Jt;exports.Nodes=ve;exports.ResolvedBlueNode=Pe;exports.TypeSchemaResolver=Ft;exports.applyBlueNodePatch=_s;exports.baseBlueObjectSchema=he;exports.blueDescriptionField=Ys;exports.blueIdField=Ks;exports.blueIdSchema=ms;exports.blueNameField=Gs;exports.blueNodeField=Ws;exports.blueObjectBooleanValueSchema=Ns;exports.blueObjectNumberValueSchema=bs;exports.blueObjectSchema=Q;exports.blueObjectStringListItemsSchema=Ts;exports.blueObjectStringValueSchema=Is;exports.calculateBlueId=Zt;exports.calculateBlueIdSync=Fr;exports.enrichWithBlueId=ze;exports.getBlueDescriptionAnnotation=wt;exports.getBlueIdAnnotation=Pt;exports.getBlueNameAnnotation=At;exports.getBlueNodeAnnotation=Vt;exports.getBlueObjectItems=Rr;exports.getBlueObjectProperties=xr;exports.getBlueObjectTypeLabel=$r;exports.getBlueObjectValue=jr;exports.getExtendedFromSchemaAnnotation=Ot;exports.getTypeBlueIdAnnotation=Mt;exports.hasBlueObjectBlueIdDefined=ht;exports.hasBlueObjectItemsDefined=pt;exports.hasBlueObjectNameDefined=Bs;exports.hasBlueObjectTypeDefined=ft;exports.hasBlueObjectValueDefined=gt;exports.isBigDecimalNumber=ge;exports.isBigIntegerNumber=$;exports.isBigNumber=P;exports.isBlueNodeSchema=Qe;exports.isBlueObject=vs;exports.isBlueObjectResolved=_t;exports.isGivenBlueObjectTypeSchema=ws;exports.isJsonBlueArray=He;exports.isJsonBlueObject=We;exports.isJsonBlueValue=Es;exports.isSchemaExtendedFrom=et;exports.isUrl=oe;exports.jsonBlueValueSchema=ce;exports.normalizeToBlueObject=Lr;exports.resolveBlueObjectItems=Ue;exports.withBlueDescription=Bt;exports.withBlueId=St;exports.withBlueName=Et;exports.withBlueNode=Ct;exports.withExtendedFromSchema=Dt;exports.withTypeBlueId=Xs;exports.yamlBlueDump=Er;exports.yamlBlueParse=F;
|
package/dist/index.mjs
CHANGED
|
@@ -2,10 +2,10 @@ var Ht = Object.defineProperty;
|
|
|
2
2
|
var Xt = (s, e, t) => e in s ? Ht(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
3
|
var d = (s, e, t) => Xt(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import $ from "big.js";
|
|
5
|
-
import { isNullable as v, isNonNullable as p, jsonPrimitiveSchema as qt, isReadonlyArray as ye, isJsonPrimitive as
|
|
5
|
+
import { isNullable as v, isNonNullable as p, jsonPrimitiveSchema as qt, isReadonlyArray as ye, isJsonPrimitive as Ke, isPreciseNumberString as ht } from "@blue-labs/shared-utils";
|
|
6
6
|
import { z as h, ZodOptional as ft, ZodNullable as gt, ZodReadonly as yt, ZodBranded as mt, ZodEffects as me, ZodLazy as Ie, ZodString as X, ZodNumber as q, ZodBoolean as he, ZodBigInt as fe, ZodEnum as Qt, ZodNativeEnum as er, ZodIntersection as tr, ZodUnion as rr, ZodObject as sr, ZodRecord as nr } from "zod";
|
|
7
7
|
import ce from "bs58";
|
|
8
|
-
import { isObject as It, isArray as
|
|
8
|
+
import { isObject as It, isArray as ze, isString as Ge, omit as Tt, pascal as ir, map as or } from "radash";
|
|
9
9
|
import { sha256 as lr } from "js-sha256";
|
|
10
10
|
import Ve from "crypto";
|
|
11
11
|
import cr from "base32.js";
|
|
@@ -138,23 +138,23 @@ class ar {
|
|
|
138
138
|
return p(r) ? r : e;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
const Q = "name", ee = "description", Te = "type",
|
|
141
|
+
const Q = "name", ee = "description", Te = "type", Je = "itemType", We = "keyType", He = "valueType", Pe = "value", Xe = "items", k = "blueId", qe = "blue", ur = [
|
|
142
142
|
Q,
|
|
143
143
|
ee,
|
|
144
144
|
Te,
|
|
145
|
+
Je,
|
|
145
146
|
We,
|
|
146
147
|
He,
|
|
147
|
-
Xe,
|
|
148
148
|
Pe,
|
|
149
|
-
|
|
149
|
+
Xe,
|
|
150
150
|
k,
|
|
151
|
-
|
|
152
|
-
], dr = "Text", pr = "Double", hr = "Integer", fr = "Boolean", gr = "List", yr = "Dictionary",
|
|
151
|
+
qe
|
|
152
|
+
], dr = "Text", pr = "Double", hr = "Integer", fr = "Boolean", gr = "List", yr = "Dictionary", Qe = [
|
|
153
153
|
dr,
|
|
154
154
|
pr,
|
|
155
155
|
hr,
|
|
156
156
|
fr
|
|
157
|
-
], vt = [...
|
|
157
|
+
], vt = [...Qe, gr, yr], K = "F92yo19rCcbBoBSpUA5LRxpfDejJDAaP1PRxxbWAraVP", z = "68ryJtnmui4j5rCZWUnkZ3DChtmEb7Z9F8atn1mBSM3L", G = "DHmxTkFbXePZHCHCYmQr2dSzcNLcryFVjXVHkdQrrZr8", J = "EL6AjrbJsxTWRTPzY8WR8Y2zAMXRbydQj83PcZwuAHbo", bt = "G8wmfjEqugPEEXByMYWJXiEdbLToPRWNQEekNxrxfQWB", wt = "294NBTj2mFRL3RB4kDRUSckwGg7Kzj6T8CTAFeR1kcSA", Bt = [
|
|
158
158
|
K,
|
|
159
159
|
z,
|
|
160
160
|
G,
|
|
@@ -401,7 +401,7 @@ const nn = h.string().max(_.MAX_BLUE_ID_LENGTH, {
|
|
|
401
401
|
value: h.boolean().optional()
|
|
402
402
|
}), an = Ee.extend({
|
|
403
403
|
items: h.array(h.string()).optional()
|
|
404
|
-
}), un = (s) => ae.safeParse(s).success, Ir = (s) => p(s) && "blueId" in s && p(s.blueId), dn = (s) => p(s) && "name" in s && p(s.name), Tr = (s) => p(s) && "items" in s && p(s.items), vr = (s) => p(s) && "type" in s && p(s.type), br = (s) => p(s) && "value" in s && p(s.value), pn = (s, e) => s.required({ type: !0 }).safeParse(e).success, A = (s) => s instanceof $, Z = (s) => A(s) && s instanceof w,
|
|
404
|
+
}), un = (s) => ae.safeParse(s).success, Ir = (s) => p(s) && "blueId" in s && p(s.blueId), dn = (s) => p(s) && "name" in s && p(s.name), Tr = (s) => p(s) && "items" in s && p(s.items), vr = (s) => p(s) && "type" in s && p(s.type), br = (s) => p(s) && "value" in s && p(s.value), pn = (s, e) => s.required({ type: !0 }).safeParse(e).success, A = (s) => s instanceof $, Z = (s) => A(s) && s instanceof w, xe = (s) => A(s) && s instanceof P, wr = h.lazy(
|
|
405
405
|
() => h.record(ve)
|
|
406
406
|
), Br = h.lazy(
|
|
407
407
|
() => h.union([
|
|
@@ -415,7 +415,7 @@ const nn = h.string().max(_.MAX_BLUE_ID_LENGTH, {
|
|
|
415
415
|
Br,
|
|
416
416
|
h.instanceof($)
|
|
417
417
|
])
|
|
418
|
-
), Nt = (s) => It(s) && !
|
|
418
|
+
), Nt = (s) => It(s) && !ze(s) && !ye(s) && !A(s), Pt = (s) => ze(s) || ye(s), hn = (s) => Pt(s) || Nt(s) || A(s) || Ke(s);
|
|
419
419
|
class y {
|
|
420
420
|
static deserialize(e) {
|
|
421
421
|
return y.handleNode(e);
|
|
@@ -452,13 +452,13 @@ class y {
|
|
|
452
452
|
case Te:
|
|
453
453
|
t.setType(y.handleNode(i));
|
|
454
454
|
break;
|
|
455
|
-
case
|
|
455
|
+
case Je:
|
|
456
456
|
t.setItemType(y.handleNode(i));
|
|
457
457
|
break;
|
|
458
|
-
case
|
|
458
|
+
case We:
|
|
459
459
|
t.setKeyType(y.handleNode(i));
|
|
460
460
|
break;
|
|
461
|
-
case
|
|
461
|
+
case He:
|
|
462
462
|
t.setValueType(y.handleNode(i));
|
|
463
463
|
break;
|
|
464
464
|
case Pe:
|
|
@@ -469,10 +469,10 @@ class y {
|
|
|
469
469
|
throw new Error(`The ${k} field must be a string.`);
|
|
470
470
|
t.setBlueId(i);
|
|
471
471
|
break;
|
|
472
|
-
case
|
|
472
|
+
case Xe:
|
|
473
473
|
t.setItems(y.handleArray(i));
|
|
474
474
|
break;
|
|
475
|
-
case
|
|
475
|
+
case qe:
|
|
476
476
|
t.setBlue(y.handleNode(i));
|
|
477
477
|
break;
|
|
478
478
|
default:
|
|
@@ -519,9 +519,9 @@ class y {
|
|
|
519
519
|
function Nr(s) {
|
|
520
520
|
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
|
|
521
521
|
}
|
|
522
|
-
var De,
|
|
522
|
+
var De, lt;
|
|
523
523
|
function Pr() {
|
|
524
|
-
return
|
|
524
|
+
return lt || (lt = 1, De = function s(e) {
|
|
525
525
|
if (typeof e == "number" && isNaN(e))
|
|
526
526
|
throw new Error("NaN is not allowed");
|
|
527
527
|
if (typeof e == "number" && !isFinite(e))
|
|
@@ -563,10 +563,10 @@ const Me = typeof process < "u" && process.versions != null && process.versions.
|
|
|
563
563
|
}
|
|
564
564
|
};
|
|
565
565
|
d(we, "instance");
|
|
566
|
-
let
|
|
566
|
+
let je = we;
|
|
567
567
|
class Cr {
|
|
568
568
|
constructor() {
|
|
569
|
-
d(this, "cryptoEnv",
|
|
569
|
+
d(this, "cryptoEnv", je.getInstance());
|
|
570
570
|
}
|
|
571
571
|
applySync(e) {
|
|
572
572
|
const t = this.canonicalizeInput(e), r = this.cryptoEnv.hasNodeCrypto() ? this.sha256Sync(t) : this.sha256SyncBrowser(t);
|
|
@@ -615,11 +615,11 @@ class T {
|
|
|
615
615
|
* @returns A JSON representation of the node.
|
|
616
616
|
*/
|
|
617
617
|
static get(e, t = "official") {
|
|
618
|
-
var
|
|
618
|
+
var ot;
|
|
619
619
|
const r = e.getValue(), n = this.handleValue(r);
|
|
620
620
|
if (n !== void 0 && t === "simple")
|
|
621
621
|
return n;
|
|
622
|
-
const i = (
|
|
622
|
+
const i = (ot = e.getItems()) == null ? void 0 : ot.map((H) => T.get(H, t));
|
|
623
623
|
if (i !== void 0 && t === "simple")
|
|
624
624
|
return i;
|
|
625
625
|
const o = e.getName(), l = e.getDescription();
|
|
@@ -637,15 +637,15 @@ class T {
|
|
|
637
637
|
H !== null && (c[Te] = { [k]: H });
|
|
638
638
|
} else u !== void 0 && (c[Te] = T.get(u, t));
|
|
639
639
|
const I = e.getItemType();
|
|
640
|
-
I !== void 0 && (c[
|
|
640
|
+
I !== void 0 && (c[Je] = T.get(I, t));
|
|
641
641
|
const m = e.getKeyType();
|
|
642
|
-
m !== void 0 && (c[
|
|
642
|
+
m !== void 0 && (c[We] = T.get(m, t));
|
|
643
643
|
const f = e.getValueType();
|
|
644
|
-
f !== void 0 && (c[
|
|
644
|
+
f !== void 0 && (c[He] = T.get(f, t)), n !== void 0 && (c[Pe] = n), i !== void 0 && (c[Xe] = i);
|
|
645
645
|
const g = e.getBlueId();
|
|
646
646
|
g !== void 0 && (c[k] = g);
|
|
647
647
|
const M = e.getBlue();
|
|
648
|
-
M !== void 0 && (c[
|
|
648
|
+
M !== void 0 && (c[qe] = M);
|
|
649
649
|
const W = e.getProperties();
|
|
650
650
|
return W !== void 0 && Object.entries(W).forEach(([H, Wt]) => {
|
|
651
651
|
c[H] = T.get(Wt, t);
|
|
@@ -666,7 +666,7 @@ class T {
|
|
|
666
666
|
return typeof e == "string" ? K : A(e) ? Z(e) ? G : z : typeof e == "boolean" ? J : null;
|
|
667
667
|
}
|
|
668
668
|
}
|
|
669
|
-
const Vr = (s) =>
|
|
669
|
+
const Vr = (s) => Ke(s) && p(s), O = class O {
|
|
670
670
|
constructor(e) {
|
|
671
671
|
d(this, "hashProvider");
|
|
672
672
|
this.hashProvider = e;
|
|
@@ -751,7 +751,7 @@ const Vr = (s) => ze(s) && p(s), O = class O {
|
|
|
751
751
|
// Method to clean the input structure by removing null or undefined values
|
|
752
752
|
cleanStructure(e) {
|
|
753
753
|
if (e != null) {
|
|
754
|
-
if (
|
|
754
|
+
if (Ke(e) || A(e))
|
|
755
755
|
return e;
|
|
756
756
|
if (Array.isArray(e) || ye(e)) {
|
|
757
757
|
const t = e.map((r) => this.cleanStructure(r)).filter(p);
|
|
@@ -866,7 +866,7 @@ function Et(s, e, t, r = !0) {
|
|
|
866
866
|
return;
|
|
867
867
|
}
|
|
868
868
|
}
|
|
869
|
-
function
|
|
869
|
+
function ct(s, e, t = !0) {
|
|
870
870
|
if (s instanceof a) {
|
|
871
871
|
const r = Et(
|
|
872
872
|
s,
|
|
@@ -912,14 +912,14 @@ function ne(s, e) {
|
|
|
912
912
|
};
|
|
913
913
|
let t = s;
|
|
914
914
|
for (let n = 0; n < e.length - 1; ++n) {
|
|
915
|
-
const i = e[n], o =
|
|
915
|
+
const i = e[n], o = ct(t, i);
|
|
916
916
|
if (o === void 0)
|
|
917
917
|
throw new Error(`Cannot resolve '/${e.slice(0, n + 1).join("/")}'`);
|
|
918
918
|
t = o;
|
|
919
919
|
}
|
|
920
920
|
const r = e[e.length - 1];
|
|
921
921
|
if (t instanceof a) {
|
|
922
|
-
const n =
|
|
922
|
+
const n = ct(t, r, !1);
|
|
923
923
|
if ((typeof n != "object" || n === null || F(n)) && !(n instanceof a) && !Array.isArray(n) && ["name", "description", "value", "blueId"].includes(r))
|
|
924
924
|
return {
|
|
925
925
|
parent: t,
|
|
@@ -932,7 +932,7 @@ function ne(s, e) {
|
|
|
932
932
|
key: Array.isArray(t) ? te(r) : r
|
|
933
933
|
};
|
|
934
934
|
}
|
|
935
|
-
function
|
|
935
|
+
function et(s, e) {
|
|
936
936
|
var t;
|
|
937
937
|
if (s instanceof a) {
|
|
938
938
|
const r = e, n = Et(s, r, !1);
|
|
@@ -963,19 +963,19 @@ function N(s) {
|
|
|
963
963
|
if (s instanceof a) return s;
|
|
964
964
|
if (s === null || typeof s == "string" || typeof s == "number" || typeof s == "boolean" || F(s))
|
|
965
965
|
return y.deserialize(s);
|
|
966
|
-
const e =
|
|
966
|
+
const e = Le(s);
|
|
967
967
|
return y.deserialize(e);
|
|
968
968
|
}
|
|
969
|
-
function
|
|
969
|
+
function Le(s) {
|
|
970
970
|
if (s === void 0) return null;
|
|
971
971
|
if (s === null || typeof s != "object") return s;
|
|
972
|
-
if (Array.isArray(s)) return s.map(
|
|
972
|
+
if (Array.isArray(s)) return s.map(Le);
|
|
973
973
|
const e = {};
|
|
974
974
|
for (const [t, r] of Object.entries(s))
|
|
975
|
-
e[t] =
|
|
975
|
+
e[t] = Le(r);
|
|
976
976
|
return e;
|
|
977
977
|
}
|
|
978
|
-
function
|
|
978
|
+
function tt(s, e, t) {
|
|
979
979
|
if (s instanceof a) {
|
|
980
980
|
const r = e;
|
|
981
981
|
switch (r) {
|
|
@@ -1087,7 +1087,7 @@ function be(s, e, t, r) {
|
|
|
1087
1087
|
return;
|
|
1088
1088
|
}
|
|
1089
1089
|
if (s instanceof a) {
|
|
1090
|
-
e === "-" || typeof e == "number" && !isNaN(e) || typeof e == "string" && /^\d+$/.test(e) ? Mr(s, e, N(t), r) :
|
|
1090
|
+
e === "-" || typeof e == "number" && !isNaN(e) || typeof e == "string" && /^\d+$/.test(e) ? Mr(s, e, N(t), r) : tt(s, e, t);
|
|
1091
1091
|
return;
|
|
1092
1092
|
}
|
|
1093
1093
|
if (x(s)) {
|
|
@@ -1111,17 +1111,17 @@ function Fr(s, e) {
|
|
|
1111
1111
|
return;
|
|
1112
1112
|
}
|
|
1113
1113
|
}
|
|
1114
|
-
|
|
1114
|
+
tt(s, e, void 0);
|
|
1115
1115
|
} else x(s) && delete s[e];
|
|
1116
1116
|
}
|
|
1117
|
-
function
|
|
1117
|
+
function Ue(s) {
|
|
1118
1118
|
if (s instanceof a) return s.clone();
|
|
1119
1119
|
if (Array.isArray(s))
|
|
1120
|
-
return s.map((t) =>
|
|
1120
|
+
return s.map((t) => Ue(t));
|
|
1121
1121
|
if (x(s)) {
|
|
1122
1122
|
const e = {};
|
|
1123
1123
|
return Object.keys(s).forEach((t) => {
|
|
1124
|
-
e[t] =
|
|
1124
|
+
e[t] = Ue(s[t]);
|
|
1125
1125
|
}), e;
|
|
1126
1126
|
}
|
|
1127
1127
|
return s;
|
|
@@ -1141,7 +1141,7 @@ function U(s, e) {
|
|
|
1141
1141
|
}
|
|
1142
1142
|
function St(s, e) {
|
|
1143
1143
|
const { parent: t, key: r } = ne(s, se(e));
|
|
1144
|
-
return
|
|
1144
|
+
return et(t, r);
|
|
1145
1145
|
}
|
|
1146
1146
|
function At(s, e, t) {
|
|
1147
1147
|
const r = se(e);
|
|
@@ -1176,9 +1176,9 @@ function Rr(s, e, t) {
|
|
|
1176
1176
|
}
|
|
1177
1177
|
const { parent: n, key: i, actualTarget: o } = ne(s, r);
|
|
1178
1178
|
if (o !== void 0 && n instanceof a)
|
|
1179
|
-
|
|
1179
|
+
tt(n, i, t);
|
|
1180
1180
|
else {
|
|
1181
|
-
const l =
|
|
1181
|
+
const l = et(n, i), c = Array.isArray(n) || n instanceof a && n.getItems() && (typeof i == "number" || typeof i == "string" && /^\d+$/.test(i));
|
|
1182
1182
|
if (l === void 0) {
|
|
1183
1183
|
if (c)
|
|
1184
1184
|
throw new Error(
|
|
@@ -1198,11 +1198,11 @@ function Ct(s, e) {
|
|
|
1198
1198
|
return Fr(r, n), !0;
|
|
1199
1199
|
}
|
|
1200
1200
|
function $r(s, e, t) {
|
|
1201
|
-
const r =
|
|
1201
|
+
const r = Ue(St(s, e));
|
|
1202
1202
|
return At(s, t, r), !0;
|
|
1203
1203
|
}
|
|
1204
1204
|
function xr(s, e, t) {
|
|
1205
|
-
const r = se(e), { parent: n, key: i } = ne(s, r), o =
|
|
1205
|
+
const r = se(e), { parent: n, key: i } = ne(s, r), o = et(n, i);
|
|
1206
1206
|
if (o === void 0)
|
|
1207
1207
|
throw new Error(`MOVE failed: 'from' location '${e}' does not exist.`);
|
|
1208
1208
|
return Ct(s, e) ? (At(s, t, o), !0) : !1;
|
|
@@ -1278,7 +1278,7 @@ const C = (s) => Vt().get(s), _r = (s) => (e) => {
|
|
|
1278
1278
|
});
|
|
1279
1279
|
}, kr = (s) => {
|
|
1280
1280
|
const e = C(s);
|
|
1281
|
-
return p(e) &&
|
|
1281
|
+
return p(e) && Ge(e.blueDescription) ? e.blueDescription : null;
|
|
1282
1282
|
}, yn = (s) => _r(s)(h.string().optional()), Zr = h.union([h.string(), h.boolean()]), Yr = (s) => (e) => {
|
|
1283
1283
|
const t = C(e);
|
|
1284
1284
|
return ie(e, {
|
|
@@ -1296,7 +1296,7 @@ const C = (s) => Vt().get(s), _r = (s) => (e) => {
|
|
|
1296
1296
|
});
|
|
1297
1297
|
}, Gr = (s) => {
|
|
1298
1298
|
const e = C(s);
|
|
1299
|
-
return p(e) &&
|
|
1299
|
+
return p(e) && Ge(e.blueName) ? e.blueName : null;
|
|
1300
1300
|
}, In = (s) => {
|
|
1301
1301
|
const e = h.string().optional();
|
|
1302
1302
|
return zr(s)(e);
|
|
@@ -1312,18 +1312,18 @@ const C = (s) => Vt().get(s), _r = (s) => (e) => {
|
|
|
1312
1312
|
}, Dt = (s) => !!Wr(s), Tn = () => {
|
|
1313
1313
|
const s = h.instanceof(a);
|
|
1314
1314
|
return Jr()(s);
|
|
1315
|
-
},
|
|
1315
|
+
}, _e = "extendedFrom", Hr = ({
|
|
1316
1316
|
schema: s,
|
|
1317
1317
|
baseSchema: e
|
|
1318
1318
|
}) => {
|
|
1319
1319
|
const t = C(s) || {};
|
|
1320
1320
|
return ie(s, {
|
|
1321
1321
|
...t,
|
|
1322
|
-
[
|
|
1322
|
+
[_e]: e
|
|
1323
1323
|
});
|
|
1324
1324
|
}, Xr = (s) => {
|
|
1325
1325
|
const e = C(s);
|
|
1326
|
-
return p(e) && e[
|
|
1326
|
+
return p(e) && e[_e] ? e[_e] : null;
|
|
1327
1327
|
}, Mt = (s, e) => {
|
|
1328
1328
|
const t = Xr(s);
|
|
1329
1329
|
return v(t) ? !1 : (t == null ? void 0 : t._def) === (e == null ? void 0 : e._def) ? !0 : Mt(t, e);
|
|
@@ -1442,7 +1442,7 @@ const B = {
|
|
|
1442
1442
|
BLUE: "blue",
|
|
1443
1443
|
ITEMS: "items"
|
|
1444
1444
|
};
|
|
1445
|
-
class
|
|
1445
|
+
class rt {
|
|
1446
1446
|
/**
|
|
1447
1447
|
* Check if a node is empty (has no fields set)
|
|
1448
1448
|
*/
|
|
@@ -1546,11 +1546,11 @@ class st {
|
|
|
1546
1546
|
}
|
|
1547
1547
|
}
|
|
1548
1548
|
}
|
|
1549
|
-
class
|
|
1549
|
+
class st {
|
|
1550
1550
|
}
|
|
1551
1551
|
class oe {
|
|
1552
1552
|
static convert(e) {
|
|
1553
|
-
const t = new
|
|
1553
|
+
const t = new ke();
|
|
1554
1554
|
return oe.traverseNode(e, "", t), t.build();
|
|
1555
1555
|
}
|
|
1556
1556
|
static traverseNode(e, t, r) {
|
|
@@ -1573,11 +1573,11 @@ class oe {
|
|
|
1573
1573
|
}
|
|
1574
1574
|
}
|
|
1575
1575
|
}
|
|
1576
|
-
function
|
|
1576
|
+
function at(s, e) {
|
|
1577
1577
|
const t = s.split(e), r = [...t].reverse().findIndex((i) => i !== ""), n = r === -1 ? 0 : t.length - r;
|
|
1578
1578
|
return t.slice(0, n);
|
|
1579
1579
|
}
|
|
1580
|
-
class Ae extends
|
|
1580
|
+
class Ae extends st {
|
|
1581
1581
|
/**
|
|
1582
1582
|
* Creates path limits with the specified paths and max depth
|
|
1583
1583
|
* @param allowedPaths - The paths to limit extension to
|
|
@@ -1629,7 +1629,7 @@ class Ae extends nt {
|
|
|
1629
1629
|
* @returns True if the path matches the allowed path pattern, false otherwise
|
|
1630
1630
|
*/
|
|
1631
1631
|
matchesAllowedPath(t, r) {
|
|
1632
|
-
const n =
|
|
1632
|
+
const n = at(t, "/"), i = at(r, "/");
|
|
1633
1633
|
if (i.length > n.length)
|
|
1634
1634
|
return !1;
|
|
1635
1635
|
for (let o = 1; o < i.length; o++)
|
|
@@ -1671,7 +1671,7 @@ class Ae extends nt {
|
|
|
1671
1671
|
* @returns The path limits
|
|
1672
1672
|
*/
|
|
1673
1673
|
static withMaxDepth(t) {
|
|
1674
|
-
const r = new
|
|
1674
|
+
const r = new ke().setMaxDepth(t);
|
|
1675
1675
|
for (let n = 1; n <= t; n++) {
|
|
1676
1676
|
const i = "/" + Array(n).fill("*").join("/");
|
|
1677
1677
|
r.addPath(i);
|
|
@@ -1684,7 +1684,7 @@ class Ae extends nt {
|
|
|
1684
1684
|
* @returns The path limits
|
|
1685
1685
|
*/
|
|
1686
1686
|
static withSinglePath(t) {
|
|
1687
|
-
return new
|
|
1687
|
+
return new ke().addPath(t).build();
|
|
1688
1688
|
}
|
|
1689
1689
|
/**
|
|
1690
1690
|
* Creates path limits by analyzing the structure of a node.
|
|
@@ -1694,7 +1694,7 @@ class Ae extends nt {
|
|
|
1694
1694
|
return oe.convert(t);
|
|
1695
1695
|
}
|
|
1696
1696
|
}
|
|
1697
|
-
class
|
|
1697
|
+
class ke {
|
|
1698
1698
|
constructor() {
|
|
1699
1699
|
d(this, "allowedPaths", /* @__PURE__ */ new Set());
|
|
1700
1700
|
d(this, "maxDepth", Number.MAX_SAFE_INTEGER);
|
|
@@ -1723,7 +1723,7 @@ class Ze {
|
|
|
1723
1723
|
return new Ae(this.allowedPaths, this.maxDepth);
|
|
1724
1724
|
}
|
|
1725
1725
|
}
|
|
1726
|
-
class rs extends
|
|
1726
|
+
class rs extends st {
|
|
1727
1727
|
/**
|
|
1728
1728
|
* Determines if a path segment should be extended - always returns true
|
|
1729
1729
|
* @returns Always true
|
|
@@ -1749,7 +1749,7 @@ class rs extends nt {
|
|
|
1749
1749
|
exitPathSegment() {
|
|
1750
1750
|
}
|
|
1751
1751
|
}
|
|
1752
|
-
class Ce extends
|
|
1752
|
+
class Ce extends st {
|
|
1753
1753
|
/**
|
|
1754
1754
|
* Creates a composite limits with the specified limit strategies
|
|
1755
1755
|
* @param limits - Array of Limits implementations to combine
|
|
@@ -1811,7 +1811,7 @@ class Ce extends nt {
|
|
|
1811
1811
|
}
|
|
1812
1812
|
}
|
|
1813
1813
|
const L = new rs();
|
|
1814
|
-
function
|
|
1814
|
+
function ut(s, e) {
|
|
1815
1815
|
const t = s.getType();
|
|
1816
1816
|
if (t === void 0)
|
|
1817
1817
|
return;
|
|
@@ -1841,19 +1841,25 @@ function E(s, e, t) {
|
|
|
1841
1841
|
if (r && de.includes(
|
|
1842
1842
|
r
|
|
1843
1843
|
)) {
|
|
1844
|
-
let
|
|
1845
|
-
for (;
|
|
1846
|
-
if (b.calculateBlueIdSync(
|
|
1844
|
+
let c = e;
|
|
1845
|
+
for (; c !== void 0; ) {
|
|
1846
|
+
if (b.calculateBlueIdSync(c) === r)
|
|
1847
1847
|
return !0;
|
|
1848
|
-
|
|
1848
|
+
c = ut(c, t);
|
|
1849
1849
|
}
|
|
1850
1850
|
return !1;
|
|
1851
1851
|
}
|
|
1852
|
-
let i =
|
|
1853
|
-
|
|
1854
|
-
|
|
1852
|
+
let i = s;
|
|
1853
|
+
const o = s.getBlueId();
|
|
1854
|
+
if (o) {
|
|
1855
|
+
const c = t.fetchByBlueId(o);
|
|
1856
|
+
c && c.length === 1 && (i = c[0]);
|
|
1857
|
+
}
|
|
1858
|
+
let l = i;
|
|
1859
|
+
for (; l !== void 0; ) {
|
|
1860
|
+
if (b.calculateBlueIdSync(l) === n)
|
|
1855
1861
|
return !0;
|
|
1856
|
-
|
|
1862
|
+
l = ut(l, t);
|
|
1857
1863
|
}
|
|
1858
1864
|
return !1;
|
|
1859
1865
|
}
|
|
@@ -1886,13 +1892,13 @@ function Ot(s) {
|
|
|
1886
1892
|
return (s == null ? void 0 : s.getBlueId()) === wt;
|
|
1887
1893
|
}
|
|
1888
1894
|
function cs(s, e) {
|
|
1889
|
-
return
|
|
1895
|
+
return Qe.some((t) => {
|
|
1890
1896
|
const r = new a().setName(t);
|
|
1891
1897
|
return E(s, r, e);
|
|
1892
1898
|
});
|
|
1893
1899
|
}
|
|
1894
1900
|
function as(s, e) {
|
|
1895
|
-
for (const t of
|
|
1901
|
+
for (const t of Qe) {
|
|
1896
1902
|
const r = new a().setName(t);
|
|
1897
1903
|
if (E(s, r, e))
|
|
1898
1904
|
return t;
|
|
@@ -2068,7 +2074,7 @@ class Rt {
|
|
|
2068
2074
|
static convertValue(e, t) {
|
|
2069
2075
|
var i;
|
|
2070
2076
|
const r = (i = e.getType()) == null ? void 0 : i.getBlueId(), n = e.getValue();
|
|
2071
|
-
return v(n) ? ps(t) &&
|
|
2077
|
+
return v(n) ? ps(t) && rt.isValidValueNode(e) ? this.getDefaultPrimitiveValue(t) : n : K === r ? this.convertFromString(String(n), t) : z === r || n instanceof P ? this.convertFromBigDecimal(
|
|
2072
2078
|
new P(n == null ? void 0 : n.toString()),
|
|
2073
2079
|
t
|
|
2074
2080
|
) : G === r || n instanceof w ? this.convertFromBigInteger(
|
|
@@ -2150,7 +2156,7 @@ class fs {
|
|
|
2150
2156
|
return Object.keys(t.shape).reduce((n, i) => {
|
|
2151
2157
|
const o = e.getProperties(), l = t.shape[i], c = Kr(l);
|
|
2152
2158
|
if (p(c)) {
|
|
2153
|
-
const g =
|
|
2159
|
+
const g = Ge(c) ? c : i, M = o == null ? void 0 : o[g], W = M ? b.calculateBlueIdSync(M) : void 0;
|
|
2154
2160
|
return n[i] = W, n;
|
|
2155
2161
|
}
|
|
2156
2162
|
const u = Gr(l);
|
|
@@ -2364,23 +2370,23 @@ class Ps extends pe {
|
|
|
2364
2370
|
return this.nodeProviders;
|
|
2365
2371
|
}
|
|
2366
2372
|
}
|
|
2367
|
-
const
|
|
2368
|
-
...
|
|
2373
|
+
const Oe = Y.types.float.options, Es = {
|
|
2374
|
+
...Oe,
|
|
2369
2375
|
construct: (s) => {
|
|
2370
2376
|
const e = s.replace(/_/g, "").toLowerCase();
|
|
2371
2377
|
if (!ht(e))
|
|
2372
2378
|
return new P(e);
|
|
2373
|
-
if (
|
|
2374
|
-
return
|
|
2379
|
+
if (Oe.construct)
|
|
2380
|
+
return Oe.construct(s);
|
|
2375
2381
|
}
|
|
2376
|
-
}, Ss = new Y.Type("tag:yaml.org,2002:float", Es),
|
|
2377
|
-
|
|
2382
|
+
}, Ss = new Y.Type("tag:yaml.org,2002:float", Es), Re = Y.types.int.options, As = {
|
|
2383
|
+
...Re,
|
|
2378
2384
|
construct: (s) => {
|
|
2379
2385
|
let e = s;
|
|
2380
2386
|
if (e.indexOf("_") !== -1 && (e = e.replace(/_/g, "")), !ht(e))
|
|
2381
2387
|
return new w(e);
|
|
2382
|
-
if (
|
|
2383
|
-
return
|
|
2388
|
+
if (Re.construct)
|
|
2389
|
+
return Re.construct(s);
|
|
2384
2390
|
}
|
|
2385
2391
|
}, Cs = new Y.Type("tag:yaml.org,2002:int", As), $t = Y.CORE_SCHEMA.extend({
|
|
2386
2392
|
implicit: [Ss, Cs]
|
|
@@ -2463,8 +2469,8 @@ const Be = class Be extends pe {
|
|
|
2463
2469
|
}
|
|
2464
2470
|
};
|
|
2465
2471
|
d(Be, "INSTANCE", new Be());
|
|
2466
|
-
let
|
|
2467
|
-
class
|
|
2472
|
+
let Ze = Be;
|
|
2473
|
+
class $e {
|
|
2468
2474
|
constructor(e, t, r) {
|
|
2469
2475
|
this.blueId = e, this.content = t, this.isMultipleDocuments = r;
|
|
2470
2476
|
}
|
|
@@ -2492,11 +2498,11 @@ class R {
|
|
|
2492
2498
|
const l = y.deserialize(r), c = t(l);
|
|
2493
2499
|
n = b.calculateBlueIdSync(c), i = T.get(c);
|
|
2494
2500
|
}
|
|
2495
|
-
return new
|
|
2501
|
+
return new $e(n, i, o);
|
|
2496
2502
|
}
|
|
2497
2503
|
static parseAndCalculateBlueIdForNode(e, t) {
|
|
2498
2504
|
const r = t(e), n = b.calculateBlueIdSync(r), i = T.get(r);
|
|
2499
|
-
return new
|
|
2505
|
+
return new $e(n, i, !1);
|
|
2500
2506
|
}
|
|
2501
2507
|
static parseAndCalculateBlueIdForNodeList(e, t) {
|
|
2502
2508
|
if (!e || e.length === 0)
|
|
@@ -2504,7 +2510,7 @@ class R {
|
|
|
2504
2510
|
const r = e.map(t), n = b.calculateBlueIdSync(r), i = r.map(
|
|
2505
2511
|
(l) => T.get(l)
|
|
2506
2512
|
), o = e.length > 1;
|
|
2507
|
-
return new
|
|
2513
|
+
return new $e(n, i, o);
|
|
2508
2514
|
}
|
|
2509
2515
|
static resolveThisReferences(e, t, r) {
|
|
2510
2516
|
return this.resolveThisReferencesRecursive(
|
|
@@ -2635,7 +2641,7 @@ class jt extends Rs {
|
|
|
2635
2641
|
]);
|
|
2636
2642
|
}
|
|
2637
2643
|
}
|
|
2638
|
-
const Lt = (s) => s instanceof a || Array.isArray(s) && s.every((e) => e instanceof a) ? s :
|
|
2644
|
+
const Lt = (s) => s instanceof a || Array.isArray(s) && s.every((e) => e instanceof a) ? s : ze(s) ? s.map((e) => y.deserialize(e)) : y.deserialize(s), $s = async (s) => {
|
|
2639
2645
|
const e = Lt(s);
|
|
2640
2646
|
return b.calculateBlueId(e);
|
|
2641
2647
|
}, wn = (s) => {
|
|
@@ -2723,7 +2729,7 @@ class js {
|
|
|
2723
2729
|
*/
|
|
2724
2730
|
inferType(e) {
|
|
2725
2731
|
const t = e.getType(), r = e.getValue();
|
|
2726
|
-
return v(t) && p(r) && (typeof r == "string" ? e.setType(new a().setBlueId(K)) : typeof r == "bigint" || Z(r) ? e.setType(new a().setBlueId(G)) :
|
|
2732
|
+
return v(t) && p(r) && (typeof r == "string" ? e.setType(new a().setBlueId(K)) : typeof r == "bigint" || Z(r) ? e.setType(new a().setBlueId(G)) : xe(r) ? e.setType(new a().setBlueId(z)) : typeof r == "boolean" && e.setType(new a().setBlueId(J))), e;
|
|
2727
2733
|
}
|
|
2728
2734
|
}
|
|
2729
2735
|
const le = class le {
|
|
@@ -2771,7 +2777,7 @@ const le = class le {
|
|
|
2771
2777
|
}
|
|
2772
2778
|
};
|
|
2773
2779
|
d(le, "MAPPINGS", "mappings");
|
|
2774
|
-
let
|
|
2780
|
+
let Ye = le;
|
|
2775
2781
|
class Ls {
|
|
2776
2782
|
/**
|
|
2777
2783
|
* Process a document node to validate all inline types have been replaced
|
|
@@ -2794,7 +2800,7 @@ class Ls {
|
|
|
2794
2800
|
}
|
|
2795
2801
|
}
|
|
2796
2802
|
}
|
|
2797
|
-
class
|
|
2803
|
+
class nt {
|
|
2798
2804
|
/**
|
|
2799
2805
|
* Creates a new NodeExtender with the specified NodeProvider and optional strategy
|
|
2800
2806
|
* @param nodeProvider - The NodeProvider to use for resolving nodes
|
|
@@ -3000,7 +3006,7 @@ const Ne = class Ne {
|
|
|
3000
3006
|
preprocessWithOptions(e, t) {
|
|
3001
3007
|
let r = e.clone(), n = r.getBlue();
|
|
3002
3008
|
if (!n && t && (n = t.clone()), n) {
|
|
3003
|
-
new
|
|
3009
|
+
new nt(this.nodeProvider).extend(
|
|
3004
3010
|
n,
|
|
3005
3011
|
Ae.withSinglePath("/*")
|
|
3006
3012
|
);
|
|
@@ -3033,7 +3039,7 @@ const Ne = class Ne {
|
|
|
3033
3039
|
var i;
|
|
3034
3040
|
const t = "27B7fuxQCS1VAptiCPc2RMkKoutP5qxkh3uDxZ7dr6Eo", r = "FGYuTXwaoSKfZmpTysLTLsb8WzSqf43384rKZDkXhxD4", n = (i = e.getType()) == null ? void 0 : i.getBlueId();
|
|
3035
3041
|
if (t === n)
|
|
3036
|
-
return new
|
|
3042
|
+
return new Ye(
|
|
3037
3043
|
e
|
|
3038
3044
|
);
|
|
3039
3045
|
if (r === n)
|
|
@@ -3146,7 +3152,7 @@ class ue {
|
|
|
3146
3152
|
* @returns A wrapped NodeProvider that includes bootstrap providers and repository definitions
|
|
3147
3153
|
*/
|
|
3148
3154
|
static wrap(e, t) {
|
|
3149
|
-
const r = [
|
|
3155
|
+
const r = [Ze.INSTANCE];
|
|
3150
3156
|
if (t && t.length > 0) {
|
|
3151
3157
|
const n = new Us(t);
|
|
3152
3158
|
r.push(n);
|
|
@@ -3493,7 +3499,7 @@ class _t {
|
|
|
3493
3499
|
t,
|
|
3494
3500
|
r
|
|
3495
3501
|
), u = new a();
|
|
3496
|
-
this.reverseNode(u, l, c),
|
|
3502
|
+
this.reverseNode(u, l, c), rt.isEmptyNode(u) || (i[o] = u);
|
|
3497
3503
|
}
|
|
3498
3504
|
Object.keys(i).length > 0 && e.setProperties(i);
|
|
3499
3505
|
}
|
|
@@ -3534,7 +3540,7 @@ class _t {
|
|
|
3534
3540
|
return p(I) && r.setItems(I.map((m) => m.clone())), r;
|
|
3535
3541
|
}
|
|
3536
3542
|
}
|
|
3537
|
-
class
|
|
3543
|
+
class it extends a {
|
|
3538
3544
|
/**
|
|
3539
3545
|
* Creates a new ResolvedBlueNode from a resolved BlueNode
|
|
3540
3546
|
* @param resolvedNode - The fully resolved node after merge operations
|
|
@@ -3568,7 +3574,7 @@ class ot extends a {
|
|
|
3568
3574
|
*/
|
|
3569
3575
|
clone() {
|
|
3570
3576
|
const e = super.clone();
|
|
3571
|
-
return new
|
|
3577
|
+
return new it(e);
|
|
3572
3578
|
}
|
|
3573
3579
|
/**
|
|
3574
3580
|
* Copies all properties from another BlueNode
|
|
@@ -3620,7 +3626,7 @@ class Ks extends Ys {
|
|
|
3620
3626
|
const o = r.getType();
|
|
3621
3627
|
if (p(o)) {
|
|
3622
3628
|
const l = o.clone();
|
|
3623
|
-
p(l.getBlueId()) && new
|
|
3629
|
+
p(l.getBlueId()) && new nt(this.nodeProvider).extend(
|
|
3624
3630
|
l,
|
|
3625
3631
|
Ae.withSinglePath("/")
|
|
3626
3632
|
);
|
|
@@ -3722,7 +3728,7 @@ class Ks extends Ys {
|
|
|
3722
3728
|
*/
|
|
3723
3729
|
resolve(t, r) {
|
|
3724
3730
|
const n = new a(), o = this.merge(n, t, r).clone().setName(t.getName()).setDescription(t.getDescription()).setBlueId(t.getBlueId());
|
|
3725
|
-
return new
|
|
3731
|
+
return new it(o);
|
|
3726
3732
|
}
|
|
3727
3733
|
}
|
|
3728
3734
|
class kt {
|
|
@@ -3765,7 +3771,7 @@ class Zt {
|
|
|
3765
3771
|
return e;
|
|
3766
3772
|
}
|
|
3767
3773
|
}
|
|
3768
|
-
const zs = (s, e) => Z(s) && Z(e) ||
|
|
3774
|
+
const zs = (s, e) => Z(s) && Z(e) || xe(s) && xe(e) ? s.eq(e) : s === e;
|
|
3769
3775
|
class Yt {
|
|
3770
3776
|
process(e, t, r) {
|
|
3771
3777
|
const n = e.getType(), i = t.getType();
|
|
@@ -4048,7 +4054,7 @@ class Cn {
|
|
|
4048
4054
|
}
|
|
4049
4055
|
extend(e, t) {
|
|
4050
4056
|
const r = this.combineWithGlobalLimits(t);
|
|
4051
|
-
new
|
|
4057
|
+
new nt(this.nodeProvider).extend(e, r);
|
|
4052
4058
|
}
|
|
4053
4059
|
jsonValueToNode(e) {
|
|
4054
4060
|
return this.preprocess(y.deserialize(e));
|
|
@@ -4269,7 +4275,7 @@ class Vn extends jt {
|
|
|
4269
4275
|
this.preprocessor = (n) => r.preprocessWithDefaultBlue(n), t.forEach((n) => this.processNode(n));
|
|
4270
4276
|
}
|
|
4271
4277
|
processNode(t) {
|
|
4272
|
-
|
|
4278
|
+
rt.hasItemsOnly(t) ? this.processNodeWithItems(t) : this.processSingleNode(t);
|
|
4273
4279
|
}
|
|
4274
4280
|
processSingleNode(t) {
|
|
4275
4281
|
const r = R.parseAndCalculateBlueIdForNode(
|
|
@@ -4394,12 +4400,12 @@ export {
|
|
|
4394
4400
|
a as BlueNode,
|
|
4395
4401
|
V as BlueNodeTypeSchema,
|
|
4396
4402
|
Ar as JsonCanonicalizer,
|
|
4397
|
-
|
|
4403
|
+
st as Limits,
|
|
4398
4404
|
Ks as Merger,
|
|
4399
4405
|
An as MergingProcessors,
|
|
4400
4406
|
Ys as NodeResolver,
|
|
4401
|
-
|
|
4402
|
-
|
|
4407
|
+
rt as Nodes,
|
|
4408
|
+
it as ResolvedBlueNode,
|
|
4403
4409
|
ts as TypeSchemaResolver,
|
|
4404
4410
|
gn as applyBlueNodePatch,
|
|
4405
4411
|
Ee as baseBlueObjectSchema,
|
|
@@ -4431,7 +4437,7 @@ export {
|
|
|
4431
4437
|
dn as hasBlueObjectNameDefined,
|
|
4432
4438
|
vr as hasBlueObjectTypeDefined,
|
|
4433
4439
|
br as hasBlueObjectValueDefined,
|
|
4434
|
-
|
|
4440
|
+
xe as isBigDecimalNumber,
|
|
4435
4441
|
Z as isBigIntegerNumber,
|
|
4436
4442
|
A as isBigNumber,
|
|
4437
4443
|
Dt as isBlueNodeSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTypes.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/NodeTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA0D/C;;GAEG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,QAAQ,EACjB,SAAS,EAAE,QAAQ,EACnB,YAAY,EAAE,YAAY,GACzB,OAAO,
|
|
1
|
+
{"version":3,"file":"NodeTypes.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/NodeTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA0D/C;;GAEG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,QAAQ,EACjB,SAAS,EAAE,QAAQ,EACnB,YAAY,EAAE,YAAY,GACzB,OAAO,CAgDT;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,YAAY,GACzB,OAAO,CAKT;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,YAAY,GACzB,OAAO,CAGT;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,YAAY,GACzB,OAAO,CAGT;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,YAAY,GACzB,OAAO,CAGT;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,YAAY,GACzB,OAAO,CAGT;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAE9D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAEpE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,YAAY,GACzB,OAAO,CAKT;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,QAAQ,EACd,YAAY,EAAE,YAAY,GACzB,MAAM,CAYR"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blue-labs/language",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@blue-labs/shared-utils": "1.
|
|
5
|
+
"@blue-labs/shared-utils": "1.35.0",
|
|
6
6
|
"@types/big.js": "^6.2.2",
|
|
7
7
|
"@types/js-yaml": "^4.0.9",
|
|
8
8
|
"base32.js": "^0.1.0",
|