Documentation
¶
Index ¶
- Constants
- Variables
- func ClearRecentMessages() error
- func DeleteMutator(client *Client, item *BatchItem) error
- func GmailAccountEmail(ctx context.Context, c *Client, name string) (string, error)
- func GmailAccountEmails(ctx context.Context, c *Client, name string) ([]string, error)
- func GmailAccountSupport(ctx context.Context, c *Client, name string) error
- func IsArchiveAlias(mailboxName string) bool
- func IsNotFound(err error) bool
- func IsSpecialMailboxName(mailboxType, mailboxName string) bool
- func NormalizeThreadSubject(subject string) string
- func ParseMessageTime(value string) (time.Time, bool)
- func RecordRecentMessage(message Message, action string) error
- func RecordRecentSearchResults(messages []Message, query string) error
- func RemoveRecentMessage(account, messageID string) error
- func SenderMatches(rawSender, sender, senderDomain string) bool
- func ThreadArchiveAllowed(thread ThreadSummary) bool
- func UpdateRecentMessageLocation(account, messageID, mailbox, action string) error
- func ValidateBatchOptions(opts BatchOptions) error
- func ValidateDraftAttachments(paths []string) ([]string, error)
- func ValidateManifest(m CleanupManifest) error
- func ValidateReadCheckpoint(path string) error
- func ValidateRuleInput(input RuleInput) error
- func ValidateScanRequest(req ScanRequest) error
- func ValidateUnsubscribeScanRequest(req UnsubscribeScanRequest) error
- func VerifyMutation(client *Client, opts BatchOptions, item BatchItem) (string, error)
- type Account
- type Attachment
- type AutomationLockTimeoutError
- type AutomationPhase
- type AutomationTimeoutError
- type BackendStats
- type BatchFailedError
- type BatchItem
- type BatchJournal
- type BatchOptions
- type BatchResult
- type BodyAlternative
- type BodyDiagnostics
- type BridgePhaseError
- type CapabilityError
- type CapabilityStatus
- type CleanupManifest
- type Client
- func (c *Client) Accounts() ([]Account, error)
- func (c *Client) ArchiveMessage(accountName, mailboxName, messageID string) error
- func (c *Client) ArchiveMessageToDestination(accountName, mailboxName, messageID, destination string) error
- func (c *Client) ArchiveMessageWithDestination(accountName, mailboxName, messageID string) (string, error)
- func (c *Client) Backend() string
- 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) Context() context.Context
- 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) Done() 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) GetMessageLinksJSON(account, mailbox, id string) (*Message, error)
- func (c *Client) GetMessageStateForVerificationJSON(accountName, mailboxName, messageID string) (*Message, error)
- func (c *Client) GetMessages(accountName, mailboxName string, limit int) ([]Message, error)
- func (c *Client) GetMessagesFromMultipleMailboxes(requests []MailboxListRequest) ([]Message, error)
- func (c *Client) GetMessagesJSON(accountName, mailboxName string, limit, offset int, ...) ([]Message, error)
- func (c *Client) GetMultipleMessageDetails(requests []MessageRef) ([]*Message, error)
- func (c *Client) GetUnifiedMessagesJSON(mailboxType string, limit, offset int, withContent bool) ([]Message, error)
- func (c *Client) GetUnreadCount() (int, error)
- func (c *Client) GetUnsubscribeJSON(account, mailbox, id string) (*UnsubscribeObservation, error)
- func (c *Client) HasMessageIdentityInMailbox(accountName, mailboxName string, identity StableIdentity) (bool, error)
- func (c *Client) IsGmailArchiveAccount(account string) (bool, error)
- func (c *Client) ListMessages(req MailboxListRequest) ([]Message, error)
- func (c *Client) ListRules() ([]Rule, error)
- func (c *Client) ListSignatures(includeContent bool) ([]Signature, error)
- func (c *Client) ListSmartMailboxes() ([]SmartMailbox, error)
- func (c *Client) ListUnified(kind string, limit, offset int) ([]Message, error)
- func (c *Client) LocateMessage(id string) (*MessageLocation, error)
- func (c *Client) LocateMessages(ids []string) (map[string]MessageLocation, error)
- func (c *Client) Mailboxes(account string) ([]Mailbox, error)
- func (c *Client) MarkMessageAsRead(accountName, mailboxName, messageID string, read bool) error
- func (c *Client) MessageDetails(account, mailbox, id string) (*Message, error)
- func (c *Client) MoveMessage(accountName, sourceMailbox, messageID, targetMailbox string) error
- func (c *Client) PreviewDraftSend(accountName, draftID string) (*OutgoingResult, error)
- func (c *Client) PreviewOutgoing(input OutgoingInput) (*OutgoingResult, error)
- func (c *Client) PrimeAccounts(accounts []Account)
- func (c *Client) ReadLocalUnsubscribeMessages(messages []ScanMessage) ([]UnsubscribeObservation, error)
- func (c *Client) ReadSelectedMessages(refs []MessageRef, timeout, budget time.Duration) SelectedReadResult
- func (c *Client) ReadSelectedMessagesWithOptions(refs []MessageRef, timeout, budget time.Duration, opts SelectedReadOptions) (SelectedReadResult, error)
- func (c *Client) RecordRecentEnvelope(accountName, mailboxName, messageID, action string) error
- func (c *Client) ResetAccountCache()
- func (c *Client) ResolveArchiveMailbox(accountName string) (string, error)
- func (c *Client) ResolveTrashMailbox(accountName string) (string, error)
- func (c *Client) RunLiveProbe(timeout time.Duration) error
- func (c *Client) RunningMailProcessIDs(timeout time.Duration) ([]int, 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) SaveThreadedOutgoing(input ThreadedOutgoingInput) (*OutgoingResult, error)
- func (c *Client) ScanMessages(req ScanRequest) (ScanResult, error)
- func (c *Client) ScanUnsubscribe(req UnsubscribeScanRequest) (UnsubscribeScanResult, error)
- func (c *Client) Search(query, account string, limit int) (SearchResult, 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) SendDraftResult(accountName, draftID string) (*DraftSendResult, error)
- func (c *Client) SendMessage(accountName, subject, body string, to, cc, bcc, attachments []string) error
- func (c *Client) SendOutgoing(input OutgoingInput) (*OutgoingResult, error)
- func (c *Client) SendThreadedOutgoing(input ThreadedOutgoingInput) (*OutgoingResult, error)
- func (c *Client) SetBackend(backend string) error
- func (c *Client) SetBodyAlternatives(include bool)
- func (c *Client) SetBodySource(source string) error
- func (c *Client) SetRuleEnabled(name string, enabled bool) error
- func (c *Client) SetWarn(fn func(string))
- 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)
- func (c *Client) WithContext(ctx context.Context) *Client
- func (c *Client) WithSendingDisabled() *Client
- type DraftInput
- type DraftSendResult
- type GmailLabelError
- type GmailLabelRequest
- type GmailLabelResult
- type GmailLabelSnapshot
- type GmailLabelWorkflow
- func (w *GmailLabelWorkflow) Change(ctx context.Context, r GmailLabelRequest) (GmailLabelResult, error)
- func (w *GmailLabelWorkflow) List(ctx context.Context, account string) ([]gmail.Label, error)
- func (w *GmailLabelWorkflow) Reconcile(ctx context.Context, path string) (GmailLabelResult, error)
- func (w *GmailLabelWorkflow) Show(ctx context.Context, r GmailLabelRequest) (GmailLabelResult, error)
- type LinkExtractionStatus
- type LocalReadStats
- type Mailbox
- type MailboxListRequest
- type ManifestItem
- type ManifestOutcome
- type ManifestResult
- type Message
- type MessageLink
- type MessageLocation
- type MessageReadResult
- type MessageRef
- type MessageUnsubscribe
- type MutationError
- type Mutator
- type NativeArchiveError
- type NotFoundError
- type OutgoingInput
- type OutgoingResult
- type PartialSearchError
- type PhaseTrace
- type RecentMessage
- type RelocationState
- type ReplyMode
- type Rule
- type RuleInput
- type ScanCheckpointProvenance
- type ScanCoverage
- type ScanMessage
- type ScanPosition
- type ScanRequest
- type ScanResult
- type SearchMailbox
- type SearchMailboxFailure
- type SearchOptions
- type SearchResult
- type SelectedReadOptions
- type SelectedReadResult
- type Sender
- type Signature
- type SmartMailbox
- type StableIdentity
- type ThreadSummary
- type ThreadedOutgoingInput
- type UnsubscribeDestination
- type UnsubscribeEvidence
- type UnsubscribeGroup
- type UnsubscribeObservation
- type UnsubscribeReadability
- type UnsubscribeScanRequest
- type UnsubscribeScanResult
Constants ¶
const ( BodySourceDisk = "disk" BodySourceMail = "mail" )
BodySourceDisk reads a message body from Mail.app's message file and asks Mail.app only when there is no readable file. BodySourceMail always asks Mail.app to render the body.
const BackendLegacy = "legacy"
const BackendNative = "native"
const DefaultGmailArchiveSettle = 3850 * time.Millisecond
DefaultGmailArchiveSettle retains the original 3.85-second local observation horizon. Longer evidence windows require an explicit --settle; neither is a server acknowledgement.
const DefaultVerifyBudget = 30 * time.Second
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 ErrGmailAccountUnsupported = errors.New("Mail account cannot be used for Gmail labels")
ErrGmailAccountUnsupported matches the error for a Mail account that Gmail labels cannot use: a disabled account or one that is not IMAP.
var ErrInvalidReadCheckpoint = errors.New("invalid read checkpoint")
var ErrInvalidScanCheckpoint = errors.New("invalid scan checkpoint")
var ErrInvalidScanCursor = errors.New("invalid scan cursor")
ErrInvalidScanCursor reports a cursor that is unreadable or that belongs to a different scan request.
var ErrInvalidUnsubscribeCheckpoint = errors.New("invalid unsubscribe checkpoint")
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.
var ErrSendingDisabled = errors.New("email sending is disabled")
ErrSendingDisabled means the client refused a send before contacting Mail.
Warn is the default sink for non-fatal warnings (index fallback, content budget, journal cleanup). A Client can be given its own with SetWarn.
Functions ¶
func ClearRecentMessages ¶
func ClearRecentMessages() error
func DeleteMutator ¶
DeleteMutator moves a message to the trash.
func GmailAccountEmail ¶
func GmailAccountEmails ¶
GmailAccountEmails returns actual Mail account addresses in primary/alias order, with normalized mailbox addresses and case-insensitive duplicates removed.
func GmailAccountSupport ¶ added in v3.2.2
GmailAccountSupport returns the error the label workflow returns for a disabled or non-IMAP account, or nil when the account can use Gmail labels.
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 IsSpecialMailboxName ¶
IsSpecialMailboxName reports whether a mailbox name is one of the conventional names for the sent, drafts, trash, or junk folder.
func NormalizeThreadSubject ¶
NormalizeThreadSubject strips reply and forward prefixes and collapses whitespace so replies land in the same thread.
func ParseMessageTime ¶
ParseMessageTime parses the timestamp shapes Mail.app and the Envelope Index produce.
func RecordRecentMessage ¶
func RemoveRecentMessage ¶
func SenderMatches ¶
SenderMatches reports whether a raw sender header satisfies the filters.
func ThreadArchiveAllowed ¶
func ThreadArchiveAllowed(thread ThreadSummary) bool
ThreadArchiveAllowed reports whether a thread can be archived as a unit.
func ValidateBatchOptions ¶
func ValidateBatchOptions(opts BatchOptions) error
ValidateBatchOptions runs before source resolution or any mailbox changes.
func ValidateDraftAttachments ¶
ValidateDraftAttachments resolves local paths and rejects missing, unreadable, or non-regular files before any draft is changed. Commas are literal in paths.
func ValidateManifest ¶ added in v3.3.0
func ValidateManifest(m CleanupManifest) error
func ValidateReadCheckpoint ¶ added in v3.3.0
ValidateReadCheckpoint validates the local file without accessing Mail.
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.
func ValidateScanRequest ¶
func ValidateScanRequest(req ScanRequest) error
func ValidateUnsubscribeScanRequest ¶ added in v3.1.0
func ValidateUnsubscribeScanRequest(req UnsubscribeScanRequest) error
func VerifyMutation ¶
func VerifyMutation(client *Client, opts BatchOptions, item BatchItem) (string, error)
VerifyMutation verifies one mutation for library callers. RunBatch uses VerifyMutations so a whole batch can share indexed snapshots and Gmail sync.
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 AutomationPhase ¶
type AutomationPhase struct {
Name string `json:"name"`
ElapsedMs int64 `json:"elapsedMs"`
Note string `json:"note,omitempty"`
Error string `json:"error,omitempty"`
}
AutomationPhase is one finished step of a bridge script.
type AutomationTimeoutError ¶
type AutomationTimeoutError struct {
Engine string
Timeout time.Duration
Trace *PhaseTrace
Cause error
}
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. Trace is set when the script announced phases.
func (*AutomationTimeoutError) Error ¶
func (e *AutomationTimeoutError) Error() string
func (*AutomationTimeoutError) Unwrap ¶
func (e *AutomationTimeoutError) Unwrap() error
type BackendStats ¶
type BackendStats struct {
NativeEvents int64 `json:"nativeEvents"`
NativeEventMS float64 `json:"nativeEventMs"`
NativeContentRequests int64 `json:"nativeContentRequests"`
LegacyProcesses int64 `json:"legacyProcesses"`
LegacyProcessMS float64 `json:"legacyProcessMs"`
LegacySQLiteProcesses int64 `json:"legacySQLiteProcesses"`
LegacySQLiteProcessMS float64 `json:"legacySQLiteProcessMs"`
}
func BackendStatistics ¶
func BackendStatistics() BackendStats
type BatchFailedError ¶
BatchFailedError reports mutation failures and requested verifications that remained inconclusive after the mutation was applied.
func (*BatchFailedError) Error ¶
func (e *BatchFailedError) Error() string
type BatchItem ¶
type BatchItem struct {
ID string `json:"id"`
Account string `json:"account"`
SourceMailbox string `json:"sourceMailbox"`
TargetMailbox string `json:"targetMailbox,omitempty"`
Subject string `json:"subject,omitempty"`
Sender string `json:"sender,omitempty"`
DateSent string `json:"dateSent,omitempty"`
MessageSize int `json:"messageSize,omitempty"`
GmailInboxSource bool `json:"gmailInboxSource,omitempty"`
// Identity is captured before a move so verification survives Mail.app
// assigning the logical message a new local ID.
IdentityCaptureMillis int64 `json:"identityCaptureMillis,omitempty"`
IdentityEnrichmentError string `json:"identityEnrichmentError,omitempty"`
MarkReadOnSkip bool `json:"markReadOnSkip,omitempty"`
Identity StableIdentity `json:"identity,omitempty"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
MarkedRead bool `json:"markedRead,omitempty"`
VerifyStatus string `json:"verifyStatus,omitempty"`
VerifyError string `json:"verifyError,omitempty"`
// Observed is what an archive or move verification found by stable
// identity once the mailboxes settled.
Observed *RelocationState `json:"observed,omitempty"`
}
BatchItem is one message inside a mutation receipt. The same shape is used whether one ID or five hundred were requested.
func VerifyMutations ¶
func VerifyMutations(client *Client, opts BatchOptions, items []BatchItem) []BatchItem
VerifyMutations verifies a completed mutation batch. State-only mutations share one indexed snapshot per account/mailbox instead of enumerating the entire Mail.app mailbox once per item.
type BatchJournal ¶
type BatchJournal struct {
// contains filtered or unexported fields
}
BatchJournal is an append-only, durable mutation receipt. Each line is a complete JSON object so a caller can recover the work completed before an interrupted process lost its normal stdout receipt.
func CreateBatchJournal ¶
func CreateBatchJournal(path string) (*BatchJournal, error)
CreateBatchJournal validates and creates path before any mailbox mutation. The caller owns Close.
func CreateDefaultBatchJournal ¶
func CreateDefaultBatchJournal() (*BatchJournal, error)
CreateDefaultBatchJournal creates a private, persistent receipt outside the working tree. It is the safety net for library and UI callers that do not explicitly configure a receipt path.
func (*BatchJournal) Close ¶
func (j *BatchJournal) Close() error
func (*BatchJournal) Path ¶
func (j *BatchJournal) Path() string
func (*BatchJournal) Record ¶
func (j *BatchJournal) Record(event string, fields map[string]any) error
Record appends and synchronizes one event. Syncing every event exceeds the per-chunk durability guarantee and deliberately favors recoverability over the small overhead of a bulk mutation receipt.
func (*BatchJournal) SetEvents ¶ added in v3.3.0
func (j *BatchJournal) SetEvents(w io.Writer)
SetEvents mirrors subsequent durable events to an optional progress stream.
type BatchOptions ¶
type BatchOptions struct {
// LabelResults records explicitly requested provider cleanup completed before filing.
LabelResults []GmailLabelResult
Action string
TargetMailbox string
DryRun bool
Verify bool
MarkReadBefore bool
MarkReadOnSkip bool
// Settle extends the final-observation window; zero preserves the default.
Settle time.Duration
// VerifyBudget bounds all post-mutation checks; zero uses the default.
VerifyBudget time.Duration
ChunkSize int
// MaxConsecutiveFailures stops after this many identical failures in one
// account/source scope. Zero disables the limit for library callers.
MaxConsecutiveFailures int
// ReuseBridge is for built-in JXA mutators, never custom mutators.
ReuseBridge bool
Read bool
Flagged bool
// Journal records each message in the recent-message journal. It costs
// index queries per message, so bulk selections leave it off.
Journal bool
// Progress receives per-chunk and per-message lines when non-nil.
Progress io.Writer
// Events mirrors durable receipt events as JSON lines; the receipt remains authoritative.
Events io.Writer
// TrustSource keeps each item's SourceMailbox as given. Otherwise an
// archive looks each message up in the Envelope Index and acts from
// INBOX or the backing mailbox, never from a user label, and skips
// messages that are already archived.
TrustSource bool
// ExplicitSource preserves an explicit non-Gmail source when the Envelope
// Index is unavailable. Gmail remains fail-closed because labels cannot be
// resolved safely without the index.
ExplicitSource bool
// Receipt is an append-only durable journal written before and after every
// mailbox-side phase. It is optional so library callers retain the existing
// in-memory receipt behavior.
Receipt *BatchJournal
// contains filtered or unexported fields
}
BatchOptions controls one mutation run.
type BatchResult ¶
type BatchResult struct {
Action string `json:"action"`
MarkReadRequested bool `json:"markReadRequested,omitempty"`
DryRun bool `json:"dryRun"`
StartedAt string `json:"startedAt,omitempty"`
EndedAt string `json:"endedAt,omitempty"`
ReceiptPath string `json:"receiptPath,omitempty"`
JournalError string `json:"journalError,omitempty"`
Matched int `json:"matched"`
Attempted int `json:"attempted"`
Succeeded int `json:"succeeded"`
Failed int `json:"failed"`
NotAttempted int `json:"notAttempted,omitempty"`
StoppedReason string `json:"stoppedReason,omitempty"`
LabelResults []GmailLabelResult `json:"labelResults,omitempty"`
Unverified int `json:"unverified,omitempty"`
Skipped int `json:"skipped"`
Chunks int `json:"chunks,omitempty"`
Items []BatchItem `json:"items"`
}
BatchResult is the mutation receipt.
func ReadRelocationReceipt ¶
func ReadRelocationReceipt(path string) (BatchResult, error)
ReadRelocationReceipt accepts a final receipt, CLI envelope, or durable JSON-lines journal. It never talks to Mail and refuses incomplete identities.
func ReconcileMutations ¶
func ReconcileMutations(client *Client, opts BatchOptions, receipt BatchResult) (BatchResult, error)
ReconcileMutations observes a saved receipt again without replaying any mutation. Unknown relocations can be reconciled when a pre-mutation stable identity survived; their original application status remains unchanged.
func RunBatch ¶
func RunBatch(client *Client, opts BatchOptions, items []BatchItem, mutate Mutator) (result BatchResult, retErr error)
RunBatch applies mutate to every item and returns the receipt. The error is a *BatchFailedError when at least one item failed; the receipt is always complete. Cancelling the client's context stops the run between items.
func (BatchResult) Summary ¶
func (r BatchResult) Summary(opts BatchOptions) string
Summary is the one-line human description of a receipt.
type BodyAlternative ¶
type BodyAlternative struct {
Group string `json:"group"`
Part string `json:"part"`
MediaType string `json:"mediaType"`
Selected bool `json:"selected"`
Text string `json:"text,omitempty"`
ExtractedCharCount int `json:"extractedCharCount"`
}
BodyAlternative records the independently extracted text of a direct child of multipart/alternative. Group and Part are MIME tree paths, starting at 1. Selected identifies the rendering chosen within that group by the existing extractor; in nested groups it does not imply selection by all ancestors.
type BodyDiagnostics ¶
type BodyDiagnostics struct {
ExtractionError string `json:"extractionError,omitempty"`
PartialFile bool `json:"partialFile"`
MIMEPartCount int `json:"mimePartCount"`
ImagePartCount int `json:"imagePartCount"`
NonTextPartCount int `json:"nonTextPartCount"`
AttachmentPartCount int `json:"attachmentPartCount"`
HTMLImageCount int `json:"htmlImageCount"`
HTMLImageAltTexts []string `json:"htmlImageAltTexts,omitempty"`
RichContentElements int `json:"richContentElements"`
ExtractedCharCount int `json:"extractedCharCount"`
Alternatives []BodyAlternative `json:"alternatives,omitempty"`
Warnings []string `json:"warnings,omitempty"`
// contains filtered or unexported fields
}
BodyDiagnostics describes the local MIME-to-text extraction, not whether a reader has received every substantive fact in a message. Counts include the root entity and every visited MIME part. On a parser error they describe only the portion visited before the error. No image is fetched or rendered.
type BridgePhaseError ¶
type BridgePhaseError struct {
Engine string
Phase string
Message string
Trace *PhaseTrace
}
BridgePhaseError is a Mail.app error raised inside a named script phase.
func (*BridgePhaseError) Error ¶
func (e *BridgePhaseError) Error() string
type CapabilityError ¶
type CapabilityError struct {
Capability string
Status CapabilityStatus
Cause error
}
CapabilityError keeps a feature limitation distinct from an empty result. Callers should present this as a capability failure, never as an empty list.
func (*CapabilityError) Error ¶
func (e *CapabilityError) Error() string
func (*CapabilityError) Unwrap ¶
func (e *CapabilityError) Unwrap() error
type CapabilityStatus ¶
type CapabilityStatus string
CapabilityStatus describes whether a Mail feature can be supplied by the backends this CLI is allowed to use.
const ( CapabilityUnsupported CapabilityStatus = "unsupported" )
type CleanupManifest ¶ added in v3.3.0
type CleanupManifest struct {
Version int `json:"version"`
Items []ManifestItem `json:"items"`
}
CleanupManifest is an explicit, reusable selection. Reading or applying it never discovers additional messages or changes an item's account.
func ReadManifest ¶ added in v3.3.0
func ReadManifest(path string) (CleanupManifest, error)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client reads the local index and MIME and sends changes through the selected Mail transport. Contexts bound local queries, queued automation and subprocesses.
func (*Client) ArchiveMessage ¶
func (*Client) ArchiveMessageToDestination ¶
func (c *Client) ArchiveMessageToDestination(accountName, mailboxName, messageID, destination string) error
ArchiveMessageToDestination uses the destination already persisted in a batch receipt; it never chooses a different mailbox after mutation starts.
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) GetMessageLinksJSON ¶ added in v3.1.0
GetMessageLinksJSON discovers destinations without visiting them. A usable partial local message is returned without asking Mail to render its body.
func (*Client) GetMessageStateForVerificationJSON ¶
func (c *Client) GetMessageStateForVerificationJSON(accountName, mailboxName, messageID string) (*Message, error)
GetMessageStateForVerificationJSON performs a bounded ID query through Mail.app. It is the verification fallback when the Envelope Index is not available; it never enumerates all IDs in the mailbox.
func (*Client) GetMessages ¶
func (*Client) GetMessagesFromMultipleMailboxes ¶
func (c *Client) GetMessagesFromMultipleMailboxes(requests []MailboxListRequest) ([]Message, error)
func (*Client) GetMessagesJSON ¶
func (*Client) GetMultipleMessageDetails ¶
func (c *Client) GetMultipleMessageDetails(requests []MessageRef) ([]*Message, error)
func (*Client) GetUnifiedMessagesJSON ¶
func (*Client) GetUnreadCount ¶
func (*Client) GetUnsubscribeJSON ¶ added in v3.1.0
func (c *Client) GetUnsubscribeJSON(account, mailbox, id string) (*UnsubscribeObservation, error)
GetUnsubscribeJSON inventories controls from the complete available local MIME source. Metadata resolution may load account inventory; no message automation fallback, remote content, or unsubscribe action is performed.
func (*Client) HasMessageIdentityInMailbox ¶
func (c *Client) HasMessageIdentityInMailbox(accountName, mailboxName string, identity StableIdentity) (bool, error)
HasMessageIdentityInMailbox finds a logical message after a move may have replaced its local Mail.app ID. The Envelope Index has no RFC header column, so a header-only identity is resolved through Mail.app by the caller; the index path intentionally requires the complete guarded fallback.
func (*Client) IsGmailArchiveAccount ¶ added in v3.3.0
IsGmailArchiveAccount checks Mail's actual incoming server host. A mailbox named All Mail or a Gmail-looking account name alone is insufficient.
func (*Client) ListMessages ¶
func (c *Client) ListMessages(req MailboxListRequest) ([]Message, error)
ListMessages lists one mailbox, newest first, from the Envelope Index when it is readable and from Mail.app otherwise.
func (*Client) ListSignatures ¶
func (*Client) ListSmartMailboxes ¶
func (c *Client) ListSmartMailboxes() ([]SmartMailbox, error)
func (*Client) ListUnified ¶
ListUnified lists an inbox-style view (inbox, unread, flagged, sent, drafts, trash, junk) merged across every enabled account.
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) Mailboxes ¶
Mailboxes lists mailboxes for one account, or every account when account is empty.
func (*Client) MarkMessageAsRead ¶
func (*Client) MessageDetails ¶
MessageDetails fetches one message with its body through Mail.app.
func (*Client) MoveMessage ¶
func (*Client) PreviewDraftSend ¶
func (c *Client) PreviewDraftSend(accountName, draftID string) (*OutgoingResult, error)
PreviewDraftSend reads the exact stored draft and validates the same sender, recipients and MIME constraints as sending, without exporting attachments or creating an outgoing message.
func (*Client) PreviewOutgoing ¶
func (c *Client) PreviewOutgoing(input OutgoingInput) (*OutgoingResult, error)
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) ReadLocalUnsubscribeMessages ¶ added in v3.1.0
func (c *Client) ReadLocalUnsubscribeMessages(messages []ScanMessage) ([]UnsubscribeObservation, error)
ReadLocalUnsubscribeMessages resolves ownership once for a bounded batch and reads at most four local files at a time. Cancellation returns only attempted inputs, allowing callers to keep unattempted IDs pending in checkpoints.
func (*Client) ReadSelectedMessages ¶
func (c *Client) ReadSelectedMessages(refs []MessageRef, timeout, budget time.Duration) SelectedReadResult
ReadSelectedMessages preserves every successful body even when another ID is missing or stalls. A timed-out read is never retried automatically. The next ID gets a fresh bridge; the overall budget bounds all reads and queueing.
func (*Client) ReadSelectedMessagesWithOptions ¶ added in v3.3.0
func (c *Client) ReadSelectedMessagesWithOptions(refs []MessageRef, timeout, budget time.Duration, opts SelectedReadOptions) (SelectedReadResult, error)
func (*Client) RecordRecentEnvelope ¶
func (*Client) ResetAccountCache ¶
func (c *Client) ResetAccountCache()
ResetAccountCache forgets the in-process account list so the next read asks Mail.app again; an explicit refresh uses it.
func (*Client) ResolveArchiveMailbox ¶
ResolveArchiveMailbox is read-only so callers can durably record the intended destination before Mail is asked to move anything.
func (*Client) ResolveTrashMailbox ¶ added in v3.3.0
ResolveTrashMailbox reads Mail's special Trash mailbox, rather than guessing a provider's spelling. Only a unique account-owned physical mailbox is safe.
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) RunningMailProcessIDs ¶
RunningMailProcessIDs inspects the workspace without sending Mail an Apple Event or launching it. A running process does not imply a responsive bridge.
func (*Client) SaveAttachment ¶
func (*Client) SaveAttachmentByIndex ¶
func (*Client) SaveThreadedOutgoing ¶
func (c *Client) SaveThreadedOutgoing(input ThreadedOutgoingInput) (*OutgoingResult, error)
SaveThreadedOutgoing saves a reply or forward in the originating account's Drafts mailbox and verifies the resulting draft identity.
func (*Client) ScanMessages ¶
func (c *Client) ScanMessages(req ScanRequest) (ScanResult, error)
func (*Client) ScanUnsubscribe ¶ added in v3.1.0
func (c *Client) ScanUnsubscribe(req UnsubscribeScanRequest) (UnsubscribeScanResult, error)
ScanUnsubscribe discovers controls from every available local MIME body and header in the requested traversal. It never requests a rendered Mail body.
func (*Client) Search ¶
func (c *Client) Search(query, account string, limit int) (SearchResult, error)
Search runs the standard search within an account (every account when empty). Partial results are returned rather than refused; check Complete.
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. Searches fail closed unless AllowPartial is set.
func (*Client) SendDraftResult ¶
func (c *Client) SendDraftResult(accountName, draftID string) (*DraftSendResult, error)
SendDraftResult supports only drafts whose raw MIME proves that rebuilding through Mail's outgoing-message API preserves their content. Mail's stored message class does not implement send, and opening a message does not expose a documented correspondence to a new outgoing object. Rich or special-header drafts therefore fail before creating any outgoing message. Ordinary file attachments preserve filenames and exported bytes; Mail chooses their MIME metadata from those files when it composes the replacement.
func (*Client) SendMessage ¶
func (c *Client) SendMessage(accountName, subject, body string, to, cc, bcc, attachments []string) error
SendMessage preserves the public API and succeeds only when Mail explicitly accepts the verified outgoing message for submission.
func (*Client) SendOutgoing ¶
func (c *Client) SendOutgoing(input OutgoingInput) (*OutgoingResult, error)
func (*Client) SendThreadedOutgoing ¶
func (c *Client) SendThreadedOutgoing(input ThreadedOutgoingInput) (*OutgoingResult, error)
SendThreadedOutgoing submits a reply or forward to Mail. Its receipt records Mail's acceptance, with the same guarantees as SendOutgoing.
func (*Client) SetBackend ¶
func (*Client) SetBodyAlternatives ¶
SetBodyAlternatives includes independently extracted MIME alternatives in message output. Counts and warnings are retained when their texts are omitted.
func (*Client) SetBodySource ¶
SetBodySource chooses where message bodies come from. The default is BodySourceDisk.
func (*Client) SetWarn ¶
SetWarn routes this client's warnings (and those of every WithContext copy) to fn instead of the package default.
func (*Client) SyncAccount ¶
SyncAccount asks Mail to synchronize the named IMAP account (including iCloud), then checks the named account for new mail regardless of its type. Mail returns after accepting the requests; this does not prove that the server has finished synchronizing.
func (*Client) SyncAllAccounts ¶
SyncAllAccounts triggers IMAP synchronization and checks for new mail for each enabled receiving account. A successful return means the requests were accepted.
func (*Client) UpdateDraft ¶
func (c *Client) UpdateDraft(accountName, draftID string, input DraftInput) (*Message, error)
func (*Client) WithContext ¶
WithContext returns a client whose subprocesses are cancelled with ctx. It shares caches with the receiver.
func (*Client) WithSendingDisabled ¶ added in v3.2.0
WithSendingDisabled returns a restricted client. Drafts and previews remain available, and all context-derived copies retain the restriction.
type DraftInput ¶
type DraftInput struct {
Account string `json:"account"`
Sender string `json:"sender,omitempty"`
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 DraftSendResult ¶
type DraftSendResult struct {
DraftID string `json:"draftId"`
Account string `json:"account"`
AccountID string `json:"accountId,omitempty"`
Sender string `json:"sender,omitempty"`
Status string `json:"status"`
Submitted bool `json:"submitted"`
Sent bool `json:"sent"`
CleanupPending bool `json:"cleanupPending"`
Uncertain bool `json:"uncertain"`
}
DraftSendResult records Mail's submission acknowledgement separately from removal of the original. A submitted result must never be retried as a send.
type GmailLabelError ¶
func (*GmailLabelError) Error ¶
func (e *GmailLabelError) Error() string
func (*GmailLabelError) Unwrap ¶
func (e *GmailLabelError) Unwrap() error
type GmailLabelRequest ¶
type GmailLabelRequest struct {
Account string `json:"account"`
Mailbox string `json:"mailbox"`
MessageID string `json:"messageId"`
Label string `json:"label"`
Add bool `json:"add"`
DryRun bool `json:"dryRun"`
Receipt *BatchJournal `json:"-"`
}
GmailLabelRequest changes one explicit provider label. Mailbox and MessageID identify the Mail message only; they are never interpreted as Gmail IDs.
type GmailLabelResult ¶
type GmailLabelResult struct {
Status string `json:"status"`
ProviderConfirmed bool `json:"providerConfirmed"`
MailStatus string `json:"mailStatus"`
Account string `json:"account"`
ProviderEmail string `json:"providerEmail"`
ProviderMessageID string `json:"providerMessageId"`
Identity StableIdentity `json:"identity"`
Label gmail.Label `json:"label"`
Labels []gmail.Label `json:"labels,omitempty"`
Add bool `json:"add"`
BeforeLabelIDs []string `json:"beforeLabelIds"`
AfterLabelIDs []string `json:"afterLabelIds"`
ProviderAllMail bool `json:"providerAllMail"`
MailBefore *GmailLabelSnapshot `json:"mailBefore,omitempty"`
MailAfter *GmailLabelSnapshot `json:"mailAfter,omitempty"`
ReceiptPath string `json:"receiptPath,omitempty"`
Error string `json:"error,omitempty"`
}
Provider confirmation and Mail observation are independent. MailStatus never asserts that a row disappeared from an open Mail viewer.
func ReadGmailLabelReceipt ¶
func ReadGmailLabelReceipt(path string) (GmailLabelResult, error)
ReadGmailLabelReceipt returns the durable pre-dispatch state, never a later success claim. A partial final line after interruption cannot erase it.
type GmailLabelSnapshot ¶
type GmailLabelWorkflow ¶
type GmailLabelWorkflow struct {
Mail *Client
Provider gmail.API
// contains filtered or unexported fields
}
func NewGmailLabelWorkflow ¶
func NewGmailLabelWorkflow(c *Client, provider gmail.API) *GmailLabelWorkflow
func (*GmailLabelWorkflow) Change ¶
func (w *GmailLabelWorkflow) Change(ctx context.Context, r GmailLabelRequest) (GmailLabelResult, error)
func (*GmailLabelWorkflow) Reconcile ¶
func (w *GmailLabelWorkflow) Reconcile(ctx context.Context, path string) (GmailLabelResult, error)
Reconcile only reads provider and Mail state. It never dispatches or retries a mutation, and never appends to or truncates the original receipt.
func (*GmailLabelWorkflow) Show ¶
func (w *GmailLabelWorkflow) Show(ctx context.Context, r GmailLabelRequest) (GmailLabelResult, error)
type LinkExtractionStatus ¶ added in v3.1.0
type LinkExtractionStatus struct {
Complete bool `json:"complete"`
Source string `json:"source"`
Warnings []string `json:"warnings,omitempty"`
}
LinkExtractionStatus reports source extraction coverage. Complete means the available local MIME was parsed, not that remote or image content was examined.
type LocalReadStats ¶
type LocalReadStats struct {
FilesRead int64 `json:"filesRead"`
BodyExtractions int64 `json:"bodyExtractions"`
BodyMS float64 `json:"bodyMs"`
PartialBodies int64 `json:"partialBodies"`
ExtractionErrors int64 `json:"extractionErrors"`
}
LocalReadStats measures disk extraction without retaining message evidence.
func LocalReadStatistics ¶
func LocalReadStatistics() LocalReadStats
type MailboxListRequest ¶
type MailboxListRequest struct {
AccountName string
MailboxName string
Limit int
Offset int
UnreadOnly bool
FlaggedOnly bool
WithContent bool
Since string
}
MailboxListRequest selects messages from one mailbox for a fan-out read.
type ManifestItem ¶ added in v3.3.0
type ManifestItem struct {
Account string `json:"account"`
ID string `json:"id"`
SourceMailbox string `json:"sourceMailbox"`
Identity StableIdentity `json:"identity"`
Action string `json:"action"`
TargetMailbox string `json:"targetMailbox,omitempty"`
Read *bool `json:"read"`
RequiredPresent []string `json:"requiredPresent"`
RequiredAbsent []string `json:"requiredAbsent"`
}
type ManifestOutcome ¶ added in v3.3.0
type ManifestOutcome struct {
Account string `json:"account"`
ID string `json:"id"`
Action string `json:"action"`
CurrentIDs []string `json:"currentIds"`
Memberships map[string][]string `json:"memberships"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
MutationStatus string `json:"mutationStatus,omitempty"`
}
type ManifestResult ¶ added in v3.3.0
type ManifestResult struct {
Version int `json:"version"`
DryRun bool `json:"dryRun"`
Matched int `json:"matched"`
Verified int `json:"verified"`
Failed int `json:"failed"`
Planned int `json:"planned"`
NotAttempted int `json:"notAttempted"`
ReceiptPath string `json:"receiptPath,omitempty"`
Items []ManifestOutcome `json:"items"`
Batches []BatchResult `json:"batches,omitempty"`
}
func ApplyManifest ¶ added in v3.3.0
func ApplyManifest(c *Client, m CleanupManifest, dryRun bool) (ManifestResult, error)
ApplyManifest resolves every selected identity before the first mutation. Only an exact verified end state permits a repeat invocation to skip work.
func VerifyManifest ¶ added in v3.3.0
func VerifyManifest(c *Client, m CleanupManifest) (ManifestResult, error)
VerifyManifest observes explicit mailbox memberships and read state in one indexed snapshot. It does not synchronize accounts or perform mutations.
type Message ¶
type Message struct {
ID string `json:"id"`
// RFCMessageID is the RFC 5322 Message-ID header when Mail.app exposes it.
// It deliberately differs from the numeric local id above.
RFCMessageID string `json:"rfcMessageId,omitempty"`
InReplyTo string `json:"inReplyTo,omitempty"`
References string `json:"references,omitempty"`
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"`
Links []MessageLink `json:"links,omitempty"`
LinkStatus *LinkExtractionStatus `json:"linkStatus,omitempty"`
Unsubscribe *MessageUnsubscribe `json:"unsubscribe,omitempty"`
ContentError string `json:"contentError,omitempty"`
// ContentSource is "disk" when the body was read from Mail.app's message
// file and "mail" when Mail.app rendered it.
ContentSource string `json:"contentSource,omitempty"`
// BodyDiagnostics inventories local extraction; it does not certify semantic completeness.
BodyDiagnostics *BodyDiagnostics `json:"bodyDiagnostics,omitempty"`
// Snippet is Mail's indexed summary, present on index-backed listings.
Snippet string `json:"snippet,omitempty"`
Mailbox string `json:"mailbox"`
Account string `json:"account"`
ToRecipients []string `json:"toRecipients"`
CcRecipients []string `json:"ccRecipients"`
BccRecipients []string `json:"bccRecipients"`
}
func FilterBySender ¶
FilterBySender keeps messages whose sender matches an exact address or a domain (including subdomains). Empty filters keep everything.
func MessagesForThread ¶
MessagesForThread picks the loaded messages that belong to the thread.
func SearchRecentMessages ¶
func (Message) MarshalJSON ¶
MarshalJSON keeps recipient lists and inspected link inventories as arrays so consumers can always iterate them; nil slices would otherwise be null.
type MessageLink ¶ added in v3.1.0
type MessageLink struct {
// URL preserves the decoded destination, resolving relative HTML URLs only with an absolute HTTP base.
URL string `json:"url"`
// Text is the anchor label or nearby plain-text context.
Text string `json:"text,omitempty"`
// Source is html, plain, or header.
Source string `json:"source"`
// MIMEPart is the source MIME tree path when locally available.
MIMEPart string `json:"mimePart,omitempty"`
// Selected reports selection through all alternative ancestors.
Selected bool `json:"selected"`
// Kind is link, unsubscribe, or preferences; body classifications are candidates.
Kind string `json:"kind"`
// Openable permits syntactically usable HTTP, HTTPS, and mailto destinations.
Openable bool `json:"openable"`
}
MessageLink is a discovered destination, not a verified or visited URL. Selected means every MIME alternative ancestor selected this rendering.
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"`
IsGmail bool `json:"-"`
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 MessageReadResult ¶
type MessageReadResult struct {
ID string `json:"id"`
Account string `json:"account"`
Mailbox string `json:"mailbox"`
Message *Message `json:"message,omitempty"`
Error string `json:"error,omitempty"`
// Diagnostics times each phase of the read. After a timeout, Pending names
// the operation Mail.app had not answered.
Diagnostics *PhaseTrace `json:"diagnostics,omitempty"`
}
type MessageRef ¶
MessageRef names one message by account, mailbox, and ID.
type MessageUnsubscribe ¶ added in v3.1.0
type MessageUnsubscribe struct {
// ListID preserves the advertised raw List-Id header value.
ListID string `json:"listId,omitempty"`
ListUnsubscribe []string `json:"listUnsubscribe"`
ListUnsubscribePost []string `json:"listUnsubscribePost"`
OneClickAdvertised bool `json:"oneClickAdvertised"`
HeaderStatus string `json:"headerStatus"`
}
MessageUnsubscribe preserves advertised list controls. OneClickAdvertised does not verify the sender, endpoint, or successful unsubscribe behavior. HeaderStatus distinguishes unavailable headers from available absent controls.
type MutationError ¶
type MutationError struct {
Operation string
Phase string
Account string
Sender string
Cleanup string
Cause error
Attempted bool
Uncertain bool
Submitted bool
Saved bool
}
MutationError records the stage of an outgoing operation. Once submission starts, a transport error cannot establish that retrying is safe.
func (*MutationError) Error ¶
func (e *MutationError) Error() string
func (*MutationError) Unwrap ¶
func (e *MutationError) Unwrap() error
type Mutator ¶
Mutator applies one action to one message and may update the item, for example to record the mailbox an archive landed in.
func ArchiveMutator ¶
ArchiveMutator archives through Mail.app and records the destination.
func MoveMutator ¶
MoveMutator moves a message to item.TargetMailbox.
type NativeArchiveError ¶
type NativeArchiveError struct{ Err error }
NativeArchiveError stops a batch when the native action may have run or its owned window could not be cleaned up. Such an operation must not be replayed.
func (*NativeArchiveError) Error ¶
func (e *NativeArchiveError) Error() string
func (*NativeArchiveError) Unwrap ¶
func (e *NativeArchiveError) Unwrap() error
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 OutgoingInput ¶
type OutgoingInput struct {
Account string `json:"account"`
Sender string `json:"sender,omitempty"`
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"`
}
OutgoingInput composes a new message. Sender optionally selects an exact configured address belonging exclusively to Account.
type OutgoingResult ¶
type OutgoingResult struct {
Account string `json:"account"`
AccountID string `json:"accountId"`
Sender string `json:"sender"`
Status string `json:"status"`
Draft *Message `json:"draft,omitempty"`
Submitted bool `json:"submitted"`
}
OutgoingResult records Mail's acceptance, never server delivery or routing.
type PartialSearchError ¶
type PartialSearchError struct {
Result SearchResult
}
PartialSearchError means one or more mailboxes were searched incompletely. 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 PhaseTrace ¶
type PhaseTrace struct {
Phases []AutomationPhase `json:"phases"`
LastCompleted string `json:"lastCompleted,omitempty"`
Pending string `json:"pending,omitempty"`
PendingMs int64 `json:"pendingMs,omitempty"`
}
PhaseTrace says how far a bridge script got. Pending names the step that had started but not returned when the trace was taken.
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 RelocationState ¶
type RelocationState struct {
ObservedAt string `json:"observedAt"`
VerificationScope string `json:"verificationScope,omitempty"`
SyncRequestedAt string `json:"syncRequestedAt,omitempty"`
Account string `json:"account"`
SourceMailbox string `json:"sourceMailbox"`
DestinationMailbox string `json:"destinationMailbox"`
SourceRemovalRequired bool `json:"sourceRemovalRequired"`
SourcePresent bool `json:"sourcePresent"`
DestinationPresent bool `json:"destinationPresent"`
DestinationRead *bool `json:"destinationRead,omitempty"`
SourceIDs []string `json:"sourceIds,omitempty"`
DestinationIDs []string `json:"destinationIds,omitempty"`
}
RelocationState reports the source and the destination separately, because a move Mail.app accepted does not prove the source copy is gone. The IDs are the current local IDs, which differ from the ID the mutation was given when Mail.app regenerated the message.
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 ScanCheckpointProvenance ¶
type ScanCheckpointProvenance struct {
Path string `json:"path"`
Resumed bool `json:"resumed"`
Pages int `json:"pages"`
ObservationStartedAt string `json:"observationStartedAt"`
ObservationEndedAt string `json:"observationEndedAt"`
PageStartedAt string `json:"pageStartedAt"`
PageEndedAt string `json:"pageEndedAt"`
}
type ScanCoverage ¶
type ScanCoverage struct {
SearchMailbox
Count int `json:"count"`
Truncated bool `json:"truncated"`
Exhausted bool `json:"exhausted"`
Remaining int `json:"remaining"`
Error string `json:"error,omitempty"`
Errors []string `json:"errors,omitempty"` // checkpoint-only cumulative failed-page observations
}
ScanCoverage reports one requested mailbox. Remaining counts the matching messages older than this page; Exhausted means the traversal reached the end of the mailbox.
type ScanMessage ¶
func (ScanMessage) MarshalJSON ¶
func (m ScanMessage) MarshalJSON() ([]byte, error)
Message has its own marshaler; explicitly merge membership so embedding it does not silently drop the scan-only field.
type ScanPosition ¶
ScanPosition is the last message a traversal returned from one mailbox.
type ScanRequest ¶
type ScanRequest struct {
Scopes []SearchMailbox
Query string
Since string
Limit int // per mailbox and page; zero means unlimited
Unread bool
// Cursor is a NextCursor from an earlier page of the same request.
Cursor string
Checkpoint string // durable private traversal state; incompatible with Cursor
RestartCheckpoint bool
}
ScanRequest names every mailbox explicitly. A scan always reads live state; its observations are sequential, not an atomic snapshot of Mail.app.
type ScanResult ¶
type ScanResult struct {
Messages []ScanMessage `json:"messages"`
Coverage []ScanCoverage `json:"coverage"`
Complete bool `json:"complete"`
// NextCursor continues every mailbox that is not yet exhausted. It is
// empty once the traversal has covered every requested mailbox.
NextCursor string `json:"nextCursor,omitempty"`
StartedAt string `json:"startedAt"`
EndedAt string `json:"endedAt"`
Checkpoint *ScanCheckpointProvenance `json:"checkpoint,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"`
Truncated bool `json:"truncated,omitempty"`
ReadFailures int `json:"readFailures,omitempty"`
ScannedMessages int `json:"scannedMessages,omitempty"`
TotalMessages int `json:"totalMessages,omitempty"`
}
SearchMailboxFailure records a mailbox that could not be searched completely. 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. 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 could not be searched completely.
type SelectedReadOptions ¶ added in v3.3.0
type SelectedReadOptions struct {
Checkpoint string
Account string // An explicit CLI account constraint, when supplied.
// SelectionIDs includes requested IDs that could not yet be located. When
// omitted, the selection is derived from refs. Cached successes remain bound
// to their captured account even when a later locator changes its answer.
SelectionIDs []string
Events io.Writer
}
SelectedReadOptions enables durable body extraction and machine-readable progress. A checkpoint is read-only evidence, never a mutation selection.
type SelectedReadResult ¶
type SelectedReadResult struct {
Items []MessageReadResult `json:"items"`
Complete bool `json:"complete"`
}
type Sender ¶
Sender is a parsed From header.
func ParseSender ¶
ParseSender splits "Name <addr@host>" into its parts, lower-casing the address. Name keeps its case for display.
type SmartMailbox ¶
type StableIdentity ¶
type StableIdentity struct {
RFCMessageID string `json:"rfcMessageId,omitempty"`
Sender string `json:"sender,omitempty"`
Subject string `json:"subject,omitempty"`
DateSent string `json:"dateSent,omitempty"`
MessageSize int `json:"messageSize,omitempty"`
}
StableIdentity identifies a logical message across Mail.app local-ID changes. RFCMessageID is used only when it is an actual RFC header; the fallback is deliberately all-or-nothing to avoid matching a nearby mail.
func StableIdentityFromMessage ¶
func StableIdentityFromMessage(message Message) StableIdentity
type ThreadSummary ¶
type ThreadSummary struct {
ID string `json:"id"`
Subject string `json:"subject"`
Synthetic bool `json:"synthetic"`
Count int `json:"count"`
UnreadCount int `json:"unreadCount"`
LatestDate string `json:"latestDate"`
Participants []string `json:"participants"`
MessageIDs []string `json:"messageIds"`
Messages []Message `json:"messages,omitempty"`
}
ThreadSummary groups messages that share a normalized subject. Synthetic is true for every subject-derived group; only single-message groups are safe to act on as a unit.
func GroupThreads ¶
func GroupThreads(messages []Message) []ThreadSummary
GroupThreads buckets messages by normalized subject, newest thread first.
type ThreadedOutgoingInput ¶
type ThreadedOutgoingInput struct {
OutgoingInput
OriginalAccount string `json:"originalAccount"`
OriginalMailbox string `json:"originalMailbox"`
OriginalID string `json:"originalId"`
Mode ReplyMode `json:"mode"`
}
ThreadedOutgoingInput retains the exact original message independently of the editable outgoing fields. Mail creates the conversation relationship; the outgoing pipeline then applies the user's edited message.
type UnsubscribeDestination ¶ added in v3.1.0
type UnsubscribeDestination struct {
URL string `json:"url"`
Kind string `json:"kind"`
Openable bool `json:"openable"`
Evidence []UnsubscribeEvidence `json:"evidence"`
}
type UnsubscribeEvidence ¶ added in v3.1.0
type UnsubscribeEvidence struct {
MessageID string `json:"messageId"`
Source string `json:"source"`
MIMEPart string `json:"mimePart,omitempty"`
Text string `json:"text,omitempty"`
Kind string `json:"kind"`
Selected bool `json:"selected"`
}
UnsubscribeEvidence identifies where a destination was observed. It never establishes that a destination was visited or that an action succeeded.
type UnsubscribeGroup ¶ added in v3.1.0
type UnsubscribeGroup struct {
Key string `json:"key"`
KeySource string `json:"keySource"`
Provisional bool `json:"provisional"`
Account string `json:"account"`
ListID string `json:"listId,omitempty"`
Senders []string `json:"senders"`
MessageCount int `json:"messageCount"`
Latest UnsubscribeObservation `json:"latest"`
Messages []UnsubscribeObservation `json:"messages"`
Destinations []UnsubscribeDestination `json:"destinations"`
DestinationsVary bool `json:"destinationsVary"`
}
func GroupUnsubscribeObservations ¶ added in v3.1.0
func GroupUnsubscribeObservations(observations []UnsubscribeObservation) []UnsubscribeGroup
GroupUnsubscribeObservations keeps every control and local evidence record. List-ID groups are advertised identity, not remote verification; sender-based fallbacks remain explicitly provisional.
type UnsubscribeObservation ¶ added in v3.1.0
type UnsubscribeObservation struct {
ID string `json:"id"`
RFCMessageID string `json:"rfcMessageId,omitempty"`
Account string `json:"account"`
Mailboxes []string `json:"mailboxes"`
Sender string `json:"sender"`
Subject string `json:"subject"`
DateReceived string `json:"dateReceived"`
ListID string `json:"listId,omitempty"`
HeaderStatus string `json:"headerStatus"`
Complete bool `json:"complete"`
Error string `json:"error,omitempty"`
Warnings []string `json:"warnings,omitempty"`
OneClickAdvertised bool `json:"oneClickAdvertised"`
HasHTTPSUnsubscribe bool `json:"hasHttpsUnsubscribe"`
Destinations []UnsubscribeDestination `json:"destinations"`
}
UnsubscribeObservation is a compact local discovery result, without the message body, suitable for a private resumable discovery checkpoint.
type UnsubscribeReadability ¶ added in v3.1.0
type UnsubscribeScanRequest ¶ added in v3.1.0
type UnsubscribeScanResult ¶ added in v3.1.0
type UnsubscribeScanResult struct {
Groups []UnsubscribeGroup `json:"groups"`
Coverage []ScanCoverage `json:"coverage"`
Readability UnsubscribeReadability `json:"readability"`
Exceptions []UnsubscribeObservation `json:"exceptions"`
TraversalComplete bool `json:"traversalComplete"`
Complete bool `json:"complete"`
Scope string `json:"scope"`
Checkpoint string `json:"checkpoint"`
Resumed bool `json:"resumed"`
Pages int `json:"pages"`
Pending int `json:"pending"`
StartedAt string `json:"startedAt"`
EndedAt string `json:"endedAt"`
}
Source Files
¶
- accounts.go
- attachments.go
- automation.go
- automation_phases.go
- automation_session.go
- backend_stats.go
- batch.go
- batch_journal.go
- batch_workflow.go
- body_diagnostics.go
- bulk.go
- capability.go
- client.go
- draft_apple_alternative.go
- draft_attachments.go
- draft_mailbox.go
- draft_send.go
- drafts.go
- emlx.go
- envelope_index.go
- errors.go
- filter.go
- gmail_archive_account.go
- gmail_labels.go
- gmail_labels_receipt.go
- gmail_labels_snapshot.go
- health.go
- legacy_execution.go
- legacy_projection.go
- list.go
- local_mime.go
- local_read.go
- local_read_attachments.go
- local_read_stats.go
- locate.go
- mailboxes.go
- manifest.go
- message_actions.go
- message_content.go
- message_links.go
- messages.go
- models.go
- mutation_verification.go
- native_account_projection.go
- native_actions.go
- native_archive.go
- native_archive_direct.go
- native_backend.go
- native_decode.go
- native_headers.go
- native_lookup.go
- native_outgoing.go
- native_outgoing_attachment_proof.go
- native_outgoing_drafts.go
- native_outgoing_workflow.go
- native_read_ranges.go
- native_reads.go
- native_reply.go
- native_rules.go
- native_search.go
- outgoing.go
- outgoing_prepare.go
- read_checkpoint.go
- read_checkpoint_recovery.go
- read_selected.go
- receipt_read.go
- recent.go
- rules.go
- scan.go
- scan_checkpoint.go
- search.go
- send.go
- signatures.go
- smart_mailboxes.go
- sync.go
- threads.go
- trash_destination.go
- unified.go
- unsubscribe.go
- unsubscribe_checkpoint.go
- unsubscribe_scan.go
- unsubscribe_types.go
- verification_snapshot.go
- verification_workflow.go
- warn.go