@deckdeckgo/api
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -1,2 +0,2 @@ | ||
var d=({apiUserInfo:e,token:n,context:r,method:o,apiUrl:s})=>new Promise(async(t,p)=>{try{if(!s){t(void 0);return}let i=await fetch(s+r,{method:o,headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify(e)});if(!i||!i.ok&&i.status!==409){p("Something went wrong while creating a user");return}let g=await i.json();t(g)}catch(i){p(i)}}),a=({userId:e,token:n,apiUrl:r})=>new Promise(async(o,s)=>{try{if(!r){o();return}let t=await fetch(r+`/users/${e}`,{method:"DELETE",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${n}`}});if(!t||!t.ok){s("Something went wrong while creating a user");return}o()}catch(t){s(t)}}),c=({userId:e,apiUrl:n})=>new Promise(async(r,o)=>{try{if(!n){r(void 0);return}let s=await fetch(n+`/users/${e}`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"}});if(!s||!s.ok){r(void 0);return}let t=await s.json();r(t)}catch(s){o(s)}});var u=({apiUserInfo:e})=>new Promise(async n=>{let r=A(e);n(r)}),A=e=>({id:e.firebase_uid,anonymous:!1,firebase_uid:e.firebase_uid,username:"Peter Parker"}),f=()=>Promise.resolve(),U=()=>Promise.resolve(void 0);var x=({authUser:e,mock:n,apiUrl:r,token:o})=>new Promise(async s=>{if(!e||e.anonymous){s(void 0);return}try{let t=await h({userId:e.uid,mock:n,apiUrl:r});if(!t){let p=P(e),i=await l({apiUserInfo:p,mock:n,apiUrl:r,token:o});s(i);return}s(t)}catch(t){console.error(t),s(void 0)}}),l=({apiUserInfo:e,token:n,mock:r,apiUrl:o})=>m({apiUserInfo:e,token:n,context:"/users",method:"POST",mock:r,apiUrl:o}),M=({apiUserInfo:e,token:n,userId:r,mock:o,apiUrl:s})=>m({apiUserInfo:e,token:n,context:`/users/${r}`,method:"PUT",mock:o,apiUrl:s}),m=({apiUserInfo:e,token:n,context:r,method:o,mock:s,apiUrl:t})=>s?u({apiUserInfo:e}):d({apiUserInfo:e,token:n,context:r,method:o,apiUrl:t}),R=({token:e,mock:n,apiUrl:r,userId:o})=>n?f():a({userId:o,token:e,apiUrl:r}),h=({userId:e,mock:n,apiUrl:r})=>n?U():c({apiUrl:r,userId:e}),P=e=>({anonymous:e.anonymous,firebase_uid:e.uid,email:e.anonymous?null:e.email});var S=({apiUrl:e,searchTerm:n,next:r})=>new Promise(async(o,s)=>{if(!e){o(void 0);return}let t=e+"search/photos/?query="+n+"&page="+r;try{let p=await fetch(t),i=JSON.parse(await p.text());if(!i){o(void 0);return}o(i)}catch(p){s(p)}}),T=({apiUrl:e,photoId:n})=>new Promise(async r=>{if(!e){r();return}let o=e+"photos/"+n+"/download/";try{await fetch(o),r()}catch(s){r()}});export{R as deleteApi,h as getApi,S as getUnsplashPhotos,l as postApi,M as putApi,m as queryApi,T as registerUnsplashDownload,x as signInApi}; | ||
var d=({apiUserInfo:e,token:n,context:r,method:o,apiUrl:s})=>new Promise(async(t,p)=>{try{if(!s){t(void 0);return}let i=await fetch(s+r,{method:o,headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify(e)});if(!i||!i.ok&&i.status!==409){p("Something went wrong while creating a user");return}let g=await i.json();t(g)}catch(i){p(i)}}),a=({userId:e,token:n,apiUrl:r})=>new Promise(async(o,s)=>{try{if(!r){o();return}let t=await fetch(r+`/users/${e}`,{method:"DELETE",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${n}`}});if(!t||!t.ok){s("Something went wrong while creating a user");return}o()}catch(t){s(t)}}),c=({userId:e,apiUrl:n})=>new Promise(async(r,o)=>{try{if(!n){r(void 0);return}let s=await fetch(n+`/users/${e}`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"}});if(!s||!s.ok){r(void 0);return}let t=await s.json();r(t)}catch(s){o(s)}});var u=({apiUserInfo:e})=>new Promise(async n=>{let r=A(e);n(r)}),A=e=>({id:e.firebase_uid,anonymous:!1,firebase_uid:e.firebase_uid,username:"Peter Parker"}),f=()=>Promise.resolve(),U=()=>Promise.resolve(void 0);var x=({authUser:e,mock:n,apiUrl:r,token:o})=>new Promise(async s=>{if(!e||!e.uid){s(void 0);return}try{let t=await l({userId:e.uid,mock:n,apiUrl:r});if(!t){let p=P(e),i=await h({apiUserInfo:p,mock:n,apiUrl:r,token:o});s(i);return}s(t)}catch(t){console.error(t),s(void 0)}}),h=({apiUserInfo:e,token:n,mock:r,apiUrl:o})=>m({apiUserInfo:e,token:n,context:"/users",method:"POST",mock:r,apiUrl:o}),M=({apiUserInfo:e,token:n,userId:r,mock:o,apiUrl:s})=>m({apiUserInfo:e,token:n,context:`/users/${r}`,method:"PUT",mock:o,apiUrl:s}),m=({apiUserInfo:e,token:n,context:r,method:o,mock:s,apiUrl:t})=>s?u({apiUserInfo:e}):d({apiUserInfo:e,token:n,context:r,method:o,apiUrl:t}),R=({token:e,mock:n,apiUrl:r,userId:o})=>n?f():a({userId:o,token:e,apiUrl:r}),l=({userId:e,mock:n,apiUrl:r})=>n?U():c({apiUrl:r,userId:e}),P=e=>({anonymous:!1,firebase_uid:e.uid,email:e.email});var S=({apiUrl:e,searchTerm:n,next:r})=>new Promise(async(o,s)=>{if(!e){o(void 0);return}let t=e+"search/photos/?query="+n+"&page="+r;try{let p=await fetch(t),i=JSON.parse(await p.text());if(!i){o(void 0);return}o(i)}catch(p){s(p)}}),T=({apiUrl:e,photoId:n})=>new Promise(async r=>{if(!e){r();return}let o=e+"photos/"+n+"/download/";try{await fetch(o),r()}catch(s){r()}});export{R as deleteApi,l as getApi,S as getUnsplashPhotos,h as postApi,M as putApi,m as queryApi,T as registerUnsplashDownload,x as signInApi}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@deckdeckgo/api", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": "David Dal Busco", | ||
@@ -26,3 +26,3 @@ "description": "The API (AWS) providers for the DeckDeckGo editor", | ||
"devDependencies": { | ||
"@deckdeckgo/editor": "^1.0.0", | ||
"@deckdeckgo/editor": "^3.0.0", | ||
"esbuild": "^0.12.28", | ||
@@ -29,0 +29,0 @@ "rimraf": "^3.0.2" |
Sorry, the diff of this file is not supported yet
52678