Documentation ¶
Index ¶
- Variables
- func MirrorTaskSyncer(api *api.API, store *Storage) *mirrorTaskSyncer
- func ModelTaskSetupLazyload(ctx context.Context, store *Storage, model *Task)
- type ChangeManager
- func (s *ChangeManager) ApplyChangesInTeam(ctx context.Context, opts *SyncPreferences, teamID string)
- func (s *ChangeManager) AuthorizeTask(ctx context.Context, task *Task) (_ *Task, changed bool)
- func (s *ChangeManager) ForceSyncForAllTasks(ctx context.Context, opts *SyncPreferences, teamID string)
- func (s *ChangeManager) Sync(ctx context.Context, opts *SyncPreferences, oldTask, task *Task, changed bool)
- type DocRef
- type Folder
- type List
- type LoadStatusOfChangedTeamTasks
- type Member
- type MirrorTask
- func (t *MirrorTask) CollectionName() string
- func (t *MirrorTask) GetMirrorTask(ctx context.Context) *Task
- func (t *MirrorTask) GetOrigTask(ctx context.Context) *Task
- func (t *MirrorTask) ModelID() string
- func (*MirrorTask) NewModel() StoreModel
- func (t *MirrorTask) ParseID(in string) (taskID, mirrorTaskID string, err error)
- func (t *MirrorTask) SetModelID(in string)
- type MirrorTaskSpecification
- type MirrorTaskStatus
- type MirrorTaskStatuses
- type StdStoreModel
- type Storage
- func (s *Storage) AllMatchesForMirrorTasks(ctx context.Context, taskID string) (_ []*MirrorTask, _ bool)
- func (s *Storage) AllTeamTasks(ctx context.Context, teamID string) []*Task
- func (s *Storage) DeleteFolder(ctx context.Context, model *Folder) error
- func (s *Storage) DeleteList(ctx context.Context, model *List) error
- func (s *Storage) DeleteMember(ctx context.Context, model *Member) error
- func (s *Storage) DeleteTask(ctx context.Context, model *Task) error
- func (s *Storage) DeleteTeam(ctx context.Context, model *Team) error
- func (s *Storage) FetchListMembers(ctx context.Context, list []*DocRef) []*Member
- func (s *Storage) FetchListTasks(ctx context.Context, list []*DocRef) []*Task
- func (s *Storage) GetFolder(ctx context.Context, modelID string) *Folder
- func (s *Storage) GetList(ctx context.Context, modelID string) *List
- func (s *Storage) GetMember(ctx context.Context, modelID string) *Member
- func (s *Storage) GetMirrorTask(ctx context.Context, modelID string) *MirrorTask
- func (s *Storage) GetStateOfLoadChangesForTeamTasks(ctx context.Context, teamID string) *LoadStatusOfChangedTeamTasks
- func (s *Storage) GetTask(ctx context.Context, modelID string) *Task
- func (s *Storage) GetTeam(ctx context.Context, modelID string) *Team
- func (s *Storage) LoadSubTasks(ctx context.Context, task *Task)
- func (s *Storage) MemberByEmail(ctx context.Context, email string) *Member
- func (s *Storage) ModelMirrorTaskFor(taskID, mirrorTaskID string) *MirrorTask
- func (s *Storage) UnlinkMirroredTask(ctx context.Context, taskID, mirrorTaskID string) error
- func (s *Storage) UpsertFolder(ctx context.Context, model *Folder) error
- func (s *Storage) UpsertList(ctx context.Context, model *List) error
- func (s *Storage) UpsertLoadStatusOfChangedTeamTasks(ctx context.Context, model *LoadStatusOfChangedTeamTasks) error
- func (s *Storage) UpsertMember(ctx context.Context, model *Member) error
- func (s *Storage) UpsertMirrorTask(ctx context.Context, model *MirrorTask) error
- func (s *Storage) UpsertTask(ctx context.Context, model *Task) error
- func (s *Storage) UpsertTeam(ctx context.Context, model *Team) error
- type StoreModel
- type StoreModelCustomID
- type SyncPreferences
- type SyncRule_CondOfAdd
- func (s *SyncRule_CondOfAdd) GetIfInFolderIDs() []string
- func (s *SyncRule_CondOfAdd) GetIfInListsIDs() []string
- func (s *SyncRule_CondOfAdd) PassedCheckByFolderID(in string) bool
- func (s *SyncRule_CondOfAdd) PassedCheckByListID(in string) bool
- func (s *SyncRule_CondOfAdd) PassedCheckByStatus(in string) bool
- type SyncRule_CondTrackChanges
- func (s *SyncRule_CondTrackChanges) GetIfInFolderIDs() []string
- func (s *SyncRule_CondTrackChanges) GetIfInListsIDs() []string
- func (s *SyncRule_CondTrackChanges) PassedCheckByFolderID(in string) bool
- func (s *SyncRule_CondTrackChanges) PassedCheckByListID(in string) bool
- func (s *SyncRule_CondTrackChanges) PassedCheckByStatus(in string) bool
- type SyncRule_SpecOfAdd
- type Task
- func (t *Task) AssignedByEmail(in string) bool
- func (t *Task) CollectionName() string
- func (t *Task) EqualUpdatedAt(in *Timestamp) bool
- func (t *Task) GetAssignees() []*Member
- func (t *Task) GetFolder(ctx context.Context) *Folder
- func (t *Task) GetLinkedTasks() []*Task
- func (t *Task) GetList(ctx context.Context) *List
- func (t *Task) GetMember(ctx context.Context) *Member
- func (t *Task) GetParentTask(ctx context.Context) *Task
- func (t *Task) GetSubTasks() []*Task
- func (t *Task) GetTeam(ctx context.Context) *Team
- func (t *Task) IsDeletedOrHidden() bool
- func (t *Task) MarkdownTaskID() string
- func (t *Task) MirrorTaskDescription() string
- func (t *Task) MirrorTaskName(ctx context.Context) string
- func (*Task) NewModel() StoreModel
- func (t *Task) TeamID() string
- func (t *Task) TotalEstimate() int64
- type Team
- type Timestamp
- type WebhookManager
Constants ¶
This section is empty.
Variables ¶
var ( TaskModel = (*Task)(nil) ListModel = (*List)(nil) FolderModel = (*Folder)(nil) TeamModel = (*Team)(nil) MemberModel = (*Member)(nil) )
var ErrInvalidContent = errors.New("invalid content")
var ErrSignatureMismatch = errors.New("webhook signature mismatch")
var (
LoadStatusOfChangedTeamTasksModel = (*LoadStatusOfChangedTeamTasks)(nil)
)
var (
MirrorTaskModel = (*MirrorTask)(nil)
)
var NewWithID = storage.NewWithID
Functions ¶
func MirrorTaskSyncer ¶
Types ¶
type ChangeManager ¶
type ChangeManager struct {
// contains filtered or unexported fields
}
func NewChangeManager ¶
func NewChangeManager(api *api.API, s *Storage) *ChangeManager
func (*ChangeManager) ApplyChangesInTeam ¶
func (s *ChangeManager) ApplyChangesInTeam(ctx context.Context, opts *SyncPreferences, teamID string)
ApplyChangesInTeam fetchs the latest changed tasks and handle. Save the date of the last changed task.
Processing details: - call to ClickUp API "give me changes tasks" - fetch and upsert related (list, folder, members) data if not exists - processing for each tasks
- lookup for rules to add mirror tasks and add if need
- lookup for rules to track changes for mirror tasks or for tasks that have a mirror task and process if need
func (*ChangeManager) AuthorizeTask ¶
func (*ChangeManager) ForceSyncForAllTasks ¶ added in v0.0.2
func (s *ChangeManager) ForceSyncForAllTasks(ctx context.Context, opts *SyncPreferences, teamID string)
ForceSyncForAllTasks force update each task from the database and apply processing to it. Not found tasks from ClickUp API to marked as deleted.
func (*ChangeManager) Sync ¶
func (s *ChangeManager) Sync(ctx context.Context, opts *SyncPreferences, oldTask, task *Task, changed bool)
type DocRef ¶
type DocRef = storage.DocumentRef
type Folder ¶
type Folder struct { StdStoreModel Name string Archived bool }
func (*Folder) CollectionName ¶
func (*Folder) NewModel ¶
func (*Folder) NewModel() StoreModel
type List ¶
type List struct { StdStoreModel Name string Archived bool FolderRef *DocRef Folder *Folder `firestore:"-"` }
func (*List) CollectionName ¶
func (*List) NewModel ¶
func (*List) NewModel() StoreModel
type LoadStatusOfChangedTeamTasks ¶
type LoadStatusOfChangedTeamTasks struct { StoreModelCustomID TeamID string `firestore:"-"` TeamRef *DocRef // stores the value from the API LastTaskUpdatedAt int64 }
func (LoadStatusOfChangedTeamTasks) CollectionName ¶
func (LoadStatusOfChangedTeamTasks) CollectionName() string
func (*LoadStatusOfChangedTeamTasks) ModelID ¶
func (t *LoadStatusOfChangedTeamTasks) ModelID() string
func (*LoadStatusOfChangedTeamTasks) NewModel ¶
func (m *LoadStatusOfChangedTeamTasks) NewModel() StoreModel
func (*LoadStatusOfChangedTeamTasks) SetModelID ¶
func (m *LoadStatusOfChangedTeamTasks) SetModelID(in string)
type Member ¶
type Member struct { StdStoreModel Username string Email string Initials string }
func (*Member) CollectionName ¶
func (*Member) NewModel ¶
func (*Member) NewModel() StoreModel
type MirrorTask ¶
type MirrorTask struct { StoreModelCustomID TaskID, MirrorTaskID string `firestore:"-"` TaskRef *DocRef Task *Task `firestore:"-"` MirrorTaskRef *DocRef MirrorTask *Task `firestore:"-"` Destroyed bool DestroyedReason string DestroyedAt *Timestamp // contains filtered or unexported fields }
func (*MirrorTask) CollectionName ¶
func (t *MirrorTask) CollectionName() string
func (*MirrorTask) GetMirrorTask ¶
func (t *MirrorTask) GetMirrorTask(ctx context.Context) *Task
func (*MirrorTask) GetOrigTask ¶ added in v0.0.15
func (t *MirrorTask) GetOrigTask(ctx context.Context) *Task
func (*MirrorTask) ModelID ¶
func (t *MirrorTask) ModelID() string
func (*MirrorTask) NewModel ¶
func (*MirrorTask) NewModel() StoreModel
func (*MirrorTask) ParseID ¶
func (t *MirrorTask) ParseID(in string) (taskID, mirrorTaskID string, err error)
func (*MirrorTask) SetModelID ¶
func (t *MirrorTask) SetModelID(in string)
type MirrorTaskSpecification ¶
type MirrorTaskSpecification struct { Name string `yaml:"name"` CondAdd *SyncRule_CondOfAdd `yaml:"cond_add"` CondTrackChanges *SyncRule_CondTrackChanges `yaml:"cond_track_changes"` SpecAdd *SyncRule_SpecOfAdd `yaml:"spec_add"` }
func (*MirrorTaskSpecification) UsedTeamIDs ¶
func (r *MirrorTaskSpecification) UsedTeamIDs() []string
type MirrorTaskStatus ¶ added in v0.0.15
type MirrorTaskStatuses ¶ added in v0.0.15
type MirrorTaskStatuses map[string]MirrorTaskStatus
func (MirrorTaskStatuses) AllowedSyncEstimate ¶ added in v0.0.15
func (s MirrorTaskStatuses) AllowedSyncEstimate(mirrorTaskStatus string) bool
func (MirrorTaskStatuses) SetStatusToOrigTaskIfExists ¶ added in v0.0.15
func (s MirrorTaskStatuses) SetStatusToOrigTaskIfExists(mirrorTaskStatus string) string
returns "" if nothing needs to be done
type StdStoreModel ¶
type Storage ¶
- method Get<ModelName> - returns model by ID - method GetStateOf<ModelName> - returns status of loading of changes for the model - method Upsert<ModelName> - create or overwrite model by ID
func NewStorage ¶
func (*Storage) AllMatchesForMirrorTasks ¶
func (s *Storage) AllMatchesForMirrorTasks(ctx context.Context, taskID string) (_ []*MirrorTask, _ bool)
AllMatchesForMirrorTasks returns union list mirror tasks by task ID and by mirror task ID.
func (*Storage) AllTeamTasks ¶
func (*Storage) DeleteFolder ¶
alias to DeleteModel
func (*Storage) DeleteList ¶
alias to DeleteModel
func (*Storage) DeleteMember ¶
alias to DeleteModel
func (*Storage) DeleteTask ¶
alias to DeleteModel
func (*Storage) DeleteTeam ¶
alias to DeleteModel
func (*Storage) FetchListMembers ¶
func (*Storage) FetchListTasks ¶
func (*Storage) GetMirrorTask ¶
func (s *Storage) GetMirrorTask(ctx context.Context, modelID string) *MirrorTask
alias to GetModel for custom model
func (*Storage) GetStateOfLoadChangesForTeamTasks ¶
func (s *Storage) GetStateOfLoadChangesForTeamTasks(ctx context.Context, teamID string) *LoadStatusOfChangedTeamTasks
a new model instance and call GetModel
func (*Storage) MemberByEmail ¶
func (*Storage) ModelMirrorTaskFor ¶
func (s *Storage) ModelMirrorTaskFor(taskID, mirrorTaskID string) *MirrorTask
ModelMirrorTaskFor returns prepared MirrorTask model with the corrects populate of the primary information. Because the user logic for preparing the storage model ID
func (*Storage) UnlinkMirroredTask ¶
alias to DeleteModel for custom model
func (*Storage) UpsertFolder ¶
alias to UpsertModel
func (*Storage) UpsertList ¶
alias to UpsertModel
func (*Storage) UpsertLoadStatusOfChangedTeamTasks ¶
func (s *Storage) UpsertLoadStatusOfChangedTeamTasks(ctx context.Context, model *LoadStatusOfChangedTeamTasks) error
alias to UpsertModel
func (*Storage) UpsertMember ¶
alias to UpsertModel
func (*Storage) UpsertMirrorTask ¶
func (s *Storage) UpsertMirrorTask(ctx context.Context, model *MirrorTask) error
alias to UpsertModel
func (*Storage) UpsertTask ¶
alias to UpsertModel
type StoreModel ¶
type StoreModelCustomID ¶
type StoreModelCustomID = storage.ModelCustomID
type SyncPreferences ¶
type SyncPreferences struct { MirrorTaskRules []MirrorTaskSpecification `yaml:"mirror_task_rules"` // ASSERTS: all mirror tasks have the same status life cycle GlobalMirrorTaskStatuses MirrorTaskStatuses `yaml:"global_mirror_task_statuses"` }
func ParseSyncPreferences ¶
func ParseSyncPreferences(in io.Reader) (*SyncPreferences, error)
func (*SyncPreferences) AllUsedTeamIDs ¶
func (s *SyncPreferences) AllUsedTeamIDs() []string
type SyncRule_CondOfAdd ¶
type SyncRule_CondOfAdd struct { // Example: https://app.clickup.com/2431928/v/f/96471870/42552884 IfInFolders []string `yaml:"if_in_folders"` // Example: https://app.clickup.com/2431928/v/li/174318787 IfInLists []string `yaml:"if_in_lists"` EqAnyTaskStatusNames []string `yaml:"eq_any_task_status_names"` IfAssignedToMemberEmail string `yaml:"if_assigned_to_member_email"` }
func (*SyncRule_CondOfAdd) GetIfInFolderIDs ¶
func (s *SyncRule_CondOfAdd) GetIfInFolderIDs() []string
func (*SyncRule_CondOfAdd) GetIfInListsIDs ¶
func (s *SyncRule_CondOfAdd) GetIfInListsIDs() []string
func (*SyncRule_CondOfAdd) PassedCheckByFolderID ¶
func (s *SyncRule_CondOfAdd) PassedCheckByFolderID(in string) bool
func (*SyncRule_CondOfAdd) PassedCheckByListID ¶
func (s *SyncRule_CondOfAdd) PassedCheckByListID(in string) bool
func (*SyncRule_CondOfAdd) PassedCheckByStatus ¶
func (s *SyncRule_CondOfAdd) PassedCheckByStatus(in string) bool
type SyncRule_CondTrackChanges ¶
type SyncRule_CondTrackChanges struct { // Example: https://app.clickup.com/2431928/v/f/96471870/42552884 IfInFolders []string `yaml:"if_in_folders"` // Example: https://app.clickup.com/2431928/v/li/174318787 IfInLists []string `yaml:"if_in_lists"` EqAnyTaskStatusNames []string `yaml:"eq_any_task_status_names"` IfAssignedToMemberEmail string `yaml:"if_assigned_to_member_email"` }
func (*SyncRule_CondTrackChanges) GetIfInFolderIDs ¶
func (s *SyncRule_CondTrackChanges) GetIfInFolderIDs() []string
func (*SyncRule_CondTrackChanges) GetIfInListsIDs ¶
func (s *SyncRule_CondTrackChanges) GetIfInListsIDs() []string
func (*SyncRule_CondTrackChanges) PassedCheckByFolderID ¶
func (s *SyncRule_CondTrackChanges) PassedCheckByFolderID(in string) bool
func (*SyncRule_CondTrackChanges) PassedCheckByListID ¶
func (s *SyncRule_CondTrackChanges) PassedCheckByListID(in string) bool
func (*SyncRule_CondTrackChanges) PassedCheckByStatus ¶
func (s *SyncRule_CondTrackChanges) PassedCheckByStatus(in string) bool
type SyncRule_SpecOfAdd ¶
type SyncRule_SpecOfAdd struct { // synced tasks to list AddToList string `yaml:"add_to_list"` SetStatusName string `yaml:"set_status_name"` AssignToMemberEmail string `yaml:"assign_to_member_email"` }
func (*SyncRule_SpecOfAdd) GetAddToListID ¶
func (s *SyncRule_SpecOfAdd) GetAddToListID() string
type Task ¶
type Task struct { StdStoreModel Name string CustomID *string Description string TextContent string StatusType string StatusName string DateCreatedAt *Timestamp DateUpdatedAt *Timestamp DateClosedAt *Timestamp DueDateAt *Timestamp StartDateAt *Timestamp TimeEstimateMs *int64 Archived bool Deleted bool CreatorMemberRef *DocRef AssigneesRef []*DocRef URL string ParentTaskRef *DocRef PriorityID *int Tags []string LinkedTasksRef []*DocRef TeamRef *DocRef ListRef *DocRef FolderRef *DocRef CreatorMember *Member `firestore:"-"` ParentTask *Task `firestore:"-"` Team *Team `firestore:"-"` List *List `firestore:"-"` Folder *Folder `firestore:"-"` // NOTE: concurrent not safe Assignees []*Member `firestore:"-"` SubTasks []*Task `firestore:"-"` LinkedTasks []*Task `firestore:"-"` // contains filtered or unexported fields }
func ModelTaskFromAPI ¶ added in v0.0.2
func (*Task) AssignedByEmail ¶
func (*Task) CollectionName ¶
func (*Task) EqualUpdatedAt ¶
func (*Task) GetAssignees ¶
func (*Task) GetLinkedTasks ¶
func (*Task) GetSubTasks ¶
func (*Task) IsDeletedOrHidden ¶
func (*Task) MarkdownTaskID ¶ added in v0.0.15
func (*Task) MirrorTaskDescription ¶
func (*Task) NewModel ¶
func (*Task) NewModel() StoreModel
func (*Task) TotalEstimate ¶
type Team ¶
type Team struct { StdStoreModel Name string }
func (*Team) CollectionName ¶
func (*Team) NewModel ¶
func (*Team) NewModel() StoreModel
type Timestamp ¶
func TimestampFromTimestampWithMilliseconds ¶
Returns Timestamp from timestamp with millesecond.
Clickup uses timestamp with milleseconds. https://clickup20.docs.apiary.io/#introduction/faq > How are dates formatted in ClickUp? ClickUp will always display dates in Unix time in milliseconds. You can use a website like Epoch Converter to convert dates between Unix and human readable date formats.
func TimestampNow ¶ added in v0.0.7
func TimestampNow() *Timestamp
type WebhookManager ¶
type WebhookManager struct {
// contains filtered or unexported fields
}
func (*WebhookManager) Handle ¶
func (s *WebhookManager) Handle(w http.ResponseWriter, req *http.Request) error