Documentation
¶
Index ¶
- Constants
- Variables
- func ClearRecentMessages() error
- func IsArchiveAlias(mailboxName string) bool
- func IsNotFound(err error) bool
- func RecordRecentMessage(message Message, action string) error
- func RecordRecentSearchResults(messages []Message, query string) error
- func RemoveRecentMessage(account, messageID string) error
- func UpdateRecentMessageLocation(account, messageID, mailbox, action string) error
- func ValidateRuleInput(input RuleInput) error
- type Account
- type Attachment
- type AutomationLockTimeoutError
- type AutomationTimeoutError
- type Client
- func (c *Client) ArchiveMessage(accountName, mailboxName, messageID string) error
- func (c *Client) ArchiveMessageWithDestination(accountName, mailboxName, messageID string) (string, error)
- func (c *Client) BulkArchiveMessages(requests []struct{ ... }) error
- func (c *Client) BulkDeleteMessages(requests []struct{ ... }) error
- func (c *Client) BulkFlagMessages(requests []struct{ ... }) error
- func (c *Client) BulkMarkMessages(requests []struct{ ... }) error
- func (c *Client) BulkMoveMessages(requests []struct{ ... }) error
- func (c *Client) CheckAccountAccess(timeout time.Duration) (int, error)
- func (c *Client) CheckAutomationAccess(timeout time.Duration) error
- func (c *Client) CheckEnvelopeIndex() error
- func (c *Client) CheckMailBridge() error
- func (c *Client) CreateDraft(input DraftInput) (*Message, error)
- func (c *Client) CreateRule(input RuleInput) (*Rule, error)
- func (c *Client) DeleteDraft(accountName, draftID string) error
- func (c *Client) DeleteMessage(accountName, mailboxName, messageID string) error
- func (c *Client) DeleteMessageResolved(accountName, mailboxName, messageID string) error
- func (c *Client) DeleteRule(name string) error
- func (c *Client) FlagMessage(accountName, mailboxName, messageID string, flagged bool) error
- func (c *Client) GetAccounts() ([]Account, error)
- func (c *Client) GetAccountsJSON() ([]Account, error)
- func (c *Client) GetAllMailboxes() ([]Mailbox, error)
- func (c *Client) GetAttachmentsJSON(accountName, mailboxName, messageID string) ([]Attachment, error)
- func (c *Client) GetDraft(accountName, draftID string) (*Message, error)
- func (c *Client) GetMailboxes(accountName string) ([]Mailbox, error)
- func (c *Client) GetMailboxesJSON(accountName string) ([]Mailbox, error)
- func (c *Client) GetMessageDetailsForVerificationJSON(accountName, mailboxName, messageID string) (*Message, error)
- func (c *Client) GetMessageDetailsJSON(accountName, mailboxName, messageID string) (*Message, error)
- func (c *Client) GetMessages(accountName, mailboxName string, limit int) ([]Message, error)
- func (c *Client) GetMessagesFromMultipleMailboxes(requests []struct{ ... }) ([]Message, error)
- func (c *Client) GetMessagesJSON(accountName, mailboxName string, limit, offset int, ...) ([]Message, error)
- func (c *Client) GetMultipleMessageDetails(requests []struct{ ... }) ([]*Message, error)
- func (c *Client) GetUnifiedMessagesJSON(mailboxType string, limit, offset int, withContent bool) ([]Message, error)
- func (c *Client) GetUnreadCount() (int, error)
- func (c *Client) ListRules() ([]Rule, error)
- func (c *Client) ListSignatures(includeContent bool) ([]Signature, error)
- func (c *Client) ListSmartMailboxes() ([]SmartMailbox, error)
- func (c *Client) LocateMessage(id string) (*MessageLocation, error)
- func (c *Client) LocateMessages(ids []string) (map[string]MessageLocation, error)
- func (c *Client) MarkMessageAsRead(accountName, mailboxName, messageID string, read bool) error
- func (c *Client) MoveMessage(accountName, sourceMailbox, messageID, targetMailbox string) error
- func (c *Client) PrimeAccounts(accounts []Account)
- func (c *Client) RecordRecentEnvelope(accountName, mailboxName, messageID, action string) error
- func (c *Client) RunLiveProbe(timeout time.Duration) error
- func (c *Client) SaveAttachment(accountName, mailboxName, messageID, attachmentName, savePath string) error
- func (c *Client) SaveAttachmentByIndex(accountName, mailboxName, messageID, attachmentName string, index int, ...) error
- func (c *Client) SearchMessages(query string, limit int) ([]Message, error)
- func (c *Client) SearchMessagesJSON(query string, accountName string, mailboxName string, limit int) ([]Message, error)
- func (c *Client) SearchMessagesJSONSince(query string, accountName string, mailboxName string, limit int, since string) ([]Message, error)
- func (c *Client) SearchMessagesJSONSinceWithOptions(query string, accountName string, mailboxName string, limit int, since string, ...) (SearchResult, error)
- func (c *Client) SendDraft(accountName, draftID string) error
- func (c *Client) SendMessage(accountName, subject, body string, to, cc, bcc, attachments []string) error
- func (c *Client) SetRuleEnabled(name string, enabled bool) error
- func (c *Client) SignatureByName(name string) (*Signature, error)
- func (c *Client) SyncAccount(accountName string) error
- func (c *Client) SyncAllAccounts() error
- func (c *Client) UpdateDraft(accountName, draftID string, input DraftInput) (*Message, error)
- type DraftInput
- type Mailbox
- type Message
- type MessageLocation
- type NotFoundError
- type PartialSearchError
- type RecentMessage
- type Rule
- type RuleInput
- type SearchMailbox
- type SearchMailboxFailure
- type SearchOptions
- type SearchResult
- type Signature
- type SmartMailbox
Constants ¶
const DoctorProbeTimeout = 3 * time.Second
DoctorProbeTimeout bounds each read-only Mail.app diagnostic. Keeping the probes separate lets doctor report partial diagnostics when one Mail.app API surface is unavailable.
const SchemaVersion = 1
SchemaVersion identifies the JSON shape of every structured value this package emits. Bump it when a field is renamed or removed.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is the sentinel every lookup failure unwraps to, so callers can classify with errors.Is without matching message text.
Warn receives every non-fatal warning this package would otherwise print to stderr (index fallback, content budget, journal cleanup). The CLI replaces it so warnings land in the JSON envelope's notices instead of interleaving with structured output.
Functions ¶
func ClearRecentMessages ¶
func ClearRecentMessages() error
func IsArchiveAlias ¶
IsArchiveAlias reports whether a mailbox name refers to Gmail's All Mail or a generic Archive mailbox.
func IsNotFound ¶
IsNotFound reports whether err is a typed lookup failure or one of the automation bridge's "Error: ... not found" strings.
func RecordRecentMessage ¶
func RemoveRecentMessage ¶
func ValidateRuleInput ¶
ValidateRuleInput verifies the complete input contract before a rule is created. Callers should use it for dry runs as well as live rule creation.
Types ¶
type Attachment ¶
type AutomationLockTimeoutError ¶
AutomationLockTimeoutError reports a command that could not enter the serialized automation queue within its bounded wait period.
func (*AutomationLockTimeoutError) Error ¶
func (e *AutomationLockTimeoutError) Error() string
func (*AutomationLockTimeoutError) Unwrap ¶
func (e *AutomationLockTimeoutError) Unwrap() error
type AutomationTimeoutError ¶
AutomationTimeoutError reports a bounded Mail.app automation invocation that did not complete. It unwraps to context.DeadlineExceeded so callers can classify it with errors.Is, and exposes the engine and configured timeout for human-readable diagnostics.
func (*AutomationTimeoutError) Error ¶
func (e *AutomationTimeoutError) Error() string
func (*AutomationTimeoutError) Unwrap ¶
func (e *AutomationTimeoutError) Unwrap() error
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ArchiveMessage ¶
func (*Client) ArchiveMessageWithDestination ¶
func (*Client) BulkArchiveMessages ¶
func (*Client) BulkDeleteMessages ¶
func (*Client) BulkFlagMessages ¶
func (*Client) BulkMarkMessages ¶
func (*Client) BulkMoveMessages ¶
func (*Client) CheckAccountAccess ¶
CheckAccountAccess verifies read access to the account collection and returns only its count, not account names or addresses.
func (*Client) CheckAutomationAccess ¶
CheckAutomationAccess verifies that the automation bridge can read a harmless Mail.app property. It is deliberately separate from the bridge probe because an installed application can still deny automation access.
func (*Client) CheckEnvelopeIndex ¶
func (*Client) CheckMailBridge ¶
CheckMailBridge verifies that the local Mail.app bundle is present without issuing an Apple Event. Automation permission is checked independently so a denied permission cannot be mistaken for a missing Mail installation.
func (*Client) CreateDraft ¶
func (c *Client) CreateDraft(input DraftInput) (*Message, error)
func (*Client) DeleteDraft ¶
func (*Client) DeleteMessage ¶
func (*Client) DeleteMessageResolved ¶
func (*Client) DeleteRule ¶
func (*Client) FlagMessage ¶
func (*Client) GetAccounts ¶
func (*Client) GetAccountsJSON ¶
func (*Client) GetAllMailboxes ¶
func (*Client) GetAttachmentsJSON ¶
func (c *Client) GetAttachmentsJSON(accountName, mailboxName, messageID string) ([]Attachment, error)
func (*Client) GetMailboxesJSON ¶
func (*Client) GetMessageDetailsForVerificationJSON ¶
func (c *Client) GetMessageDetailsForVerificationJSON(accountName, mailboxName, messageID string) (*Message, error)
GetMessageDetailsForVerificationJSON reads a message for a post-mutation verification. Unlike GetMessageDetailsJSON, it deliberately lets failures resolving the account, mailbox, or message properties reach osascript. A nil message is therefore proof that the message is absent, rather than a catch-all result for an automation failure.
func (*Client) GetMessageDetailsJSON ¶
func (*Client) GetMessages ¶
func (*Client) GetMessagesFromMultipleMailboxes ¶
func (*Client) GetMessagesJSON ¶
func (*Client) GetMultipleMessageDetails ¶
func (*Client) GetUnifiedMessagesJSON ¶
func (*Client) GetUnreadCount ¶
func (*Client) ListSignatures ¶
func (*Client) ListSmartMailboxes ¶
func (c *Client) ListSmartMailboxes() ([]SmartMailbox, error)
func (*Client) LocateMessage ¶
func (c *Client) LocateMessage(id string) (*MessageLocation, error)
LocateMessage resolves one ID. It returns a NotFoundError when the index has no live row for it.
func (*Client) LocateMessages ¶
func (c *Client) LocateMessages(ids []string) (map[string]MessageLocation, error)
LocateMessages resolves message IDs to accounts and mailboxes using the Envelope Index. IDs that are not in the index are absent from the result. The error is non-nil only when the index itself could not be queried.
func (*Client) MarkMessageAsRead ¶
func (*Client) MoveMessage ¶
func (*Client) PrimeAccounts ¶
PrimeAccounts seeds the in-process account cache so callers holding a fresh on-disk copy can avoid a Mail.app round trip.
func (*Client) RecordRecentEnvelope ¶
func (*Client) RunLiveProbe ¶
RunLiveProbe performs a bounded, read-only query against Mail.app. It is intentionally independent of account enumeration so doctor does not infer live bridge health from a cached or index-backed result.
func (*Client) SaveAttachment ¶
func (*Client) SaveAttachmentByIndex ¶
func (*Client) SearchMessages ¶
func (*Client) SearchMessagesJSON ¶
func (*Client) SearchMessagesJSONSince ¶
func (*Client) SearchMessagesJSONSinceWithOptions ¶
func (c *Client) SearchMessagesJSONSinceWithOptions(query string, accountName string, mailboxName string, limit int, since string, options SearchOptions) (SearchResult, error)
SearchMessagesJSONSinceWithOptions searches the requested mailbox scope and records its completeness. Cross-mailbox searches fail closed unless AllowPartial is set.
func (*Client) SendMessage ¶
func (*Client) SyncAccount ¶
func (*Client) SyncAllAccounts ¶
func (*Client) UpdateDraft ¶
func (c *Client) UpdateDraft(accountName, draftID string, input DraftInput) (*Message, error)
type DraftInput ¶
type DraftInput struct {
Account string `json:"account"`
Subject string `json:"subject"`
Body string `json:"body"`
To []string `json:"to"`
Cc []string `json:"cc,omitempty"`
Bcc []string `json:"bcc,omitempty"`
Attachments []string `json:"attachments,omitempty"`
SubjectSet bool `json:"-"`
BodySet bool `json:"-"`
}
type Message ¶
type Message struct {
ID string `json:"id"`
Subject string `json:"subject"`
Sender string `json:"sender"`
DateSent string `json:"dateSent"`
DateReceived string `json:"dateReceived"`
Read bool `json:"read"`
Flagged bool `json:"flagged"`
Deleted bool `json:"deleted"`
MessageSize int `json:"messageSize"`
Content string `json:"content"`
Mailbox string `json:"mailbox"`
Account string `json:"account"`
ToRecipients []string `json:"toRecipients"`
CcRecipients []string `json:"ccRecipients"`
BccRecipients []string `json:"bccRecipients"`
}
func SearchRecentMessages ¶
func (Message) MarshalJSON ¶
MarshalJSON keeps recipient lists as arrays so consumers can always iterate them; a nil slice would otherwise serialize as null.
type MessageLocation ¶
type MessageLocation struct {
ID string `json:"id"`
Account string `json:"account"`
Mailbox string `json:"mailbox"`
BackingMailbox string `json:"backingMailbox"`
// ArchiveMailbox is where an archive should act from: INBOX when the
// message carries that label, otherwise the backing mailbox. Archiving
// from a user label would strip the label instead of leaving INBOX.
ArchiveMailbox string `json:"archiveMailbox"`
Labels []string `json:"labels"`
Envelope Message `json:"-"`
}
MessageLocation is where a message can be reached through Mail.app's scripting bridge. Mailbox is the mailbox a mutation should target: for a Gmail account that is the INBOX label when the message carries it, because archiving means moving out of INBOX. BackingMailbox is the row the Envelope Index stores the message under (All Mail for labelled Gmail messages).
type NotFoundError ¶
NotFoundError names the kind of object that was missing and the selector that was used, for example ("message", "123") or ("account", "Work").
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
func (*NotFoundError) Unwrap ¶
func (e *NotFoundError) Unwrap() error
type PartialSearchError ¶
type PartialSearchError struct {
Result SearchResult
}
PartialSearchError means one or more mailboxes were unavailable. Its Result is populated so callers that deliberately opted in can inspect the precise scope of the incomplete result.
func (*PartialSearchError) Error ¶
func (e *PartialSearchError) Error() string
type RecentMessage ¶
type RecentMessage struct {
ID string `json:"id"`
Account string `json:"account"`
Mailbox string `json:"mailbox"`
OriginalMailbox string `json:"originalMailbox,omitempty"`
Subject string `json:"subject"`
Sender string `json:"sender"`
DateReceived string `json:"dateReceived"`
DateSent string `json:"dateSent"`
Read bool `json:"read"`
Flagged bool `json:"flagged"`
Deleted bool `json:"deleted,omitempty"`
MessageSize int `json:"messageSize"`
SearchTerms []string `json:"searchTerms,omitempty"`
LastAction string `json:"lastAction"`
LastSeenAt string `json:"lastSeenAt"`
}
func ResolveRecentMessage ¶
func ResolveRecentMessage(selector, accountName, mailboxName string) (*RecentMessage, error)
type RuleInput ¶
type RuleInput struct {
Name string `json:"name"`
Account string `json:"account,omitempty"`
FromDomain string `json:"fromDomain,omitempty"`
MoveTo string `json:"moveTo"`
Enabled bool `json:"enabled"`
SubjectContains []string `json:"subjectContains,omitempty"`
MarkRead bool `json:"markRead,omitempty"`
}
type SearchMailbox ¶
SearchMailbox identifies a mailbox included in a search attempt.
type SearchMailboxFailure ¶
type SearchMailboxFailure struct {
Account string `json:"account"`
Mailbox string `json:"mailbox"`
Error string `json:"error"`
}
SearchMailboxFailure records a mailbox that could not be searched. Error is diagnostic metadata rather than a machine-stable error code.
type SearchOptions ¶
type SearchOptions struct {
AllowPartial bool
}
SearchOptions controls the safety contract for searches that span multiple mailboxes. A partial result is unsafe for workflows such as duplicate detection, so callers must explicitly opt in before receiving one.
type SearchResult ¶
type SearchResult struct {
Messages []Message `json:"messages"`
Complete bool `json:"complete"`
SearchedMailboxes []SearchMailbox `json:"searchedMailboxes"`
FailedMailboxes []SearchMailboxFailure `json:"failedMailboxes"`
}
SearchResult is the structured search contract. Complete is false whenever at least one requested mailbox failed to return a result.