PageSourceSearch

https://app.honeybill.ai/assets/email-provider.api-CUZDmt38.js

js honeybill.ai collected 2026-10-05 12:04:09 UTC 3,979 bytes, 1 lines download raw bytes

1import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{D as t,F as n,O as r,h as i,r as a,t as o}from"./orpc-cHQmx6_s.js";import{i as s}from"./clsx-BUCO2i-G.js";import"./DialogDrawer-B-0xfaFM.js";import{G as c,H as l,I as u,N as d,R as f,y as p,z as m}from"./user.api-C9wvWWON.js";var h=e(s(),1),g=[];function _(){let e=p();return r({...a.emailProvider.getAllEmailProviders.queryOptions({select:e=>e.data?.connections??g}),queryKey:[...a.emailProvider.getAllEmailProviders.key({}),e],enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1})}function v(){let e=n(),r=p();return t({mutationFn:async e=>{let{provider:t,dialogId:n,tab:i,mode:a=`redirect`,connectionId:s,...l}=e,u,d;if(a===`popup`)u=l.successUrl??f(`connect-email`),d=l.errorUrl??m(`connect-email`);else{let e=c(r);n&&i&&(e=`${e}?dialog=${n}&tab=${i}`),u=l.successUrl??e,d=l.errorUrl??(n&&i?`${e}&error=cancelled`:e)}return t===`microsoft`?o.emailProvider.initiateMicrosoftConnection({successUrl:u,errorUrl:d,connectionId:s}):o.emailProvider.initiateGoogleConnection({successUrl:u,errorUrl:d,connectionId:s})},onSuccess:(t,n)=>{r&&d(e,r),(n.mode??`redirect`)!==`popup`&&t?.data?.authorizationUrl&&(window.location.href=t.data.authorizationUrl)},onError:()=>{r&&e.invalidateQueries({queryKey:[...a.emailProvider.getAllEmailProviders.key({}),r]})}})}function y(){let e=n(),t=p(),r=v(),{runPopupOAuth:o,activeProvider:s,isFlowBusy:c}=l();return{connectMailInPopup:(0,h.useCallback)(n=>{t&&(async()=>{let s={...a.emailProvider.getAllEmailProviders.queryOptions({}),queryKey:[...a.emailProvider.getAllEmailProviders.key({}),t]},c=await e.fetchQuery(s),l=new Set((c?.data?.connections??[]).map(e=>e.id));o({provider:n,labels:u,fetchAuthorizationUrl:async()=>{let e=await r.mutateAsync({provider:n,mode:`popup`});return typeof e?.data?.authorizationUrl==`string`?e.data.authorizationUrl:void 0},checkSuccess:async()=>((await e.fetchQuery(s))?.data?.connections??[]).some(e=>!l.has(e.id)),onSuccess:async()=>{await e.invalidateQueries({queryKey:[...a.emailProvider.getAllEmailProviders.key({}),t]}),d(e,t),i(`success`,`CONNECT_EMAIL_PROVIDER`,`Email connected`,`You can send invoices and reminders from this account.`)}})})()},[t,r,e,o]),reconnectMailInPopup:(0,h.useCallback)(n=>{if(!t||n.provider!==`google`&&n.provider!==`microsoft`)return;let s=n.provider;(async()=>{let c={...a.emailProvider.getAllEmailProviders.queryOptions({}),queryKey:[...a.emailProvider.getAllEmailProviders.key({}),t]};o({provider:s,labels:u,fetchAuthorizationUrl:async()=>{let e=await r.mutateAsync({provider:s,mode:`popup`,connectionId:n.id});return typeof e?.data?.authorizationUrl==`string`?e.data.authorizationUrl:void 0},checkSuccess:async()=>{let t=((await e.fetchQuery(c))?.data?.connections??[]).find(e=>e.id===n.id);return t!=null&&!t.oauthReconnectRequiredAt},onSuccess:async()=>{await e.invalidateQueries({queryKey:[...a.emailProvider.getAllEmailProviders.key({}),t]}),i(`success`,`RECONNECT_EMAIL_PROVIDER`,`Email reconnected`,`${n.providerEmail} is ready to send again.`)}})})()},[t,r,e,o]),activeProvider:s,isFlowBusy:c,isInitiatePending:r.isPending}}function b(){let e=n(),r=p();return t(a.emailProvider.removeEmailProvider.mutationOptions({onSuccess:()=>{r&&e.invalidateQueries({queryKey:[...a.emailProvider.getAllEmailProviders.key({}),r]})}}))}function x(){let e=n(),r=p();return t(a.emailProvider.createSmtpConnection.mutationOptions({onSuccess:async()=>{r&&await e.invalidateQueries({queryKey:[...a.emailProvider.getAllEmailProviders.key({}),r]})}}))}function S(){let e=n(),r=p();return t(a.emailProvider.updateSmtpConnection.mutationOptions({onSuccess:async()=>{r&&await e.invalidateQueries({queryKey:[...a.emailProvider.getAllEmailProviders.key({}),r]})}}))}function C(){let e=n(),r=p();return t(a.emailProvider.getEmailProviderHealth.mutationOptions({onSuccess:async()=>{r&&await e.invalidateQueries({queryKey:[...a.emailProvider.getAllEmailProviders.key({}),r]})}}))}export{C as a,_ as i,y as n,b as o,x as r,S as s,g as t};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.