@graphprotocol/hypergraph 0.11.3 → 0.12.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/typesync-studio/dist/assets/{authenticate-callback-DWhsU9D1.js → authenticate-callback-DffCNmxZ.js} +1 -1
- package/dist/typesync-studio/dist/assets/{authenticate-callback-BV2rlMr8.js.map → authenticate-callback-DffCNmxZ.js.map} +1 -1
- package/dist/typesync-studio/dist/assets/{ccip-B3C_8i6v.js → ccip-BJ7g8YE6.js} +1 -1
- package/dist/typesync-studio/dist/assets/{ccip-BbFvINjv.js.map → ccip-BJ7g8YE6.js.map} +1 -1
- package/dist/typesync-studio/dist/assets/{index-B6KrPHmh.js → index-B5RxXGeM.js} +111 -111
- package/dist/typesync-studio/dist/assets/{index-aqIlSDjR.js.map → index-B5RxXGeM.js.map} +1 -1
- package/dist/typesync-studio/dist/assets/{index-aSyX5aYK.js → index-CHTDYpLG.js} +1 -1
- package/dist/typesync-studio/dist/assets/index-CHTDYpLG.js.map +1 -0
- package/dist/typesync-studio/dist/index.html +1 -1
- package/package.json +2 -2
- package/dist/typesync-studio/dist/assets/authenticate-callback-BV2rlMr8.js +0 -29
- package/dist/typesync-studio/dist/assets/ccip-BbFvINjv.js +0 -167
- package/dist/typesync-studio/dist/assets/index-BVtd9x2J.js +0 -13117
- package/dist/typesync-studio/dist/assets/index-BVtd9x2J.js.map +0 -1
- package/dist/typesync-studio/dist/assets/index-aqIlSDjR.js +0 -224
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as ua,b as yl,e as bl,c as xl,f as wl,g as El,t as yi,h as Sl,i as Y,k as ke,l as ee,I as nt,m as kl,D as Ml,C as Cl,T as hs,P as bi,n as Tl,E as Fl,o as Ol,p as Rl,q as Il,s as Al,v as Vl,B as Pl,w as jl,x as Nl,F as Dl,y as Ll,z as $l,A as Hl,G as _l,H as Bl,J as da,S as Re,K as ft,U as ps,L as yn,M as St,O as Ht,N as De,Q as Je,V as se,W as Zl,X as me,Y as Bn,Z as zr,_ as zl,$ as Ul,a0 as ve,a1 as Gl,a2 as Ur,a3 as Gr,a4 as qr,a5 as mt,a6 as ms,a7 as ql,a8 as rn,a9 as rr,aa as sr,ab as gs,ac as Ir,ad as xi,ae as fa,af as wi,ag as He,ah as Zn,ai as sn,aj as zn,ak as Kr,al as Ei,am as Kl,an as Wl,ao as Yl,ap as Si,aq as ir,ar as ki,as as Ql,r as o,at as ha,au as pa,av as Mn,aw as Cn,u as vs,ax as Xl,ay as ma,az as Jl,aA as Te,aB as ga,j as d,aC as ys,aD as bs,aE as Xe,aF as Un,aG as bt,aH as jt,aI as _e,aJ as Oe,aK as Nn,aL as ec,aM as oe,aN as Ce,aO as xs,aP as _t,aQ as xt,aR as ws,aS as Fe,aT as Es,aU as Ar,aV as tc,aW as nc,aX as va,aY as rc,aZ as We,a_ as Vr,a$ as sc,b0 as ic,b1 as ac,b2 as oc,b3 as lc,b4 as ya,b5 as ba,b6 as cc,b7 as Ke,b8 as K,b9 as le,ba as he,bb as Gt,bc as Z,bd as xa,be as ar,bf as or,bg as qt,bh as lr,bi as cr,bj as te,bk as Kt,bl as Wt,bm as ur,bn as rt,bo as dr,bp as Mi,bq as un,br as uc,bs as wa,bt as ne,bu as ye,bv as bn,bw as Ea,bx as Nt,by as Sa,bz as Ss,bA as xn,bB as ae,bC as Se,bD as ka,bE as dt,bF as Ma,bG as Qe,bH as Bt,bI as ks,bJ as Ms,bK as Ca,bL as Ta,bM as Fa,bN as Ct,bO as fr,bP as ge,bQ as Cs,bR as Ts,bS as Fs,bT as Ee,bU as dc,bV as hr,bW as Wr,bX as Os,bY as Oa,bZ as fc,b_ as Ra,b$ as Rs,c0 as Ia,c1 as Aa,c2 as pr,c3 as st,c4 as Is,c5 as As,c6 as an,c7 as hc,c8 as mr,c9 as on,ca as ze,cb as et,cc as Va,cd as Ci,ce as wt,cf as pc,cg as mc,ch as gc,ci as vc,cj as Pa,ck as Ti,cl as yc,cm as bc,cn as Pr,co as xc,cp as wc,cq as Ec,cr as Sc,cs as kc,ct as Mc,cu as Cc,cv as Tc,cw as Fc,cx as Oc,cy as Vs,cz as Rc,cA as Ic,cB as Ac,cC as Vc,cD as Pc,cE as jc,cF as Nc,cG as Dc,cH as Yr,cI as Lc,cJ as Fi,cK as Ze,cL as $c,cM as Gn,cN as be,cO as ja,cP as Na,cQ as Da,cR as Zt,cS as La,cT as $a,cU as Ha,cV as Qr,cW as gr,cX as Hc,cY as Tn,cZ as _c,c_ as Bc,c$ as Zc,d0 as Fn,d1 as jr,d2 as On,d3 as zc,d4 as Uc,d5 as Gc,d6 as Oi}from"./index-B6KrPHmh.js";function qc(e){return{type:"createEntity",id:e.id,values:e.values??[]}}function zt(e){return{type:"createRelation",...e}}function Ie(e){return ua(`grc20:genesis:language:${e.toLowerCase()}`)}const Nr={english:()=>Ie("en"),spanish:()=>Ie("es"),french:()=>Ie("fr"),german:()=>Ie("de"),chinese:()=>Ie("zh"),japanese:()=>Ie("ja"),korean:()=>Ie("ko"),portuguese:()=>Ie("pt"),italian:()=>Ie("it"),russian:()=>Ie("ru"),arabic:()=>Ie("ar"),hindi:()=>Ie("hi"),fromCode:e=>Ie(e)},qn=e=>e.toUpperCase(),kt=e=>e.toLowerCase(),Kn=e=>e.length===0,tt=e=>e.length>0,Dt=e=>e.length;class Ri extends Error{_tag="IpfsUploadError"}function Kc(e){return ua(e)}async function Wc(e){const{name:n,ops:t,author:r,network:s="TESTNET"}=e,i=yl(),a={id:i,name:n,authors:[Kc(r)],createdAt:BigInt(Date.now())*1000n,ops:t},l=bl(a),c=new Uint8Array(l),f=new Blob([c],{type:"application/octet-stream"}),h=new FormData;h.append("file",f);const g=await xl(Yc(h,s)),u=wl(i);return{cid:g,editId:u}}function Yc(e,n="TESTNET"){return El(function*(){const t=yield*yi({try:()=>fetch(`${Sl(n)}/ipfs/upload-edit`,{method:"POST",body:e}),catch:s=>new Ri(`Could not upload data to IPFS: ${s}`)});return yield*yi({try:async()=>{const{cid:s}=await t.json();return s},catch:s=>new Ri(`Could not parse response from IPFS: ${s}`)})})}const Dn=({id:e,fromEntity:n,toEntity:t,position:r,fromSpace:s,toSpace:i,fromVersion:a,toVersion:l,type:c,entityId:f,entityName:h,entityDescription:g,entityCover:u,entityValues:m,entityRelations:p,entityTypes:v})=>{e&&Y(e,"`id` in `createRelation`"),n&&Y(n,"`fromEntity` in `createRelation`"),t&&Y(t,"`toEntity` in `createRelation`"),s&&Y(s,"`fromSpace` in `createRelation`"),i&&Y(i,"`toSpace` in `createRelation`"),a&&Y(a,"`fromVersion` in `createRelation`"),l&&Y(l,"`toVersion` in `createRelation`"),c&&Y(c,"`type` in `createRelation`"),f&&Y(f,"`entityId` in `createRelation`"),u&&Y(u,"`entityCover` in `createRelation`");for(const x of m??[])Y(x.property,"`entityValues` in `createRelation`"),x.type==="text"&&x.language&&Y(x.language,"`language` in `entityValues` in `createRelation`"),x.type==="float64"&&x.unit&&Y(x.unit,"`unit` in `entityValues` in `createRelation`");for(const[x]of Object.entries(p??{}))Y(x,"`entityRelations` in `createRelation`");for(const x of v??[])Y(x,"`entityTypes` in `createRelation`");const y=e??ke(),S=f??ke(),E=[];if(E.push(zt({id:ee(y),entity:ee(S),from:ee(n),to:ee(t),relationType:ee(c),...s?{fromSpace:ee(s)}:{},...a?{fromVersion:ee(a)}:{},...i?{toSpace:ee(i)}:{},...l?{toVersion:ee(l)}:{},...r!==void 0?{position:r}:{}})),h||g||u||m||p||v){const{ops:x}=Ps({id:S,name:h,description:g,cover:u,values:m,relations:p,types:v});E.push(...x)}return{id:nt(y),ops:E}},Ps=({id:e,name:n,description:t,cover:r,values:s,relations:i,types:a})=>{e&&Y(e,"`id` in `createEntity`"),r&&Y(r,"`cover` in `createEntity`");for(const h of s??[])Y(h.property,"`values` in `createEntity`"),h.type==="text"&&h.language&&Y(h.language,"`language` in `values` in `createEntity`"),h.type==="float64"&&h.unit&&Y(h.unit,"`unit` in `values` in `createEntity`");for(const[h,g]of Object.entries(i??{}))if(Y(h,"`relations` in `createEntity`"),Array.isArray(g))for(const u of g)Y(u.toEntity,"`toEntity` in `relations` in `createEntity`"),u.toSpace&&Y(u.toSpace,"`toSpace` in `relations` in `createEntity`"),u.fromSpace&&Y(u.fromSpace,"`fromSpace` in `relations` in `createEntity`"),u.fromVersion&&Y(u.fromVersion,"`fromVersion` in `relations` in `createEntity`"),u.toVersion&&Y(u.toVersion,"`toVersion` in `relations` in `createEntity`"),u.entityId&&Y(u.entityId,"`entityId` in `relations` in `createEntity`"),u.entityCover&&Y(u.entityCover,"`entityCover` in `relations` in `createEntity`");else Y(g.toEntity,"`toEntity` in `relations` in `createEntity`"),g.toSpace&&Y(g.toSpace,"`toSpace` in `relations` in `createEntity`"),g.fromSpace&&Y(g.fromSpace,"`fromSpace` in `relations` in `createEntity`"),g.fromVersion&&Y(g.fromVersion,"`fromVersion` in `relations` in `createEntity`"),g.toVersion&&Y(g.toVersion,"`toVersion` in `relations` in `createEntity`"),g.entityId&&Y(g.entityId,"`entityId` in `relations` in `createEntity`"),g.entityCover&&Y(g.entityCover,"`entityCover` in `relations` in `createEntity`");for(const h of a??[])Y(h,"`types` in `createEntity`");const l=e??ke();let c=[];const f=[];n&&f.push({property:ee(kl),value:{type:"text",value:n,language:Nr.english()}}),t&&f.push({property:ee(Ml),value:{type:"text",value:t,language:Nr.english()}});for(const h of s??[]){const g=ee(h.property);if(h.type==="text")f.push({property:g,value:{type:"text",value:h.value,language:h.language?ee(h.language):Nr.english()}});else if(h.type==="float64")f.push({property:g,value:{type:"float64",value:h.value,...h.unit?{unit:ee(h.unit)}:{}}});else if(h.type==="bool")f.push({property:g,value:{type:"bool",value:h.value}});else if(h.type==="point")f.push({property:g,value:{type:"point",lon:h.lon,lat:h.lat,...h.alt!==void 0?{alt:h.alt}:{}}});else if(h.type==="date")f.push({property:g,value:{type:"date",value:h.value}});else if(h.type==="time")f.push({property:g,value:{type:"time",value:h.value}});else if(h.type==="datetime")f.push({property:g,value:{type:"datetime",value:h.value}});else if(h.type==="schedule")f.push({property:g,value:{type:"schedule",value:h.value}});else{const u=h;throw new Error(`Unsupported value type: ${u.type}`)}}if(c.push(qc({id:ee(l),values:f})),r&&c.push(zt({id:ee(ke()),entity:ee(ke()),from:ee(l),to:ee(r),relationType:ee(Cl)})),a)for(const h of a)c.push(zt({id:ee(ke()),entity:ee(ke()),from:ee(l),to:ee(h),relationType:ee(hs)}));for(const[h,g]of Object.entries(i??{})){const u=Array.isArray(g)?g:[g];for(const m of u){const p=m.id??ke(),v=m.entityId??ke(),{ops:y}=Dn({id:p,fromEntity:l,toEntity:m.toEntity,type:nt(h),position:m.position,fromSpace:m.fromSpace,toSpace:m.toSpace,fromVersion:m.fromVersion,toVersion:m.toVersion,entityId:v,entityName:m.entityName,entityDescription:m.entityDescription,entityCover:m.entityCover,entityValues:m.entityValues,entityRelations:m.entityRelations,entityTypes:m.entityTypes});c=c.concat(y)}}return{id:nt(l),ops:c}},Qc={BOOLEAN:$l,INT64:Ll,FLOAT64:Dl,DECIMAL:Nl,TEXT:jl,BYTES:Pl,DATE:Vl,TIME:Al,DATETIME:Il,SCHEDULE:Rl,POINT:Ol,EMBEDDING:Fl},Xr=e=>{const{id:n,name:t,description:r,cover:s}=e;if(n&&Y(n,"`id` in `createProperty`"),s&&Y(s,"`cover` in `createProperty`"),e.dataType==="RELATION"){for(const c of e.properties??[])Y(c,"`properties` in `createProperty`");for(const c of e.relationValueTypes??[])Y(c,"`relationValueTypes` in `createProperty`")}const i=n??ke(),a=[],{ops:l}=Ps({id:i,name:t,description:r,cover:s});if(a.push(...l),a.push(zt({id:ee(ke()),entity:ee(ke()),from:ee(i),to:ee(bi),relationType:ee(hs)})),e.dataType==="RELATION"){if(e.properties)for(const c of e.properties){Y(c);const{ops:f}=Dn({fromEntity:i,toEntity:c,type:bi});a.push(...f)}if(e.relationValueTypes)for(const c of e.relationValueTypes){Y(c);const{ops:f}=Dn({fromEntity:i,toEntity:c,type:Tl});a.push(...f)}}else{const c=Qc[e.dataType],{ops:f}=Dn({fromEntity:i,toEntity:c,type:Hl});a.push(...f)}return{id:nt(i),ops:a}},_a=({id:e,name:n,description:t,cover:r,properties:s})=>{e&&Y(e,"`id` in `createType`");for(const l of s??[])Y(l,"`properties` in `createType`");const i=e??ke(),{ops:a}=Ps({id:i,name:n,description:t,cover:r});if(Y(i),a.push(zt({id:ee(ke()),entity:ee(ke()),from:ee(i),to:ee(_l),relationType:ee(hs)})),s)for(const l of s)Y(l,"`propertyId` in `createType`"),a.push(zt({id:ee(ke()),entity:ee(ke()),from:ee(i),to:ee(l),relationType:ee(Bl)}));return{id:nt(i),ops:a}};function Ba(e){if(Kn(e))throw new Za({input:e,cause:"Input is empty"});let n="",t=!1,r=0;for(;r<Dt(e)&&!/[a-zA-Z0-9]/.test(e[r]);)r++;for(;r<Dt(e);r++){const s=e[r];/[a-zA-Z0-9]/.test(s)?t?(n+=qn(s),t=!1):Dt(n)===0?n+=kt(s):/[A-Z]/.test(s)&&r>0&&/[a-z0-9]/.test(e[r-1])?n+=qn(s):n+=kt(s):t=Dt(n)>0}return n}function Jr(e){if(Kn(e))throw new Za({input:e,cause:"Input is empty"});let n="",t=!0,r=0;for(;r<Dt(e)&&!/[a-zA-Z0-9]/.test(e[r]);)r++;for(;r<Dt(e);r++){const s=e[r];/[a-zA-Z0-9]/.test(s)?t?(n+=qn(s),t=!1):/[A-Z]/.test(s)&&r>0&&/[a-z0-9]/.test(e[r-1])?n+=qn(s):n+=kt(s):t=!0}return n}class Za extends da("/typesync/errors/InvalidInputError"){}function vr(e){const n=new Set;for(const t of e){const r=kt(t.name);if(n.has(r))return!1;n.add(r)}return!0}function ut(e){return/^Relation\((.+)\)$/.test(e)}const za=De.pipe(St(e=>ut(e))),Ua=ms("String","Number","Boolean","Date","Point");ps(Ua,za);const Ga=Re({name:De,knowledgeGraphId:Ht(rn),optional:zr(zl(ql))}),qa=Re({...Ga.fields,dataType:za,relationType:De.annotations({identifier:"SchemaTypePropertyRelation.relationType",description:"name of the type within the schema that this property is related to",examples:["Account"]})}),Ka=Re({...Ga.fields,dataType:Ua});function dn(e){return ut(e.dataType)}const Wa=Re({name:De,knowledgeGraphId:Ht(rn),properties:ft(ps(Ka,qa)).pipe(yn(1),St(vr,{identifier:"DuplicatePropertyNames",jsonSchema:{},description:"The property.name must be unique across all properties in the type"}))}),Ya=Re({types:ft(Wa).pipe(yn(1),St(vr,{identifier:"DuplicateTypeNames",jsonSchema:{},description:"The type.name must be unique across all types in the schema"}),St(Qa,{identifier:"AllRelationTypesExist",jsonSchema:{},description:"Each type property of dataType RELATION must have a type of the same name in the schema"}))}).annotations({identifier:"typesync/Schema",title:"TypeSync app Schema",description:"An array of types in the schema defined by the user to generate a Mapping object for",examples:[{types:[{name:"Account",knowledgeGraphId:null,properties:[{name:"username",optional:null,knowledgeGraphId:null,dataType:"String"}]}]},{types:[{name:"Account",knowledgeGraphId:"a5fd07b1120f46c6b46f387ef98396a6",properties:[{name:"name",optional:!0,knowledgeGraphId:"a126ca530c8e48d5b88882c734c38935",dataType:"String"}]}]}]}),Xc=Ul(Ya);rr(Ya);function Qa(e){const n=Je(e,new Set,(t,r)=>t.add(r.name));return se(e,Bn(t=>t.properties),me(t=>dn(t)),Zl(t=>n.has(t.relationType)))}function es(e){return se(e,Je({},(n,{propName:t,id:r})=>(n[Ba(t)]=r,n)))}function ts(e){return se(e,Je({},(n,{propName:t,id:r})=>(n[Ba(t)]=r,n)))}function Jc(e,n){if(e.knowledgeGraphId)return{type:"resolved",mapping:{propName:e.name,id:nt(e.knowledgeGraphId)},ops:[]};if(dn(e)){const s=n.get(e.relationType);if(s==null)return{type:"deferred",property:e};const{id:i,ops:a}=Xr({name:e.name,dataType:"RELATION",relationValueTypes:[s]});return{type:"resolved",mapping:{propName:e.name,id:i},ops:a}}const{id:t,ops:r}=Xr({name:e.name,dataType:ru(e.dataType)});return{type:"resolved",mapping:{propName:e.name,id:t},ops:r}}function eu(e,n){const t=se(e.properties,ve(u=>Jc(u,n))),r=se(t,Ur(u=>u.type==="resolved"?qr(u):Gr())),s=se(t,Ur(u=>u.type==="deferred"?qr(u.property):Gr())),i=se(r,me(u=>{const m=e.properties.find(p=>p.name===u.mapping.propName);return m?!dn(m):!1}),ve(u=>u.mapping)),a=se(r,me(u=>{const m=e.properties.find(p=>p.name===u.mapping.propName);return m?dn(m):!1}),ve(u=>u.mapping)),l=se(r,Bn(u=>u.ops));if(e.knowledgeGraphId){const u={typeName:Jr(e.name),typeIds:[nt(e.knowledgeGraphId)]};return mt(i)&&(u.properties=es(i)),mt(a)&&(u.relations=ts(a)),{type:"complete",entry:u,ops:l}}if(mt(s))return{type:"deferred",schemaType:e,properties:i,relations:a};const c=[...i,...a],{id:f,ops:h}=_a({name:e.name,properties:se(c,ve(u=>u.id))});n.set(e.name,f);const g={typeName:Jr(e.name),typeIds:[f]};return mt(i)&&(g.properties=es(i)),mt(a)&&(g.relations=ts(a)),{type:"complete",entry:g,ops:[...l,...h]}}function tu(e){const n=Xc(e),t=se(n.types,Je(new Map,(g,u)=>g.set(u.name,u.knowledgeGraphId!=null?nt(u.knowledgeGraphId):null))),r=se(n.types,ve(g=>eu(g,t))),[s,i]=se(r,Gl(g=>g.type==="complete")),a=se(i,Bn(g=>g.ops)),{entries:l,ops:c}=se(s,Je({entries:[],ops:[]},(g,u)=>{const m=se(u.schemaType.properties,Ur(M=>{if(!dn(M)||M.knowledgeGraphId!=null)return Gr();const V=t.get(M.relationType);if(V==null)throw new nu({message:`Failed to resolve type ID for relation type: ${M.relationType}`,property:M.name,relatedType:M.relationType});const{id:b,ops:F}=Xr({name:M.name,dataType:"RELATION",relationValueTypes:[V]});return qr({mapping:{propName:M.name,id:b},ops:F})})),p=[...u.relations,...se(m,ve(M=>M.mapping))],v=[...u.properties,...p],{id:y,ops:S}=_a({name:u.schemaType.name,properties:se(v,ve(M=>M.id))});t.set(u.schemaType.name,y);const E=[...se(m,Bn(M=>M.ops)),...S],x={typeName:Jr(u.schemaType.name),typeIds:[y]};return mt(u.properties)&&(x.properties=es(u.properties)),mt(p)&&(x.relations=ts(p)),{entries:[...g.entries,x],ops:[...g.ops,...E]}})),f=[...se(i,ve(g=>g.entry)),...l];return[se(f,Je({},(g,u)=>{const{typeName:m,...p}=u;return g[m]=p,g})),[...a,...c]]}class nu extends da("/typesync/errors/RelationValueTypeDoesNotExistError"){}function ru(e){switch(!0){case e==="Boolean":return"BOOLEAN";case e==="Date":return"TIME";case e==="Number":return"FLOAT64";case e==="Point":return"POINT";case ut(e):return"RELATION";default:return"TEXT"}}const Xa=Ht(ms("published","synced","published_not_synced")),su=ps(Ka,qa).pipe(gs(Re({status:Xa})));class ns extends sr("/Hypergraph/cli/models/TypesyncHypergraphSchemaType")({...Wa.omit("properties").fields,status:Xa,properties:ft(su).pipe(yn(1),St(vr,{identifier:"DuplicatePropertyNames",jsonSchema:{},description:"The property.name must be unique across all properties in the type"}))}){}class wn extends sr("/Hypergraph/cli/models/TypesyncHypergraphSchema")({types:ft(ns).pipe(yn(1),St(vr,{identifier:"DuplicateTypeNames",jsonSchema:{},description:"The type.name must be unique across all types in the schema"}),St(Qa,{identifier:"AllRelationTypesExist",jsonSchema:{},description:"Each type property of dataType RELATION must have a type of the same name in the schema"}))}){}Ir({key:De,value:Re({typeIds:ft(rn).pipe(yn(1)),properties:zr(xi(Ir({key:De,value:rn}))),relations:zr(xi(Ir({key:De,value:rn})))})});const iu=(e,...n)=>e.reduce((t,r,s)=>`${t}${r}${s in n?String(n[s]):""}`,"");var au=class extends fa{constructor(e,n){super(),this.options=n,this.#n=e,this.#o=null,this.#a=wi(),this.bindMethods(),this.setOptions(n)}#n;#e=void 0;#r=void 0;#t=void 0;#s;#i;#a;#o;#m;#f;#h;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Ii(this.#e,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return rs(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return rs(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#x(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const n=this.options,t=this.#e;if(this.options=this.#n.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof He(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#E(),this.#e.setOptions(this.options),n._defaulted&&!Zn(this.options,n)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Ai(this.#e,t,this.options,n)&&this.#d(),this.updateResult(),r&&(this.#e!==t||He(this.options.enabled,this.#e)!==He(n.enabled,this.#e)||sn(this.options.staleTime,this.#e)!==sn(n.staleTime,this.#e))&&this.#g();const s=this.#v();r&&(this.#e!==t||He(this.options.enabled,this.#e)!==He(n.enabled,this.#e)||s!==this.#l)&&this.#y(s)}getOptimisticResult(e){const n=this.#n.getQueryCache().build(this.#n,e),t=this.createResult(n,e);return lu(this,t)&&(this.#t=t,this.#i=this.options,this.#s=this.#e.state),t}getCurrentResult(){return this.#t}trackResult(e,n){return new Proxy(e,{get:(t,r)=>(this.trackProp(r),n?.(r),r==="promise"&&!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(t,r))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const n=this.#n.defaultQueryOptions(e),t=this.#n.getQueryCache().build(this.#n,n);return t.fetch().then(()=>this.createResult(t,n))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#t))}#d(e){this.#E();let n=this.#e.fetch(this.options,e);return e?.throwOnError||(n=n.catch(zn)),n}#g(){this.#x();const e=sn(this.options.staleTime,this.#e);if(Kr||this.#t.isStale||!Ei(e))return;const t=Kl(this.#t.dataUpdatedAt,e)+1;this.#c=setTimeout(()=>{this.#t.isStale||this.updateResult()},t)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#y(e){this.#w(),this.#l=e,!(Kr||He(this.options.enabled,this.#e)===!1||!Ei(this.#l)||this.#l===0)&&(this.#u=setInterval(()=>{(this.options.refetchIntervalInBackground||Wl.isFocused())&&this.#d()},this.#l))}#b(){this.#g(),this.#y(this.#v())}#x(){this.#c&&(clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(clearInterval(this.#u),this.#u=void 0)}createResult(e,n){const t=this.#e,r=this.options,s=this.#t,i=this.#s,a=this.#i,c=e!==t?e.state:this.#r,{state:f}=e;let h={...f},g=!1,u;if(n._optimisticResults){const k=this.hasListeners(),N=!k&&Ii(e,n),T=k&&Ai(e,t,n,r);(N||T)&&(h={...h,...Yl(f.data,e.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:m,errorUpdatedAt:p,status:v}=h;u=h.data;let y=!1;if(n.placeholderData!==void 0&&u===void 0&&v==="pending"){let k;s?.isPlaceholderData&&n.placeholderData===a?.placeholderData?(k=s.data,y=!0):k=typeof n.placeholderData=="function"?n.placeholderData(this.#h?.state.data,this.#h):n.placeholderData,k!==void 0&&(v="success",u=Si(s?.data,k,n),g=!0)}if(n.select&&u!==void 0&&!y)if(s&&u===i?.data&&n.select===this.#m)u=this.#f;else try{this.#m=n.select,u=n.select(u),u=Si(s?.data,u,n),this.#f=u,this.#o=null}catch(k){this.#o=k}this.#o&&(m=this.#o,u=this.#f,p=Date.now(),v="error");const S=h.fetchStatus==="fetching",E=v==="pending",x=v==="error",M=E&&S,V=u!==void 0,F={status:v,fetchStatus:h.fetchStatus,isPending:E,isSuccess:v==="success",isError:x,isInitialLoading:M,isLoading:M,data:u,dataUpdatedAt:h.dataUpdatedAt,error:m,errorUpdatedAt:p,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>c.dataUpdateCount||h.errorUpdateCount>c.errorUpdateCount,isFetching:S,isRefetching:S&&!E,isLoadingError:x&&!V,isPaused:h.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:x&&V,isStale:js(e,n),refetch:this.refetch,promise:this.#a,isEnabled:He(n.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const k=R=>{F.status==="error"?R.reject(F.error):F.data!==void 0&&R.resolve(F.data)},N=()=>{const R=this.#a=F.promise=wi();k(R)},T=this.#a;switch(T.status){case"pending":e.queryHash===t.queryHash&&k(T);break;case"fulfilled":(F.status==="error"||F.data!==T.value)&&N();break;case"rejected":(F.status!=="error"||F.error!==T.reason)&&N();break}}return F}updateResult(){const e=this.#t,n=this.createResult(this.#e,this.options);if(this.#s=this.#e.state,this.#i=this.options,this.#s.data!==void 0&&(this.#h=this.#e),Zn(n,e))return;this.#t=n;const t=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,s=typeof r=="function"?r():r;if(s==="all"||!s&&!this.#p.size)return!0;const i=new Set(s??this.#p);return this.options.throwOnError&&i.add("error"),Object.keys(this.#t).some(a=>{const l=a;return this.#t[l]!==e[l]&&i.has(l)})};this.#S({listeners:t()})}#E(){const e=this.#n.getQueryCache().build(this.#n,this.options);if(e===this.#e)return;const n=this.#e;this.#e=e,this.#r=e.state,this.hasListeners()&&(n?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#S(e){ir.batch(()=>{e.listeners&&this.listeners.forEach(n=>{n(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function ou(e,n){return He(n.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&n.retryOnMount===!1)}function Ii(e,n){return ou(e,n)||e.state.data!==void 0&&rs(e,n,n.refetchOnMount)}function rs(e,n,t){if(He(n.enabled,e)!==!1&&sn(n.staleTime,e)!=="static"){const r=typeof t=="function"?t(e):t;return r==="always"||r!==!1&&js(e,n)}return!1}function Ai(e,n,t,r){return(e!==n||He(r.enabled,e)===!1)&&(!t.suspense||e.state.status!=="error")&&js(e,t)}function js(e,n){return He(n.enabled,e)!==!1&&e.isStaleByTime(sn(n.staleTime,e))}function lu(e,n){return!Zn(e.getCurrentResult(),n)}var cu=class extends fa{#n;#e=void 0;#r;#t;constructor(e,n){super(),this.#n=e,this.setOptions(n),this.bindMethods(),this.#s()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#n.defaultMutationOptions(e),Zn(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#r,observer:this}),n?.mutationKey&&this.options.mutationKey&&ki(n.mutationKey)!==ki(this.options.mutationKey)?this.reset():this.#r?.state.status==="pending"&&this.#r.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#r?.removeObserver(this)}onMutationUpdate(e){this.#s(),this.#i(e)}getCurrentResult(){return this.#e}reset(){this.#r?.removeObserver(this),this.#r=void 0,this.#s(),this.#i()}mutate(e,n){return this.#t=n,this.#r?.removeObserver(this),this.#r=this.#n.getMutationCache().build(this.#n,this.options),this.#r.addObserver(this),this.#r.execute(e)}#s(){const e=this.#r?.state??Ql();this.#e={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#i(e){ir.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#e.variables,t=this.#e.context;e?.type==="success"?(this.#t.onSuccess?.(e.data,n,t),this.#t.onSettled?.(e.data,null,n,t)):e?.type==="error"&&(this.#t.onError?.(e.error,n,t),this.#t.onSettled?.(void 0,e.error,n,t))}this.listeners.forEach(n=>{n(this.#e)})})}},Ja=o.createContext(!1),uu=()=>o.useContext(Ja);Ja.Provider;function du(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var fu=o.createContext(du()),hu=()=>o.useContext(fu),pu=(e,n)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(n.isReset()||(e.retryOnMount=!1))},mu=e=>{o.useEffect(()=>{e.clearReset()},[e])},gu=({result:e,errorResetBoundary:n,throwOnError:t,query:r,suspense:s})=>e.isError&&!n.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||ha(t,[e.error,r])),vu=e=>{if(e.suspense){const n=r=>r==="static"?r:Math.max(r??1e3,1e3),t=e.staleTime;e.staleTime=typeof t=="function"?(...r)=>n(t(...r)):n(t),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},yu=(e,n)=>e.isLoading&&e.isFetching&&!n,bu=(e,n)=>e?.suspense&&n.isPending,Vi=(e,n,t)=>n.fetchOptimistic(e).catch(()=>{t.clearReset()});function xu(e,n,t){const r=uu(),s=hu(),i=pa(),a=i.defaultQueryOptions(e);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=r?"isRestoring":"optimistic",vu(a),pu(a,s),mu(s);const l=!i.getQueryCache().get(a.queryHash),[c]=o.useState(()=>new n(i,a)),f=c.getOptimisticResult(a),h=!r&&e.subscribed!==!1;if(o.useSyncExternalStore(o.useCallback(g=>{const u=h?c.subscribe(ir.batchCalls(g)):zn;return c.updateResult(),u},[c,h]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),o.useEffect(()=>{c.setOptions(a)},[a,c]),bu(a,f))throw Vi(a,c,s);if(gu({result:f,errorResetBoundary:s,throwOnError:a.throwOnError,query:i.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw f.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(a,f),a.experimental_prefetchInRender&&!Kr&&yu(f,r)&&(l?Vi(a,c,s):i.getQueryCache().get(a.queryHash)?.promise)?.catch(zn).finally(()=>{c.updateResult()}),a.notifyOnChangeProps?f:c.trackResult(f)}function Ns(e,n){return xu(e,au)}function eo(e,n){const t=pa(),[r]=o.useState(()=>new cu(t,e));o.useEffect(()=>{r.setOptions(e)},[r,e]);const s=o.useSyncExternalStore(o.useCallback(a=>r.subscribe(ir.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=o.useCallback((a,l)=>{r.mutate(a,l).catch(zn)},[r]);if(s.error&&ha(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}const wu=iu`
|
|
1
|
+
import{d as ua,b as yl,e as bl,c as xl,f as wl,g as El,t as yi,h as Sl,i as Y,k as ke,l as ee,I as nt,m as kl,D as Ml,C as Cl,T as hs,P as bi,n as Tl,E as Fl,o as Ol,p as Rl,q as Il,s as Al,v as Vl,B as Pl,w as jl,x as Nl,F as Dl,y as Ll,z as $l,A as Hl,G as _l,H as Bl,J as da,S as Re,K as ft,U as ps,L as yn,M as St,O as Ht,N as De,Q as Je,V as se,W as Zl,X as me,Y as Bn,Z as zr,_ as zl,$ as Ul,a0 as ve,a1 as Gl,a2 as Ur,a3 as Gr,a4 as qr,a5 as mt,a6 as ms,a7 as ql,a8 as rn,a9 as rr,aa as sr,ab as gs,ac as Ir,ad as xi,ae as fa,af as wi,ag as He,ah as Zn,ai as sn,aj as zn,ak as Kr,al as Ei,am as Kl,an as Wl,ao as Yl,ap as Si,aq as ir,ar as ki,as as Ql,r as o,at as ha,au as pa,av as Mn,aw as Cn,u as vs,ax as Xl,ay as ma,az as Jl,aA as Te,aB as ga,j as d,aC as ys,aD as bs,aE as Xe,aF as Un,aG as bt,aH as jt,aI as _e,aJ as Oe,aK as Nn,aL as ec,aM as oe,aN as Ce,aO as xs,aP as _t,aQ as xt,aR as ws,aS as Fe,aT as Es,aU as Ar,aV as tc,aW as nc,aX as va,aY as rc,aZ as We,a_ as Vr,a$ as sc,b0 as ic,b1 as ac,b2 as oc,b3 as lc,b4 as ya,b5 as ba,b6 as cc,b7 as Ke,b8 as K,b9 as le,ba as he,bb as Gt,bc as Z,bd as xa,be as ar,bf as or,bg as qt,bh as lr,bi as cr,bj as te,bk as Kt,bl as Wt,bm as ur,bn as rt,bo as dr,bp as Mi,bq as un,br as uc,bs as wa,bt as ne,bu as ye,bv as bn,bw as Ea,bx as Nt,by as Sa,bz as Ss,bA as xn,bB as ae,bC as Se,bD as ka,bE as dt,bF as Ma,bG as Qe,bH as Bt,bI as ks,bJ as Ms,bK as Ca,bL as Ta,bM as Fa,bN as Ct,bO as fr,bP as ge,bQ as Cs,bR as Ts,bS as Fs,bT as Ee,bU as dc,bV as hr,bW as Wr,bX as Os,bY as Oa,bZ as fc,b_ as Ra,b$ as Rs,c0 as Ia,c1 as Aa,c2 as pr,c3 as st,c4 as Is,c5 as As,c6 as an,c7 as hc,c8 as mr,c9 as on,ca as ze,cb as et,cc as Va,cd as Ci,ce as wt,cf as pc,cg as mc,ch as gc,ci as vc,cj as Pa,ck as Ti,cl as yc,cm as bc,cn as Pr,co as xc,cp as wc,cq as Ec,cr as Sc,cs as kc,ct as Mc,cu as Cc,cv as Tc,cw as Fc,cx as Oc,cy as Vs,cz as Rc,cA as Ic,cB as Ac,cC as Vc,cD as Pc,cE as jc,cF as Nc,cG as Dc,cH as Yr,cI as Lc,cJ as Fi,cK as Ze,cL as $c,cM as Gn,cN as be,cO as ja,cP as Na,cQ as Da,cR as Zt,cS as La,cT as $a,cU as Ha,cV as Qr,cW as gr,cX as Hc,cY as Tn,cZ as _c,c_ as Bc,c$ as Zc,d0 as Fn,d1 as jr,d2 as On,d3 as zc,d4 as Uc,d5 as Gc,d6 as Oi}from"./index-B5RxXGeM.js";function qc(e){return{type:"createEntity",id:e.id,values:e.values??[]}}function zt(e){return{type:"createRelation",...e}}function Ie(e){return ua(`grc20:genesis:language:${e.toLowerCase()}`)}const Nr={english:()=>Ie("en"),spanish:()=>Ie("es"),french:()=>Ie("fr"),german:()=>Ie("de"),chinese:()=>Ie("zh"),japanese:()=>Ie("ja"),korean:()=>Ie("ko"),portuguese:()=>Ie("pt"),italian:()=>Ie("it"),russian:()=>Ie("ru"),arabic:()=>Ie("ar"),hindi:()=>Ie("hi"),fromCode:e=>Ie(e)},qn=e=>e.toUpperCase(),kt=e=>e.toLowerCase(),Kn=e=>e.length===0,tt=e=>e.length>0,Dt=e=>e.length;class Ri extends Error{_tag="IpfsUploadError"}function Kc(e){return ua(e)}async function Wc(e){const{name:n,ops:t,author:r,network:s="TESTNET"}=e,i=yl(),a={id:i,name:n,authors:[Kc(r)],createdAt:BigInt(Date.now())*1000n,ops:t},l=bl(a),c=new Uint8Array(l),f=new Blob([c],{type:"application/octet-stream"}),h=new FormData;h.append("file",f);const g=await xl(Yc(h,s)),u=wl(i);return{cid:g,editId:u}}function Yc(e,n="TESTNET"){return El(function*(){const t=yield*yi({try:()=>fetch(`${Sl(n)}/ipfs/upload-edit`,{method:"POST",body:e}),catch:s=>new Ri(`Could not upload data to IPFS: ${s}`)});return yield*yi({try:async()=>{const{cid:s}=await t.json();return s},catch:s=>new Ri(`Could not parse response from IPFS: ${s}`)})})}const Dn=({id:e,fromEntity:n,toEntity:t,position:r,fromSpace:s,toSpace:i,fromVersion:a,toVersion:l,type:c,entityId:f,entityName:h,entityDescription:g,entityCover:u,entityValues:m,entityRelations:p,entityTypes:v})=>{e&&Y(e,"`id` in `createRelation`"),n&&Y(n,"`fromEntity` in `createRelation`"),t&&Y(t,"`toEntity` in `createRelation`"),s&&Y(s,"`fromSpace` in `createRelation`"),i&&Y(i,"`toSpace` in `createRelation`"),a&&Y(a,"`fromVersion` in `createRelation`"),l&&Y(l,"`toVersion` in `createRelation`"),c&&Y(c,"`type` in `createRelation`"),f&&Y(f,"`entityId` in `createRelation`"),u&&Y(u,"`entityCover` in `createRelation`");for(const x of m??[])Y(x.property,"`entityValues` in `createRelation`"),x.type==="text"&&x.language&&Y(x.language,"`language` in `entityValues` in `createRelation`"),x.type==="float64"&&x.unit&&Y(x.unit,"`unit` in `entityValues` in `createRelation`");for(const[x]of Object.entries(p??{}))Y(x,"`entityRelations` in `createRelation`");for(const x of v??[])Y(x,"`entityTypes` in `createRelation`");const y=e??ke(),S=f??ke(),E=[];if(E.push(zt({id:ee(y),entity:ee(S),from:ee(n),to:ee(t),relationType:ee(c),...s?{fromSpace:ee(s)}:{},...a?{fromVersion:ee(a)}:{},...i?{toSpace:ee(i)}:{},...l?{toVersion:ee(l)}:{},...r!==void 0?{position:r}:{}})),h||g||u||m||p||v){const{ops:x}=Ps({id:S,name:h,description:g,cover:u,values:m,relations:p,types:v});E.push(...x)}return{id:nt(y),ops:E}},Ps=({id:e,name:n,description:t,cover:r,values:s,relations:i,types:a})=>{e&&Y(e,"`id` in `createEntity`"),r&&Y(r,"`cover` in `createEntity`");for(const h of s??[])Y(h.property,"`values` in `createEntity`"),h.type==="text"&&h.language&&Y(h.language,"`language` in `values` in `createEntity`"),h.type==="float64"&&h.unit&&Y(h.unit,"`unit` in `values` in `createEntity`");for(const[h,g]of Object.entries(i??{}))if(Y(h,"`relations` in `createEntity`"),Array.isArray(g))for(const u of g)Y(u.toEntity,"`toEntity` in `relations` in `createEntity`"),u.toSpace&&Y(u.toSpace,"`toSpace` in `relations` in `createEntity`"),u.fromSpace&&Y(u.fromSpace,"`fromSpace` in `relations` in `createEntity`"),u.fromVersion&&Y(u.fromVersion,"`fromVersion` in `relations` in `createEntity`"),u.toVersion&&Y(u.toVersion,"`toVersion` in `relations` in `createEntity`"),u.entityId&&Y(u.entityId,"`entityId` in `relations` in `createEntity`"),u.entityCover&&Y(u.entityCover,"`entityCover` in `relations` in `createEntity`");else Y(g.toEntity,"`toEntity` in `relations` in `createEntity`"),g.toSpace&&Y(g.toSpace,"`toSpace` in `relations` in `createEntity`"),g.fromSpace&&Y(g.fromSpace,"`fromSpace` in `relations` in `createEntity`"),g.fromVersion&&Y(g.fromVersion,"`fromVersion` in `relations` in `createEntity`"),g.toVersion&&Y(g.toVersion,"`toVersion` in `relations` in `createEntity`"),g.entityId&&Y(g.entityId,"`entityId` in `relations` in `createEntity`"),g.entityCover&&Y(g.entityCover,"`entityCover` in `relations` in `createEntity`");for(const h of a??[])Y(h,"`types` in `createEntity`");const l=e??ke();let c=[];const f=[];n&&f.push({property:ee(kl),value:{type:"text",value:n,language:Nr.english()}}),t&&f.push({property:ee(Ml),value:{type:"text",value:t,language:Nr.english()}});for(const h of s??[]){const g=ee(h.property);if(h.type==="text")f.push({property:g,value:{type:"text",value:h.value,language:h.language?ee(h.language):Nr.english()}});else if(h.type==="float64")f.push({property:g,value:{type:"float64",value:h.value,...h.unit?{unit:ee(h.unit)}:{}}});else if(h.type==="bool")f.push({property:g,value:{type:"bool",value:h.value}});else if(h.type==="point")f.push({property:g,value:{type:"point",lon:h.lon,lat:h.lat,...h.alt!==void 0?{alt:h.alt}:{}}});else if(h.type==="date")f.push({property:g,value:{type:"date",value:h.value}});else if(h.type==="time")f.push({property:g,value:{type:"time",value:h.value}});else if(h.type==="datetime")f.push({property:g,value:{type:"datetime",value:h.value}});else if(h.type==="schedule")f.push({property:g,value:{type:"schedule",value:h.value}});else{const u=h;throw new Error(`Unsupported value type: ${u.type}`)}}if(c.push(qc({id:ee(l),values:f})),r&&c.push(zt({id:ee(ke()),entity:ee(ke()),from:ee(l),to:ee(r),relationType:ee(Cl)})),a)for(const h of a)c.push(zt({id:ee(ke()),entity:ee(ke()),from:ee(l),to:ee(h),relationType:ee(hs)}));for(const[h,g]of Object.entries(i??{})){const u=Array.isArray(g)?g:[g];for(const m of u){const p=m.id??ke(),v=m.entityId??ke(),{ops:y}=Dn({id:p,fromEntity:l,toEntity:m.toEntity,type:nt(h),position:m.position,fromSpace:m.fromSpace,toSpace:m.toSpace,fromVersion:m.fromVersion,toVersion:m.toVersion,entityId:v,entityName:m.entityName,entityDescription:m.entityDescription,entityCover:m.entityCover,entityValues:m.entityValues,entityRelations:m.entityRelations,entityTypes:m.entityTypes});c=c.concat(y)}}return{id:nt(l),ops:c}},Qc={BOOLEAN:$l,INT64:Ll,FLOAT64:Dl,DECIMAL:Nl,TEXT:jl,BYTES:Pl,DATE:Vl,TIME:Al,DATETIME:Il,SCHEDULE:Rl,POINT:Ol,EMBEDDING:Fl},Xr=e=>{const{id:n,name:t,description:r,cover:s}=e;if(n&&Y(n,"`id` in `createProperty`"),s&&Y(s,"`cover` in `createProperty`"),e.dataType==="RELATION"){for(const c of e.properties??[])Y(c,"`properties` in `createProperty`");for(const c of e.relationValueTypes??[])Y(c,"`relationValueTypes` in `createProperty`")}const i=n??ke(),a=[],{ops:l}=Ps({id:i,name:t,description:r,cover:s});if(a.push(...l),a.push(zt({id:ee(ke()),entity:ee(ke()),from:ee(i),to:ee(bi),relationType:ee(hs)})),e.dataType==="RELATION"){if(e.properties)for(const c of e.properties){Y(c);const{ops:f}=Dn({fromEntity:i,toEntity:c,type:bi});a.push(...f)}if(e.relationValueTypes)for(const c of e.relationValueTypes){Y(c);const{ops:f}=Dn({fromEntity:i,toEntity:c,type:Tl});a.push(...f)}}else{const c=Qc[e.dataType],{ops:f}=Dn({fromEntity:i,toEntity:c,type:Hl});a.push(...f)}return{id:nt(i),ops:a}},_a=({id:e,name:n,description:t,cover:r,properties:s})=>{e&&Y(e,"`id` in `createType`");for(const l of s??[])Y(l,"`properties` in `createType`");const i=e??ke(),{ops:a}=Ps({id:i,name:n,description:t,cover:r});if(Y(i),a.push(zt({id:ee(ke()),entity:ee(ke()),from:ee(i),to:ee(_l),relationType:ee(hs)})),s)for(const l of s)Y(l,"`propertyId` in `createType`"),a.push(zt({id:ee(ke()),entity:ee(ke()),from:ee(i),to:ee(l),relationType:ee(Bl)}));return{id:nt(i),ops:a}};function Ba(e){if(Kn(e))throw new Za({input:e,cause:"Input is empty"});let n="",t=!1,r=0;for(;r<Dt(e)&&!/[a-zA-Z0-9]/.test(e[r]);)r++;for(;r<Dt(e);r++){const s=e[r];/[a-zA-Z0-9]/.test(s)?t?(n+=qn(s),t=!1):Dt(n)===0?n+=kt(s):/[A-Z]/.test(s)&&r>0&&/[a-z0-9]/.test(e[r-1])?n+=qn(s):n+=kt(s):t=Dt(n)>0}return n}function Jr(e){if(Kn(e))throw new Za({input:e,cause:"Input is empty"});let n="",t=!0,r=0;for(;r<Dt(e)&&!/[a-zA-Z0-9]/.test(e[r]);)r++;for(;r<Dt(e);r++){const s=e[r];/[a-zA-Z0-9]/.test(s)?t?(n+=qn(s),t=!1):/[A-Z]/.test(s)&&r>0&&/[a-z0-9]/.test(e[r-1])?n+=qn(s):n+=kt(s):t=!0}return n}class Za extends da("/typesync/errors/InvalidInputError"){}function vr(e){const n=new Set;for(const t of e){const r=kt(t.name);if(n.has(r))return!1;n.add(r)}return!0}function ut(e){return/^Relation\((.+)\)$/.test(e)}const za=De.pipe(St(e=>ut(e))),Ua=ms("String","Number","Boolean","Date","Point");ps(Ua,za);const Ga=Re({name:De,knowledgeGraphId:Ht(rn),optional:zr(zl(ql))}),qa=Re({...Ga.fields,dataType:za,relationType:De.annotations({identifier:"SchemaTypePropertyRelation.relationType",description:"name of the type within the schema that this property is related to",examples:["Account"]})}),Ka=Re({...Ga.fields,dataType:Ua});function dn(e){return ut(e.dataType)}const Wa=Re({name:De,knowledgeGraphId:Ht(rn),properties:ft(ps(Ka,qa)).pipe(yn(1),St(vr,{identifier:"DuplicatePropertyNames",jsonSchema:{},description:"The property.name must be unique across all properties in the type"}))}),Ya=Re({types:ft(Wa).pipe(yn(1),St(vr,{identifier:"DuplicateTypeNames",jsonSchema:{},description:"The type.name must be unique across all types in the schema"}),St(Qa,{identifier:"AllRelationTypesExist",jsonSchema:{},description:"Each type property of dataType RELATION must have a type of the same name in the schema"}))}).annotations({identifier:"typesync/Schema",title:"TypeSync app Schema",description:"An array of types in the schema defined by the user to generate a Mapping object for",examples:[{types:[{name:"Account",knowledgeGraphId:null,properties:[{name:"username",optional:null,knowledgeGraphId:null,dataType:"String"}]}]},{types:[{name:"Account",knowledgeGraphId:"a5fd07b1120f46c6b46f387ef98396a6",properties:[{name:"name",optional:!0,knowledgeGraphId:"a126ca530c8e48d5b88882c734c38935",dataType:"String"}]}]}]}),Xc=Ul(Ya);rr(Ya);function Qa(e){const n=Je(e,new Set,(t,r)=>t.add(r.name));return se(e,Bn(t=>t.properties),me(t=>dn(t)),Zl(t=>n.has(t.relationType)))}function es(e){return se(e,Je({},(n,{propName:t,id:r})=>(n[Ba(t)]=r,n)))}function ts(e){return se(e,Je({},(n,{propName:t,id:r})=>(n[Ba(t)]=r,n)))}function Jc(e,n){if(e.knowledgeGraphId)return{type:"resolved",mapping:{propName:e.name,id:nt(e.knowledgeGraphId)},ops:[]};if(dn(e)){const s=n.get(e.relationType);if(s==null)return{type:"deferred",property:e};const{id:i,ops:a}=Xr({name:e.name,dataType:"RELATION",relationValueTypes:[s]});return{type:"resolved",mapping:{propName:e.name,id:i},ops:a}}const{id:t,ops:r}=Xr({name:e.name,dataType:ru(e.dataType)});return{type:"resolved",mapping:{propName:e.name,id:t},ops:r}}function eu(e,n){const t=se(e.properties,ve(u=>Jc(u,n))),r=se(t,Ur(u=>u.type==="resolved"?qr(u):Gr())),s=se(t,Ur(u=>u.type==="deferred"?qr(u.property):Gr())),i=se(r,me(u=>{const m=e.properties.find(p=>p.name===u.mapping.propName);return m?!dn(m):!1}),ve(u=>u.mapping)),a=se(r,me(u=>{const m=e.properties.find(p=>p.name===u.mapping.propName);return m?dn(m):!1}),ve(u=>u.mapping)),l=se(r,Bn(u=>u.ops));if(e.knowledgeGraphId){const u={typeName:Jr(e.name),typeIds:[nt(e.knowledgeGraphId)]};return mt(i)&&(u.properties=es(i)),mt(a)&&(u.relations=ts(a)),{type:"complete",entry:u,ops:l}}if(mt(s))return{type:"deferred",schemaType:e,properties:i,relations:a};const c=[...i,...a],{id:f,ops:h}=_a({name:e.name,properties:se(c,ve(u=>u.id))});n.set(e.name,f);const g={typeName:Jr(e.name),typeIds:[f]};return mt(i)&&(g.properties=es(i)),mt(a)&&(g.relations=ts(a)),{type:"complete",entry:g,ops:[...l,...h]}}function tu(e){const n=Xc(e),t=se(n.types,Je(new Map,(g,u)=>g.set(u.name,u.knowledgeGraphId!=null?nt(u.knowledgeGraphId):null))),r=se(n.types,ve(g=>eu(g,t))),[s,i]=se(r,Gl(g=>g.type==="complete")),a=se(i,Bn(g=>g.ops)),{entries:l,ops:c}=se(s,Je({entries:[],ops:[]},(g,u)=>{const m=se(u.schemaType.properties,Ur(M=>{if(!dn(M)||M.knowledgeGraphId!=null)return Gr();const V=t.get(M.relationType);if(V==null)throw new nu({message:`Failed to resolve type ID for relation type: ${M.relationType}`,property:M.name,relatedType:M.relationType});const{id:b,ops:F}=Xr({name:M.name,dataType:"RELATION",relationValueTypes:[V]});return qr({mapping:{propName:M.name,id:b},ops:F})})),p=[...u.relations,...se(m,ve(M=>M.mapping))],v=[...u.properties,...p],{id:y,ops:S}=_a({name:u.schemaType.name,properties:se(v,ve(M=>M.id))});t.set(u.schemaType.name,y);const E=[...se(m,Bn(M=>M.ops)),...S],x={typeName:Jr(u.schemaType.name),typeIds:[y]};return mt(u.properties)&&(x.properties=es(u.properties)),mt(p)&&(x.relations=ts(p)),{entries:[...g.entries,x],ops:[...g.ops,...E]}})),f=[...se(i,ve(g=>g.entry)),...l];return[se(f,Je({},(g,u)=>{const{typeName:m,...p}=u;return g[m]=p,g})),[...a,...c]]}class nu extends da("/typesync/errors/RelationValueTypeDoesNotExistError"){}function ru(e){switch(!0){case e==="Boolean":return"BOOLEAN";case e==="Date":return"TIME";case e==="Number":return"FLOAT64";case e==="Point":return"POINT";case ut(e):return"RELATION";default:return"TEXT"}}const Xa=Ht(ms("published","synced","published_not_synced")),su=ps(Ka,qa).pipe(gs(Re({status:Xa})));class ns extends sr("/Hypergraph/cli/models/TypesyncHypergraphSchemaType")({...Wa.omit("properties").fields,status:Xa,properties:ft(su).pipe(yn(1),St(vr,{identifier:"DuplicatePropertyNames",jsonSchema:{},description:"The property.name must be unique across all properties in the type"}))}){}class wn extends sr("/Hypergraph/cli/models/TypesyncHypergraphSchema")({types:ft(ns).pipe(yn(1),St(vr,{identifier:"DuplicateTypeNames",jsonSchema:{},description:"The type.name must be unique across all types in the schema"}),St(Qa,{identifier:"AllRelationTypesExist",jsonSchema:{},description:"Each type property of dataType RELATION must have a type of the same name in the schema"}))}){}Ir({key:De,value:Re({typeIds:ft(rn).pipe(yn(1)),properties:zr(xi(Ir({key:De,value:rn}))),relations:zr(xi(Ir({key:De,value:rn})))})});const iu=(e,...n)=>e.reduce((t,r,s)=>`${t}${r}${s in n?String(n[s]):""}`,"");var au=class extends fa{constructor(e,n){super(),this.options=n,this.#n=e,this.#o=null,this.#a=wi(),this.bindMethods(),this.setOptions(n)}#n;#e=void 0;#r=void 0;#t=void 0;#s;#i;#a;#o;#m;#f;#h;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Ii(this.#e,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return rs(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return rs(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#x(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const n=this.options,t=this.#e;if(this.options=this.#n.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof He(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#E(),this.#e.setOptions(this.options),n._defaulted&&!Zn(this.options,n)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Ai(this.#e,t,this.options,n)&&this.#d(),this.updateResult(),r&&(this.#e!==t||He(this.options.enabled,this.#e)!==He(n.enabled,this.#e)||sn(this.options.staleTime,this.#e)!==sn(n.staleTime,this.#e))&&this.#g();const s=this.#v();r&&(this.#e!==t||He(this.options.enabled,this.#e)!==He(n.enabled,this.#e)||s!==this.#l)&&this.#y(s)}getOptimisticResult(e){const n=this.#n.getQueryCache().build(this.#n,e),t=this.createResult(n,e);return lu(this,t)&&(this.#t=t,this.#i=this.options,this.#s=this.#e.state),t}getCurrentResult(){return this.#t}trackResult(e,n){return new Proxy(e,{get:(t,r)=>(this.trackProp(r),n?.(r),r==="promise"&&!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(t,r))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const n=this.#n.defaultQueryOptions(e),t=this.#n.getQueryCache().build(this.#n,n);return t.fetch().then(()=>this.createResult(t,n))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#t))}#d(e){this.#E();let n=this.#e.fetch(this.options,e);return e?.throwOnError||(n=n.catch(zn)),n}#g(){this.#x();const e=sn(this.options.staleTime,this.#e);if(Kr||this.#t.isStale||!Ei(e))return;const t=Kl(this.#t.dataUpdatedAt,e)+1;this.#c=setTimeout(()=>{this.#t.isStale||this.updateResult()},t)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#y(e){this.#w(),this.#l=e,!(Kr||He(this.options.enabled,this.#e)===!1||!Ei(this.#l)||this.#l===0)&&(this.#u=setInterval(()=>{(this.options.refetchIntervalInBackground||Wl.isFocused())&&this.#d()},this.#l))}#b(){this.#g(),this.#y(this.#v())}#x(){this.#c&&(clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(clearInterval(this.#u),this.#u=void 0)}createResult(e,n){const t=this.#e,r=this.options,s=this.#t,i=this.#s,a=this.#i,c=e!==t?e.state:this.#r,{state:f}=e;let h={...f},g=!1,u;if(n._optimisticResults){const k=this.hasListeners(),N=!k&&Ii(e,n),T=k&&Ai(e,t,n,r);(N||T)&&(h={...h,...Yl(f.data,e.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:m,errorUpdatedAt:p,status:v}=h;u=h.data;let y=!1;if(n.placeholderData!==void 0&&u===void 0&&v==="pending"){let k;s?.isPlaceholderData&&n.placeholderData===a?.placeholderData?(k=s.data,y=!0):k=typeof n.placeholderData=="function"?n.placeholderData(this.#h?.state.data,this.#h):n.placeholderData,k!==void 0&&(v="success",u=Si(s?.data,k,n),g=!0)}if(n.select&&u!==void 0&&!y)if(s&&u===i?.data&&n.select===this.#m)u=this.#f;else try{this.#m=n.select,u=n.select(u),u=Si(s?.data,u,n),this.#f=u,this.#o=null}catch(k){this.#o=k}this.#o&&(m=this.#o,u=this.#f,p=Date.now(),v="error");const S=h.fetchStatus==="fetching",E=v==="pending",x=v==="error",M=E&&S,V=u!==void 0,F={status:v,fetchStatus:h.fetchStatus,isPending:E,isSuccess:v==="success",isError:x,isInitialLoading:M,isLoading:M,data:u,dataUpdatedAt:h.dataUpdatedAt,error:m,errorUpdatedAt:p,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>c.dataUpdateCount||h.errorUpdateCount>c.errorUpdateCount,isFetching:S,isRefetching:S&&!E,isLoadingError:x&&!V,isPaused:h.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:x&&V,isStale:js(e,n),refetch:this.refetch,promise:this.#a,isEnabled:He(n.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const k=R=>{F.status==="error"?R.reject(F.error):F.data!==void 0&&R.resolve(F.data)},N=()=>{const R=this.#a=F.promise=wi();k(R)},T=this.#a;switch(T.status){case"pending":e.queryHash===t.queryHash&&k(T);break;case"fulfilled":(F.status==="error"||F.data!==T.value)&&N();break;case"rejected":(F.status!=="error"||F.error!==T.reason)&&N();break}}return F}updateResult(){const e=this.#t,n=this.createResult(this.#e,this.options);if(this.#s=this.#e.state,this.#i=this.options,this.#s.data!==void 0&&(this.#h=this.#e),Zn(n,e))return;this.#t=n;const t=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,s=typeof r=="function"?r():r;if(s==="all"||!s&&!this.#p.size)return!0;const i=new Set(s??this.#p);return this.options.throwOnError&&i.add("error"),Object.keys(this.#t).some(a=>{const l=a;return this.#t[l]!==e[l]&&i.has(l)})};this.#S({listeners:t()})}#E(){const e=this.#n.getQueryCache().build(this.#n,this.options);if(e===this.#e)return;const n=this.#e;this.#e=e,this.#r=e.state,this.hasListeners()&&(n?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#S(e){ir.batch(()=>{e.listeners&&this.listeners.forEach(n=>{n(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function ou(e,n){return He(n.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&n.retryOnMount===!1)}function Ii(e,n){return ou(e,n)||e.state.data!==void 0&&rs(e,n,n.refetchOnMount)}function rs(e,n,t){if(He(n.enabled,e)!==!1&&sn(n.staleTime,e)!=="static"){const r=typeof t=="function"?t(e):t;return r==="always"||r!==!1&&js(e,n)}return!1}function Ai(e,n,t,r){return(e!==n||He(r.enabled,e)===!1)&&(!t.suspense||e.state.status!=="error")&&js(e,t)}function js(e,n){return He(n.enabled,e)!==!1&&e.isStaleByTime(sn(n.staleTime,e))}function lu(e,n){return!Zn(e.getCurrentResult(),n)}var cu=class extends fa{#n;#e=void 0;#r;#t;constructor(e,n){super(),this.#n=e,this.setOptions(n),this.bindMethods(),this.#s()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#n.defaultMutationOptions(e),Zn(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#r,observer:this}),n?.mutationKey&&this.options.mutationKey&&ki(n.mutationKey)!==ki(this.options.mutationKey)?this.reset():this.#r?.state.status==="pending"&&this.#r.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#r?.removeObserver(this)}onMutationUpdate(e){this.#s(),this.#i(e)}getCurrentResult(){return this.#e}reset(){this.#r?.removeObserver(this),this.#r=void 0,this.#s(),this.#i()}mutate(e,n){return this.#t=n,this.#r?.removeObserver(this),this.#r=this.#n.getMutationCache().build(this.#n,this.options),this.#r.addObserver(this),this.#r.execute(e)}#s(){const e=this.#r?.state??Ql();this.#e={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#i(e){ir.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#e.variables,t=this.#e.context;e?.type==="success"?(this.#t.onSuccess?.(e.data,n,t),this.#t.onSettled?.(e.data,null,n,t)):e?.type==="error"&&(this.#t.onError?.(e.error,n,t),this.#t.onSettled?.(void 0,e.error,n,t))}this.listeners.forEach(n=>{n(this.#e)})})}},Ja=o.createContext(!1),uu=()=>o.useContext(Ja);Ja.Provider;function du(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var fu=o.createContext(du()),hu=()=>o.useContext(fu),pu=(e,n)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(n.isReset()||(e.retryOnMount=!1))},mu=e=>{o.useEffect(()=>{e.clearReset()},[e])},gu=({result:e,errorResetBoundary:n,throwOnError:t,query:r,suspense:s})=>e.isError&&!n.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||ha(t,[e.error,r])),vu=e=>{if(e.suspense){const n=r=>r==="static"?r:Math.max(r??1e3,1e3),t=e.staleTime;e.staleTime=typeof t=="function"?(...r)=>n(t(...r)):n(t),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},yu=(e,n)=>e.isLoading&&e.isFetching&&!n,bu=(e,n)=>e?.suspense&&n.isPending,Vi=(e,n,t)=>n.fetchOptimistic(e).catch(()=>{t.clearReset()});function xu(e,n,t){const r=uu(),s=hu(),i=pa(),a=i.defaultQueryOptions(e);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=r?"isRestoring":"optimistic",vu(a),pu(a,s),mu(s);const l=!i.getQueryCache().get(a.queryHash),[c]=o.useState(()=>new n(i,a)),f=c.getOptimisticResult(a),h=!r&&e.subscribed!==!1;if(o.useSyncExternalStore(o.useCallback(g=>{const u=h?c.subscribe(ir.batchCalls(g)):zn;return c.updateResult(),u},[c,h]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),o.useEffect(()=>{c.setOptions(a)},[a,c]),bu(a,f))throw Vi(a,c,s);if(gu({result:f,errorResetBoundary:s,throwOnError:a.throwOnError,query:i.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw f.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(a,f),a.experimental_prefetchInRender&&!Kr&&yu(f,r)&&(l?Vi(a,c,s):i.getQueryCache().get(a.queryHash)?.promise)?.catch(zn).finally(()=>{c.updateResult()}),a.notifyOnChangeProps?f:c.trackResult(f)}function Ns(e,n){return xu(e,au)}function eo(e,n){const t=pa(),[r]=o.useState(()=>new cu(t,e));o.useEffect(()=>{r.setOptions(e)},[r,e]);const s=o.useSyncExternalStore(o.useCallback(a=>r.subscribe(ir.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=o.useCallback((a,l)=>{r.mutate(a,l).catch(zn)},[r]);if(s.error&&ha(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}const wu=iu`
|
|
2
2
|
query Spaces($memberId: UUID!) {
|
|
3
3
|
spaces(filter: {members: {some: {memberSpaceId: {is: $memberId}}}}) {
|
|
4
4
|
id
|