Versions in this module Expand all Collapse all v1 v1.1.1 Oct 30, 2021 v1.1.0 Oct 25, 2021 Changes in this version + var ErrOwner = errors.New("invalid namespace owner") + var ErrUnknownWebhook = errors.New("unknown webhook") + func InitEvent(dis event.Dispatcher) queue.InitFunc + func InitInviteEvent(db *sqlx.DB, dis event.Dispatcher) queue.InitFunc + func WebhookURL(url *url.URL) hookURL + type Event struct + Action string + Namespace *Namespace + func (e *Event) Name() string + func (e *Event) Perform() error + type InviteEvent struct + Action string + Invitee *user.User + Inviter *user.User + Namespace *Namespace + func (ev *InviteEvent) Name() string + func (ev *InviteEvent) Perform() error + type Webhook struct + Active bool + AuthorID int64 + CreatedAt time.Time + Events event.Type + ID int64 + LastDelivery *WebhookDelivery + Namespace *Namespace + NamespaceID int64 + PayloadURL hookURL + SSL bool + Secret []byte + User *user.User + UserID int64 + func WebhookFromContext(ctx context.Context) (*Webhook, bool) + func (w *Webhook) Bind(mm ...database.Model) + func (w *Webhook) Endpoint(uri ...string) string + func (w *Webhook) IsZero() bool + func (w *Webhook) JSON(addr string) map[string]interface{} + func (w *Webhook) Primary() (string, int64) + func (w *Webhook) SetPrimary(id int64) + func (w *Webhook) Values() map[string]interface{} + type WebhookDelivery struct + CreatedAt time.Time + Duration time.Duration + Error sql.NullString + Event event.Type + EventID uuid.UUID + ID int64 + NamespaceID sql.NullInt64 + Payload map[string]interface{} + Redelivery bool + RequestBody sql.NullString + RequestHeaders sql.NullString + ResponseBody sql.NullString + ResponseCode sql.NullInt64 + ResponseHeaders sql.NullString + ResponseStatus string + Webhook *Webhook + WebhookID int64 + func (e *WebhookDelivery) Endpoint(_ ...string) string + type WebhookForm struct + Active bool + Events []string + PayloadURL string + RemoveSecret bool + SSL bool + Secret string + Webhook *Webhook + Webhooks *WebhookStore + func (f WebhookForm) Fields() map[string]string + func (f WebhookForm) Validate() error + type WebhookStore struct + Namespace *Namespace + User *user.User + func NewWebhookStore(db *sqlx.DB, mm ...database.Model) *WebhookStore + func NewWebhookStoreWithCrypto(db *sqlx.DB, crypto *crypto.AESGCM, mm ...database.Model) *WebhookStore + func (s *WebhookStore) All(opts ...query.Option) ([]*Webhook, error) + func (s *WebhookStore) Bind(mm ...database.Model) + func (s *WebhookStore) Create(authorId int64, payloadUrl *url.URL, secret string, ssl bool, ...) (*Webhook, error) + func (s *WebhookStore) Delete(id int64) error + func (s *WebhookStore) Deliveries(id int64) ([]*WebhookDelivery, error) + func (s *WebhookStore) Delivery(hookId, id int64) (*WebhookDelivery, error) + func (s *WebhookStore) Dispatch(ev *event.Event) error + func (s *WebhookStore) Get(opts ...query.Option) (*Webhook, error) + func (s *WebhookStore) LastDelivery(id int64) (*WebhookDelivery, error) + func (s *WebhookStore) LoadLastDeliveries(ww ...*Webhook) error + func (s *WebhookStore) New() *Webhook + func (s *WebhookStore) Redeliver(id int64, eventId uuid.UUID) error + func (s *WebhookStore) Update(id int64, payloadUrl *url.URL, secret string, ssl bool, events event.Type, ...) error v1.0.0 Apr 20, 2021 Changes in this version + var ErrDeleteSelf = errors.New("cannot delete self from namespace") + var ErrDepth = errors.New("namespace cannot exceed depth of 20") + var ErrName = errors.New("namespace name can only contain letters and numbers") + var ErrPermission = errors.New("namespace permissions invalid") + var MaxDepth int64 = 20 + func CollaboratorModel(cc []*Collaborator) func(int) database.Model + func CollaboratorSelect(col string, opts ...query.Option) query.Query + func InviteModel(ii []*Invite) func(int) database.Model + func LoadInviteRelations(loaders *database.Loaders, ii ...*Invite) error + func Model(nn []*Namespace) func(int) database.Model + func SelectRootID(id int64) query.Query + func SharedWith(u *user.User) query.Option + func WhereCollaborator(m database.Model) query.Option + type Collaborator struct + CreatedAt time.Time + ID int64 + Namespace *Namespace + NamespaceID int64 + User *user.User + UserID int64 + func (c *Collaborator) Bind(mm ...database.Model) + func (c *Collaborator) Endpoint(uri ...string) string + func (c *Collaborator) IsZero() bool + func (c *Collaborator) JSON(addr string) map[string]interface{} + func (c *Collaborator) Primary() (string, int64) + func (c *Collaborator) SetPrimary(id int64) + func (c *Collaborator) Values() map[string]interface{} + type CollaboratorStore struct + Namespace *Namespace + User *user.User + func NewCollaboratorStore(db *sqlx.DB, mm ...database.Model) *CollaboratorStore + func (s *CollaboratorStore) All(opts ...query.Option) ([]*Collaborator, error) + func (s *CollaboratorStore) Bind(mm ...database.Model) + func (s *CollaboratorStore) Create(cc ...*Collaborator) error + func (s *CollaboratorStore) Delete(username string, chowns ...func(int64, int64) error) error + func (s *CollaboratorStore) Get(opts ...query.Option) (*Collaborator, error) + func (s *CollaboratorStore) Load(key string, vals []interface{}, load database.LoaderFunc) error + func (s *CollaboratorStore) New() *Collaborator + type Form struct + Description string + Name string + Namespace *Namespace + Namespaces *Store + Parent string + Visibility Visibility + func (f Form) Fields() map[string]string + func (f Form) Validate() error + type Invite struct + CreatedAt time.Time + ID int64 + Invitee *user.User + InviteeID int64 + Inviter *user.User + InviterID int64 + Namespace *Namespace + NamespaceID int64 + func InviteFromContext(ctx context.Context) (*Invite, bool) + func (i *Invite) Bind(mm ...database.Model) + func (i *Invite) Endpoint(_ ...string) string + func (i *Invite) IsZero() bool + func (i *Invite) JSON(addr string) map[string]interface{} + func (i *Invite) Primary() (string, int64) + func (i *Invite) SetPrimary(id int64) + func (i *Invite) Values() map[string]interface{} + type InviteForm struct + Collaborators *CollaboratorStore + Handle string + Invitee *user.User + Inviter *user.User + Invites *InviteStore + Namespace string + Namespaces *Store + Owner string + Users *user.Store + func (f *InviteForm) Fields() map[string]string + func (f *InviteForm) Validate() error + type InviteStore struct + Namespace *Namespace + User *user.User + func NewInviteStore(db *sqlx.DB, mm ...database.Model) *InviteStore + func (s *InviteStore) Accept(id int64) (*Namespace, *user.User, *user.User, error) + func (s *InviteStore) All(opts ...query.Option) ([]*Invite, error) + func (s *InviteStore) Bind(mm ...database.Model) + func (s *InviteStore) Create(inviterId, inviteeId int64) (*Invite, error) + func (s *InviteStore) Delete(ii ...*Invite) error + func (s *InviteStore) Get(opts ...query.Option) (*Invite, error) + func (s *InviteStore) New() *Invite + type Namespace struct + Build database.Model + Collaborators map[int64]struct{} + CreatedAt time.Time + Description string + ID int64 + Level int64 + Name string + Parent *Namespace + ParentID sql.NullInt64 + Path string + RootID sql.NullInt64 + User *user.User + UserID int64 + Visibility Visibility + func FromContext(ctx context.Context) (*Namespace, bool) + func (n *Namespace) AccessibleBy(m database.Model) bool + func (n *Namespace) Bind(mm ...database.Model) + func (n *Namespace) CanAdd(m database.Model) bool + func (n *Namespace) Endpoint(uri ...string) string + func (n *Namespace) IsZero() bool + func (n *Namespace) JSON(addr string) map[string]interface{} + func (n *Namespace) LoadCollaborators(cc []*Collaborator) + func (n *Namespace) Primary() (string, int64) + func (n *Namespace) SetPrimary(id int64) + func (n *Namespace) Values() map[string]interface{} + type Resource struct + Author *user.User + Namespace string + Namespaces *Store + Owner *user.User + func (r *Resource) Resolve(b database.Binder) error + type Store struct + Namespace *Namespace + User *user.User + func NewStore(db *sqlx.DB, mm ...database.Model) *Store + func (s *Store) All(opts ...query.Option) ([]*Namespace, error) + func (s *Store) Bind(mm ...database.Model) + func (s *Store) Create(parent, name, description string, visibility Visibility) (*Namespace, error) + func (s *Store) Delete(ids ...int64) error + func (s *Store) Get(opts ...query.Option) (*Namespace, error) + func (s *Store) GetByPath(path string) (*Namespace, error) + func (s *Store) Index(vals url.Values, opts ...query.Option) ([]*Namespace, database.Paginator, error) + func (s *Store) Load(key string, vals []interface{}, load database.LoaderFunc) error + func (s *Store) New() *Namespace + func (s *Store) Update(id int64, description string, visibility Visibility) error + func (s Store) Paginate(page int64, opts ...query.Option) (database.Paginator, error) + type Visibility uint8 + const Internal + const Private + const Public + func (i Visibility) String() string + func (v *Visibility) Scan(val interface{}) error + func (v *Visibility) UnmarshalJSON(b []byte) error + func (v *Visibility) UnmarshalText(b []byte) error + func (v Visibility) Value() (driver.Value, error)