Documentation
¶
Overview ¶
Package ports defines interfaces for the application.
Package ports defines the interfaces for external dependencies.
Package ports defines the interfaces for external adapters.
Package ports defines the interfaces for external dependencies.
Package ports defines interfaces for webhook server and tunnel management.
Index ¶
- Constants
- func GrantTokenKey(grantID string) string
- type AdminClient
- type AuthClient
- type Browser
- type CalendarClient
- type Column
- type ConfigStore
- type ContactClient
- type GrantStore
- type InboundClient
- type LLMProvider
- type LLMRouter
- type MessageClient
- type NotetakerClient
- type NylasClient
- type OAuthServer
- type OutputFormat
- type OutputOptions
- type OutputWriter
- type QuietFielder
- type SchedulerClient
- type SecretStore
- type SlackClient
- type TemplateStore
- type TimeZoneService
- type Tunnel
- type TunnelConfig
- type TunnelStatus
- type UtilityServices
- type WebhookClient
- type WebhookEvent
- type WebhookEventHandler
- type WebhookServer
- type WebhookServerConfig
- type WebhookServerStats
Constants ¶
const ( KeyClientID = "client_id" KeyClientSecret = "client_secret" KeyAPIKey = "api_key" KeyOrgID = "org_id" )
Secret key constants.
Variables ¶
This section is empty.
Functions ¶
func GrantTokenKey ¶
GrantTokenKey returns the keystore key for a grant's access token.
Types ¶
type AdminClient ¶
type AdminClient interface {
// ListApplications retrieves all applications.
ListApplications(ctx context.Context) ([]domain.Application, error)
// GetApplication retrieves a specific application.
GetApplication(ctx context.Context, appID string) (*domain.Application, error)
// CreateApplication creates a new application.
CreateApplication(ctx context.Context, req *domain.CreateApplicationRequest) (*domain.Application, error)
// UpdateApplication updates an existing application.
UpdateApplication(ctx context.Context, appID string, req *domain.UpdateApplicationRequest) (*domain.Application, error)
// DeleteApplication deletes an application.
DeleteApplication(ctx context.Context, appID string) error
// ListConnectors retrieves all connectors.
ListConnectors(ctx context.Context) ([]domain.Connector, error)
// GetConnector retrieves a specific connector.
GetConnector(ctx context.Context, connectorID string) (*domain.Connector, error)
// CreateConnector creates a new connector.
CreateConnector(ctx context.Context, req *domain.CreateConnectorRequest) (*domain.Connector, error)
// UpdateConnector updates an existing connector.
UpdateConnector(ctx context.Context, connectorID string, req *domain.UpdateConnectorRequest) (*domain.Connector, error)
// DeleteConnector deletes a connector.
DeleteConnector(ctx context.Context, connectorID string) error
// ListCredentials retrieves all credentials for a connector.
ListCredentials(ctx context.Context, connectorID string) ([]domain.ConnectorCredential, error)
// GetCredential retrieves a specific credential.
GetCredential(ctx context.Context, credentialID string) (*domain.ConnectorCredential, error)
// CreateCredential creates a new credential.
CreateCredential(ctx context.Context, connectorID string, req *domain.CreateCredentialRequest) (*domain.ConnectorCredential, error)
// UpdateCredential updates an existing credential.
UpdateCredential(ctx context.Context, credentialID string, req *domain.UpdateCredentialRequest) (*domain.ConnectorCredential, error)
// DeleteCredential deletes a credential.
DeleteCredential(ctx context.Context, credentialID string) error
// ListAllGrants retrieves all grants with query parameters.
ListAllGrants(ctx context.Context, params *domain.GrantsQueryParams) ([]domain.Grant, error)
// GetGrantStats retrieves grant statistics.
GetGrantStats(ctx context.Context) (*domain.GrantStats, error)
}
AdminClient defines the interface for administrative operations.
type AuthClient ¶
type AuthClient interface {
// BuildAuthURL builds an OAuth authorization URL for a provider.
BuildAuthURL(provider domain.Provider, redirectURI string) string
// ExchangeCode exchanges an authorization code for a grant.
ExchangeCode(ctx context.Context, code, redirectURI string) (*domain.Grant, error)
// ListGrants returns all grants for the authenticated application.
ListGrants(ctx context.Context) ([]domain.Grant, error)
// GetGrant retrieves a specific grant by ID.
GetGrant(ctx context.Context, grantID string) (*domain.Grant, error)
// RevokeGrant revokes a specific grant.
RevokeGrant(ctx context.Context, grantID string) error
}
AuthClient defines the interface for authentication and grant operations.
type CalendarClient ¶
type CalendarClient interface {
// GetCalendars retrieves all calendars.
GetCalendars(ctx context.Context, grantID string) ([]domain.Calendar, error)
// GetCalendar retrieves a specific calendar.
GetCalendar(ctx context.Context, grantID, calendarID string) (*domain.Calendar, error)
// CreateCalendar creates a new calendar.
CreateCalendar(ctx context.Context, grantID string, req *domain.CreateCalendarRequest) (*domain.Calendar, error)
// UpdateCalendar updates an existing calendar.
UpdateCalendar(ctx context.Context, grantID, calendarID string, req *domain.UpdateCalendarRequest) (*domain.Calendar, error)
// DeleteCalendar deletes a calendar.
DeleteCalendar(ctx context.Context, grantID, calendarID string) error
// GetEvents retrieves events with query parameters.
GetEvents(ctx context.Context, grantID, calendarID string, params *domain.EventQueryParams) ([]domain.Event, error)
// GetEventsWithCursor retrieves events with cursor-based pagination.
GetEventsWithCursor(ctx context.Context, grantID, calendarID string, params *domain.EventQueryParams) (*domain.EventListResponse, error)
// GetEvent retrieves a specific event.
GetEvent(ctx context.Context, grantID, calendarID, eventID string) (*domain.Event, error)
// CreateEvent creates a new event.
CreateEvent(ctx context.Context, grantID, calendarID string, req *domain.CreateEventRequest) (*domain.Event, error)
// UpdateEvent updates an existing event.
UpdateEvent(ctx context.Context, grantID, calendarID, eventID string, req *domain.UpdateEventRequest) (*domain.Event, error)
// DeleteEvent deletes an event.
DeleteEvent(ctx context.Context, grantID, calendarID, eventID string) error
// SendRSVP sends an RSVP response to an event.
SendRSVP(ctx context.Context, grantID, calendarID, eventID string, req *domain.SendRSVPRequest) error
// GetFreeBusy retrieves free/busy information.
GetFreeBusy(ctx context.Context, grantID string, req *domain.FreeBusyRequest) (*domain.FreeBusyResponse, error)
// GetAvailability retrieves availability across multiple accounts.
GetAvailability(ctx context.Context, req *domain.AvailabilityRequest) (*domain.AvailabilityResponse, error)
// CreateVirtualCalendarGrant creates a virtual calendar grant.
CreateVirtualCalendarGrant(ctx context.Context, email string) (*domain.VirtualCalendarGrant, error)
// ListVirtualCalendarGrants retrieves all virtual calendar grants.
ListVirtualCalendarGrants(ctx context.Context) ([]domain.VirtualCalendarGrant, error)
// GetVirtualCalendarGrant retrieves a specific virtual calendar grant.
GetVirtualCalendarGrant(ctx context.Context, grantID string) (*domain.VirtualCalendarGrant, error)
// DeleteVirtualCalendarGrant deletes a virtual calendar grant.
DeleteVirtualCalendarGrant(ctx context.Context, grantID string) error
// GetRecurringEventInstances retrieves instances of a recurring event.
GetRecurringEventInstances(ctx context.Context, grantID, calendarID, masterEventID string, params *domain.EventQueryParams) ([]domain.Event, error)
// UpdateRecurringEventInstance updates a specific instance of a recurring event.
UpdateRecurringEventInstance(ctx context.Context, grantID, calendarID, eventID string, req *domain.UpdateEventRequest) (*domain.Event, error)
// DeleteRecurringEventInstance deletes a specific instance of a recurring event.
DeleteRecurringEventInstance(ctx context.Context, grantID, calendarID, eventID string) error
}
CalendarClient defines the interface for calendar, event, and availability operations.
type Column ¶
type Column struct {
// Header is the column header text
Header string
// Field is the struct field name or map key to extract
Field string
// Width is the optional fixed width (0 = auto, -1 = no truncation)
Width int
}
Column defines a column for table output.
type ConfigStore ¶
type ConfigStore interface {
// Load loads the configuration from storage.
Load() (*domain.Config, error)
// Save saves the configuration to storage.
Save(config *domain.Config) error
// Path returns the path to the config file.
Path() string
// Exists returns true if the config file exists.
Exists() bool
}
ConfigStore defines the interface for configuration storage.
type ContactClient ¶
type ContactClient interface {
// GetContacts retrieves contacts with query parameters.
GetContacts(ctx context.Context, grantID string, params *domain.ContactQueryParams) ([]domain.Contact, error)
// GetContactsWithCursor retrieves contacts with cursor-based pagination.
GetContactsWithCursor(ctx context.Context, grantID string, params *domain.ContactQueryParams) (*domain.ContactListResponse, error)
// GetContact retrieves a specific contact.
GetContact(ctx context.Context, grantID, contactID string) (*domain.Contact, error)
// GetContactWithPicture retrieves a contact with optional picture data.
GetContactWithPicture(ctx context.Context, grantID, contactID string, includePicture bool) (*domain.Contact, error)
// CreateContact creates a new contact.
CreateContact(ctx context.Context, grantID string, req *domain.CreateContactRequest) (*domain.Contact, error)
// UpdateContact updates an existing contact.
UpdateContact(ctx context.Context, grantID, contactID string, req *domain.UpdateContactRequest) (*domain.Contact, error)
// DeleteContact deletes a contact.
DeleteContact(ctx context.Context, grantID, contactID string) error
// GetContactGroups retrieves all contact groups.
GetContactGroups(ctx context.Context, grantID string) ([]domain.ContactGroup, error)
// GetContactGroup retrieves a specific contact group.
GetContactGroup(ctx context.Context, grantID, groupID string) (*domain.ContactGroup, error)
// CreateContactGroup creates a new contact group.
CreateContactGroup(ctx context.Context, grantID string, req *domain.CreateContactGroupRequest) (*domain.ContactGroup, error)
// UpdateContactGroup updates an existing contact group.
UpdateContactGroup(ctx context.Context, grantID, groupID string, req *domain.UpdateContactGroupRequest) (*domain.ContactGroup, error)
// DeleteContactGroup deletes a contact group.
DeleteContactGroup(ctx context.Context, grantID, groupID string) error
}
ContactClient defines the interface for contact and contact group operations.
type GrantStore ¶
type GrantStore interface {
// SaveGrant saves grant info to storage.
SaveGrant(info domain.GrantInfo) error
// GetGrant retrieves grant info by ID.
GetGrant(grantID string) (*domain.GrantInfo, error)
// GetGrantByEmail retrieves grant info by email.
GetGrantByEmail(email string) (*domain.GrantInfo, error)
// ListGrants returns all stored grants.
ListGrants() ([]domain.GrantInfo, error)
// DeleteGrant removes a grant from storage.
DeleteGrant(grantID string) error
// SetDefaultGrant sets the default grant ID.
SetDefaultGrant(grantID string) error
// GetDefaultGrant returns the default grant ID.
GetDefaultGrant() (string, error)
// ClearGrants removes all grants from storage.
ClearGrants() error
}
GrantStore defines the interface for storing grant information.
type InboundClient ¶
type InboundClient interface {
// ListInboundInboxes retrieves all inbound inboxes.
ListInboundInboxes(ctx context.Context) ([]domain.InboundInbox, error)
// GetInboundInbox retrieves a specific inbound inbox.
GetInboundInbox(ctx context.Context, grantID string) (*domain.InboundInbox, error)
// CreateInboundInbox creates a new inbound inbox.
CreateInboundInbox(ctx context.Context, email string) (*domain.InboundInbox, error)
// DeleteInboundInbox deletes an inbound inbox.
DeleteInboundInbox(ctx context.Context, grantID string) error
// GetInboundMessages retrieves inbound messages with query parameters.
GetInboundMessages(ctx context.Context, grantID string, params *domain.MessageQueryParams) ([]domain.InboundMessage, error)
}
InboundClient defines the interface for inbound inbox operations.
type LLMProvider ¶
type LLMProvider interface {
// Chat sends a chat completion request
Chat(ctx context.Context, req *domain.ChatRequest) (*domain.ChatResponse, error)
// ChatWithTools sends a chat request with function calling
ChatWithTools(ctx context.Context, req *domain.ChatRequest, tools []domain.Tool) (*domain.ChatResponse, error)
// StreamChat streams chat responses
StreamChat(ctx context.Context, req *domain.ChatRequest, callback func(chunk string) error) error
// Name returns the provider name
Name() string
// IsAvailable checks if provider is configured and accessible
IsAvailable(ctx context.Context) bool
}
LLMProvider defines the interface for LLM providers.
type LLMRouter ¶
type LLMRouter interface {
// GetProvider returns the specified provider or default if empty
GetProvider(name string) (LLMProvider, error)
// Chat sends a chat request using the default provider with fallback
Chat(ctx context.Context, req *domain.ChatRequest) (*domain.ChatResponse, error)
// ChatWithProvider sends a chat request using a specific provider
ChatWithProvider(ctx context.Context, provider string, req *domain.ChatRequest) (*domain.ChatResponse, error)
// ListProviders returns available provider names
ListProviders() []string
}
LLMRouter defines the interface for routing between multiple LLM providers.
type MessageClient ¶
type MessageClient interface {
// GetMessages retrieves messages with optional limit.
GetMessages(ctx context.Context, grantID string, limit int) ([]domain.Message, error)
// GetMessagesWithParams retrieves messages with query parameters.
GetMessagesWithParams(ctx context.Context, grantID string, params *domain.MessageQueryParams) ([]domain.Message, error)
// GetMessagesWithCursor retrieves messages with cursor-based pagination.
GetMessagesWithCursor(ctx context.Context, grantID string, params *domain.MessageQueryParams) (*domain.MessageListResponse, error)
// GetMessage retrieves a specific message.
GetMessage(ctx context.Context, grantID, messageID string) (*domain.Message, error)
// GetMessageWithFields retrieves a message with optional field selection (e.g., "raw_mime").
GetMessageWithFields(ctx context.Context, grantID, messageID string, fields string) (*domain.Message, error)
// SendMessage sends a new message.
SendMessage(ctx context.Context, grantID string, req *domain.SendMessageRequest) (*domain.Message, error)
// UpdateMessage updates an existing message.
UpdateMessage(ctx context.Context, grantID, messageID string, req *domain.UpdateMessageRequest) (*domain.Message, error)
// DeleteMessage deletes a message.
DeleteMessage(ctx context.Context, grantID, messageID string) error
// ListScheduledMessages retrieves all scheduled messages.
ListScheduledMessages(ctx context.Context, grantID string) ([]domain.ScheduledMessage, error)
// GetScheduledMessage retrieves a specific scheduled message.
GetScheduledMessage(ctx context.Context, grantID, scheduleID string) (*domain.ScheduledMessage, error)
// CancelScheduledMessage cancels a scheduled message.
CancelScheduledMessage(ctx context.Context, grantID, scheduleID string) error
// SmartCompose generates AI-powered message suggestions.
SmartCompose(ctx context.Context, grantID string, req *domain.SmartComposeRequest) (*domain.SmartComposeSuggestion, error)
// SmartComposeReply generates AI-powered reply suggestions.
SmartComposeReply(ctx context.Context, grantID, messageID string, req *domain.SmartComposeRequest) (*domain.SmartComposeSuggestion, error)
// GetThreads retrieves threads with query parameters.
GetThreads(ctx context.Context, grantID string, params *domain.ThreadQueryParams) ([]domain.Thread, error)
// GetThread retrieves a specific thread.
GetThread(ctx context.Context, grantID, threadID string) (*domain.Thread, error)
// UpdateThread updates a thread.
UpdateThread(ctx context.Context, grantID, threadID string, req *domain.UpdateMessageRequest) (*domain.Thread, error)
// DeleteThread deletes a thread.
DeleteThread(ctx context.Context, grantID, threadID string) error
// GetDrafts retrieves drafts with optional limit.
GetDrafts(ctx context.Context, grantID string, limit int) ([]domain.Draft, error)
// GetDraft retrieves a specific draft.
GetDraft(ctx context.Context, grantID, draftID string) (*domain.Draft, error)
// CreateDraft creates a new draft.
CreateDraft(ctx context.Context, grantID string, req *domain.CreateDraftRequest) (*domain.Draft, error)
// UpdateDraft updates an existing draft.
UpdateDraft(ctx context.Context, grantID, draftID string, req *domain.CreateDraftRequest) (*domain.Draft, error)
// DeleteDraft deletes a draft.
DeleteDraft(ctx context.Context, grantID, draftID string) error
// SendDraft sends a draft as a message.
SendDraft(ctx context.Context, grantID, draftID string) (*domain.Message, error)
// GetFolders retrieves all folders.
GetFolders(ctx context.Context, grantID string) ([]domain.Folder, error)
// GetFolder retrieves a specific folder.
GetFolder(ctx context.Context, grantID, folderID string) (*domain.Folder, error)
// CreateFolder creates a new folder.
CreateFolder(ctx context.Context, grantID string, req *domain.CreateFolderRequest) (*domain.Folder, error)
// UpdateFolder updates an existing folder.
UpdateFolder(ctx context.Context, grantID, folderID string, req *domain.UpdateFolderRequest) (*domain.Folder, error)
// DeleteFolder deletes a folder.
DeleteFolder(ctx context.Context, grantID, folderID string) error
// ListAttachments retrieves all attachments for a message.
ListAttachments(ctx context.Context, grantID, messageID string) ([]domain.Attachment, error)
// GetAttachment retrieves a specific attachment.
GetAttachment(ctx context.Context, grantID, messageID, attachmentID string) (*domain.Attachment, error)
// DownloadAttachment downloads attachment content.
DownloadAttachment(ctx context.Context, grantID, messageID, attachmentID string) (io.ReadCloser, error)
}
MessageClient defines the interface for message, draft, thread, folder, and attachment operations.
type NotetakerClient ¶
type NotetakerClient interface {
// ListNotetakers retrieves notetakers with query parameters.
ListNotetakers(ctx context.Context, grantID string, params *domain.NotetakerQueryParams) ([]domain.Notetaker, error)
// GetNotetaker retrieves a specific notetaker.
GetNotetaker(ctx context.Context, grantID, notetakerID string) (*domain.Notetaker, error)
// CreateNotetaker creates a new notetaker.
CreateNotetaker(ctx context.Context, grantID string, req *domain.CreateNotetakerRequest) (*domain.Notetaker, error)
// DeleteNotetaker deletes a notetaker.
DeleteNotetaker(ctx context.Context, grantID, notetakerID string) error
// GetNotetakerMedia retrieves media data for a notetaker.
GetNotetakerMedia(ctx context.Context, grantID, notetakerID string) (*domain.MediaData, error)
}
NotetakerClient defines the interface for notetaker operations.
type NylasClient ¶
type NylasClient interface {
// Domain-specific interfaces
AuthClient
MessageClient
CalendarClient
ContactClient
WebhookClient
NotetakerClient
InboundClient
SchedulerClient
AdminClient
// Configuration methods
SetRegion(region string)
SetCredentials(clientID, clientSecret, apiKey string)
}
NylasClient defines the composite interface for interacting with the Nylas API. It embeds domain-specific sub-interfaces following the Interface Segregation Principle.
type OAuthServer ¶
type OAuthServer interface {
// Start starts the server on the configured port.
Start() error
// Stop stops the server.
Stop() error
// WaitForCallback waits for the OAuth callback and returns the auth code.
WaitForCallback(ctx context.Context) (string, error)
// GetRedirectURI returns the redirect URI for OAuth.
GetRedirectURI() string
}
OAuthServer defines the interface for the OAuth callback server.
type OutputFormat ¶
type OutputFormat string
OutputFormat represents the format for CLI output.
const ( FormatTable OutputFormat = "table" FormatJSON OutputFormat = "json" FormatYAML OutputFormat = "yaml" FormatQuiet OutputFormat = "quiet" )
type OutputOptions ¶
type OutputOptions struct {
// Format specifies the output format
Format OutputFormat
// NoColor disables colored output
NoColor bool
// Writer is the destination for output
Writer io.Writer
}
OutputOptions configures output behavior.
type OutputWriter ¶
type OutputWriter interface {
// Write outputs a single object (struct, map, etc.)
Write(data any) error
// WriteList outputs a list of objects as a table or list format.
// columns specifies which fields to display and their order.
WriteList(data any, columns []Column) error
// WriteError outputs an error message in the appropriate format.
WriteError(err error) error
}
OutputWriter handles formatted output for CLI commands.
type QuietFielder ¶
type QuietFielder interface {
// QuietField returns the field value to output in quiet mode (usually ID)
QuietField() string
}
QuietFielder can be implemented by types to specify their quiet-mode output.
type SchedulerClient ¶
type SchedulerClient interface {
// ListSchedulerConfigurations retrieves all scheduler configurations.
ListSchedulerConfigurations(ctx context.Context) ([]domain.SchedulerConfiguration, error)
// GetSchedulerConfiguration retrieves a specific scheduler configuration.
GetSchedulerConfiguration(ctx context.Context, configID string) (*domain.SchedulerConfiguration, error)
// CreateSchedulerConfiguration creates a new scheduler configuration.
CreateSchedulerConfiguration(ctx context.Context, req *domain.CreateSchedulerConfigurationRequest) (*domain.SchedulerConfiguration, error)
// UpdateSchedulerConfiguration updates an existing scheduler configuration.
UpdateSchedulerConfiguration(ctx context.Context, configID string, req *domain.UpdateSchedulerConfigurationRequest) (*domain.SchedulerConfiguration, error)
// DeleteSchedulerConfiguration deletes a scheduler configuration.
DeleteSchedulerConfiguration(ctx context.Context, configID string) error
// CreateSchedulerSession creates a new scheduler session.
CreateSchedulerSession(ctx context.Context, req *domain.CreateSchedulerSessionRequest) (*domain.SchedulerSession, error)
// GetSchedulerSession retrieves a specific scheduler session.
GetSchedulerSession(ctx context.Context, sessionID string) (*domain.SchedulerSession, error)
// ListBookings retrieves all bookings for a configuration.
ListBookings(ctx context.Context, configID string) ([]domain.Booking, error)
// GetBooking retrieves a specific booking.
GetBooking(ctx context.Context, bookingID string) (*domain.Booking, error)
// ConfirmBooking confirms a booking.
ConfirmBooking(ctx context.Context, bookingID string, req *domain.ConfirmBookingRequest) (*domain.Booking, error)
// RescheduleBooking reschedules an existing booking.
RescheduleBooking(ctx context.Context, bookingID string, req *domain.RescheduleBookingRequest) (*domain.Booking, error)
// CancelBooking cancels a booking.
CancelBooking(ctx context.Context, bookingID string, reason string) error
// ListSchedulerPages retrieves all scheduler pages.
ListSchedulerPages(ctx context.Context) ([]domain.SchedulerPage, error)
// GetSchedulerPage retrieves a specific scheduler page.
GetSchedulerPage(ctx context.Context, pageID string) (*domain.SchedulerPage, error)
// CreateSchedulerPage creates a new scheduler page.
CreateSchedulerPage(ctx context.Context, req *domain.CreateSchedulerPageRequest) (*domain.SchedulerPage, error)
// UpdateSchedulerPage updates an existing scheduler page.
UpdateSchedulerPage(ctx context.Context, pageID string, req *domain.UpdateSchedulerPageRequest) (*domain.SchedulerPage, error)
// DeleteSchedulerPage deletes a scheduler page.
DeleteSchedulerPage(ctx context.Context, pageID string) error
}
SchedulerClient defines the interface for scheduler operations.
type SecretStore ¶
type SecretStore interface {
// Set stores a secret value for the given key.
Set(key, value string) error
// Get retrieves a secret value for the given key.
Get(key string) (string, error)
// Delete removes a secret for the given key.
Delete(key string) error
// IsAvailable checks if the secret store is available.
IsAvailable() bool
// Name returns the name of the secret store backend.
Name() string
}
SecretStore defines the interface for storing secrets securely.
type SlackClient ¶
type SlackClient interface {
// TestAuth validates the workspace token and returns authentication details.
// Use this to verify token validity before other operations.
TestAuth(ctx context.Context) (*domain.SlackAuth, error)
// ListChannels returns all accessible channels in the workspace.
// Use params to filter by type, exclude archived, or paginate results.
ListChannels(ctx context.Context, params *domain.SlackChannelQueryParams) (*domain.SlackChannelListResponse, error)
// GetChannel returns a single channel by ID.
// Returns an error if the channel doesn't exist or is not accessible.
GetChannel(ctx context.Context, channelID string) (*domain.SlackChannel, error)
// ListMyChannels returns only channels the current user is a member of.
// Faster than ListChannels for large workspaces.
ListMyChannels(ctx context.Context, params *domain.SlackChannelQueryParams) (*domain.SlackChannelListResponse, error)
// GetMessages returns messages from a channel in reverse chronological order.
// Use params to specify time range, limit, and pagination cursor.
GetMessages(ctx context.Context, params *domain.SlackMessageQueryParams) (*domain.SlackMessageListResponse, error)
// GetThreadReplies returns replies in a message thread.
// threadTS is the timestamp of the parent message. Replies are in chronological order.
GetThreadReplies(ctx context.Context, channelID, threadTS string, limit int) ([]domain.SlackMessage, error)
// SendMessage posts a new message to a channel.
// Returns the sent message with its timestamp ID.
SendMessage(ctx context.Context, req *domain.SlackSendMessageRequest) (*domain.SlackMessage, error)
// UpdateMessage edits an existing message.
// messageTS is the timestamp ID of the message to edit.
UpdateMessage(ctx context.Context, channelID, messageTS, newText string) (*domain.SlackMessage, error)
// DeleteMessage removes a message from a channel.
// Only the message author or workspace admins can delete messages.
DeleteMessage(ctx context.Context, channelID, messageTS string) error
// ListUsers returns workspace members, excluding deleted/deactivated users.
// Use limit and cursor for pagination through large workspaces.
ListUsers(ctx context.Context, limit int, cursor string) (*domain.SlackUserListResponse, error)
// GetUser returns a single user by their Slack user ID.
// Returns an error if the user doesn't exist.
GetUser(ctx context.Context, userID string) (*domain.SlackUser, error)
// GetCurrentUser returns the user associated with the current token.
GetCurrentUser(ctx context.Context) (*domain.SlackUser, error)
// SearchMessages searches for messages matching a query string.
// Query supports Slack search syntax (e.g., "from:@user", "in:#channel").
SearchMessages(ctx context.Context, query string, limit int) ([]domain.SlackMessage, error)
// ListFiles returns files uploaded to a channel or workspace.
// Use params to filter by channel, user, or file type.
ListFiles(ctx context.Context, params *domain.SlackFileQueryParams) (*domain.SlackFileListResponse, error)
// GetFileInfo returns metadata for a single file by its ID.
// Returns an error if the file doesn't exist or is not accessible.
GetFileInfo(ctx context.Context, fileID string) (*domain.SlackAttachment, error)
// DownloadFile downloads file content from a private download URL.
// The caller must close the returned ReadCloser when done.
DownloadFile(ctx context.Context, downloadURL string) (io.ReadCloser, error)
}
SlackClient defines the contract for Slack API operations. Implementations handle authentication, rate limiting, and Slack API error responses.
type TemplateStore ¶
type TemplateStore interface {
// List returns all templates, optionally filtered by category.
// If category is empty, all templates are returned.
List(ctx context.Context, category string) ([]domain.EmailTemplate, error)
// Get retrieves a template by its ID.
Get(ctx context.Context, id string) (*domain.EmailTemplate, error)
// Create creates a new template and returns it with generated ID.
Create(ctx context.Context, t *domain.EmailTemplate) (*domain.EmailTemplate, error)
// Update updates an existing template.
Update(ctx context.Context, t *domain.EmailTemplate) (*domain.EmailTemplate, error)
// Delete removes a template by its ID.
Delete(ctx context.Context, id string) error
// IncrementUsage increments the usage count for a template.
IncrementUsage(ctx context.Context, id string) error
// Path returns the path to the templates file.
Path() string
}
TemplateStore defines the interface for email template storage. Templates are stored locally (not in Nylas API) for use with email sending.
type TimeZoneService ¶
type TimeZoneService interface {
// ConvertTime converts a time from one zone to another
ConvertTime(ctx context.Context, fromZone, toZone string, t time.Time) (time.Time, error)
// FindMeetingTime finds overlapping working hours across multiple time zones
FindMeetingTime(ctx context.Context, req *domain.MeetingFinderRequest) (*domain.MeetingTimeSlots, error)
// GetDSTTransitions returns DST transition dates for a zone in a given year
GetDSTTransitions(ctx context.Context, zone string, year int) ([]domain.DSTTransition, error)
// ListTimeZones returns all available IANA time zones
ListTimeZones(ctx context.Context) ([]string, error)
// GetTimeZoneInfo returns detailed information about a time zone
GetTimeZoneInfo(ctx context.Context, zone string, at time.Time) (*domain.TimeZoneInfo, error)
}
TimeZoneService provides time zone conversion and meeting finder utilities. Addresses the pain point where 83% of professionals struggle with time zone scheduling.
type Tunnel ¶
type Tunnel interface {
// Start starts the tunnel and returns the public URL.
Start(ctx context.Context) (publicURL string, err error)
// Stop stops the tunnel.
Stop() error
// GetPublicURL returns the current public URL.
GetPublicURL() string
// Status returns the current tunnel status.
Status() TunnelStatus
// StatusMessage returns a human-readable status message.
StatusMessage() string
}
Tunnel defines the interface for managing a tunnel to expose local server.
type TunnelConfig ¶
type TunnelConfig struct {
Provider string // cloudflared or ngrok
LocalURL string // Local URL to tunnel to
}
TunnelConfig holds configuration for a tunnel.
type TunnelStatus ¶
type TunnelStatus string
TunnelStatus represents the current tunnel status.
const ( TunnelStatusStarting TunnelStatus = "starting" TunnelStatusConnected TunnelStatus = "connected" TunnelStatusReconnecting TunnelStatus = "reconnecting" TunnelStatusDisconnected TunnelStatus = "disconnected" TunnelStatusError TunnelStatus = "error" )
type UtilityServices ¶
type UtilityServices interface {
TimeZoneService
}
UtilityServices defines interfaces for non-Nylas utility features. These services provide offline-capable tools that don't require Nylas API access.
type WebhookClient ¶
type WebhookClient interface {
// ListWebhooks retrieves all webhooks.
ListWebhooks(ctx context.Context) ([]domain.Webhook, error)
// GetWebhook retrieves a specific webhook.
GetWebhook(ctx context.Context, webhookID string) (*domain.Webhook, error)
// CreateWebhook creates a new webhook.
CreateWebhook(ctx context.Context, req *domain.CreateWebhookRequest) (*domain.Webhook, error)
// UpdateWebhook updates an existing webhook.
UpdateWebhook(ctx context.Context, webhookID string, req *domain.UpdateWebhookRequest) (*domain.Webhook, error)
// DeleteWebhook deletes a webhook.
DeleteWebhook(ctx context.Context, webhookID string) error
// SendWebhookTestEvent sends a test event to a webhook URL.
SendWebhookTestEvent(ctx context.Context, webhookURL string) error
// GetWebhookMockPayload retrieves a mock payload for a webhook trigger type.
GetWebhookMockPayload(ctx context.Context, triggerType string) (map[string]any, error)
}
WebhookClient defines the interface for webhook operations.
type WebhookEvent ¶
type WebhookEvent struct {
ID string `json:"id"`
Type string `json:"type"`
Timestamp time.Time `json:"timestamp"`
Source string `json:"source"`
GrantID string `json:"grant_id,omitempty"`
Headers map[string]string `json:"headers"`
Body map[string]any `json:"body"`
RawBody []byte `json:"-"`
Signature string `json:"signature,omitempty"`
Verified bool `json:"verified"`
ReceivedAt time.Time `json:"received_at"`
}
WebhookEvent represents a received webhook event.
type WebhookEventHandler ¶
type WebhookEventHandler func(event *WebhookEvent)
WebhookEventHandler is called when a webhook event is received.
type WebhookServer ¶
type WebhookServer interface {
// Start starts the webhook server.
Start(ctx context.Context) error
// Stop stops the webhook server.
Stop() error
// GetLocalURL returns the local server URL.
GetLocalURL() string
// GetPublicURL returns the public URL (from tunnel, if any).
GetPublicURL() string
// GetStats returns server statistics.
GetStats() WebhookServerStats
// OnEvent registers a handler for webhook events.
OnEvent(handler WebhookEventHandler)
// Events returns a channel for receiving webhook events.
Events() <-chan *WebhookEvent
}
WebhookServer defines the interface for a local webhook receiver server.
type WebhookServerConfig ¶
type WebhookServerConfig struct {
Port int
Path string // Webhook endpoint path (default: /webhook)
WebhookSecret string // For signature verification
TunnelProvider string // cloudflared, ngrok, or empty for no tunnel
}
WebhookServerConfig holds configuration for the webhook server.