@brandwave/ts 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,188 @@
1
- var z=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}},W=class{constructor(t){var e,s,r;this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(s=t.isMaybeSingle)!==null&&s!==void 0?s:!1,this.urlLengthLimit=(r=t.urlLengthLimit)!==null&&r!==void 0?r:8e3,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}then(t,e){var s=this;this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let r=this.fetch,a=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async n=>{let i=null,o=null,l=null,c=n.status,h=n.statusText;if(n.ok){var d,p;if(s.method!=="HEAD"){var u;let P=await n.text();P===""||(s.headers.get("Accept")==="text/csv"||s.headers.get("Accept")&&(!((u=s.headers.get("Accept"))===null||u===void 0)&&u.includes("application/vnd.pgrst.plan+text"))?o=P:o=JSON.parse(P))}let g=(d=s.headers.get("Prefer"))===null||d===void 0?void 0:d.match(/count=(exact|planned|estimated)/),y=(p=n.headers.get("content-range"))===null||p===void 0?void 0:p.split("/");g&&y&&y.length>1&&(l=parseInt(y[1])),s.isMaybeSingle&&s.method==="GET"&&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,l=null,c=406,h="Not Acceptable"):o.length===1?o=o[0]:o=null)}else{var f;let g=await n.text();try{i=JSON.parse(g),Array.isArray(i)&&n.status===404&&(o=[],i=null,c=200,h="OK")}catch{n.status===404&&g===""?(c=204,h="No Content"):i={message:g}}if(i&&s.isMaybeSingle&&(!(i==null||(f=i.details)===null||f===void 0)&&f.includes("0 rows"))&&(i=null,c=200,h="OK"),i&&s.shouldThrowOnError)throw new z(i)}return{error:i,data:o,count:l,status:c,statusText:h}});return this.shouldThrowOnError||(a=a.catch(n=>{var i;let o="",l="",c="",h=n?.cause;if(h){var d,p,u,f;let P=(d=h?.message)!==null&&d!==void 0?d:"",j=(p=h?.code)!==null&&p!==void 0?p:"";o=`${(u=n?.name)!==null&&u!==void 0?u:"FetchError"}: ${n?.message}`,o+=`
1
+ var Lt=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}},zt=class{constructor(t){var e,s,r;this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(s=t.isMaybeSingle)!==null&&s!==void 0?s:!1,this.urlLengthLimit=(r=t.urlLengthLimit)!==null&&r!==void 0?r:8e3,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}then(t,e){var s=this;this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let r=this.fetch,a=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{let n=null,o=null,g=null,l=i.status,c=i.statusText;if(i.ok){var d,m;if(s.method!=="HEAD"){var u;let y=await i.text();y===""||(s.headers.get("Accept")==="text/csv"||s.headers.get("Accept")&&(!((u=s.headers.get("Accept"))===null||u===void 0)&&u.includes("application/vnd.pgrst.plan+text"))?o=y:o=JSON.parse(y))}let f=(d=s.headers.get("Prefer"))===null||d===void 0?void 0:d.match(/count=(exact|planned|estimated)/),h=(m=i.headers.get("content-range"))===null||m===void 0?void 0:m.split("/");f&&h&&h.length>1&&(g=parseInt(h[1])),s.isMaybeSingle&&s.method==="GET"&&Array.isArray(o)&&(o.length>1?(n={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,g=null,l=406,c="Not Acceptable"):o.length===1?o=o[0]:o=null)}else{var p;let f=await i.text();try{n=JSON.parse(f),Array.isArray(n)&&i.status===404&&(o=[],n=null,l=200,c="OK")}catch{i.status===404&&f===""?(l=204,c="No Content"):n={message:f}}if(n&&s.isMaybeSingle&&(!(n==null||(p=n.details)===null||p===void 0)&&p.includes("0 rows"))&&(n=null,l=200,c="OK"),n&&s.shouldThrowOnError)throw new Lt(n)}return{error:n,data:o,count:g,status:l,statusText:c}});return this.shouldThrowOnError||(a=a.catch(i=>{var n;let o="",g="",l="",c=i?.cause;if(c){var d,m,u,p;let y=(d=c?.message)!==null&&d!==void 0?d:"",_=(m=c?.code)!==null&&m!==void 0?m:"";o=`${(u=i?.name)!==null&&u!==void 0?u:"FetchError"}: ${i?.message}`,o+=`
2
2
 
3
- Caused by: ${(f=h?.name)!==null&&f!==void 0?f:"Error"}: ${P}`,j&&(o+=` (${j})`),h?.stack&&(o+=`
4
- ${h.stack}`)}else{var g;o=(g=n?.stack)!==null&&g!==void 0?g:""}let y=this.url.toString().length;return n?.name==="AbortError"||n?.code==="ABORT_ERR"?(c="",l="Request was aborted (timeout or manual cancellation)",y>this.urlLengthLimit&&(l+=`. Note: Your request URL is ${y} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):(h?.name==="HeadersOverflowError"||h?.code==="UND_ERR_HEADERS_OVERFLOW")&&(c="",l="HTTP headers exceeded server limits (typically 16KB)",y>this.urlLengthLimit&&(l+=`. Your request URL is ${y} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{error:{message:`${(i=n?.name)!==null&&i!==void 0?i:"FetchError"}: ${n?.message}`,details:o,hint:l,code:c},data:null,count:null,status:0,statusText:""}})),a.then(t,e)}returns(){return this}overrideTypes(){return this}},Y=class extends W{select(t){let e=!1,s=(t??"*").split("").map(r=>/\s/.test(r)&&!e?"":(r==='"'&&(e=!e),r)).join("");return this.url.searchParams.set("select",s),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:s,foreignTable:r,referencedTable:a=r}={}){let n=a?`${a}.order`:"order",i=this.url.searchParams.get(n);return this.url.searchParams.set(n,`${i?`${i},`:""}${t}.${e?"asc":"desc"}${s===void 0?"":s?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:s=e}={}){let r=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(r,`${t}`),this}range(t,e,{foreignTable:s,referencedTable:r=s}={}){let a=typeof r>"u"?"offset":`${r}.offset`,n=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(a,`${t}`),this.url.searchParams.set(n,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:t=!1,verbose:e=!1,settings:s=!1,buffers:r=!1,wal:a=!1,format:n="text"}={}){var i;let o=[t?"analyze":null,e?"verbose":null,s?"settings":null,r?"buffers":null,a?"wal":null].filter(Boolean).join("|"),l=(i=this.headers.get("Accept"))!==null&&i!==void 0?i:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${n}; for="${l}"; options=${o};`),n==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}},R=new RegExp("[,()]"),v=class extends Y{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){let s=Array.from(new Set(e)).map(r=>typeof r=="string"&&R.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`in.(${s})`),this}notIn(t,e){let s=Array.from(new Set(e)).map(r=>typeof r=="string"&&R.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`not.in.(${s})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:s,type:r}={}){let a="";r==="plain"?a="pl":r==="phrase"?a="ph":r==="websearch"&&(a="w");let n=s===void 0?"":`(${s})`;return this.url.searchParams.append(t,`${a}fts${n}.${e}`),this}match(t){return Object.entries(t).forEach(([e,s])=>{this.url.searchParams.append(e,`eq.${s}`)}),this}not(t,e,s){return this.url.searchParams.append(t,`not.${e}.${s}`),this}or(t,{foreignTable:e,referencedTable:s=e}={}){let r=s?`${s}.or`:"or";return this.url.searchParams.append(r,`(${t})`),this}filter(t,e,s){return this.url.searchParams.append(t,`${e}.${s}`),this}},Q=class{constructor(t,{headers:e={},schema:s,fetch:r,urlLengthLimit:a=8e3}){this.url=t,this.headers=new Headers(e),this.schema=s,this.fetch=r,this.urlLengthLimit=a}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){let{head:s=!1,count:r}=e??{},a=s?"HEAD":"GET",n=!1,i=(t??"*").split("").map(c=>/\s/.test(c)&&!n?"":(c==='"'&&(n=!n),c)).join(""),{url:o,headers:l}=this.cloneRequestState();return o.searchParams.set("select",i),r&&l.append("Prefer",`count=${r}`),new v({method:a,url:o,headers:l,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}insert(t,{count:e,defaultToNull:s=!0}={}){var r;let a="POST",{url:n,headers:i}=this.cloneRequestState();if(e&&i.append("Prefer",`count=${e}`),s||i.append("Prefer","missing=default"),Array.isArray(t)){let o=t.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(o.length>0){let l=[...new Set(o)].map(c=>`"${c}"`);n.searchParams.set("columns",l.join(","))}}return new v({method:a,url:n,headers:i,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch,urlLengthLimit:this.urlLengthLimit})}upsert(t,{onConflict:e,ignoreDuplicates:s=!1,count:r,defaultToNull:a=!0}={}){var n;let i="POST",{url:o,headers:l}=this.cloneRequestState();if(l.append("Prefer",`resolution=${s?"ignore":"merge"}-duplicates`),e!==void 0&&o.searchParams.set("on_conflict",e),r&&l.append("Prefer",`count=${r}`),a||l.append("Prefer","missing=default"),Array.isArray(t)){let c=t.reduce((h,d)=>h.concat(Object.keys(d)),[]);if(c.length>0){let h=[...new Set(c)].map(d=>`"${d}"`);o.searchParams.set("columns",h.join(","))}}return new v({method:i,url:o,headers:l,schema:this.schema,body:t,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch,urlLengthLimit:this.urlLengthLimit})}update(t,{count:e}={}){var s;let r="PATCH",{url:a,headers:n}=this.cloneRequestState();return e&&n.append("Prefer",`count=${e}`),new v({method:r,url:a,headers:n,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit})}delete({count:t}={}){var e;let s="DELETE",{url:r,headers:a}=this.cloneRequestState();return t&&a.append("Prefer",`count=${t}`),new v({method:s,url:r,headers:a,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit})}};function w(t){"@babel/helpers - typeof";return w=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w(t)}function Z(t,e){if(w(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e||"default");if(w(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ee(t){var e=Z(t,"string");return w(e)=="symbol"?e:e+""}function te(t,e,s){return(e=ee(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function k(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),s.push.apply(s,r)}return s}function A(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?k(Object(s),!0).forEach(function(r){te(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):k(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}var E=class _{constructor(e,{headers:s={},schema:r,fetch:a,timeout:n,urlLengthLimit:i=8e3}={}){this.url=e,this.headers=new Headers(s),this.schemaName=r,this.urlLengthLimit=i;let o=a??globalThis.fetch;n!==void 0&&n>0?this.fetch=(l,c)=>{let h=new AbortController,d=setTimeout(()=>h.abort(),n),p=c?.signal;if(p){if(p.aborted)return clearTimeout(d),o(l,c);let u=()=>{clearTimeout(d),h.abort()};return p.addEventListener("abort",u,{once:!0}),o(l,A(A({},c),{},{signal:h.signal})).finally(()=>{clearTimeout(d),p.removeEventListener("abort",u)})}return o(l,A(A({},c),{},{signal:h.signal})).finally(()=>clearTimeout(d))}:this.fetch=o}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new Q(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}schema(e){return new _(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}rpc(e,s={},{head:r=!1,get:a=!1,count:n}={}){var i;let o,l=new URL(`${this.url}/rpc/${e}`),c,h=u=>u!==null&&typeof u=="object"&&(!Array.isArray(u)||u.some(h)),d=r&&Object.values(s).some(h);d?(o="POST",c=s):r||a?(o=r?"HEAD":"GET",Object.entries(s).filter(([u,f])=>f!==void 0).map(([u,f])=>[u,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([u,f])=>{l.searchParams.append(u,f)})):(o="POST",c=s);let p=new Headers(this.headers);return d?p.set("Prefer",n?`count=${n},return=minimal`:"return=minimal"):n&&p.set("Prefer",`count=${n}`),new v({method:o,url:l,headers:p,schema:this.schemaName,body:c,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit})}};var se=/([\p{Ll}\d])(\p{Lu})/gu,re=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,ne=/(\d)\p{Ll}|(\p{L})\d/u,ae=/[^\p{L}\d]+/giu,U="$1\0$2";function D(t){let e=t.trim();e=e.replace(se,U).replace(re,U),e=e.replace(ae,"\0");let s=0,r=e.length;for(;e.charAt(s)==="\0";)s++;if(s===r)return[];for(;e.charAt(r-1)==="\0";)r--;return e.slice(s,r).split(/\0/g)}function ie(t){let e=D(t);for(let s=0;s<e.length;s++){let r=e[s],a=ne.exec(r);if(a){let n=a.index+(a[1]??a[2]).length;e.splice(s,1,r.slice(0,n),r.slice(n))}}return e}function C(t,e){let[s,r,a]=b(t,e);return s+r.map(x(e?.locale)).join(e?.delimiter??" ")+a}function I(t,e){let[s,r,a]=b(t,e),n=x(e?.locale),i=L(e?.locale),o=e?.mergeAmbiguousCharacters?S(n,i):X(n,i);return s+r.map((l,c)=>c===0?n(l):o(l,c)).join(e?.delimiter??"")+a}function F(t,e){let[s,r,a]=b(t,e),n=x(e?.locale),i=L(e?.locale),o=e?.mergeAmbiguousCharacters?S(n,i):X(n,i);return s+r.map(o).join(e?.delimiter??"")+a}function $(t,e){let[s,r,a]=b(t,e),n=x(e?.locale),i=L(e?.locale);return s+r.map(S(n,i)).join(e?.delimiter??" ")+a}function H(t,e){let[s,r,a]=b(t,e);return s+r.map(L(e?.locale)).join(e?.delimiter??"_")+a}function q(t,e){return C(t,{delimiter:".",...e})}function N(t,e){return C(t,{delimiter:"-",...e})}function B(t,e){return C(t,{delimiter:"/",...e})}function K(t,e){let[s,r,a]=b(t,e),n=x(e?.locale),i=L(e?.locale),o=S(n,i);return s+r.map((l,c)=>c===0?o(l):n(l)).join(e?.delimiter??" ")+a}function G(t,e){return C(t,{delimiter:"_",...e})}function M(t,e){return $(t,{delimiter:"-",...e})}function x(t){return t===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t)}function L(t){return t===!1?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t)}function S(t,e){return s=>`${e(s[0])}${t(s.slice(1))}`}function X(t,e){return(s,r)=>{let a=s[0];return(r>0&&a>="0"&&a<="9"?"_"+a:e(a))+t(s.slice(1))}}function b(t,e={}){let s=e.split??(e.separateNumbers?ie:D),r=e.prefixCharacters??"",a=e.suffixCharacters??"",n=0,i=t.length;for(;n<t.length;){let o=t.charAt(n);if(!r.includes(o))break;n++}for(;i>n;){let o=i-1,l=t.charAt(o);if(!a.includes(l))break;i=o}return[t.slice(0,n),s(t.slice(n,i)),t.slice(i)]}var le=t=>t!==null&&typeof t=="object";function m(t){return function e(s,r=1,a){if(r===0||!le(s))return s;if(Array.isArray(s))return s.map(i=>e(i,r-1,a));let n=Object.create(Object.getPrototypeOf(s));return Object.keys(s).forEach(i=>{let o=s[i],l=t(i,a),c=e(o,r-1,a);n[l]=c}),n}}var J=m(I),Ce=m($),be=m(H),we=m(q),xe=m(M),Le=m(C),Ae=m(N),Se=m(F),Te=m(B),$e=m(K),V=m(G);var he=t=>V(t,100),T=t=>J(t,100),ue=t=>t.map(e=>T(e));var O=t=>({async getSettings(e){let{data:s,error:r}=await t.from("user_settings").select("*").eq("user_id",e).single();if(r){if(r.code==="PGRST116")return null;throw r}return T(s)}});var de="https://api.gobrandwave.com",pe=t=>{let e="apiKey"in t?t.apiKey:t.accessToken,s=t.baseUrl??de,r=new E(`${s}/client/rest/v1`,{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});return{users:O(r)}};export{pe as createBrandwave,T as toCamelCase,ue as toCamelCaseArray,he as toSnakeCase};
3
+ Caused by: ${(p=c?.name)!==null&&p!==void 0?p:"Error"}: ${y}`,_&&(o+=` (${_})`),c?.stack&&(o+=`
4
+ ${c.stack}`)}else{var f;o=(f=i?.stack)!==null&&f!==void 0?f:""}let h=this.url.toString().length;return i?.name==="AbortError"||i?.code==="ABORT_ERR"?(l="",g="Request was aborted (timeout or manual cancellation)",h>this.urlLengthLimit&&(g+=`. Note: Your request URL is ${h} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):(c?.name==="HeadersOverflowError"||c?.code==="UND_ERR_HEADERS_OVERFLOW")&&(l="",g="HTTP headers exceeded server limits (typically 16KB)",h>this.urlLengthLimit&&(g+=`. Your request URL is ${h} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{error:{message:`${(n=i?.name)!==null&&n!==void 0?n:"FetchError"}: ${i?.message}`,details:o,hint:g,code:l},data:null,count:null,status:0,statusText:""}})),a.then(t,e)}returns(){return this}overrideTypes(){return this}},Tt=class extends zt{select(t){let e=!1,s=(t??"*").split("").map(r=>/\s/.test(r)&&!e?"":(r==='"'&&(e=!e),r)).join("");return this.url.searchParams.set("select",s),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:s,foreignTable:r,referencedTable:a=r}={}){let i=a?`${a}.order`:"order",n=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${n?`${n},`:""}${t}.${e?"asc":"desc"}${s===void 0?"":s?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:s=e}={}){let r=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(r,`${t}`),this}range(t,e,{foreignTable:s,referencedTable:r=s}={}){let a=typeof r>"u"?"offset":`${r}.offset`,i=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(a,`${t}`),this.url.searchParams.set(i,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:t=!1,verbose:e=!1,settings:s=!1,buffers:r=!1,wal:a=!1,format:i="text"}={}){var n;let o=[t?"analyze":null,e?"verbose":null,s?"settings":null,r?"buffers":null,a?"wal":null].filter(Boolean).join("|"),g=(n=this.headers.get("Accept"))!==null&&n!==void 0?n:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${g}"; options=${o};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}},it=new RegExp("[,()]"),D=class extends Tt{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){let s=Array.from(new Set(e)).map(r=>typeof r=="string"&&it.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`in.(${s})`),this}notIn(t,e){let s=Array.from(new Set(e)).map(r=>typeof r=="string"&&it.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(t,`not.in.(${s})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:s,type:r}={}){let a="";r==="plain"?a="pl":r==="phrase"?a="ph":r==="websearch"&&(a="w");let i=s===void 0?"":`(${s})`;return this.url.searchParams.append(t,`${a}fts${i}.${e}`),this}match(t){return Object.entries(t).forEach(([e,s])=>{this.url.searchParams.append(e,`eq.${s}`)}),this}not(t,e,s){return this.url.searchParams.append(t,`not.${e}.${s}`),this}or(t,{foreignTable:e,referencedTable:s=e}={}){let r=s?`${s}.or`:"or";return this.url.searchParams.append(r,`(${t})`),this}filter(t,e,s){return this.url.searchParams.append(t,`${e}.${s}`),this}},St=class{constructor(t,{headers:e={},schema:s,fetch:r,urlLengthLimit:a=8e3}){this.url=t,this.headers=new Headers(e),this.schema=s,this.fetch=r,this.urlLengthLimit=a}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){let{head:s=!1,count:r}=e??{},a=s?"HEAD":"GET",i=!1,n=(t??"*").split("").map(l=>/\s/.test(l)&&!i?"":(l==='"'&&(i=!i),l)).join(""),{url:o,headers:g}=this.cloneRequestState();return o.searchParams.set("select",n),r&&g.append("Prefer",`count=${r}`),new D({method:a,url:o,headers:g,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}insert(t,{count:e,defaultToNull:s=!0}={}){var r;let a="POST",{url:i,headers:n}=this.cloneRequestState();if(e&&n.append("Prefer",`count=${e}`),s||n.append("Prefer","missing=default"),Array.isArray(t)){let o=t.reduce((g,l)=>g.concat(Object.keys(l)),[]);if(o.length>0){let g=[...new Set(o)].map(l=>`"${l}"`);i.searchParams.set("columns",g.join(","))}}return new D({method:a,url:i,headers:n,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch,urlLengthLimit:this.urlLengthLimit})}upsert(t,{onConflict:e,ignoreDuplicates:s=!1,count:r,defaultToNull:a=!0}={}){var i;let n="POST",{url:o,headers:g}=this.cloneRequestState();if(g.append("Prefer",`resolution=${s?"ignore":"merge"}-duplicates`),e!==void 0&&o.searchParams.set("on_conflict",e),r&&g.append("Prefer",`count=${r}`),a||g.append("Prefer","missing=default"),Array.isArray(t)){let l=t.reduce((c,d)=>c.concat(Object.keys(d)),[]);if(l.length>0){let c=[...new Set(l)].map(d=>`"${d}"`);o.searchParams.set("columns",c.join(","))}}return new D({method:n,url:o,headers:g,schema:this.schema,body:t,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit})}update(t,{count:e}={}){var s;let r="PATCH",{url:a,headers:i}=this.cloneRequestState();return e&&i.append("Prefer",`count=${e}`),new D({method:r,url:a,headers:i,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit})}delete({count:t}={}){var e;let s="DELETE",{url:r,headers:a}=this.cloneRequestState();return t&&a.append("Prefer",`count=${t}`),new D({method:s,url:r,headers:a,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit})}};function U(t){"@babel/helpers - typeof";return U=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(t)}function Ot(t,e){if(U(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,e||"default");if(U(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function qt(t){var e=Ot(t,"string");return U(e)=="symbol"?e:e+""}function Et(t,e,s){return(e=qt(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function rt(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),s.push.apply(s,r)}return s}function H(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?rt(Object(s),!0).forEach(function(r){Et(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):rt(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}var st=class nt{constructor(e,{headers:s={},schema:r,fetch:a,timeout:i,urlLengthLimit:n=8e3}={}){this.url=e,this.headers=new Headers(s),this.schemaName=r,this.urlLengthLimit=n;let o=a??globalThis.fetch;i!==void 0&&i>0?this.fetch=(g,l)=>{let c=new AbortController,d=setTimeout(()=>c.abort(),i),m=l?.signal;if(m){if(m.aborted)return clearTimeout(d),o(g,l);let u=()=>{clearTimeout(d),c.abort()};return m.addEventListener("abort",u,{once:!0}),o(g,H(H({},l),{},{signal:c.signal})).finally(()=>{clearTimeout(d),m.removeEventListener("abort",u)})}return o(g,H(H({},l),{},{signal:c.signal})).finally(()=>clearTimeout(d))}:this.fetch=o}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new St(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}schema(e){return new nt(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}rpc(e,s={},{head:r=!1,get:a=!1,count:i}={}){var n;let o,g=new URL(`${this.url}/rpc/${e}`),l,c=u=>u!==null&&typeof u=="object"&&(!Array.isArray(u)||u.some(c)),d=r&&Object.values(s).some(c);d?(o="POST",l=s):r||a?(o=r?"HEAD":"GET",Object.entries(s).filter(([u,p])=>p!==void 0).map(([u,p])=>[u,Array.isArray(p)?`{${p.join(",")}}`:`${p}`]).forEach(([u,p])=>{g.searchParams.append(u,p)})):(o="POST",l=s);let m=new Headers(this.headers);return d?m.set("Prefer",i?`count=${i},return=minimal`:"return=minimal"):i&&m.set("Prefer",`count=${i}`),new D({method:o,url:g,headers:m,schema:this.schemaName,body:l,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch,urlLengthLimit:this.urlLengthLimit})}};var Dt=/([\p{Ll}\d])(\p{Lu})/gu,$t=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,jt=/(\d)\p{Ll}|(\p{L})\d/u,Ut=/[^\p{L}\d]+/giu,at="$1\0$2";function ot(t){let e=t.trim();e=e.replace(Dt,at).replace($t,at),e=e.replace(Ut,"\0");let s=0,r=e.length;for(;e.charAt(s)==="\0";)s++;if(s===r)return[];for(;e.charAt(r-1)==="\0";)r--;return e.slice(s,r).split(/\0/g)}function Nt(t){let e=ot(t);for(let s=0;s<e.length;s++){let r=e[s],a=jt.exec(r);if(a){let i=a.index+(a[1]??a[2]).length;e.splice(s,1,r.slice(0,i),r.slice(i))}}return e}function $(t,e){let[s,r,a]=j(t,e);return s+r.map(N(e?.locale)).join(e?.delimiter??" ")+a}function ct(t,e){let[s,r,a]=j(t,e),i=N(e?.locale),n=Q(e?.locale),o=e?.mergeAmbiguousCharacters?B(i,n):yt(i,n);return s+r.map((g,l)=>l===0?i(g):o(g,l)).join(e?.delimiter??"")+a}function ut(t,e){let[s,r,a]=j(t,e),i=N(e?.locale),n=Q(e?.locale),o=e?.mergeAmbiguousCharacters?B(i,n):yt(i,n);return s+r.map(o).join(e?.delimiter??"")+a}function M(t,e){let[s,r,a]=j(t,e),i=N(e?.locale),n=Q(e?.locale);return s+r.map(B(i,n)).join(e?.delimiter??" ")+a}function lt(t,e){let[s,r,a]=j(t,e);return s+r.map(Q(e?.locale)).join(e?.delimiter??"_")+a}function dt(t,e){return $(t,{delimiter:".",...e})}function mt(t,e){return $(t,{delimiter:"-",...e})}function pt(t,e){return $(t,{delimiter:"/",...e})}function gt(t,e){let[s,r,a]=j(t,e),i=N(e?.locale),n=Q(e?.locale),o=B(i,n);return s+r.map((g,l)=>l===0?o(g):i(g)).join(e?.delimiter??" ")+a}function ft(t,e){return $(t,{delimiter:"_",...e})}function ht(t,e){return M(t,{delimiter:"-",...e})}function N(t){return t===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t)}function Q(t){return t===!1?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t)}function B(t,e){return s=>`${e(s[0])}${t(s.slice(1))}`}function yt(t,e){return(s,r)=>{let a=s[0];return(r>0&&a>="0"&&a<="9"?"_"+a:e(a))+t(s.slice(1))}}function j(t,e={}){let s=e.split??(e.separateNumbers?Nt:ot),r=e.prefixCharacters??"",a=e.suffixCharacters??"",i=0,n=t.length;for(;i<t.length;){let o=t.charAt(i);if(!r.includes(o))break;i++}for(;n>i;){let o=n-1,g=t.charAt(o);if(!a.includes(g))break;n=o}return[t.slice(0,i),s(t.slice(i,n)),t.slice(n)]}var Ft=t=>t!==null&&typeof t=="object";function z(t){return function e(s,r=1,a){if(r===0||!Ft(s))return s;if(Array.isArray(s))return s.map(n=>e(n,r-1,a));let i=Object.create(Object.getPrototypeOf(s));return Object.keys(s).forEach(n=>{let o=s[n],g=t(n,a),l=e(o,r-1,a);i[g]=l}),i}}var _t=z(ct),Yt=z(M),Zt=z(lt),te=z(dt),ee=z(ht),ie=z($),re=z(mt),se=z(ut),ne=z(pt),ae=z(gt),bt=z(ft);var K=t=>bt(t,100),P=t=>_t(t,100),v=t=>t.map(e=>P(e));var S=(t,e)=>{let{sortBy:s,sortDirection:r,defaultColumn:a,defaultAscending:i=!1}=e;if(s&&r){let n=K({[s]:""}),o=Object.keys(n)[0];return t.order(o,{ascending:r==="asc",nullsFirst:!1})}return a?t.order(a,{ascending:i}):t};var Ct=t=>({get:async l=>{let{id:c}=l,{data:d,error:m}=await t.from("activities").select("*, activity_costs(*)").eq("id",c).single();if(m)throw m;return{data:P(d),_meta:{description:"A single marketing activity with its associated costs. Activities represent content pieces, events, or other marketing efforts.",filters:{id:c}}}},list:async l=>{let{organizationId:c,pageIndex:d,pageSize:m,searchTerm:u="",sortBy:p,sortDirection:f,maxResults:h,contributorId:y,campaignId:_}=l,b=d*m,C=b+(h??m)-1,O=["id",y?"activity_contributors!inner(contributor_id)":"",_?"campaign_activities!inner(campaign_id)":""].filter(Boolean).join(", "),w=t.from("activities").select(O).eq("organization_id",c);y&&(w=w.eq("activity_contributors.contributor_id",y)),_&&(w=w.eq("campaign_activities.campaign_id",_)),u.trim()&&(w=w.ilike("description",`%${u}%`));let F=y?"activity_contributors!inner":"activity_contributors",A=_?"campaign_activities!inner":"campaign_activities",x=t.from("activities").select(`*,
5
+ ${F}(*,
6
+ contributor:contributors(*,
7
+ instagram_accounts:contributor_instagram_accounts(*,instagram_account:instagram_accounts(*)),
8
+ youtube_accounts:contributor_youtube_accounts(*,youtube_account:youtube_accounts(*)),
9
+ tiktok_accounts:contributor_tiktok_accounts(*,tiktok_account:tiktok_accounts(*)),
10
+ twitter_accounts:contributor_twitter_accounts(*,twitter_account:twitter_accounts(*)),
11
+ linkedin_accounts:contributor_linkedin_accounts(*,linkedin_account:linkedin_accounts(*)),
12
+ reddit_accounts:contributor_reddit_accounts(*,reddit_account:reddit_accounts(*)),
13
+ total_activities_cost:activity_costs!left(amount.sum())
14
+ )
15
+ ),
16
+ activity_costs(*),
17
+ ${A}(*)`).eq("organization_id",c);y&&(x=x.eq("activity_contributors.contributor_id",y)),_&&(x=x.eq("campaign_activities.campaign_id",_)),h&&(x=x.limit(h)),u.trim()&&(x=x.ilike("description",`%${u}%`));let q=S(x,{sortBy:p,sortDirection:f,defaultColumn:"created_at"}),[I,T]=await Promise.all([w,q.range(b,C)]);if(I.error)throw I.error;if(T.error)throw T.error;let E=I.data?.length??0,L={organizationId:c};return u.trim()&&(L.searchTerm=u),y&&(L.contributorId=y),_&&(L.campaignId=_),h&&(L.maxResults=h),{items:v(T.data),totalCount:E,_meta:{description:"Paginated list of marketing activities. Each includes description, channel, metrics, linked contributors with social accounts, costs, and campaign associations.",filters:L,pagination:{pageIndex:d,pageSize:m,from:b,to:C},sorting:{sortBy:p??"created_at",sortDirection:f??"desc"}}}},count:async l=>{let{organizationId:c,contributorId:d,campaignId:m}=l,u=!!(d||m),p="id";d?p="id, activity_contributors!inner(contributor_id)":m&&(p="id, campaign_activities!inner(campaign_id)");let f=t.from("activities").select(p,{count:"exact",head:!u}).eq("organization_id",c);d&&(f=f.eq("activity_contributors.contributor_id",d)),m&&(f=f.eq("campaign_activities.campaign_id",m));let{data:h,count:y,error:_}=await f;if(_)throw _;let b=u?h?.length??0:y??0,C={organizationId:c};return d&&(C.contributorId=d),m&&(C.campaignId=m),{count:b,_meta:{description:"Total number of activities matching the filters.",filters:C}}},contributors:{list:async l=>{let{organizationId:c,activityId:d,pageIndex:m,pageSize:u,maxResults:p}=l,f=m*u,h=f+(p??u)-1,y=t.from("activity_contributors").select("id").eq("organization_id",c).eq("activity_id",d),_=t.from("activity_contributors").select(`*,
18
+ contributor:contributors(
19
+ *,
20
+ instagram_accounts:contributor_instagram_accounts(*,instagram_account:instagram_accounts(*)),
21
+ youtube_accounts:contributor_youtube_accounts(*,youtube_account:youtube_accounts(*)),
22
+ tiktok_accounts:contributor_tiktok_accounts(*,tiktok_account:tiktok_accounts(*)),
23
+ twitter_accounts:contributor_twitter_accounts(*,twitter_account:twitter_accounts(*)),
24
+ linkedin_accounts:contributor_linkedin_accounts(*,linkedin_account:linkedin_accounts(*)),
25
+ reddit_accounts:contributor_reddit_accounts(*,reddit_account:reddit_accounts(*)),
26
+ total_activities_cost:activity_costs!left(amount.sum())
27
+ )
28
+ `).eq("organization_id",c).eq("activity_id",d);p&&(_=_.limit(p));let[b,C]=await Promise.all([y,_.range(f,h)]);if(b.error)throw b.error;if(C.error)throw C.error;let R=b.data?.length??0,k={organizationId:c,activityId:d};return p&&(k.maxResults=p),{items:v(C.data),totalCount:R,_meta:{description:"Contributors linked to a specific activity with their social media accounts.",filters:k,pagination:{pageIndex:m,pageSize:u,from:f,to:h}}}},count:async l=>{let{organizationId:c,activityId:d}=l,{data:m,error:u}=await t.from("activity_contributors").select("id").eq("organization_id",c).eq("activity_id",d);if(u)throw u;return{count:m?.length??0,_meta:{description:"Number of contributors linked to a specific activity.",filters:{organizationId:c,activityId:d}}}}},metrics:{history:async l=>{let{activityId:c,startDateKey:d,maxResults:m}=l,u=t.from("organization_scoped_metrics_history").select("recorded_date, reach, engagement, response, reach_tier, engagement_tier, response_tier").eq("entity_type","activity").eq("entity_id",c);d&&(u=u.gte("recorded_date",d)),m&&(u=u.limit(m));let{data:p,error:f}=await u.order("recorded_date",{ascending:!0});if(f)throw f;let h=v(p||[]),y={activityId:c};return d&&(y.startDateKey=d),m&&(y.maxResults=m),{items:h,totalCount:h.length,_meta:{description:"Historical metrics for an activity showing reach, engagement, and response over time.",filters:y}}},confidence:async l=>{let{organizationId:c,startDate:d,endDate:m}=l,{data:u,error:p}=await t.rpc("calculate_reach_confidence",{p_organization_id:c,p_start_date:d??void 0,p_end_date:m??void 0});if(p)throw p;let f=u&&u.length>0?P(u[0]):null,h={organizationId:c};return d&&(h.startDate=String(d)),m&&(h.endDate=String(m)),{data:f,_meta:{description:"Confidence scores for reach metrics based on data completeness and quality.",filters:h}}}},sparklines:{list:async l=>{let{organizationId:c,activityIds:d}=l;if(d.length===0)return{items:[],totalCount:0,_meta:{description:"Sparkline data for activities. No activity IDs provided.",filters:{organizationId:c}}};let{data:m,error:u}=await t.rpc("get_activity_sparklines",{p_organization_id:c,p_activity_ids:d,p_max_points:12});if(u)throw u;return{items:m||[],totalCount:m?.length??0,_meta:{description:"Sparkline data for rendering mini charts. Returns up to 12 data points per activity.",filters:{organizationId:c,activityCount:d.length}}}}}});var G=t=>{let e=Ct(t);return Object.assign(e.get,{list:e.list,count:e.count,contributors:e.contributors,metrics:e.metrics,sparklines:e.sparklines})};var vt=t=>({get:async r=>{let{id:a}=r,{data:i,error:n}=await t.from("campaigns").select(`
29
+ *,
30
+ activities_count:campaign_activities(count),
31
+ campaign_activities(
32
+ id,
33
+ activity_id,
34
+ activities(*)
35
+ )
36
+ `).eq("id",a).single();if(n)throw n;return{data:P(i),_meta:{description:"A single campaign with its linked activities. Includes campaign details (name, dates, budget, status) and a count of associated marketing activities.",filters:{id:a}}}},list:async r=>{let{organizationId:a,pageIndex:i,pageSize:n,searchTerm:o="",sortBy:g,sortDirection:l,maxResults:c}=r,d=i*n,m=d+(c??n)-1,u=t.from("campaigns").select("*",{count:"exact"}).eq("organization_id",a);o.trim()&&(u=u.ilike("name",`%${o}%`)),c&&(u=u.limit(c));let p=S(u,{sortBy:g,sortDirection:l,defaultColumn:"start_at"}),{data:f,count:h,error:y}=await p.range(d,m);if(y)throw y;let _={organizationId:a};return o.trim()&&(_.searchTerm=o),c&&(_.maxResults=c),{items:v(f),totalCount:h??0,_meta:{description:"Paginated list of marketing campaigns. Each campaign includes name, status, date range, budget, and aggregated performance metrics (total cost, reach, engagement).",filters:_,pagination:{pageIndex:i,pageSize:n,from:d,to:m},sorting:{sortBy:g??"start_at",sortDirection:l??"desc"}}}}});var J=t=>{let e=vt(t);return Object.assign(e.get,{list:e.list})};var wt=t=>({get:async r=>{let{id:a}=r,{data:i,error:n}=await t.from("contributors").select(`
37
+ *,
38
+ instagram_accounts:contributor_instagram_accounts(*,instagram_account:instagram_accounts!inner(*)),
39
+ youtube_accounts:contributor_youtube_accounts(*,youtube_account:youtube_accounts!inner(*)),
40
+ tiktok_accounts:contributor_tiktok_accounts(*,tiktok_account:tiktok_accounts!inner(*)),
41
+ twitter_accounts:contributor_twitter_accounts(*,twitter_account:twitter_accounts!inner(*)),
42
+ linkedin_accounts:contributor_linkedin_accounts(*,linkedin_account:linkedin_accounts!inner(*)),
43
+ reddit_accounts:contributor_reddit_accounts(*,reddit_account:reddit_accounts!inner(*)),
44
+ activities_count:activity_contributors(count),
45
+ total_activities_cost:activity_costs!left(amount.sum())
46
+ `).eq("id",a).single();if(n)throw n;return{data:P(i),_meta:{description:"A single contributor (creator, influencer, or partner) with their connected social media accounts across platforms (Instagram, YouTube, TikTok, Twitter/X, LinkedIn, Reddit). Includes activity count and total cost associated with this contributor.",filters:{id:a}}}},list:async r=>{let{organizationId:a,pageIndex:i,pageSize:n,searchTerm:o="",sortBy:g,sortDirection:l,maxResults:c,activityId:d,role:m}=r,u=i*n,p=u+(c??n)-1,f=t.from("contributors").select("id").eq("organization_id",a);d&&(f=f.eq("activity_contributors.activity_id",d)),m&&(f=f.eq("role",m)),o.trim()&&(f=f.ilike("name",`%${o}%`));let h=t.from("contributors").select(`
47
+ *,
48
+ instagram_accounts:contributor_instagram_accounts(*,instagram_account:instagram_accounts(*)),
49
+ youtube_accounts:contributor_youtube_accounts(*,youtube_account:youtube_accounts(*)),
50
+ tiktok_accounts:contributor_tiktok_accounts(*,tiktok_account:tiktok_accounts(*)),
51
+ twitter_accounts:contributor_twitter_accounts(*,twitter_account:twitter_accounts(*)),
52
+ linkedin_accounts:contributor_linkedin_accounts(*,linkedin_account:linkedin_accounts(*)),
53
+ reddit_accounts:contributor_reddit_accounts(*,reddit_account:reddit_accounts(*))
54
+ `).eq("organization_id",a);d&&(h=h.eq("activity_contributors.activity_id",d)),m&&(h=h.eq("role",m)),o.trim()&&(h=h.ilike("name",`%${o}%`)),c&&(h=h.limit(c));let y=S(h,{sortBy:g,sortDirection:l}),[_,b]=await Promise.all([f,y.range(u,p)]);if(_.error)throw _.error;if(b.error)throw b.error;let C=_.data?.length??0,R={organizationId:a};return o.trim()&&(R.searchTerm=o),d&&(R.activityId=d),m&&(R.role=m),c&&(R.maxResults=c),{items:v(b.data),totalCount:C,_meta:{description:"Paginated list of contributors (creators, influencers, partners). Each contributor includes their profile info, connected social media accounts, and can be filtered by role or activity association.",filters:R,pagination:{pageIndex:i,pageSize:n,from:u,to:p},sorting:{sortBy:g??"created_at",sortDirection:l??"desc"}}}}});var X=t=>{let e=wt(t);return Object.assign(e.get,{list:e.list})};var Rt=t=>({list:async a=>{let{organizationId:i,activityId:n,pageIndex:o,pageSize:g,maxResults:l}=a,c=o*g,d=c+(l??g)-1,m=t.from("activity_costs").select("id").eq("organization_id",i).eq("activity_id",n),u=t.from("activity_costs").select(`*,
55
+ contributor:contributors(
56
+ *,
57
+ instagram_accounts:contributor_instagram_accounts(*,instagram_account:instagram_accounts(*)),
58
+ youtube_accounts:contributor_youtube_accounts(*,youtube_account:youtube_accounts(*)),
59
+ tiktok_accounts:contributor_tiktok_accounts(*,tiktok_account:tiktok_accounts(*)),
60
+ twitter_accounts:contributor_twitter_accounts(*,twitter_account:twitter_accounts(*)),
61
+ linkedin_accounts:contributor_linkedin_accounts(*,linkedin_account:linkedin_accounts(*)),
62
+ reddit_accounts:contributor_reddit_accounts(*,reddit_account:reddit_accounts(*)),
63
+ total_activities_cost:activity_costs!left(amount.sum())
64
+ )
65
+ `).eq("organization_id",i).eq("activity_id",n);l&&(u=u.limit(l));let[p,f]=await Promise.all([m,u.range(c,d)]);if(p.error)throw p.error;if(f.error)throw f.error;let h=p.data?.length??0,y={organizationId:i,activityId:n};return l&&(y.maxResults=l),{items:v(f.data),totalCount:h,_meta:{description:"Paginated cost records associated with a marketing activity. Each cost includes amount, type, currency, and the linked contributor with their connected social media accounts.",filters:y,pagination:{pageIndex:o,pageSize:g,from:c,to:d}}}},count:async a=>{let{organizationId:i,activityId:n,contributorId:o}=a,g=t.from("activity_costs").select("*",{count:"exact",head:!0}).eq("organization_id",i);n&&(g=g.eq("activity_id",n)),o&&(g=g.eq("contributor_id",o));let{count:l,error:c}=await g;if(c)throw c;let d={organizationId:i};return n&&(d.activityId=n),o&&(d.contributorId=o),{count:l??0,_meta:{description:"Number of cost records matching the filters. Filters can be combined to narrow results (e.g., costs for a specific contributor on a specific activity).",filters:d}}},types:{list:async a=>{let{organizationId:i,maxResults:n}=a,o=t.from("activity_costs").select("type").eq("organization_id",i);n&&(o=o.limit(n));let{data:g,error:l}=await o;if(l)throw l;let c=Array.from(new Set(g.map(m=>m.type))),d={organizationId:i};return n&&(d.maxResults=n),{items:c,totalCount:c.length,_meta:{description:'Unique cost type labels that have been used across your organization. Common types include "Content", "Licensing", "Boosting", and custom values.',filters:d}}}}});var V=t=>{let e=Rt(t);return{list:e.list,count:e.count,types:e.types}};var Pt=t=>({get:async r=>{let{id:a}=r,{data:i,error:n}=await t.from("notes").select(`
66
+ *,
67
+ creator:users(*)
68
+ `).eq("id",a).single();if(n)throw n;return{data:P(i),_meta:{description:"A single note with its content and creator information. Notes are internal comments or annotations attached to activities or contributors.",filters:{id:a}}}},list:async r=>{let{organizationId:a,maxResults:i}=r;if("activityId"in r&&r.activityId){let n=t.from("activity_notes").select(`
69
+ id,
70
+ created_at,
71
+ note:notes!inner(
72
+ id,
73
+ content,
74
+ created_at,
75
+ updated_at,
76
+ created_by,
77
+ created_by_name,
78
+ organization_id,
79
+ creator:users(*)
80
+ )
81
+ `).eq("organization_id",a).eq("activity_id",r.activityId).order("created_at",{ascending:!1});i&&(n=n.limit(i));let{data:o,error:g}=await n;if(g)throw g;let l=v(o),c={organizationId:a,activityId:r.activityId};return i&&(c.maxResults=i),{items:l,totalCount:l.length,_meta:{description:"Notes attached to a marketing activity. Each note includes content, creation timestamp, and the user who created it. Ordered by most recent first.",filters:c}}}if("contributorId"in r&&r.contributorId){let n=t.from("contributor_notes").select(`
82
+ id,
83
+ created_at,
84
+ note:notes!inner(
85
+ id,
86
+ content,
87
+ created_at,
88
+ updated_at,
89
+ created_by,
90
+ created_by_name,
91
+ organization_id,
92
+ creator:users(*)
93
+ )
94
+ `).eq("organization_id",a).eq("contributor_id",r.contributorId).order("created_at",{ascending:!1});i&&(n=n.limit(i));let{data:o,error:g}=await n;if(g)throw g;let l=v(o),c={organizationId:a,contributorId:r.contributorId};return i&&(c.maxResults=i),{items:l,totalCount:l.length,_meta:{description:"Notes attached to a contributor profile. Each note includes content, creation timestamp, and the user who created it. Ordered by most recent first.",filters:c}}}throw new Error("Must provide either activityId or contributorId")}});var W=t=>{let e=Pt(t);return Object.assign(e.get,{list:e.list})};var xt=t=>({list:async r=>{let{userId:a,pageIndex:i,pageSize:n}=r,o=i*n,g=o+n-1,{data:l,count:c,error:d}=await t.from("user_organizations").select(`
95
+ *,
96
+ organization:organizations(*)
97
+ `,{count:"exact"}).eq("user_id",a).range(o,g);if(d)throw d;return{items:v(l),totalCount:c??0,_meta:{description:"Paginated list of organizations the user is a member of. Includes membership details and full organization information.",filters:{userId:a},pagination:{pageIndex:i,pageSize:n,from:o,to:g}}}},users:{list:async r=>{let{organizationId:a,pageIndex:i,pageSize:n,searchTerm:o=""}=r,g=i*n,l=g+n-1,c=t.from("user_organizations").select("*, user:users!inner(*)",{count:"exact"}).eq("organization_id",a);o.trim()&&(c=c.or(`name.ilike.%${o}%,email.ilike.%${o}%`,{foreignTable:"users"}));let{data:d,count:m,error:u}=await c.range(g,l);if(u)throw u;let p={organizationId:a};return o.trim()&&(p.searchTerm=o),{items:v(d),totalCount:m??0,_meta:{description:"Paginated list of users who are members of the organization. Includes membership details and full user information.",filters:p,pagination:{pageIndex:i,pageSize:n,from:g,to:l}}}}}});var Y=t=>{let e=xt(t);return{list:e.list,users:e.users}};var Z=t=>{let e=new Date;return e.setDate(e.getDate()-t),e.toISOString().split("T")[0]},It=t=>{let e=async m=>{let{organizationId:u}=m,{data:p,error:f}=await t.from("organizations").select(`
98
+ organization_id,
99
+ name,
100
+ total_cost,
101
+ total_engagement,
102
+ total_reach,
103
+ total_response,
104
+ cost_per_thousand_engagement,
105
+ cost_per_thousand_reach,
106
+ cost_per_thousand_response
107
+ `).eq("organization_id",u).single();if(f)throw f;return{data:p?P(p):null,_meta:{description:"Aggregated efficiency metrics for an organization including total costs, reach, engagement, response, and cost-per-thousand calculations.",filters:{organizationId:u}}}},s=async m=>{let{organizationId:u,daysBack:p=14,maxResults:f}=m,h=t.from("organization_scoped_metrics_history").select(`
108
+ cost_per_thousand_engagement,
109
+ cost_per_thousand_reach,
110
+ cost_per_thousand_response,
111
+ recorded_date
112
+ `).eq("entity_type","organization").eq("entity_id",u).gte("recorded_date",Z(p)).order("recorded_date",{ascending:!1});f&&(h=h.limit(f));let{data:y,error:_}=await h;if(_)throw _;let b=v(y||[]);return{items:b,totalCount:b.length,_meta:{description:`Historical efficiency metrics for the organization over the last ${p} days.`,filters:{organizationId:u,daysBack:p}}}},r=async m=>{let{organizationId:u,contributorId:p}=m,{data:f,error:h}=await t.from("contributors").select(`
113
+ id,
114
+ name,
115
+ role,
116
+ country_code,
117
+ activities_count,
118
+ total_activities_cost,
119
+ total_engagement,
120
+ total_reach,
121
+ total_response,
122
+ total_followers_count,
123
+ cost_per_thousand_engagement,
124
+ cost_per_thousand_reach,
125
+ cost_per_thousand_response
126
+ `).eq("organization_id",u).eq("id",p).single();if(h)throw h;return{data:f?P(f):null,_meta:{description:"A contributor's efficiency metrics including activity counts, costs, reach, engagement, response, and cost-per-thousand calculations.",filters:{organizationId:u,contributorId:p}}}},a=async m=>{let{organizationId:u,contributorId:p,daysBack:f=14,maxResults:h}=m,y=t.from("organization_scoped_metrics_history").select(`
127
+ cost_per_thousand_engagement,
128
+ cost_per_thousand_reach,
129
+ cost_per_thousand_response,
130
+ recorded_date
131
+ `).eq("entity_type","contributor").eq("entity_id",p).gte("recorded_date",Z(f)).order("recorded_date",{ascending:!1});h&&(y=y.limit(h));let{data:_,error:b}=await y;if(b)throw b;let C=v(_||[]);return{items:C,totalCount:C.length,_meta:{description:`Historical efficiency metrics for the contributor over the last ${f} days.`,filters:{organizationId:u,contributorId:p,daysBack:f}}}},i=async m=>{let{organizationId:u,campaignId:p}=m,{data:f,error:h}=await t.from("campaigns").select(`
132
+ id,
133
+ name,
134
+ start_at,
135
+ end_at,
136
+ budget,
137
+ cost,
138
+ activities_count,
139
+ total_engagement,
140
+ total_reach,
141
+ total_response,
142
+ cost_per_thousand_engagement,
143
+ cost_per_thousand_reach,
144
+ cost_per_thousand_response
145
+ `).eq("organization_id",u).eq("id",p).single();if(h)throw h;return{data:f?P(f):null,_meta:{description:"A campaign's efficiency metrics including budget, costs, activity counts, and cost-per-thousand calculations.",filters:{organizationId:u,campaignId:p}}}},n=async m=>{let{organizationId:u,campaignId:p,daysBack:f=14,maxResults:h}=m,y=t.from("organization_scoped_metrics_history").select(`
146
+ cost_per_thousand_engagement,
147
+ cost_per_thousand_reach,
148
+ cost_per_thousand_response,
149
+ recorded_date
150
+ `).eq("entity_type","campaign").eq("entity_id",p).gte("recorded_date",Z(f)).order("recorded_date",{ascending:!1});h&&(y=y.limit(h));let{data:_,error:b}=await y;if(b)throw b;let C=v(_||[]);return{items:C,totalCount:C.length,_meta:{description:`Historical efficiency metrics for the campaign over the last ${f} days.`,filters:{organizationId:u,campaignId:p,daysBack:f}}}},o=async m=>{let{organizationId:u,campaignId:p,pageIndex:f,pageSize:h,searchTerm:y="",sortBy:_,sortDirection:b,maxResults:C}=m,R=f*h,k=R+(C??h)-1,O=null;if(p){let{data:L}=await t.from("activity_contributors").select("contributor_id, activities!inner(campaign_activities!inner(campaign_id))").eq("activities.campaign_activities.campaign_id",p);if(L&&L.length>0)O=[...new Set(L.map(At=>At.contributor_id))];else return{items:[],totalCount:0,_meta:{description:"Contributors in the specified campaign ranked by efficiency with their social accounts.",filters:{organizationId:u,campaignId:p},pagination:{pageIndex:f,pageSize:h,from:R,to:k},sorting:{sortBy:_??"cost_per_thousand_reach",sortDirection:b??"asc"}}}}let w=t.from("contributors").select("id").eq("organization_id",u);O&&(w=w.in("id",O)),y.trim()&&(w=w.ilike("name",`%${y}%`));let A=t.from("contributors").select(`
151
+ id,
152
+ name,
153
+ role,
154
+ country_code,
155
+ created_at,
156
+ updated_at,
157
+ organization_id,
158
+ activities_count,
159
+ total_activities_cost,
160
+ total_engagement,
161
+ total_reach,
162
+ total_response,
163
+ total_followers_count,
164
+ cost_per_thousand_engagement,
165
+ cost_per_thousand_reach,
166
+ cost_per_thousand_response,
167
+ instagram_accounts:contributor_instagram_accounts(*,instagram_account:instagram_accounts(*)),
168
+ youtube_accounts:contributor_youtube_accounts(*,youtube_account:youtube_accounts(*)),
169
+ tiktok_accounts:contributor_tiktok_accounts(*,tiktok_account:tiktok_accounts(*)),
170
+ twitter_accounts:contributor_twitter_accounts(*,twitter_account:twitter_accounts(*)),
171
+ linkedin_accounts:contributor_linkedin_accounts(*,linkedin_account:linkedin_accounts(*)),
172
+ reddit_accounts:contributor_reddit_accounts(*,reddit_account:reddit_accounts(*))
173
+ `).eq("organization_id",u);O&&(A=A.in("id",O)),y.trim()&&(A=A.ilike("name",`%${y}%`)),C&&(A=A.limit(C));let x=S(A,{sortBy:_,sortDirection:b,defaultColumn:"cost_per_thousand_reach",defaultAscending:!0}),[q,I]=await Promise.all([w,x.range(R,k)]);if(q.error)throw q.error;if(I.error)throw I.error;let T=q.data?.length??0,E={organizationId:u};return p&&(E.campaignId=p),y.trim()&&(E.searchTerm=y),C&&(E.maxResults=C),{items:v(I.data??[]),totalCount:T,_meta:{description:p?"Contributors in the specified campaign ranked by efficiency with their social accounts.":"All contributors ranked by efficiency with their social accounts.",filters:E,pagination:{pageIndex:f,pageSize:h,from:R,to:k},sorting:{sortBy:_??"cost_per_thousand_reach",sortDirection:b??"asc"}}}},g=async m=>{let{organizationId:u,contributorId:p,pageIndex:f,pageSize:h,searchTerm:y="",sortBy:_,sortDirection:b,maxResults:C}=m,R=f*h,k=R+(C??h)-1,w=t.from("campaigns").select(`
174
+ id,
175
+ name,
176
+ start_at,
177
+ end_at,
178
+ budget,
179
+ cost,
180
+ activities_count,
181
+ total_engagement,
182
+ total_reach,
183
+ total_response,
184
+ cost_per_thousand_engagement,
185
+ cost_per_thousand_reach,
186
+ cost_per_thousand_response
187
+ `,{count:"exact"}).eq("organization_id",u);if(p){let{data:T}=await t.from("campaign_activities").select("campaign_id, activities!inner(activity_contributors!inner(contributor_id))").eq("activities.activity_contributors.contributor_id",p);if(T&&T.length>0){let E=[...new Set(T.map(L=>L.campaign_id))];w=w.in("id",E)}else return{items:[],totalCount:0,_meta:{description:"Campaigns that include the specified contributor, ranked by efficiency.",filters:{organizationId:u,contributorId:p},pagination:{pageIndex:f,pageSize:h,from:R,to:k},sorting:{sortBy:_??"cost_per_thousand_reach",sortDirection:b??"asc"}}}}y.trim()&&(w=w.ilike("name",`%${y}%`)),C&&(w=w.limit(C));let F=S(w,{sortBy:_,sortDirection:b,defaultColumn:"cost_per_thousand_reach",defaultAscending:!0}),{data:A,count:x,error:q}=await F.range(R,k);if(q)throw q;let I={organizationId:u};return p&&(I.contributorId=p),y.trim()&&(I.searchTerm=y),C&&(I.maxResults=C),{items:v(A??[]),totalCount:x??0,_meta:{description:p?"Campaigns that include the specified contributor, ranked by efficiency.":"All campaigns ranked by efficiency.",filters:I,pagination:{pageIndex:f,pageSize:h,from:R,to:k},sorting:{sortBy:_??"cost_per_thousand_reach",sortDirection:b??"asc"}}}},l=Object.assign(e,{history:s}),c=Object.assign(r,{history:a}),d=Object.assign(i,{history:n});return{efficiency:{organization:l,contributor:c,campaign:d,contributors:{list:o},campaigns:{list:g}}}};var tt=t=>{let e=It(t);return{efficiency:{organization:e.efficiency.organization,contributor:e.efficiency.contributor,campaign:e.efficiency.campaign,contributors:e.efficiency.contributors,campaigns:e.efficiency.campaigns}}};var kt=t=>({get:async a=>{let{id:i}=a,{data:n,error:o}=await t.from("users").select("*").eq("user_id",i).single();if(o)throw o;return{data:P(n),_meta:{description:"A single user with their profile information. Includes name, email, avatar, and organization membership.",filters:{id:i}}}},list:async a=>{let{organizationId:i,pageIndex:n,pageSize:o,searchTerm:g=""}=a,l=n*o,c=l+o-1,d=t.from("users").select("*",{count:"exact"}).eq("organization_id",i);g.trim()&&(d=d.ilike("name",`%${g}%`));let{data:m,count:u,error:p}=await d.range(l,c);if(p)throw p;let f={organizationId:i};return g.trim()&&(f.searchTerm=g),{items:v(m),totalCount:u??0,_meta:{description:"Paginated list of users in the organization. Includes user profile information.",filters:f,pagination:{pageIndex:n,pageSize:o,from:l,to:c}}}},settings:async a=>{let{userId:i}=a,{data:n,error:o}=await t.from("user_settings").select("*").eq("user_id",i).single();if(o){if(o.code==="PGRST116")return{data:null,_meta:{description:"User settings were not found. Settings are created when a user first customizes their preferences.",filters:{userId:i}}};throw o}return{data:P(n),_meta:{description:"User-specific settings and preferences. Includes UI preferences, notification settings, and other customizable options.",filters:{userId:i}}}}});var et=t=>{let e=kt(t);return Object.assign(e.get,{list:e.list,settings:e.settings})};var Bt="https://api.gobrandwave.com",Mt=t=>{let e="apiKey"in t?t.apiKey:t.accessToken,s=t.baseUrl??Bt,r=new st(`${s}/client/rest/v1`,{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});return{activities:G(r),campaigns:J(r),contributors:X(r),costs:V(r),notes:W(r),organizations:Y(r),reporting:tt(r),users:et(r)}};export{Mt as createBrandwave,P as toCamelCase,v as toCamelCaseArray,K as toSnakeCase};
5
188
  //# sourceMappingURL=index.js.map