Documentation
¶
Index ¶
- Constants
- Variables
- func CleanNotionID(id string) string
- func DetectCategory(labels []string) string
- func ExtractMessageBody(msg map[string]any) string
- func ExtractPlainTextBody(msg map[string]any) string
- func ExtractSenderName(from string) string
- func FormatSubjectFolder(subject, dateStr, msgID string) string
- func GetDriveAPICallCount() int64
- func GetGmailAPICallCount() int64
- func GetNotionAPICallCount() int64
- func JSONMarshal(v any) ([]byte, error)
- func JSONMarshalIndent(v any) ([]byte, error)
- func ParseEmailDate(dateStr string) time.Time
- func ResetDriveAPICallCount()
- func ResetGmailAPICallCount()
- func ResetNotionAPICallCount()
- func SanitizeFilename(name string) string
- func SanitizeFolderName(name string) string
- func StripHTML(html string) string
- type DriveClient
- func (c *DriveClient) DownloadFile(ctx context.Context, token, fileID string) ([]byte, error)
- func (c *DriveClient) ExportGoogleDoc(ctx context.Context, token, fileID, mimeType string) ([]byte, error)
- func (c *DriveClient) GetExportMimeType(mimeType string) string
- func (c *DriveClient) GetFile(ctx context.Context, token, fileID string) (*DriveFile, error)
- func (c *DriveClient) GetFileContent(ctx context.Context, token string, file *DriveFile) ([]byte, error)
- func (c *DriveClient) Integration() types.ToolName
- func (c *DriveClient) IsGoogleDoc(mimeType string) bool
- func (c *DriveClient) IsTextExtractable(mimeType string) bool
- func (c *DriveClient) ListFiles(ctx context.Context, token, query string, maxResults int) ([]*DriveFile, error)
- func (c *DriveClient) ParseFile(fileMap map[string]any) *DriveFile
- func (c *DriveClient) Request(ctx context.Context, token, path string, result any) error
- type DriveFile
- type GmailClient
- func (c *GmailClient) DetectCategory(labels []string) string
- func (c *GmailClient) ExtractMessageBody(msg map[string]any) string
- func (c *GmailClient) ExtractPlainTextBody(msg map[string]any) string
- func (c *GmailClient) GetMessage(ctx context.Context, token, msgID, format string) (map[string]any, error)
- func (c *GmailClient) Integration() types.ToolName
- func (c *GmailClient) ListMessages(ctx context.Context, token, query string, maxResults int) ([]string, error)
- func (c *GmailClient) ParseMessage(result map[string]any) *GmailMessage
- func (c *GmailClient) Request(ctx context.Context, token, path string, result any) error
- type GmailMessage
- type NotionBlock
- type NotionClient
- func (c *NotionClient) BlockToMarkdown(block *NotionBlock) string
- func (c *NotionClient) BlocksToText(blocks []*NotionBlock) string
- func (c *NotionClient) ExtractRichText(blockContent map[string]any) string
- func (c *NotionClient) ExtractTitle(obj map[string]any) string
- func (c *NotionClient) GetPage(ctx context.Context, token, pageID string) (*NotionPage, error)
- func (c *NotionClient) GetPageBlocks(ctx context.Context, token, pageID string) ([]*NotionBlock, error)
- func (c *NotionClient) Integration() types.ToolName
- func (c *NotionClient) ParsePage(obj map[string]any) *NotionPage
- func (c *NotionClient) PostRequest(ctx context.Context, token, path string, body any, result any) error
- func (c *NotionClient) Request(ctx context.Context, token, path string, result any) error
- func (c *NotionClient) Search(ctx context.Context, token string, query string, maxResults int) ([]*NotionPage, error)
- type NotionPage
Constants ¶
const ( NotionAPIBase = "https://api.notion.com/v1" NotionAPIVersion = "2022-06-28" )
const (
DriveAPIBase = "https://www.googleapis.com/drive/v3"
)
const (
GmailAPIBase = "https://gmail.googleapis.com/gmail/v1"
)
Variables ¶
var CategoryQueries = map[string]string{
"unread": "q=is:unread",
"inbox": "labelIds=INBOX",
"starred": "labelIds=STARRED",
"sent": "labelIds=SENT",
"important": "labelIds=IMPORTANT",
}
CategoryQueries maps category names to Gmail API query/label
var GmailCategories = []string{"unread", "inbox", "starred", "sent", "important"}
GmailCategories are the supported message categories
var GoogleDocsExportTypes = map[string]string{
"application/vnd.google-apps.document": "text/plain",
"application/vnd.google-apps.spreadsheet": "text/csv",
"application/vnd.google-apps.presentation": "text/plain",
}
Google Docs export MIME types
var TextMimeTypes = map[string]bool{ "text/plain": true, "text/html": true, "text/css": true, "text/javascript": true, "application/json": true, "application/xml": true, "text/xml": true, "text/markdown": true, "text/csv": true, "application/x-yaml": true, "application/javascript": true, }
Text-extractable MIME types
var UnsafeFilenameChars = regexp.MustCompile(`[<>:"/\\|?*\x00-\x1f]`)
UnsafeFilenameChars matches characters unsafe for filenames
Functions ¶
func DetectCategory ¶
DetectCategory determines the primary category for a message based on labels
func ExtractMessageBody ¶
ExtractMessageBody extracts the best available text body from a Gmail message, trying text/plain first, then falling back to text/html converted to plain text
func ExtractPlainTextBody ¶
ExtractPlainTextBody extracts plain text from a Gmail message payload
func ExtractSenderName ¶
ExtractSenderName extracts a clean sender name from a From header "noreply@calendly.com" -> "Calendly" "KAYAK <kayak@msg.kayak.com>" -> "KAYAK"
func FormatSubjectFolder ¶
FormatSubjectFolder creates a folder name from subject, date, and ID
func GetDriveAPICallCount ¶
func GetDriveAPICallCount() int64
GetDriveAPICallCount returns the current API call count
func GetGmailAPICallCount ¶
func GetGmailAPICallCount() int64
GetGmailAPICallCount returns the current API call count
func GetNotionAPICallCount ¶
func GetNotionAPICallCount() int64
GetNotionAPICallCount returns the current API call count
func JSONMarshalIndent ¶
JSONMarshalIndent marshals to indented JSON
func ParseEmailDate ¶
ParseEmailDate parses various email date formats
func ResetDriveAPICallCount ¶
func ResetDriveAPICallCount()
ResetDriveAPICallCount resets the API call counter
func ResetGmailAPICallCount ¶
func ResetGmailAPICallCount()
ResetGmailAPICallCount resets the API call counter
func ResetNotionAPICallCount ¶
func ResetNotionAPICallCount()
ResetNotionAPICallCount resets the API call counter
func SanitizeFilename ¶
SanitizeFilename makes a filename safe for filesystem use
func SanitizeFolderName ¶
SanitizeFolderName makes a folder name safe with shorter limit
Types ¶
type DriveClient ¶
DriveClient provides shared Google Drive API functionality
func NewDriveClient ¶
func NewDriveClient() *DriveClient
NewDriveClient creates a new Google Drive API client
func (*DriveClient) DownloadFile ¶
DownloadFile downloads file content
func (*DriveClient) ExportGoogleDoc ¶
func (c *DriveClient) ExportGoogleDoc(ctx context.Context, token, fileID, mimeType string) ([]byte, error)
ExportGoogleDoc exports a Google Doc as text
func (*DriveClient) GetExportMimeType ¶
func (c *DriveClient) GetExportMimeType(mimeType string) string
GetExportMimeType returns the export MIME type for a Google Doc
func (*DriveClient) GetFileContent ¶
func (c *DriveClient) GetFileContent(ctx context.Context, token string, file *DriveFile) ([]byte, error)
GetFileContent fetches file content, handling Google Docs export automatically
func (*DriveClient) Integration ¶
func (c *DriveClient) Integration() types.ToolName
Integration returns the integration name
func (*DriveClient) IsGoogleDoc ¶
func (c *DriveClient) IsGoogleDoc(mimeType string) bool
IsGoogleDoc returns true if the file is a Google Docs type that can be exported
func (*DriveClient) IsTextExtractable ¶
func (c *DriveClient) IsTextExtractable(mimeType string) bool
IsTextExtractable returns true if the file's text content can be extracted
func (*DriveClient) ListFiles ¶
func (c *DriveClient) ListFiles(ctx context.Context, token, query string, maxResults int) ([]*DriveFile, error)
ListFiles lists files from Drive
type DriveFile ¶
type DriveFile struct {
ID string
Name string
MimeType string
Size int64
ModifiedTime time.Time
Parents []string
WebViewLink string
IsFolder bool
}
DriveFile represents a Google Drive file
type GmailClient ¶
GmailClient provides shared Gmail API functionality
func NewGmailClient ¶
func NewGmailClient() *GmailClient
NewGmailClient creates a new Gmail API client
func (*GmailClient) DetectCategory ¶
func (c *GmailClient) DetectCategory(labels []string) string
DetectCategory determines the primary category for a message
func (*GmailClient) ExtractMessageBody ¶
func (c *GmailClient) ExtractMessageBody(msg map[string]any) string
ExtractMessageBody extracts the best available text body from a Gmail message, trying text/plain first, then falling back to text/html converted to plain text
func (*GmailClient) ExtractPlainTextBody ¶
func (c *GmailClient) ExtractPlainTextBody(msg map[string]any) string
ExtractPlainTextBody extracts plain text from a Gmail message payload
func (*GmailClient) GetMessage ¶
func (c *GmailClient) GetMessage(ctx context.Context, token, msgID, format string) (map[string]any, error)
GetMessage fetches a single message with metadata
func (*GmailClient) Integration ¶
func (c *GmailClient) Integration() types.ToolName
Integration returns the integration name
func (*GmailClient) ListMessages ¶
func (c *GmailClient) ListMessages(ctx context.Context, token, query string, maxResults int) ([]string, error)
ListMessages lists message IDs with optional query
func (*GmailClient) ParseMessage ¶
func (c *GmailClient) ParseMessage(result map[string]any) *GmailMessage
ParseMessage extracts structured data from a Gmail API response
type GmailMessage ¶
type GmailMessage struct {
ID string
ThreadID string
From string
To string
Subject string
Date string
Snippet string
Labels []string
SenderFolder string // Sanitized sender for folder name
SubjectFolder string // Sanitized subject with date and ID
}
GmailMessage represents a parsed Gmail message
type NotionBlock ¶
NotionBlock represents a Notion block
type NotionClient ¶
NotionClient provides shared Notion API functionality
func NewNotionClient ¶
func NewNotionClient() *NotionClient
NewNotionClient creates a new Notion API client
func (*NotionClient) BlockToMarkdown ¶
func (c *NotionClient) BlockToMarkdown(block *NotionBlock) string
BlockToMarkdown converts a single block to markdown
func (*NotionClient) BlocksToText ¶
func (c *NotionClient) BlocksToText(blocks []*NotionBlock) string
BlocksToText converts Notion blocks to plain text
func (*NotionClient) ExtractRichText ¶
func (c *NotionClient) ExtractRichText(blockContent map[string]any) string
ExtractRichText extracts plain text from a Notion rich text array
func (*NotionClient) ExtractTitle ¶
func (c *NotionClient) ExtractTitle(obj map[string]any) string
ExtractTitle extracts the title from a Notion object
func (*NotionClient) GetPage ¶
func (c *NotionClient) GetPage(ctx context.Context, token, pageID string) (*NotionPage, error)
GetPage fetches a single page
func (*NotionClient) GetPageBlocks ¶
func (c *NotionClient) GetPageBlocks(ctx context.Context, token, pageID string) ([]*NotionBlock, error)
GetPageBlocks fetches the blocks of a page
func (*NotionClient) Integration ¶
func (c *NotionClient) Integration() types.ToolName
Integration returns the integration name
func (*NotionClient) ParsePage ¶
func (c *NotionClient) ParsePage(obj map[string]any) *NotionPage
ParsePage extracts structured data from a Notion API response
func (*NotionClient) PostRequest ¶
func (c *NotionClient) PostRequest(ctx context.Context, token, path string, body any, result any) error
PostRequest makes a POST request to the Notion API
func (*NotionClient) Search ¶
func (c *NotionClient) Search(ctx context.Context, token string, query string, maxResults int) ([]*NotionPage, error)
Search searches for all accessible content