@thirstie/thirstieservices 1.4.2 → 1.5.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,48 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 1.5.0 (2026-01-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * improved session reloading ([99e996c](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/99e996c48b2457fb254bb9a2b26500394b907cb5))
12
+ * update thirstieservices global name ([8974d09](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/8974d09703e05c68db0fde2db8a642967c94bd85))
13
+
14
+
15
+ ### Features
16
+
17
+ * add sandbox environment ([f0b55c5](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/f0b55c58304d9d28d704bee2b9c16a64ab6af5fe))
18
+ * allow restoring age gate settings ([2030773](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/2030773073df53b56a08a3dd5937afac63c87217))
19
+ * simplify saving session state ([fa0ba48](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/fa0ba48d29140961e7c035605a0bee82ac7f0b17))
20
+ * TH-5423 create new session in extreme case ([3de8b13](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/3de8b131deee45281c414ae00bd2cc44f2c475f7))
21
+ * update user actions ([2f8cf07](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/2f8cf07f9bafbca4fd5d57435a37189541449ded))
22
+
23
+
24
+
25
+
26
+
27
+ ## 1.4.3 (2025-11-19)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * improved session reloading ([99e996c](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/99e996c48b2457fb254bb9a2b26500394b907cb5))
33
+ * update thirstieservices global name ([8974d09](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/8974d09703e05c68db0fde2db8a642967c94bd85))
34
+
35
+
36
+ ### Features
37
+
38
+ * add sandbox environment ([f0b55c5](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/f0b55c58304d9d28d704bee2b9c16a64ab6af5fe))
39
+ * allow restoring age gate settings ([2030773](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/2030773073df53b56a08a3dd5937afac63c87217))
40
+ * simplify saving session state ([fa0ba48](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/fa0ba48d29140961e7c035605a0bee82ac7f0b17))
41
+ * TH-5423 create new session in extreme case ([3de8b13](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/3de8b131deee45281c414ae00bd2cc44f2c475f7))
42
+ * update user actions ([2f8cf07](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/2f8cf07f9bafbca4fd5d57435a37189541449ded))
43
+
44
+
45
+
46
+
47
+
6
48
  ## 1.4.2 (2025-11-10)
7
49
 
8
50
 
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <coverage generated="1762812149895" clover="3.2.0">
3
- <project timestamp="1762812149895" name="All files">
2
+ <coverage generated="1767721709570" clover="3.2.0">
3
+ <project timestamp="1767721709570" name="All files">
4
4
  <metrics statements="123" coveredstatements="56" conditionals="91" coveredconditionals="58" methods="26" coveredmethods="13" elements="240" coveredelements="127" complexity="0" loc="123" ncloc="123" packages="2" files="3" classes="3"/>
5
5
  <package name="geoservice">
6
6
  <metrics statements="94" coveredstatements="40" conditionals="77" coveredconditionals="53" methods="21" coveredmethods="11"/>
@@ -101,7 +101,7 @@
101
101
  <div class='footer quiet pad2 space-top1 center small'>
102
102
  Code coverage generated by
103
103
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
104
- at 2025-11-10T22:02:29.883Z
104
+ at 2026-01-06T17:48:29.558Z
105
105
  </div>
106
106
  <script src="../prettify.js"></script>
107
107
  <script>
@@ -766,7 +766,7 @@ export default GeoService;
766
766
  <div class='footer quiet pad2 space-top1 center small'>
767
767
  Code coverage generated by
768
768
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
769
- at 2025-11-10T22:02:29.883Z
769
+ at 2026-01-06T17:48:29.558Z
770
770
  </div>
771
771
  <script src="../prettify.js"></script>
772
772
  <script>
@@ -116,7 +116,7 @@
116
116
  <div class='footer quiet pad2 space-top1 center small'>
117
117
  Code coverage generated by
118
118
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
119
- at 2025-11-10T22:02:29.883Z
119
+ at 2026-01-06T17:48:29.558Z
120
120
  </div>
121
121
  <script src="prettify.js"></script>
122
122
  <script>
@@ -208,7 +208,7 @@ export async function <span class="fstat-no" title="function not covered" >apiRe
208
208
  <div class='footer quiet pad2 space-top1 center small'>
209
209
  Code coverage generated by
210
210
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
211
- at 2025-11-10T22:02:29.883Z
211
+ at 2026-01-06T17:48:29.558Z
212
212
  </div>
213
213
  <script src="../../prettify.js"></script>
214
214
  <script>
@@ -160,7 +160,7 @@ export {
160
160
  <div class='footer quiet pad2 space-top1 center small'>
161
161
  Code coverage generated by
162
162
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
163
- at 2025-11-10T22:02:29.883Z
163
+ at 2026-01-06T17:48:29.558Z
164
164
  </div>
165
165
  <script src="../../prettify.js"></script>
166
166
  <script>
@@ -116,7 +116,7 @@
116
116
  <div class='footer quiet pad2 space-top1 center small'>
117
117
  Code coverage generated by
118
118
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
119
- at 2025-11-10T22:02:29.883Z
119
+ at 2026-01-06T17:48:29.558Z
120
120
  </div>
121
121
  <script src="../../prettify.js"></script>
122
122
  <script>
package/dist/bundle.cjs CHANGED
@@ -340,7 +340,7 @@ class ThirstieAPI {
340
340
  * @returns {object} - api response
341
341
  */
342
342
  async apiCaller (method, url, options = {}, errorHandler = null) {
343
- const { data, params, basicAuth, isFormData, isTemplate, isPayment } = options;
343
+ const { data, params, basicAuth, isFormData, isTemplate, isPayment, isCSV } = options;
344
344
  const { sessionRef, application, applicationRef, userRef } = this.apiState;
345
345
 
346
346
  if (!this.sessionToken && !basicAuth) {
@@ -361,6 +361,11 @@ class ThirstieAPI {
361
361
  headers['Content-Type'] = 'application/json';
362
362
  }
363
363
 
364
+ if (isCSV) {
365
+ headers.Accept = 'text/csv';
366
+ delete headers['Content-Type'];
367
+ }
368
+
364
369
  const requestConfig = { method, headers };
365
370
 
366
371
  if ([ 'POST', 'PUT', 'PATCH' ].includes(method) && !!data) {
@@ -398,6 +403,15 @@ class ThirstieAPI {
398
403
  telemetryContext
399
404
  });
400
405
  }
406
+ if (isCSV) {
407
+ return {
408
+ ok: response.ok,
409
+ status: response.status,
410
+ statusText: response.statusText,
411
+ url: response.url,
412
+ data: await response.text()
413
+ };
414
+ }
401
415
  return response;
402
416
  }
403
417
  } catch (error) {
@@ -1 +1 @@
1
- var thirstieservices=function(t){"use strict";const e=t=>{let e="https://api.next.thirstie.com";switch(t?.toLowerCase()){case"prod":e="https://api.thirstie.com";break;case"sandbox":e="https://api.sandbox.thirstie.com"}return e};function n(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function r(t){return function e(r){return 0===arguments.length||n(r)?e:t.apply(this,arguments)}}function o(t){return function e(o,a){switch(arguments.length){case 0:return e;case 1:return n(o)?e:r((function(e){return t(o,e)}));default:return n(o)&&n(a)?e:n(o)?r((function(e){return t(e,a)})):n(a)?r((function(e){return t(o,e)})):t(o,a)}}}function a(t,e){switch(t){case 0:return function(){return e.apply(this,arguments)};case 1:return function(t){return e.apply(this,arguments)};case 2:return function(t,n){return e.apply(this,arguments)};case 3:return function(t,n,r){return e.apply(this,arguments)};case 4:return function(t,n,r,o){return e.apply(this,arguments)};case 5:return function(t,n,r,o,a){return e.apply(this,arguments)};case 6:return function(t,n,r,o,a,s){return e.apply(this,arguments)};case 7:return function(t,n,r,o,a,s,i){return e.apply(this,arguments)};case 8:return function(t,n,r,o,a,s,i,u){return e.apply(this,arguments)};case 9:return function(t,n,r,o,a,s,i,u,c){return e.apply(this,arguments)};case 10:return function(t,n,r,o,a,s,i,u,c,l){return e.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function s(t,e,r){return function(){for(var o=[],i=0,u=t,c=0,l=!1;c<e.length||i<arguments.length;){var p;c<e.length&&(!n(e[c])||i>=arguments.length)?p=e[c]:(p=arguments[i],i+=1),o[c]=p,n(p)?l=!0:u-=1,c+=1}return!l&&u<=0?r.apply(this,o):a(Math.max(0,u),s(t,o,r))}}var i=o((function(t,e){return 1===t?r(e):a(t,s(t,[],e))}));function u(t){return function e(a,s,i){switch(arguments.length){case 0:return e;case 1:return n(a)?e:o((function(e,n){return t(a,e,n)}));case 2:return n(a)&&n(s)?e:n(a)?o((function(e,n){return t(e,s,n)})):n(s)?o((function(e,n){return t(a,e,n)})):r((function(e){return t(a,s,e)}));default:return n(a)&&n(s)&&n(i)?e:n(a)&&n(s)?o((function(e,n){return t(e,n,i)})):n(a)&&n(i)?o((function(e,n){return t(e,s,n)})):n(s)&&n(i)?o((function(e,n){return t(a,e,n)})):n(a)?r((function(e){return t(e,s,i)})):n(s)?r((function(e){return t(a,e,i)})):n(i)?r((function(e){return t(a,s,e)})):t(a,s,i)}}}var c=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)};function l(t,e,n){return function(){if(0===arguments.length)return n();var r=arguments[arguments.length-1];if(!c(r)){for(var o=0;o<t.length;){if("function"==typeof r[t[o]])return r[t[o]].apply(r,Array.prototype.slice.call(arguments,0,-1));o+=1}if(function(t){return null!=t&&"function"==typeof t["@@transducer/step"]}(r))return e.apply(null,Array.prototype.slice.call(arguments,0,-1))(r)}return n.apply(this,arguments)}}var p=function(){return this.xf["@@transducer/init"]()},f=function(t){return this.xf["@@transducer/result"](t)};function h(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}function y(t,e,n){for(var r=0,o=n.length;r<o;){if(t(e,n[r]))return!0;r+=1}return!1}function d(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var g="function"==typeof Object.is?Object.is:function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e},m=Object.prototype.toString,v=function(){return"[object Arguments]"===m.call(arguments)?function(t){return"[object Arguments]"===m.call(t)}:function(t){return d("callee",t)}}(),b=!{toString:null}.propertyIsEnumerable("toString"),S=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],j=function(){return arguments.propertyIsEnumerable("length")}(),w=function(t,e){for(var n=0;n<t.length;){if(t[n]===e)return!0;n+=1}return!1},A="function"!=typeof Object.keys||j?r((function(t){if(Object(t)!==t)return[];var e,n,r=[],o=j&&v(t);for(e in t)!d(e,t)||o&&"length"===e||(r[r.length]=e);if(b)for(n=S.length-1;n>=0;)d(e=S[n],t)&&!w(r,e)&&(r[r.length]=e),n-=1;return r})):r((function(t){return Object(t)!==t?[]:Object.keys(t)})),_=r((function(t){return null===t?"Null":void 0===t?"Undefined":Object.prototype.toString.call(t).slice(8,-1)}));function k(t,e,n,r){var o=h(t);function a(t,e){return O(t,e,n.slice(),r.slice())}return!y((function(t,e){return!y(a,e,t)}),h(e),o)}function O(t,e,n,r){if(g(t,e))return!0;var o,a,s=_(t);if(s!==_(e))return!1;if("function"==typeof t["fantasy-land/equals"]||"function"==typeof e["fantasy-land/equals"])return"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e)&&"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t);if("function"==typeof t.equals||"function"==typeof e.equals)return"function"==typeof t.equals&&t.equals(e)&&"function"==typeof e.equals&&e.equals(t);switch(s){case"Arguments":case"Array":case"Object":if("function"==typeof t.constructor&&"Promise"===(o=t.constructor,null==(a=String(o).match(/^function (\w*)/))?"":a[1]))return t===e;break;case"Boolean":case"Number":case"String":if(typeof t!=typeof e||!g(t.valueOf(),e.valueOf()))return!1;break;case"Date":if(!g(t.valueOf(),e.valueOf()))return!1;break;case"Error":return t.name===e.name&&t.message===e.message;case"RegExp":if(t.source!==e.source||t.global!==e.global||t.ignoreCase!==e.ignoreCase||t.multiline!==e.multiline||t.sticky!==e.sticky||t.unicode!==e.unicode)return!1}for(var i=n.length-1;i>=0;){if(n[i]===t)return r[i]===e;i-=1}switch(s){case"Map":return t.size===e.size&&k(t.entries(),e.entries(),n.concat([t]),r.concat([e]));case"Set":return t.size===e.size&&k(t.values(),e.values(),n.concat([t]),r.concat([e]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var u=A(t);if(u.length!==A(e).length)return!1;var c=n.concat([t]),l=r.concat([e]);for(i=u.length-1;i>=0;){var p=u[i];if(!d(p,e)||!O(e[p],t[p],c,l))return!1;i-=1}return!0}var T=o((function(t,e){return O(t,e,[],[])}));function x(t,e){return function(t,e,n){var r,o;if("function"==typeof t.indexOf)switch(typeof e){case"number":if(0===e){for(r=1/e;n<t.length;){if(0===(o=t[n])&&1/o===r)return n;n+=1}return-1}if(e!=e){for(;n<t.length;){if("number"==typeof(o=t[n])&&o!=o)return n;n+=1}return-1}return t.indexOf(e,n);case"string":case"boolean":case"function":case"undefined":return t.indexOf(e,n);case"object":if(null===e)return t.indexOf(e,n)}for(;n<t.length;){if(T(t[n],e))return n;n+=1}return-1}(e,t,0)>=0}function R(t,e){for(var n=0,r=e.length,o=Array(r);n<r;)o[n]=t(e[n]),n+=1;return o}function U(t){return'"'+t.replace(/\\/g,"\\\\").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0").replace(/"/g,'\\"')+'"'}var q=function(t){return(t<10?"0":"")+t},C="function"==typeof Date.prototype.toISOString?function(t){return t.toISOString()}:function(t){return t.getUTCFullYear()+"-"+q(t.getUTCMonth()+1)+"-"+q(t.getUTCDate())+"T"+q(t.getUTCHours())+":"+q(t.getUTCMinutes())+":"+q(t.getUTCSeconds())+"."+(t.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};function N(t,e,n){for(var r=0,o=n.length;r<o;)e=t(e,n[r]),r+=1;return e}function E(t){return"[object Object]"===Object.prototype.toString.call(t)}var I=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=p,t.prototype["@@transducer/result"]=f,t.prototype["@@transducer/step"]=function(t,e){return this.f(e)?this.xf["@@transducer/step"](t,e):t},t}();function P(t){return function(e){return new I(t,e)}}var $=o(l(["fantasy-land/filter","filter"],P,(function(t,e){return E(e)?N((function(n,r){return t(e[r])&&(n[r]=e[r]),n}),{},A(e)):function(t,e){for(var n=0,r=e.length,o=[];n<r;)t(e[n])&&(o[o.length]=e[n]),n+=1;return o}(t,e)}))),B=o((function(t,e){return $((n=t,function(){return!n.apply(this,arguments)}),e);var n}));function F(t,e){var n=function(n){var r=e.concat([t]);return x(n,r)?"<Circular>":F(n,r)},r=function(t,e){return R((function(e){return U(e)+": "+n(t[e])}),e.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+R(n,t).join(", ")+"))";case"[object Array]":return"["+R(n,t).concat(r(t,B((function(t){return/^\d+$/.test(t)}),A(t)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof t?"new Boolean("+n(t.valueOf())+")":t.toString();case"[object Date]":return"new Date("+(isNaN(t.valueOf())?n(NaN):U(C(t)))+")";case"[object Map]":return"new Map("+n(Array.from(t))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof t?"new Number("+n(t.valueOf())+")":1/t==-1/0?"-0":t.toString(10);case"[object Set]":return"new Set("+n(Array.from(t).sort())+")";case"[object String]":return"object"==typeof t?"new String("+n(t.valueOf())+")":U(t);case"[object Undefined]":return"undefined";default:if("function"==typeof t.toString){var o=t.toString();if("[object Object]"!==o)return o}return"{"+r(t,A(t)).join(", ")+"}"}}var K=r((function(t){return F(t,[])})),M=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=p,t.prototype["@@transducer/result"]=f,t.prototype["@@transducer/step"]=function(t,e){return this.xf["@@transducer/step"](t,this.f(e))},t}(),z=o(l(["fantasy-land/map","map"],(function(t){return function(e){return new M(t,e)}}),(function(t,e){switch(Object.prototype.toString.call(e)){case"[object Function]":return i(e.length,(function(){return t.call(this,e.apply(this,arguments))}));case"[object Object]":return N((function(n,r){return n[r]=t(e[r]),n}),{},A(e));default:return R(t,e)}}))),D=Number.isInteger||function(t){return(t|0)===t};function G(t){return"[object String]"===Object.prototype.toString.call(t)}var L=o((function(t,e){var n=t<0?e.length+t:t;return G(e)?e.charAt(n):e[n]})),Z=o((function(t,e){if(null!=e)return D(t)?L(t,e):e[t]})),H=r((function(t){return!!c(t)||!!t&&("object"==typeof t&&(!G(t)&&(0===t.length||t.length>0&&(t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1)))))})),J="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function W(t,e,n){return function(r,o,a){if(H(a))return t(r,o,a);if(null==a)return o;if("function"==typeof a["fantasy-land/reduce"])return e(r,o,a,"fantasy-land/reduce");if(null!=a[J])return n(r,o,a[J]());if("function"==typeof a.next)return n(r,o,a);if("function"==typeof a.reduce)return e(r,o,a,"reduce");throw new TypeError("reduce: list must be array or iterable")}}function X(t,e,n){for(var r=0,o=n.length;r<o;){if((e=t["@@transducer/step"](e,n[r]))&&e["@@transducer/reduced"]){e=e["@@transducer/value"];break}r+=1}return t["@@transducer/result"](e)}var Y=o((function(t,e){return a(t.length,(function(){return t.apply(e,arguments)}))}));function Q(t,e,n){for(var r=n.next();!r.done;){if((e=t["@@transducer/step"](e,r.value))&&e["@@transducer/reduced"]){e=e["@@transducer/value"];break}r=n.next()}return t["@@transducer/result"](e)}function V(t,e,n,r){return t["@@transducer/result"](n[r](Y(t["@@transducer/step"],t),e))}var tt=W(X,V,Q),et=function(){function t(t){this.f=t}return t.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},t.prototype["@@transducer/result"]=function(t){return t},t.prototype["@@transducer/step"]=function(t,e){return this.f(t,e)},t}();var nt=u((function(t,e,n){return tt("function"==typeof t?new et(t):t,e,n)}));var rt=r((function(t){return null==t})),ot=u((function t(e,n,r){if(0===e.length)return n;var o=e[0];if(e.length>1){var a=!rt(r)&&d(o,r)&&"object"==typeof r[o]?r[o]:D(e[1])?[]:{};n=t(Array.prototype.slice.call(e,1),n,a)}return function(t,e,n){if(D(t)&&c(n)){var r=[].concat(n);return r[t]=e,r}var o={};for(var a in n)o[a]=n[a];return o[t]=e,o}(o,n,r)}));function at(t,e){return function(){return e.call(this,t.apply(this,arguments))}}function st(t,e){return function(){var n=arguments.length;if(0===n)return e();var r=arguments[n-1];return c(r)||"function"!=typeof r[t]?e.apply(this,arguments):r[t].apply(r,Array.prototype.slice.call(arguments,0,n-1))}}var it=r(st("tail",u(st("slice",(function(t,e,n){return Array.prototype.slice.call(n,t,e)})))(1,1/0)));function ut(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return a(arguments[0].length,nt(at,arguments[0],it(arguments)))}var ct=r((function(t){return G(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()}));function lt(){if(0===arguments.length)throw new Error("compose requires at least one argument");return ut.apply(this,ct(arguments))}var pt=r((function(t){return i(t.length,t)}));var ft=r((function(t){return null!=t&&"function"==typeof t["fantasy-land/empty"]?t["fantasy-land/empty"]():null!=t&&null!=t.constructor&&"function"==typeof t.constructor["fantasy-land/empty"]?t.constructor["fantasy-land/empty"]():null!=t&&"function"==typeof t.empty?t.empty():null!=t&&null!=t.constructor&&"function"==typeof t.constructor.empty?t.constructor.empty():c(t)?[]:G(t)?"":E(t)?{}:v(t)?function(){return arguments}():function(t){var e=Object.prototype.toString.call(t);return"[object Uint8ClampedArray]"===e||"[object Int8Array]"===e||"[object Uint8Array]"===e||"[object Int16Array]"===e||"[object Uint16Array]"===e||"[object Int32Array]"===e||"[object Uint32Array]"===e||"[object Float32Array]"===e||"[object Float64Array]"===e||"[object BigInt64Array]"===e||"[object BigUint64Array]"===e}(t)?t.constructor.from(""):void 0})),ht=function(){function t(t,e){this.xf=e,this.f=t,this.found=!1}return t.prototype["@@transducer/init"]=p,t.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,void 0)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){var n;return this.f(e)&&(this.found=!0,t=(n=this.xf["@@transducer/step"](t,e))&&n["@@transducer/reduced"]?n:{"@@transducer/value":n,"@@transducer/reduced":!0}),t},t}();function yt(t){return function(e){return new ht(t,e)}}var dt=o(l(["find"],yt,(function(t,e){for(var n=0,r=e.length;n<r;){if(t(e[n]))return e[n];n+=1}}))),gt=o(x),mt=o((function(t,e){return i(t+1,(function(){var n=arguments[t];if(null!=n&&function(t){var e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e||"[object GeneratorFunction]"===e||"[object AsyncGeneratorFunction]"===e}(n[e]))return n[e].apply(n,Array.prototype.slice.call(arguments,0,t));throw new TypeError(K(n)+' does not have a method named "'+e+'"')}))})),vt=r((function(t){return null!=t&&T(t,ft(t))})),bt=mt(1,"join"),St=o((function(t,e){return function(n){return function(r){return z((function(t){return e(t,r)}),n(t(r)))}}})),jt=o((function(t,e){return t.map((function(t){for(var n,r=e,o=0;o<t.length;){if(null==r)return;n=t[o],r=D(n)?L(n,r):r[n],o+=1}return r}))})),wt=o((function(t,e){return jt([t],e)[0]})),At=r((function(t){return St(wt(t),ot(t))})),_t=function(t){return{value:t,"fantasy-land/map":function(){return this}}},kt=o((function(t,e){return t(_t)(e).value}));const Ot=pt(((t,e,n,r)=>lt(Z(r),dt((t=>gt(n,t[e]))))(t))),Tt=At(["results","0","address_components"]),xt=t=>{const e=t.results?t.results[0]:t.result;if(!e||vt(e))return{};let n=null;n=t.results?kt(Tt)(t):e.address_components;const r=Ot(n,"types"),o=e.formatted_address,a=e.geometry&&e.geometry.location&&e.geometry.location.lat?e.geometry.location.lat:null,s=e.geometry&&e.geometry.location&&e.geometry.location.lng?e.geometry.location.lng:null,i=r("street_number","short_name")||"",u=r("route","long_name")||"",c=(i||u)&&`${i} ${u}`,l={state:r("administrative_area_level_1","short_name"),city:r("locality","short_name")||r("sublocality","short_name")||r("neighborhood","long_name")||r("administrative_area_level_3","long_name")||r("administrative_area_level_2","short_name"),street_1:c.trim(),country:r("country","short_name"),zipcode:r("postal_code","long_name"),latitude:a&&Number(a),longitude:s&&Number(s),formattedAddress:o};return $(Boolean)(l)};return t.GeoService=class{constructor(t){this.mapsKey=t}async geocode(t){const e=await fetch(`https://maps.googleapis.com/maps/api/geocode/json?address=${t}&key=${this.mapsKey}`),n=await e.json();return xt(n)}async geocodeZip(t){const e=await fetch(`https://maps.googleapis.com/maps/api/geocode/json?components=country:US|postal_code:${t}&key=${this.mapsKey}`),n=await e.json();return xt(n)}async reverseGeocode(t,e){const n=await fetch(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${t},${e}&key=${this.mapsKey}`),r=await n.json();return xt(r)}async geoLocate(){const t=`https://www.googleapis.com/geolocation/v1/geolocate?key=${this.mapsKey}`,e=await fetch(t,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"}}),n=await e.json(),{lat:r,lng:o}=n.location;return this.reverseGeocode(r,o)}async getLocationSuggestions(t){const{input:e,latitude:n,longitude:r,radius:o}=t,{requestCity:a,requestState:s,requestZipcode:i}=t,u=bt(",",$(Boolean,[n,r]));let{sessiontoken:c}=t;c||(c=crypto.randomUUID().replaceAll("-",""));const l=$(Boolean,{input:e,sessiontoken:c,location:u,radius:o,components:"country:US",types:"address",key:this.mapsKey});let p="";if(l){p=new URLSearchParams(l).toString()}const f=`https://maps.googleapis.com/maps/api/place/autocomplete/json?${p}`,h=await fetch(f,{method:"GET",headers:{Accept:"application/json"}}),y=await h.json();let d=[];if(y.predictions&&"OK"===y.status){const t={requestCity:a,requestState:s,requestZipcode:i};d=((t,e={})=>{const{requestCity:n,requestState:r,requestZipcode:o}=e,a=t=>({description:t.description,placeId:t.place_id});let s=null;return n||r||o||(s=t.map(a)),s=t.map((t=>{const e={description:t.description,place_id:t.place_id},a=t.terms.filter((t=>n&&t.value===n)).length>0?1:0,s=t.terms.filter((t=>r&&t.value===r)).length>0?1:0,i=t.terms.filter((t=>o&&t.value===o)).length>0?1:0;return e.score=a+s+i,e.stateMatch=!r||r&&s,e.zipCodeMatch=!o||o&&i,e})).filter((t=>!!t.stateMatch&&!!t.zipCodeMatch)).sort(((t,e)=>t.score===e.score?0:t.score<e.score?1:-1)).map(a),s})(y.predictions,t)}return{autocompletePredictions:d,sessiontoken:c}}async getPlaceId(t){const{placeId:e,sessiontoken:n}=t,r=$(Boolean,{place_id:e,sessiontoken:n,key:this.mapsKey});let o="";if(r){o=new URLSearchParams(r).toString()}const a=`https://maps.googleapis.com/maps/api/place/details/json?${o}`,s=await fetch(a),i=await s.json();return xt(i)}async getNavigatorPosition(){const t=t=>{console.error(t)};navigator.geolocation&&navigator.geolocation.getCurrentPosition((t=>{const e=t.coords.latitude,n=t.coords.longitude;return this.reverseGeocode(e,n)}),t)||t({message:"geolocation is not enabled."})}},t.ThirstieAPI=class{#t;#e;#n;#r;#o;constructor(t,n={}){const{env:r,initState:o}=n;this.#o=r,this.#r={sessionToken:null,application:null,applicationRef:null,sessionRef:null,userRef:null,user:{},message:null},this.#t=t,this.#e=e(r),this.#n=Object.seal(this.#r);const{sessionToken:a,application:s,applicationRef:i,sessionRef:u}=o||{};if(a&&s&&i&&u){const t={sessionToken:a,application:s,applicationRef:i,sessionRef:u};this.apiState=t}}get sessionToken(){return this.#n.sessionToken}get sessionRef(){return this.#n.sessionRef}get userRef(){return this.#n.userRef}get applicationRef(){return this.#n.applicationRef}get application(){return this.#n.application}get sessionState(){const{sessionToken:t,application:e,applicationRef:n,sessionRef:r,userRef:o}=this.#n;return{sessionToken:t,application:e,applicationRef:n,sessionRef:r,userRef:o}}get apiState(){return this.#n}set apiState(t){try{return Object.assign(this.#n,t)}catch(t){return console.error("set apiState",t),this.#n}}#a(t){const e={application:t.application_name,applicationRef:t.uuid,sessionToken:t.token,sessionRef:t.session_uuid};if(e.userRef=t.user?.id,t.user){const{birthday:n,email:r,prefix:o,guest:a,first_name:s,last_name:i,phone_number:u,last_login:c}=t.user;e.user={email:r,birthday:n,prefix:o,firstName:s,lastName:i,phoneNumber:u,guest:a,lastLogin:c}}this.apiState=e}#s(t){this.apiState=this.#r,console.error("session error",t)}async getNewSession(t={},e=!0){const{email:n,password:r}=t,o={basicAuth:e};n&&r&&(o.data={email:n,password:r});const a=await this.apiCaller("POST","/a/v2/sessions",o);return a&&a.ok&&a.data?a.data:{code:a.status,message:a.message||"unknown error",response:a}}async validateSession(t){if(t&&(this.apiState={sessionToken:t}),!this.sessionToken)return{};const e=await this.apiCaller("GET","/a/v2/sessions");return e&&e.ok&&e.data?e.data:await this.getNewSession()}async fetchSession(t=null,e=!1){let n={};return n=!this.sessionToken&&!t||e?await this.getNewSession():await this.validateSession(t),n.token?this.#a(n):this.#s(n),this.apiState}async loginUser(t){const{email:e,password:n}=t,r=!this.sessionToken;if(!e||!n)throw new Error("Invalid credential payload");const o=await this.getNewSession(t,r);if(o.token)this.#a(o);else{this.#s(o);const{response:t}=o,{data:e}=t;e?.message&&(this.apiState.message=e?.message)}return this.apiState}async createUser(t,e=null){const n={},{email:r,password:o}=t,{birthday:a,prefix:s,firstName:i,lastName:u,phoneNumber:c,guestCheck:l,emailOptIn:p}=t,f={email:r,birthday:a,prefix:s,first_name:i,last_name:u,phone_number:c,guest_check:!!l};p&&(f.aux_data={thirstieaccess_email_opt_in:p});const h=!this.sessionToken;r&&o?f.password=o:f.guest=!0,n.data=f,n.basicAuth=h;const y=await this.apiCaller("POST","/a/v2/users",n,e);return y.data.token?this.#a(y.data):this.#s(y),this.apiState}async apiCaller(t,n,r={},o=null){const{data:a,params:s,basicAuth:i,isFormData:u,isTemplate:c,isPayment:l}=r,{sessionRef:p,application:f,applicationRef:h,userRef:y}=this.apiState;if(!this.sessionToken&&!i)throw new Error("Invalid Authorization");const d={Authorization:this.sessionToken&&!i?`Bearer ${this.sessionToken}`:`Basic ${btoa(this.#t)}`,Accept:"application/json"};u||(d["Content-Type"]="application/json");const g={method:t,headers:d};["POST","PUT","PATCH"].includes(t)&&a&&(g.body=u?a:JSON.stringify(a));const m=e(this.#o);let v=m;l&&(v="https://api.thirstie.com"===m?"https://merchant-payments.thirstie.cloud":"https://merchant-payments.next.thirstie.cloud"),c&&(v=(t=>"https://api.thirstie.com"===t?"https://templates.thirstie.cloud":"https://staging.templates.thirstie.cloud")(m));const{requestUrl:b,queryString:S}=function(t,e,n=null){let r="";n&&(r="?"+new URLSearchParams(n).toString());return{requestUrl:`${t}${e}${r}`,queryString:r}}(v,n,s),j={environment:this.#o,sessionRef:p,application:f,applicationRef:h,userRef:y,data:a,queryString:S,url:n,baseUrl:v};try{const t=await async function(t,e){const n={ok:null,status:null,statusText:null,data:{}};try{const r=await fetch(t,e);let o={};const a=r.headers;return a&&a.get("content-type")?.indexOf("application/json")>-1&&parseInt(a.get("content-length"))>0&&(o=await r.json()),Object.assign(n,{ok:r.ok,status:r.status,statusText:r.statusText,data:o,url:t})}catch(e){return console.error("apiRequest error: ",e),Object.assign(n,{ok:!1,status:500,statusText:"ERROR",data:{message:"Network error",error:e},url:t})}}(b,g);if(t)return!t.ok&&o&&o({code:t.status,message:t.statusText||"unknown error",response:t,telemetryContext:j}),t}catch(t){return o&&o({code:500,message:"unknown error",error:t,telemetryContext:j}),t}}},t}({});
1
+ var thirstieservices=function(t){"use strict";const e=t=>{let e="https://api.next.thirstie.com";switch(t?.toLowerCase()){case"prod":e="https://api.thirstie.com";break;case"sandbox":e="https://api.sandbox.thirstie.com"}return e};function n(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function r(t){return function e(r){return 0===arguments.length||n(r)?e:t.apply(this,arguments)}}function o(t){return function e(o,a){switch(arguments.length){case 0:return e;case 1:return n(o)?e:r((function(e){return t(o,e)}));default:return n(o)&&n(a)?e:n(o)?r((function(e){return t(e,a)})):n(a)?r((function(e){return t(o,e)})):t(o,a)}}}function a(t,e){switch(t){case 0:return function(){return e.apply(this,arguments)};case 1:return function(t){return e.apply(this,arguments)};case 2:return function(t,n){return e.apply(this,arguments)};case 3:return function(t,n,r){return e.apply(this,arguments)};case 4:return function(t,n,r,o){return e.apply(this,arguments)};case 5:return function(t,n,r,o,a){return e.apply(this,arguments)};case 6:return function(t,n,r,o,a,s){return e.apply(this,arguments)};case 7:return function(t,n,r,o,a,s,i){return e.apply(this,arguments)};case 8:return function(t,n,r,o,a,s,i,u){return e.apply(this,arguments)};case 9:return function(t,n,r,o,a,s,i,u,c){return e.apply(this,arguments)};case 10:return function(t,n,r,o,a,s,i,u,c,l){return e.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function s(t,e,r){return function(){for(var o=[],i=0,u=t,c=0,l=!1;c<e.length||i<arguments.length;){var p;c<e.length&&(!n(e[c])||i>=arguments.length)?p=e[c]:(p=arguments[i],i+=1),o[c]=p,n(p)?l=!0:u-=1,c+=1}return!l&&u<=0?r.apply(this,o):a(Math.max(0,u),s(t,o,r))}}var i=o((function(t,e){return 1===t?r(e):a(t,s(t,[],e))}));function u(t){return function e(a,s,i){switch(arguments.length){case 0:return e;case 1:return n(a)?e:o((function(e,n){return t(a,e,n)}));case 2:return n(a)&&n(s)?e:n(a)?o((function(e,n){return t(e,s,n)})):n(s)?o((function(e,n){return t(a,e,n)})):r((function(e){return t(a,s,e)}));default:return n(a)&&n(s)&&n(i)?e:n(a)&&n(s)?o((function(e,n){return t(e,n,i)})):n(a)&&n(i)?o((function(e,n){return t(e,s,n)})):n(s)&&n(i)?o((function(e,n){return t(a,e,n)})):n(a)?r((function(e){return t(e,s,i)})):n(s)?r((function(e){return t(a,e,i)})):n(i)?r((function(e){return t(a,s,e)})):t(a,s,i)}}}var c=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)};function l(t,e,n){return function(){if(0===arguments.length)return n();var r=arguments[arguments.length-1];if(!c(r)){for(var o=0;o<t.length;){if("function"==typeof r[t[o]])return r[t[o]].apply(r,Array.prototype.slice.call(arguments,0,-1));o+=1}if(function(t){return null!=t&&"function"==typeof t["@@transducer/step"]}(r))return e.apply(null,Array.prototype.slice.call(arguments,0,-1))(r)}return n.apply(this,arguments)}}var p=function(){return this.xf["@@transducer/init"]()},f=function(t){return this.xf["@@transducer/result"](t)};function h(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}function y(t,e,n){for(var r=0,o=n.length;r<o;){if(t(e,n[r]))return!0;r+=1}return!1}function d(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var g="function"==typeof Object.is?Object.is:function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e},m=Object.prototype.toString,v=function(){return"[object Arguments]"===m.call(arguments)?function(t){return"[object Arguments]"===m.call(t)}:function(t){return d("callee",t)}}(),b=!{toString:null}.propertyIsEnumerable("toString"),S=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],j=function(){return arguments.propertyIsEnumerable("length")}(),w=function(t,e){for(var n=0;n<t.length;){if(t[n]===e)return!0;n+=1}return!1},A="function"!=typeof Object.keys||j?r((function(t){if(Object(t)!==t)return[];var e,n,r=[],o=j&&v(t);for(e in t)!d(e,t)||o&&"length"===e||(r[r.length]=e);if(b)for(n=S.length-1;n>=0;)d(e=S[n],t)&&!w(r,e)&&(r[r.length]=e),n-=1;return r})):r((function(t){return Object(t)!==t?[]:Object.keys(t)})),k=r((function(t){return null===t?"Null":void 0===t?"Undefined":Object.prototype.toString.call(t).slice(8,-1)}));function _(t,e,n,r){var o=h(t);function a(t,e){return O(t,e,n.slice(),r.slice())}return!y((function(t,e){return!y(a,e,t)}),h(e),o)}function O(t,e,n,r){if(g(t,e))return!0;var o,a,s=k(t);if(s!==k(e))return!1;if("function"==typeof t["fantasy-land/equals"]||"function"==typeof e["fantasy-land/equals"])return"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e)&&"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t);if("function"==typeof t.equals||"function"==typeof e.equals)return"function"==typeof t.equals&&t.equals(e)&&"function"==typeof e.equals&&e.equals(t);switch(s){case"Arguments":case"Array":case"Object":if("function"==typeof t.constructor&&"Promise"===(o=t.constructor,null==(a=String(o).match(/^function (\w*)/))?"":a[1]))return t===e;break;case"Boolean":case"Number":case"String":if(typeof t!=typeof e||!g(t.valueOf(),e.valueOf()))return!1;break;case"Date":if(!g(t.valueOf(),e.valueOf()))return!1;break;case"Error":return t.name===e.name&&t.message===e.message;case"RegExp":if(t.source!==e.source||t.global!==e.global||t.ignoreCase!==e.ignoreCase||t.multiline!==e.multiline||t.sticky!==e.sticky||t.unicode!==e.unicode)return!1}for(var i=n.length-1;i>=0;){if(n[i]===t)return r[i]===e;i-=1}switch(s){case"Map":return t.size===e.size&&_(t.entries(),e.entries(),n.concat([t]),r.concat([e]));case"Set":return t.size===e.size&&_(t.values(),e.values(),n.concat([t]),r.concat([e]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var u=A(t);if(u.length!==A(e).length)return!1;var c=n.concat([t]),l=r.concat([e]);for(i=u.length-1;i>=0;){var p=u[i];if(!d(p,e)||!O(e[p],t[p],c,l))return!1;i-=1}return!0}var T=o((function(t,e){return O(t,e,[],[])}));function x(t,e){return function(t,e,n){var r,o;if("function"==typeof t.indexOf)switch(typeof e){case"number":if(0===e){for(r=1/e;n<t.length;){if(0===(o=t[n])&&1/o===r)return n;n+=1}return-1}if(e!=e){for(;n<t.length;){if("number"==typeof(o=t[n])&&o!=o)return n;n+=1}return-1}return t.indexOf(e,n);case"string":case"boolean":case"function":case"undefined":return t.indexOf(e,n);case"object":if(null===e)return t.indexOf(e,n)}for(;n<t.length;){if(T(t[n],e))return n;n+=1}return-1}(e,t,0)>=0}function R(t,e){for(var n=0,r=e.length,o=Array(r);n<r;)o[n]=t(e[n]),n+=1;return o}function U(t){return'"'+t.replace(/\\/g,"\\\\").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0").replace(/"/g,'\\"')+'"'}var C=function(t){return(t<10?"0":"")+t},q="function"==typeof Date.prototype.toISOString?function(t){return t.toISOString()}:function(t){return t.getUTCFullYear()+"-"+C(t.getUTCMonth()+1)+"-"+C(t.getUTCDate())+"T"+C(t.getUTCHours())+":"+C(t.getUTCMinutes())+":"+C(t.getUTCSeconds())+"."+(t.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};function N(t,e,n){for(var r=0,o=n.length;r<o;)e=t(e,n[r]),r+=1;return e}function E(t){return"[object Object]"===Object.prototype.toString.call(t)}var I=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=p,t.prototype["@@transducer/result"]=f,t.prototype["@@transducer/step"]=function(t,e){return this.f(e)?this.xf["@@transducer/step"](t,e):t},t}();function P(t){return function(e){return new I(t,e)}}var $=o(l(["fantasy-land/filter","filter"],P,(function(t,e){return E(e)?N((function(n,r){return t(e[r])&&(n[r]=e[r]),n}),{},A(e)):function(t,e){for(var n=0,r=e.length,o=[];n<r;)t(e[n])&&(o[o.length]=e[n]),n+=1;return o}(t,e)}))),B=o((function(t,e){return $((n=t,function(){return!n.apply(this,arguments)}),e);var n}));function F(t,e){var n=function(n){var r=e.concat([t]);return x(n,r)?"<Circular>":F(n,r)},r=function(t,e){return R((function(e){return U(e)+": "+n(t[e])}),e.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+R(n,t).join(", ")+"))";case"[object Array]":return"["+R(n,t).concat(r(t,B((function(t){return/^\d+$/.test(t)}),A(t)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof t?"new Boolean("+n(t.valueOf())+")":t.toString();case"[object Date]":return"new Date("+(isNaN(t.valueOf())?n(NaN):U(q(t)))+")";case"[object Map]":return"new Map("+n(Array.from(t))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof t?"new Number("+n(t.valueOf())+")":1/t==-1/0?"-0":t.toString(10);case"[object Set]":return"new Set("+n(Array.from(t).sort())+")";case"[object String]":return"object"==typeof t?"new String("+n(t.valueOf())+")":U(t);case"[object Undefined]":return"undefined";default:if("function"==typeof t.toString){var o=t.toString();if("[object Object]"!==o)return o}return"{"+r(t,A(t)).join(", ")+"}"}}var K=r((function(t){return F(t,[])})),M=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=p,t.prototype["@@transducer/result"]=f,t.prototype["@@transducer/step"]=function(t,e){return this.xf["@@transducer/step"](t,this.f(e))},t}(),z=o(l(["fantasy-land/map","map"],(function(t){return function(e){return new M(t,e)}}),(function(t,e){switch(Object.prototype.toString.call(e)){case"[object Function]":return i(e.length,(function(){return t.call(this,e.apply(this,arguments))}));case"[object Object]":return N((function(n,r){return n[r]=t(e[r]),n}),{},A(e));default:return R(t,e)}}))),D=Number.isInteger||function(t){return(t|0)===t};function G(t){return"[object String]"===Object.prototype.toString.call(t)}var L=o((function(t,e){var n=t<0?e.length+t:t;return G(e)?e.charAt(n):e[n]})),Z=o((function(t,e){if(null!=e)return D(t)?L(t,e):e[t]})),H=r((function(t){return!!c(t)||!!t&&("object"==typeof t&&(!G(t)&&(0===t.length||t.length>0&&(t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1)))))})),J="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function V(t,e,n){return function(r,o,a){if(H(a))return t(r,o,a);if(null==a)return o;if("function"==typeof a["fantasy-land/reduce"])return e(r,o,a,"fantasy-land/reduce");if(null!=a[J])return n(r,o,a[J]());if("function"==typeof a.next)return n(r,o,a);if("function"==typeof a.reduce)return e(r,o,a,"reduce");throw new TypeError("reduce: list must be array or iterable")}}function W(t,e,n){for(var r=0,o=n.length;r<o;){if((e=t["@@transducer/step"](e,n[r]))&&e["@@transducer/reduced"]){e=e["@@transducer/value"];break}r+=1}return t["@@transducer/result"](e)}var X=o((function(t,e){return a(t.length,(function(){return t.apply(e,arguments)}))}));function Y(t,e,n){for(var r=n.next();!r.done;){if((e=t["@@transducer/step"](e,r.value))&&e["@@transducer/reduced"]){e=e["@@transducer/value"];break}r=n.next()}return t["@@transducer/result"](e)}function Q(t,e,n,r){return t["@@transducer/result"](n[r](X(t["@@transducer/step"],t),e))}var tt=V(W,Q,Y),et=function(){function t(t){this.f=t}return t.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},t.prototype["@@transducer/result"]=function(t){return t},t.prototype["@@transducer/step"]=function(t,e){return this.f(t,e)},t}();var nt=u((function(t,e,n){return tt("function"==typeof t?new et(t):t,e,n)}));var rt=r((function(t){return null==t})),ot=u((function t(e,n,r){if(0===e.length)return n;var o=e[0];if(e.length>1){var a=!rt(r)&&d(o,r)&&"object"==typeof r[o]?r[o]:D(e[1])?[]:{};n=t(Array.prototype.slice.call(e,1),n,a)}return function(t,e,n){if(D(t)&&c(n)){var r=[].concat(n);return r[t]=e,r}var o={};for(var a in n)o[a]=n[a];return o[t]=e,o}(o,n,r)}));function at(t,e){return function(){return e.call(this,t.apply(this,arguments))}}function st(t,e){return function(){var n=arguments.length;if(0===n)return e();var r=arguments[n-1];return c(r)||"function"!=typeof r[t]?e.apply(this,arguments):r[t].apply(r,Array.prototype.slice.call(arguments,0,n-1))}}var it=r(st("tail",u(st("slice",(function(t,e,n){return Array.prototype.slice.call(n,t,e)})))(1,1/0)));function ut(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return a(arguments[0].length,nt(at,arguments[0],it(arguments)))}var ct=r((function(t){return G(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()}));function lt(){if(0===arguments.length)throw new Error("compose requires at least one argument");return ut.apply(this,ct(arguments))}var pt=r((function(t){return i(t.length,t)}));var ft=r((function(t){return null!=t&&"function"==typeof t["fantasy-land/empty"]?t["fantasy-land/empty"]():null!=t&&null!=t.constructor&&"function"==typeof t.constructor["fantasy-land/empty"]?t.constructor["fantasy-land/empty"]():null!=t&&"function"==typeof t.empty?t.empty():null!=t&&null!=t.constructor&&"function"==typeof t.constructor.empty?t.constructor.empty():c(t)?[]:G(t)?"":E(t)?{}:v(t)?function(){return arguments}():function(t){var e=Object.prototype.toString.call(t);return"[object Uint8ClampedArray]"===e||"[object Int8Array]"===e||"[object Uint8Array]"===e||"[object Int16Array]"===e||"[object Uint16Array]"===e||"[object Int32Array]"===e||"[object Uint32Array]"===e||"[object Float32Array]"===e||"[object Float64Array]"===e||"[object BigInt64Array]"===e||"[object BigUint64Array]"===e}(t)?t.constructor.from(""):void 0})),ht=function(){function t(t,e){this.xf=e,this.f=t,this.found=!1}return t.prototype["@@transducer/init"]=p,t.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,void 0)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){var n;return this.f(e)&&(this.found=!0,t=(n=this.xf["@@transducer/step"](t,e))&&n["@@transducer/reduced"]?n:{"@@transducer/value":n,"@@transducer/reduced":!0}),t},t}();function yt(t){return function(e){return new ht(t,e)}}var dt=o(l(["find"],yt,(function(t,e){for(var n=0,r=e.length;n<r;){if(t(e[n]))return e[n];n+=1}}))),gt=o(x),mt=o((function(t,e){return i(t+1,(function(){var n=arguments[t];if(null!=n&&function(t){var e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e||"[object GeneratorFunction]"===e||"[object AsyncGeneratorFunction]"===e}(n[e]))return n[e].apply(n,Array.prototype.slice.call(arguments,0,t));throw new TypeError(K(n)+' does not have a method named "'+e+'"')}))})),vt=r((function(t){return null!=t&&T(t,ft(t))})),bt=mt(1,"join"),St=o((function(t,e){return function(n){return function(r){return z((function(t){return e(t,r)}),n(t(r)))}}})),jt=o((function(t,e){return t.map((function(t){for(var n,r=e,o=0;o<t.length;){if(null==r)return;n=t[o],r=D(n)?L(n,r):r[n],o+=1}return r}))})),wt=o((function(t,e){return jt([t],e)[0]})),At=r((function(t){return St(wt(t),ot(t))})),kt=function(t){return{value:t,"fantasy-land/map":function(){return this}}},_t=o((function(t,e){return t(kt)(e).value}));const Ot=pt(((t,e,n,r)=>lt(Z(r),dt((t=>gt(n,t[e]))))(t))),Tt=At(["results","0","address_components"]),xt=t=>{const e=t.results?t.results[0]:t.result;if(!e||vt(e))return{};let n=null;n=t.results?_t(Tt)(t):e.address_components;const r=Ot(n,"types"),o=e.formatted_address,a=e.geometry&&e.geometry.location&&e.geometry.location.lat?e.geometry.location.lat:null,s=e.geometry&&e.geometry.location&&e.geometry.location.lng?e.geometry.location.lng:null,i=r("street_number","short_name")||"",u=r("route","long_name")||"",c=(i||u)&&`${i} ${u}`,l={state:r("administrative_area_level_1","short_name"),city:r("locality","short_name")||r("sublocality","short_name")||r("neighborhood","long_name")||r("administrative_area_level_3","long_name")||r("administrative_area_level_2","short_name"),street_1:c.trim(),country:r("country","short_name"),zipcode:r("postal_code","long_name"),latitude:a&&Number(a),longitude:s&&Number(s),formattedAddress:o};return $(Boolean)(l)};return t.GeoService=class{constructor(t){this.mapsKey=t}async geocode(t){const e=await fetch(`https://maps.googleapis.com/maps/api/geocode/json?address=${t}&key=${this.mapsKey}`),n=await e.json();return xt(n)}async geocodeZip(t){const e=await fetch(`https://maps.googleapis.com/maps/api/geocode/json?components=country:US|postal_code:${t}&key=${this.mapsKey}`),n=await e.json();return xt(n)}async reverseGeocode(t,e){const n=await fetch(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${t},${e}&key=${this.mapsKey}`),r=await n.json();return xt(r)}async geoLocate(){const t=`https://www.googleapis.com/geolocation/v1/geolocate?key=${this.mapsKey}`,e=await fetch(t,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"}}),n=await e.json(),{lat:r,lng:o}=n.location;return this.reverseGeocode(r,o)}async getLocationSuggestions(t){const{input:e,latitude:n,longitude:r,radius:o}=t,{requestCity:a,requestState:s,requestZipcode:i}=t,u=bt(",",$(Boolean,[n,r]));let{sessiontoken:c}=t;c||(c=crypto.randomUUID().replaceAll("-",""));const l=$(Boolean,{input:e,sessiontoken:c,location:u,radius:o,components:"country:US",types:"address",key:this.mapsKey});let p="";if(l){p=new URLSearchParams(l).toString()}const f=`https://maps.googleapis.com/maps/api/place/autocomplete/json?${p}`,h=await fetch(f,{method:"GET",headers:{Accept:"application/json"}}),y=await h.json();let d=[];if(y.predictions&&"OK"===y.status){const t={requestCity:a,requestState:s,requestZipcode:i};d=((t,e={})=>{const{requestCity:n,requestState:r,requestZipcode:o}=e,a=t=>({description:t.description,placeId:t.place_id});let s=null;return n||r||o||(s=t.map(a)),s=t.map((t=>{const e={description:t.description,place_id:t.place_id},a=t.terms.filter((t=>n&&t.value===n)).length>0?1:0,s=t.terms.filter((t=>r&&t.value===r)).length>0?1:0,i=t.terms.filter((t=>o&&t.value===o)).length>0?1:0;return e.score=a+s+i,e.stateMatch=!r||r&&s,e.zipCodeMatch=!o||o&&i,e})).filter((t=>!!t.stateMatch&&!!t.zipCodeMatch)).sort(((t,e)=>t.score===e.score?0:t.score<e.score?1:-1)).map(a),s})(y.predictions,t)}return{autocompletePredictions:d,sessiontoken:c}}async getPlaceId(t){const{placeId:e,sessiontoken:n}=t,r=$(Boolean,{place_id:e,sessiontoken:n,key:this.mapsKey});let o="";if(r){o=new URLSearchParams(r).toString()}const a=`https://maps.googleapis.com/maps/api/place/details/json?${o}`,s=await fetch(a),i=await s.json();return xt(i)}async getNavigatorPosition(){const t=t=>{console.error(t)};navigator.geolocation&&navigator.geolocation.getCurrentPosition((t=>{const e=t.coords.latitude,n=t.coords.longitude;return this.reverseGeocode(e,n)}),t)||t({message:"geolocation is not enabled."})}},t.ThirstieAPI=class{#t;#e;#n;#r;#o;constructor(t,n={}){const{env:r,initState:o}=n;this.#o=r,this.#r={sessionToken:null,application:null,applicationRef:null,sessionRef:null,userRef:null,user:{},message:null},this.#t=t,this.#e=e(r),this.#n=Object.seal(this.#r);const{sessionToken:a,application:s,applicationRef:i,sessionRef:u}=o||{};if(a&&s&&i&&u){const t={sessionToken:a,application:s,applicationRef:i,sessionRef:u};this.apiState=t}}get sessionToken(){return this.#n.sessionToken}get sessionRef(){return this.#n.sessionRef}get userRef(){return this.#n.userRef}get applicationRef(){return this.#n.applicationRef}get application(){return this.#n.application}get sessionState(){const{sessionToken:t,application:e,applicationRef:n,sessionRef:r,userRef:o}=this.#n;return{sessionToken:t,application:e,applicationRef:n,sessionRef:r,userRef:o}}get apiState(){return this.#n}set apiState(t){try{return Object.assign(this.#n,t)}catch(t){return console.error("set apiState",t),this.#n}}#a(t){const e={application:t.application_name,applicationRef:t.uuid,sessionToken:t.token,sessionRef:t.session_uuid};if(e.userRef=t.user?.id,t.user){const{birthday:n,email:r,prefix:o,guest:a,first_name:s,last_name:i,phone_number:u,last_login:c}=t.user;e.user={email:r,birthday:n,prefix:o,firstName:s,lastName:i,phoneNumber:u,guest:a,lastLogin:c}}this.apiState=e}#s(t){this.apiState=this.#r,console.error("session error",t)}async getNewSession(t={},e=!0){const{email:n,password:r}=t,o={basicAuth:e};n&&r&&(o.data={email:n,password:r});const a=await this.apiCaller("POST","/a/v2/sessions",o);return a&&a.ok&&a.data?a.data:{code:a.status,message:a.message||"unknown error",response:a}}async validateSession(t){if(t&&(this.apiState={sessionToken:t}),!this.sessionToken)return{};const e=await this.apiCaller("GET","/a/v2/sessions");return e&&e.ok&&e.data?e.data:await this.getNewSession()}async fetchSession(t=null,e=!1){let n={};return n=!this.sessionToken&&!t||e?await this.getNewSession():await this.validateSession(t),n.token?this.#a(n):this.#s(n),this.apiState}async loginUser(t){const{email:e,password:n}=t,r=!this.sessionToken;if(!e||!n)throw new Error("Invalid credential payload");const o=await this.getNewSession(t,r);if(o.token)this.#a(o);else{this.#s(o);const{response:t}=o,{data:e}=t;e?.message&&(this.apiState.message=e?.message)}return this.apiState}async createUser(t,e=null){const n={},{email:r,password:o}=t,{birthday:a,prefix:s,firstName:i,lastName:u,phoneNumber:c,guestCheck:l,emailOptIn:p}=t,f={email:r,birthday:a,prefix:s,first_name:i,last_name:u,phone_number:c,guest_check:!!l};p&&(f.aux_data={thirstieaccess_email_opt_in:p});const h=!this.sessionToken;r&&o?f.password=o:f.guest=!0,n.data=f,n.basicAuth=h;const y=await this.apiCaller("POST","/a/v2/users",n,e);return y.data.token?this.#a(y.data):this.#s(y),this.apiState}async apiCaller(t,n,r={},o=null){const{data:a,params:s,basicAuth:i,isFormData:u,isTemplate:c,isPayment:l,isCSV:p}=r,{sessionRef:f,application:h,applicationRef:y,userRef:d}=this.apiState;if(!this.sessionToken&&!i)throw new Error("Invalid Authorization");const g={Authorization:this.sessionToken&&!i?`Bearer ${this.sessionToken}`:`Basic ${btoa(this.#t)}`,Accept:"application/json"};u||(g["Content-Type"]="application/json"),p&&(g.Accept="text/csv",delete g["Content-Type"]);const m={method:t,headers:g};["POST","PUT","PATCH"].includes(t)&&a&&(m.body=u?a:JSON.stringify(a));const v=e(this.#o);let b=v;l&&(b="https://api.thirstie.com"===v?"https://merchant-payments.thirstie.cloud":"https://merchant-payments.next.thirstie.cloud"),c&&(b=(t=>"https://api.thirstie.com"===t?"https://templates.thirstie.cloud":"https://staging.templates.thirstie.cloud")(v));const{requestUrl:S,queryString:j}=function(t,e,n=null){let r="";n&&(r="?"+new URLSearchParams(n).toString());return{requestUrl:`${t}${e}${r}`,queryString:r}}(b,n,s),w={environment:this.#o,sessionRef:f,application:h,applicationRef:y,userRef:d,data:a,queryString:j,url:n,baseUrl:b};try{const t=await async function(t,e){const n={ok:null,status:null,statusText:null,data:{}};try{const r=await fetch(t,e);let o={};const a=r.headers;return a&&a.get("content-type")?.indexOf("application/json")>-1&&parseInt(a.get("content-length"))>0&&(o=await r.json()),Object.assign(n,{ok:r.ok,status:r.status,statusText:r.statusText,data:o,url:t})}catch(e){return console.error("apiRequest error: ",e),Object.assign(n,{ok:!1,status:500,statusText:"ERROR",data:{message:"Network error",error:e},url:t})}}(S,m);if(t)return!t.ok&&o&&o({code:t.status,message:t.statusText||"unknown error",response:t,telemetryContext:w}),p?{ok:t.ok,status:t.status,statusText:t.statusText,url:t.url,data:await t.text()}:t}catch(t){return o&&o({code:500,message:"unknown error",error:t,telemetryContext:w}),t}}},t}({});
package/dist/bundle.mjs CHANGED
@@ -338,7 +338,7 @@ class ThirstieAPI {
338
338
  * @returns {object} - api response
339
339
  */
340
340
  async apiCaller (method, url, options = {}, errorHandler = null) {
341
- const { data, params, basicAuth, isFormData, isTemplate, isPayment } = options;
341
+ const { data, params, basicAuth, isFormData, isTemplate, isPayment, isCSV } = options;
342
342
  const { sessionRef, application, applicationRef, userRef } = this.apiState;
343
343
 
344
344
  if (!this.sessionToken && !basicAuth) {
@@ -359,6 +359,11 @@ class ThirstieAPI {
359
359
  headers['Content-Type'] = 'application/json';
360
360
  }
361
361
 
362
+ if (isCSV) {
363
+ headers.Accept = 'text/csv';
364
+ delete headers['Content-Type'];
365
+ }
366
+
362
367
  const requestConfig = { method, headers };
363
368
 
364
369
  if ([ 'POST', 'PUT', 'PATCH' ].includes(method) && !!data) {
@@ -396,6 +401,15 @@ class ThirstieAPI {
396
401
  telemetryContext
397
402
  });
398
403
  }
404
+ if (isCSV) {
405
+ return {
406
+ ok: response.ok,
407
+ status: response.status,
408
+ statusText: response.statusText,
409
+ url: response.url,
410
+ data: await response.text()
411
+ };
412
+ }
399
413
  return response;
400
414
  }
401
415
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thirstie/thirstieservices",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "description": "Service layer for Thirstie ecommerce API",
5
5
  "author": "Thirstie, Inc. <technology@thirstie.com>",
6
6
  "license": "MIT",
@@ -33,5 +33,5 @@
33
33
  "testEnvironment": "jsdom",
34
34
  "transform": {}
35
35
  },
36
- "gitHead": "1ffa053212d1c4989b5c3750e0c40cf489d5e0d1"
36
+ "gitHead": "9e88a4a2783c8c56191ab1bd1812552ddc64fda4"
37
37
  }
@@ -272,7 +272,7 @@ export default class ThirstieAPI {
272
272
  * @returns {object} - api response
273
273
  */
274
274
  async apiCaller (method, url, options = {}, errorHandler = null) {
275
- const { data, params, basicAuth, isFormData, isTemplate, isPayment } = options;
275
+ const { data, params, basicAuth, isFormData, isTemplate, isPayment, isCSV } = options;
276
276
  const { sessionRef, application, applicationRef, userRef } = this.apiState;
277
277
 
278
278
  if (!this.sessionToken && !basicAuth) {
@@ -293,6 +293,11 @@ export default class ThirstieAPI {
293
293
  headers['Content-Type'] = 'application/json';
294
294
  }
295
295
 
296
+ if (isCSV) {
297
+ headers.Accept = 'text/csv';
298
+ delete headers['Content-Type'];
299
+ }
300
+
296
301
  const requestConfig = { method, headers };
297
302
 
298
303
  if ([ 'POST', 'PUT', 'PATCH' ].includes(method) && !!data) {
@@ -330,6 +335,15 @@ export default class ThirstieAPI {
330
335
  telemetryContext
331
336
  });
332
337
  }
338
+ if (isCSV) {
339
+ return {
340
+ ok: response.ok,
341
+ status: response.status,
342
+ statusText: response.statusText,
343
+ url: response.url,
344
+ data: await response.text()
345
+ };
346
+ }
333
347
  return response;
334
348
  }
335
349
  } catch (error) {