From b11e32327e8163f3c30c12f624222fa2622b349f Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 28 May 2021 17:02:59 +0200 Subject: [PATCH] feat(console): use new web sdk --- package-lock.json | 17 + public/dist/scripts/app-all.js | 806 +- public/dist/scripts/app-dep.js | 802 +- public/dist/scripts/app.js | 4 +- public/scripts/dependencies/appwrite.js | 9156 ++++++++++------------- public/scripts/services/console.js | 4 +- public/scripts/services/sdk.js | 4 +- 7 files changed, 4895 insertions(+), 5898 deletions(-) diff --git a/package-lock.json b/package-lock.json index b156a38f5..a74beaedd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1563,6 +1563,7 @@ "yallist" ], "dev": true, + "hasInstallScript": true, "optional": true, "os": [ "darwin" @@ -1806,6 +1807,16 @@ "license": "ISC", "optional": true }, + "node_modules/fsevents/node_modules/ini": { + "version": "1.3.5", + "dev": true, + "inBundle": true, + "license": "ISC", + "optional": true, + "engines": { + "node": "*" + } + }, "node_modules/fsevents/node_modules/is-fullwidth-code-point": { "version": "1.0.0", "dev": true, @@ -7028,6 +7039,12 @@ "dev": true, "optional": true }, + "ini": { + "version": "1.3.5", + "bundled": true, + "dev": true, + "optional": true + }, "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, diff --git a/public/dist/scripts/app-all.js b/public/dist/scripts/app-all.js index 604bf2381..723b390dc 100644 --- a/public/dist/scripts/app-all.js +++ b/public/dist/scripts/app-all.js @@ -1,463 +1,461 @@ -(function(window){'use strict';window.Appwrite=function(){let config={endpoint:'https://appwrite.io/v1',project:'',key:'',locale:'',mode:'',};let setEndpoint=function(endpoint){config.endpoint=endpoint;return this;};let setProject=function(value) -{http.addGlobalHeader('X-Appwrite-Project',value);config.project=value;return this;};let setKey=function(value) -{http.addGlobalHeader('X-Appwrite-Key',value);config.key=value;return this;};let setLocale=function(value) -{http.addGlobalHeader('X-Appwrite-Locale',value);config.locale=value;return this;};let setMode=function(value) -{http.addGlobalHeader('X-Appwrite-Mode',value);config.mode=value;return this;};let http=function(document){let globalParams=[],globalHeaders=[];let addParam=function(url,param,value){let a=document.createElement('a'),regex=/(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g;let match,str=[];a.href=url;param=encodeURIComponent(param);while(match=regex.exec(a.search))if(param!==match[1])str.push(match[1]+(match[2]?"="+match[2]:""));str.push(param+(value?"="+encodeURIComponent(value):""));a.search=str.join("&");return a.href;};let buildQuery=function(params){let str=[];for(let p in params){if(Array.isArray(params[p])){for(let index=0;index=request.status){resolve(data);}else{reject(data);}};if(progress){request.addEventListener('progress',progress);request.upload.addEventListener('progress',progress,false);} -request.onerror=function(){reject(new Error("Network Error"));};request.send(params);})};return{'get':function(path,headers={},params={}){return call('GET',path+((Object.keys(params).length>0)?'?'+buildQuery(params):''),headers,{});},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress);},'put':function(path,headers={},params={},progress=null){return call('PUT',path,headers,params,progress);},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress);},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress);},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let account={get:function(){let path='/account';let payload={};return http.get(path,{'content-type':'application/json',},payload);},create:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"');} -if(password===undefined){throw new Error('Missing required parameter: "password"');} -let path='/account';let payload={};if(email){payload['email']=email;} -if(password){payload['password']=password;} -if(name){payload['name']=name;} -return http.post(path,{'content-type':'application/json',},payload);},delete:function(){let path='/account';let payload={};return http.delete(path,{'content-type':'application/json',},payload);},updateEmail:function(email,password){if(email===undefined){throw new Error('Missing required parameter: "email"');} -if(password===undefined){throw new Error('Missing required parameter: "password"');} -let path='/account/email';let payload={};if(email){payload['email']=email;} -if(password){payload['password']=password;} -return http.patch(path,{'content-type':'application/json',},payload);},getLogs:function(){let path='/account/logs';let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateName:function(name){if(name===undefined){throw new Error('Missing required parameter: "name"');} -let path='/account/name';let payload={};if(name){payload['name']=name;} -return http.patch(path,{'content-type':'application/json',},payload);},updatePassword:function(password,oldPassword){if(password===undefined){throw new Error('Missing required parameter: "password"');} -if(oldPassword===undefined){throw new Error('Missing required parameter: "oldPassword"');} -let path='/account/password';let payload={};if(password){payload['password']=password;} -if(oldPassword){payload['oldPassword']=oldPassword;} -return http.patch(path,{'content-type':'application/json',},payload);},getPrefs:function(){let path='/account/prefs';let payload={};return http.get(path,{'content-type':'application/json',},payload);},updatePrefs:function(prefs){if(prefs===undefined){throw new Error('Missing required parameter: "prefs"');} -let path='/account/prefs';let payload={};if(prefs){payload['prefs']=prefs;} -return http.patch(path,{'content-type':'application/json',},payload);},createRecovery:function(email,url){if(email===undefined){throw new Error('Missing required parameter: "email"');} -if(url===undefined){throw new Error('Missing required parameter: "url"');} -let path='/account/recovery';let payload={};if(email){payload['email']=email;} -if(url){payload['url']=url;} -return http.post(path,{'content-type':'application/json',},payload);},updateRecovery:function(userId,secret,password,passwordAgain){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -if(secret===undefined){throw new Error('Missing required parameter: "secret"');} -if(password===undefined){throw new Error('Missing required parameter: "password"');} -if(passwordAgain===undefined){throw new Error('Missing required parameter: "passwordAgain"');} -let path='/account/recovery';let payload={};if(userId){payload['userId']=userId;} -if(secret){payload['secret']=secret;} -if(password){payload['password']=password;} -if(passwordAgain){payload['passwordAgain']=passwordAgain;} -return http.put(path,{'content-type':'application/json',},payload);},getSessions:function(){let path='/account/sessions';let payload={};return http.get(path,{'content-type':'application/json',},payload);},createSession:function(email,password){if(email===undefined){throw new Error('Missing required parameter: "email"');} -if(password===undefined){throw new Error('Missing required parameter: "password"');} -let path='/account/sessions';let payload={};if(email){payload['email']=email;} -if(password){payload['password']=password;} -return http.post(path,{'content-type':'application/json',},payload);},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload);},createOAuth2Session:function(provider,success='https://appwrite.io/auth/oauth2/success',failure='https://appwrite.io/auth/oauth2/failure',scopes=[]){if(provider===undefined){throw new Error('Missing required parameter: "provider"');} -let path='/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload['success']=success;} +var Appwrite=(function(exports,isomorphicFormData,crossFetch){'use strict';function __awaiter(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value);});} +return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value));}catch(e){reject(e);}} +function rejected(value){try{step(generator["throw"](value));}catch(e){reject(e);}} +function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected);} +step((generator=generator.apply(thisArg,_arguments||[])).next());});} +class AppwriteException extends Error{constructor(message,code=0,response=''){super(message);this.name='AppwriteException';this.message=message;this.code=code;this.response=response;}} +class Appwrite{constructor(){this.config={endpoint:'https://appwrite.io/v1',project:'',key:'',jwt:'',locale:'',mode:'',};this.headers={'x-sdk-version':'appwrite:web:2.0.0','X-Appwrite-Response-Format':'0.8.0',};this.account={get:()=>__awaiter(this,void 0,void 0,function*(){let path='/account';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),create:(email,password,name='')=>__awaiter(this,void 0,void 0,function*(){if(email===undefined){throw new AppwriteException('Missing required parameter: "email"');} +if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +let path='/account';let payload={};if(typeof email!=='undefined'){payload['email']=email;} +if(typeof password!=='undefined'){payload['password']=password;} +if(typeof name!=='undefined'){payload['name']=name;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),delete:()=>__awaiter(this,void 0,void 0,function*(){let path='/account';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),updateEmail:(email,password)=>__awaiter(this,void 0,void 0,function*(){if(email===undefined){throw new AppwriteException('Missing required parameter: "email"');} +if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +let path='/account/email';let payload={};if(typeof email!=='undefined'){payload['email']=email;} +if(typeof password!=='undefined'){payload['password']=password;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),createJWT:()=>__awaiter(this,void 0,void 0,function*(){let path='/account/jwt';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getLogs:()=>__awaiter(this,void 0,void 0,function*(){let path='/account/logs';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateName:(name)=>__awaiter(this,void 0,void 0,function*(){if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/account/name';let payload={};if(typeof name!=='undefined'){payload['name']=name;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),updatePassword:(password,oldPassword='')=>__awaiter(this,void 0,void 0,function*(){if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +let path='/account/password';let payload={};if(typeof password!=='undefined'){payload['password']=password;} +if(typeof oldPassword!=='undefined'){payload['oldPassword']=oldPassword;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),getPrefs:()=>__awaiter(this,void 0,void 0,function*(){let path='/account/prefs';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updatePrefs:(prefs)=>__awaiter(this,void 0,void 0,function*(){if(prefs===undefined){throw new AppwriteException('Missing required parameter: "prefs"');} +let path='/account/prefs';let payload={};if(typeof prefs!=='undefined'){payload['prefs']=prefs;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),createRecovery:(email,url)=>__awaiter(this,void 0,void 0,function*(){if(email===undefined){throw new AppwriteException('Missing required parameter: "email"');} +if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} +let path='/account/recovery';let payload={};if(typeof email!=='undefined'){payload['email']=email;} +if(typeof url!=='undefined'){payload['url']=url;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),updateRecovery:(userId,secret,password,passwordAgain)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +if(secret===undefined){throw new AppwriteException('Missing required parameter: "secret"');} +if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +if(passwordAgain===undefined){throw new AppwriteException('Missing required parameter: "passwordAgain"');} +let path='/account/recovery';let payload={};if(typeof userId!=='undefined'){payload['userId']=userId;} +if(typeof secret!=='undefined'){payload['secret']=secret;} +if(typeof password!=='undefined'){payload['password']=password;} +if(typeof passwordAgain!=='undefined'){payload['passwordAgain']=passwordAgain;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),getSessions:()=>__awaiter(this,void 0,void 0,function*(){let path='/account/sessions';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createSession:(email,password)=>__awaiter(this,void 0,void 0,function*(){if(email===undefined){throw new AppwriteException('Missing required parameter: "email"');} +if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +let path='/account/sessions';let payload={};if(typeof email!=='undefined'){payload['email']=email;} +if(typeof password!=='undefined'){payload['password']=password;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),deleteSessions:()=>__awaiter(this,void 0,void 0,function*(){let path='/account/sessions';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),createAnonymousSession:()=>__awaiter(this,void 0,void 0,function*(){let path='/account/sessions/anonymous';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),createOAuth2Session:(provider,success='https://appwrite.io/auth/oauth2/success',failure='https://appwrite.io/auth/oauth2/failure',scopes=[])=>{if(provider===undefined){throw new AppwriteException('Missing required parameter: "provider"');} +let path='/account/sessions/oauth2/{provider}'.replace('{provider}',provider);let payload={};if(success){payload['success']=success;} if(failure){payload['failure']=failure;} if(scopes){payload['scopes']=scopes;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index__awaiter(this,void 0,void 0,function*(){if(sessionId===undefined){throw new AppwriteException('Missing required parameter: "sessionId"');} +let path='/account/sessions/{sessionId}'.replace('{sessionId}',sessionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),createVerification:(url)=>__awaiter(this,void 0,void 0,function*(){if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} +let path='/account/verification';let payload={};if(typeof url!=='undefined'){payload['url']=url;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),updateVerification:(userId,secret)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +if(secret===undefined){throw new AppwriteException('Missing required parameter: "secret"');} +let path='/account/verification';let payload={};if(typeof userId!=='undefined'){payload['userId']=userId;} +if(typeof secret!=='undefined'){payload['secret']=secret;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);})};this.avatars={getBrowser:(code,width=100,height=100,quality=100)=>{if(code===undefined){throw new AppwriteException('Missing required parameter: "code"');} +let path='/avatars/browsers/{code}'.replace('{code}',code);let payload={};if(width){payload['width']=width;} if(height){payload['height']=height;} if(quality){payload['quality']=quality;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{if(code===undefined){throw new AppwriteException('Missing required parameter: "code"');} +let path='/avatars/credit-cards/{code}'.replace('{code}',code);let payload={};if(width){payload['width']=width;} if(height){payload['height']=height;} if(quality){payload['quality']=quality;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} let path='/avatars/favicon';let payload={};if(url){payload['url']=url;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{if(code===undefined){throw new AppwriteException('Missing required parameter: "code"');} +let path='/avatars/flags/{code}'.replace('{code}',code);let payload={};if(width){payload['width']=width;} if(height){payload['height']=height;} if(quality){payload['quality']=quality;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} let path='/avatars/image';let payload={};if(url){payload['url']=url;} if(width){payload['width']=width;} if(height){payload['height']=height;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{let path='/avatars/initials';let payload={};if(name){payload['name']=name;} if(width){payload['width']=width;} if(height){payload['height']=height;} if(color){payload['color']=color;} if(background){payload['background']=background;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{if(text===undefined){throw new AppwriteException('Missing required parameter: "text"');} let path='/avatars/qr';let payload={};if(text){payload['text']=text;} if(size){payload['size']=size;} if(margin){payload['margin']=margin;} if(download){payload['download']=download;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index__awaiter(this,void 0,void 0,function*(){let path='/database/collections';let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},createCollection:function(name,read,write,rules){if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(read===undefined){throw new Error('Missing required parameter: "read"');} -if(write===undefined){throw new Error('Missing required parameter: "write"');} -if(rules===undefined){throw new Error('Missing required parameter: "rules"');} -let path='/database/collections';let payload={};if(name){payload['name']=name;} -if(read){payload['read']=read;} -if(write){payload['write']=write;} -if(rules){payload['rules']=rules;} -return http.post(path,{'content-type':'application/json',},payload);},getCollection:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateCollection:function(collectionId,name,read,write,rules=[]){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(read===undefined){throw new Error('Missing required parameter: "read"');} -if(write===undefined){throw new Error('Missing required parameter: "write"');} -let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(name){payload['name']=name;} -if(read){payload['read']=read;} -if(write){payload['write']=write;} -if(rules){payload['rules']=rules;} -return http.put(path,{'content-type':'application/json',},payload);},deleteCollection:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},listDocuments:function(collectionId,filters=[],limit=25,offset=0,orderField='',orderType='ASC',orderCast='string',search=''){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -let path='/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(filters){payload['filters']=filters;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createCollection:(name,read,write,rules)=>__awaiter(this,void 0,void 0,function*(){if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(read===undefined){throw new AppwriteException('Missing required parameter: "read"');} +if(write===undefined){throw new AppwriteException('Missing required parameter: "write"');} +if(rules===undefined){throw new AppwriteException('Missing required parameter: "rules"');} +let path='/database/collections';let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof read!=='undefined'){payload['read']=read;} +if(typeof write!=='undefined'){payload['write']=write;} +if(typeof rules!=='undefined'){payload['rules']=rules;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getCollection:(collectionId)=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +let path='/database/collections/{collectionId}'.replace('{collectionId}',collectionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateCollection:(collectionId,name,read=[],write=[],rules=[])=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/database/collections/{collectionId}'.replace('{collectionId}',collectionId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof read!=='undefined'){payload['read']=read;} +if(typeof write!=='undefined'){payload['write']=write;} +if(typeof rules!=='undefined'){payload['rules']=rules;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),deleteCollection:(collectionId)=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +let path='/database/collections/{collectionId}'.replace('{collectionId}',collectionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),listDocuments:(collectionId,filters=[],limit=25,offset=0,orderField='',orderType='ASC',orderCast='string',search='')=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +let path='/database/collections/{collectionId}/documents'.replace('{collectionId}',collectionId);let payload={};if(filters){payload['filters']=filters;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderField){payload['orderField']=orderField;} if(orderType){payload['orderType']=orderType;} if(orderCast){payload['orderCast']=orderCast;} if(search){payload['search']=search;} -return http.get(path,{'content-type':'application/json',},payload);},createDocument:function(collectionId,data,read,write,parentDocument='',parentProperty='',parentPropertyType='assign'){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -if(data===undefined){throw new Error('Missing required parameter: "data"');} -if(read===undefined){throw new Error('Missing required parameter: "read"');} -if(write===undefined){throw new Error('Missing required parameter: "write"');} -let path='/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(data){payload['data']=data;} -if(read){payload['read']=read;} -if(write){payload['write']=write;} -if(parentDocument){payload['parentDocument']=parentDocument;} -if(parentProperty){payload['parentProperty']=parentProperty;} -if(parentPropertyType){payload['parentPropertyType']=parentPropertyType;} -return http.post(path,{'content-type':'application/json',},payload);},getDocument:function(collectionId,documentId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -if(documentId===undefined){throw new Error('Missing required parameter: "documentId"');} -let path='/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateDocument:function(collectionId,documentId,data,read,write){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -if(documentId===undefined){throw new Error('Missing required parameter: "documentId"');} -if(data===undefined){throw new Error('Missing required parameter: "data"');} -if(read===undefined){throw new Error('Missing required parameter: "read"');} -if(write===undefined){throw new Error('Missing required parameter: "write"');} -let path='/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);let payload={};if(data){payload['data']=data;} -if(read){payload['read']=read;} -if(write){payload['write']=write;} -return http.patch(path,{'content-type':'application/json',},payload);},deleteDocument:function(collectionId,documentId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -if(documentId===undefined){throw new Error('Missing required parameter: "documentId"');} -let path='/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);}};let functions={list:function(search='',limit=25,offset=0,orderType='ASC'){let path='/functions';let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createDocument:(collectionId,data,read=[],write=[],parentDocument='',parentProperty='',parentPropertyType='assign')=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +if(data===undefined){throw new AppwriteException('Missing required parameter: "data"');} +let path='/database/collections/{collectionId}/documents'.replace('{collectionId}',collectionId);let payload={};if(typeof data!=='undefined'){payload['data']=data;} +if(typeof read!=='undefined'){payload['read']=read;} +if(typeof write!=='undefined'){payload['write']=write;} +if(typeof parentDocument!=='undefined'){payload['parentDocument']=parentDocument;} +if(typeof parentProperty!=='undefined'){payload['parentProperty']=parentProperty;} +if(typeof parentPropertyType!=='undefined'){payload['parentPropertyType']=parentPropertyType;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getDocument:(collectionId,documentId)=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +if(documentId===undefined){throw new AppwriteException('Missing required parameter: "documentId"');} +let path='/database/collections/{collectionId}/documents/{documentId}'.replace('{collectionId}',collectionId).replace('{documentId}',documentId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateDocument:(collectionId,documentId,data,read=[],write=[])=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +if(documentId===undefined){throw new AppwriteException('Missing required parameter: "documentId"');} +if(data===undefined){throw new AppwriteException('Missing required parameter: "data"');} +let path='/database/collections/{collectionId}/documents/{documentId}'.replace('{collectionId}',collectionId).replace('{documentId}',documentId);let payload={};if(typeof data!=='undefined'){payload['data']=data;} +if(typeof read!=='undefined'){payload['read']=read;} +if(typeof write!=='undefined'){payload['write']=write;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),deleteDocument:(collectionId,documentId)=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +if(documentId===undefined){throw new AppwriteException('Missing required parameter: "documentId"');} +let path='/database/collections/{collectionId}/documents/{documentId}'.replace('{collectionId}',collectionId).replace('{documentId}',documentId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);})};this.functions={list:(search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){let path='/functions';let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},create:function(name,execute,env,vars={},events=[],schedule='',timeout=15){if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(execute===undefined){throw new Error('Missing required parameter: "execute"');} -if(env===undefined){throw new Error('Missing required parameter: "env"');} -let path='/functions';let payload={};if(name){payload['name']=name;} -if(execute){payload['execute']=execute;} -if(env){payload['env']=env;} -if(vars){payload['vars']=vars;} -if(events){payload['events']=events;} -if(schedule){payload['schedule']=schedule;} -if(timeout){payload['timeout']=timeout;} -return http.post(path,{'content-type':'application/json',},payload);},get:function(functionId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},update:function(functionId,name,execute,vars={},events=[],schedule='',timeout=15){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(execute===undefined){throw new Error('Missing required parameter: "execute"');} -let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(name){payload['name']=name;} -if(execute){payload['execute']=execute;} -if(vars){payload['vars']=vars;} -if(events){payload['events']=events;} -if(schedule){payload['schedule']=schedule;} -if(timeout){payload['timeout']=timeout;} -return http.put(path,{'content-type':'application/json',},payload);},delete:function(functionId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},listExecutions:function(functionId,search='',limit=25,offset=0,orderType='ASC'){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -let path='/functions/{functionId}/executions'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),create:(name,execute,env,vars={},events=[],schedule='',timeout=15)=>__awaiter(this,void 0,void 0,function*(){if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(execute===undefined){throw new AppwriteException('Missing required parameter: "execute"');} +if(env===undefined){throw new AppwriteException('Missing required parameter: "env"');} +let path='/functions';let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof execute!=='undefined'){payload['execute']=execute;} +if(typeof env!=='undefined'){payload['env']=env;} +if(typeof vars!=='undefined'){payload['vars']=vars;} +if(typeof events!=='undefined'){payload['events']=events;} +if(typeof schedule!=='undefined'){payload['schedule']=schedule;} +if(typeof timeout!=='undefined'){payload['timeout']=timeout;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),get:(functionId)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +let path='/functions/{functionId}'.replace('{functionId}',functionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),update:(functionId,name,execute,vars={},events=[],schedule='',timeout=15)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(execute===undefined){throw new AppwriteException('Missing required parameter: "execute"');} +let path='/functions/{functionId}'.replace('{functionId}',functionId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof execute!=='undefined'){payload['execute']=execute;} +if(typeof vars!=='undefined'){payload['vars']=vars;} +if(typeof events!=='undefined'){payload['events']=events;} +if(typeof schedule!=='undefined'){payload['schedule']=schedule;} +if(typeof timeout!=='undefined'){payload['timeout']=timeout;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),delete:(functionId)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +let path='/functions/{functionId}'.replace('{functionId}',functionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),listExecutions:(functionId,search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +let path='/functions/{functionId}/executions'.replace('{functionId}',functionId);let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},createExecution:function(functionId,data){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -let path='/functions/{functionId}/executions'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(data){payload['data']=data;} -return http.post(path,{'content-type':'application/json',},payload);},getExecution:function(functionId,executionId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -if(executionId===undefined){throw new Error('Missing required parameter: "executionId"');} -let path='/functions/{functionId}/executions/{executionId}'.replace(new RegExp('{functionId}','g'),functionId).replace(new RegExp('{executionId}','g'),executionId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateTag:function(functionId,tag){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -if(tag===undefined){throw new Error('Missing required parameter: "tag"');} -let path='/functions/{functionId}/tag'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(tag){payload['tag']=tag;} -return http.patch(path,{'content-type':'application/json',},payload);},listTags:function(functionId,search='',limit=25,offset=0,orderType='ASC'){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -let path='/functions/{functionId}/tags'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createExecution:(functionId,data='')=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +let path='/functions/{functionId}/executions'.replace('{functionId}',functionId);let payload={};if(typeof data!=='undefined'){payload['data']=data;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getExecution:(functionId,executionId)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +if(executionId===undefined){throw new AppwriteException('Missing required parameter: "executionId"');} +let path='/functions/{functionId}/executions/{executionId}'.replace('{functionId}',functionId).replace('{executionId}',executionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateTag:(functionId,tag)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +if(tag===undefined){throw new AppwriteException('Missing required parameter: "tag"');} +let path='/functions/{functionId}/tag'.replace('{functionId}',functionId);let payload={};if(typeof tag!=='undefined'){payload['tag']=tag;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),listTags:(functionId,search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +let path='/functions/{functionId}/tags'.replace('{functionId}',functionId);let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},createTag:function(functionId,command,code){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -if(command===undefined){throw new Error('Missing required parameter: "command"');} -if(code===undefined){throw new Error('Missing required parameter: "code"');} -let path='/functions/{functionId}/tags'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(command){payload['command']=command;} -if(code){payload['code']=code;} -return http.post(path,{'content-type':'multipart/form-data',},payload);},getTag:function(functionId,tagId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -if(tagId===undefined){throw new Error('Missing required parameter: "tagId"');} -let path='/functions/{functionId}/tags/{tagId}'.replace(new RegExp('{functionId}','g'),functionId).replace(new RegExp('{tagId}','g'),tagId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},deleteTag:function(functionId,tagId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -if(tagId===undefined){throw new Error('Missing required parameter: "tagId"');} -let path='/functions/{functionId}/tags/{tagId}'.replace(new RegExp('{functionId}','g'),functionId).replace(new RegExp('{tagId}','g'),tagId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},getUsage:function(functionId,range='30d'){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -let path='/functions/{functionId}/usage'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(range){payload['range']=range;} -return http.get(path,{'content-type':'application/json',},payload);}};let health={get:function(){let path='/health';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getAntiVirus:function(){let path='/health/anti-virus';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getCache:function(){let path='/health/cache';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getDB:function(){let path='/health/db';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getQueueCertificates:function(){let path='/health/queue/certificates';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getQueueFunctions:function(){let path='/health/queue/functions';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getQueueLogs:function(){let path='/health/queue/logs';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getQueueTasks:function(){let path='/health/queue/tasks';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getQueueUsage:function(){let path='/health/queue/usage';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getQueueWebhooks:function(){let path='/health/queue/webhooks';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getStorageLocal:function(){let path='/health/storage/local';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getTime:function(){let path='/health/time';let payload={};return http.get(path,{'content-type':'application/json',},payload);}};let locale={get:function(){let path='/locale';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getContinents:function(){let path='/locale/continents';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getCountries:function(){let path='/locale/countries';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getCountriesEU:function(){let path='/locale/countries/eu';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getCountriesPhones:function(){let path='/locale/countries/phones';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getCurrencies:function(){let path='/locale/currencies';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getLanguages:function(){let path='/locale/languages';let payload={};return http.get(path,{'content-type':'application/json',},payload);}};let projects={list:function(search='',limit=25,offset=0,orderType='ASC'){let path='/projects';let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createTag:(functionId,command,code)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +if(command===undefined){throw new AppwriteException('Missing required parameter: "command"');} +if(code===undefined){throw new AppwriteException('Missing required parameter: "code"');} +let path='/functions/{functionId}/tags'.replace('{functionId}',functionId);let payload={};if(typeof command!=='undefined'){payload['command']=command;} +if(typeof code!=='undefined'){payload['code']=code;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'multipart/form-data',},payload);}),getTag:(functionId,tagId)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +if(tagId===undefined){throw new AppwriteException('Missing required parameter: "tagId"');} +let path='/functions/{functionId}/tags/{tagId}'.replace('{functionId}',functionId).replace('{tagId}',tagId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),deleteTag:(functionId,tagId)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +if(tagId===undefined){throw new AppwriteException('Missing required parameter: "tagId"');} +let path='/functions/{functionId}/tags/{tagId}'.replace('{functionId}',functionId).replace('{tagId}',tagId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),getUsage:(functionId,range='30d')=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +let path='/functions/{functionId}/usage'.replace('{functionId}',functionId);let payload={};if(range){payload['range']=range;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);})};this.health={get:()=>__awaiter(this,void 0,void 0,function*(){let path='/health';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getAntiVirus:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/anti-virus';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getCache:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/cache';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getDB:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/db';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getQueueCertificates:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/queue/certificates';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getQueueFunctions:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/queue/functions';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getQueueLogs:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/queue/logs';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getQueueTasks:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/queue/tasks';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getQueueUsage:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/queue/usage';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getQueueWebhooks:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/queue/webhooks';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getStorageLocal:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/storage/local';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getTime:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/time';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);})};this.locale={get:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getContinents:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale/continents';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getCountries:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale/countries';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getCountriesEU:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale/countries/eu';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getCountriesPhones:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale/countries/phones';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getCurrencies:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale/currencies';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getLanguages:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale/languages';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);})};this.projects={list:(search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){let path='/projects';let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},create:function(name,teamId,description='',logo='',url='',legalName='',legalCountry='',legalState='',legalCity='',legalAddress='',legalTaxId=''){if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -let path='/projects';let payload={};if(name){payload['name']=name;} -if(teamId){payload['teamId']=teamId;} -if(description){payload['description']=description;} -if(logo){payload['logo']=logo;} -if(url){payload['url']=url;} -if(legalName){payload['legalName']=legalName;} -if(legalCountry){payload['legalCountry']=legalCountry;} -if(legalState){payload['legalState']=legalState;} -if(legalCity){payload['legalCity']=legalCity;} -if(legalAddress){payload['legalAddress']=legalAddress;} -if(legalTaxId){payload['legalTaxId']=legalTaxId;} -return http.post(path,{'content-type':'application/json',},payload);},get:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},update:function(projectId,name,description='',logo='',url='',legalName='',legalCountry='',legalState='',legalCity='',legalAddress='',legalTaxId=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -let path='/projects/{projectId}'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(name){payload['name']=name;} -if(description){payload['description']=description;} -if(logo){payload['logo']=logo;} -if(url){payload['url']=url;} -if(legalName){payload['legalName']=legalName;} -if(legalCountry){payload['legalCountry']=legalCountry;} -if(legalState){payload['legalState']=legalState;} -if(legalCity){payload['legalCity']=legalCity;} -if(legalAddress){payload['legalAddress']=legalAddress;} -if(legalTaxId){payload['legalTaxId']=legalTaxId;} -return http.patch(path,{'content-type':'application/json',},payload);},delete:function(projectId,password){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(password===undefined){throw new Error('Missing required parameter: "password"');} -let path='/projects/{projectId}'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(password){payload['password']=password;} -return http.delete(path,{'content-type':'application/json',},payload);},updateAuthLimit:function(projectId,limit){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(limit===undefined){throw new Error('Missing required parameter: "limit"');} -let path='/projects/{projectId}/auth/limit'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(typeof limit!=='undefined'){payload['limit']=limit;} -return http.patch(path,{'content-type':'application/json',},payload);},updateAuthStatus:function(projectId,method,status){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(method===undefined){throw new Error('Missing required parameter: "method"');} -if(status===undefined){throw new Error('Missing required parameter: "status"');} -let path='/projects/{projectId}/auth/{method}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{method}','g'),method);let payload={};if(status){payload['status']=status;} -return http.patch(path,{'content-type':'application/json',},payload);},listDomains:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}/domains'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},createDomain:function(projectId,domain){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(domain===undefined){throw new Error('Missing required parameter: "domain"');} -let path='/projects/{projectId}/domains'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(domain){payload['domain']=domain;} -return http.post(path,{'content-type':'application/json',},payload);},getDomain:function(projectId,domainId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(domainId===undefined){throw new Error('Missing required parameter: "domainId"');} -let path='/projects/{projectId}/domains/{domainId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{domainId}','g'),domainId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},deleteDomain:function(projectId,domainId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(domainId===undefined){throw new Error('Missing required parameter: "domainId"');} -let path='/projects/{projectId}/domains/{domainId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{domainId}','g'),domainId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},updateDomainVerification:function(projectId,domainId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(domainId===undefined){throw new Error('Missing required parameter: "domainId"');} -let path='/projects/{projectId}/domains/{domainId}/verification'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{domainId}','g'),domainId);let payload={};return http.patch(path,{'content-type':'application/json',},payload);},listKeys:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}/keys'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},createKey:function(projectId,name,scopes){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(scopes===undefined){throw new Error('Missing required parameter: "scopes"');} -let path='/projects/{projectId}/keys'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(name){payload['name']=name;} -if(scopes){payload['scopes']=scopes;} -return http.post(path,{'content-type':'application/json',},payload);},getKey:function(projectId,keyId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(keyId===undefined){throw new Error('Missing required parameter: "keyId"');} -let path='/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{keyId}','g'),keyId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateKey:function(projectId,keyId,name,scopes){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(keyId===undefined){throw new Error('Missing required parameter: "keyId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(scopes===undefined){throw new Error('Missing required parameter: "scopes"');} -let path='/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{keyId}','g'),keyId);let payload={};if(name){payload['name']=name;} -if(scopes){payload['scopes']=scopes;} -return http.put(path,{'content-type':'application/json',},payload);},deleteKey:function(projectId,keyId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(keyId===undefined){throw new Error('Missing required parameter: "keyId"');} -let path='/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{keyId}','g'),keyId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},updateOAuth2:function(projectId,provider,appId='',secret=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(provider===undefined){throw new Error('Missing required parameter: "provider"');} -let path='/projects/{projectId}/oauth2'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(provider){payload['provider']=provider;} -if(appId){payload['appId']=appId;} -if(secret){payload['secret']=secret;} -return http.patch(path,{'content-type':'application/json',},payload);},listPlatforms:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}/platforms'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},createPlatform:function(projectId,type,name,key='',store='',hostname=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(type===undefined){throw new Error('Missing required parameter: "type"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -let path='/projects/{projectId}/platforms'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(type){payload['type']=type;} -if(name){payload['name']=name;} -if(key){payload['key']=key;} -if(store){payload['store']=store;} -if(hostname){payload['hostname']=hostname;} -return http.post(path,{'content-type':'application/json',},payload);},getPlatform:function(projectId,platformId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(platformId===undefined){throw new Error('Missing required parameter: "platformId"');} -let path='/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{platformId}','g'),platformId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updatePlatform:function(projectId,platformId,name,key='',store='',hostname=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(platformId===undefined){throw new Error('Missing required parameter: "platformId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -let path='/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{platformId}','g'),platformId);let payload={};if(name){payload['name']=name;} -if(key){payload['key']=key;} -if(store){payload['store']=store;} -if(hostname){payload['hostname']=hostname;} -return http.put(path,{'content-type':'application/json',},payload);},deletePlatform:function(projectId,platformId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(platformId===undefined){throw new Error('Missing required parameter: "platformId"');} -let path='/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{platformId}','g'),platformId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},listTasks:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}/tasks'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},createTask:function(projectId,name,status,schedule,security,httpMethod,httpUrl,httpHeaders=[],httpUser='',httpPass=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(status===undefined){throw new Error('Missing required parameter: "status"');} -if(schedule===undefined){throw new Error('Missing required parameter: "schedule"');} -if(security===undefined){throw new Error('Missing required parameter: "security"');} -if(httpMethod===undefined){throw new Error('Missing required parameter: "httpMethod"');} -if(httpUrl===undefined){throw new Error('Missing required parameter: "httpUrl"');} -let path='/projects/{projectId}/tasks'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(name){payload['name']=name;} -if(status){payload['status']=status;} -if(schedule){payload['schedule']=schedule;} -if(security){payload['security']=security;} -if(httpMethod){payload['httpMethod']=httpMethod;} -if(httpUrl){payload['httpUrl']=httpUrl;} -if(httpHeaders){payload['httpHeaders']=httpHeaders;} -if(httpUser){payload['httpUser']=httpUser;} -if(httpPass){payload['httpPass']=httpPass;} -return http.post(path,{'content-type':'application/json',},payload);},getTask:function(projectId,taskId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(taskId===undefined){throw new Error('Missing required parameter: "taskId"');} -let path='/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{taskId}','g'),taskId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateTask:function(projectId,taskId,name,status,schedule,security,httpMethod,httpUrl,httpHeaders=[],httpUser='',httpPass=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(taskId===undefined){throw new Error('Missing required parameter: "taskId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(status===undefined){throw new Error('Missing required parameter: "status"');} -if(schedule===undefined){throw new Error('Missing required parameter: "schedule"');} -if(security===undefined){throw new Error('Missing required parameter: "security"');} -if(httpMethod===undefined){throw new Error('Missing required parameter: "httpMethod"');} -if(httpUrl===undefined){throw new Error('Missing required parameter: "httpUrl"');} -let path='/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{taskId}','g'),taskId);let payload={};if(name){payload['name']=name;} -if(status){payload['status']=status;} -if(schedule){payload['schedule']=schedule;} -if(security){payload['security']=security;} -if(httpMethod){payload['httpMethod']=httpMethod;} -if(httpUrl){payload['httpUrl']=httpUrl;} -if(httpHeaders){payload['httpHeaders']=httpHeaders;} -if(httpUser){payload['httpUser']=httpUser;} -if(httpPass){payload['httpPass']=httpPass;} -return http.put(path,{'content-type':'application/json',},payload);},deleteTask:function(projectId,taskId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(taskId===undefined){throw new Error('Missing required parameter: "taskId"');} -let path='/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{taskId}','g'),taskId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},getUsage:function(projectId,range='30d'){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}/usage'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(range){payload['range']=range;} -return http.get(path,{'content-type':'application/json',},payload);},listWebhooks:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}/webhooks'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},createWebhook:function(projectId,name,events,url,security,httpUser='',httpPass=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(events===undefined){throw new Error('Missing required parameter: "events"');} -if(url===undefined){throw new Error('Missing required parameter: "url"');} -if(security===undefined){throw new Error('Missing required parameter: "security"');} -let path='/projects/{projectId}/webhooks'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(name){payload['name']=name;} -if(events){payload['events']=events;} -if(url){payload['url']=url;} -if(security){payload['security']=security;} -if(httpUser){payload['httpUser']=httpUser;} -if(httpPass){payload['httpPass']=httpPass;} -return http.post(path,{'content-type':'application/json',},payload);},getWebhook:function(projectId,webhookId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(webhookId===undefined){throw new Error('Missing required parameter: "webhookId"');} -let path='/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{webhookId}','g'),webhookId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateWebhook:function(projectId,webhookId,name,events,url,security,httpUser='',httpPass=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(webhookId===undefined){throw new Error('Missing required parameter: "webhookId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(events===undefined){throw new Error('Missing required parameter: "events"');} -if(url===undefined){throw new Error('Missing required parameter: "url"');} -if(security===undefined){throw new Error('Missing required parameter: "security"');} -let path='/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{webhookId}','g'),webhookId);let payload={};if(name){payload['name']=name;} -if(events){payload['events']=events;} -if(url){payload['url']=url;} -if(security){payload['security']=security;} -if(httpUser){payload['httpUser']=httpUser;} -if(httpPass){payload['httpPass']=httpPass;} -return http.put(path,{'content-type':'application/json',},payload);},deleteWebhook:function(projectId,webhookId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(webhookId===undefined){throw new Error('Missing required parameter: "webhookId"');} -let path='/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{webhookId}','g'),webhookId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);}};let storage={listFiles:function(search='',limit=25,offset=0,orderType='ASC'){let path='/storage/files';let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),create:(name,teamId,description='',logo='',url='',legalName='',legalCountry='',legalState='',legalCity='',legalAddress='',legalTaxId='')=>__awaiter(this,void 0,void 0,function*(){if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +let path='/projects';let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof teamId!=='undefined'){payload['teamId']=teamId;} +if(typeof description!=='undefined'){payload['description']=description;} +if(typeof logo!=='undefined'){payload['logo']=logo;} +if(typeof url!=='undefined'){payload['url']=url;} +if(typeof legalName!=='undefined'){payload['legalName']=legalName;} +if(typeof legalCountry!=='undefined'){payload['legalCountry']=legalCountry;} +if(typeof legalState!=='undefined'){payload['legalState']=legalState;} +if(typeof legalCity!=='undefined'){payload['legalCity']=legalCity;} +if(typeof legalAddress!=='undefined'){payload['legalAddress']=legalAddress;} +if(typeof legalTaxId!=='undefined'){payload['legalTaxId']=legalTaxId;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),get:(projectId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}'.replace('{projectId}',projectId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),update:(projectId,name,description='',logo='',url='',legalName='',legalCountry='',legalState='',legalCity='',legalAddress='',legalTaxId='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/projects/{projectId}'.replace('{projectId}',projectId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof description!=='undefined'){payload['description']=description;} +if(typeof logo!=='undefined'){payload['logo']=logo;} +if(typeof url!=='undefined'){payload['url']=url;} +if(typeof legalName!=='undefined'){payload['legalName']=legalName;} +if(typeof legalCountry!=='undefined'){payload['legalCountry']=legalCountry;} +if(typeof legalState!=='undefined'){payload['legalState']=legalState;} +if(typeof legalCity!=='undefined'){payload['legalCity']=legalCity;} +if(typeof legalAddress!=='undefined'){payload['legalAddress']=legalAddress;} +if(typeof legalTaxId!=='undefined'){payload['legalTaxId']=legalTaxId;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),delete:(projectId,password)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +let path='/projects/{projectId}'.replace('{projectId}',projectId);let payload={};if(typeof password!=='undefined'){payload['password']=password;} +const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),updateAuthLimit:(projectId,limit)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(limit===undefined){throw new AppwriteException('Missing required parameter: "limit"');} +let path='/projects/{projectId}/auth/limit'.replace('{projectId}',projectId);let payload={};if(typeof limit!=='undefined'){payload['limit']=limit;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),updateAuthStatus:(projectId,method,status)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(method===undefined){throw new AppwriteException('Missing required parameter: "method"');} +if(status===undefined){throw new AppwriteException('Missing required parameter: "status"');} +let path='/projects/{projectId}/auth/{method}'.replace('{projectId}',projectId).replace('{method}',method);let payload={};if(typeof status!=='undefined'){payload['status']=status;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),listDomains:(projectId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}/domains'.replace('{projectId}',projectId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createDomain:(projectId,domain)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(domain===undefined){throw new AppwriteException('Missing required parameter: "domain"');} +let path='/projects/{projectId}/domains'.replace('{projectId}',projectId);let payload={};if(typeof domain!=='undefined'){payload['domain']=domain;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getDomain:(projectId,domainId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(domainId===undefined){throw new AppwriteException('Missing required parameter: "domainId"');} +let path='/projects/{projectId}/domains/{domainId}'.replace('{projectId}',projectId).replace('{domainId}',domainId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),deleteDomain:(projectId,domainId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(domainId===undefined){throw new AppwriteException('Missing required parameter: "domainId"');} +let path='/projects/{projectId}/domains/{domainId}'.replace('{projectId}',projectId).replace('{domainId}',domainId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),updateDomainVerification:(projectId,domainId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(domainId===undefined){throw new AppwriteException('Missing required parameter: "domainId"');} +let path='/projects/{projectId}/domains/{domainId}/verification'.replace('{projectId}',projectId).replace('{domainId}',domainId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),listKeys:(projectId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}/keys'.replace('{projectId}',projectId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createKey:(projectId,name,scopes)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(scopes===undefined){throw new AppwriteException('Missing required parameter: "scopes"');} +let path='/projects/{projectId}/keys'.replace('{projectId}',projectId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof scopes!=='undefined'){payload['scopes']=scopes;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getKey:(projectId,keyId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(keyId===undefined){throw new AppwriteException('Missing required parameter: "keyId"');} +let path='/projects/{projectId}/keys/{keyId}'.replace('{projectId}',projectId).replace('{keyId}',keyId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateKey:(projectId,keyId,name,scopes)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(keyId===undefined){throw new AppwriteException('Missing required parameter: "keyId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(scopes===undefined){throw new AppwriteException('Missing required parameter: "scopes"');} +let path='/projects/{projectId}/keys/{keyId}'.replace('{projectId}',projectId).replace('{keyId}',keyId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof scopes!=='undefined'){payload['scopes']=scopes;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),deleteKey:(projectId,keyId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(keyId===undefined){throw new AppwriteException('Missing required parameter: "keyId"');} +let path='/projects/{projectId}/keys/{keyId}'.replace('{projectId}',projectId).replace('{keyId}',keyId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),updateOAuth2:(projectId,provider,appId='',secret='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(provider===undefined){throw new AppwriteException('Missing required parameter: "provider"');} +let path='/projects/{projectId}/oauth2'.replace('{projectId}',projectId);let payload={};if(typeof provider!=='undefined'){payload['provider']=provider;} +if(typeof appId!=='undefined'){payload['appId']=appId;} +if(typeof secret!=='undefined'){payload['secret']=secret;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),listPlatforms:(projectId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}/platforms'.replace('{projectId}',projectId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createPlatform:(projectId,type,name,key='',store='',hostname='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(type===undefined){throw new AppwriteException('Missing required parameter: "type"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/projects/{projectId}/platforms'.replace('{projectId}',projectId);let payload={};if(typeof type!=='undefined'){payload['type']=type;} +if(typeof name!=='undefined'){payload['name']=name;} +if(typeof key!=='undefined'){payload['key']=key;} +if(typeof store!=='undefined'){payload['store']=store;} +if(typeof hostname!=='undefined'){payload['hostname']=hostname;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getPlatform:(projectId,platformId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(platformId===undefined){throw new AppwriteException('Missing required parameter: "platformId"');} +let path='/projects/{projectId}/platforms/{platformId}'.replace('{projectId}',projectId).replace('{platformId}',platformId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updatePlatform:(projectId,platformId,name,key='',store='',hostname='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(platformId===undefined){throw new AppwriteException('Missing required parameter: "platformId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/projects/{projectId}/platforms/{platformId}'.replace('{projectId}',projectId).replace('{platformId}',platformId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof key!=='undefined'){payload['key']=key;} +if(typeof store!=='undefined'){payload['store']=store;} +if(typeof hostname!=='undefined'){payload['hostname']=hostname;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),deletePlatform:(projectId,platformId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(platformId===undefined){throw new AppwriteException('Missing required parameter: "platformId"');} +let path='/projects/{projectId}/platforms/{platformId}'.replace('{projectId}',projectId).replace('{platformId}',platformId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),listTasks:(projectId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}/tasks'.replace('{projectId}',projectId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createTask:(projectId,name,status,schedule,security,httpMethod,httpUrl,httpHeaders=[],httpUser='',httpPass='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(status===undefined){throw new AppwriteException('Missing required parameter: "status"');} +if(schedule===undefined){throw new AppwriteException('Missing required parameter: "schedule"');} +if(security===undefined){throw new AppwriteException('Missing required parameter: "security"');} +if(httpMethod===undefined){throw new AppwriteException('Missing required parameter: "httpMethod"');} +if(httpUrl===undefined){throw new AppwriteException('Missing required parameter: "httpUrl"');} +let path='/projects/{projectId}/tasks'.replace('{projectId}',projectId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof status!=='undefined'){payload['status']=status;} +if(typeof schedule!=='undefined'){payload['schedule']=schedule;} +if(typeof security!=='undefined'){payload['security']=security;} +if(typeof httpMethod!=='undefined'){payload['httpMethod']=httpMethod;} +if(typeof httpUrl!=='undefined'){payload['httpUrl']=httpUrl;} +if(typeof httpHeaders!=='undefined'){payload['httpHeaders']=httpHeaders;} +if(typeof httpUser!=='undefined'){payload['httpUser']=httpUser;} +if(typeof httpPass!=='undefined'){payload['httpPass']=httpPass;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getTask:(projectId,taskId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(taskId===undefined){throw new AppwriteException('Missing required parameter: "taskId"');} +let path='/projects/{projectId}/tasks/{taskId}'.replace('{projectId}',projectId).replace('{taskId}',taskId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateTask:(projectId,taskId,name,status,schedule,security,httpMethod,httpUrl,httpHeaders=[],httpUser='',httpPass='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(taskId===undefined){throw new AppwriteException('Missing required parameter: "taskId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(status===undefined){throw new AppwriteException('Missing required parameter: "status"');} +if(schedule===undefined){throw new AppwriteException('Missing required parameter: "schedule"');} +if(security===undefined){throw new AppwriteException('Missing required parameter: "security"');} +if(httpMethod===undefined){throw new AppwriteException('Missing required parameter: "httpMethod"');} +if(httpUrl===undefined){throw new AppwriteException('Missing required parameter: "httpUrl"');} +let path='/projects/{projectId}/tasks/{taskId}'.replace('{projectId}',projectId).replace('{taskId}',taskId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof status!=='undefined'){payload['status']=status;} +if(typeof schedule!=='undefined'){payload['schedule']=schedule;} +if(typeof security!=='undefined'){payload['security']=security;} +if(typeof httpMethod!=='undefined'){payload['httpMethod']=httpMethod;} +if(typeof httpUrl!=='undefined'){payload['httpUrl']=httpUrl;} +if(typeof httpHeaders!=='undefined'){payload['httpHeaders']=httpHeaders;} +if(typeof httpUser!=='undefined'){payload['httpUser']=httpUser;} +if(typeof httpPass!=='undefined'){payload['httpPass']=httpPass;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),deleteTask:(projectId,taskId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(taskId===undefined){throw new AppwriteException('Missing required parameter: "taskId"');} +let path='/projects/{projectId}/tasks/{taskId}'.replace('{projectId}',projectId).replace('{taskId}',taskId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),getUsage:(projectId,range='30d')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}/usage'.replace('{projectId}',projectId);let payload={};if(range){payload['range']=range;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),listWebhooks:(projectId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}/webhooks'.replace('{projectId}',projectId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createWebhook:(projectId,name,events,url,security,httpUser='',httpPass='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(events===undefined){throw new AppwriteException('Missing required parameter: "events"');} +if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} +if(security===undefined){throw new AppwriteException('Missing required parameter: "security"');} +let path='/projects/{projectId}/webhooks'.replace('{projectId}',projectId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof events!=='undefined'){payload['events']=events;} +if(typeof url!=='undefined'){payload['url']=url;} +if(typeof security!=='undefined'){payload['security']=security;} +if(typeof httpUser!=='undefined'){payload['httpUser']=httpUser;} +if(typeof httpPass!=='undefined'){payload['httpPass']=httpPass;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getWebhook:(projectId,webhookId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(webhookId===undefined){throw new AppwriteException('Missing required parameter: "webhookId"');} +let path='/projects/{projectId}/webhooks/{webhookId}'.replace('{projectId}',projectId).replace('{webhookId}',webhookId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateWebhook:(projectId,webhookId,name,events,url,security,httpUser='',httpPass='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(webhookId===undefined){throw new AppwriteException('Missing required parameter: "webhookId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(events===undefined){throw new AppwriteException('Missing required parameter: "events"');} +if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} +if(security===undefined){throw new AppwriteException('Missing required parameter: "security"');} +let path='/projects/{projectId}/webhooks/{webhookId}'.replace('{projectId}',projectId).replace('{webhookId}',webhookId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof events!=='undefined'){payload['events']=events;} +if(typeof url!=='undefined'){payload['url']=url;} +if(typeof security!=='undefined'){payload['security']=security;} +if(typeof httpUser!=='undefined'){payload['httpUser']=httpUser;} +if(typeof httpPass!=='undefined'){payload['httpPass']=httpPass;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),deleteWebhook:(projectId,webhookId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(webhookId===undefined){throw new AppwriteException('Missing required parameter: "webhookId"');} +let path='/projects/{projectId}/webhooks/{webhookId}'.replace('{projectId}',projectId).replace('{webhookId}',webhookId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);})};this.storage={listFiles:(search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){let path='/storage/files';let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},createFile:function(file,read,write){if(file===undefined){throw new Error('Missing required parameter: "file"');} -if(read===undefined){throw new Error('Missing required parameter: "read"');} -if(write===undefined){throw new Error('Missing required parameter: "write"');} -let path='/storage/files';let payload={};if(file){payload['file']=file;} -if(read){payload['read']=read;} -if(write){payload['write']=write;} -return http.post(path,{'content-type':'multipart/form-data',},payload);},getFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"');} -let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateFile:function(fileId,read,write){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"');} -if(read===undefined){throw new Error('Missing required parameter: "read"');} -if(write===undefined){throw new Error('Missing required parameter: "write"');} -let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);let payload={};if(read){payload['read']=read;} -if(write){payload['write']=write;} -return http.put(path,{'content-type':'application/json',},payload);},deleteFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"');} -let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},getFileDownload:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"');} -let path='/storage/files/{fileId}/download'.replace(new RegExp('{fileId}','g'),fileId);let payload={};payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index__awaiter(this,void 0,void 0,function*(){if(file===undefined){throw new AppwriteException('Missing required parameter: "file"');} +let path='/storage/files';let payload={};if(typeof file!=='undefined'){payload['file']=file;} +if(typeof read!=='undefined'){payload['read']=read;} +if(typeof write!=='undefined'){payload['write']=write;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'multipart/form-data',},payload);}),getFile:(fileId)=>__awaiter(this,void 0,void 0,function*(){if(fileId===undefined){throw new AppwriteException('Missing required parameter: "fileId"');} +let path='/storage/files/{fileId}'.replace('{fileId}',fileId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateFile:(fileId,read,write)=>__awaiter(this,void 0,void 0,function*(){if(fileId===undefined){throw new AppwriteException('Missing required parameter: "fileId"');} +if(read===undefined){throw new AppwriteException('Missing required parameter: "read"');} +if(write===undefined){throw new AppwriteException('Missing required parameter: "write"');} +let path='/storage/files/{fileId}'.replace('{fileId}',fileId);let payload={};if(typeof read!=='undefined'){payload['read']=read;} +if(typeof write!=='undefined'){payload['write']=write;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),deleteFile:(fileId)=>__awaiter(this,void 0,void 0,function*(){if(fileId===undefined){throw new AppwriteException('Missing required parameter: "fileId"');} +let path='/storage/files/{fileId}'.replace('{fileId}',fileId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),getFileDownload:(fileId)=>{if(fileId===undefined){throw new AppwriteException('Missing required parameter: "fileId"');} +let path='/storage/files/{fileId}/download'.replace('{fileId}',fileId);let payload={};const uri=new URL(this.config.endpoint+path);payload['project']=this.config.project;for(const[key,value]of Object.entries(this.flatten(payload))){uri.searchParams.append(key,value);} +return uri;},getFilePreview:(fileId,width=0,height=0,quality=100,borderWidth=0,borderColor='',borderRadius=0,opacity=1,rotation=0,background='',output='')=>{if(fileId===undefined){throw new AppwriteException('Missing required parameter: "fileId"');} +let path='/storage/files/{fileId}/preview'.replace('{fileId}',fileId);let payload={};if(width){payload['width']=width;} if(height){payload['height']=height;} if(quality){payload['quality']=quality;} +if(borderWidth){payload['borderWidth']=borderWidth;} +if(borderColor){payload['borderColor']=borderColor;} +if(borderRadius){payload['borderRadius']=borderRadius;} +if(opacity){payload['opacity']=opacity;} +if(rotation){payload['rotation']=rotation;} if(background){payload['background']=background;} if(output){payload['output']=output;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{if(fileId===undefined){throw new AppwriteException('Missing required parameter: "fileId"');} +let path='/storage/files/{fileId}/view'.replace('{fileId}',fileId);let payload={};const uri=new URL(this.config.endpoint+path);payload['project']=this.config.project;for(const[key,value]of Object.entries(this.flatten(payload))){uri.searchParams.append(key,value);} +return uri;}};this.teams={list:(search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){let path='/teams';let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},create:function(name,roles=["owner"]){if(name===undefined){throw new Error('Missing required parameter: "name"');} -let path='/teams';let payload={};if(name){payload['name']=name;} -if(roles){payload['roles']=roles;} -return http.post(path,{'content-type':'application/json',},payload);},get:function(teamId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -let path='/teams/{teamId}'.replace(new RegExp('{teamId}','g'),teamId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},update:function(teamId,name){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -let path='/teams/{teamId}'.replace(new RegExp('{teamId}','g'),teamId);let payload={};if(name){payload['name']=name;} -return http.put(path,{'content-type':'application/json',},payload);},delete:function(teamId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -let path='/teams/{teamId}'.replace(new RegExp('{teamId}','g'),teamId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},getMemberships:function(teamId,search='',limit=25,offset=0,orderType='ASC'){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -let path='/teams/{teamId}/memberships'.replace(new RegExp('{teamId}','g'),teamId);let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),create:(name,roles=["owner"])=>__awaiter(this,void 0,void 0,function*(){if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/teams';let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof roles!=='undefined'){payload['roles']=roles;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),get:(teamId)=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +let path='/teams/{teamId}'.replace('{teamId}',teamId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),update:(teamId,name)=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/teams/{teamId}'.replace('{teamId}',teamId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),delete:(teamId)=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +let path='/teams/{teamId}'.replace('{teamId}',teamId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),getMemberships:(teamId,search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +let path='/teams/{teamId}/memberships'.replace('{teamId}',teamId);let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},createMembership:function(teamId,email,roles,url,name=''){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -if(email===undefined){throw new Error('Missing required parameter: "email"');} -if(roles===undefined){throw new Error('Missing required parameter: "roles"');} -if(url===undefined){throw new Error('Missing required parameter: "url"');} -let path='/teams/{teamId}/memberships'.replace(new RegExp('{teamId}','g'),teamId);let payload={};if(email){payload['email']=email;} -if(name){payload['name']=name;} -if(roles){payload['roles']=roles;} -if(url){payload['url']=url;} -return http.post(path,{'content-type':'application/json',},payload);},deleteMembership:function(teamId,inviteId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -if(inviteId===undefined){throw new Error('Missing required parameter: "inviteId"');} -let path='/teams/{teamId}/memberships/{inviteId}'.replace(new RegExp('{teamId}','g'),teamId).replace(new RegExp('{inviteId}','g'),inviteId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},updateMembershipStatus:function(teamId,inviteId,userId,secret){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -if(inviteId===undefined){throw new Error('Missing required parameter: "inviteId"');} -if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -if(secret===undefined){throw new Error('Missing required parameter: "secret"');} -let path='/teams/{teamId}/memberships/{inviteId}/status'.replace(new RegExp('{teamId}','g'),teamId).replace(new RegExp('{inviteId}','g'),inviteId);let payload={};if(userId){payload['userId']=userId;} -if(secret){payload['secret']=secret;} -return http.patch(path,{'content-type':'application/json',},payload);}};let users={list:function(search='',limit=25,offset=0,orderType='ASC'){let path='/users';let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createMembership:(teamId,email,roles,url,name='')=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +if(email===undefined){throw new AppwriteException('Missing required parameter: "email"');} +if(roles===undefined){throw new AppwriteException('Missing required parameter: "roles"');} +if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} +let path='/teams/{teamId}/memberships'.replace('{teamId}',teamId);let payload={};if(typeof email!=='undefined'){payload['email']=email;} +if(typeof name!=='undefined'){payload['name']=name;} +if(typeof roles!=='undefined'){payload['roles']=roles;} +if(typeof url!=='undefined'){payload['url']=url;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),updateMembershipRoles:(teamId,membershipId,roles)=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +if(membershipId===undefined){throw new AppwriteException('Missing required parameter: "membershipId"');} +if(roles===undefined){throw new AppwriteException('Missing required parameter: "roles"');} +let path='/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}',teamId).replace('{membershipId}',membershipId);let payload={};if(typeof roles!=='undefined'){payload['roles']=roles;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),deleteMembership:(teamId,membershipId)=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +if(membershipId===undefined){throw new AppwriteException('Missing required parameter: "membershipId"');} +let path='/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}',teamId).replace('{membershipId}',membershipId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),updateMembershipStatus:(teamId,membershipId,userId,secret)=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +if(membershipId===undefined){throw new AppwriteException('Missing required parameter: "membershipId"');} +if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +if(secret===undefined){throw new AppwriteException('Missing required parameter: "secret"');} +let path='/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}',teamId).replace('{membershipId}',membershipId);let payload={};if(typeof userId!=='undefined'){payload['userId']=userId;} +if(typeof secret!=='undefined'){payload['secret']=secret;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);})};this.users={list:(search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){let path='/users';let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},create:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"');} -if(password===undefined){throw new Error('Missing required parameter: "password"');} -let path='/users';let payload={};if(email){payload['email']=email;} -if(password){payload['password']=password;} -if(name){payload['name']=name;} -return http.post(path,{'content-type':'application/json',},payload);},get:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -let path='/users/{userId}'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},deleteUser:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -let path='/users/{userId}'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},getLogs:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -let path='/users/{userId}/logs'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},getPrefs:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -let path='/users/{userId}/prefs'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updatePrefs:function(userId,prefs){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -if(prefs===undefined){throw new Error('Missing required parameter: "prefs"');} -let path='/users/{userId}/prefs'.replace(new RegExp('{userId}','g'),userId);let payload={};if(prefs){payload['prefs']=prefs;} -return http.patch(path,{'content-type':'application/json',},payload);},getSessions:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -let path='/users/{userId}/sessions'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},deleteSessions:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -let path='/users/{userId}/sessions'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},deleteSession:function(userId,sessionId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"');} -let path='/users/{userId}/sessions/{sessionId}'.replace(new RegExp('{userId}','g'),userId).replace(new RegExp('{sessionId}','g'),sessionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},updateStatus:function(userId,status){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -if(status===undefined){throw new Error('Missing required parameter: "status"');} -let path='/users/{userId}/status'.replace(new RegExp('{userId}','g'),userId);let payload={};if(status){payload['status']=status;} -return http.patch(path,{'content-type':'application/json',},payload);}};return{setEndpoint:setEndpoint,setProject:setProject,setKey:setKey,setLocale:setLocale,setMode:setMode,account:account,avatars:avatars,database:database,functions:functions,health:health,locale:locale,projects:projects,storage:storage,teams:teams,users:users};};if(typeof module!=="undefined"){module.exports=window.Appwrite;}})((typeof window!=="undefined")?window:{});(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory(function(){try{return require('moment');}catch(e){}}()):typeof define==='function'&&define.amd?define(['require'],function(require){return factory(function(){try{return require('moment');}catch(e){}}());}):(global=global||self,global.Chart=factory(global.moment));}(this,(function(moment){'use strict';moment=moment&&moment.hasOwnProperty('default')?moment['default']:moment;function createCommonjsModule(fn,module){return module={exports:{}},fn(module,module.exports),module.exports;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),create:(email,password,name='')=>__awaiter(this,void 0,void 0,function*(){if(email===undefined){throw new AppwriteException('Missing required parameter: "email"');} +if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +let path='/users';let payload={};if(typeof email!=='undefined'){payload['email']=email;} +if(typeof password!=='undefined'){payload['password']=password;} +if(typeof name!=='undefined'){payload['name']=name;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),get:(userId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +let path='/users/{userId}'.replace('{userId}',userId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),delete:(userId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +let path='/users/{userId}'.replace('{userId}',userId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),getLogs:(userId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +let path='/users/{userId}/logs'.replace('{userId}',userId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getPrefs:(userId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +let path='/users/{userId}/prefs'.replace('{userId}',userId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updatePrefs:(userId,prefs)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +if(prefs===undefined){throw new AppwriteException('Missing required parameter: "prefs"');} +let path='/users/{userId}/prefs'.replace('{userId}',userId);let payload={};if(typeof prefs!=='undefined'){payload['prefs']=prefs;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),getSessions:(userId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +let path='/users/{userId}/sessions'.replace('{userId}',userId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),deleteSessions:(userId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +let path='/users/{userId}/sessions'.replace('{userId}',userId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),deleteSession:(userId,sessionId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +if(sessionId===undefined){throw new AppwriteException('Missing required parameter: "sessionId"');} +let path='/users/{userId}/sessions/{sessionId}'.replace('{userId}',userId).replace('{sessionId}',sessionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),updateStatus:(userId,status)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +if(status===undefined){throw new AppwriteException('Missing required parameter: "status"');} +let path='/users/{userId}/status'.replace('{userId}',userId);let payload={};if(typeof status!=='undefined'){payload['status']=status;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);})};} +setEndpoint(endpoint){this.config.endpoint=endpoint;return this;} +setProject(value){this.headers['X-Appwrite-Project']=value;this.config.project=value;return this;} +setKey(value){this.headers['X-Appwrite-Key']=value;this.config.key=value;return this;} +setJWT(value){this.headers['X-Appwrite-JWT']=value;this.config.jwt=value;return this;} +setLocale(value){this.headers['X-Appwrite-Locale']=value;this.config.locale=value;return this;} +setMode(value){this.headers['X-Appwrite-Mode']=value;this.config.mode=value;return this;} +call(method,url,headers={},params={}){var _a,_b;return __awaiter(this,void 0,void 0,function*(){method=method.toUpperCase();headers=Object.assign(Object.assign({},headers),this.headers);let options={method,headers,credentials:'include'};if(typeof window!=='undefined'&&window.localStorage){headers['X-Fallback-Cookies']=(_a=window.localStorage.getItem('cookieFallback'))!==null&&_a!==void 0?_a:"";} +if(method==='GET'){for(const[key,value]of Object.entries(this.flatten(params))){url.searchParams.append(key,value);}} +else{switch(headers['content-type']){case'application/json':options.body=JSON.stringify(params);break;case'multipart/form-data':let formData=new FormData();for(const key in params){if(Array.isArray(params[key])){formData.append(key+'[]',params[key].join(','));} +else{formData.append(key,params[key]);}} +options.body=formData;delete headers['content-type'];break;}} +try{let data=null;const response=yield crossFetch.fetch(url.toString(),options);if((_b=response.headers.get("content-type"))===null||_b===void 0?void 0:_b.includes("application/json")){data=yield response.json();} +else{data={message:yield response.text()};} +if(400<=response.status){throw new AppwriteException(data===null||data===void 0?void 0:data.message,response.status,data);} +const cookieFallback=response.headers.get('X-Fallback-Cookies');if(typeof window!=='undefined'&&window.localStorage&&cookieFallback){window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.');window.localStorage.setItem('cookieFallback',cookieFallback);} +return data;} +catch(e){throw new AppwriteException(e.message);}});} +flatten(data,prefix=''){let output={};for(const key in data){let value=data[key];let finalKey=prefix?`${prefix}[${key}]`:key;if(Array.isArray(value)){output=Object.assign(output,this.flatten(value,finalKey));} +else{output[finalKey]=value;}} +return output;}} +exports.Appwrite=Appwrite;return exports;}({},null,window));(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory(function(){try{return require('moment');}catch(e){}}()):typeof define==='function'&&define.amd?define(['require'],function(require){return factory(function(){try{return require('moment');}catch(e){}}());}):(global=global||self,global.Chart=factory(global.moment));}(this,(function(moment){'use strict';moment=moment&&moment.hasOwnProperty('default')?moment['default']:moment;function createCommonjsModule(fn,module){return module={exports:{}},fn(module,module.exports),module.exports;} function getCjsExportFromNamespace(n){return n&&n['default']||n;} var colorName={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]};var conversions=createCommonjsModule(function(module){var reverseKeywords={};for(var key in colorName){if(colorName.hasOwnProperty(key)){reverseKeywords[colorName[key]]=key;}} var convert=module.exports={rgb:{channels:3,labels:'rgb'},hsl:{channels:3,labels:'hsl'},hsv:{channels:3,labels:'hsv'},hwb:{channels:3,labels:'hwb'},cmyk:{channels:4,labels:'cmyk'},xyz:{channels:3,labels:'xyz'},lab:{channels:3,labels:'lab'},lch:{channels:3,labels:'lch'},hex:{channels:1,labels:['hex']},keyword:{channels:1,labels:['keyword']},ansi16:{channels:1,labels:['ansi16']},ansi256:{channels:1,labels:['ansi256']},hcg:{channels:3,labels:['h','c','g']},apple:{channels:3,labels:['r16','g16','b16']},gray:{channels:1,labels:['gray']}};for(var model in convert){if(convert.hasOwnProperty(model)){if(!('channels'in convert[model])){throw new Error('missing channels property: '+model);} @@ -2115,7 +2113,7 @@ params=formData;break;} return new Promise(function(resolve,reject){let request=new XMLHttpRequest(),key;request.withCredentials=true;request.open(method,path,true);for(key in headers){if(headers.hasOwnProperty(key)){request.setRequestHeader(key,headers[key]);}} request.onload=function(){if(4===request.readyState&&399>=request.status){let data=request.response;let contentType=this.getResponseHeader('content-type');contentType=contentType.substring(0,contentType.indexOf(';'));switch(contentType){case'application/json':data=JSON.parse(data);break;} resolve(data);}else{reject(new Error(request.statusText));}};if(progress){request.addEventListener('progress',progress);request.upload.addEventListener('progress',progress,false);} -request.onerror=function(){reject(new Error("Network Error"));};request.send(params);})};return{'get':function(path,headers={},params={}){return call('GET',path+((params.length>0)?'?'+buildQuery(params):''),headers,{});},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress);},'put':function(path,headers={},params={},progress=null){return call('PUT',headers,params,progress);},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress);},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress);},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let analytics={create:function(id,source,activity,url){return http.post('/analytics',{'content-type':'application/json'},{id:id,source:source,activity:activity,url:url,version:env.VERSION,setup:env.SETUP});},};return{analytics:analytics,};},true);})(window);(function(window){"use strict";window.ls.container.set('console',function(window){var sdk=new window.Appwrite();sdk.setEndpoint(APP_ENV.API).setProject('console').setLocale(APP_ENV.LOCALE);return sdk;},true);})(window);(function(window){"use strict";window.ls.container.set('date',function(){function format(format,timestamp){var jsdate,f +request.onerror=function(){reject(new Error("Network Error"));};request.send(params);})};return{'get':function(path,headers={},params={}){return call('GET',path+((params.length>0)?'?'+buildQuery(params):''),headers,{});},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress);},'put':function(path,headers={},params={},progress=null){return call('PUT',headers,params,progress);},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress);},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress);},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let analytics={create:function(id,source,activity,url){return http.post('/analytics',{'content-type':'application/json'},{id:id,source:source,activity:activity,url:url,version:env.VERSION,setup:env.SETUP});},};return{analytics:analytics,};},true);})(window);(function(window){"use strict";window.ls.container.set('console',function(window){var sdk=new window.Appwrite.Appwrite();sdk.setEndpoint(APP_ENV.ENDPOINT+APP_ENV.API).setProject('console').setLocale(APP_ENV.LOCALE);return sdk;},true);})(window);(function(window){"use strict";window.ls.container.set('date',function(){function format(format,timestamp){var jsdate,f var txtWords=['Sun','Mon','Tues','Wednes','Thurs','Fri','Satur','January','February','March','April','May','June','July','August','September','October','November','December'] var formatChr=/\\?(.?)/gi var formatChrCb=function(t,s){return f[t]?f[t]():s} @@ -2244,7 +2242,7 @@ return slf.renderToken(tokens,idx,opts);} md.renderer.rules.strong_open=renderEm;md.renderer.rules.strong_close=renderEm;return md;},true);})(window);(function(window){"use strict";window.ls.container.set('rtl',function(){var rtlStock="^ا^ب^ت^ث^ج^ح^خ^د^ذ^ر^ز^س^ش^ص^ض^ط^ظ^ع^غ^ف^ق^ك^ل^م^ن^ه^و^ي^א^ב^ג^ד^ה^ו^ז^ח^ט^י^כ^ך^ל^מ^ם^נ^ן^ס^ע^פ^ף^צ^ץ^ק^ר^ש^ת^";var special=["\n"," "," ","״",'"',"_","'","!","@","#","$","^","&","%","*","(",")","+","=","-","[","]","\\","/","{","}","|",":","<",">","?",",",".","0","1","2","3","4","5","6","7","8","9"];var isRTL=function(value){for(var i=0;i=request.status){resolve(data);}else{reject(data);}};if(progress){request.addEventListener('progress',progress);request.upload.addEventListener('progress',progress,false);} -request.onerror=function(){reject(new Error("Network Error"));};request.send(params);})};return{'get':function(path,headers={},params={}){return call('GET',path+((Object.keys(params).length>0)?'?'+buildQuery(params):''),headers,{});},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress);},'put':function(path,headers={},params={},progress=null){return call('PUT',path,headers,params,progress);},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress);},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress);},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let account={get:function(){let path='/account';let payload={};return http.get(path,{'content-type':'application/json',},payload);},create:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"');} -if(password===undefined){throw new Error('Missing required parameter: "password"');} -let path='/account';let payload={};if(email){payload['email']=email;} -if(password){payload['password']=password;} -if(name){payload['name']=name;} -return http.post(path,{'content-type':'application/json',},payload);},delete:function(){let path='/account';let payload={};return http.delete(path,{'content-type':'application/json',},payload);},updateEmail:function(email,password){if(email===undefined){throw new Error('Missing required parameter: "email"');} -if(password===undefined){throw new Error('Missing required parameter: "password"');} -let path='/account/email';let payload={};if(email){payload['email']=email;} -if(password){payload['password']=password;} -return http.patch(path,{'content-type':'application/json',},payload);},getLogs:function(){let path='/account/logs';let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateName:function(name){if(name===undefined){throw new Error('Missing required parameter: "name"');} -let path='/account/name';let payload={};if(name){payload['name']=name;} -return http.patch(path,{'content-type':'application/json',},payload);},updatePassword:function(password,oldPassword){if(password===undefined){throw new Error('Missing required parameter: "password"');} -if(oldPassword===undefined){throw new Error('Missing required parameter: "oldPassword"');} -let path='/account/password';let payload={};if(password){payload['password']=password;} -if(oldPassword){payload['oldPassword']=oldPassword;} -return http.patch(path,{'content-type':'application/json',},payload);},getPrefs:function(){let path='/account/prefs';let payload={};return http.get(path,{'content-type':'application/json',},payload);},updatePrefs:function(prefs){if(prefs===undefined){throw new Error('Missing required parameter: "prefs"');} -let path='/account/prefs';let payload={};if(prefs){payload['prefs']=prefs;} -return http.patch(path,{'content-type':'application/json',},payload);},createRecovery:function(email,url){if(email===undefined){throw new Error('Missing required parameter: "email"');} -if(url===undefined){throw new Error('Missing required parameter: "url"');} -let path='/account/recovery';let payload={};if(email){payload['email']=email;} -if(url){payload['url']=url;} -return http.post(path,{'content-type':'application/json',},payload);},updateRecovery:function(userId,secret,password,passwordAgain){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -if(secret===undefined){throw new Error('Missing required parameter: "secret"');} -if(password===undefined){throw new Error('Missing required parameter: "password"');} -if(passwordAgain===undefined){throw new Error('Missing required parameter: "passwordAgain"');} -let path='/account/recovery';let payload={};if(userId){payload['userId']=userId;} -if(secret){payload['secret']=secret;} -if(password){payload['password']=password;} -if(passwordAgain){payload['passwordAgain']=passwordAgain;} -return http.put(path,{'content-type':'application/json',},payload);},getSessions:function(){let path='/account/sessions';let payload={};return http.get(path,{'content-type':'application/json',},payload);},createSession:function(email,password){if(email===undefined){throw new Error('Missing required parameter: "email"');} -if(password===undefined){throw new Error('Missing required parameter: "password"');} -let path='/account/sessions';let payload={};if(email){payload['email']=email;} -if(password){payload['password']=password;} -return http.post(path,{'content-type':'application/json',},payload);},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload);},createOAuth2Session:function(provider,success='https://appwrite.io/auth/oauth2/success',failure='https://appwrite.io/auth/oauth2/failure',scopes=[]){if(provider===undefined){throw new Error('Missing required parameter: "provider"');} -let path='/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload['success']=success;} +var Appwrite=(function(exports,isomorphicFormData,crossFetch){'use strict';function __awaiter(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value);});} +return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value));}catch(e){reject(e);}} +function rejected(value){try{step(generator["throw"](value));}catch(e){reject(e);}} +function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected);} +step((generator=generator.apply(thisArg,_arguments||[])).next());});} +class AppwriteException extends Error{constructor(message,code=0,response=''){super(message);this.name='AppwriteException';this.message=message;this.code=code;this.response=response;}} +class Appwrite{constructor(){this.config={endpoint:'https://appwrite.io/v1',project:'',key:'',jwt:'',locale:'',mode:'',};this.headers={'x-sdk-version':'appwrite:web:2.0.0','X-Appwrite-Response-Format':'0.8.0',};this.account={get:()=>__awaiter(this,void 0,void 0,function*(){let path='/account';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),create:(email,password,name='')=>__awaiter(this,void 0,void 0,function*(){if(email===undefined){throw new AppwriteException('Missing required parameter: "email"');} +if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +let path='/account';let payload={};if(typeof email!=='undefined'){payload['email']=email;} +if(typeof password!=='undefined'){payload['password']=password;} +if(typeof name!=='undefined'){payload['name']=name;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),delete:()=>__awaiter(this,void 0,void 0,function*(){let path='/account';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),updateEmail:(email,password)=>__awaiter(this,void 0,void 0,function*(){if(email===undefined){throw new AppwriteException('Missing required parameter: "email"');} +if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +let path='/account/email';let payload={};if(typeof email!=='undefined'){payload['email']=email;} +if(typeof password!=='undefined'){payload['password']=password;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),createJWT:()=>__awaiter(this,void 0,void 0,function*(){let path='/account/jwt';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getLogs:()=>__awaiter(this,void 0,void 0,function*(){let path='/account/logs';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateName:(name)=>__awaiter(this,void 0,void 0,function*(){if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/account/name';let payload={};if(typeof name!=='undefined'){payload['name']=name;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),updatePassword:(password,oldPassword='')=>__awaiter(this,void 0,void 0,function*(){if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +let path='/account/password';let payload={};if(typeof password!=='undefined'){payload['password']=password;} +if(typeof oldPassword!=='undefined'){payload['oldPassword']=oldPassword;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),getPrefs:()=>__awaiter(this,void 0,void 0,function*(){let path='/account/prefs';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updatePrefs:(prefs)=>__awaiter(this,void 0,void 0,function*(){if(prefs===undefined){throw new AppwriteException('Missing required parameter: "prefs"');} +let path='/account/prefs';let payload={};if(typeof prefs!=='undefined'){payload['prefs']=prefs;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),createRecovery:(email,url)=>__awaiter(this,void 0,void 0,function*(){if(email===undefined){throw new AppwriteException('Missing required parameter: "email"');} +if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} +let path='/account/recovery';let payload={};if(typeof email!=='undefined'){payload['email']=email;} +if(typeof url!=='undefined'){payload['url']=url;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),updateRecovery:(userId,secret,password,passwordAgain)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +if(secret===undefined){throw new AppwriteException('Missing required parameter: "secret"');} +if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +if(passwordAgain===undefined){throw new AppwriteException('Missing required parameter: "passwordAgain"');} +let path='/account/recovery';let payload={};if(typeof userId!=='undefined'){payload['userId']=userId;} +if(typeof secret!=='undefined'){payload['secret']=secret;} +if(typeof password!=='undefined'){payload['password']=password;} +if(typeof passwordAgain!=='undefined'){payload['passwordAgain']=passwordAgain;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),getSessions:()=>__awaiter(this,void 0,void 0,function*(){let path='/account/sessions';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createSession:(email,password)=>__awaiter(this,void 0,void 0,function*(){if(email===undefined){throw new AppwriteException('Missing required parameter: "email"');} +if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +let path='/account/sessions';let payload={};if(typeof email!=='undefined'){payload['email']=email;} +if(typeof password!=='undefined'){payload['password']=password;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),deleteSessions:()=>__awaiter(this,void 0,void 0,function*(){let path='/account/sessions';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),createAnonymousSession:()=>__awaiter(this,void 0,void 0,function*(){let path='/account/sessions/anonymous';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),createOAuth2Session:(provider,success='https://appwrite.io/auth/oauth2/success',failure='https://appwrite.io/auth/oauth2/failure',scopes=[])=>{if(provider===undefined){throw new AppwriteException('Missing required parameter: "provider"');} +let path='/account/sessions/oauth2/{provider}'.replace('{provider}',provider);let payload={};if(success){payload['success']=success;} if(failure){payload['failure']=failure;} if(scopes){payload['scopes']=scopes;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index__awaiter(this,void 0,void 0,function*(){if(sessionId===undefined){throw new AppwriteException('Missing required parameter: "sessionId"');} +let path='/account/sessions/{sessionId}'.replace('{sessionId}',sessionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),createVerification:(url)=>__awaiter(this,void 0,void 0,function*(){if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} +let path='/account/verification';let payload={};if(typeof url!=='undefined'){payload['url']=url;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),updateVerification:(userId,secret)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +if(secret===undefined){throw new AppwriteException('Missing required parameter: "secret"');} +let path='/account/verification';let payload={};if(typeof userId!=='undefined'){payload['userId']=userId;} +if(typeof secret!=='undefined'){payload['secret']=secret;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);})};this.avatars={getBrowser:(code,width=100,height=100,quality=100)=>{if(code===undefined){throw new AppwriteException('Missing required parameter: "code"');} +let path='/avatars/browsers/{code}'.replace('{code}',code);let payload={};if(width){payload['width']=width;} if(height){payload['height']=height;} if(quality){payload['quality']=quality;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{if(code===undefined){throw new AppwriteException('Missing required parameter: "code"');} +let path='/avatars/credit-cards/{code}'.replace('{code}',code);let payload={};if(width){payload['width']=width;} if(height){payload['height']=height;} if(quality){payload['quality']=quality;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} let path='/avatars/favicon';let payload={};if(url){payload['url']=url;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{if(code===undefined){throw new AppwriteException('Missing required parameter: "code"');} +let path='/avatars/flags/{code}'.replace('{code}',code);let payload={};if(width){payload['width']=width;} if(height){payload['height']=height;} if(quality){payload['quality']=quality;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} let path='/avatars/image';let payload={};if(url){payload['url']=url;} if(width){payload['width']=width;} if(height){payload['height']=height;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{let path='/avatars/initials';let payload={};if(name){payload['name']=name;} if(width){payload['width']=width;} if(height){payload['height']=height;} if(color){payload['color']=color;} if(background){payload['background']=background;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{if(text===undefined){throw new AppwriteException('Missing required parameter: "text"');} let path='/avatars/qr';let payload={};if(text){payload['text']=text;} if(size){payload['size']=size;} if(margin){payload['margin']=margin;} if(download){payload['download']=download;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index__awaiter(this,void 0,void 0,function*(){let path='/database/collections';let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},createCollection:function(name,read,write,rules){if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(read===undefined){throw new Error('Missing required parameter: "read"');} -if(write===undefined){throw new Error('Missing required parameter: "write"');} -if(rules===undefined){throw new Error('Missing required parameter: "rules"');} -let path='/database/collections';let payload={};if(name){payload['name']=name;} -if(read){payload['read']=read;} -if(write){payload['write']=write;} -if(rules){payload['rules']=rules;} -return http.post(path,{'content-type':'application/json',},payload);},getCollection:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateCollection:function(collectionId,name,read,write,rules=[]){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(read===undefined){throw new Error('Missing required parameter: "read"');} -if(write===undefined){throw new Error('Missing required parameter: "write"');} -let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(name){payload['name']=name;} -if(read){payload['read']=read;} -if(write){payload['write']=write;} -if(rules){payload['rules']=rules;} -return http.put(path,{'content-type':'application/json',},payload);},deleteCollection:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},listDocuments:function(collectionId,filters=[],limit=25,offset=0,orderField='',orderType='ASC',orderCast='string',search=''){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -let path='/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(filters){payload['filters']=filters;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createCollection:(name,read,write,rules)=>__awaiter(this,void 0,void 0,function*(){if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(read===undefined){throw new AppwriteException('Missing required parameter: "read"');} +if(write===undefined){throw new AppwriteException('Missing required parameter: "write"');} +if(rules===undefined){throw new AppwriteException('Missing required parameter: "rules"');} +let path='/database/collections';let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof read!=='undefined'){payload['read']=read;} +if(typeof write!=='undefined'){payload['write']=write;} +if(typeof rules!=='undefined'){payload['rules']=rules;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getCollection:(collectionId)=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +let path='/database/collections/{collectionId}'.replace('{collectionId}',collectionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateCollection:(collectionId,name,read=[],write=[],rules=[])=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/database/collections/{collectionId}'.replace('{collectionId}',collectionId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof read!=='undefined'){payload['read']=read;} +if(typeof write!=='undefined'){payload['write']=write;} +if(typeof rules!=='undefined'){payload['rules']=rules;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),deleteCollection:(collectionId)=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +let path='/database/collections/{collectionId}'.replace('{collectionId}',collectionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),listDocuments:(collectionId,filters=[],limit=25,offset=0,orderField='',orderType='ASC',orderCast='string',search='')=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +let path='/database/collections/{collectionId}/documents'.replace('{collectionId}',collectionId);let payload={};if(filters){payload['filters']=filters;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderField){payload['orderField']=orderField;} if(orderType){payload['orderType']=orderType;} if(orderCast){payload['orderCast']=orderCast;} if(search){payload['search']=search;} -return http.get(path,{'content-type':'application/json',},payload);},createDocument:function(collectionId,data,read,write,parentDocument='',parentProperty='',parentPropertyType='assign'){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -if(data===undefined){throw new Error('Missing required parameter: "data"');} -if(read===undefined){throw new Error('Missing required parameter: "read"');} -if(write===undefined){throw new Error('Missing required parameter: "write"');} -let path='/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(data){payload['data']=data;} -if(read){payload['read']=read;} -if(write){payload['write']=write;} -if(parentDocument){payload['parentDocument']=parentDocument;} -if(parentProperty){payload['parentProperty']=parentProperty;} -if(parentPropertyType){payload['parentPropertyType']=parentPropertyType;} -return http.post(path,{'content-type':'application/json',},payload);},getDocument:function(collectionId,documentId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -if(documentId===undefined){throw new Error('Missing required parameter: "documentId"');} -let path='/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateDocument:function(collectionId,documentId,data,read,write){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -if(documentId===undefined){throw new Error('Missing required parameter: "documentId"');} -if(data===undefined){throw new Error('Missing required parameter: "data"');} -if(read===undefined){throw new Error('Missing required parameter: "read"');} -if(write===undefined){throw new Error('Missing required parameter: "write"');} -let path='/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);let payload={};if(data){payload['data']=data;} -if(read){payload['read']=read;} -if(write){payload['write']=write;} -return http.patch(path,{'content-type':'application/json',},payload);},deleteDocument:function(collectionId,documentId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');} -if(documentId===undefined){throw new Error('Missing required parameter: "documentId"');} -let path='/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);}};let functions={list:function(search='',limit=25,offset=0,orderType='ASC'){let path='/functions';let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createDocument:(collectionId,data,read=[],write=[],parentDocument='',parentProperty='',parentPropertyType='assign')=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +if(data===undefined){throw new AppwriteException('Missing required parameter: "data"');} +let path='/database/collections/{collectionId}/documents'.replace('{collectionId}',collectionId);let payload={};if(typeof data!=='undefined'){payload['data']=data;} +if(typeof read!=='undefined'){payload['read']=read;} +if(typeof write!=='undefined'){payload['write']=write;} +if(typeof parentDocument!=='undefined'){payload['parentDocument']=parentDocument;} +if(typeof parentProperty!=='undefined'){payload['parentProperty']=parentProperty;} +if(typeof parentPropertyType!=='undefined'){payload['parentPropertyType']=parentPropertyType;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getDocument:(collectionId,documentId)=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +if(documentId===undefined){throw new AppwriteException('Missing required parameter: "documentId"');} +let path='/database/collections/{collectionId}/documents/{documentId}'.replace('{collectionId}',collectionId).replace('{documentId}',documentId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateDocument:(collectionId,documentId,data,read=[],write=[])=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +if(documentId===undefined){throw new AppwriteException('Missing required parameter: "documentId"');} +if(data===undefined){throw new AppwriteException('Missing required parameter: "data"');} +let path='/database/collections/{collectionId}/documents/{documentId}'.replace('{collectionId}',collectionId).replace('{documentId}',documentId);let payload={};if(typeof data!=='undefined'){payload['data']=data;} +if(typeof read!=='undefined'){payload['read']=read;} +if(typeof write!=='undefined'){payload['write']=write;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),deleteDocument:(collectionId,documentId)=>__awaiter(this,void 0,void 0,function*(){if(collectionId===undefined){throw new AppwriteException('Missing required parameter: "collectionId"');} +if(documentId===undefined){throw new AppwriteException('Missing required parameter: "documentId"');} +let path='/database/collections/{collectionId}/documents/{documentId}'.replace('{collectionId}',collectionId).replace('{documentId}',documentId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);})};this.functions={list:(search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){let path='/functions';let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},create:function(name,execute,env,vars={},events=[],schedule='',timeout=15){if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(execute===undefined){throw new Error('Missing required parameter: "execute"');} -if(env===undefined){throw new Error('Missing required parameter: "env"');} -let path='/functions';let payload={};if(name){payload['name']=name;} -if(execute){payload['execute']=execute;} -if(env){payload['env']=env;} -if(vars){payload['vars']=vars;} -if(events){payload['events']=events;} -if(schedule){payload['schedule']=schedule;} -if(timeout){payload['timeout']=timeout;} -return http.post(path,{'content-type':'application/json',},payload);},get:function(functionId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},update:function(functionId,name,execute,vars={},events=[],schedule='',timeout=15){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(execute===undefined){throw new Error('Missing required parameter: "execute"');} -let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(name){payload['name']=name;} -if(execute){payload['execute']=execute;} -if(vars){payload['vars']=vars;} -if(events){payload['events']=events;} -if(schedule){payload['schedule']=schedule;} -if(timeout){payload['timeout']=timeout;} -return http.put(path,{'content-type':'application/json',},payload);},delete:function(functionId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},listExecutions:function(functionId,search='',limit=25,offset=0,orderType='ASC'){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -let path='/functions/{functionId}/executions'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),create:(name,execute,env,vars={},events=[],schedule='',timeout=15)=>__awaiter(this,void 0,void 0,function*(){if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(execute===undefined){throw new AppwriteException('Missing required parameter: "execute"');} +if(env===undefined){throw new AppwriteException('Missing required parameter: "env"');} +let path='/functions';let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof execute!=='undefined'){payload['execute']=execute;} +if(typeof env!=='undefined'){payload['env']=env;} +if(typeof vars!=='undefined'){payload['vars']=vars;} +if(typeof events!=='undefined'){payload['events']=events;} +if(typeof schedule!=='undefined'){payload['schedule']=schedule;} +if(typeof timeout!=='undefined'){payload['timeout']=timeout;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),get:(functionId)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +let path='/functions/{functionId}'.replace('{functionId}',functionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),update:(functionId,name,execute,vars={},events=[],schedule='',timeout=15)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(execute===undefined){throw new AppwriteException('Missing required parameter: "execute"');} +let path='/functions/{functionId}'.replace('{functionId}',functionId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof execute!=='undefined'){payload['execute']=execute;} +if(typeof vars!=='undefined'){payload['vars']=vars;} +if(typeof events!=='undefined'){payload['events']=events;} +if(typeof schedule!=='undefined'){payload['schedule']=schedule;} +if(typeof timeout!=='undefined'){payload['timeout']=timeout;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),delete:(functionId)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +let path='/functions/{functionId}'.replace('{functionId}',functionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),listExecutions:(functionId,search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +let path='/functions/{functionId}/executions'.replace('{functionId}',functionId);let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},createExecution:function(functionId,data){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -let path='/functions/{functionId}/executions'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(data){payload['data']=data;} -return http.post(path,{'content-type':'application/json',},payload);},getExecution:function(functionId,executionId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -if(executionId===undefined){throw new Error('Missing required parameter: "executionId"');} -let path='/functions/{functionId}/executions/{executionId}'.replace(new RegExp('{functionId}','g'),functionId).replace(new RegExp('{executionId}','g'),executionId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateTag:function(functionId,tag){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -if(tag===undefined){throw new Error('Missing required parameter: "tag"');} -let path='/functions/{functionId}/tag'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(tag){payload['tag']=tag;} -return http.patch(path,{'content-type':'application/json',},payload);},listTags:function(functionId,search='',limit=25,offset=0,orderType='ASC'){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -let path='/functions/{functionId}/tags'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createExecution:(functionId,data='')=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +let path='/functions/{functionId}/executions'.replace('{functionId}',functionId);let payload={};if(typeof data!=='undefined'){payload['data']=data;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getExecution:(functionId,executionId)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +if(executionId===undefined){throw new AppwriteException('Missing required parameter: "executionId"');} +let path='/functions/{functionId}/executions/{executionId}'.replace('{functionId}',functionId).replace('{executionId}',executionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateTag:(functionId,tag)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +if(tag===undefined){throw new AppwriteException('Missing required parameter: "tag"');} +let path='/functions/{functionId}/tag'.replace('{functionId}',functionId);let payload={};if(typeof tag!=='undefined'){payload['tag']=tag;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),listTags:(functionId,search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +let path='/functions/{functionId}/tags'.replace('{functionId}',functionId);let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},createTag:function(functionId,command,code){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -if(command===undefined){throw new Error('Missing required parameter: "command"');} -if(code===undefined){throw new Error('Missing required parameter: "code"');} -let path='/functions/{functionId}/tags'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(command){payload['command']=command;} -if(code){payload['code']=code;} -return http.post(path,{'content-type':'multipart/form-data',},payload);},getTag:function(functionId,tagId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -if(tagId===undefined){throw new Error('Missing required parameter: "tagId"');} -let path='/functions/{functionId}/tags/{tagId}'.replace(new RegExp('{functionId}','g'),functionId).replace(new RegExp('{tagId}','g'),tagId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},deleteTag:function(functionId,tagId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -if(tagId===undefined){throw new Error('Missing required parameter: "tagId"');} -let path='/functions/{functionId}/tags/{tagId}'.replace(new RegExp('{functionId}','g'),functionId).replace(new RegExp('{tagId}','g'),tagId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},getUsage:function(functionId,range='30d'){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"');} -let path='/functions/{functionId}/usage'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(range){payload['range']=range;} -return http.get(path,{'content-type':'application/json',},payload);}};let health={get:function(){let path='/health';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getAntiVirus:function(){let path='/health/anti-virus';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getCache:function(){let path='/health/cache';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getDB:function(){let path='/health/db';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getQueueCertificates:function(){let path='/health/queue/certificates';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getQueueFunctions:function(){let path='/health/queue/functions';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getQueueLogs:function(){let path='/health/queue/logs';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getQueueTasks:function(){let path='/health/queue/tasks';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getQueueUsage:function(){let path='/health/queue/usage';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getQueueWebhooks:function(){let path='/health/queue/webhooks';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getStorageLocal:function(){let path='/health/storage/local';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getTime:function(){let path='/health/time';let payload={};return http.get(path,{'content-type':'application/json',},payload);}};let locale={get:function(){let path='/locale';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getContinents:function(){let path='/locale/continents';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getCountries:function(){let path='/locale/countries';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getCountriesEU:function(){let path='/locale/countries/eu';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getCountriesPhones:function(){let path='/locale/countries/phones';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getCurrencies:function(){let path='/locale/currencies';let payload={};return http.get(path,{'content-type':'application/json',},payload);},getLanguages:function(){let path='/locale/languages';let payload={};return http.get(path,{'content-type':'application/json',},payload);}};let projects={list:function(search='',limit=25,offset=0,orderType='ASC'){let path='/projects';let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createTag:(functionId,command,code)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +if(command===undefined){throw new AppwriteException('Missing required parameter: "command"');} +if(code===undefined){throw new AppwriteException('Missing required parameter: "code"');} +let path='/functions/{functionId}/tags'.replace('{functionId}',functionId);let payload={};if(typeof command!=='undefined'){payload['command']=command;} +if(typeof code!=='undefined'){payload['code']=code;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'multipart/form-data',},payload);}),getTag:(functionId,tagId)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +if(tagId===undefined){throw new AppwriteException('Missing required parameter: "tagId"');} +let path='/functions/{functionId}/tags/{tagId}'.replace('{functionId}',functionId).replace('{tagId}',tagId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),deleteTag:(functionId,tagId)=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +if(tagId===undefined){throw new AppwriteException('Missing required parameter: "tagId"');} +let path='/functions/{functionId}/tags/{tagId}'.replace('{functionId}',functionId).replace('{tagId}',tagId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),getUsage:(functionId,range='30d')=>__awaiter(this,void 0,void 0,function*(){if(functionId===undefined){throw new AppwriteException('Missing required parameter: "functionId"');} +let path='/functions/{functionId}/usage'.replace('{functionId}',functionId);let payload={};if(range){payload['range']=range;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);})};this.health={get:()=>__awaiter(this,void 0,void 0,function*(){let path='/health';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getAntiVirus:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/anti-virus';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getCache:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/cache';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getDB:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/db';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getQueueCertificates:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/queue/certificates';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getQueueFunctions:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/queue/functions';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getQueueLogs:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/queue/logs';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getQueueTasks:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/queue/tasks';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getQueueUsage:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/queue/usage';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getQueueWebhooks:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/queue/webhooks';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getStorageLocal:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/storage/local';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getTime:()=>__awaiter(this,void 0,void 0,function*(){let path='/health/time';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);})};this.locale={get:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getContinents:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale/continents';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getCountries:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale/countries';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getCountriesEU:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale/countries/eu';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getCountriesPhones:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale/countries/phones';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getCurrencies:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale/currencies';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getLanguages:()=>__awaiter(this,void 0,void 0,function*(){let path='/locale/languages';let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);})};this.projects={list:(search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){let path='/projects';let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},create:function(name,teamId,description='',logo='',url='',legalName='',legalCountry='',legalState='',legalCity='',legalAddress='',legalTaxId=''){if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -let path='/projects';let payload={};if(name){payload['name']=name;} -if(teamId){payload['teamId']=teamId;} -if(description){payload['description']=description;} -if(logo){payload['logo']=logo;} -if(url){payload['url']=url;} -if(legalName){payload['legalName']=legalName;} -if(legalCountry){payload['legalCountry']=legalCountry;} -if(legalState){payload['legalState']=legalState;} -if(legalCity){payload['legalCity']=legalCity;} -if(legalAddress){payload['legalAddress']=legalAddress;} -if(legalTaxId){payload['legalTaxId']=legalTaxId;} -return http.post(path,{'content-type':'application/json',},payload);},get:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},update:function(projectId,name,description='',logo='',url='',legalName='',legalCountry='',legalState='',legalCity='',legalAddress='',legalTaxId=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -let path='/projects/{projectId}'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(name){payload['name']=name;} -if(description){payload['description']=description;} -if(logo){payload['logo']=logo;} -if(url){payload['url']=url;} -if(legalName){payload['legalName']=legalName;} -if(legalCountry){payload['legalCountry']=legalCountry;} -if(legalState){payload['legalState']=legalState;} -if(legalCity){payload['legalCity']=legalCity;} -if(legalAddress){payload['legalAddress']=legalAddress;} -if(legalTaxId){payload['legalTaxId']=legalTaxId;} -return http.patch(path,{'content-type':'application/json',},payload);},delete:function(projectId,password){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(password===undefined){throw new Error('Missing required parameter: "password"');} -let path='/projects/{projectId}'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(password){payload['password']=password;} -return http.delete(path,{'content-type':'application/json',},payload);},updateAuthLimit:function(projectId,limit){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(limit===undefined){throw new Error('Missing required parameter: "limit"');} -let path='/projects/{projectId}/auth/limit'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(typeof limit!=='undefined'){payload['limit']=limit;} -return http.patch(path,{'content-type':'application/json',},payload);},updateAuthStatus:function(projectId,method,status){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(method===undefined){throw new Error('Missing required parameter: "method"');} -if(status===undefined){throw new Error('Missing required parameter: "status"');} -let path='/projects/{projectId}/auth/{method}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{method}','g'),method);let payload={};if(status){payload['status']=status;} -return http.patch(path,{'content-type':'application/json',},payload);},listDomains:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}/domains'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},createDomain:function(projectId,domain){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(domain===undefined){throw new Error('Missing required parameter: "domain"');} -let path='/projects/{projectId}/domains'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(domain){payload['domain']=domain;} -return http.post(path,{'content-type':'application/json',},payload);},getDomain:function(projectId,domainId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(domainId===undefined){throw new Error('Missing required parameter: "domainId"');} -let path='/projects/{projectId}/domains/{domainId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{domainId}','g'),domainId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},deleteDomain:function(projectId,domainId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(domainId===undefined){throw new Error('Missing required parameter: "domainId"');} -let path='/projects/{projectId}/domains/{domainId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{domainId}','g'),domainId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},updateDomainVerification:function(projectId,domainId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(domainId===undefined){throw new Error('Missing required parameter: "domainId"');} -let path='/projects/{projectId}/domains/{domainId}/verification'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{domainId}','g'),domainId);let payload={};return http.patch(path,{'content-type':'application/json',},payload);},listKeys:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}/keys'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},createKey:function(projectId,name,scopes){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(scopes===undefined){throw new Error('Missing required parameter: "scopes"');} -let path='/projects/{projectId}/keys'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(name){payload['name']=name;} -if(scopes){payload['scopes']=scopes;} -return http.post(path,{'content-type':'application/json',},payload);},getKey:function(projectId,keyId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(keyId===undefined){throw new Error('Missing required parameter: "keyId"');} -let path='/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{keyId}','g'),keyId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateKey:function(projectId,keyId,name,scopes){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(keyId===undefined){throw new Error('Missing required parameter: "keyId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(scopes===undefined){throw new Error('Missing required parameter: "scopes"');} -let path='/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{keyId}','g'),keyId);let payload={};if(name){payload['name']=name;} -if(scopes){payload['scopes']=scopes;} -return http.put(path,{'content-type':'application/json',},payload);},deleteKey:function(projectId,keyId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(keyId===undefined){throw new Error('Missing required parameter: "keyId"');} -let path='/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{keyId}','g'),keyId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},updateOAuth2:function(projectId,provider,appId='',secret=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(provider===undefined){throw new Error('Missing required parameter: "provider"');} -let path='/projects/{projectId}/oauth2'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(provider){payload['provider']=provider;} -if(appId){payload['appId']=appId;} -if(secret){payload['secret']=secret;} -return http.patch(path,{'content-type':'application/json',},payload);},listPlatforms:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}/platforms'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},createPlatform:function(projectId,type,name,key='',store='',hostname=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(type===undefined){throw new Error('Missing required parameter: "type"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -let path='/projects/{projectId}/platforms'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(type){payload['type']=type;} -if(name){payload['name']=name;} -if(key){payload['key']=key;} -if(store){payload['store']=store;} -if(hostname){payload['hostname']=hostname;} -return http.post(path,{'content-type':'application/json',},payload);},getPlatform:function(projectId,platformId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(platformId===undefined){throw new Error('Missing required parameter: "platformId"');} -let path='/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{platformId}','g'),platformId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updatePlatform:function(projectId,platformId,name,key='',store='',hostname=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(platformId===undefined){throw new Error('Missing required parameter: "platformId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -let path='/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{platformId}','g'),platformId);let payload={};if(name){payload['name']=name;} -if(key){payload['key']=key;} -if(store){payload['store']=store;} -if(hostname){payload['hostname']=hostname;} -return http.put(path,{'content-type':'application/json',},payload);},deletePlatform:function(projectId,platformId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(platformId===undefined){throw new Error('Missing required parameter: "platformId"');} -let path='/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{platformId}','g'),platformId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},listTasks:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}/tasks'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},createTask:function(projectId,name,status,schedule,security,httpMethod,httpUrl,httpHeaders=[],httpUser='',httpPass=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(status===undefined){throw new Error('Missing required parameter: "status"');} -if(schedule===undefined){throw new Error('Missing required parameter: "schedule"');} -if(security===undefined){throw new Error('Missing required parameter: "security"');} -if(httpMethod===undefined){throw new Error('Missing required parameter: "httpMethod"');} -if(httpUrl===undefined){throw new Error('Missing required parameter: "httpUrl"');} -let path='/projects/{projectId}/tasks'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(name){payload['name']=name;} -if(status){payload['status']=status;} -if(schedule){payload['schedule']=schedule;} -if(security){payload['security']=security;} -if(httpMethod){payload['httpMethod']=httpMethod;} -if(httpUrl){payload['httpUrl']=httpUrl;} -if(httpHeaders){payload['httpHeaders']=httpHeaders;} -if(httpUser){payload['httpUser']=httpUser;} -if(httpPass){payload['httpPass']=httpPass;} -return http.post(path,{'content-type':'application/json',},payload);},getTask:function(projectId,taskId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(taskId===undefined){throw new Error('Missing required parameter: "taskId"');} -let path='/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{taskId}','g'),taskId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateTask:function(projectId,taskId,name,status,schedule,security,httpMethod,httpUrl,httpHeaders=[],httpUser='',httpPass=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(taskId===undefined){throw new Error('Missing required parameter: "taskId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(status===undefined){throw new Error('Missing required parameter: "status"');} -if(schedule===undefined){throw new Error('Missing required parameter: "schedule"');} -if(security===undefined){throw new Error('Missing required parameter: "security"');} -if(httpMethod===undefined){throw new Error('Missing required parameter: "httpMethod"');} -if(httpUrl===undefined){throw new Error('Missing required parameter: "httpUrl"');} -let path='/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{taskId}','g'),taskId);let payload={};if(name){payload['name']=name;} -if(status){payload['status']=status;} -if(schedule){payload['schedule']=schedule;} -if(security){payload['security']=security;} -if(httpMethod){payload['httpMethod']=httpMethod;} -if(httpUrl){payload['httpUrl']=httpUrl;} -if(httpHeaders){payload['httpHeaders']=httpHeaders;} -if(httpUser){payload['httpUser']=httpUser;} -if(httpPass){payload['httpPass']=httpPass;} -return http.put(path,{'content-type':'application/json',},payload);},deleteTask:function(projectId,taskId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(taskId===undefined){throw new Error('Missing required parameter: "taskId"');} -let path='/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{taskId}','g'),taskId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},getUsage:function(projectId,range='30d'){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}/usage'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(range){payload['range']=range;} -return http.get(path,{'content-type':'application/json',},payload);},listWebhooks:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -let path='/projects/{projectId}/webhooks'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},createWebhook:function(projectId,name,events,url,security,httpUser='',httpPass=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(events===undefined){throw new Error('Missing required parameter: "events"');} -if(url===undefined){throw new Error('Missing required parameter: "url"');} -if(security===undefined){throw new Error('Missing required parameter: "security"');} -let path='/projects/{projectId}/webhooks'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(name){payload['name']=name;} -if(events){payload['events']=events;} -if(url){payload['url']=url;} -if(security){payload['security']=security;} -if(httpUser){payload['httpUser']=httpUser;} -if(httpPass){payload['httpPass']=httpPass;} -return http.post(path,{'content-type':'application/json',},payload);},getWebhook:function(projectId,webhookId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(webhookId===undefined){throw new Error('Missing required parameter: "webhookId"');} -let path='/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{webhookId}','g'),webhookId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateWebhook:function(projectId,webhookId,name,events,url,security,httpUser='',httpPass=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(webhookId===undefined){throw new Error('Missing required parameter: "webhookId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -if(events===undefined){throw new Error('Missing required parameter: "events"');} -if(url===undefined){throw new Error('Missing required parameter: "url"');} -if(security===undefined){throw new Error('Missing required parameter: "security"');} -let path='/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{webhookId}','g'),webhookId);let payload={};if(name){payload['name']=name;} -if(events){payload['events']=events;} -if(url){payload['url']=url;} -if(security){payload['security']=security;} -if(httpUser){payload['httpUser']=httpUser;} -if(httpPass){payload['httpPass']=httpPass;} -return http.put(path,{'content-type':'application/json',},payload);},deleteWebhook:function(projectId,webhookId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"');} -if(webhookId===undefined){throw new Error('Missing required parameter: "webhookId"');} -let path='/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{webhookId}','g'),webhookId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);}};let storage={listFiles:function(search='',limit=25,offset=0,orderType='ASC'){let path='/storage/files';let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),create:(name,teamId,description='',logo='',url='',legalName='',legalCountry='',legalState='',legalCity='',legalAddress='',legalTaxId='')=>__awaiter(this,void 0,void 0,function*(){if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +let path='/projects';let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof teamId!=='undefined'){payload['teamId']=teamId;} +if(typeof description!=='undefined'){payload['description']=description;} +if(typeof logo!=='undefined'){payload['logo']=logo;} +if(typeof url!=='undefined'){payload['url']=url;} +if(typeof legalName!=='undefined'){payload['legalName']=legalName;} +if(typeof legalCountry!=='undefined'){payload['legalCountry']=legalCountry;} +if(typeof legalState!=='undefined'){payload['legalState']=legalState;} +if(typeof legalCity!=='undefined'){payload['legalCity']=legalCity;} +if(typeof legalAddress!=='undefined'){payload['legalAddress']=legalAddress;} +if(typeof legalTaxId!=='undefined'){payload['legalTaxId']=legalTaxId;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),get:(projectId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}'.replace('{projectId}',projectId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),update:(projectId,name,description='',logo='',url='',legalName='',legalCountry='',legalState='',legalCity='',legalAddress='',legalTaxId='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/projects/{projectId}'.replace('{projectId}',projectId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof description!=='undefined'){payload['description']=description;} +if(typeof logo!=='undefined'){payload['logo']=logo;} +if(typeof url!=='undefined'){payload['url']=url;} +if(typeof legalName!=='undefined'){payload['legalName']=legalName;} +if(typeof legalCountry!=='undefined'){payload['legalCountry']=legalCountry;} +if(typeof legalState!=='undefined'){payload['legalState']=legalState;} +if(typeof legalCity!=='undefined'){payload['legalCity']=legalCity;} +if(typeof legalAddress!=='undefined'){payload['legalAddress']=legalAddress;} +if(typeof legalTaxId!=='undefined'){payload['legalTaxId']=legalTaxId;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),delete:(projectId,password)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +let path='/projects/{projectId}'.replace('{projectId}',projectId);let payload={};if(typeof password!=='undefined'){payload['password']=password;} +const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),updateAuthLimit:(projectId,limit)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(limit===undefined){throw new AppwriteException('Missing required parameter: "limit"');} +let path='/projects/{projectId}/auth/limit'.replace('{projectId}',projectId);let payload={};if(typeof limit!=='undefined'){payload['limit']=limit;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),updateAuthStatus:(projectId,method,status)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(method===undefined){throw new AppwriteException('Missing required parameter: "method"');} +if(status===undefined){throw new AppwriteException('Missing required parameter: "status"');} +let path='/projects/{projectId}/auth/{method}'.replace('{projectId}',projectId).replace('{method}',method);let payload={};if(typeof status!=='undefined'){payload['status']=status;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),listDomains:(projectId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}/domains'.replace('{projectId}',projectId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createDomain:(projectId,domain)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(domain===undefined){throw new AppwriteException('Missing required parameter: "domain"');} +let path='/projects/{projectId}/domains'.replace('{projectId}',projectId);let payload={};if(typeof domain!=='undefined'){payload['domain']=domain;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getDomain:(projectId,domainId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(domainId===undefined){throw new AppwriteException('Missing required parameter: "domainId"');} +let path='/projects/{projectId}/domains/{domainId}'.replace('{projectId}',projectId).replace('{domainId}',domainId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),deleteDomain:(projectId,domainId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(domainId===undefined){throw new AppwriteException('Missing required parameter: "domainId"');} +let path='/projects/{projectId}/domains/{domainId}'.replace('{projectId}',projectId).replace('{domainId}',domainId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),updateDomainVerification:(projectId,domainId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(domainId===undefined){throw new AppwriteException('Missing required parameter: "domainId"');} +let path='/projects/{projectId}/domains/{domainId}/verification'.replace('{projectId}',projectId).replace('{domainId}',domainId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),listKeys:(projectId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}/keys'.replace('{projectId}',projectId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createKey:(projectId,name,scopes)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(scopes===undefined){throw new AppwriteException('Missing required parameter: "scopes"');} +let path='/projects/{projectId}/keys'.replace('{projectId}',projectId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof scopes!=='undefined'){payload['scopes']=scopes;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getKey:(projectId,keyId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(keyId===undefined){throw new AppwriteException('Missing required parameter: "keyId"');} +let path='/projects/{projectId}/keys/{keyId}'.replace('{projectId}',projectId).replace('{keyId}',keyId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateKey:(projectId,keyId,name,scopes)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(keyId===undefined){throw new AppwriteException('Missing required parameter: "keyId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(scopes===undefined){throw new AppwriteException('Missing required parameter: "scopes"');} +let path='/projects/{projectId}/keys/{keyId}'.replace('{projectId}',projectId).replace('{keyId}',keyId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof scopes!=='undefined'){payload['scopes']=scopes;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),deleteKey:(projectId,keyId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(keyId===undefined){throw new AppwriteException('Missing required parameter: "keyId"');} +let path='/projects/{projectId}/keys/{keyId}'.replace('{projectId}',projectId).replace('{keyId}',keyId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),updateOAuth2:(projectId,provider,appId='',secret='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(provider===undefined){throw new AppwriteException('Missing required parameter: "provider"');} +let path='/projects/{projectId}/oauth2'.replace('{projectId}',projectId);let payload={};if(typeof provider!=='undefined'){payload['provider']=provider;} +if(typeof appId!=='undefined'){payload['appId']=appId;} +if(typeof secret!=='undefined'){payload['secret']=secret;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),listPlatforms:(projectId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}/platforms'.replace('{projectId}',projectId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createPlatform:(projectId,type,name,key='',store='',hostname='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(type===undefined){throw new AppwriteException('Missing required parameter: "type"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/projects/{projectId}/platforms'.replace('{projectId}',projectId);let payload={};if(typeof type!=='undefined'){payload['type']=type;} +if(typeof name!=='undefined'){payload['name']=name;} +if(typeof key!=='undefined'){payload['key']=key;} +if(typeof store!=='undefined'){payload['store']=store;} +if(typeof hostname!=='undefined'){payload['hostname']=hostname;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getPlatform:(projectId,platformId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(platformId===undefined){throw new AppwriteException('Missing required parameter: "platformId"');} +let path='/projects/{projectId}/platforms/{platformId}'.replace('{projectId}',projectId).replace('{platformId}',platformId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updatePlatform:(projectId,platformId,name,key='',store='',hostname='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(platformId===undefined){throw new AppwriteException('Missing required parameter: "platformId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/projects/{projectId}/platforms/{platformId}'.replace('{projectId}',projectId).replace('{platformId}',platformId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof key!=='undefined'){payload['key']=key;} +if(typeof store!=='undefined'){payload['store']=store;} +if(typeof hostname!=='undefined'){payload['hostname']=hostname;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),deletePlatform:(projectId,platformId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(platformId===undefined){throw new AppwriteException('Missing required parameter: "platformId"');} +let path='/projects/{projectId}/platforms/{platformId}'.replace('{projectId}',projectId).replace('{platformId}',platformId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),listTasks:(projectId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}/tasks'.replace('{projectId}',projectId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createTask:(projectId,name,status,schedule,security,httpMethod,httpUrl,httpHeaders=[],httpUser='',httpPass='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(status===undefined){throw new AppwriteException('Missing required parameter: "status"');} +if(schedule===undefined){throw new AppwriteException('Missing required parameter: "schedule"');} +if(security===undefined){throw new AppwriteException('Missing required parameter: "security"');} +if(httpMethod===undefined){throw new AppwriteException('Missing required parameter: "httpMethod"');} +if(httpUrl===undefined){throw new AppwriteException('Missing required parameter: "httpUrl"');} +let path='/projects/{projectId}/tasks'.replace('{projectId}',projectId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof status!=='undefined'){payload['status']=status;} +if(typeof schedule!=='undefined'){payload['schedule']=schedule;} +if(typeof security!=='undefined'){payload['security']=security;} +if(typeof httpMethod!=='undefined'){payload['httpMethod']=httpMethod;} +if(typeof httpUrl!=='undefined'){payload['httpUrl']=httpUrl;} +if(typeof httpHeaders!=='undefined'){payload['httpHeaders']=httpHeaders;} +if(typeof httpUser!=='undefined'){payload['httpUser']=httpUser;} +if(typeof httpPass!=='undefined'){payload['httpPass']=httpPass;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getTask:(projectId,taskId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(taskId===undefined){throw new AppwriteException('Missing required parameter: "taskId"');} +let path='/projects/{projectId}/tasks/{taskId}'.replace('{projectId}',projectId).replace('{taskId}',taskId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateTask:(projectId,taskId,name,status,schedule,security,httpMethod,httpUrl,httpHeaders=[],httpUser='',httpPass='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(taskId===undefined){throw new AppwriteException('Missing required parameter: "taskId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(status===undefined){throw new AppwriteException('Missing required parameter: "status"');} +if(schedule===undefined){throw new AppwriteException('Missing required parameter: "schedule"');} +if(security===undefined){throw new AppwriteException('Missing required parameter: "security"');} +if(httpMethod===undefined){throw new AppwriteException('Missing required parameter: "httpMethod"');} +if(httpUrl===undefined){throw new AppwriteException('Missing required parameter: "httpUrl"');} +let path='/projects/{projectId}/tasks/{taskId}'.replace('{projectId}',projectId).replace('{taskId}',taskId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof status!=='undefined'){payload['status']=status;} +if(typeof schedule!=='undefined'){payload['schedule']=schedule;} +if(typeof security!=='undefined'){payload['security']=security;} +if(typeof httpMethod!=='undefined'){payload['httpMethod']=httpMethod;} +if(typeof httpUrl!=='undefined'){payload['httpUrl']=httpUrl;} +if(typeof httpHeaders!=='undefined'){payload['httpHeaders']=httpHeaders;} +if(typeof httpUser!=='undefined'){payload['httpUser']=httpUser;} +if(typeof httpPass!=='undefined'){payload['httpPass']=httpPass;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),deleteTask:(projectId,taskId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(taskId===undefined){throw new AppwriteException('Missing required parameter: "taskId"');} +let path='/projects/{projectId}/tasks/{taskId}'.replace('{projectId}',projectId).replace('{taskId}',taskId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),getUsage:(projectId,range='30d')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}/usage'.replace('{projectId}',projectId);let payload={};if(range){payload['range']=range;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),listWebhooks:(projectId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +let path='/projects/{projectId}/webhooks'.replace('{projectId}',projectId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createWebhook:(projectId,name,events,url,security,httpUser='',httpPass='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(events===undefined){throw new AppwriteException('Missing required parameter: "events"');} +if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} +if(security===undefined){throw new AppwriteException('Missing required parameter: "security"');} +let path='/projects/{projectId}/webhooks'.replace('{projectId}',projectId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof events!=='undefined'){payload['events']=events;} +if(typeof url!=='undefined'){payload['url']=url;} +if(typeof security!=='undefined'){payload['security']=security;} +if(typeof httpUser!=='undefined'){payload['httpUser']=httpUser;} +if(typeof httpPass!=='undefined'){payload['httpPass']=httpPass;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),getWebhook:(projectId,webhookId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(webhookId===undefined){throw new AppwriteException('Missing required parameter: "webhookId"');} +let path='/projects/{projectId}/webhooks/{webhookId}'.replace('{projectId}',projectId).replace('{webhookId}',webhookId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateWebhook:(projectId,webhookId,name,events,url,security,httpUser='',httpPass='')=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(webhookId===undefined){throw new AppwriteException('Missing required parameter: "webhookId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +if(events===undefined){throw new AppwriteException('Missing required parameter: "events"');} +if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} +if(security===undefined){throw new AppwriteException('Missing required parameter: "security"');} +let path='/projects/{projectId}/webhooks/{webhookId}'.replace('{projectId}',projectId).replace('{webhookId}',webhookId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof events!=='undefined'){payload['events']=events;} +if(typeof url!=='undefined'){payload['url']=url;} +if(typeof security!=='undefined'){payload['security']=security;} +if(typeof httpUser!=='undefined'){payload['httpUser']=httpUser;} +if(typeof httpPass!=='undefined'){payload['httpPass']=httpPass;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),deleteWebhook:(projectId,webhookId)=>__awaiter(this,void 0,void 0,function*(){if(projectId===undefined){throw new AppwriteException('Missing required parameter: "projectId"');} +if(webhookId===undefined){throw new AppwriteException('Missing required parameter: "webhookId"');} +let path='/projects/{projectId}/webhooks/{webhookId}'.replace('{projectId}',projectId).replace('{webhookId}',webhookId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);})};this.storage={listFiles:(search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){let path='/storage/files';let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},createFile:function(file,read,write){if(file===undefined){throw new Error('Missing required parameter: "file"');} -if(read===undefined){throw new Error('Missing required parameter: "read"');} -if(write===undefined){throw new Error('Missing required parameter: "write"');} -let path='/storage/files';let payload={};if(file){payload['file']=file;} -if(read){payload['read']=read;} -if(write){payload['write']=write;} -return http.post(path,{'content-type':'multipart/form-data',},payload);},getFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"');} -let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updateFile:function(fileId,read,write){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"');} -if(read===undefined){throw new Error('Missing required parameter: "read"');} -if(write===undefined){throw new Error('Missing required parameter: "write"');} -let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);let payload={};if(read){payload['read']=read;} -if(write){payload['write']=write;} -return http.put(path,{'content-type':'application/json',},payload);},deleteFile:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"');} -let path='/storage/files/{fileId}'.replace(new RegExp('{fileId}','g'),fileId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},getFileDownload:function(fileId){if(fileId===undefined){throw new Error('Missing required parameter: "fileId"');} -let path='/storage/files/{fileId}/download'.replace(new RegExp('{fileId}','g'),fileId);let payload={};payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index__awaiter(this,void 0,void 0,function*(){if(file===undefined){throw new AppwriteException('Missing required parameter: "file"');} +let path='/storage/files';let payload={};if(typeof file!=='undefined'){payload['file']=file;} +if(typeof read!=='undefined'){payload['read']=read;} +if(typeof write!=='undefined'){payload['write']=write;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'multipart/form-data',},payload);}),getFile:(fileId)=>__awaiter(this,void 0,void 0,function*(){if(fileId===undefined){throw new AppwriteException('Missing required parameter: "fileId"');} +let path='/storage/files/{fileId}'.replace('{fileId}',fileId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updateFile:(fileId,read,write)=>__awaiter(this,void 0,void 0,function*(){if(fileId===undefined){throw new AppwriteException('Missing required parameter: "fileId"');} +if(read===undefined){throw new AppwriteException('Missing required parameter: "read"');} +if(write===undefined){throw new AppwriteException('Missing required parameter: "write"');} +let path='/storage/files/{fileId}'.replace('{fileId}',fileId);let payload={};if(typeof read!=='undefined'){payload['read']=read;} +if(typeof write!=='undefined'){payload['write']=write;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),deleteFile:(fileId)=>__awaiter(this,void 0,void 0,function*(){if(fileId===undefined){throw new AppwriteException('Missing required parameter: "fileId"');} +let path='/storage/files/{fileId}'.replace('{fileId}',fileId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),getFileDownload:(fileId)=>{if(fileId===undefined){throw new AppwriteException('Missing required parameter: "fileId"');} +let path='/storage/files/{fileId}/download'.replace('{fileId}',fileId);let payload={};const uri=new URL(this.config.endpoint+path);payload['project']=this.config.project;for(const[key,value]of Object.entries(this.flatten(payload))){uri.searchParams.append(key,value);} +return uri;},getFilePreview:(fileId,width=0,height=0,quality=100,borderWidth=0,borderColor='',borderRadius=0,opacity=1,rotation=0,background='',output='')=>{if(fileId===undefined){throw new AppwriteException('Missing required parameter: "fileId"');} +let path='/storage/files/{fileId}/preview'.replace('{fileId}',fileId);let payload={};if(width){payload['width']=width;} if(height){payload['height']=height;} if(quality){payload['quality']=quality;} +if(borderWidth){payload['borderWidth']=borderWidth;} +if(borderColor){payload['borderColor']=borderColor;} +if(borderRadius){payload['borderRadius']=borderRadius;} +if(opacity){payload['opacity']=opacity;} +if(rotation){payload['rotation']=rotation;} if(background){payload['background']=background;} if(output){payload['output']=output;} -payload['project']=config.project;payload['key']=config.key;let query=[];for(let p in payload){if(Array.isArray(payload[p])){for(let index=0;index{if(fileId===undefined){throw new AppwriteException('Missing required parameter: "fileId"');} +let path='/storage/files/{fileId}/view'.replace('{fileId}',fileId);let payload={};const uri=new URL(this.config.endpoint+path);payload['project']=this.config.project;for(const[key,value]of Object.entries(this.flatten(payload))){uri.searchParams.append(key,value);} +return uri;}};this.teams={list:(search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){let path='/teams';let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},create:function(name,roles=["owner"]){if(name===undefined){throw new Error('Missing required parameter: "name"');} -let path='/teams';let payload={};if(name){payload['name']=name;} -if(roles){payload['roles']=roles;} -return http.post(path,{'content-type':'application/json',},payload);},get:function(teamId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -let path='/teams/{teamId}'.replace(new RegExp('{teamId}','g'),teamId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},update:function(teamId,name){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -if(name===undefined){throw new Error('Missing required parameter: "name"');} -let path='/teams/{teamId}'.replace(new RegExp('{teamId}','g'),teamId);let payload={};if(name){payload['name']=name;} -return http.put(path,{'content-type':'application/json',},payload);},delete:function(teamId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -let path='/teams/{teamId}'.replace(new RegExp('{teamId}','g'),teamId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},getMemberships:function(teamId,search='',limit=25,offset=0,orderType='ASC'){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -let path='/teams/{teamId}/memberships'.replace(new RegExp('{teamId}','g'),teamId);let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),create:(name,roles=["owner"])=>__awaiter(this,void 0,void 0,function*(){if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/teams';let payload={};if(typeof name!=='undefined'){payload['name']=name;} +if(typeof roles!=='undefined'){payload['roles']=roles;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),get:(teamId)=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +let path='/teams/{teamId}'.replace('{teamId}',teamId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),update:(teamId,name)=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +if(name===undefined){throw new AppwriteException('Missing required parameter: "name"');} +let path='/teams/{teamId}'.replace('{teamId}',teamId);let payload={};if(typeof name!=='undefined'){payload['name']=name;} +const uri=new URL(this.config.endpoint+path);return yield this.call('put',uri,{'content-type':'application/json',},payload);}),delete:(teamId)=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +let path='/teams/{teamId}'.replace('{teamId}',teamId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),getMemberships:(teamId,search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +let path='/teams/{teamId}/memberships'.replace('{teamId}',teamId);let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},createMembership:function(teamId,email,roles,url,name=''){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -if(email===undefined){throw new Error('Missing required parameter: "email"');} -if(roles===undefined){throw new Error('Missing required parameter: "roles"');} -if(url===undefined){throw new Error('Missing required parameter: "url"');} -let path='/teams/{teamId}/memberships'.replace(new RegExp('{teamId}','g'),teamId);let payload={};if(email){payload['email']=email;} -if(name){payload['name']=name;} -if(roles){payload['roles']=roles;} -if(url){payload['url']=url;} -return http.post(path,{'content-type':'application/json',},payload);},deleteMembership:function(teamId,inviteId){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -if(inviteId===undefined){throw new Error('Missing required parameter: "inviteId"');} -let path='/teams/{teamId}/memberships/{inviteId}'.replace(new RegExp('{teamId}','g'),teamId).replace(new RegExp('{inviteId}','g'),inviteId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},updateMembershipStatus:function(teamId,inviteId,userId,secret){if(teamId===undefined){throw new Error('Missing required parameter: "teamId"');} -if(inviteId===undefined){throw new Error('Missing required parameter: "inviteId"');} -if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -if(secret===undefined){throw new Error('Missing required parameter: "secret"');} -let path='/teams/{teamId}/memberships/{inviteId}/status'.replace(new RegExp('{teamId}','g'),teamId).replace(new RegExp('{inviteId}','g'),inviteId);let payload={};if(userId){payload['userId']=userId;} -if(secret){payload['secret']=secret;} -return http.patch(path,{'content-type':'application/json',},payload);}};let users={list:function(search='',limit=25,offset=0,orderType='ASC'){let path='/users';let payload={};if(search){payload['search']=search;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),createMembership:(teamId,email,roles,url,name='')=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +if(email===undefined){throw new AppwriteException('Missing required parameter: "email"');} +if(roles===undefined){throw new AppwriteException('Missing required parameter: "roles"');} +if(url===undefined){throw new AppwriteException('Missing required parameter: "url"');} +let path='/teams/{teamId}/memberships'.replace('{teamId}',teamId);let payload={};if(typeof email!=='undefined'){payload['email']=email;} +if(typeof name!=='undefined'){payload['name']=name;} +if(typeof roles!=='undefined'){payload['roles']=roles;} +if(typeof url!=='undefined'){payload['url']=url;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),updateMembershipRoles:(teamId,membershipId,roles)=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +if(membershipId===undefined){throw new AppwriteException('Missing required parameter: "membershipId"');} +if(roles===undefined){throw new AppwriteException('Missing required parameter: "roles"');} +let path='/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}',teamId).replace('{membershipId}',membershipId);let payload={};if(typeof roles!=='undefined'){payload['roles']=roles;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),deleteMembership:(teamId,membershipId)=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +if(membershipId===undefined){throw new AppwriteException('Missing required parameter: "membershipId"');} +let path='/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}',teamId).replace('{membershipId}',membershipId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),updateMembershipStatus:(teamId,membershipId,userId,secret)=>__awaiter(this,void 0,void 0,function*(){if(teamId===undefined){throw new AppwriteException('Missing required parameter: "teamId"');} +if(membershipId===undefined){throw new AppwriteException('Missing required parameter: "membershipId"');} +if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +if(secret===undefined){throw new AppwriteException('Missing required parameter: "secret"');} +let path='/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}',teamId).replace('{membershipId}',membershipId);let payload={};if(typeof userId!=='undefined'){payload['userId']=userId;} +if(typeof secret!=='undefined'){payload['secret']=secret;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);})};this.users={list:(search='',limit=25,offset=0,orderType='ASC')=>__awaiter(this,void 0,void 0,function*(){let path='/users';let payload={};if(search){payload['search']=search;} if(limit){payload['limit']=limit;} if(offset){payload['offset']=offset;} if(orderType){payload['orderType']=orderType;} -return http.get(path,{'content-type':'application/json',},payload);},create:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"');} -if(password===undefined){throw new Error('Missing required parameter: "password"');} -let path='/users';let payload={};if(email){payload['email']=email;} -if(password){payload['password']=password;} -if(name){payload['name']=name;} -return http.post(path,{'content-type':'application/json',},payload);},get:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -let path='/users/{userId}'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},deleteUser:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -let path='/users/{userId}'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},getLogs:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -let path='/users/{userId}/logs'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},getPrefs:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -let path='/users/{userId}/prefs'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},updatePrefs:function(userId,prefs){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -if(prefs===undefined){throw new Error('Missing required parameter: "prefs"');} -let path='/users/{userId}/prefs'.replace(new RegExp('{userId}','g'),userId);let payload={};if(prefs){payload['prefs']=prefs;} -return http.patch(path,{'content-type':'application/json',},payload);},getSessions:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -let path='/users/{userId}/sessions'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.get(path,{'content-type':'application/json',},payload);},deleteSessions:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -let path='/users/{userId}/sessions'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},deleteSession:function(userId,sessionId){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"');} -let path='/users/{userId}/sessions/{sessionId}'.replace(new RegExp('{userId}','g'),userId).replace(new RegExp('{sessionId}','g'),sessionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},updateStatus:function(userId,status){if(userId===undefined){throw new Error('Missing required parameter: "userId"');} -if(status===undefined){throw new Error('Missing required parameter: "status"');} -let path='/users/{userId}/status'.replace(new RegExp('{userId}','g'),userId);let payload={};if(status){payload['status']=status;} -return http.patch(path,{'content-type':'application/json',},payload);}};return{setEndpoint:setEndpoint,setProject:setProject,setKey:setKey,setLocale:setLocale,setMode:setMode,account:account,avatars:avatars,database:database,functions:functions,health:health,locale:locale,projects:projects,storage:storage,teams:teams,users:users};};if(typeof module!=="undefined"){module.exports=window.Appwrite;}})((typeof window!=="undefined")?window:{});(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory(function(){try{return require('moment');}catch(e){}}()):typeof define==='function'&&define.amd?define(['require'],function(require){return factory(function(){try{return require('moment');}catch(e){}}());}):(global=global||self,global.Chart=factory(global.moment));}(this,(function(moment){'use strict';moment=moment&&moment.hasOwnProperty('default')?moment['default']:moment;function createCommonjsModule(fn,module){return module={exports:{}},fn(module,module.exports),module.exports;} +const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),create:(email,password,name='')=>__awaiter(this,void 0,void 0,function*(){if(email===undefined){throw new AppwriteException('Missing required parameter: "email"');} +if(password===undefined){throw new AppwriteException('Missing required parameter: "password"');} +let path='/users';let payload={};if(typeof email!=='undefined'){payload['email']=email;} +if(typeof password!=='undefined'){payload['password']=password;} +if(typeof name!=='undefined'){payload['name']=name;} +const uri=new URL(this.config.endpoint+path);return yield this.call('post',uri,{'content-type':'application/json',},payload);}),get:(userId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +let path='/users/{userId}'.replace('{userId}',userId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),delete:(userId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +let path='/users/{userId}'.replace('{userId}',userId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),getLogs:(userId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +let path='/users/{userId}/logs'.replace('{userId}',userId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),getPrefs:(userId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +let path='/users/{userId}/prefs'.replace('{userId}',userId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),updatePrefs:(userId,prefs)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +if(prefs===undefined){throw new AppwriteException('Missing required parameter: "prefs"');} +let path='/users/{userId}/prefs'.replace('{userId}',userId);let payload={};if(typeof prefs!=='undefined'){payload['prefs']=prefs;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);}),getSessions:(userId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +let path='/users/{userId}/sessions'.replace('{userId}',userId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('get',uri,{'content-type':'application/json',},payload);}),deleteSessions:(userId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +let path='/users/{userId}/sessions'.replace('{userId}',userId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),deleteSession:(userId,sessionId)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +if(sessionId===undefined){throw new AppwriteException('Missing required parameter: "sessionId"');} +let path='/users/{userId}/sessions/{sessionId}'.replace('{userId}',userId).replace('{sessionId}',sessionId);let payload={};const uri=new URL(this.config.endpoint+path);return yield this.call('delete',uri,{'content-type':'application/json',},payload);}),updateStatus:(userId,status)=>__awaiter(this,void 0,void 0,function*(){if(userId===undefined){throw new AppwriteException('Missing required parameter: "userId"');} +if(status===undefined){throw new AppwriteException('Missing required parameter: "status"');} +let path='/users/{userId}/status'.replace('{userId}',userId);let payload={};if(typeof status!=='undefined'){payload['status']=status;} +const uri=new URL(this.config.endpoint+path);return yield this.call('patch',uri,{'content-type':'application/json',},payload);})};} +setEndpoint(endpoint){this.config.endpoint=endpoint;return this;} +setProject(value){this.headers['X-Appwrite-Project']=value;this.config.project=value;return this;} +setKey(value){this.headers['X-Appwrite-Key']=value;this.config.key=value;return this;} +setJWT(value){this.headers['X-Appwrite-JWT']=value;this.config.jwt=value;return this;} +setLocale(value){this.headers['X-Appwrite-Locale']=value;this.config.locale=value;return this;} +setMode(value){this.headers['X-Appwrite-Mode']=value;this.config.mode=value;return this;} +call(method,url,headers={},params={}){var _a,_b;return __awaiter(this,void 0,void 0,function*(){method=method.toUpperCase();headers=Object.assign(Object.assign({},headers),this.headers);let options={method,headers,credentials:'include'};if(typeof window!=='undefined'&&window.localStorage){headers['X-Fallback-Cookies']=(_a=window.localStorage.getItem('cookieFallback'))!==null&&_a!==void 0?_a:"";} +if(method==='GET'){for(const[key,value]of Object.entries(this.flatten(params))){url.searchParams.append(key,value);}} +else{switch(headers['content-type']){case'application/json':options.body=JSON.stringify(params);break;case'multipart/form-data':let formData=new FormData();for(const key in params){if(Array.isArray(params[key])){formData.append(key+'[]',params[key].join(','));} +else{formData.append(key,params[key]);}} +options.body=formData;delete headers['content-type'];break;}} +try{let data=null;const response=yield crossFetch.fetch(url.toString(),options);if((_b=response.headers.get("content-type"))===null||_b===void 0?void 0:_b.includes("application/json")){data=yield response.json();} +else{data={message:yield response.text()};} +if(400<=response.status){throw new AppwriteException(data===null||data===void 0?void 0:data.message,response.status,data);} +const cookieFallback=response.headers.get('X-Fallback-Cookies');if(typeof window!=='undefined'&&window.localStorage&&cookieFallback){window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.');window.localStorage.setItem('cookieFallback',cookieFallback);} +return data;} +catch(e){throw new AppwriteException(e.message);}});} +flatten(data,prefix=''){let output={};for(const key in data){let value=data[key];let finalKey=prefix?`${prefix}[${key}]`:key;if(Array.isArray(value)){output=Object.assign(output,this.flatten(value,finalKey));} +else{output[finalKey]=value;}} +return output;}} +exports.Appwrite=Appwrite;return exports;}({},null,window));(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory(function(){try{return require('moment');}catch(e){}}()):typeof define==='function'&&define.amd?define(['require'],function(require){return factory(function(){try{return require('moment');}catch(e){}}());}):(global=global||self,global.Chart=factory(global.moment));}(this,(function(moment){'use strict';moment=moment&&moment.hasOwnProperty('default')?moment['default']:moment;function createCommonjsModule(fn,module){return module={exports:{}},fn(module,module.exports),module.exports;} function getCjsExportFromNamespace(n){return n&&n['default']||n;} var colorName={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]};var conversions=createCommonjsModule(function(module){var reverseKeywords={};for(var key in colorName){if(colorName.hasOwnProperty(key)){reverseKeywords[colorName[key]]=key;}} var convert=module.exports={rgb:{channels:3,labels:'rgb'},hsl:{channels:3,labels:'hsl'},hsv:{channels:3,labels:'hsv'},hwb:{channels:3,labels:'hwb'},cmyk:{channels:4,labels:'cmyk'},xyz:{channels:3,labels:'xyz'},lab:{channels:3,labels:'lab'},lch:{channels:3,labels:'lch'},hex:{channels:1,labels:['hex']},keyword:{channels:1,labels:['keyword']},ansi16:{channels:1,labels:['ansi16']},ansi256:{channels:1,labels:['ansi256']},hcg:{channels:3,labels:['h','c','g']},apple:{channels:3,labels:['r16','g16','b16']},gray:{channels:1,labels:['gray']}};for(var model in convert){if(convert.hasOwnProperty(model)){if(!('channels'in convert[model])){throw new Error('missing channels property: '+model);} diff --git a/public/dist/scripts/app.js b/public/dist/scripts/app.js index 079dc0868..b3ac95c23 100644 --- a/public/dist/scripts/app.js +++ b/public/dist/scripts/app.js @@ -152,7 +152,7 @@ params=formData;break;} return new Promise(function(resolve,reject){let request=new XMLHttpRequest(),key;request.withCredentials=true;request.open(method,path,true);for(key in headers){if(headers.hasOwnProperty(key)){request.setRequestHeader(key,headers[key]);}} request.onload=function(){if(4===request.readyState&&399>=request.status){let data=request.response;let contentType=this.getResponseHeader('content-type');contentType=contentType.substring(0,contentType.indexOf(';'));switch(contentType){case'application/json':data=JSON.parse(data);break;} resolve(data);}else{reject(new Error(request.statusText));}};if(progress){request.addEventListener('progress',progress);request.upload.addEventListener('progress',progress,false);} -request.onerror=function(){reject(new Error("Network Error"));};request.send(params);})};return{'get':function(path,headers={},params={}){return call('GET',path+((params.length>0)?'?'+buildQuery(params):''),headers,{});},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress);},'put':function(path,headers={},params={},progress=null){return call('PUT',headers,params,progress);},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress);},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress);},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let analytics={create:function(id,source,activity,url){return http.post('/analytics',{'content-type':'application/json'},{id:id,source:source,activity:activity,url:url,version:env.VERSION,setup:env.SETUP});},};return{analytics:analytics,};},true);})(window);(function(window){"use strict";window.ls.container.set('console',function(window){var sdk=new window.Appwrite();sdk.setEndpoint(APP_ENV.API).setProject('console').setLocale(APP_ENV.LOCALE);return sdk;},true);})(window);(function(window){"use strict";window.ls.container.set('date',function(){function format(format,timestamp){var jsdate,f +request.onerror=function(){reject(new Error("Network Error"));};request.send(params);})};return{'get':function(path,headers={},params={}){return call('GET',path+((params.length>0)?'?'+buildQuery(params):''),headers,{});},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress);},'put':function(path,headers={},params={},progress=null){return call('PUT',headers,params,progress);},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress);},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress);},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let analytics={create:function(id,source,activity,url){return http.post('/analytics',{'content-type':'application/json'},{id:id,source:source,activity:activity,url:url,version:env.VERSION,setup:env.SETUP});},};return{analytics:analytics,};},true);})(window);(function(window){"use strict";window.ls.container.set('console',function(window){var sdk=new window.Appwrite.Appwrite();sdk.setEndpoint(APP_ENV.ENDPOINT+APP_ENV.API).setProject('console').setLocale(APP_ENV.LOCALE);return sdk;},true);})(window);(function(window){"use strict";window.ls.container.set('date',function(){function format(format,timestamp){var jsdate,f var txtWords=['Sun','Mon','Tues','Wednes','Thurs','Fri','Satur','January','February','March','April','May','June','July','August','September','October','November','December'] var formatChr=/\\?(.?)/gi var formatChrCb=function(t,s){return f[t]?f[t]():s} @@ -281,7 +281,7 @@ return slf.renderToken(tokens,idx,opts);} md.renderer.rules.strong_open=renderEm;md.renderer.rules.strong_close=renderEm;return md;},true);})(window);(function(window){"use strict";window.ls.container.set('rtl',function(){var rtlStock="^ا^ب^ت^ث^ج^ح^خ^د^ذ^ر^ز^س^ش^ص^ض^ط^ظ^ع^غ^ف^ق^ك^ل^م^ن^ه^و^ي^א^ב^ג^ד^ה^ו^ז^ח^ט^י^כ^ך^ל^מ^ם^נ^ן^ס^ע^פ^ף^צ^ץ^ק^ר^ש^ת^";var special=["\n"," "," ","״",'"',"_","'","!","@","#","$","^","&","%","*","(",")","+","=","-","[","]","\\","/","{","}","|",":","<",">","?",",",".","0","1","2","3","4","5","6","7","8","9"];var isRTL=function(value){for(var i=0;i __awaiter(this, void 0, void 0, function* () { + let path = '/account'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Account + * + * Use this endpoint to allow a new user to register a new account in your + * project. After the user registration completes successfully, you can use + * the [/account/verfication](/docs/client/account#accountCreateVerification) + * route to start verifying the user email address. To allow the new user to + * login to their new account, you need to create a new [account + * session](/docs/client/account#accountCreateSession). + * + * @param {string} email + * @param {string} password + * @param {string} name + * @throws {AppwriteException} + * @returns {Promise} + */ + create: (email, password, name = '') => __awaiter(this, void 0, void 0, function* () { + if (email === undefined) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (password === undefined) { + throw new AppwriteException('Missing required parameter: "password"'); + } + let path = '/account'; + let payload = {}; + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete Account + * + * Delete a currently logged in user account. Behind the scene, the user + * record is not deleted but permanently blocked from any access. This is done + * to avoid deleted accounts being overtaken by new users with the same email + * address. Any user-related resources like documents or storage files should + * be deleted separately. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + delete: () => __awaiter(this, void 0, void 0, function* () { + let path = '/account'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Account Email + * + * Update currently logged in user account email address. After changing user + * address, user confirmation status is being reset and a new confirmation + * mail is sent. For security measures, user password is required to complete + * this request. + * This endpoint can also be used to convert an anonymous account to a normal + * one, by passing an email address and a new password. + * + * @param {string} email + * @param {string} password + * @throws {AppwriteException} + * @returns {Promise} + */ + updateEmail: (email, password) => __awaiter(this, void 0, void 0, function* () { + if (email === undefined) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (password === undefined) { + throw new AppwriteException('Missing required parameter: "password"'); + } + let path = '/account/email'; + let payload = {}; + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Account JWT + * + * Use this endpoint to create a JSON Web Token. You can use the resulting JWT + * to authenticate on behalf of the current user when working with the + * Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes + * from its creation and will be invalid if the user will logout. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + createJWT: () => __awaiter(this, void 0, void 0, function* () { + let path = '/account/jwt'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Account Logs + * + * Get currently logged in user list of latest security activity logs. Each + * log returns user IP address, location and date and time of log. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getLogs: () => __awaiter(this, void 0, void 0, function* () { + let path = '/account/logs'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Account Name + * + * Update currently logged in user account name. + * + * @param {string} name + * @throws {AppwriteException} + * @returns {Promise} + */ + updateName: (name) => __awaiter(this, void 0, void 0, function* () { + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + let path = '/account/name'; + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Account Password + * + * Update currently logged in user password. For validation, user is required + * to pass in the new password, and the old password. For users created with + * OAuth and Team Invites, oldPassword is optional. + * + * @param {string} password + * @param {string} oldPassword + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePassword: (password, oldPassword = '') => __awaiter(this, void 0, void 0, function* () { + if (password === undefined) { + throw new AppwriteException('Missing required parameter: "password"'); + } + let path = '/account/password'; + let payload = {}; + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof oldPassword !== 'undefined') { + payload['oldPassword'] = oldPassword; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Account Preferences + * + * Get currently logged in user preferences as a key-value object. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getPrefs: () => __awaiter(this, void 0, void 0, function* () { + let path = '/account/prefs'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Account Preferences + * + * Update currently logged in user account preferences. You can pass only the + * specific settings you wish to update. + * + * @param {object} prefs + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePrefs: (prefs) => __awaiter(this, void 0, void 0, function* () { + if (prefs === undefined) { + throw new AppwriteException('Missing required parameter: "prefs"'); + } + let path = '/account/prefs'; + let payload = {}; + if (typeof prefs !== 'undefined') { + payload['prefs'] = prefs; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Password Recovery + * + * Sends the user an email with a temporary secret key for password reset. + * When the user clicks the confirmation link he is redirected back to your + * app password reset URL with the secret key and email address values + * attached to the URL query string. Use the query string params to submit a + * request to the [PUT + * /account/recovery](/docs/client/account#accountUpdateRecovery) endpoint to + * complete the process. The verification link sent to the user's email + * address is valid for 1 hour. + * + * @param {string} email + * @param {string} url + * @throws {AppwriteException} + * @returns {Promise} + */ + createRecovery: (email, url) => __awaiter(this, void 0, void 0, function* () { + if (email === undefined) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (url === undefined) { + throw new AppwriteException('Missing required parameter: "url"'); + } + let path = '/account/recovery'; + let payload = {}; + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof url !== 'undefined') { + payload['url'] = url; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Complete Password Recovery + * + * Use this endpoint to complete the user account password reset. Both the + * **userId** and **secret** arguments will be passed as query parameters to + * the redirect URL you have provided when sending your request to the [POST + * /account/recovery](/docs/client/account#accountCreateRecovery) endpoint. + * + * Please note that in order to avoid a [Redirect + * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * the only valid redirect URLs are the ones from domains you have set when + * adding your platforms in the console interface. + * + * @param {string} userId + * @param {string} secret + * @param {string} password + * @param {string} passwordAgain + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRecovery: (userId, secret, password, passwordAgain) => __awaiter(this, void 0, void 0, function* () { + if (userId === undefined) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (secret === undefined) { + throw new AppwriteException('Missing required parameter: "secret"'); + } + if (password === undefined) { + throw new AppwriteException('Missing required parameter: "password"'); + } + if (passwordAgain === undefined) { + throw new AppwriteException('Missing required parameter: "passwordAgain"'); + } + let path = '/account/recovery'; + let payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof passwordAgain !== 'undefined') { + payload['passwordAgain'] = passwordAgain; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('put', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Account Sessions + * + * Get currently logged in user list of active sessions across different + * devices. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getSessions: () => __awaiter(this, void 0, void 0, function* () { + let path = '/account/sessions'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Account Session + * + * Allow the user to login into their account by providing a valid email and + * password combination. This route will create a new session for the user. + * + * @param {string} email + * @param {string} password + * @throws {AppwriteException} + * @returns {Promise} + */ + createSession: (email, password) => __awaiter(this, void 0, void 0, function* () { + if (email === undefined) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (password === undefined) { + throw new AppwriteException('Missing required parameter: "password"'); + } + let path = '/account/sessions'; + let payload = {}; + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete All Account Sessions + * + * Delete all sessions from the user account and remove any sessions cookies + * from the end client. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteSessions: () => __awaiter(this, void 0, void 0, function* () { + let path = '/account/sessions'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Anonymous Session + * + * Use this endpoint to allow a new user to register an anonymous account in + * your project. This route will also create a new session for the user. To + * allow the new user to convert an anonymous account to a normal account + * account, you need to update its [email and + * password](/docs/client/account#accountUpdateEmail). + * + * @throws {AppwriteException} + * @returns {Promise} + */ + createAnonymousSession: () => __awaiter(this, void 0, void 0, function* () { + let path = '/account/sessions/anonymous'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Account Session with OAuth2 + * + * Allow the user to login to their account using the OAuth2 provider of their + * choice. Each OAuth2 provider should be enabled from the Appwrite console + * first. Use the success and failure arguments to provide a redirect URL's + * back to your app when login is completed. + * + * @param {string} provider + * @param {string} success + * @param {string} failure + * @param {string[]} scopes + * @throws {AppwriteException} + * @returns {void|string} + */ + createOAuth2Session: (provider, success = 'https://appwrite.io/auth/oauth2/success', failure = 'https://appwrite.io/auth/oauth2/failure', scopes = []) => { + if (provider === undefined) { + throw new AppwriteException('Missing required parameter: "provider"'); + } + let path = '/account/sessions/oauth2/{provider}'.replace('{provider}', provider); + let payload = {}; + if (success) { + payload['success'] = success; + } + if (failure) { + payload['failure'] = failure; + } + if (scopes) { + payload['scopes'] = scopes; + } + const uri = new URL(this.config.endpoint + path); + payload['project'] = this.config.project; + for (const [key, value] of Object.entries(this.flatten(payload))) { + uri.searchParams.append(key, value); + } + if (typeof window !== 'undefined' && (window === null || window === void 0 ? void 0 : window.location)) { + window.location.href = uri.toString(); + } + else { + return uri; + } + }, + /** + * Delete Account Session + * + * Use this endpoint to log out the currently logged in user from all their + * account sessions across all of their different devices. When using the + * option id argument, only the session unique ID provider will be deleted. + * + * @param {string} sessionId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteSession: (sessionId) => __awaiter(this, void 0, void 0, function* () { + if (sessionId === undefined) { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Email Verification + * + * Use this endpoint to send a verification message to your user email address + * to confirm they are the valid owners of that address. Both the **userId** + * and **secret** arguments will be passed as query parameters to the URL you + * have provided to be attached to the verification email. The provided URL + * should redirect the user back to your app and allow you to complete the + * verification process by verifying both the **userId** and **secret** + * parameters. Learn more about how to [complete the verification + * process](/docs/client/account#accountUpdateVerification). The verification + * link sent to the user's email address is valid for 7 days. + * + * Please note that in order to avoid a [Redirect + * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), + * the only valid redirect URLs are the ones from domains you have set when + * adding your platforms in the console interface. + * + * + * @param {string} url + * @throws {AppwriteException} + * @returns {Promise} + */ + createVerification: (url) => __awaiter(this, void 0, void 0, function* () { + if (url === undefined) { + throw new AppwriteException('Missing required parameter: "url"'); + } + let path = '/account/verification'; + let payload = {}; + if (typeof url !== 'undefined') { + payload['url'] = url; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Complete Email Verification + * + * Use this endpoint to complete the user email verification process. Use both + * the **userId** and **secret** parameters that were attached to your app URL + * to verify the user email ownership. If confirmed this route will return a + * 200 status code. + * + * @param {string} userId + * @param {string} secret + * @throws {AppwriteException} + * @returns {Promise} + */ + updateVerification: (userId, secret) => __awaiter(this, void 0, void 0, function* () { + if (userId === undefined) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (secret === undefined) { + throw new AppwriteException('Missing required parameter: "secret"'); + } + let path = '/account/verification'; + let payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('put', uri, { + 'content-type': 'application/json', + }, payload); + }) + }; + this.avatars = { + /** + * Get Browser Icon + * + * You can use this endpoint to show different browser icons to your users. + * The code argument receives the browser code as it appears in your user + * /account/sessions endpoint. Use width, height and quality arguments to + * change the output settings. + * + * @param {string} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {AppwriteException} + * @returns {URL} + */ + getBrowser: (code, width = 100, height = 100, quality = 100) => { + if (code === undefined) { + throw new AppwriteException('Missing required parameter: "code"'); + } + let path = '/avatars/browsers/{code}'.replace('{code}', code); + let payload = {}; + if (width) { + payload['width'] = width; + } + if (height) { + payload['height'] = height; + } + if (quality) { + payload['quality'] = quality; + } + const uri = new URL(this.config.endpoint + path); + payload['project'] = this.config.project; + for (const [key, value] of Object.entries(this.flatten(payload))) { + uri.searchParams.append(key, value); + } + return uri; + }, + /** + * Get Credit Card Icon + * + * The credit card endpoint will return you the icon of the credit card + * provider you need. Use width, height and quality arguments to change the + * output settings. + * + * @param {string} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {AppwriteException} + * @returns {URL} + */ + getCreditCard: (code, width = 100, height = 100, quality = 100) => { + if (code === undefined) { + throw new AppwriteException('Missing required parameter: "code"'); + } + let path = '/avatars/credit-cards/{code}'.replace('{code}', code); + let payload = {}; + if (width) { + payload['width'] = width; + } + if (height) { + payload['height'] = height; + } + if (quality) { + payload['quality'] = quality; + } + const uri = new URL(this.config.endpoint + path); + payload['project'] = this.config.project; + for (const [key, value] of Object.entries(this.flatten(payload))) { + uri.searchParams.append(key, value); + } + return uri; + }, + /** + * Get Favicon + * + * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote + * website URL. + * + * + * @param {string} url + * @throws {AppwriteException} + * @returns {URL} + */ + getFavicon: (url) => { + if (url === undefined) { + throw new AppwriteException('Missing required parameter: "url"'); + } + let path = '/avatars/favicon'; + let payload = {}; + if (url) { + payload['url'] = url; + } + const uri = new URL(this.config.endpoint + path); + payload['project'] = this.config.project; + for (const [key, value] of Object.entries(this.flatten(payload))) { + uri.searchParams.append(key, value); + } + return uri; + }, + /** + * Get Country Flag + * + * You can use this endpoint to show different country flags icons to your + * users. The code argument receives the 2 letter country code. Use width, + * height and quality arguments to change the output settings. + * + * @param {string} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {AppwriteException} + * @returns {URL} + */ + getFlag: (code, width = 100, height = 100, quality = 100) => { + if (code === undefined) { + throw new AppwriteException('Missing required parameter: "code"'); + } + let path = '/avatars/flags/{code}'.replace('{code}', code); + let payload = {}; + if (width) { + payload['width'] = width; + } + if (height) { + payload['height'] = height; + } + if (quality) { + payload['quality'] = quality; + } + const uri = new URL(this.config.endpoint + path); + payload['project'] = this.config.project; + for (const [key, value] of Object.entries(this.flatten(payload))) { + uri.searchParams.append(key, value); + } + return uri; + }, + /** + * Get Image from URL + * + * Use this endpoint to fetch a remote image URL and crop it to any image size + * you want. This endpoint is very useful if you need to crop and display + * remote images in your app or in case you want to make sure a 3rd party + * image is properly served using a TLS protocol. + * + * @param {string} url + * @param {number} width + * @param {number} height + * @throws {AppwriteException} + * @returns {URL} + */ + getImage: (url, width = 400, height = 400) => { + if (url === undefined) { + throw new AppwriteException('Missing required parameter: "url"'); + } + let path = '/avatars/image'; + let payload = {}; + if (url) { + payload['url'] = url; + } + if (width) { + payload['width'] = width; + } + if (height) { + payload['height'] = height; + } + const uri = new URL(this.config.endpoint + path); + payload['project'] = this.config.project; + for (const [key, value] of Object.entries(this.flatten(payload))) { + uri.searchParams.append(key, value); + } + return uri; + }, + /** + * Get User Initials + * + * Use this endpoint to show your user initials avatar icon on your website or + * app. By default, this route will try to print your logged-in user name or + * email initials. You can also overwrite the user name if you pass the 'name' + * parameter. If no name is given and no user is logged, an empty avatar will + * be returned. + * + * You can use the color and background params to change the avatar colors. By + * default, a random theme will be selected. The random theme will persist for + * the user's initials when reloading the same theme will always return for + * the same initials. + * + * @param {string} name + * @param {number} width + * @param {number} height + * @param {string} color + * @param {string} background + * @throws {AppwriteException} + * @returns {URL} + */ + getInitials: (name = '', width = 500, height = 500, color = '', background = '') => { + let path = '/avatars/initials'; + let payload = {}; + if (name) { + payload['name'] = name; + } + if (width) { + payload['width'] = width; + } + if (height) { + payload['height'] = height; + } + if (color) { + payload['color'] = color; + } + if (background) { + payload['background'] = background; + } + const uri = new URL(this.config.endpoint + path); + payload['project'] = this.config.project; + for (const [key, value] of Object.entries(this.flatten(payload))) { + uri.searchParams.append(key, value); + } + return uri; + }, + /** + * Get QR Code + * + * Converts a given plain text to a QR code image. You can use the query + * parameters to change the size and style of the resulting image. + * + * @param {string} text + * @param {number} size + * @param {number} margin + * @param {boolean} download + * @throws {AppwriteException} + * @returns {URL} + */ + getQR: (text, size = 400, margin = 1, download = false) => { + if (text === undefined) { + throw new AppwriteException('Missing required parameter: "text"'); + } + let path = '/avatars/qr'; + let payload = {}; + if (text) { + payload['text'] = text; + } + if (size) { + payload['size'] = size; + } + if (margin) { + payload['margin'] = margin; + } + if (download) { + payload['download'] = download; + } + const uri = new URL(this.config.endpoint + path); + payload['project'] = this.config.project; + for (const [key, value] of Object.entries(this.flatten(payload))) { + uri.searchParams.append(key, value); + } + return uri; + } + }; + this.database = { + /** + * List Collections + * + * Get a list of all the user collections. You can use the query params to + * filter your results. On admin mode, this endpoint will return a list of all + * of the project's collections. [Learn more about different API + * modes](/docs/admin). + * + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {AppwriteException} + * @returns {Promise} + */ + listCollections: (search = '', limit = 25, offset = 0, orderType = 'ASC') => __awaiter(this, void 0, void 0, function* () { + let path = '/database/collections'; + let payload = {}; + if (search) { + payload['search'] = search; + } + if (limit) { + payload['limit'] = limit; + } + if (offset) { + payload['offset'] = offset; + } + if (orderType) { + payload['orderType'] = orderType; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Collection + * + * Create a new Collection. + * + * @param {string} name + * @param {string[]} read + * @param {string[]} write + * @param {string[]} rules + * @throws {AppwriteException} + * @returns {Promise} + */ + createCollection: (name, read, write, rules) => __awaiter(this, void 0, void 0, function* () { + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (read === undefined) { + throw new AppwriteException('Missing required parameter: "read"'); + } + if (write === undefined) { + throw new AppwriteException('Missing required parameter: "write"'); + } + if (rules === undefined) { + throw new AppwriteException('Missing required parameter: "rules"'); + } + let path = '/database/collections'; + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof read !== 'undefined') { + payload['read'] = read; + } + if (typeof write !== 'undefined') { + payload['write'] = write; + } + if (typeof rules !== 'undefined') { + payload['rules'] = rules; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Collection + * + * Get a collection by its unique ID. This endpoint response returns a JSON + * object with the collection metadata. + * + * @param {string} collectionId + * @throws {AppwriteException} + * @returns {Promise} + */ + getCollection: (collectionId) => __awaiter(this, void 0, void 0, function* () { + if (collectionId === undefined) { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + let path = '/database/collections/{collectionId}'.replace('{collectionId}', collectionId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Collection + * + * Update a collection by its unique ID. + * + * @param {string} collectionId + * @param {string} name + * @param {string[]} read + * @param {string[]} write + * @param {string[]} rules + * @throws {AppwriteException} + * @returns {Promise} + */ + updateCollection: (collectionId, name, read = [], write = [], rules = []) => __awaiter(this, void 0, void 0, function* () { + if (collectionId === undefined) { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + let path = '/database/collections/{collectionId}'.replace('{collectionId}', collectionId); + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof read !== 'undefined') { + payload['read'] = read; + } + if (typeof write !== 'undefined') { + payload['write'] = write; + } + if (typeof rules !== 'undefined') { + payload['rules'] = rules; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('put', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete Collection + * + * Delete a collection by its unique ID. Only users with write permissions + * have access to delete this resource. + * + * @param {string} collectionId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteCollection: (collectionId) => __awaiter(this, void 0, void 0, function* () { + if (collectionId === undefined) { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + let path = '/database/collections/{collectionId}'.replace('{collectionId}', collectionId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List Documents + * + * Get a list of all the user documents. You can use the query params to + * filter your results. On admin mode, this endpoint will return a list of all + * of the project's documents. [Learn more about different API + * modes](/docs/admin). + * + * @param {string} collectionId + * @param {string[]} filters + * @param {number} limit + * @param {number} offset + * @param {string} orderField + * @param {string} orderType + * @param {string} orderCast + * @param {string} search + * @throws {AppwriteException} + * @returns {Promise} + */ + listDocuments: (collectionId, filters = [], limit = 25, offset = 0, orderField = '', orderType = 'ASC', orderCast = 'string', search = '') => __awaiter(this, void 0, void 0, function* () { + if (collectionId === undefined) { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + let path = '/database/collections/{collectionId}/documents'.replace('{collectionId}', collectionId); + let payload = {}; + if (filters) { + payload['filters'] = filters; + } + if (limit) { + payload['limit'] = limit; + } + if (offset) { + payload['offset'] = offset; + } + if (orderField) { + payload['orderField'] = orderField; + } + if (orderType) { + payload['orderType'] = orderType; + } + if (orderCast) { + payload['orderCast'] = orderCast; + } + if (search) { + payload['search'] = search; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Document + * + * Create a new Document. Before using this route, you should create a new + * collection resource using either a [server + * integration](/docs/server/database#databaseCreateCollection) API or + * directly from your database console. + * + * @param {string} collectionId + * @param {object} data + * @param {string[]} read + * @param {string[]} write + * @param {string} parentDocument + * @param {string} parentProperty + * @param {string} parentPropertyType + * @throws {AppwriteException} + * @returns {Promise} + */ + createDocument: (collectionId, data, read = [], write = [], parentDocument = '', parentProperty = '', parentPropertyType = 'assign') => __awaiter(this, void 0, void 0, function* () { + if (collectionId === undefined) { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (data === undefined) { + throw new AppwriteException('Missing required parameter: "data"'); + } + let path = '/database/collections/{collectionId}/documents'.replace('{collectionId}', collectionId); + let payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof read !== 'undefined') { + payload['read'] = read; + } + if (typeof write !== 'undefined') { + payload['write'] = write; + } + if (typeof parentDocument !== 'undefined') { + payload['parentDocument'] = parentDocument; + } + if (typeof parentProperty !== 'undefined') { + payload['parentProperty'] = parentProperty; + } + if (typeof parentPropertyType !== 'undefined') { + payload['parentPropertyType'] = parentPropertyType; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Document + * + * Get a document by its unique ID. This endpoint response returns a JSON + * object with the document data. + * + * @param {string} collectionId + * @param {string} documentId + * @throws {AppwriteException} + * @returns {Promise} + */ + getDocument: (collectionId, documentId) => __awaiter(this, void 0, void 0, function* () { + if (collectionId === undefined) { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (documentId === undefined) { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + let path = '/database/collections/{collectionId}/documents/{documentId}'.replace('{collectionId}', collectionId).replace('{documentId}', documentId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Document + * + * Update a document by its unique ID. Using the patch method you can pass + * only specific fields that will get updated. + * + * @param {string} collectionId + * @param {string} documentId + * @param {object} data + * @param {string[]} read + * @param {string[]} write + * @throws {AppwriteException} + * @returns {Promise} + */ + updateDocument: (collectionId, documentId, data, read = [], write = []) => __awaiter(this, void 0, void 0, function* () { + if (collectionId === undefined) { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (documentId === undefined) { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + if (data === undefined) { + throw new AppwriteException('Missing required parameter: "data"'); + } + let path = '/database/collections/{collectionId}/documents/{documentId}'.replace('{collectionId}', collectionId).replace('{documentId}', documentId); + let payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof read !== 'undefined') { + payload['read'] = read; + } + if (typeof write !== 'undefined') { + payload['write'] = write; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete Document + * + * Delete a document by its unique ID. This endpoint deletes only the parent + * documents, its attributes and relations to other documents. Child documents + * **will not** be deleted. + * + * @param {string} collectionId + * @param {string} documentId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteDocument: (collectionId, documentId) => __awaiter(this, void 0, void 0, function* () { + if (collectionId === undefined) { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (documentId === undefined) { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + let path = '/database/collections/{collectionId}/documents/{documentId}'.replace('{collectionId}', collectionId).replace('{documentId}', documentId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }) + }; + this.functions = { + /** + * List Functions + * + * Get a list of all the project's functions. You can use the query params to + * filter your results. + * + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {AppwriteException} + * @returns {Promise} + */ + list: (search = '', limit = 25, offset = 0, orderType = 'ASC') => __awaiter(this, void 0, void 0, function* () { + let path = '/functions'; + let payload = {}; + if (search) { + payload['search'] = search; + } + if (limit) { + payload['limit'] = limit; + } + if (offset) { + payload['offset'] = offset; + } + if (orderType) { + payload['orderType'] = orderType; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Function + * + * Create a new function. You can pass a list of + * [permissions](/docs/permissions) to allow different project users or team + * with access to execute the function using the client API. + * + * @param {string} name + * @param {string[]} execute + * @param {string} env + * @param {object} vars + * @param {string[]} events + * @param {string} schedule + * @param {number} timeout + * @throws {AppwriteException} + * @returns {Promise} + */ + create: (name, execute, env, vars = {}, events = [], schedule = '', timeout = 15) => __awaiter(this, void 0, void 0, function* () { + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (execute === undefined) { + throw new AppwriteException('Missing required parameter: "execute"'); + } + if (env === undefined) { + throw new AppwriteException('Missing required parameter: "env"'); + } + let path = '/functions'; + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof execute !== 'undefined') { + payload['execute'] = execute; + } + if (typeof env !== 'undefined') { + payload['env'] = env; + } + if (typeof vars !== 'undefined') { + payload['vars'] = vars; + } + if (typeof events !== 'undefined') { + payload['events'] = events; + } + if (typeof schedule !== 'undefined') { + payload['schedule'] = schedule; + } + if (typeof timeout !== 'undefined') { + payload['timeout'] = timeout; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Function + * + * Get a function by its unique ID. + * + * @param {string} functionId + * @throws {AppwriteException} + * @returns {Promise} + */ + get: (functionId) => __awaiter(this, void 0, void 0, function* () { + if (functionId === undefined) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + let path = '/functions/{functionId}'.replace('{functionId}', functionId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Function + * + * Update function by its unique ID. + * + * @param {string} functionId + * @param {string} name + * @param {string[]} execute + * @param {object} vars + * @param {string[]} events + * @param {string} schedule + * @param {number} timeout + * @throws {AppwriteException} + * @returns {Promise} + */ + update: (functionId, name, execute, vars = {}, events = [], schedule = '', timeout = 15) => __awaiter(this, void 0, void 0, function* () { + if (functionId === undefined) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (execute === undefined) { + throw new AppwriteException('Missing required parameter: "execute"'); + } + let path = '/functions/{functionId}'.replace('{functionId}', functionId); + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof execute !== 'undefined') { + payload['execute'] = execute; + } + if (typeof vars !== 'undefined') { + payload['vars'] = vars; + } + if (typeof events !== 'undefined') { + payload['events'] = events; + } + if (typeof schedule !== 'undefined') { + payload['schedule'] = schedule; + } + if (typeof timeout !== 'undefined') { + payload['timeout'] = timeout; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('put', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete Function + * + * Delete a function by its unique ID. + * + * @param {string} functionId + * @throws {AppwriteException} + * @returns {Promise} + */ + delete: (functionId) => __awaiter(this, void 0, void 0, function* () { + if (functionId === undefined) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + let path = '/functions/{functionId}'.replace('{functionId}', functionId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List Executions + * + * Get a list of all the current user function execution logs. You can use the + * query params to filter your results. On admin mode, this endpoint will + * return a list of all of the project's executions. [Learn more about + * different API modes](/docs/admin). + * + * @param {string} functionId + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {AppwriteException} + * @returns {Promise} + */ + listExecutions: (functionId, search = '', limit = 25, offset = 0, orderType = 'ASC') => __awaiter(this, void 0, void 0, function* () { + if (functionId === undefined) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId); + let payload = {}; + if (search) { + payload['search'] = search; + } + if (limit) { + payload['limit'] = limit; + } + if (offset) { + payload['offset'] = offset; + } + if (orderType) { + payload['orderType'] = orderType; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Execution + * + * Trigger a function execution. The returned object will return you the + * current execution status. You can ping the `Get Execution` endpoint to get + * updates on the current execution status. Once this endpoint is called, your + * function execution process will start asynchronously. + * + * @param {string} functionId + * @param {string} data + * @throws {AppwriteException} + * @returns {Promise} + */ + createExecution: (functionId, data = '') => __awaiter(this, void 0, void 0, function* () { + if (functionId === undefined) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId); + let payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Execution + * + * Get a function execution log by its unique ID. + * + * @param {string} functionId + * @param {string} executionId + * @throws {AppwriteException} + * @returns {Promise} + */ + getExecution: (functionId, executionId) => __awaiter(this, void 0, void 0, function* () { + if (functionId === undefined) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (executionId === undefined) { + throw new AppwriteException('Missing required parameter: "executionId"'); + } + let path = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Function Tag + * + * Update the function code tag ID using the unique function ID. Use this + * endpoint to switch the code tag that should be executed by the execution + * endpoint. + * + * @param {string} functionId + * @param {string} tag + * @throws {AppwriteException} + * @returns {Promise} + */ + updateTag: (functionId, tag) => __awaiter(this, void 0, void 0, function* () { + if (functionId === undefined) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (tag === undefined) { + throw new AppwriteException('Missing required parameter: "tag"'); + } + let path = '/functions/{functionId}/tag'.replace('{functionId}', functionId); + let payload = {}; + if (typeof tag !== 'undefined') { + payload['tag'] = tag; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List Tags + * + * Get a list of all the project's code tags. You can use the query params to + * filter your results. + * + * @param {string} functionId + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {AppwriteException} + * @returns {Promise} + */ + listTags: (functionId, search = '', limit = 25, offset = 0, orderType = 'ASC') => __awaiter(this, void 0, void 0, function* () { + if (functionId === undefined) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + let path = '/functions/{functionId}/tags'.replace('{functionId}', functionId); + let payload = {}; + if (search) { + payload['search'] = search; + } + if (limit) { + payload['limit'] = limit; + } + if (offset) { + payload['offset'] = offset; + } + if (orderType) { + payload['orderType'] = orderType; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Tag + * + * Create a new function code tag. Use this endpoint to upload a new version + * of your code function. To execute your newly uploaded code, you'll need to + * update the function's tag to use your new tag UID. + * + * This endpoint accepts a tar.gz file compressed with your code. Make sure to + * include any dependencies your code has within the compressed file. You can + * learn more about code packaging in the [Appwrite Cloud Functions + * tutorial](/docs/functions). + * + * Use the "command" param to set the entry point used to execute your code. + * + * @param {string} functionId + * @param {string} command + * @param {File} code + * @throws {AppwriteException} + * @returns {Promise} + */ + createTag: (functionId, command, code) => __awaiter(this, void 0, void 0, function* () { + if (functionId === undefined) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (command === undefined) { + throw new AppwriteException('Missing required parameter: "command"'); + } + if (code === undefined) { + throw new AppwriteException('Missing required parameter: "code"'); + } + let path = '/functions/{functionId}/tags'.replace('{functionId}', functionId); + let payload = {}; + if (typeof command !== 'undefined') { + payload['command'] = command; + } + if (typeof code !== 'undefined') { + payload['code'] = code; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'multipart/form-data', + }, payload); + }), + /** + * Get Tag + * + * Get a code tag by its unique ID. + * + * @param {string} functionId + * @param {string} tagId + * @throws {AppwriteException} + * @returns {Promise} + */ + getTag: (functionId, tagId) => __awaiter(this, void 0, void 0, function* () { + if (functionId === undefined) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (tagId === undefined) { + throw new AppwriteException('Missing required parameter: "tagId"'); + } + let path = '/functions/{functionId}/tags/{tagId}'.replace('{functionId}', functionId).replace('{tagId}', tagId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete Tag + * + * Delete a code tag by its unique ID. + * + * @param {string} functionId + * @param {string} tagId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteTag: (functionId, tagId) => __awaiter(this, void 0, void 0, function* () { + if (functionId === undefined) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (tagId === undefined) { + throw new AppwriteException('Missing required parameter: "tagId"'); + } + let path = '/functions/{functionId}/tags/{tagId}'.replace('{functionId}', functionId).replace('{tagId}', tagId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Function Usage + * + * + * @param {string} functionId + * @param {string} range + * @throws {AppwriteException} + * @returns {Promise} + */ + getUsage: (functionId, range = '30d') => __awaiter(this, void 0, void 0, function* () { + if (functionId === undefined) { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + let path = '/functions/{functionId}/usage'.replace('{functionId}', functionId); + let payload = {}; + if (range) { + payload['range'] = range; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }) + }; + this.health = { + /** + * Get HTTP + * + * Check the Appwrite HTTP server is up and responsive. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + get: () => __awaiter(this, void 0, void 0, function* () { + let path = '/health'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Anti virus + * + * Check the Appwrite Anti Virus server is up and connection is successful. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getAntiVirus: () => __awaiter(this, void 0, void 0, function* () { + let path = '/health/anti-virus'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Cache + * + * Check the Appwrite in-memory cache server is up and connection is + * successful. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getCache: () => __awaiter(this, void 0, void 0, function* () { + let path = '/health/cache'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get DB + * + * Check the Appwrite database server is up and connection is successful. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getDB: () => __awaiter(this, void 0, void 0, function* () { + let path = '/health/db'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Certificate Queue + * + * Get the number of certificates that are waiting to be issued against + * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue + * server. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getQueueCertificates: () => __awaiter(this, void 0, void 0, function* () { + let path = '/health/queue/certificates'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Functions Queue + * + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getQueueFunctions: () => __awaiter(this, void 0, void 0, function* () { + let path = '/health/queue/functions'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Logs Queue + * + * Get the number of logs that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getQueueLogs: () => __awaiter(this, void 0, void 0, function* () { + let path = '/health/queue/logs'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Tasks Queue + * + * Get the number of tasks that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getQueueTasks: () => __awaiter(this, void 0, void 0, function* () { + let path = '/health/queue/tasks'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Usage Queue + * + * Get the number of usage stats that are waiting to be processed in the + * Appwrite internal queue server. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getQueueUsage: () => __awaiter(this, void 0, void 0, function* () { + let path = '/health/queue/usage'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Webhooks Queue + * + * Get the number of webhooks that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getQueueWebhooks: () => __awaiter(this, void 0, void 0, function* () { + let path = '/health/queue/webhooks'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Local Storage + * + * Check the Appwrite local storage device is up and connection is successful. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getStorageLocal: () => __awaiter(this, void 0, void 0, function* () { + let path = '/health/storage/local'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Time + * + * Check the Appwrite server time is synced with Google remote NTP server. We + * use this technology to smoothly handle leap seconds with no disruptive + * events. The [Network Time + * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is + * used by hundreds of millions of computers and devices to synchronize their + * clocks over the Internet. If your computer sets its own clock, it likely + * uses NTP. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getTime: () => __awaiter(this, void 0, void 0, function* () { + let path = '/health/time'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }) + }; + this.locale = { + /** + * Get User Locale + * + * Get the current user location based on IP. Returns an object with user + * country code, country name, continent name, continent code, ip address and + * suggested currency. You can use the locale header to get the data in a + * supported language. + * + * ([IP Geolocation by DB-IP](https://db-ip.com)) + * + * @throws {AppwriteException} + * @returns {Promise} + */ + get: () => __awaiter(this, void 0, void 0, function* () { + let path = '/locale'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List Continents + * + * List of all continents. You can use the locale header to get the data in a + * supported language. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getContinents: () => __awaiter(this, void 0, void 0, function* () { + let path = '/locale/continents'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List Countries + * + * List of all countries. You can use the locale header to get the data in a + * supported language. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getCountries: () => __awaiter(this, void 0, void 0, function* () { + let path = '/locale/countries'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List EU Countries + * + * List of all countries that are currently members of the EU. You can use the + * locale header to get the data in a supported language. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getCountriesEU: () => __awaiter(this, void 0, void 0, function* () { + let path = '/locale/countries/eu'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List Countries Phone Codes + * + * List of all countries phone codes. You can use the locale header to get the + * data in a supported language. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getCountriesPhones: () => __awaiter(this, void 0, void 0, function* () { + let path = '/locale/countries/phones'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List Currencies + * + * List of all currencies, including currency symbol, name, plural, and + * decimal digits for all major and minor currencies. You can use the locale + * header to get the data in a supported language. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getCurrencies: () => __awaiter(this, void 0, void 0, function* () { + let path = '/locale/currencies'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List Languages + * + * List of all languages classified by ISO 639-1 including 2-letter code, name + * in English, and name in the respective language. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + getLanguages: () => __awaiter(this, void 0, void 0, function* () { + let path = '/locale/languages'; + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }) + }; + this.projects = { + /** + * List Projects + * + * + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {AppwriteException} + * @returns {Promise} + */ + list: (search = '', limit = 25, offset = 0, orderType = 'ASC') => __awaiter(this, void 0, void 0, function* () { + let path = '/projects'; + let payload = {}; + if (search) { + payload['search'] = search; + } + if (limit) { + payload['limit'] = limit; + } + if (offset) { + payload['offset'] = offset; + } + if (orderType) { + payload['orderType'] = orderType; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Project + * + * + * @param {string} name + * @param {string} teamId + * @param {string} description + * @param {string} logo + * @param {string} url + * @param {string} legalName + * @param {string} legalCountry + * @param {string} legalState + * @param {string} legalCity + * @param {string} legalAddress + * @param {string} legalTaxId + * @throws {AppwriteException} + * @returns {Promise} + */ + create: (name, teamId, description = '', logo = '', url = '', legalName = '', legalCountry = '', legalState = '', legalCity = '', legalAddress = '', legalTaxId = '') => __awaiter(this, void 0, void 0, function* () { + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (teamId === undefined) { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + let path = '/projects'; + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof teamId !== 'undefined') { + payload['teamId'] = teamId; + } + if (typeof description !== 'undefined') { + payload['description'] = description; + } + if (typeof logo !== 'undefined') { + payload['logo'] = logo; + } + if (typeof url !== 'undefined') { + payload['url'] = url; + } + if (typeof legalName !== 'undefined') { + payload['legalName'] = legalName; + } + if (typeof legalCountry !== 'undefined') { + payload['legalCountry'] = legalCountry; + } + if (typeof legalState !== 'undefined') { + payload['legalState'] = legalState; + } + if (typeof legalCity !== 'undefined') { + payload['legalCity'] = legalCity; + } + if (typeof legalAddress !== 'undefined') { + payload['legalAddress'] = legalAddress; + } + if (typeof legalTaxId !== 'undefined') { + payload['legalTaxId'] = legalTaxId; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Project + * + * + * @param {string} projectId + * @throws {AppwriteException} + * @returns {Promise} + */ + get: (projectId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + let path = '/projects/{projectId}'.replace('{projectId}', projectId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Project + * + * + * @param {string} projectId + * @param {string} name + * @param {string} description + * @param {string} logo + * @param {string} url + * @param {string} legalName + * @param {string} legalCountry + * @param {string} legalState + * @param {string} legalCity + * @param {string} legalAddress + * @param {string} legalTaxId + * @throws {AppwriteException} + * @returns {Promise} + */ + update: (projectId, name, description = '', logo = '', url = '', legalName = '', legalCountry = '', legalState = '', legalCity = '', legalAddress = '', legalTaxId = '') => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + let path = '/projects/{projectId}'.replace('{projectId}', projectId); + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof description !== 'undefined') { + payload['description'] = description; + } + if (typeof logo !== 'undefined') { + payload['logo'] = logo; + } + if (typeof url !== 'undefined') { + payload['url'] = url; + } + if (typeof legalName !== 'undefined') { + payload['legalName'] = legalName; + } + if (typeof legalCountry !== 'undefined') { + payload['legalCountry'] = legalCountry; + } + if (typeof legalState !== 'undefined') { + payload['legalState'] = legalState; + } + if (typeof legalCity !== 'undefined') { + payload['legalCity'] = legalCity; + } + if (typeof legalAddress !== 'undefined') { + payload['legalAddress'] = legalAddress; + } + if (typeof legalTaxId !== 'undefined') { + payload['legalTaxId'] = legalTaxId; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete Project + * + * + * @param {string} projectId + * @param {string} password + * @throws {AppwriteException} + * @returns {Promise} + */ + delete: (projectId, password) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (password === undefined) { + throw new AppwriteException('Missing required parameter: "password"'); + } + let path = '/projects/{projectId}'.replace('{projectId}', projectId); + let payload = {}; + if (typeof password !== 'undefined') { + payload['password'] = password; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Project users limit + * + * + * @param {string} projectId + * @param {string} limit + * @throws {AppwriteException} + * @returns {Promise} + */ + updateAuthLimit: (projectId, limit) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (limit === undefined) { + throw new AppwriteException('Missing required parameter: "limit"'); + } + let path = '/projects/{projectId}/auth/limit'.replace('{projectId}', projectId); + let payload = {}; + if (typeof limit !== 'undefined') { + payload['limit'] = limit; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Project auth method status. Use this endpoint to enable or disable a given auth method for this project. + * + * + * @param {string} projectId + * @param {string} method + * @param {boolean} status + * @throws {AppwriteException} + * @returns {Promise} + */ + updateAuthStatus: (projectId, method, status) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (method === undefined) { + throw new AppwriteException('Missing required parameter: "method"'); + } + if (status === undefined) { + throw new AppwriteException('Missing required parameter: "status"'); + } + let path = '/projects/{projectId}/auth/{method}'.replace('{projectId}', projectId).replace('{method}', method); + let payload = {}; + if (typeof status !== 'undefined') { + payload['status'] = status; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List Domains + * + * + * @param {string} projectId + * @throws {AppwriteException} + * @returns {Promise} + */ + listDomains: (projectId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + let path = '/projects/{projectId}/domains'.replace('{projectId}', projectId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Domain + * + * + * @param {string} projectId + * @param {string} domain + * @throws {AppwriteException} + * @returns {Promise} + */ + createDomain: (projectId, domain) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (domain === undefined) { + throw new AppwriteException('Missing required parameter: "domain"'); + } + let path = '/projects/{projectId}/domains'.replace('{projectId}', projectId); + let payload = {}; + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Domain + * + * + * @param {string} projectId + * @param {string} domainId + * @throws {AppwriteException} + * @returns {Promise} + */ + getDomain: (projectId, domainId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (domainId === undefined) { + throw new AppwriteException('Missing required parameter: "domainId"'); + } + let path = '/projects/{projectId}/domains/{domainId}'.replace('{projectId}', projectId).replace('{domainId}', domainId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete Domain + * + * + * @param {string} projectId + * @param {string} domainId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteDomain: (projectId, domainId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (domainId === undefined) { + throw new AppwriteException('Missing required parameter: "domainId"'); + } + let path = '/projects/{projectId}/domains/{domainId}'.replace('{projectId}', projectId).replace('{domainId}', domainId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Domain Verification Status + * + * + * @param {string} projectId + * @param {string} domainId + * @throws {AppwriteException} + * @returns {Promise} + */ + updateDomainVerification: (projectId, domainId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (domainId === undefined) { + throw new AppwriteException('Missing required parameter: "domainId"'); + } + let path = '/projects/{projectId}/domains/{domainId}/verification'.replace('{projectId}', projectId).replace('{domainId}', domainId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List Keys + * + * + * @param {string} projectId + * @throws {AppwriteException} + * @returns {Promise} + */ + listKeys: (projectId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + let path = '/projects/{projectId}/keys'.replace('{projectId}', projectId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Key + * + * + * @param {string} projectId + * @param {string} name + * @param {string[]} scopes + * @throws {AppwriteException} + * @returns {Promise} + */ + createKey: (projectId, name, scopes) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (scopes === undefined) { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + let path = '/projects/{projectId}/keys'.replace('{projectId}', projectId); + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Key + * + * + * @param {string} projectId + * @param {string} keyId + * @throws {AppwriteException} + * @returns {Promise} + */ + getKey: (projectId, keyId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (keyId === undefined) { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + let path = '/projects/{projectId}/keys/{keyId}'.replace('{projectId}', projectId).replace('{keyId}', keyId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Key + * + * + * @param {string} projectId + * @param {string} keyId + * @param {string} name + * @param {string[]} scopes + * @throws {AppwriteException} + * @returns {Promise} + */ + updateKey: (projectId, keyId, name, scopes) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (keyId === undefined) { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (scopes === undefined) { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + let path = '/projects/{projectId}/keys/{keyId}'.replace('{projectId}', projectId).replace('{keyId}', keyId); + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('put', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete Key + * + * + * @param {string} projectId + * @param {string} keyId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteKey: (projectId, keyId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (keyId === undefined) { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + let path = '/projects/{projectId}/keys/{keyId}'.replace('{projectId}', projectId).replace('{keyId}', keyId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Project OAuth2 + * + * + * @param {string} projectId + * @param {string} provider + * @param {string} appId + * @param {string} secret + * @throws {AppwriteException} + * @returns {Promise} + */ + updateOAuth2: (projectId, provider, appId = '', secret = '') => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (provider === undefined) { + throw new AppwriteException('Missing required parameter: "provider"'); + } + let path = '/projects/{projectId}/oauth2'.replace('{projectId}', projectId); + let payload = {}; + if (typeof provider !== 'undefined') { + payload['provider'] = provider; + } + if (typeof appId !== 'undefined') { + payload['appId'] = appId; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List Platforms + * + * + * @param {string} projectId + * @throws {AppwriteException} + * @returns {Promise} + */ + listPlatforms: (projectId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + let path = '/projects/{projectId}/platforms'.replace('{projectId}', projectId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Platform + * + * + * @param {string} projectId + * @param {string} type + * @param {string} name + * @param {string} key + * @param {string} store + * @param {string} hostname + * @throws {AppwriteException} + * @returns {Promise} + */ + createPlatform: (projectId, type, name, key = '', store = '', hostname = '') => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (type === undefined) { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + let path = '/projects/{projectId}/platforms'.replace('{projectId}', projectId); + let payload = {}; + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof store !== 'undefined') { + payload['store'] = store; + } + if (typeof hostname !== 'undefined') { + payload['hostname'] = hostname; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Platform + * + * + * @param {string} projectId + * @param {string} platformId + * @throws {AppwriteException} + * @returns {Promise} + */ + getPlatform: (projectId, platformId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (platformId === undefined) { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + let path = '/projects/{projectId}/platforms/{platformId}'.replace('{projectId}', projectId).replace('{platformId}', platformId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Platform + * + * + * @param {string} projectId + * @param {string} platformId + * @param {string} name + * @param {string} key + * @param {string} store + * @param {string} hostname + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePlatform: (projectId, platformId, name, key = '', store = '', hostname = '') => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (platformId === undefined) { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + let path = '/projects/{projectId}/platforms/{platformId}'.replace('{projectId}', projectId).replace('{platformId}', platformId); + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof store !== 'undefined') { + payload['store'] = store; + } + if (typeof hostname !== 'undefined') { + payload['hostname'] = hostname; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('put', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete Platform + * + * + * @param {string} projectId + * @param {string} platformId + * @throws {AppwriteException} + * @returns {Promise} + */ + deletePlatform: (projectId, platformId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (platformId === undefined) { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + let path = '/projects/{projectId}/platforms/{platformId}'.replace('{projectId}', projectId).replace('{platformId}', platformId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List Tasks + * + * + * @param {string} projectId + * @throws {AppwriteException} + * @returns {Promise} + */ + listTasks: (projectId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + let path = '/projects/{projectId}/tasks'.replace('{projectId}', projectId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Task + * + * + * @param {string} projectId + * @param {string} name + * @param {string} status + * @param {string} schedule + * @param {boolean} security + * @param {string} httpMethod + * @param {string} httpUrl + * @param {string[]} httpHeaders + * @param {string} httpUser + * @param {string} httpPass + * @throws {AppwriteException} + * @returns {Promise} + */ + createTask: (projectId, name, status, schedule, security, httpMethod, httpUrl, httpHeaders = [], httpUser = '', httpPass = '') => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (status === undefined) { + throw new AppwriteException('Missing required parameter: "status"'); + } + if (schedule === undefined) { + throw new AppwriteException('Missing required parameter: "schedule"'); + } + if (security === undefined) { + throw new AppwriteException('Missing required parameter: "security"'); + } + if (httpMethod === undefined) { + throw new AppwriteException('Missing required parameter: "httpMethod"'); + } + if (httpUrl === undefined) { + throw new AppwriteException('Missing required parameter: "httpUrl"'); + } + let path = '/projects/{projectId}/tasks'.replace('{projectId}', projectId); + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof status !== 'undefined') { + payload['status'] = status; + } + if (typeof schedule !== 'undefined') { + payload['schedule'] = schedule; + } + if (typeof security !== 'undefined') { + payload['security'] = security; + } + if (typeof httpMethod !== 'undefined') { + payload['httpMethod'] = httpMethod; + } + if (typeof httpUrl !== 'undefined') { + payload['httpUrl'] = httpUrl; + } + if (typeof httpHeaders !== 'undefined') { + payload['httpHeaders'] = httpHeaders; + } + if (typeof httpUser !== 'undefined') { + payload['httpUser'] = httpUser; + } + if (typeof httpPass !== 'undefined') { + payload['httpPass'] = httpPass; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Task + * + * + * @param {string} projectId + * @param {string} taskId + * @throws {AppwriteException} + * @returns {Promise} + */ + getTask: (projectId, taskId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (taskId === undefined) { + throw new AppwriteException('Missing required parameter: "taskId"'); + } + let path = '/projects/{projectId}/tasks/{taskId}'.replace('{projectId}', projectId).replace('{taskId}', taskId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Task + * + * + * @param {string} projectId + * @param {string} taskId + * @param {string} name + * @param {string} status + * @param {string} schedule + * @param {boolean} security + * @param {string} httpMethod + * @param {string} httpUrl + * @param {string[]} httpHeaders + * @param {string} httpUser + * @param {string} httpPass + * @throws {AppwriteException} + * @returns {Promise} + */ + updateTask: (projectId, taskId, name, status, schedule, security, httpMethod, httpUrl, httpHeaders = [], httpUser = '', httpPass = '') => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (taskId === undefined) { + throw new AppwriteException('Missing required parameter: "taskId"'); + } + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (status === undefined) { + throw new AppwriteException('Missing required parameter: "status"'); + } + if (schedule === undefined) { + throw new AppwriteException('Missing required parameter: "schedule"'); + } + if (security === undefined) { + throw new AppwriteException('Missing required parameter: "security"'); + } + if (httpMethod === undefined) { + throw new AppwriteException('Missing required parameter: "httpMethod"'); + } + if (httpUrl === undefined) { + throw new AppwriteException('Missing required parameter: "httpUrl"'); + } + let path = '/projects/{projectId}/tasks/{taskId}'.replace('{projectId}', projectId).replace('{taskId}', taskId); + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof status !== 'undefined') { + payload['status'] = status; + } + if (typeof schedule !== 'undefined') { + payload['schedule'] = schedule; + } + if (typeof security !== 'undefined') { + payload['security'] = security; + } + if (typeof httpMethod !== 'undefined') { + payload['httpMethod'] = httpMethod; + } + if (typeof httpUrl !== 'undefined') { + payload['httpUrl'] = httpUrl; + } + if (typeof httpHeaders !== 'undefined') { + payload['httpHeaders'] = httpHeaders; + } + if (typeof httpUser !== 'undefined') { + payload['httpUser'] = httpUser; + } + if (typeof httpPass !== 'undefined') { + payload['httpPass'] = httpPass; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('put', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete Task + * + * + * @param {string} projectId + * @param {string} taskId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteTask: (projectId, taskId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (taskId === undefined) { + throw new AppwriteException('Missing required parameter: "taskId"'); + } + let path = '/projects/{projectId}/tasks/{taskId}'.replace('{projectId}', projectId).replace('{taskId}', taskId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Project + * + * + * @param {string} projectId + * @param {string} range + * @throws {AppwriteException} + * @returns {Promise} + */ + getUsage: (projectId, range = '30d') => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + let path = '/projects/{projectId}/usage'.replace('{projectId}', projectId); + let payload = {}; + if (range) { + payload['range'] = range; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * List Webhooks + * + * + * @param {string} projectId + * @throws {AppwriteException} + * @returns {Promise} + */ + listWebhooks: (projectId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + let path = '/projects/{projectId}/webhooks'.replace('{projectId}', projectId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Webhook + * + * + * @param {string} projectId + * @param {string} name + * @param {string[]} events + * @param {string} url + * @param {boolean} security + * @param {string} httpUser + * @param {string} httpPass + * @throws {AppwriteException} + * @returns {Promise} + */ + createWebhook: (projectId, name, events, url, security, httpUser = '', httpPass = '') => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (events === undefined) { + throw new AppwriteException('Missing required parameter: "events"'); + } + if (url === undefined) { + throw new AppwriteException('Missing required parameter: "url"'); + } + if (security === undefined) { + throw new AppwriteException('Missing required parameter: "security"'); + } + let path = '/projects/{projectId}/webhooks'.replace('{projectId}', projectId); + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof events !== 'undefined') { + payload['events'] = events; + } + if (typeof url !== 'undefined') { + payload['url'] = url; + } + if (typeof security !== 'undefined') { + payload['security'] = security; + } + if (typeof httpUser !== 'undefined') { + payload['httpUser'] = httpUser; + } + if (typeof httpPass !== 'undefined') { + payload['httpPass'] = httpPass; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Webhook + * + * + * @param {string} projectId + * @param {string} webhookId + * @throws {AppwriteException} + * @returns {Promise} + */ + getWebhook: (projectId, webhookId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (webhookId === undefined) { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + let path = '/projects/{projectId}/webhooks/{webhookId}'.replace('{projectId}', projectId).replace('{webhookId}', webhookId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Webhook + * + * + * @param {string} projectId + * @param {string} webhookId + * @param {string} name + * @param {string[]} events + * @param {string} url + * @param {boolean} security + * @param {string} httpUser + * @param {string} httpPass + * @throws {AppwriteException} + * @returns {Promise} + */ + updateWebhook: (projectId, webhookId, name, events, url, security, httpUser = '', httpPass = '') => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (webhookId === undefined) { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (events === undefined) { + throw new AppwriteException('Missing required parameter: "events"'); + } + if (url === undefined) { + throw new AppwriteException('Missing required parameter: "url"'); + } + if (security === undefined) { + throw new AppwriteException('Missing required parameter: "security"'); + } + let path = '/projects/{projectId}/webhooks/{webhookId}'.replace('{projectId}', projectId).replace('{webhookId}', webhookId); + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof events !== 'undefined') { + payload['events'] = events; + } + if (typeof url !== 'undefined') { + payload['url'] = url; + } + if (typeof security !== 'undefined') { + payload['security'] = security; + } + if (typeof httpUser !== 'undefined') { + payload['httpUser'] = httpUser; + } + if (typeof httpPass !== 'undefined') { + payload['httpPass'] = httpPass; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('put', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete Webhook + * + * + * @param {string} projectId + * @param {string} webhookId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteWebhook: (projectId, webhookId) => __awaiter(this, void 0, void 0, function* () { + if (projectId === undefined) { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + if (webhookId === undefined) { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + let path = '/projects/{projectId}/webhooks/{webhookId}'.replace('{projectId}', projectId).replace('{webhookId}', webhookId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }) + }; + this.storage = { + /** + * List Files + * + * Get a list of all the user files. You can use the query params to filter + * your results. On admin mode, this endpoint will return a list of all of the + * project's files. [Learn more about different API modes](/docs/admin). + * + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {AppwriteException} + * @returns {Promise} + */ + listFiles: (search = '', limit = 25, offset = 0, orderType = 'ASC') => __awaiter(this, void 0, void 0, function* () { + let path = '/storage/files'; + let payload = {}; + if (search) { + payload['search'] = search; + } + if (limit) { + payload['limit'] = limit; + } + if (offset) { + payload['offset'] = offset; + } + if (orderType) { + payload['orderType'] = orderType; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create File + * + * Create a new file. The user who creates the file will automatically be + * assigned to read and write access unless he has passed custom values for + * read and write arguments. + * + * @param {File} file + * @param {string[]} read + * @param {string[]} write + * @throws {AppwriteException} + * @returns {Promise} + */ + createFile: (file, read = [], write = []) => __awaiter(this, void 0, void 0, function* () { + if (file === undefined) { + throw new AppwriteException('Missing required parameter: "file"'); + } + let path = '/storage/files'; + let payload = {}; + if (typeof file !== 'undefined') { + payload['file'] = file; + } + if (typeof read !== 'undefined') { + payload['read'] = read; + } + if (typeof write !== 'undefined') { + payload['write'] = write; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'multipart/form-data', + }, payload); + }), + /** + * Get File + * + * Get a file by its unique ID. This endpoint response returns a JSON object + * with the file metadata. + * + * @param {string} fileId + * @throws {AppwriteException} + * @returns {Promise} + */ + getFile: (fileId) => __awaiter(this, void 0, void 0, function* () { + if (fileId === undefined) { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + let path = '/storage/files/{fileId}'.replace('{fileId}', fileId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update File + * + * Update a file by its unique ID. Only users with write permissions have + * access to update this resource. + * + * @param {string} fileId + * @param {string[]} read + * @param {string[]} write + * @throws {AppwriteException} + * @returns {Promise} + */ + updateFile: (fileId, read, write) => __awaiter(this, void 0, void 0, function* () { + if (fileId === undefined) { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + if (read === undefined) { + throw new AppwriteException('Missing required parameter: "read"'); + } + if (write === undefined) { + throw new AppwriteException('Missing required parameter: "write"'); + } + let path = '/storage/files/{fileId}'.replace('{fileId}', fileId); + let payload = {}; + if (typeof read !== 'undefined') { + payload['read'] = read; + } + if (typeof write !== 'undefined') { + payload['write'] = write; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('put', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete File + * + * Delete a file by its unique ID. Only users with write permissions have + * access to delete this resource. + * + * @param {string} fileId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteFile: (fileId) => __awaiter(this, void 0, void 0, function* () { + if (fileId === undefined) { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + let path = '/storage/files/{fileId}'.replace('{fileId}', fileId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get File for Download + * + * Get a file content by its unique ID. The endpoint response return with a + * 'Content-Disposition: attachment' header that tells the browser to start + * downloading the file to user downloads directory. + * + * @param {string} fileId + * @throws {AppwriteException} + * @returns {URL} + */ + getFileDownload: (fileId) => { + if (fileId === undefined) { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + let path = '/storage/files/{fileId}/download'.replace('{fileId}', fileId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + payload['project'] = this.config.project; + for (const [key, value] of Object.entries(this.flatten(payload))) { + uri.searchParams.append(key, value); + } + return uri; + }, + /** + * Get File Preview + * + * Get a file preview image. Currently, this method supports preview for image + * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, + * and spreadsheets, will return the file icon image. You can also pass query + * string arguments for cutting and resizing your preview image. + * + * @param {string} fileId + * @param {number} width + * @param {number} height + * @param {number} quality + * @param {number} borderWidth + * @param {string} borderColor + * @param {number} borderRadius + * @param {number} opacity + * @param {number} rotation + * @param {string} background + * @param {string} output + * @throws {AppwriteException} + * @returns {URL} + */ + getFilePreview: (fileId, width = 0, height = 0, quality = 100, borderWidth = 0, borderColor = '', borderRadius = 0, opacity = 1, rotation = 0, background = '', output = '') => { + if (fileId === undefined) { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + let path = '/storage/files/{fileId}/preview'.replace('{fileId}', fileId); + let payload = {}; + if (width) { + payload['width'] = width; + } + if (height) { + payload['height'] = height; + } + if (quality) { + payload['quality'] = quality; + } + if (borderWidth) { + payload['borderWidth'] = borderWidth; + } + if (borderColor) { + payload['borderColor'] = borderColor; + } + if (borderRadius) { + payload['borderRadius'] = borderRadius; + } + if (opacity) { + payload['opacity'] = opacity; + } + if (rotation) { + payload['rotation'] = rotation; + } + if (background) { + payload['background'] = background; + } + if (output) { + payload['output'] = output; + } + const uri = new URL(this.config.endpoint + path); + payload['project'] = this.config.project; + for (const [key, value] of Object.entries(this.flatten(payload))) { + uri.searchParams.append(key, value); + } + return uri; + }, + /** + * Get File for View + * + * Get a file content by its unique ID. This endpoint is similar to the + * download method but returns with no 'Content-Disposition: attachment' + * header. + * + * @param {string} fileId + * @throws {AppwriteException} + * @returns {URL} + */ + getFileView: (fileId) => { + if (fileId === undefined) { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + let path = '/storage/files/{fileId}/view'.replace('{fileId}', fileId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + payload['project'] = this.config.project; + for (const [key, value] of Object.entries(this.flatten(payload))) { + uri.searchParams.append(key, value); + } + return uri; + } + }; + this.teams = { + /** + * List Teams + * + * Get a list of all the current user teams. You can use the query params to + * filter your results. On admin mode, this endpoint will return a list of all + * of the project's teams. [Learn more about different API + * modes](/docs/admin). + * + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {AppwriteException} + * @returns {Promise} + */ + list: (search = '', limit = 25, offset = 0, orderType = 'ASC') => __awaiter(this, void 0, void 0, function* () { + let path = '/teams'; + let payload = {}; + if (search) { + payload['search'] = search; + } + if (limit) { + payload['limit'] = limit; + } + if (offset) { + payload['offset'] = offset; + } + if (orderType) { + payload['orderType'] = orderType; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Team + * + * Create a new team. The user who creates the team will automatically be + * assigned as the owner of the team. The team owner can invite new members, + * who will be able add new owners and update or delete the team from your + * project. + * + * @param {string} name + * @param {string[]} roles + * @throws {AppwriteException} + * @returns {Promise} + */ + create: (name, roles = ["owner"]) => __awaiter(this, void 0, void 0, function* () { + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + let path = '/teams'; + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof roles !== 'undefined') { + payload['roles'] = roles; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Team + * + * Get a team by its unique ID. All team members have read access for this + * resource. + * + * @param {string} teamId + * @throws {AppwriteException} + * @returns {Promise} + */ + get: (teamId) => __awaiter(this, void 0, void 0, function* () { + if (teamId === undefined) { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + let path = '/teams/{teamId}'.replace('{teamId}', teamId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Team + * + * Update a team by its unique ID. Only team owners have write access for this + * resource. + * + * @param {string} teamId + * @param {string} name + * @throws {AppwriteException} + * @returns {Promise} + */ + update: (teamId, name) => __awaiter(this, void 0, void 0, function* () { + if (teamId === undefined) { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + if (name === undefined) { + throw new AppwriteException('Missing required parameter: "name"'); + } + let path = '/teams/{teamId}'.replace('{teamId}', teamId); + let payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('put', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete Team + * + * Delete a team by its unique ID. Only team owners have write access for this + * resource. + * + * @param {string} teamId + * @throws {AppwriteException} + * @returns {Promise} + */ + delete: (teamId) => __awaiter(this, void 0, void 0, function* () { + if (teamId === undefined) { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + let path = '/teams/{teamId}'.replace('{teamId}', teamId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get Team Memberships + * + * Get a team members by the team unique ID. All team members have read access + * for this list of resources. + * + * @param {string} teamId + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {AppwriteException} + * @returns {Promise} + */ + getMemberships: (teamId, search = '', limit = 25, offset = 0, orderType = 'ASC') => __awaiter(this, void 0, void 0, function* () { + if (teamId === undefined) { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + let path = '/teams/{teamId}/memberships'.replace('{teamId}', teamId); + let payload = {}; + if (search) { + payload['search'] = search; + } + if (limit) { + payload['limit'] = limit; + } + if (offset) { + payload['offset'] = offset; + } + if (orderType) { + payload['orderType'] = orderType; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create Team Membership + * + * Use this endpoint to invite a new member to join your team. An email with a + * link to join the team will be sent to the new member email address if the + * member doesn't exist in the project it will be created automatically. + * + * Use the 'URL' parameter to redirect the user from the invitation email back + * to your app. When the user is redirected, use the [Update Team Membership + * Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow + * the user to accept the invitation to the team. + * + * Please note that in order to avoid a [Redirect + * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * the only valid redirect URL's are the once from domains you have set when + * added your platforms in the console interface. + * + * @param {string} teamId + * @param {string} email + * @param {string[]} roles + * @param {string} url + * @param {string} name + * @throws {AppwriteException} + * @returns {Promise} + */ + createMembership: (teamId, email, roles, url, name = '') => __awaiter(this, void 0, void 0, function* () { + if (teamId === undefined) { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + if (email === undefined) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (roles === undefined) { + throw new AppwriteException('Missing required parameter: "roles"'); + } + if (url === undefined) { + throw new AppwriteException('Missing required parameter: "url"'); + } + let path = '/teams/{teamId}/memberships'.replace('{teamId}', teamId); + let payload = {}; + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof roles !== 'undefined') { + payload['roles'] = roles; + } + if (typeof url !== 'undefined') { + payload['url'] = url; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Membership Roles + * + * + * @param {string} teamId + * @param {string} membershipId + * @param {string[]} roles + * @throws {AppwriteException} + * @returns {Promise} + */ + updateMembershipRoles: (teamId, membershipId, roles) => __awaiter(this, void 0, void 0, function* () { + if (teamId === undefined) { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + if (membershipId === undefined) { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + if (roles === undefined) { + throw new AppwriteException('Missing required parameter: "roles"'); + } + let path = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); + let payload = {}; + if (typeof roles !== 'undefined') { + payload['roles'] = roles; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete Team Membership + * + * This endpoint allows a user to leave a team or for a team owner to delete + * the membership of any other team member. You can also use this endpoint to + * delete a user membership even if it is not accepted. + * + * @param {string} teamId + * @param {string} membershipId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteMembership: (teamId, membershipId) => __awaiter(this, void 0, void 0, function* () { + if (teamId === undefined) { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + if (membershipId === undefined) { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + let path = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update Team Membership Status + * + * Use this endpoint to allow a user to accept an invitation to join a team + * after being redirected back to your app from the invitation email recieved + * by the user. + * + * @param {string} teamId + * @param {string} membershipId + * @param {string} userId + * @param {string} secret + * @throws {AppwriteException} + * @returns {Promise} + */ + updateMembershipStatus: (teamId, membershipId, userId, secret) => __awaiter(this, void 0, void 0, function* () { + if (teamId === undefined) { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + if (membershipId === undefined) { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + if (userId === undefined) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (secret === undefined) { + throw new AppwriteException('Missing required parameter: "secret"'); + } + let path = '/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); + let payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }) + }; + this.users = { + /** + * List Users + * + * Get a list of all the project's users. You can use the query params to + * filter your results. + * + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {AppwriteException} + * @returns {Promise} + */ + list: (search = '', limit = 25, offset = 0, orderType = 'ASC') => __awaiter(this, void 0, void 0, function* () { + let path = '/users'; + let payload = {}; + if (search) { + payload['search'] = search; + } + if (limit) { + payload['limit'] = limit; + } + if (offset) { + payload['offset'] = offset; + } + if (orderType) { + payload['orderType'] = orderType; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Create User + * + * Create a new user. + * + * @param {string} email + * @param {string} password + * @param {string} name + * @throws {AppwriteException} + * @returns {Promise} + */ + create: (email, password, name = '') => __awaiter(this, void 0, void 0, function* () { + if (email === undefined) { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (password === undefined) { + throw new AppwriteException('Missing required parameter: "password"'); + } + let path = '/users'; + let payload = {}; + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get User + * + * Get a user by its unique ID. + * + * @param {string} userId + * @throws {AppwriteException} + * @returns {Promise} + */ + get: (userId) => __awaiter(this, void 0, void 0, function* () { + if (userId === undefined) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + let path = '/users/{userId}'.replace('{userId}', userId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete User + * + * Delete a user by its unique ID. + * + * @param {string} userId + * @throws {AppwriteException} + * @returns {Promise} + */ + delete: (userId) => __awaiter(this, void 0, void 0, function* () { + if (userId === undefined) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + let path = '/users/{userId}'.replace('{userId}', userId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get User Logs + * + * Get a user activity logs list by its unique ID. + * + * @param {string} userId + * @throws {AppwriteException} + * @returns {Promise} + */ + getLogs: (userId) => __awaiter(this, void 0, void 0, function* () { + if (userId === undefined) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + let path = '/users/{userId}/logs'.replace('{userId}', userId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get User Preferences + * + * Get the user preferences by its unique ID. + * + * @param {string} userId + * @throws {AppwriteException} + * @returns {Promise} + */ + getPrefs: (userId) => __awaiter(this, void 0, void 0, function* () { + if (userId === undefined) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + let path = '/users/{userId}/prefs'.replace('{userId}', userId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update User Preferences + * + * Update the user preferences by its unique ID. You can pass only the + * specific settings you wish to update. + * + * @param {string} userId + * @param {object} prefs + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePrefs: (userId, prefs) => __awaiter(this, void 0, void 0, function* () { + if (userId === undefined) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (prefs === undefined) { + throw new AppwriteException('Missing required parameter: "prefs"'); + } + let path = '/users/{userId}/prefs'.replace('{userId}', userId); + let payload = {}; + if (typeof prefs !== 'undefined') { + payload['prefs'] = prefs; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Get User Sessions + * + * Get the user sessions list by its unique ID. + * + * @param {string} userId + * @throws {AppwriteException} + * @returns {Promise} + */ + getSessions: (userId) => __awaiter(this, void 0, void 0, function* () { + if (userId === undefined) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + let path = '/users/{userId}/sessions'.replace('{userId}', userId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete User Sessions + * + * Delete all user's sessions by using the user's unique ID. + * + * @param {string} userId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteSessions: (userId) => __awaiter(this, void 0, void 0, function* () { + if (userId === undefined) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + let path = '/users/{userId}/sessions'.replace('{userId}', userId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Delete User Session + * + * Delete a user sessions by its unique ID. + * + * @param {string} userId + * @param {string} sessionId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteSession: (userId, sessionId) => __awaiter(this, void 0, void 0, function* () { + if (userId === undefined) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (sessionId === undefined) { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + let path = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', userId).replace('{sessionId}', sessionId); + let payload = {}; + const uri = new URL(this.config.endpoint + path); + return yield this.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }), + /** + * Update User Status + * + * Update the user status by its unique ID. + * + * @param {string} userId + * @param {number} status + * @throws {AppwriteException} + * @returns {Promise} + */ + updateStatus: (userId, status) => __awaiter(this, void 0, void 0, function* () { + if (userId === undefined) { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (status === undefined) { + throw new AppwriteException('Missing required parameter: "status"'); + } + let path = '/users/{userId}/status'.replace('{userId}', userId); + let payload = {}; + if (typeof status !== 'undefined') { + payload['status'] = status; + } + const uri = new URL(this.config.endpoint + path); + return yield this.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }) + }; + } /** + * Set Endpoint + * + * Your project ID + * * @param {string} endpoint + * * @returns {this} */ - let setEndpoint = function(endpoint) { - config.endpoint = endpoint; - + setEndpoint(endpoint) { + this.config.endpoint = endpoint; return this; - }; - + } /** * Set Project * @@ -29,17 +3980,13 @@ * * @param value string * - * @return this + * @return {this} */ - let setProject = function (value) - { - http.addGlobalHeader('X-Appwrite-Project', value); - - config.project = value; - + setProject(value) { + this.headers['X-Appwrite-Project'] = value; + this.config.project = value; return this; - }; - + } /** * Set Key * @@ -47,5096 +3994,133 @@ * * @param value string * - * @return this + * @return {this} */ - let setKey = function (value) - { - http.addGlobalHeader('X-Appwrite-Key', value); - - config.key = value; - + setKey(value) { + this.headers['X-Appwrite-Key'] = value; + this.config.key = value; return this; - }; - + } + /** + * Set JWT + * + * Your secret JSON Web Token + * + * @param value string + * + * @return {this} + */ + setJWT(value) { + this.headers['X-Appwrite-JWT'] = value; + this.config.jwt = value; + return this; + } /** * Set Locale * * @param value string * - * @return this + * @return {this} */ - let setLocale = function (value) - { - http.addGlobalHeader('X-Appwrite-Locale', value); - - config.locale = value; - + setLocale(value) { + this.headers['X-Appwrite-Locale'] = value; + this.config.locale = value; return this; - }; - + } /** * Set Mode * * @param value string * - * @return this + * @return {this} */ - let setMode = function (value) - { - http.addGlobalHeader('X-Appwrite-Mode', value); - - config.mode = value; - + setMode(value) { + this.headers['X-Appwrite-Mode'] = value; + this.config.mode = value; return this; - }; - - let http = function(document) { - let globalParams = [], - globalHeaders = []; - - let addParam = function (url, param, value) { - let a = document.createElement('a'), regex = /(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g; - let match, str = []; - a.href = url; - param = encodeURIComponent(param); - - while (match = regex.exec(a.search)) if (param !== match[1]) str.push(match[1] + (match[2] ? "=" + match[2] : "")); - - str.push(param + (value ? "=" + encodeURIComponent(value) : "")); - - a.search = str.join("&"); - - return a.href; - }; - - /** - * @param {Object} params - * @returns {string} - */ - let buildQuery = function(params) { - let str = []; - - for (let p in params) { - if(Array.isArray(params[p])) { - for (let index = 0; index < params[p].length; index++) { - let param = params[p][index]; - str.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - str.push(encodeURIComponent(p) + "=" + encodeURIComponent(params[p])); + } + call(method, url, headers = {}, params = {}) { + var _a, _b; + return __awaiter(this, void 0, void 0, function* () { + method = method.toUpperCase(); + headers = Object.assign(Object.assign({}, headers), this.headers); + let options = { + method, + headers, + credentials: 'include' + }; + if (typeof window !== 'undefined' && window.localStorage) { + headers['X-Fallback-Cookies'] = (_a = window.localStorage.getItem('cookieFallback')) !== null && _a !== void 0 ? _a : ""; + } + if (method === 'GET') { + for (const [key, value] of Object.entries(this.flatten(params))) { + url.searchParams.append(key, value); } } - - return str.join("&"); - }; - - let addGlobalHeader = function(key, value) { - globalHeaders[key] = {key: key.toLowerCase(), value: value.toLowerCase()}; - }; - - let addGlobalParam = function(key, value) { - globalParams.push({key: key, value: value}); - }; - - addGlobalHeader('x-sdk-version', 'appwrite:web:1.0.0'); - addGlobalHeader('content-type', ''); - - /** - * @param {string} method - * @param {string} path string - * @param {Object} headers - * @param {Object} params - * @param {function} progress - * @returns {Promise} - */ - let call = function (method, path, headers = {}, params = {}, progress = null) { - let i; - - path = config.endpoint + path; - - if (-1 === ['GET', 'POST', 'PUT', 'DELETE', 'TRACE', 'HEAD', 'OPTIONS', 'CONNECT', 'PATCH'].indexOf(method)) { - throw new Error('var method must contain a valid HTTP method name'); - } - - if (typeof path !== 'string') { - throw new Error('var path must be of type string'); - } - - if (typeof headers !== 'object') { - throw new Error('var headers must be of type object'); - } - - for (i = 0; i < globalParams.length; i++) { // Add global params to URL - path = addParam(path, globalParams[i].key, globalParams[i].value); - } - - if(window.localStorage && window.localStorage.getItem('cookieFallback')) { - headers['X-Fallback-Cookies'] = window.localStorage.getItem('cookieFallback'); - } - - for (let key in globalHeaders) { // Add Global Headers - if (globalHeaders.hasOwnProperty(key)) { - if (!headers[globalHeaders[key].key]) { - headers[globalHeaders[key].key] = globalHeaders[key].value; - } - } - } - - if(method === 'GET') { - for (let param in params) { - if (param.hasOwnProperty(key)) { - path = addParam(path, key + (Array.isArray(param) ? '[]' : ''), params[key]); - } - } - } - - switch (headers['content-type']) { // Parse request by content type - case 'application/json': - params = JSON.stringify(params); - break; - - case 'multipart/form-data': - let formData = new FormData(); - - Object.keys(params).forEach(function(key) { - let param = params[key]; - formData.append(key + (Array.isArray(param) ? '[]' : ''), param); - }); - - params = formData; - break; - } - - return new Promise(function (resolve, reject) { - - let request = new XMLHttpRequest(), key; - - request.withCredentials = true; - request.open(method, path, true); - - for (key in headers) { // Set Headers - if (headers.hasOwnProperty(key)) { - if (key === 'content-type' && headers[key] === 'multipart/form-data') { // Skip to avoid missing boundary - continue; + else { + switch (headers['content-type']) { + case 'application/json': + options.body = JSON.stringify(params); + break; + case 'multipart/form-data': + let formData = new FormData(); + for (const key in params) { + if (Array.isArray(params[key])) { + formData.append(key + '[]', params[key].join(',')); + } + else { + formData.append(key, params[key]); + } } - - request.setRequestHeader(key, headers[key]); - } + options.body = formData; + delete headers['content-type']; + break; } - - request.onload = function () { - let data = request.response; - let contentType = this.getResponseHeader('content-type') || ''; - contentType = contentType.substring(0, contentType.indexOf(';')); - - switch (contentType) { - case 'application/json': - data = JSON.parse(data); - break; - } - - let cookieFallback = this.getResponseHeader('X-Fallback-Cookies') || ''; - - if(window.localStorage && cookieFallback) { - window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.'); - window.localStorage.setItem('cookieFallback', cookieFallback); - } - - if (4 === request.readyState && 399 >= request.status) { - resolve(data); - } else { - reject(data); - } - }; - - if (progress) { - request.addEventListener('progress', progress); - request.upload.addEventListener('progress', progress, false); - } - - // Handle network errors - request.onerror = function () { - reject(new Error("Network Error")); - }; - - request.send(params); - }) - }; - - return { - 'get': function(path, headers = {}, params = {}) { - return call('GET', path + ((Object.keys(params).length > 0) ? '?' + buildQuery(params) : ''), headers, {}); - }, - 'post': function(path, headers = {}, params = {}, progress = null) { - return call('POST', path, headers, params, progress); - }, - 'put': function(path, headers = {}, params = {}, progress = null) { - return call('PUT', path, headers, params, progress); - }, - 'patch': function(path, headers = {}, params = {}, progress = null) { - return call('PATCH', path, headers, params, progress); - }, - 'delete': function(path, headers = {}, params = {}, progress = null) { - return call('DELETE', path, headers, params, progress); - }, - 'addGlobalParam': addGlobalParam, - 'addGlobalHeader': addGlobalHeader - } - }(window.document); - - let account = { - - /** - * Get Account - * - * Get currently logged in user data as JSON object. - * - * @throws {Error} - * @return {Promise} - */ - get: function() { - let path = '/account'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Account - * - * Use this endpoint to allow a new user to register a new account in your - * project. After the user registration completes successfully, you can use - * the [/account/verfication](/docs/client/account#accountCreateVerification) - * route to start verifying the user email address. To allow the new user to - * login to their new account, you need to create a new [account - * session](/docs/client/account#accountCreateSession). - * - * @param {string} email - * @param {string} password - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - create: function(email, password, name = '') { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - let path = '/account'; - - let payload = {}; - - if(typeof email !== 'undefined') { - payload['email'] = email; - } - - if(typeof password !== 'undefined') { - payload['password'] = password; - } - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Account - * - * Delete a currently logged in user account. Behind the scene, the user - * record is not deleted but permanently blocked from any access. This is done - * to avoid deleted accounts being overtaken by new users with the same email - * address. Any user-related resources like documents or storage files should - * be deleted separately. - * - * @throws {Error} - * @return {Promise} - */ - delete: function() { - let path = '/account'; - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Account Email - * - * Update currently logged in user account email address. After changing user - * address, user confirmation status is being reset and a new confirmation - * mail is sent. For security measures, user password is required to complete - * this request. - * - * @param {string} email - * @param {string} password - * @throws {Error} - * @return {Promise} - */ - updateEmail: function(email, password) { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - let path = '/account/email'; - - let payload = {}; - - if(typeof email !== 'undefined') { - payload['email'] = email; - } - - if(typeof password !== 'undefined') { - payload['password'] = password; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Account Logs - * - * Get currently logged in user list of latest security activity logs. Each - * log returns user IP address, location and date and time of log. - * - * @throws {Error} - * @return {Promise} - */ - getLogs: function() { - let path = '/account/logs'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Account Name - * - * Update currently logged in user account name. - * - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - updateName: function(name) { - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/account/name'; - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Account Password - * - * Update currently logged in user password. For validation, user is required - * to pass the password twice. - * - * @param {string} password - * @param {string} oldPassword - * @throws {Error} - * @return {Promise} - */ - updatePassword: function(password, oldPassword) { - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - if(oldPassword === undefined) { - throw new Error('Missing required parameter: "oldPassword"'); - } - - let path = '/account/password'; - - let payload = {}; - - if(typeof password !== 'undefined') { - payload['password'] = password; - } - - if(typeof oldPassword !== 'undefined') { - payload['oldPassword'] = oldPassword; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Account Preferences - * - * Get currently logged in user preferences as a key-value object. - * - * @throws {Error} - * @return {Promise} - */ - getPrefs: function() { - let path = '/account/prefs'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Account Preferences - * - * Update currently logged in user account preferences. You can pass only the - * specific settings you wish to update. - * - * @param {object} prefs - * @throws {Error} - * @return {Promise} - */ - updatePrefs: function(prefs) { - if(prefs === undefined) { - throw new Error('Missing required parameter: "prefs"'); - } - - let path = '/account/prefs'; - - let payload = {}; - - if(typeof prefs !== 'undefined') { - payload['prefs'] = prefs; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Password Recovery - * - * Sends the user an email with a temporary secret key for password reset. - * When the user clicks the confirmation link he is redirected back to your - * app password reset URL with the secret key and email address values - * attached to the URL query string. Use the query string params to submit a - * request to the [PUT - * /account/recovery](/docs/client/account#accountUpdateRecovery) endpoint to - * complete the process. - * - * @param {string} email - * @param {string} url - * @throws {Error} - * @return {Promise} - */ - createRecovery: function(email, url) { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/account/recovery'; - - let payload = {}; - - if(typeof email !== 'undefined') { - payload['email'] = email; - } - - if(typeof url !== 'undefined') { - payload['url'] = url; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Complete Password Recovery - * - * Use this endpoint to complete the user account password reset. Both the - * **userId** and **secret** arguments will be passed as query parameters to - * the redirect URL you have provided when sending your request to the [POST - * /account/recovery](/docs/client/account#accountCreateRecovery) endpoint. - * - * Please note that in order to avoid a [Redirect - * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URLs are the ones from domains you have set when - * adding your platforms in the console interface. - * - * @param {string} userId - * @param {string} secret - * @param {string} password - * @param {string} passwordAgain - * @throws {Error} - * @return {Promise} - */ - updateRecovery: function(userId, secret, password, passwordAgain) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(secret === undefined) { - throw new Error('Missing required parameter: "secret"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - if(passwordAgain === undefined) { - throw new Error('Missing required parameter: "passwordAgain"'); - } - - let path = '/account/recovery'; - - let payload = {}; - - if(typeof userId !== 'undefined') { - payload['userId'] = userId; - } - - if(typeof secret !== 'undefined') { - payload['secret'] = secret; - } - - if(typeof password !== 'undefined') { - payload['password'] = password; - } - - if(typeof passwordAgain !== 'undefined') { - payload['passwordAgain'] = passwordAgain; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Account Sessions - * - * Get currently logged in user list of active sessions across different - * devices. - * - * @throws {Error} - * @return {Promise} - */ - getSessions: function() { - let path = '/account/sessions'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Account Session - * - * Allow the user to login into their account by providing a valid email and - * password combination. This route will create a new session for the user. - * - * @param {string} email - * @param {string} password - * @throws {Error} - * @return {Promise} - */ - createSession: function(email, password) { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - let path = '/account/sessions'; - - let payload = {}; - - if(typeof email !== 'undefined') { - payload['email'] = email; - } - - if(typeof password !== 'undefined') { - payload['password'] = password; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete All Account Sessions - * - * Delete all sessions from the user account and remove any sessions cookies - * from the end client. - * - * @throws {Error} - * @return {Promise} - */ - deleteSessions: function() { - let path = '/account/sessions'; - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Account Session with OAuth2 - * - * Allow the user to login to their account using the OAuth2 provider of their - * choice. Each OAuth2 provider should be enabled from the Appwrite console - * first. Use the success and failure arguments to provide a redirect URL's - * back to your app when login is completed. - * - * @param {string} provider - * @param {string} success - * @param {string} failure - * @param {string[]} scopes - * @throws {Error} - * @return {Promise} - */ - createOAuth2Session: function(provider, success = 'https://appwrite.io/auth/oauth2/success', failure = 'https://appwrite.io/auth/oauth2/failure', scopes = []) { - if(provider === undefined) { - throw new Error('Missing required parameter: "provider"'); - } - - let path = '/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}', 'g'), provider); - - let payload = {}; - - if(success) { - payload['success'] = success; - } - - if(failure) { - payload['failure'] = failure; - } - - if(scopes) { - payload['scopes'] = scopes; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } + try { + let data = null; + const response = yield crossFetch.fetch(url.toString(), options); + if ((_b = response.headers.get("content-type")) === null || _b === void 0 ? void 0 : _b.includes("application/json")) { + data = yield response.json(); } else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); + data = { + message: yield response.text() + }; } + if (400 <= response.status) { + throw new AppwriteException(data === null || data === void 0 ? void 0 : data.message, response.status, data); + } + const cookieFallback = response.headers.get('X-Fallback-Cookies'); + if (typeof window !== 'undefined' && window.localStorage && cookieFallback) { + window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.'); + window.localStorage.setItem('cookieFallback', cookieFallback); + } + return data; } - - query = query.join("&"); - - window.location = config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Delete Account Session - * - * Use this endpoint to log out the currently logged in user from all their - * account sessions across all of their different devices. When using the - * option id argument, only the session unique ID provider will be deleted. - * - * @param {string} sessionId - * @throws {Error} - * @return {Promise} - */ - deleteSession: function(sessionId) { - if(sessionId === undefined) { - throw new Error('Missing required parameter: "sessionId"'); + catch (e) { + throw new AppwriteException(e.message); } - - let path = '/account/sessions/{sessionId}'.replace(new RegExp('{sessionId}', 'g'), sessionId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Email Verification - * - * Use this endpoint to send a verification message to your user email address - * to confirm they are the valid owners of that address. Both the **userId** - * and **secret** arguments will be passed as query parameters to the URL you - * have provided to be attached to the verification email. The provided URL - * should redirect the user back to your app and allow you to complete the - * verification process by verifying both the **userId** and **secret** - * parameters. Learn more about how to [complete the verification - * process](/docs/client/account#accountUpdateVerification). - * - * Please note that in order to avoid a [Redirect - * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), - * the only valid redirect URLs are the ones from domains you have set when - * adding your platforms in the console interface. - * - * - * @param {string} url - * @throws {Error} - * @return {Promise} - */ - createVerification: function(url) { - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); + }); + } + flatten(data, prefix = '') { + let output = {}; + for (const key in data) { + let value = data[key]; + let finalKey = prefix ? `${prefix}[${key}]` : key; + if (Array.isArray(value)) { + output = Object.assign(output, this.flatten(value, finalKey)); } - - let path = '/account/verification'; - - let payload = {}; - - if(typeof url !== 'undefined') { - payload['url'] = url; + else { + output[finalKey] = value; } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Complete Email Verification - * - * Use this endpoint to complete the user email verification process. Use both - * the **userId** and **secret** parameters that were attached to your app URL - * to verify the user email ownership. If confirmed this route will return a - * 200 status code. - * - * @param {string} userId - * @param {string} secret - * @throws {Error} - * @return {Promise} - */ - updateVerification: function(userId, secret) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(secret === undefined) { - throw new Error('Missing required parameter: "secret"'); - } - - let path = '/account/verification'; - - let payload = {}; - - if(typeof userId !== 'undefined') { - payload['userId'] = userId; - } - - if(typeof secret !== 'undefined') { - payload['secret'] = secret; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); } - }; - - let avatars = { - - /** - * Get Browser Icon - * - * You can use this endpoint to show different browser icons to your users. - * The code argument receives the browser code as it appears in your user - * /account/sessions endpoint. Use width, height and quality arguments to - * change the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getBrowser: function(code, width = 100, height = 100, quality = 100) { - if(code === undefined) { - throw new Error('Missing required parameter: "code"'); - } - - let path = '/avatars/browsers/{code}'.replace(new RegExp('{code}', 'g'), code); - - let payload = {}; - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(quality) { - payload['quality'] = quality; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get Credit Card Icon - * - * The credit card endpoint will return you the icon of the credit card - * provider you need. Use width, height and quality arguments to change the - * output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getCreditCard: function(code, width = 100, height = 100, quality = 100) { - if(code === undefined) { - throw new Error('Missing required parameter: "code"'); - } - - let path = '/avatars/credit-cards/{code}'.replace(new RegExp('{code}', 'g'), code); - - let payload = {}; - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(quality) { - payload['quality'] = quality; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get Favicon - * - * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote - * website URL. - * - * - * @param {string} url - * @throws {Error} - * @return {string} - */ - getFavicon: function(url) { - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/avatars/favicon'; - - let payload = {}; - - if(url) { - payload['url'] = url; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get Country Flag - * - * You can use this endpoint to show different country flags icons to your - * users. The code argument receives the 2 letter country code. Use width, - * height and quality arguments to change the output settings. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {Error} - * @return {string} - */ - getFlag: function(code, width = 100, height = 100, quality = 100) { - if(code === undefined) { - throw new Error('Missing required parameter: "code"'); - } - - let path = '/avatars/flags/{code}'.replace(new RegExp('{code}', 'g'), code); - - let payload = {}; - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(quality) { - payload['quality'] = quality; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get Image from URL - * - * Use this endpoint to fetch a remote image URL and crop it to any image size - * you want. This endpoint is very useful if you need to crop and display - * remote images in your app or in case you want to make sure a 3rd party - * image is properly served using a TLS protocol. - * - * @param {string} url - * @param {number} width - * @param {number} height - * @throws {Error} - * @return {string} - */ - getImage: function(url, width = 400, height = 400) { - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/avatars/image'; - - let payload = {}; - - if(url) { - payload['url'] = url; - } - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get User Initials - * - * Use this endpoint to show your user initials avatar icon on your website or - * app. By default, this route will try to print your logged-in user name or - * email initials. You can also overwrite the user name if you pass the 'name' - * parameter. If no name is given and no user is logged, an empty avatar will - * be returned. - * - * You can use the color and background params to change the avatar colors. By - * default, a random theme will be selected. The random theme will persist for - * the user's initials when reloading the same theme will always return for - * the same initials. - * - * @param {string} name - * @param {number} width - * @param {number} height - * @param {string} color - * @param {string} background - * @throws {Error} - * @return {string} - */ - getInitials: function(name = '', width = 500, height = 500, color = '', background = '') { - let path = '/avatars/initials'; - - let payload = {}; - - if(name) { - payload['name'] = name; - } - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(color) { - payload['color'] = color; - } - - if(background) { - payload['background'] = background; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get QR Code - * - * Converts a given plain text to a QR code image. You can use the query - * parameters to change the size and style of the resulting image. - * - * @param {string} text - * @param {number} size - * @param {number} margin - * @param {boolean} download - * @throws {Error} - * @return {string} - */ - getQR: function(text, size = 400, margin = 1, download = false) { - if(text === undefined) { - throw new Error('Missing required parameter: "text"'); - } - - let path = '/avatars/qr'; - - let payload = {}; - - if(text) { - payload['text'] = text; - } - - if(size) { - payload['size'] = size; - } - - if(margin) { - payload['margin'] = margin; - } - - if(download) { - payload['download'] = download; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - } - }; - - let database = { - - /** - * List Collections - * - * Get a list of all the user collections. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project's collections. [Learn more about different API - * modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - listCollections: function(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/database/collections'; - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Collection - * - * Create a new Collection. - * - * @param {string} name - * @param {string[]} read - * @param {string[]} write - * @param {string[]} rules - * @throws {Error} - * @return {Promise} - */ - createCollection: function(name, read, write, rules) { - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - if(rules === undefined) { - throw new Error('Missing required parameter: "rules"'); - } - - let path = '/database/collections'; - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof read !== 'undefined') { - payload['read'] = read; - } - - if(typeof write !== 'undefined') { - payload['write'] = write; - } - - if(typeof rules !== 'undefined') { - payload['rules'] = rules; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Collection - * - * Get a collection by its unique ID. This endpoint response returns a JSON - * object with the collection metadata. - * - * @param {string} collectionId - * @throws {Error} - * @return {Promise} - */ - getCollection: function(collectionId) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Collection - * - * Update a collection by its unique ID. - * - * @param {string} collectionId - * @param {string} name - * @param {string[]} read - * @param {string[]} write - * @param {string[]} rules - * @throws {Error} - * @return {Promise} - */ - updateCollection: function(collectionId, name, read, write, rules = []) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof read !== 'undefined') { - payload['read'] = read; - } - - if(typeof write !== 'undefined') { - payload['write'] = write; - } - - if(typeof rules !== 'undefined') { - payload['rules'] = rules; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Collection - * - * Delete a collection by its unique ID. Only users with write permissions - * have access to delete this resource. - * - * @param {string} collectionId - * @throws {Error} - * @return {Promise} - */ - deleteCollection: function(collectionId) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Documents - * - * Get a list of all the user documents. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project's documents. [Learn more about different API - * modes](/docs/admin). - * - * @param {string} collectionId - * @param {string[]} filters - * @param {number} limit - * @param {number} offset - * @param {string} orderField - * @param {string} orderType - * @param {string} orderCast - * @param {string} search - * @throws {Error} - * @return {Promise} - */ - listDocuments: function(collectionId, filters = [], limit = 25, offset = 0, orderField = '', orderType = 'ASC', orderCast = 'string', search = '') { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - let payload = {}; - - if(filters) { - payload['filters'] = filters; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderField) { - payload['orderField'] = orderField; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - if(orderCast) { - payload['orderCast'] = orderCast; - } - - if(search) { - payload['search'] = search; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Document - * - * Create a new Document. Before using this route, you should create a new - * collection resource using either a [server - * integration](/docs/server/database#databaseCreateCollection) API or - * directly from your database console. - * - * @param {string} collectionId - * @param {object} data - * @param {string[]} read - * @param {string[]} write - * @param {string} parentDocument - * @param {string} parentProperty - * @param {string} parentPropertyType - * @throws {Error} - * @return {Promise} - */ - createDocument: function(collectionId, data, read, write, parentDocument = '', parentProperty = '', parentPropertyType = 'assign') { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(data === undefined) { - throw new Error('Missing required parameter: "data"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); - - let payload = {}; - - if(typeof data !== 'undefined') { - payload['data'] = data; - } - - if(typeof read !== 'undefined') { - payload['read'] = read; - } - - if(typeof write !== 'undefined') { - payload['write'] = write; - } - - if(typeof parentDocument !== 'undefined') { - payload['parentDocument'] = parentDocument; - } - - if(typeof parentProperty !== 'undefined') { - payload['parentProperty'] = parentProperty; - } - - if(typeof parentPropertyType !== 'undefined') { - payload['parentPropertyType'] = parentPropertyType; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Document - * - * Get a document by its unique ID. This endpoint response returns a JSON - * object with the document data. - * - * @param {string} collectionId - * @param {string} documentId - * @throws {Error} - * @return {Promise} - */ - getDocument: function(collectionId, documentId) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(documentId === undefined) { - throw new Error('Missing required parameter: "documentId"'); - } - - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Document - * - * Update a document by its unique ID. Using the patch method you can pass - * only specific fields that will get updated. - * - * @param {string} collectionId - * @param {string} documentId - * @param {object} data - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - updateDocument: function(collectionId, documentId, data, read, write) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(documentId === undefined) { - throw new Error('Missing required parameter: "documentId"'); - } - - if(data === undefined) { - throw new Error('Missing required parameter: "data"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - let payload = {}; - - if(typeof data !== 'undefined') { - payload['data'] = data; - } - - if(typeof read !== 'undefined') { - payload['read'] = read; - } - - if(typeof write !== 'undefined') { - payload['write'] = write; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Document - * - * Delete a document by its unique ID. This endpoint deletes only the parent - * documents, its attributes and relations to other documents. Child documents - * **will not** be deleted. - * - * @param {string} collectionId - * @param {string} documentId - * @throws {Error} - * @return {Promise} - */ - deleteDocument: function(collectionId, documentId) { - if(collectionId === undefined) { - throw new Error('Missing required parameter: "collectionId"'); - } - - if(documentId === undefined) { - throw new Error('Missing required parameter: "documentId"'); - } - - let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let functions = { - - /** - * List Functions - * - * Get a list of all the project's functions. You can use the query params to - * filter your results. - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - list: function(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/functions'; - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Function - * - * Create a new function. You can pass a list of - * [permissions](/docs/permissions) to allow different project users or team - * with access to execute the function using the client API. - * - * @param {string} name - * @param {string[]} execute - * @param {string} env - * @param {object} vars - * @param {string[]} events - * @param {string} schedule - * @param {number} timeout - * @throws {Error} - * @return {Promise} - */ - create: function(name, execute, env, vars = {}, events = [], schedule = '', timeout = 15) { - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(execute === undefined) { - throw new Error('Missing required parameter: "execute"'); - } - - if(env === undefined) { - throw new Error('Missing required parameter: "env"'); - } - - let path = '/functions'; - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof execute !== 'undefined') { - payload['execute'] = execute; - } - - if(typeof env !== 'undefined') { - payload['env'] = env; - } - - if(typeof vars !== 'undefined') { - payload['vars'] = vars; - } - - if(typeof events !== 'undefined') { - payload['events'] = events; - } - - if(typeof schedule !== 'undefined') { - payload['schedule'] = schedule; - } - - if(typeof timeout !== 'undefined') { - payload['timeout'] = timeout; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Function - * - * Get a function by its unique ID. - * - * @param {string} functionId - * @throws {Error} - * @return {Promise} - */ - get: function(functionId) { - if(functionId === undefined) { - throw new Error('Missing required parameter: "functionId"'); - } - - let path = '/functions/{functionId}'.replace(new RegExp('{functionId}', 'g'), functionId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Function - * - * Update function by its unique ID. - * - * @param {string} functionId - * @param {string} name - * @param {string[]} execute - * @param {object} vars - * @param {string[]} events - * @param {string} schedule - * @param {number} timeout - * @throws {Error} - * @return {Promise} - */ - update: function(functionId, name, execute, vars = {}, events = [], schedule = '', timeout = 15) { - if(functionId === undefined) { - throw new Error('Missing required parameter: "functionId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(execute === undefined) { - throw new Error('Missing required parameter: "execute"'); - } - - let path = '/functions/{functionId}'.replace(new RegExp('{functionId}', 'g'), functionId); - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof execute !== 'undefined') { - payload['execute'] = execute; - } - - if(typeof vars !== 'undefined') { - payload['vars'] = vars; - } - - if(typeof events !== 'undefined') { - payload['events'] = events; - } - - if(typeof schedule !== 'undefined') { - payload['schedule'] = schedule; - } - - if(typeof timeout !== 'undefined') { - payload['timeout'] = timeout; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Function - * - * Delete a function by its unique ID. - * - * @param {string} functionId - * @throws {Error} - * @return {Promise} - */ - delete: function(functionId) { - if(functionId === undefined) { - throw new Error('Missing required parameter: "functionId"'); - } - - let path = '/functions/{functionId}'.replace(new RegExp('{functionId}', 'g'), functionId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Executions - * - * Get a list of all the current user function execution logs. You can use the - * query params to filter your results. On admin mode, this endpoint will - * return a list of all of the project's executions. [Learn more about - * different API modes](/docs/admin). - * - * @param {string} functionId - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - listExecutions: function(functionId, search = '', limit = 25, offset = 0, orderType = 'ASC') { - if(functionId === undefined) { - throw new Error('Missing required parameter: "functionId"'); - } - - let path = '/functions/{functionId}/executions'.replace(new RegExp('{functionId}', 'g'), functionId); - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Execution - * - * Trigger a function execution. The returned object will return you the - * current execution status. You can ping the `Get Execution` endpoint to get - * updates on the current execution status. Once this endpoint is called, your - * function execution process will start asynchronously. - * - * @param {string} functionId - * @param {string} data - * @throws {Error} - * @return {Promise} - */ - createExecution: function(functionId, data) { - if(functionId === undefined) { - throw new Error('Missing required parameter: "functionId"'); - } - - let path = '/functions/{functionId}/executions'.replace(new RegExp('{functionId}', 'g'), functionId); - - let payload = {}; - - if (data) { - payload['data'] = data; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Execution - * - * Get a function execution log by its unique ID. - * - * @param {string} functionId - * @param {string} executionId - * @throws {Error} - * @return {Promise} - */ - getExecution: function(functionId, executionId) { - if(functionId === undefined) { - throw new Error('Missing required parameter: "functionId"'); - } - - if(executionId === undefined) { - throw new Error('Missing required parameter: "executionId"'); - } - - let path = '/functions/{functionId}/executions/{executionId}'.replace(new RegExp('{functionId}', 'g'), functionId).replace(new RegExp('{executionId}', 'g'), executionId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Function Tag - * - * Update the function code tag ID using the unique function ID. Use this - * endpoint to switch the code tag that should be executed by the execution - * endpoint. - * - * @param {string} functionId - * @param {string} tag - * @throws {Error} - * @return {Promise} - */ - updateTag: function(functionId, tag) { - if(functionId === undefined) { - throw new Error('Missing required parameter: "functionId"'); - } - - if(tag === undefined) { - throw new Error('Missing required parameter: "tag"'); - } - - let path = '/functions/{functionId}/tag'.replace(new RegExp('{functionId}', 'g'), functionId); - - let payload = {}; - - if(typeof tag !== 'undefined') { - payload['tag'] = tag; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Tags - * - * Get a list of all the project's code tags. You can use the query params to - * filter your results. - * - * @param {string} functionId - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - listTags: function(functionId, search = '', limit = 25, offset = 0, orderType = 'ASC') { - if(functionId === undefined) { - throw new Error('Missing required parameter: "functionId"'); - } - - let path = '/functions/{functionId}/tags'.replace(new RegExp('{functionId}', 'g'), functionId); - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Tag - * - * Create a new function code tag. Use this endpoint to upload a new version - * of your code function. To execute your newly uploaded code, you'll need to - * update the function's tag to use your new tag UID. - * - * This endpoint accepts a tar.gz file compressed with your code. Make sure to - * include any dependencies your code has within the compressed file. You can - * learn more about code packaging in the [Appwrite Cloud Functions - * tutorial](/docs/functions). - * - * Use the "command" param to set the entry point used to execute your code. - * - * @param {string} functionId - * @param {string} command - * @param {File} code - * @throws {Error} - * @return {Promise} - */ - createTag: function(functionId, command, code) { - if(functionId === undefined) { - throw new Error('Missing required parameter: "functionId"'); - } - - if(command === undefined) { - throw new Error('Missing required parameter: "command"'); - } - - if(code === undefined) { - throw new Error('Missing required parameter: "code"'); - } - - let path = '/functions/{functionId}/tags'.replace(new RegExp('{functionId}', 'g'), functionId); - - let payload = {}; - - if(typeof command !== 'undefined') { - payload['command'] = command; - } - - if(typeof code !== 'undefined') { - payload['code'] = code; - } - - return http - .post(path, { - 'content-type': 'multipart/form-data', - }, payload); - }, - - /** - * Get Tag - * - * Get a code tag by its unique ID. - * - * @param {string} functionId - * @param {string} tagId - * @throws {Error} - * @return {Promise} - */ - getTag: function(functionId, tagId) { - if(functionId === undefined) { - throw new Error('Missing required parameter: "functionId"'); - } - - if(tagId === undefined) { - throw new Error('Missing required parameter: "tagId"'); - } - - let path = '/functions/{functionId}/tags/{tagId}'.replace(new RegExp('{functionId}', 'g'), functionId).replace(new RegExp('{tagId}', 'g'), tagId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Tag - * - * Delete a code tag by its unique ID. - * - * @param {string} functionId - * @param {string} tagId - * @throws {Error} - * @return {Promise} - */ - deleteTag: function(functionId, tagId) { - if(functionId === undefined) { - throw new Error('Missing required parameter: "functionId"'); - } - - if(tagId === undefined) { - throw new Error('Missing required parameter: "tagId"'); - } - - let path = '/functions/{functionId}/tags/{tagId}'.replace(new RegExp('{functionId}', 'g'), functionId).replace(new RegExp('{tagId}', 'g'), tagId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Function Usage - * - * - * @param {string} functionId - * @param {string} range - * @throws {Error} - * @return {Promise} - */ - getUsage: function(functionId, range = '30d') { - if(functionId === undefined) { - throw new Error('Missing required parameter: "functionId"'); - } - - let path = '/functions/{functionId}/usage'.replace(new RegExp('{functionId}', 'g'), functionId); - - let payload = {}; - - if(range) { - payload['range'] = range; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let health = { - - /** - * Get HTTP - * - * Check the Appwrite HTTP server is up and responsive. - * - * @throws {Error} - * @return {Promise} - */ - get: function() { - let path = '/health'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Anti virus - * - * Check the Appwrite Anti Virus server is up and connection is successful. - * - * @throws {Error} - * @return {Promise} - */ - getAntiVirus: function() { - let path = '/health/anti-virus'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Cache - * - * Check the Appwrite in-memory cache server is up and connection is - * successful. - * - * @throws {Error} - * @return {Promise} - */ - getCache: function() { - let path = '/health/cache'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get DB - * - * Check the Appwrite database server is up and connection is successful. - * - * @throws {Error} - * @return {Promise} - */ - getDB: function() { - let path = '/health/db'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Certificate Queue - * - * Get the number of certificates that are waiting to be issued against - * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue - * server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueCertificates: function() { - let path = '/health/queue/certificates'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Functions Queue - * - * - * @throws {Error} - * @return {Promise} - */ - getQueueFunctions: function() { - let path = '/health/queue/functions'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Logs Queue - * - * Get the number of logs that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueLogs: function() { - let path = '/health/queue/logs'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Tasks Queue - * - * Get the number of tasks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueTasks: function() { - let path = '/health/queue/tasks'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Usage Queue - * - * Get the number of usage stats that are waiting to be processed in the - * Appwrite internal queue server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueUsage: function() { - let path = '/health/queue/usage'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Webhooks Queue - * - * Get the number of webhooks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @throws {Error} - * @return {Promise} - */ - getQueueWebhooks: function() { - let path = '/health/queue/webhooks'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Local Storage - * - * Check the Appwrite local storage device is up and connection is successful. - * - * @throws {Error} - * @return {Promise} - */ - getStorageLocal: function() { - let path = '/health/storage/local'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Time - * - * Check the Appwrite server time is synced with Google remote NTP server. We - * use this technology to smoothly handle leap seconds with no disruptive - * events. The [Network Time - * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is - * used by hundreds of millions of computers and devices to synchronize their - * clocks over the Internet. If your computer sets its own clock, it likely - * uses NTP. - * - * @throws {Error} - * @return {Promise} - */ - getTime: function() { - let path = '/health/time'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let locale = { - - /** - * Get User Locale - * - * Get the current user location based on IP. Returns an object with user - * country code, country name, continent name, continent code, ip address and - * suggested currency. You can use the locale header to get the data in a - * supported language. - * - * ([IP Geolocation by DB-IP](https://db-ip.com)) - * - * @throws {Error} - * @return {Promise} - */ - get: function() { - let path = '/locale'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Continents - * - * List of all continents. You can use the locale header to get the data in a - * supported language. - * - * @throws {Error} - * @return {Promise} - */ - getContinents: function() { - let path = '/locale/continents'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Countries - * - * List of all countries. You can use the locale header to get the data in a - * supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountries: function() { - let path = '/locale/countries'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List EU Countries - * - * List of all countries that are currently members of the EU. You can use the - * locale header to get the data in a supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountriesEU: function() { - let path = '/locale/countries/eu'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Countries Phone Codes - * - * List of all countries phone codes. You can use the locale header to get the - * data in a supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCountriesPhones: function() { - let path = '/locale/countries/phones'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Currencies - * - * List of all currencies, including currency symbol, name, plural, and - * decimal digits for all major and minor currencies. You can use the locale - * header to get the data in a supported language. - * - * @throws {Error} - * @return {Promise} - */ - getCurrencies: function() { - let path = '/locale/currencies'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Languages - * - * List of all languages classified by ISO 639-1 including 2-letter code, name - * in English, and name in the respective language. - * - * @throws {Error} - * @return {Promise} - */ - getLanguages: function() { - let path = '/locale/languages'; - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let projects = { - - /** - * List Projects - * - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - list: function(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/projects'; - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Project - * - * - * @param {string} name - * @param {string} teamId - * @param {string} description - * @param {string} logo - * @param {string} url - * @param {string} legalName - * @param {string} legalCountry - * @param {string} legalState - * @param {string} legalCity - * @param {string} legalAddress - * @param {string} legalTaxId - * @throws {Error} - * @return {Promise} - */ - create: function(name, teamId, description = '', logo = '', url = '', legalName = '', legalCountry = '', legalState = '', legalCity = '', legalAddress = '', legalTaxId = '') { - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - let path = '/projects'; - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof teamId !== 'undefined') { - payload['teamId'] = teamId; - } - - if(typeof description !== 'undefined') { - payload['description'] = description; - } - - if(typeof logo !== 'undefined') { - payload['logo'] = logo; - } - - if(typeof url !== 'undefined') { - payload['url'] = url; - } - - if(typeof legalName !== 'undefined') { - payload['legalName'] = legalName; - } - - if(typeof legalCountry !== 'undefined') { - payload['legalCountry'] = legalCountry; - } - - if(typeof legalState !== 'undefined') { - payload['legalState'] = legalState; - } - - if(typeof legalCity !== 'undefined') { - payload['legalCity'] = legalCity; - } - - if(typeof legalAddress !== 'undefined') { - payload['legalAddress'] = legalAddress; - } - - if(typeof legalTaxId !== 'undefined') { - payload['legalTaxId'] = legalTaxId; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Project - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - get: function(projectId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Project - * - * - * @param {string} projectId - * @param {string} name - * @param {string} description - * @param {string} logo - * @param {string} url - * @param {string} legalName - * @param {string} legalCountry - * @param {string} legalState - * @param {string} legalCity - * @param {string} legalAddress - * @param {string} legalTaxId - * @throws {Error} - * @return {Promise} - */ - update: function(projectId, name, description = '', logo = '', url = '', legalName = '', legalCountry = '', legalState = '', legalCity = '', legalAddress = '', legalTaxId = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/projects/{projectId}'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof description !== 'undefined') { - payload['description'] = description; - } - - if(typeof logo !== 'undefined') { - payload['logo'] = logo; - } - - if(typeof url !== 'undefined') { - payload['url'] = url; - } - - if(typeof legalName !== 'undefined') { - payload['legalName'] = legalName; - } - - if(typeof legalCountry !== 'undefined') { - payload['legalCountry'] = legalCountry; - } - - if(typeof legalState !== 'undefined') { - payload['legalState'] = legalState; - } - - if(typeof legalCity !== 'undefined') { - payload['legalCity'] = legalCity; - } - - if(typeof legalAddress !== 'undefined') { - payload['legalAddress'] = legalAddress; - } - - if(typeof legalTaxId !== 'undefined') { - payload['legalTaxId'] = legalTaxId; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Project - * - * - * @param {string} projectId - * @param {string} password - * @throws {Error} - * @return {Promise} - */ - delete: function(projectId, password) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - let path = '/projects/{projectId}'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(typeof password !== 'undefined') { - payload['password'] = password; - } - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Project users limit - * - * - * @param {string} projectId - * @param {string} limit - * @throws {Error} - * @return {Promise} - */ - updateAuthLimit: function(projectId, limit) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(limit === undefined) { - throw new Error('Missing required parameter: "limit"'); - } - - let path = '/projects/{projectId}/auth/limit'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(typeof limit !== 'undefined') { - payload['limit'] = limit; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Project auth method status. Use this endpoint to enable or disable a given auth method for this project. - * - * - * @param {string} projectId - * @param {string} method - * @param {boolean} status - * @throws {Error} - * @return {Promise} - */ - updateAuthStatus: function(projectId, method, status) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(method === undefined) { - throw new Error('Missing required parameter: "method"'); - } - - if(status === undefined) { - throw new Error('Missing required parameter: "status"'); - } - - let path = '/projects/{projectId}/auth/{method}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{method}', 'g'), method); - - let payload = {}; - - if(typeof status !== 'undefined') { - payload['status'] = status; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Domains - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listDomains: function(projectId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}/domains'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Domain - * - * - * @param {string} projectId - * @param {string} domain - * @throws {Error} - * @return {Promise} - */ - createDomain: function(projectId, domain) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(domain === undefined) { - throw new Error('Missing required parameter: "domain"'); - } - - let path = '/projects/{projectId}/domains'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(typeof domain !== 'undefined') { - payload['domain'] = domain; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Domain - * - * - * @param {string} projectId - * @param {string} domainId - * @throws {Error} - * @return {Promise} - */ - getDomain: function(projectId, domainId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(domainId === undefined) { - throw new Error('Missing required parameter: "domainId"'); - } - - let path = '/projects/{projectId}/domains/{domainId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{domainId}', 'g'), domainId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Domain - * - * - * @param {string} projectId - * @param {string} domainId - * @throws {Error} - * @return {Promise} - */ - deleteDomain: function(projectId, domainId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(domainId === undefined) { - throw new Error('Missing required parameter: "domainId"'); - } - - let path = '/projects/{projectId}/domains/{domainId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{domainId}', 'g'), domainId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Domain Verification Status - * - * - * @param {string} projectId - * @param {string} domainId - * @throws {Error} - * @return {Promise} - */ - updateDomainVerification: function(projectId, domainId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(domainId === undefined) { - throw new Error('Missing required parameter: "domainId"'); - } - - let path = '/projects/{projectId}/domains/{domainId}/verification'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{domainId}', 'g'), domainId); - - let payload = {}; - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Keys - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listKeys: function(projectId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}/keys'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Key - * - * - * @param {string} projectId - * @param {string} name - * @param {string[]} scopes - * @throws {Error} - * @return {Promise} - */ - createKey: function(projectId, name, scopes) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(scopes === undefined) { - throw new Error('Missing required parameter: "scopes"'); - } - - let path = '/projects/{projectId}/keys'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof scopes !== 'undefined') { - payload['scopes'] = scopes; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Key - * - * - * @param {string} projectId - * @param {string} keyId - * @throws {Error} - * @return {Promise} - */ - getKey: function(projectId, keyId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(keyId === undefined) { - throw new Error('Missing required parameter: "keyId"'); - } - - let path = '/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{keyId}', 'g'), keyId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Key - * - * - * @param {string} projectId - * @param {string} keyId - * @param {string} name - * @param {string[]} scopes - * @throws {Error} - * @return {Promise} - */ - updateKey: function(projectId, keyId, name, scopes) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(keyId === undefined) { - throw new Error('Missing required parameter: "keyId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(scopes === undefined) { - throw new Error('Missing required parameter: "scopes"'); - } - - let path = '/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{keyId}', 'g'), keyId); - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof scopes !== 'undefined') { - payload['scopes'] = scopes; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Key - * - * - * @param {string} projectId - * @param {string} keyId - * @throws {Error} - * @return {Promise} - */ - deleteKey: function(projectId, keyId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(keyId === undefined) { - throw new Error('Missing required parameter: "keyId"'); - } - - let path = '/projects/{projectId}/keys/{keyId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{keyId}', 'g'), keyId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Project OAuth2 - * - * - * @param {string} projectId - * @param {string} provider - * @param {string} appId - * @param {string} secret - * @throws {Error} - * @return {Promise} - */ - updateOAuth2: function(projectId, provider, appId = '', secret = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(provider === undefined) { - throw new Error('Missing required parameter: "provider"'); - } - - let path = '/projects/{projectId}/oauth2'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(typeof provider !== 'undefined') { - payload['provider'] = provider; - } - - if(typeof appId !== 'undefined') { - payload['appId'] = appId; - } - - if(typeof secret !== 'undefined') { - payload['secret'] = secret; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Platforms - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listPlatforms: function(projectId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}/platforms'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Platform - * - * - * @param {string} projectId - * @param {string} type - * @param {string} name - * @param {string} key - * @param {string} store - * @param {string} hostname - * @throws {Error} - * @return {Promise} - */ - createPlatform: function(projectId, type, name, key = '', store = '', hostname = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(type === undefined) { - throw new Error('Missing required parameter: "type"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/projects/{projectId}/platforms'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(typeof type !== 'undefined') { - payload['type'] = type; - } - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof key !== 'undefined') { - payload['key'] = key; - } - - if(typeof store !== 'undefined') { - payload['store'] = store; - } - - if(typeof hostname !== 'undefined') { - payload['hostname'] = hostname; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Platform - * - * - * @param {string} projectId - * @param {string} platformId - * @throws {Error} - * @return {Promise} - */ - getPlatform: function(projectId, platformId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(platformId === undefined) { - throw new Error('Missing required parameter: "platformId"'); - } - - let path = '/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{platformId}', 'g'), platformId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Platform - * - * - * @param {string} projectId - * @param {string} platformId - * @param {string} name - * @param {string} key - * @param {string} store - * @param {string} hostname - * @throws {Error} - * @return {Promise} - */ - updatePlatform: function(projectId, platformId, name, key = '', store = '', hostname = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(platformId === undefined) { - throw new Error('Missing required parameter: "platformId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{platformId}', 'g'), platformId); - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof key !== 'undefined') { - payload['key'] = key; - } - - if(typeof store !== 'undefined') { - payload['store'] = store; - } - - if(typeof hostname !== 'undefined') { - payload['hostname'] = hostname; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Platform - * - * - * @param {string} projectId - * @param {string} platformId - * @throws {Error} - * @return {Promise} - */ - deletePlatform: function(projectId, platformId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(platformId === undefined) { - throw new Error('Missing required parameter: "platformId"'); - } - - let path = '/projects/{projectId}/platforms/{platformId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{platformId}', 'g'), platformId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Tasks - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listTasks: function(projectId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}/tasks'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Task - * - * - * @param {string} projectId - * @param {string} name - * @param {string} status - * @param {string} schedule - * @param {boolean} security - * @param {string} httpMethod - * @param {string} httpUrl - * @param {string[]} httpHeaders - * @param {string} httpUser - * @param {string} httpPass - * @throws {Error} - * @return {Promise} - */ - createTask: function(projectId, name, status, schedule, security, httpMethod, httpUrl, httpHeaders = [], httpUser = '', httpPass = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(status === undefined) { - throw new Error('Missing required parameter: "status"'); - } - - if(schedule === undefined) { - throw new Error('Missing required parameter: "schedule"'); - } - - if(security === undefined) { - throw new Error('Missing required parameter: "security"'); - } - - if(httpMethod === undefined) { - throw new Error('Missing required parameter: "httpMethod"'); - } - - if(httpUrl === undefined) { - throw new Error('Missing required parameter: "httpUrl"'); - } - - let path = '/projects/{projectId}/tasks'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof status !== 'undefined') { - payload['status'] = status; - } - - if(typeof schedule !== 'undefined') { - payload['schedule'] = schedule; - } - - if(typeof security !== 'undefined') { - payload['security'] = security; - } - - if(typeof httpMethod !== 'undefined') { - payload['httpMethod'] = httpMethod; - } - - if(typeof httpUrl !== 'undefined') { - payload['httpUrl'] = httpUrl; - } - - if(typeof httpHeaders !== 'undefined') { - payload['httpHeaders'] = httpHeaders; - } - - if(typeof httpUser !== 'undefined') { - payload['httpUser'] = httpUser; - } - - if(typeof httpPass !== 'undefined') { - payload['httpPass'] = httpPass; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Task - * - * - * @param {string} projectId - * @param {string} taskId - * @throws {Error} - * @return {Promise} - */ - getTask: function(projectId, taskId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(taskId === undefined) { - throw new Error('Missing required parameter: "taskId"'); - } - - let path = '/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{taskId}', 'g'), taskId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Task - * - * - * @param {string} projectId - * @param {string} taskId - * @param {string} name - * @param {string} status - * @param {string} schedule - * @param {boolean} security - * @param {string} httpMethod - * @param {string} httpUrl - * @param {string[]} httpHeaders - * @param {string} httpUser - * @param {string} httpPass - * @throws {Error} - * @return {Promise} - */ - updateTask: function(projectId, taskId, name, status, schedule, security, httpMethod, httpUrl, httpHeaders = [], httpUser = '', httpPass = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(taskId === undefined) { - throw new Error('Missing required parameter: "taskId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(status === undefined) { - throw new Error('Missing required parameter: "status"'); - } - - if(schedule === undefined) { - throw new Error('Missing required parameter: "schedule"'); - } - - if(security === undefined) { - throw new Error('Missing required parameter: "security"'); - } - - if(httpMethod === undefined) { - throw new Error('Missing required parameter: "httpMethod"'); - } - - if(httpUrl === undefined) { - throw new Error('Missing required parameter: "httpUrl"'); - } - - let path = '/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{taskId}', 'g'), taskId); - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof status !== 'undefined') { - payload['status'] = status; - } - - if(typeof schedule !== 'undefined') { - payload['schedule'] = schedule; - } - - if(typeof security !== 'undefined') { - payload['security'] = security; - } - - if(typeof httpMethod !== 'undefined') { - payload['httpMethod'] = httpMethod; - } - - if(typeof httpUrl !== 'undefined') { - payload['httpUrl'] = httpUrl; - } - - if(typeof httpHeaders !== 'undefined') { - payload['httpHeaders'] = httpHeaders; - } - - if(typeof httpUser !== 'undefined') { - payload['httpUser'] = httpUser; - } - - if(typeof httpPass !== 'undefined') { - payload['httpPass'] = httpPass; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Task - * - * - * @param {string} projectId - * @param {string} taskId - * @throws {Error} - * @return {Promise} - */ - deleteTask: function(projectId, taskId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(taskId === undefined) { - throw new Error('Missing required parameter: "taskId"'); - } - - let path = '/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{taskId}', 'g'), taskId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Project - * - * - * @param {string} projectId - * @param {string} range - * @throws {Error} - * @return {Promise} - */ - getUsage: function(projectId, range = '30d') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}/usage'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(range) { - payload['range'] = range; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * List Webhooks - * - * - * @param {string} projectId - * @throws {Error} - * @return {Promise} - */ - listWebhooks: function(projectId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - let path = '/projects/{projectId}/webhooks'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Webhook - * - * - * @param {string} projectId - * @param {string} name - * @param {string[]} events - * @param {string} url - * @param {boolean} security - * @param {string} httpUser - * @param {string} httpPass - * @throws {Error} - * @return {Promise} - */ - createWebhook: function(projectId, name, events, url, security, httpUser = '', httpPass = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(events === undefined) { - throw new Error('Missing required parameter: "events"'); - } - - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - if(security === undefined) { - throw new Error('Missing required parameter: "security"'); - } - - let path = '/projects/{projectId}/webhooks'.replace(new RegExp('{projectId}', 'g'), projectId); - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof events !== 'undefined') { - payload['events'] = events; - } - - if(typeof url !== 'undefined') { - payload['url'] = url; - } - - if(typeof security !== 'undefined') { - payload['security'] = security; - } - - if(typeof httpUser !== 'undefined') { - payload['httpUser'] = httpUser; - } - - if(typeof httpPass !== 'undefined') { - payload['httpPass'] = httpPass; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Webhook - * - * - * @param {string} projectId - * @param {string} webhookId - * @throws {Error} - * @return {Promise} - */ - getWebhook: function(projectId, webhookId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(webhookId === undefined) { - throw new Error('Missing required parameter: "webhookId"'); - } - - let path = '/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{webhookId}', 'g'), webhookId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Webhook - * - * - * @param {string} projectId - * @param {string} webhookId - * @param {string} name - * @param {string[]} events - * @param {string} url - * @param {boolean} security - * @param {string} httpUser - * @param {string} httpPass - * @throws {Error} - * @return {Promise} - */ - updateWebhook: function(projectId, webhookId, name, events, url, security, httpUser = '', httpPass = '') { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(webhookId === undefined) { - throw new Error('Missing required parameter: "webhookId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - if(events === undefined) { - throw new Error('Missing required parameter: "events"'); - } - - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - if(security === undefined) { - throw new Error('Missing required parameter: "security"'); - } - - let path = '/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{webhookId}', 'g'), webhookId); - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof events !== 'undefined') { - payload['events'] = events; - } - - if(typeof url !== 'undefined') { - payload['url'] = url; - } - - if(typeof security !== 'undefined') { - payload['security'] = security; - } - - if(typeof httpUser !== 'undefined') { - payload['httpUser'] = httpUser; - } - - if(typeof httpPass !== 'undefined') { - payload['httpPass'] = httpPass; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Webhook - * - * - * @param {string} projectId - * @param {string} webhookId - * @throws {Error} - * @return {Promise} - */ - deleteWebhook: function(projectId, webhookId) { - if(projectId === undefined) { - throw new Error('Missing required parameter: "projectId"'); - } - - if(webhookId === undefined) { - throw new Error('Missing required parameter: "webhookId"'); - } - - let path = '/projects/{projectId}/webhooks/{webhookId}'.replace(new RegExp('{projectId}', 'g'), projectId).replace(new RegExp('{webhookId}', 'g'), webhookId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let storage = { - - /** - * List Files - * - * Get a list of all the user files. You can use the query params to filter - * your results. On admin mode, this endpoint will return a list of all of the - * project's files. [Learn more about different API modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - listFiles: function(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/storage/files'; - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create File - * - * Create a new file. The user who creates the file will automatically be - * assigned to read and write access unless he has passed custom values for - * read and write arguments. - * - * @param {File} file - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - createFile: function(file, read, write) { - if(file === undefined) { - throw new Error('Missing required parameter: "file"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/storage/files'; - - let payload = {}; - - if(typeof file !== 'undefined') { - payload['file'] = file; - } - - if(typeof read !== 'undefined') { - payload['read'] = read; - } - - if(typeof write !== 'undefined') { - payload['write'] = write; - } - - return http - .post(path, { - 'content-type': 'multipart/form-data', - }, payload); - }, - - /** - * Get File - * - * Get a file by its unique ID. This endpoint response returns a JSON object - * with the file metadata. - * - * @param {string} fileId - * @throws {Error} - * @return {Promise} - */ - getFile: function(fileId) { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update File - * - * Update a file by its unique ID. Only users with write permissions have - * access to update this resource. - * - * @param {string} fileId - * @param {string[]} read - * @param {string[]} write - * @throws {Error} - * @return {Promise} - */ - updateFile: function(fileId, read, write) { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - if(read === undefined) { - throw new Error('Missing required parameter: "read"'); - } - - if(write === undefined) { - throw new Error('Missing required parameter: "write"'); - } - - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - if(typeof read !== 'undefined') { - payload['read'] = read; - } - - if(typeof write !== 'undefined') { - payload['write'] = write; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete File - * - * Delete a file by its unique ID. Only users with write permissions have - * access to delete this resource. - * - * @param {string} fileId - * @throws {Error} - * @return {Promise} - */ - deleteFile: function(fileId) { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get File for Download - * - * Get a file content by its unique ID. The endpoint response return with a - * 'Content-Disposition: attachment' header that tells the browser to start - * downloading the file to user downloads directory. - * - * @param {string} fileId - * @throws {Error} - * @return {string} - */ - getFileDownload: function(fileId) { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}/download'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get File Preview - * - * Get a file preview image. Currently, this method supports preview for image - * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, - * and spreadsheets, will return the file icon image. You can also pass query - * string arguments for cutting and resizing your preview image. - * - * @param {string} fileId - * @param {number} width - * @param {number} height - * @param {number} quality - * @param {string} background - * @param {string} output - * @throws {Error} - * @return {string} - */ - getFilePreview: function(fileId, width = 0, height = 0, quality = 100, background = '', output = '') { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - if(width) { - payload['width'] = width; - } - - if(height) { - payload['height'] = height; - } - - if(quality) { - payload['quality'] = quality; - } - - if(background) { - payload['background'] = background; - } - - if(output) { - payload['output'] = output; - } - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - }, - - /** - * Get File for View - * - * Get a file content by its unique ID. This endpoint is similar to the - * download method but returns with no 'Content-Disposition: attachment' - * header. - * - * @param {string} fileId - * @throws {Error} - * @return {string} - */ - getFileView: function(fileId) { - if(fileId === undefined) { - throw new Error('Missing required parameter: "fileId"'); - } - - let path = '/storage/files/{fileId}/view'.replace(new RegExp('{fileId}', 'g'), fileId); - - let payload = {}; - - payload['project'] = config.project; - - payload['key'] = config.key; - - - let query = []; - - for (let p in payload) { - if(Array.isArray(payload[p])) { - for (let index = 0; index < payload[p].length; index++) { - let param = payload[p][index]; - query.push(encodeURIComponent(p + '[]') + "=" + encodeURIComponent(param)); - } - } - else { - query.push(encodeURIComponent(p) + "=" + encodeURIComponent(payload[p])); - } - } - - query = query.join("&"); - - return config.endpoint + path + ((query) ? '?' + query : ''); - } - }; - - let teams = { - - /** - * List Teams - * - * Get a list of all the current user teams. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project's teams. [Learn more about different API - * modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - list: function(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/teams'; - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Team - * - * Create a new team. The user who creates the team will automatically be - * assigned as the owner of the team. The team owner can invite new members, - * who will be able add new owners and update or delete the team from your - * project. - * - * @param {string} name - * @param {string[]} roles - * @throws {Error} - * @return {Promise} - */ - create: function(name, roles = ["owner"]) { - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/teams'; - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof roles !== 'undefined') { - payload['roles'] = roles; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Team - * - * Get a team by its unique ID. All team members have read access for this - * resource. - * - * @param {string} teamId - * @throws {Error} - * @return {Promise} - */ - get: function(teamId) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Team - * - * Update a team by its unique ID. Only team owners have write access for this - * resource. - * - * @param {string} teamId - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - update: function(teamId, name) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - if(name === undefined) { - throw new Error('Missing required parameter: "name"'); - } - - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - return http - .put(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Team - * - * Delete a team by its unique ID. Only team owners have write access for this - * resource. - * - * @param {string} teamId - * @throws {Error} - * @return {Promise} - */ - delete: function(teamId) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get Team Memberships - * - * Get a team members by the team unique ID. All team members have read access - * for this list of resources. - * - * @param {string} teamId - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - getMemberships: function(teamId, search = '', limit = 25, offset = 0, orderType = 'ASC') { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create Team Membership - * - * Use this endpoint to invite a new member to join your team. An email with a - * link to join the team will be sent to the new member email address if the - * member doesn't exist in the project it will be created automatically. - * - * Use the 'URL' parameter to redirect the user from the invitation email back - * to your app. When the user is redirected, use the [Update Team Membership - * Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow - * the user to accept the invitation to the team. - * - * Please note that in order to avoid a [Redirect - * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URL's are the once from domains you have set when - * added your platforms in the console interface. - * - * @param {string} teamId - * @param {string} email - * @param {string[]} roles - * @param {string} url - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - createMembership: function(teamId, email, roles, url, name = '') { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(roles === undefined) { - throw new Error('Missing required parameter: "roles"'); - } - - if(url === undefined) { - throw new Error('Missing required parameter: "url"'); - } - - let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); - - let payload = {}; - - if(typeof email !== 'undefined') { - payload['email'] = email; - } - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - if(typeof roles !== 'undefined') { - payload['roles'] = roles; - } - - if(typeof url !== 'undefined') { - payload['url'] = url; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete Team Membership - * - * This endpoint allows a user to leave a team or for a team owner to delete - * the membership of any other team member. You can also use this endpoint to - * delete a user membership even if it is not accepted. - * - * @param {string} teamId - * @param {string} inviteId - * @throws {Error} - * @return {Promise} - */ - deleteMembership: function(teamId, inviteId) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - if(inviteId === undefined) { - throw new Error('Missing required parameter: "inviteId"'); - } - - let path = '/teams/{teamId}/memberships/{inviteId}'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update Team Membership Status - * - * Use this endpoint to allow a user to accept an invitation to join a team - * after being redirected back to your app from the invitation email recieved - * by the user. - * - * @param {string} teamId - * @param {string} inviteId - * @param {string} userId - * @param {string} secret - * @throws {Error} - * @return {Promise} - */ - updateMembershipStatus: function(teamId, inviteId, userId, secret) { - if(teamId === undefined) { - throw new Error('Missing required parameter: "teamId"'); - } - - if(inviteId === undefined) { - throw new Error('Missing required parameter: "inviteId"'); - } - - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(secret === undefined) { - throw new Error('Missing required parameter: "secret"'); - } - - let path = '/teams/{teamId}/memberships/{inviteId}/status'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); - - let payload = {}; - - if(typeof userId !== 'undefined') { - payload['userId'] = userId; - } - - if(typeof secret !== 'undefined') { - payload['secret'] = secret; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - let users = { - - /** - * List Users - * - * Get a list of all the project's users. You can use the query params to - * filter your results. - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} orderType - * @throws {Error} - * @return {Promise} - */ - list: function(search = '', limit = 25, offset = 0, orderType = 'ASC') { - let path = '/users'; - - let payload = {}; - - if(search) { - payload['search'] = search; - } - - if(limit) { - payload['limit'] = limit; - } - - if(offset) { - payload['offset'] = offset; - } - - if(orderType) { - payload['orderType'] = orderType; - } - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Create User - * - * Create a new user. - * - * @param {string} email - * @param {string} password - * @param {string} name - * @throws {Error} - * @return {Promise} - */ - create: function(email, password, name = '') { - if(email === undefined) { - throw new Error('Missing required parameter: "email"'); - } - - if(password === undefined) { - throw new Error('Missing required parameter: "password"'); - } - - let path = '/users'; - - let payload = {}; - - if(typeof email !== 'undefined') { - payload['email'] = email; - } - - if(typeof password !== 'undefined') { - payload['password'] = password; - } - - if(typeof name !== 'undefined') { - payload['name'] = name; - } - - return http - .post(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get User - * - * Get a user by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - get: function(userId) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - let path = '/users/{userId}'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete User - * - * Delete a user by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - deleteUser: function(userId) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - let path = '/users/{userId}'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get User Logs - * - * Get a user activity logs list by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - getLogs: function(userId) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - let path = '/users/{userId}/logs'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get User Preferences - * - * Get the user preferences by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - getPrefs: function(userId) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - let path = '/users/{userId}/prefs'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update User Preferences - * - * Update the user preferences by its unique ID. You can pass only the - * specific settings you wish to update. - * - * @param {string} userId - * @param {object} prefs - * @throws {Error} - * @return {Promise} - */ - updatePrefs: function(userId, prefs) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(prefs === undefined) { - throw new Error('Missing required parameter: "prefs"'); - } - - let path = '/users/{userId}/prefs'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - if(typeof prefs !== 'undefined') { - payload['prefs'] = prefs; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Get User Sessions - * - * Get the user sessions list by its unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - getSessions: function(userId) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - let path = '/users/{userId}/sessions'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - return http - .get(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete User Sessions - * - * Delete all user's sessions by using the user's unique ID. - * - * @param {string} userId - * @throws {Error} - * @return {Promise} - */ - deleteSessions: function(userId) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - let path = '/users/{userId}/sessions'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Delete User Session - * - * Delete a user sessions by its unique ID. - * - * @param {string} userId - * @param {string} sessionId - * @throws {Error} - * @return {Promise} - */ - deleteSession: function(userId, sessionId) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(sessionId === undefined) { - throw new Error('Missing required parameter: "sessionId"'); - } - - let path = '/users/{userId}/sessions/{sessionId}'.replace(new RegExp('{userId}', 'g'), userId).replace(new RegExp('{sessionId}', 'g'), sessionId); - - let payload = {}; - - return http - .delete(path, { - 'content-type': 'application/json', - }, payload); - }, - - /** - * Update User Status - * - * Update the user status by its unique ID. - * - * @param {string} userId - * @param {string} status - * @throws {Error} - * @return {Promise} - */ - updateStatus: function(userId, status) { - if(userId === undefined) { - throw new Error('Missing required parameter: "userId"'); - } - - if(status === undefined) { - throw new Error('Missing required parameter: "status"'); - } - - let path = '/users/{userId}/status'.replace(new RegExp('{userId}', 'g'), userId); - - let payload = {}; - - if(typeof status !== 'undefined') { - payload['status'] = status; - } - - return http - .patch(path, { - 'content-type': 'application/json', - }, payload); - } - }; - - return { - setEndpoint: setEndpoint, - setProject: setProject, - setKey: setKey, - setLocale: setLocale, - setMode: setMode, - account: account, - avatars: avatars, - database: database, - functions: functions, - health: health, - locale: locale, - projects: projects, - storage: storage, - teams: teams, - users: users - }; - }; - - if(typeof module !== "undefined") { - module.exports = window.Appwrite; + return output; + } } -})((typeof window !== "undefined") ? window : {}); \ No newline at end of file + exports.Appwrite = Appwrite; + + return exports; + +}({}, null, window)); diff --git a/public/scripts/services/console.js b/public/scripts/services/console.js index 7a08cc4e2..1904187c2 100644 --- a/public/scripts/services/console.js +++ b/public/scripts/services/console.js @@ -2,10 +2,10 @@ "use strict"; window.ls.container.set('console', function (window) { - var sdk = new window.Appwrite(); + var sdk = new window.Appwrite.Appwrite(); sdk - .setEndpoint(APP_ENV.API) + .setEndpoint(APP_ENV.ENDPOINT + APP_ENV.API) .setProject('console') .setLocale(APP_ENV.LOCALE) ; diff --git a/public/scripts/services/sdk.js b/public/scripts/services/sdk.js index fa3a4fb6d..117c958f8 100644 --- a/public/scripts/services/sdk.js +++ b/public/scripts/services/sdk.js @@ -2,10 +2,10 @@ "use strict"; window.ls.container.set('sdk', function (window, router) { - var sdk = new window.Appwrite(); + var sdk = new window.Appwrite.Appwrite(); sdk - .setEndpoint(APP_ENV.API) + .setEndpoint(APP_ENV.ENDPOINT + APP_ENV.API) .setProject(router.params.project || '') .setLocale(APP_ENV.LOCALE) .setMode('admin')