Documentation
¶
Index ¶
- Variables
- type AckResponse
- type Client
- func (c *Client) AddMember(projectID, email, role string) (*MemberResponse, error)
- func (c *Client) CreateProject(name, description string) (*ProjectResponse, error)
- func (c *Client) GetSnapshot(projectID string) (*SnapshotResponse, error)
- func (c *Client) HealthCheck() (*HealthResponse, error)
- func (c *Client) ListMembers(projectID string) ([]MemberResponse, error)
- func (c *Client) ListProjects() ([]ProjectResponse, error)
- func (c *Client) LoginPoll(deviceCode string) (*LoginPollResponse, error)
- func (c *Client) LoginStart(email string) (*LoginStartResponse, error)
- func (c *Client) Pull(projectID string, afterSeq int64, limit int, excludeDeviceID string) (*PullResponse, error)
- func (c *Client) Push(projectID string, req *PushRequest) (*PushResponse, error)
- func (c *Client) RemoveMember(projectID, userID string) error
- func (c *Client) SyncStatus(projectID string) (*SyncStatusResponse, error)
- func (c *Client) UpdateMemberRole(projectID, userID, role string) error
- type EventInput
- type HealthResponse
- type LoginPollResponse
- type LoginStartResponse
- type MemberResponse
- type ProjectResponse
- type PullEvent
- type PullResponse
- type PushRequest
- type PushResponse
- type RejectResponse
- type SnapshotResponse
- type SyncStatusResponse
Constants ¶
This section is empty.
Variables ¶
var ( ErrForbidden = errors.New("forbidden") ErrNotFound = errors.New("not found") )
Sentinel errors for common HTTP error classes.
Functions ¶
This section is empty.
Types ¶
type AckResponse ¶
type AckResponse struct {
ClientActionID int64 `json:"client_action_id"`
ServerSeq int64 `json:"server_seq"`
}
AckResponse is a single acknowledged event.
type Client ¶
Client is an HTTP client for the td-sync server.
func (*Client) AddMember ¶
func (c *Client) AddMember(projectID, email, role string) (*MemberResponse, error)
AddMember invites a user to a project by email.
func (*Client) CreateProject ¶
func (c *Client) CreateProject(name, description string) (*ProjectResponse, error)
CreateProject creates a new project on the server.
func (*Client) GetSnapshot ¶
func (c *Client) GetSnapshot(projectID string) (*SnapshotResponse, error)
GetSnapshot downloads a snapshot database for bootstrap.
func (*Client) HealthCheck ¶
func (c *Client) HealthCheck() (*HealthResponse, error)
HealthCheck hits the /healthz endpoint to verify server reachability.
func (*Client) ListMembers ¶
func (c *Client) ListMembers(projectID string) ([]MemberResponse, error)
ListMembers lists all members of a project.
func (*Client) ListProjects ¶
func (c *Client) ListProjects() ([]ProjectResponse, error)
ListProjects lists all projects for the authenticated user.
func (*Client) LoginPoll ¶
func (c *Client) LoginPoll(deviceCode string) (*LoginPollResponse, error)
LoginPoll checks the status of a device auth request. No API key required.
func (*Client) LoginStart ¶
func (c *Client) LoginStart(email string) (*LoginStartResponse, error)
LoginStart initiates device auth flow. No API key required.
func (*Client) Pull ¶
func (c *Client) Pull(projectID string, afterSeq int64, limit int, excludeDeviceID string) (*PullResponse, error)
Pull fetches remote events from the server.
func (*Client) Push ¶
func (c *Client) Push(projectID string, req *PushRequest) (*PushResponse, error)
Push sends local events to the server.
func (*Client) RemoveMember ¶
RemoveMember removes a user from a project.
func (*Client) SyncStatus ¶
func (c *Client) SyncStatus(projectID string) (*SyncStatusResponse, error)
SyncStatus gets the sync status for a project.
func (*Client) UpdateMemberRole ¶
UpdateMemberRole changes a member's role in a project.
type EventInput ¶
type EventInput struct {
ClientActionID int64 `json:"client_action_id"`
ActionType string `json:"action_type"`
EntityType string `json:"entity_type"`
EntityID string `json:"entity_id"`
Payload json.RawMessage `json:"payload"`
ClientTimestamp string `json:"client_timestamp"`
}
EventInput is a single event in a push request.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
}
HealthResponse is the response from GET /healthz.
type LoginPollResponse ¶
type LoginPollResponse struct {
Status string `json:"status"`
APIKey *string `json:"api_key,omitempty"`
UserID *string `json:"user_id,omitempty"`
Email *string `json:"email,omitempty"`
ExpiresAt *string `json:"expires_at,omitempty"`
}
LoginPollResponse is the response from POST /v1/auth/login/poll.
type LoginStartResponse ¶
type LoginStartResponse struct {
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
ExpiresIn int `json:"expires_in"`
Interval int `json:"interval"`
}
LoginStartResponse is the response from POST /v1/auth/login/start.
type MemberResponse ¶
type MemberResponse struct {
ProjectID string `json:"project_id"`
UserID string `json:"user_id"`
Role string `json:"role"`
InvitedBy string `json:"invited_by"`
CreatedAt string `json:"created_at"`
}
MemberResponse represents a project member from the server.
type ProjectResponse ¶
type ProjectResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
DeletedAt *string `json:"deleted_at,omitempty"`
}
ProjectResponse represents a project from the server.
type PullEvent ¶
type PullEvent struct {
ServerSeq int64 `json:"server_seq"`
DeviceID string `json:"device_id"`
SessionID string `json:"session_id"`
ClientActionID int64 `json:"client_action_id"`
ActionType string `json:"action_type"`
EntityType string `json:"entity_type"`
EntityID string `json:"entity_id"`
Payload json.RawMessage `json:"payload"`
ClientTimestamp string `json:"client_timestamp"`
}
PullEvent is a single event in a pull response.
type PullResponse ¶
type PullResponse struct {
Events []PullEvent `json:"events"`
LastServerSeq int64 `json:"last_server_seq"`
HasMore bool `json:"has_more"`
}
PullResponse is the response from a pull request.
type PushRequest ¶
type PushRequest struct {
DeviceID string `json:"device_id"`
SessionID string `json:"session_id"`
Events []EventInput `json:"events"`
}
PushRequest is the body for POST /v1/projects/{id}/sync/push.
type PushResponse ¶
type PushResponse struct {
Accepted int `json:"accepted"`
Acks []AckResponse `json:"acks"`
Rejected []RejectResponse `json:"rejected,omitempty"`
}
PushResponse is the response from a push request.
type RejectResponse ¶
type RejectResponse struct {
ClientActionID int64 `json:"client_action_id"`
Reason string `json:"reason"`
ServerSeq int64 `json:"server_seq,omitempty"`
}
RejectResponse is a single rejected event.
type SnapshotResponse ¶
SnapshotResponse holds the result of a snapshot download.
type SyncStatusResponse ¶
type SyncStatusResponse struct {
EventCount int64 `json:"event_count"`
LastServerSeq int64 `json:"last_server_seq"`
LastEventTime string `json:"last_event_time,omitempty"`
}
SyncStatusResponse is the response from GET /v1/projects/{id}/sync/status.