@saasquatch/component-boilerplate 1.6.0-0 → 1.6.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.
@@ -161,7 +161,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
161
161
  token
162
162
  }
163
163
  }
164
- `));function nt(){const e=N(),[t,{loading:n,data:r,errors:a}]=ve(tt);return[async n=>{const r=await t(n);if(!(r instanceof Error)&&r.authenticateManagedIdentityWithInstantAccess){if("APPROVED"!==await async function(e,t){try{var n;const r=await fetch(`${l()}/api/v1/${c()}/graphql`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({query:"\n query checkReferralFraudStatus($programId: ID) {\n viewer {\n ... on User {\n id\n instantAccessRewards(filter: { programId_eq: $programId }) {\n data {\n id\n pendingReasons\n cancelledReason\n }\n }\n }\n }\n }\n",variables:{programId:e}})});if(!r.ok)throw new Error("Failed to fetch locale");const a=await r.json();if(a.errors)throw new Error(JSON.stringify(a.errors,null,2));const o=(null==(n=a.data.viewer.instantAccessRewards)?void 0:n.data)||[];return o.some(e=>"SUSPECTED_FRAUD"===e.cancelledReason)?"DENIED":o.some(e=>{var t;return null==(t=e.pendingReasons)?void 0:t.includes("SUSPECTED_FRAUD")})?"PENDING_REVIEW":"APPROVED"}catch(e){return void console.error(e)}}(e,r.authenticateManagedIdentityWithInstantAccess.token))return{name:"fraud_error",message:"Referral flagged as fraud."};{const e=r.authenticateManagedIdentityWithInstantAccess.email;d({jwt:r.authenticateManagedIdentityWithInstantAccess.token,id:e,accountId:e})}}return r},{loading:n,data:r,errors:a}]}function rt(e,t){const n=F();return n.current&&A(t,n.current.key)||(n.current={key:t,value:e()}),n.current.value}function at(){return y(e=>e+1,0)}function ot(e){const t=Object.getOwnPropertyNames(e);for(const n of t){const t=e[n];t&&"object"==typeof t&&ot(t)}return Object.freeze(e)}const st={loading:!0,data:void 0,errors:void 0};function it(e,t,n){const[r,a]=he(e,st),[o,s]=at();return rt(()=>{!n&&a(t)},[e,t,a,o,n]),Ne({skip:n,update:a,variables:t}),ot(ne({},r,{refetch:s}))}function dt(){const[,e]=at();return w(()=>m.listen(()=>{e()}),[]),m.location}const ct=m;function lt(e){const[t,n]=C({limit:e.limit,offset:e.offset}),{offset:r,limit:a}=t,o=(e,t)=>e*t,s=(e,t)=>Math.ceil(e/t)||0;return{limit:a,setLimit:e=>{const a=s(r,e),i=o(e,a);n(ne({},t,{limit:e,offset:i}))},offset:r,setCurrentPage:e=>{let t=o(e,a);n(e=>ne({},e,{offset:t}))},calculatePagination:function(e,t){const n=s(r,a),o=((e,t)=>Math.ceil(e/t)||0)(t,a),i=0===e?"0":e>1?`${r+1}-${r+e}`:`${r+1}`;return{currentPage:n,pageCount:o,rangeOnPage:i,pageProgress:`${i} of ${t}`}}}}function ut(e,t,n,r={},a=!1){var o;const{limit:s,offset:i,setLimit:d,setCurrentPage:c,calculatePagination:l}=lt(n),u=ne({limit:s,offset:i},r),{loading:m,errors:f,data:g,refetch:p}=it(e,u,a),h=t(g),{currentPage:y,pageCount:v,pageProgress:C}=l((null==h||null==(o=h.data)?void 0:o.length)||0,(null==h?void 0:h.totalCount)||0);return{envelope:h,states:{errors:f,loading:m,limit:s,currentPage:y,pageCount:v,pageProgress:C},callbacks:{refetch:p,setLimit:d,setCurrentPage:c}}}function mt(e,t){return e===t}function ft(e,t,n){const r=n&&n.equalityFn||mt,[a,o]=C(e),s=gt(v(e=>o(e),[]),t,n),i=F(e);return w(()=>{r(i.current,e)||(s.callback(e),i.current=e)},[e,s,r]),[a,{cancel:s.cancel,flush:s.flush}]}function gt(e,t=0,n={leading:!1}){const r=b(()=>q(e,t,n.leading),[e,t,n.leading]),{flush:a,clear:o}=r;return{flush:a,cancel:o,callback:r}}let pt;const ht=S(pt||(pt=(e=>e)`
164
+ `));function nt(){const e=N(),[t,{loading:n,data:r,errors:a}]=ve(tt);return[async n=>{const r=await t(n);if(!(r instanceof Error)&&r.authenticateManagedIdentityWithInstantAccess){if("APPROVED"!==await async function(e,t){try{var n;const r=await fetch(`${l()}/api/v1/${c()}/graphql`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({query:"\n query checkReferralFraudStatus($programId: ID) {\n viewer {\n ... on User {\n id\n instantAccessRewards(filter: { programId_eq: $programId }) {\n data {\n id\n pendingReasons\n cancelledReason\n }\n }\n }\n }\n }\n",variables:{programId:e}})});if(!r.ok)throw new Error("Failed to fetch locale");const a=await r.json();if(a.errors)throw new Error(JSON.stringify(a.errors,null,2));const o=(null==(n=a.data.viewer.instantAccessRewards)?void 0:n.data)||[];return o.some(e=>"SUSPECTED_FRAUD"===e.cancelledReason)?"DENIED":o.some(e=>{var t;return null==(t=e.pendingReasons)?void 0:t.includes("SUSPECTED_FRAUD")})?"PENDING_REVIEW":"APPROVED"}catch(e){return void console.error(e)}}(e,r.authenticateManagedIdentityWithInstantAccess.token))throw{name:"fraud_error",message:"Referral flagged as fraud."};{const e=r.authenticateManagedIdentityWithInstantAccess.email;d({jwt:r.authenticateManagedIdentityWithInstantAccess.token,id:e,accountId:e})}}return r},{loading:n,data:r,errors:a}]}function rt(e,t){const n=F();return n.current&&A(t,n.current.key)||(n.current={key:t,value:e()}),n.current.value}function at(){return y(e=>e+1,0)}function ot(e){const t=Object.getOwnPropertyNames(e);for(const n of t){const t=e[n];t&&"object"==typeof t&&ot(t)}return Object.freeze(e)}const st={loading:!0,data:void 0,errors:void 0};function it(e,t,n){const[r,a]=he(e,st),[o,s]=at();return rt(()=>{!n&&a(t)},[e,t,a,o,n]),Ne({skip:n,update:a,variables:t}),ot(ne({},r,{refetch:s}))}function dt(){const[,e]=at();return w(()=>m.listen(()=>{e()}),[]),m.location}const ct=m;function lt(e){const[t,n]=C({limit:e.limit,offset:e.offset}),{offset:r,limit:a}=t,o=(e,t)=>e*t,s=(e,t)=>Math.ceil(e/t)||0;return{limit:a,setLimit:e=>{const a=s(r,e),i=o(e,a);n(ne({},t,{limit:e,offset:i}))},offset:r,setCurrentPage:e=>{let t=o(e,a);n(e=>ne({},e,{offset:t}))},calculatePagination:function(e,t){const n=s(r,a),o=((e,t)=>Math.ceil(e/t)||0)(t,a),i=0===e?"0":e>1?`${r+1}-${r+e}`:`${r+1}`;return{currentPage:n,pageCount:o,rangeOnPage:i,pageProgress:`${i} of ${t}`}}}}function ut(e,t,n,r={},a=!1){var o;const{limit:s,offset:i,setLimit:d,setCurrentPage:c,calculatePagination:l}=lt(n),u=ne({limit:s,offset:i},r),{loading:m,errors:f,data:g,refetch:p}=it(e,u,a),h=t(g),{currentPage:y,pageCount:v,pageProgress:C}=l((null==h||null==(o=h.data)?void 0:o.length)||0,(null==h?void 0:h.totalCount)||0);return{envelope:h,states:{errors:f,loading:m,limit:s,currentPage:y,pageCount:v,pageProgress:C},callbacks:{refetch:p,setLimit:d,setCurrentPage:c}}}function mt(e,t){return e===t}function ft(e,t,n){const r=n&&n.equalityFn||mt,[a,o]=C(e),s=gt(v(e=>o(e),[]),t,n),i=F(e);return w(()=>{r(i.current,e)||(s.callback(e),i.current=e)},[e,s,r]),[a,{cancel:s.cancel,flush:s.flush}]}function gt(e,t=0,n={leading:!1}){const r=b(()=>q(e,t,n.leading),[e,t,n.leading]),{flush:a,clear:o}=r;return{flush:a,cancel:o,callback:r}}let pt;const ht=S(pt||(pt=(e=>e)`
165
165
  mutation ($eventMeta: UserAnalyticsEvent!) {
166
166
  createUserAnalyticsEvent(eventMeta: $eventMeta)
167
167
  }