diff --git a/.env b/.env index a1dfa55..2da37e5 100644 --- a/.env +++ b/.env @@ -21,4 +21,5 @@ WORKER_REGION=europe PRODUCTION_MODE=false -ENDPOINT_CHECK_TIMEOUT_IN_SECONDS=30 \ No newline at end of file +ENDPOINT_CHECK_TIMEOUT_IN_SECONDS=30 +# NGROK_URL= \ No newline at end of file diff --git a/Taskfile.yml b/Taskfile.yml index 835ddea..dde4022 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -3,6 +3,7 @@ version: 3 dotenv: - ./.env.local - ./.env + - ./.env.secrets tasks: service: @@ -22,6 +23,10 @@ tasks: - | reflex -r '\.go' -s -- sh -c '{{.CLI_ARGS}}' + webhook: + cmds: + - ngrok http --domain=$NGROK_URL 8080 + mig:up: cmds: - goose -s -dir ./misc/sql/migrations up @@ -30,6 +35,10 @@ tasks: cmds: - goose -s -dir ./misc/sql/migrations down + mig:reset: + cmds: + - goose -s -dir ./misc/sql/migrations reset + mig:create: cmds: - goose -s -dir ./misc/sql/migrations create {{.CLI_ARGS}} sql @@ -48,7 +57,7 @@ tasks: orm: cmds: - - task mig:down + - task mig:reset - task mig:up - sqlboiler psql --wipe --no-tests -o ./internal/adapters/models diff --git a/api/openapi.yml b/api/openapi.yml index 2f765ea..9ee292c 100644 --- a/api/openapi.yml +++ b/api/openapi.yml @@ -235,43 +235,7 @@ paths: $ref: '#/components/schemas/GetIncidentByByIdPayload' default: $ref: '#/components/responses/DefaultError' - /accounts/profile: - get: - tags: - - Accounts - operationId: getProfileDetails - summary: Get details about the user currently logged in - security: - - BearerAuth: [ ] - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/GetProfileDetailsPayload' - default: - $ref: '#/components/responses/DefaultError' - /accounts/members/invite: - post: - tags: - - Members - operationId: bulkInviteMembersByEmail - summary: Bulk invite members by email - security: - - BearerAuth: [ ] - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/BulkInviteMembersByEmail' - responses: - '200': - description: OK - default: - $ref: '#/components/responses/DefaultError' - /auth/accounts: + /webhooks/create-account: post: tags: - Auth @@ -288,44 +252,6 @@ paths: description: CREATED default: $ref: '#/components/responses/DefaultError' - /auth/accounts/confirm-invitation: - post: - tags: - - Auth - operationId: confirmInvitation - summary: Creates a user in a team - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/ConfirmInvitationRequest' - responses: - '201': - description: CREATED - default: - $ref: '#/components/responses/DefaultError' - /auth/login: - post: - tags: - - Auth - operationId: login - summary: Log in - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/LogInRequest' - responses: - '200': - description: SIGNED UP - content: - application/json: - schema: - $ref: '#/components/schemas/LogInPayload' - default: - $ref: '#/components/responses/DefaultError' components: schemas: BulkInviteMembersByEmail: @@ -460,36 +386,137 @@ components: type: string response_status: type: integer - LogInPayload: - required: [ token ] - properties: - token: - type: string - LogInRequest: - required: [ email, password ] - properties: - email: - type: string - password: - type: string CreateAccountRequest: - required: [ account_name, email, password ] - properties: - account_name: - type: string - email: - type: string - password: - type: string - ConfirmInvitationRequest: - required: [ invitation_token, email, password ] + type: object properties: - invitation_token: - type: string - email: - type: string - password: - type: string + data: + type: object + required: [id, password_enabled, two_factor_enabled] + properties: + birthday: + type: string + description: User's birthday (empty string if not set) + created_at: + type: integer + description: Timestamp (epoch milliseconds) representing user creation time + email_addresses: + type: array + items: + type: object + properties: + email_address: + type: string + description: User's email address + id: + type: string + description: Unique identifier for the email address + linked_to: + type: array + description: (Array is empty for this event) + items: + type: object + # Add properties for linked objects if needed + object: + type: string + description: Object type (always "email_address" for this event) + verification: + type: object + properties: + status: + type: string + description: Verification status (e.g., "verified", "unverified") + strategy: + type: string + description: Verification strategy (e.g., "ticket", "link") + external_accounts: + type: array + description: (Array is empty for this event) + items: + type: object + # Add properties for external accounts if needed + external_id: + type: string + nullable: true + description: User's external identifier + first_name: + type: string + nullable: true + description: User's first name + gender: + type: string + description: User's gender (empty string if not set) + id: + type: string + description: Unique identifier for the user + image_url: + type: string + description: User's image URL (may be redacted) + last_name: + type: string + nullable: true + description: User's last name + last_sign_in_at: + type: integer + nullable: true + description: Timestamp (epoch milliseconds) representing last sign-in time + object: + type: string + description: Object type (always "user" for this event) + password_enabled: + type: boolean + description: Whether the user has password authentication enabled + phone_numbers: + type: array + description: (Array is empty for this event) + items: + type: object + # Add properties for phone numbers if needed + primary_email_address_id: + type: string + nullable: true + description: Unique identifier for the primary email address + primary_phone_number_id: + type: string + nullable: true + description: Unique identifier for the primary phone number (null if not set) + primary_web3_wallet_id: + type: string + nullable: true + description: Unique identifier for the primary web3 wallet (null if not set) + private_metadata: + type: object + description: User's private metadata (empty object for this event) + profile_image_url: + type: string + description: User's profile image URL (may be redacted) + public_metadata: + type: object + description: User's public metadata (empty object for this event) + two_factor_enabled: + type: boolean + description: Whether two-factor authentication is enabled + unsafe_metadata: + type: object + description: User's unsafe metadata (empty object for this event) + updated_at: + type: integer + description: Timestamp (epoch milliseconds) representing user update time + username: + type: string + nullable: true + description: Username (null if not set) + web3_wallets: + type: array + description: (Array is empty for this event) + items: + type: object + # Add properties for web3 wallets if needed + object: + type: string + description: Event type (always "user.created" for this event) + type: + type: string + description: Event type (always "user.created" for this event) CreateMonitorRequest: required: [endpoint_url, check_interval_in_seconds] properties: diff --git a/cmd/service/main.go b/cmd/service/main.go index af3d232..335a75e 100644 --- a/cmd/service/main.go +++ b/cmd/service/main.go @@ -164,7 +164,6 @@ func main() { Commands: app.Commands{ // Auth CreateAccount: observability.NewCommandDecorator[command.CreateAccount](command.NewCreateAccountHandler(txProvider), logger), - LogIn: observability.NewCommandWithResultDecorator[command.LogIn, string](command.NewLoginHandler(userRepository, tokenSigner), logger), // Monitor DeleteMonitor: observability.NewCommandDecorator[command.DeleteMonitor](command.NewDeleteMonitorHandler(txProvider), logger), diff --git a/docker-compose.yml b/docker-compose.yml index 21a4b2d..143f38f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.9' - services: rabbitmq: image: heidiks/rabbitmq-delayed-message-exchange:3.9.13-management diff --git a/internal/adapters/models/monitors.go b/internal/adapters/models/monitors.go index 1ede297..92388e9 100644 --- a/internal/adapters/models/monitors.go +++ b/internal/adapters/models/monitors.go @@ -932,7 +932,7 @@ func (monitorL) LoadUsers(ctx context.Context, e boil.ContextExecutor, singular } query := NewQuery( - qm.Select("\"users\".\"id\", \"users\".\"first_name\", \"users\".\"last_name\", \"users\".\"email\", \"users\".\"password\", \"users\".\"role\", \"users\".\"account_id\", \"users\".\"created_at\", \"a\".\"monitor_id\""), + qm.Select("\"users\".\"id\", \"users\".\"first_name\", \"users\".\"last_name\", \"users\".\"email\", \"users\".\"login_provider_id\", \"users\".\"role\", \"users\".\"account_id\", \"users\".\"created_at\", \"a\".\"monitor_id\""), qm.From("\"users\""), qm.InnerJoin("\"subscribers\" as \"a\" on \"users\".\"id\" = \"a\".\"user_id\""), qm.WhereIn("\"a\".\"monitor_id\" in ?", args...), @@ -953,7 +953,7 @@ func (monitorL) LoadUsers(ctx context.Context, e boil.ContextExecutor, singular one := new(User) var localJoinCol string - err = results.Scan(&one.ID, &one.FirstName, &one.LastName, &one.Email, &one.Password, &one.Role, &one.AccountID, &one.CreatedAt, &localJoinCol) + err = results.Scan(&one.ID, &one.FirstName, &one.LastName, &one.Email, &one.LoginProviderID, &one.Role, &one.AccountID, &one.CreatedAt, &localJoinCol) if err != nil { return errors.Wrap(err, "failed to scan eager loaded results for users") } diff --git a/internal/adapters/models/users.go b/internal/adapters/models/users.go index b3c2cb4..f8ba8db 100644 --- a/internal/adapters/models/users.go +++ b/internal/adapters/models/users.go @@ -24,79 +24,79 @@ import ( // User is an object representing the database table. type User struct { - ID string `boil:"id" json:"id" toml:"id" yaml:"id"` - FirstName null.String `boil:"first_name" json:"first_name,omitempty" toml:"first_name" yaml:"first_name,omitempty"` - LastName null.String `boil:"last_name" json:"last_name,omitempty" toml:"last_name" yaml:"last_name,omitempty"` - Email string `boil:"email" json:"email" toml:"email" yaml:"email"` - Password string `boil:"password" json:"password" toml:"password" yaml:"password"` - Role string `boil:"role" json:"role" toml:"role" yaml:"role"` - AccountID string `boil:"account_id" json:"account_id" toml:"account_id" yaml:"account_id"` - CreatedAt time.Time `boil:"created_at" json:"created_at" toml:"created_at" yaml:"created_at"` + ID string `boil:"id" json:"id" toml:"id" yaml:"id"` + FirstName null.String `boil:"first_name" json:"first_name,omitempty" toml:"first_name" yaml:"first_name,omitempty"` + LastName null.String `boil:"last_name" json:"last_name,omitempty" toml:"last_name" yaml:"last_name,omitempty"` + Email string `boil:"email" json:"email" toml:"email" yaml:"email"` + LoginProviderID string `boil:"login_provider_id" json:"login_provider_id" toml:"login_provider_id" yaml:"login_provider_id"` + Role string `boil:"role" json:"role" toml:"role" yaml:"role"` + AccountID string `boil:"account_id" json:"account_id" toml:"account_id" yaml:"account_id"` + CreatedAt time.Time `boil:"created_at" json:"created_at" toml:"created_at" yaml:"created_at"` R *userR `boil:"-" json:"-" toml:"-" yaml:"-"` L userL `boil:"-" json:"-" toml:"-" yaml:"-"` } var UserColumns = struct { - ID string - FirstName string - LastName string - Email string - Password string - Role string - AccountID string - CreatedAt string + ID string + FirstName string + LastName string + Email string + LoginProviderID string + Role string + AccountID string + CreatedAt string }{ - ID: "id", - FirstName: "first_name", - LastName: "last_name", - Email: "email", - Password: "password", - Role: "role", - AccountID: "account_id", - CreatedAt: "created_at", + ID: "id", + FirstName: "first_name", + LastName: "last_name", + Email: "email", + LoginProviderID: "login_provider_id", + Role: "role", + AccountID: "account_id", + CreatedAt: "created_at", } var UserTableColumns = struct { - ID string - FirstName string - LastName string - Email string - Password string - Role string - AccountID string - CreatedAt string + ID string + FirstName string + LastName string + Email string + LoginProviderID string + Role string + AccountID string + CreatedAt string }{ - ID: "users.id", - FirstName: "users.first_name", - LastName: "users.last_name", - Email: "users.email", - Password: "users.password", - Role: "users.role", - AccountID: "users.account_id", - CreatedAt: "users.created_at", + ID: "users.id", + FirstName: "users.first_name", + LastName: "users.last_name", + Email: "users.email", + LoginProviderID: "users.login_provider_id", + Role: "users.role", + AccountID: "users.account_id", + CreatedAt: "users.created_at", } // Generated where var UserWhere = struct { - ID whereHelperstring - FirstName whereHelpernull_String - LastName whereHelpernull_String - Email whereHelperstring - Password whereHelperstring - Role whereHelperstring - AccountID whereHelperstring - CreatedAt whereHelpertime_Time + ID whereHelperstring + FirstName whereHelpernull_String + LastName whereHelpernull_String + Email whereHelperstring + LoginProviderID whereHelperstring + Role whereHelperstring + AccountID whereHelperstring + CreatedAt whereHelpertime_Time }{ - ID: whereHelperstring{field: "\"users\".\"id\""}, - FirstName: whereHelpernull_String{field: "\"users\".\"first_name\""}, - LastName: whereHelpernull_String{field: "\"users\".\"last_name\""}, - Email: whereHelperstring{field: "\"users\".\"email\""}, - Password: whereHelperstring{field: "\"users\".\"password\""}, - Role: whereHelperstring{field: "\"users\".\"role\""}, - AccountID: whereHelperstring{field: "\"users\".\"account_id\""}, - CreatedAt: whereHelpertime_Time{field: "\"users\".\"created_at\""}, + ID: whereHelperstring{field: "\"users\".\"id\""}, + FirstName: whereHelpernull_String{field: "\"users\".\"first_name\""}, + LastName: whereHelpernull_String{field: "\"users\".\"last_name\""}, + Email: whereHelperstring{field: "\"users\".\"email\""}, + LoginProviderID: whereHelperstring{field: "\"users\".\"login_provider_id\""}, + Role: whereHelperstring{field: "\"users\".\"role\""}, + AccountID: whereHelperstring{field: "\"users\".\"account_id\""}, + CreatedAt: whereHelpertime_Time{field: "\"users\".\"created_at\""}, } // UserRels is where relationship names are stored. @@ -147,8 +147,8 @@ func (r *userR) GetMonitors() MonitorSlice { type userL struct{} var ( - userAllColumns = []string{"id", "first_name", "last_name", "email", "password", "role", "account_id", "created_at"} - userColumnsWithoutDefault = []string{"id", "email", "password", "account_id"} + userAllColumns = []string{"id", "first_name", "last_name", "email", "login_provider_id", "role", "account_id", "created_at"} + userColumnsWithoutDefault = []string{"id", "email", "login_provider_id", "account_id"} userColumnsWithDefault = []string{"first_name", "last_name", "role", "created_at"} userPrimaryKeyColumns = []string{"id"} userGeneratedColumns = []string{} diff --git a/internal/adapters/psql/mappers.go b/internal/adapters/psql/mappers.go index c855a34..a67c78a 100644 --- a/internal/adapters/psql/mappers.go +++ b/internal/adapters/psql/mappers.go @@ -16,55 +16,17 @@ import ( func mapUserToModel(user *account.User) models.User { return models.User{ - ID: user.ID().String(), - FirstName: null.StringFrom(user.FirstName()), - LastName: null.StringFrom(user.LastName()), - Email: user.Email().Address(), - Password: user.Password().String(), - Role: user.Role().String(), - AccountID: user.AccountID().String(), - CreatedAt: user.CreatedAt(), + ID: user.ID().String(), + FirstName: null.String{}, + LastName: null.String{}, + Email: user.Email().Address(), + LoginProviderID: user.LoginProviderID(), + Role: user.Role().String(), + AccountID: user.AccountID().String(), + CreatedAt: user.CreatedAt(), } } -func mapModelToUser(model *models.User) (*account.User, error) { - id, err := domain.NewIdFromString(model.ID) - if err != nil { - return nil, err - } - - accountId, err := domain.NewIdFromString(model.AccountID) - if err != nil { - return nil, err - } - - email, err := account.NewEmail(model.Email) - if err != nil { - return nil, err - } - - role, err := account.NewRole(model.Role) - if err != nil { - return nil, err - } - - password, err := account.NewPasswordFromHash(model.Password) - if err != nil { - return nil, err - } - - return account.NewUser( - id, - model.FirstName.String, - model.LastName.String, - email, - role, - password, - accountId, - model.CreatedAt, - ) -} - func mapMonitorToModel(m *monitor.Monitor) *models.Monitor { return &models.Monitor{ ID: m.ID().String(), @@ -226,10 +188,8 @@ func mapModelsToIncidents(modelList []*models.Incident) ([]*monitor.Incident, er func mapAccountToModel(acc *account.Account) models.Account { return models.Account{ - ID: acc.ID().String(), - Name: acc.Name(), - VerifiedAt: null.TimeFromPtr(acc.VerifiedAt()), - CreatedAt: time.Now(), + ID: acc.ID().String(), + CreatedAt: time.Now(), } } diff --git a/internal/adapters/psql/user.go b/internal/adapters/psql/user.go index bbfdcfd..9a1d46d 100644 --- a/internal/adapters/psql/user.go +++ b/internal/adapters/psql/user.go @@ -2,8 +2,6 @@ package psql import ( "context" - "database/sql" - "errors" "fmt" "github.com/volatiletech/sqlboiler/v4/boil" @@ -24,33 +22,17 @@ type UserRepository struct { } func (p UserRepository) FindByID(ctx context.Context, id domain.ID) (*account.User, error) { - model, err := models.FindUser(ctx, p.db, id.String()) - if errors.Is(err, sql.ErrNoRows) { - return nil, account.ErrUserNotFound - } - - if err != nil { - return nil, err - } - - return mapModelToUser(model) + panic("implement me") } func (p UserRepository) FindByEmail(ctx context.Context, email account.Email) (*account.User, error) { - model, err := models.Users(models.UserWhere.Email.EQ(email.Address())).One(ctx, p.db) - if errors.Is(err, sql.ErrNoRows) { - return nil, account.ErrUserNotFound - } - - if err != nil { - return nil, err - } - - return mapModelToUser(model) + panic("implement me") } func (p UserRepository) Insert(ctx context.Context, user *account.User) error { - exists, err := models.Users(models.UserWhere.Email.EQ(user.Email().Address())).Exists(ctx, p.db) + exists, err := models.Users( + models.UserWhere.Email.EQ(user.Email().Address()), + ).Exists(ctx, p.db) if err != nil { return fmt.Errorf("unable to check if %s is already taken: %v", user.Email(), err) } diff --git a/internal/adapters/resend/service.go b/internal/adapters/resend/service.go index 8fd5782..50d215d 100644 --- a/internal/adapters/resend/service.go +++ b/internal/adapters/resend/service.go @@ -38,13 +38,11 @@ func (s *service) SendEmailAboutIncident( m *monitor.Monitor, incident *monitor.Incident, ) error { - body := fmt.Sprintf(` -%s,
-An incident has been created for the monitor %s.
+ body := fmt.Sprintf(`An incident has been created for the monitor %s.
For more details please follow the link %s.
Dobermann - Endpoint monitoring -`, getGreetings(user), m.EndpointUrl(), getIncidentLink(s.hostname, incident.ID())) +`, m.EndpointUrl(), getIncidentLink(s.hostname, incident.ID())) _, err := s.client.Emails.SendWithContext(ctx, &resendsdk.SendEmailRequest{ From: fmt.Sprintf("Dobermann <%s>", s.from), @@ -65,13 +63,11 @@ func (s *service) SendEmailIncidentResolution( m *monitor.Monitor, incidentID domain.ID, ) error { - body := fmt.Sprintf(` -%s,
-The last incident reported on the monitor %s has been resolved.
+ body := fmt.Sprintf(`The last incident reported on the monitor %s has been resolved.
For more details please follow the link %s.
Dobermann - Endpoint monitoring -`, getGreetings(user), m.EndpointUrl(), getIncidentLink(s.hostname, incidentID)) +`, m.EndpointUrl(), getIncidentLink(s.hostname, incidentID)) _, err := s.client.Emails.SendWithContext(ctx, &resendsdk.SendEmailRequest{ From: fmt.Sprintf("Dobermann <%s>", s.from), @@ -90,11 +86,3 @@ func getIncidentLink(host string, incidentID domain.ID) string { link := fmt.Sprintf("%s/dashboard/incidents/%s", host, incidentID) return fmt.Sprintf(`%s`, link, link) } - -func getGreetings(user *account.User) string { - if user.FirstName() == "" { - return "Hi" - } - - return fmt.Sprintf("Hi %s", user.FirstName()) -} diff --git a/internal/app/app.go b/internal/app/app.go index 6870d95..1af4c19 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -36,7 +36,6 @@ type Commands struct { // IAM CreateAccount CommandHandler[command.CreateAccount] - LogIn CommandHandlerWithResult[command.LogIn, string] } type Queries struct { diff --git a/internal/app/command/create_account.go b/internal/app/command/create_account.go index ebdc503..419435f 100644 --- a/internal/app/command/create_account.go +++ b/internal/app/command/create_account.go @@ -8,7 +8,8 @@ import ( ) type CreateAccount struct { - Account *account.Account + LoginProviderID string + Email string } type CreateAccountHandler struct { @@ -23,21 +24,27 @@ func NewCreateAccountHandler(txProvider TransactionProvider) CreateAccountHandle func (h CreateAccountHandler) Execute(ctx context.Context, cmd CreateAccount) error { return h.txProvider.Transact(ctx, func(adapters TransactableAdapters) error { - err := adapters.AccountRepository.Insert(ctx, cmd.Account) + acc := account.NewAccount() + err := adapters.AccountRepository.Insert(ctx, acc) if err != nil { return fmt.Errorf("unable to save account: %v", err) } - accountOwner, err := cmd.Account.FirstAccountOwner() + email, err := account.NewEmail(cmd.Email) if err != nil { return err } - - err = adapters.UserRepository.Insert(ctx, accountOwner) + user, err := account.NewUser(account.RoleOwner, email, cmd.LoginProviderID, acc.ID()) if err != nil { return err } + // save user + err = adapters.UserRepository.Insert(ctx, user) + if err != nil { + return fmt.Errorf("unable to save user: %v", err) + } + return nil }) } diff --git a/internal/app/command/login.go b/internal/app/command/login.go deleted file mode 100644 index 780444c..0000000 --- a/internal/app/command/login.go +++ /dev/null @@ -1,52 +0,0 @@ -package command - -import ( - "context" - - "github.com/dobermanndotdev/dobermann/internal/domain/account" -) - -type LogIn struct { - Email account.Email - PlainTextPassword string -} - -type tokenSigner interface { - Sign(metadata map[string]string) (string, error) -} - -type LoginHandler struct { - tokenSigner tokenSigner - userRepository account.UserRepository -} - -func NewLoginHandler(userRepository account.UserRepository, tokenSigner tokenSigner) LoginHandler { - return LoginHandler{ - tokenSigner: tokenSigner, - userRepository: userRepository, - } -} - -func (h LoginHandler) Execute(ctx context.Context, cmd LogIn) (string, error) { - user, err := h.userRepository.FindByEmail(ctx, cmd.Email) - if err != nil { - return "", err - } - - err = user.Authenticate(cmd.PlainTextPassword) - if err != nil { - return "", err - } - - token, err := h.tokenSigner.Sign(map[string]string{ - "id": user.ID().String(), - "email": user.Email().Address(), - "account_id": user.AccountID().String(), - "role": user.Role().String(), - }) - if err != nil { - return "", err - } - - return token, nil -} diff --git a/internal/domain/account/account.go b/internal/domain/account/account.go index 04d584e..6dfef6f 100644 --- a/internal/domain/account/account.go +++ b/internal/domain/account/account.go @@ -1,62 +1,27 @@ package account import ( - "errors" - "strings" "time" "github.com/dobermanndotdev/dobermann/internal/domain" ) type Account struct { - id domain.ID - name string - verifiedAt *time.Time - users []*User + id domain.ID + createdAt time.Time } -func (a *Account) VerifiedAt() *time.Time { - return a.verifiedAt +func NewAccount() *Account { + return &Account{ + id: domain.NewID(), + createdAt: time.Now(), + } } -func (a *Account) Name() string { - return a.name +func (a *Account) CreatedAt() time.Time { + return a.createdAt } func (a *Account) ID() domain.ID { return a.id } - -func (a *Account) Users() []*User { - return a.users -} - -func (a *Account) FirstAccountOwner() (*User, error) { - if len(a.users) == 0 { - return nil, errors.New("no user found") - } - - // TODO: Implement this properly - return a.users[0], nil -} - -func NewFirstTimeAccount(name string, email Email, password Password) (*Account, error) { - accountID := domain.NewID() - - name = strings.TrimSpace(name) - if name == "" { - return nil, errors.New("account name cannot be empty") - } - - user, err := NewUser(domain.NewID(), "", "", email, RoleOwner, password, accountID, time.Now()) - if err != nil { - return nil, err - } - - return &Account{ - id: accountID, - name: name, - verifiedAt: nil, - users: []*User{user}, - }, nil -} diff --git a/internal/domain/account/password.go b/internal/domain/account/password.go deleted file mode 100644 index c13f923..0000000 --- a/internal/domain/account/password.go +++ /dev/null @@ -1,47 +0,0 @@ -package account - -import ( - "errors" - "strings" - - "golang.org/x/crypto/bcrypt" - - "github.com/dobermanndotdev/dobermann/internal/common/hashing" -) - -type Password struct { - hash string -} - -func NewPassword(plainText string) (Password, error) { - plainText = strings.TrimSpace(plainText) - - if plainText == "" { - return Password{}, errors.New("password cannot be empty") - } - - hash, err := hashing.Hash(plainText) - if err != nil { - return Password{}, err - } - - return Password{hash: hash}, nil -} - -func NewPasswordFromHash(hash string) (Password, error) { - hash = strings.TrimSpace(hash) - _, err := bcrypt.Cost([]byte(hash)) - if err != nil { - return Password{}, errors.New("the hash provided is invalid") - } - - return Password{hash: hash}, nil -} - -func (p Password) IsEmpty() bool { - return p.hash == "" -} - -func (p Password) String() string { - return p.hash -} diff --git a/internal/domain/account/password_test.go b/internal/domain/account/password_test.go deleted file mode 100644 index 0cd59e0..0000000 --- a/internal/domain/account/password_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package account_test - -import ( - "testing" - - "github.com/brianvoe/gofakeit" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/dobermanndotdev/dobermann/internal/common/hashing" - "github.com/dobermanndotdev/dobermann/internal/domain/account" -) - -func TestNewPassword(t *testing.T) { - testCases := []struct { - name string - expectedErr string - - plainText string - }{ - { - name: "create_new_password", - expectedErr: "", - plainText: gofakeit.Password(true, true, true, true, false, 12), - }, - { - name: "error_empty_password", - expectedErr: "password cannot be empty", - plainText: " ", - }, - } - - for i := range testCases { - tc := testCases[i] - - t.Run(tc.name, func(t *testing.T) { - t.Parallel() - - password, err := account.NewPassword(tc.plainText) - if tc.expectedErr != "" { - assert.EqualError(t, err, tc.expectedErr) - return - } - - require.NoError(t, err) - assert.True(t, hashing.IsHash(password.String())) - }) - } -} - -func TestNewPasswordFromHash(t *testing.T) { - testCases := []struct { - name string - expectedErr string - - hash string - }{ - { - name: "create_new_password_from_hash", - expectedErr: "", - hash: fixtureHash(t), - }, - { - name: "error_invalid_hash", - expectedErr: "the hash provided is invalid", - hash: gofakeit.Sentence(10), - }, - { - name: "error_invalid_hash_empty_string", - expectedErr: "the hash provided is invalid", - hash: " ", - }, - } - - for i := range testCases { - tc := testCases[i] - - t.Run(tc.name, func(t *testing.T) { - t.Parallel() - - password, err := account.NewPasswordFromHash(tc.hash) - if tc.expectedErr != "" { - assert.EqualError(t, err, tc.expectedErr) - return - } - - require.NoError(t, err) - assert.True(t, hashing.IsHash(password.String())) - }) - } -} - -func fixtureHash(t *testing.T) string { - hash, err := hashing.Hash(gofakeit.Password(true, true, true, true, false, 12)) - require.NoError(t, err) - return hash -} diff --git a/internal/domain/account/user.go b/internal/domain/account/user.go index c211cfd..9f3ae80 100644 --- a/internal/domain/account/user.go +++ b/internal/domain/account/user.go @@ -6,80 +6,42 @@ import ( "errors" - "github.com/dobermanndotdev/dobermann/internal/common/hashing" "github.com/dobermanndotdev/dobermann/internal/domain" ) type User struct { - id domain.ID - firstName string - lastName string - email Email - password Password - role Role - verificationToken *domain.ID - verifiedAt *time.Time - accountID domain.ID - createdAt time.Time + id domain.ID + loginProviderID string + email Email + role Role + accountID domain.ID + createdAt time.Time } func NewUser( - id domain.ID, - firstName, - lastName string, - email Email, role Role, - password Password, + email Email, + loginProviderID string, accountID domain.ID, - createdAt time.Time, ) (*User, error) { - firstName = strings.TrimSpace(firstName) - lastName = strings.TrimSpace(lastName) - - if id.IsEmpty() { - return nil, errors.New("id cannot be invalid") - } - - if email.IsEmpty() { - return nil, errors.New("email cannot be invalid") - } - - if password.IsEmpty() { - return nil, errors.New("password cannot be invalid") - } - if role.IsEmpty() { return nil, errors.New("role cannot be invalid") } - if time.Now().Before(createdAt) { - return nil, errors.New("createdAt cannot be set in the future") + if strings.TrimSpace(loginProviderID) == "" { + return nil, errors.New("loginProviderID cannot be empty") } return &User{ - id: id, - firstName: firstName, - lastName: lastName, - email: email, - password: password, - role: role, - accountID: accountID, - createdAt: createdAt.UTC(), + id: domain.NewID(), + role: role, + email: email, + accountID: accountID, + createdAt: time.Now().UTC(), + loginProviderID: loginProviderID, }, nil } -func (u *User) Password() Password { - return u.password -} - -func (u *User) VerificationToken() *domain.ID { - return u.verificationToken -} - -func (u *User) VerifiedAt() *time.Time { - return u.verifiedAt -} - func (u *User) CreatedAt() time.Time { return u.createdAt } @@ -88,18 +50,6 @@ func (u *User) ID() domain.ID { return u.id } -func (u *User) FirstName() string { - return u.firstName -} - -func (u *User) LastName() string { - return u.lastName -} - -func (u *User) Email() Email { - return u.email -} - func (u *User) Role() Role { return u.role } @@ -108,11 +58,10 @@ func (u *User) AccountID() domain.ID { return u.accountID } -func (u *User) Authenticate(plainTextPassword string) error { - err := hashing.Compare(plainTextPassword, u.password.hash) - if err != nil { - return ErrAuthenticationFailed - } +func (u *User) Email() Email { + return u.email +} - return nil +func (u *User) LoginProviderID() string { + return u.loginProviderID } diff --git a/internal/ports/http/accounts.go b/internal/ports/http/accounts.go deleted file mode 100644 index c4ca04e..0000000 --- a/internal/ports/http/accounts.go +++ /dev/null @@ -1,37 +0,0 @@ -package http - -import ( - "errors" - "net/http" - - "github.com/labstack/echo/v4" - - "github.com/dobermanndotdev/dobermann/internal/app/query" - "github.com/dobermanndotdev/dobermann/internal/domain/account" -) - -func (h handlers) GetProfileDetails(c echo.Context) error { - authUser, err := retrieveUserFromCtx(c) - if err != nil { - return NewUnableToRetrieveUserFromCtx(err) - } - - ctx := c.Request().Context() - user, err := h.application.Queries.UserByID.Execute(ctx, query.UserByID{ - ID: authUser.ID, - }) - if errors.Is(err, account.ErrUserNotFound) { - return NewHandlerErrorWithStatus(err, "user-not-found", http.StatusNotFound) - } - - if err != nil { - return NewHandlerError(err, "unable-to-get-profile-details") - } - - return c.JSON(http.StatusOK, mapUserToResponse(user)) -} - -func (h handlers) BulkInviteMembersByEmail(ctx echo.Context) error { - //TODO implement me - panic("implement me") -} diff --git a/internal/ports/http/auth.go b/internal/ports/http/auth.go index 3c80c8d..599f18a 100644 --- a/internal/ports/http/auth.go +++ b/internal/ports/http/auth.go @@ -7,7 +7,6 @@ import ( "github.com/labstack/echo/v4" "github.com/dobermanndotdev/dobermann/internal/app/command" - "github.com/dobermanndotdev/dobermann/internal/domain/account" ) func (h handlers) CreateAccount(c echo.Context) error { @@ -16,28 +15,17 @@ func (h handlers) CreateAccount(c echo.Context) error { return NewHandlerError(err, "error-loading-the-payload") } - email, err := account.NewEmail(body.Email) - if err != nil { - return NewHandlerErrorWithStatus(err, "validation-error", http.StatusBadRequest) - } - - password, err := account.NewPassword(body.Password) - if err != nil { - return NewHandlerErrorWithStatus(err, "validation-error", http.StatusBadRequest) + if body.Data.EmailAddresses == nil || len(*body.Data.EmailAddresses) == 0 { + return NewHandlerErrorWithStatus(errors.New("missing email"), "missing-email", http.StatusBadRequest) } - newAccount, err := account.NewFirstTimeAccount(body.AccountName, email, password) - if err != nil { - return NewHandlerErrorWithStatus(err, "validation-error", http.StatusBadRequest) - } + emailAddresses := *body.Data.EmailAddresses + email := emailAddresses[0].EmailAddress - err = h.application.Commands.CreateAccount.Execute(c.Request().Context(), command.CreateAccount{ - Account: newAccount, + err := h.application.Commands.CreateAccount.Execute(c.Request().Context(), command.CreateAccount{ + Email: *email, + LoginProviderID: body.Data.Id, }) - if errors.Is(err, account.ErrAccountExists) { - return NewHandlerErrorWithStatus(err, "email-in-use", http.StatusBadRequest) - } - if err != nil { return NewHandlerError(err, "unable-to-create-account") } @@ -45,32 +33,6 @@ func (h handlers) CreateAccount(c echo.Context) error { return c.NoContent(http.StatusCreated) } -func (h handlers) Login(c echo.Context) error { - var body LogInRequest - if err := c.Bind(&body); err != nil { - return NewHandlerError(err, "error-loading-the-payload") - } - - email, err := account.NewEmail(body.Email) - if err != nil { - return NewHandlerErrorWithStatus(err, "validation-error", http.StatusBadRequest) - } - - token, err := h.application.Commands.LogIn.Execute(c.Request().Context(), command.LogIn{ - Email: email, - PlainTextPassword: body.Password, - }) - if errors.Is(err, account.ErrAuthenticationFailed) { - return NewHandlerErrorWithStatus(err, "user-details-mismatch", http.StatusForbidden) - } - - if err != nil { - return NewHandlerError(err, "unable-to-authenticate") - } - - return c.JSON(http.StatusOK, LogInPayload{Token: token}) -} - func (h handlers) ConfirmInvitation(ctx echo.Context) error { //TODO implement me panic("implement me") diff --git a/internal/ports/http/mappers.go b/internal/ports/http/mappers.go index cdb6d22..e0592ed 100644 --- a/internal/ports/http/mappers.go +++ b/internal/ports/http/mappers.go @@ -5,7 +5,6 @@ import ( "github.com/dobermanndotdev/dobermann/internal/app/query" "github.com/dobermanndotdev/dobermann/internal/domain" - "github.com/dobermanndotdev/dobermann/internal/domain/account" "github.com/dobermanndotdev/dobermann/internal/domain/monitor" ) @@ -107,14 +106,3 @@ func mapMonitorResponseTimeStatsToResponse(stats []query.ResponseTimeStat) GetMo Data: result, } } - -func mapUserToResponse(user *account.User) GetProfileDetailsPayload { - return GetProfileDetailsPayload{Data: User{ - Id: user.ID().String(), - Email: user.Email().Address(), - FirstName: user.FirstName(), - LastName: user.LastName(), - Role: user.Role().String(), - CreatedAt: user.CreatedAt(), - }} -} diff --git a/internal/ports/http/server.gen.go b/internal/ports/http/server.gen.go index ae58e91..509dd0b 100644 --- a/internal/ports/http/server.gen.go +++ b/internal/ports/http/server.gen.go @@ -23,23 +23,107 @@ const ( BearerAuthScopes = "BearerAuth.Scopes" ) -// BulkInviteMembersByEmail defines model for BulkInviteMembersByEmail. -type BulkInviteMembersByEmail struct { - Emails []string `json:"emails"` -} - -// ConfirmInvitationRequest defines model for ConfirmInvitationRequest. -type ConfirmInvitationRequest struct { - Email string `json:"email"` - InvitationToken string `json:"invitation_token"` - Password string `json:"password"` -} - // CreateAccountRequest defines model for CreateAccountRequest. type CreateAccountRequest struct { - AccountName string `json:"account_name"` - Email string `json:"email"` - Password string `json:"password"` + Data *struct { + // Birthday User's birthday (empty string if not set) + Birthday *string `json:"birthday,omitempty"` + + // CreatedAt Timestamp (epoch milliseconds) representing user creation time + CreatedAt *int `json:"created_at,omitempty"` + EmailAddresses *[]struct { + // EmailAddress User's email address + EmailAddress *string `json:"email_address,omitempty"` + + // Id Unique identifier for the email address + Id *string `json:"id,omitempty"` + + // LinkedTo (Array is empty for this event) + LinkedTo *[]map[string]interface{} `json:"linked_to,omitempty"` + + // Object Object type (always "email_address" for this event) + Object *string `json:"object,omitempty"` + Verification *struct { + // Status Verification status (e.g., "verified", "unverified") + Status *string `json:"status,omitempty"` + + // Strategy Verification strategy (e.g., "ticket", "link") + Strategy *string `json:"strategy,omitempty"` + } `json:"verification,omitempty"` + } `json:"email_addresses,omitempty"` + + // ExternalAccounts (Array is empty for this event) + ExternalAccounts *[]map[string]interface{} `json:"external_accounts,omitempty"` + + // ExternalId User's external identifier + ExternalId *string `json:"external_id"` + + // FirstName User's first name + FirstName *string `json:"first_name"` + + // Gender User's gender (empty string if not set) + Gender *string `json:"gender,omitempty"` + + // Id Unique identifier for the user + Id string `json:"id"` + + // ImageUrl User's image URL (may be redacted) + ImageUrl *string `json:"image_url,omitempty"` + + // LastName User's last name + LastName *string `json:"last_name"` + + // LastSignInAt Timestamp (epoch milliseconds) representing last sign-in time + LastSignInAt *int `json:"last_sign_in_at"` + + // Object Object type (always "user" for this event) + Object *string `json:"object,omitempty"` + + // PasswordEnabled Whether the user has password authentication enabled + PasswordEnabled bool `json:"password_enabled"` + + // PhoneNumbers (Array is empty for this event) + PhoneNumbers *[]map[string]interface{} `json:"phone_numbers,omitempty"` + + // PrimaryEmailAddressId Unique identifier for the primary email address + PrimaryEmailAddressId *string `json:"primary_email_address_id"` + + // PrimaryPhoneNumberId Unique identifier for the primary phone number (null if not set) + PrimaryPhoneNumberId *string `json:"primary_phone_number_id"` + + // PrimaryWeb3WalletId Unique identifier for the primary web3 wallet (null if not set) + PrimaryWeb3WalletId *string `json:"primary_web3_wallet_id"` + + // PrivateMetadata User's private metadata (empty object for this event) + PrivateMetadata *map[string]interface{} `json:"private_metadata,omitempty"` + + // ProfileImageUrl User's profile image URL (may be redacted) + ProfileImageUrl *string `json:"profile_image_url,omitempty"` + + // PublicMetadata User's public metadata (empty object for this event) + PublicMetadata *map[string]interface{} `json:"public_metadata,omitempty"` + + // TwoFactorEnabled Whether two-factor authentication is enabled + TwoFactorEnabled bool `json:"two_factor_enabled"` + + // UnsafeMetadata User's unsafe metadata (empty object for this event) + UnsafeMetadata *map[string]interface{} `json:"unsafe_metadata,omitempty"` + + // UpdatedAt Timestamp (epoch milliseconds) representing user update time + UpdatedAt *int `json:"updated_at,omitempty"` + + // Username Username (null if not set) + Username *string `json:"username"` + + // Web3Wallets (Array is empty for this event) + Web3Wallets *[]map[string]interface{} `json:"web3_wallets,omitempty"` + } `json:"data,omitempty"` + + // Object Event type (always "user.created" for this event) + Object *string `json:"object,omitempty"` + + // Type Event type (always "user.created" for this event) + Type *string `json:"type,omitempty"` } // CreateMonitorRequest defines model for CreateMonitorRequest. @@ -107,11 +191,6 @@ type GetMonitorResponseTimeStatsPayload struct { Data []ResponseTimeStat `json:"data"` } -// GetProfileDetailsPayload defines model for GetProfileDetailsPayload. -type GetProfileDetailsPayload struct { - Data User `json:"data"` -} - // Incident defines model for Incident. type Incident struct { Cause string `json:"cause"` @@ -121,17 +200,6 @@ type Incident struct { ResolvedAt *time.Time `json:"resolved_at,omitempty"` } -// LogInPayload defines model for LogInPayload. -type LogInPayload struct { - Token string `json:"token"` -} - -// LogInRequest defines model for LogInRequest. -type LogInRequest struct { - Email string `json:"email"` - Password string `json:"password"` -} - // Monitor defines model for Monitor. type Monitor struct { CheckIntervalInSeconds int `json:"check_interval_in_seconds"` @@ -158,16 +226,6 @@ type ToggleMonitorPauseRequest struct { Pause bool `json:"pause"` } -// User defines model for User. -type User struct { - CreatedAt time.Time `json:"created_at"` - Email string `json:"email"` - FirstName string `json:"first_name"` - Id string `json:"id"` - LastName string `json:"last_name"` - Role string `json:"role"` -} - // DefaultError defines model for DefaultError. type DefaultError = ErrorResponse @@ -188,18 +246,6 @@ type GetMonitorResponseTimeStatsParams struct { RangeInDays *int `form:"range_in_days,omitempty" json:"range_in_days,omitempty"` } -// BulkInviteMembersByEmailJSONRequestBody defines body for BulkInviteMembersByEmail for application/json ContentType. -type BulkInviteMembersByEmailJSONRequestBody = BulkInviteMembersByEmail - -// CreateAccountJSONRequestBody defines body for CreateAccount for application/json ContentType. -type CreateAccountJSONRequestBody = CreateAccountRequest - -// ConfirmInvitationJSONRequestBody defines body for ConfirmInvitation for application/json ContentType. -type ConfirmInvitationJSONRequestBody = ConfirmInvitationRequest - -// LoginJSONRequestBody defines body for Login for application/json ContentType. -type LoginJSONRequestBody = LogInRequest - // CreateMonitorJSONRequestBody defines body for CreateMonitor for application/json ContentType. type CreateMonitorJSONRequestBody = CreateMonitorRequest @@ -209,23 +255,11 @@ type ToggleMonitorPauseJSONRequestBody = ToggleMonitorPauseRequest // EditMonitorJSONRequestBody defines body for EditMonitor for application/json ContentType. type EditMonitorJSONRequestBody = EditMonitorRequest +// CreateAccountJSONRequestBody defines body for CreateAccount for application/json ContentType. +type CreateAccountJSONRequestBody = CreateAccountRequest + // ServerInterface represents all server handlers. type ServerInterface interface { - // Bulk invite members by email - // (POST /accounts/members/invite) - BulkInviteMembersByEmail(ctx echo.Context) error - // Get details about the user currently logged in - // (GET /accounts/profile) - GetProfileDetails(ctx echo.Context) error - // Creates a new account - // (POST /auth/accounts) - CreateAccount(ctx echo.Context) error - // Creates a user in a team - // (POST /auth/accounts/confirm-invitation) - ConfirmInvitation(ctx echo.Context) error - // Log in - // (POST /auth/login) - Login(ctx echo.Context) error // Get all incidents // (GET /incidents) GetAllIncidents(ctx echo.Context, params GetAllIncidentsParams) error @@ -253,6 +287,9 @@ type ServerInterface interface { // Get the stats about the response time // (GET /monitors/{monitorID}/stats/response-times) GetMonitorResponseTimeStats(ctx echo.Context, monitorID string, params GetMonitorResponseTimeStatsParams) error + // Creates a new account + // (POST /webhooks/create-account) + CreateAccount(ctx echo.Context) error } // ServerInterfaceWrapper converts echo contexts to parameters. @@ -260,55 +297,6 @@ type ServerInterfaceWrapper struct { Handler ServerInterface } -// BulkInviteMembersByEmail converts echo context to params. -func (w *ServerInterfaceWrapper) BulkInviteMembersByEmail(ctx echo.Context) error { - var err error - - ctx.Set(BearerAuthScopes, []string{}) - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.BulkInviteMembersByEmail(ctx) - return err -} - -// GetProfileDetails converts echo context to params. -func (w *ServerInterfaceWrapper) GetProfileDetails(ctx echo.Context) error { - var err error - - ctx.Set(BearerAuthScopes, []string{}) - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.GetProfileDetails(ctx) - return err -} - -// CreateAccount converts echo context to params. -func (w *ServerInterfaceWrapper) CreateAccount(ctx echo.Context) error { - var err error - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.CreateAccount(ctx) - return err -} - -// ConfirmInvitation converts echo context to params. -func (w *ServerInterfaceWrapper) ConfirmInvitation(ctx echo.Context) error { - var err error - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.ConfirmInvitation(ctx) - return err -} - -// Login converts echo context to params. -func (w *ServerInterfaceWrapper) Login(ctx echo.Context) error { - var err error - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.Login(ctx) - return err -} - // GetAllIncidents converts echo context to params. func (w *ServerInterfaceWrapper) GetAllIncidents(ctx echo.Context) error { var err error @@ -491,6 +479,15 @@ func (w *ServerInterfaceWrapper) GetMonitorResponseTimeStats(ctx echo.Context) e return err } +// CreateAccount converts echo context to params. +func (w *ServerInterfaceWrapper) CreateAccount(ctx echo.Context) error { + var err error + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.CreateAccount(ctx) + return err +} + // This is a simple interface which specifies echo.Route addition functions which // are present on both echo.Echo and echo.Group, since we want to allow using // either of them for path registration @@ -519,11 +516,6 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL Handler: si, } - router.POST(baseURL+"/accounts/members/invite", wrapper.BulkInviteMembersByEmail) - router.GET(baseURL+"/accounts/profile", wrapper.GetProfileDetails) - router.POST(baseURL+"/auth/accounts", wrapper.CreateAccount) - router.POST(baseURL+"/auth/accounts/confirm-invitation", wrapper.ConfirmInvitation) - router.POST(baseURL+"/auth/login", wrapper.Login) router.GET(baseURL+"/incidents", wrapper.GetAllIncidents) router.GET(baseURL+"/incidents/:incidentID", wrapper.GetIncidentByID) router.GET(baseURL+"/monitors", wrapper.GetAllMonitors) @@ -533,42 +525,48 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL router.POST(baseURL+"/monitors/:monitorID", wrapper.ToggleMonitorPause) router.PUT(baseURL+"/monitors/:monitorID", wrapper.EditMonitor) router.GET(baseURL+"/monitors/:monitorID/stats/response-times", wrapper.GetMonitorResponseTimeStats) + router.POST(baseURL+"/webhooks/create-account", wrapper.CreateAccount) } // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+xaW28buxH+KwRbIC97vEoTFAd6qh3pBGrtE8N20IfAWFC7oxVjLrkhuXYEQ/+9ILn3", - "m+RYst2ibyuRO5fvmxkOR3rEoUhSwYFrhaePWIJKBVdgP8xgRTKm51IKaT6Hgmvg2jySNGU0JJoK7n9X", - "gpvvVLiGhJinv0pY4Sn+i18J992q8q20q1wN3m63Ho5AhZKmRhie4lMUAwdJQwRmK5LVXi/XYa07y9jd", - "gt9TDReQLEGqs808IZSZtVSKFKSmzg8wX9snqiGxD3qTAp5ipSXlMd56xRdESrKxmiT8yKiECE+/FQJu", - "tx7+JPiKysQqtu5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7+3wmAMnOcVz/GY6m76xW7NOLTBB", + "p/wkYP1losqePFzFeN7vRe3XkmSg7Tng5wdMjbCvBcitmb+dW8oWoLndq+e1732dhJ8JoxnVXS7k95LL", + "bDbZz/N20r2X/Mts9mzXkSPtuede8uM/XWjZO9ExtrWeQefytJ2h1tHt3Px8ayxURZYRuXUoIcIYahdF", + "TRKDEG6ws1nfYB48VD+vFrt9AdD0aFeLkQAwIdVA1/DF7erjzmQaJ/d3hDOD5m81vzlsvEYNrbbI7oNj", + "0JWT46FsrYaR/ydrlaz98eyPkKsVmIhyRNCG6hTlJKHc3Qk3QVCjaTqCXCgP7J0TtTLlQOm3It4+myO9", + "p3a7bnthEnw3APP7YQ/w7np5ebNcvJDHneqIIA6byu1+B7eTLHgof5XVMQYGrjPsOn9h3zfOP1wea75P", + "rI4/DB27WL5fvpxjnen7XToZrVTNEc3iRd12puLyh9pUnre+DOeQcwP2/PVrfJY6qoh5cu3FELXaIiFR", + "we34Zk/MDyRdXnhwbF1e/PcB6Ll5OQq52TdEzuiMSIXVoL87YucJlCYtZew5xN7+b+xw84yAj/SEkvAE", + "QsrDmGwV9jB4sQ7w0IHvty7XJp8tzq0bsYp3fUfuj5kNrFIh7lTgzrlel/+cs0dCe3rF8j+wZ+0Ve/+z", + "/ba9Yq8ZVGU3SGo/VP61KN3uHIbyvkqW5oxnHgRMRISlQun5j7MfZ3h3u/tPAAAA//8r0IZSFS0AAA==", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/misc/sql/migrations/00001_init.sql b/misc/sql/migrations/00001_init.sql index 4c3574a..cc24c1e 100644 --- a/misc/sql/migrations/00001_init.sql +++ b/misc/sql/migrations/00001_init.sql @@ -14,7 +14,7 @@ CREATE TABLE users ( first_name VARCHAR(64), last_name VARCHAR(64), email VARCHAR(128) NOT NULL, - password VARCHAR(128) NOT NULL, + login_provider_id TEXT NOT NULL, role ROLE_TYPE NOT NULL DEFAULT 'admin', account_id VARCHAR(26) NOT NULL, created_at TIMESTAMPTZ DEFAULT now() NOT NULL, diff --git a/tests/client/client.gen.go b/tests/client/client.gen.go index 7273f64..dae775d 100644 --- a/tests/client/client.gen.go +++ b/tests/client/client.gen.go @@ -25,23 +25,107 @@ const ( BearerAuthScopes = "BearerAuth.Scopes" ) -// BulkInviteMembersByEmail defines model for BulkInviteMembersByEmail. -type BulkInviteMembersByEmail struct { - Emails []string `json:"emails"` -} - -// ConfirmInvitationRequest defines model for ConfirmInvitationRequest. -type ConfirmInvitationRequest struct { - Email string `json:"email"` - InvitationToken string `json:"invitation_token"` - Password string `json:"password"` -} - // CreateAccountRequest defines model for CreateAccountRequest. type CreateAccountRequest struct { - AccountName string `json:"account_name"` - Email string `json:"email"` - Password string `json:"password"` + Data *struct { + // Birthday User's birthday (empty string if not set) + Birthday *string `json:"birthday,omitempty"` + + // CreatedAt Timestamp (epoch milliseconds) representing user creation time + CreatedAt *int `json:"created_at,omitempty"` + EmailAddresses *[]struct { + // EmailAddress User's email address + EmailAddress *string `json:"email_address,omitempty"` + + // Id Unique identifier for the email address + Id *string `json:"id,omitempty"` + + // LinkedTo (Array is empty for this event) + LinkedTo *[]map[string]interface{} `json:"linked_to,omitempty"` + + // Object Object type (always "email_address" for this event) + Object *string `json:"object,omitempty"` + Verification *struct { + // Status Verification status (e.g., "verified", "unverified") + Status *string `json:"status,omitempty"` + + // Strategy Verification strategy (e.g., "ticket", "link") + Strategy *string `json:"strategy,omitempty"` + } `json:"verification,omitempty"` + } `json:"email_addresses,omitempty"` + + // ExternalAccounts (Array is empty for this event) + ExternalAccounts *[]map[string]interface{} `json:"external_accounts,omitempty"` + + // ExternalId User's external identifier + ExternalId *string `json:"external_id"` + + // FirstName User's first name + FirstName *string `json:"first_name"` + + // Gender User's gender (empty string if not set) + Gender *string `json:"gender,omitempty"` + + // Id Unique identifier for the user + Id string `json:"id"` + + // ImageUrl User's image URL (may be redacted) + ImageUrl *string `json:"image_url,omitempty"` + + // LastName User's last name + LastName *string `json:"last_name"` + + // LastSignInAt Timestamp (epoch milliseconds) representing last sign-in time + LastSignInAt *int `json:"last_sign_in_at"` + + // Object Object type (always "user" for this event) + Object *string `json:"object,omitempty"` + + // PasswordEnabled Whether the user has password authentication enabled + PasswordEnabled bool `json:"password_enabled"` + + // PhoneNumbers (Array is empty for this event) + PhoneNumbers *[]map[string]interface{} `json:"phone_numbers,omitempty"` + + // PrimaryEmailAddressId Unique identifier for the primary email address + PrimaryEmailAddressId *string `json:"primary_email_address_id"` + + // PrimaryPhoneNumberId Unique identifier for the primary phone number (null if not set) + PrimaryPhoneNumberId *string `json:"primary_phone_number_id"` + + // PrimaryWeb3WalletId Unique identifier for the primary web3 wallet (null if not set) + PrimaryWeb3WalletId *string `json:"primary_web3_wallet_id"` + + // PrivateMetadata User's private metadata (empty object for this event) + PrivateMetadata *map[string]interface{} `json:"private_metadata,omitempty"` + + // ProfileImageUrl User's profile image URL (may be redacted) + ProfileImageUrl *string `json:"profile_image_url,omitempty"` + + // PublicMetadata User's public metadata (empty object for this event) + PublicMetadata *map[string]interface{} `json:"public_metadata,omitempty"` + + // TwoFactorEnabled Whether two-factor authentication is enabled + TwoFactorEnabled bool `json:"two_factor_enabled"` + + // UnsafeMetadata User's unsafe metadata (empty object for this event) + UnsafeMetadata *map[string]interface{} `json:"unsafe_metadata,omitempty"` + + // UpdatedAt Timestamp (epoch milliseconds) representing user update time + UpdatedAt *int `json:"updated_at,omitempty"` + + // Username Username (null if not set) + Username *string `json:"username"` + + // Web3Wallets (Array is empty for this event) + Web3Wallets *[]map[string]interface{} `json:"web3_wallets,omitempty"` + } `json:"data,omitempty"` + + // Object Event type (always "user.created" for this event) + Object *string `json:"object,omitempty"` + + // Type Event type (always "user.created" for this event) + Type *string `json:"type,omitempty"` } // CreateMonitorRequest defines model for CreateMonitorRequest. @@ -109,11 +193,6 @@ type GetMonitorResponseTimeStatsPayload struct { Data []ResponseTimeStat `json:"data"` } -// GetProfileDetailsPayload defines model for GetProfileDetailsPayload. -type GetProfileDetailsPayload struct { - Data User `json:"data"` -} - // Incident defines model for Incident. type Incident struct { Cause string `json:"cause"` @@ -123,17 +202,6 @@ type Incident struct { ResolvedAt *time.Time `json:"resolved_at,omitempty"` } -// LogInPayload defines model for LogInPayload. -type LogInPayload struct { - Token string `json:"token"` -} - -// LogInRequest defines model for LogInRequest. -type LogInRequest struct { - Email string `json:"email"` - Password string `json:"password"` -} - // Monitor defines model for Monitor. type Monitor struct { CheckIntervalInSeconds int `json:"check_interval_in_seconds"` @@ -160,16 +228,6 @@ type ToggleMonitorPauseRequest struct { Pause bool `json:"pause"` } -// User defines model for User. -type User struct { - CreatedAt time.Time `json:"created_at"` - Email string `json:"email"` - FirstName string `json:"first_name"` - Id string `json:"id"` - LastName string `json:"last_name"` - Role string `json:"role"` -} - // DefaultError defines model for DefaultError. type DefaultError = ErrorResponse @@ -190,18 +248,6 @@ type GetMonitorResponseTimeStatsParams struct { RangeInDays *int `form:"range_in_days,omitempty" json:"range_in_days,omitempty"` } -// BulkInviteMembersByEmailJSONRequestBody defines body for BulkInviteMembersByEmail for application/json ContentType. -type BulkInviteMembersByEmailJSONRequestBody = BulkInviteMembersByEmail - -// CreateAccountJSONRequestBody defines body for CreateAccount for application/json ContentType. -type CreateAccountJSONRequestBody = CreateAccountRequest - -// ConfirmInvitationJSONRequestBody defines body for ConfirmInvitation for application/json ContentType. -type ConfirmInvitationJSONRequestBody = ConfirmInvitationRequest - -// LoginJSONRequestBody defines body for Login for application/json ContentType. -type LoginJSONRequestBody = LogInRequest - // CreateMonitorJSONRequestBody defines body for CreateMonitor for application/json ContentType. type CreateMonitorJSONRequestBody = CreateMonitorRequest @@ -211,6 +257,9 @@ type ToggleMonitorPauseJSONRequestBody = ToggleMonitorPauseRequest // EditMonitorJSONRequestBody defines body for EditMonitor for application/json ContentType. type EditMonitorJSONRequestBody = EditMonitorRequest +// CreateAccountJSONRequestBody defines body for CreateAccount for application/json ContentType. +type CreateAccountJSONRequestBody = CreateAccountRequest + // RequestEditorFn is the function signature for the RequestEditor callback function type RequestEditorFn func(ctx context.Context, req *http.Request) error @@ -284,29 +333,6 @@ func WithRequestEditorFn(fn RequestEditorFn) ClientOption { // The interface specification for the client above. type ClientInterface interface { - // BulkInviteMembersByEmailWithBody request with any body - BulkInviteMembersByEmailWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - BulkInviteMembersByEmail(ctx context.Context, body BulkInviteMembersByEmailJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetProfileDetails request - GetProfileDetails(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) - - // CreateAccountWithBody request with any body - CreateAccountWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - CreateAccount(ctx context.Context, body CreateAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ConfirmInvitationWithBody request with any body - ConfirmInvitationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - ConfirmInvitation(ctx context.Context, body ConfirmInvitationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // LoginWithBody request with any body - LoginWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - Login(ctx context.Context, body LoginJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // GetAllIncidents request GetAllIncidents(ctx context.Context, params *GetAllIncidentsParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -339,114 +365,11 @@ type ClientInterface interface { // GetMonitorResponseTimeStats request GetMonitorResponseTimeStats(ctx context.Context, monitorID string, params *GetMonitorResponseTimeStatsParams, reqEditors ...RequestEditorFn) (*http.Response, error) -} - -func (c *Client) BulkInviteMembersByEmailWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewBulkInviteMembersByEmailRequestWithBody(c.Server, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) BulkInviteMembersByEmail(ctx context.Context, body BulkInviteMembersByEmailJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewBulkInviteMembersByEmailRequest(c.Server, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) GetProfileDetails(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetProfileDetailsRequest(c.Server) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) CreateAccountWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateAccountRequestWithBody(c.Server, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} -func (c *Client) CreateAccount(ctx context.Context, body CreateAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateAccountRequest(c.Server, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) ConfirmInvitationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewConfirmInvitationRequestWithBody(c.Server, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) ConfirmInvitation(ctx context.Context, body ConfirmInvitationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewConfirmInvitationRequest(c.Server, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) LoginWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewLoginRequestWithBody(c.Server, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} + // CreateAccountWithBody request with any body + CreateAccountWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) Login(ctx context.Context, body LoginJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewLoginRequest(c.Server, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) + CreateAccount(ctx context.Context, body CreateAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) } func (c *Client) GetAllIncidents(ctx context.Context, params *GetAllIncidentsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { @@ -593,191 +516,28 @@ func (c *Client) GetMonitorResponseTimeStats(ctx context.Context, monitorID stri return c.Client.Do(req) } -// NewBulkInviteMembersByEmailRequest calls the generic BulkInviteMembersByEmail builder with application/json body -func NewBulkInviteMembersByEmailRequest(server string, body BulkInviteMembersByEmailJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewBulkInviteMembersByEmailRequestWithBody(server, "application/json", bodyReader) -} - -// NewBulkInviteMembersByEmailRequestWithBody generates requests for BulkInviteMembersByEmail with any type of body -func NewBulkInviteMembersByEmailRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/accounts/members/invite") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewGetProfileDetailsRequest generates requests for GetProfileDetails -func NewGetProfileDetailsRequest(server string) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/accounts/profile") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - -// NewCreateAccountRequest calls the generic CreateAccount builder with application/json body -func NewCreateAccountRequest(server string, body CreateAccountJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewCreateAccountRequestWithBody(server, "application/json", bodyReader) -} - -// NewCreateAccountRequestWithBody generates requests for CreateAccount with any type of body -func NewCreateAccountRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/auth/accounts") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewConfirmInvitationRequest calls the generic ConfirmInvitation builder with application/json body -func NewConfirmInvitationRequest(server string, body ConfirmInvitationJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewConfirmInvitationRequestWithBody(server, "application/json", bodyReader) -} - -// NewConfirmInvitationRequestWithBody generates requests for ConfirmInvitation with any type of body -func NewConfirmInvitationRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/auth/accounts/confirm-invitation") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) +func (c *Client) CreateAccountWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateAccountRequestWithBody(c.Server, contentType, body) if err != nil { return nil, err } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - -// NewLoginRequest calls the generic Login builder with application/json body -func NewLoginRequest(server string, body LoginJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } - bodyReader = bytes.NewReader(buf) - return NewLoginRequestWithBody(server, "application/json", bodyReader) + return c.Client.Do(req) } -// NewLoginRequestWithBody generates requests for Login with any type of body -func NewLoginRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/auth/login") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) +func (c *Client) CreateAccount(ctx context.Context, body CreateAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateAccountRequest(c.Server, body) if err != nil { return nil, err } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } - - req.Header.Add("Content-Type", contentType) - - return req, nil + return c.Client.Do(req) } // NewGetAllIncidentsRequest generates requests for GetAllIncidents @@ -1202,6 +962,46 @@ func NewGetMonitorResponseTimeStatsRequest(server string, monitorID string, para return req, nil } +// NewCreateAccountRequest calls the generic CreateAccount builder with application/json body +func NewCreateAccountRequest(server string, body CreateAccountJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateAccountRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateAccountRequestWithBody generates requests for CreateAccount with any type of body +func NewCreateAccountRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/webhooks/create-account") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { for _, r := range c.RequestEditors { if err := r(ctx, req); err != nil { @@ -1245,29 +1045,6 @@ func WithBaseURL(baseURL string) ClientOption { // ClientWithResponsesInterface is the interface specification for the client with responses above. type ClientWithResponsesInterface interface { - // BulkInviteMembersByEmailWithBodyWithResponse request with any body - BulkInviteMembersByEmailWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BulkInviteMembersByEmailResponse, error) - - BulkInviteMembersByEmailWithResponse(ctx context.Context, body BulkInviteMembersByEmailJSONRequestBody, reqEditors ...RequestEditorFn) (*BulkInviteMembersByEmailResponse, error) - - // GetProfileDetailsWithResponse request - GetProfileDetailsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetProfileDetailsResponse, error) - - // CreateAccountWithBodyWithResponse request with any body - CreateAccountWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAccountResponse, error) - - CreateAccountWithResponse(ctx context.Context, body CreateAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAccountResponse, error) - - // ConfirmInvitationWithBodyWithResponse request with any body - ConfirmInvitationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ConfirmInvitationResponse, error) - - ConfirmInvitationWithResponse(ctx context.Context, body ConfirmInvitationJSONRequestBody, reqEditors ...RequestEditorFn) (*ConfirmInvitationResponse, error) - - // LoginWithBodyWithResponse request with any body - LoginWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LoginResponse, error) - - LoginWithResponse(ctx context.Context, body LoginJSONRequestBody, reqEditors ...RequestEditorFn) (*LoginResponse, error) - // GetAllIncidentsWithResponse request GetAllIncidentsWithResponse(ctx context.Context, params *GetAllIncidentsParams, reqEditors ...RequestEditorFn) (*GetAllIncidentsResponse, error) @@ -1285,133 +1062,26 @@ type ClientWithResponsesInterface interface { // DeleteMonitorWithResponse request DeleteMonitorWithResponse(ctx context.Context, monitorID string, reqEditors ...RequestEditorFn) (*DeleteMonitorResponse, error) - // GetMonitorByIDWithResponse request - GetMonitorByIDWithResponse(ctx context.Context, monitorID string, reqEditors ...RequestEditorFn) (*GetMonitorByIDResponse, error) - - // ToggleMonitorPauseWithBodyWithResponse request with any body - ToggleMonitorPauseWithBodyWithResponse(ctx context.Context, monitorID string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ToggleMonitorPauseResponse, error) - - ToggleMonitorPauseWithResponse(ctx context.Context, monitorID string, body ToggleMonitorPauseJSONRequestBody, reqEditors ...RequestEditorFn) (*ToggleMonitorPauseResponse, error) - - // EditMonitorWithBodyWithResponse request with any body - EditMonitorWithBodyWithResponse(ctx context.Context, monitorID string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*EditMonitorResponse, error) - - EditMonitorWithResponse(ctx context.Context, monitorID string, body EditMonitorJSONRequestBody, reqEditors ...RequestEditorFn) (*EditMonitorResponse, error) - - // GetMonitorResponseTimeStatsWithResponse request - GetMonitorResponseTimeStatsWithResponse(ctx context.Context, monitorID string, params *GetMonitorResponseTimeStatsParams, reqEditors ...RequestEditorFn) (*GetMonitorResponseTimeStatsResponse, error) -} - -type BulkInviteMembersByEmailResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *DefaultError -} - -// Status returns HTTPResponse.Status -func (r BulkInviteMembersByEmailResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r BulkInviteMembersByEmailResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type GetProfileDetailsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *GetProfileDetailsPayload - JSONDefault *DefaultError -} - -// Status returns HTTPResponse.Status -func (r GetProfileDetailsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetProfileDetailsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - -type CreateAccountResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *DefaultError -} - -// Status returns HTTPResponse.Status -func (r CreateAccountResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r CreateAccountResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // GetMonitorByIDWithResponse request + GetMonitorByIDWithResponse(ctx context.Context, monitorID string, reqEditors ...RequestEditorFn) (*GetMonitorByIDResponse, error) -type ConfirmInvitationResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *DefaultError -} + // ToggleMonitorPauseWithBodyWithResponse request with any body + ToggleMonitorPauseWithBodyWithResponse(ctx context.Context, monitorID string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ToggleMonitorPauseResponse, error) -// Status returns HTTPResponse.Status -func (r ConfirmInvitationResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + ToggleMonitorPauseWithResponse(ctx context.Context, monitorID string, body ToggleMonitorPauseJSONRequestBody, reqEditors ...RequestEditorFn) (*ToggleMonitorPauseResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r ConfirmInvitationResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // EditMonitorWithBodyWithResponse request with any body + EditMonitorWithBodyWithResponse(ctx context.Context, monitorID string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*EditMonitorResponse, error) -type LoginResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *LogInPayload - JSONDefault *DefaultError -} + EditMonitorWithResponse(ctx context.Context, monitorID string, body EditMonitorJSONRequestBody, reqEditors ...RequestEditorFn) (*EditMonitorResponse, error) -// Status returns HTTPResponse.Status -func (r LoginResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // GetMonitorResponseTimeStatsWithResponse request + GetMonitorResponseTimeStatsWithResponse(ctx context.Context, monitorID string, params *GetMonitorResponseTimeStatsParams, reqEditors ...RequestEditorFn) (*GetMonitorResponseTimeStatsResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r LoginResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 + // CreateAccountWithBodyWithResponse request with any body + CreateAccountWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAccountResponse, error) + + CreateAccountWithResponse(ctx context.Context, body CreateAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAccountResponse, error) } type GetAllIncidentsResponse struct { @@ -1617,81 +1287,26 @@ func (r GetMonitorResponseTimeStatsResponse) StatusCode() int { return 0 } -// BulkInviteMembersByEmailWithBodyWithResponse request with arbitrary body returning *BulkInviteMembersByEmailResponse -func (c *ClientWithResponses) BulkInviteMembersByEmailWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BulkInviteMembersByEmailResponse, error) { - rsp, err := c.BulkInviteMembersByEmailWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseBulkInviteMembersByEmailResponse(rsp) -} - -func (c *ClientWithResponses) BulkInviteMembersByEmailWithResponse(ctx context.Context, body BulkInviteMembersByEmailJSONRequestBody, reqEditors ...RequestEditorFn) (*BulkInviteMembersByEmailResponse, error) { - rsp, err := c.BulkInviteMembersByEmail(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseBulkInviteMembersByEmailResponse(rsp) -} - -// GetProfileDetailsWithResponse request returning *GetProfileDetailsResponse -func (c *ClientWithResponses) GetProfileDetailsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetProfileDetailsResponse, error) { - rsp, err := c.GetProfileDetails(ctx, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetProfileDetailsResponse(rsp) -} - -// CreateAccountWithBodyWithResponse request with arbitrary body returning *CreateAccountResponse -func (c *ClientWithResponses) CreateAccountWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAccountResponse, error) { - rsp, err := c.CreateAccountWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateAccountResponse(rsp) -} - -func (c *ClientWithResponses) CreateAccountWithResponse(ctx context.Context, body CreateAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAccountResponse, error) { - rsp, err := c.CreateAccount(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateAccountResponse(rsp) -} - -// ConfirmInvitationWithBodyWithResponse request with arbitrary body returning *ConfirmInvitationResponse -func (c *ClientWithResponses) ConfirmInvitationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ConfirmInvitationResponse, error) { - rsp, err := c.ConfirmInvitationWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseConfirmInvitationResponse(rsp) -} - -func (c *ClientWithResponses) ConfirmInvitationWithResponse(ctx context.Context, body ConfirmInvitationJSONRequestBody, reqEditors ...RequestEditorFn) (*ConfirmInvitationResponse, error) { - rsp, err := c.ConfirmInvitation(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseConfirmInvitationResponse(rsp) +type CreateAccountResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *DefaultError } -// LoginWithBodyWithResponse request with arbitrary body returning *LoginResponse -func (c *ClientWithResponses) LoginWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LoginResponse, error) { - rsp, err := c.LoginWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r CreateAccountResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseLoginResponse(rsp) + return http.StatusText(0) } -func (c *ClientWithResponses) LoginWithResponse(ctx context.Context, body LoginJSONRequestBody, reqEditors ...RequestEditorFn) (*LoginResponse, error) { - rsp, err := c.Login(ctx, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r CreateAccountResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseLoginResponse(rsp) + return 0 } // GetAllIncidentsWithResponse request returning *GetAllIncidentsResponse @@ -1799,148 +1414,21 @@ func (c *ClientWithResponses) GetMonitorResponseTimeStatsWithResponse(ctx contex return ParseGetMonitorResponseTimeStatsResponse(rsp) } -// ParseBulkInviteMembersByEmailResponse parses an HTTP response from a BulkInviteMembersByEmailWithResponse call -func ParseBulkInviteMembersByEmailResponse(rsp *http.Response) (*BulkInviteMembersByEmailResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &BulkInviteMembersByEmailResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest DefaultError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - - } - - return response, nil -} - -// ParseGetProfileDetailsResponse parses an HTTP response from a GetProfileDetailsWithResponse call -func ParseGetProfileDetailsResponse(rsp *http.Response) (*GetProfileDetailsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetProfileDetailsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest GetProfileDetailsPayload - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest DefaultError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - - } - - return response, nil -} - -// ParseCreateAccountResponse parses an HTTP response from a CreateAccountWithResponse call -func ParseCreateAccountResponse(rsp *http.Response) (*CreateAccountResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &CreateAccountResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest DefaultError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - - } - - return response, nil -} - -// ParseConfirmInvitationResponse parses an HTTP response from a ConfirmInvitationWithResponse call -func ParseConfirmInvitationResponse(rsp *http.Response) (*ConfirmInvitationResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// CreateAccountWithBodyWithResponse request with arbitrary body returning *CreateAccountResponse +func (c *ClientWithResponses) CreateAccountWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAccountResponse, error) { + rsp, err := c.CreateAccountWithBody(ctx, contentType, body, reqEditors...) if err != nil { return nil, err } - - response := &ConfirmInvitationResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest DefaultError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - - } - - return response, nil + return ParseCreateAccountResponse(rsp) } -// ParseLoginResponse parses an HTTP response from a LoginWithResponse call -func ParseLoginResponse(rsp *http.Response) (*LoginResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +func (c *ClientWithResponses) CreateAccountWithResponse(ctx context.Context, body CreateAccountJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAccountResponse, error) { + rsp, err := c.CreateAccount(ctx, body, reqEditors...) if err != nil { return nil, err } - - response := &LoginResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest LogInPayload - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest DefaultError - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - - } - - return response, nil + return ParseCreateAccountResponse(rsp) } // ParseGetAllIncidentsResponse parses an HTTP response from a GetAllIncidentsWithResponse call @@ -2212,39 +1700,70 @@ func ParseGetMonitorResponseTimeStatsResponse(rsp *http.Response) (*GetMonitorRe return response, nil } +// ParseCreateAccountResponse parses an HTTP response from a CreateAccountWithResponse call +func ParseCreateAccountResponse(rsp *http.Response) (*CreateAccountResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateAccountResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest DefaultError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+xaW28buxH+KwRbIC97vEoTFAd6qh3pBGrtE8N20IfAWFC7oxVjLrkhuXYEQ/+9ILn3", - "m+RYst2ibyuRO5fvmxkOR3rEoUhSwYFrhaePWIJKBVdgP8xgRTKm51IKaT6Hgmvg2jySNGU0JJoK7n9X", - "gpvvVLiGhJinv0pY4Sn+i18J992q8q20q1wN3m63Ho5AhZKmRhie4lMUAwdJQwRmK5LVXi/XYa07y9jd", - "gt9TDReQLEGqs808IZSZtVSKFKSmzg8wX9snqiGxD3qTAp5ipSXlMd56xRdESrKxmiT8yKiECE+/FQJu", - "tx7+JPiKysQqtu5fwY8MlB7Q2quLli8HWtwB792UEqUehIx6FlvWdcR5ue6aEGu6BKLhNAxFxvWg2cSt", - "B5wk0GvYsF/7m9xQMmruheBUm4AZMDdcQ3gXUK5B3hMWUB4oCAWP7GJCOU2yBE8/TEqGzdYYpPWER6mg", - "XAeZZLttbuz2RhQb4+cR1c8y/WWtbeRkN5KLAtBMVPsWCjOlRZLnaigiQCoL14go9M7SanRlCt5hrxsw", - "CShFYuiKPkW1z4gsRaaRXoPT0pXU9j3fVYi/LV8Qy+8QaqP6j4yxBQ9pVBQ0xr6s8PTbePEq39h6bZAS", - "x3ZAo97cKKpYoDTRWS/FLS9qArsOGNY+gz6tnFCXZMMEibr0RUSTRvHb08NWTTTpGUN/bJqVwKb0wDrI", - "YPhtLTRh1esrIROi3Za/f8TeLqCs4JqOhjlN6Z4Do0Ivz9GzzSLaid8Y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rVTNEc3iRd12puLyh9pUnre+DOeQcwP2/PVrfJY6qoh5cu3FELXaIiFR", + "we34Zk/MDyRdXnhwbF1e/PcB6Ll5OQq52TdEzuiMSIXVoL87YucJlCYtZew5xN7+b+xw84yAj/SEkvAE", + "QsrDmGwV9jB4sQ7w0IHvty7XJp8tzq0bsYp3fUfuj5kNrFIh7lTgzrlel/+cs0dCe3rF8j+wZ+0Ve/+z", + "/ba9Yq8ZVGU3SGo/VP61KN3uHIbyvkqW5oxnHgRMRISlQun5j7MfZ3h3u/tPAAAA//8r0IZSFS0AAA==", } // GetSwagger returns the content of the embedded swagger specification file