clerkhooks

package
v1.1.39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpdateCreatedUser added in v1.1.27

func UpdateCreatedUser(
	ctx context.Context,
	userID pulid.ID,
	AccountID string,
	isEmployee bool,
	personalOrgID *pulid.ID,
) error

Types

type App

type App interface {
	// contains filtered or unexported methods
}

type AppClient

type AppClient interface {
	CreateMembership(ctx context.Context, data *CreateMembershipData) error
	CreateOrganization(ctx context.Context, data *CreateOrgData) (*Organization, error)
	CreateUser(ctx context.Context, data *CreateUserData) (*User, error)
	DeleteMembership(ctx context.Context, orgID pulid.ID, userID pulid.ID) error
	GetUser(ctx context.Context, userID pulid.ID) (*User, error)
	GetUserByAccountID(ctx context.Context, accountID string) (*User, error)
	GetOrgByAccountID(ctx context.Context, accountID string) (*Organization, error)
	GetUserByAccountIDOrNil(ctx context.Context, accountID string) (*User, error)
	GetOrgByAccountIDOrNil(ctx context.Context, accountID string) (*Organization, error)
	MembershipExists(ctx context.Context, orgID pulid.ID, userID pulid.ID) (bool, error)
	SetOrgDetails(ctx context.Context, orgID pulid.ID, data *OrgInputData) error
	SetUserProfileDetails(ctx context.Context, userID pulid.ID, data *UserInputData) error
	UpdateMembership(
		ctx context.Context,
		data *CreateMembershipData,
	) error
	SetUserSubscriptionPlan(
		ctx context.Context,
		userID pulid.ID,
		plan string,
	) error
}

type ClerkHook

type ClerkHook struct {
	// contains filtered or unexported fields
}

func NewClerkWebhook

func NewClerkWebhook(
	appClient AppClient,
	wh *svix.Webhook,
	opts ...ClerkHookOption,
) *ClerkHook

func (*ClerkHook) GetOrCreateOrgByAccountID added in v1.1.3

func (c *ClerkHook) GetOrCreateOrgByAccountID(
	ctx context.Context,
	accountID string,
	userID pulid.ID,
	orgID *pulid.ID,
) (*Organization, error)

func (*ClerkHook) GetOrCreateUserByAccountID added in v1.1.3

func (c *ClerkHook) GetOrCreateUserByAccountID(
	ctx context.Context,
	accountID string,
	userID *pulid.ID,
	personalOrgID *pulid.ID,
	isEmployee bool,
) (*User, error)

func (*ClerkHook) GetPersonalOrgByAccountID added in v1.1.3

func (c *ClerkHook) GetPersonalOrgByAccountID(
	ctx context.Context,
	accountID string,
	user *User,
	orgID *pulid.ID,
) (*Organization, error)

func (*ClerkHook) GetUserByAccountID

func (c *ClerkHook) GetUserByAccountID(
	ctx context.Context,
	accountID string,
) (*User, error)

func (*ClerkHook) HandleHooks

func (c *ClerkHook) HandleHooks(
	ctx context.Context,
	w http.ResponseWriter,
	r *http.Request,
) error

type ClerkHookOption

type ClerkHookOption func(*ClerkHook)

func WithEmployeeEmailDomain added in v1.1.6

func WithEmployeeEmailDomain(domain string) ClerkHookOption

func WithEmployeeEmails added in v1.1.6

func WithEmployeeEmails(emails []string) ClerkHookOption

func WithPersonalOrgs

func WithPersonalOrgs() ClerkHookOption

type CreateMembershipData

type CreateMembershipData struct {
	OrgID  pulid.ID
	UserID pulid.ID
	Role   membershiprole.MembershipRole
}

type CreateOrgData

type CreateOrgData struct {
	UserID       pulid.ID
	OrgID        *pulid.ID
	OrgAccountID string
	OrgInputData
}

type CreateUserData

type CreateUserData struct {
	AccountID               string
	UserID                  *pulid.ID
	IsEmployee              bool
	PersonalOrgID           *pulid.ID
	ExternalAccountProvider *string
	Plan                    string
	UserInputData
}

type OrgInputData

type OrgInputData struct {
	Name     string
	ImageURL *string
}

type Organization

type Organization struct {
	ID pulid.ID
}

type User

type User struct {
	ID            pulid.ID
	PersonalOrgID *pulid.ID
	ImageURL      *string
}

type UserInputData

type UserInputData struct {
	FirstName    *string
	LastName     *string
	Username     *string
	ImageURL     *string
	EmailAddress *string
	Phone        *string
}

type UserPublicMetadata added in v1.1.27

type UserPublicMetadata struct {
	UserID        string `json:"app_user_id"`
	PersonalOrgID string `json:"app_personal_org_id"`
	Role          string `json:"app_user_role"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL