@chirper/node 0.0.83 → 0.0.85
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bundle.js +1 -1
- package/package.json +1 -1
- package/src/api/Chirper.ts +28 -0
- package/src/api/Item.ts +14 -0
- package/src/index.ts +2 -0
package/dist/bundle.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var ht=Object.create;var S=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var dt=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var D=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),pt=(i,t)=>{for(var e in t)S(i,e,{get:t[e],enumerable:!0})},F=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ct(t))!ft.call(i,o)&&o!==e&&S(i,o,{get:()=>t[o],enumerable:!(r=at(t,o))||r.enumerable});return i};var C=(i,t,e)=>(e=i!=null?ht(dt(i)):{},F(t||!i||!i.__esModule?S(e,"default",{value:i,enumerable:!0}):e,i)),gt=i=>F(S({},"__esModule",{value:!0}),i);var T=D((yt,k)=>{var U=(()=>{var i=Object.defineProperty,t=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,o=(f,c,g)=>c in f?i(f,c,{enumerable:!0,configurable:!0,writable:!0,value:g}):f[c]=g,l=(f,c)=>{for(var g in c||(c={}))e.call(c,g)&&o(f,g,c[g]);if(t)for(var g of t(c))r.call(c,g)&&o(f,g,c[g]);return f},u=f=>i(f,"__esModule",{value:!0}),m=(f,c)=>{u(f);for(var g in c)i(f,g,{get:c[g],enumerable:!0})},s={};m(s,{DEFAULT_UUID_LENGTH:()=>v,default:()=>y});var w="4.4.4",v=6,h={dictionary:"alphanum",shuffle:!0,debug:!1,length:v},b=class extends Function{constructor(f={}){super(),this.dictIndex=0,this.dictRange=[],this.lowerBound=0,this.upperBound=0,this.dictLength=0,this._digit_first_ascii=48,this._digit_last_ascii=58,this._alpha_lower_first_ascii=97,this._alpha_lower_last_ascii=123,this._hex_last_ascii=103,this._alpha_upper_first_ascii=65,this._alpha_upper_last_ascii=91,this._number_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii]},this._alpha_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alpha_lower_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alpha_upper_dict_ranges={upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_lower_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alphanum_upper_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._hex_dict_ranges={decDigits:[this._digit_first_ascii,this._digit_last_ascii],alphaDigits:[this._alpha_lower_first_ascii,this._hex_last_ascii]},this.log=(...n)=>{let a=[...n];if(a[0]=`[short-unique-id] ${n[0]}`,this.debug===!0&&typeof console<"u"&&console!==null)return console.log(...a)},this.setDictionary=(n,a)=>{let d;if(n&&Array.isArray(n)&&n.length>1)d=n;else{d=[];let _;this.dictIndex=_=0;let x=`_${n}_dict_ranges`,P=this[x];Object.keys(P).forEach(ut=>{let lt=ut;for(this.dictRange=P[lt],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=_=this.lowerBound;this.lowerBound<=this.upperBound?_<this.upperBound:_>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?_+=1:_-=1)d.push(String.fromCharCode(this.dictIndex))})}a&&(d=d.sort(()=>Math.random()-.5)),this.dict=d,this.dictLength=this.dict.length,this.counter=0},this.seq=()=>this.sequentialUUID(),this.sequentialUUID=()=>{let n,a,d="";n=this.counter;do a=n%this.dictLength,n=Math.trunc(n/this.dictLength),d+=this.dict[a];while(n!==0);return this.counter+=1,d},this.randomUUID=(n=this.uuidLength||v)=>{let a,d,_;if(n===null||typeof n>"u"||n<1)throw new Error("Invalid UUID Length Provided");let x=n>=0;for(a="",_=0;_<n;_+=1)d=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,a+=this.dict[d];return a},this.availableUUIDs=(n=this.uuidLength)=>parseFloat(Math.pow([...new Set(this.dict)].length,n).toFixed(0)),this.approxMaxBeforeCollision=(n=this.availableUUIDs(this.uuidLength))=>parseFloat(Math.sqrt(Math.PI/2*n).toFixed(20)),this.collisionProbability=(n=this.availableUUIDs(this.uuidLength),a=this.uuidLength)=>parseFloat((this.approxMaxBeforeCollision(n)/this.availableUUIDs(a)).toFixed(20)),this.uniqueness=(n=this.availableUUIDs(this.uuidLength))=>{let a=parseFloat((1-this.approxMaxBeforeCollision(n)/n).toFixed(20));return a>1?1:a<0?0:a},this.getVersion=()=>this.version,this.stamp=n=>{if(typeof n!="number"||n<10)throw new Error("Param finalLength must be number greater than 10");let a=Math.floor(+new Date/1e3).toString(16),d=n-9,_=Math.round(Math.random()*(d>15?15:d)),x=this.randomUUID(d);return`${x.substr(0,_)}${a}${x.substr(_)}${_.toString(16)}`},this.parseStamp=n=>{if(n.length<10)throw new Error("Stamp length invalid");let a=parseInt(n.substr(n.length-1,1),16);return new Date(parseInt(n.substr(a,8),16)*1e3)};let c=l(l({},h),f);this.counter=0,this.debug=!1,this.dict=[],this.version=w;let{dictionary:g,shuffle:nt,length:ot}=c;return this.uuidLength=ot,this.setDictionary(g,nt),this.debug=c.debug,this.log(this.dict),this.log(`Generator instantiated with Dictionary Size ${this.dictLength}`),new Proxy(this,{apply:(n,a,d)=>this.randomUUID(...d)})}},y=b;return y.default=b,s})();typeof k<"u"&&(k.exports=U.default),typeof window<"u"&&(U=U.default)});var B=D((xt,E)=>{"use strict";var _t=Object.prototype.hasOwnProperty,$="~";function O(){}Object.create&&(O.prototype=Object.create(null),new O().__proto__||($=!1));function $t(i,t,e){this.fn=i,this.context=t,this.once=e||!1}function A(i,t,e,r,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var l=new $t(e,r||i,o),u=$?$+t:t;return i._events[u]?i._events[u].fn?i._events[u]=[i._events[u],l]:i._events[u].push(l):(i._events[u]=l,i._eventsCount++),i}function I(i,t){--i._eventsCount===0?i._events=new O:delete i._events[t]}function p(){this._events=new O,this._eventsCount=0}p.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)_t.call(e,r)&&t.push($?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};p.prototype.listeners=function(t){var e=$?$+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,l=r.length,u=new Array(l);o<l;o++)u[o]=r[o].fn;return u};p.prototype.listenerCount=function(t){var e=$?$+t:t,r=this._events[e];return r?r.fn?1:r.length:0};p.prototype.emit=function(t,e,r,o,l,u){var m=$?$+t:t;if(!this._events[m])return!1;var s=this._events[m],w=arguments.length,v,h;if(s.fn){switch(s.once&&this.removeListener(t,s.fn,void 0,!0),w){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,e),!0;case 3:return s.fn.call(s.context,e,r),!0;case 4:return s.fn.call(s.context,e,r,o),!0;case 5:return s.fn.call(s.context,e,r,o,l),!0;case 6:return s.fn.call(s.context,e,r,o,l,u),!0}for(h=1,v=new Array(w-1);h<w;h++)v[h-1]=arguments[h];s.fn.apply(s.context,v)}else{var b=s.length,y;for(h=0;h<b;h++)switch(s[h].once&&this.removeListener(t,s[h].fn,void 0,!0),w){case 1:s[h].fn.call(s[h].context);break;case 2:s[h].fn.call(s[h].context,e);break;case 3:s[h].fn.call(s[h].context,e,r);break;case 4:s[h].fn.call(s[h].context,e,r,o);break;default:if(!v)for(y=1,v=new Array(w-1);y<w;y++)v[y-1]=arguments[y];s[h].fn.apply(s[h].context,v)}}return!0};p.prototype.on=function(t,e,r){return A(this,t,e,r,!1)};p.prototype.once=function(t,e,r){return A(this,t,e,r,!0)};p.prototype.removeListener=function(t,e,r,o){var l=$?$+t:t;if(!this._events[l])return this;if(!e)return I(this,l),this;var u=this._events[l];if(u.fn)u.fn===e&&(!o||u.once)&&(!r||u.context===r)&&I(this,l);else{for(var m=0,s=[],w=u.length;m<w;m++)(u[m].fn!==e||o&&!u[m].once||r&&u[m].context!==r)&&s.push(u[m]);s.length?this._events[l]=s.length===1?s[0]:s:I(this,l)}return this};p.prototype.removeAllListeners=function(t){var e;return t?(e=$?$+t:t,this._events[e]&&I(this,e)):(this._events=new O,this._eventsCount=0),this};p.prototype.off=p.prototype.removeListener;p.prototype.addListener=p.prototype.on;p.prefixed=$;p.EventEmitter=p;typeof E<"u"&&(E.exports=p)});var vt={};pt(vt,{default:()=>L});module.exports=gt(vt);var et=C(require("pako")),it=C(T()),rt=C(require("socket.io-client")),st=require("compress-json");var N=C(B(),1);var J=i=>({prompt:t=>i.post("/:account/ai",t),image:t=>i.post("/:account/ai/image",t)});var M=i=>({get:(t,e={})=>i.get(`/user/${t}`,e),list:(t={})=>i.get("/user",t),image:(t,e={})=>i.post(`/user/${t?.id||t}/image`,e),update:(t={})=>i.patch(`/user/${t.id}`,t),validate:(t,e,r)=>i.get("/user/value",{key:e,value:r,user:t?.id}),password:(t,e,r)=>i.patch("/user/password",{password:t,newPassword:e,newPassword2:r}),username:(t,e=null)=>i.post("/user/username",{username:t,id:e?.id||e}),suggestion:(t={})=>i.get("/user/suggestion",t),Pin:{list:(t={})=>i.get("/user/pin",t),create:(t={})=>i.post("/user/pin",t),update:(t={})=>i.patch("/user/pin",t),delete:(t={})=>i.delete("/user/pin",t)}});var q=i=>({get:(t,e)=>i.get(`/chat/${t?.id||t}`,e),list:t=>i.get("/chat",t),read:t=>i.get(`/chat/${t?.id||t}/read`),create:(t,e)=>i.post(`/chat/${t?.id||t}`,e),typing:(t,e=!0)=>i.post(`/chat/${t?.id||t}/typing`,{typing:e}),leaveChat:t=>i.delete(`/chat/${t?.id||t}`),readChat:t=>i.post(`/chat/${t?.id||t}/read`),loadMembers:(t,e)=>i.get(`/chat/${t?.id||t}/member`,e),loadMessages:(t,e)=>i.get(`/chat/${t?.id||t}/message`,e),sendMessage:(t,e)=>i.post(`/chat/${t?.id||t}/message`,e),inviteMember:(t,e)=>i.post(`/chat/${t?.id||t}/member`,{member:e?.id||e}),removeMember:(t,e)=>i.delete(`/chat/${t?.id||t}/member/${e?.id||e}`)});var j=i=>({get:(t,e={})=>i.get(`/file/${t?.id||t}`,e),list:(t={})=>i.get("/file",t),modelList:(t={})=>i.get("/file/model",t)});var R=i=>({get:(t,e=null,r=null)=>i.get(`/:account/stat/${t}`,{from:e,to:r})});var K=i=>({code:(t,e)=>i.post("/oauth2/code",{application:t,redirect:e})});var G=i=>({get:(t,e)=>i.get(`/chirp/${t}`,{lang:e},!1,!1),list:(t={})=>i.get("/chirp",t,!1,!1),add:(t,e)=>i.post(`/chirp/${t}/add`,{chirper:e?.id||e}),like:t=>i.post(`/chirp/${t}/like`),dislike:t=>i.post(`/chirp/${t}/dislike`),play:t=>i.post(`/chirp/${t}/play`),view:t=>i.post(`/chirp/${t}/view`),liked:t=>i.get(`/chirp/${t}/like`),count:t=>i.get(`/chirp/${t?.id||t}/count`),delete:t=>i.delete(`/chirp/${t?.id||t}`),create:(t={})=>i.post("/chirp",t),subscribe:t=>i.post(`/chirp/${t?.id||t}/subscribe`),unsubscribe:t=>i.delete(`/chirp/${t?.id||t}/subscribe`)});var H=i=>({get:t=>i.get(`/world/${t}`),list:(t={})=>i.get("/world",t),image:(t,e={})=>i.post(`/world/${t?.id||t}/image`,e),invite:(t,e)=>i.post(`/world/${t?.id||t}/invite`,{chirper:e?.id||e}),remove:(t,e)=>i.post(`/world/${t?.id||t}/remove`,{chirper:e?.id||e}),members:(t,e={})=>i.get(`/world/${t?.id||t}/members`,e),alerts:(t={})=>i.get("/world/alerts",t),create:t=>i.post("/world",t),update:t=>i.patch(`/world/${t?.id}`,t),delete:t=>i.delete(`/world/${t?.id||t}`),restore:t=>i.post(`/world/${t?.id||t}/cancel`),validate:(t,e,r)=>i.get("/world/value",{key:e,value:r,world:t?.id})});var z=i=>({get:(t,e={})=>i.get(`/brain/${t}`,e),list:(t={})=>i.get("/brain",t),run:(t,e={})=>i.post(`/brain/${t?.id||t}/run`,e),create:(t={})=>i.post("/brain",t),update:(t={})=>i.patch(`/brain/${t.id}`,t),delete:t=>i.delete(`/brain/${t?.id||t}`),validate:(t,e,r)=>i.get("/brain/value",{key:e,value:r,brain:t?.id}),Frame:{list:(t,e={})=>i.get(`/brain/${t?.id||t}/frame`,e)}});var V=i=>({like:(t,e={})=>i.post(`/studio/${t?.id||t||"default"}/like`,e),dislike:(t,e={})=>i.post(`/studio/${t?.id||t||"default"}/dislike`,e),liked:(t,e={})=>i.get(`/studio/${t?.id||t||"default"}/like`,e),upload:(t={})=>i.post("/studio/upload",t),complete:(t,e={})=>i.post(`/studio/upload/${t?.id||t||"default"}`,e),generate:(t,e={})=>i.post(`/studio/${t?.id||t||"default"}/generate`,e),Message:{list:(t,e={})=>i.get(`/studio/${t?.id||t||"default"}/message`,e),delete:(t,e,r={})=>i.delete(`/studio/${t?.id||t||"default"}/message/${e?.id||e}`,r)}});var W=i=>({get:t=>i.get(`/follow/${t}`),toggle:t=>i.post(`/follow/${t?.id||t}`)});var Y=i=>({get:(t,e={})=>i.get(`/chirper/${t}`,e),list:(t={})=>i.get("/chirper",t),spec:(t,e)=>i.post(`/chirper/${t?.id||t}/spec`,{type:e}),bump:t=>i.post(`/chirper/${t?.id||t}/bump`),image:(t,e={})=>i.post(`/chirper/${t?.id||t}/image`,e),journal:(t,e)=>i.get(`/chirper/${t?.id||t}/journal`,e),progress:(t,e)=>i.get(`/chirper/${t?.id||t}/progress`,e),username:(t,e=null)=>i.post("/chirper/username",{username:t,id:e?.id||e}),create:(t={})=>i.post("/chirper",t),update:(t={})=>i.patch(`/chirper/${t.id}`,t),delete:t=>i.delete(`/chirper/${t?.id||t}`),toggleRunning:t=>i.post(`/chirper/${t?.id||t}/running`),validate:(t,e,r)=>i.get("/chirper/value",{key:e,value:r,chirper:t?.id}),trip:(t,e={})=>i.get(`/chirper/${t?.id||t}/trip`,e),Trip:{list:(t,e={})=>i.get(`/chirper/${t?.id||t}/trip`,e),get:(t,e={})=>i.get(`/chirper/trip/${t?.id||t}`,e)}});var Q=i=>({list:({lang:t}={})=>i.get("/trending",{lang:t},!1,!1)});var X=i=>({get:t=>i.get(`/category/${t?.id||t}`,{}),list:t=>i.get("/category",t)});var Z=i=>({get:t=>i.get(`/application/${t?.id||t}`,{}),list:t=>i.get("/application",t),create:t=>i.post("/application",t),update:(t,e)=>i.patch(`/application/${t?.id||t}`,e),secret:(t,e)=>i.get(`/application/${t?.id||t}/secret`,e)});var tt=i=>({list:t=>i.get("/notification",t),count:t=>i.get("/notification/count",t),read:t=>i.post("/notification/count",t)});var mt=new it.default({length:10}),L=class{constructor({url:t,version:e,options:r={}}){this.key=null;this.url=null;this.cache={};this.events=new N.default;this.call=null;this.socket=null;this.account=null;this.version="v1";this.loading=!0;this.authing=null;this.authKey=null;this.shareKey=null;this.customer=null;this.presences={};this.connecting=null;this.extraOptions={};this.options={path:"/ws",cors:!0,agent:!0,reconnect:!0,transports:["websocket"],withCredentials:!0};t&&(this.url=t),e&&(this.version=e),r&&(this.extraOptions=r),this.build=this.build.bind(this),this.fetch=this.fetch.bind(this),this.wsFetch=this.wsFetch.bind(this),this.on=this.on.bind(this),this.off=this.off.bind(this),this.emit=this.emit.bind(this),this.once=this.once.bind(this),this.addListener=this.events.addListener.bind(this.events),this.removeListener=this.events.removeListener.bind(this.events),this.get=this.get.bind(this),this.put=this.put.bind(this),this.post=this.post.bind(this),this.patch=this.patch.bind(this),this.delete=this.delete.bind(this),this.AI=J(this),this.File=j(this),this.User=M(this),this.Chat=q(this),this.Stat=R(this),this.OAuth=K(this),this.Chirp=G(this),this.Brain=z(this),this.World=H(this),this.Studio=V(this),this.Follow=W(this),this.Chirper=Y(this),this.Trending=Q(this),this.Category=X(this),this.Application=Z(this),this.Notification=tt(this),this.build()}build(){if(this.__resolveConnecting=null,this.connecting=new Promise(r=>{this.__resolveConnecting=r}),!this.url)return;let t={...this.options,...this.extraOptions};t.query||(t.query={}),t.query.compression=!0;let e=rt.default.connect(`${this.url}`,t);e.on("connect",async(...r)=>{this.authing||(this.authing=this.auth(this.authKey,this.shareKey),await this.authing,this.authing=null,this.__resolveConnecting())}),e.on("disconnect",()=>{this.connecting=new Promise(r=>{this.__resolveConnecting=r})}),this.socket=e}async auth(t){!t&&this.user&&(t=this.user),t||(this.loading=!0,this.events.emit("loading",!0),t=(await this.get("/auth",{key:this.key},!1,!1))?.user),t&&(this.user=t,this.events.emit("user",t)),this.loading=!1,this.events.emit("loading",!1),typeof window<"u"&&(window.chirper=this)}async fetch(t,e,r={},o=!1){if(["patch","put","delete","post"].includes(t.toLowerCase())&&(o=!1),o&&this.cache[`${t}${e}${JSON.stringify(r)}`])return this.cache[`${t}${e}${JSON.stringify(r)}`];delete this.cache[`${t}${e}${JSON.stringify(r)}`],console.time(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(r)}`),Object.keys(r).forEach(u=>{r[u]===void 0&&delete r[u]});let l;try{l=await(await fetch(`${this.url}/${this.version}${e}${`${t}`.toLowerCase()==="get"?`?${new URLSearchParams(r)}`:""}`,{body:`${t}`.toLowerCase()!=="get"?JSON.stringify(r):void 0,headers:{"Content-Type":"application/json",Authentication:this.key?`Bearer ${this.key}`:void 0},credentials:"include"})).json()}catch(u){throw console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(r)}`),u}if(console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(r)}`),!l?.success)throw new Error(l.message);return o&&(this.cache[`${t}${e}${JSON.stringify(r)}`]=l,this.cache[`${t}${e}${JSON.stringify(r)}`].then(()=>{typeof o=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(r)}`]},o):delete this.cache[`${t}${e}${JSON.stringify(r)}`]})),l.result}async wsFetch(t,e,r={},o=!1,l=!0){if(l&&await this.connecting,l&&await this.authing,["patch","put","delete","post"].includes(t.toLowerCase())&&(o=!1),o&&this.cache[`${t}${e}${JSON.stringify(r)}`])return this.cache[`${t}${e}${JSON.stringify(r)}`];delete this.cache[`${t}${e}${JSON.stringify(r)}`];let u=mt();console.time(`[chirper] [${u}] ${t}:${e} ${JSON.stringify(r)}`);let m=new Promise((s,w)=>{this.socket.once(u,v=>{let h=et.default.ungzip(v,{to:"string"}),{success:b,result:y,message:f,time:c}=(0,st.decompress)(JSON.parse(h));if(console.timeEnd(`[chirper] [${u}] ${t}:${e} ${JSON.stringify(r)}`),console.log(`[chirper] [${u}] backend time ${c}ms`),b)return s(y);w(f)})});return o&&(this.cache[`${t}${e}${JSON.stringify(r)}`]=m,this.cache[`${t}${e}${JSON.stringify(r)}`].then(()=>{typeof o=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(r)}`]},o):delete this.cache[`${t}${e}${JSON.stringify(r)}`]})),this.socket.emit("call",u,t.toUpperCase(),e,r),m}on(...t){this.socket.on(...t)}off(...t){this.socket.off(...t)}emit(...t){this.socket.emit(...t)}once(...t){this.socket.once(...t)}get(t,e,...r){return this.wsFetch("GET",`/${this.version}${t}`,e,...r)}put(t,e,...r){return this.wsFetch("PUT",`/${this.version}${t}`,e,...r)}post(t,e,...r){return this.wsFetch("POST",`/${this.version}${t}`,e,...r)}patch(t,e,...r){return this.wsFetch("PATCH",`/${this.version}${t}`,e,...r)}delete(t,e,...r){return this.wsFetch("DELETE",`/${this.version}${t}`,e,...r)}};
|
1
|
+
var ct=Object.create;var S=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var ft=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty;var D=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),gt=(r,t)=>{for(var e in t)S(r,e,{get:t[e],enumerable:!0})},F=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of dt(t))!pt.call(r,o)&&o!==e&&S(r,o,{get:()=>t[o],enumerable:!(i=at(t,o))||i.enumerable});return r};var C=(r,t,e)=>(e=r!=null?ct(ft(r)):{},F(t||!r||!r.__esModule?S(e,"default",{value:r,enumerable:!0}):e,r)),_t=r=>F(S({},"__esModule",{value:!0}),r);var A=D((bt,k)=>{var U=(()=>{var r=Object.defineProperty,t=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,o=(f,a,g)=>a in f?r(f,a,{enumerable:!0,configurable:!0,writable:!0,value:g}):f[a]=g,l=(f,a)=>{for(var g in a||(a={}))e.call(a,g)&&o(f,g,a[g]);if(t)for(var g of t(a))i.call(a,g)&&o(f,g,a[g]);return f},u=f=>r(f,"__esModule",{value:!0}),m=(f,a)=>{u(f);for(var g in a)r(f,g,{get:a[g],enumerable:!0})},s={};m(s,{DEFAULT_UUID_LENGTH:()=>v,default:()=>y});var w="4.4.4",v=6,h={dictionary:"alphanum",shuffle:!0,debug:!1,length:v},b=class extends Function{constructor(f={}){super(),this.dictIndex=0,this.dictRange=[],this.lowerBound=0,this.upperBound=0,this.dictLength=0,this._digit_first_ascii=48,this._digit_last_ascii=58,this._alpha_lower_first_ascii=97,this._alpha_lower_last_ascii=123,this._hex_last_ascii=103,this._alpha_upper_first_ascii=65,this._alpha_upper_last_ascii=91,this._number_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii]},this._alpha_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alpha_lower_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alpha_upper_dict_ranges={upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_lower_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alphanum_upper_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._hex_dict_ranges={decDigits:[this._digit_first_ascii,this._digit_last_ascii],alphaDigits:[this._alpha_lower_first_ascii,this._hex_last_ascii]},this.log=(...n)=>{let c=[...n];if(c[0]=`[short-unique-id] ${n[0]}`,this.debug===!0&&typeof console<"u"&&console!==null)return console.log(...c)},this.setDictionary=(n,c)=>{let d;if(n&&Array.isArray(n)&&n.length>1)d=n;else{d=[];let _;this.dictIndex=_=0;let x=`_${n}_dict_ranges`,P=this[x];Object.keys(P).forEach(lt=>{let ht=lt;for(this.dictRange=P[ht],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=_=this.lowerBound;this.lowerBound<=this.upperBound?_<this.upperBound:_>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?_+=1:_-=1)d.push(String.fromCharCode(this.dictIndex))})}c&&(d=d.sort(()=>Math.random()-.5)),this.dict=d,this.dictLength=this.dict.length,this.counter=0},this.seq=()=>this.sequentialUUID(),this.sequentialUUID=()=>{let n,c,d="";n=this.counter;do c=n%this.dictLength,n=Math.trunc(n/this.dictLength),d+=this.dict[c];while(n!==0);return this.counter+=1,d},this.randomUUID=(n=this.uuidLength||v)=>{let c,d,_;if(n===null||typeof n>"u"||n<1)throw new Error("Invalid UUID Length Provided");let x=n>=0;for(c="",_=0;_<n;_+=1)d=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,c+=this.dict[d];return c},this.availableUUIDs=(n=this.uuidLength)=>parseFloat(Math.pow([...new Set(this.dict)].length,n).toFixed(0)),this.approxMaxBeforeCollision=(n=this.availableUUIDs(this.uuidLength))=>parseFloat(Math.sqrt(Math.PI/2*n).toFixed(20)),this.collisionProbability=(n=this.availableUUIDs(this.uuidLength),c=this.uuidLength)=>parseFloat((this.approxMaxBeforeCollision(n)/this.availableUUIDs(c)).toFixed(20)),this.uniqueness=(n=this.availableUUIDs(this.uuidLength))=>{let c=parseFloat((1-this.approxMaxBeforeCollision(n)/n).toFixed(20));return c>1?1:c<0?0:c},this.getVersion=()=>this.version,this.stamp=n=>{if(typeof n!="number"||n<10)throw new Error("Param finalLength must be number greater than 10");let c=Math.floor(+new Date/1e3).toString(16),d=n-9,_=Math.round(Math.random()*(d>15?15:d)),x=this.randomUUID(d);return`${x.substr(0,_)}${c}${x.substr(_)}${_.toString(16)}`},this.parseStamp=n=>{if(n.length<10)throw new Error("Stamp length invalid");let c=parseInt(n.substr(n.length-1,1),16);return new Date(parseInt(n.substr(c,8),16)*1e3)};let a=l(l({},h),f);this.counter=0,this.debug=!1,this.dict=[],this.version=w;let{dictionary:g,shuffle:ot,length:ut}=a;return this.uuidLength=ut,this.setDictionary(g,ot),this.debug=a.debug,this.log(this.dict),this.log(`Generator instantiated with Dictionary Size ${this.dictLength}`),new Proxy(this,{apply:(n,c,d)=>this.randomUUID(...d)})}},y=b;return y.default=b,s})();typeof k<"u"&&(k.exports=U.default),typeof window<"u"&&(U=U.default)});var B=D((Ot,E)=>{"use strict";var $t=Object.prototype.hasOwnProperty,$="~";function O(){}Object.create&&(O.prototype=Object.create(null),new O().__proto__||($=!1));function mt(r,t,e){this.fn=r,this.context=t,this.once=e||!1}function T(r,t,e,i,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var l=new mt(e,i||r,o),u=$?$+t:t;return r._events[u]?r._events[u].fn?r._events[u]=[r._events[u],l]:r._events[u].push(l):(r._events[u]=l,r._eventsCount++),r}function I(r,t){--r._eventsCount===0?r._events=new O:delete r._events[t]}function p(){this._events=new O,this._eventsCount=0}p.prototype.eventNames=function(){var t=[],e,i;if(this._eventsCount===0)return t;for(i in e=this._events)$t.call(e,i)&&t.push($?i.slice(1):i);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};p.prototype.listeners=function(t){var e=$?$+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var o=0,l=i.length,u=new Array(l);o<l;o++)u[o]=i[o].fn;return u};p.prototype.listenerCount=function(t){var e=$?$+t:t,i=this._events[e];return i?i.fn?1:i.length:0};p.prototype.emit=function(t,e,i,o,l,u){var m=$?$+t:t;if(!this._events[m])return!1;var s=this._events[m],w=arguments.length,v,h;if(s.fn){switch(s.once&&this.removeListener(t,s.fn,void 0,!0),w){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,e),!0;case 3:return s.fn.call(s.context,e,i),!0;case 4:return s.fn.call(s.context,e,i,o),!0;case 5:return s.fn.call(s.context,e,i,o,l),!0;case 6:return s.fn.call(s.context,e,i,o,l,u),!0}for(h=1,v=new Array(w-1);h<w;h++)v[h-1]=arguments[h];s.fn.apply(s.context,v)}else{var b=s.length,y;for(h=0;h<b;h++)switch(s[h].once&&this.removeListener(t,s[h].fn,void 0,!0),w){case 1:s[h].fn.call(s[h].context);break;case 2:s[h].fn.call(s[h].context,e);break;case 3:s[h].fn.call(s[h].context,e,i);break;case 4:s[h].fn.call(s[h].context,e,i,o);break;default:if(!v)for(y=1,v=new Array(w-1);y<w;y++)v[y-1]=arguments[y];s[h].fn.apply(s[h].context,v)}}return!0};p.prototype.on=function(t,e,i){return T(this,t,e,i,!1)};p.prototype.once=function(t,e,i){return T(this,t,e,i,!0)};p.prototype.removeListener=function(t,e,i,o){var l=$?$+t:t;if(!this._events[l])return this;if(!e)return I(this,l),this;var u=this._events[l];if(u.fn)u.fn===e&&(!o||u.once)&&(!i||u.context===i)&&I(this,l);else{for(var m=0,s=[],w=u.length;m<w;m++)(u[m].fn!==e||o&&!u[m].once||i&&u[m].context!==i)&&s.push(u[m]);s.length?this._events[l]=s.length===1?s[0]:s:I(this,l)}return this};p.prototype.removeAllListeners=function(t){var e;return t?(e=$?$+t:t,this._events[e]&&I(this,e)):(this._events=new O,this._eventsCount=0),this};p.prototype.off=p.prototype.removeListener;p.prototype.addListener=p.prototype.on;p.prefixed=$;p.EventEmitter=p;typeof E<"u"&&(E.exports=p)});var wt={};gt(wt,{default:()=>L});module.exports=_t(wt);var rt=C(require("pako")),it=C(A()),st=C(require("socket.io-client")),nt=require("compress-json");var N=C(B(),1);var J=r=>({prompt:t=>r.post("/:account/ai",t),image:t=>r.post("/:account/ai/image",t)});var M=r=>({get:(t,e={})=>r.get(`/user/${t}`,e),list:(t={})=>r.get("/user",t),image:(t,e={})=>r.post(`/user/${t?.id||t}/image`,e),update:(t={})=>r.patch(`/user/${t.id}`,t),validate:(t,e,i)=>r.get("/user/value",{key:e,value:i,user:t?.id}),password:(t,e,i)=>r.patch("/user/password",{password:t,newPassword:e,newPassword2:i}),username:(t,e=null)=>r.post("/user/username",{username:t,id:e?.id||e}),suggestion:(t={})=>r.get("/user/suggestion",t),Pin:{list:(t={})=>r.get("/user/pin",t),create:(t={})=>r.post("/user/pin",t),update:(t={})=>r.patch("/user/pin",t),delete:(t={})=>r.delete("/user/pin",t)}});var q=r=>({get:(t,e)=>r.get(`/chat/${t?.id||t}`,e),list:t=>r.get("/chat",t),read:t=>r.get(`/chat/${t?.id||t}/read`),create:(t,e)=>r.post(`/chat/${t?.id||t}`,e),typing:(t,e=!0)=>r.post(`/chat/${t?.id||t}/typing`,{typing:e}),leaveChat:t=>r.delete(`/chat/${t?.id||t}`),readChat:t=>r.post(`/chat/${t?.id||t}/read`),loadMembers:(t,e)=>r.get(`/chat/${t?.id||t}/member`,e),loadMessages:(t,e)=>r.get(`/chat/${t?.id||t}/message`,e),sendMessage:(t,e)=>r.post(`/chat/${t?.id||t}/message`,e),inviteMember:(t,e)=>r.post(`/chat/${t?.id||t}/member`,{member:e?.id||e}),removeMember:(t,e)=>r.delete(`/chat/${t?.id||t}/member/${e?.id||e}`)});var j=r=>({get:(t,e={})=>r.get(`/file/${t?.id||t}`,e),list:(t={})=>r.get("/file",t),modelList:(t={})=>r.get("/file/model",t)});var R=r=>({get:(t,e=null,i=null)=>r.get(`/:account/stat/${t}`,{from:e,to:i})});var K=r=>({get:(t,e={})=>r.get(`/item/${t?.id||t}`,e),list:(t={})=>r.get("/item",t)});var G=r=>({code:(t,e)=>r.post("/oauth2/code",{application:t,redirect:e})});var H=r=>({get:(t,e)=>r.get(`/chirp/${t}`,{lang:e},!1,!1),list:(t={})=>r.get("/chirp",t,!1,!1),add:(t,e)=>r.post(`/chirp/${t}/add`,{chirper:e?.id||e}),like:t=>r.post(`/chirp/${t}/like`),dislike:t=>r.post(`/chirp/${t}/dislike`),play:t=>r.post(`/chirp/${t}/play`),view:t=>r.post(`/chirp/${t}/view`),liked:t=>r.get(`/chirp/${t}/like`),count:t=>r.get(`/chirp/${t?.id||t}/count`),delete:t=>r.delete(`/chirp/${t?.id||t}`),create:(t={})=>r.post("/chirp",t),subscribe:t=>r.post(`/chirp/${t?.id||t}/subscribe`),unsubscribe:t=>r.delete(`/chirp/${t?.id||t}/subscribe`)});var z=r=>({get:t=>r.get(`/world/${t}`),list:(t={})=>r.get("/world",t),image:(t,e={})=>r.post(`/world/${t?.id||t}/image`,e),invite:(t,e)=>r.post(`/world/${t?.id||t}/invite`,{chirper:e?.id||e}),remove:(t,e)=>r.post(`/world/${t?.id||t}/remove`,{chirper:e?.id||e}),members:(t,e={})=>r.get(`/world/${t?.id||t}/members`,e),alerts:(t={})=>r.get("/world/alerts",t),create:t=>r.post("/world",t),update:t=>r.patch(`/world/${t?.id}`,t),delete:t=>r.delete(`/world/${t?.id||t}`),restore:t=>r.post(`/world/${t?.id||t}/cancel`),validate:(t,e,i)=>r.get("/world/value",{key:e,value:i,world:t?.id})});var V=r=>({get:(t,e={})=>r.get(`/brain/${t}`,e),list:(t={})=>r.get("/brain",t),run:(t,e={})=>r.post(`/brain/${t?.id||t}/run`,e),create:(t={})=>r.post("/brain",t),update:(t={})=>r.patch(`/brain/${t.id}`,t),delete:t=>r.delete(`/brain/${t?.id||t}`),validate:(t,e,i)=>r.get("/brain/value",{key:e,value:i,brain:t?.id}),Frame:{list:(t,e={})=>r.get(`/brain/${t?.id||t}/frame`,e)}});var W=r=>({like:(t,e={})=>r.post(`/studio/${t?.id||t||"default"}/like`,e),dislike:(t,e={})=>r.post(`/studio/${t?.id||t||"default"}/dislike`,e),liked:(t,e={})=>r.get(`/studio/${t?.id||t||"default"}/like`,e),upload:(t={})=>r.post("/studio/upload",t),complete:(t,e={})=>r.post(`/studio/upload/${t?.id||t||"default"}`,e),generate:(t,e={})=>r.post(`/studio/${t?.id||t||"default"}/generate`,e),Message:{list:(t,e={})=>r.get(`/studio/${t?.id||t||"default"}/message`,e),delete:(t,e,i={})=>r.delete(`/studio/${t?.id||t||"default"}/message/${e?.id||e}`,i)}});var Y=r=>({get:t=>r.get(`/follow/${t}`),toggle:t=>r.post(`/follow/${t?.id||t}`)});var Q=r=>({get:(t,e={})=>r.get(`/chirper/${t}`,e),list:(t={})=>r.get("/chirper",t),spec:(t,e)=>r.post(`/chirper/${t?.id||t}/spec`,{type:e}),bump:t=>r.post(`/chirper/${t?.id||t}/bump`),image:(t,e={})=>r.post(`/chirper/${t?.id||t}/image`,e),journal:(t,e)=>r.get(`/chirper/${t?.id||t}/journal`,e),progress:(t,e)=>r.get(`/chirper/${t?.id||t}/progress`,e),username:(t,e=null)=>r.post("/chirper/username",{username:t,id:e?.id||e}),grant:(t={},e={})=>r.post(`/chirper/${t?.id||t}/grant`,e),create:(t={})=>r.post("/chirper",t),update:(t={})=>r.patch(`/chirper/${t.id}`,t),delete:t=>r.delete(`/chirper/${t?.id||t}`),toggleRunning:t=>r.post(`/chirper/${t?.id||t}/running`),validate:(t,e,i)=>r.get("/chirper/value",{key:e,value:i,chirper:t?.id}),trip:(t,e={})=>r.get(`/chirper/${t?.id||t}/trip`,e),Trip:{list:(t,e={})=>r.get(`/chirper/${t?.id||t}/trip`,e),get:(t,e={})=>r.get(`/chirper/trip/${t?.id||t}`,e)},Action:{list:(t,e={})=>r.get(`/chirper/${t?.id||t}/action`,e),get:(t,e={})=>r.get(`/chirper/action/${t?.id||t}`,e)},Item:{list:(t,e={})=>r.get(`/chirper/${t?.id||t}/item`,e),get:(t,e={})=>r.get(`/chirper/item/${t?.id||t}`,e)}});var X=r=>({list:({lang:t}={})=>r.get("/trending",{lang:t},!1,!1)});var Z=r=>({get:t=>r.get(`/category/${t?.id||t}`,{}),list:t=>r.get("/category",t)});var tt=r=>({get:t=>r.get(`/application/${t?.id||t}`,{}),list:t=>r.get("/application",t),create:t=>r.post("/application",t),update:(t,e)=>r.patch(`/application/${t?.id||t}`,e),secret:(t,e)=>r.get(`/application/${t?.id||t}/secret`,e)});var et=r=>({list:t=>r.get("/notification",t),count:t=>r.get("/notification/count",t),read:t=>r.post("/notification/count",t)});var vt=new it.default({length:10}),L=class{constructor({url:t,version:e,options:i={}}){this.key=null;this.url=null;this.cache={};this.events=new N.default;this.call=null;this.socket=null;this.account=null;this.version="v1";this.loading=!0;this.authing=null;this.authKey=null;this.shareKey=null;this.customer=null;this.presences={};this.connecting=null;this.extraOptions={};this.options={path:"/ws",cors:!0,agent:!0,reconnect:!0,transports:["websocket"],withCredentials:!0};t&&(this.url=t),e&&(this.version=e),i&&(this.extraOptions=i),this.build=this.build.bind(this),this.fetch=this.fetch.bind(this),this.wsFetch=this.wsFetch.bind(this),this.on=this.on.bind(this),this.off=this.off.bind(this),this.emit=this.emit.bind(this),this.once=this.once.bind(this),this.addListener=this.events.addListener.bind(this.events),this.removeListener=this.events.removeListener.bind(this.events),this.get=this.get.bind(this),this.put=this.put.bind(this),this.post=this.post.bind(this),this.patch=this.patch.bind(this),this.delete=this.delete.bind(this),this.AI=J(this),this.File=j(this),this.Item=K(this),this.User=M(this),this.Chat=q(this),this.Stat=R(this),this.OAuth=G(this),this.Chirp=H(this),this.Brain=V(this),this.World=z(this),this.Studio=W(this),this.Follow=Y(this),this.Chirper=Q(this),this.Trending=X(this),this.Category=Z(this),this.Application=tt(this),this.Notification=et(this),this.build()}build(){if(this.__resolveConnecting=null,this.connecting=new Promise(i=>{this.__resolveConnecting=i}),!this.url)return;let t={...this.options,...this.extraOptions};t.query||(t.query={}),t.query.compression=!0;let e=st.default.connect(`${this.url}`,t);e.on("connect",async(...i)=>{this.authing||(this.authing=this.auth(this.authKey,this.shareKey),await this.authing,this.authing=null,this.__resolveConnecting())}),e.on("disconnect",()=>{this.connecting=new Promise(i=>{this.__resolveConnecting=i})}),this.socket=e}async auth(t){!t&&this.user&&(t=this.user),t||(this.loading=!0,this.events.emit("loading",!0),t=(await this.get("/auth",{key:this.key},!1,!1))?.user),t&&(this.user=t,this.events.emit("user",t)),this.loading=!1,this.events.emit("loading",!1),typeof window<"u"&&(window.chirper=this)}async fetch(t,e,i={},o=!1){if(["patch","put","delete","post"].includes(t.toLowerCase())&&(o=!1),o&&this.cache[`${t}${e}${JSON.stringify(i)}`])return this.cache[`${t}${e}${JSON.stringify(i)}`];delete this.cache[`${t}${e}${JSON.stringify(i)}`],console.time(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(i)}`),Object.keys(i).forEach(u=>{i[u]===void 0&&delete i[u]});let l;try{l=await(await fetch(`${this.url}/${this.version}${e}${`${t}`.toLowerCase()==="get"?`?${new URLSearchParams(i)}`:""}`,{body:`${t}`.toLowerCase()!=="get"?JSON.stringify(i):void 0,headers:{"Content-Type":"application/json",Authentication:this.key?`Bearer ${this.key}`:void 0},credentials:"include"})).json()}catch(u){throw console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(i)}`),u}if(console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(i)}`),!l?.success)throw new Error(l.message);return o&&(this.cache[`${t}${e}${JSON.stringify(i)}`]=l,this.cache[`${t}${e}${JSON.stringify(i)}`].then(()=>{typeof o=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(i)}`]},o):delete this.cache[`${t}${e}${JSON.stringify(i)}`]})),l.result}async wsFetch(t,e,i={},o=!1,l=!0){if(l&&await this.connecting,l&&await this.authing,["patch","put","delete","post"].includes(t.toLowerCase())&&(o=!1),o&&this.cache[`${t}${e}${JSON.stringify(i)}`])return this.cache[`${t}${e}${JSON.stringify(i)}`];delete this.cache[`${t}${e}${JSON.stringify(i)}`];let u=vt();console.time(`[chirper] [${u}] ${t}:${e} ${JSON.stringify(i)}`);let m=new Promise((s,w)=>{this.socket.once(u,v=>{let h=rt.default.ungzip(v,{to:"string"}),{success:b,result:y,message:f,time:a}=(0,nt.decompress)(JSON.parse(h));if(console.timeEnd(`[chirper] [${u}] ${t}:${e} ${JSON.stringify(i)}`),console.log(`[chirper] [${u}] backend time ${a}ms`),b)return s(y);w(f)})});return o&&(this.cache[`${t}${e}${JSON.stringify(i)}`]=m,this.cache[`${t}${e}${JSON.stringify(i)}`].then(()=>{typeof o=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(i)}`]},o):delete this.cache[`${t}${e}${JSON.stringify(i)}`]})),this.socket.emit("call",u,t.toUpperCase(),e,i),m}on(...t){this.socket.on(...t)}off(...t){this.socket.off(...t)}emit(...t){this.socket.emit(...t)}once(...t){this.socket.once(...t)}get(t,e,...i){return this.wsFetch("GET",`/${this.version}${t}`,e,...i)}put(t,e,...i){return this.wsFetch("PUT",`/${this.version}${t}`,e,...i)}post(t,e,...i){return this.wsFetch("POST",`/${this.version}${t}`,e,...i)}patch(t,e,...i){return this.wsFetch("PATCH",`/${this.version}${t}`,e,...i)}delete(t,e,...i){return this.wsFetch("DELETE",`/${this.version}${t}`,e,...i)}};
|
package/package.json
CHANGED
package/src/api/Chirper.ts
CHANGED
@@ -39,6 +39,10 @@ export default (api) => ({
|
|
39
39
|
},
|
40
40
|
|
41
41
|
// validate field
|
42
|
+
grant : (chirper = {}, grant = {}) => {
|
43
|
+
// return patch
|
44
|
+
return api.post(`/chirper/${chirper?.id || chirper}/grant`, grant);
|
45
|
+
},
|
42
46
|
create : (chirper = {}) => {
|
43
47
|
// return patch
|
44
48
|
return api.post(`/chirper`, chirper);
|
@@ -78,5 +82,29 @@ export default (api) => ({
|
|
78
82
|
// return
|
79
83
|
return api.get(`/chirper/trip/${trip?.id || trip}`, opts);
|
80
84
|
}
|
85
|
+
},
|
86
|
+
|
87
|
+
Action : {
|
88
|
+
// list chirper actions
|
89
|
+
list : (chirper, opts = {}) => {
|
90
|
+
// return
|
91
|
+
return api.get(`/chirper/${chirper?.id || chirper}/action`, opts);
|
92
|
+
},
|
93
|
+
get : (action, opts = {}) => {
|
94
|
+
// return
|
95
|
+
return api.get(`/chirper/action/${action?.id || action}`, opts);
|
96
|
+
},
|
97
|
+
},
|
98
|
+
|
99
|
+
Item : {
|
100
|
+
// list chirper items
|
101
|
+
list : (chirper, opts = {}) => {
|
102
|
+
// return
|
103
|
+
return api.get(`/chirper/${chirper?.id || chirper}/item`, opts);
|
104
|
+
},
|
105
|
+
get : (item, opts = {}) => {
|
106
|
+
// return
|
107
|
+
return api.get(`/chirper/item/${item?.id || item}`, opts);
|
108
|
+
},
|
81
109
|
}
|
82
110
|
});
|
package/src/api/Item.ts
ADDED
package/src/index.ts
CHANGED
@@ -15,6 +15,7 @@ import User from './api/User';
|
|
15
15
|
import Chat from './api/Chat';
|
16
16
|
import File from './api/File';
|
17
17
|
import Stat from './api/Stat';
|
18
|
+
import Item from './api/Item';
|
18
19
|
import OAuth from './api/OAuth';
|
19
20
|
import Chirp from './api/Chirp';
|
20
21
|
import World from './api/World';
|
@@ -98,6 +99,7 @@ export default class chirperNode {
|
|
98
99
|
// api
|
99
100
|
this.AI = AI(this);
|
100
101
|
this.File = File(this);
|
102
|
+
this.Item = Item(this);
|
101
103
|
this.User = User(this);
|
102
104
|
this.Chat = Chat(this);
|
103
105
|
this.Stat = Stat(this);
|