@corsair-dev/gmail 0.1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EAEjB,uBAAuB,EAKvB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAW7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EACX,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,MAAM,YAAY,CAAC;AASpB;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;CAIS,CAAC;AAEtC,MAAM,MAAM,YAAY,GAAG,oBAAoB,CAC9C,OAAO,WAAW,EAClB,kBAAkB,EAClB,SAAS,EACT,OAAO,eAAe,CACtB,CAAC;AAEF,KAAK,aAAa,CAAC,CAAC,SAAS,MAAM,oBAAoB,IAAI,eAAe,CACzE,YAAY,EACZ,mBAAmB,CAAC,CAAC,CAAC,EACtB,oBAAoB,CAAC,CAAC,CAAC,CACvB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC5B,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC5C,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IAC1C,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC5C,cAAc,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAChD,cAAc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EACN,yBAAyB,EACzB,mBAAmB,GACnB,MAAM,kBAAkB,CAAC;AAM1B,YAAY,EACX,mBAAmB,EACnB,oBAAoB,GACpB,MAAM,mBAAmB,CAAC;AAM3B,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,mBAAmB,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{request as xe}from"corsair/http";var j=class extends Error{constructor(a,o){super(a);this.code=o;this.name="GmailAPIError"}},Re="https://gmail.googleapis.com/gmail/v1";async function Ae(e,t,a){let o=await fetch("https://oauth2.googleapis.com/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:e,client_secret:t,refresh_token:a,grant_type:"refresh_token"})});if(!o.ok){let i=await o.text();throw new j(`Failed to refresh access token: ${i}`,o.status)}return await o.json()}async function B({accessToken:e,expiresAt:t,clientId:a,clientSecret:o,refreshToken:r,forceRefresh:i=!1}){let d=Math.floor(Date.now()/1e3);if(!i&&e&&t&&Number(t)>d+300)return{accessToken:e,expiresAt:Number(t),refreshed:!1};let l=await Ae(a,o,r);return{accessToken:l.access_token,expiresAt:d+l.expires_in,refreshed:!0}}async function y(e,t,a={}){let{method:o="GET",body:r,query:i}=a;return await xe({BASE:Re,VERSION:"1.0.0",WITH_CREDENTIALS:!1,CREDENTIALS:"omit",TOKEN:t,HEADERS:{"Content-Type":"application/json"}},{method:o,url:e,body:o==="POST"||o==="PUT"||o==="PATCH"?r:void 0,mediaType:"application/json",query:o==="GET"?i:void 0})}function Oe(e){return e instanceof Error&&"status"in e&&e.status===401}async function g(e,t,a={}){try{return await y(e,t.key,a)}catch(o){if(Oe(o)&&t._refreshAuth){let r=await t._refreshAuth();return await y(e,r,a)}throw o}}import{logEventFromContext as M}from"corsair/core";var z=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/drafts`,e,{method:"GET",query:{maxResults:t.maxResults,pageToken:t.pageToken,q:t.q}});if(a.drafts&&e.db.drafts)try{for(let o of a.drafts)o.id&&await e.db.drafts.upsertByEntityId(o.id,{...o,id:o.id,messageId:o.message?.id,createdAt:new Date})}catch(o){console.warn("Failed to save drafts to database:",o)}return await M(e,"gmail.drafts.list",{...t},"completed"),a},F=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/drafts/${t.id}`,e,{method:"GET",query:{format:t.format}});if(a.id&&e.db.drafts)try{await e.db.drafts.upsertByEntityId(a.id,{...a,id:a.id,messageId:a.message?.id,createdAt:new Date})}catch(o){console.warn("Failed to save draft to database:",o)}return await M(e,"gmail.drafts.get",{...t},"completed"),a},V=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/drafts`,e,{method:"POST",body:t.draft});return a.id&&await e.endpoints.drafts.get({id:a.id,userId:t.userId}),await M(e,"gmail.drafts.create",{...t},"completed"),a},K=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/drafts/${t.id}`,e,{method:"PUT",body:t.draft});return a.id&&await e.endpoints.drafts.get({id:a.id,userId:t.userId}),await M(e,"gmail.drafts.update",{...t},"completed"),a},Y=async(e,t)=>{if(await g(`/users/${t.userId||"me"}/drafts/${t.id}`,e,{method:"DELETE"}),e.db.drafts)try{await e.db.drafts.deleteByEntityId(t.id)}catch(a){console.warn("Failed to delete draft from database:",a)}await M(e,"gmail.drafts.delete",{...t},"completed")},Z=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/drafts/send`,e,{method:"POST",body:{id:t.id,message:t.message}});return await M(e,"gmail.drafts.send",{...t},"completed"),a};import{logEventFromContext as v}from"corsair/core";var J=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/labels`,e,{method:"GET"});if(a.labels&&e.db.labels)try{for(let o of a.labels)o.id&&await e.db.labels.upsertByEntityId(o.id,{...o,id:o.id,createdAt:new Date})}catch(o){console.warn("Failed to save labels to database:",o)}return await v(e,"gmail.labels.list",{...t},"completed"),a},X=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/labels/${t.id}`,e,{method:"GET"});if(a.id&&e.db.labels)try{await e.db.labels.upsertByEntityId(a.id,{id:a.id,name:a.name,messageListVisibility:a.messageListVisibility,labelListVisibility:a.labelListVisibility,type:a.type,messagesTotal:a.messagesTotal,messagesUnread:a.messagesUnread,threadsTotal:a.threadsTotal,threadsUnread:a.threadsUnread,createdAt:new Date})}catch(o){console.warn("Failed to save label to database:",o)}return await v(e,"gmail.labels.get",{...t},"completed"),a},Q=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/labels`,e,{method:"POST",body:t.label});return a.id&&await e.endpoints.labels.get({id:a.id,userId:t.userId}),await v(e,"gmail.labels.create",{...t},"completed"),a},ee=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/labels/${t.id}`,e,{method:"PUT",body:t.label});return a.id&&await e.endpoints.labels.get({id:a.id,userId:t.userId}),await v(e,"gmail.labels.update",{...t},"completed"),a},te=async(e,t)=>{if(await g(`/users/${t.userId||"me"}/labels/${t.id}`,e,{method:"DELETE"}),e.db.labels)try{await e.db.labels.deleteByEntityId(t.id)}catch(a){console.warn("Failed to delete label from database:",a)}await v(e,"gmail.labels.delete",{...t},"completed")};import{logEventFromContext as I}from"corsair/core";function U(e,t){return e?.headers?e.headers.find(o=>o.name?.toLowerCase()===t.toLowerCase())?.value:void 0}function Ue(e){if(e.payload)return U(e.payload,"Subject")}function $e(e){if(e.payload)return U(e.payload,"From")}function _e(e){if(e.payload)return U(e.payload,"To")}function se(e){if(!e)return;let t,a;if(e.body?.data)try{let o=Buffer.from(e.body.data,"base64").toString("utf-8");e.mimeType==="text/plain"?t=o:e.mimeType==="text/html"&&(a=o)}catch{}if(e.parts&&e.parts.length>0)for(let o of e.parts){let r=se(o);r&&(o.mimeType==="text/plain"?t=r:o.mimeType==="text/html"&&!t&&(a=r))}return t||a}function Ne(e){if(e.payload)return se(e.payload)}var ae=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/messages`,e,{method:"GET",query:{q:t.q,maxResults:t.maxResults,pageToken:t.pageToken,labelIds:t.labelIds?.join(","),includeSpamTrash:t.includeSpamTrash}});if(a.messages&&e.db.messages)try{for(let o of a.messages)o.id&&await e.db.messages.upsertByEntityId(o.id,{...o,id:o.id,createdAt:new Date})}catch(o){console.warn("Failed to save messages to database:",o)}return await I(e,"gmail.messages.list",{...t},"completed"),a},oe=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/messages/${t.id}`,e,{method:"GET",query:{format:t.format,metadataHeaders:t.metadataHeaders?.join(",")}});if(a.id&&e.db.messages)try{let o=Ue(a),r=Ne(a),i=$e(a),d=_e(a);await e.db.messages.upsertByEntityId(a.id,{...a,subject:o,body:r,from:i,to:d,id:a.id,createdAt:new Date})}catch(o){console.warn("Failed to save message to database:",o)}return await I(e,"gmail.messages.get",{...t},"completed"),a},ie=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/messages/send`,e,{method:"POST",body:{raw:t.raw,threadId:t.threadId}});return a.id&&await e.endpoints.messages.get({id:a.id,userId:t.userId}),await I(e,"gmail.messages.send",{...t},"completed"),a},re=async(e,t)=>{if(await g(`/users/${t.userId||"me"}/messages/${t.id}`,e,{method:"DELETE"}),e.db.messages)try{await e.db.messages.deleteByEntityId(t.id)}catch(a){console.warn("Failed to delete message from database:",a)}await I(e,"gmail.messages.delete",{...t},"completed")},ne=async(e,t)=>{let a={};t.addLabelIds&&t.addLabelIds.length>0&&(a.addLabelIds=t.addLabelIds),t.removeLabelIds&&t.removeLabelIds.length>0&&(a.removeLabelIds=t.removeLabelIds);let o=await g(`/users/${t.userId||"me"}/messages/${t.id}/modify`,e,{method:"POST",body:a});return o.id&&await e.endpoints.messages.get({id:o.id,userId:t.userId}),await I(e,"gmail.messages.modify",{...t},"completed"),o},de=async(e,t)=>{let a={ids:t.ids};t.addLabelIds&&t.addLabelIds.length>0&&(a.addLabelIds=t.addLabelIds),t.removeLabelIds&&t.removeLabelIds.length>0&&(a.removeLabelIds=t.removeLabelIds),await g(`/users/${t.userId||"me"}/messages/batchModify`,e,{method:"POST",body:a}),await I(e,"gmail.messages.batchModify",{...t},"completed")},le=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/messages/${t.id}/trash`,e,{method:"POST"});return a.id&&await e.endpoints.messages.get({id:a.id,userId:t.userId}),await I(e,"gmail.messages.trash",{...t},"completed"),a},me=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/messages/${t.id}/untrash`,e,{method:"POST"});return a.id&&await e.endpoints.messages.get({id:a.id,userId:t.userId}),await I(e,"gmail.messages.untrash",{...t},"completed"),a};import{logEventFromContext as L}from"corsair/core";var pe=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/threads`,e,{method:"GET",query:{q:t.q,maxResults:t.maxResults,pageToken:t.pageToken,labelIds:t.labelIds?.join(","),includeSpamTrash:t.includeSpamTrash}});if(a.threads&&e.db.threads)try{for(let o of a.threads)o.id&&await e.db.threads.upsertByEntityId(o.id,{...o,id:o.id,createdAt:new Date})}catch(o){console.warn("Failed to save threads to database:",o)}return await L(e,"gmail.threads.list",{...t},"completed"),a},ge=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/threads/${t.id}`,e,{method:"GET",query:{format:t.format,metadataHeaders:t.metadataHeaders?.join(",")}});if(a.id&&e.db.threads)try{await e.db.threads.upsertByEntityId(a.id,{...a,id:a.id,createdAt:new Date})}catch(o){console.warn("Failed to save thread to database:",o)}return await L(e,"gmail.threads.get",{...t},"completed"),a},ce=async(e,t)=>{let a={};t.addLabelIds&&t.addLabelIds.length>0&&(a.addLabelIds=t.addLabelIds),t.removeLabelIds&&t.removeLabelIds.length>0&&(a.removeLabelIds=t.removeLabelIds);let o=await g(`/users/${t.userId||"me"}/threads/${t.id}/modify`,e,{method:"POST",body:a});return o.id&&await e.endpoints.threads.get({id:o.id,userId:t.userId}),await L(e,"gmail.threads.modify",{...t},"completed"),o},ue=async(e,t)=>{if(await g(`/users/${t.userId||"me"}/threads/${t.id}`,e,{method:"DELETE"}),e.db.threads)try{await e.db.threads.deleteByEntityId(t.id)}catch(a){console.warn("Failed to delete thread from database:",a)}await L(e,"gmail.threads.delete",{...t},"completed")},he=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/threads/${t.id}/trash`,e,{method:"POST"});return a.id&&await e.endpoints.threads.get({id:a.id,userId:t.userId}),await L(e,"gmail.threads.trash",{...t},"completed"),a},fe=async(e,t)=>{let a=await g(`/users/${t.userId||"me"}/threads/${t.id}/untrash`,e,{method:"POST"});return a.id&&await e.endpoints.threads.get({id:a.id,userId:t.userId}),await L(e,"gmail.threads.untrash",{...t},"completed"),a};import{z as s}from"zod";var He=s.object({userId:s.string().optional(),q:s.string().optional(),maxResults:s.number().optional(),pageToken:s.string().optional(),labelIds:s.array(s.string()).optional(),includeSpamTrash:s.boolean().optional()}),ze=s.object({userId:s.string().optional(),id:s.string(),format:s.enum(["minimal","full","raw","metadata"]).optional(),metadataHeaders:s.array(s.string()).optional()}),Fe=s.object({userId:s.string().optional(),raw:s.string(),threadId:s.string().optional()}),Ve=s.object({userId:s.string().optional(),id:s.string()}),Ke=s.object({userId:s.string().optional(),id:s.string(),addLabelIds:s.array(s.string()).optional(),removeLabelIds:s.array(s.string()).optional()}),Ye=s.object({userId:s.string().optional(),ids:s.array(s.string()).optional(),addLabelIds:s.array(s.string()).optional(),removeLabelIds:s.array(s.string()).optional()}),Ze=s.object({userId:s.string().optional(),id:s.string()}),Je=s.object({userId:s.string().optional(),id:s.string()}),Xe=s.object({userId:s.string().optional()}),Qe=s.object({userId:s.string().optional(),id:s.string()}),et=s.object({userId:s.string().optional(),label:s.object({name:s.string().optional(),messageListVisibility:s.enum(["show","hide"]).optional(),labelListVisibility:s.enum(["labelShow","labelShowIfUnread","labelHide"]).optional(),color:s.object({textColor:s.string().optional(),backgroundColor:s.string().optional()}).optional()})}),tt=s.object({userId:s.string().optional(),id:s.string(),label:s.object({name:s.string().optional(),messageListVisibility:s.enum(["show","hide"]).optional(),labelListVisibility:s.enum(["labelShow","labelShowIfUnread","labelHide"]).optional(),color:s.object({textColor:s.string().optional(),backgroundColor:s.string().optional()}).optional()})}),st=s.object({userId:s.string().optional(),id:s.string()}),at=s.object({userId:s.string().optional(),maxResults:s.number().optional(),pageToken:s.string().optional(),q:s.string().optional()}),ot=s.object({userId:s.string().optional(),id:s.string(),format:s.enum(["minimal","full","raw","metadata"]).optional()}),it=s.object({userId:s.string().optional(),draft:s.object({message:s.object({raw:s.string().optional(),threadId:s.string().optional()}).optional()})}),rt=s.object({userId:s.string().optional(),id:s.string(),draft:s.object({message:s.object({raw:s.string().optional(),threadId:s.string().optional()}).optional()})}),nt=s.object({userId:s.string().optional(),id:s.string()}),dt=s.object({userId:s.string().optional(),id:s.string().optional(),message:s.object({raw:s.string().optional(),threadId:s.string().optional()}).optional()}),lt=s.object({userId:s.string().optional(),q:s.string().optional(),maxResults:s.number().optional(),pageToken:s.string().optional(),labelIds:s.array(s.string()).optional(),includeSpamTrash:s.boolean().optional()}),mt=s.object({userId:s.string().optional(),id:s.string(),format:s.enum(["minimal","full","metadata"]).optional(),metadataHeaders:s.array(s.string()).optional()}),pt=s.object({userId:s.string().optional(),id:s.string(),addLabelIds:s.array(s.string()).optional(),removeLabelIds:s.array(s.string()).optional()}),gt=s.object({userId:s.string().optional(),id:s.string()}),ct=s.object({userId:s.string().optional(),id:s.string()}),ut=s.object({userId:s.string().optional(),id:s.string()}),ht=s.object({userId:s.string().optional()}),c={messagesList:He,messagesGet:ze,messagesSend:Fe,messagesDelete:Ve,messagesModify:Ke,messagesBatchModify:Ye,messagesTrash:Ze,messagesUntrash:Je,labelsList:Xe,labelsGet:Qe,labelsCreate:et,labelsUpdate:tt,labelsDelete:st,draftsList:at,draftsGet:ot,draftsCreate:it,draftsUpdate:rt,draftsDelete:nt,draftsSend:dt,threadsList:lt,threadsGet:mt,threadsModify:pt,threadsDelete:gt,threadsTrash:ct,threadsUntrash:ut,usersGetProfile:ht},ft=s.object({name:s.string().optional(),value:s.string().optional()}),bt=s.object({attachmentId:s.string().optional(),size:s.number().optional(),data:s.string().optional()}),yt=s.object({partId:s.string().optional(),mimeType:s.string().optional(),filename:s.string().optional(),headers:s.array(ft).optional(),body:bt.optional()}),be=yt.extend({parts:s.lazy(()=>s.array(be).optional())}),E=s.object({id:s.string().optional(),threadId:s.string().optional(),labelIds:s.array(s.string()).optional(),snippet:s.string().optional(),historyId:s.string().optional(),internalDate:s.union([s.string(),s.number(),s.date()]).transform(e=>{if(e instanceof Date)return e;if(typeof e=="number")return new Date(e);if(typeof e=="string"){let t=Number(e);return isNaN(t)?null:new Date(t)}return null}).nullable().optional(),sizeEstimate:s.number().optional(),payload:be.optional(),raw:s.string().optional()}),Et=s.object({messages:s.array(E).optional(),nextPageToken:s.string().optional(),resultSizeEstimate:s.number().optional()}),Gt=s.object({textColor:s.string().optional(),backgroundColor:s.string().optional()}),x=s.object({id:s.string().optional(),name:s.string().optional(),messageListVisibility:s.enum(["show","hide"]).optional(),labelListVisibility:s.enum(["labelShow","labelShowIfUnread","labelHide"]).optional(),type:s.enum(["system","user"]).optional(),messagesTotal:s.number().optional(),messagesUnread:s.number().optional(),threadsTotal:s.number().optional(),threadsUnread:s.number().optional(),color:Gt.optional()}),It=s.object({labels:s.array(x).optional()}),R=s.object({id:s.string().optional(),message:E.optional()}),wt=s.object({drafts:s.array(R).optional(),nextPageToken:s.string().optional(),resultSizeEstimate:s.number().optional()}),P=s.object({id:s.string().optional(),snippet:s.string().optional(),historyId:s.string().optional(),messages:s.array(E).optional()}),Tt=s.object({threads:s.array(P).optional(),nextPageToken:s.string().optional(),resultSizeEstimate:s.number().optional()}),Mt=s.object({emailAddress:s.string().optional(),messagesTotal:s.number().optional(),threadsTotal:s.number().optional(),historyId:s.string().optional()}),u={messagesList:Et,messagesGet:E,messagesSend:E,messagesDelete:s.void(),messagesModify:E,messagesBatchModify:s.void(),messagesTrash:E,messagesUntrash:E,labelsList:It,labelsGet:x,labelsCreate:x,labelsUpdate:x,labelsDelete:s.void(),draftsList:wt,draftsGet:R,draftsCreate:R,draftsUpdate:R,draftsDelete:s.void(),draftsSend:E,threadsList:Tt,threadsGet:P,threadsModify:P,threadsDelete:s.void(),threadsTrash:P,threadsUntrash:P,usersGetProfile:Mt};var G={list:ae,get:oe,send:ie,delete:re,modify:ne,batchModify:de,trash:le,untrash:me},S={list:J,get:X,create:Q,update:ee,delete:te},w={list:z,get:F,create:V,update:K,delete:Y,send:Z},T={list:pe,get:ge,modify:ce,delete:ue,trash:he,untrash:fe};import{z as C}from"zod";import{z as n}from"zod";var Lt=n.object({name:n.string().optional(),value:n.string().optional()}),St=n.object({attachmentId:n.string().optional(),size:n.number().optional(),data:n.string().optional()}),ye=n.lazy(()=>n.object({partId:n.string().optional(),mimeType:n.string().optional(),filename:n.string().optional(),headers:n.array(Lt).optional(),body:St.optional(),parts:n.array(ye).optional()})),Ee=n.object({id:n.string(),threadId:n.string().optional(),labelIds:n.array(n.string()).optional(),snippet:n.string().optional(),historyId:n.string().optional(),internalDate:n.string().optional(),sizeEstimate:n.number().optional(),payload:ye.optional(),raw:n.string().optional(),subject:n.string().optional(),body:n.string().optional(),from:n.string().optional(),to:n.string().optional(),createdAt:n.coerce.date().nullable().optional()}),Ge=n.object({id:n.string(),name:n.string().optional(),messageListVisibility:n.enum(["show","hide"]).optional(),labelListVisibility:n.enum(["labelShow","labelShowIfUnread","labelHide"]).optional(),type:n.enum(["system","user"]).optional(),messagesTotal:n.number().optional(),messagesUnread:n.number().optional(),threadsTotal:n.number().optional(),threadsUnread:n.number().optional(),createdAt:n.coerce.date().nullable().optional()}),Ie=n.object({id:n.string(),messageId:n.string().optional(),createdAt:n.coerce.date().nullable().optional()}),we=n.object({id:n.string(),snippet:n.string().optional(),historyId:n.string().optional(),createdAt:n.coerce.date().nullable().optional()});var us=C.object({clientId:C.string(),clientSecret:C.string(),accessToken:C.string(),refreshToken:C.string()}),$={version:"1.0.0",entities:{messages:Ee,labels:Ge,drafts:Ie,threads:we}};import{logEventFromContext as D}from"corsair/core";import{z as m}from"zod";var kt=m.object({data:m.string().optional(),attributes:m.record(m.string()).optional(),messageId:m.string().optional(),publishTime:m.string().optional()}),Te=m.object({message:kt.optional(),subscription:m.string().optional(),event:m.unknown().optional()}),bs=m.object({emailAddress:m.string().optional(),historyId:m.string().optional()}),vt=m.object({type:m.literal("messageReceived"),emailAddress:m.string(),historyId:m.string(),message:m.custom()}),Pt=m.object({type:m.literal("messageDeleted"),emailAddress:m.string(),historyId:m.string(),message:m.custom()}),Ct=m.object({type:m.literal("messageLabelChanged"),emailAddress:m.string(),historyId:m.string(),message:m.custom(),labelsAdded:m.array(m.string()).optional(),labelsRemoved:m.array(m.string()).optional()}),Me=m.union([vt,Pt,Ct]);function k(e){let t=Buffer.from(e,"base64").toString("utf-8");return JSON.parse(t)}function _(e){return t=>{let a=t.body;if(!a.message?.data)return!1;try{let o=k(a.message.data);return!!o.historyId&&!!o.emailAddress}catch{return!1}}}var Dt=100,xt=10,Rt=10;function N(e,t){return e?.headers?e.headers.find(o=>o.name?.toLowerCase()===t.toLowerCase())?.value:void 0}function At(e){if(e.payload)return N(e.payload,"Subject")}function Ot(e){if(e.payload)return N(e.payload,"From")}function jt(e){if(e.payload)return N(e.payload,"To")}function ke(e){if(!e)return;let t,a;if(e.body?.data)try{let o=Buffer.from(e.body.data,"base64").toString("utf-8");e.mimeType==="text/plain"?t=o:e.mimeType==="text/html"&&(a=o)}catch{}if(e.parts&&e.parts.length>0)for(let o of e.parts){let r=ke(o);r&&(o.mimeType==="text/plain"?t=r:o.mimeType==="text/html"&&!t&&(a=r))}return t||a}function Bt(e){if(e.payload)return ke(e.payload)}function Ut(e){let t=[],a=[],o=[];if(!e)return{added:t,deleted:a,modified:o};for(let r of e){if(r.messagesAdded)for(let i of r.messagesAdded)i.message?.id&&t.push(i.message.id);if(r.messagesDeleted)for(let i of r.messagesDeleted)i.message?.id&&a.push(i.message.id);if(r.labelsAdded||r.labelsRemoved){if(r.labelsAdded)for(let i of r.labelsAdded)i.message?.id&&o.push(i.message.id);if(r.labelsRemoved)for(let i of r.labelsRemoved)i.message?.id&&o.push(i.message.id)}}return{added:[...new Set(t)],deleted:[...new Set(a)],modified:[...new Set(o)]}}async function q(e,t,a){let[o,r]=await Promise.all([y(`/users/${t}/messages/${a}`,e,{method:"GET",query:{format:"full"}}),y(`/users/${t}/messages/${a}`,e,{method:"GET",query:{format:"raw"}}).catch(()=>null)]);return{...o,raw:r?.raw}}async function $t(e,t,a,o){return y(`/users/${t}/messages/${a}/attachments/${o}`,e,{method:"GET"})}async function ve(e,t,a){if(!a.payload)return a;let o=async i=>{if(!i)return i;if(i.body?.attachmentId)try{let d=await $t(e,t,a.id,i.body.attachmentId);return{...i,body:{...i.body,data:d.data,size:d.size}}}catch(d){return console.warn(`Failed to fetch attachment ${i.body.attachmentId} for message ${a.id}:`,d),i}if(i.parts&&i.parts.length>0){let d=await Promise.all(i.parts.map(o));return{...i,parts:d.filter(p=>p!==void 0)}}return i},r=await o(a.payload);return{...a,payload:r}}function _t(e){let t=Number(e);return t>1?String(t-1):e}async function Pe(e,t){return!e.db?.messages||!t.id?"":(await e.db.messages.upsertByEntityId(t.id,{...t,id:t.id,subject:At(t),body:Bt(t),from:Ot(t),to:jt(t),createdAt:new Date}))?.id??""}async function Nt(e,t,a,o){let r=await y(`/users/${a}/messages`,t,{method:"GET",query:{maxResults:xt}}),i=[],d=[];if(!r.messages?.length)return{added:i,modified:d};let p=Number(o);for(let l of r.messages)if(l.id)try{let h=await q(t,a,l.id);(h.historyId?Number(h.historyId):0)>=p-Rt&&(e.db?.messages&&await e.db.messages.findByEntityId(l.id)?d.push(l.id):i.push(l.id))}catch{}return{added:i,modified:d}}async function Le(e,t,a,o){let r=null,i="";for(let d of o)try{let p=await q(t,a,d),l=await ve(t,a,p);r||(r=l);try{let h=await Pe(e,l);!i&&h&&(i=h)}catch(h){throw console.error(`Failed to save message ${l.id} to database:`,h),h}}catch(p){console.warn(`Failed to process message ${d}:`,p)}return{message:r,corsairEntityId:i}}async function qt(e,t,a,o){let r=null,i="";if(!e.db?.messages)return{message:null,corsairEntityId:i};for(let d of o)try{let p=null;try{p=await y(`/users/${a}/messages/${d}`,t,{method:"GET",query:{format:"full"}})}catch(l){if(l?.statusCode===404)continue}if(!r&&p&&(r=p),!i){let l=await e.db.messages.findByEntityId(d);l&&(i=l.id)}await e.db.messages.deleteByEntityId(d)}catch(p){console.warn(`Failed to delete message ${d} from database:`,p)}return{message:r,corsairEntityId:i}}async function Se(e,t,a,o){let r=null,i="";if(!e.db?.messages)return{message:null,corsairEntityId:i};for(let d of o)try{let p=await q(t,a,d),l=await ve(t,a,p);r||(r=l);try{let h=await Pe(e,l);!i&&h&&(i=h)}catch(h){throw console.error(`Failed to update message ${l.id} in database:`,h),h}}catch(p){console.warn(`Failed to process message ${d}:`,p)}return{message:r,corsairEntityId:i}}var Ce={match:_("messageChanged"),handler:async(e,t)=>{let a=t.payload;if(!a.message?.data)return{success:!1,error:"No message data in notification"};let o=k(a.message.data);if(!o.historyId||!o.emailAddress)return{success:!1,error:"Invalid push notification format"};let r=e.key,i=o.emailAddress,d=o.historyId;try{let p=_t(d),l=await y(`/users/${i}/history`,r,{method:"GET",query:{startHistoryId:p,maxResults:Dt}}),{added:h,deleted:A,modified:O}=Ut(l.history);if(O.length>0){let f=await Se(e,r,i,O),b={type:"messageLabelChanged",emailAddress:i,historyId:d,message:f.message??{}};return await D(e,"gmail.webhook.messageLabelChanged",{...b},"completed"),{success:!0,corsairEntityId:f.corsairEntityId,data:b}}if(h.length>0){let f=await Le(e,r,i,h),b={type:"messageReceived",emailAddress:i,historyId:d,message:f.message??{}};return await D(e,"gmail.webhook.messageReceived",{...b},"completed"),{success:!0,corsairEntityId:f.corsairEntityId,data:b}}if(A.length>0){let f=await qt(e,r,i,A),b={type:"messageDeleted",emailAddress:i,historyId:d,message:f.message??{}};return await D(e,"gmail.webhook.messageDeleted",{...b},"completed"),{success:!0,corsairEntityId:f.corsairEntityId,data:b}}let{added:W,modified:H}=await Nt(e,r,i,d);if(H.length>0){let f=await Se(e,r,i,H),b={type:"messageLabelChanged",emailAddress:i,historyId:d,message:f.message??{}};return await D(e,"gmail.webhook.messageLabelChanged",{...b},"completed"),{success:!0,corsairEntityId:f.corsairEntityId,data:b}}if(W.length>0){let f=await Le(e,r,i,W),b={type:"messageReceived",emailAddress:i,historyId:d,message:f.message??{}};return await D(e,"gmail.webhook.messageReceived",{...b},"completed"),{success:!0,corsairEntityId:f.corsairEntityId,data:b}}return{success:!0,corsairEntityId:"",data:{type:"messageReceived",emailAddress:i,historyId:d,message:{}}}}catch(p){return console.error("Failed to process Gmail webhook:",p),{success:!1,error:`Failed to process message: ${p instanceof Error?p.message:"Unknown error"}`}}}};var De={messageChanged:Ce};var Wt={oauth_2:{integration:["topic_id"]}},Ht={messages:{list:G.list,get:G.get,send:G.send,delete:G.delete,modify:G.modify,batchModify:G.batchModify,trash:G.trash,untrash:G.untrash},labels:{list:S.list,get:S.get,create:S.create,update:S.update,delete:S.delete},drafts:{list:w.list,get:w.get,create:w.create,update:w.update,delete:w.delete,send:w.send},threads:{list:T.list,get:T.get,modify:T.modify,delete:T.delete,trash:T.trash,untrash:T.untrash}},zt={"messages.list":{input:c.messagesList,output:u.messagesList},"messages.get":{input:c.messagesGet,output:u.messagesGet},"messages.send":{input:c.messagesSend,output:u.messagesSend},"messages.delete":{input:c.messagesDelete,output:u.messagesDelete},"messages.modify":{input:c.messagesModify,output:u.messagesModify},"messages.batchModify":{input:c.messagesBatchModify,output:u.messagesBatchModify},"messages.trash":{input:c.messagesTrash,output:u.messagesTrash},"messages.untrash":{input:c.messagesUntrash,output:u.messagesUntrash},"labels.list":{input:c.labelsList,output:u.labelsList},"labels.get":{input:c.labelsGet,output:u.labelsGet},"labels.create":{input:c.labelsCreate,output:u.labelsCreate},"labels.update":{input:c.labelsUpdate,output:u.labelsUpdate},"labels.delete":{input:c.labelsDelete,output:u.labelsDelete},"drafts.list":{input:c.draftsList,output:u.draftsList},"drafts.get":{input:c.draftsGet,output:u.draftsGet},"drafts.create":{input:c.draftsCreate,output:u.draftsCreate},"drafts.update":{input:c.draftsUpdate,output:u.draftsUpdate},"drafts.delete":{input:c.draftsDelete,output:u.draftsDelete},"drafts.send":{input:c.draftsSend,output:u.draftsSend},"threads.list":{input:c.threadsList,output:u.threadsList},"threads.get":{input:c.threadsGet,output:u.threadsGet},"threads.modify":{input:c.threadsModify,output:u.threadsModify},"threads.delete":{input:c.threadsDelete,output:u.threadsDelete},"threads.trash":{input:c.threadsTrash,output:u.threadsTrash},"threads.untrash":{input:c.threadsUntrash,output:u.threadsUntrash}},Ft={messageChanged:De.messageChanged},Vt={messageChanged:{description:"A Gmail message was received, deleted, or had its labels changed",payload:Te,response:Me}},Kt="oauth_2",Yt={"messages.list":{riskLevel:"read",description:"List messages in a mailbox"},"messages.get":{riskLevel:"read",description:"Get a specific message"},"messages.send":{riskLevel:"write",description:"Send an email to one or more recipients"},"messages.delete":{riskLevel:"destructive",irreversible:!0,description:"Permanently delete a message [DESTRUCTIVE \xB7 IRREVERSIBLE]"},"messages.modify":{riskLevel:"write",description:"Add or remove labels from a message"},"messages.batchModify":{riskLevel:"write",description:"Add or remove labels from multiple messages in bulk"},"messages.trash":{riskLevel:"write",description:"Move a message to the trash"},"messages.untrash":{riskLevel:"write",description:"Restore a message from the trash"},"labels.list":{riskLevel:"read",description:"List all labels in the mailbox"},"labels.get":{riskLevel:"read",description:"Get a specific label"},"labels.create":{riskLevel:"write",description:"Create a new label"},"labels.update":{riskLevel:"write",description:"Update an existing label"},"labels.delete":{riskLevel:"destructive",description:"Delete a label [DESTRUCTIVE]"},"drafts.list":{riskLevel:"read",description:"List drafts in the mailbox"},"drafts.get":{riskLevel:"read",description:"Get a specific draft"},"drafts.create":{riskLevel:"write",description:"Create a new draft"},"drafts.update":{riskLevel:"write",description:"Update an existing draft"},"drafts.delete":{riskLevel:"destructive",description:"Delete a draft [DESTRUCTIVE]"},"drafts.send":{riskLevel:"write",description:"Send a draft as an email"},"threads.list":{riskLevel:"read",description:"List threads in the mailbox"},"threads.get":{riskLevel:"read",description:"Get a specific thread"},"threads.modify":{riskLevel:"write",description:"Add or remove labels from a thread"},"threads.delete":{riskLevel:"destructive",irreversible:!0,description:"Permanently delete a thread [DESTRUCTIVE \xB7 IRREVERSIBLE]"},"threads.trash":{riskLevel:"write",description:"Move a thread to the trash"},"threads.untrash":{riskLevel:"write",description:"Restore a thread from the trash"}};function xs(e={}){let t={...e,authType:e.authType??Kt};return{id:"gmail",schema:$,options:t,authConfig:Wt,oauthConfig:{providerName:"Google",authUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",scopes:["https://www.googleapis.com/auth/gmail.modify","https://www.googleapis.com/auth/gmail.labels","https://www.googleapis.com/auth/gmail.send","https://www.googleapis.com/auth/gmail.compose"],authParams:{access_type:"offline",prompt:"consent"}},hooks:t.hooks,webhookHooks:t.webhookHooks,endpoints:Ht,webhooks:Ft,endpointMeta:Yt,endpointSchemas:zt,webhookSchemas:Vt,keyBuilder:async a=>{if(t.key)return t.key;if(a.authType==="oauth_2"){let[o,r,i]=await Promise.all([a.keys.get_access_token(),a.keys.get_expires_at(),a.keys.get_refresh_token()]);if(!i)throw new Error("[corsair:gmail] No refresh token found. Run `corsair auth --plugin=gmail` to re-authenticate.");let d=await a.keys.get_integration_credentials();if(!d.client_id||!d.client_secret)throw new Error("[corsair:gmail] Missing client_id or client_secret. Run `corsair setup --gmail` to configure credentials.");let p;try{p=await B({accessToken:o,expiresAt:r,refreshToken:i,clientId:d.client_id,clientSecret:d.client_secret})}catch(l){throw new Error(`[corsair:gmail] Failed to obtain valid access token: ${l instanceof Error?l.message:String(l)}`)}if(p.refreshed)try{await a.keys.set_access_token(p.accessToken),await a.keys.set_expires_at(String(p.expiresAt))}catch(l){throw new Error(`[corsair:gmail] Token was refreshed but failed to persist new credentials: ${l instanceof Error?l.message:String(l)}`)}return a._refreshAuth=async()=>{let l=await B({accessToken:null,expiresAt:null,refreshToken:i,clientId:d.client_id,clientSecret:d.client_secret,forceRefresh:!0});return await a.keys.set_access_token(l.accessToken),await a.keys.set_expires_at(String(l.expiresAt)),l.accessToken},p.accessToken}return""},pluginWebhookMatcher:a=>{let o=a.headers;if(!(o.from==="noreply@google.com"||typeof o["user-agent"]=="string"&&o["user-agent"].includes("APIs-Google")))return!1;let i=a.body;if(!i?.message?.data)return!1;try{let d=k(i.message.data);return!!d.emailAddress&&!!d.historyId}catch{return!1}}}}export{$ as GmailSchema,_ as createGmailWebhookMatcher,k as decodePubSubMessage,xs as gmail,Wt as gmailAuthConfig,zt as gmailEndpointSchemas,Ht as gmailEndpointsNested,Ft as gmailWebhooksNested};
@@ -0,0 +1,115 @@
1
+ import { z } from 'zod';
2
+ export declare const GmailMessage: z.ZodObject<{
3
+ id: z.ZodString;
4
+ threadId: z.ZodOptional<z.ZodString>;
5
+ labelIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
6
+ snippet: z.ZodOptional<z.ZodString>;
7
+ historyId: z.ZodOptional<z.ZodString>;
8
+ internalDate: z.ZodOptional<z.ZodString>;
9
+ sizeEstimate: z.ZodOptional<z.ZodNumber>;
10
+ payload: z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>;
11
+ raw: z.ZodOptional<z.ZodString>;
12
+ subject: z.ZodOptional<z.ZodString>;
13
+ body: z.ZodOptional<z.ZodString>;
14
+ from: z.ZodOptional<z.ZodString>;
15
+ to: z.ZodOptional<z.ZodString>;
16
+ createdAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
17
+ }, "strip", z.ZodTypeAny, {
18
+ id: string;
19
+ from?: string | undefined;
20
+ body?: string | undefined;
21
+ payload?: any;
22
+ labelIds?: string[] | undefined;
23
+ raw?: string | undefined;
24
+ threadId?: string | undefined;
25
+ snippet?: string | undefined;
26
+ historyId?: string | undefined;
27
+ internalDate?: string | undefined;
28
+ sizeEstimate?: number | undefined;
29
+ subject?: string | undefined;
30
+ to?: string | undefined;
31
+ createdAt?: Date | null | undefined;
32
+ }, {
33
+ id: string;
34
+ from?: string | undefined;
35
+ body?: string | undefined;
36
+ payload?: any;
37
+ labelIds?: string[] | undefined;
38
+ raw?: string | undefined;
39
+ threadId?: string | undefined;
40
+ snippet?: string | undefined;
41
+ historyId?: string | undefined;
42
+ internalDate?: string | undefined;
43
+ sizeEstimate?: number | undefined;
44
+ subject?: string | undefined;
45
+ to?: string | undefined;
46
+ createdAt?: Date | null | undefined;
47
+ }>;
48
+ export declare const GmailLabel: z.ZodObject<{
49
+ id: z.ZodString;
50
+ name: z.ZodOptional<z.ZodString>;
51
+ messageListVisibility: z.ZodOptional<z.ZodEnum<["show", "hide"]>>;
52
+ labelListVisibility: z.ZodOptional<z.ZodEnum<["labelShow", "labelShowIfUnread", "labelHide"]>>;
53
+ type: z.ZodOptional<z.ZodEnum<["system", "user"]>>;
54
+ messagesTotal: z.ZodOptional<z.ZodNumber>;
55
+ messagesUnread: z.ZodOptional<z.ZodNumber>;
56
+ threadsTotal: z.ZodOptional<z.ZodNumber>;
57
+ threadsUnread: z.ZodOptional<z.ZodNumber>;
58
+ createdAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
59
+ }, "strip", z.ZodTypeAny, {
60
+ id: string;
61
+ name?: string | undefined;
62
+ type?: "system" | "user" | undefined;
63
+ messageListVisibility?: "show" | "hide" | undefined;
64
+ labelListVisibility?: "labelShow" | "labelShowIfUnread" | "labelHide" | undefined;
65
+ messagesTotal?: number | undefined;
66
+ messagesUnread?: number | undefined;
67
+ threadsTotal?: number | undefined;
68
+ threadsUnread?: number | undefined;
69
+ createdAt?: Date | null | undefined;
70
+ }, {
71
+ id: string;
72
+ name?: string | undefined;
73
+ type?: "system" | "user" | undefined;
74
+ messageListVisibility?: "show" | "hide" | undefined;
75
+ labelListVisibility?: "labelShow" | "labelShowIfUnread" | "labelHide" | undefined;
76
+ messagesTotal?: number | undefined;
77
+ messagesUnread?: number | undefined;
78
+ threadsTotal?: number | undefined;
79
+ threadsUnread?: number | undefined;
80
+ createdAt?: Date | null | undefined;
81
+ }>;
82
+ export declare const GmailDraft: z.ZodObject<{
83
+ id: z.ZodString;
84
+ messageId: z.ZodOptional<z.ZodString>;
85
+ createdAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
86
+ }, "strip", z.ZodTypeAny, {
87
+ id: string;
88
+ createdAt?: Date | null | undefined;
89
+ messageId?: string | undefined;
90
+ }, {
91
+ id: string;
92
+ createdAt?: Date | null | undefined;
93
+ messageId?: string | undefined;
94
+ }>;
95
+ export declare const GmailThread: z.ZodObject<{
96
+ id: z.ZodString;
97
+ snippet: z.ZodOptional<z.ZodString>;
98
+ historyId: z.ZodOptional<z.ZodString>;
99
+ createdAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ id: string;
102
+ snippet?: string | undefined;
103
+ historyId?: string | undefined;
104
+ createdAt?: Date | null | undefined;
105
+ }, {
106
+ id: string;
107
+ snippet?: string | undefined;
108
+ historyId?: string | undefined;
109
+ createdAt?: Date | null | undefined;
110
+ }>;
111
+ export type GmailMessage = z.infer<typeof GmailMessage>;
112
+ export type GmailLabel = z.infer<typeof GmailLabel>;
113
+ export type GmailDraft = z.infer<typeof GmailDraft>;
114
+ export type GmailThread = z.infer<typeof GmailThread>;
115
+ //# sourceMappingURL=database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../schema/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwBxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAevB,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAarB,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;EAIrB,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;EAKtB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AACpD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AACpD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -0,0 +1,133 @@
1
+ import { z } from 'zod';
2
+ export declare const GmailCredentials: z.ZodObject<{
3
+ clientId: z.ZodString;
4
+ clientSecret: z.ZodString;
5
+ accessToken: z.ZodString;
6
+ refreshToken: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ accessToken: string;
9
+ clientId: string;
10
+ clientSecret: string;
11
+ refreshToken: string;
12
+ }, {
13
+ accessToken: string;
14
+ clientId: string;
15
+ clientSecret: string;
16
+ refreshToken: string;
17
+ }>;
18
+ export type GmailCredentials = z.infer<typeof GmailCredentials>;
19
+ export declare const GmailSchema: {
20
+ readonly version: "1.0.0";
21
+ readonly entities: {
22
+ readonly messages: z.ZodObject<{
23
+ id: z.ZodString;
24
+ threadId: z.ZodOptional<z.ZodString>;
25
+ labelIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
26
+ snippet: z.ZodOptional<z.ZodString>;
27
+ historyId: z.ZodOptional<z.ZodString>;
28
+ internalDate: z.ZodOptional<z.ZodString>;
29
+ sizeEstimate: z.ZodOptional<z.ZodNumber>;
30
+ payload: z.ZodOptional<z.ZodType<any, z.ZodTypeDef, any>>;
31
+ raw: z.ZodOptional<z.ZodString>;
32
+ subject: z.ZodOptional<z.ZodString>;
33
+ body: z.ZodOptional<z.ZodString>;
34
+ from: z.ZodOptional<z.ZodString>;
35
+ to: z.ZodOptional<z.ZodString>;
36
+ createdAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
37
+ }, "strip", z.ZodTypeAny, {
38
+ id: string;
39
+ from?: string | undefined;
40
+ body?: string | undefined;
41
+ payload?: any;
42
+ labelIds?: string[] | undefined;
43
+ raw?: string | undefined;
44
+ threadId?: string | undefined;
45
+ snippet?: string | undefined;
46
+ historyId?: string | undefined;
47
+ internalDate?: string | undefined;
48
+ sizeEstimate?: number | undefined;
49
+ subject?: string | undefined;
50
+ to?: string | undefined;
51
+ createdAt?: Date | null | undefined;
52
+ }, {
53
+ id: string;
54
+ from?: string | undefined;
55
+ body?: string | undefined;
56
+ payload?: any;
57
+ labelIds?: string[] | undefined;
58
+ raw?: string | undefined;
59
+ threadId?: string | undefined;
60
+ snippet?: string | undefined;
61
+ historyId?: string | undefined;
62
+ internalDate?: string | undefined;
63
+ sizeEstimate?: number | undefined;
64
+ subject?: string | undefined;
65
+ to?: string | undefined;
66
+ createdAt?: Date | null | undefined;
67
+ }>;
68
+ readonly labels: z.ZodObject<{
69
+ id: z.ZodString;
70
+ name: z.ZodOptional<z.ZodString>;
71
+ messageListVisibility: z.ZodOptional<z.ZodEnum<["show", "hide"]>>;
72
+ labelListVisibility: z.ZodOptional<z.ZodEnum<["labelShow", "labelShowIfUnread", "labelHide"]>>;
73
+ type: z.ZodOptional<z.ZodEnum<["system", "user"]>>;
74
+ messagesTotal: z.ZodOptional<z.ZodNumber>;
75
+ messagesUnread: z.ZodOptional<z.ZodNumber>;
76
+ threadsTotal: z.ZodOptional<z.ZodNumber>;
77
+ threadsUnread: z.ZodOptional<z.ZodNumber>;
78
+ createdAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
79
+ }, "strip", z.ZodTypeAny, {
80
+ id: string;
81
+ name?: string | undefined;
82
+ type?: "system" | "user" | undefined;
83
+ messageListVisibility?: "show" | "hide" | undefined;
84
+ labelListVisibility?: "labelShow" | "labelShowIfUnread" | "labelHide" | undefined;
85
+ messagesTotal?: number | undefined;
86
+ messagesUnread?: number | undefined;
87
+ threadsTotal?: number | undefined;
88
+ threadsUnread?: number | undefined;
89
+ createdAt?: Date | null | undefined;
90
+ }, {
91
+ id: string;
92
+ name?: string | undefined;
93
+ type?: "system" | "user" | undefined;
94
+ messageListVisibility?: "show" | "hide" | undefined;
95
+ labelListVisibility?: "labelShow" | "labelShowIfUnread" | "labelHide" | undefined;
96
+ messagesTotal?: number | undefined;
97
+ messagesUnread?: number | undefined;
98
+ threadsTotal?: number | undefined;
99
+ threadsUnread?: number | undefined;
100
+ createdAt?: Date | null | undefined;
101
+ }>;
102
+ readonly drafts: z.ZodObject<{
103
+ id: z.ZodString;
104
+ messageId: z.ZodOptional<z.ZodString>;
105
+ createdAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
106
+ }, "strip", z.ZodTypeAny, {
107
+ id: string;
108
+ createdAt?: Date | null | undefined;
109
+ messageId?: string | undefined;
110
+ }, {
111
+ id: string;
112
+ createdAt?: Date | null | undefined;
113
+ messageId?: string | undefined;
114
+ }>;
115
+ readonly threads: z.ZodObject<{
116
+ id: z.ZodString;
117
+ snippet: z.ZodOptional<z.ZodString>;
118
+ historyId: z.ZodOptional<z.ZodString>;
119
+ createdAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
120
+ }, "strip", z.ZodTypeAny, {
121
+ id: string;
122
+ snippet?: string | undefined;
123
+ historyId?: string | undefined;
124
+ createdAt?: Date | null | undefined;
125
+ }, {
126
+ id: string;
127
+ snippet?: string | undefined;
128
+ historyId?: string | undefined;
129
+ createdAt?: Date | null | undefined;
130
+ }>;
131
+ };
132
+ };
133
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAK3B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQd,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("tsup").Options | import("tsup").Options[] | ((overrideOptions: import("tsup").Options) => import("tsup").Options | import("tsup").Options[] | Promise<import("tsup").Options | import("tsup").Options[]>);
2
+ export default _default;
3
+ //# sourceMappingURL=tsup.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsup.config.d.ts","sourceRoot":"","sources":["../tsup.config.ts"],"names":[],"mappings":";AAEA,wBAYG"}
@@ -0,0 +1,119 @@
1
+ export type MessagePartHeader = {
2
+ name?: string;
3
+ value?: string;
4
+ };
5
+ export type MessagePartBody = {
6
+ attachmentId?: string;
7
+ size?: number;
8
+ data?: string;
9
+ };
10
+ export type MessagePart = {
11
+ partId?: string;
12
+ mimeType?: string;
13
+ filename?: string;
14
+ headers?: MessagePartHeader[];
15
+ body?: MessagePartBody;
16
+ parts?: MessagePart[];
17
+ };
18
+ export type Message = {
19
+ id?: string;
20
+ threadId?: string;
21
+ labelIds?: string[];
22
+ snippet?: string;
23
+ historyId?: string;
24
+ internalDate?: string;
25
+ payload?: MessagePart;
26
+ sizeEstimate?: number;
27
+ raw?: string;
28
+ };
29
+ export type MessageListResponse = {
30
+ messages?: Message[];
31
+ nextPageToken?: string;
32
+ resultSizeEstimate?: number;
33
+ };
34
+ export type ModifyMessageRequest = {
35
+ addLabelIds?: string[];
36
+ removeLabelIds?: string[];
37
+ };
38
+ export type BatchModifyMessagesRequest = {
39
+ ids?: string[];
40
+ addLabelIds?: string[];
41
+ removeLabelIds?: string[];
42
+ };
43
+ export type LabelColor = {
44
+ textColor?: string;
45
+ backgroundColor?: string;
46
+ };
47
+ export type Label = {
48
+ id?: string;
49
+ name?: string;
50
+ messageListVisibility?: 'show' | 'hide';
51
+ labelListVisibility?: 'labelShow' | 'labelShowIfUnread' | 'labelHide';
52
+ type?: 'system' | 'user';
53
+ messagesTotal?: number;
54
+ messagesUnread?: number;
55
+ threadsTotal?: number;
56
+ threadsUnread?: number;
57
+ color?: LabelColor;
58
+ };
59
+ export type LabelListResponse = {
60
+ labels?: Label[];
61
+ };
62
+ export type Draft = {
63
+ id?: string;
64
+ message?: Message;
65
+ };
66
+ export type DraftListResponse = {
67
+ drafts?: Draft[];
68
+ nextPageToken?: string;
69
+ resultSizeEstimate?: number;
70
+ };
71
+ export type Thread = {
72
+ id?: string;
73
+ snippet?: string;
74
+ historyId?: string;
75
+ messages?: Message[];
76
+ };
77
+ export type ThreadListResponse = {
78
+ threads?: Thread[];
79
+ nextPageToken?: string;
80
+ resultSizeEstimate?: number;
81
+ };
82
+ export type ModifyThreadRequest = {
83
+ addLabelIds?: string[];
84
+ removeLabelIds?: string[];
85
+ };
86
+ export type HistoryMessageAdded = {
87
+ message?: Message;
88
+ };
89
+ export type HistoryMessageDeleted = {
90
+ message?: Message;
91
+ };
92
+ export type HistoryLabelAdded = {
93
+ message?: Message;
94
+ labelIds?: string[];
95
+ };
96
+ export type HistoryLabelRemoved = {
97
+ message?: Message;
98
+ labelIds?: string[];
99
+ };
100
+ export type History = {
101
+ id?: string;
102
+ messages?: Message[];
103
+ messagesAdded?: HistoryMessageAdded[];
104
+ messagesDeleted?: HistoryMessageDeleted[];
105
+ labelsAdded?: HistoryLabelAdded[];
106
+ labelsRemoved?: HistoryLabelRemoved[];
107
+ };
108
+ export type HistoryListResponse = {
109
+ history?: History[];
110
+ nextPageToken?: string;
111
+ historyId?: string;
112
+ };
113
+ export type Profile = {
114
+ emailAddress?: string;
115
+ messagesTotal?: number;
116
+ threadsTotal?: number;
117
+ historyId?: string;
118
+ };
119
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 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B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC"}
@@ -0,0 +1,42 @@
1
+ export declare const MessageWebhooks: {
2
+ messageChanged: {
3
+ match: import("corsair/core").CorsairWebhookMatcher;
4
+ handler: import("corsair/core").CorsairWebhookHandler<import("..").GmailContext, import("./types").GmailWebhookPayload<{
5
+ message: import("..").Message;
6
+ type: "messageReceived";
7
+ historyId: string;
8
+ emailAddress: string;
9
+ } | {
10
+ message: import("..").Message;
11
+ type: "messageDeleted";
12
+ historyId: string;
13
+ emailAddress: string;
14
+ } | {
15
+ message: import("..").Message;
16
+ type: "messageLabelChanged";
17
+ historyId: string;
18
+ emailAddress: string;
19
+ labelsAdded?: string[] | undefined;
20
+ labelsRemoved?: string[] | undefined;
21
+ }>, {
22
+ message: import("..").Message;
23
+ type: "messageReceived";
24
+ historyId: string;
25
+ emailAddress: string;
26
+ } | {
27
+ message: import("..").Message;
28
+ type: "messageDeleted";
29
+ historyId: string;
30
+ emailAddress: string;
31
+ } | {
32
+ message: import("..").Message;
33
+ type: "messageLabelChanged";
34
+ historyId: string;
35
+ emailAddress: string;
36
+ labelsAdded?: string[] | undefined;
37
+ labelsRemoved?: string[] | undefined;
38
+ }>;
39
+ };
40
+ };
41
+ export * from './types';
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../webhooks/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAE3B,CAAC;AAEF,cAAc,SAAS,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { GmailWebhooks } from '..';
2
+ export declare const messageChanged: GmailWebhooks['messageChanged'];
3
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../webhooks/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AA2dxC,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC,gBAAgB,CAkN1D,CAAC"}