Skip to content

Instantly share code, notes, and snippets.

@phamhieu
Created August 14, 2020 01:18
Show Gist options
  • Select an option

  • Save phamhieu/444060a562a77fe38867c864a43a79e0 to your computer and use it in GitHub Desktop.

Select an option

Save phamhieu/444060a562a77fe38867c864a43a79e0 to your computer and use it in GitHub Desktop.
Supabase standalone js client
var Supabase=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=8)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.objectToQueryString=function(t){return Object.keys(t).map((function(e){return"".concat(e,"=").concat(t[e])})).join("&")},e.cleanFilterArray=function(t){return t.map((function(t){return"string"==typeof t&&(t.includes(",")||t.includes("(")||t.includes(")"))?'"'.concat(t,'"'):t}))},e.cleanColumnName=function(t){var e=t,r=null;return t.includes(".")&&(e=t.split(".")[1],r=t.split(".")[0]),{cleanedColumnName:e,foreignTableName:r}}},function(t,e,r){const{CHANNEL_EVENTS:n,CHANNEL_STATES:o}=r(2),i=r(12),s=r(3);t.exports=class{constructor(t,e,r){this.state=o.closed,this.topic=t,this.params=e||{},this.socket=r,this.bindings=[],this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new i(this,n.join,this.params,this.timeout),this.pushBuffer=[],this.rejoinTimer=new s(()=>this.rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=o.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(t=>t.send()),this.pushBuffer=[]}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=o.closed,this.socket.remove(this)}),this.onError(t=>{this.isLeaving()||this.isClosed()||(this.socket.log("channel","error "+this.topic,t),this.state=o.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this.isJoining()&&(this.socket.log("channel","timeout "+this.topic,this.joinPush.timeout),this.state=o.errored,this.rejoinTimer.scheduleTimeout())}),this.on(n.reply,(t,e)=>{this.trigger(this.replyEventName(e),t)})}rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this.rejoin()}join(t=this.timeout){if(this.joinedOnce)throw"tried to join multiple times. 'join' can only be called a single time per channel instance";return this.joinedOnce=!0,this.rejoin(t),this.joinPush}onClose(t){this.on(n.close,t)}onError(t){this.on(n.error,e=>t(e))}on(t,e){this.bindings.push({event:t,callback:e})}off(t){this.bindings=this.bindings.filter(e=>e.event!==t)}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,e,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`;let n=new i(this,t,e,r);return this.canPush()?n.send():(n.startTimeout(),this.pushBuffer.push(n)),n}leave(t=this.timeout){this.state=o.leaving;let e=()=>{this.socket.log("channel","leave "+this.topic),this.trigger(n.close,"leave",this.joinRef())},r=new i(this,n.leave,{},t);return r.receive("ok",()=>e()).receive("timeout",()=>e()),r.send(),this.canPush()||r.trigger("ok",{}),r}onMessage(t,e,r){return e}isMember(t){return this.topic===t}joinRef(){return this.joinPush.ref}sendJoin(t){this.state=o.joining,this.joinPush.resend(t)}rejoin(t=this.timeout){this.isLeaving()||this.sendJoin(t)}trigger(t,e,r){let{close:o,error:i,leave:s,join:a}=n;if(r&&[o,i,s,a].indexOf(t)>=0&&r!==this.joinRef())return;let c=this.onMessage(t,e,r);if(e&&!c)throw"channel onMessage callbacks must return the payload, modified or unmodified";this.bindings.filter(e=>e.event===t).map(t=>t.callback(c,r))}replyEventName(t){return"chan_reply_"+t}isClosed(){return this.state===o.closed}isErrored(){return this.state===o.errored}isJoined(){return this.state===o.joined}isJoining(){return this.state===o.joining}isLeaving(){return this.state===o.leaving}}},function(t,e){t.exports={VSN:"1.0.0",SOCKET_STATES:{connecting:0,open:1,closing:2,closed:3},DEFAULT_TIMEOUT:1e4,WS_CLOSE_NORMAL:1e3,CHANNEL_STATES:{closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},CHANNEL_EVENTS:{close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},TRANSPORTS:{websocket:"websocket"}}},function(t,e){t.exports=class{constructor(t,e){this.callback=t,this.timerCalc=e,this.timer=null,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}},function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var o;"undefined"!=typeof window?o=window:"undefined"==typeof self?(console.warn("Using browser-only version of superagent in non-browser environment"),o=void 0):o=self;var i=r(28),s=r(29),a=r(30),c=r(5),u=r(31),l=r(33);function h(){}t.exports=function(t,r){return"function"==typeof r?new e.Request("GET",t).end(r):1===arguments.length?new e.Request("GET",t):new e.Request(t,r)};var f=e=t.exports;e.Request=g,f.getXHR=function(){if(o.XMLHttpRequest&&(!o.location||"file:"!==o.location.protocol||!o.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}throw new Error("Browser-only version of superagent could not find XHR")};var p="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};function d(t){if(!c(t))return t;var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&y(e,r,t[r]);return e.join("&")}function y(t,e,r){if(void 0!==r)if(null!==r)if(Array.isArray(r))r.forEach((function(r){y(t,e,r)}));else if(c(r))for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&y(t,"".concat(e,"[").concat(n,"]"),r[n]);else t.push(encodeURI(e)+"="+encodeURIComponent(r));else t.push(encodeURI(e))}function m(t){for(var e,r,n={},o=t.split("&"),i=0,s=o.length;i<s;++i)-1===(r=(e=o[i]).indexOf("="))?n[decodeURIComponent(e)]="":n[decodeURIComponent(e.slice(0,r))]=decodeURIComponent(e.slice(r+1));return n}function b(t){return/[/+]json($|[^-\w])/.test(t)}function v(t){this.req=t,this.xhr=this.req.xhr,this.text="HEAD"!==this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var e=this.xhr.status;1223===e&&(e=204),this._setStatusProperties(e),this.headers=function(t){for(var e,r,n,o,i=t.split(/\r?\n/),s={},a=0,c=i.length;a<c;++a)-1!==(e=(r=i[a]).indexOf(":"))&&(n=r.slice(0,e).toLowerCase(),o=p(r.slice(e+1)),s[n]=o);return s}(this.xhr.getAllResponseHeaders()),this.header=this.headers,this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&t._responseType?this.body=this.xhr.response:this.body="HEAD"===this.req.method?null:this._parseBody(this.text?this.text:this.xhr.response)}function g(t,e){var r=this;this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",(function(){var t,e=null,n=null;try{n=new v(r)}catch(t){return(e=new Error("Parser is unable to parse the response")).parse=!0,e.original=t,r.xhr?(e.rawResponse=void 0===r.xhr.responseType?r.xhr.responseText:r.xhr.response,e.status=r.xhr.status?r.xhr.status:null,e.statusCode=e.status):(e.rawResponse=null,e.status=null),r.callback(e)}r.emit("response",n);try{r._isResponseOK(n)||(t=new Error(n.statusText||n.text||"Unsuccessful HTTP response"))}catch(e){t=e}t?(t.original=e,t.response=n,t.status=n.status,r.callback(t,n)):r.callback(null,n)}))}function _(t,e,r){var n=f("DELETE",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}f.serializeObject=d,f.parseString=m,f.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},f.serialize={"application/x-www-form-urlencoded":d,"application/json":s},f.parse={"application/x-www-form-urlencoded":m,"application/json":JSON.parse},u(v.prototype),v.prototype._parseBody=function(t){var e=f.parse[this.type];return this.req._parser?this.req._parser(this,t):(!e&&b(this.type)&&(e=f.parse["application/json"]),e&&t&&(t.length>0||t instanceof Object)?e(t):null)},v.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n="cannot ".concat(e," ").concat(r," (").concat(this.status,")"),o=new Error(n);return o.status=this.status,o.method=e,o.url=r,o},f.Response=v,i(g.prototype),a(g.prototype),g.prototype.type=function(t){return this.set("Content-Type",f.types[t]||t),this},g.prototype.accept=function(t){return this.set("Accept",f.types[t]||t),this},g.prototype.auth=function(t,e,r){1===arguments.length&&(e=""),"object"===n(e)&&null!==e&&(r=e,e=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var o=function(t){if("function"==typeof btoa)return btoa(t);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(t,e,r,o)},g.prototype.query=function(t){return"string"!=typeof t&&(t=d(t)),t&&this._query.push(t),this},g.prototype.attach=function(t,e,r){if(e){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(t,e,r||e.name)}return this},g.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},g.prototype.callback=function(t,e){if(this._shouldRetry(t,e))return this._retry();var r=this._callback;this.clearTimeout(),t&&(this._maxRetries&&(t.retries=this._retries-1),this.emit("error",t)),r(t,e)},g.prototype.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},g.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},g.prototype.ca=g.prototype.agent,g.prototype.buffer=g.prototype.ca,g.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},g.prototype.pipe=g.prototype.write,g.prototype._isHost=function(t){return t&&"object"===n(t)&&!Array.isArray(t)&&"[object Object]"!==Object.prototype.toString.call(t)},g.prototype.end=function(t){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=t||h,this._finalizeQueryString(),this._end()},g.prototype._setUploadTimeout=function(){var t=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){t._timeoutError("Upload timeout of ",t._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},g.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var t=this;this.xhr=f.getXHR();var e=this.xhr,r=this._formData||this._data;this._setTimeouts(),e.onreadystatechange=function(){var r=e.readyState;if(r>=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4===r){var n;try{n=e.status}catch(t){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100,100===r.percent&&clearTimeout(t._uploadTimeoutTimer)),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.addEventListener("progress",n.bind(null,"download")),e.upload&&e.upload.addEventListener("progress",n.bind(null,"upload"))}catch(t){}e.upload&&this._setUploadTimeout();try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof r&&!this._isHost(r)){var o=this._header["content-type"],i=this._serializer||f.serialize[o?o.split(";")[0]:""];!i&&b(o)&&(i=f.serialize["application/json"]),i&&(r=i(r))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&e.setRequestHeader(s,this.header[s]);this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0===r?null:r)},f.agent=function(){return new l},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(t){l.prototype[t.toLowerCase()]=function(e,r){var n=new f.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}})),l.prototype.del=l.prototype.delete,f.get=function(t,e,r){var n=f("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.head=function(t,e,r){var n=f("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.options=function(t,e,r){var n=f("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.del=_,f.delete=_,f.patch=function(t,e,r){var n=f("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.post=function(t,e,r){var n=f("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.put=function(t,e,r){var n=f("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}t.exports=function(t){return null!==t&&"object"===n(t)}},function(t,e){t.exports=function(t){return t&&t.__esModule?t:{default:t}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=r(4),o=a(r(36)),i=a(r(0));function s(){if("function"!=typeof WeakMap)return null;var t=new WeakMap;return s=function(){return t},t}function a(t){if(t&&t.__esModule)return t;if(null===t||"object"!==c(t)&&"function"!=typeof t)return{default:t};var e=s();if(e&&e.has(t))return e.get(t);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var i=n?Object.getOwnPropertyDescriptor(t,o):null;i&&(i.get||i.set)?Object.defineProperty(r,o,i):r[o]=t[o]}return r.default=t,e&&e.set(t,r),r}function c(t){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e){for(var r,n=0;n<e.length;n++)(r=e[n]).enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}function h(t,e,r){return(h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=y(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(r):o.value}})(t,e,r||t)}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=y(t);if(e){var o=y(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return d(this,r)}}function d(t,e){return!e||"object"!==c(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function y(t){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var m=/^(\d+)-(\d+)\/(\d+)$/,b=function(t){function e(t,n){var o,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(u(this,e),(o=r.call(this,t,n)).set("Accept","application/json"),{}!=i)for(var s in i)o.set(s,i[s]);return o.get||(o.get=o.getHeader),o}!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}(e,t);var r=p(e);return function(t,e,r){e&&l(t.prototype,e),r&&l(t,r)}(e,[{key:"auth",value:function(t,r){return"string"==typeof t&&null==r?(this.set("Authorization","Bearer ".concat(t)),this):("object"===c(t)&&null==r&&(r=t.pass,t=t.user),h(y(e.prototype),"auth",this).call(this,t,r))}},{key:"filter",value:function(t,e,r){if(["in","cs","cd","ova","ovr","sl","sr","nxr","nxl","adj"].includes(e)&&!Array.isArray(r))return{body:null,status:400,statusCode:400,statusText:".".concat(e,"() cannot be invoked with criteria that is not an Array.")};if(["ovr","sl","sr","nxr","nxl","adj"].includes(e)&&2!=r.length)return{body:null,status:400,statusCode:400,statusText:".".concat(e,"() can only be invoked with a criteria that is an Array of length 2.")};if(["fts","plfts","phfts","wfts"].includes(e)&&void 0===r.queryText)return{body:null,status:400,statusCode:400,statusText:".".concat(e,"() can only be invoked with a criteria that is an Object with key queryText.")};var n=o["_".concat(e.toLowerCase())](t,r);return this.query(n)}},{key:"not",value:function(t,e,r){var n=o["_".concat(e.toLowerCase())](t,r),i="".concat(n.split("=")[0],"=not.").concat(n.split("=")[1]);return this.query(i)}},{key:"match",value:function(t){var e=this;return Object.keys(t).forEach((function(r){e.query("".concat(r,"=eq.").concat(t[r]))})),this}},{key:"select",value:function(t){return t&&this.query({select:t.replace(/\s/g,"")}),this}},{key:"order",value:function(t){var e=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],r=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2],n=i.cleanColumnName(t),o=n.cleanedColumnName,s=n.foreignTableName;return this.query("".concat(null==s?"":"".concat(s,"."),"order=").concat(o,".").concat(e?"asc":"desc",".").concat(r?"nullsfirst":"nullslast")),this}},{key:"limit",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return"number"==typeof t?(this.query("".concat(null==e?"":"".concat(e,"."),"limit=").concat(t)),this):{body:null,status:400,statusCode:400,statusText:".limit() cannot be invoked with criteria that is not a number."}}},{key:"offset",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return"number"==typeof t?(this.query("".concat(null==e?"":"".concat(e,"."),"offset=").concat(t)),this):{body:null,status:400,statusCode:400,statusText:".offset() cannot be invoked with criteria that is not a number."}}},{key:"range",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if("number"!=typeof t||"number"!=typeof e&&null!=e)return{body:null,status:400,statusCode:400,statusText:".range() cannot be invoked with parameters that are not numbers."};var r=null==e?"":e;return this.set("Range-Unit","items"),this.set("Range","".concat(t,"-").concat(r)),this}},{key:"single",value:function(){return this.set("Accept","application/vnd.pgrst.object+json"),this.set("Prefer","return=representation"),this}},{key:"end",value:function(){var t=this;return new Promise((function(r,n){if(["DELETE","PATCH"].includes(t.method)&&0==t._query.length){var o="DELETE"===t.method?".delete()":".update()";return r({body:null,status:400,statusCode:400,statusText:"".concat(o," cannot be invoked without any filters.")})}h(y(e.prototype),"end",t).call(t,(function(t,e){if(t)return n(t);var o=e.body,i=e.headers,s=e.status,a=e.statusCode,c=e.statusText,u=i["content-range"];return Array.isArray(o)&&u&&m.test(u)&&(o.fullLength=parseInt(m.exec(u)[3],10)),r({body:o,status:s,statusCode:a,statusText:c})}))}))}},{key:"then",value:function(t,e){return this.end().then(t,e)}},{key:"catch",value:function(t){return this.end().catch(t)}}]),e}(n.Request);["eq","neq","gt","lt","gte","lte","like","ilike","is","in","fts","plfts","phfts","wfts","cs","cd","ova","ovr","sl","sr","nxr","nxl","adj","or"].forEach((function(t){return b.prototype[t]=function(e,r){return this.filter(e,t,r)}}));var v=b;e.default=v},function(t,e,r){var n,o,i;"undefined"==typeof globalThis?"undefined"==typeof self||self:globalThis,o=[e,r(9),r(10),r(26),r(34)],void 0===(i="function"==typeof(n=function(t,e,n,o,i){"use strict";var s=r(6);Object.defineProperty(t,"__esModule",{value:!0}),t.createClient=void 0,n=s(n);class a{constructor(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{autoRefreshToken:!0};this.supabaseUrl=null,this.supabaseKey=null,this.restUrl=null,this.realtimeUrl=null,this.authUrl=null,this.schema="public",this.subscriptions={},this.tableName=null,this.queryFilters=[],r.schema&&(this.schema=r.schema),this.authenticate(t,e),this.auth=new o.Auth(this.authUrl,e,{autoRefreshToken:r.autoRefreshToken})}authenticate(t,e){this.supabaseUrl=t,this.supabaseKey=e,this.restUrl="".concat(t,"/rest/v1"),this.realtimeUrl="".concat(t,"/realtime/v1").replace("http","ws"),this.authUrl="".concat(t,"/auth/v1")}clear(){this.tableName=null,this.queryFilters=[]}from(t){return this.tableName=t,this}on(t,r){var o=(0,e.uuid)();return this.subscriptions[o]=new n.default(this.tableName,this.realtimeUrl,this.schema,this.supabaseKey,o,t,r,this.queryFilters),this.clear(),this.subscriptions[o]}getSubscriptions(){return Object.values(this.subscriptions)}removeSubscription(t){t.unsubscribe(),delete this.subscriptions[t.uuid]}rpc(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return new i.PostgrestClient(this.restUrl,{headers:{apikey:this.supabaseKey},schema:this.schema}).rpc(t,e)}initClient(){var t={apikey:this.supabaseKey};45<this.supabaseKey.length&&this.auth.authHeader()&&(t.Authorization=this.auth.authHeader());var e=new i.PostgrestClient(this.restUrl,{headers:t,schema:this.schema}).from(this.tableName);return this.queryFilters.forEach(t=>{switch(t.filter){case"filter":e.filter(t.columnName,t.operator,t.criteria);break;case"match":e.match(t.query);break;case"order":e.order(t.property,t.ascending,t.nullsFirst);break;case"range":e.range(t.from,t.to);break;case"single":e.single()}}),this.clear(),e}select(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"*",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this.initClient().select(t,e)}insert(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this.initClient().insert(t,e)}update(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this.initClient().update(t,e)}delete(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return this.initClient().delete(t)}filter(t,e,r){return this.queryFilters.push({filter:"filter",columnName:t,operator:e,criteria:r}),this}match(t){return this.queryFilters.push({filter:"match",query:t}),this}order(t){var e=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],r=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];return this.queryFilters.push({filter:"order",property:t,ascending:e,nullsFirst:r}),this}range(t,e){return this.queryFilters.push({filter:"range",from:t,to:e}),this}single(){return this.queryFilters.push({filter:"single"}),this}}["eq","neq","gt","lt","gte","lte","like","ilike","is","in","cs","cd","ova","ovr","sl","sr","nxr","nxl","adj"].forEach(t=>a.prototype[t]=function(e,r){return this.filter(e,t,r)}),t.createClient=function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return new a(t,e,r)}})?n.apply(e,o):n)||(t.exports=i)},function(t,e,r){var n,o,i;"undefined"==typeof globalThis?"undefined"==typeof self||self:globalThis,o=[e],void 0===(i="function"==typeof(n=function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uuid=function(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()}})?n.apply(e,o):n)||(t.exports=i)},function(t,e,r){var n,o,i;"undefined"==typeof globalThis?"undefined"==typeof self||self:globalThis,o=[e,r(11),r(23)],void 0===(i="function"==typeof(n=function(t,e,n){"use strict";var o=r(24);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,n=o(n),t.default=class{constructor(t,e,r,n,o,i,s,a){this.tableName=t,this.realtimeUrl=e,this.schema=r,this.apikey=n,this.uuid=o,this.socket=null,this.channel=null,this.listeners={},this.queryFilters=a,this.on(i,s)}createListener(){var t="".concat(this.realtimeUrl),r="";this.queryFilters.forEach(t=>{switch(t.filter){case"filter":"eq"===t.operator&&(r=":".concat(t.columnName,"=").concat(t.operator,".").concat(t.criteria))}});var n="*"==this.tableName?"realtime:*":"realtime:".concat(this.schema,":").concat(this.tableName).concat(r);this.socket=new e.Socket(t,{params:{apikey:this.apikey}}),this.channel=this.socket.channel(n),this.socket.onOpen(()=>{console.debug("".concat(this.realtimeUrl,": REALTIME CONNECTED"))}),this.socket.onClose(()=>{console.debug("".concat(this.realtimeUrl,": REALTIME DISCONNECTED"))})}on(t,e){return null==this.socket&&this.createListener(),this.channel.on(t,t=>{var r={schema:t.schema,table:t.table,commit_timestamp:t.commit_timestamp},o={},i={},s={};switch(t.type){case"INSERT":o=n.convertChangeData(t.columns,t.record),r.eventType="INSERT",r.new=o;break;case"UPDATE":i=n.convertChangeData(t.columns,t.old_record),o=n.convertChangeData(t.columns,t.record),Object.keys(i).forEach(t=>{null!=i[t]&&(s[t]=i[t])}),r.eventType="UPDATE",r.old=s,r.new=o;break;case"DELETE":i=n.convertChangeData(t.columns,t.old_record),Object.keys(i).forEach(t=>{null!=i[t]&&(s[t]=i[t])}),r.eventType="DELETE",r.old=s}e(r)}),this.listeners[t]=e,this}subscribe(){return null==this.socket&&this.createListener(),this.socket.connect(),"joined"!==this.channel.state&&this.channel.join().receive("ok",t=>console.debug("".concat(this.realtimeUrl,": Joined Realtime successfully "),t)).receive("error",t=>console.debug("".concat(this.realtimeUrl,": Unable to join "),t)).receive("timeout",()=>console.debug("".concat(this.realtimeUrl,": Network timeout. Still waiting..."))),this}unsubscribe(){return this.socket&&this.socket.disconnect(),this}}})?n.apply(e,o):n)||(t.exports=i)},function(t,e,r){t.exports={Channel:r(1),Socket:r(13),Presence:r(22)}},function(t,e){t.exports=class{constructor(t,e,r,n){this.channel=t,this.event=e,this.payload=r||{},this.receivedResp=null,this.timeout=n,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(t){this.timeout=t,this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref}))}receive(t,e){return this.hasReceived(t)&&e(this.receivedResp.response),this.recHooks.push({status:t,callback:e}),this}matchReceive({status:t,response:e,ref:r}){this.recHooks.filter(e=>e.status===t).forEach(t=>t.callback(e))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer||(this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout))}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,e){this.channel.trigger(this.refEvent,{status:t,response:e})}}},function(t,e,r){const{VSN:n,CHANNEL_EVENTS:o,TRANSPORTS:i,SOCKET_STATES:s,DEFAULT_TIMEOUT:a,WS_CLOSE_NORMAL:c}=r(2),u=r(14),l=r(18).w3cwebsocket,h=r(3),f=r(1);t.exports=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=e.timeout||a,this.transport=e.transport||l,this.defaultEncoder=(t,e)=>e(JSON.stringify(t)),this.defaultDecoder=(t,e)=>e(JSON.parse(t)),this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder,this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.reconnectAfterMs=e.reconnectAfterMs||function(t){return[1e3,2e3,5e3,1e4][t-1]||1e4},this.logger=e.logger||function(){},this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=e.params||{},this.headers=e.headers||{},this.endPoint=`${t}/${i.websocket}`,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new h(()=>{this.disconnect(()=>this.connect())},this.reconnectAfterMs)}endPointURL(){return this.appendParams(this.endPoint,Object.assign({},this.params,{vsn:n}))}appendParams(t,e){if(0===Object.keys(e).length)return t;let r=t.match(/\?/)?"&":"?";return`${t}${r}${u.stringify(e)}`}disconnect(t,e,r){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,r||""):this.conn.close(),this.conn=null),t&&t()}connect(){this.conn||(this.conn=new this.transport(this.endPointURL(),[],null,this.headers),this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=t=>this.onConnError(t),this.conn.onmessage=t=>this.onConnMessage(t),this.conn.onclose=t=>this.onConnClose(t))}log(t,e,r){this.logger(t,e,r)}onOpen(t){this.stateChangeCallbacks.open.push(t)}onClose(t){this.stateChangeCallbacks.close.push(t)}onError(t){this.stateChangeCallbacks.error.push(t)}onMessage(t){this.stateChangeCallbacks.message.push(t)}onConnOpen(){this.log("transport","connected to "+this.endPointURL()),this.flushSendBuffer(),this.reconnectTimer.reset(),this.conn.skipHeartbeat||(clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.stateChangeCallbacks.open.forEach(t=>t())}onConnClose(t){this.log("transport","close",t),this.triggerChanError(),clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(e=>e(t))}onConnError(t){this.log("transport",t),this.triggerChanError(),this.stateChangeCallbacks.error.forEach(e=>e(t))}triggerChanError(){this.channels.forEach(t=>t.trigger(o.error))}connectionState(){switch(this.conn&&this.conn.readyState){case s.connecting:return"connecting";case s.open:return"open";case s.closing:return"closing";default:return"closed"}}isConnected(){return"open"===this.connectionState()}remove(t){this.channels=this.channels.filter(e=>e.joinRef()!==t.joinRef())}channel(t,e={}){let r=new f(t,e,this);return this.channels.push(r),r}push(t){let{topic:e,event:r,payload:n,ref:o}=t,i=()=>{this.encode(t,t=>{this.conn.send(t)})};this.log("push",`${e} ${r} (${o})`,n),this.isConnected()?i():this.sendBuffer.push(i)}makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}sendHeartbeat(){if(this.isConnected()){if(this.pendingHeartbeatRef)return this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),void this.conn.close(c,"hearbeat timeout");this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef})}}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}onConnMessage(t){this.decode(t.data,t=>{let{topic:e,event:r,payload:n,ref:o}=t;o&&o===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null),this.log("receive",`${n.status||""} ${e} ${r} ${o&&"("+o+")"||""}`,n),this.channels.filter(t=>t.isMember(e)).forEach(t=>t.trigger(r,n,o)),this.stateChangeCallbacks.message.forEach(e=>e(t))})}}},function(t,e,r){"use strict";const n=r(15),o=r(16),i=r(17);function s(t){if("string"!=typeof t||1!==t.length)throw new TypeError("arrayFormatSeparator must be single character string")}function a(t,e){return e.encode?e.strict?n(t):encodeURIComponent(t):t}function c(t,e){return e.decode?o(t):t}function u(t){const e=t.indexOf("#");return-1!==e&&(t=t.slice(0,e)),t}function l(t){const e=(t=u(t)).indexOf("?");return-1===e?"":t.slice(e+1)}function h(t,e){return e.parseNumbers&&!Number.isNaN(Number(t))&&"string"==typeof t&&""!==t.trim()?t=Number(t):!e.parseBooleans||null===t||"true"!==t.toLowerCase()&&"false"!==t.toLowerCase()||(t="true"===t.toLowerCase()),t}function f(t,e){s((e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e)).arrayFormatSeparator);const r=function(t){let e;switch(t.arrayFormat){case"index":return(t,r,n)=>{e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),e?(void 0===n[t]&&(n[t]={}),n[t][e[1]]=r):n[t]=r};case"bracket":return(t,r,n)=>{e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),e?void 0!==n[t]?n[t]=[].concat(n[t],r):n[t]=[r]:n[t]=r};case"comma":case"separator":return(e,r,n)=>{const o="string"==typeof r&&r.split("").indexOf(t.arrayFormatSeparator)>-1?r.split(t.arrayFormatSeparator).map(e=>c(e,t)):null===r?r:c(r,t);n[e]=o};default:return(t,e,r)=>{void 0!==r[t]?r[t]=[].concat(r[t],e):r[t]=e}}}(e),n=Object.create(null);if("string"!=typeof t)return n;if(!(t=t.trim().replace(/^[?#&]/,"")))return n;for(const o of t.split("&")){let[t,s]=i(e.decode?o.replace(/\+/g," "):o,"=");s=void 0===s?null:["comma","separator"].includes(e.arrayFormat)?s:c(s,e),r(c(t,e),s,n)}for(const t of Object.keys(n)){const r=n[t];if("object"==typeof r&&null!==r)for(const t of Object.keys(r))r[t]=h(r[t],e);else n[t]=h(r,e)}return!1===e.sort?n:(!0===e.sort?Object.keys(n).sort():Object.keys(n).sort(e.sort)).reduce((t,e)=>{const r=n[e];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?t[e]=function t(e){return Array.isArray(e)?e.sort():"object"==typeof e?t(Object.keys(e)).sort((t,e)=>Number(t)-Number(e)).map(t=>e[t]):e}(r):t[e]=r,t},Object.create(null))}e.extract=l,e.parse=f,e.stringify=(t,e)=>{if(!t)return"";s((e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e)).arrayFormatSeparator);const r=r=>e.skipNull&&null==t[r]||e.skipEmptyString&&""===t[r],n=function(t){switch(t.arrayFormat){case"index":return e=>(r,n)=>{const o=r.length;return void 0===n||t.skipNull&&null===n||t.skipEmptyString&&""===n?r:null===n?[...r,[a(e,t),"[",o,"]"].join("")]:[...r,[a(e,t),"[",a(o,t),"]=",a(n,t)].join("")]};case"bracket":return e=>(r,n)=>void 0===n||t.skipNull&&null===n||t.skipEmptyString&&""===n?r:null===n?[...r,[a(e,t),"[]"].join("")]:[...r,[a(e,t),"[]=",a(n,t)].join("")];case"comma":case"separator":return e=>(r,n)=>null==n||0===n.length?r:0===r.length?[[a(e,t),"=",a(n,t)].join("")]:[[r,a(n,t)].join(t.arrayFormatSeparator)];default:return e=>(r,n)=>void 0===n||t.skipNull&&null===n||t.skipEmptyString&&""===n?r:null===n?[...r,a(e,t)]:[...r,[a(e,t),"=",a(n,t)].join("")]}}(e),o={};for(const e of Object.keys(t))r(e)||(o[e]=t[e]);const i=Object.keys(o);return!1!==e.sort&&i.sort(e.sort),i.map(r=>{const o=t[r];return void 0===o?"":null===o?a(r,e):Array.isArray(o)?o.reduce(n(r),[]).join("&"):a(r,e)+"="+a(o,e)}).filter(t=>t.length>0).join("&")},e.parseUrl=(t,e)=>{e=Object.assign({decode:!0},e);const[r,n]=i(t,"#");return Object.assign({url:r.split("?")[0]||"",query:f(l(t),e)},e&&e.parseFragmentIdentifier&&n?{fragmentIdentifier:c(n,e)}:{})},e.stringifyUrl=(t,r)=>{r=Object.assign({encode:!0,strict:!0},r);const n=u(t.url).split("?")[0]||"",o=e.extract(t.url),i=e.parse(o,{sort:!1}),s=Object.assign(i,t.query);let c=e.stringify(s,r);c&&(c="?"+c);let l=function(t){let e="";const r=t.indexOf("#");return-1!==r&&(e=t.slice(r)),e}(t.url);return t.fragmentIdentifier&&(l="#"+a(t.fragmentIdentifier,r)),`${n}${c}${l}`}},function(t,e,r){"use strict";t.exports=t=>encodeURIComponent(t).replace(/[!'()*]/g,t=>"%"+t.charCodeAt(0).toString(16).toUpperCase())},function(t,e,r){"use strict";var n=new RegExp("%[a-f0-9]{2}","gi"),o=new RegExp("(%[a-f0-9]{2})+","gi");function i(t,e){try{return decodeURIComponent(t.join(""))}catch(t){}if(1===t.length)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],i(r),i(n))}function s(t){try{return decodeURIComponent(t)}catch(o){for(var e=t.match(n),r=1;r<e.length;r++)e=(t=i(e,r).join("")).match(n);return t}}t.exports=function(t){if("string"!=typeof t)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch(e){return function(t){for(var e={"%FE%FF":"��","%FF%FE":"��"},r=o.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch(t){var n=s(r[0]);n!==r[0]&&(e[r[0]]=n)}r=o.exec(t)}e["%C2"]="�";for(var i=Object.keys(e),a=0;a<i.length;a++){var c=i[a];t=t.replace(new RegExp(c,"g"),e[c])}return t}(t)}}},function(t,e,r){"use strict";t.exports=(t,e)=>{if("string"!=typeof t||"string"!=typeof e)throw new TypeError("Expected the arguments to be of type `string`");if(""===e)return[t];const r=t.indexOf(e);return-1===r?[t]:[t.slice(0,r),t.slice(r+e.length)]}},function(t,e,r){var n;try{n=r(19)}catch(t){}finally{if(n||"undefined"==typeof window||(n=window),!n)throw new Error("Could not determine global this")}var o=n.WebSocket||n.MozWebSocket,i=r(20);function s(t,e){return e?new o(t,e):new o(t)}o&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(t){Object.defineProperty(s,t,{get:function(){return o[t]}})})),t.exports={w3cwebsocket:o?s:null,version:i}},function(t,e){var r=function(){if("object"==typeof self&&self)return self;if("object"==typeof window&&window)return window;throw new Error("Unable to resolve global `this`")};t.exports=function(){if(this)return this;if("object"==typeof globalThis&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch(t){return r()}try{return __global__||r()}finally{delete Object.prototype.__global__}}()},function(t,e,r){t.exports=r(21).version},function(t){t.exports=JSON.parse('{"_args":[["websocket@1.0.31","/Users/phamhieu/Documents/Projects/nodejs/supabase-js"]],"_from":"websocket@1.0.31","_id":"websocket@1.0.31","_inBundle":false,"_integrity":"sha512-VAouplvGKPiKFDTeCCO65vYHsyay8DqoBSlzIO3fayrfOgU94lQN5a1uWVnFrMLceTJw/+fQXR5PGbUVRaHshQ==","_location":"/websocket","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"websocket@1.0.31","name":"websocket","escapedName":"websocket","rawSpec":"1.0.31","saveSpec":null,"fetchSpec":"1.0.31"},"_requiredBy":["/@supabase/realtime-js"],"_resolved":"https://registry.npmjs.org/websocket/-/websocket-1.0.31.tgz","_spec":"1.0.31","_where":"/Users/phamhieu/Documents/Projects/nodejs/supabase-js","author":{"name":"Brian McKelvey","email":"theturtle32@gmail.com","url":"https://github.com/theturtle32"},"browser":"lib/browser.js","bugs":{"url":"https://github.com/theturtle32/WebSocket-Node/issues"},"config":{"verbose":false},"contributors":[{"name":"Iñaki Baz Castillo","email":"ibc@aliax.net","url":"http://dev.sipdoc.net"}],"dependencies":{"debug":"^2.2.0","es5-ext":"^0.10.50","nan":"^2.14.0","typedarray-to-buffer":"^3.1.5","yaeti":"^0.0.6"},"description":"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.","devDependencies":{"buffer-equal":"^1.0.0","faucet":"^0.0.1","gulp":"^4.0.2","gulp-jshint":"^2.0.4","jshint":"^2.0.0","jshint-stylish":"^2.2.1","tape":"^4.9.1"},"directories":{"lib":"./lib"},"engines":{"node":">=0.10.0"},"homepage":"https://github.com/theturtle32/WebSocket-Node","keywords":["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],"license":"Apache-2.0","main":"index","name":"websocket","repository":{"type":"git","url":"git+https://github.com/theturtle32/WebSocket-Node.git"},"scripts":{"gulp":"gulp","install":"(node-gyp rebuild 2> builderror.log) || (exit 0)","test":"faucet test/unit"},"version":"1.0.31"}')},function(t,e){var r={syncState(t,e,r,n){let o=this.clone(t),i={},s={};return this.map(o,(t,r)=>{e[t]||(s[t]=r)}),this.map(e,(t,e)=>{let r=o[t];if(r){let n=e.metas.map(t=>t.phx_ref),o=r.metas.map(t=>t.phx_ref),a=e.metas.filter(t=>o.indexOf(t.phx_ref)<0),c=r.metas.filter(t=>n.indexOf(t.phx_ref)<0);a.length>0&&(i[t]=e,i[t].metas=a),c.length>0&&(s[t]=this.clone(r),s[t].metas=c)}else i[t]=e}),this.syncDiff(o,{joins:i,leaves:s},r,n)},syncDiff(t,{joins:e,leaves:r},n,o){let i=this.clone(t);return n||(n=function(){}),o||(o=function(){}),this.map(e,(t,e)=>{let r=i[t];i[t]=e,r&&i[t].metas.unshift(...r.metas),n(t,r,e)}),this.map(r,(t,e)=>{let r=i[t];if(!r)return;let n=e.metas.map(t=>t.phx_ref);r.metas=r.metas.filter(t=>n.indexOf(t.phx_ref)<0),o(t,r,e),0===r.metas.length&&delete i[t]}),i},list(t,e){return e||(e=function(t,e){return e}),this.map(t,(t,r)=>e(t,r))},map:(t,e)=>Object.getOwnPropertyNames(t).map(r=>e(r,t[r])),clone:t=>JSON.parse(JSON.stringify(t))};t.exports=r},function(t,e,r){var n,o,i;"undefined"==typeof globalThis?"undefined"==typeof self||self:globalThis,o=[e],void 0===(i="function"==typeof(n=function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toTimestampString=t.toArray=t.toJson=t.toIntRange=t.toInt=t.toFloat=t.toDateRange=t.toDate=t.toBoolean=t.noop=t.convertCell=t.convertColumn=t.convertChangeData=void 0,t.convertChangeData=function(t,r){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},o={},i=void 0===n.skipTypes?[]:n.skipTypes;return Object.entries(r).map(n=>{var[s,a]=n;o[s]=e(s,t,r,i)}),o};var e=(t,e,o,i)=>{var s=e.find(e=>e.name==t);return i.includes(s.type)?n(o[t]):r(s.type,o[t])};t.convertColumn=e;var r=(t,e)=>{try{if(null===e)return null;if("_"===t.charAt(0)){var r=t.slice(1,t.length);return l(e,r)}return"abstime"===t?n(e):"bool"===t?o(e):"date"===t?n(e):"daterange"===t?i(e):"float4"===t||"float8"===t?s(e):"int2"===t||"int4"===t?a(e):"int4range"===t?c(e):"int8"===t?a(e):"int8range"===t?c(e):"json"===t||"jsonb"===t?u(e):"money"===t||"numeric"===t?s(e):"oid"===t?a(e):"reltime"===t||"time"===t?n(e):"timestamp"===t?h(e):"timestamptz"===t||"timetz"===t?n(e):"tsrange"===t||"tstzrange"===t?i(e):n(e)}catch(r){return console.log("Could not convert cell of type ".concat(t," and value ").concat(e)),console.log("This is the error: ".concat(r)),e}};t.convertCell=r;var n=t=>t;t.noop=n;var o=t=>"t"===t||"f"!==t&&null;t.toBoolean=o,t.toDate=t=>new Date(t);var i=t=>{var e=JSON.parse(t);return[new Date(e[0]),new Date(e[1])]};t.toDateRange=i;var s=t=>parseFloat(t);t.toFloat=s;var a=t=>parseInt(t);t.toInt=a;var c=t=>{var e=JSON.parse(t);return[parseInt(e[0]),parseInt(e[1])]};t.toIntRange=c;var u=t=>JSON.parse(t);t.toJson=u;var l=(t,e)=>{var n=t.slice(1,t.length-1);return(0<n.length?n.split(","):[]).map(t=>r(e,t))};t.toArray=l;var h=t=>t.replace(" ","T");t.toTimestampString=h})?n.apply(e,o):n)||(t.exports=i)},function(t,e,r){var n=r(25);function o(){if("function"!=typeof WeakMap)return null;var t=new WeakMap;return o=function(){return t},t}t.exports=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==n(t)&&"function"!=typeof t)return{default:t};var e=o();if(e&&e.has(t))return e.get(t);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s)){var a=i?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(r,s,a):r[s]=t[s]}return r.default=t,e&&e.set(t,r),r}},function(t,e){function r(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=r=function(t){return typeof t}:t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(e)}t.exports=r},function(t,e,r){var n,o,i;"undefined"==typeof globalThis?"undefined"==typeof self||self:globalThis,o=[e,r(27),r(4)],void 0===(i="function"==typeof(n=function(t,e,n){"use strict";var o=r(6);Object.defineProperty(t,"__esModule",{value:!0}),t.Auth=void 0,e=o(e),n=o(n);var i=()=>"undefined"!=typeof window,s="supabase.auth.token";t.Auth=class{constructor(t,r){var o=Math.round,a=this,c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{autoRefreshToken:!0,persistSession:!0};this.authUrl=t,this.accessToken=r,this.refreshToken=null,this.supabaseKey=r,this.currentUser=null,this.autoRefreshToken=!(void 0!==c.autoRefreshToken)||c.autoRefreshToken,this.persistSession=!(void 0!==c.persistSession)||c.persistSession,this.signup=function(){var r=(0,e.default)((function*(e,r){a.removeSavedSession();var i=yield n.default.post("".concat(t,"/signup"),{email:e,password:r}).set("accept","json").set("apikey",a.supabaseKey);if(200===i.status&&i.body.user.confirmed_at){a.accessToken=i.body.access_token,a.refreshToken=i.body.refresh_token,a.currentUser=i.body.user;var s=i.body.expires_in;if(a.autoRefreshToken&&s&&setTimeout(a.callRefreshToken,1e3*(s-60)),a.persistSession){var c=o(Date.now()/1e3);a.saveSession(a.accessToken,a.refreshToken,c+s,a.currentUser)}}return i}));return function(){return r.apply(this,arguments)}}(),this.login=function(){var r=(0,e.default)((function*(e,r){a.removeSavedSession();var i=yield n.default.post("".concat(t,"/token?grant_type=password"),{email:e,password:r}).set("accept","json").set("apikey",a.supabaseKey);if(200===i.status){a.accessToken=i.body.access_token,a.refreshToken=i.body.refresh_token,a.currentUser=i.body.user;var s=i.body.expires_in;if(a.autoRefreshToken&&s&&setTimeout(a.callRefreshToken,1e3*(s-60)),a.persistSession){var c=o(Date.now()/1e3);a.saveSession(a.accessToken,a.refreshToken,c+s,a.currentUser)}}return i}));return function(){return r.apply(this,arguments)}}(),this.callRefreshToken=(0,e.default)((function*(){var e=yield n.default.post("".concat(t,"/token?grant_type=refresh_token"),{refresh_token:a.refreshToken}).set("accept","json").set("apikey",a.supabaseKey);if(200===e.status){a.accessToken=e.body.access_token,a.refreshToken=e.body.refresh_token;var r=e.body.expires_in;if(a.autoRefreshToken&&r&&setTimeout(a.callRefreshToken,1e3*(r-60)),a.persistSession){var i=o(Date.now()/1e3);a.saveSession(a.accessToken,a.refreshToken,i+r,a.currentUser)}}return e})),this.logout=(0,e.default)((function*(){yield n.default.post("".concat(t,"/logout")).set("Authorization","Bearer ".concat(a.accessToken)).set("apikey",a.supabaseKey),a.removeSavedSession()})),this.user=(0,e.default)((function*(){if(a.currentUser)return a.currentUser;var e=yield n.default.get("".concat(t,"/user")).set("Authorization","Bearer ".concat(a.accessToken)).set("apikey",a.supabaseKey);return 200===e.status&&(a.currentUser=e.body,a.currentUser.access_token=a.accessToken,a.currentUser.refresh_token=a.refreshToken),a.currentUser})),this.saveSession=(t,e,r,n)=>{i()&&localStorage.setItem(s,JSON.stringify({accessToken:t,refreshToken:e,expiresAt:r,currentUser:n}))},this.removeSavedSession=()=>{this.currentUser=null,this.refreshToken=null,this.accessToken=this.supabaseKey,i()&&localStorage.removeItem(s)},this.authHeader=()=>{var t=i()&&localStorage.getItem(s),e=t?JSON.parse(t):null;return(null==e?void 0:e.accessToken)?"Bearer ".concat(e.accessToken):this.accessToken?"Bearer ".concat(this.accessToken):null},this.recoverSession=()=>{var t=i()&&localStorage.getItem(s);if(t)try{var e=JSON.parse(t),{accessToken:r,refreshToken:n,currentUser:a,expiresAt:c}=e,u=o(Date.now()/1e3);c<u?(console.log("saved session has expired"),this.removeSavedSession()):(this.accessToken=r,this.refreshToken=n,this.currentUser=a,setTimeout(this.callRefreshToken,1e3*(c-u-60)))}catch(t){return console.error(t),null}return null},this.recoverSession()}}})?n.apply(e,o):n)||(t.exports=i)},function(t,e){function r(t,e,r,n,o,i,s){try{var a=t[i](s),c=a.value}catch(t){return void r(t)}a.done?e(c):Promise.resolve(c).then(n,o)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var s=t.apply(e,n);function a(t){r(s,o,i,a,c,"next",t)}function c(t){r(s,o,i,a,c,"throw",t)}a(void 0)}))}}},function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var o=0;o<n.length;o++)if((r=n[o])===e||r.fn===e){n.splice(o,1);break}return 0===n.length&&delete this._callbacks["$"+t],this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){n=0;for(var o=(r=r.slice(0)).length;n<o;++n)r[n].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e){t.exports=o,o.default=o,o.stable=s,o.stableStringify=s;var r=[],n=[];function o(t,e,o){var i;for(!function t(e,o,i,s){var a;if("object"==typeof e&&null!==e){for(a=0;a<i.length;a++)if(i[a]===e){var c=Object.getOwnPropertyDescriptor(s,o);return void(void 0!==c.get?c.configurable?(Object.defineProperty(s,o,{value:"[Circular]"}),r.push([s,o,e,c])):n.push([e,o]):(s[o]="[Circular]",r.push([s,o,e])))}if(i.push(e),Array.isArray(e))for(a=0;a<e.length;a++)t(e[a],a,i,e);else{var u=Object.keys(e);for(a=0;a<u.length;a++){var l=u[a];t(e[l],l,i,e)}}i.pop()}}(t,"",[],void 0),i=0===n.length?JSON.stringify(t,e,o):JSON.stringify(t,a(e),o);0!==r.length;){var s=r.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}return i}function i(t,e){return t<e?-1:t>e?1:0}function s(t,e,o){var s,c=function t(e,o,s,a){var c;if("object"==typeof e&&null!==e){for(c=0;c<s.length;c++)if(s[c]===e){var u=Object.getOwnPropertyDescriptor(a,o);return void(void 0!==u.get?u.configurable?(Object.defineProperty(a,o,{value:"[Circular]"}),r.push([a,o,e,u])):n.push([e,o]):(a[o]="[Circular]",r.push([a,o,e])))}if("function"==typeof e.toJSON)return;if(s.push(e),Array.isArray(e))for(c=0;c<e.length;c++)t(e[c],c,s,e);else{var l={},h=Object.keys(e).sort(i);for(c=0;c<h.length;c++){var f=h[c];t(e[f],f,s,e),l[f]=e[f]}if(void 0===a)return l;r.push([a,o,e]),a[o]=l}s.pop()}}(t,"",[],void 0)||t;for(s=0===n.length?JSON.stringify(c,e,o):JSON.stringify(c,a(e),o);0!==r.length;){var u=r.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}return s}function a(t){return t=void 0!==t?t:function(t,e){return e},function(e,r){if(n.length>0)for(var o=0;o<n.length;o++){var i=n[o];if(i[1]===e&&i[0]===r){r="[Circular]",n.splice(o,1);break}}return t.call(this,e,r)}}},function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var o=r(5);function i(t){if(t)return function(t){for(var e in i.prototype)Object.prototype.hasOwnProperty.call(i.prototype,e)&&(t[e]=i.prototype[e]);return t}(t)}t.exports=i,i.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},i.prototype.parse=function(t){return this._parser=t,this},i.prototype.responseType=function(t){return this._responseType=t,this},i.prototype.serialize=function(t){return this._serializer=t,this},i.prototype.timeout=function(t){if(!t||"object"!==n(t))return this._timeout=t,this._responseTimeout=0,this._uploadTimeout=0,this;for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;case"upload":this._uploadTimeout=t.upload;break;default:console.warn("Unknown timeout option",e)}return this},i.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var s=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&e.status>=500&&501!==e.status)return!0;if(t){if(t.code&&s.includes(t.code))return!0;if(t.timeout&&"ECONNABORTED"===t.code)return!0;if(t.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},i.prototype.then=function(t,e){var r=this;if(!this._fullfilledPromise){var n=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(t,e){n.on("abort",(function(){if(!(r._maxRetries&&r._maxRetries>r._retries))if(r.timedout&&r.timedoutError)e(r.timedoutError);else{var t=new Error("Aborted");t.code="ABORTED",t.status=r.status,t.method=r.method,t.url=r.url,e(t)}})),n.end((function(r,n){r?e(r):t(n)}))}))}return this._fullfilledPromise.then(t,e)},i.prototype.catch=function(t){return this.then(void 0,t)},i.prototype.use=function(t){return t(this),this},i.prototype.ok=function(t){if("function"!=typeof t)throw new Error("Callback required");return this._okCallback=t,this},i.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},i.prototype.get=function(t){return this._header[t.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(t,e){if(o(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},i.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},i.prototype.field=function(t,e){if(null==t)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(o(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(r,t[r]);return this}if(Array.isArray(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(t,e[n]);return this}if(null==e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=String(e)),this._getFormData().append(t,e),this},i.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},i.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic ".concat(n("".concat(t,":").concat(e))));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer ".concat(t))}return this},i.prototype.withCredentials=function(t){return void 0===t&&(t=!0),this._withCredentials=t,this},i.prototype.redirects=function(t){return this._maxRedirects=t,this},i.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw new TypeError("Invalid argument");return this._maxResponseSize=t,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(t){var e=o(t),r=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(e&&o(this._data))for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(this._data[n]=t[n]);else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"===r?this._data?"".concat(this._data,"&").concat(t):t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)||r||this.type("json"),this},i.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},i.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.includes("?")?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.slice(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.slice(0,e)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.warn("Unsupported")},i.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error("".concat(t+e,"ms exceeded"));n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.timedoutError=n,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))}},function(t,e,r){"use strict";var n=r(32);function o(t){if(t)return function(t){for(var e in o.prototype)Object.prototype.hasOwnProperty.call(o.prototype,e)&&(t[e]=o.prototype[e]);return t}(t)}t.exports=o,o.prototype.get=function(t){return this.header[t.toLowerCase()]},o.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(this[o]=r[o]);this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(t){}},o.prototype._setStatusProperties=function(t){var e=t/100|0;this.statusCode=t,this.status=this.statusCode,this.statusType=e,this.info=1===e,this.ok=2===e,this.redirect=3===e,this.clientError=4===e,this.serverError=5===e,this.error=(4===e||5===e)&&this.toError(),this.created=201===t,this.accepted=202===t,this.noContent=204===t,this.badRequest=400===t,this.unauthorized=401===t,this.notAcceptable=406===t,this.forbidden=403===t,this.notFound=404===t,this.unprocessableEntity=422===t}},function(t,e,r){"use strict";e.type=function(t){return t.split(/ *; */).shift()},e.params=function(t){return t.split(/ *; */).reduce((function(t,e){var r=e.split(/ *= */),n=r.shift(),o=r.shift();return n&&o&&(t[n]=o),t}),{})},e.parseLinks=function(t){return t.split(/ *, */).reduce((function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t}),{})},e.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},function(t,e,r){"use strict";function n(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(){this._defaults=[]}["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert","disableTLSCerts"].forEach((function(t){i.prototype[t]=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return this._defaults.push({fn:t,args:r}),this}})),i.prototype._setDefaults=function(t){this._defaults.forEach((function(e){t[e.fn].apply(t,n(e.args))}))},t.exports=i},function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestClient=void 0;var o=c(r(35)),i=c(r(7)),s=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==n(t)&&"function"!=typeof t)return{default:t};var e=a();if(e&&e.has(t))return e.get(t);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=o?Object.getOwnPropertyDescriptor(t,i):null;s&&(s.get||s.set)?Object.defineProperty(r,i,s):r[i]=t[i]}return r.default=t,e&&e.set(t,r),r}(r(0));function a(){if("function"!=typeof WeakMap)return null;var t=new WeakMap;return a=function(){return t},t}function c(t){return t&&t.__esModule?t:{default:t}}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e){for(var r,n=0;n<e.length;n++)(r=e[n]).enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}var h=function(){function t(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};u(this,t),this.restUrl=e,this.headers={},this.queryString=null,this.schema=null,r.headers&&(this.headers=r.headers),r.queryParams&&(this.queryString=s.objectToQueryString(r.queryParams)),r.schema&&(this.schema=r.schema)}return function(t,e,r){e&&l(t.prototype,e),r&&l(t,r)}(t,[{key:"from",value:function(t){var e="".concat(this.restUrl,"/").concat(t);return this.queryString&&(e+="?".concat(this.queryString)),new o.default(e,this.headers,this.schema)}},{key:"rpc",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,r="".concat(this.restUrl,"/rpc/").concat(t),n=this.headers;this.queryString&&(r+="?".concat(this.queryString)),this.schema&&(n["Content-Profile"]=this.schema);var o=new i.default("post",r,n);return null!=e&&o.send(e),o}}]),t}();e.PostgrestClient=h},function(t,e,r){"use strict";var n,o=(n=r(7))&&n.__esModule?n:{default:n};function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var r,n=0;n<e.length;n++)(r=e[n]).enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var a=function(){function t(e){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=2<arguments.length?arguments[2]:void 0;i(this,t),this.url=e,this.queryFilters=[],this.headers=r,this.schema=n}return function(t,e,r){e&&s(t.prototype,e),r&&s(t,r)}(t,[{key:"request",value:function(t){return this.schema&&("GET"==t?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),new o.default(t,this.url,this.headers)}},{key:"addFilters",value:function(t){this.queryFilters.forEach((function(e){switch(e.filter){case"filter":t.filter(e.columnName,e.operator,e.criteria);break;case"not":t.not(e.columnName,e.operator,e.criteria);break;case"or":t.or(e.filters);break;case"match":t.match(e.query);break;case"order":t.order(e.columnName,e.ascending,e.nullsFirst);break;case"limit":t.limit(e.criteria,e.columnName);break;case"offset":t.offset(e.criteria,e.columnName);break;case"range":t.range(e.from,e.to);break;case"single":t.single()}}))}},{key:"filter",value:function(t,e,r){return this.queryFilters.push({filter:"filter",columnName:t,operator:e,criteria:r}),this}},{key:"not",value:function(t,e,r){return this.queryFilters.push({filter:"not",columnName:t,operator:e,criteria:r}),this}},{key:"or",value:function(t){return this.queryFilters.push({filter:"or",filters:t}),this}},{key:"match",value:function(t){return this.queryFilters.push({filter:"match",query:t}),this}},{key:"order",value:function(t){var e=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],r=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];return this.queryFilters.push({filter:"order",columnName:t,ascending:e,nullsFirst:r}),this}},{key:"limit",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return this.queryFilters.push({filter:"limit",criteria:t,columnName:e}),this}},{key:"offset",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return this.queryFilters.push({filter:"offset",columnName:e,criteria:t}),this}},{key:"range",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return this.queryFilters.push({filter:"range",from:t,to:e}),this}},{key:"single",value:function(){return this.queryFilters.push({filter:"single"}),this}},{key:"select",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"*",e=this.request("GET");return e.select(t),this.addFilters(e),e}},{key:"insert",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{upsert:!1},r=this.request("POST"),n=e.upsert?"return=representation,resolution=merge-duplicates":"return=representation";return r.set("Prefer",n),r.send(t),this.addFilters(r),r}},{key:"update",value:function(t){var e=this.request("PATCH");return Array.isArray(t)?{body:null,status:400,statusCode:400,statusText:"Data type should be an object."}:(e.set("Prefer","return=representation"),e.send(t),this.addFilters(e),e)}},{key:"delete",value:function(){var t=this.request("DELETE");return this.addFilters(t),t}}]),t}();["eq","neq","gt","lt","gte","lte","like","ilike","is","in","fts","plfts","phfts","wfts","cs","cd","ova","ovr","sl","sr","nxr","nxl","adj"].forEach((function(t){return a.prototype[t]=function(e,r){return this.filter(e,t,r),this}}));var c=a;e.default=c},function(t,e,r){"use strict";var n=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==o(t)&&"function"!=typeof t)return{default:t};var e=i();if(e&&e.has(t))return e.get(t);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s)){var a=n?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(r,s,a):r[s]=t[s]}return r.default=t,e&&e.set(t,r),r}(r(0));function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(){if("function"!=typeof WeakMap)return null;var t=new WeakMap;return i=function(){return t},t}Object.defineProperty(e,"__esModule",{value:!0}),e._eq=function(t,e){return"".concat(t,"=eq.").concat(e)},e._gt=function(t,e){return"".concat(t,"=gt.").concat(e)},e._lt=function(t,e){return"".concat(t,"=lt.").concat(e)},e._gte=function(t,e){return"".concat(t,"=gte.").concat(e)},e._lte=function(t,e){return"".concat(t,"=lte.").concat(e)},e._like=function(t,e){var r=e.replace(/%/g,"*");return"".concat(t,"=like.").concat(r)},e._ilike=function(t,e){var r=e.replace(/%/g,"*");return"".concat(t,"=ilike.").concat(r)},e._is=function(t,e){return"".concat(t,"=is.").concat(e)},e._in=function(t,e){var r=n.cleanFilterArray(e);return"".concat(t,"=in.(").concat(r.join(","),")")},e._neq=function(t,e){return"".concat(t,"=neq.").concat(e)},e._fts=function(t,e){return void 0===e.config?"".concat(t,"=fts.").concat(e.queryText):"".concat(t,"=fts(").concat(e.config,").").concat(e.queryText)},e._plfts=function(t,e){return void 0===e.config?"".concat(t,"=plfts.").concat(e.queryText):"".concat(t,"=plfts(").concat(e.config,").").concat(e.queryText)},e._phfts=function(t,e){return void 0===e.config?"".concat(t,"=phfts.").concat(e.queryText):"".concat(t,"=phfts(").concat(e.config,").").concat(e.queryText)},e._wfts=function(t,e){return void 0===e.config?"".concat(t,"=wfts.").concat(e.queryText):"".concat(t,"=wfts(").concat(e.config,").").concat(e.queryText)},e._cs=function(t,e){if(Array.isArray(e)){var r=n.cleanFilterArray(e);return"".concat(t,"=cs.{").concat(r.join(","),"}")}return"".concat(t,"=cs.").concat(JSON.stringify(e))},e._cd=function(t,e){if(Array.isArray(e)){var r=n.cleanFilterArray(e);return"".concat(t,"=cd.{").concat(r.join(","),"}")}return"".concat(t,"=cd.").concat(JSON.stringify(e))},e._ova=function(t,e){var r=n.cleanFilterArray(e);return"".concat(t,"=ov.{").concat(r.join(","),"}")},e._ovr=function(t,e){return"".concat(t,"=ov.(").concat(e.join(","),")")},e._sl=function(t,e){return"".concat(t,"=sl.(").concat(e.join(","),")")},e._sr=function(t,e){return"".concat(t,"=sr.(").concat(e.join(","),")")},e._nxl=function(t,e){return"".concat(t,"=nxl.(").concat(e.join(","),")")},e._nxr=function(t,e){return"".concat(t,"=nxr.(").concat(e.join(","),")")},e._adj=function(t,e){return"".concat(t,"=adj.(").concat(e.join(","),")")},e._or=function(t){return"or=(".concat(t,")")}}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment