forked from Romeo-Rosete/awesome
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
9329-6ff54d2035653a4b.js.download
2 lines (2 loc) · 11.9 KB
/
9329-6ff54d2035653a4b.js.download
1
2
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9329],{15466:function(n,e,t){t.d(e,{Z:function(){return p}});var i=t(40794),r=t(86692),o=t(92228),a=t(60138);function u(){var n=(0,o.Z)(["\n fragment AppConnection on AppConnection {\n banner\n canConnect\n id\n slug\n selectedApi\n title\n images {\n url128X128\n url64X64\n url32X32\n url16X16\n }\n hasStaleAuth\n }\n"]);return u=function(){return n},n}var c=(0,a.Ps)(u());function s(){var n=(0,o.Z)(["\n fragment App on App {\n categories {\n id\n name\n }\n canConnect\n currentImplementationId\n currentImplementationMeta {\n authType\n hasUpfrontFields\n id\n }\n description\n id\n image\n name\n primaryColor\n slug\n }\n"]);return s=function(){return n},n}var l=(0,a.Ps)(s());function d(){var n=(0,o.Z)(["\n ","\n ","\n\n query GetApp(\n $selectedApis: [String!]\n $serviceSlug: String!\n $isPrivate: Boolean!\n ) {\n appBySlug(slug: $serviceSlug) @skip(if: $isPrivate) {\n ...App\n }\n appConnections(\n isPrivate: $isPrivate\n limit: 1\n selectedApis: $selectedApis\n ) @include(if: $isPrivate) {\n edges {\n ...AppConnection\n }\n }\n }\n"]);return d=function(){return n},n}var f=(0,a.Ps)(d(),c,l),v=t(2784),p=function(n){var e=n.selectedApi,t=n.serviceSlug,o=(0,i.a)(f,{skip:!e&&!t,variables:{isPrivate:!!e,selectedApis:e?[e]:null,serviceSlug:t||""}}),a=o.data,u=o.error,c=o.loading,s=(0,v.useMemo)((function(){var n,e;return(null===a||void 0===a?void 0:a.appBySlug)||(null===a||void 0===a||null===(n=a.appConnections)||void 0===n||null===(e=n.edges)||void 0===e?void 0:e[0])}),[a]);return{app:s,error:(0,r.e$)(u),isLoading:c}}},94641:function(n,e,t){t.d(e,{c8:function(){return h},s3:function(){return v},ek:function(){return p}});var i=t(92228),r=t(60138);function o(){var n=(0,i.Z)(["\n fragment PrimaryAuth on Authentication {\n created\n description\n destinationSelectedApi\n id\n identifier\n isPrivate\n isShared\n isStale\n permissions {\n delete\n edit\n reconnect\n share\n test\n transfer\n }\n selectedApi\n sharedWithAll\n title\n }\n"]);return o=function(){return n},n}function a(){var n=(0,i.Z)(["\n fragment SecondaryAuth on Authentication {\n destinationSelectedApiImages {\n url16X16\n url32X32\n url64X64\n url128X128\n }\n id\n owner {\n email\n id\n imageUrl\n name\n }\n selectedApiImages {\n url16X16\n url32X32\n url64X64\n url128X128\n }\n sharedWith {\n ... on ShareTeam {\n description\n id\n imageUrl\n memberCount\n name\n type\n }\n ... on ShareMember {\n description\n email\n id\n imageUrl\n name\n type\n }\n }\n zapCount\n }\n"]);return a=function(){return n},n}function u(){var n=(0,i.Z)(["\n ","\n ","\n fragment Auth on Authentication {\n ...PrimaryAuth\n ...SecondaryAuth\n }\n"]);return u=function(){return n},n}var c=(0,r.Ps)(o()),s=(0,r.Ps)(a());(0,r.Ps)(u(),c,s);function l(){var n=(0,i.Z)(["\n ","\n\n query GetPrimaryAppAuthentications(\n $offset: Int\n $limit: Int\n $serviceSlug: String\n $selectedApi: String\n ) {\n authentications(\n offset: $offset\n limit: $limit\n serviceSlug: $serviceSlug\n selectedApi: $selectedApi\n ) {\n edges {\n ...PrimaryAuth\n }\n pageInfo {\n offset\n hasNextPage\n }\n totalCount\n }\n }\n"]);return l=function(){return n},n}function d(){var n=(0,i.Z)(["\n ","\n\n query GetSecondaryAppAuthentications(\n $offset: Int\n $limit: Int\n $serviceSlug: String\n $selectedApi: String\n ) {\n authentications(\n offset: $offset\n limit: $limit\n serviceSlug: $serviceSlug\n selectedApi: $selectedApi\n ) {\n edges {\n ...SecondaryAuth\n }\n pageInfo {\n offset\n hasNextPage\n }\n totalCount\n }\n }\n"]);return d=function(){return n},n}function f(){var n=(0,i.Z)(["\n ","\n ","\n\n query GetAppAuthentications(\n $offset: Int\n $limit: Int\n $serviceSlug: String\n $selectedApi: String\n ) {\n authentications(\n offset: $offset\n limit: $limit\n serviceSlug: $serviceSlug\n selectedApi: $selectedApi\n ) {\n edges {\n ...PrimaryAuth\n ...SecondaryAuth\n }\n pageInfo {\n hasNextPage\n }\n totalCount\n }\n }\n"]);return f=function(){return n},n}var v=(0,r.Ps)(l(),c),p=(0,r.Ps)(d(),s),h=(0,r.Ps)(f(),c,s)},60390:function(n,e,t){t.d(e,{Z:function(){return g}});var i=t(70865),r=t(66383),o=t(40794),a=t(2784),u=t(35591),c=t(86692),s=t(47842),l=t(96670),d=t(50930),f=function(n,e){return!n||e.id===n||(e.destinationAuths||[]).some((function(e){return e.id===n}))},v=function(n){var e=n.selectedApi,t=n.identifier;return"".concat(e,":").concat(t||"")},p=function(n,e,t){var r=(0,a.useMemo)((function(){var e=n.reduce((function(n,e){return e.destinationSelectedApi||n.add(v({selectedApi:e.selectedApi,identifier:e.identifier||null})),n}),new Set);return n.reduce((function(n,t){if(t.destinationSelectedApi){var r=v({selectedApi:t.selectedApi,identifier:t.identifier||null});if(e.has(r))return(0,l.Z)((0,i.Z)({},n),(0,s.Z)({},r,(0,d.Z)(n[r]||[]).concat([t])))}return n}),{})}),[n]),o=(0,a.useMemo)((function(){return n.filter((function(n){return!n.destinationSelectedApi||!r[v({selectedApi:n.selectedApi,identifier:n.identifier||null})]})).map((function(n){var e=v({selectedApi:n.selectedApi,identifier:n.identifier||null});return(0,l.Z)((0,i.Z)({},n),{destinationAuths:r[e]||[]})})).sort((function(n,e){return((null===n||void 0===n?void 0:n.title)||"").localeCompare((null===e||void 0===e?void 0:e.title)||"")}))}),[n,r]);return(0,a.useMemo)((function(){var n=[],i=[],r=[],a=!0,u=!1,c=void 0;try{for(var s,l=o[Symbol.iterator]();!(a=(s=l.next()).done);a=!0){var d,v,p=s.value;if(f(e,p))(null===p||void 0===p||null===(d=p.owner)||void 0===d?void 0:d.id)===t?n.push(p):(null===p||void 0===p||null===(v=p.sharedWith)||void 0===v?void 0:v.length)>0?i.push(p):r.push(p)}}catch(h){u=!0,c=h}finally{try{a||null==l.return||l.return()}finally{if(u)throw c}}return[n,i,r,o]}),[o,e,t])},h=t(94641),g=function(n){var e,t,s,l=n||{},d=l.id,f=l.limit,v=l.serviceSlug,g=l.userId,m=l.selectedApi,A=l.skip,S=(0,i.Z)({},f?{limit:f}:{},m?{selectedApi:m}:{},v?{serviceSlug:v}:{}),y=(0,o.a)(h.s3,{variables:S,skip:A,onError:function(n){(0,u.Z)("PrimaryAppAuth",n)}}),I=y.error,P=y.loading,w=y.refetch,$=y.fetchMore,Z=(0,o.a)(h.ek,{variables:S,skip:A,onError:function(n){(0,u.Z)("SecondaryAppAuth",n)}}).fetchMore,_=(0,o.a)(h.c8,{fetchPolicy:"cache-only",returnPartialData:!0,variables:S}).data,C=(null===_||void 0===_||null===(e=_.authentications)||void 0===e?void 0:e.totalCount)||0,b=!!(null===_||void 0===_||null===(t=_.authentications)||void 0===t||null===(s=t.pageInfo)||void 0===s?void 0:s.hasNextPage),k=(0,a.useMemo)((function(){var n;return(null===_||void 0===_||null===(n=_.authentications)||void 0===n?void 0:n.edges)||[]}),[_]),E=(0,r.Z)(p(k,d,g),4),U=E[0],F=E[1],M=E[2],X=E[3];return{allAuthentications:k,connectionsError:(0,c.e$)(I),hasConnections:(null===X||void 0===X?void 0:X.length)>0,hasNextPage:b,isConnectionsLoading:P,myAuthentications:U,onLoadMore:function(){$({variables:{offset:k.length}}),Z({variables:{offset:k.length}})},privateAuthentications:M,refetch:w,sharedAuthentications:F,totalConnectionCount:C}}},50293:function(n,e,t){t.d(e,{Z:function(){return y}});var i=t(98788),r=t(5163),o=t(2784),a=t(38716),u=t(47842),c=t(96459),s=t(9197),l=t(59251),d=function(){return new Promise((function(n,e){var t,i=window.location.origin,r=function(n){return window.open(n,"_blank","height=700,width=980,scrollbars=yes")}((t="/window-splash/",(0,l.v)("csrftoken")?t:(0,c.Sr)("/csrf/fix/",{next:t})));if(r){var o=function(e){e.origin===i&&"ready"===e.data&&(window.removeEventListener("message",o),n(r))};window.addEventListener("message",o,!1)}else e(new Error("Popup was blocked."))}))},f="_zapier_auth_id",v="authenticationSuccess",p="AUTH_FAILED_CONN",h=function(n,e){var t=new Error(e);return t.code=n,t},g=function(n){return(0,s.uz)(function(n){var e,t=n.serviceKey,i=n.accountId,r=n.isShared,o=n.authId,a=n.authIdentifier,s=n.destinationServiceKey,l=n.isForSignup;return(0,c.Sr)("/engine/auth/start/".concat(t,"/"),(e={},(0,u.Z)(e,"_zapier_account_id",i),(0,u.Z)(e,"_zapier_is_shared",r),(0,u.Z)(e,f,o),(0,u.Z)(e,"_zapier_expected_identifier",a),(0,u.Z)(e,"_zapier_destination_selected_api",s),(0,u.Z)(e,"for_signup",l),e),!0)}(n)).then((function(n){return n.url}))},m=function(n,e){return new Promise((function(t,i){var r,o=window.location.origin,a=!1,u=function(n){n.origin===o&&n.data.type===v&&(r=n.data.authId,a=!0)};window.addEventListener("message",u);var c=function(){n.closed?setTimeout((function(){window.removeEventListener("message",u),a&&(null!=r||e)||i(h(p,"Failed to connect account.")),t(r)}),0):setTimeout(c,1e3)};c()}))},A=function(){var n=(0,i.Z)((function(n){var e,t,i,o,a,s,l,v,p,A,S,y,I,P,w,$,Z,_,C;return(0,r.__generator)(this,(function(r){switch(r.label){case 0:return e=n.accountId,t=n.hasUpfrontFields,i=n.isShared,o=n.isOauth,a=n.serviceKey,s=n.authId,l=n.authIdentifier,v=n.destinationServiceKey,p=n.onError,A=void 0===p?function(){}:p,S=n.onTrack,y=void 0===S?function(){return Promise.resolve()}:S,I=n.isForSignup,P={accountId:e,isShared:i,serviceKey:a,authId:s,authIdentifier:l,destinationServiceKey:v,isForSignup:I},[4,d()];case 1:return w=r.sent(),[4,g(P)];case 2:$=r.sent(),Z=function(n,e,t,i){var r;return!t||i?(0,c.Sr)(n,(r={},(0,u.Z)(r,"isShared",e.isShared),(0,u.Z)(r,f,e.authId),r),!0):n}($,P,o,t),y("auth: redirect to first leg",{accountId:e,authId:s,isForSignup:I,isOauth:o,parameterizedUrl:Z,serviceKey:a});try{w.location=Z}catch(b){throw A(b),h("AUTH_POPUP_FAILURE","Could not change the popup location.")}r.label=3;case 3:return r.trys.push([3,5,,6]),[4,m(w,o)];case 4:return _=r.sent(),y("auth: connection success",{accountId:e,authId:s,conn:_,isForSignup:I,isOauth:o,parameterizedUrl:Z,serviceKey:a}),[2,_];case 5:throw C=r.sent(),y("auth: could not get connection",{accountId:e,authId:s,error:C.message,isForSignup:I,isOauth:o,parameterizedUrl:Z,serviceKey:a}),C;case 6:return[2]}}))}));return function(e){return n.apply(this,arguments)}}(),S=t(53736),y=function(){var n=(0,a.X8)(),e=(0,S.l)().createNotification,t=(0,o.useCallback)(function(){var t=(0,i.Z)((function(t,i){var o,a,u,c,s;return(0,r.__generator)(this,(function(r){switch(r.label){case 0:if(r.trys.push([0,2,,3]),!(null===t||void 0===t?void 0:t.canConnect))throw new Error("".concat(null===t||void 0===t?void 0:t.name," does not require connections"));return[4,A({accountId:n,authId:null===i||void 0===i?void 0:i.id,authIdentifier:(null===i||void 0===i?void 0:i.identifier)||void 0,destinationServiceKey:(null===i||void 0===i?void 0:i.destinationSelectedApi)||void 0,hasUpfrontFields:Boolean(null===t||void 0===t||null===(o=t.currentImplementationMeta)||void 0===o?void 0:o.hasUpfrontFields),isOauth:"oauth"===(null===(a=t.currentImplementationMeta)||void 0===a?void 0:a.authType),isShared:(null===i||void 0===i?void 0:i.isShared)||void 0,serviceKey:(null===(u=t.currentImplementationMeta)||void 0===u?void 0:u.id)||t.selectedApi||void 0})];case 1:return c=r.sent(),[2,{app:t,connection:i,id:c}];case 2:return(null===(s=r.sent())||void 0===s?void 0:s.code)!==p&&e({message:s.toString(),type:"error"}),[3,3];case 3:return[2,{app:t,connection:i}]}}))}));return function(n,e){return t.apply(this,arguments)}}(),[n,e]);return t}},57037:function(n,e,t){var i=t(2784);e.Z=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:300,t=(0,i.useState)(n),r=t[0],o=t[1];return(0,i.useEffect)((function(){var t=setTimeout((function(){o(n)}),e);return function(){clearTimeout(t)}}),[e,n]),r}}}]);
//# sourceMappingURL=9329-6ff54d2035653a4b.js.map