Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion application/action/delete_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package action
import (
"fmt"

"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/action/dto"
)

Expand All @@ -13,7 +14,7 @@ func (app *ActionApplication) DeleteAction(input dto.DeleteActionInput) error {
}

if action.UserId != input.UserId {
return fmt.Errorf("access denied")
return apperrors.ErrAccessDenied
}

if err := app.ActionPers.Delete(input.ActionId); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions application/action/dto/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import "time"

// Step configuration
type ActionStep struct {
Type string `json:"type"`
Config map[string]interface{} `json:"config"`
Type string `json:"type"`
Config map[string]any `json:"config"`
}

type ActionItem struct {
Expand Down
8 changes: 4 additions & 4 deletions application/action/execute_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (app *ActionApplication) ExecuteActions(input dto.ExecuteActionInput) {
}
}

func (app *ActionApplication) executeAction(action domain.Action, triggerData map[string]interface{}) {
func (app *ActionApplication) executeAction(action domain.Action, triggerData map[string]any) {
logger := app.Logger.With().
Str("component", "action.execute").
Str("action_id", action.Id).
Expand All @@ -45,12 +45,12 @@ func (app *ActionApplication) executeAction(action domain.Action, triggerData ma
}

// Execute each step
stepsResult := make([]map[string]interface{}, len(steps))
stepsResult := make([]map[string]any, len(steps))
var execError error

for i, step := range steps {
result, err := app.executeStep(step, triggerData)
stepsResult[i] = map[string]interface{}{
stepsResult[i] = map[string]any{
"step": i + 1,
"type": step.Type,
"success": err == nil,
Expand Down Expand Up @@ -90,7 +90,7 @@ func (app *ActionApplication) executeAction(action domain.Action, triggerData ma
}
}

func (app *ActionApplication) executeStep(step dto.ActionStep, triggerData map[string]interface{}) (interface{}, error) {
func (app *ActionApplication) executeStep(step dto.ActionStep, triggerData map[string]any) (any, error) {
// This is a simplified implementation - in production, you'd have actual step executors
switch domain.ActionStepType(step.Type) {
case domain.StepSendWebhook:
Expand Down
5 changes: 3 additions & 2 deletions application/action/get_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"

"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/action/dto"
)

Expand All @@ -14,7 +15,7 @@ func (app *ActionApplication) GetAction(input dto.GetActionInput) (*dto.GetActio
}

if action.UserId != input.UserId {
return nil, fmt.Errorf("access denied")
return nil, apperrors.ErrAccessDenied
}

// Parse steps
Expand All @@ -31,7 +32,7 @@ func (app *ActionApplication) GetAction(input dto.GetActionInput) (*dto.GetActio
SpaceId: action.SpaceId,
DatabaseId: action.DatabaseId,
TriggerType: string(action.TriggerType),
TriggerConfig: map[string]interface{}(action.TriggerConfig),
TriggerConfig: map[string]any(action.TriggerConfig),
Steps: steps,
Active: action.Active,
LastRunAt: action.LastRunAt,
Expand Down
3 changes: 2 additions & 1 deletion application/action/get_runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package action
import (
"fmt"

"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/action/dto"
)

Expand All @@ -14,7 +15,7 @@ func (app *ActionApplication) GetRuns(input dto.GetRunsInput) (*dto.GetRunsOutpu
}

if action.UserId != input.UserId {
return nil, fmt.Errorf("access denied")
return nil, apperrors.ErrAccessDenied
}

limit := input.Limit
Expand Down
3 changes: 2 additions & 1 deletion application/action/update_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/action/dto"
"github.com/labbs/nexo/domain"
)
Expand All @@ -16,7 +17,7 @@ func (app *ActionApplication) UpdateAction(input dto.UpdateActionInput) error {
}

if action.UserId != input.UserId {
return fmt.Errorf("access denied")
return apperrors.ErrAccessDenied
}

if input.Name != nil {
Expand Down
3 changes: 2 additions & 1 deletion application/apikey/delete_apikey.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package apikey
import (
"fmt"

"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/apikey/dto"
)

Expand All @@ -14,7 +15,7 @@ func (app *ApiKeyApplication) DeleteApiKey(input dto.DeleteApiKeyInput) error {

// Verify ownership
if apiKey.UserId != input.UserId {
return fmt.Errorf("access denied")
return apperrors.ErrAccessDenied
}

if err := app.ApiKeyPers.Delete(input.ApiKeyId); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion application/apikey/list_apikeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (app *ApiKeyApplication) ListApiKeys(input dto.ListApiKeysInput) (*dto.List
for i, k := range apiKeys {
var scopes []string
if k.Permissions != nil {
if s, ok := k.Permissions["scopes"].([]interface{}); ok {
if s, ok := k.Permissions["scopes"].([]any); ok {
for _, scope := range s {
if str, ok := scope.(string); ok {
scopes = append(scopes, str)
Expand Down
3 changes: 2 additions & 1 deletion application/apikey/update_apikey.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"time"

"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/apikey/dto"
"github.com/labbs/nexo/domain"
)
Expand All @@ -16,7 +17,7 @@ func (app *ApiKeyApplication) UpdateApiKey(input dto.UpdateApiKeyInput) error {

// Verify ownership
if apiKey.UserId != input.UserId {
return fmt.Errorf("access denied")
return apperrors.ErrAccessDenied
}

if input.Name != nil {
Expand Down
2 changes: 1 addition & 1 deletion application/apikey/validate_apikey.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (app *ApiKeyApplication) ValidateApiKey(input dto.ValidateApiKeyInput) (*dt
// Extract scopes
var scopes []string
if apiKey.Permissions != nil {
if s, ok := apiKey.Permissions["scopes"].([]interface{}); ok {
if s, ok := apiKey.Permissions["scopes"].([]any); ok {
for _, scope := range s {
if str, ok := scope.(string); ok {
scopes = append(scopes, str)
Expand Down
5 changes: 3 additions & 2 deletions application/auth/authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"time"

"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/auth/dto"
s "github.com/labbs/nexo/application/session/dto"
u "github.com/labbs/nexo/application/user/dto"
Expand All @@ -21,13 +22,13 @@ func (c *AuthApplication) Authenticate(input dto.AuthenticateInput) (*dto.Authen

if !resp.User.Active {
logger.Warn().Str("email", input.Email).Msg("attempt to authenticate inactive user")
return nil, fmt.Errorf("user is not active")
return nil, apperrors.ErrUserNotActive
}

err = bcrypt.CompareHashAndPassword([]byte(resp.User.Password), []byte(input.Password))
if err != nil {
logger.Warn().Str("email", input.Email).Msg("invalid password attempt")
return nil, fmt.Errorf("invalid credentials")
return nil, apperrors.ErrInvalidCredentials
}

sessionResult, err := c.SessionApplication.Create(s.CreateSessionInput{
Expand Down
3 changes: 2 additions & 1 deletion application/database/bulk_delete_rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package database
import (
"fmt"

"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/database/dto"
spaceDto "github.com/labbs/nexo/application/space/dto"
)
Expand All @@ -20,7 +21,7 @@ func (app *DatabaseApplication) BulkDeleteRows(input dto.BulkDeleteRowsInput) er
}

if spaceResult.Space.GetUserRole(input.UserId) == nil {
return fmt.Errorf("access denied")
return apperrors.ErrAccessDenied
}

if err := app.DatabaseRowPers.BulkDelete(input.RowIds); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion application/database/create_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/google/uuid"
"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/database/dto"
permissionDto "github.com/labbs/nexo/application/permission/dto"
spaceDto "github.com/labbs/nexo/application/space/dto"
Expand All @@ -20,7 +21,7 @@ func (app *DatabaseApplication) CreateDatabase(input dto.CreateDatabaseInput) (*
}

if spaceResult.Space.GetUserRole(input.UserId) == nil {
return nil, fmt.Errorf("access denied")
return nil, apperrors.ErrAccessDenied
}

// Determine database type (default to spreadsheet)
Expand Down
3 changes: 2 additions & 1 deletion application/database/create_row.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/google/uuid"
"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/database/dto"
spaceDto "github.com/labbs/nexo/application/space/dto"
"github.com/labbs/nexo/domain"
Expand All @@ -23,7 +24,7 @@ func (app *DatabaseApplication) CreateRow(input dto.CreateRowInput) (*dto.Create
}

if spaceResult.Space.GetUserRole(input.UserId) == nil {
return nil, fmt.Errorf("access denied")
return nil, apperrors.ErrAccessDenied
}

row := &domain.DatabaseRow{
Expand Down
3 changes: 2 additions & 1 deletion application/database/create_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/google/uuid"
"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/database/dto"
spaceDto "github.com/labbs/nexo/application/space/dto"
"github.com/labbs/nexo/domain"
Expand All @@ -24,7 +25,7 @@ func (app *DatabaseApplication) CreateView(input dto.CreateViewInput) (*dto.Crea
}

if spaceResult.Space.GetUserRole(input.UserId) == nil {
return nil, fmt.Errorf("access denied")
return nil, apperrors.ErrAccessDenied
}

// Parse existing views
Expand Down
3 changes: 2 additions & 1 deletion application/database/delete_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package database
import (
"fmt"

"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/database/dto"
spaceDto "github.com/labbs/nexo/application/space/dto"
)
Expand All @@ -20,7 +21,7 @@ func (app *DatabaseApplication) DeleteDatabase(input dto.DeleteDatabaseInput) er
}

if spaceResult.Space.GetUserRole(input.UserId) == nil {
return fmt.Errorf("access denied")
return apperrors.ErrAccessDenied
}

if err := app.DatabasePers.Delete(input.DatabaseId); err != nil {
Expand Down
5 changes: 3 additions & 2 deletions application/database/delete_row.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package database
import (
"fmt"

"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/database/dto"
spaceDto "github.com/labbs/nexo/application/space/dto"
)
Expand All @@ -14,7 +15,7 @@ func (app *DatabaseApplication) DeleteRow(input dto.DeleteRowInput) error {
}

if row.DatabaseId != input.DatabaseId {
return fmt.Errorf("row not found in this database")
return apperrors.ErrRowNotFound
}

database, err := app.DatabasePers.GetById(input.DatabaseId)
Expand All @@ -29,7 +30,7 @@ func (app *DatabaseApplication) DeleteRow(input dto.DeleteRowInput) error {
}

if spaceResult.Space.GetUserRole(input.UserId) == nil {
return fmt.Errorf("access denied")
return apperrors.ErrAccessDenied
}

if err := app.DatabaseRowPers.Delete(input.RowId); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion application/database/delete_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

"github.com/labbs/nexo/infrastructure/helpers/apperrors"
"github.com/labbs/nexo/application/database/dto"
spaceDto "github.com/labbs/nexo/application/space/dto"
"github.com/labbs/nexo/domain"
Expand All @@ -23,7 +24,7 @@ func (app *DatabaseApplication) DeleteView(input dto.DeleteViewInput) error {
}

if spaceResult.Space.GetUserRole(input.UserId) == nil {
return fmt.Errorf("access denied")
return apperrors.ErrAccessDenied
}

// Parse existing views
Expand Down
28 changes: 14 additions & 14 deletions application/database/dto/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ type UserInfo struct {

// Property schema
type PropertySchema struct {
Id string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Options map[string]interface{} `json:"options,omitempty"`
Id string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Options map[string]any `json:"options,omitempty"`
}

// View configuration
type ViewConfig struct {
Id string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Filter map[string]interface{} `json:"filter,omitempty"`
Sort []SortConfig `json:"sort,omitempty"`
Columns []string `json:"columns,omitempty"`
HiddenColumns []string `json:"hidden_columns,omitempty"`
GroupBy string `json:"group_by,omitempty"`
Id string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Filter map[string]any `json:"filter,omitempty"`
Sort []SortConfig `json:"sort,omitempty"`
Columns []string `json:"columns,omitempty"`
HiddenColumns []string `json:"hidden_columns,omitempty"`
GroupBy string `json:"group_by,omitempty"`
}

type SortConfig struct {
Expand All @@ -49,8 +49,8 @@ type DatabaseItem struct {

type RowItem struct {
Id string
Properties map[string]interface{}
Content map[string]interface{}
Properties map[string]any
Content map[string]any
ShowInSidebar bool
CreatedBy string
CreatedByUser *UserInfo
Expand Down
6 changes: 3 additions & 3 deletions application/database/dto/create_row.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import "time"
type CreateRowInput struct {
UserId string
DatabaseId string
Properties map[string]interface{}
Content map[string]interface{}
Properties map[string]any
Content map[string]any
ShowInSidebar bool
}

type CreateRowOutput struct {
Id string
Properties map[string]interface{}
Properties map[string]any
CreatedAt time.Time
}
Loading
Loading