diff --git a/.github/workflows/test-push.yml b/.github/workflows/test-push.yml
new file mode 100644
index 0000000..77d2387
--- /dev/null
+++ b/.github/workflows/test-push.yml
@@ -0,0 +1,17 @@
+name: Test PUSH action
+on: push
+jobs:
+ test:
+ runs-on: ubuntu-latest #nodejs preinstalled on the ubuntu runner
+ steps:
+ #action needs specific access to download the code from the repository onto this runner or this server
+ - name: Get code
+ uses: actions/checkout@v4
+ - name: Install NodeJS
+ uses: actions/setup-node@v4
+ with:
+ node-version: 18
+ - name: Install dependencies
+ run: npm ci #npm ci is best practice over npm i
+ - name: Run tests
+ run: npm test
\ No newline at end of file
diff --git a/flake-guard-app/.gitignore b/flake-guard-app/.gitignore
index a682e36..cec19d1 100644
--- a/flake-guard-app/.gitignore
+++ b/flake-guard-app/.gitignore
@@ -2,6 +2,7 @@ node_modules
.env
.DS_Store
build/
-dist/
+dist/*
coverage/
-package-lock.json
\ No newline at end of file
+package-lock.json
+dist/
\ No newline at end of file
diff --git a/flake-guard-app/dist/591.bundle.js b/flake-guard-app/dist/591.bundle.js
new file mode 100644
index 0000000..080b45a
--- /dev/null
+++ b/flake-guard-app/dist/591.bundle.js
@@ -0,0 +1 @@
+"use strict";(self.webpackChunkflake_guard=self.webpackChunkflake_guard||[]).push([[591],{1591:e=>{e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}}}]);
\ No newline at end of file
diff --git a/flake-guard-app/dist/bundle.js b/flake-guard-app/dist/bundle.js
new file mode 100644
index 0000000..f8f4187
--- /dev/null
+++ b/flake-guard-app/dist/bundle.js
@@ -0,0 +1,2 @@
+/*! For license information please see bundle.js.LICENSE.txt */
+(()=>{var e,t,n,r,i={4603:(e,t,n)=>{"use strict";e.exports=n(3853)},907:(e,t,n)=>{"use strict";n.r(t),n.d(t,{Headers:()=>a,Request:()=>s,Response:()=>l,default:()=>o,fetch:()=>i});var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n.g)return n.g;throw new Error("unable to locate global object")}();const i=r.fetch,o=r.fetch.bind(r),a=r.Headers,s=r.Request,l=r.Response},6191:(e,t,n)=>{"use strict";n.r(t),n.d(t,{AuthAdminApi:()=>wt,AuthApiError:()=>Ue,AuthClient:()=>kt,AuthError:()=>Fe,AuthImplicitGrantRedirectError:()=>Ke,AuthInvalidCredentialsError:()=>Je,AuthInvalidTokenResponseError:()=>Ge,AuthPKCEGrantCodeExchangeError:()=>$e,AuthRetryableFetchError:()=>Ze,AuthSessionMissingError:()=>Ye,AuthUnknownError:()=>We,AuthWeakPasswordError:()=>Xe,CustomAuthError:()=>Ve,FunctionRegion:()=>s,FunctionsError:()=>r,FunctionsFetchError:()=>i,FunctionsHttpError:()=>a,FunctionsRelayError:()=>o,GoTrueAdminApi:()=>ut,GoTrueClient:()=>xt,NavigatorLockAcquireTimeoutError:()=>gt,REALTIME_CHANNEL_STATES:()=>U,REALTIME_LISTEN_TYPES:()=>F,REALTIME_POSTGRES_CHANGES_LISTEN_EVENT:()=>z,REALTIME_PRESENCE_LISTEN_EVENTS:()=>_,REALTIME_SUBSCRIBE_STATES:()=>B,RealtimeChannel:()=>H,RealtimeClient:()=>Y,RealtimePresence:()=>P,SupabaseClient:()=>Ct,createClient:()=>At,isAuthApiError:()=>He,isAuthError:()=>Be,isAuthRetryableFetchError:()=>qe,isAuthWeakPasswordError:()=>Qe,lockInternals:()=>ft,navigatorLock:()=>mt});class r extends Error{constructor(e,t="FunctionsError",n){super(e),this.name=t,this.context=n}}class i extends r{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class o extends r{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class a extends r{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var s;!function(e){e.Any="any",e.ApNortheast1="ap-northeast-1",e.ApNortheast2="ap-northeast-2",e.ApSouth1="ap-south-1",e.ApSoutheast1="ap-southeast-1",e.ApSoutheast2="ap-southeast-2",e.CaCentral1="ca-central-1",e.EuCentral1="eu-central-1",e.EuWest1="eu-west-1",e.EuWest2="eu-west-2",e.EuWest3="eu-west-3",e.SaEast1="sa-east-1",e.UsEast1="us-east-1",e.UsWest1="us-west-1",e.UsWest2="us-west-2"}(s||(s={}));class l{constructor(e,{headers:t={},customFetch:r,region:i=s.Any}={}){this.url=e,this.headers=t,this.region=i,this.fetch=(e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>Promise.resolve().then(n.bind(n,907)).then((({default:t})=>t(...e))):fetch),(...e)=>t(...e)})(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var n,r,s,l,c;return r=this,s=void 0,c=function*(){try{const{headers:r,method:s,body:l}=t;let c,u={},{region:d}=t;d||(d=this.region),d&&"any"!==d&&(u["x-region"]=d),l&&(r&&!Object.prototype.hasOwnProperty.call(r,"Content-Type")||!r)&&("undefined"!=typeof Blob&&l instanceof Blob||l instanceof ArrayBuffer?(u["Content-Type"]="application/octet-stream",c=l):"string"==typeof l?(u["Content-Type"]="text/plain",c=l):"undefined"!=typeof FormData&&l instanceof FormData?c=l:(u["Content-Type"]="application/json",c=JSON.stringify(l)));const h=yield this.fetch(`${this.url}/${e}`,{method:s||"POST",headers:Object.assign(Object.assign(Object.assign({},u),this.headers),r),body:c}).catch((e=>{throw new i(e)})),f=h.headers.get("x-relay-error");if(f&&"true"===f)throw new o(h);if(!h.ok)throw new a(h);let p,g=(null!==(n=h.headers.get("Content-Type"))&&void 0!==n?n:"text/plain").split(";")[0].trim();return p="application/json"===g?yield h.json():"application/octet-stream"===g?yield h.blob():"text/event-stream"===g?h:"multipart/form-data"===g?yield h.formData():yield h.text(),{data:p,error:null}}catch(e){return{data:null,error:e}}},new((l=void 0)||(l=Promise))((function(e,t){function n(e){try{o(c.next(e))}catch(e){t(e)}}function i(e){try{o(c.throw(e))}catch(e){t(e)}}function o(t){var r;t.done?e(t.value):(r=t.value,r instanceof l?r:new l((function(e){e(r)}))).then(n,i)}o((c=c.apply(r,s||[])).next())}))}}var c=n(907);class u extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}}class d{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:"undefined"==typeof fetch?this.fetch=c.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}then(e,t){void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),"GET"!==this.method&&"HEAD"!==this.method&&(this.headers["Content-Type"]="application/json");let n=(0,this.fetch)(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then((async e=>{var t,n,r;let i=null,o=null,a=null,s=e.status,l=e.statusText;if(e.ok){if("HEAD"!==this.method){const t=await e.text();""===t||(o="text/csv"===this.headers.Accept||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?t:JSON.parse(t))}const r=null===(t=this.headers.Prefer)||void 0===t?void 0:t.match(/count=(exact|planned|estimated)/),c=null===(n=e.headers.get("content-range"))||void 0===n?void 0:n.split("/");r&&c&&c.length>1&&(a=parseInt(c[1])),this.isMaybeSingle&&"GET"===this.method&&Array.isArray(o)&&(o.length>1?(i={code:"PGRST116",details:`Results contain ${o.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},o=null,a=null,s=406,l="Not Acceptable"):o=1===o.length?o[0]:null)}else{const t=await e.text();try{i=JSON.parse(t),Array.isArray(i)&&404===e.status&&(o=[],i=null,s=200,l="OK")}catch(n){404===e.status&&""===t?(s=204,l="No Content"):i={message:t}}if(i&&this.isMaybeSingle&&(null===(r=null==i?void 0:i.details)||void 0===r?void 0:r.includes("0 rows"))&&(i=null,s=200,l="OK"),i&&this.shouldThrowOnError)throw new u(i)}return{error:i,data:o,count:a,status:s,statusText:l}}));return this.shouldThrowOnError||(n=n.catch((e=>{var t,n,r;return{error:{message:`${null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"FetchError"}: ${null==e?void 0:e.message}`,details:`${null!==(n=null==e?void 0:e.stack)&&void 0!==n?n:""}`,hint:"",code:`${null!==(r=null==e?void 0:e.code)&&void 0!==r?r:""}`},data:null,count:null,status:0,statusText:""}}))),n.then(e,t)}}class h extends d{select(e){let t=!1;const n=(null!=e?e:"*").split("").map((e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e))).join("");return this.url.searchParams.set("select",n),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:r,referencedTable:i=r}={}){const o=i?`${i}.order`:"order",a=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${void 0===n?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){const r=void 0===n?"limit":`${n}.limit`;return this.url.searchParams.set(r,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:r=n}={}){const i=void 0===r?"offset":`${r}.offset`,o=void 0===r?"limit":`${r}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(o,""+(t-e+1)),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return"GET"===this.method?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:r=!1,wal:i=!1,format:o="text"}={}){var a;const s=[e?"analyze":null,t?"verbose":null,n?"settings":null,r?"buffers":null,i?"wal":null].filter(Boolean).join("|"),l=null!==(a=this.headers.Accept)&&void 0!==a?a:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${o}; for="${l}"; options=${s};`,this}rollback(){var e;return(null!==(e=this.headers.Prefer)&&void 0!==e?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}}class f extends h{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){const n=Array.from(new Set(t)).map((e=>"string"==typeof e&&new RegExp("[,()]").test(e)?`"${e}"`:`${e}`)).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,t){return"string"==typeof t?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return"string"==typeof t?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return"string"==typeof t?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:n,type:r}={}){let i="";"plain"===r?i="pl":"phrase"===r?i="ph":"websearch"===r&&(i="w");const o=void 0===n?"":`(${n})`;return this.url.searchParams.append(e,`${i}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach((([e,t])=>{this.url.searchParams.append(e,`eq.${t}`)})),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){const r=n?`${n}.or`:"or";return this.url.searchParams.append(r,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}}class p{constructor(e,{headers:t={},schema:n,fetch:r}){this.url=e,this.headers=t,this.schema=n,this.fetch=r}select(e,{head:t=!1,count:n}={}){const r=t?"HEAD":"GET";let i=!1;const o=(null!=e?e:"*").split("").map((e=>/\s/.test(e)&&!i?"":('"'===e&&(i=!i),e))).join("");return this.url.searchParams.set("select",o),n&&(this.headers.Prefer=`count=${n}`),new f({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t,defaultToNull:n=!0}={}){const r=[];if(this.headers.Prefer&&r.push(this.headers.Prefer),t&&r.push(`count=${t}`),n||r.push("missing=default"),this.headers.Prefer=r.join(","),Array.isArray(e)){const t=e.reduce(((e,t)=>e.concat(Object.keys(t))),[]);if(t.length>0){const e=[...new Set(t)].map((e=>`"${e}"`));this.url.searchParams.set("columns",e.join(","))}}return new f({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:r,defaultToNull:i=!0}={}){const o=[`resolution=${n?"ignore":"merge"}-duplicates`];if(void 0!==t&&this.url.searchParams.set("on_conflict",t),this.headers.Prefer&&o.push(this.headers.Prefer),r&&o.push(`count=${r}`),i||o.push("missing=default"),this.headers.Prefer=o.join(","),Array.isArray(e)){const t=e.reduce(((e,t)=>e.concat(Object.keys(t))),[]);if(t.length>0){const e=[...new Set(t)].map((e=>`"${e}"`));this.url.searchParams.set("columns",e.join(","))}}return new f({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){const n=[];return this.headers.Prefer&&n.push(this.headers.Prefer),t&&n.push(`count=${t}`),this.headers.Prefer=n.join(","),new f({method:"PATCH",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){const t=[];return e&&t.push(`count=${e}`),this.headers.Prefer&&t.unshift(this.headers.Prefer),this.headers.Prefer=t.join(","),new f({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}const g={"X-Client-Info":"postgrest-js/1.15.2"};class m{constructor(e,{headers:t={},schema:n,fetch:r}={}){this.url=e,this.headers=Object.assign(Object.assign({},g),t),this.schemaName=n,this.fetch=r}from(e){const t=new URL(`${this.url}/${e}`);return new p(t,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new m(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:n=!1,get:r=!1,count:i}={}){let o;const a=new URL(`${this.url}/rpc/${e}`);let s;n||r?(o=n?"HEAD":"GET",Object.entries(t).filter((([e,t])=>void 0!==t)).map((([e,t])=>[e,Array.isArray(t)?`{${t.join(",")}}`:`${t}`])).forEach((([e,t])=>{a.searchParams.append(e,t)}))):(o="POST",s=t);const l=Object.assign({},this.headers);return i&&(l.Prefer=`count=${i}`),new f({method:o,url:a,headers:l,schema:this.schemaName,body:s,fetch:this.fetch,allowEmpty:!1})}}const b={"X-Client-Info":"realtime-js/2.9.5"};var y,v,x,w,k,_,C;!function(e){e[e.connecting=0]="connecting",e[e.open=1]="open",e[e.closing=2]="closing",e[e.closed=3]="closed"}(y||(y={})),function(e){e.closed="closed",e.errored="errored",e.joined="joined",e.joining="joining",e.leaving="leaving"}(v||(v={})),function(e){e.close="phx_close",e.error="phx_error",e.join="phx_join",e.reply="phx_reply",e.leave="phx_leave",e.access_token="access_token"}(x||(x={})),function(e){e.websocket="websocket"}(w||(w={})),function(e){e.Connecting="connecting",e.Open="open",e.Closing="closing",e.Closed="closed"}(k||(k={}));class A{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}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))}}class S{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t("string"==typeof e?JSON.parse(e):{})}_binaryDecode(e){const t=new DataView(e),n=new TextDecoder;return this._decodeBroadcast(e,t,n)}_decodeBroadcast(e,t,n){const r=t.getUint8(1),i=t.getUint8(2);let o=this.HEADER_LENGTH+2;const a=n.decode(e.slice(o,o+r));o+=r;const s=n.decode(e.slice(o,o+i));return o+=i,{ref:null,topic:a,event:s,payload:JSON.parse(n.decode(e.slice(o,e.byteLength)))}}}class E{constructor(e,t,n={},r=1e4){this.channel=e,this.event=t,this.payload=n,this.timeout=r,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",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,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var n;return this._hasReceived(e)&&t(null===(n=this.receivedResp)||void 0===n?void 0:n.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){this.timeoutTimer||(this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref),this.channel._on(this.refEvent,{},(e=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=e,this._matchReceive(e)})),this.timeoutTimer=setTimeout((()=>{this.trigger("timeout",{})}),this.timeout))}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter((t=>t.status===e)).forEach((e=>e.callback(t)))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}!function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"}(_||(_={}));class P{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const n=(null==t?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},(e=>{const{onJoin:t,onLeave:n,onSync:r}=this.caller;this.joinRef=this.channel._joinRef(),this.state=P.syncState(this.state,e,t,n),this.pendingDiffs.forEach((e=>{this.state=P.syncDiff(this.state,e,t,n)})),this.pendingDiffs=[],r()})),this.channel._on(n.diff,{},(e=>{const{onJoin:t,onLeave:n,onSync:r}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(e):(this.state=P.syncDiff(this.state,e,t,n),r())})),this.onJoin(((e,t,n)=>{this.channel._trigger("presence",{event:"join",key:e,currentPresences:t,newPresences:n})})),this.onLeave(((e,t,n)=>{this.channel._trigger("presence",{event:"leave",key:e,currentPresences:t,leftPresences:n})})),this.onSync((()=>{this.channel._trigger("presence",{event:"sync"})}))}static syncState(e,t,n,r){const i=this.cloneDeep(e),o=this.transformState(t),a={},s={};return this.map(i,((e,t)=>{o[e]||(s[e]=t)})),this.map(o,((e,t)=>{const n=i[e];if(n){const r=t.map((e=>e.presence_ref)),i=n.map((e=>e.presence_ref)),o=t.filter((e=>i.indexOf(e.presence_ref)<0)),l=n.filter((e=>r.indexOf(e.presence_ref)<0));o.length>0&&(a[e]=o),l.length>0&&(s[e]=l)}else a[e]=t})),this.syncDiff(i,{joins:a,leaves:s},n,r)}static syncDiff(e,t,n,r){const{joins:i,leaves:o}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return n||(n=()=>{}),r||(r=()=>{}),this.map(i,((t,r)=>{var i;const o=null!==(i=e[t])&&void 0!==i?i:[];if(e[t]=this.cloneDeep(r),o.length>0){const n=e[t].map((e=>e.presence_ref)),r=o.filter((e=>n.indexOf(e.presence_ref)<0));e[t].unshift(...r)}n(t,o,r)})),this.map(o,((t,n)=>{let i=e[t];if(!i)return;const o=n.map((e=>e.presence_ref));i=i.filter((e=>o.indexOf(e.presence_ref)<0)),e[t]=i,r(t,i,n),0===i.length&&delete e[t]})),e}static map(e,t){return Object.getOwnPropertyNames(e).map((n=>t(n,e[n])))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce(((t,n)=>{const r=e[n];return t[n]="metas"in r?r.metas.map((e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))):r,t}),{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}!function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"}(C||(C={}));const O=(e,t,n={})=>{var r;const i=null!==(r=n.skipTypes)&&void 0!==r?r:[];return Object.keys(t).reduce(((n,r)=>(n[r]=R(r,e,t,i),n)),{})},R=(e,t,n,r)=>{const i=t.find((t=>t.name===e)),o=null==i?void 0:i.type,a=n[e];return o&&!r.includes(o)?j(o,a):I(a)},j=(e,t)=>{if("_"===e.charAt(0)){const n=e.slice(1,e.length);return D(t,n)}switch(e){case C.bool:return T(t);case C.float4:case C.float8:case C.int2:case C.int4:case C.int8:case C.numeric:case C.oid:return M(t);case C.json:case C.jsonb:return N(t);case C.timestamp:return L(t);case C.abstime:case C.date:case C.daterange:case C.int4range:case C.int8range:case C.money:case C.reltime:case C.text:case C.time:case C.timestamptz:case C.timetz:case C.tsrange:case C.tstzrange:default:return I(t)}},I=e=>e,T=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},M=e=>{if("string"==typeof e){const t=parseFloat(e);if(!Number.isNaN(t))return t}return e},N=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(t){return console.log(`JSON parse error: ${t}`),e}return e},D=(e,t)=>{if("string"!=typeof e)return e;const n=e.length-1,r=e[n];if("{"===e[0]&&"}"===r){let r;const i=e.slice(1,n);try{r=JSON.parse("["+i+"]")}catch(e){r=i?i.split(","):[]}return r.map((e=>j(t,e)))}return e},L=e=>"string"==typeof e?e.replace(" ","T"):e;var z,F,B;!function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"}(z||(z={})),function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes"}(F||(F={})),function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"}(B||(B={}));const U=v;class H{constructor(e,t={config:{}},n){this.topic=e,this.params=t,this.socket=n,this.bindings={},this.state=v.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""}},t.config),this.timeout=this.socket.timeout,this.joinPush=new E(this,x.join,this.params,this.timeout),this.rejoinTimer=new A((()=>this._rejoinUntilConnected()),this.socket.reconnectAfterMs),this.joinPush.receive("ok",(()=>{this.state=v.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach((e=>e.send())),this.pushBuffer=[]})),this._onClose((()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=v.closed,this.socket._remove(this)})),this._onError((e=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,e),this.state=v.errored,this.rejoinTimer.scheduleTimeout())})),this.joinPush.receive("timeout",(()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=v.errored,this.rejoinTimer.scheduleTimeout())})),this._on(x.reply,{},((e,t)=>{this._trigger(this._replyEventName(t),e)})),this.presence=new P(this),this.broadcastEndpointURL=this._broadcastEndpointURL()}subscribe(e,t=this.timeout){var n,r;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{config:{broadcast:i,presence:o}}=this.params;this._onError((t=>e&&e("CHANNEL_ERROR",t))),this._onClose((()=>e&&e("CLOSED")));const a={},s={broadcast:i,presence:o,postgres_changes:null!==(r=null===(n=this.bindings.postgres_changes)||void 0===n?void 0:n.map((e=>e.filter)))&&void 0!==r?r:[]};this.socket.accessToken&&(a.access_token=this.socket.accessToken),this.updateJoinPayload(Object.assign({config:s},a)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",(({postgres_changes:t})=>{var n;if(this.socket.accessToken&&this.socket.setAuth(this.socket.accessToken),void 0!==t){const r=this.bindings.postgres_changes,i=null!==(n=null==r?void 0:r.length)&&void 0!==n?n:0,o=[];for(let n=0;n{e&&e("CHANNEL_ERROR",new Error(JSON.stringify(Object.values(t).join(", ")||"error")))})).receive("timeout",(()=>{e&&e("TIMED_OUT")}))}return this}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,n){return this._on(e,t,n)}async send(e,t={}){var n,r;if(this._canPush()||"broadcast"!==e.type)return new Promise((n=>{var r,i,o;const a=this._push(e.type,e,t.timeout||this.timeout);"broadcast"!==e.type||(null===(o=null===(i=null===(r=this.params)||void 0===r?void 0:r.config)||void 0===i?void 0:i.broadcast)||void 0===o?void 0:o.ack)||n("ok"),a.receive("ok",(()=>n("ok"))),a.receive("error",(()=>n("error"))),a.receive("timeout",(()=>n("timed out")))}));{const{event:i,payload:o}=e,a={method:"POST",headers:{apikey:null!==(n=this.socket.apiKey)&&void 0!==n?n:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:o}]})};try{return(await this._fetchWithTimeout(this.broadcastEndpointURL,a,null!==(r=t.timeout)&&void 0!==r?r:this.timeout)).ok?"ok":"error"}catch(e){return"AbortError"===e.name?"timed out":"error"}}}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=v.leaving;const t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(x.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise((n=>{const r=new E(this,x.leave,{},e);r.receive("ok",(()=>{t(),n("ok")})).receive("timeout",(()=>{t(),n("timed out")})).receive("error",(()=>{n("error")})),r.send(),this._canPush()||r.trigger("ok",{})}))}_broadcastEndpointURL(){let e=this.socket.endPoint;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")+"/api/broadcast"}async _fetchWithTimeout(e,t,n){const r=new AbortController,i=setTimeout((()=>r.abort()),n),o=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:r.signal}));return clearTimeout(i),o}_push(e,t,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let r=new E(this,e,t,n);return this._canPush()?r.send():(r.startTimeout(),this.pushBuffer.push(r)),r}_onMessage(e,t,n){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,n){var r,i;const o=e.toLocaleLowerCase(),{close:a,error:s,leave:l,join:c}=x;if(n&&[a,s,l,c].indexOf(o)>=0&&n!==this._joinRef())return;let u=this._onMessage(o,t,n);if(t&&!u)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?null===(r=this.bindings.postgres_changes)||void 0===r||r.filter((e=>{var t,n,r;return"*"===(null===(t=e.filter)||void 0===t?void 0:t.event)||(null===(r=null===(n=e.filter)||void 0===n?void 0:n.event)||void 0===r?void 0:r.toLocaleLowerCase())===o})).map((e=>e.callback(u,n))):null===(i=this.bindings[o])||void 0===i||i.filter((e=>{var n,r,i,a,s,l;if(["broadcast","presence","postgres_changes"].includes(o)){if("id"in e){const o=e.id,a=null===(n=e.filter)||void 0===n?void 0:n.event;return o&&(null===(r=t.ids)||void 0===r?void 0:r.includes(o))&&("*"===a||(null==a?void 0:a.toLocaleLowerCase())===(null===(i=t.data)||void 0===i?void 0:i.type.toLocaleLowerCase()))}{const n=null===(s=null===(a=null==e?void 0:e.filter)||void 0===a?void 0:a.event)||void 0===s?void 0:s.toLocaleLowerCase();return"*"===n||n===(null===(l=null==t?void 0:t.event)||void 0===l?void 0:l.toLocaleLowerCase())}}return e.type.toLocaleLowerCase()===o})).map((e=>{if("object"==typeof u&&"ids"in u){const e=u.data,{schema:t,table:n,commit_timestamp:r,type:i,errors:o}=e,a={schema:t,table:n,commit_timestamp:r,eventType:i,new:{},old:{},errors:o};u=Object.assign(Object.assign({},a),this._getPayloadRecords(e))}e.callback(u,n)}))}_isClosed(){return this.state===v.closed}_isJoined(){return this.state===v.joined}_isJoining(){return this.state===v.joining}_isLeaving(){return this.state===v.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,n){const r=e.toLocaleLowerCase(),i={type:r,filter:t,callback:n};return this.bindings[r]?this.bindings[r].push(i):this.bindings[r]=[i],this}_off(e,t){const n=e.toLocaleLowerCase();return this.bindings[n]=this.bindings[n].filter((e=>{var r;return!((null===(r=e.type)||void 0===r?void 0:r.toLocaleLowerCase())===n&&H.isEqual(e.filter,t))})),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(x.close,{},e)}_onError(e){this._on(x.error,{},(t=>e(t)))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=v.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const t={new:{},old:{}};return"INSERT"!==e.type&&"UPDATE"!==e.type||(t.new=O(e.columns,e.record)),"UPDATE"!==e.type&&"DELETE"!==e.type||(t.old=O(e.columns,e.old_record)),t}}const W=()=>{},V="undefined"!=typeof WebSocket;class Y{constructor(e,t){var r;this.accessToken=null,this.apiKey=null,this.channels=[],this.endPoint="",this.headers=b,this.params={},this.timeout=1e4,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=W,this.conn=null,this.sendBuffer=[],this.serializer=new S,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this._resolveFetch=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>Promise.resolve().then(n.bind(n,907)).then((({default:t})=>t(...e))):fetch),(...e)=>t(...e)},this.endPoint=`${e}/${w.websocket}`,(null==t?void 0:t.transport)?this.transport=t.transport:this.transport=null,(null==t?void 0:t.params)&&(this.params=t.params),(null==t?void 0:t.headers)&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),(null==t?void 0:t.timeout)&&(this.timeout=t.timeout),(null==t?void 0:t.logger)&&(this.logger=t.logger),(null==t?void 0:t.heartbeatIntervalMs)&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);const i=null===(r=null==t?void 0:t.params)||void 0===r?void 0:r.apikey;i&&(this.accessToken=i,this.apiKey=i),this.reconnectAfterMs=(null==t?void 0:t.reconnectAfterMs)?t.reconnectAfterMs:e=>[1e3,2e3,5e3,1e4][e-1]||1e4,this.encode=(null==t?void 0:t.encode)?t.encode:(e,t)=>t(JSON.stringify(e)),this.decode=(null==t?void 0:t.decode)?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new A((async()=>{this.disconnect(),this.connect()}),this.reconnectAfterMs),this.fetch=this._resolveFetch(null==t?void 0:t.fetch)}connect(){if(!this.conn)if(this.transport)this.conn=new this.transport(this._endPointURL(),void 0,{headers:this.headers});else{if(V)return this.conn=new WebSocket(this._endPointURL()),void this.setupConnection();this.conn=new G(this._endPointURL(),void 0,{close:()=>{this.conn=null}}),n.e(591).then(n.t.bind(n,1591,23)).then((({default:e})=>{this.conn=new e(this._endPointURL(),void 0,{headers:this.headers}),this.setupConnection()}))}}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,null!=t?t:""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}async removeChannel(e){const t=await e.unsubscribe();return 0===this.channels.length&&this.disconnect(),t}async removeAllChannels(){const e=await Promise.all(this.channels.map((e=>e.unsubscribe())));return this.disconnect(),e}log(e,t,n){this.logger(e,t,n)}connectionState(){switch(this.conn&&this.conn.readyState){case y.connecting:return k.Connecting;case y.open:return k.Open;case y.closing:return k.Closing;default:return k.Closed}}isConnected(){return this.connectionState()===k.Open}channel(e,t={config:{}}){const n=new H(`realtime:${e}`,t,this);return this.channels.push(n),n}push(e){const{topic:t,event:n,payload:r,ref:i}=e,o=()=>{this.encode(e,(e=>{var t;null===(t=this.conn)||void 0===t||t.send(e)}))};this.log("push",`${t} ${n} (${i})`,r),this.isConnected()?o():this.sendBuffer.push(o)}setAuth(e){this.accessToken=e,this.channels.forEach((t=>{e&&t.updateJoinPayload({access_token:e}),t.joinedOnce&&t._isJoined()&&t._push(x.access_token,{access_token:e})}))}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let t=this.channels.find((t=>t.topic===e&&(t._isJoined()||t._isJoining())));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter((t=>t._joinRef()!==e._joinRef()))}setupConnection(){this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_endPointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:"1.0.0"}))}_onConnMessage(e){this.decode(e.data,(e=>{let{topic:t,event:n,payload:r,ref:i}=e;(i&&i===this.pendingHeartbeatRef||n===(null==r?void 0:r.type))&&(this.pendingHeartbeatRef=null),this.log("receive",`${r.status||""} ${t} ${n} ${i&&"("+i+")"||""}`,r),this.channels.filter((e=>e._isMember(t))).forEach((e=>e._trigger(n,r,i))),this.stateChangeCallbacks.message.forEach((t=>t(e)))}))}_onConnOpen(){this.log("transport",`connected to ${this._endPointURL()}`),this._flushSendBuffer(),this.reconnectTimer.reset(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval((()=>this._sendHeartbeat()),this.heartbeatIntervalMs),this.stateChangeCallbacks.open.forEach((e=>e()))}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach((t=>t(e)))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach((t=>t(e)))}_triggerChanError(){this.channels.forEach((e=>e._trigger(x.error)))}_appendParams(e,t){if(0===Object.keys(t).length)return e;const n=e.match(/\?/)?"&":"?";return`${e}${n}${new URLSearchParams(t)}`}_flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach((e=>e())),this.sendBuffer=[])}_sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef)return this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),void(null===(e=this.conn)||void 0===e||e.close(1e3,"hearbeat timeout"));this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth(this.accessToken)}}}class G{constructor(e,t,n){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=y.connecting,this.send=()=>{},this.url=null,this.url=e,this.close=n.close}}class J extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function K(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}class $ extends J{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class Z extends J{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}const q=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>Promise.resolve().then(n.bind(n,907)).then((({default:t})=>t(...e))):fetch),(...e)=>t(...e)};var X=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))};const Q=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),ee=(e,t)=>X(void 0,void 0,void 0,(function*(){const r=yield(i=void 0,o=void 0,a=void 0,s=function*(){return"undefined"==typeof Response?(yield Promise.resolve().then(n.bind(n,907))).Response:Response},new(a||(a=Promise))((function(e,t){function n(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a((function(e){e(i)}))).then(n,r)}l((s=s.apply(i,o||[])).next())})));var i,o,a,s;e instanceof r?e.json().then((n=>{t(new $(Q(n),e.status||500))})).catch((e=>{t(new Z(Q(e),e))})):t(new Z(Q(e),e))})),te=(e,t,n,r)=>{const i={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?i:(i.headers=Object.assign({"Content-Type":"application/json"},null==t?void 0:t.headers),i.body=JSON.stringify(r),Object.assign(Object.assign({},i),n))};function ne(e,t,n,r,i,o){return X(this,void 0,void 0,(function*(){return new Promise(((a,s)=>{e(n,te(t,r,i,o)).then((e=>{if(!e.ok)throw e;return(null==r?void 0:r.noResolveJson)?e:e.json()})).then((e=>a(e))).catch((e=>ee(e,s)))}))}))}function re(e,t,n,r){return X(this,void 0,void 0,(function*(){return ne(e,"GET",t,n,r)}))}function ie(e,t,n,r,i){return X(this,void 0,void 0,(function*(){return ne(e,"POST",t,r,i,n)}))}function oe(e,t,n,r,i){return X(this,void 0,void 0,(function*(){return ne(e,"DELETE",t,r,i,n)}))}var ae=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))};const se={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},le={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class ce{constructor(e,t={},n,r){this.url=e,this.headers=t,this.bucketId=n,this.fetch=q(r)}uploadOrUpdate(e,t,n,r){return ae(this,void 0,void 0,(function*(){try{let i;const o=Object.assign(Object.assign({},le),r),a=Object.assign(Object.assign({},this.headers),"POST"===e&&{"x-upsert":String(o.upsert)});"undefined"!=typeof Blob&&n instanceof Blob?(i=new FormData,i.append("cacheControl",o.cacheControl),i.append("",n)):"undefined"!=typeof FormData&&n instanceof FormData?(i=n,i.append("cacheControl",o.cacheControl)):(i=n,a["cache-control"]=`max-age=${o.cacheControl}`,a["content-type"]=o.contentType);const s=this._removeEmptyFolders(t),l=this._getFinalPath(s),c=yield this.fetch(`${this.url}/object/${l}`,Object.assign({method:e,body:i,headers:a},(null==o?void 0:o.duplex)?{duplex:o.duplex}:{})),u=yield c.json();return c.ok?{data:{path:s,id:u.Id,fullPath:u.Key},error:null}:{data:null,error:u}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}upload(e,t,n){return ae(this,void 0,void 0,(function*(){return this.uploadOrUpdate("POST",e,t,n)}))}uploadToSignedUrl(e,t,n,r){return ae(this,void 0,void 0,(function*(){const i=this._removeEmptyFolders(e),o=this._getFinalPath(i),a=new URL(this.url+`/object/upload/sign/${o}`);a.searchParams.set("token",t);try{let e;const t=Object.assign({upsert:le.upsert},r),o=Object.assign(Object.assign({},this.headers),{"x-upsert":String(t.upsert)});"undefined"!=typeof Blob&&n instanceof Blob?(e=new FormData,e.append("cacheControl",t.cacheControl),e.append("",n)):"undefined"!=typeof FormData&&n instanceof FormData?(e=n,e.append("cacheControl",t.cacheControl)):(e=n,o["cache-control"]=`max-age=${t.cacheControl}`,o["content-type"]=t.contentType);const s=yield this.fetch(a.toString(),{method:"PUT",body:e,headers:o}),l=yield s.json();return s.ok?{data:{path:i,fullPath:l.Key},error:null}:{data:null,error:l}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}createSignedUploadUrl(e){return ae(this,void 0,void 0,(function*(){try{let t=this._getFinalPath(e);const n=yield ie(this.fetch,`${this.url}/object/upload/sign/${t}`,{},{headers:this.headers}),r=new URL(this.url+n.url),i=r.searchParams.get("token");if(!i)throw new J("No token returned by API");return{data:{signedUrl:r.toString(),path:e,token:i},error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}update(e,t,n){return ae(this,void 0,void 0,(function*(){return this.uploadOrUpdate("PUT",e,t,n)}))}move(e,t){return ae(this,void 0,void 0,(function*(){try{return{data:yield ie(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers}),error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}copy(e,t){return ae(this,void 0,void 0,(function*(){try{return{data:{path:(yield ie(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers})).Key},error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}createSignedUrl(e,t,n){return ae(this,void 0,void 0,(function*(){try{let r=this._getFinalPath(e),i=yield ie(this.fetch,`${this.url}/object/sign/${r}`,Object.assign({expiresIn:t},(null==n?void 0:n.transform)?{transform:n.transform}:{}),{headers:this.headers});const o=(null==n?void 0:n.download)?`&download=${!0===n.download?"":n.download}`:"";return i={signedUrl:encodeURI(`${this.url}${i.signedURL}${o}`)},{data:i,error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}createSignedUrls(e,t,n){return ae(this,void 0,void 0,(function*(){try{const r=yield ie(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),i=(null==n?void 0:n.download)?`&download=${!0===n.download?"":n.download}`:"";return{data:r.map((e=>Object.assign(Object.assign({},e),{signedUrl:e.signedURL?encodeURI(`${this.url}${e.signedURL}${i}`):null}))),error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}download(e,t){return ae(this,void 0,void 0,(function*(){const n=void 0!==(null==t?void 0:t.transform)?"render/image/authenticated":"object",r=this.transformOptsToQueryString((null==t?void 0:t.transform)||{}),i=r?`?${r}`:"";try{const t=this._getFinalPath(e),r=yield re(this.fetch,`${this.url}/${n}/${t}${i}`,{headers:this.headers,noResolveJson:!0});return{data:yield r.blob(),error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}getPublicUrl(e,t){const n=this._getFinalPath(e),r=[],i=(null==t?void 0:t.download)?`download=${!0===t.download?"":t.download}`:"";""!==i&&r.push(i);const o=void 0!==(null==t?void 0:t.transform)?"render/image":"object",a=this.transformOptsToQueryString((null==t?void 0:t.transform)||{});""!==a&&r.push(a);let s=r.join("&");return""!==s&&(s=`?${s}`),{data:{publicUrl:encodeURI(`${this.url}/${o}/public/${n}${s}`)}}}remove(e){return ae(this,void 0,void 0,(function*(){try{return{data:yield oe(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}list(e,t,n){return ae(this,void 0,void 0,(function*(){try{const r=Object.assign(Object.assign(Object.assign({},se),t),{prefix:e||""});return{data:yield ie(this.fetch,`${this.url}/object/list/${this.bucketId}`,r,{headers:this.headers},n),error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join("&")}}const ue={"X-Client-Info":"storage-js/2.5.5"};var de=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))};class he{constructor(e,t={},n){this.url=e,this.headers=Object.assign(Object.assign({},ue),t),this.fetch=q(n)}listBuckets(){return de(this,void 0,void 0,(function*(){try{return{data:yield re(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}getBucket(e){return de(this,void 0,void 0,(function*(){try{return{data:yield re(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}createBucket(e,t={public:!1}){return de(this,void 0,void 0,(function*(){try{return{data:yield ie(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}updateBucket(e,t){return de(this,void 0,void 0,(function*(){try{const n=yield function(e,t,n,r,i){return X(this,void 0,void 0,(function*(){return ne(e,"PUT",t,r,undefined,n)}))}(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers});return{data:n,error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}emptyBucket(e){return de(this,void 0,void 0,(function*(){try{return{data:yield ie(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}deleteBucket(e){return de(this,void 0,void 0,(function*(){try{return{data:yield oe(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(e){if(K(e))return{data:null,error:e};throw e}}))}}class fe extends he{constructor(e,t={},n){super(e,t,n)}from(e){return new ce(this.url,this.headers,e,this.fetch)}}let pe="";pe="undefined"!=typeof Deno?"deno":"undefined"!=typeof document?"web":"undefined"!=typeof navigator&&"ReactNative"===navigator.product?"react-native":"node";const ge={headers:{"X-Client-Info":`supabase-js-${pe}/2.43.4`}},me={schema:"public"},be={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},ye={};const ve=e=>{let t;return t=e||("undefined"==typeof fetch?c.default:fetch),(...e)=>t(...e)},xe=(e,t,n)=>{const r=ve(n),i="undefined"==typeof Headers?c.Headers:Headers;return(n,o)=>{return a=void 0,s=void 0,c=function*(){var a;const s=null!==(a=yield t())&&void 0!==a?a:e;let l=new i(null==o?void 0:o.headers);return l.has("apikey")||l.set("apikey",e),l.has("Authorization")||l.set("Authorization",`Bearer ${s}`),r(n,Object.assign(Object.assign({},o),{headers:l}))},new((l=void 0)||(l=Promise))((function(e,t){function n(e){try{i(c.next(e))}catch(e){t(e)}}function r(e){try{i(c.throw(e))}catch(e){t(e)}}function i(t){var i;t.done?e(t.value):(i=t.value,i instanceof l?i:new l((function(e){e(i)}))).then(n,r)}i((c=c.apply(a,s||[])).next())}));var a,s,l,c}},we="2.64.2",ke={"X-Client-Info":`gotrue-js/${we}`},_e="X-Supabase-Api-Version",Ce={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},Ae=()=>"undefined"!=typeof document,Se={tested:!1,writable:!1},Ee=()=>{if(!Ae())return!1;try{if("object"!=typeof globalThis.localStorage)return!1}catch(e){return!1}if(Se.tested)return Se.writable;const e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),Se.tested=!0,Se.writable=!0}catch(e){Se.tested=!0,Se.writable=!1}return Se.writable};function Pe(e){const t={},n=new URL(e);if(n.hash&&"#"===n.hash[0])try{new URLSearchParams(n.hash.substring(1)).forEach(((e,n)=>{t[n]=e}))}catch(e){}return n.searchParams.forEach(((e,n)=>{t[n]=e})),t}const Oe=e=>{let t;return t=e||("undefined"==typeof fetch?(...e)=>Promise.resolve().then(n.bind(n,907)).then((({default:t})=>t(...e))):fetch),(...e)=>t(...e)},Re=e=>"object"==typeof e&&null!==e&&"status"in e&&"ok"in e&&"json"in e&&"function"==typeof e.json,je=async(e,t,n)=>{await e.setItem(t,JSON.stringify(n))},Ie=async(e,t)=>{const n=await e.getItem(t);if(!n)return null;try{return JSON.parse(n)}catch(e){return n}},Te=async(e,t)=>{await e.removeItem(t)};class Me{constructor(){this.promise=new Me.promiseConstructor(((e,t)=>{this.resolve=e,this.reject=t}))}}function Ne(e){const t=e.split(".");if(3!==t.length)throw new Error("JWT is not valid: not a JWT structure");if(!/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i.test(t[1]))throw new Error("JWT is not valid: payload is not in base64url format");const n=t[1];return JSON.parse(function(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let n,r,i,o,a,s,l,c="",u=0;for(e=e.replace("-","+").replace("_","/");u
+ The default number of test runs is 10,
+ but this can be adjusted as described below.
+ In general, there is a time versus accuracy tradeoff. More test
+ executions increase accuracy but reduce speed.
To adjust FlakeGuard configuration variables, you can create a
file in the root directory of your project called{' '}
- fg.config.json
. Below are the defaults, which can
+ fg.config.json
Below are the defaults, which can
be overridden in your local 'fg.config.json' file.
+
Reduced Confidence: They undermine trust in the test suite, as developers can't rely on test results to reflect the true state of the code. @@ -148,7 +139,6 @@ const Faq = (): JSX.Element => { data-bs-target="#flush-collapseFive" aria-expanded="false" aria-controls="flush-collapseFive" - aria-label="faq-button" > What are the best practices to prevent flaky tests? @@ -159,20 +149,12 @@ const Faq = (): JSX.Element => { aria-labelledby="flush-headingFive" data-bs-parent="#accordionFlushExample" > -
- By identifying flaky tests, FlakeGuard helps developers resolve + By identifying flaky tests, Flake Guard helps developers resolve inconsistencies, leading to more reliable and trustworthy test suites.
-// Stability Starts Here: -// -// Master Test Flakiness Ensure Reliability -// -//-// -// -//
- Flake-Guard is a free, open-source tool that allows developers to - run Jest tests to automatically detect, report, and manage flaky - tests in software development. + Flake Guard is a free, open-source, software that allows developers to automatically run Jest testing files to detect, report, and manage flaky tests in development.
- By identifying and handling these inconsistent tests, Flake-Guard + By identifying and handling these inconsistent tests, Flake Guard helps maintain test reliability.