@zimbra/api-client 101.0.1-master.89348c4.0 → 101.0.1-master.f2f7505.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.
@@ -23,5 +23,5 @@ To disable this validator, use:
23
23
  fragment session on Session {
24
24
  id
25
25
  }
26
- `;class SessionHandler{constructor(e){_defineProperty(this,"cache",void 0),_defineProperty(this,"cacheKeyForSession","Session"),_defineProperty(this,"readSessionId",()=>{return this.cache.readFragment({id:this.cacheKeyForSession,fragment:Xd})?.id||"1"}),_defineProperty(this,"writeSessionId",e=>{this.cache.writeFragment({id:this.cacheKeyForSession,fragment:Xd,data:{id:e,__typename:"Session"}})}),this.cache=e.cache}}function createZimbraSchema(e){const{cache:n,getApolloClient:i,...t}=e;var a=n?new SessionHandler({cache:n}):void 0;const r=new ZimbraBatchClient({...t,sessionHandler:a}),d=e.localStoreClient;a=makeExecutableSchema({typeDefs:pa,resolvers:{Query:{accountInfo:r.accountInfo,autoComplete:(e,n)=>r.autoComplete(n),autoCompleteGAL:(e,n)=>r.autoCompleteGAL(n),discoverRights:(e,n)=>r.discoverRights(n),downloadAttachment:(e,n)=>r.downloadAttachment(n),downloadDocument:(e,n)=>r.downloadDocument(n),listDocumentRevisions:(e,n)=>r.listDocumentRevisions(n),getItem:(e,n)=>r.getItem(n),downloadMessage:function(e,n){var i=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{})["local"];return(i?d:r).downloadMessage(n)},freeBusy:(e,n)=>r.freeBusy(n),getContact:(e,n)=>r.getContact(n),clientInfo:(e,n)=>r.clientInfo(n),getContactFrequency:(e,n)=>r.getContactFrequency(n),getConversation:(e,n)=>r.getConversation(n),getCustomMetadata:(e,n)=>r.getCustomMetadata(n),getDocumentShareURL:(e,n)=>r.getDocumentShareURL(n),getFilterRules:r.getFilterRules,getFolder:function(e,n){var i=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{})["local"];return(i?d:r).getFolder(n)},getHAB:(e,n)=>{n=n.habRootGroupId;return r.getHAB(n)},getAccountDistributionLists:(e,n)=>{var{attrs:n,ownerOf:i}=n;return r.getAccountDistributionLists(n,i)},getDistributionList:(e,n)=>{var{dl:n,needOwners:i,needRights:t,by:a}=n;return r.getDistributionList(n,i,t,a)},getDistributionListMembers:(e,n)=>{var{limit:n,offset:i,dl:t}=n;return r.getDistributionListMembers(n,i,t)},getAppointment:(e,n)=>r.getAppointment(n),getAppointments:(e,n)=>r.search(n),getReminders:(e,n)=>r.search(n),getTasks:(e,n)=>r.getTasks(n),getAvailableLocales:e=>r.getAvailableLocales(),getMailboxMetadata:(e,n)=>r.getMailboxMetadata(n),getMessage:function(e,n){var i=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{})["local"];return(i?d:r).getMessage(n)},getMessagesMetadata:function(e,n){var i=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{})["local"];return(i?d:r).getMessagesMetadata(n)},getRights:(e,n)=>r.getRights(n),getScratchCodes:r.getScratchCodes,getSearchFolder:r.getSearchFolder,getSMimePublicCerts:(e,n)=>r.getSMimePublicCerts(n),getSMimeCertInfo:r.getSMimeCertInfo,getTrustedDevices:r.getTrustedDevices,getDeviceStatus:r.getDeviceStatus,getWorkingHours:(e,n)=>r.getWorkingHours(n),getPreferences:r.getPreferences,getDataSources:r.getDataSources,getIdentities:r.getIdentities,getImportStatus:r.getImportStatus,getSignatures:r.getSignatures,noop:function(e,n){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return r.noop(n,i.fetchOptions)},recoverAccount:(e,n)=>r.recoverAccount(n),relatedContacts:(e,n)=>r.relatedContacts(n),search:function(e,n){var i=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{})["local"];return(i?d:r).search(n)},searchCalendarResources:(e,n)=>r.searchCalendarResources(n),searchGal:(e,n)=>r.searchGal(n),shareInfo:(e,n)=>r.shareInfo(n),taskFolders:r.taskFolders,getWhiteBlackList:r.getWhiteBlackList,getAppSpecificPasswords:r.getAppSpecificPasswords,getTag:r.getTag},MailItem:{__resolveType(e){return e.conversationId?"MessageInfo":"Conversation"}},Mutation:{action:function(e,n){let{type:i,...t}=n;n=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}).local;return(n?d:r).action(i,t)},addMessage:function(e,n){var i=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{})["local"],t=n["message"];return i?d.addMessage(n):r.addMessage(t)},applyFilterRules:(e,n)=>r.applyFilterRules(n),cancelTask:(e,n)=>r.cancelTask(n),itemAction:(e,n)=>r.itemAction(n),login:(e,n)=>r.login(n),logout:r.logout,disableTwoFactorAuth:(e,n)=>{n=n.method;return r.disableTwoFactorAuth(n)},enableTwoFactorAuth:(e,n)=>{n=n.options;return r.enableTwoFactorAuth(n)},messageAction:(e,n)=>r.messageAction(n),changePassword:(e,n)=>r.changePassword(n),modifyProfileImage:(e,n)=>r.modifyProfileImage(n),contactAction:(e,n)=>r.contactAction(n),createAppSpecificPassword:(e,n)=>{n=n.appName;return r.createAppSpecificPassword(n)},conversationAction:(e,n)=>r.conversationAction(n),createFolder:(e,n,i)=>{let{isLocalFolder:t,...a}=n;n=i.local;return n?d.createFolder({isLocalFolder:t,...a}):r.createFolder(a)},createSearchFolder:(e,n)=>r.createSearchFolder(n),createContact:(e,n)=>{n=n.contact;return r.createContact(n)},createContactList:(e,n)=>{n=n.contact;return r.createContact(n)},modifyContact:(e,n)=>{n=n.contact;return r.modifyContact(n)},modifyContactList:(e,n)=>{n=n.contact;return r.modifyContact(n)},createAppointment:(e,n)=>{var{accountName:n,appointment:i}=n;return r.createAppointment(n,i)},snoozeCalendarItem:(e,n)=>{var{appointment:n,task:i}=n;return r.snoozeCalendarItem(n,i)},dismissCalendarItem:(e,n)=>{var{appointment:n,task:i}=n;return r.dismissCalendarItem(n,i)},createAppointmentException:(e,n)=>{var{accountName:n,appointment:i}=n;return r.createAppointmentException(n,i)},modifyAppointment:(e,n)=>{var{accountName:n,appointment:i}=n;return r.modifyAppointment(n,i)},createMountpoint:(e,n)=>r.createMountpoint(n),deleteAppointment:(e,n)=>{n=n.appointment;return r.deleteAppointment(n)},checkCalendars:(e,n)=>r.checkCalendars(n.actions),counterAppointment:(e,n)=>{n=n.counterAppointmentInvite;return r.counterAppointment(n)},createCalendar:(e,n)=>{var{name:n,color:i,url:t,parentFolderId:a}=n;return r.createFolder({name:n,color:i,url:t,view:"appointment",flags:"#",parentFolderId:a})},createSharedCalendar:(e,n)=>{n=n.link;return r.createMountpoint({link:{...n,parentFolderId:1,view:"appointment",flags:"#"}})},saveDocument:(e,n)=>r.saveDocument(n),changeFolderColor:(e,n)=>r.changeFolderColor(n),declineCounterAppointment:(e,n)=>{n=n.counterAppointmentInvite;return r.declineCounterAppointment(n)},folderAction:(e,n)=>{n=n.action;return r.folderAction(n)},documentAction:(e,n)=>{n=n.action;return r.documentAction(n)},forwardAppointment:(e,n)=>{n=n.appointmentInvite;return r.forwardAppointment(n)},forwardAppointmentInvite:(e,n)=>{n=n.appointmentInvite;return r.forwardAppointmentInvite(n)},generateScratchCodes:r.generateScratchCodes,grantRights:(e,n)=>r.grantRights(n.input),sendShareNotification:(e,n)=>{n=n.shareNotification;return r.sendShareNotification(n)},sendTwoFactorAuthCode:(e,n)=>{n=n.options;return r.sendTwoFactorAuthCode(n)},testExternalAccount:(e,n)=>{n=n.externalAccount;return r.testExternalAccount(n)},addExternalAccount:(e,n)=>{n=n.externalAccount;return r.addExternalAccount(n)},modifyExternalAccount:(e,n)=>r.modifyExternalAccount(n),deleteExternalAccount:(e,n)=>r.deleteExternalAccount(n),importExternalAccount:(e,n)=>{n=n.externalAccount;return r.importExternalAccount(n)},purgeRevision:(e,n)=>r.purgeRevision(n),prefEnableOutOfOfficeAlertOnLogin:(e,n)=>{n=n.value;return r.modifyPrefs({zimbraPrefOutOfOfficeStatusAlertOnLogin:n}).then(Boolean)},prefEnableOutOfOfficeReply:(e,n)=>{n=n.value;return r.modifyPrefs({zimbraPrefOutOfOfficeReplyEnabled:n}).then(Boolean)},prefOutOfOfficeFromDate:(e,n)=>{let i=n["value"];return r.modifyPrefs({zimbraPrefOutOfOfficeFromDate:i}).then(()=>i)},prefOutOfOfficeUntilDate:(e,n)=>{let i=n["value"];return r.modifyPrefs({zimbraPrefOutOfOfficeUntilDate:i}).then(()=>i)},prefOutOfOfficeReply:(e,n)=>{let i=n["value"];return r.modifyPrefs({zimbraPrefOutOfOfficeReply:i}).then(()=>i)},createIdentity:(e,n)=>r.createIdentity(n),modifyIdentity:(e,n)=>r.modifyIdentity(n).then(Boolean),deleteIdentity:(e,n)=>r.deleteIdentity(n).then(Boolean),modifyPrefs:(e,n)=>{n=n.prefs;return r.modifyPrefs(n)},modifyProps:(e,n)=>{n=n.props;return r.modifyProps(n)},modifyZimletPrefs:(e,n)=>{n=n.zimlets;return r.modifyZimletPrefs(n)},modifyFilterRules:(e,n)=>{n=n.filters;return r.modifyFilterRules(n)},createSignature:(e,n)=>r.createSignature(n),modifySignature:(e,n)=>r.modifySignature(n),modifySearchFolder:(e,n)=>r.modifySearchFolder(n),deleteSignature:(e,n)=>r.deleteSignature(n),saveDraft:function(e,n){var{message:n,accountName:i}=n;return((2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}).local?d:r).saveDraft(n,i)},sendMessage:function(e,n){var{message:n,accountName:i,sign:t=!1,encrypt:a=!1}=n;return((2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}).local?d:r).sendMessage(n,i,t,a)},saveSMimeCert:(e,n)=>{var{upload:n,password:i}=n;return r.saveSMimeCert(n,i)},sendDeliveryReport:(e,n)=>{n=n.messageId;return r.sendDeliveryReport(n)},uploadMessage:(e,n)=>{n=n.value;return r.uploadMessage(n)},createTask:(e,n)=>{n=n.task;return r.createTask(n)},modifyTask:(e,n)=>{n=n.task;return r.modifyTask(n)},sendInviteReply:(e,n)=>{n=n.inviteReply;return r.sendInviteReply(n)},recoverAccount:(e,n)=>r.recoverAccount(n),resetPassword:(e,n)=>r.resetPassword(n),revokeAppSpecificPassword:(e,n)=>{n=n.appName;return r.revokeAppSpecificPassword(n)},revokeOtherTrustedDevices:r.revokeOtherTrustedDevices,revokeRights:(e,n)=>r.revokeRights(n.input),revokeTrustedDevice:r.revokeTrustedDevice,setCustomMetadata:(e,n)=>r.setCustomMetadata(n),setMailboxMetadata:(e,n)=>r.jsonRequest({name:"SetMailboxMetadata",body:{meta:{section:n.section,_attrs:mapValues(n.attrs||{},coerceBooleanToString)}}}).then(Boolean),setRecoveryAccount:(e,n)=>r.setRecoveryAccount(n),modifyWhiteBlackList:(e,n)=>{n=n.whiteBlackList;return r.modifyWhiteBlackList(n)},createTag:(e,n)=>{n=n.tag;return r.createTag(n)},tagAction:(e,n)=>{n=n.action;return r.action(An.tag,n)},quarantineDeviceSync:(e,n)=>{n=n.deviceId;r.quarantineDeviceSync(n)},allowDeviceSync:(e,n)=>{n=n.deviceId;r.allowDeviceSync(n)},removeDeviceSync:(e,n)=>{n=n.deviceId;r.removeDeviceSync(n)},blockDeviceSync:(e,n)=>{n=n.deviceId;r.blockDeviceSync(n)},accountOnlyRemoteWipeSync:(e,n)=>{n=n.deviceId;r.accountOnlyRemoteWipeSync(n)},cancelPendingAccountOnlyRemoteWipeSync:(e,n)=>{n=n.deviceId;r.cancelPendingAccountOnlyRemoteWipeSync(n)},remoteWipeSync:(e,n)=>{n=n.deviceId;r.remoteWipeSync(n)},cancelPendingRemoteWipeSync:(e,n)=>{n=n.deviceId;r.cancelPendingRemoteWipeSync(n)},subscribeDistributionList:(e,n)=>{var{op:n,by:i,dl:t}=n;return r.subscribeDistributionList(n,i,t)},distributionListAction:(e,n)=>{n=n.dlActions;return r.distributionListAction(n)}}}});return{client:r,schema:a}}var eo=function(){function OperationBatcher(e){var n=e.batchDebounce,i=e.batchInterval,t=e.batchMax,a=e.batchHandler,e=e.batchKey;this.batchesByKey=new Map,this.scheduledBatchTimerByKey=new Map,this.batchDebounce=n,this.batchInterval=i,this.batchMax=t||0,this.batchHandler=a,this.batchKey=e||function(){return""}}return OperationBatcher.prototype.enqueueRequest=function(e){var a=this,r=I(I({},e),{next:[],error:[],complete:[],subscribers:new Set}),d=this.batchKey(e.operation);return r.observable||(r.observable=new y(function(n){var i=a.batchesByKey.get(d),e=(i||a.batchesByKey.set(d,i=new Set),0===i.size),t=0===r.subscribers.size;return r.subscribers.add(n),t&&i.add(r),n.next&&r.next.push(n.next.bind(n)),n.error&&r.error.push(n.error.bind(n)),n.complete&&r.complete.push(n.complete.bind(n)),(e||a.batchDebounce)&&a.scheduleQueueConsumption(d),i.size===a.batchMax&&a.consumeQueue(d),function(){var e;r.subscribers.delete(n)&&r.subscribers.size<1&&i.delete(r)&&i.size<1&&(a.consumeQueue(d),null!=(e=i.subscription))&&e.unsubscribe()}})),r.observable},OperationBatcher.prototype.consumeQueue=function(e){var n,i,t,a,r,d,o,s=this.batchesByKey.get(e=void 0===e?"":e);if(this.batchesByKey.delete(e),s&&s.size)return n=[],i=[],t=[],a=[],r=[],d=[],s.forEach(function(e){n.push(e.operation),i.push(e.forward),t.push(e.observable),a.push(e.next),r.push(e.error),d.push(e.complete)}),e=this.batchHandler(n,i)||y.of(),s.subscription=e.subscribe({next:function(e){var n;if(Array.isArray(e)||(e=[e]),a.length!==e.length)return(n=new Error("server returned results with length ".concat(e.length,", expected length of ").concat(a.length))).result=e,o(n);e.forEach(function(n,e){a[e]&&a[e].forEach(function(e){return e(n)})})},error:o=function(n){r.forEach(function(e){e&&e.forEach(function(e){return e(n)})})},complete:function(){d.forEach(function(e){e&&e.forEach(function(e){return e()})})}}),t},OperationBatcher.prototype.scheduleQueueConsumption=function(e){var n=this;clearTimeout(this.scheduledBatchTimerByKey.get(e)),this.scheduledBatchTimerByKey.set(e,setTimeout(function(){n.consumeQueue(e),n.scheduledBatchTimerByKey.delete(e)},this.batchInterval))},OperationBatcher}(),no=function(o){function BatchLink(e){var n=o.call(this)||this,i=e||{},t=i.batchInterval,a=i.batchMax,r=i.batchHandler,d=i.batchKey;return n.batcher=new eo({batchDebounce:i.batchDebounce,batchInterval:void 0===t?10:t,batchMax:void 0===a?0:a,batchHandler:void 0===r?function(){return null}:r,batchKey:void 0===d?function(){return""}:d}),e.batchHandler.length<=1&&(n.request=function(e){return n.batcher.enqueueRequest({operation:e})}),n}return __extends(BatchLink,o),BatchLink.prototype.request=function(e,n){return this.batcher.enqueueRequest({operation:e,forward:n})},BatchLink}(xr);class LocalBatchLink extends xr{constructor(t){super(),_defineProperty(this,"off",void 0),_defineProperty(this,"on",void 0),_defineProperty(this,"schema",void 0),_defineProperty(this,"batcher",void 0),this.schema=t.schema;const a=new events;this.on=a.on,this.off=a.off;this.batcher=new no({batchInterval:t.batchInterval,batchHandler:e=>new y(n=>{a.emit("req",e);let i=!1;Promise.all(e.map(e=>{var{operationName:n,variables:i={}}=e;return graphql({schema:this.schema,source:print$1(e.query),rootValue:null,contextValue:e.getContext()||t.context||{},variableValues:i,operationName:n})})).then(e=>(i=!0,a.emit("res",e),n.next(e),n.complete(),e)).catch(e=>{i||a.emit("res",e),n.error(e)})})})}request(e){return this.batcher.request(e)}}function onError(d){return new xr(function(a,r){return new y(function(n){var e,i,t;try{e=r(a).subscribe({next:function(e){e.errors?t=d({graphQLErrors:e.errors,response:e,operation:a,forward:r}):graphQLResultHasProtocolErrors(e)&&(t=d({protocolErrors:e.extensions[zr],response:e,operation:a,forward:r})),t?i=t.subscribe({next:n.next.bind(n),error:n.error.bind(n),complete:n.complete.bind(n)}):n.next(e)},error:function(e){(t=d({operation:a,networkError:e,graphQLErrors:e&&e.result&&e.result.errors||void 0,forward:r}))?i=t.subscribe({next:n.next.bind(n),error:n.error.bind(n),complete:n.complete.bind(n)}):n.error(e)},complete:function(){t||n.complete.bind(n)()}})}catch(e){d({networkError:e,operation:a,forward:r}),n.error(e)}return function(){e&&e.unsubscribe(),i&&e.unsubscribe()}})})}var io,to,ao,ro,oo,so=function(i){function ErrorLink(e){var n=i.call(this)||this;return n.link=onError(e),n}return __extends(ErrorLink,i),ErrorLink.prototype.request=function(e,n){return this.link.request(e,n)},ErrorLink}(xr);class ZimbraErrorLink extends so{constructor(){super(e=>{var{graphQLErrors:e,networkError:n}=e;e&&e.map(e=>{const{message:n,...i}=e;e=e.originalError;this.executeHandlers({errorCode:e?.faults?.[0]?.Detail?.Error?.Code||"",message:n,originalError:e,...i})}),n&&this.executeHandlers({message:"[Network error]: "+n})}),_defineProperty(this,"handlers",[]),_defineProperty(this,"executeHandlers",n=>{this.handlers.map(e=>{e(n)})}),_defineProperty(this,"registerHandler",e=>{this.handlers.push(e)}),_defineProperty(this,"unRegisterAllHandlers",()=>{this.handlers=[]}),_defineProperty(this,"unRegisterHandler",e=>{e=this.handlers.findIndex(e);-1!==e&&this.handlers.splice(e,1)})}}const lo=(e,n)=>{if(e.__typename)return(n=getValueByPath(e,n))?e.__typename+":"+n:defaultDataIdFromObject(e)},mo=e=>{switch(e.__typename){case"CalendarItemHitInfo":return e.instances?defaultDataIdFromObject(e)+":"+e.instances.length:""+defaultDataIdFromObject(e);case"MailboxMetadata":return lo(e,"meta.0.section");case"Folder":return e.local&&null!==e.local?defaultDataIdFromObject(e)+":local":"1"===e.id?e.__typename+`:${e.id}:`+e.uuid:e.id?.includes(":")?e.id+":"+e.absFolderPath:defaultDataIdFromObject(e);case"AutoCompleteMatch":return defaultDataIdFromObject(e)+":"+e.email;case"ContactListMember":return e.type+":"+e.value;case"MessageInfo":return e.part&&null!==e.part?defaultDataIdFromObject(e)+":"+e.part:defaultDataIdFromObject(e);case"SMimeMessage":return defaultDataIdFromObject(e)+":"+e.isSecure;case"Document":return defaultDataIdFromObject(e)+":"+e.version;default:return defaultDataIdFromObject(e)}};function createPossibleTypes(){return(0<arguments.length&&void 0!==arguments[0]?arguments[0]:Object)({MailItem:["Conversation","MessageInfo","MsgWithGroupInfo"]})}function isReference(e){return e&&"object"==typeof e&&"__ref"in e}function resolvedRefrenceAddress(e,n){return(e||[]).map(e=>isReference(e)?{__typename:n("__typename",e),address:n("address",e),type:n("type",e),isGroup:n("isGroup",e),name:n("name",e),displayName:n("displayName",e)}:e)}const uo={Query:{fields:{accountInfo:{merge:!0},getPreferences:{merge:!0}}},AccountInfo:{fields:{attrs:{merge:!0},habRoots:{merge:!0},license:{merge:!0},zimlets:{merge:!0},props:{merge:!0},cos:{merge:!0}}},Contact:{fields:{attributes:{merge:!0}}},Conversation:{fields:{messages:{merge:!1},emailAddresses:{merge:!1}}},MessageInfo:{fields:{emailAddresses:{merge(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],i=(2<arguments.length?arguments[2]:void 0)["readField"],e=resolvedRefrenceAddress(e,i),n=[...resolvedRefrenceAddress(n,i)||[],...e||[]];return n.sort((e,n)=>Number(null!=n.isGroup)-Number(null!=e.isGroup)),uniqWith(n,(e,n)=>e.address===n.address&&e.type===n.type)}}}}};class ZimbraInMemoryCache extends Ld{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};e.possibleTypes&&"function"!=typeof e.possibleTypes||(e.possibleTypes=createPossibleTypes(e.possibleTypes)),super({dataIdFromObject:mo,typePolicies:uo,...e})}}class SyncOfflineOperations{constructor(e){var n=this,{apolloClient:e,storage:i,storeKey:t="@offlineQueueKey"}=e;if(_defineProperty(this,"apolloClient",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"offlineData",void 0),_defineProperty(this,"storeKey",void 0),_defineProperty(this,"addOfflineData",function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];e&&0<e.length&&n.storage.setItem(n.storeKey,JSON.stringify(e))}),_defineProperty(this,"clearOfflineData",()=>(this.offlineData=[],Promise.resolve(this.storage.removeItem(this.storeKey)))),_defineProperty(this,"getOfflineData",()=>Promise.resolve(this.storage.getItem(this.storeKey))),_defineProperty(this,"hasOfflineData",()=>!!(this.offlineData&&0<this.offlineData.length)),_defineProperty(this,"init",()=>this.getOfflineData().then(e=>this.offlineData=e&&JSON.parse(e)||[])),_defineProperty(this,"sync",()=>{if(this.hasOfflineData()){const n=[];return Promise.all(this.offlineData.map(e=>this.apolloClient["mutation"in e?"mutate":"query"](e).catch(()=>{n.push(e)}))).catch(e=>console.warn("SyncOfflineOperations::sync ERR:",e)).then(this.clearOfflineData).then(()=>{this.addOfflineData(n)})}}),!e)throw new Error("Apollo Client instance is required when syncing data, please assign value to it");if(!i)throw new Error("Storage can be window.localStorage or AsyncStorage but was not set");this.apolloClient=e,this.storage=i,this.storeKey=t,this.offlineData=[]}}function hasSensitiveVariables(e){return!!e?.variables?.password}function isMutationOperation(e){e=e.query;return e&&e.definitions&&0<e.definitions.filter(e=>"mutation"===e.operation).length}function deriveOfflineQueue(e){return e.map(e=>{var{query:e,variables:n}=e["operation"];return{[isMutationOperation({query:e})?"mutation":"query"]:e,variables:n}})}class OfflineQueueLink extends xr{constructor(e){var n,{storage:e,storeKey:i="@offlineQueueKey",isOpen:t=!0}=e;if(super(),_defineProperty(n=this,"isOpen",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"operationQueue",void 0),_defineProperty(this,"storeKey",void 0),_defineProperty(this,"close",()=>{this.isOpen=!1}),_defineProperty(this,"dequeue",e=>{e=this.operationQueue.indexOf(e);-1!==e&&(this.operationQueue=[...this.operationQueue.slice(0,e),...this.operationQueue.slice(e+1)]),this.persist()}),_defineProperty(this,"enqueue",e=>{this.operationQueue.push(e),this.persist()}),_defineProperty(this,"getSize",()=>Promise.resolve(this.storage.getItem(this.storeKey)).then(e=>(e||"").length)),_defineProperty(this,"handleCancelAndOfflineQueue",i=>{let t=-1;this.operationQueue.forEach((e,n)=>{i.offlineQuery===e.offlineQuery&&(t=n),i.cancelQuery===e.offlineQuery&&(this.operationQueue=[...this.operationQueue.slice(0,n),...this.operationQueue.slice(n+1)],this.persist())}),-1!==t?(this.operationQueue[t]=i,this.persist()):this.enqueue(i)}),_defineProperty(this,"open",function(){var e=(0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})["apolloClient"];if(e)return n.isOpen=!0,n.retry()}),_defineProperty(this,"persist",()=>Promise.resolve(this.storage.setItem(this.storeKey,JSON.stringify(deriveOfflineQueue(this.operationQueue))))),_defineProperty(this,"purge",()=>Promise.resolve(this.storage.removeItem(this.storeKey))),_defineProperty(this,"retry",()=>new Promise(e=>{let n=this.operationQueue.length;if(!n)return e();const a=()=>{0==--n&&e()};this.operationQueue.forEach(n=>{const{operation:e,forward:i,observer:t}=n;i(e).subscribe({next:e=>{t.next&&t.next(e)},error:e=>{this.dequeue(n),t.error&&t.error(e),a()},complete:()=>{this.dequeue(n),t.complete&&t.complete(),a()}})})})),_defineProperty(this,"sync",e=>{e=e.apolloClient;if(e){const n=new SyncOfflineOperations({apolloClient:e,storage:this.storage,storeKey:this.storeKey});return n.init().then(e=>{if(e&&e.length)return n.sync()})}}),!e)throw new Error("Storage can be window.localStorage or AsyncStorage but was not set");this.storage=e,this.storeKey=i,this.operationQueue=[],this.isOpen=t}request(i,t){const{skipQueue:e,cancelQueues:a,offlineQueueName:r,local:n}=i.getContext();return(this.isOpen||n||e||hasSensitiveVariables(i))&&t?t(i):new y(e=>{const n={operation:i,forward:t,observer:e,offlineQuery:r,cancelQuery:a};return r||a?this.handleCancelAndOfflineQueue(n):this.enqueue(n),()=>this.dequeue(n)})}}!function(e){e.conversation="conversation",e.message="message"}(io=io||{}),function(e){e.unread="u",e.flagged="f",e.hasAttachment="a",e.replied="r",e.sentByMe="s",e.forwarded="w",e.calendarInvite="v",e.draft="d",e.imapDeleted="x",e.notificationSent="n",e.urgent="!",e.lowPriority="?",e.priority="+"}(to=to||{}),function(e){e.update="update",e.delete="delete",e.read="read",e.unread="!read",e.flag="flag",e.unflag="!flag",e.tag="tag",e.untag="!tag",e.move="move",e.spam="spam",e.unspam="!spam",e.trash="trash",e.copy="copy",e.recover="recover",e.rename="rename"}(ao=ao||{}),(ro=ro||{}).update="update",(oo=oo||{}).priority="priority";var po=Object.freeze({__proto__:null,get MailFolderView(){return io},get MessageFlags(){return to},get ActionOps(){return ao},get _MessageActionOps(){return ro},get _ConversationActionOps(){return oo},get ActionType(){return An},get ActionResultType(){return On},get AccountType(){return we},get ActionTypeName(){return _e},get AddressType(){return Pe},get AlarmAction(){return Ve},get AlarmRelatedTo(){return Le},get AutoCompleteMatchType(){return Me},get CalendarItemClass(){return Be},get CalendarItemRecurrenceFrequency(){return xe},get ConnectionType(){return je},get ContactType(){return ze},get ConversationOrderBy(){return qe},get ExternalSendersType(){return $e},get FilterMatchCondition(){return Ue},get FolderView(){return Qe},get FreeBusyStatus(){return Ge},get GalSearchType(){return We},get GranteeType(){return He},get Importance(){return Ke},get InviteCompletionStatus(){return Ye},get InviteReplyType(){return Je},get InviteReplyVerb(){return Ze},get InviteType(){return Xe},get LicenseStatus(){return en},get Mode(){return nn},get NeedIsMemberType(){return tn},get ParticipationRole(){return an},get ParticipationStatus(){return rn},get PasswordRecoveryAddressStatus(){return dn},get Pop3DeleteOption(){return on},get PrefCalendarInitialView(){return sn},get PrefClientType(){return ln},get PrefDelegatedSendSaveTarget(){return mn},get PrefMailSelectAfterDelete(){return un},get PrefMailSendReadReceipts(){return pn},get ReadingPaneLocation(){return cn},get RecoverAccountOp(){return vn},get ResetPasswordStatus(){return kn},get SaveDocumentAction(){return yn},get SaveDocumentType(){return fn},get SearchType(){return Nn},get SetRecoveryAccountChannel(){return gn},get SetRecoveryAccountOp(){return hn},get ShareInputAction(){return Tn},get SortBy(){return In},get Weekday(){return Dn},get ZimletPresence(){return bn}});const co={Contact:nt,Conversation:Ti,Document:tt,FolderEntity:Mi,Mailbox:Ut,MessageInfo:gi,Tag:$t};exports.LocalBatchLink=LocalBatchLink,exports.OfflineQueueLink=OfflineQueueLink,exports.SyncOfflineOperations=SyncOfflineOperations,exports.ZimbraBatchClient=ZimbraBatchClient,exports.ZimbraErrorLink=ZimbraErrorLink,exports.ZimbraInMemoryCache=ZimbraInMemoryCache,exports.batchJsonRequest=batchJsonRequest,exports.createZimbraSchema=createZimbraSchema,exports.entities=co,exports.jsonRequest=jsonRequest,exports.normalize=normalize$2,exports.schema=pa,exports.types=po;
26
+ `;class SessionHandler{constructor(e){_defineProperty(this,"cache",void 0),_defineProperty(this,"cacheKeyForSession","Session"),_defineProperty(this,"readSessionId",()=>{return this.cache.readFragment({id:this.cacheKeyForSession,fragment:Xd})?.id||"1"}),_defineProperty(this,"writeSessionId",e=>{this.cache.writeFragment({id:this.cacheKeyForSession,fragment:Xd,data:{id:e,__typename:"Session"}})}),this.cache=e.cache}}function createZimbraSchema(e){const{cache:n,getApolloClient:i,...t}=e;var a=n?new SessionHandler({cache:n}):void 0;const r=new ZimbraBatchClient({...t,sessionHandler:a}),d=e.localStoreClient;a=makeExecutableSchema({typeDefs:pa,resolvers:{Query:{accountInfo:r.accountInfo,autoComplete:(e,n)=>r.autoComplete(n),autoCompleteGAL:(e,n)=>r.autoCompleteGAL(n),discoverRights:(e,n)=>r.discoverRights(n),downloadAttachment:(e,n)=>r.downloadAttachment(n),downloadDocument:(e,n)=>r.downloadDocument(n),listDocumentRevisions:(e,n)=>r.listDocumentRevisions(n),getItem:(e,n)=>r.getItem(n),downloadMessage:function(e,n){var i=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{})["local"];return(i?d:r).downloadMessage(n)},freeBusy:(e,n)=>r.freeBusy(n),getContact:(e,n)=>r.getContact(n),clientInfo:(e,n)=>r.clientInfo(n),getContactFrequency:(e,n)=>r.getContactFrequency(n),getConversation:(e,n)=>r.getConversation(n),getCustomMetadata:(e,n)=>r.getCustomMetadata(n),getDocumentShareURL:(e,n)=>r.getDocumentShareURL(n),getFilterRules:r.getFilterRules,getFolder:function(e,n){var i=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{})["local"];return(i?d:r).getFolder(n)},getHAB:(e,n)=>{n=n.habRootGroupId;return r.getHAB(n)},getAccountDistributionLists:(e,n)=>{var{attrs:n,ownerOf:i}=n;return r.getAccountDistributionLists(n,i)},getDistributionList:(e,n)=>{var{dl:n,needOwners:i,needRights:t,by:a}=n;return r.getDistributionList(n,i,t,a)},getDistributionListMembers:(e,n)=>{var{limit:n,offset:i,dl:t}=n;return r.getDistributionListMembers(n,i,t)},getAppointment:(e,n)=>r.getAppointment(n),getAppointments:(e,n)=>r.search(n),getReminders:(e,n)=>r.search(n),getTasks:(e,n)=>r.getTasks(n),getAvailableLocales:e=>r.getAvailableLocales(),getMailboxMetadata:(e,n)=>r.getMailboxMetadata(n),getMessage:function(e,n){var i=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{})["local"];return(i?d:r).getMessage(n)},getMessagesMetadata:function(e,n){var i=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{})["local"];return(i?d:r).getMessagesMetadata(n)},getRights:(e,n)=>r.getRights(n),getScratchCodes:r.getScratchCodes,getSearchFolder:r.getSearchFolder,getSMimePublicCerts:(e,n)=>r.getSMimePublicCerts(n),getSMimeCertInfo:r.getSMimeCertInfo,getTrustedDevices:r.getTrustedDevices,getDeviceStatus:r.getDeviceStatus,getWorkingHours:(e,n)=>r.getWorkingHours(n),getPreferences:r.getPreferences,getDataSources:r.getDataSources,getIdentities:r.getIdentities,getImportStatus:r.getImportStatus,getSignatures:r.getSignatures,noop:function(e,n){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return r.noop(n,i.fetchOptions)},recoverAccount:(e,n)=>r.recoverAccount(n),relatedContacts:(e,n)=>r.relatedContacts(n),search:function(e,n){var i=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{})["local"];return(i?d:r).search(n)},searchCalendarResources:(e,n)=>r.searchCalendarResources(n),searchGal:(e,n)=>r.searchGal(n),shareInfo:(e,n)=>r.shareInfo(n),taskFolders:r.taskFolders,getWhiteBlackList:r.getWhiteBlackList,getAppSpecificPasswords:r.getAppSpecificPasswords,getTag:r.getTag},MailItem:{__resolveType(e){return e.conversationId?"MessageInfo":"Conversation"}},Mutation:{action:function(e,n){let{type:i,...t}=n;n=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}).local;return(n?d:r).action(i,t)},addMessage:function(e,n){var i=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{})["local"],t=n["message"];return i?d.addMessage(n):r.addMessage(t)},applyFilterRules:(e,n)=>r.applyFilterRules(n),cancelTask:(e,n)=>r.cancelTask(n),itemAction:(e,n)=>r.itemAction(n),login:(e,n)=>r.login(n),logout:r.logout,disableTwoFactorAuth:(e,n)=>{n=n.method;return r.disableTwoFactorAuth(n)},enableTwoFactorAuth:(e,n)=>{n=n.options;return r.enableTwoFactorAuth(n)},messageAction:(e,n)=>r.messageAction(n),changePassword:(e,n)=>r.changePassword(n),modifyProfileImage:(e,n)=>r.modifyProfileImage(n),contactAction:(e,n)=>r.contactAction(n),createAppSpecificPassword:(e,n)=>{n=n.appName;return r.createAppSpecificPassword(n)},conversationAction:(e,n)=>r.conversationAction(n),createFolder:(e,n,i)=>{let{isLocalFolder:t,...a}=n;n=i.local;return n?d.createFolder({isLocalFolder:t,...a}):r.createFolder(a)},createSearchFolder:(e,n)=>r.createSearchFolder(n),createContact:(e,n)=>{n=n.contact;return r.createContact(n)},createContactList:(e,n)=>{n=n.contact;return r.createContact(n)},modifyContact:(e,n)=>{n=n.contact;return r.modifyContact(n)},modifyContactList:(e,n)=>{n=n.contact;return r.modifyContact(n)},createAppointment:(e,n)=>{var{accountName:n,appointment:i}=n;return r.createAppointment(n,i)},snoozeCalendarItem:(e,n)=>{var{appointment:n,task:i}=n;return r.snoozeCalendarItem(n,i)},dismissCalendarItem:(e,n)=>{var{appointment:n,task:i}=n;return r.dismissCalendarItem(n,i)},createAppointmentException:(e,n)=>{var{accountName:n,appointment:i}=n;return r.createAppointmentException(n,i)},modifyAppointment:(e,n)=>{var{accountName:n,appointment:i}=n;return r.modifyAppointment(n,i)},createMountpoint:(e,n)=>r.createMountpoint(n),deleteAppointment:(e,n)=>{n=n.appointment;return r.deleteAppointment(n)},checkCalendars:(e,n)=>r.checkCalendars(n.actions),counterAppointment:(e,n)=>{n=n.counterAppointmentInvite;return r.counterAppointment(n)},createCalendar:(e,n)=>{var{name:n,color:i,url:t,parentFolderId:a}=n;return r.createFolder({name:n,color:i,url:t,view:"appointment",flags:"#",parentFolderId:a})},createSharedCalendar:(e,n)=>{n=n.link;return r.createMountpoint({link:{...n,parentFolderId:1,view:"appointment",flags:"#"}})},saveDocument:(e,n)=>r.saveDocument(n),changeFolderColor:(e,n)=>r.changeFolderColor(n),declineCounterAppointment:(e,n)=>{n=n.counterAppointmentInvite;return r.declineCounterAppointment(n)},folderAction:(e,n)=>{n=n.action;return r.folderAction(n)},documentAction:(e,n)=>{n=n.action;return r.documentAction(n)},forwardAppointment:(e,n)=>{n=n.appointmentInvite;return r.forwardAppointment(n)},forwardAppointmentInvite:(e,n)=>{n=n.appointmentInvite;return r.forwardAppointmentInvite(n)},generateScratchCodes:r.generateScratchCodes,grantRights:(e,n)=>r.grantRights(n.input),sendShareNotification:(e,n)=>{n=n.shareNotification;return r.sendShareNotification(n)},sendTwoFactorAuthCode:(e,n)=>{n=n.options;return r.sendTwoFactorAuthCode(n)},testExternalAccount:(e,n)=>{n=n.externalAccount;return r.testExternalAccount(n)},addExternalAccount:(e,n)=>{n=n.externalAccount;return r.addExternalAccount(n)},modifyExternalAccount:(e,n)=>r.modifyExternalAccount(n),deleteExternalAccount:(e,n)=>r.deleteExternalAccount(n),importExternalAccount:(e,n)=>{n=n.externalAccount;return r.importExternalAccount(n)},purgeRevision:(e,n)=>r.purgeRevision(n),prefEnableOutOfOfficeAlertOnLogin:(e,n)=>{n=n.value;return r.modifyPrefs({zimbraPrefOutOfOfficeStatusAlertOnLogin:n}).then(Boolean)},prefEnableOutOfOfficeReply:(e,n)=>{n=n.value;return r.modifyPrefs({zimbraPrefOutOfOfficeReplyEnabled:n}).then(Boolean)},prefOutOfOfficeFromDate:(e,n)=>{let i=n["value"];return r.modifyPrefs({zimbraPrefOutOfOfficeFromDate:i}).then(()=>i)},prefOutOfOfficeUntilDate:(e,n)=>{let i=n["value"];return r.modifyPrefs({zimbraPrefOutOfOfficeUntilDate:i}).then(()=>i)},prefOutOfOfficeReply:(e,n)=>{let i=n["value"];return r.modifyPrefs({zimbraPrefOutOfOfficeReply:i}).then(()=>i)},createIdentity:(e,n)=>r.createIdentity(n),modifyIdentity:(e,n)=>r.modifyIdentity(n).then(Boolean),deleteIdentity:(e,n)=>r.deleteIdentity(n).then(Boolean),modifyPrefs:(e,n)=>{n=n.prefs;return r.modifyPrefs(n)},modifyProps:(e,n)=>{n=n.props;return r.modifyProps(n)},modifyZimletPrefs:(e,n)=>{n=n.zimlets;return r.modifyZimletPrefs(n)},modifyFilterRules:(e,n)=>{n=n.filters;return r.modifyFilterRules(n)},createSignature:(e,n)=>r.createSignature(n),modifySignature:(e,n)=>r.modifySignature(n),modifySearchFolder:(e,n)=>r.modifySearchFolder(n),deleteSignature:(e,n)=>r.deleteSignature(n),saveDraft:function(e,n){var{message:n,accountName:i}=n;return((2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}).local?d:r).saveDraft(n,i)},sendMessage:function(e,n){var{message:n,accountName:i,sign:t=!1,encrypt:a=!1}=n;return((2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}).local?d:r).sendMessage(n,i,t,a)},saveSMimeCert:(e,n)=>{var{upload:n,password:i}=n;return r.saveSMimeCert(n,i)},sendDeliveryReport:(e,n)=>{n=n.messageId;return r.sendDeliveryReport(n)},uploadMessage:(e,n)=>{n=n.value;return r.uploadMessage(n)},createTask:(e,n)=>{n=n.task;return r.createTask(n)},modifyTask:(e,n)=>{n=n.task;return r.modifyTask(n)},sendInviteReply:(e,n)=>{n=n.inviteReply;return r.sendInviteReply(n)},recoverAccount:(e,n)=>r.recoverAccount(n),resetPassword:(e,n)=>r.resetPassword(n),revokeAppSpecificPassword:(e,n)=>{n=n.appName;return r.revokeAppSpecificPassword(n)},revokeOtherTrustedDevices:r.revokeOtherTrustedDevices,revokeRights:(e,n)=>r.revokeRights(n.input),revokeTrustedDevice:r.revokeTrustedDevice,setCustomMetadata:(e,n)=>r.setCustomMetadata(n),setMailboxMetadata:(e,n)=>r.jsonRequest({name:"SetMailboxMetadata",body:{meta:{section:n.section,_attrs:mapValues(n.attrs||{},coerceBooleanToString)}}}).then(Boolean),setRecoveryAccount:(e,n)=>r.setRecoveryAccount(n),modifyWhiteBlackList:(e,n)=>{n=n.whiteBlackList;return r.modifyWhiteBlackList(n)},createTag:(e,n)=>{n=n.tag;return r.createTag(n)},tagAction:(e,n)=>{n=n.action;return r.action(An.tag,n)},quarantineDeviceSync:(e,n)=>{n=n.deviceId;r.quarantineDeviceSync(n)},allowDeviceSync:(e,n)=>{n=n.deviceId;r.allowDeviceSync(n)},removeDeviceSync:(e,n)=>{n=n.deviceId;r.removeDeviceSync(n)},blockDeviceSync:(e,n)=>{n=n.deviceId;r.blockDeviceSync(n)},accountOnlyRemoteWipeSync:(e,n)=>{n=n.deviceId;r.accountOnlyRemoteWipeSync(n)},cancelPendingAccountOnlyRemoteWipeSync:(e,n)=>{n=n.deviceId;r.cancelPendingAccountOnlyRemoteWipeSync(n)},remoteWipeSync:(e,n)=>{n=n.deviceId;r.remoteWipeSync(n)},cancelPendingRemoteWipeSync:(e,n)=>{n=n.deviceId;r.cancelPendingRemoteWipeSync(n)},subscribeDistributionList:(e,n)=>{var{op:n,by:i,dl:t}=n;return r.subscribeDistributionList(n,i,t)},distributionListAction:(e,n)=>{n=n.dlActions;return r.distributionListAction(n)}}}});return{client:r,schema:a}}var eo=function(){function OperationBatcher(e){var n=e.batchDebounce,i=e.batchInterval,t=e.batchMax,a=e.batchHandler,e=e.batchKey;this.batchesByKey=new Map,this.scheduledBatchTimerByKey=new Map,this.batchDebounce=n,this.batchInterval=i,this.batchMax=t||0,this.batchHandler=a,this.batchKey=e||function(){return""}}return OperationBatcher.prototype.enqueueRequest=function(e){var a=this,r=I(I({},e),{next:[],error:[],complete:[],subscribers:new Set}),d=this.batchKey(e.operation);return r.observable||(r.observable=new y(function(n){var i=a.batchesByKey.get(d),e=(i||a.batchesByKey.set(d,i=new Set),0===i.size),t=0===r.subscribers.size;return r.subscribers.add(n),t&&i.add(r),n.next&&r.next.push(n.next.bind(n)),n.error&&r.error.push(n.error.bind(n)),n.complete&&r.complete.push(n.complete.bind(n)),(e||a.batchDebounce)&&a.scheduleQueueConsumption(d),i.size===a.batchMax&&a.consumeQueue(d),function(){var e;r.subscribers.delete(n)&&r.subscribers.size<1&&i.delete(r)&&i.size<1&&(a.consumeQueue(d),null!=(e=i.subscription))&&e.unsubscribe()}})),r.observable},OperationBatcher.prototype.consumeQueue=function(e){var n,i,t,a,r,d,o,s=this.batchesByKey.get(e=void 0===e?"":e);if(this.batchesByKey.delete(e),s&&s.size)return n=[],i=[],t=[],a=[],r=[],d=[],s.forEach(function(e){n.push(e.operation),i.push(e.forward),t.push(e.observable),a.push(e.next),r.push(e.error),d.push(e.complete)}),e=this.batchHandler(n,i)||y.of(),s.subscription=e.subscribe({next:function(e){var n;if(Array.isArray(e)||(e=[e]),a.length!==e.length)return(n=new Error("server returned results with length ".concat(e.length,", expected length of ").concat(a.length))).result=e,o(n);e.forEach(function(n,e){a[e]&&a[e].forEach(function(e){return e(n)})})},error:o=function(n){r.forEach(function(e){e&&e.forEach(function(e){return e(n)})})},complete:function(){d.forEach(function(e){e&&e.forEach(function(e){return e()})})}}),t},OperationBatcher.prototype.scheduleQueueConsumption=function(e){var n=this;clearTimeout(this.scheduledBatchTimerByKey.get(e)),this.scheduledBatchTimerByKey.set(e,setTimeout(function(){n.consumeQueue(e),n.scheduledBatchTimerByKey.delete(e)},this.batchInterval))},OperationBatcher}(),no=function(o){function BatchLink(e){var n=o.call(this)||this,i=e||{},t=i.batchInterval,a=i.batchMax,r=i.batchHandler,d=i.batchKey;return n.batcher=new eo({batchDebounce:i.batchDebounce,batchInterval:void 0===t?10:t,batchMax:void 0===a?0:a,batchHandler:void 0===r?function(){return null}:r,batchKey:void 0===d?function(){return""}:d}),e.batchHandler.length<=1&&(n.request=function(e){return n.batcher.enqueueRequest({operation:e})}),n}return __extends(BatchLink,o),BatchLink.prototype.request=function(e,n){return this.batcher.enqueueRequest({operation:e,forward:n})},BatchLink}(xr);class LocalBatchLink extends xr{constructor(t){super(),_defineProperty(this,"off",void 0),_defineProperty(this,"on",void 0),_defineProperty(this,"schema",void 0),_defineProperty(this,"batcher",void 0),this.schema=t.schema;const a=new events;this.on=a.on,this.off=a.off;this.batcher=new no({batchInterval:t.batchInterval,batchHandler:e=>new y(n=>{a.emit("req",e);let i=!1;Promise.all(e.map(e=>{var{operationName:n,variables:i={}}=e;return graphql({schema:this.schema,source:print$1(e.query),rootValue:null,contextValue:e.getContext()||t.context||{},variableValues:i,operationName:n})})).then(e=>(i=!0,a.emit("res",e),n.next(e),n.complete(),e)).catch(e=>{i||a.emit("res",e),n.error(e)})})})}request(e){return this.batcher.request(e)}}function onError(d){return new xr(function(a,r){return new y(function(n){var e,i,t;try{e=r(a).subscribe({next:function(e){e.errors?t=d({graphQLErrors:e.errors,response:e,operation:a,forward:r}):graphQLResultHasProtocolErrors(e)&&(t=d({protocolErrors:e.extensions[zr],response:e,operation:a,forward:r})),t?i=t.subscribe({next:n.next.bind(n),error:n.error.bind(n),complete:n.complete.bind(n)}):n.next(e)},error:function(e){(t=d({operation:a,networkError:e,graphQLErrors:e&&e.result&&e.result.errors||void 0,forward:r}))?i=t.subscribe({next:n.next.bind(n),error:n.error.bind(n),complete:n.complete.bind(n)}):n.error(e)},complete:function(){t||n.complete.bind(n)()}})}catch(e){d({networkError:e,operation:a,forward:r}),n.error(e)}return function(){e&&e.unsubscribe(),i&&e.unsubscribe()}})})}var io,to,ao,ro,oo,so=function(i){function ErrorLink(e){var n=i.call(this)||this;return n.link=onError(e),n}return __extends(ErrorLink,i),ErrorLink.prototype.request=function(e,n){return this.link.request(e,n)},ErrorLink}(xr);class ZimbraErrorLink extends so{constructor(){super(e=>{var{graphQLErrors:e,networkError:n}=e;e&&e.map(e=>{const{message:n,...i}=e;e=e.originalError;this.executeHandlers({errorCode:e?.faults?.[0]?.Detail?.Error?.Code||"",message:n,originalError:e,...i})}),n&&this.executeHandlers({message:"[Network error]: "+n})}),_defineProperty(this,"handlers",[]),_defineProperty(this,"executeHandlers",n=>{this.handlers.map(e=>{e(n)})}),_defineProperty(this,"registerHandler",e=>{this.handlers.push(e)}),_defineProperty(this,"unRegisterAllHandlers",()=>{this.handlers=[]}),_defineProperty(this,"unRegisterHandler",e=>{e=this.handlers.findIndex(e);-1!==e&&this.handlers.splice(e,1)})}}const lo=(e,n)=>{if(e.__typename)return(n=getValueByPath(e,n))?e.__typename+":"+n:defaultDataIdFromObject(e)},mo=e=>{switch(e.__typename){case"CalendarItemHitInfo":return e.instances?defaultDataIdFromObject(e)+":"+e.instances.length:""+defaultDataIdFromObject(e);case"MailboxMetadata":return lo(e,"meta.0.section");case"Folder":return e.local&&null!==e.local?defaultDataIdFromObject(e)+":local":"1"===e.id?e.__typename+`:${e.id}:`+e.uuid:e.id?.includes(":")?e.id+":"+e.absFolderPath:defaultDataIdFromObject(e);case"AutoCompleteMatch":return defaultDataIdFromObject(e)+":"+e.email;case"ContactListMember":return e.type+":"+e.value;case"MessageInfo":return e.part&&null!==e.part?defaultDataIdFromObject(e)+":"+e.part:defaultDataIdFromObject(e);case"SMimeMessage":return defaultDataIdFromObject(e)+":"+e.isSecure;case"Document":return defaultDataIdFromObject(e)+":"+e.version;default:return defaultDataIdFromObject(e)}};function createPossibleTypes(){return(0<arguments.length&&void 0!==arguments[0]?arguments[0]:Object)({MailItem:["Conversation","MessageInfo","MsgWithGroupInfo"]})}function isReference(e){return e&&"object"==typeof e&&"__ref"in e}function resolvedRefrenceAddress(e,n){return(e||[]).map(e=>isReference(e)?{__typename:n("__typename",e),address:n("address",e),type:n("type",e),isGroup:n("isGroup",e),name:n("name",e),displayName:n("displayName",e)}:e)}const uo={Query:{fields:{accountInfo:{merge:!0},getPreferences:{merge:!0}}},AccountInfo:{fields:{attrs:{merge:!0},habRoots:{merge:!0},license:{merge:!0},zimlets:{merge:!0},props:{merge:!0},cos:{merge:!0}}},Contact:{fields:{attributes:{merge:!0}}},Conversation:{fields:{messages:{merge:!1},emailAddresses:{merge:!1},sortField:{merge(e,n){return null!=n?n:e}}}},MessageInfo:{fields:{emailAddresses:{merge(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],i=(2<arguments.length?arguments[2]:void 0)["readField"],e=resolvedRefrenceAddress(e,i),n=[...resolvedRefrenceAddress(n,i)||[],...e||[]];return n.sort((e,n)=>Number(null!=n.isGroup)-Number(null!=e.isGroup)),uniqWith(n,(e,n)=>e.address===n.address&&e.type===n.type)}}}}};class ZimbraInMemoryCache extends Ld{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};e.possibleTypes&&"function"!=typeof e.possibleTypes||(e.possibleTypes=createPossibleTypes(e.possibleTypes)),super({dataIdFromObject:mo,typePolicies:uo,...e})}}class SyncOfflineOperations{constructor(e){var n=this,{apolloClient:e,storage:i,storeKey:t="@offlineQueueKey"}=e;if(_defineProperty(this,"apolloClient",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"offlineData",void 0),_defineProperty(this,"storeKey",void 0),_defineProperty(this,"addOfflineData",function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];e&&0<e.length&&n.storage.setItem(n.storeKey,JSON.stringify(e))}),_defineProperty(this,"clearOfflineData",()=>(this.offlineData=[],Promise.resolve(this.storage.removeItem(this.storeKey)))),_defineProperty(this,"getOfflineData",()=>Promise.resolve(this.storage.getItem(this.storeKey))),_defineProperty(this,"hasOfflineData",()=>!!(this.offlineData&&0<this.offlineData.length)),_defineProperty(this,"init",()=>this.getOfflineData().then(e=>this.offlineData=e&&JSON.parse(e)||[])),_defineProperty(this,"sync",()=>{if(this.hasOfflineData()){const n=[];return Promise.all(this.offlineData.map(e=>this.apolloClient["mutation"in e?"mutate":"query"](e).catch(()=>{n.push(e)}))).catch(e=>console.warn("SyncOfflineOperations::sync ERR:",e)).then(this.clearOfflineData).then(()=>{this.addOfflineData(n)})}}),!e)throw new Error("Apollo Client instance is required when syncing data, please assign value to it");if(!i)throw new Error("Storage can be window.localStorage or AsyncStorage but was not set");this.apolloClient=e,this.storage=i,this.storeKey=t,this.offlineData=[]}}function hasSensitiveVariables(e){return!!e?.variables?.password}function isMutationOperation(e){e=e.query;return e&&e.definitions&&0<e.definitions.filter(e=>"mutation"===e.operation).length}function deriveOfflineQueue(e){return e.map(e=>{var{query:e,variables:n}=e["operation"];return{[isMutationOperation({query:e})?"mutation":"query"]:e,variables:n}})}class OfflineQueueLink extends xr{constructor(e){var n,{storage:e,storeKey:i="@offlineQueueKey",isOpen:t=!0}=e;if(super(),_defineProperty(n=this,"isOpen",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"operationQueue",void 0),_defineProperty(this,"storeKey",void 0),_defineProperty(this,"close",()=>{this.isOpen=!1}),_defineProperty(this,"dequeue",e=>{e=this.operationQueue.indexOf(e);-1!==e&&(this.operationQueue=[...this.operationQueue.slice(0,e),...this.operationQueue.slice(e+1)]),this.persist()}),_defineProperty(this,"enqueue",e=>{this.operationQueue.push(e),this.persist()}),_defineProperty(this,"getSize",()=>Promise.resolve(this.storage.getItem(this.storeKey)).then(e=>(e||"").length)),_defineProperty(this,"handleCancelAndOfflineQueue",i=>{let t=-1;this.operationQueue.forEach((e,n)=>{i.offlineQuery===e.offlineQuery&&(t=n),i.cancelQuery===e.offlineQuery&&(this.operationQueue=[...this.operationQueue.slice(0,n),...this.operationQueue.slice(n+1)],this.persist())}),-1!==t?(this.operationQueue[t]=i,this.persist()):this.enqueue(i)}),_defineProperty(this,"open",function(){var e=(0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})["apolloClient"];if(e)return n.isOpen=!0,n.retry()}),_defineProperty(this,"persist",()=>Promise.resolve(this.storage.setItem(this.storeKey,JSON.stringify(deriveOfflineQueue(this.operationQueue))))),_defineProperty(this,"purge",()=>Promise.resolve(this.storage.removeItem(this.storeKey))),_defineProperty(this,"retry",()=>new Promise(e=>{let n=this.operationQueue.length;if(!n)return e();const a=()=>{0==--n&&e()};this.operationQueue.forEach(n=>{const{operation:e,forward:i,observer:t}=n;i(e).subscribe({next:e=>{t.next&&t.next(e)},error:e=>{this.dequeue(n),t.error&&t.error(e),a()},complete:()=>{this.dequeue(n),t.complete&&t.complete(),a()}})})})),_defineProperty(this,"sync",e=>{e=e.apolloClient;if(e){const n=new SyncOfflineOperations({apolloClient:e,storage:this.storage,storeKey:this.storeKey});return n.init().then(e=>{if(e&&e.length)return n.sync()})}}),!e)throw new Error("Storage can be window.localStorage or AsyncStorage but was not set");this.storage=e,this.storeKey=i,this.operationQueue=[],this.isOpen=t}request(i,t){const{skipQueue:e,cancelQueues:a,offlineQueueName:r,local:n}=i.getContext();return(this.isOpen||n||e||hasSensitiveVariables(i))&&t?t(i):new y(e=>{const n={operation:i,forward:t,observer:e,offlineQuery:r,cancelQuery:a};return r||a?this.handleCancelAndOfflineQueue(n):this.enqueue(n),()=>this.dequeue(n)})}}!function(e){e.conversation="conversation",e.message="message"}(io=io||{}),function(e){e.unread="u",e.flagged="f",e.hasAttachment="a",e.replied="r",e.sentByMe="s",e.forwarded="w",e.calendarInvite="v",e.draft="d",e.imapDeleted="x",e.notificationSent="n",e.urgent="!",e.lowPriority="?",e.priority="+"}(to=to||{}),function(e){e.update="update",e.delete="delete",e.read="read",e.unread="!read",e.flag="flag",e.unflag="!flag",e.tag="tag",e.untag="!tag",e.move="move",e.spam="spam",e.unspam="!spam",e.trash="trash",e.copy="copy",e.recover="recover",e.rename="rename"}(ao=ao||{}),(ro=ro||{}).update="update",(oo=oo||{}).priority="priority";var po=Object.freeze({__proto__:null,get MailFolderView(){return io},get MessageFlags(){return to},get ActionOps(){return ao},get _MessageActionOps(){return ro},get _ConversationActionOps(){return oo},get ActionType(){return An},get ActionResultType(){return On},get AccountType(){return we},get ActionTypeName(){return _e},get AddressType(){return Pe},get AlarmAction(){return Ve},get AlarmRelatedTo(){return Le},get AutoCompleteMatchType(){return Me},get CalendarItemClass(){return Be},get CalendarItemRecurrenceFrequency(){return xe},get ConnectionType(){return je},get ContactType(){return ze},get ConversationOrderBy(){return qe},get ExternalSendersType(){return $e},get FilterMatchCondition(){return Ue},get FolderView(){return Qe},get FreeBusyStatus(){return Ge},get GalSearchType(){return We},get GranteeType(){return He},get Importance(){return Ke},get InviteCompletionStatus(){return Ye},get InviteReplyType(){return Je},get InviteReplyVerb(){return Ze},get InviteType(){return Xe},get LicenseStatus(){return en},get Mode(){return nn},get NeedIsMemberType(){return tn},get ParticipationRole(){return an},get ParticipationStatus(){return rn},get PasswordRecoveryAddressStatus(){return dn},get Pop3DeleteOption(){return on},get PrefCalendarInitialView(){return sn},get PrefClientType(){return ln},get PrefDelegatedSendSaveTarget(){return mn},get PrefMailSelectAfterDelete(){return un},get PrefMailSendReadReceipts(){return pn},get ReadingPaneLocation(){return cn},get RecoverAccountOp(){return vn},get ResetPasswordStatus(){return kn},get SaveDocumentAction(){return yn},get SaveDocumentType(){return fn},get SearchType(){return Nn},get SetRecoveryAccountChannel(){return gn},get SetRecoveryAccountOp(){return hn},get ShareInputAction(){return Tn},get SortBy(){return In},get Weekday(){return Dn},get ZimletPresence(){return bn}});const co={Contact:nt,Conversation:Ti,Document:tt,FolderEntity:Mi,Mailbox:Ut,MessageInfo:gi,Tag:$t};exports.LocalBatchLink=LocalBatchLink,exports.OfflineQueueLink=OfflineQueueLink,exports.SyncOfflineOperations=SyncOfflineOperations,exports.ZimbraBatchClient=ZimbraBatchClient,exports.ZimbraErrorLink=ZimbraErrorLink,exports.ZimbraInMemoryCache=ZimbraInMemoryCache,exports.batchJsonRequest=batchJsonRequest,exports.createZimbraSchema=createZimbraSchema,exports.entities=co,exports.jsonRequest=jsonRequest,exports.normalize=normalize$2,exports.schema=pa,exports.types=po;
27
27
  //# sourceMappingURL=zm-api-js-client.js.map