diff --git a/public/dist/scripts/app-all.js b/public/dist/scripts/app-all.js index 8929b4519..fbd1344e6 100644 --- a/public/dist/scripts/app-all.js +++ b/public/dist/scripts/app-all.js @@ -66,9 +66,9 @@ updatePassword(password,oldPassword){return __awaiter(this,void 0,void 0,functio 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.client.config.endpoint+path);return yield this.client.call('patch',uri,{'content-type':'application/json',},payload);});} -updatePhone(number,password){return __awaiter(this,void 0,void 0,function*(){if(typeof number==='undefined'){throw new AppwriteException('Missing required parameter: "number"');} +updatePhone(phone,password){return __awaiter(this,void 0,void 0,function*(){if(typeof phone==='undefined'){throw new AppwriteException('Missing required parameter: "phone"');} if(typeof password==='undefined'){throw new AppwriteException('Missing required parameter: "password"');} -let path='/account/phone';let payload={};if(typeof number!=='undefined'){payload['number']=number;} +let path='/account/phone';let payload={};if(typeof phone!=='undefined'){payload['phone']=phone;} if(typeof password!=='undefined'){payload['password']=password;} const uri=new URL(this.client.config.endpoint+path);return yield this.client.call('patch',uri,{'content-type':'application/json',},payload);});} getPrefs(){return __awaiter(this,void 0,void 0,function*(){let path='/account/prefs';let payload={};const uri=new URL(this.client.config.endpoint+path);return yield this.client.call('get',uri,{'content-type':'application/json',},payload);});} @@ -115,10 +115,10 @@ if(typeof scopes!=='undefined'){payload['scopes']=scopes;} const uri=new URL(this.client.config.endpoint+path);payload['project']=this.client.config.project;for(const[key,value]of Object.entries(Service.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;}} -createPhoneSession(userId,number){return __awaiter(this,void 0,void 0,function*(){if(typeof userId==='undefined'){throw new AppwriteException('Missing required parameter: "userId"');} -if(typeof number==='undefined'){throw new AppwriteException('Missing required parameter: "number"');} +createPhoneSession(userId,phone){return __awaiter(this,void 0,void 0,function*(){if(typeof userId==='undefined'){throw new AppwriteException('Missing required parameter: "userId"');} +if(typeof phone==='undefined'){throw new AppwriteException('Missing required parameter: "phone"');} let path='/account/sessions/phone';let payload={};if(typeof userId!=='undefined'){payload['userId']=userId;} -if(typeof number!=='undefined'){payload['number']=number;} +if(typeof phone!=='undefined'){payload['phone']=phone;} const uri=new URL(this.client.config.endpoint+path);return yield this.client.call('post',uri,{'content-type':'application/json',},payload);});} updatePhoneSession(userId,secret){return __awaiter(this,void 0,void 0,function*(){if(typeof userId==='undefined'){throw new AppwriteException('Missing required parameter: "userId"');} if(typeof secret==='undefined'){throw new AppwriteException('Missing required parameter: "secret"');} @@ -860,11 +860,10 @@ if(typeof cursor!=='undefined'){payload['cursor']=cursor;} if(typeof cursorDirection!=='undefined'){payload['cursorDirection']=cursorDirection;} if(typeof orderType!=='undefined'){payload['orderType']=orderType;} const uri=new URL(this.client.config.endpoint+path);return yield this.client.call('get',uri,{'content-type':'application/json',},payload);});} -create(userId,email,password,name){return __awaiter(this,void 0,void 0,function*(){if(typeof userId==='undefined'){throw new AppwriteException('Missing required parameter: "userId"');} -if(typeof email==='undefined'){throw new AppwriteException('Missing required parameter: "email"');} -if(typeof password==='undefined'){throw new AppwriteException('Missing required parameter: "password"');} +create(userId,email,phone,password,name){return __awaiter(this,void 0,void 0,function*(){if(typeof userId==='undefined'){throw new AppwriteException('Missing required parameter: "userId"');} let path='/users';let payload={};if(typeof userId!=='undefined'){payload['userId']=userId;} if(typeof email!=='undefined'){payload['email']=email;} +if(typeof phone!=='undefined'){payload['phone']=phone;} if(typeof password!=='undefined'){payload['password']=password;} if(typeof name!=='undefined'){payload['name']=name;} const uri=new URL(this.client.config.endpoint+path);return yield this.client.call('post',uri,{'content-type':'application/json',},payload);});} @@ -995,12 +994,91 @@ updatePhoneVerification(userId,phoneVerification){return __awaiter(this,void 0,v if(typeof phoneVerification==='undefined'){throw new AppwriteException('Missing required parameter: "phoneVerification"');} let path='/users/{userId}/verification/phone'.replace('{userId}',userId);let payload={};if(typeof phoneVerification!=='undefined'){payload['phoneVerification']=phoneVerification;} const uri=new URL(this.client.config.endpoint+path);return yield this.client.call('patch',uri,{'content-type':'application/json',},payload);});}} -exports.Account=Account;exports.AppwriteException=AppwriteException;exports.Avatars=Avatars;exports.Client=Client;exports.Databases=Databases;exports.Functions=Functions;exports.Health=Health;exports.Locale=Locale;exports.Projects=Projects;exports.Query=Query;exports.Storage=Storage;exports.Teams=Teams;exports.Users=Users;Object.defineProperty(exports,'__esModule',{value:true});})(this.Appwrite=this.Appwrite||{},null,window);(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory():typeof define==='function'&&define.amd?define(factory):(global=typeof globalThis!=='undefined'?globalThis:global||self,global.Chart=factory());})(this,(function(){'use strict';function fontString(pixelSize,fontStyle,fontFamily){return fontStyle+' '+pixelSize+'px '+fontFamily;} +exports.Account=Account;exports.AppwriteException=AppwriteException;exports.Avatars=Avatars;exports.Client=Client;exports.Databases=Databases;exports.Functions=Functions;exports.Health=Health;exports.Locale=Locale;exports.Projects=Projects;exports.Query=Query;exports.Storage=Storage;exports.Teams=Teams;exports.Users=Users;Object.defineProperty(exports,'__esModule',{value:true});})(this.Appwrite=this.Appwrite||{},null,window);(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory():typeof define==='function'&&define.amd?define(factory):(global=typeof globalThis!=='undefined'?globalThis:global||self,global.Chart=factory());})(this,(function(){'use strict';function noop(){} +const uid=(function(){let id=0;return function(){return id++;};}());function isNullOrUndef(value){return value===null||typeof value==='undefined';} +function isArray(value){if(Array.isArray&&Array.isArray(value)){return true;} +const type=Object.prototype.toString.call(value);if(type.slice(0,7)==='[object'&&type.slice(-6)==='Array]'){return true;} +return false;} +function isObject(value){return value!==null&&Object.prototype.toString.call(value)==='[object Object]';} +const isNumberFinite=(value)=>(typeof value==='number'||value instanceof Number)&&isFinite(+value);function finiteOrDefault(value,defaultValue){return isNumberFinite(value)?value:defaultValue;} +function valueOrDefault(value,defaultValue){return typeof value==='undefined'?defaultValue:value;} +const toPercentage=(value,dimension)=>typeof value==='string'&&value.endsWith('%')?parseFloat(value)/100:value/dimension;const toDimension=(value,dimension)=>typeof value==='string'&&value.endsWith('%')?parseFloat(value)/100*dimension:+value;function callback(fn,args,thisArg){if(fn&&typeof fn.call==='function'){return fn.apply(thisArg,args);}} +function each(loopable,fn,thisArg,reverse){let i,len,keys;if(isArray(loopable)){len=loopable.length;if(reverse){for(i=len-1;i>=0;i--){fn.call(thisArg,loopable[i],i);}}else{for(i=0;iv,x:o=>o.x,y:o=>o.y};function resolveObjectKey(obj,key){const resolver=keyResolvers[key]||(keyResolvers[key]=_getKeyResolver(key));return resolver(obj);} +function _getKeyResolver(key){const keys=_splitKey(key);return obj=>{for(const k of keys){if(k===''){break;} +obj=obj&&obj[k];} +return obj;};} +function _splitKey(key){const parts=key.split('.');const keys=[];let tmp='';for(const part of parts){tmp+=part;if(tmp.endsWith('\\')){tmp=tmp.slice(0,-1)+'.';}else{keys.push(tmp);tmp='';}} +return keys;} +function _capitalize(str){return str.charAt(0).toUpperCase()+str.slice(1);} +const defined=(value)=>typeof value!=='undefined';const isFunction=(value)=>typeof value==='function';const setsEqual=(a,b)=>{if(a.size!==b.size){return false;} +for(const item of a){if(!b.has(item)){return false;}} +return true;};function _isClickEvent(e){return e.type==='mouseup'||e.type==='click'||e.type==='contextmenu';} +const PI=Math.PI;const TAU=2*PI;const PITAU=TAU+PI;const INFINITY=Number.POSITIVE_INFINITY;const RAD_PER_DEG=PI/180;const HALF_PI=PI/2;const QUARTER_PI=PI/4;const TWO_THIRDS_PI=PI*2/3;const log10=Math.log10;const sign=Math.sign;function niceNum(range){const roundedRange=Math.round(range);range=almostEquals(range,roundedRange,range/1000)?roundedRange:range;const niceRange=Math.pow(10,Math.floor(log10(range)));const fraction=range/niceRange;const niceFraction=fraction<=1?1:fraction<=2?2:fraction<=5?5:10;return niceFraction*niceRange;} +function _factorize(value){const result=[];const sqrt=Math.sqrt(value);let i;for(i=1;ia-b).pop();return result;} +function isNumber(n){return!isNaN(parseFloat(n))&&isFinite(n);} +function almostEquals(x,y,epsilon){return Math.abs(x-y)=x);} +function _setMinAndMaxByKey(array,target,property){let i,ilen,value;for(i=0,ilen=array.length;iangleToEnd&&startToAngle=Math.min(start,end)-epsilon&&value<=Math.max(start,end)+epsilon;} +function _lookup(table,value,cmp){cmp=cmp||((index)=>table[index]1){mid=(lo+hi)>>1;if(cmp(mid)){lo=mid;}else{hi=mid;}} +return{lo,hi};} +const _lookupByKey=(table,key,value,last)=>_lookup(table,value,last?index=>table[index][key]<=value:index=>table[index][key]_lookup(table,value,index=>table[index][key]>=value);function _filterBetween(values,min,max){let start=0;let end=values.length;while(startstart&&values[end-1]>max){end--;} +return start>0||end{const method='_onData'+_capitalize(key);const base=array[key];Object.defineProperty(array,key,{configurable:true,enumerable:false,value(...args){const res=base.apply(this,args);array._chartjs.listeners.forEach((object)=>{if(typeof object[method]==='function'){object[method](...args);}});return res;}});});} +function unlistenArrayEvents(array,listener){const stub=array._chartjs;if(!stub){return;} +const listeners=stub.listeners;const index=listeners.indexOf(listener);if(index!==-1){listeners.splice(index,1);} +if(listeners.length>0){return;} +arrayEvents.forEach((key)=>{delete array[key];});delete array._chartjs;} +function _arrayUnique(items){const set=new Set();let i,ilen;for(i=0,ilen=items.length;iArray.prototype.slice.call(args));let ticking=false;let args=[];return function(...rest){args=updateArgs(rest);if(!ticking){ticking=true;requestAnimFrame.call(window,()=>{ticking=false;fn.apply(thisArg,args);});}};} function debounce(fn,delay){let timeout;return function(...args){if(delay){clearTimeout(timeout);timeout=setTimeout(fn,delay,args);}else{fn.apply(this,args);} return delay;};} -const _toLeftRightCenter=(align)=>align==='start'?'left':align==='end'?'right':'center';const _alignStartEnd=(align,start,end)=>align==='start'?start:align==='end'?end:(start+end)/2;const _textX=(align,left,right,rtl)=>{const check=rtl?'left':'right';return align===check?right:align==='center'?(left+right)/2:left;};class Animator{constructor(){this._request=null;this._charts=new Map();this._running=false;this._lastDate=undefined;} +const _toLeftRightCenter=(align)=>align==='start'?'left':align==='end'?'right':'center';const _alignStartEnd=(align,start,end)=>align==='start'?start:align==='end'?end:(start+end)/2;const _textX=(align,left,right,rtl)=>{const check=rtl?'left':'right';return align===check?right:align==='center'?(left+right)/2:left;};function _getStartAndCountOfVisiblePoints(meta,points,animationsDisabled){const pointCount=points.length;let start=0;let count=pointCount;if(meta._sorted){const{iScale,_parsed}=meta;const axis=iScale.axis;const{min,max,minDefined,maxDefined}=iScale.getUserBounds();if(minDefined){start=_limitValue(Math.min(_lookupByKey(_parsed,iScale.axis,min).lo,animationsDisabled?pointCount:_lookupByKey(points,axis,iScale.getPixelForValue(min)).lo),0,pointCount-1);} +if(maxDefined){count=_limitValue(Math.max(_lookupByKey(_parsed,iScale.axis,max,true).hi+1,animationsDisabled?0:_lookupByKey(points,axis,iScale.getPixelForValue(max),true).hi+1),start,pointCount)-start;}else{count=pointCount-start;}} +return{start,count};} +function _scaleRangesChanged(meta){const{xScale,yScale,_scaleRanges}=meta;const newRanges={xmin:xScale.min,xmax:xScale.max,ymin:yScale.min,ymax:yScale.max};if(!_scaleRanges){meta._scaleRanges=newRanges;return true;} +const changed=_scaleRanges.xmin!==xScale.min||_scaleRanges.xmax!==xScale.max||_scaleRanges.ymin!==yScale.min||_scaleRanges.ymax!==yScale.max;Object.assign(_scaleRanges,newRanges);return changed;} +class Animator{constructor(){this._request=null;this._charts=new Map();this._running=false;this._lastDate=undefined;} _notify(chart,anims,date,type){const callbacks=anims.listeners[type];const numSteps=anims.duration;callbacks.forEach(fn=>fn({chart,initial:anims.initial,numSteps,currentStep:Math.min(date-anims.start,numSteps)}));} _refresh(){if(this._request){return;} this._running=true;this._request=requestAnimFrame.call(window,()=>{this._update();this._request=null;if(this._running){this._refresh();}});} @@ -1066,8 +1144,8 @@ r=+m[1];g=+m[3];b=+m[5];r=255&(m[2]?p2b(r):lim(r,0,255));g=255&(m[4]?p2b(g):lim( function rgbString(v){return v&&(v.a<255?`rgba(${v.r}, ${v.g}, ${v.b}, ${b2n(v.a)})`:`rgb(${v.r}, ${v.g}, ${v.b})`);} const to=v=>v<=0.0031308?v*12.92:Math.pow(v,1.0/2.4)*1.055-0.055;const from=v=>v<=0.04045?v/12.92:Math.pow((v+0.055)/1.055,2.4);function interpolate$1(rgb1,rgb2,t){const r=from(b2n(rgb1.r));const g=from(b2n(rgb1.g));const b=from(b2n(rgb1.b));return{r:n2b(to(r+t*(from(b2n(rgb2.r))-r))),g:n2b(to(g+t*(from(b2n(rgb2.g))-g))),b:n2b(to(b+t*(from(b2n(rgb2.b))-b))),a:rgb1.a+t*(rgb2.a-rgb1.a)};} function modHSL(v,i,ratio){if(v){let tmp=rgb2hsl(v);tmp[i]=Math.max(0,Math.min(tmp[i]+tmp[i]*ratio,i===0?360:1));tmp=hsl2rgb(tmp);v.r=tmp[0];v.g=tmp[1];v.b=tmp[2];}} -function clone$1(v,proto){return v?Object.assign(proto||{},v):v;} -function fromObject(input){var v={r:0,g:0,b:0,a:255};if(Array.isArray(input)){if(input.length>=3){v={r:input[0],g:input[1],b:input[2],a:255};if(input.length>3){v.a=n2b(input[3]);}}}else{v=clone$1(input,{r:0,g:0,b:0,a:1});v.a=n2b(v.a);} +function clone(v,proto){return v?Object.assign(proto||{},v):v;} +function fromObject(input){var v={r:0,g:0,b:0,a:255};if(Array.isArray(input)){if(input.length>=3){v={r:input[0],g:input[1],b:input[2],a:255};if(input.length>3){v.a=n2b(input[3]);}}}else{v=clone(input,{r:0,g:0,b:0,a:1});v.a=n2b(v.a);} return v;} function functionParse(str){if(str.charAt(0)==='r'){return rgbParse(str);} return hueParse(str);} @@ -1075,7 +1153,7 @@ class Color{constructor(input){if(input instanceof Color){return input;} const type=typeof input;let v;if(type==='object'){v=fromObject(input);}else if(type==='string'){v=hexParse(input)||nameParse(input)||functionParse(input);} this._rgb=v;this._valid=!!v;} get valid(){return this._valid;} -get rgb(){var v=clone$1(this._rgb);if(v){v.a=b2n(v.a);} +get rgb(){var v=clone(this._rgb);if(v){v.a=b2n(v.a);} return v;} set rgb(obj){this._rgb=fromObject(obj);} rgbString(){return this._valid?rgbString(this._rgb):undefined;} @@ -1101,42 +1179,6 @@ function isPatternOrGradient(value){if(value&&typeof value==='object'){const typ return false;} function color(value){return isPatternOrGradient(value)?value:index_esm(value);} function getHoverColor(value){return isPatternOrGradient(value)?value:index_esm(value).saturate(0.5).darken(0.1).hexString();} -function noop(){} -const uid=(function(){let id=0;return function(){return id++;};}());function isNullOrUndef(value){return value===null||typeof value==='undefined';} -function isArray(value){if(Array.isArray&&Array.isArray(value)){return true;} -const type=Object.prototype.toString.call(value);if(type.slice(0,7)==='[object'&&type.slice(-6)==='Array]'){return true;} -return false;} -function isObject(value){return value!==null&&Object.prototype.toString.call(value)==='[object Object]';} -const isNumberFinite=(value)=>(typeof value==='number'||value instanceof Number)&&isFinite(+value);function finiteOrDefault(value,defaultValue){return isNumberFinite(value)?value:defaultValue;} -function valueOrDefault(value,defaultValue){return typeof value==='undefined'?defaultValue:value;} -const toPercentage=(value,dimension)=>typeof value==='string'&&value.endsWith('%')?parseFloat(value)/100:value/dimension;const toDimension=(value,dimension)=>typeof value==='string'&&value.endsWith('%')?parseFloat(value)/100*dimension:+value;function callback(fn,args,thisArg){if(fn&&typeof fn.call==='function'){return fn.apply(thisArg,args);}} -function each(loopable,fn,thisArg,reverse){let i,len,keys;if(isArray(loopable)){len=loopable.length;if(reverse){for(i=len-1;i>=0;i--){fn.call(thisArg,loopable[i],i);}}else{for(i=0;ipos){obj=obj[key.slice(pos,idx)];pos=idx+1;idx=indexOfDotOrLength(key,pos);} -return obj;} -function _capitalize(str){return str.charAt(0).toUpperCase()+str.slice(1);} -const defined=(value)=>typeof value!=='undefined';const isFunction=(value)=>typeof value==='function';const setsEqual=(a,b)=>{if(a.size!==b.size){return false;} -for(const item of a){if(!b.has(item)){return false;}} -return true;};function _isClickEvent(e){return e.type==='mouseup'||e.type==='click'||e.type==='contextmenu';} const overrides=Object.create(null);const descriptors=Object.create(null);function getScope$1(node,key){if(!key){return node;} const keys=key.split('.');for(let i=0,n=keys.length;i!name.startsWith('on'),_indexable:(name)=>name!=='events',hover:{_fallback:'interaction'},interaction:{_scriptable:false,_indexable:false,}});function _lookup(table,value,cmp){cmp=cmp||((index)=>table[index]1){mid=(lo+hi)>>1;if(cmp(mid)){lo=mid;}else{hi=mid;}} -return{lo,hi};} -const _lookupByKey=(table,key,value)=>_lookup(table,value,index=>table[index][key]_lookup(table,value,index=>table[index][key]>=value);function _filterBetween(values,min,max){let start=0;let end=values.length;while(startstart&&values[end-1]>max){end--;} -return start>0||end{const method='_onData'+_capitalize(key);const base=array[key];Object.defineProperty(array,key,{configurable:true,enumerable:false,value(...args){const res=base.apply(this,args);array._chartjs.listeners.forEach((object)=>{if(typeof object[method]==='function'){object[method](...args);}});return res;}});});} -function unlistenArrayEvents(array,listener){const stub=array._chartjs;if(!stub){return;} -const listeners=stub.listeners;const index=listeners.indexOf(listener);if(index!==-1){listeners.splice(index,1);} -if(listeners.length>0){return;} -arrayEvents.forEach((key)=>{delete array[key];});delete array._chartjs;} -function _arrayUnique(items){const set=new Set();let i,ilen;for(i=0,ilen=items.length;ia-b).pop();return result;} -function isNumber(n){return!isNaN(parseFloat(n))&&isFinite(n);} -function almostEquals(x,y,epsilon){return Math.abs(x-y)=x);} -function _setMinAndMaxByKey(array,target,property){let i,ilen,value;for(i=0,ilen=array.length;iangleToEnd&&startToAngle=Math.min(start,end)-epsilon&&value<=Math.max(start,end)+epsilon;} -function _isDomSupported(){return typeof window!=='undefined'&&typeof document!=='undefined';} +var defaults=new Defaults({_scriptable:(name)=>!name.startsWith('on'),_indexable:(name)=>name!=='events',hover:{_fallback:'interaction'},interaction:{_scriptable:false,_indexable:false,}});function _isDomSupported(){return typeof window!=='undefined'&&typeof document!=='undefined';} function _getParentNode(domNode){let parent=domNode.parentNode;if(parent&&parent.toString()==='[object ShadowRoot]'){parent=parent.host;} return parent;} function parseMaxStyle(styleValue,node,parentProperty){let valueInPixels;if(typeof styleValue==='string'){valueInPixels=parseInt(styleValue,10);if(styleValue.indexOf('%')!==-1){valueInPixels=valueInPixels/100*node.parentNode[parentProperty];}}else{valueInPixels=styleValue;} @@ -1378,7 +1384,7 @@ if(start0;} _computeGridLineItems(chartArea){const axis=this.axis;const chart=this.chart;const options=this.options;const{grid,position}=options;const offset=grid.offset;const isHorizontal=this.isHorizontal();const ticks=this.ticks;const ticksLength=ticks.length+(offset?1:0);const tl=getTickMarkLength(grid);const items=[];const borderOpts=grid.setContext(this.getContext());const axisWidth=borderOpts.drawBorder?borderOpts.borderWidth:0;const axisHalfWidth=axisWidth/2;const alignBorderValue=function(pixel){return _alignPixel(chart,pixel,axisWidth);};let borderValue,i,lineValue,alignedLineValue;let tx1,ty1,tx2,ty2,x1,y1,x2,y2;if(position==='top'){borderValue=alignBorderValue(this.bottom);ty1=this.bottom-tl;ty2=borderValue-axisHalfWidth;y1=alignBorderValue(chartArea.top)+axisHalfWidth;y2=chartArea.bottom;}else if(position==='bottom'){borderValue=alignBorderValue(this.top);y1=chartArea.top;y2=alignBorderValue(chartArea.bottom)-axisHalfWidth;ty1=borderValue+axisHalfWidth;ty2=this.top+tl;}else if(position==='left'){borderValue=alignBorderValue(this.right);tx1=this.right-tl;tx2=borderValue-axisHalfWidth;x1=alignBorderValue(chartArea.left)+axisHalfWidth;x2=chartArea.right;}else if(position==='right'){borderValue=alignBorderValue(this.left);x1=chartArea.left;x2=alignBorderValue(chartArea.right)-axisHalfWidth;tx1=borderValue+axisHalfWidth;tx2=this.left+tl;}else if(axis==='x'){if(position==='center'){borderValue=alignBorderValue((chartArea.top+chartArea.bottom)/2+0.5);}else if(isObject(position)){const positionAxisID=Object.keys(position)[0];const value=position[positionAxisID];borderValue=alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value));} y1=chartArea.top;y2=chartArea.bottom;ty1=borderValue+axisHalfWidth;ty2=ty1+tl;}else if(axis==='y'){if(position==='center'){borderValue=alignBorderValue((chartArea.left+chartArea.right)/2);}else if(isObject(position)){const positionAxisID=Object.keys(position)[0];const value=position[positionAxisID];borderValue=alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value));} tx1=borderValue-axisHalfWidth;tx2=tx1-tl;x1=chartArea.left;x2=chartArea.right;} -const limit=valueOrDefault(options.ticks.maxTicksLimit,ticksLength);const step=Math.max(1,Math.ceil(ticksLength/limit));for(i=0;iisObject(value)&&Object.getOwnPropertyNames(value).reduce((acc,key)=>acc||isFunction(value[key]),false);function needContext(proxy,names){const{isScriptable,isIndexable}=_descriptors(proxy);for(const prop of names){const scriptable=isScriptable(prop);const indexable=isIndexable(prop);const value=(indexable||scriptable)&&proxy[prop];if((scriptable&&(isFunction(value)||hasFunction(value)))||(indexable&&isArray(value))){return true;}} return false;} -var version="3.8.2";const KNOWN_POSITIONS=['top','bottom','left','right','chartArea'];function positionIsHorizontal(position,axis){return position==='top'||position==='bottom'||(KNOWN_POSITIONS.indexOf(position)===-1&&axis==='x');} +var version="3.9.1";const KNOWN_POSITIONS=['top','bottom','left','right','chartArea'];function positionIsHorizontal(position,axis){return position==='top'||position==='bottom'||(KNOWN_POSITIONS.indexOf(position)===-1&&axis==='x');} function compare2Level(l1,l2){return function(a,b){return a[l1]===b[l1]?a[l2]-b[l2]:a[l1]-b[l1];};} function onAnimationsComplete(context){const chart=context.chart;const animationOptions=chart.options.animation;chart.notifyPlugins('afterRender');callback(animationOptions&&animationOptions.onComplete,[context],chart);} function onAnimationProgress(context){const chart=context.chart;const animationOptions=chart.options.animation;callback(animationOptions&&animationOptions.onProgress,[context],chart);} @@ -2030,6 +2036,7 @@ if(!inChartArea){return lastActive;} const hoverOptions=this.options.hover;return this.getElementsAtEventForMode(e,hoverOptions.mode,hoverOptions,useFinalPosition);}} const invalidatePlugins=()=>each(Chart.instances,(chart)=>chart._plugins.invalidate());const enumerable=true;Object.defineProperties(Chart,{defaults:{enumerable,value:defaults},instances:{enumerable,value:instances},overrides:{enumerable,value:overrides},registry:{enumerable,value:registry},version:{enumerable,value:version},getChart:{enumerable,value:getChart},register:{enumerable,value:(...items)=>{registry.add(...items);invalidatePlugins();}},unregister:{enumerable,value:(...items)=>{registry.remove(...items);invalidatePlugins();}}});function abstract(){throw new Error('This method is not implemented: Check that a complete date adapter is provided.');} class DateAdapter{constructor(options){this.options=options||{};} +init(chartOptions){} formats(){return abstract();} parse(value,format){return abstract();} format(timestamp,format){return abstract();} @@ -2063,6 +2070,7 @@ function borderProps(properties){let reverse,start,end,top,bottom;if(properties. if(reverse){top='end';bottom='start';}else{top='start';bottom='end';} return{start,end,reverse,top,bottom};} function setBorderSkipped(properties,options,stack,index){let edge=options.borderSkipped;const res={};if(!edge){properties.borderSkipped=res;return;} +if(edge===true){properties.borderSkipped={top:true,right:true,bottom:true,left:true};return;} const{start,end,reverse,top,bottom}=borderProps(properties);if(edge==='middle'&&stack){properties.enableBorderRadius=true;if((stack._top||0)===index){edge=top;}else if((stack._bottom||0)===index){edge=bottom;}else{res[parseEdge(bottom,start,end,reverse)]=true;edge=top;}} res[parseEdge(edge,start,end,reverse)]=true;properties.borderSkipped=res;} function parseEdge(edge,a,b,reverse){if(reverse){edge=swap(edge,a,b);edge=startEnd(edge,b,a);}else{edge=startEnd(edge,a,b);} @@ -2151,7 +2159,7 @@ _getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data DoughnutController.id='doughnut';DoughnutController.defaults={datasetElementType:false,dataElementType:'arc',animation:{animateRotate:true,animateScale:false},animations:{numbers:{type:'number',properties:['circumference','endAngle','innerRadius','outerRadius','startAngle','x','y','offset','borderWidth','spacing']},},cutout:'50%',rotation:0,circumference:360,radius:'100%',spacing:0,indexAxis:'r',};DoughnutController.descriptors={_scriptable:(name)=>name!=='spacing',_indexable:(name)=>name!=='spacing',};DoughnutController.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(chart){const data=chart.data;if(data.labels.length&&data.datasets.length){const{labels:{pointStyle}}=chart.legend.options;return data.labels.map((label,i)=>{const meta=chart.getDatasetMeta(0);const style=meta.controller.getStyle(i);return{text:label,fillStyle:style.backgroundColor,strokeStyle:style.borderColor,lineWidth:style.borderWidth,pointStyle:pointStyle,hidden:!chart.getDataVisibility(i),index:i};});} return[];}},onClick(e,legendItem,legend){legend.chart.toggleDataVisibility(legendItem.index);legend.chart.update();}},tooltip:{callbacks:{title(){return'';},label(tooltipItem){let dataLabel=tooltipItem.label;const value=': '+tooltipItem.formattedValue;if(isArray(dataLabel)){dataLabel=dataLabel.slice();dataLabel[0]+=value;}else{dataLabel+=value;} return dataLabel;}}}}};class LineController extends DatasetController{initialize(){this.enableOptionSharing=true;this.supportsDecimation=true;super.initialize();} -update(mode){const meta=this._cachedMeta;const{dataset:line,data:points=[],_dataset}=meta;const animationsDisabled=this.chart._animationsDisabled;let{start,count}=getStartAndCountOfVisiblePoints(meta,points,animationsDisabled);this._drawStart=start;this._drawCount=count;if(scaleRangesChanged(meta)){start=0;count=points.length;} +update(mode){const meta=this._cachedMeta;const{dataset:line,data:points=[],_dataset}=meta;const animationsDisabled=this.chart._animationsDisabled;let{start,count}=_getStartAndCountOfVisiblePoints(meta,points,animationsDisabled);this._drawStart=start;this._drawCount=count;if(_scaleRangesChanged(meta)){start=0;count=points.length;} line._chart=this.chart;line._datasetIndex=this.index;line._decimated=!!_dataset._decimated;line.points=points;const options=this.resolveDatasetElementOptions(mode);if(!this.options.showLine){options.borderWidth=0;} options.segment=this.options.segment;this.updateElement(line,undefined,{animated:!animationsDisabled,options},mode);this.updateElements(points,start,count,mode);} updateElements(points,start,count,mode){const reset=mode==='reset';const{iScale,vScale,_stacked,_dataset}=this._cachedMeta;const{sharedOptions,includeOptions}=this._getSharedOptions(start,mode);const iAxis=iScale.axis;const vAxis=vScale.axis;const{spanGaps,segment}=this.options;const maxGapLength=isNumber(spanGaps)?spanGaps:Number.POSITIVE_INFINITY;const directUpdate=this.chart._animationsDisabled||reset||mode==='none';let prevParsed=start>0&&this.getParsed(start-1);for(let i=start;i0&&(Math.abs(parsed[iAxis]-prevParsed[iAxis]))>maxGapLength;if(segment){properties.parsed=parsed;properties.raw=_dataset.data[i];} @@ -2161,12 +2169,7 @@ prevParsed=parsed;}} getMaxOverflow(){const meta=this._cachedMeta;const dataset=meta.dataset;const border=dataset.options&&dataset.options.borderWidth||0;const data=meta.data||[];if(!data.length){return border;} const firstPoint=data[0].size(this.resolveDataElementOptions(0));const lastPoint=data[data.length-1].size(this.resolveDataElementOptions(data.length-1));return Math.max(border,firstPoint,lastPoint)/2;} draw(){const meta=this._cachedMeta;meta.dataset.updateControlPoints(this.chart.chartArea,meta.iScale.axis);super.draw();}} -LineController.id='line';LineController.defaults={datasetElementType:'line',dataElementType:'point',showLine:true,spanGaps:false,};LineController.overrides={scales:{_index_:{type:'category',},_value_:{type:'linear',},}};function getStartAndCountOfVisiblePoints(meta,points,animationsDisabled){const pointCount=points.length;let start=0;let count=pointCount;if(meta._sorted){const{iScale,_parsed}=meta;const axis=iScale.axis;const{min,max,minDefined,maxDefined}=iScale.getUserBounds();if(minDefined){start=_limitValue(Math.min(_lookupByKey(_parsed,iScale.axis,min).lo,animationsDisabled?pointCount:_lookupByKey(points,axis,iScale.getPixelForValue(min)).lo),0,pointCount-1);} -if(maxDefined){count=_limitValue(Math.max(_lookupByKey(_parsed,iScale.axis,max).hi+1,animationsDisabled?0:_lookupByKey(points,axis,iScale.getPixelForValue(max)).hi+1),start,pointCount)-start;}else{count=pointCount-start;}} -return{start,count};} -function scaleRangesChanged(meta){const{xScale,yScale,_scaleRanges}=meta;const newRanges={xmin:xScale.min,xmax:xScale.max,ymin:yScale.min,ymax:yScale.max};if(!_scaleRanges){meta._scaleRanges=newRanges;return true;} -const changed=_scaleRanges.xmin!==xScale.min||_scaleRanges.xmax!==xScale.max||_scaleRanges.ymin!==yScale.min||_scaleRanges.ymax!==yScale.max;Object.assign(_scaleRanges,newRanges);return changed;} -class PolarAreaController extends DatasetController{constructor(chart,datasetIndex){super(chart,datasetIndex);this.innerRadius=undefined;this.outerRadius=undefined;} +LineController.id='line';LineController.defaults={datasetElementType:'line',dataElementType:'point',showLine:true,spanGaps:false,};LineController.overrides={scales:{_index_:{type:'category',},_value_:{type:'linear',},}};class PolarAreaController extends DatasetController{constructor(chart,datasetIndex){super(chart,datasetIndex);this.innerRadius=undefined;this.outerRadius=undefined;} getLabelAndValue(index){const meta=this._cachedMeta;const chart=this.chart;const labels=chart.data.labels||[];const value=formatNumber(meta._parsed[index].r,chart.options.locale);return{label:labels[index]||'',value,};} parseObjectData(meta,data,start,count){return _parseObjectDataRadialScale.bind(this)(meta,data,start,count);} update(mode){const arcs=this._cachedMeta.data;this._updateRadius();this.updateElements(arcs,0,arcs.length,mode);} @@ -2187,37 +2190,50 @@ update(mode){const meta=this._cachedMeta;const line=meta.dataset;const points=me const properties={_loop:true,_fullLoop:labels.length===points.length,options};this.updateElement(line,undefined,properties,mode);} this.updateElements(points,0,points.length,mode);} updateElements(points,start,count,mode){const scale=this._cachedMeta.rScale;const reset=mode==='reset';for(let i=start;ipixelMargin){angleMargin=pixelMargin/innerRadius;ctx.arc(x,y,innerRadius,endAngle+angleMargin,startAngle-angleMargin,true);}else{ctx.arc(x,y,pixelMargin,endAngle+HALF_PI,startAngle-HALF_PI);} +RadarController.id='radar';RadarController.defaults={datasetElementType:'line',dataElementType:'point',indexAxis:'r',showLine:true,elements:{line:{fill:'start'}},};RadarController.overrides={aspectRatio:1,scales:{r:{type:'radialLinear',}}};class ScatterController extends DatasetController{update(mode){const meta=this._cachedMeta;const{data:points=[]}=meta;const animationsDisabled=this.chart._animationsDisabled;let{start,count}=_getStartAndCountOfVisiblePoints(meta,points,animationsDisabled);this._drawStart=start;this._drawCount=count;if(_scaleRangesChanged(meta)){start=0;count=points.length;} +if(this.options.showLine){const{dataset:line,_dataset}=meta;line._chart=this.chart;line._datasetIndex=this.index;line._decimated=!!_dataset._decimated;line.points=points;const options=this.resolveDatasetElementOptions(mode);options.segment=this.options.segment;this.updateElement(line,undefined,{animated:!animationsDisabled,options},mode);} +this.updateElements(points,start,count,mode);} +addElements(){const{showLine}=this.options;if(!this.datasetElementType&&showLine){this.datasetElementType=registry.getElement('line');} +super.addElements();} +updateElements(points,start,count,mode){const reset=mode==='reset';const{iScale,vScale,_stacked,_dataset}=this._cachedMeta;const firstOpts=this.resolveDataElementOptions(start,mode);const sharedOptions=this.getSharedOptions(firstOpts);const includeOptions=this.includeOptions(mode,sharedOptions);const iAxis=iScale.axis;const vAxis=vScale.axis;const{spanGaps,segment}=this.options;const maxGapLength=isNumber(spanGaps)?spanGaps:Number.POSITIVE_INFINITY;const directUpdate=this.chart._animationsDisabled||reset||mode==='none';let prevParsed=start>0&&this.getParsed(start-1);for(let i=start;i0&&(Math.abs(parsed[iAxis]-prevParsed[iAxis]))>maxGapLength;if(segment){properties.parsed=parsed;properties.raw=_dataset.data[i];} +if(includeOptions){properties.options=sharedOptions||this.resolveDataElementOptions(i,point.active?'active':mode);} +if(!directUpdate){this.updateElement(point,i,properties,mode);} +prevParsed=parsed;} +this.updateSharedOptions(sharedOptions,mode,firstOpts);} +getMaxOverflow(){const meta=this._cachedMeta;const data=meta.data||[];if(!this.options.showLine){let max=0;for(let i=data.length-1;i>=0;--i){max=Math.max(max,data[i].size(this.resolveDataElementOptions(i))/2);} +return max>0&&max;} +const dataset=meta.dataset;const border=dataset.options&&dataset.options.borderWidth||0;if(!data.length){return border;} +const firstPoint=data[0].size(this.resolveDataElementOptions(0));const lastPoint=data[data.length-1].size(this.resolveDataElementOptions(data.length-1));return Math.max(border,firstPoint,lastPoint)/2;}} +ScatterController.id='scatter';ScatterController.defaults={datasetElementType:false,dataElementType:'point',showLine:false,fill:false};ScatterController.overrides={interaction:{mode:'point'},plugins:{tooltip:{callbacks:{title(){return'';},label(item){return'('+item.label+', '+item.formattedValue+')';}}}},scales:{x:{type:'linear'},y:{type:'linear'}}};var controllers=Object.freeze({__proto__:null,BarController:BarController,BubbleController:BubbleController,DoughnutController:DoughnutController,LineController:LineController,PolarAreaController:PolarAreaController,PieController:PieController,RadarController:RadarController,ScatterController:ScatterController});function clipArc(ctx,element,endAngle){const{startAngle,pixelMargin,x,y,outerRadius,innerRadius}=element;let angleMargin=pixelMargin/outerRadius;ctx.beginPath();ctx.arc(x,y,outerRadius,startAngle-angleMargin,endAngle+angleMargin);if(innerRadius>pixelMargin){angleMargin=pixelMargin/innerRadius;ctx.arc(x,y,innerRadius,endAngle+angleMargin,startAngle-angleMargin,true);}else{ctx.arc(x,y,pixelMargin,endAngle+HALF_PI,startAngle-HALF_PI);} ctx.closePath();ctx.clip();} function toRadiusCorners(value){return _readValueToProps(value,['outerStart','outerEnd','innerStart','innerEnd']);} function parseBorderRadius$1(arc,innerRadius,outerRadius,angleDelta){const o=toRadiusCorners(arc.options.borderRadius);const halfThickness=(outerRadius-innerRadius)/2;const innerLimit=Math.min(halfThickness,angleDelta*innerRadius/2);const computeOuterLimit=(val)=>{const outerArcLimit=(outerRadius-Math.min(halfThickness,val))*angleDelta/2;return _limitValue(val,0,Math.min(halfThickness,outerArcLimit));};return{outerStart:computeOuterLimit(o.outerStart),outerEnd:computeOuterLimit(o.outerEnd),innerStart:_limitValue(o.innerStart,0,innerLimit),innerEnd:_limitValue(o.innerEnd,0,innerLimit),};} function rThetaToXY(r,theta,x,y){return{x:x+r*Math.cos(theta),y:y+r*Math.sin(theta),};} -function pathArc(ctx,element,offset,spacing,end){const{x,y,startAngle:start,pixelMargin,innerRadius:innerR}=element;const outerRadius=Math.max(element.outerRadius+spacing+offset-pixelMargin,0);const innerRadius=innerR>0?innerR+spacing+offset+pixelMargin:0;let spacingOffset=0;const alpha=end-start;if(spacing){const noSpacingInnerRadius=innerR>0?innerR-spacing:0;const noSpacingOuterRadius=outerRadius>0?outerRadius-spacing:0;const avNogSpacingRadius=(noSpacingInnerRadius+noSpacingOuterRadius)/2;const adjustedAngle=avNogSpacingRadius!==0?(alpha*avNogSpacingRadius)/(avNogSpacingRadius+spacing):alpha;spacingOffset=(alpha-adjustedAngle)/2;} -const beta=Math.max(0.001,alpha*outerRadius-offset/PI)/outerRadius;const angleOffset=(alpha-beta)/2;const startAngle=start+angleOffset+spacingOffset;const endAngle=end-angleOffset-spacingOffset;const{outerStart,outerEnd,innerStart,innerEnd}=parseBorderRadius$1(element,innerRadius,outerRadius,endAngle-startAngle);const outerStartAdjustedRadius=outerRadius-outerStart;const outerEndAdjustedRadius=outerRadius-outerEnd;const outerStartAdjustedAngle=startAngle+outerStart/outerStartAdjustedRadius;const outerEndAdjustedAngle=endAngle-outerEnd/outerEndAdjustedRadius;const innerStartAdjustedRadius=innerRadius+innerStart;const innerEndAdjustedRadius=innerRadius+innerEnd;const innerStartAdjustedAngle=startAngle+innerStart/innerStartAdjustedRadius;const innerEndAdjustedAngle=endAngle-innerEnd/innerEndAdjustedRadius;ctx.beginPath();ctx.arc(x,y,outerRadius,outerStartAdjustedAngle,outerEndAdjustedAngle);if(outerEnd>0){const pCenter=rThetaToXY(outerEndAdjustedRadius,outerEndAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,outerEnd,outerEndAdjustedAngle,endAngle+HALF_PI);} +function pathArc(ctx,element,offset,spacing,end,circular){const{x,y,startAngle:start,pixelMargin,innerRadius:innerR}=element;const outerRadius=Math.max(element.outerRadius+spacing+offset-pixelMargin,0);const innerRadius=innerR>0?innerR+spacing+offset+pixelMargin:0;let spacingOffset=0;const alpha=end-start;if(spacing){const noSpacingInnerRadius=innerR>0?innerR-spacing:0;const noSpacingOuterRadius=outerRadius>0?outerRadius-spacing:0;const avNogSpacingRadius=(noSpacingInnerRadius+noSpacingOuterRadius)/2;const adjustedAngle=avNogSpacingRadius!==0?(alpha*avNogSpacingRadius)/(avNogSpacingRadius+spacing):alpha;spacingOffset=(alpha-adjustedAngle)/2;} +const beta=Math.max(0.001,alpha*outerRadius-offset/PI)/outerRadius;const angleOffset=(alpha-beta)/2;const startAngle=start+angleOffset+spacingOffset;const endAngle=end-angleOffset-spacingOffset;const{outerStart,outerEnd,innerStart,innerEnd}=parseBorderRadius$1(element,innerRadius,outerRadius,endAngle-startAngle);const outerStartAdjustedRadius=outerRadius-outerStart;const outerEndAdjustedRadius=outerRadius-outerEnd;const outerStartAdjustedAngle=startAngle+outerStart/outerStartAdjustedRadius;const outerEndAdjustedAngle=endAngle-outerEnd/outerEndAdjustedRadius;const innerStartAdjustedRadius=innerRadius+innerStart;const innerEndAdjustedRadius=innerRadius+innerEnd;const innerStartAdjustedAngle=startAngle+innerStart/innerStartAdjustedRadius;const innerEndAdjustedAngle=endAngle-innerEnd/innerEndAdjustedRadius;ctx.beginPath();if(circular){ctx.arc(x,y,outerRadius,outerStartAdjustedAngle,outerEndAdjustedAngle);if(outerEnd>0){const pCenter=rThetaToXY(outerEndAdjustedRadius,outerEndAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,outerEnd,outerEndAdjustedAngle,endAngle+HALF_PI);} const p4=rThetaToXY(innerEndAdjustedRadius,endAngle,x,y);ctx.lineTo(p4.x,p4.y);if(innerEnd>0){const pCenter=rThetaToXY(innerEndAdjustedRadius,innerEndAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,innerEnd,endAngle+HALF_PI,innerEndAdjustedAngle+Math.PI);} ctx.arc(x,y,innerRadius,endAngle-(innerEnd/innerRadius),startAngle+(innerStart/innerRadius),true);if(innerStart>0){const pCenter=rThetaToXY(innerStartAdjustedRadius,innerStartAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,innerStart,innerStartAdjustedAngle+Math.PI,startAngle-HALF_PI);} -const p8=rThetaToXY(outerStartAdjustedRadius,startAngle,x,y);ctx.lineTo(p8.x,p8.y);if(outerStart>0){const pCenter=rThetaToXY(outerStartAdjustedRadius,outerStartAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,outerStart,startAngle-HALF_PI,outerStartAdjustedAngle);} +const p8=rThetaToXY(outerStartAdjustedRadius,startAngle,x,y);ctx.lineTo(p8.x,p8.y);if(outerStart>0){const pCenter=rThetaToXY(outerStartAdjustedRadius,outerStartAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,outerStart,startAngle-HALF_PI,outerStartAdjustedAngle);}}else{ctx.moveTo(x,y);const outerStartX=Math.cos(outerStartAdjustedAngle)*outerRadius+x;const outerStartY=Math.sin(outerStartAdjustedAngle)*outerRadius+y;ctx.lineTo(outerStartX,outerStartY);const outerEndX=Math.cos(outerEndAdjustedAngle)*outerRadius+x;const outerEndY=Math.sin(outerEndAdjustedAngle)*outerRadius+y;ctx.lineTo(outerEndX,outerEndY);} ctx.closePath();} -function drawArc(ctx,element,offset,spacing){const{fullCircles,startAngle,circumference}=element;let endAngle=element.endAngle;if(fullCircles){pathArc(ctx,element,offset,spacing,startAngle+TAU);for(let i=0;i=TAU||_angleBetween(angle,startAngle,endAngle);const withinRadius=_isBetween(distance,innerRadius+rAdjust,outerRadius+rAdjust);return(betweenAngles&&withinRadius);} getCenterPoint(useFinalPosition){const{x,y,startAngle,endAngle,innerRadius,outerRadius}=this.getProps(['x','y','startAngle','endAngle','innerRadius','outerRadius','circumference',],useFinalPosition);const{offset,spacing}=this.options;const halfAngle=(startAngle+endAngle)/2;const halfRadius=(innerRadius+outerRadius+spacing+offset)/2;return{x:x+Math.cos(halfAngle)*halfRadius,y:y+Math.sin(halfAngle)*halfRadius};} tooltipPosition(useFinalPosition){return this.getCenterPoint(useFinalPosition);} -draw(ctx){const{options,circumference}=this;const offset=(options.offset||0)/2;const spacing=(options.spacing||0)/2;this.pixelMargin=(options.borderAlign==='inner')?0.33:0;this.fullCircles=circumference>TAU?Math.floor(circumference/TAU):0;if(circumference===0||this.innerRadius<0||this.outerRadius<0){return;} +draw(ctx){const{options,circumference}=this;const offset=(options.offset||0)/2;const spacing=(options.spacing||0)/2;const circular=options.circular;this.pixelMargin=(options.borderAlign==='inner')?0.33:0;this.fullCircles=circumference>TAU?Math.floor(circumference/TAU):0;if(circumference===0||this.innerRadius<0||this.outerRadius<0){return;} ctx.save();let radiusOffset=0;if(offset){radiusOffset=offset/2;const halfAngle=(this.startAngle+this.endAngle)/2;ctx.translate(Math.cos(halfAngle)*radiusOffset,Math.sin(halfAngle)*radiusOffset);if(this.circumference>=PI){radiusOffset=offset;}} -ctx.fillStyle=options.backgroundColor;ctx.strokeStyle=options.borderColor;const endAngle=drawArc(ctx,this,radiusOffset,spacing);drawBorder(ctx,this,radiusOffset,spacing,endAngle);ctx.restore();}} -ArcElement.id='arc';ArcElement.defaults={borderAlign:'center',borderColor:'#fff',borderJoinStyle:undefined,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:undefined,};ArcElement.defaultRoutes={backgroundColor:'backgroundColor'};function setStyle(ctx,options,style=options){ctx.lineCap=valueOrDefault(style.borderCapStyle,options.borderCapStyle);ctx.setLineDash(valueOrDefault(style.borderDash,options.borderDash));ctx.lineDashOffset=valueOrDefault(style.borderDashOffset,options.borderDashOffset);ctx.lineJoin=valueOrDefault(style.borderJoinStyle,options.borderJoinStyle);ctx.lineWidth=valueOrDefault(style.borderWidth,options.borderWidth);ctx.strokeStyle=valueOrDefault(style.borderColor,options.borderColor);} +ctx.fillStyle=options.backgroundColor;ctx.strokeStyle=options.borderColor;const endAngle=drawArc(ctx,this,radiusOffset,spacing,circular);drawBorder(ctx,this,radiusOffset,spacing,endAngle,circular);ctx.restore();}} +ArcElement.id='arc';ArcElement.defaults={borderAlign:'center',borderColor:'#fff',borderJoinStyle:undefined,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:undefined,circular:true,};ArcElement.defaultRoutes={backgroundColor:'backgroundColor'};function setStyle(ctx,options,style=options){ctx.lineCap=valueOrDefault(style.borderCapStyle,options.borderCapStyle);ctx.setLineDash(valueOrDefault(style.borderDash,options.borderDash));ctx.lineDashOffset=valueOrDefault(style.borderDashOffset,options.borderDashOffset);ctx.lineJoin=valueOrDefault(style.borderJoinStyle,options.borderJoinStyle);ctx.lineWidth=valueOrDefault(style.borderWidth,options.borderWidth);ctx.strokeStyle=valueOrDefault(style.borderColor,options.borderColor);} function lineTo(ctx,previous,target){ctx.lineTo(target.x,target.y);} function getLineMethod(options){if(options.stepped){return _steppedLineTo;} if(options.tension||options.cubicInterpolationMode==='monotone'){return _bezierCurveTo;} @@ -2411,7 +2427,7 @@ hitbox.top=top;hitbox.left+=this.left+padding;hitbox.left=rtlHelper.leftForLtr(r isHorizontal(){return this.options.position==='top'||this.options.position==='bottom';} draw(){if(this.options.display){const ctx=this.ctx;clipArea(ctx,this);this._draw();unclipArea(ctx);}} _draw(){const{options:opts,columnSizes,lineWidths,ctx}=this;const{align,labels:labelOpts}=opts;const defaultColor=defaults.color;const rtlHelper=getRtlAdapter(opts.rtl,this.left,this.width);const labelFont=toFont(labelOpts.font);const{color:fontColor,padding}=labelOpts;const fontSize=labelFont.size;const halfFontSize=fontSize/2;let cursor;this.drawTitle();ctx.textAlign=rtlHelper.textAlign('left');ctx.textBaseline='middle';ctx.lineWidth=0.5;ctx.font=labelFont.string;const{boxWidth,boxHeight,itemHeight}=getBoxSize(labelOpts,fontSize);const drawLegendBox=function(x,y,legendItem){if(isNaN(boxWidth)||boxWidth<=0||isNaN(boxHeight)||boxHeight<0){return;} -ctx.save();const lineWidth=valueOrDefault(legendItem.lineWidth,1);ctx.fillStyle=valueOrDefault(legendItem.fillStyle,defaultColor);ctx.lineCap=valueOrDefault(legendItem.lineCap,'butt');ctx.lineDashOffset=valueOrDefault(legendItem.lineDashOffset,0);ctx.lineJoin=valueOrDefault(legendItem.lineJoin,'miter');ctx.lineWidth=lineWidth;ctx.strokeStyle=valueOrDefault(legendItem.strokeStyle,defaultColor);ctx.setLineDash(valueOrDefault(legendItem.lineDash,[]));if(labelOpts.usePointStyle){const drawOptions={radius:boxHeight*Math.SQRT2/2,pointStyle:legendItem.pointStyle,rotation:legendItem.rotation,borderWidth:lineWidth};const centerX=rtlHelper.xPlus(x,boxWidth/2);const centerY=y+halfFontSize;drawPointLegend(ctx,drawOptions,centerX,centerY,boxWidth);}else{const yBoxTop=y+Math.max((fontSize-boxHeight)/2,0);const xBoxLeft=rtlHelper.leftForLtr(x,boxWidth);const borderRadius=toTRBLCorners(legendItem.borderRadius);ctx.beginPath();if(Object.values(borderRadius).some(v=>v!==0)){addRoundedRectPath(ctx,{x:xBoxLeft,y:yBoxTop,w:boxWidth,h:boxHeight,radius:borderRadius,});}else{ctx.rect(xBoxLeft,yBoxTop,boxWidth,boxHeight);} +ctx.save();const lineWidth=valueOrDefault(legendItem.lineWidth,1);ctx.fillStyle=valueOrDefault(legendItem.fillStyle,defaultColor);ctx.lineCap=valueOrDefault(legendItem.lineCap,'butt');ctx.lineDashOffset=valueOrDefault(legendItem.lineDashOffset,0);ctx.lineJoin=valueOrDefault(legendItem.lineJoin,'miter');ctx.lineWidth=lineWidth;ctx.strokeStyle=valueOrDefault(legendItem.strokeStyle,defaultColor);ctx.setLineDash(valueOrDefault(legendItem.lineDash,[]));if(labelOpts.usePointStyle){const drawOptions={radius:boxHeight*Math.SQRT2/2,pointStyle:legendItem.pointStyle,rotation:legendItem.rotation,borderWidth:lineWidth};const centerX=rtlHelper.xPlus(x,boxWidth/2);const centerY=y+halfFontSize;drawPointLegend(ctx,drawOptions,centerX,centerY,labelOpts.pointStyleWidth&&boxWidth);}else{const yBoxTop=y+Math.max((fontSize-boxHeight)/2,0);const xBoxLeft=rtlHelper.leftForLtr(x,boxWidth);const borderRadius=toTRBLCorners(legendItem.borderRadius);ctx.beginPath();if(Object.values(borderRadius).some(v=>v!==0)){addRoundedRectPath(ctx,{x:xBoxLeft,y:yBoxTop,w:boxWidth,h:boxHeight,radius:borderRadius,});}else{ctx.rect(xBoxLeft,yBoxTop,boxWidth,boxHeight);} ctx.fill();if(lineWidth!==0){ctx.stroke();}} ctx.restore();};const fillText=function(x,y,legendItem){renderText(ctx,legendItem.text,x,y+(itemHeight/2),labelFont,{strikethrough:legendItem.hidden,textAlign:rtlHelper.textAlign(legendItem.textAlign)});};const isHorizontal=this.isHorizontal();const titleHeight=this._computeTitleHeight();if(isHorizontal){cursor={x:_alignStartEnd(align,this.left+padding,this.right-lineWidths[0]),y:this.top+padding+titleHeight,line:0};}else{cursor={x:this.left+padding,y:_alignStartEnd(align,this.top+titleHeight+padding,this.bottom-columnSizes[0].height),line:0};} overrideTextDirection(this.ctx,opts.textDirection);const lineHeight=itemHeight+padding;this.legendItems.forEach((legendItem,i)=>{ctx.strokeStyle=legendItem.fontColor||fontColor;ctx.fillStyle=legendItem.fontColor||fontColor;const textWidth=ctx.measureText(legendItem.text).width;const textAlign=rtlHelper.textAlign(legendItem.textAlign||(legendItem.textAlign=labelOpts.textAlign));const width=boxWidth+halfFontSize+textWidth;let x=cursor.x;let y=cursor.y;rtlHelper.setWidth(this.width);if(isHorizontal){if(i>0&&x+width+padding>this.right){y=cursor.y+=lineHeight;cursor.line++;x=cursor.x=_alignStartEnd(align,this.left+padding,this.right-lineWidths[cursor.line]);}}else if(i>0&&y+lineHeight>this.bottom){x=cursor.x=x+columnSizes[cursor.line].width+padding;cursor.line++;y=cursor.y=_alignStartEnd(align,this.top+titleHeight+padding,this.bottom-columnSizes[cursor.line].height);} @@ -2683,7 +2699,7 @@ return ticks;} function ticksFromTimestamps(scale,values,majorUnit){const ticks=[];const map={};const ilen=values.length;let i,value;for(i=0;i(typeof value==='number'||value instanceof Number)&&isFinite(+value);function finiteOrDefault(value,defaultValue){return isNumberFinite(value)?value:defaultValue;} +function valueOrDefault(value,defaultValue){return typeof value==='undefined'?defaultValue:value;} +const toPercentage=(value,dimension)=>typeof value==='string'&&value.endsWith('%')?parseFloat(value)/100:value/dimension;const toDimension=(value,dimension)=>typeof value==='string'&&value.endsWith('%')?parseFloat(value)/100*dimension:+value;function callback(fn,args,thisArg){if(fn&&typeof fn.call==='function'){return fn.apply(thisArg,args);}} +function each(loopable,fn,thisArg,reverse){let i,len,keys;if(isArray(loopable)){len=loopable.length;if(reverse){for(i=len-1;i>=0;i--){fn.call(thisArg,loopable[i],i);}}else{for(i=0;iv,x:o=>o.x,y:o=>o.y};function resolveObjectKey(obj,key){const resolver=keyResolvers[key]||(keyResolvers[key]=_getKeyResolver(key));return resolver(obj);} +function _getKeyResolver(key){const keys=_splitKey(key);return obj=>{for(const k of keys){if(k===''){break;} +obj=obj&&obj[k];} +return obj;};} +function _splitKey(key){const parts=key.split('.');const keys=[];let tmp='';for(const part of parts){tmp+=part;if(tmp.endsWith('\\')){tmp=tmp.slice(0,-1)+'.';}else{keys.push(tmp);tmp='';}} +return keys;} +function _capitalize(str){return str.charAt(0).toUpperCase()+str.slice(1);} +const defined=(value)=>typeof value!=='undefined';const isFunction=(value)=>typeof value==='function';const setsEqual=(a,b)=>{if(a.size!==b.size){return false;} +for(const item of a){if(!b.has(item)){return false;}} +return true;};function _isClickEvent(e){return e.type==='mouseup'||e.type==='click'||e.type==='contextmenu';} +const PI=Math.PI;const TAU=2*PI;const PITAU=TAU+PI;const INFINITY=Number.POSITIVE_INFINITY;const RAD_PER_DEG=PI/180;const HALF_PI=PI/2;const QUARTER_PI=PI/4;const TWO_THIRDS_PI=PI*2/3;const log10=Math.log10;const sign=Math.sign;function niceNum(range){const roundedRange=Math.round(range);range=almostEquals(range,roundedRange,range/1000)?roundedRange:range;const niceRange=Math.pow(10,Math.floor(log10(range)));const fraction=range/niceRange;const niceFraction=fraction<=1?1:fraction<=2?2:fraction<=5?5:10;return niceFraction*niceRange;} +function _factorize(value){const result=[];const sqrt=Math.sqrt(value);let i;for(i=1;ia-b).pop();return result;} +function isNumber(n){return!isNaN(parseFloat(n))&&isFinite(n);} +function almostEquals(x,y,epsilon){return Math.abs(x-y)=x);} +function _setMinAndMaxByKey(array,target,property){let i,ilen,value;for(i=0,ilen=array.length;iangleToEnd&&startToAngle=Math.min(start,end)-epsilon&&value<=Math.max(start,end)+epsilon;} +function _lookup(table,value,cmp){cmp=cmp||((index)=>table[index]1){mid=(lo+hi)>>1;if(cmp(mid)){lo=mid;}else{hi=mid;}} +return{lo,hi};} +const _lookupByKey=(table,key,value,last)=>_lookup(table,value,last?index=>table[index][key]<=value:index=>table[index][key]_lookup(table,value,index=>table[index][key]>=value);function _filterBetween(values,min,max){let start=0;let end=values.length;while(startstart&&values[end-1]>max){end--;} +return start>0||end{const method='_onData'+_capitalize(key);const base=array[key];Object.defineProperty(array,key,{configurable:true,enumerable:false,value(...args){const res=base.apply(this,args);array._chartjs.listeners.forEach((object)=>{if(typeof object[method]==='function'){object[method](...args);}});return res;}});});} +function unlistenArrayEvents(array,listener){const stub=array._chartjs;if(!stub){return;} +const listeners=stub.listeners;const index=listeners.indexOf(listener);if(index!==-1){listeners.splice(index,1);} +if(listeners.length>0){return;} +arrayEvents.forEach((key)=>{delete array[key];});delete array._chartjs;} +function _arrayUnique(items){const set=new Set();let i,ilen;for(i=0,ilen=items.length;iArray.prototype.slice.call(args));let ticking=false;let args=[];return function(...rest){args=updateArgs(rest);if(!ticking){ticking=true;requestAnimFrame.call(window,()=>{ticking=false;fn.apply(thisArg,args);});}};} function debounce(fn,delay){let timeout;return function(...args){if(delay){clearTimeout(timeout);timeout=setTimeout(fn,delay,args);}else{fn.apply(this,args);} return delay;};} -const _toLeftRightCenter=(align)=>align==='start'?'left':align==='end'?'right':'center';const _alignStartEnd=(align,start,end)=>align==='start'?start:align==='end'?end:(start+end)/2;const _textX=(align,left,right,rtl)=>{const check=rtl?'left':'right';return align===check?right:align==='center'?(left+right)/2:left;};class Animator{constructor(){this._request=null;this._charts=new Map();this._running=false;this._lastDate=undefined;} +const _toLeftRightCenter=(align)=>align==='start'?'left':align==='end'?'right':'center';const _alignStartEnd=(align,start,end)=>align==='start'?start:align==='end'?end:(start+end)/2;const _textX=(align,left,right,rtl)=>{const check=rtl?'left':'right';return align===check?right:align==='center'?(left+right)/2:left;};function _getStartAndCountOfVisiblePoints(meta,points,animationsDisabled){const pointCount=points.length;let start=0;let count=pointCount;if(meta._sorted){const{iScale,_parsed}=meta;const axis=iScale.axis;const{min,max,minDefined,maxDefined}=iScale.getUserBounds();if(minDefined){start=_limitValue(Math.min(_lookupByKey(_parsed,iScale.axis,min).lo,animationsDisabled?pointCount:_lookupByKey(points,axis,iScale.getPixelForValue(min)).lo),0,pointCount-1);} +if(maxDefined){count=_limitValue(Math.max(_lookupByKey(_parsed,iScale.axis,max,true).hi+1,animationsDisabled?0:_lookupByKey(points,axis,iScale.getPixelForValue(max),true).hi+1),start,pointCount)-start;}else{count=pointCount-start;}} +return{start,count};} +function _scaleRangesChanged(meta){const{xScale,yScale,_scaleRanges}=meta;const newRanges={xmin:xScale.min,xmax:xScale.max,ymin:yScale.min,ymax:yScale.max};if(!_scaleRanges){meta._scaleRanges=newRanges;return true;} +const changed=_scaleRanges.xmin!==xScale.min||_scaleRanges.xmax!==xScale.max||_scaleRanges.ymin!==yScale.min||_scaleRanges.ymax!==yScale.max;Object.assign(_scaleRanges,newRanges);return changed;} +class Animator{constructor(){this._request=null;this._charts=new Map();this._running=false;this._lastDate=undefined;} _notify(chart,anims,date,type){const callbacks=anims.listeners[type];const numSteps=anims.duration;callbacks.forEach(fn=>fn({chart,initial:anims.initial,numSteps,currentStep:Math.min(date-anims.start,numSteps)}));} _refresh(){if(this._request){return;} this._running=true;this._request=requestAnimFrame.call(window,()=>{this._update();this._request=null;if(this._running){this._refresh();}});} @@ -1066,8 +1144,8 @@ r=+m[1];g=+m[3];b=+m[5];r=255&(m[2]?p2b(r):lim(r,0,255));g=255&(m[4]?p2b(g):lim( function rgbString(v){return v&&(v.a<255?`rgba(${v.r}, ${v.g}, ${v.b}, ${b2n(v.a)})`:`rgb(${v.r}, ${v.g}, ${v.b})`);} const to=v=>v<=0.0031308?v*12.92:Math.pow(v,1.0/2.4)*1.055-0.055;const from=v=>v<=0.04045?v/12.92:Math.pow((v+0.055)/1.055,2.4);function interpolate$1(rgb1,rgb2,t){const r=from(b2n(rgb1.r));const g=from(b2n(rgb1.g));const b=from(b2n(rgb1.b));return{r:n2b(to(r+t*(from(b2n(rgb2.r))-r))),g:n2b(to(g+t*(from(b2n(rgb2.g))-g))),b:n2b(to(b+t*(from(b2n(rgb2.b))-b))),a:rgb1.a+t*(rgb2.a-rgb1.a)};} function modHSL(v,i,ratio){if(v){let tmp=rgb2hsl(v);tmp[i]=Math.max(0,Math.min(tmp[i]+tmp[i]*ratio,i===0?360:1));tmp=hsl2rgb(tmp);v.r=tmp[0];v.g=tmp[1];v.b=tmp[2];}} -function clone$1(v,proto){return v?Object.assign(proto||{},v):v;} -function fromObject(input){var v={r:0,g:0,b:0,a:255};if(Array.isArray(input)){if(input.length>=3){v={r:input[0],g:input[1],b:input[2],a:255};if(input.length>3){v.a=n2b(input[3]);}}}else{v=clone$1(input,{r:0,g:0,b:0,a:1});v.a=n2b(v.a);} +function clone(v,proto){return v?Object.assign(proto||{},v):v;} +function fromObject(input){var v={r:0,g:0,b:0,a:255};if(Array.isArray(input)){if(input.length>=3){v={r:input[0],g:input[1],b:input[2],a:255};if(input.length>3){v.a=n2b(input[3]);}}}else{v=clone(input,{r:0,g:0,b:0,a:1});v.a=n2b(v.a);} return v;} function functionParse(str){if(str.charAt(0)==='r'){return rgbParse(str);} return hueParse(str);} @@ -1075,7 +1153,7 @@ class Color{constructor(input){if(input instanceof Color){return input;} const type=typeof input;let v;if(type==='object'){v=fromObject(input);}else if(type==='string'){v=hexParse(input)||nameParse(input)||functionParse(input);} this._rgb=v;this._valid=!!v;} get valid(){return this._valid;} -get rgb(){var v=clone$1(this._rgb);if(v){v.a=b2n(v.a);} +get rgb(){var v=clone(this._rgb);if(v){v.a=b2n(v.a);} return v;} set rgb(obj){this._rgb=fromObject(obj);} rgbString(){return this._valid?rgbString(this._rgb):undefined;} @@ -1101,42 +1179,6 @@ function isPatternOrGradient(value){if(value&&typeof value==='object'){const typ return false;} function color(value){return isPatternOrGradient(value)?value:index_esm(value);} function getHoverColor(value){return isPatternOrGradient(value)?value:index_esm(value).saturate(0.5).darken(0.1).hexString();} -function noop(){} -const uid=(function(){let id=0;return function(){return id++;};}());function isNullOrUndef(value){return value===null||typeof value==='undefined';} -function isArray(value){if(Array.isArray&&Array.isArray(value)){return true;} -const type=Object.prototype.toString.call(value);if(type.slice(0,7)==='[object'&&type.slice(-6)==='Array]'){return true;} -return false;} -function isObject(value){return value!==null&&Object.prototype.toString.call(value)==='[object Object]';} -const isNumberFinite=(value)=>(typeof value==='number'||value instanceof Number)&&isFinite(+value);function finiteOrDefault(value,defaultValue){return isNumberFinite(value)?value:defaultValue;} -function valueOrDefault(value,defaultValue){return typeof value==='undefined'?defaultValue:value;} -const toPercentage=(value,dimension)=>typeof value==='string'&&value.endsWith('%')?parseFloat(value)/100:value/dimension;const toDimension=(value,dimension)=>typeof value==='string'&&value.endsWith('%')?parseFloat(value)/100*dimension:+value;function callback(fn,args,thisArg){if(fn&&typeof fn.call==='function'){return fn.apply(thisArg,args);}} -function each(loopable,fn,thisArg,reverse){let i,len,keys;if(isArray(loopable)){len=loopable.length;if(reverse){for(i=len-1;i>=0;i--){fn.call(thisArg,loopable[i],i);}}else{for(i=0;ipos){obj=obj[key.slice(pos,idx)];pos=idx+1;idx=indexOfDotOrLength(key,pos);} -return obj;} -function _capitalize(str){return str.charAt(0).toUpperCase()+str.slice(1);} -const defined=(value)=>typeof value!=='undefined';const isFunction=(value)=>typeof value==='function';const setsEqual=(a,b)=>{if(a.size!==b.size){return false;} -for(const item of a){if(!b.has(item)){return false;}} -return true;};function _isClickEvent(e){return e.type==='mouseup'||e.type==='click'||e.type==='contextmenu';} const overrides=Object.create(null);const descriptors=Object.create(null);function getScope$1(node,key){if(!key){return node;} const keys=key.split('.');for(let i=0,n=keys.length;i!name.startsWith('on'),_indexable:(name)=>name!=='events',hover:{_fallback:'interaction'},interaction:{_scriptable:false,_indexable:false,}});function _lookup(table,value,cmp){cmp=cmp||((index)=>table[index]1){mid=(lo+hi)>>1;if(cmp(mid)){lo=mid;}else{hi=mid;}} -return{lo,hi};} -const _lookupByKey=(table,key,value)=>_lookup(table,value,index=>table[index][key]_lookup(table,value,index=>table[index][key]>=value);function _filterBetween(values,min,max){let start=0;let end=values.length;while(startstart&&values[end-1]>max){end--;} -return start>0||end{const method='_onData'+_capitalize(key);const base=array[key];Object.defineProperty(array,key,{configurable:true,enumerable:false,value(...args){const res=base.apply(this,args);array._chartjs.listeners.forEach((object)=>{if(typeof object[method]==='function'){object[method](...args);}});return res;}});});} -function unlistenArrayEvents(array,listener){const stub=array._chartjs;if(!stub){return;} -const listeners=stub.listeners;const index=listeners.indexOf(listener);if(index!==-1){listeners.splice(index,1);} -if(listeners.length>0){return;} -arrayEvents.forEach((key)=>{delete array[key];});delete array._chartjs;} -function _arrayUnique(items){const set=new Set();let i,ilen;for(i=0,ilen=items.length;ia-b).pop();return result;} -function isNumber(n){return!isNaN(parseFloat(n))&&isFinite(n);} -function almostEquals(x,y,epsilon){return Math.abs(x-y)=x);} -function _setMinAndMaxByKey(array,target,property){let i,ilen,value;for(i=0,ilen=array.length;iangleToEnd&&startToAngle=Math.min(start,end)-epsilon&&value<=Math.max(start,end)+epsilon;} -function _isDomSupported(){return typeof window!=='undefined'&&typeof document!=='undefined';} +var defaults=new Defaults({_scriptable:(name)=>!name.startsWith('on'),_indexable:(name)=>name!=='events',hover:{_fallback:'interaction'},interaction:{_scriptable:false,_indexable:false,}});function _isDomSupported(){return typeof window!=='undefined'&&typeof document!=='undefined';} function _getParentNode(domNode){let parent=domNode.parentNode;if(parent&&parent.toString()==='[object ShadowRoot]'){parent=parent.host;} return parent;} function parseMaxStyle(styleValue,node,parentProperty){let valueInPixels;if(typeof styleValue==='string'){valueInPixels=parseInt(styleValue,10);if(styleValue.indexOf('%')!==-1){valueInPixels=valueInPixels/100*node.parentNode[parentProperty];}}else{valueInPixels=styleValue;} @@ -1378,7 +1384,7 @@ if(start0;} _computeGridLineItems(chartArea){const axis=this.axis;const chart=this.chart;const options=this.options;const{grid,position}=options;const offset=grid.offset;const isHorizontal=this.isHorizontal();const ticks=this.ticks;const ticksLength=ticks.length+(offset?1:0);const tl=getTickMarkLength(grid);const items=[];const borderOpts=grid.setContext(this.getContext());const axisWidth=borderOpts.drawBorder?borderOpts.borderWidth:0;const axisHalfWidth=axisWidth/2;const alignBorderValue=function(pixel){return _alignPixel(chart,pixel,axisWidth);};let borderValue,i,lineValue,alignedLineValue;let tx1,ty1,tx2,ty2,x1,y1,x2,y2;if(position==='top'){borderValue=alignBorderValue(this.bottom);ty1=this.bottom-tl;ty2=borderValue-axisHalfWidth;y1=alignBorderValue(chartArea.top)+axisHalfWidth;y2=chartArea.bottom;}else if(position==='bottom'){borderValue=alignBorderValue(this.top);y1=chartArea.top;y2=alignBorderValue(chartArea.bottom)-axisHalfWidth;ty1=borderValue+axisHalfWidth;ty2=this.top+tl;}else if(position==='left'){borderValue=alignBorderValue(this.right);tx1=this.right-tl;tx2=borderValue-axisHalfWidth;x1=alignBorderValue(chartArea.left)+axisHalfWidth;x2=chartArea.right;}else if(position==='right'){borderValue=alignBorderValue(this.left);x1=chartArea.left;x2=alignBorderValue(chartArea.right)-axisHalfWidth;tx1=borderValue+axisHalfWidth;tx2=this.left+tl;}else if(axis==='x'){if(position==='center'){borderValue=alignBorderValue((chartArea.top+chartArea.bottom)/2+0.5);}else if(isObject(position)){const positionAxisID=Object.keys(position)[0];const value=position[positionAxisID];borderValue=alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value));} y1=chartArea.top;y2=chartArea.bottom;ty1=borderValue+axisHalfWidth;ty2=ty1+tl;}else if(axis==='y'){if(position==='center'){borderValue=alignBorderValue((chartArea.left+chartArea.right)/2);}else if(isObject(position)){const positionAxisID=Object.keys(position)[0];const value=position[positionAxisID];borderValue=alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value));} tx1=borderValue-axisHalfWidth;tx2=tx1-tl;x1=chartArea.left;x2=chartArea.right;} -const limit=valueOrDefault(options.ticks.maxTicksLimit,ticksLength);const step=Math.max(1,Math.ceil(ticksLength/limit));for(i=0;iisObject(value)&&Object.getOwnPropertyNames(value).reduce((acc,key)=>acc||isFunction(value[key]),false);function needContext(proxy,names){const{isScriptable,isIndexable}=_descriptors(proxy);for(const prop of names){const scriptable=isScriptable(prop);const indexable=isIndexable(prop);const value=(indexable||scriptable)&&proxy[prop];if((scriptable&&(isFunction(value)||hasFunction(value)))||(indexable&&isArray(value))){return true;}} return false;} -var version="3.8.2";const KNOWN_POSITIONS=['top','bottom','left','right','chartArea'];function positionIsHorizontal(position,axis){return position==='top'||position==='bottom'||(KNOWN_POSITIONS.indexOf(position)===-1&&axis==='x');} +var version="3.9.1";const KNOWN_POSITIONS=['top','bottom','left','right','chartArea'];function positionIsHorizontal(position,axis){return position==='top'||position==='bottom'||(KNOWN_POSITIONS.indexOf(position)===-1&&axis==='x');} function compare2Level(l1,l2){return function(a,b){return a[l1]===b[l1]?a[l2]-b[l2]:a[l1]-b[l1];};} function onAnimationsComplete(context){const chart=context.chart;const animationOptions=chart.options.animation;chart.notifyPlugins('afterRender');callback(animationOptions&&animationOptions.onComplete,[context],chart);} function onAnimationProgress(context){const chart=context.chart;const animationOptions=chart.options.animation;callback(animationOptions&&animationOptions.onProgress,[context],chart);} @@ -2030,6 +2036,7 @@ if(!inChartArea){return lastActive;} const hoverOptions=this.options.hover;return this.getElementsAtEventForMode(e,hoverOptions.mode,hoverOptions,useFinalPosition);}} const invalidatePlugins=()=>each(Chart.instances,(chart)=>chart._plugins.invalidate());const enumerable=true;Object.defineProperties(Chart,{defaults:{enumerable,value:defaults},instances:{enumerable,value:instances},overrides:{enumerable,value:overrides},registry:{enumerable,value:registry},version:{enumerable,value:version},getChart:{enumerable,value:getChart},register:{enumerable,value:(...items)=>{registry.add(...items);invalidatePlugins();}},unregister:{enumerable,value:(...items)=>{registry.remove(...items);invalidatePlugins();}}});function abstract(){throw new Error('This method is not implemented: Check that a complete date adapter is provided.');} class DateAdapter{constructor(options){this.options=options||{};} +init(chartOptions){} formats(){return abstract();} parse(value,format){return abstract();} format(timestamp,format){return abstract();} @@ -2063,6 +2070,7 @@ function borderProps(properties){let reverse,start,end,top,bottom;if(properties. if(reverse){top='end';bottom='start';}else{top='start';bottom='end';} return{start,end,reverse,top,bottom};} function setBorderSkipped(properties,options,stack,index){let edge=options.borderSkipped;const res={};if(!edge){properties.borderSkipped=res;return;} +if(edge===true){properties.borderSkipped={top:true,right:true,bottom:true,left:true};return;} const{start,end,reverse,top,bottom}=borderProps(properties);if(edge==='middle'&&stack){properties.enableBorderRadius=true;if((stack._top||0)===index){edge=top;}else if((stack._bottom||0)===index){edge=bottom;}else{res[parseEdge(bottom,start,end,reverse)]=true;edge=top;}} res[parseEdge(edge,start,end,reverse)]=true;properties.borderSkipped=res;} function parseEdge(edge,a,b,reverse){if(reverse){edge=swap(edge,a,b);edge=startEnd(edge,b,a);}else{edge=startEnd(edge,a,b);} @@ -2151,7 +2159,7 @@ _getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data DoughnutController.id='doughnut';DoughnutController.defaults={datasetElementType:false,dataElementType:'arc',animation:{animateRotate:true,animateScale:false},animations:{numbers:{type:'number',properties:['circumference','endAngle','innerRadius','outerRadius','startAngle','x','y','offset','borderWidth','spacing']},},cutout:'50%',rotation:0,circumference:360,radius:'100%',spacing:0,indexAxis:'r',};DoughnutController.descriptors={_scriptable:(name)=>name!=='spacing',_indexable:(name)=>name!=='spacing',};DoughnutController.overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(chart){const data=chart.data;if(data.labels.length&&data.datasets.length){const{labels:{pointStyle}}=chart.legend.options;return data.labels.map((label,i)=>{const meta=chart.getDatasetMeta(0);const style=meta.controller.getStyle(i);return{text:label,fillStyle:style.backgroundColor,strokeStyle:style.borderColor,lineWidth:style.borderWidth,pointStyle:pointStyle,hidden:!chart.getDataVisibility(i),index:i};});} return[];}},onClick(e,legendItem,legend){legend.chart.toggleDataVisibility(legendItem.index);legend.chart.update();}},tooltip:{callbacks:{title(){return'';},label(tooltipItem){let dataLabel=tooltipItem.label;const value=': '+tooltipItem.formattedValue;if(isArray(dataLabel)){dataLabel=dataLabel.slice();dataLabel[0]+=value;}else{dataLabel+=value;} return dataLabel;}}}}};class LineController extends DatasetController{initialize(){this.enableOptionSharing=true;this.supportsDecimation=true;super.initialize();} -update(mode){const meta=this._cachedMeta;const{dataset:line,data:points=[],_dataset}=meta;const animationsDisabled=this.chart._animationsDisabled;let{start,count}=getStartAndCountOfVisiblePoints(meta,points,animationsDisabled);this._drawStart=start;this._drawCount=count;if(scaleRangesChanged(meta)){start=0;count=points.length;} +update(mode){const meta=this._cachedMeta;const{dataset:line,data:points=[],_dataset}=meta;const animationsDisabled=this.chart._animationsDisabled;let{start,count}=_getStartAndCountOfVisiblePoints(meta,points,animationsDisabled);this._drawStart=start;this._drawCount=count;if(_scaleRangesChanged(meta)){start=0;count=points.length;} line._chart=this.chart;line._datasetIndex=this.index;line._decimated=!!_dataset._decimated;line.points=points;const options=this.resolveDatasetElementOptions(mode);if(!this.options.showLine){options.borderWidth=0;} options.segment=this.options.segment;this.updateElement(line,undefined,{animated:!animationsDisabled,options},mode);this.updateElements(points,start,count,mode);} updateElements(points,start,count,mode){const reset=mode==='reset';const{iScale,vScale,_stacked,_dataset}=this._cachedMeta;const{sharedOptions,includeOptions}=this._getSharedOptions(start,mode);const iAxis=iScale.axis;const vAxis=vScale.axis;const{spanGaps,segment}=this.options;const maxGapLength=isNumber(spanGaps)?spanGaps:Number.POSITIVE_INFINITY;const directUpdate=this.chart._animationsDisabled||reset||mode==='none';let prevParsed=start>0&&this.getParsed(start-1);for(let i=start;i0&&(Math.abs(parsed[iAxis]-prevParsed[iAxis]))>maxGapLength;if(segment){properties.parsed=parsed;properties.raw=_dataset.data[i];} @@ -2161,12 +2169,7 @@ prevParsed=parsed;}} getMaxOverflow(){const meta=this._cachedMeta;const dataset=meta.dataset;const border=dataset.options&&dataset.options.borderWidth||0;const data=meta.data||[];if(!data.length){return border;} const firstPoint=data[0].size(this.resolveDataElementOptions(0));const lastPoint=data[data.length-1].size(this.resolveDataElementOptions(data.length-1));return Math.max(border,firstPoint,lastPoint)/2;} draw(){const meta=this._cachedMeta;meta.dataset.updateControlPoints(this.chart.chartArea,meta.iScale.axis);super.draw();}} -LineController.id='line';LineController.defaults={datasetElementType:'line',dataElementType:'point',showLine:true,spanGaps:false,};LineController.overrides={scales:{_index_:{type:'category',},_value_:{type:'linear',},}};function getStartAndCountOfVisiblePoints(meta,points,animationsDisabled){const pointCount=points.length;let start=0;let count=pointCount;if(meta._sorted){const{iScale,_parsed}=meta;const axis=iScale.axis;const{min,max,minDefined,maxDefined}=iScale.getUserBounds();if(minDefined){start=_limitValue(Math.min(_lookupByKey(_parsed,iScale.axis,min).lo,animationsDisabled?pointCount:_lookupByKey(points,axis,iScale.getPixelForValue(min)).lo),0,pointCount-1);} -if(maxDefined){count=_limitValue(Math.max(_lookupByKey(_parsed,iScale.axis,max).hi+1,animationsDisabled?0:_lookupByKey(points,axis,iScale.getPixelForValue(max)).hi+1),start,pointCount)-start;}else{count=pointCount-start;}} -return{start,count};} -function scaleRangesChanged(meta){const{xScale,yScale,_scaleRanges}=meta;const newRanges={xmin:xScale.min,xmax:xScale.max,ymin:yScale.min,ymax:yScale.max};if(!_scaleRanges){meta._scaleRanges=newRanges;return true;} -const changed=_scaleRanges.xmin!==xScale.min||_scaleRanges.xmax!==xScale.max||_scaleRanges.ymin!==yScale.min||_scaleRanges.ymax!==yScale.max;Object.assign(_scaleRanges,newRanges);return changed;} -class PolarAreaController extends DatasetController{constructor(chart,datasetIndex){super(chart,datasetIndex);this.innerRadius=undefined;this.outerRadius=undefined;} +LineController.id='line';LineController.defaults={datasetElementType:'line',dataElementType:'point',showLine:true,spanGaps:false,};LineController.overrides={scales:{_index_:{type:'category',},_value_:{type:'linear',},}};class PolarAreaController extends DatasetController{constructor(chart,datasetIndex){super(chart,datasetIndex);this.innerRadius=undefined;this.outerRadius=undefined;} getLabelAndValue(index){const meta=this._cachedMeta;const chart=this.chart;const labels=chart.data.labels||[];const value=formatNumber(meta._parsed[index].r,chart.options.locale);return{label:labels[index]||'',value,};} parseObjectData(meta,data,start,count){return _parseObjectDataRadialScale.bind(this)(meta,data,start,count);} update(mode){const arcs=this._cachedMeta.data;this._updateRadius();this.updateElements(arcs,0,arcs.length,mode);} @@ -2187,37 +2190,50 @@ update(mode){const meta=this._cachedMeta;const line=meta.dataset;const points=me const properties={_loop:true,_fullLoop:labels.length===points.length,options};this.updateElement(line,undefined,properties,mode);} this.updateElements(points,0,points.length,mode);} updateElements(points,start,count,mode){const scale=this._cachedMeta.rScale;const reset=mode==='reset';for(let i=start;ipixelMargin){angleMargin=pixelMargin/innerRadius;ctx.arc(x,y,innerRadius,endAngle+angleMargin,startAngle-angleMargin,true);}else{ctx.arc(x,y,pixelMargin,endAngle+HALF_PI,startAngle-HALF_PI);} +RadarController.id='radar';RadarController.defaults={datasetElementType:'line',dataElementType:'point',indexAxis:'r',showLine:true,elements:{line:{fill:'start'}},};RadarController.overrides={aspectRatio:1,scales:{r:{type:'radialLinear',}}};class ScatterController extends DatasetController{update(mode){const meta=this._cachedMeta;const{data:points=[]}=meta;const animationsDisabled=this.chart._animationsDisabled;let{start,count}=_getStartAndCountOfVisiblePoints(meta,points,animationsDisabled);this._drawStart=start;this._drawCount=count;if(_scaleRangesChanged(meta)){start=0;count=points.length;} +if(this.options.showLine){const{dataset:line,_dataset}=meta;line._chart=this.chart;line._datasetIndex=this.index;line._decimated=!!_dataset._decimated;line.points=points;const options=this.resolveDatasetElementOptions(mode);options.segment=this.options.segment;this.updateElement(line,undefined,{animated:!animationsDisabled,options},mode);} +this.updateElements(points,start,count,mode);} +addElements(){const{showLine}=this.options;if(!this.datasetElementType&&showLine){this.datasetElementType=registry.getElement('line');} +super.addElements();} +updateElements(points,start,count,mode){const reset=mode==='reset';const{iScale,vScale,_stacked,_dataset}=this._cachedMeta;const firstOpts=this.resolveDataElementOptions(start,mode);const sharedOptions=this.getSharedOptions(firstOpts);const includeOptions=this.includeOptions(mode,sharedOptions);const iAxis=iScale.axis;const vAxis=vScale.axis;const{spanGaps,segment}=this.options;const maxGapLength=isNumber(spanGaps)?spanGaps:Number.POSITIVE_INFINITY;const directUpdate=this.chart._animationsDisabled||reset||mode==='none';let prevParsed=start>0&&this.getParsed(start-1);for(let i=start;i0&&(Math.abs(parsed[iAxis]-prevParsed[iAxis]))>maxGapLength;if(segment){properties.parsed=parsed;properties.raw=_dataset.data[i];} +if(includeOptions){properties.options=sharedOptions||this.resolveDataElementOptions(i,point.active?'active':mode);} +if(!directUpdate){this.updateElement(point,i,properties,mode);} +prevParsed=parsed;} +this.updateSharedOptions(sharedOptions,mode,firstOpts);} +getMaxOverflow(){const meta=this._cachedMeta;const data=meta.data||[];if(!this.options.showLine){let max=0;for(let i=data.length-1;i>=0;--i){max=Math.max(max,data[i].size(this.resolveDataElementOptions(i))/2);} +return max>0&&max;} +const dataset=meta.dataset;const border=dataset.options&&dataset.options.borderWidth||0;if(!data.length){return border;} +const firstPoint=data[0].size(this.resolveDataElementOptions(0));const lastPoint=data[data.length-1].size(this.resolveDataElementOptions(data.length-1));return Math.max(border,firstPoint,lastPoint)/2;}} +ScatterController.id='scatter';ScatterController.defaults={datasetElementType:false,dataElementType:'point',showLine:false,fill:false};ScatterController.overrides={interaction:{mode:'point'},plugins:{tooltip:{callbacks:{title(){return'';},label(item){return'('+item.label+', '+item.formattedValue+')';}}}},scales:{x:{type:'linear'},y:{type:'linear'}}};var controllers=Object.freeze({__proto__:null,BarController:BarController,BubbleController:BubbleController,DoughnutController:DoughnutController,LineController:LineController,PolarAreaController:PolarAreaController,PieController:PieController,RadarController:RadarController,ScatterController:ScatterController});function clipArc(ctx,element,endAngle){const{startAngle,pixelMargin,x,y,outerRadius,innerRadius}=element;let angleMargin=pixelMargin/outerRadius;ctx.beginPath();ctx.arc(x,y,outerRadius,startAngle-angleMargin,endAngle+angleMargin);if(innerRadius>pixelMargin){angleMargin=pixelMargin/innerRadius;ctx.arc(x,y,innerRadius,endAngle+angleMargin,startAngle-angleMargin,true);}else{ctx.arc(x,y,pixelMargin,endAngle+HALF_PI,startAngle-HALF_PI);} ctx.closePath();ctx.clip();} function toRadiusCorners(value){return _readValueToProps(value,['outerStart','outerEnd','innerStart','innerEnd']);} function parseBorderRadius$1(arc,innerRadius,outerRadius,angleDelta){const o=toRadiusCorners(arc.options.borderRadius);const halfThickness=(outerRadius-innerRadius)/2;const innerLimit=Math.min(halfThickness,angleDelta*innerRadius/2);const computeOuterLimit=(val)=>{const outerArcLimit=(outerRadius-Math.min(halfThickness,val))*angleDelta/2;return _limitValue(val,0,Math.min(halfThickness,outerArcLimit));};return{outerStart:computeOuterLimit(o.outerStart),outerEnd:computeOuterLimit(o.outerEnd),innerStart:_limitValue(o.innerStart,0,innerLimit),innerEnd:_limitValue(o.innerEnd,0,innerLimit),};} function rThetaToXY(r,theta,x,y){return{x:x+r*Math.cos(theta),y:y+r*Math.sin(theta),};} -function pathArc(ctx,element,offset,spacing,end){const{x,y,startAngle:start,pixelMargin,innerRadius:innerR}=element;const outerRadius=Math.max(element.outerRadius+spacing+offset-pixelMargin,0);const innerRadius=innerR>0?innerR+spacing+offset+pixelMargin:0;let spacingOffset=0;const alpha=end-start;if(spacing){const noSpacingInnerRadius=innerR>0?innerR-spacing:0;const noSpacingOuterRadius=outerRadius>0?outerRadius-spacing:0;const avNogSpacingRadius=(noSpacingInnerRadius+noSpacingOuterRadius)/2;const adjustedAngle=avNogSpacingRadius!==0?(alpha*avNogSpacingRadius)/(avNogSpacingRadius+spacing):alpha;spacingOffset=(alpha-adjustedAngle)/2;} -const beta=Math.max(0.001,alpha*outerRadius-offset/PI)/outerRadius;const angleOffset=(alpha-beta)/2;const startAngle=start+angleOffset+spacingOffset;const endAngle=end-angleOffset-spacingOffset;const{outerStart,outerEnd,innerStart,innerEnd}=parseBorderRadius$1(element,innerRadius,outerRadius,endAngle-startAngle);const outerStartAdjustedRadius=outerRadius-outerStart;const outerEndAdjustedRadius=outerRadius-outerEnd;const outerStartAdjustedAngle=startAngle+outerStart/outerStartAdjustedRadius;const outerEndAdjustedAngle=endAngle-outerEnd/outerEndAdjustedRadius;const innerStartAdjustedRadius=innerRadius+innerStart;const innerEndAdjustedRadius=innerRadius+innerEnd;const innerStartAdjustedAngle=startAngle+innerStart/innerStartAdjustedRadius;const innerEndAdjustedAngle=endAngle-innerEnd/innerEndAdjustedRadius;ctx.beginPath();ctx.arc(x,y,outerRadius,outerStartAdjustedAngle,outerEndAdjustedAngle);if(outerEnd>0){const pCenter=rThetaToXY(outerEndAdjustedRadius,outerEndAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,outerEnd,outerEndAdjustedAngle,endAngle+HALF_PI);} +function pathArc(ctx,element,offset,spacing,end,circular){const{x,y,startAngle:start,pixelMargin,innerRadius:innerR}=element;const outerRadius=Math.max(element.outerRadius+spacing+offset-pixelMargin,0);const innerRadius=innerR>0?innerR+spacing+offset+pixelMargin:0;let spacingOffset=0;const alpha=end-start;if(spacing){const noSpacingInnerRadius=innerR>0?innerR-spacing:0;const noSpacingOuterRadius=outerRadius>0?outerRadius-spacing:0;const avNogSpacingRadius=(noSpacingInnerRadius+noSpacingOuterRadius)/2;const adjustedAngle=avNogSpacingRadius!==0?(alpha*avNogSpacingRadius)/(avNogSpacingRadius+spacing):alpha;spacingOffset=(alpha-adjustedAngle)/2;} +const beta=Math.max(0.001,alpha*outerRadius-offset/PI)/outerRadius;const angleOffset=(alpha-beta)/2;const startAngle=start+angleOffset+spacingOffset;const endAngle=end-angleOffset-spacingOffset;const{outerStart,outerEnd,innerStart,innerEnd}=parseBorderRadius$1(element,innerRadius,outerRadius,endAngle-startAngle);const outerStartAdjustedRadius=outerRadius-outerStart;const outerEndAdjustedRadius=outerRadius-outerEnd;const outerStartAdjustedAngle=startAngle+outerStart/outerStartAdjustedRadius;const outerEndAdjustedAngle=endAngle-outerEnd/outerEndAdjustedRadius;const innerStartAdjustedRadius=innerRadius+innerStart;const innerEndAdjustedRadius=innerRadius+innerEnd;const innerStartAdjustedAngle=startAngle+innerStart/innerStartAdjustedRadius;const innerEndAdjustedAngle=endAngle-innerEnd/innerEndAdjustedRadius;ctx.beginPath();if(circular){ctx.arc(x,y,outerRadius,outerStartAdjustedAngle,outerEndAdjustedAngle);if(outerEnd>0){const pCenter=rThetaToXY(outerEndAdjustedRadius,outerEndAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,outerEnd,outerEndAdjustedAngle,endAngle+HALF_PI);} const p4=rThetaToXY(innerEndAdjustedRadius,endAngle,x,y);ctx.lineTo(p4.x,p4.y);if(innerEnd>0){const pCenter=rThetaToXY(innerEndAdjustedRadius,innerEndAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,innerEnd,endAngle+HALF_PI,innerEndAdjustedAngle+Math.PI);} ctx.arc(x,y,innerRadius,endAngle-(innerEnd/innerRadius),startAngle+(innerStart/innerRadius),true);if(innerStart>0){const pCenter=rThetaToXY(innerStartAdjustedRadius,innerStartAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,innerStart,innerStartAdjustedAngle+Math.PI,startAngle-HALF_PI);} -const p8=rThetaToXY(outerStartAdjustedRadius,startAngle,x,y);ctx.lineTo(p8.x,p8.y);if(outerStart>0){const pCenter=rThetaToXY(outerStartAdjustedRadius,outerStartAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,outerStart,startAngle-HALF_PI,outerStartAdjustedAngle);} +const p8=rThetaToXY(outerStartAdjustedRadius,startAngle,x,y);ctx.lineTo(p8.x,p8.y);if(outerStart>0){const pCenter=rThetaToXY(outerStartAdjustedRadius,outerStartAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,outerStart,startAngle-HALF_PI,outerStartAdjustedAngle);}}else{ctx.moveTo(x,y);const outerStartX=Math.cos(outerStartAdjustedAngle)*outerRadius+x;const outerStartY=Math.sin(outerStartAdjustedAngle)*outerRadius+y;ctx.lineTo(outerStartX,outerStartY);const outerEndX=Math.cos(outerEndAdjustedAngle)*outerRadius+x;const outerEndY=Math.sin(outerEndAdjustedAngle)*outerRadius+y;ctx.lineTo(outerEndX,outerEndY);} ctx.closePath();} -function drawArc(ctx,element,offset,spacing){const{fullCircles,startAngle,circumference}=element;let endAngle=element.endAngle;if(fullCircles){pathArc(ctx,element,offset,spacing,startAngle+TAU);for(let i=0;i=TAU||_angleBetween(angle,startAngle,endAngle);const withinRadius=_isBetween(distance,innerRadius+rAdjust,outerRadius+rAdjust);return(betweenAngles&&withinRadius);} getCenterPoint(useFinalPosition){const{x,y,startAngle,endAngle,innerRadius,outerRadius}=this.getProps(['x','y','startAngle','endAngle','innerRadius','outerRadius','circumference',],useFinalPosition);const{offset,spacing}=this.options;const halfAngle=(startAngle+endAngle)/2;const halfRadius=(innerRadius+outerRadius+spacing+offset)/2;return{x:x+Math.cos(halfAngle)*halfRadius,y:y+Math.sin(halfAngle)*halfRadius};} tooltipPosition(useFinalPosition){return this.getCenterPoint(useFinalPosition);} -draw(ctx){const{options,circumference}=this;const offset=(options.offset||0)/2;const spacing=(options.spacing||0)/2;this.pixelMargin=(options.borderAlign==='inner')?0.33:0;this.fullCircles=circumference>TAU?Math.floor(circumference/TAU):0;if(circumference===0||this.innerRadius<0||this.outerRadius<0){return;} +draw(ctx){const{options,circumference}=this;const offset=(options.offset||0)/2;const spacing=(options.spacing||0)/2;const circular=options.circular;this.pixelMargin=(options.borderAlign==='inner')?0.33:0;this.fullCircles=circumference>TAU?Math.floor(circumference/TAU):0;if(circumference===0||this.innerRadius<0||this.outerRadius<0){return;} ctx.save();let radiusOffset=0;if(offset){radiusOffset=offset/2;const halfAngle=(this.startAngle+this.endAngle)/2;ctx.translate(Math.cos(halfAngle)*radiusOffset,Math.sin(halfAngle)*radiusOffset);if(this.circumference>=PI){radiusOffset=offset;}} -ctx.fillStyle=options.backgroundColor;ctx.strokeStyle=options.borderColor;const endAngle=drawArc(ctx,this,radiusOffset,spacing);drawBorder(ctx,this,radiusOffset,spacing,endAngle);ctx.restore();}} -ArcElement.id='arc';ArcElement.defaults={borderAlign:'center',borderColor:'#fff',borderJoinStyle:undefined,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:undefined,};ArcElement.defaultRoutes={backgroundColor:'backgroundColor'};function setStyle(ctx,options,style=options){ctx.lineCap=valueOrDefault(style.borderCapStyle,options.borderCapStyle);ctx.setLineDash(valueOrDefault(style.borderDash,options.borderDash));ctx.lineDashOffset=valueOrDefault(style.borderDashOffset,options.borderDashOffset);ctx.lineJoin=valueOrDefault(style.borderJoinStyle,options.borderJoinStyle);ctx.lineWidth=valueOrDefault(style.borderWidth,options.borderWidth);ctx.strokeStyle=valueOrDefault(style.borderColor,options.borderColor);} +ctx.fillStyle=options.backgroundColor;ctx.strokeStyle=options.borderColor;const endAngle=drawArc(ctx,this,radiusOffset,spacing,circular);drawBorder(ctx,this,radiusOffset,spacing,endAngle,circular);ctx.restore();}} +ArcElement.id='arc';ArcElement.defaults={borderAlign:'center',borderColor:'#fff',borderJoinStyle:undefined,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:undefined,circular:true,};ArcElement.defaultRoutes={backgroundColor:'backgroundColor'};function setStyle(ctx,options,style=options){ctx.lineCap=valueOrDefault(style.borderCapStyle,options.borderCapStyle);ctx.setLineDash(valueOrDefault(style.borderDash,options.borderDash));ctx.lineDashOffset=valueOrDefault(style.borderDashOffset,options.borderDashOffset);ctx.lineJoin=valueOrDefault(style.borderJoinStyle,options.borderJoinStyle);ctx.lineWidth=valueOrDefault(style.borderWidth,options.borderWidth);ctx.strokeStyle=valueOrDefault(style.borderColor,options.borderColor);} function lineTo(ctx,previous,target){ctx.lineTo(target.x,target.y);} function getLineMethod(options){if(options.stepped){return _steppedLineTo;} if(options.tension||options.cubicInterpolationMode==='monotone'){return _bezierCurveTo;} @@ -2411,7 +2427,7 @@ hitbox.top=top;hitbox.left+=this.left+padding;hitbox.left=rtlHelper.leftForLtr(r isHorizontal(){return this.options.position==='top'||this.options.position==='bottom';} draw(){if(this.options.display){const ctx=this.ctx;clipArea(ctx,this);this._draw();unclipArea(ctx);}} _draw(){const{options:opts,columnSizes,lineWidths,ctx}=this;const{align,labels:labelOpts}=opts;const defaultColor=defaults.color;const rtlHelper=getRtlAdapter(opts.rtl,this.left,this.width);const labelFont=toFont(labelOpts.font);const{color:fontColor,padding}=labelOpts;const fontSize=labelFont.size;const halfFontSize=fontSize/2;let cursor;this.drawTitle();ctx.textAlign=rtlHelper.textAlign('left');ctx.textBaseline='middle';ctx.lineWidth=0.5;ctx.font=labelFont.string;const{boxWidth,boxHeight,itemHeight}=getBoxSize(labelOpts,fontSize);const drawLegendBox=function(x,y,legendItem){if(isNaN(boxWidth)||boxWidth<=0||isNaN(boxHeight)||boxHeight<0){return;} -ctx.save();const lineWidth=valueOrDefault(legendItem.lineWidth,1);ctx.fillStyle=valueOrDefault(legendItem.fillStyle,defaultColor);ctx.lineCap=valueOrDefault(legendItem.lineCap,'butt');ctx.lineDashOffset=valueOrDefault(legendItem.lineDashOffset,0);ctx.lineJoin=valueOrDefault(legendItem.lineJoin,'miter');ctx.lineWidth=lineWidth;ctx.strokeStyle=valueOrDefault(legendItem.strokeStyle,defaultColor);ctx.setLineDash(valueOrDefault(legendItem.lineDash,[]));if(labelOpts.usePointStyle){const drawOptions={radius:boxHeight*Math.SQRT2/2,pointStyle:legendItem.pointStyle,rotation:legendItem.rotation,borderWidth:lineWidth};const centerX=rtlHelper.xPlus(x,boxWidth/2);const centerY=y+halfFontSize;drawPointLegend(ctx,drawOptions,centerX,centerY,boxWidth);}else{const yBoxTop=y+Math.max((fontSize-boxHeight)/2,0);const xBoxLeft=rtlHelper.leftForLtr(x,boxWidth);const borderRadius=toTRBLCorners(legendItem.borderRadius);ctx.beginPath();if(Object.values(borderRadius).some(v=>v!==0)){addRoundedRectPath(ctx,{x:xBoxLeft,y:yBoxTop,w:boxWidth,h:boxHeight,radius:borderRadius,});}else{ctx.rect(xBoxLeft,yBoxTop,boxWidth,boxHeight);} +ctx.save();const lineWidth=valueOrDefault(legendItem.lineWidth,1);ctx.fillStyle=valueOrDefault(legendItem.fillStyle,defaultColor);ctx.lineCap=valueOrDefault(legendItem.lineCap,'butt');ctx.lineDashOffset=valueOrDefault(legendItem.lineDashOffset,0);ctx.lineJoin=valueOrDefault(legendItem.lineJoin,'miter');ctx.lineWidth=lineWidth;ctx.strokeStyle=valueOrDefault(legendItem.strokeStyle,defaultColor);ctx.setLineDash(valueOrDefault(legendItem.lineDash,[]));if(labelOpts.usePointStyle){const drawOptions={radius:boxHeight*Math.SQRT2/2,pointStyle:legendItem.pointStyle,rotation:legendItem.rotation,borderWidth:lineWidth};const centerX=rtlHelper.xPlus(x,boxWidth/2);const centerY=y+halfFontSize;drawPointLegend(ctx,drawOptions,centerX,centerY,labelOpts.pointStyleWidth&&boxWidth);}else{const yBoxTop=y+Math.max((fontSize-boxHeight)/2,0);const xBoxLeft=rtlHelper.leftForLtr(x,boxWidth);const borderRadius=toTRBLCorners(legendItem.borderRadius);ctx.beginPath();if(Object.values(borderRadius).some(v=>v!==0)){addRoundedRectPath(ctx,{x:xBoxLeft,y:yBoxTop,w:boxWidth,h:boxHeight,radius:borderRadius,});}else{ctx.rect(xBoxLeft,yBoxTop,boxWidth,boxHeight);} ctx.fill();if(lineWidth!==0){ctx.stroke();}} ctx.restore();};const fillText=function(x,y,legendItem){renderText(ctx,legendItem.text,x,y+(itemHeight/2),labelFont,{strikethrough:legendItem.hidden,textAlign:rtlHelper.textAlign(legendItem.textAlign)});};const isHorizontal=this.isHorizontal();const titleHeight=this._computeTitleHeight();if(isHorizontal){cursor={x:_alignStartEnd(align,this.left+padding,this.right-lineWidths[0]),y:this.top+padding+titleHeight,line:0};}else{cursor={x:this.left+padding,y:_alignStartEnd(align,this.top+titleHeight+padding,this.bottom-columnSizes[0].height),line:0};} overrideTextDirection(this.ctx,opts.textDirection);const lineHeight=itemHeight+padding;this.legendItems.forEach((legendItem,i)=>{ctx.strokeStyle=legendItem.fontColor||fontColor;ctx.fillStyle=legendItem.fontColor||fontColor;const textWidth=ctx.measureText(legendItem.text).width;const textAlign=rtlHelper.textAlign(legendItem.textAlign||(legendItem.textAlign=labelOpts.textAlign));const width=boxWidth+halfFontSize+textWidth;let x=cursor.x;let y=cursor.y;rtlHelper.setWidth(this.width);if(isHorizontal){if(i>0&&x+width+padding>this.right){y=cursor.y+=lineHeight;cursor.line++;x=cursor.x=_alignStartEnd(align,this.left+padding,this.right-lineWidths[cursor.line]);}}else if(i>0&&y+lineHeight>this.bottom){x=cursor.x=x+columnSizes[cursor.line].width+padding;cursor.line++;y=cursor.y=_alignStartEnd(align,this.top+titleHeight+padding,this.bottom-columnSizes[cursor.line].height);} @@ -2683,7 +2699,7 @@ return ticks;} function ticksFromTimestamps(scale,values,majorUnit){const ticks=[];const map={};const ilen=values.length;let i,value;for(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} userId - * @param {string} email - * @param {string} password - * @param {string} name - * @throws {AppwriteException} - * @returns {Promise} - */ - create: (userId, email, password, name) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof email === 'undefined') { - throw new AppwriteException('Missing required parameter: "email"'); - } - if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); - } - let path = '/account'; - let payload = {}; - if (typeof userId !== 'undefined') { - payload['userId'] = userId; - } - 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); - }), - /** - * Update Account Email - * - * Update currently logged in user account email address. After changing user - * address, the user confirmation status will get reset. A new confirmation - * email is not sent automatically however you can use the send confirmation - * email endpoint again to send the confirmation email. 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 (typeof email === 'undefined') { - throw new AppwriteException('Missing required parameter: "email"'); - } - if (typeof 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 in that time - * frame. - * - * @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. - * - * @param {number} limit - * @param {number} offset - * @throws {AppwriteException} - * @returns {Promise} - */ - getLogs: (limit, offset) => __awaiter(this, void 0, void 0, function* () { - let path = '/account/logs'; - let payload = {}; - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - 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 (typeof 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, Team Invites and Magic URL, oldPassword is optional. - * - * @param {string} password - * @param {string} oldPassword - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePassword: (password, oldPassword) => __awaiter(this, void 0, void 0, function* () { - if (typeof 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); - }), - /** - * Update Account Phone - * - * Update currently logged in user account phone number. After changing phone - * number, the user confirmation status will get reset. A new confirmation SMS - * is not sent automatically however you can use the phone confirmation - * endpoint again to send the confirmation SMS. - * - * @param {string} number - * @param {string} password - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePhone: (number, password) => __awaiter(this, void 0, void 0, function* () { - if (typeof number === 'undefined') { - throw new AppwriteException('Missing required parameter: "number"'); - } - if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); - } - let path = '/account/phone'; - let payload = {}; - if (typeof number !== 'undefined') { - payload['number'] = number; - } - 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); - }), - /** - * 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. The object you pass is - * stored as is, and replaces any previous value. The maximum allowed prefs - * size is 64kB and throws error if exceeded. - * - * @param {object} prefs - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePrefs: (prefs) => __awaiter(this, void 0, void 0, function* () { - if (typeof 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 (typeof email === 'undefined') { - throw new AppwriteException('Missing required parameter: "email"'); - } - if (typeof 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); - }), - /** - * Create Password Recovery (confirmation) - * - * 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 (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof secret === 'undefined') { - throw new AppwriteException('Missing required parameter: "secret"'); - } - if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); - } - if (typeof 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); - }), - /** - * 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, you - * need to update its [email and - * password](/docs/client/account#accountUpdateEmail) or create an [OAuth2 - * session](/docs/client/account#accountCreateOAuth2Session). - * - * @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 Email - * - * 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} - */ - createEmailSession: (email, password) => __awaiter(this, void 0, void 0, function* () { - if (typeof email === 'undefined') { - throw new AppwriteException('Missing required parameter: "email"'); - } - if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); - } - let path = '/account/sessions/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('post', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create Magic URL session - * - * Sends the user an email with a secret key for creating a session. When the - * user clicks the link in the email, the user is redirected back to the URL - * you provided with the secret key and userId values attached to the URL - * query string. Use the query string parameters to submit a request to the - * [PUT - * /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession) - * endpoint to complete the login process. The link sent to the user's email - * address is valid for 1 hour. If you are on a mobile device you can leave - * the URL parameter empty, so that the login completion will be handled by - * your Appwrite instance by default. - * - * @param {string} userId - * @param {string} email - * @param {string} url - * @throws {AppwriteException} - * @returns {Promise} - */ - createMagicURLSession: (userId, email, url) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof email === 'undefined') { - throw new AppwriteException('Missing required parameter: "email"'); - } - let path = '/account/sessions/magic-url'; - let payload = {}; - if (typeof userId !== 'undefined') { - payload['userId'] = userId; - } - 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); - }), - /** - * Create Magic URL session (confirmation) - * - * Use this endpoint to complete creating the session with the Magic URL. 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/sessions/magic-url](/docs/client/account#accountCreateMagicURLSession) - * 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 - * @throws {AppwriteException} - * @returns {Promise} - */ - updateMagicURLSession: (userId, secret) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof secret === 'undefined') { - throw new AppwriteException('Missing required parameter: "secret"'); - } - let path = '/account/sessions/magic-url'; - 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); - }), - /** - * 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. - * - * If there is already an active session, the new session will be attached to - * the logged-in account. If there are no active sessions, the server will - * attempt to look for a user with the same email address as the email - * received from the OAuth2 provider and attach the new session to the - * existing user. If no matching user is found - the server will create a new - * user.. - * - * - * @param {string} provider - * @param {string} success - * @param {string} failure - * @param {string[]} scopes - * @throws {AppwriteException} - * @returns {void|string} - */ - createOAuth2Session: (provider, success, failure, scopes) => { - if (typeof provider === 'undefined') { - throw new AppwriteException('Missing required parameter: "provider"'); - } - let path = '/account/sessions/oauth2/{provider}'.replace('{provider}', provider); - let payload = {}; - if (typeof success !== 'undefined') { - payload['success'] = success; - } - if (typeof failure !== 'undefined') { - payload['failure'] = failure; - } - if (typeof scopes !== 'undefined') { - 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; - } - }, - /** - * Create Phone session - * - * Sends the user a SMS with a secret key for creating a session. Use the - * returned user ID and the secret to submit a request to the [PUT - * /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession) - * endpoint to complete the login process. The secret sent to the user's phone - * is valid for 15 minutes. - * - * @param {string} userId - * @param {string} number - * @throws {AppwriteException} - * @returns {Promise} - */ - createPhoneSession: (userId, number) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof number === 'undefined') { - throw new AppwriteException('Missing required parameter: "number"'); - } - let path = '/account/sessions/phone'; - let payload = {}; - if (typeof userId !== 'undefined') { - payload['userId'] = userId; - } - if (typeof number !== 'undefined') { - payload['number'] = number; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('post', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create Phone session (confirmation) - * - * Use this endpoint to complete creating the session with the Magic URL. 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/sessions/magic-url](/docs/client/account#accountCreateMagicURLSession) - * 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 - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePhoneSession: (userId, secret) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof secret === 'undefined') { - throw new AppwriteException('Missing required parameter: "secret"'); - } - let path = '/account/sessions/phone'; - 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); - }), - /** - * Get Session By ID - * - * Use this endpoint to get a logged in user's session using a Session ID. - * Inputting 'current' will return the current session being used. - * - * @param {string} sessionId - * @throws {AppwriteException} - * @returns {Promise} - */ - getSession: (sessionId) => __awaiter(this, void 0, void 0, function* () { - if (typeof 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('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Update Session (Refresh Tokens) - * - * Access tokens have limited lifespan and expire to mitigate security risks. - * If session was created using an OAuth provider, this route can be used to - * "refresh" the access token. - * - * @param {string} sessionId - * @throws {AppwriteException} - * @returns {Promise} - */ - updateSession: (sessionId) => __awaiter(this, void 0, void 0, function* () { - if (typeof 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('patch', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * 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 - * Session ID argument, only the unique session ID provided is deleted. - * - * - * @param {string} sessionId - * @throws {AppwriteException} - * @returns {Promise} - */ - deleteSession: (sessionId) => __awaiter(this, void 0, void 0, function* () { - if (typeof 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); - }), - /** - * Update Account Status - * - * Block the currently logged in user account. Behind the scene, the user - * record is not deleted but permanently blocked from any access. To - * completely delete a user, use the Users API instead. - * - * @throws {AppwriteException} - * @returns {Promise} - */ - updateStatus: () => __awaiter(this, void 0, void 0, function* () { - let path = '/account/status'; - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('patch', 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#accountUpdateEmailVerification). 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 (typeof 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); - }), - /** - * Create Email Verification (confirmation) - * - * 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 (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof 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); - }), - /** - * Create Phone Verification - * - * Use this endpoint to send a verification message to your user's phone - * number to confirm they are the valid owners of that address. The provided - * secret should 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#accountUpdatePhoneVerification). The - * verification link sent to the user's phone number is valid for 15 minutes. - * - * @throws {AppwriteException} - * @returns {Promise} - */ - createPhoneVerification: () => __awaiter(this, void 0, void 0, function* () { - let path = '/account/verification/phone'; - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('post', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create Phone Verification (confirmation) - * - * Use this endpoint to complete the user phone verification process. Use the - * **userId** and **secret** that were sent to your user's phone number 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} - */ - updatePhoneVerification: (userId, secret) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof secret === 'undefined') { - throw new AppwriteException('Missing required parameter: "secret"'); - } - let path = '/account/verification/phone'; - 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 [GET - * /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use - * width, height and quality arguments to change the output settings. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 100x100px. - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {AppwriteException} - * @returns {URL} - */ - getBrowser: (code, width, height, quality) => { - if (typeof code === 'undefined') { - throw new AppwriteException('Missing required parameter: "code"'); - } - let path = '/avatars/browsers/{code}'.replace('{code}', code); - let payload = {}; - if (typeof width !== 'undefined') { - payload['width'] = width; - } - if (typeof height !== 'undefined') { - payload['height'] = height; - } - if (typeof quality !== 'undefined') { - 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. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 100x100px. - * - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {AppwriteException} - * @returns {URL} - */ - getCreditCard: (code, width, height, quality) => { - if (typeof code === 'undefined') { - throw new AppwriteException('Missing required parameter: "code"'); - } - let path = '/avatars/credit-cards/{code}'.replace('{code}', code); - let payload = {}; - if (typeof width !== 'undefined') { - payload['width'] = width; - } - if (typeof height !== 'undefined') { - payload['height'] = height; - } - if (typeof quality !== 'undefined') { - 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 (typeof url === 'undefined') { - throw new AppwriteException('Missing required parameter: "url"'); - } - let path = '/avatars/favicon'; - let payload = {}; - if (typeof url !== 'undefined') { - 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. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 100x100px. - * - * - * @param {string} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {AppwriteException} - * @returns {URL} - */ - getFlag: (code, width, height, quality) => { - if (typeof code === 'undefined') { - throw new AppwriteException('Missing required parameter: "code"'); - } - let path = '/avatars/flags/{code}'.replace('{code}', code); - let payload = {}; - if (typeof width !== 'undefined') { - payload['width'] = width; - } - if (typeof height !== 'undefined') { - payload['height'] = height; - } - if (typeof quality !== 'undefined') { - 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. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 400x400px. - * - * - * @param {string} url - * @param {number} width - * @param {number} height - * @throws {AppwriteException} - * @returns {URL} - */ - getImage: (url, width, height) => { - if (typeof url === 'undefined') { - throw new AppwriteException('Missing required parameter: "url"'); - } - let path = '/avatars/image'; - let payload = {}; - if (typeof url !== 'undefined') { - payload['url'] = url; - } - if (typeof width !== 'undefined') { - payload['width'] = width; - } - if (typeof height !== 'undefined') { - 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. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 100x100px. - * - * - * @param {string} name - * @param {number} width - * @param {number} height - * @param {string} color - * @param {string} background - * @throws {AppwriteException} - * @returns {URL} - */ - getInitials: (name, width, height, color, background) => { - let path = '/avatars/initials'; - let payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof width !== 'undefined') { - payload['width'] = width; - } - if (typeof height !== 'undefined') { - payload['height'] = height; - } - if (typeof color !== 'undefined') { - payload['color'] = color; - } - if (typeof background !== 'undefined') { - 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, margin, download) => { - if (typeof text === 'undefined') { - throw new AppwriteException('Missing required parameter: "text"'); - } - let path = '/avatars/qr'; - let payload = {}; - if (typeof text !== 'undefined') { - payload['text'] = text; - } - if (typeof size !== 'undefined') { - payload['size'] = size; - } - if (typeof margin !== 'undefined') { - payload['margin'] = margin; - } - if (typeof download !== 'undefined') { - 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.databases = { - /** - * List Databases - * - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} cursor - * @param {string} cursorDirection - * @param {string} orderType - * @throws {AppwriteException} - * @returns {Promise} - */ - list: (search, limit, offset, cursor, cursorDirection, orderType) => __awaiter(this, void 0, void 0, function* () { - let path = '/databases'; - let payload = {}; - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - if (typeof cursor !== 'undefined') { - payload['cursor'] = cursor; - } - if (typeof cursorDirection !== 'undefined') { - payload['cursorDirection'] = cursorDirection; - } - if (typeof orderType !== 'undefined') { - payload['orderType'] = orderType; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create Database - * - * - * @param {string} databaseId - * @param {string} name - * @throws {AppwriteException} - * @returns {Promise} - */ - create: (databaseId, name) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - let path = '/databases'; - let payload = {}; - if (typeof databaseId !== 'undefined') { - payload['databaseId'] = databaseId; - } - 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 usage stats for the database - * - * - * @param {string} range - * @throws {AppwriteException} - * @returns {Promise} - */ - getUsage: (range) => __awaiter(this, void 0, void 0, function* () { - let path = '/databases/usage'; - let payload = {}; - if (typeof range !== 'undefined') { - payload['range'] = range; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Get Database - * - * - * @param {string} databaseId - * @throws {AppwriteException} - * @returns {Promise} - */ - get: (databaseId) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Update Database - * - * - * @param {string} databaseId - * @param {string} name - * @throws {AppwriteException} - * @returns {Promise} - */ - update: (databaseId, name) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId); - 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 Database - * - * - * @param {string} databaseId - * @throws {AppwriteException} - * @returns {Promise} - */ - delete: (databaseId) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('delete', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * 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} databaseId - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} cursor - * @param {string} cursorDirection - * @param {string} orderType - * @throws {AppwriteException} - * @returns {Promise} - */ - listCollections: (databaseId, search, limit, offset, cursor, cursorDirection, orderType) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - let path = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId); - let payload = {}; - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - if (typeof cursor !== 'undefined') { - payload['cursor'] = cursor; - } - if (typeof cursorDirection !== 'undefined') { - payload['cursorDirection'] = cursorDirection; - } - if (typeof orderType !== 'undefined') { - 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} databaseId - * @param {string} collectionId - * @param {string} name - * @param {string} permission - * @param {string[]} read - * @param {string[]} write - * @throws {AppwriteException} - * @returns {Promise} - */ - createCollection: (databaseId, collectionId, name, permission, read, write) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof permission === 'undefined') { - throw new AppwriteException('Missing required parameter: "permission"'); - } - if (typeof read === 'undefined') { - throw new AppwriteException('Missing required parameter: "read"'); - } - if (typeof write === 'undefined') { - throw new AppwriteException('Missing required parameter: "write"'); - } - let path = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId); - let payload = {}; - if (typeof collectionId !== 'undefined') { - payload['collectionId'] = collectionId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof permission !== 'undefined') { - payload['permission'] = permission; - } - 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': '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} databaseId - * @param {string} collectionId - * @throws {AppwriteException} - * @returns {Promise} - */ - getCollection: (databaseId, collectionId) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).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} databaseId - * @param {string} collectionId - * @param {string} name - * @param {string} permission - * @param {string[]} read - * @param {string[]} write - * @param {boolean} enabled - * @throws {AppwriteException} - * @returns {Promise} - */ - updateCollection: (databaseId, collectionId, name, permission, read, write, enabled) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof permission === 'undefined') { - throw new AppwriteException('Missing required parameter: "permission"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof permission !== 'undefined') { - payload['permission'] = permission; - } - if (typeof read !== 'undefined') { - payload['read'] = read; - } - if (typeof write !== 'undefined') { - payload['write'] = write; - } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } - 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} databaseId - * @param {string} collectionId - * @throws {AppwriteException} - * @returns {Promise} - */ - deleteCollection: (databaseId, collectionId) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).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 Attributes - * - * - * @param {string} databaseId - * @param {string} collectionId - * @throws {AppwriteException} - * @returns {Promise} - */ - listAttributes: (databaseId, collectionId) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create Boolean Attribute - * - * Create a boolean attribute. - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {boolean} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - createBooleanAttribute: (databaseId, collectionId, key, required, xdefault, array) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('post', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create Email Attribute - * - * Create an email attribute. - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - createEmailAttribute: (databaseId, collectionId, key, required, xdefault, array) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('post', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create Enum Attribute - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {string[]} elements - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - createEnumAttribute: (databaseId, collectionId, key, elements, required, xdefault, array) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - if (typeof elements === 'undefined') { - throw new AppwriteException('Missing required parameter: "elements"'); - } - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof elements !== 'undefined') { - payload['elements'] = elements; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('post', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create Float Attribute - * - * Create a float attribute. Optionally, minimum and maximum values can be - * provided. - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {number} min - * @param {number} max - * @param {number} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - createFloatAttribute: (databaseId, collectionId, key, required, min, max, xdefault, array) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof min !== 'undefined') { - payload['min'] = min; - } - if (typeof max !== 'undefined') { - payload['max'] = max; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('post', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create Integer Attribute - * - * Create an integer attribute. Optionally, minimum and maximum values can be - * provided. - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {number} min - * @param {number} max - * @param {number} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - createIntegerAttribute: (databaseId, collectionId, key, required, min, max, xdefault, array) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof min !== 'undefined') { - payload['min'] = min; - } - if (typeof max !== 'undefined') { - payload['max'] = max; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('post', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create IP Address Attribute - * - * Create IP address attribute. - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - createIpAttribute: (databaseId, collectionId, key, required, xdefault, array) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('post', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create String Attribute - * - * Create a string attribute. - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {number} size - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - createStringAttribute: (databaseId, collectionId, key, size, required, xdefault, array) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - if (typeof size === 'undefined') { - throw new AppwriteException('Missing required parameter: "size"'); - } - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof size !== 'undefined') { - payload['size'] = size; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('post', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create URL Attribute - * - * Create a URL attribute. - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {boolean} required - * @param {string} xdefault - * @param {boolean} array - * @throws {AppwriteException} - * @returns {Promise} - */ - createUrlAttribute: (databaseId, collectionId, key, required, xdefault, array) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - if (typeof required === 'undefined') { - throw new AppwriteException('Missing required parameter: "required"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof required !== 'undefined') { - payload['required'] = required; - } - if (typeof xdefault !== 'undefined') { - payload['default'] = xdefault; - } - if (typeof array !== 'undefined') { - payload['array'] = array; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('post', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Get Attribute - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @throws {AppwriteException} - * @returns {Promise} - */ - getAttribute: (databaseId, collectionId, key) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Delete Attribute - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @throws {AppwriteException} - * @returns {Promise} - */ - deleteAttribute: (databaseId, collectionId, key) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - 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} databaseId - * @param {string} collectionId - * @param {string[]} queries - * @param {number} limit - * @param {number} offset - * @param {string} cursor - * @param {string} cursorDirection - * @param {string[]} orderAttributes - * @param {string[]} orderTypes - * @throws {AppwriteException} - * @returns {Promise} - */ - listDocuments: (databaseId, collectionId, queries, limit, offset, cursor, cursorDirection, orderAttributes, orderTypes) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - if (typeof cursor !== 'undefined') { - payload['cursor'] = cursor; - } - if (typeof cursorDirection !== 'undefined') { - payload['cursorDirection'] = cursorDirection; - } - if (typeof orderAttributes !== 'undefined') { - payload['orderAttributes'] = orderAttributes; - } - if (typeof orderTypes !== 'undefined') { - payload['orderTypes'] = orderTypes; - } - 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/databases#databasesCreateCollection) API or - * directly from your database console. - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} documentId - * @param {object} data - * @param {string[]} read - * @param {string[]} write - * @throws {AppwriteException} - * @returns {Promise} - */ - createDocument: (databaseId, collectionId, documentId, data, read, write) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - if (typeof data === 'undefined') { - throw new AppwriteException('Missing required parameter: "data"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof documentId !== 'undefined') { - payload['documentId'] = documentId; - } - 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('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} databaseId - * @param {string} collectionId - * @param {string} documentId - * @throws {AppwriteException} - * @returns {Promise} - */ - getDocument: (databaseId, collectionId, documentId) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).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} databaseId - * @param {string} collectionId - * @param {string} documentId - * @param {object} data - * @param {string[]} read - * @param {string[]} write - * @throws {AppwriteException} - * @returns {Promise} - */ - updateDocument: (databaseId, collectionId, documentId, data, read, write) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - if (typeof data === 'undefined') { - throw new AppwriteException('Missing required parameter: "data"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).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. - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} documentId - * @throws {AppwriteException} - * @returns {Promise} - */ - deleteDocument: (databaseId, collectionId, documentId) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).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); - }), - /** - * List Document Logs - * - * Get the document activity logs list by its unique ID. - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} documentId - * @param {number} limit - * @param {number} offset - * @throws {AppwriteException} - * @returns {Promise} - */ - listDocumentLogs: (databaseId, collectionId, documentId, limit, offset) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/logs'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); - let payload = {}; - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * List Indexes - * - * - * @param {string} databaseId - * @param {string} collectionId - * @throws {AppwriteException} - * @returns {Promise} - */ - listIndexes: (databaseId, collectionId) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create Index - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @param {string} type - * @param {string[]} attributes - * @param {string[]} orders - * @throws {AppwriteException} - * @returns {Promise} - */ - createIndex: (databaseId, collectionId, key, type, attributes, orders) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - if (typeof type === 'undefined') { - throw new AppwriteException('Missing required parameter: "type"'); - } - if (typeof attributes === 'undefined') { - throw new AppwriteException('Missing required parameter: "attributes"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof key !== 'undefined') { - payload['key'] = key; - } - if (typeof type !== 'undefined') { - payload['type'] = type; - } - if (typeof attributes !== 'undefined') { - payload['attributes'] = attributes; - } - if (typeof orders !== 'undefined') { - payload['orders'] = orders; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('post', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Get Index - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @throws {AppwriteException} - * @returns {Promise} - */ - getIndex: (databaseId, collectionId, key) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Delete Index - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} key - * @throws {AppwriteException} - * @returns {Promise} - */ - deleteIndex: (databaseId, collectionId, key) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - if (typeof key === 'undefined') { - throw new AppwriteException('Missing required parameter: "key"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('delete', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * List Collection Logs - * - * Get the collection activity logs list by its unique ID. - * - * @param {string} databaseId - * @param {string} collectionId - * @param {number} limit - * @param {number} offset - * @throws {AppwriteException} - * @returns {Promise} - */ - listCollectionLogs: (databaseId, collectionId, limit, offset) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/logs'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Get usage stats for a collection - * - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} range - * @throws {AppwriteException} - * @returns {Promise} - */ - getCollectionUsage: (databaseId, collectionId, range) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - let path = '/databases/{databaseId}/collections/{collectionId}/usage'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - let payload = {}; - if (typeof range !== 'undefined') { - payload['range'] = range; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * List Collection Logs - * - * Get the collection activity logs list by its unique ID. - * - * @param {string} databaseId - * @param {number} limit - * @param {number} offset - * @throws {AppwriteException} - * @returns {Promise} - */ - listLogs: (databaseId, limit, offset) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - let path = '/databases/{databaseId}/logs'.replace('{databaseId}', databaseId); - let payload = {}; - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Get usage stats for the database - * - * - * @param {string} databaseId - * @param {string} range - * @throws {AppwriteException} - * @returns {Promise} - */ - getDatabaseUsage: (databaseId, range) => __awaiter(this, void 0, void 0, function* () { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - let path = '/databases/{databaseId}/usage'.replace('{databaseId}', databaseId); - let payload = {}; - if (typeof range !== 'undefined') { - payload['range'] = range; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', 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} cursor - * @param {string} cursorDirection - * @param {string} orderType - * @throws {AppwriteException} - * @returns {Promise} - */ - list: (search, limit, offset, cursor, cursorDirection, orderType) => __awaiter(this, void 0, void 0, function* () { - let path = '/functions'; - let payload = {}; - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - if (typeof cursor !== 'undefined') { - payload['cursor'] = cursor; - } - if (typeof cursorDirection !== 'undefined') { - payload['cursorDirection'] = cursorDirection; - } - if (typeof orderType !== 'undefined') { - 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} functionId - * @param {string} name - * @param {string[]} execute - * @param {string} runtime - * @param {object} vars - * @param {string[]} events - * @param {string} schedule - * @param {number} timeout - * @throws {AppwriteException} - * @returns {Promise} - */ - create: (functionId, name, execute, runtime, vars, events, schedule, timeout) => __awaiter(this, void 0, void 0, function* () { - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof execute === 'undefined') { - throw new AppwriteException('Missing required parameter: "execute"'); - } - if (typeof runtime === 'undefined') { - throw new AppwriteException('Missing required parameter: "runtime"'); - } - let path = '/functions'; - let payload = {}; - if (typeof functionId !== 'undefined') { - payload['functionId'] = functionId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof execute !== 'undefined') { - payload['execute'] = execute; - } - if (typeof runtime !== 'undefined') { - payload['runtime'] = runtime; - } - 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); - }), - /** - * List runtimes - * - * Get a list of all runtimes that are currently active on your instance. - * - * @throws {AppwriteException} - * @returns {Promise} - */ - listRuntimes: () => __awaiter(this, void 0, void 0, function* () { - let path = '/functions/runtimes'; - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', 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 (typeof 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) => __awaiter(this, void 0, void 0, function* () { - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof 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 (typeof 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 Deployments - * - * Get a list of all the project's code deployments. You can use the query - * params to filter your results. - * - * @param {string} functionId - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} cursor - * @param {string} cursorDirection - * @param {string} orderType - * @throws {AppwriteException} - * @returns {Promise} - */ - listDeployments: (functionId, search, limit, offset, cursor, cursorDirection, orderType) => __awaiter(this, void 0, void 0, function* () { - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); - let payload = {}; - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - if (typeof cursor !== 'undefined') { - payload['cursor'] = cursor; - } - if (typeof cursorDirection !== 'undefined') { - payload['cursorDirection'] = cursorDirection; - } - if (typeof orderType !== 'undefined') { - payload['orderType'] = orderType; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create Deployment - * - * Create a new function code deployment. 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 deployment to use your new deployment 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} entrypoint - * @param {File} code - * @param {boolean} activate - * @throws {AppwriteException} - * @returns {Promise} - */ - createDeployment: (functionId, entrypoint, code, activate, onProgress = (progress) => { }) => __awaiter(this, void 0, void 0, function* () { - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - if (typeof entrypoint === 'undefined') { - throw new AppwriteException('Missing required parameter: "entrypoint"'); - } - if (typeof code === 'undefined') { - throw new AppwriteException('Missing required parameter: "code"'); - } - if (typeof activate === 'undefined') { - throw new AppwriteException('Missing required parameter: "activate"'); - } - let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); - let payload = {}; - if (typeof entrypoint !== 'undefined') { - payload['entrypoint'] = entrypoint; - } - if (typeof code !== 'undefined') { - payload['code'] = code; - } - if (typeof activate !== 'undefined') { - payload['activate'] = activate; - } - const uri = new URL(this.config.endpoint + path); - if (!(code instanceof File)) { - throw new AppwriteException('Parameter "code" has to be a File.'); - } - const size = code.size; - if (size <= Appwrite.CHUNK_SIZE) { - return yield this.call('post', uri, { - 'content-type': 'multipart/form-data', - }, payload); - } - let id = undefined; - let response = undefined; - const headers = { - 'content-type': 'multipart/form-data', - }; - let counter = 0; - const totalCounters = Math.ceil(size / Appwrite.CHUNK_SIZE); - for (counter; counter < totalCounters; counter++) { - const start = (counter * Appwrite.CHUNK_SIZE); - const end = Math.min((((counter * Appwrite.CHUNK_SIZE) + Appwrite.CHUNK_SIZE) - 1), size); - headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size; - if (id) { - headers['x-appwrite-id'] = id; - } - const stream = code.slice(start, end + 1); - payload['code'] = new File([stream], code.name); - response = yield this.call('post', uri, headers, payload); - if (!id) { - id = response['$id']; - } - if (onProgress) { - onProgress({ - $id: response.$id, - progress: Math.min((counter + 1) * Appwrite.CHUNK_SIZE - 1, size) / size * 100, - sizeUploaded: end, - chunksTotal: response.chunksTotal, - chunksUploaded: response.chunksUploaded - }); - } - } - return response; - }), - /** - * Get Deployment - * - * Get a code deployment by its unique ID. - * - * @param {string} functionId - * @param {string} deploymentId - * @throws {AppwriteException} - * @returns {Promise} - */ - getDeployment: (functionId, deploymentId) => __awaiter(this, void 0, void 0, function* () { - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Update Function Deployment - * - * Update the function code deployment ID using the unique function ID. Use - * this endpoint to switch the code deployment that should be executed by the - * execution endpoint. - * - * @param {string} functionId - * @param {string} deploymentId - * @throws {AppwriteException} - * @returns {Promise} - */ - updateDeployment: (functionId, deploymentId) => __awaiter(this, void 0, void 0, function* () { - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('patch', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Delete Deployment - * - * Delete a code deployment by its unique ID. - * - * @param {string} functionId - * @param {string} deploymentId - * @throws {AppwriteException} - * @returns {Promise} - */ - deleteDeployment: (functionId, deploymentId) => __awaiter(this, void 0, void 0, function* () { - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('delete', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Retry Build - * - * - * @param {string} functionId - * @param {string} deploymentId - * @param {string} buildId - * @throws {AppwriteException} - * @returns {Promise} - */ - retryBuild: (functionId, deploymentId, buildId) => __awaiter(this, void 0, void 0, function* () { - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - if (typeof deploymentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "deploymentId"'); - } - if (typeof buildId === 'undefined') { - throw new AppwriteException('Missing required parameter: "buildId"'); - } - let path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('post', 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 {number} limit - * @param {number} offset - * @param {string} search - * @param {string} cursor - * @param {string} cursorDirection - * @throws {AppwriteException} - * @returns {Promise} - */ - listExecutions: (functionId, limit, offset, search, cursor, cursorDirection) => __awaiter(this, void 0, void 0, function* () { - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId); - let payload = {}; - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof cursor !== 'undefined') { - payload['cursor'] = cursor; - } - if (typeof cursorDirection !== 'undefined') { - payload['cursorDirection'] = cursorDirection; - } - 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 - * @param {boolean} async - * @throws {AppwriteException} - * @returns {Promise} - */ - createExecution: (functionId, data, async) => __awaiter(this, void 0, void 0, function* () { - if (typeof 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; - } - if (typeof async !== 'undefined') { - payload['async'] = async; - } - 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 (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - if (typeof 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); - }), - /** - * Get Function Usage - * - * - * @param {string} functionId - * @param {string} range - * @throws {AppwriteException} - * @returns {Promise} - */ - getUsage: (functionId, range) => __awaiter(this, void 0, void 0, function* () { - if (typeof functionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "functionId"'); - } - let path = '/functions/{functionId}/usage'.replace('{functionId}', functionId); - let payload = {}; - if (typeof range !== 'undefined') { - 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 Antivirus - * - * Check the Appwrite Antivirus 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 Certificates 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 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} cursor - * @param {string} cursorDirection - * @param {string} orderType - * @throws {AppwriteException} - * @returns {Promise} - */ - list: (search, limit, offset, cursor, cursorDirection, orderType) => __awaiter(this, void 0, void 0, function* () { - let path = '/projects'; - let payload = {}; - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - if (typeof cursor !== 'undefined') { - payload['cursor'] = cursor; - } - if (typeof cursorDirection !== 'undefined') { - payload['cursorDirection'] = cursorDirection; - } - if (typeof orderType !== 'undefined') { - 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} projectId - * @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: (projectId, name, teamId, description, logo, url, legalName, legalCountry, legalState, legalCity, legalAddress, legalTaxId) => __awaiter(this, void 0, void 0, function* () { - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof teamId === 'undefined') { - throw new AppwriteException('Missing required parameter: "teamId"'); - } - let path = '/projects'; - let payload = {}; - if (typeof projectId !== 'undefined') { - payload['projectId'] = projectId; - } - 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 (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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 {number} limit - * @throws {AppwriteException} - * @returns {Promise} - */ - updateAuthLimit: (projectId, limit) => __awaiter(this, void 0, void 0, function* () { - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof method === 'undefined') { - throw new AppwriteException('Missing required parameter: "method"'); - } - if (typeof 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 (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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 (typeof 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 - * @param {number} expire - * @throws {AppwriteException} - * @returns {Promise} - */ - createKey: (projectId, name, scopes, expire) => __awaiter(this, void 0, void 0, function* () { - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof 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; - } - if (typeof expire !== 'undefined') { - payload['expire'] = expire; - } - 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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 - * @param {number} expire - * @throws {AppwriteException} - * @returns {Promise} - */ - updateKey: (projectId, keyId, name, scopes, expire) => __awaiter(this, void 0, void 0, function* () { - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof keyId === 'undefined') { - throw new AppwriteException('Missing required parameter: "keyId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof 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; - } - if (typeof expire !== 'undefined') { - payload['expire'] = expire; - } - 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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 (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof type === 'undefined') { - throw new AppwriteException('Missing required parameter: "type"'); - } - if (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof platformId === 'undefined') { - throw new AppwriteException('Missing required parameter: "platformId"'); - } - if (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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); - }), - /** - * Update service status - * - * - * @param {string} projectId - * @param {string} service - * @param {boolean} status - * @throws {AppwriteException} - * @returns {Promise} - */ - updateServiceStatus: (projectId, service, status) => __awaiter(this, void 0, void 0, function* () { - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof service === 'undefined') { - throw new AppwriteException('Missing required parameter: "service"'); - } - if (typeof status === 'undefined') { - throw new AppwriteException('Missing required parameter: "status"'); - } - let path = '/projects/{projectId}/service'.replace('{projectId}', projectId); - let payload = {}; - if (typeof service !== 'undefined') { - payload['service'] = service; - } - 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); - }), - /** - * Get usage stats for a project - * - * - * @param {string} projectId - * @param {string} range - * @throws {AppwriteException} - * @returns {Promise} - */ - getUsage: (projectId, range) => __awaiter(this, void 0, void 0, function* () { - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - let path = '/projects/{projectId}/usage'.replace('{projectId}', projectId); - let payload = {}; - if (typeof range !== 'undefined') { - 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 (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof events === 'undefined') { - throw new AppwriteException('Missing required parameter: "events"'); - } - if (typeof url === 'undefined') { - throw new AppwriteException('Missing required parameter: "url"'); - } - if (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof webhookId === 'undefined') { - throw new AppwriteException('Missing required parameter: "webhookId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof events === 'undefined') { - throw new AppwriteException('Missing required parameter: "events"'); - } - if (typeof url === 'undefined') { - throw new AppwriteException('Missing required parameter: "url"'); - } - if (typeof 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 (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof 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); - }), - /** - * Update Webhook Signature Key - * - * - * @param {string} projectId - * @param {string} webhookId - * @throws {AppwriteException} - * @returns {Promise} - */ - updateWebhookSignature: (projectId, webhookId) => __awaiter(this, void 0, void 0, function* () { - if (typeof projectId === 'undefined') { - throw new AppwriteException('Missing required parameter: "projectId"'); - } - if (typeof webhookId === 'undefined') { - throw new AppwriteException('Missing required parameter: "webhookId"'); - } - let path = '/projects/{projectId}/webhooks/{webhookId}/signature'.replace('{projectId}', projectId).replace('{webhookId}', webhookId); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('patch', uri, { - 'content-type': 'application/json', - }, payload); - }) - }; - this.storage = { - /** - * List buckets - * - * Get a list of all the storage buckets. You can use the query params to - * filter your results. - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} cursor - * @param {string} cursorDirection - * @param {string} orderType - * @throws {AppwriteException} - * @returns {Promise} - */ - listBuckets: (search, limit, offset, cursor, cursorDirection, orderType) => __awaiter(this, void 0, void 0, function* () { - let path = '/storage/buckets'; - let payload = {}; - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - if (typeof cursor !== 'undefined') { - payload['cursor'] = cursor; - } - if (typeof cursorDirection !== 'undefined') { - payload['cursorDirection'] = cursorDirection; - } - if (typeof orderType !== 'undefined') { - payload['orderType'] = orderType; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Create bucket - * - * Create a new storage bucket. - * - * @param {string} bucketId - * @param {string} name - * @param {string} permission - * @param {string[]} read - * @param {string[]} write - * @param {boolean} enabled - * @param {number} maximumFileSize - * @param {string[]} allowedFileExtensions - * @param {boolean} encryption - * @param {boolean} antivirus - * @throws {AppwriteException} - * @returns {Promise} - */ - createBucket: (bucketId, name, permission, read, write, enabled, maximumFileSize, allowedFileExtensions, encryption, antivirus) => __awaiter(this, void 0, void 0, function* () { - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof permission === 'undefined') { - throw new AppwriteException('Missing required parameter: "permission"'); - } - let path = '/storage/buckets'; - let payload = {}; - if (typeof bucketId !== 'undefined') { - payload['bucketId'] = bucketId; - } - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof permission !== 'undefined') { - payload['permission'] = permission; - } - if (typeof read !== 'undefined') { - payload['read'] = read; - } - if (typeof write !== 'undefined') { - payload['write'] = write; - } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } - if (typeof maximumFileSize !== 'undefined') { - payload['maximumFileSize'] = maximumFileSize; - } - if (typeof allowedFileExtensions !== 'undefined') { - payload['allowedFileExtensions'] = allowedFileExtensions; - } - if (typeof encryption !== 'undefined') { - payload['encryption'] = encryption; - } - if (typeof antivirus !== 'undefined') { - payload['antivirus'] = antivirus; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('post', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Get Bucket - * - * Get a storage bucket by its unique ID. This endpoint response returns a - * JSON object with the storage bucket metadata. - * - * @param {string} bucketId - * @throws {AppwriteException} - * @returns {Promise} - */ - getBucket: (bucketId) => __awaiter(this, void 0, void 0, function* () { - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); - } - let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Update Bucket - * - * Update a storage bucket by its unique ID. - * - * @param {string} bucketId - * @param {string} name - * @param {string} permission - * @param {string[]} read - * @param {string[]} write - * @param {boolean} enabled - * @param {number} maximumFileSize - * @param {string[]} allowedFileExtensions - * @param {boolean} encryption - * @param {boolean} antivirus - * @throws {AppwriteException} - * @returns {Promise} - */ - updateBucket: (bucketId, name, permission, read, write, enabled, maximumFileSize, allowedFileExtensions, encryption, antivirus) => __awaiter(this, void 0, void 0, function* () { - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof permission === 'undefined') { - throw new AppwriteException('Missing required parameter: "permission"'); - } - let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); - let payload = {}; - if (typeof name !== 'undefined') { - payload['name'] = name; - } - if (typeof permission !== 'undefined') { - payload['permission'] = permission; - } - if (typeof read !== 'undefined') { - payload['read'] = read; - } - if (typeof write !== 'undefined') { - payload['write'] = write; - } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } - if (typeof maximumFileSize !== 'undefined') { - payload['maximumFileSize'] = maximumFileSize; - } - if (typeof allowedFileExtensions !== 'undefined') { - payload['allowedFileExtensions'] = allowedFileExtensions; - } - if (typeof encryption !== 'undefined') { - payload['encryption'] = encryption; - } - if (typeof antivirus !== 'undefined') { - payload['antivirus'] = antivirus; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('put', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Delete Bucket - * - * Delete a storage bucket by its unique ID. - * - * @param {string} bucketId - * @throws {AppwriteException} - * @returns {Promise} - */ - deleteBucket: (bucketId) => __awaiter(this, void 0, void 0, function* () { - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); - } - let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); - let payload = {}; - const uri = new URL(this.config.endpoint + path); - return yield this.call('delete', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * 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} bucketId - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} cursor - * @param {string} cursorDirection - * @param {string} orderType - * @throws {AppwriteException} - * @returns {Promise} - */ - listFiles: (bucketId, search, limit, offset, cursor, cursorDirection, orderType) => __awaiter(this, void 0, void 0, function* () { - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); - } - let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId); - let payload = {}; - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - if (typeof cursor !== 'undefined') { - payload['cursor'] = cursor; - } - if (typeof cursorDirection !== 'undefined') { - payload['cursorDirection'] = cursorDirection; - } - if (typeof orderType !== 'undefined') { - 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. Before using this route, you should create a new bucket - * resource using either a [server - * integration](/docs/server/storage#storageCreateBucket) API or directly - * from your Appwrite console. - * - * Larger files should be uploaded using multiple requests with the - * [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) - * header to send a partial request with a maximum supported chunk of `5MB`. - * The `content-range` header values should always be in bytes. - * - * When the first request is sent, the server will return the **File** object, - * and the subsequent part request must include the file's **id** in - * `x-appwrite-id` header to allow the server to know that the partial upload - * is for the existing file and not for a new one. - * - * If you're creating a new file using one of the Appwrite SDKs, all the - * chunking logic will be managed by the SDK internally. - * - * - * @param {string} bucketId - * @param {string} fileId - * @param {File} file - * @param {string[]} read - * @param {string[]} write - * @throws {AppwriteException} - * @returns {Promise} - */ - createFile: (bucketId, fileId, file, read, write, onProgress = (progress) => { }) => __awaiter(this, void 0, void 0, function* () { - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); - } - if (typeof fileId === 'undefined') { - throw new AppwriteException('Missing required parameter: "fileId"'); - } - if (typeof file === 'undefined') { - throw new AppwriteException('Missing required parameter: "file"'); - } - let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId); - let payload = {}; - if (typeof fileId !== 'undefined') { - payload['fileId'] = fileId; - } - 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); - if (!(file instanceof File)) { - throw new AppwriteException('Parameter "file" has to be a File.'); - } - const size = file.size; - if (size <= Appwrite.CHUNK_SIZE) { - return yield this.call('post', uri, { - 'content-type': 'multipart/form-data', - }, payload); - } - let id = undefined; - let response = undefined; - const headers = { - 'content-type': 'multipart/form-data', - }; - let counter = 0; - const totalCounters = Math.ceil(size / Appwrite.CHUNK_SIZE); - if (fileId != 'unique()') { - try { - response = yield this.call('GET', new URL(this.config.endpoint + path + '/' + fileId), headers); - counter = response.chunksUploaded; - } - catch (e) { - } - } - for (counter; counter < totalCounters; counter++) { - const start = (counter * Appwrite.CHUNK_SIZE); - const end = Math.min((((counter * Appwrite.CHUNK_SIZE) + Appwrite.CHUNK_SIZE) - 1), size); - headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size; - if (id) { - headers['x-appwrite-id'] = id; - } - const stream = file.slice(start, end + 1); - payload['file'] = new File([stream], file.name); - response = yield this.call('post', uri, headers, payload); - if (!id) { - id = response['$id']; - } - if (onProgress) { - onProgress({ - $id: response.$id, - progress: Math.min((counter + 1) * Appwrite.CHUNK_SIZE - 1, size) / size * 100, - sizeUploaded: end, - chunksTotal: response.chunksTotal, - chunksUploaded: response.chunksUploaded - }); - } - } - return response; - }), - /** - * Get File - * - * Get a file by its unique ID. This endpoint response returns a JSON object - * with the file metadata. - * - * @param {string} bucketId - * @param {string} fileId - * @throws {AppwriteException} - * @returns {Promise} - */ - getFile: (bucketId, fileId) => __awaiter(this, void 0, void 0, function* () { - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); - } - if (typeof fileId === 'undefined') { - throw new AppwriteException('Missing required parameter: "fileId"'); - } - let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).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} bucketId - * @param {string} fileId - * @param {string[]} read - * @param {string[]} write - * @throws {AppwriteException} - * @returns {Promise} - */ - updateFile: (bucketId, fileId, read, write) => __awaiter(this, void 0, void 0, function* () { - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); - } - if (typeof fileId === 'undefined') { - throw new AppwriteException('Missing required parameter: "fileId"'); - } - let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).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} bucketId - * @param {string} fileId - * @throws {AppwriteException} - * @returns {Promise} - */ - deleteFile: (bucketId, fileId) => __awaiter(this, void 0, void 0, function* () { - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); - } - if (typeof fileId === 'undefined') { - throw new AppwriteException('Missing required parameter: "fileId"'); - } - let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).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} bucketId - * @param {string} fileId - * @throws {AppwriteException} - * @returns {URL} - */ - getFileDownload: (bucketId, fileId) => { - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); - } - if (typeof fileId === 'undefined') { - throw new AppwriteException('Missing required parameter: "fileId"'); - } - let path = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).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. Preview is - * supported only for image files smaller than 10MB. - * - * @param {string} bucketId - * @param {string} fileId - * @param {number} width - * @param {number} height - * @param {string} gravity - * @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: (bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output) => { - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); - } - if (typeof fileId === 'undefined') { - throw new AppwriteException('Missing required parameter: "fileId"'); - } - let path = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - let payload = {}; - if (typeof width !== 'undefined') { - payload['width'] = width; - } - if (typeof height !== 'undefined') { - payload['height'] = height; - } - if (typeof gravity !== 'undefined') { - payload['gravity'] = gravity; - } - if (typeof quality !== 'undefined') { - payload['quality'] = quality; - } - if (typeof borderWidth !== 'undefined') { - payload['borderWidth'] = borderWidth; - } - if (typeof borderColor !== 'undefined') { - payload['borderColor'] = borderColor; - } - if (typeof borderRadius !== 'undefined') { - payload['borderRadius'] = borderRadius; - } - if (typeof opacity !== 'undefined') { - payload['opacity'] = opacity; - } - if (typeof rotation !== 'undefined') { - payload['rotation'] = rotation; - } - if (typeof background !== 'undefined') { - payload['background'] = background; - } - if (typeof output !== 'undefined') { - 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} bucketId - * @param {string} fileId - * @throws {AppwriteException} - * @returns {URL} - */ - getFileView: (bucketId, fileId) => { - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); - } - if (typeof fileId === 'undefined') { - throw new AppwriteException('Missing required parameter: "fileId"'); - } - let path = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).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 usage stats for storage - * - * - * @param {string} range - * @throws {AppwriteException} - * @returns {Promise} - */ - getUsage: (range) => __awaiter(this, void 0, void 0, function* () { - let path = '/storage/usage'; - let payload = {}; - if (typeof range !== 'undefined') { - payload['range'] = range; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Get usage stats for a storage bucket - * - * - * @param {string} bucketId - * @param {string} range - * @throws {AppwriteException} - * @returns {Promise} - */ - getBucketUsage: (bucketId, range) => __awaiter(this, void 0, void 0, function* () { - if (typeof bucketId === 'undefined') { - throw new AppwriteException('Missing required parameter: "bucketId"'); - } - let path = '/storage/{bucketId}/usage'.replace('{bucketId}', bucketId); - let payload = {}; - if (typeof range !== 'undefined') { - payload['range'] = range; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }) - }; - this.teams = { - /** - * List Teams - * - * Get a list of all the teams in which the current user is a member. You can - * use the parameters to filter your results. - * - * In admin mode, this endpoint returns a list of all the teams in the current - * project. [Learn more about different API modes](/docs/admin). - * - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} cursor - * @param {string} cursorDirection - * @param {string} orderType - * @throws {AppwriteException} - * @returns {Promise} - */ - list: (search, limit, offset, cursor, cursorDirection, orderType) => __awaiter(this, void 0, void 0, function* () { - let path = '/teams'; - let payload = {}; - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - if (typeof cursor !== 'undefined') { - payload['cursor'] = cursor; - } - if (typeof cursorDirection !== 'undefined') { - payload['cursorDirection'] = cursorDirection; - } - if (typeof orderType !== 'undefined') { - 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. Only the users with the owner role can - * invite new members, add new owners and delete or update the team. - * - * @param {string} teamId - * @param {string} name - * @param {string[]} roles - * @throws {AppwriteException} - * @returns {Promise} - */ - create: (teamId, name, roles) => __awaiter(this, void 0, void 0, function* () { - if (typeof teamId === 'undefined') { - throw new AppwriteException('Missing required parameter: "teamId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - let path = '/teams'; - let payload = {}; - if (typeof teamId !== 'undefined') { - payload['teamId'] = teamId; - } - 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 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 (typeof 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 using its ID. Only members with the owner role can update the - * team. - * - * @param {string} teamId - * @param {string} name - * @throws {AppwriteException} - * @returns {Promise} - */ - update: (teamId, name) => __awaiter(this, void 0, void 0, function* () { - if (typeof teamId === 'undefined') { - throw new AppwriteException('Missing required parameter: "teamId"'); - } - if (typeof 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 using its ID. Only team members with the owner role can - * delete the team. - * - * @param {string} teamId - * @throws {AppwriteException} - * @returns {Promise} - */ - delete: (teamId) => __awaiter(this, void 0, void 0, function* () { - if (typeof 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); - }), - /** - * List Team Logs - * - * Get the team activity logs list by its unique ID. - * - * @param {string} teamId - * @param {number} limit - * @param {number} offset - * @throws {AppwriteException} - * @returns {Promise} - */ - listLogs: (teamId, limit, offset) => __awaiter(this, void 0, void 0, function* () { - if (typeof teamId === 'undefined') { - throw new AppwriteException('Missing required parameter: "teamId"'); - } - let path = '/teams/{teamId}/logs'.replace('{teamId}', teamId); - let payload = {}; - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Get Team Memberships - * - * Use this endpoint to list a team's members using the team's ID. All team - * members have read access to this endpoint. - * - * @param {string} teamId - * @param {string} search - * @param {number} limit - * @param {number} offset - * @param {string} cursor - * @param {string} cursorDirection - * @param {string} orderType - * @throws {AppwriteException} - * @returns {Promise} - */ - getMemberships: (teamId, search, limit, offset, cursor, cursorDirection, orderType) => __awaiter(this, void 0, void 0, function* () { - if (typeof teamId === 'undefined') { - throw new AppwriteException('Missing required parameter: "teamId"'); - } - let path = '/teams/{teamId}/memberships'.replace('{teamId}', teamId); - let payload = {}; - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - if (typeof cursor !== 'undefined') { - payload['cursor'] = cursor; - } - if (typeof cursorDirection !== 'undefined') { - payload['cursorDirection'] = cursorDirection; - } - if (typeof orderType !== 'undefined') { - 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 - * - * Invite a new member to join your team. If initiated from the client SDK, an - * email with a link to join the team will be sent to the member's email - * address and an account will be created for them should they not be signed - * up already. If initiated from server-side SDKs, the new member will - * automatically be added to the team. - * - * 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 to avoid a [Redirect - * Attack](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 - * adding 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 (typeof teamId === 'undefined') { - throw new AppwriteException('Missing required parameter: "teamId"'); - } - if (typeof email === 'undefined') { - throw new AppwriteException('Missing required parameter: "email"'); - } - if (typeof roles === 'undefined') { - throw new AppwriteException('Missing required parameter: "roles"'); - } - if (typeof 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 roles !== 'undefined') { - payload['roles'] = roles; - } - if (typeof url !== 'undefined') { - payload['url'] = url; - } - 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 Team Membership - * - * Get a team member by the membership unique id. All team members have read - * access for this resource. - * - * @param {string} teamId - * @param {string} membershipId - * @throws {AppwriteException} - * @returns {Promise} - */ - getMembership: (teamId, membershipId) => __awaiter(this, void 0, void 0, function* () { - if (typeof teamId === 'undefined') { - throw new AppwriteException('Missing required parameter: "teamId"'); - } - if (typeof 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('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Update Membership Roles - * - * Modify the roles of a team member. Only team members with the owner role - * have access to this endpoint. Learn more about [roles and - * permissions](/docs/permissions). - * - * @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 (typeof teamId === 'undefined') { - throw new AppwriteException('Missing required parameter: "teamId"'); - } - if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); - } - if (typeof 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 (typeof teamId === 'undefined') { - throw new AppwriteException('Missing required parameter: "teamId"'); - } - if (typeof 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 received - * by the user. - * - * If the request is successful, a session for the user is automatically - * created. - * - * - * @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 (typeof teamId === 'undefined') { - throw new AppwriteException('Missing required parameter: "teamId"'); - } - if (typeof membershipId === 'undefined') { - throw new AppwriteException('Missing required parameter: "membershipId"'); - } - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof 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} cursor - * @param {string} cursorDirection - * @param {string} orderType - * @throws {AppwriteException} - * @returns {Promise} - */ - list: (search, limit, offset, cursor, cursorDirection, orderType) => __awaiter(this, void 0, void 0, function* () { - let path = '/users'; - let payload = {}; - if (typeof search !== 'undefined') { - payload['search'] = search; - } - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - if (typeof cursor !== 'undefined') { - payload['cursor'] = cursor; - } - if (typeof cursorDirection !== 'undefined') { - payload['cursorDirection'] = cursorDirection; - } - if (typeof orderType !== 'undefined') { - 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} userId - * @param {string} email - * @param {string} password - * @param {string} name - * @throws {AppwriteException} - * @returns {Promise} - */ - create: (userId, email, password, name) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof email === 'undefined') { - throw new AppwriteException('Missing required parameter: "email"'); - } - if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); - } - let path = '/users'; - let payload = {}; - if (typeof userId !== 'undefined') { - payload['userId'] = userId; - } - 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 usage stats for the users API - * - * - * @param {string} range - * @param {string} provider - * @throws {AppwriteException} - * @returns {Promise} - */ - getUsage: (range, provider) => __awaiter(this, void 0, void 0, function* () { - let path = '/users/usage'; - let payload = {}; - if (typeof range !== 'undefined') { - payload['range'] = range; - } - if (typeof provider !== 'undefined') { - payload['provider'] = provider; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', 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 (typeof 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, thereby releasing it's ID. Since ID is - * released and can be reused, all user-related resources like documents or - * storage files should be deleted before user deletion. If you want to keep - * ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus) - * endpoint instead. - * - * @param {string} userId - * @throws {AppwriteException} - * @returns {Promise} - */ - delete: (userId) => __awaiter(this, void 0, void 0, function* () { - if (typeof 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); - }), - /** - * Update Email - * - * Update the user email by its unique ID. - * - * @param {string} userId - * @param {string} email - * @throws {AppwriteException} - * @returns {Promise} - */ - updateEmail: (userId, email) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof email === 'undefined') { - throw new AppwriteException('Missing required parameter: "email"'); - } - let path = '/users/{userId}/email'.replace('{userId}', userId); - let payload = {}; - if (typeof email !== 'undefined') { - payload['email'] = email; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('patch', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Get User Logs - * - * Get the user activity logs list by its unique ID. - * - * @param {string} userId - * @param {number} limit - * @param {number} offset - * @throws {AppwriteException} - * @returns {Promise} - */ - getLogs: (userId, limit, offset) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - let path = '/users/{userId}/logs'.replace('{userId}', userId); - let payload = {}; - if (typeof limit !== 'undefined') { - payload['limit'] = limit; - } - if (typeof offset !== 'undefined') { - payload['offset'] = offset; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('get', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Get User Memberships - * - * Get the user membership list by its unique ID. - * - * @param {string} userId - * @throws {AppwriteException} - * @returns {Promise} - */ - getMemberships: (userId) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - let path = '/users/{userId}/memberships'.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 Name - * - * Update the user name by its unique ID. - * - * @param {string} userId - * @param {string} name - * @throws {AppwriteException} - * @returns {Promise} - */ - updateName: (userId, name) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - let path = '/users/{userId}/name'.replace('{userId}', userId); - 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 Password - * - * Update the user password by its unique ID. - * - * @param {string} userId - * @param {string} password - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePassword: (userId, password) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); - } - let path = '/users/{userId}/password'.replace('{userId}', userId); - let payload = {}; - 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); - }), - /** - * Update Phone - * - * Update the user phone by its unique ID. - * - * @param {string} userId - * @param {string} number - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePhone: (userId, number) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof number === 'undefined') { - throw new AppwriteException('Missing required parameter: "number"'); - } - let path = '/users/{userId}/phone'.replace('{userId}', userId); - let payload = {}; - if (typeof number !== 'undefined') { - payload['number'] = number; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('patch', 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 (typeof 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. The object you pass is stored - * as is, and replaces any previous value. The maximum allowed prefs size is - * 64kB and throws error if exceeded. - * - * @param {string} userId - * @param {object} prefs - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePrefs: (userId, prefs) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof 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 (typeof 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 (typeof 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 (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof 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. Use this endpoint as an - * alternative to deleting a user if you want to keep user's ID reserved. - * - * @param {string} userId - * @param {boolean} status - * @throws {AppwriteException} - * @returns {Promise} - */ - updateStatus: (userId, status) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof 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); - }), - /** - * Update Email Verification - * - * Update the user email verification status by its unique ID. - * - * @param {string} userId - * @param {boolean} emailVerification - * @throws {AppwriteException} - * @returns {Promise} - */ - updateEmailVerification: (userId, emailVerification) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof emailVerification === 'undefined') { - throw new AppwriteException('Missing required parameter: "emailVerification"'); - } - let path = '/users/{userId}/verification'.replace('{userId}', userId); - let payload = {}; - if (typeof emailVerification !== 'undefined') { - payload['emailVerification'] = emailVerification; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('patch', uri, { - 'content-type': 'application/json', - }, payload); - }), - /** - * Update Phone Verification - * - * Update the user phone verification status by its unique ID. - * - * @param {string} userId - * @param {boolean} phoneVerification - * @throws {AppwriteException} - * @returns {Promise} - */ - updatePhoneVerification: (userId, phoneVerification) => __awaiter(this, void 0, void 0, function* () { - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof phoneVerification === 'undefined') { - throw new AppwriteException('Missing required parameter: "phoneVerification"'); - } - let path = '/users/{userId}/verification/phone'.replace('{userId}', userId); - let payload = {}; - if (typeof phoneVerification !== 'undefined') { - payload['phoneVerification'] = phoneVerification; - } - const uri = new URL(this.config.endpoint + path); - return yield this.call('patch', uri, { - 'content-type': 'application/json', - }, payload); - }) - }; } /** * Set Endpoint @@ -6198,7 +363,7 @@ 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))) { + for (const [key, value] of Object.entries(Service.flatten(params))) { url.searchParams.append(key, value); } } @@ -6253,19 +418,55 @@ } }); } - 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)); + } + + class Account extends Service { + constructor(client) { + super(client); + } + /** + * Get Account + * + * Get currently logged in user data as JSON object. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + get() { + return __awaiter(this, void 0, void 0, function* () { + let path = '/account'; + let payload = {}; + const uri = new URL(this.client.config.endpoint + path); + return yield this.client.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} userId + * @param {string} email + * @param {string} password + * @param {string} name + * @throws {AppwriteException} + * @returns {Promise} + */ + create(userId, email, password, name) { + return __awaiter(this, void 0, void 0, function* () { + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); } - else { - output[finalKey] = value; + if (typeof email === 'undefined') { + throw new AppwriteException('Missing required parameter: "email"'); } -<<<<<<< HEAD -======= if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } @@ -6442,23 +643,23 @@ * /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) * endpoint to send a confirmation SMS. * - * @param {string} number + * @param {string} phone * @param {string} password * @throws {AppwriteException} * @returns {Promise} */ - updatePhone(number, password) { + updatePhone(phone, password) { return __awaiter(this, void 0, void 0, function* () { - if (typeof number === 'undefined') { - throw new AppwriteException('Missing required parameter: "number"'); + if (typeof phone === 'undefined') { + throw new AppwriteException('Missing required parameter: "phone"'); } if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } let path = '/account/phone'; let payload = {}; - if (typeof number !== 'undefined') { - payload['number'] = number; + if (typeof phone !== 'undefined') { + payload['phone'] = phone; } if (typeof password !== 'undefined') { payload['password'] = password; @@ -6815,15 +1016,328 @@ createOAuth2Session(provider, success, failure, scopes) { if (typeof provider === 'undefined') { throw new AppwriteException('Missing required parameter: "provider"'); ->>>>>>> 1e404e379be11c98f1e2e7ef38625bee43b110bf } - return output; + let path = '/account/sessions/oauth2/{provider}'.replace('{provider}', provider); + let payload = {}; + if (typeof success !== 'undefined') { + payload['success'] = success; + } + if (typeof failure !== 'undefined') { + payload['failure'] = failure; + } + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + const uri = new URL(this.client.config.endpoint + path); + payload['project'] = this.client.config.project; + for (const [key, value] of Object.entries(Service.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; + } + } + /** + * Create Phone session + * + * Sends the user an SMS with a secret key for creating a session. If the + * provided user ID has not be registered, a new user will be created. Use the + * returned user ID and secret and submit a request to the [PUT + * /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession) + * endpoint to complete the login process. The secret sent to the user's phone + * is valid for 15 minutes. + * + * @param {string} userId + * @param {string} phone + * @throws {AppwriteException} + * @returns {Promise} + */ + createPhoneSession(userId, phone) { + return __awaiter(this, void 0, void 0, function* () { + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof phone === 'undefined') { + throw new AppwriteException('Missing required parameter: "phone"'); + } + let path = '/account/sessions/phone'; + let payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof phone !== 'undefined') { + payload['phone'] = phone; + } + const uri = new URL(this.client.config.endpoint + path); + return yield this.client.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }); + } + /** + * Create Phone Session (confirmation) + * + * Use this endpoint to complete creating a session with SMS. Use the + * **userId** from the + * [createPhoneSession](/docs/client/account#accountCreatePhoneSession) + * endpoint and the **secret** received via SMS to successfully update and + * confirm the phone session. + * + * @param {string} userId + * @param {string} secret + * @throws {AppwriteException} + * @returns {Promise} + */ + updatePhoneSession(userId, secret) { + return __awaiter(this, void 0, void 0, function* () { + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof secret === 'undefined') { + throw new AppwriteException('Missing required parameter: "secret"'); + } + let path = '/account/sessions/phone'; + let payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + path); + return yield this.client.call('put', uri, { + 'content-type': 'application/json', + }, payload); + }); + } + /** + * Get Session By ID + * + * Use this endpoint to get a logged in user's session using a Session ID. + * Inputting 'current' will return the current session being used. + * + * @param {string} sessionId + * @throws {AppwriteException} + * @returns {Promise} + */ + getSession(sessionId) { + return __awaiter(this, void 0, void 0, function* () { + if (typeof sessionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); + let payload = {}; + const uri = new URL(this.client.config.endpoint + path); + return yield this.client.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }); + } + /** + * Update Session (Refresh Tokens) + * + * Access tokens have limited lifespan and expire to mitigate security risks. + * If session was created using an OAuth provider, this route can be used to + * "refresh" the access token. + * + * @param {string} sessionId + * @throws {AppwriteException} + * @returns {Promise} + */ + updateSession(sessionId) { + return __awaiter(this, void 0, void 0, function* () { + if (typeof sessionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); + let payload = {}; + const uri = new URL(this.client.config.endpoint + path); + return yield this.client.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + }); + } + /** + * 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 + * Session ID argument, only the unique session ID provided is deleted. + * + * + * @param {string} sessionId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteSession(sessionId) { + return __awaiter(this, void 0, void 0, function* () { + if (typeof sessionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); + let payload = {}; + const uri = new URL(this.client.config.endpoint + path); + return yield this.client.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + }); + } + /** + * Update Account Status + * + * Block the currently logged in user account. Behind the scene, the user + * record is not deleted but permanently blocked from any access. To + * completely delete a user, use the Users API instead. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + updateStatus() { + return __awaiter(this, void 0, void 0, function* () { + let path = '/account/status'; + let payload = {}; + const uri = new URL(this.client.config.endpoint + path); + return yield this.client.call('patch', 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#accountUpdateEmailVerification). 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) { + return __awaiter(this, void 0, void 0, function* () { + if (typeof 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.client.config.endpoint + path); + return yield this.client.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }); + } + /** + * Create Email Verification (confirmation) + * + * 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) { + return __awaiter(this, void 0, void 0, function* () { + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof 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.client.config.endpoint + path); + return yield this.client.call('put', uri, { + 'content-type': 'application/json', + }, payload); + }); + } + /** + * Create Phone Verification + * + * Use this endpoint to send a verification SMS to the currently logged in + * user. This endpoint is meant for use after updating a user's phone number + * using the [accountUpdatePhone](/docs/client/account#accountUpdatePhone) + * endpoint. Learn more about how to [complete the verification + * process](/docs/client/account#accountUpdatePhoneVerification). The + * verification code sent to the user's phone number is valid for 15 minutes. + * + * @throws {AppwriteException} + * @returns {Promise} + */ + createPhoneVerification() { + return __awaiter(this, void 0, void 0, function* () { + let path = '/account/verification/phone'; + let payload = {}; + const uri = new URL(this.client.config.endpoint + path); + return yield this.client.call('post', uri, { + 'content-type': 'application/json', + }, payload); + }); + } + /** + * Create Phone Verification (confirmation) + * + * Use this endpoint to complete the user phone verification process. Use the + * **userId** and **secret** that were sent to your user's phone number 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} + */ + updatePhoneVerification(userId, secret) { + return __awaiter(this, void 0, void 0, function* () { + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof secret === 'undefined') { + throw new AppwriteException('Missing required parameter: "secret"'); + } + let path = '/account/verification/phone'; + let payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + path); + return yield this.client.call('put', uri, { + 'content-type': 'application/json', + }, payload); + }); } } -<<<<<<< HEAD - Appwrite.CHUNK_SIZE = 5 * 1024 * 1024; // 5MB - class Query { -======= class Avatars extends Service { constructor(client) { @@ -8645,6 +3159,27 @@ }, payload); }); } + /** + * Get Functions Usage + * + * + * @param {string} range + * @throws {AppwriteException} + * @returns {Promise} + */ + getUsage(range) { + return __awaiter(this, void 0, void 0, function* () { + let path = '/functions/usage'; + let payload = {}; + if (typeof range !== 'undefined') { + payload['range'] = range; + } + const uri = new URL(this.client.config.endpoint + path); + return yield this.client.call('get', uri, { + 'content-type': 'application/json', + }, payload); + }); + } /** * Get Function * @@ -9099,7 +3634,7 @@ * @throws {AppwriteException} * @returns {Promise} */ - getUsage(functionId, range) { + getFunctionUsage(functionId, range) { return __awaiter(this, void 0, void 0, function* () { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); @@ -11637,22 +6172,17 @@ * * @param {string} userId * @param {string} email + * @param {string} phone * @param {string} password * @param {string} name * @throws {AppwriteException} * @returns {Promise} */ - create(userId, email, password, name) { + create(userId, email, phone, password, name) { return __awaiter(this, void 0, void 0, function* () { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } - if (typeof email === 'undefined') { - throw new AppwriteException('Missing required parameter: "email"'); - } - if (typeof password === 'undefined') { - throw new AppwriteException('Missing required parameter: "password"'); - } let path = '/users'; let payload = {}; if (typeof userId !== 'undefined') { @@ -11661,6 +6191,9 @@ if (typeof email !== 'undefined') { payload['email'] = email; } + if (typeof phone !== 'undefined') { + payload['phone'] = phone; + } if (typeof password !== 'undefined') { payload['password'] = password; } @@ -12507,7 +7040,6 @@ }, payload); }); } ->>>>>>> 1e404e379be11c98f1e2e7ef38625bee43b110bf } exports.Account = Account;