@thirstie/thirstieservices 0.11.0 → 1.0.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 +20 -0
- package/coverage/clover.xml +2 -2
- package/coverage/lcov-report/geoservice/index.html +1 -1
- package/coverage/lcov-report/geoservice/index.js.html +1 -1
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/thirstieapi/utils/apirequest.js.html +1 -1
- package/coverage/lcov-report/thirstieapi/utils/environment.js.html +1 -1
- package/coverage/lcov-report/thirstieapi/utils/index.html +1 -1
- package/dist/bundle.cjs +2 -2
- package/dist/bundle.iife.js +1 -1
- package/dist/bundle.mjs +2 -2
- package/package.json +2 -2
- package/src/thirstieapi/index.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
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.0.0 (2025-03-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* improved session reloading ([99e996c](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/99e996c48b2457fb254bb9a2b26500394b907cb5))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* add sandbox environment ([f0b55c5](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/f0b55c58304d9d28d704bee2b9c16a64ab6af5fe))
|
|
17
|
+
* allow restoring age gate settings ([2030773](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/2030773073df53b56a08a3dd5937afac63c87217))
|
|
18
|
+
* simplify saving session state ([fa0ba48](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/fa0ba48d29140961e7c035605a0bee82ac7f0b17))
|
|
19
|
+
* TH-5423 create new session in extreme case ([82df06c](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/82df06c07b98331699593e05e2d1c39e65683e97))
|
|
20
|
+
* update user actions ([2f8cf07](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/2f8cf07f9bafbca4fd5d57435a37189541449ded))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
6
26
|
# 0.11.0 (2025-03-03)
|
|
7
27
|
|
|
8
28
|
|
package/coverage/clover.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="
|
|
3
|
-
<project timestamp="
|
|
2
|
+
<coverage generated="1742220735013" clover="3.2.0">
|
|
3
|
+
<project timestamp="1742220735013" name="All files">
|
|
4
4
|
<metrics statements="119" coveredstatements="54" conditionals="87" coveredconditionals="58" methods="24" coveredmethods="13" elements="230" coveredelements="125" complexity="0" loc="119" ncloc="119" 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-03-
|
|
104
|
+
at 2025-03-17T14:12:14.997Z
|
|
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-03-
|
|
769
|
+
at 2025-03-17T14:12:14.997Z
|
|
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-03-
|
|
119
|
+
at 2025-03-17T14:12:14.997Z
|
|
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-03-
|
|
211
|
+
at 2025-03-17T14:12:14.997Z
|
|
212
212
|
</div>
|
|
213
213
|
<script src="../../prettify.js"></script>
|
|
214
214
|
<script>
|
|
@@ -118,7 +118,7 @@ export {
|
|
|
118
118
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
119
119
|
Code coverage generated by
|
|
120
120
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
121
|
-
at 2025-03-
|
|
121
|
+
at 2025-03-17T14:12:14.997Z
|
|
122
122
|
</div>
|
|
123
123
|
<script src="../../prettify.js"></script>
|
|
124
124
|
<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-03-
|
|
119
|
+
at 2025-03-17T14:12:14.997Z
|
|
120
120
|
</div>
|
|
121
121
|
<script src="../../prettify.js"></script>
|
|
122
122
|
<script>
|
package/dist/bundle.cjs
CHANGED
|
@@ -230,9 +230,9 @@ class ThirstieAPI {
|
|
|
230
230
|
* @param {string} [existingToken] If provided, session JWT to be validated
|
|
231
231
|
* @returns {object} API State
|
|
232
232
|
*/
|
|
233
|
-
async fetchSession (existingToken = null) {
|
|
233
|
+
async fetchSession (existingToken = null, forceNewSession = false) {
|
|
234
234
|
let sessionData = {};
|
|
235
|
-
if (!this.sessionToken && !existingToken) {
|
|
235
|
+
if ((!this.sessionToken && !existingToken) || forceNewSession) {
|
|
236
236
|
sessionData = await this.getNewSession();
|
|
237
237
|
} else {
|
|
238
238
|
sessionData = await this.validateSession(existingToken);
|
package/dist/bundle.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var thirstieclient=function(t){"use strict";function e(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function n(t){return function n(r){return 0===arguments.length||e(r)?n:t.apply(this,arguments)}}function r(t){return function r(o,a){switch(arguments.length){case 0:return r;case 1:return e(o)?r:n((function(e){return t(o,e)}));default:return e(o)&&e(a)?r:e(o)?n((function(e){return t(e,a)})):e(a)?n((function(e){return t(o,e)})):t(o,a)}}}function o(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 a(t,n,r){return function(){for(var s=[],i=0,u=t,c=0,l=!1;c<n.length||i<arguments.length;){var f;c<n.length&&(!e(n[c])||i>=arguments.length)?f=n[c]:(f=arguments[i],i+=1),s[c]=f,e(f)?l=!0:u-=1,c+=1}return!l&&u<=0?r.apply(this,s):o(Math.max(0,u),a(t,s,r))}}var s=r((function(t,e){return 1===t?n(e):o(t,a(t,[],e))}));function i(t){return function o(a,s,i){switch(arguments.length){case 0:return o;case 1:return e(a)?o:r((function(e,n){return t(a,e,n)}));case 2:return e(a)&&e(s)?o:e(a)?r((function(e,n){return t(e,s,n)})):e(s)?r((function(e,n){return t(a,e,n)})):n((function(e){return t(a,s,e)}));default:return e(a)&&e(s)&&e(i)?o:e(a)&&e(s)?r((function(e,n){return t(e,n,i)})):e(a)&&e(i)?r((function(e,n){return t(e,s,n)})):e(s)&&e(i)?r((function(e,n){return t(a,e,n)})):e(a)?n((function(e){return t(e,s,i)})):e(s)?n((function(e){return t(a,e,i)})):e(i)?n((function(e){return t(a,s,e)})):t(a,s,i)}}}var u=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)};function c(t,e,n){return function(){if(0===arguments.length)return n();var r=arguments[arguments.length-1];if(!u(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 l=function(){return this.xf["@@transducer/init"]()},f=function(t){return this.xf["@@transducer/result"](t)};function p(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}function h(t,e,n){for(var r=0,o=n.length;r<o;){if(t(e,n[r]))return!0;r+=1}return!1}function y(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var d="function"==typeof Object.is?Object.is:function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e},g=Object.prototype.toString,m=function(){return"[object Arguments]"===g.call(arguments)?function(t){return"[object Arguments]"===g.call(t)}:function(t){return y("callee",t)}}(),v=!{toString:null}.propertyIsEnumerable("toString"),b=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],S=function(){return arguments.propertyIsEnumerable("length")}(),j=function(t,e){for(var n=0;n<t.length;){if(t[n]===e)return!0;n+=1}return!1},w="function"!=typeof Object.keys||S?n((function(t){if(Object(t)!==t)return[];var e,n,r=[],o=S&&m(t);for(e in t)!y(e,t)||o&&"length"===e||(r[r.length]=e);if(v)for(n=b.length-1;n>=0;)y(e=b[n],t)&&!j(r,e)&&(r[r.length]=e),n-=1;return r})):n((function(t){return Object(t)!==t?[]:Object.keys(t)})),A=n((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=p(t);function a(t,e){return k(t,e,n.slice(),r.slice())}return!h((function(t,e){return!h(a,e,t)}),p(e),o)}function k(t,e,n,r){if(d(t,e))return!0;var o,a,s=A(t);if(s!==A(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||!d(t.valueOf(),e.valueOf()))return!1;break;case"Date":if(!d(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=w(t);if(u.length!==w(e).length)return!1;var c=n.concat([t]),l=r.concat([e]);for(i=u.length-1;i>=0;){var f=u[i];if(!y(f,e)||!k(e[f],t[f],c,l))return!1;i-=1}return!0}var O=r((function(t,e){return k(t,e,[],[])}));function T(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(O(t[n],e))return n;n+=1}return-1}(e,t,0)>=0}function x(t,e){for(var n=0,r=e.length,o=Array(r);n<r;)o[n]=t(e[n]),n+=1;return o}function R(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 U=function(t){return(t<10?"0":"")+t},q="function"==typeof Date.prototype.toISOString?function(t){return t.toISOString()}:function(t){return t.getUTCFullYear()+"-"+U(t.getUTCMonth()+1)+"-"+U(t.getUTCDate())+"T"+U(t.getUTCHours())+":"+U(t.getUTCMinutes())+":"+U(t.getUTCSeconds())+"."+(t.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};function C(t,e,n){for(var r=0,o=n.length;r<o;)e=t(e,n[r]),r+=1;return e}function N(t){return"[object Object]"===Object.prototype.toString.call(t)}var E=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=l,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 I(t){return function(e){return new E(t,e)}}var P=r(c(["fantasy-land/filter","filter"],I,(function(t,e){return N(e)?C((function(n,r){return t(e[r])&&(n[r]=e[r]),n}),{},w(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)}))),$=r((function(t,e){return P((n=t,function(){return!n.apply(this,arguments)}),e);var n}));function B(t,e){var n=function(n){var r=e.concat([t]);return T(n,r)?"<Circular>":B(n,r)},r=function(t,e){return x((function(e){return R(e)+": "+n(t[e])}),e.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+x(n,t).join(", ")+"))";case"[object Array]":return"["+x(n,t).concat(r(t,$((function(t){return/^\d+$/.test(t)}),w(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):R(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())+")":R(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,w(t)).join(", ")+"}"}}var F=n((function(t){return B(t,[])})),K=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=l,t.prototype["@@transducer/result"]=f,t.prototype["@@transducer/step"]=function(t,e){return this.xf["@@transducer/step"](t,this.f(e))},t}(),M=r(c(["fantasy-land/map","map"],(function(t){return function(e){return new K(t,e)}}),(function(t,e){switch(Object.prototype.toString.call(e)){case"[object Function]":return s(e.length,(function(){return t.call(this,e.apply(this,arguments))}));case"[object Object]":return C((function(n,r){return n[r]=t(e[r]),n}),{},w(e));default:return x(t,e)}}))),z=Number.isInteger||function(t){return(t|0)===t};function G(t){return"[object String]"===Object.prototype.toString.call(t)}var L=r((function(t,e){var n=t<0?e.length+t:t;return G(e)?e.charAt(n):e[n]})),D=r((function(t,e){if(null!=e)return z(t)?L(t,e):e[t]})),Z=n((function(t){return!!u(t)||!!t&&("object"==typeof t&&(!G(t)&&(0===t.length||t.length>0&&(t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1)))))})),H="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function J(t,e,n){return function(r,o,a){if(Z(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[H])return n(r,o,a[H]());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=r((function(t,e){return o(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 V=J(W,Q,Y),tt=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 et=i((function(t,e,n){return V("function"==typeof t?new tt(t):t,e,n)}));var nt=n((function(t){return null==t})),rt=i((function t(e,n,r){if(0===e.length)return n;var o=e[0];if(e.length>1){var a=!nt(r)&&y(o,r)&&"object"==typeof r[o]?r[o]:z(e[1])?[]:{};n=t(Array.prototype.slice.call(e,1),n,a)}return function(t,e,n){if(z(t)&&u(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 ot(t,e){return function(){return e.call(this,t.apply(this,arguments))}}function at(t,e){return function(){var n=arguments.length;if(0===n)return e();var r=arguments[n-1];return u(r)||"function"!=typeof r[t]?e.apply(this,arguments):r[t].apply(r,Array.prototype.slice.call(arguments,0,n-1))}}var st=n(at("tail",i(at("slice",(function(t,e,n){return Array.prototype.slice.call(n,t,e)})))(1,1/0)));function it(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return o(arguments[0].length,et(ot,arguments[0],st(arguments)))}var ut=n((function(t){return G(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()}));function ct(){if(0===arguments.length)throw new Error("compose requires at least one argument");return it.apply(this,ut(arguments))}var lt=n((function(t){return s(t.length,t)}));var ft=n((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():u(t)?[]:G(t)?"":N(t)?{}:m(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})),pt=function(){function t(t,e){this.xf=e,this.f=t,this.found=!1}return t.prototype["@@transducer/init"]=l,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 ht(t){return function(e){return new pt(t,e)}}var yt=r(c(["find"],ht,(function(t,e){for(var n=0,r=e.length;n<r;){if(t(e[n]))return e[n];n+=1}}))),dt=r(T),gt=r((function(t,e){return s(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(F(n)+' does not have a method named "'+e+'"')}))})),mt=n((function(t){return null!=t&&O(t,ft(t))})),vt=gt(1,"join"),bt=r((function(t,e){return function(n){return function(r){return M((function(t){return e(t,r)}),n(t(r)))}}})),St=r((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=z(n)?L(n,r):r[n],o+=1}return r}))})),jt=r((function(t,e){return St([t],e)[0]})),wt=n((function(t){return bt(jt(t),rt(t))})),At=function(t){return{value:t,"fantasy-land/map":function(){return this}}},_t=r((function(t,e){return t(At)(e).value}));const kt=lt(((t,e,n,r)=>ct(D(r),yt((t=>dt(n,t[e]))))(t))),Ot=wt(["results","0","address_components"]),Tt=t=>{const e=t.results?t.results[0]:t.result;if(!e||mt(e))return{};let n=null;n=t.results?_t(Ot)(t):e.address_components;const r=kt(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 P(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 Tt(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 Tt(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 Tt(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=vt(",",P(Boolean,[n,r]));let{sessiontoken:c}=t;c||(c=crypto.randomUUID().replaceAll("-",""));const l=P(Boolean,{input:e,sessiontoken:c,location:u,radius:o,components:"country:US",types:"address",key:this.mapsKey});let f="";if(l){f=new URLSearchParams(l).toString()}const p=`https://maps.googleapis.com/maps/api/place/autocomplete/json?${f}`,h=await fetch(p,{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=P(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 Tt(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,e={}){const{env:n,initState:r}=e;this.#o=n,this.#r={sessionToken:null,application:null,applicationRef:null,sessionRef:null,userRef:null,user:{},message:null},this.#t=t,this.#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})(n),this.#n=Object.seal(this.#r);const{sessionToken:o,application:a,applicationRef:s,sessionRef:i}=r||{};if(o&&a&&s&&i){const t={sessionToken:o,application:a,applicationRef:s,sessionRef:i};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){let e={};return e=this.sessionToken||t?await this.validateSession(t):await this.getNewSession(),e.token?this.#a(e):this.#s(e),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:f}=t,p={email:r,birthday:a,prefix:s,first_name:i,last_name:u,phone_number:c,guest_check:!!l};f&&(p.aux_data={thirstieaccess_email_opt_in:f});const h=!this.sessionToken;r&&o?p.password=o:p.guest=!0,n.data=p,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,e,n={},r=null){const{data:o,params:a,basicAuth:s}=n,{sessionRef:i,application:u,applicationRef:c,userRef:l}=this.apiState;if(!this.sessionToken&&!s)throw new Error("Invalid Authorization");const f={method:t,headers:{Authorization:this.sessionToken&&!s?`Bearer ${this.sessionToken}`:`Basic ${btoa(this.#t)}`,Accept:"application/json","Content-Type":"application/json"}};["POST","PUT","PATCH"].includes(t)&&o&&(f.body=JSON.stringify(o));const{requestUrl:p,queryString:h}=function(t,e,n=null){let r="";n&&(r="?"+new URLSearchParams(n).toString());return{requestUrl:`${t}${e}${r}`,queryString:r}}(this.#e,e,a),y={environment:this.#o,sessionRef:i,application:u,applicationRef:c,userRef:l,data:o,queryString:h,url:e};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})}}(p,f);if(t)return!t.ok&&r&&r({code:t.status,message:t.statusText||"unknown error",response:t,telemetryContext:y}),t}catch(t){return r&&r({code:500,message:"unknown error",error:t,telemetryContext:y}),t}}},t}({});
|
|
1
|
+
var thirstieclient=function(t){"use strict";function e(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function n(t){return function n(r){return 0===arguments.length||e(r)?n:t.apply(this,arguments)}}function r(t){return function r(o,a){switch(arguments.length){case 0:return r;case 1:return e(o)?r:n((function(e){return t(o,e)}));default:return e(o)&&e(a)?r:e(o)?n((function(e){return t(e,a)})):e(a)?n((function(e){return t(o,e)})):t(o,a)}}}function o(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 a(t,n,r){return function(){for(var s=[],i=0,u=t,c=0,l=!1;c<n.length||i<arguments.length;){var f;c<n.length&&(!e(n[c])||i>=arguments.length)?f=n[c]:(f=arguments[i],i+=1),s[c]=f,e(f)?l=!0:u-=1,c+=1}return!l&&u<=0?r.apply(this,s):o(Math.max(0,u),a(t,s,r))}}var s=r((function(t,e){return 1===t?n(e):o(t,a(t,[],e))}));function i(t){return function o(a,s,i){switch(arguments.length){case 0:return o;case 1:return e(a)?o:r((function(e,n){return t(a,e,n)}));case 2:return e(a)&&e(s)?o:e(a)?r((function(e,n){return t(e,s,n)})):e(s)?r((function(e,n){return t(a,e,n)})):n((function(e){return t(a,s,e)}));default:return e(a)&&e(s)&&e(i)?o:e(a)&&e(s)?r((function(e,n){return t(e,n,i)})):e(a)&&e(i)?r((function(e,n){return t(e,s,n)})):e(s)&&e(i)?r((function(e,n){return t(a,e,n)})):e(a)?n((function(e){return t(e,s,i)})):e(s)?n((function(e){return t(a,e,i)})):e(i)?n((function(e){return t(a,s,e)})):t(a,s,i)}}}var u=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)};function c(t,e,n){return function(){if(0===arguments.length)return n();var r=arguments[arguments.length-1];if(!u(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 l=function(){return this.xf["@@transducer/init"]()},f=function(t){return this.xf["@@transducer/result"](t)};function p(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}function h(t,e,n){for(var r=0,o=n.length;r<o;){if(t(e,n[r]))return!0;r+=1}return!1}function y(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var d="function"==typeof Object.is?Object.is:function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e},g=Object.prototype.toString,m=function(){return"[object Arguments]"===g.call(arguments)?function(t){return"[object Arguments]"===g.call(t)}:function(t){return y("callee",t)}}(),v=!{toString:null}.propertyIsEnumerable("toString"),b=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],S=function(){return arguments.propertyIsEnumerable("length")}(),j=function(t,e){for(var n=0;n<t.length;){if(t[n]===e)return!0;n+=1}return!1},w="function"!=typeof Object.keys||S?n((function(t){if(Object(t)!==t)return[];var e,n,r=[],o=S&&m(t);for(e in t)!y(e,t)||o&&"length"===e||(r[r.length]=e);if(v)for(n=b.length-1;n>=0;)y(e=b[n],t)&&!j(r,e)&&(r[r.length]=e),n-=1;return r})):n((function(t){return Object(t)!==t?[]:Object.keys(t)})),A=n((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=p(t);function a(t,e){return k(t,e,n.slice(),r.slice())}return!h((function(t,e){return!h(a,e,t)}),p(e),o)}function k(t,e,n,r){if(d(t,e))return!0;var o,a,s=A(t);if(s!==A(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||!d(t.valueOf(),e.valueOf()))return!1;break;case"Date":if(!d(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=w(t);if(u.length!==w(e).length)return!1;var c=n.concat([t]),l=r.concat([e]);for(i=u.length-1;i>=0;){var f=u[i];if(!y(f,e)||!k(e[f],t[f],c,l))return!1;i-=1}return!0}var O=r((function(t,e){return k(t,e,[],[])}));function T(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(O(t[n],e))return n;n+=1}return-1}(e,t,0)>=0}function x(t,e){for(var n=0,r=e.length,o=Array(r);n<r;)o[n]=t(e[n]),n+=1;return o}function R(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 U=function(t){return(t<10?"0":"")+t},q="function"==typeof Date.prototype.toISOString?function(t){return t.toISOString()}:function(t){return t.getUTCFullYear()+"-"+U(t.getUTCMonth()+1)+"-"+U(t.getUTCDate())+"T"+U(t.getUTCHours())+":"+U(t.getUTCMinutes())+":"+U(t.getUTCSeconds())+"."+(t.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};function C(t,e,n){for(var r=0,o=n.length;r<o;)e=t(e,n[r]),r+=1;return e}function N(t){return"[object Object]"===Object.prototype.toString.call(t)}var E=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=l,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 I(t){return function(e){return new E(t,e)}}var P=r(c(["fantasy-land/filter","filter"],I,(function(t,e){return N(e)?C((function(n,r){return t(e[r])&&(n[r]=e[r]),n}),{},w(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)}))),$=r((function(t,e){return P((n=t,function(){return!n.apply(this,arguments)}),e);var n}));function B(t,e){var n=function(n){var r=e.concat([t]);return T(n,r)?"<Circular>":B(n,r)},r=function(t,e){return x((function(e){return R(e)+": "+n(t[e])}),e.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+x(n,t).join(", ")+"))";case"[object Array]":return"["+x(n,t).concat(r(t,$((function(t){return/^\d+$/.test(t)}),w(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):R(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())+")":R(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,w(t)).join(", ")+"}"}}var F=n((function(t){return B(t,[])})),K=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=l,t.prototype["@@transducer/result"]=f,t.prototype["@@transducer/step"]=function(t,e){return this.xf["@@transducer/step"](t,this.f(e))},t}(),M=r(c(["fantasy-land/map","map"],(function(t){return function(e){return new K(t,e)}}),(function(t,e){switch(Object.prototype.toString.call(e)){case"[object Function]":return s(e.length,(function(){return t.call(this,e.apply(this,arguments))}));case"[object Object]":return C((function(n,r){return n[r]=t(e[r]),n}),{},w(e));default:return x(t,e)}}))),z=Number.isInteger||function(t){return(t|0)===t};function G(t){return"[object String]"===Object.prototype.toString.call(t)}var L=r((function(t,e){var n=t<0?e.length+t:t;return G(e)?e.charAt(n):e[n]})),D=r((function(t,e){if(null!=e)return z(t)?L(t,e):e[t]})),Z=n((function(t){return!!u(t)||!!t&&("object"==typeof t&&(!G(t)&&(0===t.length||t.length>0&&(t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1)))))})),H="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function J(t,e,n){return function(r,o,a){if(Z(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[H])return n(r,o,a[H]());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=r((function(t,e){return o(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 V=J(W,Q,Y),tt=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 et=i((function(t,e,n){return V("function"==typeof t?new tt(t):t,e,n)}));var nt=n((function(t){return null==t})),rt=i((function t(e,n,r){if(0===e.length)return n;var o=e[0];if(e.length>1){var a=!nt(r)&&y(o,r)&&"object"==typeof r[o]?r[o]:z(e[1])?[]:{};n=t(Array.prototype.slice.call(e,1),n,a)}return function(t,e,n){if(z(t)&&u(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 ot(t,e){return function(){return e.call(this,t.apply(this,arguments))}}function at(t,e){return function(){var n=arguments.length;if(0===n)return e();var r=arguments[n-1];return u(r)||"function"!=typeof r[t]?e.apply(this,arguments):r[t].apply(r,Array.prototype.slice.call(arguments,0,n-1))}}var st=n(at("tail",i(at("slice",(function(t,e,n){return Array.prototype.slice.call(n,t,e)})))(1,1/0)));function it(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return o(arguments[0].length,et(ot,arguments[0],st(arguments)))}var ut=n((function(t){return G(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()}));function ct(){if(0===arguments.length)throw new Error("compose requires at least one argument");return it.apply(this,ut(arguments))}var lt=n((function(t){return s(t.length,t)}));var ft=n((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():u(t)?[]:G(t)?"":N(t)?{}:m(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})),pt=function(){function t(t,e){this.xf=e,this.f=t,this.found=!1}return t.prototype["@@transducer/init"]=l,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 ht(t){return function(e){return new pt(t,e)}}var yt=r(c(["find"],ht,(function(t,e){for(var n=0,r=e.length;n<r;){if(t(e[n]))return e[n];n+=1}}))),dt=r(T),gt=r((function(t,e){return s(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(F(n)+' does not have a method named "'+e+'"')}))})),mt=n((function(t){return null!=t&&O(t,ft(t))})),vt=gt(1,"join"),bt=r((function(t,e){return function(n){return function(r){return M((function(t){return e(t,r)}),n(t(r)))}}})),St=r((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=z(n)?L(n,r):r[n],o+=1}return r}))})),jt=r((function(t,e){return St([t],e)[0]})),wt=n((function(t){return bt(jt(t),rt(t))})),At=function(t){return{value:t,"fantasy-land/map":function(){return this}}},_t=r((function(t,e){return t(At)(e).value}));const kt=lt(((t,e,n,r)=>ct(D(r),yt((t=>dt(n,t[e]))))(t))),Ot=wt(["results","0","address_components"]),Tt=t=>{const e=t.results?t.results[0]:t.result;if(!e||mt(e))return{};let n=null;n=t.results?_t(Ot)(t):e.address_components;const r=kt(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 P(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 Tt(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 Tt(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 Tt(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=vt(",",P(Boolean,[n,r]));let{sessiontoken:c}=t;c||(c=crypto.randomUUID().replaceAll("-",""));const l=P(Boolean,{input:e,sessiontoken:c,location:u,radius:o,components:"country:US",types:"address",key:this.mapsKey});let f="";if(l){f=new URLSearchParams(l).toString()}const p=`https://maps.googleapis.com/maps/api/place/autocomplete/json?${f}`,h=await fetch(p,{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=P(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 Tt(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,e={}){const{env:n,initState:r}=e;this.#o=n,this.#r={sessionToken:null,application:null,applicationRef:null,sessionRef:null,userRef:null,user:{},message:null},this.#t=t,this.#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})(n),this.#n=Object.seal(this.#r);const{sessionToken:o,application:a,applicationRef:s,sessionRef:i}=r||{};if(o&&a&&s&&i){const t={sessionToken:o,application:a,applicationRef:s,sessionRef:i};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:f}=t,p={email:r,birthday:a,prefix:s,first_name:i,last_name:u,phone_number:c,guest_check:!!l};f&&(p.aux_data={thirstieaccess_email_opt_in:f});const h=!this.sessionToken;r&&o?p.password=o:p.guest=!0,n.data=p,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,e,n={},r=null){const{data:o,params:a,basicAuth:s}=n,{sessionRef:i,application:u,applicationRef:c,userRef:l}=this.apiState;if(!this.sessionToken&&!s)throw new Error("Invalid Authorization");const f={method:t,headers:{Authorization:this.sessionToken&&!s?`Bearer ${this.sessionToken}`:`Basic ${btoa(this.#t)}`,Accept:"application/json","Content-Type":"application/json"}};["POST","PUT","PATCH"].includes(t)&&o&&(f.body=JSON.stringify(o));const{requestUrl:p,queryString:h}=function(t,e,n=null){let r="";n&&(r="?"+new URLSearchParams(n).toString());return{requestUrl:`${t}${e}${r}`,queryString:r}}(this.#e,e,a),y={environment:this.#o,sessionRef:i,application:u,applicationRef:c,userRef:l,data:o,queryString:h,url:e};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})}}(p,f);if(t)return!t.ok&&r&&r({code:t.status,message:t.statusText||"unknown error",response:t,telemetryContext:y}),t}catch(t){return r&&r({code:500,message:"unknown error",error:t,telemetryContext:y}),t}}},t}({});
|
package/dist/bundle.mjs
CHANGED
|
@@ -228,9 +228,9 @@ class ThirstieAPI {
|
|
|
228
228
|
* @param {string} [existingToken] If provided, session JWT to be validated
|
|
229
229
|
* @returns {object} API State
|
|
230
230
|
*/
|
|
231
|
-
async fetchSession (existingToken = null) {
|
|
231
|
+
async fetchSession (existingToken = null, forceNewSession = false) {
|
|
232
232
|
let sessionData = {};
|
|
233
|
-
if (!this.sessionToken && !existingToken) {
|
|
233
|
+
if ((!this.sessionToken && !existingToken) || forceNewSession) {
|
|
234
234
|
sessionData = await this.getNewSession();
|
|
235
235
|
} else {
|
|
236
236
|
sessionData = await this.validateSession(existingToken);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thirstie/thirstieservices",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.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": "
|
|
36
|
+
"gitHead": "5b1c73ddfd235ef5f77adc491c5751a896c2cf23"
|
|
37
37
|
}
|
package/src/thirstieapi/index.js
CHANGED
|
@@ -171,9 +171,9 @@ export default class ThirstieAPI {
|
|
|
171
171
|
* @param {string} [existingToken] If provided, session JWT to be validated
|
|
172
172
|
* @returns {object} API State
|
|
173
173
|
*/
|
|
174
|
-
async fetchSession (existingToken = null) {
|
|
174
|
+
async fetchSession (existingToken = null, forceNewSession = false) {
|
|
175
175
|
let sessionData = {};
|
|
176
|
-
if (!this.sessionToken && !existingToken) {
|
|
176
|
+
if ((!this.sessionToken && !existingToken) || forceNewSession) {
|
|
177
177
|
sessionData = await this.getNewSession();
|
|
178
178
|
} else {
|
|
179
179
|
sessionData = await this.validateSession(existingToken);
|