@junobuild/admin 0.0.44-next-2024-01-30 → 0.0.44-next-2024-02-01

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.
@@ -10,5 +10,5 @@ index ${n} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display
10
10
 
11
11
  variant ${r} -> ${o.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${T(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,o]=this._fields[r];if(t.hasOwnProperty(n)){let i=b(r),s=o.encodeValue(t[n]);return m(i,s)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,i])=>{i.buildTypeTable(t)});let r=N(-21),n=b(this._fields.length),o=this._fields.map(([i,s])=>m(b(B(i)),s.encodeType(t)));t.add(this,m(r,n,...o))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a variant type");let o=Number(R(t));if(o>=n._fields.length)throw Error("Invalid variant index: "+o);let[i,s]=n._fields[o];for(let[l,u]of this._fields)if(B(i)===B(l)){let c=u.decodeValue(t,s);return{[l]:c}}throw new Error("Cannot find field hash "+i)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(t){for(let[r,n]of this._fields)if(t.hasOwnProperty(r)){let o=n.valueToString(t[r]);return o==="null"?`variant {${r}}`:`variant {${r}=${o}}`}throw new Error("Variant has no data: "+t)}},W=class e extends ${constructor(){super(...arguments),this._id=e._counter++,this._type=void 0}accept(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,r)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${T(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};W._counter=0;function Fe(e){if(H(e)!==1)throw new Error("Cannot decode principal");let r=Number(R(e));return Er.fromUint8Array(new Uint8Array(K(e,r)))}var we=class extends E{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${T(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=b(r.byteLength);return m(new Uint8Array([1]),n,r)}encodeType(){return N(-24)}decodeValue(t,r){return this.checkType(r),Fe(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}},se=class extends ${constructor(t,r,n=[]){super(),this.argTypes=t,this.retTypes=r,this.annotations=n}static argsToString(t,r){if(t.length!==r.length)throw new Error("arity mismatch");return"("+t.map((n,o)=>n.valueToString(r[o])).join(", ")+")"}accept(t,r){return t.visitFunc(this,r)}covariant(t){if(Array.isArray(t)&&t.length===2&&t[0]&&t[0]._isPrincipal&&typeof t[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${T(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),o=b(n.byteLength),i=m(new Uint8Array([1]),o,n),s=new TextEncoder().encode(r),l=b(s.byteLength);return m(new Uint8Array([1]),i,l,s)}_buildTypeTableImpl(t){this.argTypes.forEach(c=>c.buildTypeTable(t)),this.retTypes.forEach(c=>c.buildTypeTable(t));let r=N(-22),n=b(this.argTypes.length),o=m(...this.argTypes.map(c=>c.encodeType(t))),i=b(this.retTypes.length),s=m(...this.retTypes.map(c=>c.encodeType(t))),l=b(this.annotations.length),u=m(...this.annotations.map(c=>this.encodeAnnotation(c)));t.add(this,m(r,n,o,i,s,l,u))}decodeValue(t){if(H(t)!==1)throw new Error("Cannot decode function reference");let n=Fe(t),o=Number(R(t)),i=K(t,o),l=new TextDecoder("utf8",{fatal:!0}).decode(i);return[n,l]}get name(){let t=this.argTypes.map(o=>o.name).join(", "),r=this.retTypes.map(o=>o.name).join(", "),n=" "+this.annotations.join(" ");return`(${t}) -> (${r})${n}`}valueToString([t,r]){return`func "${t.toText()}".${r}`}display(){let t=this.argTypes.map(o=>o.display()).join(", "),r=this.retTypes.map(o=>o.display()).join(", "),n=" "+this.annotations.join(" ");return`(${t}) \u2192 (${r})${n}`}encodeAnnotation(t){if(t==="query")return new Uint8Array([1]);if(t==="oneway")return new Uint8Array([2]);if(t==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}},be=class extends ${constructor(t){super(),this._fields=Object.entries(t).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(t,r){return t.visitService(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${T(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=b(r.length);return m(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([i,s])=>s.buildTypeTable(t));let r=N(-23),n=b(this._fields.length),o=this._fields.map(([i,s])=>{let l=new TextEncoder().encode(i),u=b(l.length);return m(u,l,s.encodeType(t))});t.add(this,m(r,n,...o))}decodeValue(t){return Fe(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};function T(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>st?t.substring(0,st-3)+"...":t}function kr(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new Ce;e.forEach(u=>u.buildTypeTable(r));let n=new TextEncoder().encode(le),o=r.encode(),i=b(t.length),s=m(...e.map(u=>u.encodeType(r))),l=m(...ne(e,t,(u,c)=>{try{u.covariant(c)}catch(d){throw new Error(d.message+`
12
12
 
13
- `)}return u.encodeValue(c)}));return m(n,o,i,s,l)}function Br(e,t){let r=new U(t);if(t.byteLength<le.length)throw new Error("Message length smaller than magic number");let n=K(r,le.length),o=new TextDecoder().decode(n);if(o!==le)throw new Error("Wrong magic number: "+JSON.stringify(o));function i(a){let p=[],h=Number(R(a));for(let f=0;f<h;f++){let v=Number(q(a));switch(v){case-18:case-19:{let w=Number(q(a));p.push([v,w]);break}case-20:case-21:{let w=[],V=Number(R(a)),P;for(;V--;){let C=Number(R(a));if(C>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof P=="number"&&P>=C)throw new Error("field id collision or not sorted");P=C;let S=Number(q(a));w.push([C,S])}p.push([v,w]);break}case-22:{let w=[],V=Number(R(a));for(;V--;)w.push(Number(q(a)));let P=[],C=Number(R(a));for(;C--;)P.push(Number(q(a)));let S=[],k=Number(R(a));for(;k--;)switch(Number(R(a))){case 1:{S.push("query");break}case 2:{S.push("oneway");break}case 3:{S.push("composite_query");break}default:throw new Error("unknown annotation")}p.push([v,[w,P,S]]);break}case-23:{let w=Number(R(a)),V=[];for(;w--;){let P=Number(R(a)),C=new TextDecoder().decode(K(a,P)),S=q(a);V.push([C,S])}p.push([v,V]);break}default:throw new Error("Illegal op_code: "+v)}}let y=[],x=Number(R(a));for(let f=0;f<x;f++)y.push(Number(q(a)));return[p,y]}let[s,l]=i(r);if(l.length<e.length)throw new Error("Wrong number of return values");let u=s.map(a=>Ft());function c(a){if(a<-24)throw new Error("future value not supported");if(a<0)switch(a){case-1:return ut;case-2:return lt;case-3:return mt;case-4:return dt;case-5:return Tt;case-6:return wt;case-7:return bt;case-8:return Nt;case-9:return _t;case-10:return yt;case-11:return gt;case-12:return xt;case-13:return ht;case-14:return ft;case-15:return pt;case-16:return ct;case-17:return at;case-24:return vt;default:throw new Error("Illegal op_code: "+a)}if(a>=s.length)throw new Error("type index out of range");return u[a]}function d(a){switch(a[0]){case-19:{let p=c(a[1]);return Vt(p)}case-18:{let p=c(a[1]);return Rt(p)}case-20:{let p={};for(let[x,f]of a[1]){let v=`_${x}_`;p[v]=c(f)}let h=St(p),y=h.tryAsTuple();return Array.isArray(y)?Pt(...y):h}case-21:{let p={};for(let[h,y]of a[1]){let x=`_${h}_`;p[x]=c(y)}return Ct(p)}case-22:{let[p,h,y]=a[1];return At(p.map(x=>c(x)),h.map(x=>c(x)),y)}case-23:{let p={},h=a[1];for(let[y,x]of h){let f=c(x);if(f instanceof W&&(f=f.getType()),!(f instanceof se))throw new Error("Illegal service definition: services can only contain functions");p[y]=f}return Ot(p)}default:throw new Error("Illegal op_code: "+a[0])}}s.forEach((a,p)=>{if(a[0]===-22){let h=d(a);u[p].fill(h)}}),s.forEach((a,p)=>{if(a[0]!==-22){let h=d(a);u[p].fill(h)}});let _=l.map(a=>c(a)),g=e.map((a,p)=>a.decodeValue(r,_[p]));for(let a=e.length;a<_.length;a++)_[a].decodeValue(r,_[a]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return g}var at=new pe,ct=new X,Mr=new de,lt=new me,ut=new he,pt=new fe,dt=new _e,mt=new ye,ht=new oe(32),ft=new oe(64),_t=new j(8),yt=new j(16),gt=new j(32),xt=new j(64),Tt=new M(8),wt=new M(16),bt=new M(32),Nt=new M(64),vt=new we;function Pt(...e){return new xe(e)}function Vt(e){return new ge(e)}function Rt(e){return new Z(e)}function St(e){return new ie(e)}function Ct(e){return new Te(e)}function Ft(){return new W}function At(e,t,r=[]){return new se(e,t,r)}function Ot(e){return new be(e)}import{Principal as zn}from"@dfinity/principal";var Et=e=>F.encode([F.Record({user:F.Principal})],[{user:e}]),Ne=e=>F.encode([F.Record({controllers:F.Vec(F.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var no=async e=>De(e),oo=async({missionControl:e,wasm_module:t})=>{let r=await Le({missionControl:e}),{missionControlId:n,...o}=e;if(!n)throw new Error("No mission control principal defined.");let i=Et(r);await G({actor:o,code:{canister_id:Ur.fromText(n),arg:new Uint8Array(i),wasm_module:t,mode:{upgrade:null}}})},io=async({controllerId:e,profile:t,...r})=>tt({...r,...Ve({controllerId:e,profile:t})}),so=async({controllerId:e,profile:t,...r})=>rt({...r,...Ve({controllerId:e,profile:t})}),ao=e=>et(e);import{Principal as qr}from"@dfinity/principal";var kt=async({orbiter:e})=>(await ae(e)).version(),Ae=async({orbiter:e})=>(await ae(e)).list_controllers(),Bt=async({orbiter:e})=>{let{memory_size:t}=await ae(e);return t()};var _o=async e=>kt(e),yo=async({orbiter:e,wasm_module:t,reset:r=!1})=>{let{orbiterId:n,...o}=e;if(!n)throw new Error("No orbiter principal defined.");let i=await Ae({orbiter:e}),s=Ne(i);await G({actor:o,code:{canister_id:qr.fromText(n),arg:new Uint8Array(s),wasm_module:t,mode:r?{reinstall:null}:{upgrade:null}}})},go=e=>Bt(e),xo=e=>Ae(e);import{major as Mt,minor as $t,patch as Ut}from"semver";var bo=({currentVersion:e,selectedVersion:t})=>{let r=Mt(e),n=Mt(t),o=$t(e),i=$t(t),s=Ut(e),l=Ut(t);return r<n-1||o<i-1||s<l-1?{canUpgrade:!1}:{canUpgrade:!0}};import{Principal as pr}from"@dfinity/principal";import{fromNullable as Wr,isNullish as Jr}from"@junobuild/utils";import{toNullable as jr}from"@junobuild/utils";var qt=async({config:e,satellite:t})=>(await O(t)).set_config(e),jt=async({satellite:e,type:t})=>(await O(e)).list_rules(t),zt=async({type:e,collection:t,rule:r,satellite:n})=>(await O(n)).set_rule(e,t,r),Ht=async({satellite:e})=>{let{version:t}=await O(e);return t()},Kt=async({satellite:e})=>{let{version_build:t}=await O(e);return t()},Wt=async({satellite:e})=>(await Ye(e)).list_controllers(),Oe=async({satellite:e})=>(await Qe(e)).list_controllers(),Ee=async({satellite:e})=>(await O(e)).list_controllers(),Jt=async({satellite:e})=>{let{list_custom_domains:t}=await O(e);return t()},Gt=async({satellite:e,domainName:t,boundaryNodesId:r})=>{let{set_custom_domain:n}=await O(e);await n(t,jr(r))},Yt=async({satellite:e})=>{let{memory_size:t}=await O(e);return t()},Qt=async({collection:e,satellite:t})=>{let{count_docs:r}=await O(t);return r(e)},Xt=async({collection:e,satellite:t})=>{let{count_assets:r}=await O(t);return r(e)},Zt=async({collection:e,satellite:t})=>{let{del_docs:r}=await O(t);return r(e)},It=async({collection:e,satellite:t})=>{let{del_assets:r}=await O(t);return r(e)},Dt=async({args:e,satellite:t})=>{let{set_controllers:r}=await O(t);return r(e)};import{fromNullable as Be,isNullish as zr,nonNullish as Me,toNullable as sr}from"@junobuild/utils";var Lt={Db:null},er={Storage:null},tr={Public:null},rr={Private:null},nr={Managed:null},or={Controllers:null},ke={Heap:null},ir={Stable:null};var $e=e=>e==="storage"?er:Lt,lr=({read:e,write:t,memory:r,max_size:n,updated_at:o,mutablePermissions:i})=>({read:cr(e),write:cr(t),memory:Me(r)?[Hr(r)]:[],updated_at:zr(o)?[]:[o],max_size:sr(Me(n)&&n>0?BigInt(n):void 0),mutable_permissions:sr(i)}),ur=([e,t])=>{let{read:r,write:n,updated_at:o,created_at:i,max_size:s,memory:l,mutable_permissions:u}=t,c=s?.[0]??0n>0n?Number(Be(s)):void 0;return{collection:e,read:ar(r),write:ar(n),memory:Kr(Be(l)??ke),updated_at:o,created_at:i,...Me(c)&&{max_size:c},mutablePermissions:Be(u)??!0}},ar=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",cr=e=>{switch(e){case"public":return tr;case"private":return rr;case"managed":return nr;default:return or}},Hr=e=>{switch(e){case"Stable":return ir;default:return ke}},Kr=e=>"Stable"in e?"Stable":"Heap";var Uo=async({config:{storage:{headers:e,rewrites:t,redirects:r,iframe:n}},satellite:o})=>{let i=(e??[]).map(({source:c,headers:d})=>[c,d]),s=(t??[]).map(({source:c,destination:d})=>[c,d]),l=(r??[]).map(({source:c,location:d,code:_})=>[c,{status_code:_,location:d}]);return qt({satellite:o,config:{storage:{headers:i,rewrites:s,redirects:[l],iframe:[n==="same-origin"?{SameOrigin:null}:n==="allow-any"?{AllowAny:null}:{Deny:null}]}}})},qo=async({type:e,satellite:t})=>(await jt({satellite:t,type:$e(e)})).map(n=>ur(n)),jo=async({rule:{collection:e,...t},type:r,satellite:n})=>zt({type:$e(r),rule:lr(t),satellite:n,collection:e}),zo=e=>Ht(e),Ho=e=>Kt(e),Ko=({satellite:{satelliteId:e,...t}})=>Ie({...t,canisterId:e,path:"juno:build"}),Wo=async({satellite:e,wasm_module:t,deprecated:r,deprecatedNoScope:n,reset:o=!1})=>{let{satelliteId:i,...s}=e;if(Jr(i))throw new Error("No satellite principal defined.");if(r){let d=await Wt({satellite:e}),_=F.encode([F.Record({controllers:F.Vec(F.Principal)})],[{controllers:d}]);await G({actor:s,code:{canister_id:pr.fromText(i),arg:new Uint8Array(_),wasm_module:t,mode:o?{reinstall:null}:{upgrade:null}}});return}let u=await(n?Oe:Ee)({satellite:e}),c=Ne(u);await G({actor:s,code:{canister_id:pr.fromText(i),arg:new Uint8Array(c),wasm_module:t,mode:o?{reinstall:null}:{upgrade:null}}})},Jo=async({satellite:e})=>(await Jt({satellite:e})).map(([r,n])=>({domain:r,bn_id:Wr(n.bn_id),created_at:n.created_at,updated_at:n.updated_at})),Go=async({satellite:e,domains:t})=>Promise.all(t.map(({domain:r,bn_id:n})=>Gt({satellite:e,domainName:r,boundaryNodesId:n}))),Yo=e=>Yt(e),Qo=async e=>Qt(e),Xo=async e=>Zt(e),Zo=async e=>Xt(e),Io=async e=>It(e),Do=({deprecatedNoScope:e,...t})=>(e===!0?Oe:Ee)(t),Lo=e=>Dt(e);export{bo as checkUpgradeVersion,Zo as countAssets,Qo as countDocs,Io as deleteAssets,Xo as deleteDocs,Jo as listCustomDomains,ao as listMissionControlControllers,xo as listOrbiterControllers,qo as listRules,Do as listSatelliteControllers,no as missionControlVersion,go as orbiterMemorySize,_o as orbiterVersion,Yo as satelliteMemorySize,zo as satelliteVersion,Ho as satelliteVersionBuild,Ko as satelliteWasmMetadataBuild,Uo as setConfig,Go as setCustomDomains,so as setMissionControlController,jo as setRule,Lo as setSatelliteControllers,io as setSatellitesController,oo as upgradeMissionControl,yo as upgradeOrbiter,Wo as upgradeSatellite};
13
+ `)}return u.encodeValue(c)}));return m(n,o,i,s,l)}function Br(e,t){let r=new U(t);if(t.byteLength<le.length)throw new Error("Message length smaller than magic number");let n=K(r,le.length),o=new TextDecoder().decode(n);if(o!==le)throw new Error("Wrong magic number: "+JSON.stringify(o));function i(a){let p=[],h=Number(R(a));for(let f=0;f<h;f++){let v=Number(q(a));switch(v){case-18:case-19:{let w=Number(q(a));p.push([v,w]);break}case-20:case-21:{let w=[],V=Number(R(a)),P;for(;V--;){let C=Number(R(a));if(C>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof P=="number"&&P>=C)throw new Error("field id collision or not sorted");P=C;let S=Number(q(a));w.push([C,S])}p.push([v,w]);break}case-22:{let w=[],V=Number(R(a));for(;V--;)w.push(Number(q(a)));let P=[],C=Number(R(a));for(;C--;)P.push(Number(q(a)));let S=[],k=Number(R(a));for(;k--;)switch(Number(R(a))){case 1:{S.push("query");break}case 2:{S.push("oneway");break}case 3:{S.push("composite_query");break}default:throw new Error("unknown annotation")}p.push([v,[w,P,S]]);break}case-23:{let w=Number(R(a)),V=[];for(;w--;){let P=Number(R(a)),C=new TextDecoder().decode(K(a,P)),S=q(a);V.push([C,S])}p.push([v,V]);break}default:throw new Error("Illegal op_code: "+v)}}let y=[],x=Number(R(a));for(let f=0;f<x;f++)y.push(Number(q(a)));return[p,y]}let[s,l]=i(r);if(l.length<e.length)throw new Error("Wrong number of return values");let u=s.map(a=>Ft());function c(a){if(a<-24)throw new Error("future value not supported");if(a<0)switch(a){case-1:return ut;case-2:return lt;case-3:return mt;case-4:return dt;case-5:return Tt;case-6:return wt;case-7:return bt;case-8:return Nt;case-9:return _t;case-10:return yt;case-11:return gt;case-12:return xt;case-13:return ht;case-14:return ft;case-15:return pt;case-16:return ct;case-17:return at;case-24:return vt;default:throw new Error("Illegal op_code: "+a)}if(a>=s.length)throw new Error("type index out of range");return u[a]}function d(a){switch(a[0]){case-19:{let p=c(a[1]);return Vt(p)}case-18:{let p=c(a[1]);return Rt(p)}case-20:{let p={};for(let[x,f]of a[1]){let v=`_${x}_`;p[v]=c(f)}let h=St(p),y=h.tryAsTuple();return Array.isArray(y)?Pt(...y):h}case-21:{let p={};for(let[h,y]of a[1]){let x=`_${h}_`;p[x]=c(y)}return Ct(p)}case-22:{let[p,h,y]=a[1];return At(p.map(x=>c(x)),h.map(x=>c(x)),y)}case-23:{let p={},h=a[1];for(let[y,x]of h){let f=c(x);if(f instanceof W&&(f=f.getType()),!(f instanceof se))throw new Error("Illegal service definition: services can only contain functions");p[y]=f}return Ot(p)}default:throw new Error("Illegal op_code: "+a[0])}}s.forEach((a,p)=>{if(a[0]===-22){let h=d(a);u[p].fill(h)}}),s.forEach((a,p)=>{if(a[0]!==-22){let h=d(a);u[p].fill(h)}});let _=l.map(a=>c(a)),g=e.map((a,p)=>a.decodeValue(r,_[p]));for(let a=e.length;a<_.length;a++)_[a].decodeValue(r,_[a]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return g}var at=new pe,ct=new X,Mr=new de,lt=new me,ut=new he,pt=new fe,dt=new _e,mt=new ye,ht=new oe(32),ft=new oe(64),_t=new j(8),yt=new j(16),gt=new j(32),xt=new j(64),Tt=new M(8),wt=new M(16),bt=new M(32),Nt=new M(64),vt=new we;function Pt(...e){return new xe(e)}function Vt(e){return new ge(e)}function Rt(e){return new Z(e)}function St(e){return new ie(e)}function Ct(e){return new Te(e)}function Ft(){return new W}function At(e,t,r=[]){return new se(e,t,r)}function Ot(e){return new be(e)}import{Principal as Hn}from"@dfinity/principal";var Et=e=>F.encode([F.Record({user:F.Principal})],[{user:e}]),Ne=e=>F.encode([F.Record({controllers:F.Vec(F.Principal)})],[{controllers:e.map(([t,r])=>t)}]);var oo=async e=>De(e),io=async({missionControl:e,wasm_module:t})=>{let r=await Le({missionControl:e}),{missionControlId:n,...o}=e;if(!n)throw new Error("No mission control principal defined.");let i=Et(r);await G({actor:o,code:{canister_id:Ur.fromText(n),arg:new Uint8Array(i),wasm_module:t,mode:{upgrade:null}}})},so=async({controllerId:e,profile:t,...r})=>tt({...r,...Ve({controllerId:e,profile:t})}),ao=async({controllerId:e,profile:t,...r})=>rt({...r,...Ve({controllerId:e,profile:t})}),co=e=>et(e);import{Principal as qr}from"@dfinity/principal";var kt=async({orbiter:e})=>(await ae(e)).version(),Ae=async({orbiter:e})=>(await ae(e)).list_controllers(),Bt=async({orbiter:e})=>{let{memory_size:t}=await ae(e);return t()};var yo=async e=>kt(e),go=async({orbiter:e,wasm_module:t,reset:r=!1})=>{let{orbiterId:n,...o}=e;if(!n)throw new Error("No orbiter principal defined.");let i=await Ae({orbiter:e}),s=Ne(i);await G({actor:o,code:{canister_id:qr.fromText(n),arg:new Uint8Array(s),wasm_module:t,mode:r?{reinstall:null}:{upgrade:null}}})},xo=e=>Bt(e),To=e=>Ae(e);import{major as Mt,minor as $t,patch as Ut}from"semver";var No=({currentVersion:e,selectedVersion:t})=>{let r=Mt(e),n=Mt(t),o=$t(e),i=$t(t),s=Ut(e),l=Ut(t);return r<n-1||o<i-1||s<l-1?{canUpgrade:!1}:{canUpgrade:!0}};import{Principal as pr}from"@dfinity/principal";import{fromNullable as Wr,isNullish as Jr,nonNullish as Gr}from"@junobuild/utils";import{toNullable as jr}from"@junobuild/utils";var qt=async({config:e,satellite:t})=>(await O(t)).set_config(e),jt=async({satellite:e,type:t})=>(await O(e)).list_rules(t),zt=async({type:e,collection:t,rule:r,satellite:n})=>(await O(n)).set_rule(e,t,r),Ht=async({satellite:e})=>{let{version:t}=await O(e);return t()},Kt=async({satellite:e})=>{let{version_build:t}=await O(e);return t()},Wt=async({satellite:e})=>(await Ye(e)).list_controllers(),Oe=async({satellite:e})=>(await Qe(e)).list_controllers(),Ee=async({satellite:e})=>(await O(e)).list_controllers(),Jt=async({satellite:e})=>{let{list_custom_domains:t}=await O(e);return t()},Gt=async({satellite:e,domainName:t,boundaryNodesId:r})=>{let{set_custom_domain:n}=await O(e);await n(t,jr(r))},Yt=async({satellite:e})=>{let{memory_size:t}=await O(e);return t()},Qt=async({collection:e,satellite:t})=>{let{count_docs:r}=await O(t);return r(e)},Xt=async({collection:e,satellite:t})=>{let{count_assets:r}=await O(t);return r(e)},Zt=async({collection:e,satellite:t})=>{let{del_docs:r}=await O(t);return r(e)},It=async({collection:e,satellite:t})=>{let{del_assets:r}=await O(t);return r(e)},Dt=async({args:e,satellite:t})=>{let{set_controllers:r}=await O(t);return r(e)};import{fromNullable as Be,isNullish as zr,nonNullish as Me,toNullable as sr}from"@junobuild/utils";var Lt={Db:null},er={Storage:null},tr={Public:null},rr={Private:null},nr={Managed:null},or={Controllers:null},ke={Heap:null},ir={Stable:null};var $e=e=>e==="storage"?er:Lt,lr=({read:e,write:t,memory:r,max_size:n,updated_at:o,mutablePermissions:i})=>({read:cr(e),write:cr(t),memory:Me(r)?[Hr(r)]:[],updated_at:zr(o)?[]:[o],max_size:sr(Me(n)&&n>0?BigInt(n):void 0),mutable_permissions:sr(i)}),ur=([e,t])=>{let{read:r,write:n,updated_at:o,created_at:i,max_size:s,memory:l,mutable_permissions:u}=t,c=s?.[0]??0n>0n?Number(Be(s)):void 0;return{collection:e,read:ar(r),write:ar(n),memory:Kr(Be(l)??ke),updated_at:o,created_at:i,...Me(c)&&{max_size:c},mutablePermissions:Be(u)??!0}},ar=e=>"Public"in e?"public":"Private"in e?"private":"Managed"in e?"managed":"controllers",cr=e=>{switch(e){case"public":return tr;case"private":return rr;case"managed":return nr;default:return or}},Hr=e=>{switch(e){case"Stable":return ir;default:return ke}},Kr=e=>"Stable"in e?"Stable":"Heap";var qo=async({config:{storage:{headers:e,rewrites:t,redirects:r,iframe:n}},satellite:o})=>{let i=(e??[]).map(({source:c,headers:d})=>[c,d]),s=(t??[]).map(({source:c,destination:d})=>[c,d]),l=(r??[]).map(({source:c,location:d,code:_})=>[c,{status_code:_,location:d}]);return qt({satellite:o,config:{storage:{headers:i,rewrites:s,redirects:[l],iframe:[n==="same-origin"?{SameOrigin:null}:n==="allow-any"?{AllowAny:null}:{Deny:null}]}}})},jo=async({type:e,satellite:t})=>(await jt({satellite:t,type:$e(e)})).map(n=>ur(n)),zo=async({rule:{collection:e,...t},type:r,satellite:n})=>zt({type:$e(r),rule:lr(t),satellite:n,collection:e}),Ho=e=>Ht(e),Ko=e=>Kt(e),Wo=async({satellite:{satelliteId:e,...t}})=>{let r=await Ie({...t,canisterId:e,path:"juno:build"});return Gr(r)&&["stock","extended"].includes(r)?r:void 0},Jo=async({satellite:e,wasm_module:t,deprecated:r,deprecatedNoScope:n,reset:o=!1})=>{let{satelliteId:i,...s}=e;if(Jr(i))throw new Error("No satellite principal defined.");if(r){let d=await Wt({satellite:e}),_=F.encode([F.Record({controllers:F.Vec(F.Principal)})],[{controllers:d}]);await G({actor:s,code:{canister_id:pr.fromText(i),arg:new Uint8Array(_),wasm_module:t,mode:o?{reinstall:null}:{upgrade:null}}});return}let u=await(n?Oe:Ee)({satellite:e}),c=Ne(u);await G({actor:s,code:{canister_id:pr.fromText(i),arg:new Uint8Array(c),wasm_module:t,mode:o?{reinstall:null}:{upgrade:null}}})},Go=async({satellite:e})=>(await Jt({satellite:e})).map(([r,n])=>({domain:r,bn_id:Wr(n.bn_id),created_at:n.created_at,updated_at:n.updated_at})),Yo=async({satellite:e,domains:t})=>Promise.all(t.map(({domain:r,bn_id:n})=>Gt({satellite:e,domainName:r,boundaryNodesId:n}))),Qo=e=>Yt(e),Xo=async e=>Qt(e),Zo=async e=>Zt(e),Io=async e=>Xt(e),Do=async e=>It(e),Lo=({deprecatedNoScope:e,...t})=>(e===!0?Oe:Ee)(t),ei=e=>Dt(e);export{No as checkUpgradeVersion,Io as countAssets,Xo as countDocs,Do as deleteAssets,Zo as deleteDocs,Go as listCustomDomains,co as listMissionControlControllers,To as listOrbiterControllers,jo as listRules,Lo as listSatelliteControllers,oo as missionControlVersion,xo as orbiterMemorySize,yo as orbiterVersion,Wo as satelliteBuildType,Qo as satelliteMemorySize,Ho as satelliteVersion,Ko as satelliteVersionBuild,qo as setConfig,Yo as setCustomDomains,ao as setMissionControlController,zo as setRule,ei as setSatelliteControllers,so as setSatellitesController,io as upgradeMissionControl,go as upgradeOrbiter,Jo as upgradeSatellite};
14
14
  //# sourceMappingURL=index.js.map