diff --git a/Makefile b/Makefile index 5c92098e..cffc493b 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ APP_TAGS ?= $(or ${APP_BUILD_TAGS},postgres jaeger migrate) .DEPS: @echo "Install dependencies" go install github.com/NoahShen/gotunnelme + go install go.uber.org/mock/mockgen@latest .PHONY: all all: lint cover @@ -44,10 +45,6 @@ cover: @echo Open the coverage report: @echo open $(TMP_ETC)/coverage.html -.PHONY: __eval_srcs -__eval_srcs: - $(eval SRCS := $(shell find . -not -path 'bazel-*' -not -path '.tmp*' -name '*.go')) - .PHONY: generate-code generate-code: ## Run codegeneration procedure @echo "Generate code" @@ -62,6 +59,10 @@ build-gql: ## Build graphql server run-test-api: ## Run test api server cd example/api && make run-api +.PHONY: build-test-api +build-test-api: ## Build test api server + cd example/api && make build-docker-dev + .PHONY: announce-test-api announce-test-api: ## Run test api server with announce via tunnelme cd example/api && make -j2 announce-run-api diff --git a/README.md b/README.md index 848eb8ba..d44ec84f 100644 --- a/README.md +++ b/README.md @@ -4,51 +4,460 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/geniusrabbit/blaze-api)](https://goreportcard.com/report/github.com/geniusrabbit/blaze-api) [![Coverage Status](https://coveralls.io/repos/github/geniusrabbit/blaze-api/badge.svg?branch=main)](https://coveralls.io/github/geniusrabbit/blaze-api?branch=main) -Blaze-API is a foundational template for building and deploying APIs in Go. This template is designed to provide a basic structure for creating both RESTful and GraphQL APIs. It includes essential features such as user management, account handling, role-based access control (RBAC), and JWT authentication. +Blaze-API is a foundational template for building and deploying APIs in Go. It provides a production-ready structure for creating GraphQL APIs with user management, account handling, role-based access control (RBAC), OAuth2, and JWT authentication. + +**Features** - [x] Users: Manage user data and interactions. - [x] Accounts: Handle account operations and storage. -- [x] Roles: Implement Role-Based Access Control (RBAC) for managing user permissions. +- [x] Roles: Role-Based Access Control (RBAC) for managing user permissions. - [x] Permissions: Define and manage access rights for different roles. - [x] JWT Authentication: Secure your API with JWT-based authentication. - [x] GraphQL API: Integrated GraphQL support for building flexible APIs. +- [x] OAuth2: Server and client support with remote authorization. +- [x] Social auth: Facebook OAuth2 login out of the box (Google, LinkedIn, X.com ready to configure). +- [x] Object history log: Track all mutations with a per-request message. +- [x] Auth clients: OAuth2 client management (token issuance, revocation). +- [x] Direct access tokens: Long-lived tokens for service-to-service auth. +- [x] Generic repository/usecase layer: Type-safe CRUD with compile-time model constraints. +- [x] Tests: Comprehensive test suite for maintaining code quality. +- [x] Logging: Structured logging (Zap) with context propagation. +- [x] Profiler & metrics: pprof + Prometheus endpoints built in. - [ ] REST API: RESTful API interface for your application. - [ ] Swagger API documentation: Generate comprehensive API documentation with Swagger. -- [x] Tests: Comprehensive test suite for maintaining code quality. -- [x] Logging: Robust logging for monitoring and debugging. ## Quick Start ### Installation -To install Blaze-API, run the following command: - ```bash go get github.com/geniusrabbit/blaze-api ``` -### Example Usage +### Run the example locally (Docker) + +```bash +cd example/api + +# Start Postgres + run migrations + start the API +make run-api + +# API is available at http://localhost:8581 +# GraphQL playground: http://localhost:8581/ +# Prometheus metrics: http://localhost:8581/metrics +# pprof profiler: http://localhost:8583/debug/pprof/ +``` -Below is a brief example to get you started with Blaze-API. +The `run-api` target builds the Docker image, runs migrations, and starts the full stack via docker-compose. + +### Configuration + +All settings are read from environment variables (or a `.env` file). The key ones: + +```bash +# Database (PostgreSQL) +SYSTEM_STORAGE_DATABASE_MASTER_CONNECT=postgres://dbuser:password@localhost:5432/project?sslmode=disable +SYSTEM_STORAGE_DATABASE_SLAVE_CONNECT=postgres://dbuser:password@localhost:5432/project?sslmode=disable + +# OAuth2 / JWT +OAUTH2_SECRET=your-secret-min-32-chars +OAUTH2_ACCESS_TOKEN_LIFESPAN=1h +OAUTH2_REFRESH_TOKEN_LIFESPAN=720h + +# Session +SESSION_COOKIE_NAME=sessid +SESSION_LIFETIME=1h + +# Dev mode (skip auth with a static token) +DEBUG=true +LOG_LEVEL=debug +SESSION_DEV_TOKEN=develop +SESSION_DEV_USER_ID=1 +SESSION_DEV_ACCOUNT_ID=1 + +# Social auth (optional) +FACEBOOK_CLIENT_ID=... +FACEBOOK_CLIENT_SECRET=... +FACEBOOK_REDIRECT_URL=http://localhost:8581/auth/facebook/callback +``` + +A full annotated example lives in [example/api/.env](example/api/.env) and [example/api/deploy/develop/.api.env](example/api/deploy/develop/.api.env). + +### Wiring it together (`main.go`) ```go -// @see example/api/main.go +// example/api/cmd/api/main.go package main import ( - ... - "github.com/geniusrabbit/blaze-api/context/ctxlogger" - "github.com/geniusrabbit/blaze-api/context/permissionmanager" - "github.com/geniusrabbit/blaze-api/database" - "github.com/geniusrabbit/blaze-api/middleware" - "github.com/geniusrabbit/blaze-api/permissions" - "github.com/geniusrabbit/blaze-api/profiler" + "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" + "github.com/geniusrabbit/blaze-api/pkg/database" + "github.com/geniusrabbit/blaze-api/pkg/permissions" + "github.com/geniusrabbit/blaze-api/pkg/auth/jwt" + "github.com/geniusrabbit/blaze-api/pkg/auth/oauth2" + "github.com/geniusrabbit/blaze-api/repository/account/authorizer" "github.com/geniusrabbit/blaze-api/repository/historylog/middleware/gormlog" ) func main() { + // Connect master + slave databases + masterDB, slaveDB, _ := database.ConnectMasterSlave(ctx, + conf.System.Storage.MasterConnect, + conf.System.Storage.SlaveConnect) + + // Register GORM callback — writes a HistoryAction row for every mutation + gormlog.Register(masterDB) + + // Build permission manager (RBAC, cached) + permissionManager := permissions.NewManager(masterDB, conf.Permissions.RoleCacheLifetime) + appinit.InitModelPermissions(permissionManager) // register all domain models + + // Build OAuth2 + JWT providers + oauth2provider, jwtProvider := appinit.Auth(ctx, conf, masterDB) + + // Attach services to context (propagated to every request handler) + ctx = ctxlogger.WithLogger(ctx, logger) + ctx = database.WithDatabase(ctx, masterDB, slaveDB) + ctx = permissions.WithManager(ctx, permissionManager) + + httpServer := server.HTTPServer{ + Logger: logger, + JWTProvider: jwtProvider, + Authorizers: []auth.Authorizer[*user.User, *account.Account]{ + jwt.NewAuthorizer(jwtProvider), + oauth2.NewAuthorizer(oauth2provider), + authorizer.NewDevTokenAuthorizer(...), // dev-only static token + }, + ContextWrap: func(ctx context.Context) context.Context { + ctx = ctxlogger.WithLogger(ctx, logger) + ctx = database.WithDatabase(ctx, masterDB, slaveDB) + ctx = permissions.WithManager(ctx, permissionManager) + return ctx + }, + } + httpServer.Run(ctx, conf.Server.HTTP.Listen) +} +``` + +### Registering permissions for a domain model + +Every model that should participate in ACL must be registered with the permission manager: + +```go +// example/api/cmd/api/appinit/acl.go +func InitModelPermissions(pm *permissions.Manager) { + acl.InitModelPermissions(pm, + &user.User{}, + &rbacModels.Role{}, + &authclient.AuthClient{}, + &account.Account{}, + &historylog.HistoryAction{}, + // ... add your own models here + ) + + // Standard CRUD permissions + _ = pm.RegisterNewOwningPermissions(&user.User{}, + []string{acl.PermView, acl.PermList, acl.PermCreate, acl.PermUpdate, acl.PermDelete}) + + // With approval workflow + _ = pm.RegisterNewOwningPermissions(&account.Account{}, + append(crudPermissions, acl.PermApprove, acl.PermReject), + rbac.WithCustomCheck(accountCustomCheck)) +} +``` + +## Architecture + +### Repository / Usecase layer (`repository/generated`) + +All domain entities follow the same layered pattern: + +``` +repository// + models/ — domain structs (must implement generated.Model[TID]) + repository.go — domain Repository/Usecase interface + repository/ — GORM implementation (embeds generated.Repository[T, TID]) + usecase/ — business logic (embeds generated.Usecase[T, TID]) + mocks/ — generated mocks (go:generate mockgen, DO NOT EDIT) + delivery/ — transport adapters (GraphQL resolvers, REST handlers) +``` + +The generic base types live in `repository/generated`: + +| Type | Description | +| ------------------------- | ------------------------------------------------------------------- | +| `Repository[T, TID]` | GORM CRUD implementation for any model satisfying `Model[TID]` | +| `Usecase[T, TID]` | ACL-checked business logic delegating to `RepositoryIface[T, TID]` | +| `UsecaseApprover[T, TID]` | Approve/reject workflow with ACL checks | +| `BaseModel[TID]` | Convenience embed — provides `GetID`/`SetID` for free | +| `BaseTimestamps` | Convenience embed — provides `SetCreatedAt`/`SetUpdatedAt` for free | + +#### Defining a new domain model + +A model type `T` must satisfy the `generated.Model[TID]` constraint — i.e., expose `GetID() TID` via a **value receiver**. The easiest way is to embed `generated.BaseModel`: + +```go +import "github.com/geniusrabbit/blaze-api/repository/generated" + +type Widget struct { + generated.BaseModel[uint64] // GetID() + SetID() for free + generated.BaseTimestamps // SetCreatedAt() + SetUpdatedAt() for free + gorm.DeletedAt + + Name string +} + +func (w *Widget) TableName() string { return "widget" } +func (w *Widget) RBACResourceName() string { return "widget" } +``` + +Then create the repository and usecase: + +```go +// repository/widget/repository/repository.go +type Repository struct { + generated.Repository[widget.Widget, uint64] +} + +func New() *Repository { + return &Repository{Repository: *generated.NewRepository[widget.Widget, uint64]()} +} + +// repository/widget/usecase/usecase.go +type Usecase struct { + generated.Usecase[widget.Widget, uint64] +} + +func New(repo widget.Repository) *Usecase { + return &Usecase{Usecase: generated.Usecase[widget.Widget, uint64]{Repo: repo}} +} +``` + +If your model already has `ID`, `CreatedAt`, `UpdatedAt` fields but no embeds, add the methods explicitly (value receiver required for `GetID`): + +```go +func (m Widget) GetID() uint64 { return m.ID } +func (m *Widget) SetID(id uint64) { m.ID = id } +func (m *Widget) SetCreatedAt(t time.Time) { m.CreatedAt = t } +func (m *Widget) SetUpdatedAt(t time.Time) { m.UpdatedAt = t } +``` + +### Query options (`repository.QOption`) + +All mutation and query methods accept `...QOption` instead of positional parameters. Options compose freely: + +```go +type QOption interface { + PrepareQuery(query *gorm.DB) *gorm.DB +} +``` + +Built-in options: + +| Option | Package | Effect | +| ----------------------------------------------------------- | ----------------------- | ----------------------------------------------------------------------------- | +| `historylog.Message("reason")` | `repository/historylog` | Attaches a human-readable message to the mutation recorded in the history log | +| `&repository.PreloadOption{Fields: []string{"ChildRoles"}}` | `repository` | Adds GORM `.Preload(...)` calls | +| `filter` (`*Filter` implementing `QOption`) | domain package | Adds WHERE conditions | +| `order` (`*Order` implementing `QOption`) | domain package | Adds ORDER BY | + +Example: + +```go +id, err := roleRepo.Create(ctx, role, historylog.Message("initial seed")) + +err = roleRepo.Delete(ctx, id, historylog.Message("cleanup")) +``` + +### History log + +Every write that goes through a GORM master connection registered with `gormlog.Register(db)` records a `HistoryAction` row. The optional `historylog.Message(msg)` option attaches a human-readable reason: + +```go +gormlog.Register(masterDatabase) + +// in a usecase or resolver: +repo.Delete(ctx, id, historylog.Message("user requested account deletion")) +``` + +### Mock generation + +Mocks are generated with [mockgen](https://github.com/uber-go/mock) and committed as source code. **Never edit mock files by hand** — regenerate them: + +```bash +make generate-code # runs: go generate ./... +``` + +Each mock package carries the directive: + +```go +//go:generate mockgen -source=../repository.go -destination=../mocks/repository.go +``` + +## Extending the GraphQL API + +1. Add a `.graphql` schema file to `protocol/graphql/schemas/` (or your app's `schemas/` folder). +2. Point `gqlgen.yml` at the schemas — the example app uses: + +```yaml +# example/api/protocol/graphql/gqlgen.yml +schema: + - ../../../../protocol/graphql/schemas/*.graphql + - ../../../../repository/**/*.graphql +``` + +1. Regenerate: + +```bash +cd example/api && make build-gql # runs: go run github.com/99designs/gqlgen +``` + +1. Implement the generated resolver stubs in `internal/server/graphql/resolvers/`. + +A complete `gqlgen.yml` that maps blaze-api connection types: + +```yaml +schema: + - ../../../../protocol/graphql/schemas/*.graphql + - ../../../../repository/**/*.graphql + +skip_mod_tidy: true + +exec: + filename: ../../internal/server/graphql/generated/exec.go + package: generated + +model: + filename: ../../internal/server/graphql/models/generated.go + package: models + +resolver: + layout: follow-schema + dir: ../../internal/server/graphql/resolvers + package: resolvers + +omit_slice_element_pointers: false +skip_validation: true + +autobind: + - github.com/geniusrabbit/blaze-api/server/graphql/models + +models: + ID: + model: + - github.com/99designs/gqlgen/graphql.ID + - github.com/99designs/gqlgen/graphql.Int + - github.com/99designs/gqlgen/graphql.Int64 + - github.com/99designs/gqlgen/graphql.Int32 + Int64: + model: + - github.com/99designs/gqlgen/graphql.Int64 + Time: + model: github.com/geniusrabbit/blaze-api/server/graphql/types.Time + TimeDuration: + model: github.com/geniusrabbit/blaze-api/server/graphql/types.TimeDuration + DateTime: + model: github.com/geniusrabbit/blaze-api/server/graphql/types.DateTime + JSON: + model: github.com/geniusrabbit/blaze-api/server/graphql/types.JSON + NullableJSON: + model: github.com/geniusrabbit/blaze-api/server/graphql/types.NullableJSON + UUID: + model: github.com/geniusrabbit/blaze-api/server/graphql/types.UUID + ID64: + model: github.com/geniusrabbit/blaze-api/server/graphql/types.ID64 + # Connection types — use blaze-api's built-in implementations + UserConnection: + model: github.com/geniusrabbit/blaze-api/repository/user/delivery/graphql.UserConnection + AccountConnection: + model: github.com/geniusrabbit/blaze-api/repository/account/delivery/graphql.AccountConnection + MemberConnection: + model: github.com/geniusrabbit/blaze-api/repository/account/delivery/graphql.MemberConnection + RBACRoleConnection: + model: github.com/geniusrabbit/blaze-api/repository/rbac/delivery/graphql.RBACRoleConnection + AuthClientConnection: + model: github.com/geniusrabbit/blaze-api/repository/authclient/delivery/graphql.AuthClientConnection + HistoryActionConnection: + model: github.com/geniusrabbit/blaze-api/repository/historylog/delivery/graphql.HistoryActionConnection + OptionConnection: + model: github.com/geniusrabbit/blaze-api/repository/option/delivery/graphql.OptionConnection + DirectAccessTokenConnection: + model: github.com/geniusrabbit/blaze-api/repository/directaccesstoken/delivery/graphql.DirectAccessTokenConnection +``` + +## Development + +```bash +# Run all tests +make test + +# Run tests with race detector + coverage report +make cover + +# Regenerate mocks (go generate ./...) +make generate-code + +# Regenerate GraphQL server code (gqlgen) +cd example/api && make build-gql + +# Build the example API binary +cd example/api && make build-api + +# Run full stack via Docker Compose (Postgres + migrations + API) +cd example/api && make run-api + +# Lint +make lint +``` + +## TODO + +- [ ] OAuth2 social providers: Google, LinkedIn, X.com (endpoints are already wired; need full handler) +- [ ] REST API interface +- [ ] Swagger / OpenAPI documentation +- [ ] OpenTelemetry tracing ([opentelemetry-go](https://github.com/open-telemetry/opentelemetry-go/)) + +**Features** + +- [x] Users: Manage user data and interactions. +- [x] Accounts: Handle account operations and storage. +- [x] Roles: Role-Based Access Control (RBAC) for managing user permissions. +- [x] Permissions: Define and manage access rights for different roles. +- [x] JWT Authentication: Secure your API with JWT-based authentication. +- [x] GraphQL API: Integrated GraphQL support for building flexible APIs. +- [x] OAuth2: Server and client support with remote authorization. +- [x] Object history log: Track all mutations with a per-request message. +- [x] Auth clients: OAuth2 client management (token issuance, revocation). +- [x] Generic repository/usecase layer: Type-safe CRUD with compile-time model constraints. +- [x] Tests: Comprehensive test suite for maintaining code quality. +- [x] Logging: Structured logging with context propagation. +- [ ] REST API: RESTful API interface for your application. +- [ ] Swagger API documentation: Generate comprehensive API documentation with Swagger. + +## Quick Start + +### Installation + +```bash +go get github.com/geniusrabbit/blaze-api +``` + +### Example Usage + +```go +// @see example/api/cmd/api/main.go +package main + +import ( ... + "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" + "github.com/geniusrabbit/blaze-api/pkg/permissions" + "github.com/geniusrabbit/blaze-api/pkg/database" + "github.com/geniusrabbit/blaze-api/pkg/middleware" + "github.com/geniusrabbit/blaze-api/repository/historylog/middleware/gormlog" +) +func main() { // Register callback for history log (only for modifications) gormlog.Register(masterDatabase) @@ -56,10 +465,10 @@ func main() { permissionManager := permissions.NewManager(masterDatabase, conf.Permissions.RoleCacheLifetime) appinit.InitModelPermissions(permissionManager) - // Init OAuth2 provider + // Init OAuth2 + JWT providers oauth2provider, jwtProvider := appinit.Auth(ctx, conf, masterDatabase) - // Init HTTP server + // Init HTTP server httpServer := server.HTTPServer{ OAuth2provider: oauth2provider, JWTProvider: jwtProvider, @@ -80,80 +489,184 @@ func main() { } ``` -### Extend existing GraphQL API +## Architecture -To extend the existing GraphQL API, you need to create a new schema file in the `src/graphql/schemas` folder. Then, you need to add the new schema file to the `gqlgen.yml` configuration file. Finally, you need to run the `go generate` command to generate the new GraphQL API. +### Repository / Usecase layer (`repository/generated`) + +All domain entities follow the same layered pattern: + +``` +repository// + models/ — domain structs (must implement generated.Model[TID]) + repository.go — domain Repository/Usecase interface + repository/ — GORM implementation (embeds generated.Repository[T, TID]) + usecase/ — business logic (embeds generated.Usecase[T, TID]) + mocks/ — generated mocks (go:generate mockgen, DO NOT EDIT) + delivery/ — transport adapters (GraphQL resolvers, REST handlers) +``` + +The generic base types live in `repository/generated`: + +| Type | Description | +| ------------------------- | ------------------------------------------------------------------- | +| `Repository[T, TID]` | GORM CRUD implementation for any model satisfying `Model[TID]` | +| `Usecase[T, TID]` | ACL-checked business logic delegating to `RepositoryIface[T, TID]` | +| `UsecaseApprover[T, TID]` | Approve/reject workflow with ACL checks | +| `BaseModel[TID]` | Convenience embed — provides `GetID`/`SetID` for free | +| `BaseTimestamps` | Convenience embed — provides `SetCreatedAt`/`SetUpdatedAt` for free | + +#### Defining a new domain model + +A model type `T` must satisfy the `generated.Model[TID]` constraint — i.e., expose `GetID() TID` via a **value receiver**. The easiest way is to embed `generated.BaseModel`: + +```go +import "github.com/geniusrabbit/blaze-api/repository/generated" + +type Widget struct { + generated.BaseModel[uint64] // GetID() + SetID() for free + generated.BaseTimestamps // SetCreatedAt() + SetUpdatedAt() for free + gorm.DeletedAt + + Name string +} +``` + +Then create the repository: + +```go +type Repository struct { + generated.Repository[Widget, uint64] +} + +func New() *Repository { + return &Repository{Repository: *generated.NewRepository[Widget, uint64]()} +} +``` + +If your model already has `ID`, `CreatedAt`, `UpdatedAt` fields but no embeds, add the methods explicitly (value receiver required for `GetID`): + +```go +func (m Widget) GetID() uint64 { return m.ID } +func (m *Widget) SetID(id uint64) { m.ID = id } +func (m *Widget) SetCreatedAt(t time.Time) { m.CreatedAt = t } +func (m *Widget) SetUpdatedAt(t time.Time) { m.UpdatedAt = t } +``` + +### Query options (`repository.QOption`) + +All mutation and query methods accept `...QOption` instead of positional parameters. Options compose freely: + +```go +type QOption interface { + PrepareQuery(query *gorm.DB) *gorm.DB +} +``` + +Built-in options: + +| Option | Package | Effect | +| ----------------------------------------------------------- | ----------------------- | ----------------------------------------------------------------------------- | +| `historylog.Message("reason")` | `repository/historylog` | Attaches a human-readable message to the mutation recorded in the history log | +| `&repository.PreloadOption{Fields: []string{"ChildRoles"}}` | `repository` | Adds GORM `.Preload(...)` calls | +| `filter` (`*Filter` implementing `QOption`) | domain package | Adds WHERE conditions | +| `order` (`*Order` implementing `QOption`) | domain package | Adds ORDER BY | + +Example: + +```go +id, err := roleRepo.Create(ctx, role, historylog.Message("initial seed")) + +err = roleRepo.Delete(ctx, id, + historylog.Message("cleanup"), +) +``` + +### History log + +Every write that goes through a GORM master connection registered with `gormlog.Register(db)` records a `HistoryAction` row. The optional `historylog.Message(msg)` option attaches a human-readable reason: + +```go +gormlog.Register(masterDatabase) + +// later, in a usecase or resolver: +repo.Delete(ctx, id, historylog.Message("user requested account deletion")) +``` + +### Mock generation + +Mocks are generated with [mockgen](https://github.com/uber-go/mock) and committed as source code. **Never edit mock files by hand** — regenerate them: + +```bash +make generate-code # runs: go generate ./... +``` + +Each mock package carries the directive: + +Each mock package carries the directive: + +```go +//go:generate mockgen -source=../repository.go -destination=../mocks/repository.go +``` + +## Extending the GraphQL API + +1. Add a schema file to `protocol/graphql/schemas/` (or your app's `schemas/` folder). +2. Reference it in `gqlgen.yml`: ```yaml -# Generate the server inside the folder -# > go run github.com/99designs/gqlgen +schema: + - ./schemas/*.graphql + - ../../vendor/github.com/geniusrabbit/blaze-api/protocol/graphql/schemas/*.graphql + - ../../vendor/github.com/geniusrabbit/blaze-api/repository/**/*.graphql +``` + +1. Regenerate the server code: + +```bash +make build-gql # runs: go run github.com/99designs/gqlgen +``` + +1. Implement the generated resolver stubs in `internal/server/graphql/resolvers/`. + +A minimal `gqlgen.yml` for an application that imports blaze-api: -# Where are all the schema files located? globs are supported eg src/**/*.graphqls +```yaml schema: - ./schemas/*.graphql - ../../vendor/github.com/geniusrabbit/blaze-api/protocol/graphql/schemas/*.graphql + - ../../vendor/github.com/geniusrabbit/blaze-api/repository/**/*.graphql skip_mod_tidy: yes -# Where should the generated server code go? exec: filename: ../../internal/server/graphql/generated/exec.go package: generated -# federation: -# filename: ../../lib/server/graphql/generated/federation.go -# package: generated - model: filename: ../../internal/server/graphql/models/generated.go package: models -# Where should the resolver implementations go? resolver: layout: follow-schema dir: ../../internal/server/graphql/resolvers package: resolvers -# Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models -# struct_tag: json - -# Optional: turn on to use []Thing instead of []*Thing omit_slice_element_pointers: false - -# Optional: set to speed up generation time by not performing a final validation pass. skip_validation: true -# gqlgen will search for any type names in the schema in these go packages -# if they match it will use them, otherwise it will generate them. autobind: - github.com/geniusrabbit/blaze-api/server/graphql/models -# This section declares type mapping between the GraphQL and go type systems -# -# The first line in each type will be used as defaults for resolver arguments and -# modelgen, the others will be allowed when binding to fields. Configure them to -# your liking models: ID: model: - github.com/99designs/gqlgen/graphql.ID - - github.com/99designs/gqlgen/graphql.Int - - github.com/99designs/gqlgen/graphql.Int64 - - github.com/99designs/gqlgen/graphql.Int32 - Int: - model: - - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - - github.com/99designs/gqlgen/graphql.Int32 Int64: model: - github.com/99designs/gqlgen/graphql.Int64 Time: model: github.com/geniusrabbit/blaze-api/server/graphql/types.Time - TimeDuration: - model: github.com/geniusrabbit/blaze-api/server/graphql/types.TimeDuration - DateTime: - model: github.com/geniusrabbit/blaze-api/server/graphql/types.DateTime JSON: model: github.com/geniusrabbit/blaze-api/server/graphql/types.JSON NullableJSON: @@ -162,13 +675,10 @@ models: model: github.com/geniusrabbit/blaze-api/server/graphql/types.UUID ID64: model: github.com/geniusrabbit/blaze-api/server/graphql/types.ID64 - # Connectors UserConnection: model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.UserConnection AccountConnection: model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.AccountConnection - MemberConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.MemberConnection RBACRoleConnection: model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.RBACRoleConnection AuthClientConnection: @@ -179,18 +689,28 @@ models: model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.OptionConnection ``` -## TODO features +## Development -- [ ] OAuth2 add authorization providers: Google, Facebook, LinkedIn, GitHub, etc. -- [x] OAuth2 remote authorization. -- [ ] REST API: RESTful API interface for your application. -- [ ] Swagger API documentation: Generate comprehensive API documentation with Swagger. -- [x] GraphQL API: Integrated GraphQL support for building flexible APIs. -- [x] Support different databases (PostgreSQL, MySQL, SQLite, etc.) -- [x] OAuth2 server and client support. -- [x] RBAC: Role-Based Access Control (RBAC) for managing user permissions. -- [x] JWT Authentication: Secure your API with JWT-based authentication. -- [x] Object modification history log. -- [x] Profiler: Integrated profiler for monitoring and debugging. -- [x] Mailer/messanger support (abstract interface layer). -- [ ] Add support [OpenTelemetry-Go](https://github.com/open-telemetry/opentelemetry-go/) +```bash +# Run all tests +make test + +# Run tests with coverage report +make cover + +# Regenerate mocks and gqlgen code +make generate-code + +# Build the example API +cd example/api && make build-api + +# Lint +make lint +``` + +## TODO + +- [ ] OAuth2 social providers: Google, Facebook, LinkedIn, GitHub +- [ ] REST API interface +- [ ] Swagger / OpenAPI documentation +- [ ] OpenTelemetry tracing ([opentelemetry-go](https://github.com/open-telemetry/opentelemetry-go/)) diff --git a/migrations/fixtures/001_init.up.sql b/deploy/migrations/fixtures/001_init.up.sql similarity index 100% rename from migrations/fixtures/001_init.up.sql rename to deploy/migrations/fixtures/001_init.up.sql diff --git a/migrations/initial/001_init.up.sql b/deploy/migrations/initial/001_init.up.sql similarity index 100% rename from migrations/initial/001_init.up.sql rename to deploy/migrations/initial/001_init.up.sql diff --git a/migrations/initial/002_account.up.sql b/deploy/migrations/initial/002_account.up.sql similarity index 98% rename from migrations/initial/002_account.up.sql rename to deploy/migrations/initial/002_account.up.sql index 054d4cfa..7c5ab51a 100644 --- a/migrations/initial/002_account.up.sql +++ b/deploy/migrations/initial/002_account.up.sql @@ -14,6 +14,7 @@ CREATE TABLE account_user , email VARCHAR(128) NOT NULL CHECK (email ~* '^[^\s]+$') UNIQUE , password VARCHAR(128) NOT NULL CHECK (LENGTH(password) = 0 OR LENGTH(password) > 5) +, required_password_reset BOOL NOT NULL DEFAULT FALSE , created_at TIMESTAMP NOT NULL DEFAULT NOW() , updated_at TIMESTAMP NOT NULL DEFAULT NOW() diff --git a/migrations/initial/003_auth.up.sql b/deploy/migrations/initial/003_auth.up.sql similarity index 100% rename from migrations/initial/003_auth.up.sql rename to deploy/migrations/initial/003_auth.up.sql diff --git a/migrations/initial/004_auth_account.up.sql b/deploy/migrations/initial/004_auth_account.up.sql similarity index 100% rename from migrations/initial/004_auth_account.up.sql rename to deploy/migrations/initial/004_auth_account.up.sql diff --git a/migrations/initial/005_auth_roles.up.sql b/deploy/migrations/initial/005_auth_roles.up.sql similarity index 100% rename from migrations/initial/005_auth_roles.up.sql rename to deploy/migrations/initial/005_auth_roles.up.sql diff --git a/migrations/initial/006_social_login.up.sql b/deploy/migrations/initial/006_social_login.up.sql similarity index 100% rename from migrations/initial/006_social_login.up.sql rename to deploy/migrations/initial/006_social_login.up.sql diff --git a/migrations/initial/007_historylog.up.sql b/deploy/migrations/initial/007_historylog.up.sql similarity index 100% rename from migrations/initial/007_historylog.up.sql rename to deploy/migrations/initial/007_historylog.up.sql diff --git a/migrations/initial/008_option.up.sql b/deploy/migrations/initial/008_option.up.sql similarity index 100% rename from migrations/initial/008_option.up.sql rename to deploy/migrations/initial/008_option.up.sql diff --git a/migrations/initial/009_direct_access_token.up.sql b/deploy/migrations/initial/009_direct_access_token.up.sql similarity index 100% rename from migrations/initial/009_direct_access_token.up.sql rename to deploy/migrations/initial/009_direct_access_token.up.sql diff --git a/example/api/cmd/api/appinit/acl.go b/example/api/cmd/api/appinit/acl.go index de2e5970..3280b0ab 100644 --- a/example/api/cmd/api/appinit/acl.go +++ b/example/api/cmd/api/appinit/acl.go @@ -5,11 +5,18 @@ import ( "github.com/demdxx/rbac" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/acl" "github.com/geniusrabbit/blaze-api/pkg/context/session" "github.com/geniusrabbit/blaze-api/pkg/permissions" + "github.com/geniusrabbit/blaze-api/repository/account" "github.com/geniusrabbit/blaze-api/repository/account/repository" + "github.com/geniusrabbit/blaze-api/repository/authclient" + daModels "github.com/geniusrabbit/blaze-api/repository/directaccesstoken/models" + "github.com/geniusrabbit/blaze-api/repository/historylog" + "github.com/geniusrabbit/blaze-api/repository/option" + rbacModels "github.com/geniusrabbit/blaze-api/repository/rbac/models" + "github.com/geniusrabbit/blaze-api/repository/socialaccount" + "github.com/geniusrabbit/blaze-api/repository/user" ) var ( @@ -30,46 +37,46 @@ const ( func InitModelPermissions(pm *permissions.Manager) { // Register permission objects acl.InitModelPermissions(pm, - &model.User{}, - &model.Role{}, - &model.AuthClient{}, - &model.Account{}, - &model.AccountMember{}, - &model.AccountSocialSession{}, - &model.AccountSocial{}, - &model.HistoryAction{}, - &model.Option{}, - &model.DirectAccessToken{}, + &user.User{}, + &rbacModels.Role{}, + &authclient.AuthClient{}, + &account.Account{}, + &account.AccountMember{}, + &socialaccount.AccountSocialSession{}, + &socialaccount.AccountSocial{}, + &historylog.HistoryAction{}, + &option.Option{}, + &daModels.DirectAccessToken{}, ) // Register user permissions - _ = pm.RegisterNewOwningPermissions(&model.User{}, append(crudPermissions, PermUserPassReset, PermUserPassSet)) + _ = pm.RegisterNewOwningPermissions(&user.User{}, append(crudPermissions, PermUserPassReset, PermUserPassSet)) // Register basic models CRUD permissions for Account with member checks - _ = pm.RegisterNewOwningPermissions(&model.Account{}, crudPermissionsWithApprove, rbac.WithCustomCheck(accountCustomCheck)) + _ = pm.RegisterNewOwningPermissions(&account.Account{}, crudPermissionsWithApprove, rbac.WithCustomCheck(accountCustomCheck)) _ = pm.RegisterNewPermission(nil, PermAccountRegister, rbac.WithoutCustomCheck) // Register basic roles permissions - _ = pm.RegisterNewOwningPermissions(&model.Role{}, crudPermissions) - _ = pm.RegisterNewPermission(&model.Role{}, `check`, + _ = pm.RegisterNewOwningPermissions(&rbacModels.Role{}, crudPermissions) + _ = pm.RegisterNewPermission(&rbacModels.Role{}, `check`, rbac.WithDescription("Check role permissions is assigned to the user")) _ = pm.RegisterNewPermission(nil, PermPermissionList, rbac.WithDescription("List all permissions")) // Register basic permissions for the AuthClient model - _ = pm.RegisterNewOwningPermissions(&model.AuthClient{}, crudPermissions) + _ = pm.RegisterNewOwningPermissions(&authclient.AuthClient{}, crudPermissions) // Register basic permissions for the AccountMember model - _ = pm.RegisterNewOwningPermissions(&model.AccountMember{}, crudPermissionsWithApprove) - _ = pm.RegisterNewPermissions(&model.AccountMember{}, []string{`roles.set.account`, `roles.set.all`, `invite`}) + _ = pm.RegisterNewOwningPermissions(&account.AccountMember{}, crudPermissionsWithApprove) + _ = pm.RegisterNewPermissions(&account.AccountMember{}, []string{`roles.set.account`, `roles.set.all`, `invite`}) // Register basic permissions for the HistoryAction model - _ = pm.RegisterNewOwningPermissions(&model.HistoryAction{}, []string{acl.PermView, acl.PermList, acl.PermCount}) + _ = pm.RegisterNewOwningPermissions(&historylog.HistoryAction{}, []string{acl.PermView, acl.PermList, acl.PermCount}) // Register basic permissions for the Option model - _ = pm.RegisterNewOwningPermissions(&model.Option{}, []string{acl.PermGet, acl.PermSet, acl.PermList, acl.PermCount}) + _ = pm.RegisterNewOwningPermissions(&option.Option{}, []string{acl.PermGet, acl.PermSet, acl.PermList, acl.PermCount}) // Register basic permissions for the DirectAccessToken model - _ = pm.RegisterNewOwningPermissions(&model.DirectAccessToken{}, []string{acl.PermGet, acl.PermList, acl.PermCount, acl.PermCreate, acl.PermDelete}) + _ = pm.RegisterNewOwningPermissions(&daModels.DirectAccessToken{}, []string{acl.PermGet, acl.PermList, acl.PermCount, acl.PermCreate, acl.PermDelete}) // Register anonymous role and fill permissions for it pm.RegisterRole(context.Background(), @@ -97,14 +104,14 @@ func InitModelPermissions(pm *permissions.Manager) { } func accountCustomCheck(ctx context.Context, resource any, perm rbac.Permission) bool { - account, _ := resource.(*model.Account) + acc, _ := resource.(*account.Account) user := session.User(ctx) - if account.IsOwnerUser(user.ID) { + if acc.IsOwnerUser(user.ID) { return true } - repo := repository.New() + members := repository.NewMemberRepository() if perm.MatchPermissionPattern(`*.{view|list|count}.*`) { - return repo.IsMember(ctx, user.ID, account.ID) + return members.IsMember(ctx, user.ID, acc.ID) } - return repo.IsAdmin(ctx, user.ID, account.ID) + return members.IsAdmin(ctx, user.ID, acc.ID) } diff --git a/example/api/cmd/api/appinit/auth.go b/example/api/cmd/api/appinit/auth.go index 86f506f2..3385b11b 100644 --- a/example/api/cmd/api/appinit/auth.go +++ b/example/api/cmd/api/appinit/auth.go @@ -31,7 +31,7 @@ func Auth(ctx context.Context, conf *appcontext.ConfigType, masterDatabase *gorm SendDebugMessagesToClients: conf.OAuth2.SendDebugMessagesToClients, } sessionCache := newCache(ctx, conf.OAuth2.CacheConnect, conf.OAuth2.CacheLifetime) - userRepository := user_repository.New() + userRepository := user_repository.NewUserRepository() oauth2storage := serverprovider.NewDatabaseStorage( masterDatabase, userRepository, diff --git a/example/api/cmd/api/main.go b/example/api/cmd/api/main.go index 86c26d3d..7112fcc2 100644 --- a/example/api/cmd/api/main.go +++ b/example/api/cmd/api/main.go @@ -17,7 +17,6 @@ import ( "github.com/geniusrabbit/blaze-api/example/api/cmd/api/appinit" "github.com/geniusrabbit/blaze-api/example/api/internal/server" "github.com/geniusrabbit/blaze-api/pkg/auth" - "github.com/geniusrabbit/blaze-api/pkg/auth/devtoken" "github.com/geniusrabbit/blaze-api/pkg/auth/elogin/facebook" "github.com/geniusrabbit/blaze-api/pkg/auth/jwt" "github.com/geniusrabbit/blaze-api/pkg/auth/oauth2" @@ -28,8 +27,11 @@ import ( "github.com/geniusrabbit/blaze-api/pkg/permissions" "github.com/geniusrabbit/blaze-api/pkg/profiler" "github.com/geniusrabbit/blaze-api/pkg/zlogger" + "github.com/geniusrabbit/blaze-api/repository/account" + "github.com/geniusrabbit/blaze-api/repository/account/authorizer" "github.com/geniusrabbit/blaze-api/repository/historylog/middleware/gormlog" "github.com/geniusrabbit/blaze-api/repository/socialauth/delivery/rest" + "github.com/geniusrabbit/blaze-api/repository/user" ) var ( @@ -118,10 +120,10 @@ func main() { Logger: loggerObj, JWTProvider: jwtProvider, SessionManager: appinit.SessionManager(conf.Session.CookieName, conf.Session.Lifetime), - Authorizers: []auth.Authorizer{ + Authorizers: []auth.Authorizer[*user.User, *account.Account]{ jwt.NewAuthorizer(jwtProvider), oauth2.NewAuthorizer(oauth2provider), - devtoken.NewAuthorizer(gocast.IfThen(conf.IsDebug(), &devtoken.AuthOption{ + authorizer.NewDevTokenAuthorizer(gocast.IfThen(conf.IsDebug(), &authorizer.AuthOption{ DevToken: conf.Session.DevToken, DevUserID: conf.Session.DevUserID, DevAccountID: conf.Session.DevAccountID, diff --git a/example/api/deploy/migrations b/example/api/deploy/migrations index 888f5a63..d6e8a610 120000 --- a/example/api/deploy/migrations +++ b/example/api/deploy/migrations @@ -1 +1 @@ -../../../migrations \ No newline at end of file +../../../deploy/migrations \ No newline at end of file diff --git a/example/api/internal/server/graphql/generated/exec.go b/example/api/internal/server/graphql/generated/exec.go index b4712958..e518ea96 100644 --- a/example/api/internal/server/graphql/generated/exec.go +++ b/example/api/internal/server/graphql/generated/exec.go @@ -8,13 +8,11 @@ import ( "errors" "fmt" "strconv" - "sync" "sync/atomic" "time" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" - models1 "github.com/geniusrabbit/blaze-api/example/api/internal/server/graphql/models" "github.com/geniusrabbit/blaze-api/server/graphql/connectors" "github.com/geniusrabbit/blaze-api/server/graphql/models" "github.com/geniusrabbit/blaze-api/server/graphql/types" @@ -27,20 +25,10 @@ import ( // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - schema: cfg.Schema, - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } + return &executableSchema{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity} } -type Config struct { - Schema *ast.Schema - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} +type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot] type ResolverRoot interface { Mutation() MutationResolver @@ -52,6 +40,10 @@ type DirectiveRoot struct { Auth func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) CacheData func(ctx context.Context, obj any, next graphql.Resolver, ttl int, key *string, fields []string) (res any, err error) HasPermissions func(ctx context.Context, obj any, next graphql.Resolver, permissions []string) (res any, err error) + Length func(ctx context.Context, obj any, next graphql.Resolver, min int, max int, trim bool, ornil bool) (res any, err error) + Notempty func(ctx context.Context, obj any, next graphql.Resolver, trim bool, ornil bool) (res any, err error) + Range func(ctx context.Context, obj any, next graphql.Resolver, min float64, max float64, ornil bool) (res any, err error) + Regex func(ctx context.Context, obj any, next graphql.Resolver, pattern string, trim bool, ornil bool) (res any, err error) SkipNoPermissions func(ctx context.Context, obj any, next graphql.Resolver, permissions []string) (res any, err error) } @@ -226,7 +218,7 @@ type ComplexityRoot struct { ApproveAccount func(childComplexity int, id uint64, msg string) int ApproveAccountMember func(childComplexity int, memberID uint64, msg string) int ApproveUser func(childComplexity int, id uint64, msg *string) int - CreateAuthClient func(childComplexity int, input models.AuthClientInput) int + CreateAuthClient func(childComplexity int, input models.AuthClientCreateInput) int CreateRole func(childComplexity int, input models.RBACRoleInput) int CreateUser func(childComplexity int, input models.UserInput) int DeleteAuthClient func(childComplexity int, id string, msg *string) int @@ -248,7 +240,7 @@ type ComplexityRoot struct { SwitchAccount func(childComplexity int, id uint64) int UpdateAccount func(childComplexity int, id uint64, input models.AccountInput) int UpdateAccountMember func(childComplexity int, memberID uint64, member models.MemberInput) int - UpdateAuthClient func(childComplexity int, id string, input models.AuthClientInput) int + UpdateAuthClient func(childComplexity int, id string, input models.AuthClientUpdateInput) int UpdateRole func(childComplexity int, id uint64, input models.RBACRoleInput) int UpdateUser func(childComplexity int, id uint64, input models.UserInput) int UpdateUserPassword func(childComplexity int, token string, email string, password string) int @@ -318,7 +310,7 @@ type ComplexityRoot struct { GetDirectAccessToken func(childComplexity int, id uint64) int ListAccountRolesAndPermissions func(childComplexity int, accountID uint64, order *models.RBACRoleListOrder) int ListAccounts func(childComplexity int, filter *models.AccountListFilter, order *models.AccountListOrder, page *models.Page) int - ListAuthClients func(childComplexity int, filter *models.AuthClientListFilter, order *models.AuthClientListOrder, page *models.Page) int + ListAuthClients func(childComplexity int, filter *models.AuthClientListFilter, order []*models.AuthClientListOrder, page *models.Page) int ListDirectAccessTokens func(childComplexity int, filter *models.DirectAccessTokenListFilter, order *models.DirectAccessTokenListOrder, page *models.Page) int ListHistory func(childComplexity int, filter *models.HistoryActionListFilter, order *models.HistoryActionListOrder, page *models.Page) int ListMembers func(childComplexity int, filter *models.MemberListFilter, order *models.MemberListOrder, page *models.Page) int @@ -467,6 +459,12 @@ type ComplexityRoot struct { type MutationResolver interface { Poke(ctx context.Context) (string, error) + CreateUser(ctx context.Context, input models.UserInput) (*models.UserPayload, error) + UpdateUser(ctx context.Context, id uint64, input models.UserInput) (*models.UserPayload, error) + ApproveUser(ctx context.Context, id uint64, msg *string) (*models.UserPayload, error) + RejectUser(ctx context.Context, id uint64, msg *string) (*models.UserPayload, error) + ResetUserPassword(ctx context.Context, email string) (*models.StatusResponse, error) + UpdateUserPassword(ctx context.Context, token string, email string, password string) (*models.StatusResponse, error) Login(ctx context.Context, login string, password string) (*models.SessionToken, error) Logout(ctx context.Context) (bool, error) SwitchAccount(ctx context.Context, id uint64) (*models.SessionToken, error) @@ -479,15 +477,8 @@ type MutationResolver interface { RemoveAccountMember(ctx context.Context, memberID uint64) (*models.MemberPayload, error) ApproveAccountMember(ctx context.Context, memberID uint64, msg string) (*models.MemberPayload, error) RejectAccountMember(ctx context.Context, memberID uint64, msg string) (*models.MemberPayload, error) - DisconnectSocialAccount(ctx context.Context, id uint64) (*models.SocialAccountPayload, error) - CreateUser(ctx context.Context, input models.UserInput) (*models.UserPayload, error) - UpdateUser(ctx context.Context, id uint64, input models.UserInput) (*models.UserPayload, error) - ApproveUser(ctx context.Context, id uint64, msg *string) (*models.UserPayload, error) - RejectUser(ctx context.Context, id uint64, msg *string) (*models.UserPayload, error) - ResetUserPassword(ctx context.Context, email string) (*models.StatusResponse, error) - UpdateUserPassword(ctx context.Context, token string, email string, password string) (*models.StatusResponse, error) - CreateAuthClient(ctx context.Context, input models.AuthClientInput) (*models.AuthClientPayload, error) - UpdateAuthClient(ctx context.Context, id string, input models.AuthClientInput) (*models.AuthClientPayload, error) + CreateAuthClient(ctx context.Context, input models.AuthClientCreateInput) (*models.AuthClientPayload, error) + UpdateAuthClient(ctx context.Context, id string, input models.AuthClientUpdateInput) (*models.AuthClientPayload, error) DeleteAuthClient(ctx context.Context, id string, msg *string) (*models.AuthClientPayload, error) GenerateDirectAccessToken(ctx context.Context, userID *uint64, description string, expiresAt *time.Time) (*models.DirectAccessTokenPayload, error) RevokeDirectAccessToken(ctx context.Context, filter models.DirectAccessTokenListFilter) (*models.StatusResponse, error) @@ -495,25 +486,23 @@ type MutationResolver interface { CreateRole(ctx context.Context, input models.RBACRoleInput) (*models.RBACRolePayload, error) UpdateRole(ctx context.Context, id uint64, input models.RBACRoleInput) (*models.RBACRolePayload, error) DeleteRole(ctx context.Context, id uint64, msg *string) (*models.RBACRolePayload, error) + DisconnectSocialAccount(ctx context.Context, id uint64) (*models.SocialAccountPayload, error) } type QueryResolver interface { ServiceVersion(ctx context.Context) (string, error) + CurrentUser(ctx context.Context) (*models.UserPayload, error) + User(ctx context.Context, id uint64, username string) (*models.UserPayload, error) + ListUsers(ctx context.Context, filter *models.UserListFilter, order *models.UserListOrder, page *models.Page) (*connectors.CollectionConnection[models.User, models.UserEdge], error) CurrentSession(ctx context.Context) (*models.SessionToken, error) CurrentAccount(ctx context.Context) (*models.AccountPayload, error) Account(ctx context.Context, id uint64) (*models.AccountPayload, error) ListAccounts(ctx context.Context, filter *models.AccountListFilter, order *models.AccountListOrder, page *models.Page) (*connectors.CollectionConnection[models.Account, models.AccountEdge], error) ListAccountRolesAndPermissions(ctx context.Context, accountID uint64, order *models.RBACRoleListOrder) (*connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge], error) ListMembers(ctx context.Context, filter *models.MemberListFilter, order *models.MemberListOrder, page *models.Page) (*connectors.CollectionConnection[models.Member, models.MemberEdge], error) - SocialAccount(ctx context.Context, id uint64) (*models.SocialAccountPayload, error) - CurrentSocialAccounts(ctx context.Context, filter *models.SocialAccountListFilter, order *models.SocialAccountListOrder) (*connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge], error) - ListSocialAccounts(ctx context.Context, filter *models.SocialAccountListFilter, order *models.SocialAccountListOrder, page *models.Page) (*connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge], error) - CurrentUser(ctx context.Context) (*models.UserPayload, error) - User(ctx context.Context, id uint64, username string) (*models.UserPayload, error) - ListUsers(ctx context.Context, filter *models.UserListFilter, order *models.UserListOrder, page *models.Page) (*connectors.CollectionConnection[models.User, models.UserEdge], error) AuthClient(ctx context.Context, id string) (*models.AuthClientPayload, error) - ListAuthClients(ctx context.Context, filter *models.AuthClientListFilter, order *models.AuthClientListOrder, page *models.Page) (*connectors.CollectionConnection[models.AuthClient, models.AuthClientEdge], error) + ListAuthClients(ctx context.Context, filter *models.AuthClientListFilter, order []*models.AuthClientListOrder, page *models.Page) (*connectors.CollectionConnection[models.AuthClient, models.AuthClientEdge], error) GetDirectAccessToken(ctx context.Context, id uint64) (*models.DirectAccessTokenPayload, error) - ListDirectAccessTokens(ctx context.Context, filter *models.DirectAccessTokenListFilter, order *models.DirectAccessTokenListOrder, page *models.Page) (*models1.DirectAccessTokenConnection, error) + ListDirectAccessTokens(ctx context.Context, filter *models.DirectAccessTokenListFilter, order *models.DirectAccessTokenListOrder, page *models.Page) (*connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge], error) ListHistory(ctx context.Context, filter *models.HistoryActionListFilter, order *models.HistoryActionListOrder, page *models.Page) (*connectors.CollectionConnection[models.HistoryAction, models.HistoryActionEdge], error) Option(ctx context.Context, name string, typeArg models.OptionType, targetID uint64) (*models.OptionPayload, error) ListOptions(ctx context.Context, filter *models.OptionListFilter, order *models.OptionListOrder, page *models.Page) (*connectors.CollectionConnection[models.Option, models.OptionEdge], error) @@ -522,668 +511,666 @@ type QueryResolver interface { ListRoles(ctx context.Context, filter *models.RBACRoleListFilter, order *models.RBACRoleListOrder, page *models.Page) (*connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge], error) ListPermissions(ctx context.Context, patterns []string) ([]*models.RBACPermission, error) ListMyPermissions(ctx context.Context, patterns []string) ([]*models.RBACPermission, error) + SocialAccount(ctx context.Context, id uint64) (*models.SocialAccountPayload, error) + CurrentSocialAccounts(ctx context.Context, filter *models.SocialAccountListFilter, order *models.SocialAccountListOrder) (*connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge], error) + ListSocialAccounts(ctx context.Context, filter *models.SocialAccountListFilter, order *models.SocialAccountListOrder, page *models.Page) (*connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge], error) } -type executableSchema struct { - schema *ast.Schema - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} +type executableSchema graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot] func (e *executableSchema) Schema() *ast.Schema { - if e.schema != nil { - return e.schema + if e.SchemaData != nil { + return e.SchemaData } return parsedSchema } func (e *executableSchema) Complexity(ctx context.Context, typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) { - ec := executionContext{nil, e, 0, 0, nil} + ec := newExecutionContext(nil, e, nil) _ = ec switch typeName + "." + field { case "Account.clientURI": - if e.complexity.Account.ClientURI == nil { + if e.ComplexityRoot.Account.ClientURI == nil { break } - return e.complexity.Account.ClientURI(childComplexity), true + return e.ComplexityRoot.Account.ClientURI(childComplexity), true case "Account.contacts": - if e.complexity.Account.Contacts == nil { + if e.ComplexityRoot.Account.Contacts == nil { break } - return e.complexity.Account.Contacts(childComplexity), true + return e.ComplexityRoot.Account.Contacts(childComplexity), true case "Account.createdAt": - if e.complexity.Account.CreatedAt == nil { + if e.ComplexityRoot.Account.CreatedAt == nil { break } - return e.complexity.Account.CreatedAt(childComplexity), true + return e.ComplexityRoot.Account.CreatedAt(childComplexity), true case "Account.description": - if e.complexity.Account.Description == nil { + if e.ComplexityRoot.Account.Description == nil { break } - return e.complexity.Account.Description(childComplexity), true + return e.ComplexityRoot.Account.Description(childComplexity), true case "Account.ID": - if e.complexity.Account.ID == nil { + if e.ComplexityRoot.Account.ID == nil { break } - return e.complexity.Account.ID(childComplexity), true + return e.ComplexityRoot.Account.ID(childComplexity), true case "Account.logoURI": - if e.complexity.Account.LogoURI == nil { + if e.ComplexityRoot.Account.LogoURI == nil { break } - return e.complexity.Account.LogoURI(childComplexity), true + return e.ComplexityRoot.Account.LogoURI(childComplexity), true case "Account.policyURI": - if e.complexity.Account.PolicyURI == nil { + if e.ComplexityRoot.Account.PolicyURI == nil { break } - return e.complexity.Account.PolicyURI(childComplexity), true + return e.ComplexityRoot.Account.PolicyURI(childComplexity), true case "Account.status": - if e.complexity.Account.Status == nil { + if e.ComplexityRoot.Account.Status == nil { break } - return e.complexity.Account.Status(childComplexity), true + return e.ComplexityRoot.Account.Status(childComplexity), true case "Account.statusMessage": - if e.complexity.Account.StatusMessage == nil { + if e.ComplexityRoot.Account.StatusMessage == nil { break } - return e.complexity.Account.StatusMessage(childComplexity), true + return e.ComplexityRoot.Account.StatusMessage(childComplexity), true case "Account.termsOfServiceURI": - if e.complexity.Account.TermsOfServiceURI == nil { + if e.ComplexityRoot.Account.TermsOfServiceURI == nil { break } - return e.complexity.Account.TermsOfServiceURI(childComplexity), true + return e.ComplexityRoot.Account.TermsOfServiceURI(childComplexity), true case "Account.title": - if e.complexity.Account.Title == nil { + if e.ComplexityRoot.Account.Title == nil { break } - return e.complexity.Account.Title(childComplexity), true + return e.ComplexityRoot.Account.Title(childComplexity), true case "Account.updatedAt": - if e.complexity.Account.UpdatedAt == nil { + if e.ComplexityRoot.Account.UpdatedAt == nil { break } - return e.complexity.Account.UpdatedAt(childComplexity), true + return e.ComplexityRoot.Account.UpdatedAt(childComplexity), true case "AccountConnection.edges": - if e.complexity.AccountConnection.Edges == nil { + if e.ComplexityRoot.AccountConnection.Edges == nil { break } - return e.complexity.AccountConnection.Edges(childComplexity), true + return e.ComplexityRoot.AccountConnection.Edges(childComplexity), true case "AccountConnection.list": - if e.complexity.AccountConnection.List == nil { + if e.ComplexityRoot.AccountConnection.List == nil { break } - return e.complexity.AccountConnection.List(childComplexity), true + return e.ComplexityRoot.AccountConnection.List(childComplexity), true case "AccountConnection.pageInfo": - if e.complexity.AccountConnection.PageInfo == nil { + if e.ComplexityRoot.AccountConnection.PageInfo == nil { break } - return e.complexity.AccountConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.AccountConnection.PageInfo(childComplexity), true case "AccountConnection.totalCount": - if e.complexity.AccountConnection.TotalCount == nil { + if e.ComplexityRoot.AccountConnection.TotalCount == nil { break } - return e.complexity.AccountConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.AccountConnection.TotalCount(childComplexity), true case "AccountCreatePayload.account": - if e.complexity.AccountCreatePayload.Account == nil { + if e.ComplexityRoot.AccountCreatePayload.Account == nil { break } - return e.complexity.AccountCreatePayload.Account(childComplexity), true + return e.ComplexityRoot.AccountCreatePayload.Account(childComplexity), true case "AccountCreatePayload.clientMutationID": - if e.complexity.AccountCreatePayload.ClientMutationID == nil { + if e.ComplexityRoot.AccountCreatePayload.ClientMutationID == nil { break } - return e.complexity.AccountCreatePayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.AccountCreatePayload.ClientMutationID(childComplexity), true case "AccountCreatePayload.owner": - if e.complexity.AccountCreatePayload.Owner == nil { + if e.ComplexityRoot.AccountCreatePayload.Owner == nil { break } - return e.complexity.AccountCreatePayload.Owner(childComplexity), true + return e.ComplexityRoot.AccountCreatePayload.Owner(childComplexity), true case "AccountEdge.cursor": - if e.complexity.AccountEdge.Cursor == nil { + if e.ComplexityRoot.AccountEdge.Cursor == nil { break } - return e.complexity.AccountEdge.Cursor(childComplexity), true + return e.ComplexityRoot.AccountEdge.Cursor(childComplexity), true case "AccountEdge.node": - if e.complexity.AccountEdge.Node == nil { + if e.ComplexityRoot.AccountEdge.Node == nil { break } - return e.complexity.AccountEdge.Node(childComplexity), true + return e.ComplexityRoot.AccountEdge.Node(childComplexity), true case "AccountPayload.account": - if e.complexity.AccountPayload.Account == nil { + if e.ComplexityRoot.AccountPayload.Account == nil { break } - return e.complexity.AccountPayload.Account(childComplexity), true + return e.ComplexityRoot.AccountPayload.Account(childComplexity), true case "AccountPayload.accountID": - if e.complexity.AccountPayload.AccountID == nil { + if e.ComplexityRoot.AccountPayload.AccountID == nil { break } - return e.complexity.AccountPayload.AccountID(childComplexity), true + return e.ComplexityRoot.AccountPayload.AccountID(childComplexity), true case "AccountPayload.clientMutationID": - if e.complexity.AccountPayload.ClientMutationID == nil { + if e.ComplexityRoot.AccountPayload.ClientMutationID == nil { break } - return e.complexity.AccountPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.AccountPayload.ClientMutationID(childComplexity), true case "AuthClient.accountID": - if e.complexity.AuthClient.AccountID == nil { + if e.ComplexityRoot.AuthClient.AccountID == nil { break } - return e.complexity.AuthClient.AccountID(childComplexity), true + return e.ComplexityRoot.AuthClient.AccountID(childComplexity), true case "AuthClient.allowedCORSOrigins": - if e.complexity.AuthClient.AllowedCORSOrigins == nil { + if e.ComplexityRoot.AuthClient.AllowedCORSOrigins == nil { break } - return e.complexity.AuthClient.AllowedCORSOrigins(childComplexity), true + return e.ComplexityRoot.AuthClient.AllowedCORSOrigins(childComplexity), true case "AuthClient.audience": - if e.complexity.AuthClient.Audience == nil { + if e.ComplexityRoot.AuthClient.Audience == nil { break } - return e.complexity.AuthClient.Audience(childComplexity), true + return e.ComplexityRoot.AuthClient.Audience(childComplexity), true case "AuthClient.createdAt": - if e.complexity.AuthClient.CreatedAt == nil { + if e.ComplexityRoot.AuthClient.CreatedAt == nil { break } - return e.complexity.AuthClient.CreatedAt(childComplexity), true + return e.ComplexityRoot.AuthClient.CreatedAt(childComplexity), true case "AuthClient.deletedAt": - if e.complexity.AuthClient.DeletedAt == nil { + if e.ComplexityRoot.AuthClient.DeletedAt == nil { break } - return e.complexity.AuthClient.DeletedAt(childComplexity), true + return e.ComplexityRoot.AuthClient.DeletedAt(childComplexity), true case "AuthClient.expiresAt": - if e.complexity.AuthClient.ExpiresAt == nil { + if e.ComplexityRoot.AuthClient.ExpiresAt == nil { break } - return e.complexity.AuthClient.ExpiresAt(childComplexity), true + return e.ComplexityRoot.AuthClient.ExpiresAt(childComplexity), true case "AuthClient.grantTypes": - if e.complexity.AuthClient.GrantTypes == nil { + if e.ComplexityRoot.AuthClient.GrantTypes == nil { break } - return e.complexity.AuthClient.GrantTypes(childComplexity), true + return e.ComplexityRoot.AuthClient.GrantTypes(childComplexity), true case "AuthClient.ID": - if e.complexity.AuthClient.ID == nil { + if e.ComplexityRoot.AuthClient.ID == nil { break } - return e.complexity.AuthClient.ID(childComplexity), true + return e.ComplexityRoot.AuthClient.ID(childComplexity), true case "AuthClient.public": - if e.complexity.AuthClient.Public == nil { + if e.ComplexityRoot.AuthClient.Public == nil { break } - return e.complexity.AuthClient.Public(childComplexity), true + return e.ComplexityRoot.AuthClient.Public(childComplexity), true case "AuthClient.redirectURIs": - if e.complexity.AuthClient.RedirectURIs == nil { + if e.ComplexityRoot.AuthClient.RedirectURIs == nil { break } - return e.complexity.AuthClient.RedirectURIs(childComplexity), true + return e.ComplexityRoot.AuthClient.RedirectURIs(childComplexity), true case "AuthClient.responseTypes": - if e.complexity.AuthClient.ResponseTypes == nil { + if e.ComplexityRoot.AuthClient.ResponseTypes == nil { break } - return e.complexity.AuthClient.ResponseTypes(childComplexity), true + return e.ComplexityRoot.AuthClient.ResponseTypes(childComplexity), true case "AuthClient.scope": - if e.complexity.AuthClient.Scope == nil { + if e.ComplexityRoot.AuthClient.Scope == nil { break } - return e.complexity.AuthClient.Scope(childComplexity), true + return e.ComplexityRoot.AuthClient.Scope(childComplexity), true case "AuthClient.secret": - if e.complexity.AuthClient.Secret == nil { + if e.ComplexityRoot.AuthClient.Secret == nil { break } - return e.complexity.AuthClient.Secret(childComplexity), true + return e.ComplexityRoot.AuthClient.Secret(childComplexity), true case "AuthClient.subjectType": - if e.complexity.AuthClient.SubjectType == nil { + if e.ComplexityRoot.AuthClient.SubjectType == nil { break } - return e.complexity.AuthClient.SubjectType(childComplexity), true + return e.ComplexityRoot.AuthClient.SubjectType(childComplexity), true case "AuthClient.title": - if e.complexity.AuthClient.Title == nil { + if e.ComplexityRoot.AuthClient.Title == nil { break } - return e.complexity.AuthClient.Title(childComplexity), true + return e.ComplexityRoot.AuthClient.Title(childComplexity), true case "AuthClient.updatedAt": - if e.complexity.AuthClient.UpdatedAt == nil { + if e.ComplexityRoot.AuthClient.UpdatedAt == nil { break } - return e.complexity.AuthClient.UpdatedAt(childComplexity), true + return e.ComplexityRoot.AuthClient.UpdatedAt(childComplexity), true case "AuthClient.userID": - if e.complexity.AuthClient.UserID == nil { + if e.ComplexityRoot.AuthClient.UserID == nil { break } - return e.complexity.AuthClient.UserID(childComplexity), true + return e.ComplexityRoot.AuthClient.UserID(childComplexity), true case "AuthClientConnection.edges": - if e.complexity.AuthClientConnection.Edges == nil { + if e.ComplexityRoot.AuthClientConnection.Edges == nil { break } - return e.complexity.AuthClientConnection.Edges(childComplexity), true + return e.ComplexityRoot.AuthClientConnection.Edges(childComplexity), true case "AuthClientConnection.list": - if e.complexity.AuthClientConnection.List == nil { + if e.ComplexityRoot.AuthClientConnection.List == nil { break } - return e.complexity.AuthClientConnection.List(childComplexity), true + return e.ComplexityRoot.AuthClientConnection.List(childComplexity), true case "AuthClientConnection.pageInfo": - if e.complexity.AuthClientConnection.PageInfo == nil { + if e.ComplexityRoot.AuthClientConnection.PageInfo == nil { break } - return e.complexity.AuthClientConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.AuthClientConnection.PageInfo(childComplexity), true case "AuthClientConnection.totalCount": - if e.complexity.AuthClientConnection.TotalCount == nil { + if e.ComplexityRoot.AuthClientConnection.TotalCount == nil { break } - return e.complexity.AuthClientConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.AuthClientConnection.TotalCount(childComplexity), true case "AuthClientEdge.cursor": - if e.complexity.AuthClientEdge.Cursor == nil { + if e.ComplexityRoot.AuthClientEdge.Cursor == nil { break } - return e.complexity.AuthClientEdge.Cursor(childComplexity), true + return e.ComplexityRoot.AuthClientEdge.Cursor(childComplexity), true case "AuthClientEdge.node": - if e.complexity.AuthClientEdge.Node == nil { + if e.ComplexityRoot.AuthClientEdge.Node == nil { break } - return e.complexity.AuthClientEdge.Node(childComplexity), true + return e.ComplexityRoot.AuthClientEdge.Node(childComplexity), true case "AuthClientPayload.authClient": - if e.complexity.AuthClientPayload.AuthClient == nil { + if e.ComplexityRoot.AuthClientPayload.AuthClient == nil { break } - return e.complexity.AuthClientPayload.AuthClient(childComplexity), true + return e.ComplexityRoot.AuthClientPayload.AuthClient(childComplexity), true case "AuthClientPayload.authClientID": - if e.complexity.AuthClientPayload.AuthClientID == nil { + if e.ComplexityRoot.AuthClientPayload.AuthClientID == nil { break } - return e.complexity.AuthClientPayload.AuthClientID(childComplexity), true + return e.ComplexityRoot.AuthClientPayload.AuthClientID(childComplexity), true case "AuthClientPayload.clientMutationID": - if e.complexity.AuthClientPayload.ClientMutationID == nil { + if e.ComplexityRoot.AuthClientPayload.ClientMutationID == nil { break } - return e.complexity.AuthClientPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.AuthClientPayload.ClientMutationID(childComplexity), true case "DirectAccessToken.accountID": - if e.complexity.DirectAccessToken.AccountID == nil { + if e.ComplexityRoot.DirectAccessToken.AccountID == nil { break } - return e.complexity.DirectAccessToken.AccountID(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.AccountID(childComplexity), true case "DirectAccessToken.createdAt": - if e.complexity.DirectAccessToken.CreatedAt == nil { + if e.ComplexityRoot.DirectAccessToken.CreatedAt == nil { break } - return e.complexity.DirectAccessToken.CreatedAt(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.CreatedAt(childComplexity), true case "DirectAccessToken.description": - if e.complexity.DirectAccessToken.Description == nil { + if e.ComplexityRoot.DirectAccessToken.Description == nil { break } - return e.complexity.DirectAccessToken.Description(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.Description(childComplexity), true case "DirectAccessToken.expiresAt": - if e.complexity.DirectAccessToken.ExpiresAt == nil { + if e.ComplexityRoot.DirectAccessToken.ExpiresAt == nil { break } - return e.complexity.DirectAccessToken.ExpiresAt(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.ExpiresAt(childComplexity), true case "DirectAccessToken.ID": - if e.complexity.DirectAccessToken.ID == nil { + if e.ComplexityRoot.DirectAccessToken.ID == nil { break } - return e.complexity.DirectAccessToken.ID(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.ID(childComplexity), true case "DirectAccessToken.token": - if e.complexity.DirectAccessToken.Token == nil { + if e.ComplexityRoot.DirectAccessToken.Token == nil { break } - return e.complexity.DirectAccessToken.Token(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.Token(childComplexity), true case "DirectAccessToken.userID": - if e.complexity.DirectAccessToken.UserID == nil { + if e.ComplexityRoot.DirectAccessToken.UserID == nil { break } - return e.complexity.DirectAccessToken.UserID(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.UserID(childComplexity), true case "DirectAccessTokenConnection.edges": - if e.complexity.DirectAccessTokenConnection.Edges == nil { + if e.ComplexityRoot.DirectAccessTokenConnection.Edges == nil { break } - return e.complexity.DirectAccessTokenConnection.Edges(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenConnection.Edges(childComplexity), true case "DirectAccessTokenConnection.list": - if e.complexity.DirectAccessTokenConnection.List == nil { + if e.ComplexityRoot.DirectAccessTokenConnection.List == nil { break } - return e.complexity.DirectAccessTokenConnection.List(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenConnection.List(childComplexity), true case "DirectAccessTokenConnection.pageInfo": - if e.complexity.DirectAccessTokenConnection.PageInfo == nil { + if e.ComplexityRoot.DirectAccessTokenConnection.PageInfo == nil { break } - return e.complexity.DirectAccessTokenConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenConnection.PageInfo(childComplexity), true case "DirectAccessTokenConnection.totalCount": - if e.complexity.DirectAccessTokenConnection.TotalCount == nil { + if e.ComplexityRoot.DirectAccessTokenConnection.TotalCount == nil { break } - return e.complexity.DirectAccessTokenConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenConnection.TotalCount(childComplexity), true case "DirectAccessTokenEdge.cursor": - if e.complexity.DirectAccessTokenEdge.Cursor == nil { + if e.ComplexityRoot.DirectAccessTokenEdge.Cursor == nil { break } - return e.complexity.DirectAccessTokenEdge.Cursor(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenEdge.Cursor(childComplexity), true case "DirectAccessTokenEdge.node": - if e.complexity.DirectAccessTokenEdge.Node == nil { + if e.ComplexityRoot.DirectAccessTokenEdge.Node == nil { break } - return e.complexity.DirectAccessTokenEdge.Node(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenEdge.Node(childComplexity), true case "DirectAccessTokenPayload.clientMutationID": - if e.complexity.DirectAccessTokenPayload.ClientMutationID == nil { + if e.ComplexityRoot.DirectAccessTokenPayload.ClientMutationID == nil { break } - return e.complexity.DirectAccessTokenPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenPayload.ClientMutationID(childComplexity), true case "DirectAccessTokenPayload.token": - if e.complexity.DirectAccessTokenPayload.Token == nil { + if e.ComplexityRoot.DirectAccessTokenPayload.Token == nil { break } - return e.complexity.DirectAccessTokenPayload.Token(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenPayload.Token(childComplexity), true case "HistoryAction.accountID": - if e.complexity.HistoryAction.AccountID == nil { + if e.ComplexityRoot.HistoryAction.AccountID == nil { break } - return e.complexity.HistoryAction.AccountID(childComplexity), true + return e.ComplexityRoot.HistoryAction.AccountID(childComplexity), true case "HistoryAction.actionAt": - if e.complexity.HistoryAction.ActionAt == nil { + if e.ComplexityRoot.HistoryAction.ActionAt == nil { break } - return e.complexity.HistoryAction.ActionAt(childComplexity), true + return e.ComplexityRoot.HistoryAction.ActionAt(childComplexity), true case "HistoryAction.data": - if e.complexity.HistoryAction.Data == nil { + if e.ComplexityRoot.HistoryAction.Data == nil { break } - return e.complexity.HistoryAction.Data(childComplexity), true + return e.ComplexityRoot.HistoryAction.Data(childComplexity), true case "HistoryAction.ID": - if e.complexity.HistoryAction.ID == nil { + if e.ComplexityRoot.HistoryAction.ID == nil { break } - return e.complexity.HistoryAction.ID(childComplexity), true + return e.ComplexityRoot.HistoryAction.ID(childComplexity), true case "HistoryAction.message": - if e.complexity.HistoryAction.Message == nil { + if e.ComplexityRoot.HistoryAction.Message == nil { break } - return e.complexity.HistoryAction.Message(childComplexity), true + return e.ComplexityRoot.HistoryAction.Message(childComplexity), true case "HistoryAction.name": - if e.complexity.HistoryAction.Name == nil { + if e.ComplexityRoot.HistoryAction.Name == nil { break } - return e.complexity.HistoryAction.Name(childComplexity), true + return e.ComplexityRoot.HistoryAction.Name(childComplexity), true case "HistoryAction.objectID": - if e.complexity.HistoryAction.ObjectID == nil { + if e.ComplexityRoot.HistoryAction.ObjectID == nil { break } - return e.complexity.HistoryAction.ObjectID(childComplexity), true + return e.ComplexityRoot.HistoryAction.ObjectID(childComplexity), true case "HistoryAction.objectIDs": - if e.complexity.HistoryAction.ObjectIDs == nil { + if e.ComplexityRoot.HistoryAction.ObjectIDs == nil { break } - return e.complexity.HistoryAction.ObjectIDs(childComplexity), true + return e.ComplexityRoot.HistoryAction.ObjectIDs(childComplexity), true case "HistoryAction.objectType": - if e.complexity.HistoryAction.ObjectType == nil { + if e.ComplexityRoot.HistoryAction.ObjectType == nil { break } - return e.complexity.HistoryAction.ObjectType(childComplexity), true + return e.ComplexityRoot.HistoryAction.ObjectType(childComplexity), true case "HistoryAction.RequestID": - if e.complexity.HistoryAction.RequestID == nil { + if e.ComplexityRoot.HistoryAction.RequestID == nil { break } - return e.complexity.HistoryAction.RequestID(childComplexity), true + return e.ComplexityRoot.HistoryAction.RequestID(childComplexity), true case "HistoryAction.userID": - if e.complexity.HistoryAction.UserID == nil { + if e.ComplexityRoot.HistoryAction.UserID == nil { break } - return e.complexity.HistoryAction.UserID(childComplexity), true + return e.ComplexityRoot.HistoryAction.UserID(childComplexity), true case "HistoryActionConnection.edges": - if e.complexity.HistoryActionConnection.Edges == nil { + if e.ComplexityRoot.HistoryActionConnection.Edges == nil { break } - return e.complexity.HistoryActionConnection.Edges(childComplexity), true + return e.ComplexityRoot.HistoryActionConnection.Edges(childComplexity), true case "HistoryActionConnection.list": - if e.complexity.HistoryActionConnection.List == nil { + if e.ComplexityRoot.HistoryActionConnection.List == nil { break } - return e.complexity.HistoryActionConnection.List(childComplexity), true + return e.ComplexityRoot.HistoryActionConnection.List(childComplexity), true case "HistoryActionConnection.pageInfo": - if e.complexity.HistoryActionConnection.PageInfo == nil { + if e.ComplexityRoot.HistoryActionConnection.PageInfo == nil { break } - return e.complexity.HistoryActionConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.HistoryActionConnection.PageInfo(childComplexity), true case "HistoryActionConnection.totalCount": - if e.complexity.HistoryActionConnection.TotalCount == nil { + if e.ComplexityRoot.HistoryActionConnection.TotalCount == nil { break } - return e.complexity.HistoryActionConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.HistoryActionConnection.TotalCount(childComplexity), true case "HistoryActionEdge.cursor": - if e.complexity.HistoryActionEdge.Cursor == nil { + if e.ComplexityRoot.HistoryActionEdge.Cursor == nil { break } - return e.complexity.HistoryActionEdge.Cursor(childComplexity), true + return e.ComplexityRoot.HistoryActionEdge.Cursor(childComplexity), true case "HistoryActionEdge.node": - if e.complexity.HistoryActionEdge.Node == nil { + if e.ComplexityRoot.HistoryActionEdge.Node == nil { break } - return e.complexity.HistoryActionEdge.Node(childComplexity), true + return e.ComplexityRoot.HistoryActionEdge.Node(childComplexity), true case "HistoryActionPayload.action": - if e.complexity.HistoryActionPayload.Action == nil { + if e.ComplexityRoot.HistoryActionPayload.Action == nil { break } - return e.complexity.HistoryActionPayload.Action(childComplexity), true + return e.ComplexityRoot.HistoryActionPayload.Action(childComplexity), true case "HistoryActionPayload.actionID": - if e.complexity.HistoryActionPayload.ActionID == nil { + if e.ComplexityRoot.HistoryActionPayload.ActionID == nil { break } - return e.complexity.HistoryActionPayload.ActionID(childComplexity), true + return e.ComplexityRoot.HistoryActionPayload.ActionID(childComplexity), true case "HistoryActionPayload.clientMutationId": - if e.complexity.HistoryActionPayload.ClientMutationID == nil { + if e.ComplexityRoot.HistoryActionPayload.ClientMutationID == nil { break } - return e.complexity.HistoryActionPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.HistoryActionPayload.ClientMutationID(childComplexity), true case "Member.account": - if e.complexity.Member.Account == nil { + if e.ComplexityRoot.Member.Account == nil { break } - return e.complexity.Member.Account(childComplexity), true + return e.ComplexityRoot.Member.Account(childComplexity), true case "Member.createdAt": - if e.complexity.Member.CreatedAt == nil { + if e.ComplexityRoot.Member.CreatedAt == nil { break } - return e.complexity.Member.CreatedAt(childComplexity), true + return e.ComplexityRoot.Member.CreatedAt(childComplexity), true case "Member.deletedAt": - if e.complexity.Member.DeletedAt == nil { + if e.ComplexityRoot.Member.DeletedAt == nil { break } - return e.complexity.Member.DeletedAt(childComplexity), true + return e.ComplexityRoot.Member.DeletedAt(childComplexity), true case "Member.ID": - if e.complexity.Member.ID == nil { + if e.ComplexityRoot.Member.ID == nil { break } - return e.complexity.Member.ID(childComplexity), true + return e.ComplexityRoot.Member.ID(childComplexity), true case "Member.isAdmin": - if e.complexity.Member.IsAdmin == nil { + if e.ComplexityRoot.Member.IsAdmin == nil { break } - return e.complexity.Member.IsAdmin(childComplexity), true + return e.ComplexityRoot.Member.IsAdmin(childComplexity), true case "Member.roles": - if e.complexity.Member.Roles == nil { + if e.ComplexityRoot.Member.Roles == nil { break } - return e.complexity.Member.Roles(childComplexity), true + return e.ComplexityRoot.Member.Roles(childComplexity), true case "Member.status": - if e.complexity.Member.Status == nil { + if e.ComplexityRoot.Member.Status == nil { break } - return e.complexity.Member.Status(childComplexity), true + return e.ComplexityRoot.Member.Status(childComplexity), true case "Member.updatedAt": - if e.complexity.Member.UpdatedAt == nil { + if e.ComplexityRoot.Member.UpdatedAt == nil { break } - return e.complexity.Member.UpdatedAt(childComplexity), true + return e.ComplexityRoot.Member.UpdatedAt(childComplexity), true case "Member.user": - if e.complexity.Member.User == nil { + if e.ComplexityRoot.Member.User == nil { break } - return e.complexity.Member.User(childComplexity), true + return e.ComplexityRoot.Member.User(childComplexity), true case "MemberConnection.edges": - if e.complexity.MemberConnection.Edges == nil { + if e.ComplexityRoot.MemberConnection.Edges == nil { break } - return e.complexity.MemberConnection.Edges(childComplexity), true + return e.ComplexityRoot.MemberConnection.Edges(childComplexity), true case "MemberConnection.list": - if e.complexity.MemberConnection.List == nil { + if e.ComplexityRoot.MemberConnection.List == nil { break } - return e.complexity.MemberConnection.List(childComplexity), true + return e.ComplexityRoot.MemberConnection.List(childComplexity), true case "MemberConnection.pageInfo": - if e.complexity.MemberConnection.PageInfo == nil { + if e.ComplexityRoot.MemberConnection.PageInfo == nil { break } - return e.complexity.MemberConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.MemberConnection.PageInfo(childComplexity), true case "MemberConnection.totalCount": - if e.complexity.MemberConnection.TotalCount == nil { + if e.ComplexityRoot.MemberConnection.TotalCount == nil { break } - return e.complexity.MemberConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.MemberConnection.TotalCount(childComplexity), true case "MemberEdge.cursor": - if e.complexity.MemberEdge.Cursor == nil { + if e.ComplexityRoot.MemberEdge.Cursor == nil { break } - return e.complexity.MemberEdge.Cursor(childComplexity), true + return e.ComplexityRoot.MemberEdge.Cursor(childComplexity), true case "MemberEdge.node": - if e.complexity.MemberEdge.Node == nil { + if e.ComplexityRoot.MemberEdge.Node == nil { break } - return e.complexity.MemberEdge.Node(childComplexity), true + return e.ComplexityRoot.MemberEdge.Node(childComplexity), true case "MemberPayload.clientMutationID": - if e.complexity.MemberPayload.ClientMutationID == nil { + if e.ComplexityRoot.MemberPayload.ClientMutationID == nil { break } - return e.complexity.MemberPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.MemberPayload.ClientMutationID(childComplexity), true case "MemberPayload.member": - if e.complexity.MemberPayload.Member == nil { + if e.ComplexityRoot.MemberPayload.Member == nil { break } - return e.complexity.MemberPayload.Member(childComplexity), true + return e.ComplexityRoot.MemberPayload.Member(childComplexity), true case "MemberPayload.memberID": - if e.complexity.MemberPayload.MemberID == nil { + if e.ComplexityRoot.MemberPayload.MemberID == nil { break } - return e.complexity.MemberPayload.MemberID(childComplexity), true + return e.ComplexityRoot.MemberPayload.MemberID(childComplexity), true case "Mutation.approveAccount": - if e.complexity.Mutation.ApproveAccount == nil { + if e.ComplexityRoot.Mutation.ApproveAccount == nil { break } @@ -1192,9 +1179,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.ApproveAccount(childComplexity, args["id"].(uint64), args["msg"].(string)), true + return e.ComplexityRoot.Mutation.ApproveAccount(childComplexity, args["id"].(uint64), args["msg"].(string)), true case "Mutation.approveAccountMember": - if e.complexity.Mutation.ApproveAccountMember == nil { + if e.ComplexityRoot.Mutation.ApproveAccountMember == nil { break } @@ -1203,9 +1190,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.ApproveAccountMember(childComplexity, args["memberID"].(uint64), args["msg"].(string)), true + return e.ComplexityRoot.Mutation.ApproveAccountMember(childComplexity, args["memberID"].(uint64), args["msg"].(string)), true case "Mutation.approveUser": - if e.complexity.Mutation.ApproveUser == nil { + if e.ComplexityRoot.Mutation.ApproveUser == nil { break } @@ -1214,9 +1201,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.ApproveUser(childComplexity, args["id"].(uint64), args["msg"].(*string)), true + return e.ComplexityRoot.Mutation.ApproveUser(childComplexity, args["id"].(uint64), args["msg"].(*string)), true case "Mutation.createAuthClient": - if e.complexity.Mutation.CreateAuthClient == nil { + if e.ComplexityRoot.Mutation.CreateAuthClient == nil { break } @@ -1225,9 +1212,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.CreateAuthClient(childComplexity, args["input"].(models.AuthClientInput)), true + return e.ComplexityRoot.Mutation.CreateAuthClient(childComplexity, args["input"].(models.AuthClientCreateInput)), true case "Mutation.createRole": - if e.complexity.Mutation.CreateRole == nil { + if e.ComplexityRoot.Mutation.CreateRole == nil { break } @@ -1236,9 +1223,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.CreateRole(childComplexity, args["input"].(models.RBACRoleInput)), true + return e.ComplexityRoot.Mutation.CreateRole(childComplexity, args["input"].(models.RBACRoleInput)), true case "Mutation.createUser": - if e.complexity.Mutation.CreateUser == nil { + if e.ComplexityRoot.Mutation.CreateUser == nil { break } @@ -1247,9 +1234,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.CreateUser(childComplexity, args["input"].(models.UserInput)), true + return e.ComplexityRoot.Mutation.CreateUser(childComplexity, args["input"].(models.UserInput)), true case "Mutation.deleteAuthClient": - if e.complexity.Mutation.DeleteAuthClient == nil { + if e.ComplexityRoot.Mutation.DeleteAuthClient == nil { break } @@ -1258,9 +1245,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.DeleteAuthClient(childComplexity, args["id"].(string), args["msg"].(*string)), true + return e.ComplexityRoot.Mutation.DeleteAuthClient(childComplexity, args["id"].(string), args["msg"].(*string)), true case "Mutation.deleteRole": - if e.complexity.Mutation.DeleteRole == nil { + if e.ComplexityRoot.Mutation.DeleteRole == nil { break } @@ -1269,9 +1256,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.DeleteRole(childComplexity, args["id"].(uint64), args["msg"].(*string)), true + return e.ComplexityRoot.Mutation.DeleteRole(childComplexity, args["id"].(uint64), args["msg"].(*string)), true case "Mutation.disconnectSocialAccount": - if e.complexity.Mutation.DisconnectSocialAccount == nil { + if e.ComplexityRoot.Mutation.DisconnectSocialAccount == nil { break } @@ -1280,9 +1267,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.DisconnectSocialAccount(childComplexity, args["id"].(uint64)), true + return e.ComplexityRoot.Mutation.DisconnectSocialAccount(childComplexity, args["id"].(uint64)), true case "Mutation.generateDirectAccessToken": - if e.complexity.Mutation.GenerateDirectAccessToken == nil { + if e.ComplexityRoot.Mutation.GenerateDirectAccessToken == nil { break } @@ -1291,9 +1278,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.GenerateDirectAccessToken(childComplexity, args["userID"].(*uint64), args["description"].(string), args["expiresAt"].(*time.Time)), true + return e.ComplexityRoot.Mutation.GenerateDirectAccessToken(childComplexity, args["userID"].(*uint64), args["description"].(string), args["expiresAt"].(*time.Time)), true case "Mutation.inviteAccountMember": - if e.complexity.Mutation.InviteAccountMember == nil { + if e.ComplexityRoot.Mutation.InviteAccountMember == nil { break } @@ -1302,9 +1289,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.InviteAccountMember(childComplexity, args["accountID"].(uint64), args["member"].(models.InviteMemberInput)), true + return e.ComplexityRoot.Mutation.InviteAccountMember(childComplexity, args["accountID"].(uint64), args["member"].(models.InviteMemberInput)), true case "Mutation.login": - if e.complexity.Mutation.Login == nil { + if e.ComplexityRoot.Mutation.Login == nil { break } @@ -1313,21 +1300,21 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.Login(childComplexity, args["login"].(string), args["password"].(string)), true + return e.ComplexityRoot.Mutation.Login(childComplexity, args["login"].(string), args["password"].(string)), true case "Mutation.logout": - if e.complexity.Mutation.Logout == nil { + if e.ComplexityRoot.Mutation.Logout == nil { break } - return e.complexity.Mutation.Logout(childComplexity), true + return e.ComplexityRoot.Mutation.Logout(childComplexity), true case "Mutation.poke": - if e.complexity.Mutation.Poke == nil { + if e.ComplexityRoot.Mutation.Poke == nil { break } - return e.complexity.Mutation.Poke(childComplexity), true + return e.ComplexityRoot.Mutation.Poke(childComplexity), true case "Mutation.registerAccount": - if e.complexity.Mutation.RegisterAccount == nil { + if e.ComplexityRoot.Mutation.RegisterAccount == nil { break } @@ -1336,9 +1323,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.RegisterAccount(childComplexity, args["input"].(models.AccountCreateInput)), true + return e.ComplexityRoot.Mutation.RegisterAccount(childComplexity, args["input"].(models.AccountCreateInput)), true case "Mutation.rejectAccount": - if e.complexity.Mutation.RejectAccount == nil { + if e.ComplexityRoot.Mutation.RejectAccount == nil { break } @@ -1347,9 +1334,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.RejectAccount(childComplexity, args["id"].(uint64), args["msg"].(string)), true + return e.ComplexityRoot.Mutation.RejectAccount(childComplexity, args["id"].(uint64), args["msg"].(string)), true case "Mutation.rejectAccountMember": - if e.complexity.Mutation.RejectAccountMember == nil { + if e.ComplexityRoot.Mutation.RejectAccountMember == nil { break } @@ -1358,9 +1345,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.RejectAccountMember(childComplexity, args["memberID"].(uint64), args["msg"].(string)), true + return e.ComplexityRoot.Mutation.RejectAccountMember(childComplexity, args["memberID"].(uint64), args["msg"].(string)), true case "Mutation.rejectUser": - if e.complexity.Mutation.RejectUser == nil { + if e.ComplexityRoot.Mutation.RejectUser == nil { break } @@ -1369,9 +1356,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.RejectUser(childComplexity, args["id"].(uint64), args["msg"].(*string)), true + return e.ComplexityRoot.Mutation.RejectUser(childComplexity, args["id"].(uint64), args["msg"].(*string)), true case "Mutation.removeAccountMember": - if e.complexity.Mutation.RemoveAccountMember == nil { + if e.ComplexityRoot.Mutation.RemoveAccountMember == nil { break } @@ -1380,9 +1367,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.RemoveAccountMember(childComplexity, args["memberID"].(uint64)), true + return e.ComplexityRoot.Mutation.RemoveAccountMember(childComplexity, args["memberID"].(uint64)), true case "Mutation.resetUserPassword": - if e.complexity.Mutation.ResetUserPassword == nil { + if e.ComplexityRoot.Mutation.ResetUserPassword == nil { break } @@ -1391,9 +1378,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.ResetUserPassword(childComplexity, args["email"].(string)), true + return e.ComplexityRoot.Mutation.ResetUserPassword(childComplexity, args["email"].(string)), true case "Mutation.revokeDirectAccessToken": - if e.complexity.Mutation.RevokeDirectAccessToken == nil { + if e.ComplexityRoot.Mutation.RevokeDirectAccessToken == nil { break } @@ -1402,9 +1389,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.RevokeDirectAccessToken(childComplexity, args["filter"].(models.DirectAccessTokenListFilter)), true + return e.ComplexityRoot.Mutation.RevokeDirectAccessToken(childComplexity, args["filter"].(models.DirectAccessTokenListFilter)), true case "Mutation.setOption": - if e.complexity.Mutation.SetOption == nil { + if e.ComplexityRoot.Mutation.SetOption == nil { break } @@ -1413,9 +1400,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.SetOption(childComplexity, args["name"].(string), args["value"].(*types.NullableJSON), args["type"].(models.OptionType), args["targetID"].(uint64)), true + return e.ComplexityRoot.Mutation.SetOption(childComplexity, args["name"].(string), args["value"].(*types.NullableJSON), args["type"].(models.OptionType), args["targetID"].(uint64)), true case "Mutation.switchAccount": - if e.complexity.Mutation.SwitchAccount == nil { + if e.ComplexityRoot.Mutation.SwitchAccount == nil { break } @@ -1424,9 +1411,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.SwitchAccount(childComplexity, args["id"].(uint64)), true + return e.ComplexityRoot.Mutation.SwitchAccount(childComplexity, args["id"].(uint64)), true case "Mutation.updateAccount": - if e.complexity.Mutation.UpdateAccount == nil { + if e.ComplexityRoot.Mutation.UpdateAccount == nil { break } @@ -1435,9 +1422,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.UpdateAccount(childComplexity, args["id"].(uint64), args["input"].(models.AccountInput)), true + return e.ComplexityRoot.Mutation.UpdateAccount(childComplexity, args["id"].(uint64), args["input"].(models.AccountInput)), true case "Mutation.updateAccountMember": - if e.complexity.Mutation.UpdateAccountMember == nil { + if e.ComplexityRoot.Mutation.UpdateAccountMember == nil { break } @@ -1446,9 +1433,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.UpdateAccountMember(childComplexity, args["memberID"].(uint64), args["member"].(models.MemberInput)), true + return e.ComplexityRoot.Mutation.UpdateAccountMember(childComplexity, args["memberID"].(uint64), args["member"].(models.MemberInput)), true case "Mutation.updateAuthClient": - if e.complexity.Mutation.UpdateAuthClient == nil { + if e.ComplexityRoot.Mutation.UpdateAuthClient == nil { break } @@ -1457,9 +1444,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.UpdateAuthClient(childComplexity, args["id"].(string), args["input"].(models.AuthClientInput)), true + return e.ComplexityRoot.Mutation.UpdateAuthClient(childComplexity, args["id"].(string), args["input"].(models.AuthClientUpdateInput)), true case "Mutation.updateRole": - if e.complexity.Mutation.UpdateRole == nil { + if e.ComplexityRoot.Mutation.UpdateRole == nil { break } @@ -1468,9 +1455,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.UpdateRole(childComplexity, args["id"].(uint64), args["input"].(models.RBACRoleInput)), true + return e.ComplexityRoot.Mutation.UpdateRole(childComplexity, args["id"].(uint64), args["input"].(models.RBACRoleInput)), true case "Mutation.updateUser": - if e.complexity.Mutation.UpdateUser == nil { + if e.ComplexityRoot.Mutation.UpdateUser == nil { break } @@ -1479,9 +1466,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.UpdateUser(childComplexity, args["id"].(uint64), args["input"].(models.UserInput)), true + return e.ComplexityRoot.Mutation.UpdateUser(childComplexity, args["id"].(uint64), args["input"].(models.UserInput)), true case "Mutation.updateUserPassword": - if e.complexity.Mutation.UpdateUserPassword == nil { + if e.ComplexityRoot.Mutation.UpdateUserPassword == nil { break } @@ -1490,209 +1477,209 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.UpdateUserPassword(childComplexity, args["token"].(string), args["email"].(string), args["password"].(string)), true + return e.ComplexityRoot.Mutation.UpdateUserPassword(childComplexity, args["token"].(string), args["email"].(string), args["password"].(string)), true case "Option.name": - if e.complexity.Option.Name == nil { + if e.ComplexityRoot.Option.Name == nil { break } - return e.complexity.Option.Name(childComplexity), true + return e.ComplexityRoot.Option.Name(childComplexity), true case "Option.targetID": - if e.complexity.Option.TargetID == nil { + if e.ComplexityRoot.Option.TargetID == nil { break } - return e.complexity.Option.TargetID(childComplexity), true + return e.ComplexityRoot.Option.TargetID(childComplexity), true case "Option.type": - if e.complexity.Option.Type == nil { + if e.ComplexityRoot.Option.Type == nil { break } - return e.complexity.Option.Type(childComplexity), true + return e.ComplexityRoot.Option.Type(childComplexity), true case "Option.value": - if e.complexity.Option.Value == nil { + if e.ComplexityRoot.Option.Value == nil { break } - return e.complexity.Option.Value(childComplexity), true + return e.ComplexityRoot.Option.Value(childComplexity), true case "OptionConnection.edges": - if e.complexity.OptionConnection.Edges == nil { + if e.ComplexityRoot.OptionConnection.Edges == nil { break } - return e.complexity.OptionConnection.Edges(childComplexity), true + return e.ComplexityRoot.OptionConnection.Edges(childComplexity), true case "OptionConnection.list": - if e.complexity.OptionConnection.List == nil { + if e.ComplexityRoot.OptionConnection.List == nil { break } - return e.complexity.OptionConnection.List(childComplexity), true + return e.ComplexityRoot.OptionConnection.List(childComplexity), true case "OptionConnection.pageInfo": - if e.complexity.OptionConnection.PageInfo == nil { + if e.ComplexityRoot.OptionConnection.PageInfo == nil { break } - return e.complexity.OptionConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.OptionConnection.PageInfo(childComplexity), true case "OptionConnection.totalCount": - if e.complexity.OptionConnection.TotalCount == nil { + if e.ComplexityRoot.OptionConnection.TotalCount == nil { break } - return e.complexity.OptionConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.OptionConnection.TotalCount(childComplexity), true case "OptionEdge.cursor": - if e.complexity.OptionEdge.Cursor == nil { + if e.ComplexityRoot.OptionEdge.Cursor == nil { break } - return e.complexity.OptionEdge.Cursor(childComplexity), true + return e.ComplexityRoot.OptionEdge.Cursor(childComplexity), true case "OptionEdge.node": - if e.complexity.OptionEdge.Node == nil { + if e.ComplexityRoot.OptionEdge.Node == nil { break } - return e.complexity.OptionEdge.Node(childComplexity), true + return e.ComplexityRoot.OptionEdge.Node(childComplexity), true case "OptionPayload.clientMutationId": - if e.complexity.OptionPayload.ClientMutationID == nil { + if e.ComplexityRoot.OptionPayload.ClientMutationID == nil { break } - return e.complexity.OptionPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.OptionPayload.ClientMutationID(childComplexity), true case "OptionPayload.name": - if e.complexity.OptionPayload.Name == nil { + if e.ComplexityRoot.OptionPayload.Name == nil { break } - return e.complexity.OptionPayload.Name(childComplexity), true + return e.ComplexityRoot.OptionPayload.Name(childComplexity), true case "OptionPayload.option": - if e.complexity.OptionPayload.Option == nil { + if e.ComplexityRoot.OptionPayload.Option == nil { break } - return e.complexity.OptionPayload.Option(childComplexity), true + return e.ComplexityRoot.OptionPayload.Option(childComplexity), true case "PageInfo.count": - if e.complexity.PageInfo.Count == nil { + if e.ComplexityRoot.PageInfo.Count == nil { break } - return e.complexity.PageInfo.Count(childComplexity), true + return e.ComplexityRoot.PageInfo.Count(childComplexity), true case "PageInfo.endCursor": - if e.complexity.PageInfo.EndCursor == nil { + if e.ComplexityRoot.PageInfo.EndCursor == nil { break } - return e.complexity.PageInfo.EndCursor(childComplexity), true + return e.ComplexityRoot.PageInfo.EndCursor(childComplexity), true case "PageInfo.hasNextPage": - if e.complexity.PageInfo.HasNextPage == nil { + if e.ComplexityRoot.PageInfo.HasNextPage == nil { break } - return e.complexity.PageInfo.HasNextPage(childComplexity), true + return e.ComplexityRoot.PageInfo.HasNextPage(childComplexity), true case "PageInfo.hasPreviousPage": - if e.complexity.PageInfo.HasPreviousPage == nil { + if e.ComplexityRoot.PageInfo.HasPreviousPage == nil { break } - return e.complexity.PageInfo.HasPreviousPage(childComplexity), true + return e.ComplexityRoot.PageInfo.HasPreviousPage(childComplexity), true case "PageInfo.page": - if e.complexity.PageInfo.Page == nil { + if e.ComplexityRoot.PageInfo.Page == nil { break } - return e.complexity.PageInfo.Page(childComplexity), true + return e.ComplexityRoot.PageInfo.Page(childComplexity), true case "PageInfo.startCursor": - if e.complexity.PageInfo.StartCursor == nil { + if e.ComplexityRoot.PageInfo.StartCursor == nil { break } - return e.complexity.PageInfo.StartCursor(childComplexity), true + return e.ComplexityRoot.PageInfo.StartCursor(childComplexity), true case "PageInfo.total": - if e.complexity.PageInfo.Total == nil { + if e.ComplexityRoot.PageInfo.Total == nil { break } - return e.complexity.PageInfo.Total(childComplexity), true + return e.ComplexityRoot.PageInfo.Total(childComplexity), true case "Profile.about": - if e.complexity.Profile.About == nil { + if e.ComplexityRoot.Profile.About == nil { break } - return e.complexity.Profile.About(childComplexity), true + return e.ComplexityRoot.Profile.About(childComplexity), true case "Profile.companyName": - if e.complexity.Profile.CompanyName == nil { + if e.ComplexityRoot.Profile.CompanyName == nil { break } - return e.complexity.Profile.CompanyName(childComplexity), true + return e.ComplexityRoot.Profile.CompanyName(childComplexity), true case "Profile.createdAt": - if e.complexity.Profile.CreatedAt == nil { + if e.ComplexityRoot.Profile.CreatedAt == nil { break } - return e.complexity.Profile.CreatedAt(childComplexity), true + return e.ComplexityRoot.Profile.CreatedAt(childComplexity), true case "Profile.email": - if e.complexity.Profile.Email == nil { + if e.ComplexityRoot.Profile.Email == nil { break } - return e.complexity.Profile.Email(childComplexity), true + return e.ComplexityRoot.Profile.Email(childComplexity), true case "Profile.firstName": - if e.complexity.Profile.FirstName == nil { + if e.ComplexityRoot.Profile.FirstName == nil { break } - return e.complexity.Profile.FirstName(childComplexity), true + return e.ComplexityRoot.Profile.FirstName(childComplexity), true case "Profile.ID": - if e.complexity.Profile.ID == nil { + if e.ComplexityRoot.Profile.ID == nil { break } - return e.complexity.Profile.ID(childComplexity), true + return e.ComplexityRoot.Profile.ID(childComplexity), true case "Profile.lastName": - if e.complexity.Profile.LastName == nil { + if e.ComplexityRoot.Profile.LastName == nil { break } - return e.complexity.Profile.LastName(childComplexity), true + return e.ComplexityRoot.Profile.LastName(childComplexity), true case "Profile.messgangers": - if e.complexity.Profile.Messgangers == nil { + if e.ComplexityRoot.Profile.Messgangers == nil { break } - return e.complexity.Profile.Messgangers(childComplexity), true + return e.ComplexityRoot.Profile.Messgangers(childComplexity), true case "Profile.updatedAt": - if e.complexity.Profile.UpdatedAt == nil { + if e.ComplexityRoot.Profile.UpdatedAt == nil { break } - return e.complexity.Profile.UpdatedAt(childComplexity), true + return e.ComplexityRoot.Profile.UpdatedAt(childComplexity), true case "Profile.user": - if e.complexity.Profile.User == nil { + if e.ComplexityRoot.Profile.User == nil { break } - return e.complexity.Profile.User(childComplexity), true + return e.ComplexityRoot.Profile.User(childComplexity), true case "ProfileMessanger.address": - if e.complexity.ProfileMessanger.Address == nil { + if e.ComplexityRoot.ProfileMessanger.Address == nil { break } - return e.complexity.ProfileMessanger.Address(childComplexity), true + return e.ComplexityRoot.ProfileMessanger.Address(childComplexity), true case "ProfileMessanger.mtype": - if e.complexity.ProfileMessanger.Mtype == nil { + if e.ComplexityRoot.ProfileMessanger.Mtype == nil { break } - return e.complexity.ProfileMessanger.Mtype(childComplexity), true + return e.ComplexityRoot.ProfileMessanger.Mtype(childComplexity), true case "Query.account": - if e.complexity.Query.Account == nil { + if e.ComplexityRoot.Query.Account == nil { break } @@ -1701,9 +1688,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.Account(childComplexity, args["id"].(uint64)), true + return e.ComplexityRoot.Query.Account(childComplexity, args["id"].(uint64)), true case "Query.authClient": - if e.complexity.Query.AuthClient == nil { + if e.ComplexityRoot.Query.AuthClient == nil { break } @@ -1712,9 +1699,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.AuthClient(childComplexity, args["id"].(string)), true + return e.ComplexityRoot.Query.AuthClient(childComplexity, args["id"].(string)), true case "Query.checkPermission": - if e.complexity.Query.CheckPermission == nil { + if e.ComplexityRoot.Query.CheckPermission == nil { break } @@ -1723,21 +1710,21 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.CheckPermission(childComplexity, args["name"].(string), args["key"].(*string), args["targetID"].(*string), args["idKey"].(*string)), true + return e.ComplexityRoot.Query.CheckPermission(childComplexity, args["name"].(string), args["key"].(*string), args["targetID"].(*string), args["idKey"].(*string)), true case "Query.currentAccount": - if e.complexity.Query.CurrentAccount == nil { + if e.ComplexityRoot.Query.CurrentAccount == nil { break } - return e.complexity.Query.CurrentAccount(childComplexity), true + return e.ComplexityRoot.Query.CurrentAccount(childComplexity), true case "Query.currentSession": - if e.complexity.Query.CurrentSession == nil { + if e.ComplexityRoot.Query.CurrentSession == nil { break } - return e.complexity.Query.CurrentSession(childComplexity), true + return e.ComplexityRoot.Query.CurrentSession(childComplexity), true case "Query.currentSocialAccounts": - if e.complexity.Query.CurrentSocialAccounts == nil { + if e.ComplexityRoot.Query.CurrentSocialAccounts == nil { break } @@ -1746,15 +1733,15 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.CurrentSocialAccounts(childComplexity, args["filter"].(*models.SocialAccountListFilter), args["order"].(*models.SocialAccountListOrder)), true + return e.ComplexityRoot.Query.CurrentSocialAccounts(childComplexity, args["filter"].(*models.SocialAccountListFilter), args["order"].(*models.SocialAccountListOrder)), true case "Query.currentUser": - if e.complexity.Query.CurrentUser == nil { + if e.ComplexityRoot.Query.CurrentUser == nil { break } - return e.complexity.Query.CurrentUser(childComplexity), true + return e.ComplexityRoot.Query.CurrentUser(childComplexity), true case "Query.getDirectAccessToken": - if e.complexity.Query.GetDirectAccessToken == nil { + if e.ComplexityRoot.Query.GetDirectAccessToken == nil { break } @@ -1763,9 +1750,10 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.GetDirectAccessToken(childComplexity, args["id"].(uint64)), true + return e.ComplexityRoot.Query.GetDirectAccessToken(childComplexity, args["id"].(uint64)), true + case "Query.listAccountRolesAndPermissions": - if e.complexity.Query.ListAccountRolesAndPermissions == nil { + if e.ComplexityRoot.Query.ListAccountRolesAndPermissions == nil { break } @@ -1774,9 +1762,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListAccountRolesAndPermissions(childComplexity, args["accountID"].(uint64), args["order"].(*models.RBACRoleListOrder)), true + return e.ComplexityRoot.Query.ListAccountRolesAndPermissions(childComplexity, args["accountID"].(uint64), args["order"].(*models.RBACRoleListOrder)), true case "Query.listAccounts": - if e.complexity.Query.ListAccounts == nil { + if e.ComplexityRoot.Query.ListAccounts == nil { break } @@ -1785,9 +1773,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListAccounts(childComplexity, args["filter"].(*models.AccountListFilter), args["order"].(*models.AccountListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListAccounts(childComplexity, args["filter"].(*models.AccountListFilter), args["order"].(*models.AccountListOrder), args["page"].(*models.Page)), true case "Query.listAuthClients": - if e.complexity.Query.ListAuthClients == nil { + if e.ComplexityRoot.Query.ListAuthClients == nil { break } @@ -1796,9 +1784,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListAuthClients(childComplexity, args["filter"].(*models.AuthClientListFilter), args["order"].(*models.AuthClientListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListAuthClients(childComplexity, args["filter"].(*models.AuthClientListFilter), args["order"].([]*models.AuthClientListOrder), args["page"].(*models.Page)), true case "Query.listDirectAccessTokens": - if e.complexity.Query.ListDirectAccessTokens == nil { + if e.ComplexityRoot.Query.ListDirectAccessTokens == nil { break } @@ -1807,9 +1795,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListDirectAccessTokens(childComplexity, args["filter"].(*models.DirectAccessTokenListFilter), args["order"].(*models.DirectAccessTokenListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListDirectAccessTokens(childComplexity, args["filter"].(*models.DirectAccessTokenListFilter), args["order"].(*models.DirectAccessTokenListOrder), args["page"].(*models.Page)), true case "Query.listHistory": - if e.complexity.Query.ListHistory == nil { + if e.ComplexityRoot.Query.ListHistory == nil { break } @@ -1818,9 +1806,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListHistory(childComplexity, args["filter"].(*models.HistoryActionListFilter), args["order"].(*models.HistoryActionListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListHistory(childComplexity, args["filter"].(*models.HistoryActionListFilter), args["order"].(*models.HistoryActionListOrder), args["page"].(*models.Page)), true case "Query.listMembers": - if e.complexity.Query.ListMembers == nil { + if e.ComplexityRoot.Query.ListMembers == nil { break } @@ -1829,9 +1817,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListMembers(childComplexity, args["filter"].(*models.MemberListFilter), args["order"].(*models.MemberListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListMembers(childComplexity, args["filter"].(*models.MemberListFilter), args["order"].(*models.MemberListOrder), args["page"].(*models.Page)), true case "Query.listMyPermissions": - if e.complexity.Query.ListMyPermissions == nil { + if e.ComplexityRoot.Query.ListMyPermissions == nil { break } @@ -1840,9 +1828,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListMyPermissions(childComplexity, args["patterns"].([]string)), true + return e.ComplexityRoot.Query.ListMyPermissions(childComplexity, args["patterns"].([]string)), true case "Query.listOptions": - if e.complexity.Query.ListOptions == nil { + if e.ComplexityRoot.Query.ListOptions == nil { break } @@ -1851,9 +1839,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListOptions(childComplexity, args["filter"].(*models.OptionListFilter), args["order"].(*models.OptionListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListOptions(childComplexity, args["filter"].(*models.OptionListFilter), args["order"].(*models.OptionListOrder), args["page"].(*models.Page)), true case "Query.listPermissions": - if e.complexity.Query.ListPermissions == nil { + if e.ComplexityRoot.Query.ListPermissions == nil { break } @@ -1862,9 +1850,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListPermissions(childComplexity, args["patterns"].([]string)), true + return e.ComplexityRoot.Query.ListPermissions(childComplexity, args["patterns"].([]string)), true case "Query.listRoles": - if e.complexity.Query.ListRoles == nil { + if e.ComplexityRoot.Query.ListRoles == nil { break } @@ -1873,9 +1861,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListRoles(childComplexity, args["filter"].(*models.RBACRoleListFilter), args["order"].(*models.RBACRoleListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListRoles(childComplexity, args["filter"].(*models.RBACRoleListFilter), args["order"].(*models.RBACRoleListOrder), args["page"].(*models.Page)), true case "Query.listSocialAccounts": - if e.complexity.Query.ListSocialAccounts == nil { + if e.ComplexityRoot.Query.ListSocialAccounts == nil { break } @@ -1884,9 +1872,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListSocialAccounts(childComplexity, args["filter"].(*models.SocialAccountListFilter), args["order"].(*models.SocialAccountListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListSocialAccounts(childComplexity, args["filter"].(*models.SocialAccountListFilter), args["order"].(*models.SocialAccountListOrder), args["page"].(*models.Page)), true case "Query.listUsers": - if e.complexity.Query.ListUsers == nil { + if e.ComplexityRoot.Query.ListUsers == nil { break } @@ -1895,9 +1883,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListUsers(childComplexity, args["filter"].(*models.UserListFilter), args["order"].(*models.UserListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListUsers(childComplexity, args["filter"].(*models.UserListFilter), args["order"].(*models.UserListOrder), args["page"].(*models.Page)), true case "Query.option": - if e.complexity.Query.Option == nil { + if e.ComplexityRoot.Query.Option == nil { break } @@ -1906,9 +1894,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.Option(childComplexity, args["name"].(string), args["type"].(models.OptionType), args["targetID"].(uint64)), true + return e.ComplexityRoot.Query.Option(childComplexity, args["name"].(string), args["type"].(models.OptionType), args["targetID"].(uint64)), true case "Query.role": - if e.complexity.Query.Role == nil { + if e.ComplexityRoot.Query.Role == nil { break } @@ -1917,15 +1905,15 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.Role(childComplexity, args["id"].(uint64)), true + return e.ComplexityRoot.Query.Role(childComplexity, args["id"].(uint64)), true case "Query.serviceVersion": - if e.complexity.Query.ServiceVersion == nil { + if e.ComplexityRoot.Query.ServiceVersion == nil { break } - return e.complexity.Query.ServiceVersion(childComplexity), true + return e.ComplexityRoot.Query.ServiceVersion(childComplexity), true case "Query.socialAccount": - if e.complexity.Query.SocialAccount == nil { + if e.ComplexityRoot.Query.SocialAccount == nil { break } @@ -1934,9 +1922,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.SocialAccount(childComplexity, args["id"].(uint64)), true + return e.ComplexityRoot.Query.SocialAccount(childComplexity, args["id"].(uint64)), true case "Query.user": - if e.complexity.Query.User == nil { + if e.ComplexityRoot.Query.User == nil { break } @@ -1945,509 +1933,509 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.User(childComplexity, args["id"].(uint64), args["username"].(string)), true + return e.ComplexityRoot.Query.User(childComplexity, args["id"].(uint64), args["username"].(string)), true case "RBACPermission.access": - if e.complexity.RBACPermission.Access == nil { + if e.ComplexityRoot.RBACPermission.Access == nil { break } - return e.complexity.RBACPermission.Access(childComplexity), true + return e.ComplexityRoot.RBACPermission.Access(childComplexity), true case "RBACPermission.description": - if e.complexity.RBACPermission.Description == nil { + if e.ComplexityRoot.RBACPermission.Description == nil { break } - return e.complexity.RBACPermission.Description(childComplexity), true + return e.ComplexityRoot.RBACPermission.Description(childComplexity), true case "RBACPermission.fullname": - if e.complexity.RBACPermission.Fullname == nil { + if e.ComplexityRoot.RBACPermission.Fullname == nil { break } - return e.complexity.RBACPermission.Fullname(childComplexity), true + return e.ComplexityRoot.RBACPermission.Fullname(childComplexity), true case "RBACPermission.name": - if e.complexity.RBACPermission.Name == nil { + if e.ComplexityRoot.RBACPermission.Name == nil { break } - return e.complexity.RBACPermission.Name(childComplexity), true + return e.ComplexityRoot.RBACPermission.Name(childComplexity), true case "RBACPermission.object": - if e.complexity.RBACPermission.Object == nil { + if e.ComplexityRoot.RBACPermission.Object == nil { break } - return e.complexity.RBACPermission.Object(childComplexity), true + return e.ComplexityRoot.RBACPermission.Object(childComplexity), true case "RBACRole.childRoles": - if e.complexity.RBACRole.ChildRoles == nil { + if e.ComplexityRoot.RBACRole.ChildRoles == nil { break } - return e.complexity.RBACRole.ChildRoles(childComplexity), true + return e.ComplexityRoot.RBACRole.ChildRoles(childComplexity), true case "RBACRole.context": - if e.complexity.RBACRole.Context == nil { + if e.ComplexityRoot.RBACRole.Context == nil { break } - return e.complexity.RBACRole.Context(childComplexity), true + return e.ComplexityRoot.RBACRole.Context(childComplexity), true case "RBACRole.createdAt": - if e.complexity.RBACRole.CreatedAt == nil { + if e.ComplexityRoot.RBACRole.CreatedAt == nil { break } - return e.complexity.RBACRole.CreatedAt(childComplexity), true + return e.ComplexityRoot.RBACRole.CreatedAt(childComplexity), true case "RBACRole.deletedAt": - if e.complexity.RBACRole.DeletedAt == nil { + if e.ComplexityRoot.RBACRole.DeletedAt == nil { break } - return e.complexity.RBACRole.DeletedAt(childComplexity), true + return e.ComplexityRoot.RBACRole.DeletedAt(childComplexity), true case "RBACRole.description": - if e.complexity.RBACRole.Description == nil { + if e.ComplexityRoot.RBACRole.Description == nil { break } - return e.complexity.RBACRole.Description(childComplexity), true + return e.ComplexityRoot.RBACRole.Description(childComplexity), true case "RBACRole.ID": - if e.complexity.RBACRole.ID == nil { + if e.ComplexityRoot.RBACRole.ID == nil { break } - return e.complexity.RBACRole.ID(childComplexity), true + return e.ComplexityRoot.RBACRole.ID(childComplexity), true case "RBACRole.name": - if e.complexity.RBACRole.Name == nil { + if e.ComplexityRoot.RBACRole.Name == nil { break } - return e.complexity.RBACRole.Name(childComplexity), true + return e.ComplexityRoot.RBACRole.Name(childComplexity), true case "RBACRole.permissionPatterns": - if e.complexity.RBACRole.PermissionPatterns == nil { + if e.ComplexityRoot.RBACRole.PermissionPatterns == nil { break } - return e.complexity.RBACRole.PermissionPatterns(childComplexity), true + return e.ComplexityRoot.RBACRole.PermissionPatterns(childComplexity), true case "RBACRole.permissions": - if e.complexity.RBACRole.Permissions == nil { + if e.ComplexityRoot.RBACRole.Permissions == nil { break } - return e.complexity.RBACRole.Permissions(childComplexity), true + return e.ComplexityRoot.RBACRole.Permissions(childComplexity), true case "RBACRole.title": - if e.complexity.RBACRole.Title == nil { + if e.ComplexityRoot.RBACRole.Title == nil { break } - return e.complexity.RBACRole.Title(childComplexity), true + return e.ComplexityRoot.RBACRole.Title(childComplexity), true case "RBACRole.updatedAt": - if e.complexity.RBACRole.UpdatedAt == nil { + if e.ComplexityRoot.RBACRole.UpdatedAt == nil { break } - return e.complexity.RBACRole.UpdatedAt(childComplexity), true + return e.ComplexityRoot.RBACRole.UpdatedAt(childComplexity), true case "RBACRoleConnection.edges": - if e.complexity.RBACRoleConnection.Edges == nil { + if e.ComplexityRoot.RBACRoleConnection.Edges == nil { break } - return e.complexity.RBACRoleConnection.Edges(childComplexity), true + return e.ComplexityRoot.RBACRoleConnection.Edges(childComplexity), true case "RBACRoleConnection.list": - if e.complexity.RBACRoleConnection.List == nil { + if e.ComplexityRoot.RBACRoleConnection.List == nil { break } - return e.complexity.RBACRoleConnection.List(childComplexity), true + return e.ComplexityRoot.RBACRoleConnection.List(childComplexity), true case "RBACRoleConnection.pageInfo": - if e.complexity.RBACRoleConnection.PageInfo == nil { + if e.ComplexityRoot.RBACRoleConnection.PageInfo == nil { break } - return e.complexity.RBACRoleConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.RBACRoleConnection.PageInfo(childComplexity), true case "RBACRoleConnection.totalCount": - if e.complexity.RBACRoleConnection.TotalCount == nil { + if e.ComplexityRoot.RBACRoleConnection.TotalCount == nil { break } - return e.complexity.RBACRoleConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.RBACRoleConnection.TotalCount(childComplexity), true case "RBACRoleEdge.cursor": - if e.complexity.RBACRoleEdge.Cursor == nil { + if e.ComplexityRoot.RBACRoleEdge.Cursor == nil { break } - return e.complexity.RBACRoleEdge.Cursor(childComplexity), true + return e.ComplexityRoot.RBACRoleEdge.Cursor(childComplexity), true case "RBACRoleEdge.node": - if e.complexity.RBACRoleEdge.Node == nil { + if e.ComplexityRoot.RBACRoleEdge.Node == nil { break } - return e.complexity.RBACRoleEdge.Node(childComplexity), true + return e.ComplexityRoot.RBACRoleEdge.Node(childComplexity), true case "RBACRolePayload.clientMutationID": - if e.complexity.RBACRolePayload.ClientMutationID == nil { + if e.ComplexityRoot.RBACRolePayload.ClientMutationID == nil { break } - return e.complexity.RBACRolePayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.RBACRolePayload.ClientMutationID(childComplexity), true case "RBACRolePayload.role": - if e.complexity.RBACRolePayload.Role == nil { + if e.ComplexityRoot.RBACRolePayload.Role == nil { break } - return e.complexity.RBACRolePayload.Role(childComplexity), true + return e.ComplexityRoot.RBACRolePayload.Role(childComplexity), true case "RBACRolePayload.roleID": - if e.complexity.RBACRolePayload.RoleID == nil { + if e.ComplexityRoot.RBACRolePayload.RoleID == nil { break } - return e.complexity.RBACRolePayload.RoleID(childComplexity), true + return e.ComplexityRoot.RBACRolePayload.RoleID(childComplexity), true case "SessionToken.expiresAt": - if e.complexity.SessionToken.ExpiresAt == nil { + if e.ComplexityRoot.SessionToken.ExpiresAt == nil { break } - return e.complexity.SessionToken.ExpiresAt(childComplexity), true + return e.ComplexityRoot.SessionToken.ExpiresAt(childComplexity), true case "SessionToken.isAdmin": - if e.complexity.SessionToken.IsAdmin == nil { + if e.ComplexityRoot.SessionToken.IsAdmin == nil { break } - return e.complexity.SessionToken.IsAdmin(childComplexity), true + return e.ComplexityRoot.SessionToken.IsAdmin(childComplexity), true case "SessionToken.roles": - if e.complexity.SessionToken.Roles == nil { + if e.ComplexityRoot.SessionToken.Roles == nil { break } - return e.complexity.SessionToken.Roles(childComplexity), true + return e.ComplexityRoot.SessionToken.Roles(childComplexity), true case "SessionToken.token": - if e.complexity.SessionToken.Token == nil { + if e.ComplexityRoot.SessionToken.Token == nil { break } - return e.complexity.SessionToken.Token(childComplexity), true + return e.ComplexityRoot.SessionToken.Token(childComplexity), true case "SocialAccount.avatar": - if e.complexity.SocialAccount.Avatar == nil { + if e.ComplexityRoot.SocialAccount.Avatar == nil { break } - return e.complexity.SocialAccount.Avatar(childComplexity), true + return e.ComplexityRoot.SocialAccount.Avatar(childComplexity), true case "SocialAccount.createdAt": - if e.complexity.SocialAccount.CreatedAt == nil { + if e.ComplexityRoot.SocialAccount.CreatedAt == nil { break } - return e.complexity.SocialAccount.CreatedAt(childComplexity), true + return e.ComplexityRoot.SocialAccount.CreatedAt(childComplexity), true case "SocialAccount.data": - if e.complexity.SocialAccount.Data == nil { + if e.ComplexityRoot.SocialAccount.Data == nil { break } - return e.complexity.SocialAccount.Data(childComplexity), true + return e.ComplexityRoot.SocialAccount.Data(childComplexity), true case "SocialAccount.deletedAt": - if e.complexity.SocialAccount.DeletedAt == nil { + if e.ComplexityRoot.SocialAccount.DeletedAt == nil { break } - return e.complexity.SocialAccount.DeletedAt(childComplexity), true + return e.ComplexityRoot.SocialAccount.DeletedAt(childComplexity), true case "SocialAccount.email": - if e.complexity.SocialAccount.Email == nil { + if e.ComplexityRoot.SocialAccount.Email == nil { break } - return e.complexity.SocialAccount.Email(childComplexity), true + return e.ComplexityRoot.SocialAccount.Email(childComplexity), true case "SocialAccount.firstName": - if e.complexity.SocialAccount.FirstName == nil { + if e.ComplexityRoot.SocialAccount.FirstName == nil { break } - return e.complexity.SocialAccount.FirstName(childComplexity), true + return e.ComplexityRoot.SocialAccount.FirstName(childComplexity), true case "SocialAccount.ID": - if e.complexity.SocialAccount.ID == nil { + if e.ComplexityRoot.SocialAccount.ID == nil { break } - return e.complexity.SocialAccount.ID(childComplexity), true + return e.ComplexityRoot.SocialAccount.ID(childComplexity), true case "SocialAccount.lastName": - if e.complexity.SocialAccount.LastName == nil { + if e.ComplexityRoot.SocialAccount.LastName == nil { break } - return e.complexity.SocialAccount.LastName(childComplexity), true + return e.ComplexityRoot.SocialAccount.LastName(childComplexity), true case "SocialAccount.link": - if e.complexity.SocialAccount.Link == nil { + if e.ComplexityRoot.SocialAccount.Link == nil { break } - return e.complexity.SocialAccount.Link(childComplexity), true + return e.ComplexityRoot.SocialAccount.Link(childComplexity), true case "SocialAccount.provider": - if e.complexity.SocialAccount.Provider == nil { + if e.ComplexityRoot.SocialAccount.Provider == nil { break } - return e.complexity.SocialAccount.Provider(childComplexity), true + return e.ComplexityRoot.SocialAccount.Provider(childComplexity), true case "SocialAccount.sessions": - if e.complexity.SocialAccount.Sessions == nil { + if e.ComplexityRoot.SocialAccount.Sessions == nil { break } - return e.complexity.SocialAccount.Sessions(childComplexity), true + return e.ComplexityRoot.SocialAccount.Sessions(childComplexity), true case "SocialAccount.socialID": - if e.complexity.SocialAccount.SocialID == nil { + if e.ComplexityRoot.SocialAccount.SocialID == nil { break } - return e.complexity.SocialAccount.SocialID(childComplexity), true + return e.ComplexityRoot.SocialAccount.SocialID(childComplexity), true case "SocialAccount.updatedAt": - if e.complexity.SocialAccount.UpdatedAt == nil { + if e.ComplexityRoot.SocialAccount.UpdatedAt == nil { break } - return e.complexity.SocialAccount.UpdatedAt(childComplexity), true + return e.ComplexityRoot.SocialAccount.UpdatedAt(childComplexity), true case "SocialAccount.userID": - if e.complexity.SocialAccount.UserID == nil { + if e.ComplexityRoot.SocialAccount.UserID == nil { break } - return e.complexity.SocialAccount.UserID(childComplexity), true + return e.ComplexityRoot.SocialAccount.UserID(childComplexity), true case "SocialAccount.username": - if e.complexity.SocialAccount.Username == nil { + if e.ComplexityRoot.SocialAccount.Username == nil { break } - return e.complexity.SocialAccount.Username(childComplexity), true + return e.ComplexityRoot.SocialAccount.Username(childComplexity), true case "SocialAccountConnection.edges": - if e.complexity.SocialAccountConnection.Edges == nil { + if e.ComplexityRoot.SocialAccountConnection.Edges == nil { break } - return e.complexity.SocialAccountConnection.Edges(childComplexity), true + return e.ComplexityRoot.SocialAccountConnection.Edges(childComplexity), true case "SocialAccountConnection.list": - if e.complexity.SocialAccountConnection.List == nil { + if e.ComplexityRoot.SocialAccountConnection.List == nil { break } - return e.complexity.SocialAccountConnection.List(childComplexity), true + return e.ComplexityRoot.SocialAccountConnection.List(childComplexity), true case "SocialAccountConnection.pageInfo": - if e.complexity.SocialAccountConnection.PageInfo == nil { + if e.ComplexityRoot.SocialAccountConnection.PageInfo == nil { break } - return e.complexity.SocialAccountConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.SocialAccountConnection.PageInfo(childComplexity), true case "SocialAccountConnection.totalCount": - if e.complexity.SocialAccountConnection.TotalCount == nil { + if e.ComplexityRoot.SocialAccountConnection.TotalCount == nil { break } - return e.complexity.SocialAccountConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.SocialAccountConnection.TotalCount(childComplexity), true case "SocialAccountEdge.cursor": - if e.complexity.SocialAccountEdge.Cursor == nil { + if e.ComplexityRoot.SocialAccountEdge.Cursor == nil { break } - return e.complexity.SocialAccountEdge.Cursor(childComplexity), true + return e.ComplexityRoot.SocialAccountEdge.Cursor(childComplexity), true case "SocialAccountEdge.node": - if e.complexity.SocialAccountEdge.Node == nil { + if e.ComplexityRoot.SocialAccountEdge.Node == nil { break } - return e.complexity.SocialAccountEdge.Node(childComplexity), true + return e.ComplexityRoot.SocialAccountEdge.Node(childComplexity), true case "SocialAccountPayload.clientMutationID": - if e.complexity.SocialAccountPayload.ClientMutationID == nil { + if e.ComplexityRoot.SocialAccountPayload.ClientMutationID == nil { break } - return e.complexity.SocialAccountPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.SocialAccountPayload.ClientMutationID(childComplexity), true case "SocialAccountPayload.socialAccount": - if e.complexity.SocialAccountPayload.SocialAccount == nil { + if e.ComplexityRoot.SocialAccountPayload.SocialAccount == nil { break } - return e.complexity.SocialAccountPayload.SocialAccount(childComplexity), true + return e.ComplexityRoot.SocialAccountPayload.SocialAccount(childComplexity), true case "SocialAccountPayload.socialAccountID": - if e.complexity.SocialAccountPayload.SocialAccountID == nil { + if e.ComplexityRoot.SocialAccountPayload.SocialAccountID == nil { break } - return e.complexity.SocialAccountPayload.SocialAccountID(childComplexity), true + return e.ComplexityRoot.SocialAccountPayload.SocialAccountID(childComplexity), true case "SocialAccountSession.accessToken": - if e.complexity.SocialAccountSession.AccessToken == nil { + if e.ComplexityRoot.SocialAccountSession.AccessToken == nil { break } - return e.complexity.SocialAccountSession.AccessToken(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.AccessToken(childComplexity), true case "SocialAccountSession.createdAt": - if e.complexity.SocialAccountSession.CreatedAt == nil { + if e.ComplexityRoot.SocialAccountSession.CreatedAt == nil { break } - return e.complexity.SocialAccountSession.CreatedAt(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.CreatedAt(childComplexity), true case "SocialAccountSession.deletedAt": - if e.complexity.SocialAccountSession.DeletedAt == nil { + if e.ComplexityRoot.SocialAccountSession.DeletedAt == nil { break } - return e.complexity.SocialAccountSession.DeletedAt(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.DeletedAt(childComplexity), true case "SocialAccountSession.expiresAt": - if e.complexity.SocialAccountSession.ExpiresAt == nil { + if e.ComplexityRoot.SocialAccountSession.ExpiresAt == nil { break } - return e.complexity.SocialAccountSession.ExpiresAt(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.ExpiresAt(childComplexity), true case "SocialAccountSession.name": - if e.complexity.SocialAccountSession.Name == nil { + if e.ComplexityRoot.SocialAccountSession.Name == nil { break } - return e.complexity.SocialAccountSession.Name(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.Name(childComplexity), true case "SocialAccountSession.refreshToken": - if e.complexity.SocialAccountSession.RefreshToken == nil { + if e.ComplexityRoot.SocialAccountSession.RefreshToken == nil { break } - return e.complexity.SocialAccountSession.RefreshToken(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.RefreshToken(childComplexity), true case "SocialAccountSession.scope": - if e.complexity.SocialAccountSession.Scope == nil { + if e.ComplexityRoot.SocialAccountSession.Scope == nil { break } - return e.complexity.SocialAccountSession.Scope(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.Scope(childComplexity), true case "SocialAccountSession.socialAccountID": - if e.complexity.SocialAccountSession.SocialAccountID == nil { + if e.ComplexityRoot.SocialAccountSession.SocialAccountID == nil { break } - return e.complexity.SocialAccountSession.SocialAccountID(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.SocialAccountID(childComplexity), true case "SocialAccountSession.tokenType": - if e.complexity.SocialAccountSession.TokenType == nil { + if e.ComplexityRoot.SocialAccountSession.TokenType == nil { break } - return e.complexity.SocialAccountSession.TokenType(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.TokenType(childComplexity), true case "SocialAccountSession.updatedAt": - if e.complexity.SocialAccountSession.UpdatedAt == nil { + if e.ComplexityRoot.SocialAccountSession.UpdatedAt == nil { break } - return e.complexity.SocialAccountSession.UpdatedAt(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.UpdatedAt(childComplexity), true case "StatusResponse.clientMutationID": - if e.complexity.StatusResponse.ClientMutationID == nil { + if e.ComplexityRoot.StatusResponse.ClientMutationID == nil { break } - return e.complexity.StatusResponse.ClientMutationID(childComplexity), true + return e.ComplexityRoot.StatusResponse.ClientMutationID(childComplexity), true case "StatusResponse.message": - if e.complexity.StatusResponse.Message == nil { + if e.ComplexityRoot.StatusResponse.Message == nil { break } - return e.complexity.StatusResponse.Message(childComplexity), true + return e.ComplexityRoot.StatusResponse.Message(childComplexity), true case "StatusResponse.status": - if e.complexity.StatusResponse.Status == nil { + if e.ComplexityRoot.StatusResponse.Status == nil { break } - return e.complexity.StatusResponse.Status(childComplexity), true + return e.ComplexityRoot.StatusResponse.Status(childComplexity), true case "User.createdAt": - if e.complexity.User.CreatedAt == nil { + if e.ComplexityRoot.User.CreatedAt == nil { break } - return e.complexity.User.CreatedAt(childComplexity), true + return e.ComplexityRoot.User.CreatedAt(childComplexity), true case "User.ID": - if e.complexity.User.ID == nil { + if e.ComplexityRoot.User.ID == nil { break } - return e.complexity.User.ID(childComplexity), true + return e.ComplexityRoot.User.ID(childComplexity), true case "User.status": - if e.complexity.User.Status == nil { + if e.ComplexityRoot.User.Status == nil { break } - return e.complexity.User.Status(childComplexity), true + return e.ComplexityRoot.User.Status(childComplexity), true case "User.statusMessage": - if e.complexity.User.StatusMessage == nil { + if e.ComplexityRoot.User.StatusMessage == nil { break } - return e.complexity.User.StatusMessage(childComplexity), true + return e.ComplexityRoot.User.StatusMessage(childComplexity), true case "User.updatedAt": - if e.complexity.User.UpdatedAt == nil { + if e.ComplexityRoot.User.UpdatedAt == nil { break } - return e.complexity.User.UpdatedAt(childComplexity), true + return e.ComplexityRoot.User.UpdatedAt(childComplexity), true case "User.username": - if e.complexity.User.Username == nil { + if e.ComplexityRoot.User.Username == nil { break } - return e.complexity.User.Username(childComplexity), true + return e.ComplexityRoot.User.Username(childComplexity), true case "UserConnection.edges": - if e.complexity.UserConnection.Edges == nil { + if e.ComplexityRoot.UserConnection.Edges == nil { break } - return e.complexity.UserConnection.Edges(childComplexity), true + return e.ComplexityRoot.UserConnection.Edges(childComplexity), true case "UserConnection.list": - if e.complexity.UserConnection.List == nil { + if e.ComplexityRoot.UserConnection.List == nil { break } - return e.complexity.UserConnection.List(childComplexity), true + return e.ComplexityRoot.UserConnection.List(childComplexity), true case "UserConnection.pageInfo": - if e.complexity.UserConnection.PageInfo == nil { + if e.ComplexityRoot.UserConnection.PageInfo == nil { break } - return e.complexity.UserConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.UserConnection.PageInfo(childComplexity), true case "UserConnection.totalCount": - if e.complexity.UserConnection.TotalCount == nil { + if e.ComplexityRoot.UserConnection.TotalCount == nil { break } - return e.complexity.UserConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.UserConnection.TotalCount(childComplexity), true case "UserEdge.cursor": - if e.complexity.UserEdge.Cursor == nil { + if e.ComplexityRoot.UserEdge.Cursor == nil { break } - return e.complexity.UserEdge.Cursor(childComplexity), true + return e.ComplexityRoot.UserEdge.Cursor(childComplexity), true case "UserEdge.node": - if e.complexity.UserEdge.Node == nil { + if e.ComplexityRoot.UserEdge.Node == nil { break } - return e.complexity.UserEdge.Node(childComplexity), true + return e.ComplexityRoot.UserEdge.Node(childComplexity), true case "UserPayload.clientMutationID": - if e.complexity.UserPayload.ClientMutationID == nil { + if e.ComplexityRoot.UserPayload.ClientMutationID == nil { break } - return e.complexity.UserPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.UserPayload.ClientMutationID(childComplexity), true case "UserPayload.user": - if e.complexity.UserPayload.User == nil { + if e.ComplexityRoot.UserPayload.User == nil { break } - return e.complexity.UserPayload.User(childComplexity), true + return e.ComplexityRoot.UserPayload.User(childComplexity), true case "UserPayload.userID": - if e.complexity.UserPayload.UserID == nil { + if e.ComplexityRoot.UserPayload.UserID == nil { break } - return e.complexity.UserPayload.UserID(childComplexity), true + return e.ComplexityRoot.UserPayload.UserID(childComplexity), true } return 0, false @@ -2455,15 +2443,16 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { opCtx := graphql.GetOperationContext(ctx) - ec := executionContext{opCtx, e, 0, 0, make(chan graphql.DeferredResult)} + ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult)) inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputAccountCreateInput, ec.unmarshalInputAccountInput, ec.unmarshalInputAccountListFilter, ec.unmarshalInputAccountListOrder, - ec.unmarshalInputAuthClientInput, + ec.unmarshalInputAuthClientCreateInput, ec.unmarshalInputAuthClientListFilter, ec.unmarshalInputAuthClientListOrder, + ec.unmarshalInputAuthClientUpdateInput, ec.unmarshalInputDirectAccessTokenListFilter, ec.unmarshalInputDirectAccessTokenListOrder, ec.unmarshalInputHistoryActionListFilter, @@ -2496,9 +2485,9 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) data = ec._Query(ctx, opCtx.Operation.SelectionSet) } else { - if atomic.LoadInt32(&ec.pendingDeferred) > 0 { - result := <-ec.deferredResults - atomic.AddInt32(&ec.pendingDeferred, -1) + if atomic.LoadInt32(&ec.PendingDeferred) > 0 { + result := <-ec.DeferredResults + atomic.AddInt32(&ec.PendingDeferred, -1) data = result.Result response.Path = result.Path response.Label = result.Label @@ -2510,8 +2499,8 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { var buf bytes.Buffer data.MarshalGQL(&buf) response.Data = buf.Bytes() - if atomic.LoadInt32(&ec.deferred) > 0 { - hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + if atomic.LoadInt32(&ec.Deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.PendingDeferred) > 0 response.HasNext = &hasNext } @@ -2539,107 +2528,55 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { } type executionContext struct { - *graphql.OperationContext - *executableSchema - deferred int32 - pendingDeferred int32 - deferredResults chan graphql.DeferredResult -} - -func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { - atomic.AddInt32(&ec.pendingDeferred, 1) - go func() { - ctx := graphql.WithFreshResponseContext(dg.Context) - dg.FieldSet.Dispatch(ctx) - ds := graphql.DeferredResult{ - Path: dg.Path, - Label: dg.Label, - Result: dg.FieldSet, - Errors: graphql.GetErrors(ctx), - } - // null fields should bubble up - if dg.FieldSet.Invalids > 0 { - ds.Result = graphql.Null - } - ec.deferredResults <- ds - }() -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapSchema(ec.Schema()), nil + *graphql.ExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot] } -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") +func newExecutionContext( + opCtx *graphql.OperationContext, + execSchema *executableSchema, + deferredResults chan graphql.DeferredResult, +) executionContext { + return executionContext{ + ExecutionContextState: graphql.NewExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot]( + opCtx, + (*graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot])(execSchema), + parsedSchema, + deferredResults, + ), } - return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } var sources = []*ast.Source{ - {Name: "../../../../../../protocol/graphql/schemas/account_base.graphql", Input: `""" -Account is a company account that can be used to login to the system. + {Name: "../../../../../../protocol/graphql/schemas/account_users.graphql", Input: ` """ -type Account { - """ - The primary key of the Account - """ - ID: ID64! - - """ - Status of Account active - """ - status: ApproveStatus! - - """ - Message which defined during user approve/rejection process - """ - statusMessage: String - - title: String! - description: String! - - """ - logoURI is an URL string that references a logo for the client. - """ - logoURI: String! - +User represents a user object of the system +""" +type User { """ - policyURI is a URL string that points to a human-readable privacy policy document - that describes how the deployment organization collects, uses, - retains, and discloses personal data. + The primary key of the user """ - policyURI: String! + ID: ID64! """ - termsOfServiceURI is a URL string that points to a human-readable terms of service - document for the client that describes a contractual relationship - between the end-user and the client that the end-user accepts when - authorizing the client. + Unical user name """ - termsOfServiceURI: String! + username: String! """ - clientURI is an URL string of a web page providing information about the client. - If present, the server SHOULD display this URL to the end-user in - a clickable fashion. + Status of user active """ - clientURI: String! + status: ApproveStatus! """ - contacts is a array of strings representing ways to contact people responsible - for this client, typically email addresses. + Message which defined during user approve/rejection process """ - contacts: [String!] + statusMessage: String createdAt: Time! updatedAt: Time! } -type AccountEdge { +type UserEdge { """ A cursor for use in pagination. """ @@ -2648,27 +2585,27 @@ type AccountEdge { """ The item at the end of the edge. """ - node: Account + node: User } """ -AccountConnection implements collection accessor interface with pagination. +UserConnection implements collection accessor interface with pagination. """ -type AccountConnection { +type UserConnection { """ The total number of campaigns """ totalCount: Int! """ - The edges for each of the account's lists + The edges for each of the users's lists """ - edges: [AccountEdge!] + edges: [UserEdge!] """ - A list of the accounts, as a convenience when edges are not needed. + A list of the users, as a convenience when edges are not needed. """ - list: [Account!] + list: [User!] """ Information for paginating this connection @@ -2677,583 +2614,703 @@ type AccountConnection { } """ -AccountPayload wrapper to access of Account oprtation results +UserPayload wrapper to access of user oprtation results """ -type AccountPayload { +type UserPayload { """ A unique identifier for the client performing the mutation. """ clientMutationID: String! """ - Account ID operation result + User ID operation result """ - accountID: ID64! + userID: ID64! """ - Account object accessor + User object accessor """ - account: Account + user: User } ############################################################################### # Query ############################################################################### -input AccountListFilter { +""" +UserListFilter implements filter for user list query +""" +input UserListFilter { ID: [ID64!] - UserID: [ID64!] - title: [String!] - status: [ApproveStatus!] + accountID: [ID64!] + emails: [String!] + roles: [ID64!] } -input AccountListOrder { - ID: Ordering - title: Ordering - status: Ordering +""" +UserListOrder implements order for user list query +""" +input UserListOrder { + ID: Ordering + email: Ordering + username: Ordering + status: Ordering + registrationDate: Ordering + country: Ordering + manager: Ordering + createdAt: Ordering + updatedAt: Ordering } ############################################################################### # Mutations ############################################################################### -input AccountInput { +input UserInput { + username: String status: ApproveStatus - title: String - description: String - logoURI: String - policyURI: String - termsOfServiceURI: String - clientURI: String - contacts: [String!] } -input AccountCreateInput { - ownerID: ID64 - owner: UserInput - account: AccountInput! - password: String! -} +type Profile { + ID: ID64! + user: User! + firstName: String! + lastName: String! + companyName: String! + about: String! + email: String! + messgangers: [ProfileMessanger!] -type AccountCreatePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationID: String! + createdAt: Time! + updatedAt: Time! +} - """ - The account object - """ - account: Account! +enum MessangerType { + SKYPE + AIM + ICQ + WHATSAPP + TELEGRAM + VIBER + PHONE +} - """ - The user object - """ - owner: User! +type ProfileMessanger { + mtype: MessangerType! + address: String! } ############################################################################### -# Query declarations +# Query ############################################################################### extend type Query { """ - Current session from the token - """ - currentSession: SessionToken! @hasPermissions(permissions: ["account.view.*"]) - - """ - Current account from the session + Current user from the session """ - currentAccount: AccountPayload! @hasPermissions(permissions: ["account.view.*"]) + currentUser: UserPayload! @hasPermissions(permissions: ["user.view.*"]) """ - Get account object by ID + Get user object by ID or username """ - account(id: ID64!): AccountPayload! @hasPermissions(permissions: ["account.view.*"]) + user( + id: ID64! = 0, + username: String! = "" + ): UserPayload! @hasPermissions(permissions: ["user.view.*"]) """ - List of the account objects which can be filtered and ordered by some fields + List of the user objects which can be filtered and ordered by some fields """ - listAccounts( - filter: AccountListFilter = null, - order: AccountListOrder = null, + listUsers( + filter: UserListFilter = null, + order: UserListOrder = null, page: Page = null - ): AccountConnection @hasPermissions(permissions: ["account.list.*"]) - - """ - List of the account roles/permissions - """ - listAccountRolesAndPermissions(accountID: ID64!, order: RBACRoleListOrder = null): RBACRoleConnection @hasPermissions(permissions: ["account.view.*"]) + ): UserConnection @hasPermissions(permissions: ["user.list.*"]) } extend type Mutation { """ - Login to the system and get the token as JWT session - """ - login(login: String!, password: String!): SessionToken! - - """ - Logout from the system + Create the new user """ - logout: Boolean! + createUser(input: UserInput!): UserPayload! @hasPermissions(permissions: ["user.create.*"]) """ - Switch the account by ID + Update user info """ - switchAccount(id: ID64!): SessionToken! + updateUser(id: ID64!, input: UserInput!): UserPayload! @hasPermissions(permissions: ["user.update.*"]) """ - Register the new account + Approve user and leave the comment """ - registerAccount(input: AccountCreateInput!): AccountCreatePayload! @hasPermissions(permissions: ["account.register"]) + approveUser(id: ID64!, msg: String): UserPayload! @hasPermissions(permissions: ["user.approve.*"]) """ - Update account info + Reject user and leave the comment """ - updateAccount(id: ID64!, input: AccountInput!): AccountPayload! @hasPermissions(permissions: ["account.update.*"]) + rejectUser(id: ID64!, msg: String): UserPayload! @hasPermissions(permissions: ["user.reject.*"]) """ - Approve account and leave the comment + Reset password of the particular user in case if user forgot it """ - approveAccount(id: ID64!, msg: String!): AccountPayload! @hasPermissions(permissions: ["account.approve.*"]) + resetUserPassword(email: String!): StatusResponse! @hasPermissions(permissions: ["user.password.reset.*"]) """ - Reject account and leave the comment + Update password of the particular user """ - rejectAccount(id: ID64!, msg: String!): AccountPayload! @hasPermissions(permissions: ["account.reject.*"]) + updateUserPassword(token: String!, email: String!, password: String!): StatusResponse! @hasPermissions(permissions: ["user.password.reset.*"]) } `, BuiltIn: false}, - {Name: "../../../../../../protocol/graphql/schemas/account_member.graphql", Input: `""" -Account Member represents a member of the account + {Name: "../../../../../../protocol/graphql/schemas/constants.graphql", Input: ` """ -type Member { +The list of statuses that shows is object approved or not +""" +enum ApproveStatus { """ - The primary key of the Member + Pending status of the just inited objects """ - ID: ID64! + PENDING """ - Status of Member active + Approved status of object could be obtained from the some authorized user who have permissions """ - status: ApproveStatus! + APPROVED """ - User object accessor + Rejected status of object could be obtained from the some authorized user who have permissions """ - user: User! + REJECTED +} +""" +The list of statuses that shows is particular object active or paused +""" +enum ActiveStatus { """ - Account object accessor + All object by default have to be paused """ - account: Account! + PAUSED """ - Is the user an admin of the account + Status of the active object """ - isAdmin: Boolean! + ACTIVE +} +""" +The list of statuses that shows is particular object is available +""" +enum AvailableStatus { """ - Roles of the member - """ - roles: [RBACRole!] + All object by default have to be undefined + """ + UNDEFINED - createdAt: Time! - updatedAt: Time! - deletedAt: Time + """ + Status of the available object + """ + AVAILABLE + + """ + Status of the unavailable object + """ + UNAVAILABLE } -type MemberEdge { +""" +Constants of the order of data +""" +enum Ordering { """ - A cursor for use in pagination. + Ascending ordering of data """ - cursor: String! + ASC """ - The item at the end of the edge. + Descending ordering of data """ - node: Member + DESC } -type MemberConnection { +""" +Constants of the response status +""" +enum ResponseStatus { """ - The total number of campaigns + Success status of the response """ - totalCount: Int! + SUCCESS """ - The edges for each of the members's lists + Error status of the response """ - edges: [MemberEdge!] + ERROR +} +`, BuiltIn: false}, + {Name: "../../../../../../protocol/graphql/schemas/directives.graphql", Input: `"Prevents access to a field if the user is not authenticated" +directive @auth on FIELD_DEFINITION | FIELD + +"Prevents access to a field/method if the user doesnt have the matching permissions" +directive @hasPermissions(permissions: [String!]!) on FIELD_DEFINITION | FIELD + +"Prevents access to a field/method if the user doesnt have the matching permissions" +directive @acl(permissions: [String!]!) on FIELD_DEFINITION | FIELD + +"Prevents access to a field/method if the user doesnt have the matching permissions" +directive @skipNoPermissions(permissions: [String!]) on FIELD_DEFINITION | FIELD + +"Caches the result of a field/method for a specified time to live (ttl) in seconds" +directive @cacheData( + ttl: Int! + key: String + fields: [String!] +) on FIELD_DEFINITION | FIELD + +# Validation directives + +## @length validates the length of a string or array. +directive @length( + min: Int! + max: Int! = 0 + trim: Boolean! = false + ornil: Boolean! = false +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR + +## @notempty validates that a string or array is not empty. +directive @notempty( + trim: Boolean! = false + ornil: Boolean! = false +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR + +## @regex validates a string against a regular expression. +directive @regex( + pattern: String! + trim: Boolean! = true + ornil: Boolean! = false +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR + +## @range validates that a number is within a specified range. +directive @range( + min: Float! + max: Float! = 0 + ornil: Boolean! = false +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR +`, BuiltIn: false}, + {Name: "../../../../../../protocol/graphql/schemas/pagination.graphql", Input: ` +# @link https://developer.github.com/v4/object/pageinfo/ +""" +Information for paginating +""" +type PageInfo { """ - A list of the members, as a convenience when edges are not needed. + When paginating backwards, the cursor to continue. """ - list: [Member!] + startCursor: String! """ - Information for paginating this connection + When paginating forwards, the cursor to continue. """ - pageInfo: PageInfo! + endCursor: String! + + """ + When paginating backwards, are there more items? + """ + hasPreviousPage: Boolean! + + """ + When paginating forwards, are there more items? + """ + hasNextPage: Boolean! + + """ + Total number of pages available + """ + total: Int! + + """ + Current page number + """ + page: Int! + + """ + Number of pages + """ + count: Int! } -type MemberPayload { +""" +Information for paginating +""" +input Page { """ - A unique identifier for the client performing the mutation. + Start after the cursor ID """ - clientMutationID: String! + after: String """ - Member ID operation result + Start after some records """ - memberID: ID64! + offset: Int """ - Member object accessor + Page number to start at (0-based), defaults to 0 (0, 1, 2, etc.) """ - member: Member + startPage: Int + + """ + Maximum number of items to return + """ + size: Int } +`, BuiltIn: false}, + {Name: "../../../../../../protocol/graphql/schemas/schema.graphql", Input: `# https://github.com/prisma/graphql-import +# Pagination https://graphql.org/learn/pagination/#pagination-and-edges -############################################################################### -# Query -############################################################################### +scalar Time +scalar TimeDuration +scalar DateTime +scalar Map +scalar JSON +scalar NullableJSON +scalar UUID +scalar ID64 -input MemberListFilter { - ID: [ID64!] - status: [ApproveStatus!] - userID: [ID64!] - accountID: [ID64!] - isAdmin: Boolean +schema { + query: Query + mutation: Mutation } -input MemberListOrder { - ID: Ordering - status: Ordering - userID: Ordering - accountID: Ordering - isAdmin: Ordering - createdAt: Ordering - updatedAt: Ordering +type Query { + serviceVersion: String! } -input InviteMemberInput { +type Mutation { + poke: String! +} +`, BuiltIn: false}, + {Name: "../../../../../../protocol/graphql/schemas/status.graphql", Input: `""" +Simple response type for the API +""" +type StatusResponse { """ - The email of the member to invite + Unique identifier for the client performing the mutation """ - email: String! + clientMutationID: String! """ - The roles to assign to the member + The status of the response """ - roles: [String!]! + status: ResponseStatus! """ - Is the user an admin of the account + The message of the response """ - isAdmin: Boolean! = false + message: String } +`, BuiltIn: false}, + {Name: "../../../../../../repository/account/delivery/graphql/account_base.graphql", Input: `""" +Account is a company account that can be used to login to the system. +""" +type Account { + """ + The primary key of the Account + """ + ID: ID64! -input MemberInput { """ - The roles to assign to the member + Status of Account active """ - roles: [String!]! + status: ApproveStatus! """ - Is the user an admin of the account + Message which defined during user approve/rejection process """ - isAdmin: Boolean! = false -} + statusMessage: String -############################################################################### -# Query declarations -############################################################################### + title: String! + description: String! -extend type Query { - listMembers( - """ - The filter to apply to the list - """ - filter: MemberListFilter = null, + """ + logoURI is an URL string that references a logo for the client. + """ + logoURI: String! - """ - The order to apply to the list - """ - order: MemberListOrder = null, + """ + policyURI is a URL string that points to a human-readable privacy policy document + that describes how the deployment organization collects, uses, + retains, and discloses personal data. + """ + policyURI: String! - """ - The pagination to apply to the list - """ - page: Page = null - ): MemberConnection @acl(permissions: ["account.member.list.*"]) + """ + termsOfServiceURI is a URL string that points to a human-readable terms of service + document for the client that describes a contractual relationship + between the end-user and the client that the end-user accepts when + authorizing the client. + """ + termsOfServiceURI: String! + + """ + clientURI is an URL string of a web page providing information about the client. + If present, the server SHOULD display this URL to the end-user in + a clickable fashion. + """ + clientURI: String! + + """ + contacts is a array of strings representing ways to contact people responsible + for this client, typically email addresses. + """ + contacts: [String!] + + createdAt: Time! + updatedAt: Time! } -extend type Mutation { +type AccountEdge { """ - Invite a new member to the account + A cursor for use in pagination. """ - inviteAccountMember( - """ - The account ID to invite the member to - """ - accountID: ID64!, + cursor: String! - """ - The new member to invite to the account - """ - member: InviteMemberInput! - ): MemberPayload! @acl(permissions: ["account.member.invite.*"]) + """ + The item at the end of the edge. + """ + node: Account +} +""" +AccountConnection implements collection accessor interface with pagination. +""" +type AccountConnection { """ - Update the member data + The total number of campaigns """ - updateAccountMember( - """ - The member ID to update - """ - memberID: ID64!, + totalCount: Int! - """ - The new member data to update - """ - member: MemberInput! - ): MemberPayload! @acl(permissions: ["account.member.update.*"]) + """ + The edges for each of the account's lists + """ + edges: [AccountEdge!] """ - Remove the member from the account + A list of the accounts, as a convenience when edges are not needed. """ - removeAccountMember( - """ - The member ID to remove - """ - memberID: ID64! - ): MemberPayload! @acl(permissions: ["account.member.delete.*"]) + list: [Account!] """ - Approve the member to join the account + Information for paginating this connection """ - approveAccountMember( - """ - The member ID to approve - """ - memberID: ID64! + pageInfo: PageInfo! +} - """ - Reason message for the approval - """ - msg: String! = "" - ): MemberPayload! @acl(permissions: ["account.member.approve.*"]) +""" +AccountPayload wrapper to access of Account oprtation results +""" +type AccountPayload { + """ + A unique identifier for the client performing the mutation. + """ + clientMutationID: String! """ - Reject the member to join the account + Account ID operation result """ - rejectAccountMember( - """ - The member ID to reject - """ - memberID: ID64! + accountID: ID64! - """ - Reason message for the rejection - """ - msg: String! = "" - ): MemberPayload! @acl(permissions: ["account.member.reject.*"]) -} -`, BuiltIn: false}, - {Name: "../../../../../../protocol/graphql/schemas/account_social.graphql", Input: `type SocialAccountSession { """ - The unique name of the session to destinguish between different sessions with different scopes + Account object accessor """ - name: String! - socialAccountID: ID64! + account: Account +} - tokenType: String! - accessToken: String! - refreshToken: String! - scope: [String!] +""" +SessionToken object represents an OAuth 2.0 / JWT session token +""" +type SessionToken { + token: String! + expiresAt: Time! + isAdmin: Boolean! + roles: [String!] +} - createdAt: Time! - updatedAt: Time! - expiresAt: Time - deletedAt: Time +############################################################################### +# Query +############################################################################### + +input AccountListFilter { + ID: [ID64!] + UserID: [ID64!] + title: [String!] + status: [ApproveStatus!] } -type SocialAccount { - ID: ID64! - userID: ID64! +input AccountListOrder { + ID: Ordering + title: Ordering + status: Ordering +} - socialID: String! - provider: String! - email: String! - username: String! +############################################################################### +# Mutations +############################################################################### - firstName: String! - lastName: String! - avatar: String! - link: String! +input AccountInput { + status: ApproveStatus + title: String + description: String + logoURI: String + policyURI: String + termsOfServiceURI: String + clientURI: String + contacts: [String!] +} - data: NullableJSON! +input AccountCreateInput { + ownerID: ID64 + owner: UserInput + account: AccountInput! + password: String! +} +type AccountCreatePayload { """ - Social Account session object accessor + A unique identifier for the client performing the mutation. """ - sessions: [SocialAccountSession!] - - createdAt: Time! - updatedAt: Time! - deletedAt: Time -} + clientMutationID: String! -type SocialAccountEdge { """ - A cursor for use in pagination. + The account object """ - cursor: String! + account: Account! """ - The item at the end of the edge. + The user object """ - node: SocialAccount + owner: User! } -""" -SocialAccountConnection implements collection accessor interface with pagination -""" -type SocialAccountConnection { +############################################################################### +# Query declarations +############################################################################### + +extend type Query { """ - The total number of records + Current session from the token """ - totalCount: Int! + currentSession: SessionToken! @hasPermissions(permissions: ["account.view.*"]) """ - The edges for each of the social account's lists + Current account from the session """ - edges: [SocialAccountEdge!] + currentAccount: AccountPayload! + @hasPermissions(permissions: ["account.view.*"]) """ - A list of the social accounts, as a convenience when edges are not needed. + Get account object by ID """ - list: [SocialAccount!] + account(id: ID64!): AccountPayload! + @hasPermissions(permissions: ["account.view.*"]) """ - Information for paginating this connection + List of the account objects which can be filtered and ordered by some fields """ - pageInfo: PageInfo! -} + listAccounts( + filter: AccountListFilter = null + order: AccountListOrder = null + page: Page = null + ): AccountConnection @hasPermissions(permissions: ["account.list.*"]) -""" -SocialAccountPayload wrapper to access of SocialAccount oprtation results -""" -type SocialAccountPayload { """ - A unique identifier for the client performing the mutation. + List of the account roles/permissions """ - clientMutationID: String! + listAccountRolesAndPermissions( + accountID: ID64! + order: RBACRoleListOrder = null + ): RBACRoleConnection @hasPermissions(permissions: ["account.view.*"]) +} +extend type Mutation { """ - Social Account ID operation result + Login to the system and get the token as JWT session """ - socialAccountID: ID64! + login(login: String!, password: String!): SessionToken! """ - Social Account object accessor + Logout from the system """ - socialAccount: SocialAccount -} - -############################################################################### -# Query -############################################################################### - -input SocialAccountListFilter { - ID: [ID64!] - userID: [ID64!] - provider: [String!] - username: [String!] - email: [String!] -} + logout: Boolean! -input SocialAccountListOrder { - ID: Ordering - userID: Ordering - provider: Ordering - email: Ordering - username: Ordering - firstName: Ordering - lastName: Ordering -} + """ + Switch the account by ID + """ + switchAccount(id: ID64!): SessionToken! -extend type Query { """ - Get a social account by its unique identifier + Register the new account """ - socialAccount( - """ - The unique identifier of the social account - """ - id: ID64! - ): SocialAccountPayload! @hasPermissions(permissions: ["account_social.view.*"]) + registerAccount(input: AccountCreateInput!): AccountCreatePayload! + @hasPermissions(permissions: ["account.register"]) """ - Get the current user's social accounts + Update account info """ - currentSocialAccounts( - filter: SocialAccountListFilter = null, - order: SocialAccountListOrder = null - ): SocialAccountConnection! @hasPermissions(permissions: ["account_social.list.*"]) + updateAccount(id: ID64!, input: AccountInput!): AccountPayload! + @hasPermissions(permissions: ["account.update.*"]) """ - List all social accounts + Approve account and leave the comment """ - listSocialAccounts( - filter: SocialAccountListFilter = null, - order: SocialAccountListOrder = null, - page: Page = null - ): SocialAccountConnection! @hasPermissions(permissions: ["account_social.list.*"]) -} + approveAccount(id: ID64!, msg: String!): AccountPayload! + @hasPermissions(permissions: ["account.approve.*"]) -extend type Mutation { """ - Disconnect a social account + Reject account and leave the comment """ - disconnectSocialAccount( - """ - The unique identifier of the social account to disconnect - """ - id: ID64! - ): SocialAccountPayload! @hasPermissions(permissions: ["account_social.disconnect.*"]) + rejectAccount(id: ID64!, msg: String!): AccountPayload! + @hasPermissions(permissions: ["account.reject.*"]) } `, BuiltIn: false}, - {Name: "../../../../../../protocol/graphql/schemas/account_users.graphql", Input: ` -""" -User represents a user object of the system + {Name: "../../../../../../repository/account/delivery/graphql/account_member.graphql", Input: `""" +Account Member represents a member of the account """ -type User { +type Member { """ - The primary key of the user + The primary key of the Member """ - ID: ID64! + ID: ID64! """ - Unical user name + Status of Member active """ - username: String! + status: ApproveStatus! """ - Status of user active + User object accessor """ - status: ApproveStatus! + user: User! """ - Message which defined during user approve/rejection process + Account object accessor """ - statusMessage: String + account: Account! + + """ + Is the user an admin of the account + """ + isAdmin: Boolean! + + """ + Roles of the member + """ + roles: [RBACRole!] createdAt: Time! updatedAt: Time! + deletedAt: Time } -type UserEdge { +type MemberEdge { """ A cursor for use in pagination. """ @@ -3262,27 +3319,24 @@ type UserEdge { """ The item at the end of the edge. """ - node: User + node: Member } -""" -UserConnection implements collection accessor interface with pagination. -""" -type UserConnection { +type MemberConnection { """ The total number of campaigns """ totalCount: Int! """ - The edges for each of the users's lists + The edges for each of the members's lists """ - edges: [UserEdge!] + edges: [MemberEdge!] """ - A list of the users, as a convenience when edges are not needed. + A list of the members, as a convenience when edges are not needed. """ - list: [User!] + list: [Member!] """ Information for paginating this connection @@ -3290,241 +3344,257 @@ type UserConnection { pageInfo: PageInfo! } -""" -UserPayload wrapper to access of user oprtation results -""" -type UserPayload { +type MemberPayload { """ A unique identifier for the client performing the mutation. """ clientMutationID: String! """ - User ID operation result + Member ID operation result """ - userID: ID64! + memberID: ID64! """ - User object accessor + Member object accessor """ - user: User + member: Member } ############################################################################### # Query ############################################################################### -""" -UserListFilter implements filter for user list query -""" -input UserListFilter { +input MemberListFilter { ID: [ID64!] - accountID: [ID64!] - emails: [String!] - roles: [ID64!] -} - -""" -UserListOrder implements order for user list query -""" -input UserListOrder { - ID: Ordering - email: Ordering - username: Ordering - status: Ordering - registrationDate: Ordering - country: Ordering - manager: Ordering - createdAt: Ordering - updatedAt: Ordering -} - -############################################################################### -# Mutations -############################################################################### - -input UserInput { - username: String - status: ApproveStatus -} - -type Profile { - ID: ID64! - user: User! - firstName: String! - lastName: String! - companyName: String! - about: String! - email: String! - messgangers: [ProfileMessanger!] - - createdAt: Time! - updatedAt: Time! -} - -enum MessangerType { - SKYPE - AIM - ICQ - WHATSAPP - TELEGRAM - VIBER - PHONE + status: [ApproveStatus!] + userID: [ID64!] + accountID: [ID64!] + isAdmin: Boolean } -type ProfileMessanger { - mtype: MessangerType! - address: String! +input MemberListOrder { + ID: Ordering + status: Ordering + userID: Ordering + accountID: Ordering + isAdmin: Ordering + createdAt: Ordering + updatedAt: Ordering } -############################################################################### -# Query -############################################################################### +input InviteMemberInput { + """ + The email of the member to invite + """ + email: String! -extend type Query { """ - Current user from the session + The roles to assign to the member """ - currentUser: UserPayload! @hasPermissions(permissions: ["user.view.*"]) + roles: [String!]! """ - Get user object by ID or username + Is the user an admin of the account """ - user( - id: ID64! = 0, - username: String! = "" - ): UserPayload! @hasPermissions(permissions: ["user.view.*"]) + isAdmin: Boolean! = false +} +input MemberInput { """ - List of the user objects which can be filtered and ordered by some fields + The roles to assign to the member """ - listUsers( - filter: UserListFilter = null, - order: UserListOrder = null, + roles: [String!]! + + """ + Is the user an admin of the account + """ + isAdmin: Boolean! = false +} + +############################################################################### +# Query declarations +############################################################################### + +extend type Query { + listMembers( + """ + The filter to apply to the list + """ + filter: MemberListFilter = null, + + """ + The order to apply to the list + """ + order: MemberListOrder = null, + + """ + The pagination to apply to the list + """ page: Page = null - ): UserConnection @hasPermissions(permissions: ["user.list.*"]) + ): MemberConnection @acl(permissions: ["account.member.list.*"]) } extend type Mutation { """ - Create the new user + Invite a new member to the account """ - createUser(input: UserInput!): UserPayload! @hasPermissions(permissions: ["user.create.*"]) + inviteAccountMember( + """ + The account ID to invite the member to + """ + accountID: ID64!, - """ - Update user info - """ - updateUser(id: ID64!, input: UserInput!): UserPayload! @hasPermissions(permissions: ["user.update.*"]) + """ + The new member to invite to the account + """ + member: InviteMemberInput! + ): MemberPayload! @acl(permissions: ["account.member.invite.*"]) """ - Approve user and leave the comment + Update the member data """ - approveUser(id: ID64!, msg: String): UserPayload! @hasPermissions(permissions: ["user.approve.*"]) + updateAccountMember( + """ + The member ID to update + """ + memberID: ID64!, + + """ + The new member data to update + """ + member: MemberInput! + ): MemberPayload! @acl(permissions: ["account.member.update.*"]) """ - Reject user and leave the comment + Remove the member from the account """ - rejectUser(id: ID64!, msg: String): UserPayload! @hasPermissions(permissions: ["user.reject.*"]) + removeAccountMember( + """ + The member ID to remove + """ + memberID: ID64! + ): MemberPayload! @acl(permissions: ["account.member.delete.*"]) """ - Reset password of the particular user in case if user forgot it + Approve the member to join the account """ - resetUserPassword(email: String!): StatusResponse! @hasPermissions(permissions: ["user.password.reset.*"]) + approveAccountMember( + """ + The member ID to approve + """ + memberID: ID64! + + """ + Reason message for the approval + """ + msg: String! = "" + ): MemberPayload! @acl(permissions: ["account.member.approve.*"]) """ - Update password of the particular user + Reject the member to join the account """ - updateUserPassword(token: String!, email: String!, password: String!): StatusResponse! @hasPermissions(permissions: ["user.password.reset.*"]) + rejectAccountMember( + """ + The member ID to reject + """ + memberID: ID64! + + """ + Reason message for the rejection + """ + msg: String! = "" + ): MemberPayload! @acl(permissions: ["account.member.reject.*"]) } `, BuiltIn: false}, - {Name: "../../../../../../protocol/graphql/schemas/auth_client.graphql", Input: `""" + {Name: "../../../../../../repository/authclient/delivery/graphql/auth_client.graphql", Input: `""" AuthClient object represents an OAuth 2.0 client """ type AuthClient { """ ClientID is the client ID which represents unique connection indentificator """ - ID: ID! + ID: ID! - # Owner and creator of the auth client - accountID: ID64! - userID: ID64! + # Owner and creator of the auth client + accountID: ID64! + userID: ID64! """ - Title of the AuthClient as himan readable name + Title of the AuthClient as himan readable name """ - title: String! + title: String! """ - Secret is the client's secret. The secret will be included in the create request as cleartext, and then - never again. The secret is stored using BCrypt so it is impossible to recover it. Tell your users - that they need to write the secret down as it will not be made available again. + Secret is the client's secret. The secret will be included in the create request as cleartext, and then + never again. The secret is stored using BCrypt so it is impossible to recover it. Tell your users + that they need to write the secret down as it will not be made available again. """ - secret: String! + secret: String! """ - RedirectURIs is an array of allowed redirect urls for the client, for example http://mydomain/oauth/callback . + RedirectURIs is an array of allowed redirect urls for the client, for example http://mydomain/oauth/callback . """ - redirectURIs: [String!] + redirectURIs: [String!] """ - GrantTypes is an array of grant types the client is allowed to use. + GrantTypes is an array of grant types the client is allowed to use. - Pattern: client_credentials|authorization_code|implicit|refresh_token + Pattern: client_credentials|authorization_code|implicit|refresh_token """ - grantTypes: [String!] + grantTypes: [String!] """ - ResponseTypes is an array of the OAuth 2.0 response type strings that the client can - use at the authorization endpoint. - - Pattern: id_token|code|token + ResponseTypes is an array of the OAuth 2.0 response type strings that the client can + use at the authorization endpoint. + + Pattern: id_token|code|token """ - responseTypes: [String!] + responseTypes: [String!] """ - Scope is a string containing a space-separated list of scope values (as - described in Section 3.3 of OAuth 2.0 [RFC6749]) that the client - can use when requesting access tokens. - - Pattern: ([a-zA-Z0-9\.\*]+\s?)+ + Scope is a string containing a space-separated list of scope values (as + described in Section 3.3 of OAuth 2.0 [RFC6749]) that the client + can use when requesting access tokens. + + Pattern: ([a-zA-Z0-9\.\*]+\s?)+ """ - scope: String! + scope: String! """ - Audience is a whitelist defining the audiences this client is allowed to request tokens for. An audience limits - the applicability of an OAuth 2.0 Access Token to, for example, certain API endpoints. The value is a list - of URLs. URLs MUST NOT contain whitespaces. + Audience is a whitelist defining the audiences this client is allowed to request tokens for. An audience limits + the applicability of an OAuth 2.0 Access Token to, for example, certain API endpoints. The value is a list + of URLs. URLs MUST NOT contain whitespaces. """ - audience: [String!] + audience: [String!] """ - SubjectType requested for responses to this Client. The subject_types_supported Discovery parameter contains a - list of the supported subject_type values for this server. Valid types include ` + "`" + `pairwise` + "`" + ` and ` + "`" + `public` + "`" + `. + SubjectType requested for responses to this Client. The subject_types_supported Discovery parameter contains a + list of the supported subject_type values for this server. Valid types include ` + "`" + `pairwise` + "`" + ` and ` + "`" + `public` + "`" + `. """ - subjectType: String! + subjectType: String! """ - AllowedCORSOrigins are one or more URLs (scheme://host[:port]) which are allowed to make CORS requests - to the /oauth/token endpoint. If this array is empty, the sever's CORS origin configuration (` + "`" + `CORS_ALLOWED_ORIGINS` + "`" + `) - will be used instead. If this array is set, the allowed origins are appended to the server's CORS origin configuration. - Be aware that environment variable ` + "`" + `CORS_ENABLED` + "`" + ` MUST be set to ` + "`" + `true` + "`" + ` for this to work. + AllowedCORSOrigins are one or more URLs (scheme://host[:port]) which are allowed to make CORS requests + to the /oauth/token endpoint. If this array is empty, the sever's CORS origin configuration (` + "`" + `CORS_ALLOWED_ORIGINS` + "`" + `) + will be used instead. If this array is set, the allowed origins are appended to the server's CORS origin configuration. + Be aware that environment variable ` + "`" + `CORS_ENABLED` + "`" + ` MUST be set to ` + "`" + `true` + "`" + ` for this to work. """ - allowedCORSOrigins: [String!] + allowedCORSOrigins: [String!] """ - Public flag tells that the client is public + Public flag tells that the client is public """ - public: Boolean! + public: Boolean! """ - ExpiresAt contins the time of expiration of the client + ExpiresAt contins the time of expiration of the client """ - expiresAt: Time! + expiresAt: Time! createdAt: Time! updatedAt: Time! - deletedAt: Time + deletedAt: Time } type AuthClientEdge { @@ -3584,16 +3654,6 @@ type AuthClientPayload { authClient: AuthClient } -""" -SessionToken object represents an OAuth 2.0 / JWT session token -""" -type SessionToken { - token: String! - expiresAt: Time! - isAdmin: Boolean! - roles: [String!] -} - ############################################################################### # Query ############################################################################### @@ -3606,158 +3666,204 @@ input AuthClientListFilter { } input AuthClientListOrder { - ID: Ordering - userID: Ordering - accountID: Ordering - title: Ordering - public: Ordering - lastUpdate: Ordering + ID: Ordering + userID: Ordering + accountID: Ordering + title: Ordering + public: Ordering + lastUpdate: Ordering } ############################################################################### # Mutations ############################################################################### -input AuthClientInput { - accountID: ID64 - userID: ID64 - title: String - secret: String - redirectURIs: [String!] - grantTypes: [String!] - responseTypes: [String!] - scope: String - audience: [String!] - subjectType: String! - allowedCORSOrigins: [String!] - public: Boolean - expiresAt: Time -} - ############################################################################### -# Query and Mutations +# Input Types ############################################################################### -extend type Query { +""" +AuthClientCreateInput is used to create a new OAuth 2.0 client +""" +input AuthClientCreateInput { """ - Get auth client object by ID + AccountID of the auth client owner """ - authClient(id: ID!): AuthClientPayload! @hasPermissions(permissions: ["auth_client.view.*"]) + accountID: ID64 @notempty """ - List of the auth client objects which can be filtered and ordered by some fields + UserID of the auth client creator """ - listAuthClients( - filter: AuthClientListFilter = null, - order: AuthClientListOrder = null, - page: Page = null - ): AuthClientConnection @hasPermissions(permissions: ["auth_client.list.*"]) -} + userID: ID64 @notempty -extend type Mutation { """ - Create the new auth client + Title of the auth client as human readable name """ - createAuthClient(input: AuthClientInput!): AuthClientPayload! @hasPermissions(permissions: ["auth_client.create.*"]) + title: String @notempty(trim: true) """ - Update auth client info + Secret for the OAuth 2.0 client """ - updateAuthClient(id: ID!, input: AuthClientInput!): AuthClientPayload! @hasPermissions(permissions: ["auth_client.update.*"]) + secret: String @notempty(trim: true) """ - Delete auth client + RedirectURIs allowed for this client """ - deleteAuthClient(id: ID!, msg: String = null): AuthClientPayload! @hasPermissions(permissions: ["auth_client.delete.*"]) -} -`, BuiltIn: false}, - {Name: "../../../../../../protocol/graphql/schemas/constants.graphql", Input: ` -""" -The list of statuses that shows is object approved or not -""" -enum ApproveStatus { + redirectURIs: [String!] + """ - Pending status of the just inited objects + GrantTypes allowed for this client """ - PENDING + grantTypes: [String!] """ - Approved status of object could be obtained from the some authorized user who have permissions + ResponseTypes allowed for this client """ - APPROVED + responseTypes: [String!] """ - Rejected status of object could be obtained from the some authorized user who have permissions + Scope string for the client """ - REJECTED -} + scope: String -""" -The list of statuses that shows is particular object active or paused -""" -enum ActiveStatus { """ - All object by default have to be paused + Audience whitelist for token requests """ - PAUSED + audience: [String!] """ - Status of the active object + SubjectType for responses to this client """ - ACTIVE + subjectType: String! + + """ + AllowedCORSOrigins for this client + """ + allowedCORSOrigins: [String!] + + """ + Public flag for the client + """ + public: Boolean + + """ + ExpiresAt time for the client + """ + expiresAt: Time } """ -The list of statuses that shows is particular object is available +AuthClientUpdateInput is used to update an existing OAuth 2.0 client """ -enum AvailableStatus { +input AuthClientUpdateInput { """ - All object by default have to be undefined + AccountID of the auth client owner """ - UNDEFINED + accountID: ID64 @notempty(ornil: true) """ - Status of the available object + UserID of the auth client creator """ - AVAILABLE + userID: ID64 @notempty(ornil: true) """ - Status of the unavailable object + Title of the auth client as human readable name """ - UNAVAILABLE + title: String @notempty(trim: true, ornil: true) + + """ + Secret for the OAuth 2.0 client + """ + secret: String @notempty(trim: true, ornil: true) + + """ + RedirectURIs allowed for this client + """ + redirectURIs: [String!] @notempty(ornil: true) + + """ + GrantTypes allowed for this client + """ + grantTypes: [String!] @notempty(ornil: true) + + """ + ResponseTypes allowed for this client + """ + responseTypes: [String!] @notempty(ornil: true) + + """ + Scope string for the client + """ + scope: String @notempty(trim: true, ornil: true) + + """ + Audience whitelist for token requests + """ + audience: [String!] @notempty(ornil: true) + + """ + SubjectType for responses to this client + """ + subjectType: String @notempty(trim: true, ornil: true) + + """ + AllowedCORSOrigins for this client + """ + allowedCORSOrigins: [String!] @notempty(ornil: true) + + """ + Public flag for the client + """ + public: Boolean + + """ + ExpiresAt time for the client + """ + expiresAt: Time @notempty(ornil: true) } -""" -Constants of the order of data -""" -enum Ordering { +############################################################################### +# Query and Mutations +############################################################################### + +extend type Query { """ - Ascending ordering of data + Get auth client object by ID """ - ASC + authClient(id: ID!): AuthClientPayload! + @hasPermissions(permissions: ["auth_client.view.*"]) """ - Descending ordering of data + List of the auth client objects which can be filtered and ordered by some fields """ - DESC + listAuthClients( + filter: AuthClientListFilter = null + order: [AuthClientListOrder] = null + page: Page = null + ): AuthClientConnection @hasPermissions(permissions: ["auth_client.list.*"]) } -""" -Constants of the response status -""" -enum ResponseStatus { +extend type Mutation { """ - Success status of the response + Create the new auth client """ - SUCCESS + createAuthClient(input: AuthClientCreateInput!): AuthClientPayload! + @hasPermissions(permissions: ["auth_client.create.*"]) """ - Error status of the response + Update auth client info """ - ERROR + updateAuthClient(id: ID!, input: AuthClientUpdateInput!): AuthClientPayload! + @hasPermissions(permissions: ["auth_client.update.*"]) + + """ + Delete auth client + """ + deleteAuthClient(id: ID!, msg: String = null): AuthClientPayload! + @hasPermissions(permissions: ["auth_client.delete.*"]) } `, BuiltIn: false}, - {Name: "../../../../../../protocol/graphql/schemas/directaccesstoken.graphql", Input: `type DirectAccessToken { + {Name: "../../../../../../repository/directaccesstoken/delivery/graphql/directaccesstoken.graphql", Input: `type DirectAccessToken { ID: ID64! token: String! description: String! @@ -3884,26 +3990,7 @@ extend type Mutation { ): StatusResponse @hasPermissions(permissions: ["directaccesstoken.delete.*"]) } `, BuiltIn: false}, - {Name: "../../../../../../protocol/graphql/schemas/directives.graphql", Input: `"Prevents access to a field if the user is not authenticated" -directive @auth on FIELD_DEFINITION | FIELD - -"Prevents access to a field/method if the user doesnt have the matching permissions" -directive @hasPermissions(permissions: [String!]!) on FIELD_DEFINITION | FIELD - -"Prevents access to a field/method if the user doesnt have the matching permissions" -directive @acl(permissions: [String!]!) on FIELD_DEFINITION | FIELD - -"Prevents access to a field/method if the user doesnt have the matching permissions" -directive @skipNoPermissions(permissions: [String!]) on FIELD_DEFINITION | FIELD - -"Caches the result of a field/method for a specified time to live (ttl) in seconds" -directive @cacheData( - ttl: Int! - key: String - fields: [String!] -) on FIELD_DEFINITION | FIELD -`, BuiltIn: false}, - {Name: "../../../../../../protocol/graphql/schemas/history.graphql", Input: `""" + {Name: "../../../../../../repository/historylog/delivery/graphql/history.graphql", Input: `""" HistoryAction is the model for history actions. """ type HistoryAction { @@ -4057,7 +4144,7 @@ extend type Query { ): HistoryActionConnection @hasPermissions(permissions: ["history_log.list.*"]) } `, BuiltIn: false}, - {Name: "../../../../../../protocol/graphql/schemas/options.graphql", Input: `enum OptionType { + {Name: "../../../../../../repository/option/delivery/graphql/options.graphql", Input: `enum OptionType { UNDEFINED, USER, ACCOUNT, @@ -4169,75 +4256,7 @@ extend type Mutation { setOption(name: String!, value: NullableJSON, type: OptionType! = USER, targetID: ID64! = 0): OptionPayload! @hasPermissions(permissions: ["option.set.*"]) } `, BuiltIn: false}, - {Name: "../../../../../../protocol/graphql/schemas/pagination.graphql", Input: ` -# @link https://developer.github.com/v4/object/pageinfo/ - -""" -Information for paginating -""" -type PageInfo { - """ - When paginating backwards, the cursor to continue. - """ - startCursor: String! - - """ - When paginating forwards, the cursor to continue. - """ - endCursor: String! - - """ - When paginating backwards, are there more items? - """ - hasPreviousPage: Boolean! - - """ - When paginating forwards, are there more items? - """ - hasNextPage: Boolean! - - """ - Total number of pages available - """ - total: Int! - - """ - Current page number - """ - page: Int! - - """ - Number of pages - """ - count: Int! -} - -""" -Information for paginating -""" -input Page { - """ - Start after the cursor ID - """ - after: String - - """ - Start after some records - """ - offset: Int - - """ - Page number to start at (0-based), defaults to 0 (0, 1, 2, etc.) - """ - startPage: Int - - """ - Maximum number of items to return - """ - size: Int -} -`, BuiltIn: false}, - {Name: "../../../../../../protocol/graphql/schemas/rbac.graphql", Input: `type RBACPermission { + {Name: "../../../../../../repository/rbac/delivery/graphql/rbac.graphql", Input: `type RBACPermission { name: String! object: String! access: String! @@ -4416,49 +4435,168 @@ extend type Mutation { deleteRole(id: ID64!, msg: String = null): RBACRolePayload! @hasPermissions(permissions: ["role.delete.*"]) } `, BuiltIn: false}, - {Name: "../../../../../../protocol/graphql/schemas/schema.graphql", Input: `# https://github.com/prisma/graphql-import -# Pagination https://graphql.org/learn/pagination/#pagination-and-edges + {Name: "../../../../../../repository/socialaccount/delivery/graphql/account_social.graphql", Input: `type SocialAccountSession { + """ + The unique name of the session to destinguish between different sessions with different scopes + """ + name: String! + socialAccountID: ID64! -scalar Time -scalar TimeDuration -scalar DateTime -scalar Map -scalar JSON -scalar NullableJSON -scalar UUID -scalar ID64 + tokenType: String! + accessToken: String! + refreshToken: String! + scope: [String!] -schema { - query: Query - mutation: Mutation + createdAt: Time! + updatedAt: Time! + expiresAt: Time + deletedAt: Time } -type Query { - serviceVersion: String! +type SocialAccount { + ID: ID64! + userID: ID64! + + socialID: String! + provider: String! + email: String! + username: String! + + firstName: String! + lastName: String! + avatar: String! + link: String! + + data: NullableJSON! + + """ + Social Account session object accessor + """ + sessions: [SocialAccountSession!] + + createdAt: Time! + updatedAt: Time! + deletedAt: Time } -type Mutation { - poke: String! +type SocialAccountEdge { + """ + A cursor for use in pagination. + """ + cursor: String! + + """ + The item at the end of the edge. + """ + node: SocialAccount } -`, BuiltIn: false}, - {Name: "../../../../../../protocol/graphql/schemas/status.graphql", Input: `""" -Simple response type for the API + """ -type StatusResponse { +SocialAccountConnection implements collection accessor interface with pagination +""" +type SocialAccountConnection { + """ + The total number of records + """ + totalCount: Int! + + """ + The edges for each of the social account's lists + """ + edges: [SocialAccountEdge!] + + """ + A list of the social accounts, as a convenience when edges are not needed. + """ + list: [SocialAccount!] + + """ + Information for paginating this connection + """ + pageInfo: PageInfo! +} + +""" +SocialAccountPayload wrapper to access of SocialAccount oprtation results +""" +type SocialAccountPayload { + """ + A unique identifier for the client performing the mutation. + """ + clientMutationID: String! + + """ + Social Account ID operation result + """ + socialAccountID: ID64! + + """ + Social Account object accessor + """ + socialAccount: SocialAccount +} + +############################################################################### +# Query +############################################################################### + +input SocialAccountListFilter { + ID: [ID64!] + userID: [ID64!] + provider: [String!] + username: [String!] + email: [String!] +} + +input SocialAccountListOrder { + ID: Ordering + userID: Ordering + provider: Ordering + email: Ordering + username: Ordering + firstName: Ordering + lastName: Ordering +} + +extend type Query { + """ + Get a social account by its unique identifier + """ + socialAccount( + """ + The unique identifier of the social account + """ + id: ID64! + ): SocialAccountPayload! @hasPermissions(permissions: ["account_social.view.*"]) + """ - Unique identifier for the client performing the mutation + Get the current user's social accounts """ - clientMutationID: String! + currentSocialAccounts( + filter: SocialAccountListFilter = null, + order: SocialAccountListOrder = null + ): SocialAccountConnection! @hasPermissions(permissions: ["account_social.list.*"]) """ - The status of the response + List all social accounts """ - status: ResponseStatus! + listSocialAccounts( + filter: SocialAccountListFilter = null, + order: SocialAccountListOrder = null, + page: Page = null + ): SocialAccountConnection! @hasPermissions(permissions: ["account_social.list.*"]) +} +extend type Mutation { """ - The message of the response + Disconnect a social account """ - message: String + disconnectSocialAccount( + """ + The unique identifier of the social account to disconnect + """ + id: ID64! + ): SocialAccountPayload! @hasPermissions(permissions: ["account_social.disconnect.*"]) } `, BuiltIn: false}, } @@ -4511,6 +4649,90 @@ func (ec *executionContext) dir_hasPermissions_args(ctx context.Context, rawArgs return args, nil } +func (ec *executionContext) dir_length_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "min", ec.unmarshalNInt2int) + if err != nil { + return nil, err + } + args["min"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "max", ec.unmarshalNInt2int) + if err != nil { + return nil, err + } + args["max"] = arg1 + arg2, err := graphql.ProcessArgField(ctx, rawArgs, "trim", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["trim"] = arg2 + arg3, err := graphql.ProcessArgField(ctx, rawArgs, "ornil", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["ornil"] = arg3 + return args, nil +} + +func (ec *executionContext) dir_notempty_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "trim", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["trim"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "ornil", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["ornil"] = arg1 + return args, nil +} + +func (ec *executionContext) dir_range_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "min", ec.unmarshalNFloat2float64) + if err != nil { + return nil, err + } + args["min"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "max", ec.unmarshalNFloat2float64) + if err != nil { + return nil, err + } + args["max"] = arg1 + arg2, err := graphql.ProcessArgField(ctx, rawArgs, "ornil", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["ornil"] = arg2 + return args, nil +} + +func (ec *executionContext) dir_regex_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "pattern", ec.unmarshalNString2string) + if err != nil { + return nil, err + } + args["pattern"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "trim", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["trim"] = arg1 + arg2, err := graphql.ProcessArgField(ctx, rawArgs, "ornil", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["ornil"] = arg2 + return args, nil +} + func (ec *executionContext) dir_skipNoPermissions_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -4573,7 +4795,7 @@ func (ec *executionContext) field_Mutation_approveUser_args(ctx context.Context, func (ec *executionContext) field_Mutation_createAuthClient_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNAuthClientInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientInput) + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNAuthClientCreateInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientCreateInput) if err != nil { return nil, err } @@ -4868,7 +5090,7 @@ func (ec *executionContext) field_Mutation_updateAuthClient_args(ctx context.Con return nil, err } args["id"] = arg0 - arg1, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNAuthClientInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientInput) + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNAuthClientUpdateInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientUpdateInput) if err != nil { return nil, err } @@ -5060,7 +5282,7 @@ func (ec *executionContext) field_Query_listAuthClients_args(ctx context.Context return nil, err } args["filter"] = arg0 - arg1, err := graphql.ProcessArgField(ctx, rawArgs, "order", ec.unmarshalOAuthClientListOrder2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientListOrder) + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "order", ec.unmarshalOAuthClientListOrder2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientListOrder) if err != nil { return nil, err } @@ -5362,18 +5584,18 @@ func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj any, next } n := next next = func(ctx context.Context) (any, error) { - if ec.directives.Acl == nil { + if ec.Directives.Acl == nil { return nil, errors.New("directive acl is not implemented") } - return ec.directives.Acl(ctx, obj, n, args["permissions"].([]string)) + return ec.Directives.Acl(ctx, obj, n, args["permissions"].([]string)) } case "auth": n := next next = func(ctx context.Context) (any, error) { - if ec.directives.Auth == nil { + if ec.Directives.Auth == nil { return nil, errors.New("directive auth is not implemented") } - return ec.directives.Auth(ctx, obj, n) + return ec.Directives.Auth(ctx, obj, n) } case "cacheData": rawArgs := d.ArgumentMap(ec.Variables) @@ -5384,10 +5606,10 @@ func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj any, next } n := next next = func(ctx context.Context) (any, error) { - if ec.directives.CacheData == nil { + if ec.Directives.CacheData == nil { return nil, errors.New("directive cacheData is not implemented") } - return ec.directives.CacheData(ctx, obj, n, args["ttl"].(int), args["key"].(*string), args["fields"].([]string)) + return ec.Directives.CacheData(ctx, obj, n, args["ttl"].(int), args["key"].(*string), args["fields"].([]string)) } case "hasPermissions": rawArgs := d.ArgumentMap(ec.Variables) @@ -5398,10 +5620,10 @@ func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj any, next } n := next next = func(ctx context.Context) (any, error) { - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { return nil, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, obj, n, args["permissions"].([]string)) + return ec.Directives.HasPermissions(ctx, obj, n, args["permissions"].([]string)) } case "skipNoPermissions": rawArgs := d.ArgumentMap(ec.Variables) @@ -5412,10 +5634,10 @@ func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj any, next } n := next next = func(ctx context.Context) (any, error) { - if ec.directives.SkipNoPermissions == nil { + if ec.Directives.SkipNoPermissions == nil { return nil, errors.New("directive skipNoPermissions is not implemented") } - return ec.directives.SkipNoPermissions(ctx, obj, n, args["permissions"].([]string)) + return ec.Directives.SkipNoPermissions(ctx, obj, n, args["permissions"].([]string)) } } } @@ -7463,14 +7685,14 @@ func (ec *executionContext) fieldContext_DirectAccessToken_expiresAt(_ context.C return fc, nil } -func (ec *executionContext) _DirectAccessTokenConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *models1.DirectAccessTokenConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _DirectAccessTokenConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DirectAccessTokenConnection_totalCount, func(ctx context.Context) (any, error) { - return obj.TotalCount, nil + return obj.TotalCount(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) @@ -7485,7 +7707,7 @@ func (ec *executionContext) fieldContext_DirectAccessTokenConnection_totalCount( fc = &graphql.FieldContext{ Object: "DirectAccessTokenConnection", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") @@ -7494,14 +7716,14 @@ func (ec *executionContext) fieldContext_DirectAccessTokenConnection_totalCount( return fc, nil } -func (ec *executionContext) _DirectAccessTokenConnection_edges(ctx context.Context, field graphql.CollectedField, obj *models1.DirectAccessTokenConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _DirectAccessTokenConnection_edges(ctx context.Context, field graphql.CollectedField, obj *connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DirectAccessTokenConnection_edges, func(ctx context.Context) (any, error) { - return obj.Edges, nil + return obj.Edges(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) @@ -7516,7 +7738,7 @@ func (ec *executionContext) fieldContext_DirectAccessTokenConnection_edges(_ con fc = &graphql.FieldContext{ Object: "DirectAccessTokenConnection", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { @@ -7531,14 +7753,14 @@ func (ec *executionContext) fieldContext_DirectAccessTokenConnection_edges(_ con return fc, nil } -func (ec *executionContext) _DirectAccessTokenConnection_list(ctx context.Context, field graphql.CollectedField, obj *models1.DirectAccessTokenConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _DirectAccessTokenConnection_list(ctx context.Context, field graphql.CollectedField, obj *connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DirectAccessTokenConnection_list, func(ctx context.Context) (any, error) { - return obj.List, nil + return obj.List(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) @@ -7553,7 +7775,7 @@ func (ec *executionContext) fieldContext_DirectAccessTokenConnection_list(_ cont fc = &graphql.FieldContext{ Object: "DirectAccessTokenConnection", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { @@ -7578,14 +7800,14 @@ func (ec *executionContext) fieldContext_DirectAccessTokenConnection_list(_ cont return fc, nil } -func (ec *executionContext) _DirectAccessTokenConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *models1.DirectAccessTokenConnection) (ret graphql.Marshaler) { +func (ec *executionContext) _DirectAccessTokenConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge]) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DirectAccessTokenConnection_pageInfo, func(ctx context.Context) (any, error) { - return obj.PageInfo, nil + return obj.PageInfo(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) @@ -7600,7 +7822,7 @@ func (ec *executionContext) fieldContext_DirectAccessTokenConnection_pageInfo(_ fc = &graphql.FieldContext{ Object: "DirectAccessTokenConnection", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { @@ -9206,7 +9428,7 @@ func (ec *executionContext) _Mutation_poke(ctx context.Context, field graphql.Co field, ec.fieldContext_Mutation_poke, func(ctx context.Context) (any, error) { - return ec.resolvers.Mutation().Poke(ctx) + return ec.Resolvers.Mutation().Poke(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) @@ -9230,26 +9452,42 @@ func (ec *executionContext) fieldContext_Mutation_poke(_ context.Context, field return fc, nil } -func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_createUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_login, + ec.fieldContext_Mutation_createUser, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().Login(ctx, fc.Args["login"].(string), fc.Args["password"].(string)) + return ec.Resolvers.Mutation().CreateUser(ctx, fc.Args["input"].(models.UserInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.create.*"}) + if err != nil { + var zeroVal *models.UserPayload + return zeroVal, err + } + if ec.Directives.HasPermissions == nil { + var zeroVal *models.UserPayload + return zeroVal, errors.New("directive hasPermissions is not implemented") + } + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) + } + + next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNSessionToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSessionToken, + ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9257,16 +9495,14 @@ func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, fie IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "token": - return ec.fieldContext_SessionToken_token(ctx, field) - case "expiresAt": - return ec.fieldContext_SessionToken_expiresAt(ctx, field) - case "isAdmin": - return ec.fieldContext_SessionToken_isAdmin(ctx, field) - case "roles": - return ec.fieldContext_SessionToken_roles(ctx, field) + case "clientMutationID": + return ec.fieldContext_UserPayload_clientMutationID(ctx, field) + case "userID": + return ec.fieldContext_UserPayload_userID(ctx, field) + case "user": + return ec.fieldContext_UserPayload_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SessionToken", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) }, } defer func() { @@ -9276,64 +9512,49 @@ func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, fie } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_login_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_logout, + ec.fieldContext_Mutation_updateUser, func(ctx context.Context) (any, error) { - return ec.resolvers.Mutation().Logout(ctx) + fc := graphql.GetFieldContext(ctx) + return ec.Resolvers.Mutation().UpdateUser(ctx, fc.Args["id"].(uint64), fc.Args["input"].(models.UserInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - return ec._fieldMiddleware(ctx, nil, next) - }, - ec.marshalNBoolean2bool, - true, - true, - ) -} + directive0 := next -func (ec *executionContext) fieldContext_Mutation_logout(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} + directive1 := func(ctx context.Context) (any, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.update.*"}) + if err != nil { + var zeroVal *models.UserPayload + return zeroVal, err + } + if ec.Directives.HasPermissions == nil { + var zeroVal *models.UserPayload + return zeroVal, errors.New("directive hasPermissions is not implemented") + } + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) + } -func (ec *executionContext) _Mutation_switchAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Mutation_switchAccount, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().SwitchAccount(ctx, fc.Args["id"].(uint64)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNSessionToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSessionToken, + ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_switchAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9341,16 +9562,14 @@ func (ec *executionContext) fieldContext_Mutation_switchAccount(ctx context.Cont IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "token": - return ec.fieldContext_SessionToken_token(ctx, field) - case "expiresAt": - return ec.fieldContext_SessionToken_expiresAt(ctx, field) - case "isAdmin": - return ec.fieldContext_SessionToken_isAdmin(ctx, field) - case "roles": - return ec.fieldContext_SessionToken_roles(ctx, field) + case "clientMutationID": + return ec.fieldContext_UserPayload_clientMutationID(ctx, field) + case "userID": + return ec.fieldContext_UserPayload_userID(ctx, field) + case "user": + return ec.fieldContext_UserPayload_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SessionToken", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) }, } defer func() { @@ -9360,49 +9579,49 @@ func (ec *executionContext) fieldContext_Mutation_switchAccount(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_switchAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_registerAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_approveUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_registerAccount, + ec.fieldContext_Mutation_approveUser, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().RegisterAccount(ctx, fc.Args["input"].(models.AccountCreateInput)) + return ec.Resolvers.Mutation().ApproveUser(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.register"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.approve.*"}) if err != nil { - var zeroVal *models.AccountCreatePayload + var zeroVal *models.UserPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.AccountCreatePayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.UserPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNAccountCreatePayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountCreatePayload, + ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_registerAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_approveUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9411,13 +9630,13 @@ func (ec *executionContext) fieldContext_Mutation_registerAccount(ctx context.Co Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_AccountCreatePayload_clientMutationID(ctx, field) - case "account": - return ec.fieldContext_AccountCreatePayload_account(ctx, field) - case "owner": - return ec.fieldContext_AccountCreatePayload_owner(ctx, field) + return ec.fieldContext_UserPayload_clientMutationID(ctx, field) + case "userID": + return ec.fieldContext_UserPayload_userID(ctx, field) + case "user": + return ec.fieldContext_UserPayload_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AccountCreatePayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) }, } defer func() { @@ -9427,49 +9646,49 @@ func (ec *executionContext) fieldContext_Mutation_registerAccount(ctx context.Co } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_registerAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_approveUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_rejectUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_updateAccount, + ec.fieldContext_Mutation_rejectUser, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().UpdateAccount(ctx, fc.Args["id"].(uint64), fc.Args["input"].(models.AccountInput)) + return ec.Resolvers.Mutation().RejectUser(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.update.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.reject.*"}) if err != nil { - var zeroVal *models.AccountPayload + var zeroVal *models.UserPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.AccountPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.UserPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, + ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_updateAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_rejectUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9478,13 +9697,13 @@ func (ec *executionContext) fieldContext_Mutation_updateAccount(ctx context.Cont Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) - case "accountID": - return ec.fieldContext_AccountPayload_accountID(ctx, field) - case "account": - return ec.fieldContext_AccountPayload_account(ctx, field) + return ec.fieldContext_UserPayload_clientMutationID(ctx, field) + case "userID": + return ec.fieldContext_UserPayload_userID(ctx, field) + case "user": + return ec.fieldContext_UserPayload_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) }, } defer func() { @@ -9494,49 +9713,49 @@ func (ec *executionContext) fieldContext_Mutation_updateAccount(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_rejectUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_approveAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_resetUserPassword(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_approveAccount, + ec.fieldContext_Mutation_resetUserPassword, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().ApproveAccount(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(string)) + return ec.Resolvers.Mutation().ResetUserPassword(ctx, fc.Args["email"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.approve.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.password.reset.*"}) if err != nil { - var zeroVal *models.AccountPayload + var zeroVal *models.StatusResponse return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.AccountPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.StatusResponse return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, + ec.marshalNStatusResponse2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐStatusResponse, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_approveAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_resetUserPassword(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9545,13 +9764,13 @@ func (ec *executionContext) fieldContext_Mutation_approveAccount(ctx context.Con Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) - case "accountID": - return ec.fieldContext_AccountPayload_accountID(ctx, field) - case "account": - return ec.fieldContext_AccountPayload_account(ctx, field) + return ec.fieldContext_StatusResponse_clientMutationID(ctx, field) + case "status": + return ec.fieldContext_StatusResponse_status(ctx, field) + case "message": + return ec.fieldContext_StatusResponse_message(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type StatusResponse", field.Name) }, } defer func() { @@ -9561,49 +9780,49 @@ func (ec *executionContext) fieldContext_Mutation_approveAccount(ctx context.Con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_approveAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_resetUserPassword_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_rejectAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateUserPassword(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_rejectAccount, + ec.fieldContext_Mutation_updateUserPassword, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().RejectAccount(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(string)) + return ec.Resolvers.Mutation().UpdateUserPassword(ctx, fc.Args["token"].(string), fc.Args["email"].(string), fc.Args["password"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.reject.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.password.reset.*"}) if err != nil { - var zeroVal *models.AccountPayload + var zeroVal *models.StatusResponse return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.AccountPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.StatusResponse return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, + ec.marshalNStatusResponse2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐStatusResponse, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_rejectAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateUserPassword(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9612,13 +9831,13 @@ func (ec *executionContext) fieldContext_Mutation_rejectAccount(ctx context.Cont Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) - case "accountID": - return ec.fieldContext_AccountPayload_accountID(ctx, field) - case "account": - return ec.fieldContext_AccountPayload_account(ctx, field) + return ec.fieldContext_StatusResponse_clientMutationID(ctx, field) + case "status": + return ec.fieldContext_StatusResponse_status(ctx, field) + case "message": + return ec.fieldContext_StatusResponse_message(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type StatusResponse", field.Name) }, } defer func() { @@ -9628,49 +9847,33 @@ func (ec *executionContext) fieldContext_Mutation_rejectAccount(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_rejectAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateUserPassword_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_inviteAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_inviteAccountMember, + ec.fieldContext_Mutation_login, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().InviteAccountMember(ctx, fc.Args["accountID"].(uint64), fc.Args["member"].(models.InviteMemberInput)) + return ec.Resolvers.Mutation().Login(ctx, fc.Args["login"].(string), fc.Args["password"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.invite.*"}) - if err != nil { - var zeroVal *models.MemberPayload - return zeroVal, err - } - if ec.directives.Acl == nil { - var zeroVal *models.MemberPayload - return zeroVal, errors.New("directive acl is not implemented") - } - return ec.directives.Acl(ctx, nil, directive0, permissions) - } - - next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, + ec.marshalNSessionToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSessionToken, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_inviteAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9678,14 +9881,16 @@ func (ec *executionContext) fieldContext_Mutation_inviteAccountMember(ctx contex IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "clientMutationID": - return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) - case "memberID": - return ec.fieldContext_MemberPayload_memberID(ctx, field) - case "member": - return ec.fieldContext_MemberPayload_member(ctx, field) + case "token": + return ec.fieldContext_SessionToken_token(ctx, field) + case "expiresAt": + return ec.fieldContext_SessionToken_expiresAt(ctx, field) + case "isAdmin": + return ec.fieldContext_SessionToken_isAdmin(ctx, field) + case "roles": + return ec.fieldContext_SessionToken_roles(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SessionToken", field.Name) }, } defer func() { @@ -9695,116 +9900,64 @@ func (ec *executionContext) fieldContext_Mutation_inviteAccountMember(ctx contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_inviteAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_login_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_updateAccountMember, + ec.fieldContext_Mutation_logout, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().UpdateAccountMember(ctx, fc.Args["memberID"].(uint64), fc.Args["member"].(models.MemberInput)) + return ec.Resolvers.Mutation().Logout(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.update.*"}) - if err != nil { - var zeroVal *models.MemberPayload - return zeroVal, err - } - if ec.directives.Acl == nil { - var zeroVal *models.MemberPayload - return zeroVal, errors.New("directive acl is not implemented") - } - return ec.directives.Acl(ctx, nil, directive0, permissions) - } - - next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, + ec.marshalNBoolean2bool, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_updateAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_logout(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "clientMutationID": - return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) - case "memberID": - return ec.fieldContext_MemberPayload_memberID(ctx, field) - case "member": - return ec.fieldContext_MemberPayload_member(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_removeAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_switchAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_removeAccountMember, + ec.fieldContext_Mutation_switchAccount, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().RemoveAccountMember(ctx, fc.Args["memberID"].(uint64)) + return ec.Resolvers.Mutation().SwitchAccount(ctx, fc.Args["id"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.delete.*"}) - if err != nil { - var zeroVal *models.MemberPayload - return zeroVal, err - } - if ec.directives.Acl == nil { - var zeroVal *models.MemberPayload - return zeroVal, errors.New("directive acl is not implemented") - } - return ec.directives.Acl(ctx, nil, directive0, permissions) - } - - next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, + ec.marshalNSessionToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSessionToken, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_removeAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_switchAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9812,14 +9965,16 @@ func (ec *executionContext) fieldContext_Mutation_removeAccountMember(ctx contex IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "clientMutationID": - return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) - case "memberID": - return ec.fieldContext_MemberPayload_memberID(ctx, field) - case "member": - return ec.fieldContext_MemberPayload_member(ctx, field) + case "token": + return ec.fieldContext_SessionToken_token(ctx, field) + case "expiresAt": + return ec.fieldContext_SessionToken_expiresAt(ctx, field) + case "isAdmin": + return ec.fieldContext_SessionToken_isAdmin(ctx, field) + case "roles": + return ec.fieldContext_SessionToken_roles(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SessionToken", field.Name) }, } defer func() { @@ -9829,49 +9984,49 @@ func (ec *executionContext) fieldContext_Mutation_removeAccountMember(ctx contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_removeAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_switchAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_approveAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_registerAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_approveAccountMember, + ec.fieldContext_Mutation_registerAccount, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().ApproveAccountMember(ctx, fc.Args["memberID"].(uint64), fc.Args["msg"].(string)) + return ec.Resolvers.Mutation().RegisterAccount(ctx, fc.Args["input"].(models.AccountCreateInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.approve.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.register"}) if err != nil { - var zeroVal *models.MemberPayload + var zeroVal *models.AccountCreatePayload return zeroVal, err } - if ec.directives.Acl == nil { - var zeroVal *models.MemberPayload - return zeroVal, errors.New("directive acl is not implemented") + if ec.Directives.HasPermissions == nil { + var zeroVal *models.AccountCreatePayload + return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.Acl(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, + ec.marshalNAccountCreatePayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountCreatePayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_approveAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_registerAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9880,13 +10035,13 @@ func (ec *executionContext) fieldContext_Mutation_approveAccountMember(ctx conte Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) - case "memberID": - return ec.fieldContext_MemberPayload_memberID(ctx, field) - case "member": - return ec.fieldContext_MemberPayload_member(ctx, field) + return ec.fieldContext_AccountCreatePayload_clientMutationID(ctx, field) + case "account": + return ec.fieldContext_AccountCreatePayload_account(ctx, field) + case "owner": + return ec.fieldContext_AccountCreatePayload_owner(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountCreatePayload", field.Name) }, } defer func() { @@ -9896,49 +10051,49 @@ func (ec *executionContext) fieldContext_Mutation_approveAccountMember(ctx conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_approveAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_registerAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_rejectAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_rejectAccountMember, + ec.fieldContext_Mutation_updateAccount, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().RejectAccountMember(ctx, fc.Args["memberID"].(uint64), fc.Args["msg"].(string)) + return ec.Resolvers.Mutation().UpdateAccount(ctx, fc.Args["id"].(uint64), fc.Args["input"].(models.AccountInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.reject.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.update.*"}) if err != nil { - var zeroVal *models.MemberPayload + var zeroVal *models.AccountPayload return zeroVal, err } - if ec.directives.Acl == nil { - var zeroVal *models.MemberPayload - return zeroVal, errors.New("directive acl is not implemented") + if ec.Directives.HasPermissions == nil { + var zeroVal *models.AccountPayload + return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.Acl(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, + ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_rejectAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9947,13 +10102,13 @@ func (ec *executionContext) fieldContext_Mutation_rejectAccountMember(ctx contex Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) - case "memberID": - return ec.fieldContext_MemberPayload_memberID(ctx, field) - case "member": - return ec.fieldContext_MemberPayload_member(ctx, field) + return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) + case "accountID": + return ec.fieldContext_AccountPayload_accountID(ctx, field) + case "account": + return ec.fieldContext_AccountPayload_account(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) }, } defer func() { @@ -9963,49 +10118,49 @@ func (ec *executionContext) fieldContext_Mutation_rejectAccountMember(ctx contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_rejectAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_disconnectSocialAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_approveAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_disconnectSocialAccount, + ec.fieldContext_Mutation_approveAccount, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().DisconnectSocialAccount(ctx, fc.Args["id"].(uint64)) + return ec.Resolvers.Mutation().ApproveAccount(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.disconnect.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.approve.*"}) if err != nil { - var zeroVal *models.SocialAccountPayload + var zeroVal *models.AccountPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.SocialAccountPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.AccountPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNSocialAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountPayload, + ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_disconnectSocialAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_approveAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10014,13 +10169,13 @@ func (ec *executionContext) fieldContext_Mutation_disconnectSocialAccount(ctx co Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_SocialAccountPayload_clientMutationID(ctx, field) - case "socialAccountID": - return ec.fieldContext_SocialAccountPayload_socialAccountID(ctx, field) - case "socialAccount": - return ec.fieldContext_SocialAccountPayload_socialAccount(ctx, field) + return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) + case "accountID": + return ec.fieldContext_AccountPayload_accountID(ctx, field) + case "account": + return ec.fieldContext_AccountPayload_account(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SocialAccountPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) }, } defer func() { @@ -10030,49 +10185,49 @@ func (ec *executionContext) fieldContext_Mutation_disconnectSocialAccount(ctx co } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_disconnectSocialAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_approveAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_createUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_rejectAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_createUser, + ec.fieldContext_Mutation_rejectAccount, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().CreateUser(ctx, fc.Args["input"].(models.UserInput)) + return ec.Resolvers.Mutation().RejectAccount(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.create.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.reject.*"}) if err != nil { - var zeroVal *models.UserPayload + var zeroVal *models.AccountPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.UserPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.AccountPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, + ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_rejectAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10081,13 +10236,13 @@ func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_UserPayload_clientMutationID(ctx, field) - case "userID": - return ec.fieldContext_UserPayload_userID(ctx, field) - case "user": - return ec.fieldContext_UserPayload_user(ctx, field) + return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) + case "accountID": + return ec.fieldContext_AccountPayload_accountID(ctx, field) + case "account": + return ec.fieldContext_AccountPayload_account(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) }, } defer func() { @@ -10097,49 +10252,49 @@ func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_rejectAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_inviteAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_updateUser, + ec.fieldContext_Mutation_inviteAccountMember, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().UpdateUser(ctx, fc.Args["id"].(uint64), fc.Args["input"].(models.UserInput)) + return ec.Resolvers.Mutation().InviteAccountMember(ctx, fc.Args["accountID"].(uint64), fc.Args["member"].(models.InviteMemberInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.update.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.invite.*"}) if err != nil { - var zeroVal *models.UserPayload + var zeroVal *models.MemberPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.UserPayload - return zeroVal, errors.New("directive hasPermissions is not implemented") + if ec.Directives.Acl == nil { + var zeroVal *models.MemberPayload + return zeroVal, errors.New("directive acl is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.Acl(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, + ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_inviteAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10148,13 +10303,13 @@ func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_UserPayload_clientMutationID(ctx, field) - case "userID": - return ec.fieldContext_UserPayload_userID(ctx, field) - case "user": - return ec.fieldContext_UserPayload_user(ctx, field) + return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) + case "memberID": + return ec.fieldContext_MemberPayload_memberID(ctx, field) + case "member": + return ec.fieldContext_MemberPayload_member(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) }, } defer func() { @@ -10164,49 +10319,49 @@ func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_inviteAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_approveUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_approveUser, + ec.fieldContext_Mutation_updateAccountMember, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().ApproveUser(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(*string)) + return ec.Resolvers.Mutation().UpdateAccountMember(ctx, fc.Args["memberID"].(uint64), fc.Args["member"].(models.MemberInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.approve.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.update.*"}) if err != nil { - var zeroVal *models.UserPayload + var zeroVal *models.MemberPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.UserPayload - return zeroVal, errors.New("directive hasPermissions is not implemented") + if ec.Directives.Acl == nil { + var zeroVal *models.MemberPayload + return zeroVal, errors.New("directive acl is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.Acl(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, + ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_approveUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10215,13 +10370,13 @@ func (ec *executionContext) fieldContext_Mutation_approveUser(ctx context.Contex Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_UserPayload_clientMutationID(ctx, field) - case "userID": - return ec.fieldContext_UserPayload_userID(ctx, field) - case "user": - return ec.fieldContext_UserPayload_user(ctx, field) + return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) + case "memberID": + return ec.fieldContext_MemberPayload_memberID(ctx, field) + case "member": + return ec.fieldContext_MemberPayload_member(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) }, } defer func() { @@ -10231,49 +10386,49 @@ func (ec *executionContext) fieldContext_Mutation_approveUser(ctx context.Contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_approveUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_rejectUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_removeAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_rejectUser, + ec.fieldContext_Mutation_removeAccountMember, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().RejectUser(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(*string)) + return ec.Resolvers.Mutation().RemoveAccountMember(ctx, fc.Args["memberID"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.reject.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.delete.*"}) if err != nil { - var zeroVal *models.UserPayload + var zeroVal *models.MemberPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.UserPayload - return zeroVal, errors.New("directive hasPermissions is not implemented") + if ec.Directives.Acl == nil { + var zeroVal *models.MemberPayload + return zeroVal, errors.New("directive acl is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.Acl(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, + ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_rejectUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_removeAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10282,13 +10437,13 @@ func (ec *executionContext) fieldContext_Mutation_rejectUser(ctx context.Context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_UserPayload_clientMutationID(ctx, field) - case "userID": - return ec.fieldContext_UserPayload_userID(ctx, field) - case "user": - return ec.fieldContext_UserPayload_user(ctx, field) + return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) + case "memberID": + return ec.fieldContext_MemberPayload_memberID(ctx, field) + case "member": + return ec.fieldContext_MemberPayload_member(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) }, } defer func() { @@ -10298,49 +10453,49 @@ func (ec *executionContext) fieldContext_Mutation_rejectUser(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_rejectUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_removeAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_resetUserPassword(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_approveAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_resetUserPassword, + ec.fieldContext_Mutation_approveAccountMember, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().ResetUserPassword(ctx, fc.Args["email"].(string)) + return ec.Resolvers.Mutation().ApproveAccountMember(ctx, fc.Args["memberID"].(uint64), fc.Args["msg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.password.reset.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.approve.*"}) if err != nil { - var zeroVal *models.StatusResponse + var zeroVal *models.MemberPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.StatusResponse - return zeroVal, errors.New("directive hasPermissions is not implemented") + if ec.Directives.Acl == nil { + var zeroVal *models.MemberPayload + return zeroVal, errors.New("directive acl is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.Acl(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNStatusResponse2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐStatusResponse, + ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_resetUserPassword(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_approveAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10349,13 +10504,13 @@ func (ec *executionContext) fieldContext_Mutation_resetUserPassword(ctx context. Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_StatusResponse_clientMutationID(ctx, field) - case "status": - return ec.fieldContext_StatusResponse_status(ctx, field) - case "message": - return ec.fieldContext_StatusResponse_message(ctx, field) + return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) + case "memberID": + return ec.fieldContext_MemberPayload_memberID(ctx, field) + case "member": + return ec.fieldContext_MemberPayload_member(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type StatusResponse", field.Name) + return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) }, } defer func() { @@ -10365,49 +10520,49 @@ func (ec *executionContext) fieldContext_Mutation_resetUserPassword(ctx context. } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_resetUserPassword_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_approveAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateUserPassword(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_rejectAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_updateUserPassword, + ec.fieldContext_Mutation_rejectAccountMember, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().UpdateUserPassword(ctx, fc.Args["token"].(string), fc.Args["email"].(string), fc.Args["password"].(string)) + return ec.Resolvers.Mutation().RejectAccountMember(ctx, fc.Args["memberID"].(uint64), fc.Args["msg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.password.reset.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.reject.*"}) if err != nil { - var zeroVal *models.StatusResponse + var zeroVal *models.MemberPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.StatusResponse - return zeroVal, errors.New("directive hasPermissions is not implemented") + if ec.Directives.Acl == nil { + var zeroVal *models.MemberPayload + return zeroVal, errors.New("directive acl is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.Acl(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNStatusResponse2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐStatusResponse, + ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_updateUserPassword(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_rejectAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10416,13 +10571,13 @@ func (ec *executionContext) fieldContext_Mutation_updateUserPassword(ctx context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_StatusResponse_clientMutationID(ctx, field) - case "status": - return ec.fieldContext_StatusResponse_status(ctx, field) - case "message": - return ec.fieldContext_StatusResponse_message(ctx, field) + return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) + case "memberID": + return ec.fieldContext_MemberPayload_memberID(ctx, field) + case "member": + return ec.fieldContext_MemberPayload_member(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type StatusResponse", field.Name) + return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) }, } defer func() { @@ -10432,7 +10587,7 @@ func (ec *executionContext) fieldContext_Mutation_updateUserPassword(ctx context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateUserPassword_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_rejectAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -10447,7 +10602,7 @@ func (ec *executionContext) _Mutation_createAuthClient(ctx context.Context, fiel ec.fieldContext_Mutation_createAuthClient, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().CreateAuthClient(ctx, fc.Args["input"].(models.AuthClientInput)) + return ec.Resolvers.Mutation().CreateAuthClient(ctx, fc.Args["input"].(models.AuthClientCreateInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -10458,11 +10613,11 @@ func (ec *executionContext) _Mutation_createAuthClient(ctx context.Context, fiel var zeroVal *models.AuthClientPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.AuthClientPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10514,7 +10669,7 @@ func (ec *executionContext) _Mutation_updateAuthClient(ctx context.Context, fiel ec.fieldContext_Mutation_updateAuthClient, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().UpdateAuthClient(ctx, fc.Args["id"].(string), fc.Args["input"].(models.AuthClientInput)) + return ec.Resolvers.Mutation().UpdateAuthClient(ctx, fc.Args["id"].(string), fc.Args["input"].(models.AuthClientUpdateInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -10525,11 +10680,11 @@ func (ec *executionContext) _Mutation_updateAuthClient(ctx context.Context, fiel var zeroVal *models.AuthClientPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.AuthClientPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10581,7 +10736,7 @@ func (ec *executionContext) _Mutation_deleteAuthClient(ctx context.Context, fiel ec.fieldContext_Mutation_deleteAuthClient, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().DeleteAuthClient(ctx, fc.Args["id"].(string), fc.Args["msg"].(*string)) + return ec.Resolvers.Mutation().DeleteAuthClient(ctx, fc.Args["id"].(string), fc.Args["msg"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -10592,11 +10747,11 @@ func (ec *executionContext) _Mutation_deleteAuthClient(ctx context.Context, fiel var zeroVal *models.AuthClientPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.AuthClientPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10648,7 +10803,7 @@ func (ec *executionContext) _Mutation_generateDirectAccessToken(ctx context.Cont ec.fieldContext_Mutation_generateDirectAccessToken, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().GenerateDirectAccessToken(ctx, fc.Args["userID"].(*uint64), fc.Args["description"].(string), fc.Args["expiresAt"].(*time.Time)) + return ec.Resolvers.Mutation().GenerateDirectAccessToken(ctx, fc.Args["userID"].(*uint64), fc.Args["description"].(string), fc.Args["expiresAt"].(*time.Time)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -10659,11 +10814,11 @@ func (ec *executionContext) _Mutation_generateDirectAccessToken(ctx context.Cont var zeroVal *models.DirectAccessTokenPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.DirectAccessTokenPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10713,7 +10868,7 @@ func (ec *executionContext) _Mutation_revokeDirectAccessToken(ctx context.Contex ec.fieldContext_Mutation_revokeDirectAccessToken, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().RevokeDirectAccessToken(ctx, fc.Args["filter"].(models.DirectAccessTokenListFilter)) + return ec.Resolvers.Mutation().RevokeDirectAccessToken(ctx, fc.Args["filter"].(models.DirectAccessTokenListFilter)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -10724,11 +10879,11 @@ func (ec *executionContext) _Mutation_revokeDirectAccessToken(ctx context.Contex var zeroVal *models.StatusResponse return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.StatusResponse return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10780,7 +10935,7 @@ func (ec *executionContext) _Mutation_setOption(ctx context.Context, field graph ec.fieldContext_Mutation_setOption, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().SetOption(ctx, fc.Args["name"].(string), fc.Args["value"].(*types.NullableJSON), fc.Args["type"].(models.OptionType), fc.Args["targetID"].(uint64)) + return ec.Resolvers.Mutation().SetOption(ctx, fc.Args["name"].(string), fc.Args["value"].(*types.NullableJSON), fc.Args["type"].(models.OptionType), fc.Args["targetID"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -10791,11 +10946,11 @@ func (ec *executionContext) _Mutation_setOption(ctx context.Context, field graph var zeroVal *models.OptionPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.OptionPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10822,7 +10977,74 @@ func (ec *executionContext) fieldContext_Mutation_setOption(ctx context.Context, case "option": return ec.fieldContext_OptionPayload_option(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type OptionPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type OptionPayload", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_setOption_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_createRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Mutation_createRole, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.Resolvers.Mutation().CreateRole(ctx, fc.Args["input"].(models.RBACRoleInput)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"role.create.*"}) + if err != nil { + var zeroVal *models.RBACRolePayload + return zeroVal, err + } + if ec.Directives.HasPermissions == nil { + var zeroVal *models.RBACRolePayload + return zeroVal, errors.New("directive hasPermissions is not implemented") + } + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) + } + + next = directive1 + return ec._fieldMiddleware(ctx, nil, next) + }, + ec.marshalNRBACRolePayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACRolePayload, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Mutation_createRole(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "clientMutationID": + return ec.fieldContext_RBACRolePayload_clientMutationID(ctx, field) + case "roleID": + return ec.fieldContext_RBACRolePayload_roleID(ctx, field) + case "role": + return ec.fieldContext_RBACRolePayload_role(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RBACRolePayload", field.Name) }, } defer func() { @@ -10832,37 +11054,37 @@ func (ec *executionContext) fieldContext_Mutation_setOption(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_setOption_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createRole_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_createRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_createRole, + ec.fieldContext_Mutation_updateRole, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().CreateRole(ctx, fc.Args["input"].(models.RBACRoleInput)) + return ec.Resolvers.Mutation().UpdateRole(ctx, fc.Args["id"].(uint64), fc.Args["input"].(models.RBACRoleInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"role.create.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"role.update.*"}) if err != nil { var zeroVal *models.RBACRolePayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.RBACRolePayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10874,7 +11096,7 @@ func (ec *executionContext) _Mutation_createRole(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_Mutation_createRole(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateRole(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10899,37 +11121,37 @@ func (ec *executionContext) fieldContext_Mutation_createRole(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createRole_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateRole_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_deleteRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_updateRole, + ec.fieldContext_Mutation_deleteRole, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().UpdateRole(ctx, fc.Args["id"].(uint64), fc.Args["input"].(models.RBACRoleInput)) + return ec.Resolvers.Mutation().DeleteRole(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"role.update.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"role.delete.*"}) if err != nil { var zeroVal *models.RBACRolePayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.RBACRolePayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10941,7 +11163,7 @@ func (ec *executionContext) _Mutation_updateRole(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_Mutation_updateRole(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteRole(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10966,49 +11188,49 @@ func (ec *executionContext) fieldContext_Mutation_updateRole(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateRole_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_deleteRole_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_deleteRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_disconnectSocialAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_deleteRole, + ec.fieldContext_Mutation_disconnectSocialAccount, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().DeleteRole(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(*string)) + return ec.Resolvers.Mutation().DisconnectSocialAccount(ctx, fc.Args["id"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"role.delete.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.disconnect.*"}) if err != nil { - var zeroVal *models.RBACRolePayload + var zeroVal *models.SocialAccountPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.RBACRolePayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.SocialAccountPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNRBACRolePayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACRolePayload, + ec.marshalNSocialAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_deleteRole(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_disconnectSocialAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -11017,13 +11239,13 @@ func (ec *executionContext) fieldContext_Mutation_deleteRole(ctx context.Context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_RBACRolePayload_clientMutationID(ctx, field) - case "roleID": - return ec.fieldContext_RBACRolePayload_roleID(ctx, field) - case "role": - return ec.fieldContext_RBACRolePayload_role(ctx, field) + return ec.fieldContext_SocialAccountPayload_clientMutationID(ctx, field) + case "socialAccountID": + return ec.fieldContext_SocialAccountPayload_socialAccountID(ctx, field) + case "socialAccount": + return ec.fieldContext_SocialAccountPayload_socialAccount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type RBACRolePayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SocialAccountPayload", field.Name) }, } defer func() { @@ -11033,7 +11255,7 @@ func (ec *executionContext) fieldContext_Mutation_deleteRole(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteRole_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_disconnectSocialAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -12111,7 +12333,7 @@ func (ec *executionContext) _Query_serviceVersion(ctx context.Context, field gra field, ec.fieldContext_Query_serviceVersion, func(ctx context.Context) (any, error) { - return ec.resolvers.Query().ServiceVersion(ctx) + return ec.Resolvers.Query().ServiceVersion(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) @@ -12135,290 +12357,97 @@ func (ec *executionContext) fieldContext_Query_serviceVersion(_ context.Context, return fc, nil } -func (ec *executionContext) _Query_currentSession(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Query_currentSession, - func(ctx context.Context) (any, error) { - return ec.resolvers.Query().CurrentSession(ctx) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) - if err != nil { - var zeroVal *models.SessionToken - return zeroVal, err - } - if ec.directives.HasPermissions == nil { - var zeroVal *models.SessionToken - return zeroVal, errors.New("directive hasPermissions is not implemented") - } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) - } - - next = directive1 - return ec._fieldMiddleware(ctx, nil, next) - }, - ec.marshalNSessionToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSessionToken, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_Query_currentSession(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "token": - return ec.fieldContext_SessionToken_token(ctx, field) - case "expiresAt": - return ec.fieldContext_SessionToken_expiresAt(ctx, field) - case "isAdmin": - return ec.fieldContext_SessionToken_isAdmin(ctx, field) - case "roles": - return ec.fieldContext_SessionToken_roles(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type SessionToken", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_currentAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Query_currentAccount, - func(ctx context.Context) (any, error) { - return ec.resolvers.Query().CurrentAccount(ctx) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) - if err != nil { - var zeroVal *models.AccountPayload - return zeroVal, err - } - if ec.directives.HasPermissions == nil { - var zeroVal *models.AccountPayload - return zeroVal, errors.New("directive hasPermissions is not implemented") - } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) - } - - next = directive1 - return ec._fieldMiddleware(ctx, nil, next) - }, - ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_Query_currentAccount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "clientMutationID": - return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) - case "accountID": - return ec.fieldContext_AccountPayload_accountID(ctx, field) - case "account": - return ec.fieldContext_AccountPayload_account(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_account(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_currentUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_account, + ec.fieldContext_Query_currentUser, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Account(ctx, fc.Args["id"].(uint64)) + return ec.Resolvers.Query().CurrentUser(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.view.*"}) if err != nil { - var zeroVal *models.AccountPayload + var zeroVal *models.UserPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.AccountPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.UserPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, - true, + ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, true, - ) -} - -func (ec *executionContext) fieldContext_Query_account(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "clientMutationID": - return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) - case "accountID": - return ec.fieldContext_AccountPayload_accountID(ctx, field) - case "account": - return ec.fieldContext_AccountPayload_account(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_account_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_listAccounts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Query_listAccounts, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListAccounts(ctx, fc.Args["filter"].(*models.AccountListFilter), fc.Args["order"].(*models.AccountListOrder), fc.Args["page"].(*models.Page)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.list.*"}) - if err != nil { - var zeroVal *connectors.CollectionConnection[models.Account, models.AccountEdge] - return zeroVal, err - } - if ec.directives.HasPermissions == nil { - var zeroVal *connectors.CollectionConnection[models.Account, models.AccountEdge] - return zeroVal, errors.New("directive hasPermissions is not implemented") - } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) - } - - next = directive1 - return ec._fieldMiddleware(ctx, nil, next) - }, - ec.marshalOAccountConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, true, - false, ) } -func (ec *executionContext) fieldContext_Query_listAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "totalCount": - return ec.fieldContext_AccountConnection_totalCount(ctx, field) - case "edges": - return ec.fieldContext_AccountConnection_edges(ctx, field) - case "list": - return ec.fieldContext_AccountConnection_list(ctx, field) - case "pageInfo": - return ec.fieldContext_AccountConnection_pageInfo(ctx, field) +func (ec *executionContext) fieldContext_Query_currentUser(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "clientMutationID": + return ec.fieldContext_UserPayload_clientMutationID(ctx, field) + case "userID": + return ec.fieldContext_UserPayload_userID(ctx, field) + case "user": + return ec.fieldContext_UserPayload_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AccountConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listAccounts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_listAccountRolesAndPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_listAccountRolesAndPermissions, + ec.fieldContext_Query_user, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListAccountRolesAndPermissions(ctx, fc.Args["accountID"].(uint64), fc.Args["order"].(*models.RBACRoleListOrder)) + return ec.Resolvers.Query().User(ctx, fc.Args["id"].(uint64), fc.Args["username"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.view.*"}) if err != nil { - var zeroVal *connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge] + var zeroVal *models.UserPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge] + if ec.Directives.HasPermissions == nil { + var zeroVal *models.UserPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalORBACRoleConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Query_listAccountRolesAndPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12426,16 +12455,14 @@ func (ec *executionContext) fieldContext_Query_listAccountRolesAndPermissions(ct IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "totalCount": - return ec.fieldContext_RBACRoleConnection_totalCount(ctx, field) - case "edges": - return ec.fieldContext_RBACRoleConnection_edges(ctx, field) - case "list": - return ec.fieldContext_RBACRoleConnection_list(ctx, field) - case "pageInfo": - return ec.fieldContext_RBACRoleConnection_pageInfo(ctx, field) + case "clientMutationID": + return ec.fieldContext_UserPayload_clientMutationID(ctx, field) + case "userID": + return ec.fieldContext_UserPayload_userID(ctx, field) + case "user": + return ec.fieldContext_UserPayload_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type RBACRoleConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) }, } defer func() { @@ -12445,49 +12472,49 @@ func (ec *executionContext) fieldContext_Query_listAccountRolesAndPermissions(ct } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listAccountRolesAndPermissions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_user_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_listMembers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_listUsers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_listMembers, + ec.fieldContext_Query_listUsers, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListMembers(ctx, fc.Args["filter"].(*models.MemberListFilter), fc.Args["order"].(*models.MemberListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListUsers(ctx, fc.Args["filter"].(*models.UserListFilter), fc.Args["order"].(*models.UserListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.list.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.list.*"}) if err != nil { - var zeroVal *connectors.CollectionConnection[models.Member, models.MemberEdge] + var zeroVal *connectors.CollectionConnection[models.User, models.UserEdge] return zeroVal, err } - if ec.directives.Acl == nil { - var zeroVal *connectors.CollectionConnection[models.Member, models.MemberEdge] - return zeroVal, errors.New("directive acl is not implemented") + if ec.Directives.HasPermissions == nil { + var zeroVal *connectors.CollectionConnection[models.User, models.UserEdge] + return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.Acl(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalOMemberConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + ec.marshalOUserConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, true, false, ) } -func (ec *executionContext) fieldContext_Query_listMembers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_listUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12496,15 +12523,15 @@ func (ec *executionContext) fieldContext_Query_listMembers(ctx context.Context, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "totalCount": - return ec.fieldContext_MemberConnection_totalCount(ctx, field) + return ec.fieldContext_UserConnection_totalCount(ctx, field) case "edges": - return ec.fieldContext_MemberConnection_edges(ctx, field) + return ec.fieldContext_UserConnection_edges(ctx, field) case "list": - return ec.fieldContext_MemberConnection_list(ctx, field) + return ec.fieldContext_UserConnection_list(ctx, field) case "pageInfo": - return ec.fieldContext_MemberConnection_pageInfo(ctx, field) + return ec.fieldContext_UserConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type MemberConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) }, } defer func() { @@ -12514,49 +12541,48 @@ func (ec *executionContext) fieldContext_Query_listMembers(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listMembers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_listUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_socialAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_currentSession(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_socialAccount, + ec.fieldContext_Query_currentSession, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().SocialAccount(ctx, fc.Args["id"].(uint64)) + return ec.Resolvers.Query().CurrentSession(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.view.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) if err != nil { - var zeroVal *models.SocialAccountPayload + var zeroVal *models.SessionToken return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.SocialAccountPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.SessionToken return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNSocialAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountPayload, + ec.marshalNSessionToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSessionToken, true, true, ) } -func (ec *executionContext) fieldContext_Query_socialAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_currentSession(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12564,66 +12590,56 @@ func (ec *executionContext) fieldContext_Query_socialAccount(ctx context.Context IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "clientMutationID": - return ec.fieldContext_SocialAccountPayload_clientMutationID(ctx, field) - case "socialAccountID": - return ec.fieldContext_SocialAccountPayload_socialAccountID(ctx, field) - case "socialAccount": - return ec.fieldContext_SocialAccountPayload_socialAccount(ctx, field) + case "token": + return ec.fieldContext_SessionToken_token(ctx, field) + case "expiresAt": + return ec.fieldContext_SessionToken_expiresAt(ctx, field) + case "isAdmin": + return ec.fieldContext_SessionToken_isAdmin(ctx, field) + case "roles": + return ec.fieldContext_SessionToken_roles(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SocialAccountPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SessionToken", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_socialAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_currentSocialAccounts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_currentAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_currentSocialAccounts, + ec.fieldContext_Query_currentAccount, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().CurrentSocialAccounts(ctx, fc.Args["filter"].(*models.SocialAccountListFilter), fc.Args["order"].(*models.SocialAccountListOrder)) + return ec.Resolvers.Query().CurrentAccount(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.list.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) if err != nil { - var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] + var zeroVal *models.AccountPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] + if ec.Directives.HasPermissions == nil { + var zeroVal *models.AccountPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNSocialAccountConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, true, true, ) } -func (ec *executionContext) fieldContext_Query_currentSocialAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_currentAccount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12631,68 +12647,55 @@ func (ec *executionContext) fieldContext_Query_currentSocialAccounts(ctx context IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "totalCount": - return ec.fieldContext_SocialAccountConnection_totalCount(ctx, field) - case "edges": - return ec.fieldContext_SocialAccountConnection_edges(ctx, field) - case "list": - return ec.fieldContext_SocialAccountConnection_list(ctx, field) - case "pageInfo": - return ec.fieldContext_SocialAccountConnection_pageInfo(ctx, field) + case "clientMutationID": + return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) + case "accountID": + return ec.fieldContext_AccountPayload_accountID(ctx, field) + case "account": + return ec.fieldContext_AccountPayload_account(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SocialAccountConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_currentSocialAccounts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_listSocialAccounts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_account(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_listSocialAccounts, + ec.fieldContext_Query_account, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListSocialAccounts(ctx, fc.Args["filter"].(*models.SocialAccountListFilter), fc.Args["order"].(*models.SocialAccountListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().Account(ctx, fc.Args["id"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.list.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) if err != nil { - var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] + var zeroVal *models.AccountPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] + if ec.Directives.HasPermissions == nil { + var zeroVal *models.AccountPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNSocialAccountConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, true, true, ) } -func (ec *executionContext) fieldContext_Query_listSocialAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_account(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12700,16 +12703,14 @@ func (ec *executionContext) fieldContext_Query_listSocialAccounts(ctx context.Co IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "totalCount": - return ec.fieldContext_SocialAccountConnection_totalCount(ctx, field) - case "edges": - return ec.fieldContext_SocialAccountConnection_edges(ctx, field) - case "list": - return ec.fieldContext_SocialAccountConnection_list(ctx, field) - case "pageInfo": - return ec.fieldContext_SocialAccountConnection_pageInfo(ctx, field) + case "clientMutationID": + return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) + case "accountID": + return ec.fieldContext_AccountPayload_accountID(ctx, field) + case "account": + return ec.fieldContext_AccountPayload_account(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SocialAccountConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) }, } defer func() { @@ -12719,48 +12720,49 @@ func (ec *executionContext) fieldContext_Query_listSocialAccounts(ctx context.Co } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listSocialAccounts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_account_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_currentUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_listAccounts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_currentUser, + ec.fieldContext_Query_listAccounts, func(ctx context.Context) (any, error) { - return ec.resolvers.Query().CurrentUser(ctx) + fc := graphql.GetFieldContext(ctx) + return ec.Resolvers.Query().ListAccounts(ctx, fc.Args["filter"].(*models.AccountListFilter), fc.Args["order"].(*models.AccountListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.view.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.list.*"}) if err != nil { - var zeroVal *models.UserPayload + var zeroVal *connectors.CollectionConnection[models.Account, models.AccountEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.UserPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *connectors.CollectionConnection[models.Account, models.AccountEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, - true, + ec.marshalOAccountConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, true, + false, ) } -func (ec *executionContext) fieldContext_Query_currentUser(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_listAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12768,55 +12770,68 @@ func (ec *executionContext) fieldContext_Query_currentUser(_ context.Context, fi IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "clientMutationID": - return ec.fieldContext_UserPayload_clientMutationID(ctx, field) - case "userID": - return ec.fieldContext_UserPayload_userID(ctx, field) - case "user": - return ec.fieldContext_UserPayload_user(ctx, field) + case "totalCount": + return ec.fieldContext_AccountConnection_totalCount(ctx, field) + case "edges": + return ec.fieldContext_AccountConnection_edges(ctx, field) + case "list": + return ec.fieldContext_AccountConnection_list(ctx, field) + case "pageInfo": + return ec.fieldContext_AccountConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_listAccounts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_listAccountRolesAndPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_user, + ec.fieldContext_Query_listAccountRolesAndPermissions, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().User(ctx, fc.Args["id"].(uint64), fc.Args["username"].(string)) + return ec.Resolvers.Query().ListAccountRolesAndPermissions(ctx, fc.Args["accountID"].(uint64), fc.Args["order"].(*models.RBACRoleListOrder)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.view.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) if err != nil { - var zeroVal *models.UserPayload + var zeroVal *connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.UserPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, - true, + ec.marshalORBACRoleConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, true, + false, ) } -func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_listAccountRolesAndPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12824,14 +12839,16 @@ func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field g IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "clientMutationID": - return ec.fieldContext_UserPayload_clientMutationID(ctx, field) - case "userID": - return ec.fieldContext_UserPayload_userID(ctx, field) - case "user": - return ec.fieldContext_UserPayload_user(ctx, field) + case "totalCount": + return ec.fieldContext_RBACRoleConnection_totalCount(ctx, field) + case "edges": + return ec.fieldContext_RBACRoleConnection_edges(ctx, field) + case "list": + return ec.fieldContext_RBACRoleConnection_list(ctx, field) + case "pageInfo": + return ec.fieldContext_RBACRoleConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type RBACRoleConnection", field.Name) }, } defer func() { @@ -12841,49 +12858,49 @@ func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field g } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_user_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_listAccountRolesAndPermissions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_listUsers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_listMembers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_listUsers, + ec.fieldContext_Query_listMembers, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListUsers(ctx, fc.Args["filter"].(*models.UserListFilter), fc.Args["order"].(*models.UserListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListMembers(ctx, fc.Args["filter"].(*models.MemberListFilter), fc.Args["order"].(*models.MemberListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.list.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.list.*"}) if err != nil { - var zeroVal *connectors.CollectionConnection[models.User, models.UserEdge] + var zeroVal *connectors.CollectionConnection[models.Member, models.MemberEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *connectors.CollectionConnection[models.User, models.UserEdge] - return zeroVal, errors.New("directive hasPermissions is not implemented") + if ec.Directives.Acl == nil { + var zeroVal *connectors.CollectionConnection[models.Member, models.MemberEdge] + return zeroVal, errors.New("directive acl is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.Acl(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalOUserConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + ec.marshalOMemberConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, true, false, ) } -func (ec *executionContext) fieldContext_Query_listUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_listMembers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12892,15 +12909,15 @@ func (ec *executionContext) fieldContext_Query_listUsers(ctx context.Context, fi Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "totalCount": - return ec.fieldContext_UserConnection_totalCount(ctx, field) + return ec.fieldContext_MemberConnection_totalCount(ctx, field) case "edges": - return ec.fieldContext_UserConnection_edges(ctx, field) + return ec.fieldContext_MemberConnection_edges(ctx, field) case "list": - return ec.fieldContext_UserConnection_list(ctx, field) + return ec.fieldContext_MemberConnection_list(ctx, field) case "pageInfo": - return ec.fieldContext_UserConnection_pageInfo(ctx, field) + return ec.fieldContext_MemberConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type MemberConnection", field.Name) }, } defer func() { @@ -12910,7 +12927,7 @@ func (ec *executionContext) fieldContext_Query_listUsers(ctx context.Context, fi } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_listMembers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -12925,7 +12942,7 @@ func (ec *executionContext) _Query_authClient(ctx context.Context, field graphql ec.fieldContext_Query_authClient, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().AuthClient(ctx, fc.Args["id"].(string)) + return ec.Resolvers.Query().AuthClient(ctx, fc.Args["id"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -12936,11 +12953,11 @@ func (ec *executionContext) _Query_authClient(ctx context.Context, field graphql var zeroVal *models.AuthClientPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.AuthClientPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -12992,7 +13009,7 @@ func (ec *executionContext) _Query_listAuthClients(ctx context.Context, field gr ec.fieldContext_Query_listAuthClients, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListAuthClients(ctx, fc.Args["filter"].(*models.AuthClientListFilter), fc.Args["order"].(*models.AuthClientListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListAuthClients(ctx, fc.Args["filter"].(*models.AuthClientListFilter), fc.Args["order"].([]*models.AuthClientListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13003,11 +13020,11 @@ func (ec *executionContext) _Query_listAuthClients(ctx context.Context, field gr var zeroVal *connectors.CollectionConnection[models.AuthClient, models.AuthClientEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *connectors.CollectionConnection[models.AuthClient, models.AuthClientEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13061,7 +13078,7 @@ func (ec *executionContext) _Query_getDirectAccessToken(ctx context.Context, fie ec.fieldContext_Query_getDirectAccessToken, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().GetDirectAccessToken(ctx, fc.Args["id"].(uint64)) + return ec.Resolvers.Query().GetDirectAccessToken(ctx, fc.Args["id"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13072,11 +13089,11 @@ func (ec *executionContext) _Query_getDirectAccessToken(ctx context.Context, fie var zeroVal *models.DirectAccessTokenPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.DirectAccessTokenPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13126,7 +13143,7 @@ func (ec *executionContext) _Query_listDirectAccessTokens(ctx context.Context, f ec.fieldContext_Query_listDirectAccessTokens, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListDirectAccessTokens(ctx, fc.Args["filter"].(*models.DirectAccessTokenListFilter), fc.Args["order"].(*models.DirectAccessTokenListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListDirectAccessTokens(ctx, fc.Args["filter"].(*models.DirectAccessTokenListFilter), fc.Args["order"].(*models.DirectAccessTokenListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13134,20 +13151,20 @@ func (ec *executionContext) _Query_listDirectAccessTokens(ctx context.Context, f directive1 := func(ctx context.Context) (any, error) { permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"directaccesstoken.list.*"}) if err != nil { - var zeroVal *models1.DirectAccessTokenConnection + var zeroVal *connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models1.DirectAccessTokenConnection + if ec.Directives.HasPermissions == nil { + var zeroVal *connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalODirectAccessTokenConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋexampleᚋapiᚋinternalᚋserverᚋgraphqlᚋmodelsᚐDirectAccessTokenConnection, + ec.marshalODirectAccessTokenConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, true, false, ) @@ -13195,7 +13212,7 @@ func (ec *executionContext) _Query_listHistory(ctx context.Context, field graphq ec.fieldContext_Query_listHistory, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListHistory(ctx, fc.Args["filter"].(*models.HistoryActionListFilter), fc.Args["order"].(*models.HistoryActionListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListHistory(ctx, fc.Args["filter"].(*models.HistoryActionListFilter), fc.Args["order"].(*models.HistoryActionListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13206,11 +13223,11 @@ func (ec *executionContext) _Query_listHistory(ctx context.Context, field graphq var zeroVal *connectors.CollectionConnection[models.HistoryAction, models.HistoryActionEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *connectors.CollectionConnection[models.HistoryAction, models.HistoryActionEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13264,7 +13281,7 @@ func (ec *executionContext) _Query_option(ctx context.Context, field graphql.Col ec.fieldContext_Query_option, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Option(ctx, fc.Args["name"].(string), fc.Args["type"].(models.OptionType), fc.Args["targetID"].(uint64)) + return ec.Resolvers.Query().Option(ctx, fc.Args["name"].(string), fc.Args["type"].(models.OptionType), fc.Args["targetID"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13275,11 +13292,11 @@ func (ec *executionContext) _Query_option(ctx context.Context, field graphql.Col var zeroVal *models.OptionPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.OptionPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13331,7 +13348,7 @@ func (ec *executionContext) _Query_listOptions(ctx context.Context, field graphq ec.fieldContext_Query_listOptions, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListOptions(ctx, fc.Args["filter"].(*models.OptionListFilter), fc.Args["order"].(*models.OptionListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListOptions(ctx, fc.Args["filter"].(*models.OptionListFilter), fc.Args["order"].(*models.OptionListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13342,11 +13359,11 @@ func (ec *executionContext) _Query_listOptions(ctx context.Context, field graphq var zeroVal *connectors.CollectionConnection[models.Option, models.OptionEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *connectors.CollectionConnection[models.Option, models.OptionEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13400,7 +13417,7 @@ func (ec *executionContext) _Query_role(ctx context.Context, field graphql.Colle ec.fieldContext_Query_role, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Role(ctx, fc.Args["id"].(uint64)) + return ec.Resolvers.Query().Role(ctx, fc.Args["id"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13411,11 +13428,11 @@ func (ec *executionContext) _Query_role(ctx context.Context, field graphql.Colle var zeroVal *models.RBACRolePayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.RBACRolePayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13467,7 +13484,7 @@ func (ec *executionContext) _Query_checkPermission(ctx context.Context, field gr ec.fieldContext_Query_checkPermission, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().CheckPermission(ctx, fc.Args["name"].(string), fc.Args["key"].(*string), fc.Args["targetID"].(*string), fc.Args["idKey"].(*string)) + return ec.Resolvers.Query().CheckPermission(ctx, fc.Args["name"].(string), fc.Args["key"].(*string), fc.Args["targetID"].(*string), fc.Args["idKey"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13478,11 +13495,11 @@ func (ec *executionContext) _Query_checkPermission(ctx context.Context, field gr var zeroVal *string return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *string return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13526,7 +13543,7 @@ func (ec *executionContext) _Query_listRoles(ctx context.Context, field graphql. ec.fieldContext_Query_listRoles, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListRoles(ctx, fc.Args["filter"].(*models.RBACRoleListFilter), fc.Args["order"].(*models.RBACRoleListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListRoles(ctx, fc.Args["filter"].(*models.RBACRoleListFilter), fc.Args["order"].(*models.RBACRoleListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13537,11 +13554,11 @@ func (ec *executionContext) _Query_listRoles(ctx context.Context, field graphql. var zeroVal *connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13561,16 +13578,225 @@ func (ec *executionContext) fieldContext_Query_listRoles(ctx context.Context, fi IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "totalCount": - return ec.fieldContext_RBACRoleConnection_totalCount(ctx, field) - case "edges": - return ec.fieldContext_RBACRoleConnection_edges(ctx, field) - case "list": - return ec.fieldContext_RBACRoleConnection_list(ctx, field) - case "pageInfo": - return ec.fieldContext_RBACRoleConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_RBACRoleConnection_totalCount(ctx, field) + case "edges": + return ec.fieldContext_RBACRoleConnection_edges(ctx, field) + case "list": + return ec.fieldContext_RBACRoleConnection_list(ctx, field) + case "pageInfo": + return ec.fieldContext_RBACRoleConnection_pageInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RBACRoleConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_listRoles_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_listPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Query_listPermissions, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.Resolvers.Query().ListPermissions(ctx, fc.Args["patterns"].([]string)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"permission.list"}) + if err != nil { + var zeroVal []*models.RBACPermission + return zeroVal, err + } + if ec.Directives.HasPermissions == nil { + var zeroVal []*models.RBACPermission + return zeroVal, errors.New("directive hasPermissions is not implemented") + } + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) + } + + next = directive1 + return ec._fieldMiddleware(ctx, nil, next) + }, + ec.marshalORBACPermission2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACPermissionᚄ, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Query_listPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_RBACPermission_name(ctx, field) + case "object": + return ec.fieldContext_RBACPermission_object(ctx, field) + case "access": + return ec.fieldContext_RBACPermission_access(ctx, field) + case "fullname": + return ec.fieldContext_RBACPermission_fullname(ctx, field) + case "description": + return ec.fieldContext_RBACPermission_description(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RBACPermission", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_listPermissions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_listMyPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Query_listMyPermissions, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.Resolvers.Query().ListMyPermissions(ctx, fc.Args["patterns"].([]string)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"permission.list"}) + if err != nil { + var zeroVal []*models.RBACPermission + return zeroVal, err + } + if ec.Directives.HasPermissions == nil { + var zeroVal []*models.RBACPermission + return zeroVal, errors.New("directive hasPermissions is not implemented") + } + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) + } + + next = directive1 + return ec._fieldMiddleware(ctx, nil, next) + }, + ec.marshalORBACPermission2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACPermissionᚄ, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Query_listMyPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_RBACPermission_name(ctx, field) + case "object": + return ec.fieldContext_RBACPermission_object(ctx, field) + case "access": + return ec.fieldContext_RBACPermission_access(ctx, field) + case "fullname": + return ec.fieldContext_RBACPermission_fullname(ctx, field) + case "description": + return ec.fieldContext_RBACPermission_description(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RBACPermission", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_listMyPermissions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_socialAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Query_socialAccount, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.Resolvers.Query().SocialAccount(ctx, fc.Args["id"].(uint64)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.view.*"}) + if err != nil { + var zeroVal *models.SocialAccountPayload + return zeroVal, err + } + if ec.Directives.HasPermissions == nil { + var zeroVal *models.SocialAccountPayload + return zeroVal, errors.New("directive hasPermissions is not implemented") + } + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) + } + + next = directive1 + return ec._fieldMiddleware(ctx, nil, next) + }, + ec.marshalNSocialAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountPayload, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Query_socialAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "clientMutationID": + return ec.fieldContext_SocialAccountPayload_clientMutationID(ctx, field) + case "socialAccountID": + return ec.fieldContext_SocialAccountPayload_socialAccountID(ctx, field) + case "socialAccount": + return ec.fieldContext_SocialAccountPayload_socialAccount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type RBACRoleConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SocialAccountPayload", field.Name) }, } defer func() { @@ -13580,49 +13806,49 @@ func (ec *executionContext) fieldContext_Query_listRoles(ctx context.Context, fi } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listRoles_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_socialAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_listPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_currentSocialAccounts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_listPermissions, + ec.fieldContext_Query_currentSocialAccounts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListPermissions(ctx, fc.Args["patterns"].([]string)) + return ec.Resolvers.Query().CurrentSocialAccounts(ctx, fc.Args["filter"].(*models.SocialAccountListFilter), fc.Args["order"].(*models.SocialAccountListOrder)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"permission.list"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.list.*"}) if err != nil { - var zeroVal []*models.RBACPermission + var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal []*models.RBACPermission + if ec.Directives.HasPermissions == nil { + var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalORBACPermission2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACPermissionᚄ, + ec.marshalNSocialAccountConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Query_listPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_currentSocialAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -13630,18 +13856,16 @@ func (ec *executionContext) fieldContext_Query_listPermissions(ctx context.Conte IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "name": - return ec.fieldContext_RBACPermission_name(ctx, field) - case "object": - return ec.fieldContext_RBACPermission_object(ctx, field) - case "access": - return ec.fieldContext_RBACPermission_access(ctx, field) - case "fullname": - return ec.fieldContext_RBACPermission_fullname(ctx, field) - case "description": - return ec.fieldContext_RBACPermission_description(ctx, field) + case "totalCount": + return ec.fieldContext_SocialAccountConnection_totalCount(ctx, field) + case "edges": + return ec.fieldContext_SocialAccountConnection_edges(ctx, field) + case "list": + return ec.fieldContext_SocialAccountConnection_list(ctx, field) + case "pageInfo": + return ec.fieldContext_SocialAccountConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type RBACPermission", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SocialAccountConnection", field.Name) }, } defer func() { @@ -13651,49 +13875,49 @@ func (ec *executionContext) fieldContext_Query_listPermissions(ctx context.Conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listPermissions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_currentSocialAccounts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_listMyPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_listSocialAccounts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_listMyPermissions, + ec.fieldContext_Query_listSocialAccounts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListMyPermissions(ctx, fc.Args["patterns"].([]string)) + return ec.Resolvers.Query().ListSocialAccounts(ctx, fc.Args["filter"].(*models.SocialAccountListFilter), fc.Args["order"].(*models.SocialAccountListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"permission.list"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.list.*"}) if err != nil { - var zeroVal []*models.RBACPermission + var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal []*models.RBACPermission + if ec.Directives.HasPermissions == nil { + var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalORBACPermission2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACPermissionᚄ, + ec.marshalNSocialAccountConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Query_listMyPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_listSocialAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -13701,18 +13925,16 @@ func (ec *executionContext) fieldContext_Query_listMyPermissions(ctx context.Con IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "name": - return ec.fieldContext_RBACPermission_name(ctx, field) - case "object": - return ec.fieldContext_RBACPermission_object(ctx, field) - case "access": - return ec.fieldContext_RBACPermission_access(ctx, field) - case "fullname": - return ec.fieldContext_RBACPermission_fullname(ctx, field) - case "description": - return ec.fieldContext_RBACPermission_description(ctx, field) + case "totalCount": + return ec.fieldContext_SocialAccountConnection_totalCount(ctx, field) + case "edges": + return ec.fieldContext_SocialAccountConnection_edges(ctx, field) + case "list": + return ec.fieldContext_SocialAccountConnection_list(ctx, field) + case "pageInfo": + return ec.fieldContext_SocialAccountConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type RBACPermission", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SocialAccountConnection", field.Name) }, } defer func() { @@ -13722,7 +13944,7 @@ func (ec *executionContext) fieldContext_Query_listMyPermissions(ctx context.Con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listMyPermissions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_listSocialAccounts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -13737,7 +13959,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col ec.fieldContext_Query___type, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.introspectType(fc.Args["name"].(string)) + return ec.IntrospectType(fc.Args["name"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) @@ -13803,7 +14025,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C field, ec.fieldContext_Query___schema, func(ctx context.Context) (any, error) { - return ec.introspectSchema() + return ec.IntrospectSchema() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) @@ -18201,145 +18423,472 @@ func (ec *executionContext) fieldContext___Type_isOneOf(_ context.Context, field return nil, errors.New("field of type Boolean does not have child fields") }, } - return fc, nil + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputAccountCreateInput(ctx context.Context, obj any) (models.AccountCreateInput, error) { + var it models.AccountCreateInput + if obj == nil { + return it, nil + } + + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"ownerID", "owner", "account", "password"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "ownerID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerID")) + data, err := ec.unmarshalOID642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.OwnerID = data + case "owner": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("owner")) + data, err := ec.unmarshalOUserInput2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserInput(ctx, v) + if err != nil { + return it, err + } + it.Owner = data + case "account": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("account")) + data, err := ec.unmarshalNAccountInput2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountInput(ctx, v) + if err != nil { + return it, err + } + it.Account = data + case "password": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Password = data + } + } + return it, nil +} + +func (ec *executionContext) unmarshalInputAccountInput(ctx context.Context, obj any) (models.AccountInput, error) { + var it models.AccountInput + if obj == nil { + return it, nil + } + + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"status", "title", "description", "logoURI", "policyURI", "termsOfServiceURI", "clientURI", "contacts"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "status": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) + data, err := ec.unmarshalOApproveStatus2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐApproveStatus(ctx, v) + if err != nil { + return it, err + } + it.Status = data + case "title": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Title = data + case "description": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Description = data + case "logoURI": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("logoURI")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.LogoURI = data + case "policyURI": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("policyURI")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PolicyURI = data + case "termsOfServiceURI": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("termsOfServiceURI")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TermsOfServiceURI = data + case "clientURI": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clientURI")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ClientURI = data + case "contacts": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("contacts")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Contacts = data + } + } + return it, nil +} + +func (ec *executionContext) unmarshalInputAccountListFilter(ctx context.Context, obj any) (models.AccountListFilter, error) { + var it models.AccountListFilter + if obj == nil { + return it, nil + } + + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"ID", "UserID", "title", "status"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "ID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ID")) + data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "UserID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("UserID")) + data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) + if err != nil { + return it, err + } + it.UserID = data + case "title": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Title = data + case "status": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) + data, err := ec.unmarshalOApproveStatus2ᚕgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐApproveStatusᚄ(ctx, v) + if err != nil { + return it, err + } + it.Status = data + } + } + return it, nil } -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** +func (ec *executionContext) unmarshalInputAccountListOrder(ctx context.Context, obj any) (models.AccountListOrder, error) { + var it models.AccountListOrder + if obj == nil { + return it, nil + } -func (ec *executionContext) unmarshalInputAccountCreateInput(ctx context.Context, obj any) (models.AccountCreateInput, error) { - var it models.AccountCreateInput asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } - fieldsInOrder := [...]string{"ownerID", "owner", "account", "password"} + fieldsInOrder := [...]string{"ID", "title", "status"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "ownerID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerID")) - data, err := ec.unmarshalOID642ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.OwnerID = data - case "owner": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("owner")) - data, err := ec.unmarshalOUserInput2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserInput(ctx, v) + case "ID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ID")) + data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) if err != nil { return it, err } - it.Owner = data - case "account": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("account")) - data, err := ec.unmarshalNAccountInput2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountInput(ctx, v) + it.ID = data + case "title": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) + data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) if err != nil { return it, err } - it.Account = data - case "password": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) - data, err := ec.unmarshalNString2string(ctx, v) + it.Title = data + case "status": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) + data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) if err != nil { return it, err } - it.Password = data + it.Status = data } } - return it, nil } -func (ec *executionContext) unmarshalInputAccountInput(ctx context.Context, obj any) (models.AccountInput, error) { - var it models.AccountInput +func (ec *executionContext) unmarshalInputAuthClientCreateInput(ctx context.Context, obj any) (models.AuthClientCreateInput, error) { + var it models.AuthClientCreateInput + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } - fieldsInOrder := [...]string{"status", "title", "description", "logoURI", "policyURI", "termsOfServiceURI", "clientURI", "contacts"} + fieldsInOrder := [...]string{"accountID", "userID", "title", "secret", "redirectURIs", "grantTypes", "responseTypes", "scope", "audience", "subjectType", "allowedCORSOrigins", "public", "expiresAt"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "status": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - data, err := ec.unmarshalOApproveStatus2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐApproveStatus(ctx, v) + case "accountID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountID")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOID642ᚖuint64(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *uint64 + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*uint64); ok { + it.AccountID = data + } else if tmp == nil { + it.AccountID = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *uint64`, tmp) + return it, graphql.ErrorOnPath(ctx, err) + } + case "userID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOID642ᚖuint64(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *uint64 + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) + if err != nil { + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*uint64); ok { + it.UserID = data + } else if tmp == nil { + it.UserID = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *uint64`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.Status = data case "title": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) + if err != nil { + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*string); ok { + it.Title = data + } else if tmp == nil { + it.Title = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) + } + case "secret": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secret")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) + if err != nil { + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*string); ok { + it.Secret = data + } else if tmp == nil { + it.Secret = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) + } + case "redirectURIs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("redirectURIs")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Title = data - case "description": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.RedirectURIs = data + case "grantTypes": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("grantTypes")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Description = data - case "logoURI": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("logoURI")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.GrantTypes = data + case "responseTypes": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("responseTypes")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.LogoURI = data - case "policyURI": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("policyURI")) + it.ResponseTypes = data + case "scope": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("scope")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PolicyURI = data - case "termsOfServiceURI": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("termsOfServiceURI")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.Scope = data + case "audience": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("audience")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.TermsOfServiceURI = data - case "clientURI": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clientURI")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.Audience = data + case "subjectType": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subjectType")) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - it.ClientURI = data - case "contacts": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("contacts")) + it.SubjectType = data + case "allowedCORSOrigins": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("allowedCORSOrigins")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Contacts = data + it.AllowedCORSOrigins = data + case "public": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.Public = data + case "expiresAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("expiresAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.ExpiresAt = data } } - return it, nil } -func (ec *executionContext) unmarshalInputAccountListFilter(ctx context.Context, obj any) (models.AccountListFilter, error) { - var it models.AccountListFilter +func (ec *executionContext) unmarshalInputAuthClientListFilter(ctx context.Context, obj any) (models.AuthClientListFilter, error) { + var it models.AuthClientListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } - fieldsInOrder := [...]string{"ID", "UserID", "title", "status"} + fieldsInOrder := [...]string{"ID", "userID", "accountID", "public"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -18348,46 +18897,49 @@ func (ec *executionContext) unmarshalInputAccountListFilter(ctx context.Context, switch k { case "ID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ID")) - data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } it.ID = data - case "UserID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("UserID")) + case "userID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } it.UserID = data - case "title": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + case "accountID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountID")) + data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.Title = data - case "status": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - data, err := ec.unmarshalOApproveStatus2ᚕgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐApproveStatusᚄ(ctx, v) + it.AccountID = data + case "public": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.Status = data + it.Public = data } } - return it, nil } -func (ec *executionContext) unmarshalInputAccountListOrder(ctx context.Context, obj any) (models.AccountListOrder, error) { - var it models.AccountListOrder +func (ec *executionContext) unmarshalInputAuthClientListOrder(ctx context.Context, obj any) (models.AuthClientListOrder, error) { + var it models.AuthClientListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } - fieldsInOrder := [...]string{"ID", "title", "status"} + fieldsInOrder := [...]string{"ID", "userID", "accountID", "title", "public", "lastUpdate"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -18400,7 +18952,21 @@ func (ec *executionContext) unmarshalInputAccountListOrder(ctx context.Context, if err != nil { return it, err } - it.ID = data + it.ID = data + case "userID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) + data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + if err != nil { + return it, err + } + it.UserID = data + case "accountID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountID")) + data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + if err != nil { + return it, err + } + it.AccountID = data case "title": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) @@ -18408,21 +18974,31 @@ func (ec *executionContext) unmarshalInputAccountListOrder(ctx context.Context, return it, err } it.Title = data - case "status": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) + case "public": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) if err != nil { return it, err } - it.Status = data + it.Public = data + case "lastUpdate": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastUpdate")) + data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + if err != nil { + return it, err + } + it.LastUpdate = data } } - return it, nil } -func (ec *executionContext) unmarshalInputAuthClientInput(ctx context.Context, obj any) (models.AuthClientInput, error) { - var it models.AuthClientInput +func (ec *executionContext) unmarshalInputAuthClientUpdateInput(ctx context.Context, obj any) (models.AuthClientUpdateInput, error) { + var it models.AuthClientUpdateInput + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -18437,213 +19013,430 @@ func (ec *executionContext) unmarshalInputAuthClientInput(ctx context.Context, o switch k { case "accountID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountID")) - data, err := ec.unmarshalOID642ᚖuint64(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOID642ᚖuint64(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *uint64 + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*uint64); ok { + it.AccountID = data + } else if tmp == nil { + it.AccountID = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *uint64`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.AccountID = data case "userID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) - data, err := ec.unmarshalOID642ᚖuint64(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOID642ᚖuint64(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *uint64 + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*uint64); ok { + it.UserID = data + } else if tmp == nil { + it.UserID = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *uint64`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.UserID = data case "title": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*string); ok { + it.Title = data + } else if tmp == nil { + it.Title = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.Title = data case "secret": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secret")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*string); ok { + it.Secret = data + } else if tmp == nil { + it.Secret = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.Secret = data case "redirectURIs": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("redirectURIs")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚕstringᚄ(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal []string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal []string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal []string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.([]string); ok { + it.RedirectURIs = data + } else if tmp == nil { + it.RedirectURIs = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be []string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.RedirectURIs = data case "grantTypes": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("grantTypes")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚕstringᚄ(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal []string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal []string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal []string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.([]string); ok { + it.GrantTypes = data + } else if tmp == nil { + it.GrantTypes = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be []string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.GrantTypes = data case "responseTypes": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("responseTypes")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.ResponseTypes = data - case "scope": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("scope")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚕstringᚄ(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal []string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal []string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal []string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) } - it.Scope = data - case "audience": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("audience")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) } - it.Audience = data - case "subjectType": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subjectType")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err + if data, ok := tmp.([]string); ok { + it.ResponseTypes = data + } else if tmp == nil { + it.ResponseTypes = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be []string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.SubjectType = data - case "allowedCORSOrigins": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("allowedCORSOrigins")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err + case "scope": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("scope")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) } - it.AllowedCORSOrigins = data - case "public": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) } - it.Public = data - case "expiresAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("expiresAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err + if data, ok := tmp.(*string); ok { + it.Scope = data + } else if tmp == nil { + it.Scope = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.ExpiresAt = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputAuthClientListFilter(ctx context.Context, obj any) (models.AuthClientListFilter, error) { - var it models.AuthClientListFilter - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } + case "audience": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("audience")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚕstringᚄ(ctx, v) } - fieldsInOrder := [...]string{"ID", "userID", "accountID", "public"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "ID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ID")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal []string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal []string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal []string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) } - it.ID = data - case "userID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) - data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) } - it.UserID = data - case "accountID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountID")) - data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err + if data, ok := tmp.([]string); ok { + it.Audience = data + } else if tmp == nil { + it.Audience = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be []string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.AccountID = data - case "public": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err + case "subjectType": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subjectType")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) } - it.Public = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputAuthClientListOrder(ctx context.Context, obj any) (models.AuthClientListOrder, error) { - var it models.AuthClientListOrder - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } - fieldsInOrder := [...]string{"ID", "userID", "accountID", "title", "public", "lastUpdate"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "ID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ID")) - data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) } - it.ID = data - case "userID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) - data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) - if err != nil { - return it, err + if data, ok := tmp.(*string); ok { + it.SubjectType = data + } else if tmp == nil { + it.SubjectType = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.UserID = data - case "accountID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountID")) - data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) - if err != nil { - return it, err + case "allowedCORSOrigins": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("allowedCORSOrigins")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚕstringᚄ(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal []string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal []string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal []string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) } - it.AccountID = data - case "title": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) - data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.([]string); ok { + it.AllowedCORSOrigins = data + } else if tmp == nil { + it.AllowedCORSOrigins = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be []string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.Title = data case "public": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) - data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } it.Public = data - case "lastUpdate": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastUpdate")) - data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + case "expiresAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("expiresAt")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *time.Time + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *time.Time + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *time.Time + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*time.Time); ok { + it.ExpiresAt = data + } else if tmp == nil { + it.ExpiresAt = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *time.Time`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.LastUpdate = data } } - return it, nil } func (ec *executionContext) unmarshalInputDirectAccessTokenListFilter(ctx context.Context, obj any) (models.DirectAccessTokenListFilter, error) { var it models.DirectAccessTokenListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -18700,12 +19493,15 @@ func (ec *executionContext) unmarshalInputDirectAccessTokenListFilter(ctx contex it.MaxExpiresAt = data } } - return it, nil } func (ec *executionContext) unmarshalInputDirectAccessTokenListOrder(ctx context.Context, obj any) (models.DirectAccessTokenListOrder, error) { var it models.DirectAccessTokenListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -18762,12 +19558,15 @@ func (ec *executionContext) unmarshalInputDirectAccessTokenListOrder(ctx context it.ExpiresAt = data } } - return it, nil } func (ec *executionContext) unmarshalInputHistoryActionListFilter(ctx context.Context, obj any) (models.HistoryActionListFilter, error) { var it models.HistoryActionListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -18838,12 +19637,15 @@ func (ec *executionContext) unmarshalInputHistoryActionListFilter(ctx context.Co it.ObjectIDs = data } } - return it, nil } func (ec *executionContext) unmarshalInputHistoryActionListOrder(ctx context.Context, obj any) (models.HistoryActionListOrder, error) { var it models.HistoryActionListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -18921,12 +19723,15 @@ func (ec *executionContext) unmarshalInputHistoryActionListOrder(ctx context.Con it.ActionAt = data } } - return it, nil } func (ec *executionContext) unmarshalInputInviteMemberInput(ctx context.Context, obj any) (models.InviteMemberInput, error) { var it models.InviteMemberInput + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -18966,12 +19771,15 @@ func (ec *executionContext) unmarshalInputInviteMemberInput(ctx context.Context, it.IsAdmin = data } } - return it, nil } func (ec *executionContext) unmarshalInputMemberInput(ctx context.Context, obj any) (models.MemberInput, error) { var it models.MemberInput + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19004,12 +19812,15 @@ func (ec *executionContext) unmarshalInputMemberInput(ctx context.Context, obj a it.IsAdmin = data } } - return it, nil } func (ec *executionContext) unmarshalInputMemberListFilter(ctx context.Context, obj any) (models.MemberListFilter, error) { var it models.MemberListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19059,12 +19870,15 @@ func (ec *executionContext) unmarshalInputMemberListFilter(ctx context.Context, it.IsAdmin = data } } - return it, nil } func (ec *executionContext) unmarshalInputMemberListOrder(ctx context.Context, obj any) (models.MemberListOrder, error) { var it models.MemberListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19128,12 +19942,15 @@ func (ec *executionContext) unmarshalInputMemberListOrder(ctx context.Context, o it.UpdatedAt = data } } - return it, nil } func (ec *executionContext) unmarshalInputOptionListFilter(ctx context.Context, obj any) (models.OptionListFilter, error) { var it models.OptionListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19176,12 +19993,15 @@ func (ec *executionContext) unmarshalInputOptionListFilter(ctx context.Context, it.NamePattern = data } } - return it, nil } func (ec *executionContext) unmarshalInputOptionListOrder(ctx context.Context, obj any) (models.OptionListOrder, error) { var it models.OptionListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19224,12 +20044,15 @@ func (ec *executionContext) unmarshalInputOptionListOrder(ctx context.Context, o it.Value = data } } - return it, nil } func (ec *executionContext) unmarshalInputPage(ctx context.Context, obj any) (models.Page, error) { var it models.Page + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19272,12 +20095,15 @@ func (ec *executionContext) unmarshalInputPage(ctx context.Context, obj any) (mo it.Size = data } } - return it, nil } func (ec *executionContext) unmarshalInputRBACRoleInput(ctx context.Context, obj any) (models.RBACRoleInput, error) { var it models.RBACRoleInput + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19320,12 +20146,15 @@ func (ec *executionContext) unmarshalInputRBACRoleInput(ctx context.Context, obj it.Permissions = data } } - return it, nil } func (ec *executionContext) unmarshalInputRBACRoleListFilter(ctx context.Context, obj any) (models.RBACRoleListFilter, error) { var it models.RBACRoleListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19354,12 +20183,15 @@ func (ec *executionContext) unmarshalInputRBACRoleListFilter(ctx context.Context it.Name = data } } - return it, nil } func (ec *executionContext) unmarshalInputRBACRoleListOrder(ctx context.Context, obj any) (models.RBACRoleListOrder, error) { var it models.RBACRoleListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19395,12 +20227,15 @@ func (ec *executionContext) unmarshalInputRBACRoleListOrder(ctx context.Context, it.Title = data } } - return it, nil } func (ec *executionContext) unmarshalInputSocialAccountListFilter(ctx context.Context, obj any) (models.SocialAccountListFilter, error) { var it models.SocialAccountListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19450,12 +20285,15 @@ func (ec *executionContext) unmarshalInputSocialAccountListFilter(ctx context.Co it.Email = data } } - return it, nil } func (ec *executionContext) unmarshalInputSocialAccountListOrder(ctx context.Context, obj any) (models.SocialAccountListOrder, error) { var it models.SocialAccountListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19519,12 +20357,15 @@ func (ec *executionContext) unmarshalInputSocialAccountListOrder(ctx context.Con it.LastName = data } } - return it, nil } func (ec *executionContext) unmarshalInputUserInput(ctx context.Context, obj any) (models.UserInput, error) { var it models.UserInput + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19553,12 +20394,15 @@ func (ec *executionContext) unmarshalInputUserInput(ctx context.Context, obj any it.Status = data } } - return it, nil } func (ec *executionContext) unmarshalInputUserListFilter(ctx context.Context, obj any) (models.UserListFilter, error) { var it models.UserListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19601,12 +20445,15 @@ func (ec *executionContext) unmarshalInputUserListFilter(ctx context.Context, ob it.Roles = data } } - return it, nil } func (ec *executionContext) unmarshalInputUserListOrder(ctx context.Context, obj any) (models.UserListOrder, error) { var it models.UserListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19684,7 +20531,6 @@ func (ec *executionContext) unmarshalInputUserListOrder(ctx context.Context, obj it.UpdatedAt = data } } - return it, nil } @@ -19770,10 +20616,10 @@ func (ec *executionContext) _Account(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -19818,10 +20664,10 @@ func (ec *executionContext) _AccountConnection(ctx context.Context, sel ast.Sele return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -19867,10 +20713,10 @@ func (ec *executionContext) _AccountCreatePayload(ctx context.Context, sel ast.S return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -19908,10 +20754,10 @@ func (ec *executionContext) _AccountEdge(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -19954,10 +20800,10 @@ func (ec *executionContext) _AccountPayload(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20055,10 +20901,10 @@ func (ec *executionContext) _AuthClient(ctx context.Context, sel ast.SelectionSe return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20103,10 +20949,10 @@ func (ec *executionContext) _AuthClientConnection(ctx context.Context, sel ast.S return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20144,10 +20990,10 @@ func (ec *executionContext) _AuthClientEdge(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20190,10 +21036,10 @@ func (ec *executionContext) _AuthClientPayload(ctx context.Context, sel ast.Sele return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20256,10 +21102,10 @@ func (ec *executionContext) _DirectAccessToken(ctx context.Context, sel ast.Sele return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20272,7 +21118,7 @@ func (ec *executionContext) _DirectAccessToken(ctx context.Context, sel ast.Sele var directAccessTokenConnectionImplementors = []string{"DirectAccessTokenConnection"} -func (ec *executionContext) _DirectAccessTokenConnection(ctx context.Context, sel ast.SelectionSet, obj *models1.DirectAccessTokenConnection) graphql.Marshaler { +func (ec *executionContext) _DirectAccessTokenConnection(ctx context.Context, sel ast.SelectionSet, obj *connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge]) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, directAccessTokenConnectionImplementors) out := graphql.NewFieldSet(fields) @@ -20304,10 +21150,10 @@ func (ec *executionContext) _DirectAccessTokenConnection(ctx context.Context, se return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20345,10 +21191,10 @@ func (ec *executionContext) _DirectAccessTokenEdge(ctx context.Context, sel ast. return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20386,10 +21232,10 @@ func (ec *executionContext) _DirectAccessTokenPayload(ctx context.Context, sel a return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20475,10 +21321,10 @@ func (ec *executionContext) _HistoryAction(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20523,10 +21369,10 @@ func (ec *executionContext) _HistoryActionConnection(ctx context.Context, sel as return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20567,10 +21413,10 @@ func (ec *executionContext) _HistoryActionEdge(ctx context.Context, sel ast.Sele return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20613,10 +21459,10 @@ func (ec *executionContext) _HistoryActionPayload(ctx context.Context, sel ast.S return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20686,10 +21532,10 @@ func (ec *executionContext) _Member(ctx context.Context, sel ast.SelectionSet, o return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20734,10 +21580,10 @@ func (ec *executionContext) _MemberConnection(ctx context.Context, sel ast.Selec return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20775,10 +21621,10 @@ func (ec *executionContext) _MemberEdge(ctx context.Context, sel ast.SelectionSe return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20821,10 +21667,10 @@ func (ec *executionContext) _MemberPayload(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20861,135 +21707,128 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } - case "login": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_login(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "logout": + case "createUser": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_logout(ctx, field) + return ec._Mutation_createUser(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "switchAccount": + case "updateUser": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_switchAccount(ctx, field) + return ec._Mutation_updateUser(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "registerAccount": + case "approveUser": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_registerAccount(ctx, field) + return ec._Mutation_approveUser(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "updateAccount": + case "rejectUser": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateAccount(ctx, field) + return ec._Mutation_rejectUser(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "approveAccount": + case "resetUserPassword": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_approveAccount(ctx, field) + return ec._Mutation_resetUserPassword(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "rejectAccount": + case "updateUserPassword": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_rejectAccount(ctx, field) + return ec._Mutation_updateUserPassword(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "inviteAccountMember": + case "login": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_inviteAccountMember(ctx, field) + return ec._Mutation_login(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "updateAccountMember": + case "logout": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateAccountMember(ctx, field) + return ec._Mutation_logout(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "removeAccountMember": + case "switchAccount": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_removeAccountMember(ctx, field) + return ec._Mutation_switchAccount(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "approveAccountMember": + case "registerAccount": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_approveAccountMember(ctx, field) + return ec._Mutation_registerAccount(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "rejectAccountMember": + case "updateAccount": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_rejectAccountMember(ctx, field) + return ec._Mutation_updateAccount(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "disconnectSocialAccount": + case "approveAccount": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_disconnectSocialAccount(ctx, field) + return ec._Mutation_approveAccount(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "createUser": + case "rejectAccount": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_createUser(ctx, field) + return ec._Mutation_rejectAccount(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "updateUser": + case "inviteAccountMember": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateUser(ctx, field) + return ec._Mutation_inviteAccountMember(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "approveUser": + case "updateAccountMember": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_approveUser(ctx, field) + return ec._Mutation_updateAccountMember(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "rejectUser": + case "removeAccountMember": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_rejectUser(ctx, field) + return ec._Mutation_removeAccountMember(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "resetUserPassword": + case "approveAccountMember": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_resetUserPassword(ctx, field) + return ec._Mutation_approveAccountMember(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "updateUserPassword": + case "rejectAccountMember": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateUserPassword(ctx, field) + return ec._Mutation_rejectAccountMember(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ @@ -21051,6 +21890,13 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } + case "disconnectSocialAccount": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_disconnectSocialAccount(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -21060,10 +21906,10 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21111,10 +21957,10 @@ func (ec *executionContext) _Option(ctx context.Context, sel ast.SelectionSet, o return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21165,10 +22011,10 @@ func (ec *executionContext) _OptionConnection(ctx context.Context, sel ast.Selec return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21209,10 +22055,10 @@ func (ec *executionContext) _OptionEdge(ctx context.Context, sel ast.SelectionSe return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21255,10 +22101,10 @@ func (ec *executionContext) _OptionPayload(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21324,10 +22170,10 @@ func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21405,10 +22251,10 @@ func (ec *executionContext) _Profile(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21449,10 +22295,10 @@ func (ec *executionContext) _ProfileMessanger(ctx context.Context, sel ast.Selec return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21469,42 +22315,20 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", - }) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "serviceVersion": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_serviceVersion(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } + }) - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "currentSession": + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ + Object: field.Name, + Field: field, + }) + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "serviceVersion": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -21513,7 +22337,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_currentSession(ctx, field) + res = ec._Query_serviceVersion(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -21526,7 +22350,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "currentAccount": + case "currentUser": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -21535,7 +22359,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_currentAccount(ctx, field) + res = ec._Query_currentUser(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -21548,7 +22372,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "account": + case "user": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -21557,7 +22381,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_account(ctx, field) + res = ec._Query_user(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -21570,45 +22394,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "listAccounts": - field := field - - innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_listAccounts(ctx, field) - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "listAccountRolesAndPermissions": - field := field - - innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_listAccountRolesAndPermissions(ctx, field) - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "listMembers": + case "listUsers": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { @@ -21617,7 +22403,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_listMembers(ctx, field) + res = ec._Query_listUsers(ctx, field) return res } @@ -21627,7 +22413,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "socialAccount": + case "currentSession": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -21636,7 +22422,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_socialAccount(ctx, field) + res = ec._Query_currentSession(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -21649,7 +22435,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "currentSocialAccounts": + case "currentAccount": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -21658,7 +22444,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_currentSocialAccounts(ctx, field) + res = ec._Query_currentAccount(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -21671,7 +22457,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "listSocialAccounts": + case "account": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -21680,7 +22466,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_listSocialAccounts(ctx, field) + res = ec._Query_account(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -21693,19 +22479,16 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "currentUser": + case "listAccounts": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_currentUser(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_listAccounts(ctx, field) return res } @@ -21715,19 +22498,16 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "user": + case "listAccountRolesAndPermissions": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_user(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_listAccountRolesAndPermissions(ctx, field) return res } @@ -21737,7 +22517,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "listUsers": + case "listMembers": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { @@ -21746,7 +22526,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_listUsers(ctx, field) + res = ec._Query_listMembers(ctx, field) return res } @@ -21992,6 +22772,72 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "socialAccount": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_socialAccount(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "currentSocialAccounts": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_currentSocialAccounts(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "listSocialAccounts": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_listSocialAccounts(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { @@ -22010,10 +22856,10 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22066,10 +22912,10 @@ func (ec *executionContext) _RBACPermission(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22137,10 +22983,10 @@ func (ec *executionContext) _RBACRole(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22185,10 +23031,10 @@ func (ec *executionContext) _RBACRoleConnection(ctx context.Context, sel ast.Sel return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22226,10 +23072,10 @@ func (ec *executionContext) _RBACRoleEdge(ctx context.Context, sel ast.Selection return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22272,10 +23118,10 @@ func (ec *executionContext) _RBACRolePayload(ctx context.Context, sel ast.Select return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22323,10 +23169,10 @@ func (ec *executionContext) _SessionToken(ctx context.Context, sel ast.Selection return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22426,10 +23272,10 @@ func (ec *executionContext) _SocialAccount(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22474,10 +23320,10 @@ func (ec *executionContext) _SocialAccountConnection(ctx context.Context, sel as return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22515,10 +23361,10 @@ func (ec *executionContext) _SocialAccountEdge(ctx context.Context, sel ast.Sele return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22561,10 +23407,10 @@ func (ec *executionContext) _SocialAccountPayload(ctx context.Context, sel ast.S return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22636,10 +23482,10 @@ func (ec *executionContext) _SocialAccountSession(ctx context.Context, sel ast.S return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22682,10 +23528,10 @@ func (ec *executionContext) _StatusResponse(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22743,10 +23589,10 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22791,10 +23637,10 @@ func (ec *executionContext) _UserConnection(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22832,10 +23678,10 @@ func (ec *executionContext) _UserEdge(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22878,10 +23724,10 @@ func (ec *executionContext) _UserPayload(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22934,10 +23780,10 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22982,10 +23828,10 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -23040,10 +23886,10 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -23095,10 +23941,10 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -23150,10 +23996,10 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -23209,10 +24055,10 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -23310,6 +24156,11 @@ func (ec *executionContext) marshalNAuthClient2ᚖgithubᚗcomᚋgeniusrabbitᚋ return ec._AuthClient(ctx, sel, v) } +func (ec *executionContext) unmarshalNAuthClientCreateInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientCreateInput(ctx context.Context, v any) (models.AuthClientCreateInput, error) { + res, err := ec.unmarshalInputAuthClientCreateInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalNAuthClientEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientEdge(ctx context.Context, sel ast.SelectionSet, v *models.AuthClientEdge) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -23320,11 +24171,6 @@ func (ec *executionContext) marshalNAuthClientEdge2ᚖgithubᚗcomᚋgeniusrabbi return ec._AuthClientEdge(ctx, sel, v) } -func (ec *executionContext) unmarshalNAuthClientInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientInput(ctx context.Context, v any) (models.AuthClientInput, error) { - res, err := ec.unmarshalInputAuthClientInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) marshalNAuthClientPayload2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientPayload(ctx context.Context, sel ast.SelectionSet, v models.AuthClientPayload) graphql.Marshaler { return ec._AuthClientPayload(ctx, sel, &v) } @@ -23339,6 +24185,11 @@ func (ec *executionContext) marshalNAuthClientPayload2ᚖgithubᚗcomᚋgeniusra return ec._AuthClientPayload(ctx, sel, v) } +func (ec *executionContext) unmarshalNAuthClientUpdateInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientUpdateInput(ctx context.Context, v any) (models.AuthClientUpdateInput, error) { + res, err := ec.unmarshalInputAuthClientUpdateInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v any) (bool, error) { res, err := graphql.UnmarshalBoolean(v) return res, graphql.ErrorOnPath(ctx, err) @@ -23380,6 +24231,22 @@ func (ec *executionContext) unmarshalNDirectAccessTokenListFilter2githubᚗcom return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v any) (float64, error) { + res, err := graphql.UnmarshalFloatContext(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { + _ = sel + res := graphql.MarshalFloatContext(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + } + return graphql.WrapContextMarshaler(ctx, res) +} + func (ec *executionContext) marshalNHistoryAction2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐHistoryAction(ctx context.Context, sel ast.SelectionSet, v *models.HistoryAction) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -23513,39 +24380,11 @@ func (ec *executionContext) marshalNNullableJSON2githubᚗcomᚋgeniusrabbitᚋb } func (ec *executionContext) marshalNOption2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOptionᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.Option) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNOption2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOption(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNOption2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOption(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -23567,39 +24406,11 @@ func (ec *executionContext) marshalNOption2ᚖgithubᚗcomᚋgeniusrabbitᚋblaz } func (ec *executionContext) marshalNOptionEdge2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOptionEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.OptionEdge) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNOptionEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOptionEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNOptionEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOptionEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -23931,39 +24742,11 @@ func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24006,39 +24789,11 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx conte } func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24062,39 +24817,11 @@ func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlg } func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24110,39 +24837,11 @@ func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24183,39 +24882,11 @@ func (ec *executionContext) marshalOAccount2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋ if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNAccount2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccount(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNAccount2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccount(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24244,39 +24915,11 @@ func (ec *executionContext) marshalOAccountEdge2ᚕᚖgithubᚗcomᚋgeniusrabbi if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNAccountEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNAccountEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24325,39 +24968,11 @@ func (ec *executionContext) marshalOApproveStatus2ᚕgithubᚗcomᚋgeniusrabbit if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNApproveStatus2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐApproveStatus(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNApproveStatus2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐApproveStatus(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24388,39 +25003,11 @@ func (ec *executionContext) marshalOAuthClient2ᚕᚖgithubᚗcomᚋgeniusrabbit if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNAuthClient2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClient(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNAuthClient2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClient(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24449,39 +25036,11 @@ func (ec *executionContext) marshalOAuthClientEdge2ᚕᚖgithubᚗcomᚋgeniusra if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNAuthClientEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNAuthClientEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24500,6 +25059,24 @@ func (ec *executionContext) unmarshalOAuthClientListFilter2ᚖgithubᚗcomᚋgen return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalOAuthClientListOrder2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientListOrder(ctx context.Context, v any) ([]*models.AuthClientListOrder, error) { + if v == nil { + return nil, nil + } + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]*models.AuthClientListOrder, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOAuthClientListOrder2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientListOrder(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + func (ec *executionContext) unmarshalOAuthClientListOrder2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientListOrder(ctx context.Context, v any) (*models.AuthClientListOrder, error) { if v == nil { return nil, nil @@ -24542,39 +25119,11 @@ func (ec *executionContext) marshalODirectAccessToken2ᚕᚖgithubᚗcomᚋgeniu if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNDirectAccessToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐDirectAccessToken(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNDirectAccessToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐDirectAccessToken(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24592,7 +25141,7 @@ func (ec *executionContext) marshalODirectAccessToken2ᚖgithubᚗcomᚋgeniusra return ec._DirectAccessToken(ctx, sel, v) } -func (ec *executionContext) marshalODirectAccessTokenConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋexampleᚋapiᚋinternalᚋserverᚋgraphqlᚋmodelsᚐDirectAccessTokenConnection(ctx context.Context, sel ast.SelectionSet, v *models1.DirectAccessTokenConnection) graphql.Marshaler { +func (ec *executionContext) marshalODirectAccessTokenConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection(ctx context.Context, sel ast.SelectionSet, v *connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge]) graphql.Marshaler { if v == nil { return graphql.Null } @@ -24603,39 +25152,11 @@ func (ec *executionContext) marshalODirectAccessTokenEdge2ᚕᚖgithubᚗcomᚋg if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNDirectAccessTokenEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐDirectAccessTokenEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNDirectAccessTokenEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐDirectAccessTokenEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24673,39 +25194,11 @@ func (ec *executionContext) marshalOHistoryAction2ᚕᚖgithubᚗcomᚋgeniusrab if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNHistoryAction2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐHistoryAction(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNHistoryAction2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐHistoryAction(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24727,39 +25220,11 @@ func (ec *executionContext) marshalOHistoryActionEdge2ᚕᚖgithubᚗcomᚋgeniu if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNHistoryActionEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐHistoryActionEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNHistoryActionEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐHistoryActionEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24862,39 +25327,11 @@ func (ec *executionContext) marshalOMember2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋb if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNMember2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMember(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNMember2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMember(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24923,39 +25360,11 @@ func (ec *executionContext) marshalOMemberEdge2ᚕᚖgithubᚗcomᚋgeniusrabbit if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNMemberEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNMemberEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25050,39 +25459,11 @@ func (ec *executionContext) marshalOOptionType2ᚕgithubᚗcomᚋgeniusrabbitᚋ if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNOptionType2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOptionType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNOptionType2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOptionType(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25121,39 +25502,11 @@ func (ec *executionContext) marshalOProfileMessanger2ᚕᚖgithubᚗcomᚋgenius if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNProfileMessanger2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐProfileMessanger(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNProfileMessanger2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐProfileMessanger(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25168,39 +25521,11 @@ func (ec *executionContext) marshalORBACPermission2ᚕᚖgithubᚗcomᚋgeniusra if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNRBACPermission2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACPermission(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNRBACPermission2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACPermission(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25215,39 +25540,11 @@ func (ec *executionContext) marshalORBACRole2ᚕᚖgithubᚗcomᚋgeniusrabbit if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNRBACRole2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACRole(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNRBACRole2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACRole(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25276,39 +25573,11 @@ func (ec *executionContext) marshalORBACRoleEdge2ᚕᚖgithubᚗcomᚋgeniusrabb if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNRBACRoleEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACRoleEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNRBACRoleEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACRoleEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25339,39 +25608,11 @@ func (ec *executionContext) marshalOSocialAccount2ᚕᚖgithubᚗcomᚋgeniusrab if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNSocialAccount2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccount(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNSocialAccount2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccount(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25393,39 +25634,11 @@ func (ec *executionContext) marshalOSocialAccountEdge2ᚕᚖgithubᚗcomᚋgeniu if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNSocialAccountEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNSocialAccountEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25456,39 +25669,11 @@ func (ec *executionContext) marshalOSocialAccountSession2ᚕᚖgithubᚗcomᚋge if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNSocialAccountSession2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountSession(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNSocialAccountSession2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountSession(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25618,39 +25803,11 @@ func (ec *executionContext) marshalOUser2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋbla if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNUser2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUser(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNUser2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUser(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25679,39 +25836,11 @@ func (ec *executionContext) marshalOUserEdge2ᚕᚖgithubᚗcomᚋgeniusrabbit if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNUserEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNUserEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25750,39 +25879,11 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25797,39 +25898,11 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25844,39 +25917,11 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25898,39 +25943,11 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { diff --git a/example/api/internal/server/graphql/models/generated.go b/example/api/internal/server/graphql/models/generated.go deleted file mode 100644 index cb33a305..00000000 --- a/example/api/internal/server/graphql/models/generated.go +++ /dev/null @@ -1,18 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package models - -import ( - "github.com/geniusrabbit/blaze-api/server/graphql/models" -) - -type DirectAccessTokenConnection struct { - // Total count of DirectAccessToken objects - TotalCount int `json:"totalCount"` - // Edges for the DirectAccessTokenConnection - Edges []*models.DirectAccessTokenEdge `json:"edges,omitempty"` - // List of DirectAccessToken objects - List []*models.DirectAccessToken `json:"list,omitempty"` - // PageInfo for the DirectAccessTokenConnection - PageInfo *models.PageInfo `json:"pageInfo"` -} diff --git a/example/api/internal/server/graphql/resolvers/account_base.resolvers.go b/example/api/internal/server/graphql/resolvers/account_base.resolvers.go index 4fc76a53..fcacf673 100644 --- a/example/api/internal/server/graphql/resolvers/account_base.resolvers.go +++ b/example/api/internal/server/graphql/resolvers/account_base.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/example/api/internal/server/graphql/resolvers/account_member.resolvers.go b/example/api/internal/server/graphql/resolvers/account_member.resolvers.go index bb75bd50..1c82a8d7 100644 --- a/example/api/internal/server/graphql/resolvers/account_member.resolvers.go +++ b/example/api/internal/server/graphql/resolvers/account_member.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/example/api/internal/server/graphql/resolvers/account_social.resolvers.go b/example/api/internal/server/graphql/resolvers/account_social.resolvers.go index baa607c7..ff673736 100644 --- a/example/api/internal/server/graphql/resolvers/account_social.resolvers.go +++ b/example/api/internal/server/graphql/resolvers/account_social.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/example/api/internal/server/graphql/resolvers/account_users.resolvers.go b/example/api/internal/server/graphql/resolvers/account_users.resolvers.go index 335b352a..e2a30eca 100644 --- a/example/api/internal/server/graphql/resolvers/account_users.resolvers.go +++ b/example/api/internal/server/graphql/resolvers/account_users.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/example/api/internal/server/graphql/resolvers/auth_client.resolvers.go b/example/api/internal/server/graphql/resolvers/auth_client.resolvers.go index 42db3fc3..f80a1e47 100644 --- a/example/api/internal/server/graphql/resolvers/auth_client.resolvers.go +++ b/example/api/internal/server/graphql/resolvers/auth_client.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" @@ -13,12 +13,12 @@ import ( ) // CreateAuthClient is the resolver for the createAuthClient field. -func (r *mutationResolver) CreateAuthClient(ctx context.Context, input models.AuthClientInput) (*models.AuthClientPayload, error) { +func (r *mutationResolver) CreateAuthClient(ctx context.Context, input models.AuthClientCreateInput) (*models.AuthClientPayload, error) { return r.Resolver.Mutation().CreateAuthClient(ctx, input) } // UpdateAuthClient is the resolver for the updateAuthClient field. -func (r *mutationResolver) UpdateAuthClient(ctx context.Context, id string, input models.AuthClientInput) (*models.AuthClientPayload, error) { +func (r *mutationResolver) UpdateAuthClient(ctx context.Context, id string, input models.AuthClientUpdateInput) (*models.AuthClientPayload, error) { return r.Resolver.Mutation().UpdateAuthClient(ctx, id, input) } @@ -33,6 +33,6 @@ func (r *queryResolver) AuthClient(ctx context.Context, id string) (*models.Auth } // ListAuthClients is the resolver for the listAuthClients field. -func (r *queryResolver) ListAuthClients(ctx context.Context, filter *models.AuthClientListFilter, order *models.AuthClientListOrder, page *models.Page) (*connectors.CollectionConnection[models.AuthClient, models.AuthClientEdge], error) { +func (r *queryResolver) ListAuthClients(ctx context.Context, filter *models.AuthClientListFilter, order []*models.AuthClientListOrder, page *models.Page) (*connectors.CollectionConnection[models.AuthClient, models.AuthClientEdge], error) { return r.Resolver.Query().ListAuthClients(ctx, filter, order, page) } diff --git a/example/api/internal/server/graphql/resolvers/directaccesstoken.resolvers.go b/example/api/internal/server/graphql/resolvers/directaccesstoken.resolvers.go index 4ebf9dc1..07fb19f8 100644 --- a/example/api/internal/server/graphql/resolvers/directaccesstoken.resolvers.go +++ b/example/api/internal/server/graphql/resolvers/directaccesstoken.resolvers.go @@ -3,33 +3,32 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" - "fmt" "time" - models1 "github.com/geniusrabbit/blaze-api/example/api/internal/server/graphql/models" + "github.com/geniusrabbit/blaze-api/server/graphql/connectors" "github.com/geniusrabbit/blaze-api/server/graphql/models" ) // GenerateDirectAccessToken is the resolver for the generateDirectAccessToken field. func (r *mutationResolver) GenerateDirectAccessToken(ctx context.Context, userID *uint64, description string, expiresAt *time.Time) (*models.DirectAccessTokenPayload, error) { - panic(fmt.Errorf("not implemented: GenerateDirectAccessToken - generateDirectAccessToken")) + return r.Resolver.Mutation().GenerateDirectAccessToken(ctx, userID, description, expiresAt) } // RevokeDirectAccessToken is the resolver for the revokeDirectAccessToken field. func (r *mutationResolver) RevokeDirectAccessToken(ctx context.Context, filter models.DirectAccessTokenListFilter) (*models.StatusResponse, error) { - panic(fmt.Errorf("not implemented: RevokeDirectAccessToken - revokeDirectAccessToken")) + return r.Resolver.Mutation().RevokeDirectAccessToken(ctx, filter) } // GetDirectAccessToken is the resolver for the getDirectAccessToken field. func (r *queryResolver) GetDirectAccessToken(ctx context.Context, id uint64) (*models.DirectAccessTokenPayload, error) { - panic(fmt.Errorf("not implemented: GetDirectAccessToken - getDirectAccessToken")) + return r.Resolver.Query().GetDirectAccessToken(ctx, id) } // ListDirectAccessTokens is the resolver for the listDirectAccessTokens field. -func (r *queryResolver) ListDirectAccessTokens(ctx context.Context, filter *models.DirectAccessTokenListFilter, order *models.DirectAccessTokenListOrder, page *models.Page) (*models1.DirectAccessTokenConnection, error) { - panic(fmt.Errorf("not implemented: ListDirectAccessTokens - listDirectAccessTokens")) +func (r *queryResolver) ListDirectAccessTokens(ctx context.Context, filter *models.DirectAccessTokenListFilter, order *models.DirectAccessTokenListOrder, page *models.Page) (*connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge], error) { + return r.Resolver.Query().ListDirectAccessTokens(ctx, filter, order, page) } diff --git a/example/api/internal/server/graphql/resolvers/history.resolvers.go b/example/api/internal/server/graphql/resolvers/history.resolvers.go index 933d4012..bfd51704 100644 --- a/example/api/internal/server/graphql/resolvers/history.resolvers.go +++ b/example/api/internal/server/graphql/resolvers/history.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/example/api/internal/server/graphql/resolvers/options.resolvers.go b/example/api/internal/server/graphql/resolvers/options.resolvers.go index f64def75..f2ab4d85 100644 --- a/example/api/internal/server/graphql/resolvers/options.resolvers.go +++ b/example/api/internal/server/graphql/resolvers/options.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/example/api/internal/server/graphql/resolvers/rbac.resolvers.go b/example/api/internal/server/graphql/resolvers/rbac.resolvers.go index 1e69a3bb..152b7682 100644 --- a/example/api/internal/server/graphql/resolvers/rbac.resolvers.go +++ b/example/api/internal/server/graphql/resolvers/rbac.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/example/api/internal/server/graphql/resolvers/schema.resolvers.go b/example/api/internal/server/graphql/resolvers/schema.resolvers.go index 834517e4..54a80064 100644 --- a/example/api/internal/server/graphql/resolvers/schema.resolvers.go +++ b/example/api/internal/server/graphql/resolvers/schema.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/example/api/internal/server/server.go b/example/api/internal/server/server.go index 844fdffc..1fea393b 100644 --- a/example/api/internal/server/server.go +++ b/example/api/internal/server/server.go @@ -20,8 +20,11 @@ import ( "github.com/geniusrabbit/blaze-api/pkg/auth/jwt" "github.com/geniusrabbit/blaze-api/pkg/middleware" "github.com/geniusrabbit/blaze-api/pkg/profiler" + "github.com/geniusrabbit/blaze-api/repository/account" + accAuth "github.com/geniusrabbit/blaze-api/repository/account/auth" "github.com/geniusrabbit/blaze-api/repository/option/repository" "github.com/geniusrabbit/blaze-api/repository/option/usecase" + "github.com/geniusrabbit/blaze-api/repository/user" ) type ( @@ -34,7 +37,7 @@ type HTTPServer struct { RequestTimeout time.Duration ContextWrap contextWrapper InitWrap muxInitWrapper - Authorizers []auth.Authorizer + Authorizers []auth.Authorizer[*user.User, *account.Account] JWTProvider *jwt.Provider SessionManager *scs.SessionManager Logger *zap.Logger @@ -51,7 +54,7 @@ func (s *HTTPServer) Run(ctx context.Context, address string) (err error) { mux.Handle("/healthcheck", http.HandlerFunc(profiler.HealthCheckHandler)) mux.Handle("/metrics", promhttp.Handler()) mux.Handle("/graphql", graphql.GraphQL(s.JWTProvider, - usecase.NewUsecase(repository.New(nil)))) + usecase.NewUsecase(repository.NewOptionRepository(nil)))) if s.InitWrap != nil { s.InitWrap(mux) @@ -60,7 +63,7 @@ func (s *HTTPServer) Run(ctx context.Context, address string) (err error) { h := http.Handler(mux) // Add middleware's - h = auth.Middelware(h, s.Authorizers...) + h = accAuth.Middleware(h, s.Authorizers...) h = middleware.HTTPContextWrapper(h, s.ContextWrap) h = middleware.HTTPSession(h, s.SessionManager) h = middleware.RealIP(h) diff --git a/example/api/protocol/graphql/gqlgen.yml b/example/api/protocol/graphql/gqlgen.yml index af991f97..1bf125e8 100644 --- a/example/api/protocol/graphql/gqlgen.yml +++ b/example/api/protocol/graphql/gqlgen.yml @@ -3,8 +3,8 @@ # Where are all the schema files located? globs are supported eg src/**/*.graphqls schema: - - ./schemas/*.graphql - ../../../../protocol/graphql/schemas/*.graphql + - ../../../../repository/**/*.graphql skip_mod_tidy: true @@ -77,18 +77,20 @@ models: model: github.com/geniusrabbit/blaze-api/server/graphql/types.ID64 # Connectors UserConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.UserConnection + model: github.com/geniusrabbit/blaze-api/repository/user/delivery/graphql.UserConnection AccountConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.AccountConnection + model: github.com/geniusrabbit/blaze-api/repository/account/delivery/graphql.AccountConnection MemberConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.MemberConnection + model: github.com/geniusrabbit/blaze-api/repository/account/delivery/graphql.MemberConnection SocialAccountConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.SocialAccountConnection + model: github.com/geniusrabbit/blaze-api/repository/socialaccount/delivery/graphql.SocialAccountConnection RBACRoleConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.RBACRoleConnection + model: github.com/geniusrabbit/blaze-api/repository/rbac/delivery/graphql.RBACRoleConnection AuthClientConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.AuthClientConnection + model: github.com/geniusrabbit/blaze-api/repository/authclient/delivery/graphql.AuthClientConnection HistoryActionConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.HistoryActionConnection + model: github.com/geniusrabbit/blaze-api/repository/historylog/delivery/graphql.HistoryActionConnection OptionConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.OptionConnection + model: github.com/geniusrabbit/blaze-api/repository/option/delivery/graphql.OptionConnection + DirectAccessTokenConnection: + model: github.com/geniusrabbit/blaze-api/repository/directaccesstoken/delivery/graphql.DirectAccessTokenConnection diff --git a/go.mod b/go.mod index 1888b130..6f4497be 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,14 @@ module github.com/geniusrabbit/blaze-api -go 1.25.3 +go 1.25.7 require ( github.com/99designs/basicauth-go v0.0.0-20230316000542-bf6f9cbbf0f8 - github.com/99designs/gqlgen v0.17.86 + github.com/99designs/gqlgen v0.17.91 github.com/DATA-DOG/go-sqlmock v1.5.2 github.com/WinterYukky/gorm-extra-clause-plugin v0.4.0 github.com/alexedwards/scs/v2 v2.9.0 - github.com/alicebob/miniredis/v2 v2.36.1 + github.com/alicebob/miniredis/v2 v2.38.0 github.com/allegro/bigcache/v3 v3.1.0 github.com/auth0/go-jwt-middleware v1.0.1 github.com/demdxx/gocast/v2 v2.11.0 @@ -20,15 +20,14 @@ require ( github.com/form3tech-oss/jwt-go v3.2.5+incompatible github.com/geniusrabbit/gosql/v2 v2.3.2 github.com/geniusrabbit/notificationcenter/v2 v2.5.0 - github.com/go-chi/chi/v5 v5.2.5 + github.com/go-chi/chi/v5 v5.3.0 github.com/go-faster/errors v0.7.1 github.com/go-redis/redis/v8 v8.11.5 github.com/golang-migrate/migrate v3.5.4+incompatible - github.com/golang/mock v1.6.0 github.com/google/uuid v1.6.0 github.com/guregu/null v4.0.0+incompatible - github.com/lib/pq v1.11.2 - github.com/nats-io/nats.go v1.48.0 + github.com/lib/pq v1.12.3 + github.com/nats-io/nats.go v1.52.0 github.com/opentracing-contrib/go-stdlib v1.1.1 github.com/opentracing/opentracing-go v1.2.0 github.com/ory/fosite v0.49.0 @@ -37,14 +36,15 @@ require ( github.com/prometheus/client_golang v1.23.2 github.com/stretchr/testify v1.11.1 github.com/uber/jaeger-client-go v2.30.0+incompatible - github.com/vektah/gqlparser/v2 v2.5.32 + github.com/vektah/gqlparser/v2 v2.5.34 github.com/ydb-platform/gorm-driver v0.2.0 go.elastic.co/apm/module/apmot v1.15.0 go.elastic.co/ecszap v1.0.3 + go.uber.org/mock v0.6.0 go.uber.org/multierr v1.11.0 - go.uber.org/zap v1.27.1 - golang.org/x/crypto v0.48.0 - golang.org/x/oauth2 v0.35.0 + go.uber.org/zap v1.28.0 + golang.org/x/crypto v0.53.0 + golang.org/x/oauth2 v0.36.0 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 gorm.io/driver/clickhouse v0.7.0 gorm.io/driver/mysql v1.6.0 @@ -57,37 +57,36 @@ require ( require ( cloud.google.com/go/compute/metadata v0.9.0 // indirect filippo.io/edwards25519 v1.2.0 // indirect - github.com/ClickHouse/ch-go v0.71.0 // indirect - github.com/ClickHouse/clickhouse-go/v2 v2.43.0 // indirect + github.com/ClickHouse/ch-go v0.72.0 // indirect + github.com/ClickHouse/clickhouse-go/v2 v2.46.0 // indirect github.com/HdrHistogram/hdrhistogram-go v1.2.0 // indirect - github.com/IBM/sarama v1.46.3 // indirect + github.com/IBM/sarama v1.50.2 // indirect github.com/agnivade/levenshtein v1.2.1 // indirect - github.com/andybalholm/brotli v1.2.0 // indirect + github.com/andybalholm/brotli v1.2.1 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/caarlos0/env/v6 v6.10.1 // indirect github.com/cenkalti/backoff/v5 v5.0.3 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/coder/websocket v1.8.14 // indirect github.com/cristalhq/jwt/v4 v4.0.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgraph-io/ristretto v1.0.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/eapache/go-resiliency v1.7.0 // indirect - github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect - github.com/eapache/queue v1.1.0 // indirect github.com/elastic/go-licenser v0.4.2 // indirect github.com/elastic/go-sysinfo v1.15.4 // indirect github.com/elastic/go-windows v1.0.2 // indirect github.com/felixge/fgprof v0.9.5 // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.9.0 // indirect + github.com/felixge/httpsnoop v1.1.0 // indirect + github.com/fsnotify/fsnotify v1.10.1 // indirect github.com/go-faster/city v1.0.1 // indirect - github.com/go-jose/go-jose/v3 v3.0.4 // indirect + github.com/go-jose/go-jose/v3 v3.0.5 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-sql-driver/mysql v1.9.3 // indirect + github.com/go-sql-driver/mysql v1.10.0 // indirect github.com/go-viper/mapstructure/v2 v2.5.0 // indirect github.com/goccy/go-yaml v1.19.2 // indirect github.com/gogo/googleapis v1.4.1 // indirect @@ -95,22 +94,22 @@ require ( github.com/golang-jwt/jwt/v4 v4.5.2 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect - github.com/golang/snappy v0.0.4 // indirect - github.com/google/pprof v0.0.0-20260202012954-cb029daf43ef // indirect + github.com/golang/mock v1.6.0 // indirect + github.com/google/pprof v0.0.0-20260604005048-7023385849c0 // indirect github.com/gorilla/websocket v1.5.3 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-retryablehttp v0.7.8 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect - github.com/hashicorp/go-version v1.8.0 // indirect + github.com/hashicorp/go-version v1.9.0 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect - github.com/jackc/pgx/v5 v5.8.0 // indirect + github.com/jackc/pgx/v5 v5.10.0 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect - github.com/jaegertracing/jaeger-idl v0.6.0 // indirect + github.com/jaegertracing/jaeger-idl v0.9.0 // indirect github.com/jcchavezs/porto v0.7.0 // indirect github.com/jcmturner/aescts/v2 v2.0.0 // indirect github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect @@ -120,27 +119,27 @@ require ( github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/jonboulle/clockwork v0.5.0 // indirect - github.com/klauspost/compress v1.18.4 // indirect + github.com/klauspost/compress v1.18.6 // indirect github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect github.com/mattn/goveralls v0.0.12 // indirect github.com/mcuadros/go-defaults v1.2.0 // indirect - github.com/microsoft/go-mssqldb v1.9.6 // indirect + github.com/microsoft/go-mssqldb v1.10.0 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/nats-io/nkeys v0.4.15 // indirect + github.com/nats-io/nkeys v0.4.16 // indirect github.com/nats-io/nuid v1.0.1 // indirect github.com/openzipkin/zipkin-go v0.4.3 // indirect github.com/ory/go-acc v0.2.9-0.20230103102148-6b1c9a70dbbe // indirect github.com/ory/go-convenience v0.1.0 // indirect - github.com/ory/pop/v6 v6.3.1 // indirect + github.com/ory/pop/v6 v6.4.1 // indirect github.com/ory/x v0.0.729 // indirect - github.com/paulmach/orb v0.12.0 // indirect - github.com/pelletier/go-toml/v2 v2.2.4 // indirect - github.com/pierrec/lz4/v4 v4.1.25 // indirect + github.com/paulmach/orb v0.13.0 // indirect + github.com/pelletier/go-toml/v2 v2.3.1 // indirect + github.com/pierrec/lz4/v4 v4.1.27 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_model v0.6.2 // indirect - github.com/prometheus/common v0.67.5 // indirect - github.com/prometheus/procfs v0.19.2 // indirect + github.com/prometheus/common v0.68.1 // indirect + github.com/prometheus/procfs v0.20.1 // indirect github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect github.com/sagikazarmark/locafero v0.12.0 // indirect github.com/santhosh-tekuri/jsonschema v1.2.4 // indirect @@ -148,7 +147,7 @@ require ( github.com/segmentio/asm v1.2.1 // indirect github.com/shopspring/decimal v1.4.0 // indirect github.com/sirupsen/logrus v1.9.4 // indirect - github.com/sosodev/duration v1.3.1 // indirect + github.com/sosodev/duration v1.4.0 // indirect github.com/spf13/afero v1.15.0 // indirect github.com/spf13/cast v1.10.0 // indirect github.com/spf13/cobra v1.10.2 // indirect @@ -157,43 +156,42 @@ require ( github.com/stretchr/objx v0.5.3 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/uber/jaeger-lib v2.4.1+incompatible // indirect - github.com/urfave/cli/v3 v3.6.2 // indirect - github.com/ydb-platform/ydb-go-genproto v0.0.0-20260128080146-c4ed16b24b37 // indirect - github.com/ydb-platform/ydb-go-sdk/v3 v3.126.5 // indirect - github.com/yuin/gopher-lua v1.1.1 // indirect + github.com/urfave/cli/v3 v3.9.1 // indirect + github.com/ydb-platform/ydb-go-genproto v0.0.0-20260428144813-1c07baab7f7b // indirect + github.com/ydb-platform/ydb-go-sdk/v3 v3.139.6 // indirect + github.com/yuin/gopher-lua v1.1.2 // indirect go.elastic.co/apm v1.15.0 // indirect go.elastic.co/apm/module/apmhttp v1.15.0 // indirect go.elastic.co/fastjson v1.5.1 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.65.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.65.0 // indirect - go.opentelemetry.io/contrib/propagators/b3 v1.40.0 // indirect - go.opentelemetry.io/contrib/propagators/jaeger v1.40.0 // indirect - go.opentelemetry.io/contrib/samplers/jaegerremote v0.34.0 // indirect - go.opentelemetry.io/otel v1.40.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.69.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 // indirect + go.opentelemetry.io/contrib/propagators/b3 v1.44.0 // indirect + go.opentelemetry.io/contrib/propagators/jaeger v1.44.0 // indirect + go.opentelemetry.io/contrib/samplers/jaegerremote v0.37.1 // indirect + go.opentelemetry.io/otel v1.44.0 // indirect go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.40.0 // indirect - go.opentelemetry.io/otel/exporters/zipkin v1.40.0 // indirect - go.opentelemetry.io/otel/metric v1.40.0 // indirect - go.opentelemetry.io/otel/sdk v1.40.0 // indirect - go.opentelemetry.io/otel/trace v1.40.0 // indirect - go.opentelemetry.io/proto/otlp v1.9.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.44.0 // indirect + go.opentelemetry.io/otel/exporters/zipkin v1.44.0 // indirect + go.opentelemetry.io/otel/metric v1.44.0 // indirect + go.opentelemetry.io/otel/sdk v1.44.0 // indirect + go.opentelemetry.io/otel/trace v1.44.0 // indirect + go.opentelemetry.io/proto/otlp v1.10.0 // indirect go.uber.org/atomic v1.11.0 // indirect - go.yaml.in/yaml/v2 v2.4.3 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa // indirect + golang.org/x/exp v0.0.0-20260611194520-c48552f49976 // indirect golang.org/x/lint v0.0.0-20241112194109-818c5a804067 // indirect - golang.org/x/mod v0.33.0 // indirect - golang.org/x/net v0.50.0 // indirect - golang.org/x/sync v0.19.0 // indirect - golang.org/x/sys v0.41.0 // indirect - golang.org/x/telemetry v0.0.0-20260213145524-e0ab670178e1 // indirect - golang.org/x/text v0.34.0 // indirect - golang.org/x/tools v0.42.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20260217215200-42d3e9bedb6d // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20260217215200-42d3e9bedb6d // indirect - google.golang.org/grpc v1.79.1 // indirect + golang.org/x/mod v0.37.0 // indirect + golang.org/x/net v0.56.0 // indirect + golang.org/x/sync v0.21.0 // indirect + golang.org/x/sys v0.46.0 // indirect + golang.org/x/telemetry v0.0.0-20260611141451-d61e87d5f4a3 // indirect + golang.org/x/text v0.38.0 // indirect + golang.org/x/tools v0.46.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20260610212136-7ab31c22f7ad // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20260610212136-7ab31c22f7ad // indirect + google.golang.org/grpc v1.81.1 // indirect google.golang.org/protobuf v1.36.11 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect howett.net/plist v1.0.1 // indirect diff --git a/go.sum b/go.sum index 4c2308b4..43f5f1d9 100644 --- a/go.sum +++ b/go.sum @@ -6,47 +6,45 @@ filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo= filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc= github.com/99designs/basicauth-go v0.0.0-20230316000542-bf6f9cbbf0f8 h1:nMpu1t4amK3vJWBibQ5X/Nv0aXL+b69TQf2uK5PH7Go= github.com/99designs/basicauth-go v0.0.0-20230316000542-bf6f9cbbf0f8/go.mod h1:3cARGAK9CfW3HoxCy1a0G4TKrdiKke8ftOMEOHyySYs= -github.com/99designs/gqlgen v0.17.86 h1:C8N3UTa5heXX6twl+b0AJyGkTwYL6dNmFrgZNLRcU6w= -github.com/99designs/gqlgen v0.17.86/go.mod h1:KTrPl+vHA1IUzNlh4EYkl7+tcErL3MgKnhHrBcV74Fw= +github.com/99designs/gqlgen v0.17.91 h1:/mIvXnN0lAorqszP3Vukw10SVRfLVUYtBTQFwmYRMmI= +github.com/99designs/gqlgen v0.17.91/go.mod h1:N7+yJF6zbGIEqohF+ZtEUp/eq2dTnn0bDizLUIYPUCU= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1/go.mod h1:a6xsAQUZg+VsS3TJ05SRp524Hs4pZ/AeFSr5ENf0Yjo= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 h1:Gt0j3wceWMwPmiazCa8MzMA0MfhmPIz0Qp0FJ6qcM0U= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0/go.mod h1:Ot/6aikWnKWi4l9QB7qVSwa8iMphQNqkWALMoNT3rzM= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.1 h1:jHb/wfvRikGdxMXYV3QG/SzUOPYN9KEUUuC0Yd0/vC0= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.1/go.mod h1:pzBXCYn05zvYIrwLgtK8Ap8QcjRg+0i76tMQdWN6wOk= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1/go.mod h1:uE9zaUfEQT/nbQjVi2IblCG9iaLtZsuYZ8ne+PuQ02M= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.6.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 h1:B+blDbyVIG3WaikNxPnhPiJ1MThR03b3vKGtER95TP4= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1/go.mod h1:JdM5psgjfBf5fo2uWOZhflPWyDBZ/O/CNAH9CtsuZE4= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 h1:Hk5QBxZQC1jb2Fwj6mpzme37xbCDdNTxU7O9eb5+LB4= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1/go.mod h1:IYus9qsFobWIc2YVwe/WPjcnyCkPKtnHAqUYeebc8z0= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc= github.com/Azure/azure-sdk-for-go/sdk/internal v1.8.0/go.mod h1:4OG6tQ9EOP/MT0NMjDlRzWoVFxfu9rN9B2X+tlSVktg= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 h1:FPKJS1T+clwv+OLGt13a8UjqeRuh0O4SJ3lUriThc+4= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1/go.mod h1:j2chePtV91HrC22tGoRX3sGY42uF13WzmmV80/OdVAA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0 h1:fhqpLE3UEXi9lPaBRpQ6XuRW0nU7hgg4zlmZZa+a9q4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.12.0/go.mod h1:7dCRMLwisfRH3dBupKeNCioWYUZ4SS09Z14H+7i8ZoY= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.1/go.mod h1:GpPjLhVR9dnUoJMyHWSPy71xY9/lcmpzIPZXmF0FCVY= -github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.3.1 h1:Wgf5rZba3YZqeTNJPtvqZoBu1sBN/L4sry+u2U3Y75w= -github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.3.1/go.mod h1:xxCBG/f/4Vbmh2XQJBsOmNdxWUY5j/s27jujKPbQf14= +github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.4.0 h1:E4MgwLBGeVB5f2MdcIVD3ELVAWpr+WD6MUe1i+tM/PA= +github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.4.0/go.mod h1:Y2b/1clN4zsAoUd/pgNAQHjLDnTis/6ROkUfyob6psM= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0/go.mod h1:bTSOgj05NGRuHHhQwAdPnYr9TOdNmKlZTgGLL6nyAdI= -github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.1.1 h1:bFWuoEKg+gImo7pvkiQEFAc8ocibADgXeiLAxWhWmkI= -github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.1.1/go.mod h1:Vih/3yc6yac2JzU4hzpaDupBJP0Flaia9rXXrU8xyww= +github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.2.0 h1:nCYfgcSyHZXJI8J0IWE5MsCGlb2xp9fJiXyxWgmOFg4= +github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.2.0/go.mod h1:ucUjca2JtSZboY8IoUqyQyuuXvwbMBVwFOm0vdQPNhA= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0 h1:XRzhVemXdgvJqCH0sFfrBUTnUJSBrBf7++ypk+twtRs= +github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0/go.mod h1:HKpQxkWaGLJ+D/5H8QRpyQXA1eKjxkFlOMwck5+33Jk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/ClickHouse/ch-go v0.71.0 h1:bUdZ/EZj/LcVHsMqaRUP2holqygrPWQKeMjc6nZoyRM= -github.com/ClickHouse/ch-go v0.71.0/go.mod h1:NwbNc+7jaqfY58dmdDUbG4Jl22vThgx1cYjBw0vtgXw= -github.com/ClickHouse/clickhouse-go/v2 v2.43.0 h1:fUR05TrF1GyvLDa/mAQjkx7KbgwdLRffs2n9O3WobtE= -github.com/ClickHouse/clickhouse-go/v2 v2.43.0/go.mod h1:o6jf7JM/zveWC/PP277BLxjHy5KjnGX/jfljhM4s34g= +github.com/ClickHouse/ch-go v0.72.0 h1:DSyUd4kuxisOVXlZSXyIQYBAajSErZWC379651DpAMU= +github.com/ClickHouse/ch-go v0.72.0/go.mod h1:eeWlJavWDsMf5fZzLNCYaBiMxVoREJYK00aiZ9FJ3E0= +github.com/ClickHouse/clickhouse-go/v2 v2.46.0 h1:s3eRy+hYmu5uzotB6ZhDofgHu8kDgGN/fpmjxRkqSpk= +github.com/ClickHouse/clickhouse-go/v2 v2.46.0/go.mod h1:giJfUVlMkcfUEPVfRpt51zZaGEx9i17gCos8gBl392c= github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU= github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/HdrHistogram/hdrhistogram-go v1.2.0 h1:XMJkDWuz6bM9Fzy7zORuVFKH7ZJY41G2q8KWhVGkNiY= github.com/HdrHistogram/hdrhistogram-go v1.2.0/go.mod h1:CiIeGiHSd06zjX+FypuEJ5EQ07KKtxZ+8J6hszwVQig= -github.com/IBM/sarama v1.46.3 h1:njRsX6jNlnR+ClJ8XmkO+CM4unbrNr/2vB5KK6UA+IE= -github.com/IBM/sarama v1.46.3/go.mod h1:GTUYiF9DMOZVe3FwyGT+dtSPceGFIgA+sPc5u6CBwko= +github.com/IBM/sarama v1.50.2 h1:Pp8T5SmQl/eeF4RU8zmmO7afo1+v+hltagOX0lkK4uI= +github.com/IBM/sarama v1.50.2/go.mod h1:dY2DVtbyI34f4i6FrJnclUMA2YHM+rbb1H+uzARqrmM= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/PuerkitoBio/goquery v1.11.0 h1:jZ7pwMQXIITcUXNH83LLk+txlaEy6NVOfTuP43xxfqw= -github.com/PuerkitoBio/goquery v1.11.0/go.mod h1:wQHgxUOU3JGuj3oD/QFfxUdlzW6xPHfqyHre6VMY4DQ= github.com/WinterYukky/gorm-extra-clause-plugin v0.4.0 h1:e4gYsN9tNzoBMYKYBaGwwZpSljJhW231+1cBlYwv8YQ= github.com/WinterYukky/gorm-extra-clause-plugin v0.4.0/go.mod h1:jNWq8AymgsVev9Kq6mke0b3o3yzY6bTSwjMDfTvZPPM= github.com/agnivade/levenshtein v1.2.1 h1:EHBY3UOn1gwdy/VbFwgo4cxecRznFk7fKWN1KOX7eoM= @@ -55,16 +53,12 @@ github.com/alexedwards/scs/v2 v2.9.0 h1:xa05mVpwTBm1iLeTMNFfAWpKUm4fXAW7CeAViqBV github.com/alexedwards/scs/v2 v2.9.0/go.mod h1:ToaROZxyKukJKT/xLcVQAChi5k6+Pn1Gvmdl7h3RRj8= github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= github.com/alicebob/miniredis/v2 v2.14.1/go.mod h1:uS970Sw5Gs9/iK3yBg0l9Uj9s25wXxSpQUE9EaJ/Blg= -github.com/alicebob/miniredis/v2 v2.36.1 h1:Dvc5oAnNOr7BIfPn7tF269U8DvRW1dBG2D5n0WrfYMI= -github.com/alicebob/miniredis/v2 v2.36.1/go.mod h1:TcL7YfarKPGDAthEtl5NBeHZfeUQj6OXMm/+iu5cLMM= +github.com/alicebob/miniredis/v2 v2.38.0 h1:nZAzCR+Lj+Vxk4ZXzm2NuKq2O33RXj1XxJ2e2uP9jiw= +github.com/alicebob/miniredis/v2 v2.38.0/go.mod h1:TcL7YfarKPGDAthEtl5NBeHZfeUQj6OXMm/+iu5cLMM= github.com/allegro/bigcache/v3 v3.1.0 h1:H2Vp8VOvxcrB91o86fUSVJFqeuz8kpyyB02eH3bSzwk= github.com/allegro/bigcache/v3 v3.1.0/go.mod h1:aPyh7jEvrog9zAwx5N7+JUQX5dZTSGpxF1LAR4dr35I= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ= -github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= -github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM= -github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA= +github.com/andybalholm/brotli v1.2.1 h1:R+f5xP285VArJDRgowrfb9DqL18yVK0gKAW/F+eTWro= +github.com/andybalholm/brotli v1.2.1/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= @@ -100,6 +94,8 @@ github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XP github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g= +github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg= github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= @@ -144,10 +140,6 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/eapache/go-resiliency v1.7.0 h1:n3NRTnBn5N0Cbi/IeOHuQn9s2UwVUH7Ga0ZWcP+9JTA= github.com/eapache/go-resiliency v1.7.0/go.mod h1:5yPzW0MIvSe0JDsv0v+DvcjEv2FyD6iZYSs1ZI+iQho= -github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4ALJ04o5Qqpdz8XLIpNA3WM/iSIXqxtqo7UGVws= -github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0= -github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= -github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/elastic/go-licenser v0.3.1/go.mod h1:D8eNQk70FOCVBl3smCGQt/lv7meBeQno2eI1S5apiHQ= github.com/elastic/go-licenser v0.4.2 h1:bPbGm8bUd8rxzSswFOqvQh1dAkKGkgAmrPxbUi+Y9+A= github.com/elastic/go-licenser v0.4.2/go.mod h1:W8eH6FaZDR8fQGm+7FnVa7MxI1b/6dAqxz+zPB8nm5c= @@ -170,32 +162,30 @@ github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/ github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw= github.com/felixge/fgprof v0.9.5 h1:8+vR6yu2vvSKn08urWyEuxx75NWPEvybbkBirEpsbVY= github.com/felixge/fgprof v0.9.5/go.mod h1:yKl+ERSa++RYOs32d8K6WEXCB4uXdLls4ZaZPpayhMM= -github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= -github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc= +github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/form3tech-oss/jwt-go v3.2.5+incompatible h1:/l4kBbb4/vGSsdtB5nUe8L7B9mImVMaBPw9L/0TBHU8= github.com/form3tech-oss/jwt-go v3.2.5+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= -github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= -github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= -github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho= +github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo= github.com/geniusrabbit/gosql/v2 v2.3.2 h1:dZTIEZ2JcnYG/uExZwWRMxpahblnN/PpyfPTva9Wz8w= github.com/geniusrabbit/gosql/v2 v2.3.2/go.mod h1:0AfJ5CwRl/Nsuc4b/z1IcPxOhaooKvAiWFFxyvz6K4g= github.com/geniusrabbit/notificationcenter/v2 v2.5.0 h1:n51meoNN5WW8VnWXF+gdwQxJSiWkKKcnRSrcnuAPgF0= github.com/geniusrabbit/notificationcenter/v2 v2.5.0/go.mod h1:hBoJzRKoytMCLX+VnbRXJlkWuNwb4WLRbSc5iUCgDGQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-chi/chi/v5 v5.2.5 h1:Eg4myHZBjyvJmAFjFvWgrqDTXFyOzjj7YIm3L3mu6Ug= -github.com/go-chi/chi/v5 v5.2.5/go.mod h1:X7Gx4mteadT3eDOMTsXzmI4/rwUpOwBHLpAfupzFJP0= +github.com/go-chi/chi/v5 v5.3.0 h1:halUjDxhshgXHMrao5bB8eNBXo/rnzwr8m5m36glehM= +github.com/go-chi/chi/v5 v5.3.0/go.mod h1:R+tYY2hNuVUUjxoPtqUdgBqevM9s9njzkTLutVsOCto= github.com/go-faster/city v1.0.1 h1:4WAxSZ3V2Ws4QRDrscLEDcibJY8uf41H6AhXDrNDcGw= github.com/go-faster/city v1.0.1/go.mod h1:jKcUJId49qdW3L1qKHH/3wPeUstCVpVSXTM6vO3VcTw= github.com/go-faster/errors v0.7.1 h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg= github.com/go-faster/errors v0.7.1/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo= -github.com/go-jose/go-jose/v3 v3.0.4 h1:Wp5HA7bLQcKnf6YYao/4kpRpVMp/yf6+pJKV8WFSaNY= -github.com/go-jose/go-jose/v3 v3.0.4/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ= +github.com/go-jose/go-jose/v3 v3.0.5 h1:BLLJWbC4nMZOfuPVxoZIxeYsn6Nl2r1fITaJ78UQlVQ= +github.com/go-jose/go-jose/v3 v3.0.5/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -204,8 +194,8 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre github.com/go-redis/redis/v8 v8.11.0/go.mod h1:DLomh7y2e3ggQXQLd1YgmvIfecPJoFl7WU5SOQ/r06M= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= -github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo= -github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= +github.com/go-sql-driver/mysql v1.10.0 h1:Q+1LV8DkHJvSYAdR83XzuhDaTykuDx0l6fkXxoWCWfw= +github.com/go-sql-driver/mysql v1.10.0/go.mod h1:M+cqaI7+xxXGG9swrdeUIoPG3Y3KCkF0pZej+SK+nWk= github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= @@ -222,8 +212,8 @@ github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= -github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= +github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY= +github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= github.com/golang-migrate/migrate v3.5.4+incompatible h1:R7OzwvCJTCgwapPCiX6DyBiu2czIUMDCB118gFTKTUA= github.com/golang-migrate/migrate v3.5.4+incompatible/go.mod h1:IsVUlFN5puWOmXrqjgGUfIRIbU7mr8oNBE2tyERd9Wk= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= @@ -249,15 +239,11 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -266,8 +252,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= -github.com/google/pprof v0.0.0-20260202012954-cb029daf43ef h1:xpF9fUHpoIrrjX24DURVKiwHcFpw19ndIs+FwTSMbno= -github.com/google/pprof v0.0.0-20260202012954-cb029daf43ef/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI= +github.com/google/pprof v0.0.0-20260604005048-7023385849c0 h1:h1QTMDl6q9wDvDCJVpKQSjgleGFYnd2fOxmg2K+6BGE= +github.com/google/pprof v0.0.0-20260604005048-7023385849c0/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -283,8 +269,8 @@ github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/z github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 h1:HWRh5R2+9EifMyIHV7ZV+MIZqgz+PMpZ14Jynv3O2Zs= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0/go.mod h1:JfhWUomR1baixubs02l85lZYYOm7LV6om4ceouMv45c= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 h1:5VipnvEpbqr2gA2VbM+nYVbkIF28c5ZQfqCBQ5g2xfk= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0/go.mod h1:Hyl3n6Twe1hvtd9XUXDec4pTvgMSEixRuQKPTMH2bNs= github.com/guregu/null v4.0.0+incompatible h1:4zw0ckM7ECd6FNNddc3Fu4aty9nTlpkkzH7dPn4/4Gw= github.com/guregu/null v4.0.0+incompatible/go.mod h1:ePGpQaN9cw0tj45IR5E5ehMvsFlLlQZAkkOXZurJ3NM= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= @@ -296,8 +282,8 @@ github.com/hashicorp/go-retryablehttp v0.7.8/go.mod h1:rjiScheydd+CxvumBsIrFKlx3 github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.8.0 h1:KAkNb1HAiZd1ukkxDFGmokVZe1Xy9HG6NUp+bPle2i4= -github.com/hashicorp/go-version v1.8.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.9.0 h1:CeOIz6k+LoN3qX9Z0tyQrPtiB1DFYRPfCIBtaXPSCnA= +github.com/hashicorp/go-version v1.9.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= @@ -311,12 +297,12 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgx/v5 v5.8.0 h1:TYPDoleBBme0xGSAX3/+NujXXtpZn9HBONkQC7IEZSo= -github.com/jackc/pgx/v5 v5.8.0/go.mod h1:QVeDInX2m9VyzvNeiCJVjCkNFqzsNb43204HshNSZKw= +github.com/jackc/pgx/v5 v5.10.0 h1:VhSvgU2jSli8o3AqIEOTJr7rZwAEUVo4E4XhR94Zfr0= +github.com/jackc/pgx/v5 v5.10.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4= github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= -github.com/jaegertracing/jaeger-idl v0.6.0 h1:LOVQfVby9ywdMPI9n3hMwKbyLVV3BL1XH2QqsP5KTMk= -github.com/jaegertracing/jaeger-idl v0.6.0/go.mod h1:mpW0lZfG907/+o5w5OlnNnig7nHJGT3SfKmRqC42HGQ= +github.com/jaegertracing/jaeger-idl v0.9.0 h1:dI4olA7ArW3cjXwVbic/aYKDbdlfe7V+9wPQqAdzu8Y= +github.com/jaegertracing/jaeger-idl v0.9.0/go.mod h1:W+9vbcr2cVZyS6z/cbr540EOzSkKYml3hmaWEavxkB0= github.com/jcchavezs/porto v0.1.0/go.mod h1:fESH0gzDHiutHRdX2hv27ojnOVFco37hg1W6E9EZF4A= github.com/jcchavezs/porto v0.7.0 h1:VncK84yxV7QZD4GdvoslzjnieSuruztGxLCmFi/Eu28= github.com/jcchavezs/porto v0.7.0/go.mod h1:tQ1cJ85cNzzZg/58VuZWOLbmrjcH1wPxkWgeBjvOq5o= @@ -346,9 +332,8 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.18.4 h1:RPhnKRAQ4Fh8zU2FY/6ZFDwTVTxgJ/EMydqSTzE9a2c= -github.com/klauspost/compress v1.18.4/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4= +github.com/klauspost/compress v1.18.6 h1:2jupLlAwFm95+YDR+NwD2MEfFO9d4z4Prjl1XXDjuao= +github.com/klauspost/compress v1.18.6/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= github.com/knadh/koanf/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs= github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/parsers/json v0.1.0 h1:dzSZl5pf5bBcW0Acnu20Djleto19T0CfHcvZ14NJ6fU= @@ -368,13 +353,13 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs= -github.com/lib/pq v1.11.2 h1:x6gxUeu39V0BHZiugWe8LXZYZ+Utk7hSJGThs8sdzfs= -github.com/lib/pq v1.11.2/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA= +github.com/lib/pq v1.12.3 h1:tTWxr2YLKwIvK90ZXEw8GP7UFHtcbTtty8zsI+YjrfQ= +github.com/lib/pq v1.12.3/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.21 h1:xYae+lCNBP7QuW4PUnNG61ffM4hVIfm+zUzDuSzYLGs= +github.com/mattn/go-isatty v0.0.21/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U= github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/goveralls v0.0.12 h1:PEEeF0k1SsTjOBQ8FOmrOAoCu4ytuMaWCnWe94zxbCg= @@ -382,8 +367,8 @@ github.com/mattn/goveralls v0.0.12/go.mod h1:44ImGEUfmqH8bBtaMrYKsM65LXfNLWmwaxF github.com/mcuadros/go-defaults v1.2.0 h1:FODb8WSf0uGaY8elWJAkoLL0Ri6AlZ1bFlenk56oZtc= github.com/mcuadros/go-defaults v1.2.0/go.mod h1:WEZtHEVIGYVDqkKSWBdWKUVdRyKlMfulPaGDWIVeCWY= github.com/microsoft/go-mssqldb v1.8.2/go.mod h1:vp38dT33FGfVotRiTmDo3bFyaHq+p3LektQrjTULowo= -github.com/microsoft/go-mssqldb v1.9.6 h1:1MNQg5UiSsokiPz3++K2KPx4moKrwIqly1wv+RyCKTw= -github.com/microsoft/go-mssqldb v1.9.6/go.mod h1:yYMPDufyoF2vVuVCUGtZARr06DKFIhMrluTcgWlXpr4= +github.com/microsoft/go-mssqldb v1.10.0 h1:pHEt+Qz6YFPWqREq10mqSE524QQo+/QremwTCQht7TY= +github.com/microsoft/go-mssqldb v1.10.0/go.mod h1:mnG7lGa9iYJbzJqGCXyuQCegStKMr3kogDLD6+bmggg= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= @@ -393,14 +378,13 @@ github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6U github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/nats-io/nats.go v1.48.0 h1:pSFyXApG+yWU/TgbKCjmm5K4wrHu86231/w84qRVR+U= -github.com/nats-io/nats.go v1.48.0/go.mod h1:iRWIPokVIFbVijxuMQq4y9ttaBTMe0SFdlZfMDd+33g= -github.com/nats-io/nkeys v0.4.15 h1:JACV5jRVO9V856KOapQ7x+EY8Jo3qw1vJt/9Jpwzkk4= -github.com/nats-io/nkeys v0.4.15/go.mod h1:CpMchTXC9fxA5zrMo4KpySxNjiDVvr8ANOSZdiNfUrs= +github.com/nats-io/nats.go v1.52.0 h1:n3avV4VBsCgsdwh71TppsTwtv+QdPs7ntSKM8qJLGsc= +github.com/nats-io/nats.go v1.52.0/go.mod h1:26HypzazeOkyO3/mqd1zZd53STJN0EjCYF9Uy2ZOBno= +github.com/nats-io/nkeys v0.4.16 h1:rd5oAuLOb8mnAycB0xleuEBNS1pVVnN0fv/FF34Eypg= +github.com/nats-io/nkeys v0.4.16/go.mod h1:llLgWoI0o4z/Q57q2R1kHfmocyhGV6VG/U18Glg1Afs= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= @@ -443,17 +427,16 @@ github.com/ory/herodot v0.10.3-0.20250318104651-3179543efba8 h1:bBFBzJ+sy1l/9+uY github.com/ory/herodot v0.10.3-0.20250318104651-3179543efba8/go.mod h1:aq2fDNzFXlh8wF6+ILtlEin2oZSrqR79/Zdsi05WEVA= github.com/ory/jsonschema/v3 v3.0.9-0.20250317235931-280c5fc7bf0e h1:4tUrC7x4YWRVMFp+c64KACNSGchW1zXo4l6Pa9/1hA8= github.com/ory/jsonschema/v3 v3.0.9-0.20250317235931-280c5fc7bf0e/go.mod h1:XWLxVK4un/iuIcrw+6lCeanbF3NZwO5k6RdLeu/loQk= -github.com/ory/pop/v6 v6.3.1 h1:d73i7e2kqxMMCgyHBkQk3TqfPBnOMS8EJd+EP5bIP6A= -github.com/ory/pop/v6 v6.3.1/go.mod h1:PEqjxMcIV87rBhlyDDha76I7/w2W/FHenSq3V3X1A/A= +github.com/ory/pop/v6 v6.4.1 h1:mxwfgwIB+kRlE4hvcoeEuxFqXZai6TWgQ23sOCBTERo= +github.com/ory/pop/v6 v6.4.1/go.mod h1:o+a3+gdnfWUd/IpFCTKidX7sRgQ6GdPmH02XYiMH8cw= github.com/ory/x v0.0.729 h1:7ttCYNCjCdspI6X0oaxGAXoiYWSBrwGRz6w/IG8s3I4= github.com/ory/x v0.0.729/go.mod h1:qdUK3Sp4K4nRbYJG0sEnFO1tDLN/Ct53G+ymre0JhCU= -github.com/paulmach/orb v0.12.0 h1:z+zOwjmG3MyEEqzv92UN49Lg1JFYx0L9GpGKNVDKk1s= -github.com/paulmach/orb v0.12.0/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU= -github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY= -github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= -github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= -github.com/pierrec/lz4/v4 v4.1.25 h1:kocOqRffaIbU5djlIBr7Wh+cx82C0vtFb0fOurZHqD0= -github.com/pierrec/lz4/v4 v4.1.25/go.mod h1:EoQMVJgeeEOMsCqCzqFm2O0cJvljX2nGZjcRIPL34O4= +github.com/paulmach/orb v0.13.0 h1:r7n7mQGGF+cj/CbcivEj9J3HGK+XR+yXnvzRdq9saIw= +github.com/paulmach/orb v0.13.0/go.mod h1:6scRWINywA2Jf05dcjOfLfxrUIMECvTSG2MVbRLxu/k= +github.com/pelletier/go-toml/v2 v2.3.1 h1:MYEvvGnQjeNkRF1qUuGolNtNExTDwct51yp7olPtrEc= +github.com/pelletier/go-toml/v2 v2.3.1/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= +github.com/pierrec/lz4/v4 v4.1.27 h1:+PhzhWDrjRj89TH2sw43nE3+4+W8lSxIuQadEHZyjUk= +github.com/pierrec/lz4/v4 v4.1.27/go.mod h1:EoQMVJgeeEOMsCqCzqFm2O0cJvljX2nGZjcRIPL34O4= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= @@ -472,11 +455,11 @@ github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UH github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= -github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4= -github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw= +github.com/prometheus/common v0.68.1 h1:omjRRl4QP4komogpXuhfeOiisQg7xdy8VM1UY+pStaY= +github.com/prometheus/common v0.68.1/go.mod h1:ZzL3f6u94qUxh9p+tJTrF+FvBS1XXbbRAZCQkytAL0Y= github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws= -github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw= +github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc= +github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo= github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 h1:bsUq1dX0N8AOIL7EB/X911+m4EHsnWEHeJ0c+3TTBrg= github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rekby/fixenv v0.6.1 h1:jUFiSPpajT4WY2cYuc++7Y1zWrnCxnovGCIX72PZniM= @@ -495,8 +478,6 @@ github.com/seatgeek/logrus-gelf-formatter v0.0.0-20210414080842-5b05eb8ff761 h1: github.com/seatgeek/logrus-gelf-formatter v0.0.0-20210414080842-5b05eb8ff761/go.mod h1:/THDZYi7F/BsVEcYzYPqdcWFQ+1C2InkawTKfLOAnzg= github.com/segmentio/asm v1.2.1 h1:DTNbBqs57ioxAD4PrArqftgypG4/qNpXoJx8TVXxPR0= github.com/segmentio/asm v1.2.1/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= -github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw= -github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w= @@ -506,8 +487,8 @@ github.com/smartystreets/assertions v1.1.0 h1:MkTeG1DMwsrdH7QtLXy5W+fUxWq+vmb6cL github.com/smartystreets/assertions v1.1.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= -github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= +github.com/sosodev/duration v1.4.0 h1:35ed0KiVFriGHHzZZJaZLgmTEEICIyt8Sx0RQfj9IjE= +github.com/sosodev/duration v1.4.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg= github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY= @@ -543,7 +524,6 @@ github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= @@ -552,40 +532,36 @@ github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaO github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg= github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= -github.com/urfave/cli/v3 v3.6.2 h1:lQuqiPrZ1cIz8hz+HcrG0TNZFxU70dPZ3Yl+pSrH9A8= -github.com/urfave/cli/v3 v3.6.2/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso= +github.com/urfave/cli/v3 v3.9.1 h1:OLU13atWZ0M+a4xmyBuBNOLZsSRYXyPeMeNjOvgYP54= +github.com/urfave/cli/v3 v3.9.1/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso= github.com/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc= github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= -github.com/vektah/gqlparser/v2 v2.5.32 h1:k9QPJd4sEDTL+qB4ncPLflqTJ3MmjB9SrVzJrawpFSc= -github.com/vektah/gqlparser/v2 v2.5.32/go.mod h1:c1I28gSOVNzlfc4WuDlqU7voQnsqI6OG2amkBAFmgts= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= -github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= +github.com/vektah/gqlparser/v2 v2.5.34 h1:MEea5P0qhdcqfBL45ghKE+qr9laidVHTMHjav5h7ckk= +github.com/vektah/gqlparser/v2 v2.5.34/go.mod h1:mFdHLGCio7OGX1fby9ZjTW6FN+qxgmbnBcRIeeScE5s= github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/yandex-cloud/go-genproto v0.0.0-20211115083454-9ca41db5ed9e h1:9LPdmD1vqadsDQUva6t2O9MbnyvoOgo8nFNPaOIH5U8= github.com/yandex-cloud/go-genproto v0.0.0-20211115083454-9ca41db5ed9e/go.mod h1:HEUYX/p8966tMUHHT+TsS0hF/Ca/NYwqprC5WXSDMfE= github.com/ydb-platform/gorm-driver v0.2.0 h1:H+l2FN+GvJcxUqOG0rpYbuWVJzgMmTAdWtoYYQvwDo4= github.com/ydb-platform/gorm-driver v0.2.0/go.mod h1:sAazHSkcJvZV8TztvnwMwLF+uWfgpF6QxTUClkNjLTw= -github.com/ydb-platform/ydb-go-genproto v0.0.0-20260128080146-c4ed16b24b37 h1:kUXMT/fM/DpDT66WQgRUf3I8VOAWjypkMf52W5PChwA= -github.com/ydb-platform/ydb-go-genproto v0.0.0-20260128080146-c4ed16b24b37/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I= +github.com/ydb-platform/ydb-go-genproto v0.0.0-20260428144813-1c07baab7f7b h1:xeiobG1riqe6dTMZuTcOvwOY0BbFidSk3gRLyVeLfJA= +github.com/ydb-platform/ydb-go-genproto v0.0.0-20260428144813-1c07baab7f7b/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I= github.com/ydb-platform/ydb-go-sdk-auth-environ v0.5.0 h1:/NyPd9KnCJgzrEXCArqk1ThqCH2Dh31uUwl88o/VkuM= github.com/ydb-platform/ydb-go-sdk-auth-environ v0.5.0/go.mod h1:9YzkhlIymWaJGX6KMU3vh5sOf3UKbCXkG/ZdjaI3zNM= -github.com/ydb-platform/ydb-go-sdk/v3 v3.126.5 h1:e/PXq6Eh3Zos8KMxqmLgXSyu9LMS3LaASsoZHsYwNy8= -github.com/ydb-platform/ydb-go-sdk/v3 v3.126.5/go.mod h1:stS1mQYjbJvwwYaYzKyFY9eMiuVXWWXQA6T+SpOLg9c= +github.com/ydb-platform/ydb-go-sdk/v3 v3.139.6 h1:rwhGamSuhSBCMWzd/usiASZU95SFSWkuf/6rmX88h80= +github.com/ydb-platform/ydb-go-sdk/v3 v3.139.6/go.mod h1:b9NEO6mgaiqsnOMkS003uS82XsKh6GL+ZTFfPqXWz+c= github.com/ydb-platform/ydb-go-yc v0.12.1 h1:qw3Fa+T81+Kpu5Io2vYHJOwcrYrVjgJlT6t/0dOXJrA= github.com/ydb-platform/ydb-go-yc v0.12.1/go.mod h1:t/ZA4ECdgPWjAb4jyDe8AzQZB5dhpGbi3iCahFaNwBY= github.com/ydb-platform/ydb-go-yc-metadata v0.6.1 h1:9E5q8Nsy2RiJMZDNVy0A3KUrIMBPakJ2VgloeWbcI84= github.com/ydb-platform/ydb-go-yc-metadata v0.6.1/go.mod h1:NW4LXW2WhY2tLAwCBHBuHAwRUVF5lsscaSPjdAFKldc= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/gopher-lua v0.0.0-20191220021717-ab39c6098bdb/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ= github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA= -github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M= -github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= +github.com/yuin/gopher-lua v1.1.2 h1:yF/FjE3hD65tBbt0VXLE13HWS9h34fdzJmrWRXwobGA= +github.com/yuin/gopher-lua v1.1.2/go.mod h1:7aRmXIWl37SqRf0koeyylBEzJ+aPt8A+mmkQ4f1ntR8= go.elastic.co/apm v1.15.0 h1:uPk2g/whK7c7XiZyz/YCUnAUBNPiyNeE3ARX3G6Gx7Q= go.elastic.co/apm v1.15.0/go.mod h1:dylGv2HKR0tiCV+wliJz1KHtDyuD8SPe69oV7VyK6WY= go.elastic.co/apm/module/apmhttp v1.15.0 h1:Le/DhI0Cqpr9wG/NIGOkbz7+rOMqJrfE4MRG6q/+leU= @@ -597,59 +573,57 @@ go.elastic.co/ecszap v1.0.3/go.mod h1:fM1RLWDU25TB/L48RUJgz5Le2AnoCeY/g0zf2op8gD go.elastic.co/fastjson v1.1.0/go.mod h1:boNGISWMjQsUPy/t6yqt2/1Wx4YNPSe+mZjlyw9vKKI= go.elastic.co/fastjson v1.5.1 h1:zeh1xHrFH79aQ6Xsw7YxixvnOdAl3OSv0xch/jRDzko= go.elastic.co/fastjson v1.5.1/go.mod h1:WtvH5wz8z9pDOPqNYSYKoLLv/9zCWZLeejHWuvdL/EM= -go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= -go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.65.0 h1:ab5U7DpTjjN8pNgwqlA/s0Csb+N2Raqo9eTSDhfg4Z8= -go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.65.0/go.mod h1:nwFJC46Dxhqz5R9k7IV8To/Z46JPvW+GNKhTxQQlUzg= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.65.0 h1:7iP2uCb7sGddAr30RRS6xjKy7AZ2JtTOPA3oolgVSw8= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.65.0/go.mod h1:c7hN3ddxs/z6q9xwvfLPk+UHlWRQyaeR1LdgfL/66l0= -go.opentelemetry.io/contrib/propagators/b3 v1.40.0 h1:xariChe8OOVF3rNlfzGFgQc61npQmXhzZj/i82mxMfg= -go.opentelemetry.io/contrib/propagators/b3 v1.40.0/go.mod h1:72WvbdxbOfXaELEQfonFfOL6osvcVjI7uJEE8C2nkrs= -go.opentelemetry.io/contrib/propagators/jaeger v1.40.0 h1:aXl9uobjJs5vquMLt9ZkI/3zIuz8XQ3TqOKSWx0/xdU= -go.opentelemetry.io/contrib/propagators/jaeger v1.40.0/go.mod h1:ioMePqe6k6c/ovXSkmkMr1mbN5qRBGJxNTVop7/2XO0= -go.opentelemetry.io/contrib/samplers/jaegerremote v0.34.0 h1:RZjNfF9OoR4oPLEWaP+Memql2MNVkZvnwjB2N5tR3cA= -go.opentelemetry.io/contrib/samplers/jaegerremote v0.34.0/go.mod h1:b5U9IcSnv+lMvEcSOXZB61kXSf0KkwickleKWuAQclw= -go.opentelemetry.io/otel v1.40.0 h1:oA5YeOcpRTXq6NN7frwmwFR0Cn3RhTVZvXsP4duvCms= -go.opentelemetry.io/otel v1.40.0/go.mod h1:IMb+uXZUKkMXdPddhwAHm6UfOwJyh4ct1ybIlV14J0g= +go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.69.0 h1:MCcYL7J6Vt/X0kjqbMZkekCmwsurbQRbL69vkiye2lk= +go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.69.0/go.mod h1:3jnStNwSufK+f5ktjL4EPcwtig4rtd81NS70lqHuXl8= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 h1:8tvICD4vSTOOsNrsI4Ljf6C+6UKvpTEH5XY3JMoyPoo= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0/go.mod h1:z9+yiacE0IHRqM4qFfkbt/JYlmYXgss8GY/jXoNuPJI= +go.opentelemetry.io/contrib/propagators/b3 v1.44.0 h1:1IFH4oFKK8KupzIelCl3u+bkxpGRps1oWRjQI2+TTWs= +go.opentelemetry.io/contrib/propagators/b3 v1.44.0/go.mod h1:JqWFXsc7VDaqIyubFhEd2cPHqsrzqP0Lvn783SUwyro= +go.opentelemetry.io/contrib/propagators/jaeger v1.44.0 h1:OyzvsAMc/zHt0DRPcfstn0wgfq8ApDkeY0ABMcueweM= +go.opentelemetry.io/contrib/propagators/jaeger v1.44.0/go.mod h1:44kghcGX+BNxy9UTiWtd6VDt8Nd4EypGBkH2+v2Dqrc= +go.opentelemetry.io/contrib/samplers/jaegerremote v0.37.1 h1:pV2nZ1iE87X9ym+crkD9k15zTLbN08+IC4C7sk9sQYM= +go.opentelemetry.io/contrib/samplers/jaegerremote v0.37.1/go.mod h1:nvgrM8LaG2+5G7WxbtjEPiSkg87+d0/ltZZK70p7FVo= +go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU= +go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc= go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4= go.opentelemetry.io/otel/exporters/jaeger v1.17.0/go.mod h1:nPCqOnEH9rNLKqH/+rrUjiMzHJdV1BlpKcTwRTyKkKI= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0 h1:QKdN8ly8zEMrByybbQgv8cWBcdAarwmIPZ6FThrWXJs= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0/go.mod h1:bTdK1nhqF76qiPoCCdyFIV+N/sRHYXYCTQc+3VCi3MI= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.40.0 h1:wVZXIWjQSeSmMoxF74LzAnpVQOAFDo3pPji9Y4SOFKc= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.40.0/go.mod h1:khvBS2IggMFNwZK/6lEeHg/W57h/IX6J4URh57fuI40= -go.opentelemetry.io/otel/exporters/zipkin v1.40.0 h1:zu+I4j+FdO6xIxBVPeuncQVbjxUM4LiMgv6GwGe9REE= -go.opentelemetry.io/otel/exporters/zipkin v1.40.0/go.mod h1:zS6cC4nFBYXbu18e7aLfMzubBjOiN7ZcROu477qtMf8= -go.opentelemetry.io/otel/metric v1.40.0 h1:rcZe317KPftE2rstWIBitCdVp89A2HqjkxR3c11+p9g= -go.opentelemetry.io/otel/metric v1.40.0/go.mod h1:ib/crwQH7N3r5kfiBZQbwrTge743UDc7DTFVZrrXnqc= -go.opentelemetry.io/otel/sdk v1.40.0 h1:KHW/jUzgo6wsPh9At46+h4upjtccTmuZCFAc9OJ71f8= -go.opentelemetry.io/otel/sdk v1.40.0/go.mod h1:Ph7EFdYvxq72Y8Li9q8KebuYUr2KoeyHx0DRMKrYBUE= -go.opentelemetry.io/otel/sdk/metric v1.40.0 h1:mtmdVqgQkeRxHgRv4qhyJduP3fYJRMX4AtAlbuWdCYw= -go.opentelemetry.io/otel/sdk/metric v1.40.0/go.mod h1:4Z2bGMf0KSK3uRjlczMOeMhKU2rhUqdWNoKcYrtcBPg= -go.opentelemetry.io/otel/trace v1.40.0 h1:WA4etStDttCSYuhwvEa8OP8I5EWu24lkOzp+ZYblVjw= -go.opentelemetry.io/otel/trace v1.40.0/go.mod h1:zeAhriXecNGP/s2SEG3+Y8X9ujcJOTqQ5RgdEJcawiA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0 h1:4YsVu3B8+3qtWYYrsUYgn0OG78pN0rnNPRGX4SbokQI= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0/go.mod h1:+wnlSn0mD1ADVMe3v9Z/WIaiz6q6gL2J/ejaAmdmv80= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.44.0 h1:lgh3PiVrRUWMLOVSkQicxzZll5NjF1r+AtsX1XRIHw0= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.44.0/go.mod h1:5Cnhth3m/AgOeTgE3ex12pPmiu/gGtZit03kSzx9X7s= +go.opentelemetry.io/otel/exporters/zipkin v1.44.0 h1:zv7PRYGLrQHkdeZj0c5SNAZOJcw55XgaTezUkNpwA+w= +go.opentelemetry.io/otel/exporters/zipkin v1.44.0/go.mod h1:3+VZyCi6hFW+UuxFF+wSOvwsOwncfBpQfP7Qdb3JXKg= +go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc= +go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo= +go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58= +go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0= +go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI= +go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA= +go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk= +go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A= -go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4= +go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g= +go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= -go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= +go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= +go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= -go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= -go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= +go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo= +go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q= +go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= +go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= @@ -660,11 +634,11 @@ golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOM golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= -golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts= -golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos= +golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto= +golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa h1:Zt3DZoOFFYkKhDT3v7Lm9FDMEV06GpzjG2jrqW+QTE0= -golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa/go.mod h1:K79w1Vqn7PoiZn+TkNpx3BUWUQksGO3JcVX6qIjytmA= +golang.org/x/exp v0.0.0-20260611194520-c48552f49976 h1:X8Hz2ImujgbmetVuW+w2YkyZChE3cBpZi2P158rTG9M= +golang.org/x/exp v0.0.0-20260611194520-c48552f49976/go.mod h1:vnf4pv9iKZXY58sQE1L86zmNWJ4159e1RkcWiLCkeEY= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= @@ -682,8 +656,8 @@ golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8= -golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w= +golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ= +golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -700,7 +674,6 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= @@ -716,12 +689,12 @@ golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= -golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60= -golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM= +golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o= +golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.35.0 h1:Mv2mzuHuZuY2+bkyWXIHMfhNdJAdwW3FuWeCPYN5GVQ= -golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= +golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= +golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -735,8 +708,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= -golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= +golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -753,7 +726,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -775,11 +747,11 @@ golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k= -golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= +golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= -golang.org/x/telemetry v0.0.0-20260213145524-e0ab670178e1 h1:QNaHp8YvpPswfDNxlCmJyeesxbGOgaKf41iT9/QrErY= -golang.org/x/telemetry v0.0.0-20260213145524-e0ab670178e1/go.mod h1:NuITXsA9cTiqnXtVk+/wrBT2Ja4X5hsfGOYRJ6kgYjs= +golang.org/x/telemetry v0.0.0-20260611141451-d61e87d5f4a3 h1:npLQMrOn2MsmuA1yJESQ+woxUfrPCRTSjODXQu2ltow= +golang.org/x/telemetry v0.0.0-20260611141451-d61e87d5f4a3/go.mod h1:3AWMyWHS+caVoiEXpiq6+tzKA40J4vQT3MYr80ZtQpc= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -798,7 +770,6 @@ golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= @@ -810,8 +781,8 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= -golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk= -golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA= +golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE= +golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -830,24 +801,24 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k= -golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0= +golang.org/x/tools v0.46.0 h1:7jTurBkPZu4moS/Uy4OQT1M+QBlsj3wejyZwsT8Z7rk= +golang.org/x/tools v0.46.0/go.mod h1:FrD85F8l+NWL+9XWBSyVSHO6Ne4jutsfIFba7AWQ5Ys= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= +gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= +gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto/googleapis/api v0.0.0-20260217215200-42d3e9bedb6d h1:EocjzKLywydp5uZ5tJ79iP6Q0UjDnyiHkGRWxuPBP8s= -google.golang.org/genproto/googleapis/api v0.0.0-20260217215200-42d3e9bedb6d/go.mod h1:48U2I+QQUYhsFrg2SY6r+nJzeOtjey7j//WBESw+qyQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260217215200-42d3e9bedb6d h1:t/LOSXPJ9R0B6fnZNyALBRfZBH0Uy0gT+uR+SJ6syqQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260217215200-42d3e9bedb6d/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= +google.golang.org/genproto/googleapis/api v0.0.0-20260610212136-7ab31c22f7ad h1:3iLyITS/sySRwbUKoC7ogfj2Yr1Cjs0pfaRKj5U5HEw= +google.golang.org/genproto/googleapis/api v0.0.0-20260610212136-7ab31c22f7ad/go.mod h1:KdNqO+rCIWgFumrNBSEDlDNrkrQnpkax7Tv1WxNY8V4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260610212136-7ab31c22f7ad h1:45WmJvIV6C2+O/jjLkPUH+F3aOj/1miDoU2DD0+NWbg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260610212136-7ab31c22f7ad/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= @@ -855,8 +826,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.79.1 h1:zGhSi45ODB9/p3VAawt9a+O/MULLl9dpizzNNpq7flY= -google.golang.org/grpc v1.79.1/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ= +google.golang.org/grpc v1.81.1 h1:VnnIIZ88UzOOKLukQi+ImGz8O1Wdp8nAGGnvOfEIWQQ= +google.golang.org/grpc v1.81.1/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/model/account_social.go b/model/account_social.go deleted file mode 100644 index d4d4bdf7..00000000 --- a/model/account_social.go +++ /dev/null @@ -1,52 +0,0 @@ -package model - -import ( - "time" - - "github.com/geniusrabbit/gosql/v2" - "gorm.io/gorm" -) - -// AccountSocial object represents a social network account -type AccountSocial struct { - ID uint64 `db:"id" gorm:"primaryKey"` - UserID uint64 `db:"user_id"` - User *User `db:"-" gorm:"foreignKey:UserID"` - - SocialID string `db:"social_id"` // social network user id - Provider string `db:"provider"` // facebook, google, twitter, github, etc - Email string `db:"email"` - FirstName string `db:"first_name"` - LastName string `db:"last_name"` - Username string `db:"username"` - Avatar string `db:"avatar"` - Link string `db:"link"` - - // Data is a JSON object with additional data - Data gosql.NullableJSON[map[string]any] `db:"data" gorm:"type:jsonb"` - - // Sessions list linked to the account - Sessions []*AccountSocialSession `db:"-" gorm:"foreignKey:AccountSocialID;references:ID"` - - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` - DeletedAt gorm.DeletedAt `db:"deleted_at"` -} - -// TableName in database -func (m *AccountSocial) TableName() string { - return `account_social` -} - -// RBACResourceName returns the name of the resource for the RBAC -func (m *AccountSocial) RBACResourceName() string { - return `account_social` -} - -// CreatorUserID returns the ID of the owner of the resource -func (m *AccountSocial) CreatorUserID() uint64 { - if m == nil { - return 0 - } - return m.UserID -} diff --git a/model/account_social_sessiong.go b/model/account_social_sessiong.go deleted file mode 100644 index fcccb35e..00000000 --- a/model/account_social_sessiong.go +++ /dev/null @@ -1,30 +0,0 @@ -package model - -import ( - "time" - - "github.com/geniusrabbit/gosql/v2" - "github.com/guregu/null" - "gorm.io/gorm" -) - -type AccountSocialSession struct { - // Unique name of the session to destinguish between different sessions with different scopes - Name string `db:"name" gorm:"primaryKey"` - AccountSocialID uint64 `db:"account_social_id" gorm:"primaryKey;autoIncrement:false"` - - TokenType string `db:"token_type" json:"token_type,omitempty"` - AccessToken string `db:"access_token" json:"access_token"` - RefreshToken string `db:"refresh_token" json:"refresh_token"` - Scopes gosql.NullableStringArray `db:"scopes" json:"scopes,omitempty" gorm:"type:text[]"` - - CreatedAt time.Time `db:"created_at" json:"created_at"` - UpdatedAt time.Time `db:"updated_at" json:"updated_at"` - ExpiresAt null.Time `db:"expires_at" json:"expires_at,omitempty"` - DeletedAt gorm.DeletedAt `db:"deleted_at" json:"deleted_at,omitempty"` -} - -// TableName in database -func (m *AccountSocialSession) TableName() string { - return `account_social_session` -} diff --git a/model/option.go b/model/option.go deleted file mode 100644 index 5cab4937..00000000 --- a/model/option.go +++ /dev/null @@ -1,49 +0,0 @@ -package model - -import ( - "time" - - "github.com/geniusrabbit/gosql/v2" - "gorm.io/gorm" -) - -type OptionType string - -const ( - UndefinedOptionType OptionType = "undefined" - UserOptionType OptionType = "user" - AccountOptionType OptionType = "account" - SystemOptionType OptionType = "system" -) - -type Option struct { - Type OptionType `json:"type"` - TargetID uint64 `json:"target_id"` - Name string `json:"name"` - Value gosql.NullableJSON[any] `json:"value" gorm:"type:jsonb"` - - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` - DeletedAt gorm.DeletedAt `db:"deleted_at"` -} - -func (o *Option) TableName() string { return "option" } - -func (o *Option) CreatorUserID() uint64 { - if o != nil && o.Type == UserOptionType { - return o.TargetID - } - return 0 -} - -func (o *Option) OwnerAccountID() uint64 { - if o != nil && o.Type == AccountOptionType { - return o.TargetID - } - return 0 -} - -// RBACResourceName returns the name of the resource for the RBAC -func (o *Option) RBACResourceName() string { - return "option" -} diff --git a/pkg/auth/authorizer.go b/pkg/auth/authorizer.go index 5a083a1a..5448c327 100644 --- a/pkg/auth/authorizer.go +++ b/pkg/auth/authorizer.go @@ -4,35 +4,51 @@ import ( "net/http" "github.com/demdxx/xtypes" - - "github.com/geniusrabbit/blaze-api/model" ) -type Authorizer interface { +// IsNillable describes a type that can report whether it is nil/empty. +type IsNillable interface { + IsNil() bool +} + +// Authorizer defines a single authorization strategy. +type Authorizer[User IsNillable, Account IsNillable] interface { + // AuthorizerCode returns a unique identifier for the authorizer. AuthorizerCode() string - Authorize(w http.ResponseWriter, r *http.Request) (string /* token */, *model.User, *model.Account, error) + // Authorize validates request credentials and returns token, user, account, and error. + Authorize(w http.ResponseWriter, r *http.Request) (string /* token */, User, Account, error) } -type AuthorizeWrapper struct { - authorizers []Authorizer +// AuthorizeWrapper combines multiple authorizers and executes them in order. +type AuthorizeWrapper[User IsNillable, Account IsNillable] struct { + authorizers []Authorizer[User, Account] } -func NewAuthorizeWrapper(authorizers ...Authorizer) *AuthorizeWrapper { - return &AuthorizeWrapper{ - authorizers: xtypes.Slice[Authorizer](authorizers). - Filter(func(a Authorizer) bool { return a != nil }), +// NewAuthorizeWrapper creates a wrapper from the provided non-nil authorizers. +func NewAuthorizeWrapper[User IsNillable, Account IsNillable](authorizers ...Authorizer[User, Account]) *AuthorizeWrapper[User, Account] { + return &AuthorizeWrapper[User, Account]{ + authorizers: xtypes.Slice[Authorizer[User, Account]](authorizers). + Filter(func(a Authorizer[User, Account]) bool { return a != nil }), } } -func (a *AuthorizeWrapper) Authorize(w http.ResponseWriter, r *http.Request) (string, *model.User, *model.Account, error) { +// Authorize runs each authorizer until one returns a non-nil user or account. +// If any authorizer returns an error, authorization stops and the error is returned. +func (a *AuthorizeWrapper[User, Account]) Authorize(w http.ResponseWriter, r *http.Request) (string, User, Account, error) { + var ( + zeroUser User + zeroAccount Account + ) + for _, authorizer := range a.authorizers { token, user, account, err := authorizer.Authorize(w, r) if err != nil { - return token, nil, nil, err + return token, zeroUser, zeroAccount, err } - if user != nil || account != nil { + if !user.IsNil() || !account.IsNil() { return token, user, account, nil } } - return "", nil, nil, nil + + return "", zeroUser, zeroAccount, nil } diff --git a/pkg/auth/authutils/account.go b/pkg/auth/authutils/account.go deleted file mode 100644 index 315df5c4..00000000 --- a/pkg/auth/authutils/account.go +++ /dev/null @@ -1,63 +0,0 @@ -package authutils - -import ( - "context" - "errors" - - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/pkg/context/session" - accountRepository "github.com/geniusrabbit/blaze-api/repository/account/repository" - userRepository "github.com/geniusrabbit/blaze-api/repository/user/repository" -) - -var ( - errAuthUserIsNotMemberOfAccount = errors.New("user is not a member of the account") - errNoCrossAuthPermission = errors.New("user don't have cross auth permissions") -) - -func UserAccountByID(ctx context.Context, uid, accid uint64, preUser *model.User, prevAccount *model.Account) (*model.User, *model.Account, error) { - var ( - err error - users = userRepository.New() - accounts = accountRepository.New() - account = prevAccount - userObj = preUser - ) - if uid > 0 && (preUser == nil || preUser.ID != uid) { - if userObj, err = users.Get(ctx, uid); err != nil { - return nil, nil, err - } - } - if accid > 0 && (prevAccount == nil || prevAccount.ID != accid) { - if account, err = accounts.Get(ctx, accid); err != nil { - return nil, nil, err - } - } - if account != nil { - if userObj != nil && !accounts.IsMember(ctx, userObj.ID, account.ID) { - return nil, nil, errAuthUserIsNotMemberOfAccount - } - if prevAccount != nil && prevAccount.ID != account.ID && - !prevAccount.CheckPermissions(ctx, account, session.PermAuthCross) { - return nil, nil, errNoCrossAuthPermission - } - err = accounts.LoadPermissions(ctx, account, userObj) - if err != nil { - return nil, nil, err - } - if prevAccount != nil { - account.ExtendPermissions(prevAccount.Permissions) - } - } - return userObj, account, nil -} - -func CrossAccountConnect(ctx context.Context, crossAccountID string, userObj *model.User, accountObj *model.Account) (*model.User, *model.Account, error) { - if crossAccountID != "" { - userID, accountID := session.ParseCrossAuthHeader(crossAccountID) - if userID > 0 || accountID > 0 { - return UserAccountByID(ctx, userID, accountID, userObj, accountObj) - } - } - return userObj, accountObj, nil -} diff --git a/pkg/auth/devtoken/authorizer.go b/pkg/auth/devtoken/authorizer.go deleted file mode 100644 index d687500c..00000000 --- a/pkg/auth/devtoken/authorizer.go +++ /dev/null @@ -1,53 +0,0 @@ -package devtoken - -import ( - "net/http" - - "github.com/demdxx/gocast/v2" - "go.uber.org/zap" - - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/pkg/auth/authutils" - "github.com/geniusrabbit/blaze-api/pkg/auth/tokenextractor" - "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" -) - -type Authorizer struct { - options AuthOption -} - -func NewAuthorizer(opts *AuthOption) *Authorizer { - return &Authorizer{ - options: gocast.IfThenExec(opts != nil, - func() AuthOption { return *opts }, - func() AuthOption { return AuthOption{} }), - } -} - -func (au *Authorizer) AuthorizerCode() string { - return "devtoken" -} - -func (au *Authorizer) Authorize(w http.ResponseWriter, r *http.Request) (string, *model.User, *model.Account, error) { - if au.options.DevToken == "" { - return "", nil, nil, nil - } - ctx := r.Context() - token, err := tokenextractor.DefaultExtractor(r) - if err != nil { - ctxlogger.Get(r.Context()).Error("token extraction", zap.Error(err)) - return "", nil, nil, nil - } - if token == "" { - return "", nil, nil, nil - } - if au.options.DevToken == token { - usr, acc, err := authutils.UserAccountByID(ctx, au.options.DevUserID, au.options.DevAccountID, nil, nil) - if err != nil { - ctxlogger.Get(r.Context()).Error("get user acc", zap.Error(err)) - return "", nil, nil, nil - } - return token, usr, acc, nil - } - return "", nil, nil, nil -} diff --git a/pkg/auth/devtoken/token.go b/pkg/auth/devtoken/token.go deleted file mode 100644 index a1bce699..00000000 --- a/pkg/auth/devtoken/token.go +++ /dev/null @@ -1,8 +0,0 @@ -package devtoken - -// AuthOption to access to default user -type AuthOption struct { - DevToken string - DevUserID uint64 - DevAccountID uint64 -} diff --git a/pkg/auth/directtoken/authorize.go b/pkg/auth/directtoken/authorize.go deleted file mode 100644 index d7c02d57..00000000 --- a/pkg/auth/directtoken/authorize.go +++ /dev/null @@ -1,36 +0,0 @@ -package directtoken - -import ( - "net/http" - - "go.uber.org/zap" - - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/pkg/auth/tokenextractor" - "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" - userRepository "github.com/geniusrabbit/blaze-api/repository/user/repository" -) - -type Authorizer struct{} - -func NewAuthorizer() *Authorizer { - return &Authorizer{} -} - -func (au *Authorizer) AuthorizerCode() string { - return "directtoken" -} - -func (au *Authorizer) Authorize(w http.ResponseWriter, r *http.Request) (string, *model.User, *model.Account, error) { - ctx := r.Context() - token, err := tokenextractor.DefaultExtractor(r) - if err != nil { - ctxlogger.Get(r.Context()).Error("token extraction", zap.Error(err)) - return "", nil, nil, nil - } - if token == "" { - return "", nil, nil, nil - } - userObj, accountObj, err := userRepository.New().GetByToken(ctx, token) - return token, userObj, accountObj, err -} diff --git a/pkg/auth/elogin/auth_accessor.go b/pkg/auth/elogin/auth_accessor.go index 10d851c9..7467e8a6 100644 --- a/pkg/auth/elogin/auth_accessor.go +++ b/pkg/auth/elogin/auth_accessor.go @@ -5,9 +5,21 @@ import ( "net/url" ) +// AuthAccessor defines the interface for authentication providers. +// It handles OAuth/login flow operations like generating login URLs +// and exchanging codes for user data. type AuthAccessor interface { + // Provider returns the name of the authentication provider (e.g., "google", "github"). Provider() string + + // Protocol returns the protocol used by the provider (e.g., "oauth2", "saml"). Protocol() string + + // LoginURL generates the login URL with the provided URL parameters. LoginURL(urlParams []URLParam) string + + // UserData exchanges authentication values for user information and token. + // It takes a context, URL values from the callback, and URL parameters, + // returning the token, user data, or an error. UserData(ctx context.Context, values url.Values, urlParams []URLParam) (*Token, *UserData, error) } diff --git a/pkg/auth/elogin/auth_http_wrapper.go b/pkg/auth/elogin/auth_http_wrapper.go index ecb90c32..d8f54554 100644 --- a/pkg/auth/elogin/auth_http_wrapper.go +++ b/pkg/auth/elogin/auth_http_wrapper.go @@ -4,24 +4,28 @@ import ( "net/http" ) +// URLParam represents a URL parameter with a key-value pair type URLParam struct { Key string Value string } +// ErrorHandler defines the interface for handling authentication errors type ErrorHandler interface { Error(w http.ResponseWriter, r *http.Request, err error) } +// SuccessHandler defines the interface for handling successful authentication type SuccessHandler interface { Success(w http.ResponseWriter, r *http.Request, token *Token, data *UserData) } +// RedirectParamsExtractor defines the interface for extracting redirect parameters type RedirectParamsExtractor interface { RedirectParams(w http.ResponseWriter, r *http.Request, login bool) []URLParam } -// AuthHTTPWrapper provides a wrapper for auth authentication +// AuthHTTPWrapper provides HTTP handler wrapping for authentication flows type AuthHTTPWrapper struct { Auth AuthAccessor Error ErrorHandler @@ -39,17 +43,17 @@ func NewWrapper(auth AuthAccessor, err ErrorHandler, success SuccessHandler, red } } -// Protocol returns the protocol name +// Protocol returns the authentication protocol name func (wr *AuthHTTPWrapper) Protocol() string { return wr.Auth.Protocol() } -// Provider returns the provider name +// Provider returns the authentication provider name func (wr *AuthHTTPWrapper) Provider() string { return wr.Auth.Provider() } -// HandleWrapper returns the http handler which handles the auth authentication +// HandleWrapper returns an HTTP handler for the authentication routes func (wr *AuthHTTPWrapper) HandleWrapper(prefix string) http.Handler { mux := http.NewServeMux() mux.HandleFunc("/login", wr.Login) @@ -60,19 +64,19 @@ func (wr *AuthHTTPWrapper) HandleWrapper(prefix string) http.Handler { return mux } -// Login handles the login request +// Login handles the login request and redirects to the provider func (wr *AuthHTTPWrapper) Login(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, wr.Auth.LoginURL(wr.rediParams(w, r, true)), http.StatusTemporaryRedirect) + http.Redirect(w, r, wr.Auth.LoginURL(wr.redirectParams(w, r, true)), http.StatusTemporaryRedirect) } -// Callback handles the callback request +// Callback handles the provider callback and authenticates the user func (wr *AuthHTTPWrapper) Callback(w http.ResponseWriter, r *http.Request) { if err := r.ParseForm(); err != nil { wr.Error.Error(w, r, err) return } - token, data, err := wr.Auth.UserData(r.Context(), r.Form, wr.rediParams(w, r, false)) + token, data, err := wr.Auth.UserData(r.Context(), r.Form, wr.redirectParams(w, r, false)) if err != nil { wr.Error.Error(w, r, err) return @@ -80,7 +84,8 @@ func (wr *AuthHTTPWrapper) Callback(w http.ResponseWriter, r *http.Request) { wr.Success.Success(w, r, token, data) } -func (wr *AuthHTTPWrapper) rediParams(w http.ResponseWriter, r *http.Request, isLogin bool) []URLParam { +// redirectParams retrieves redirect parameters from the extractor +func (wr *AuthHTTPWrapper) redirectParams(w http.ResponseWriter, r *http.Request, isLogin bool) []URLParam { if wr.RedirectParams != nil { return wr.RedirectParams.RedirectParams(w, r, isLogin) } diff --git a/pkg/auth/elogin/facebook/acessor.go b/pkg/auth/elogin/facebook/acessor.go index 65582e55..c9108737 100644 --- a/pkg/auth/elogin/facebook/acessor.go +++ b/pkg/auth/elogin/facebook/acessor.go @@ -16,6 +16,7 @@ import ( const facebookMeURL = "https://graph.facebook.com/v19.0/me?fields=id,name,email,picture&access_token=" +// facebookUserDetails represents the user data structure returned by Facebook API. type facebookUserDetails struct { ID string `json:"id"` Name string `json:"name"` @@ -30,11 +31,13 @@ type facebookUserDetails struct { } `json:"picture"` } +// FirstName extracts and returns the first name from the full name. func (dt *facebookUserDetails) FirstName() string { name := strings.Split(dt.Name, " ") return name[0] } +// LastName extracts and returns the last name from the full name. func (dt *facebookUserDetails) LastName() string { name := strings.Split(dt.Name, " ") if len(name) == 1 { @@ -43,10 +46,11 @@ func (dt *facebookUserDetails) LastName() string { return name[1] } -// FacebookUserData returns user data from Facebook API using access token +// FacebookUserData fetches user data from Facebook API using the provided access token. func FacebookUserData(ctx context.Context, token *oauth2.Token, oauth2conf *oauth2.Config) (*elogin.UserData, error) { var fbUserDetails facebookUserDetails + // Create request to fetch user details from Facebook API. fbUserDetailsRequest, _ := http.NewRequest("GET", facebookMeURL+url.QueryEscape(token.AccessToken), nil) fbUserDetailsResp, fbUserDetailsRespError := http.DefaultClient.Do(fbUserDetailsRequest) @@ -57,6 +61,7 @@ func FacebookUserData(ctx context.Context, token *oauth2.Token, oauth2conf *oaut _ = fbUserDetailsResp.Body.Close() }() + // Decode the JSON response into facebookUserDetails struct. decoderErr := json.NewDecoder(fbUserDetailsResp.Body).Decode(&fbUserDetails) if decoderErr != nil { return nil, errors.Wrap(decoderErr, "Error occurred while getting information from Facebook") @@ -73,7 +78,7 @@ func FacebookUserData(ctx context.Context, token *oauth2.Token, oauth2conf *oaut }, nil } -// NewFacebookConfig creates a new instance of Facebook oauth2 configuration +// NewFacebookConfig creates and returns a new Facebook OAuth2 configuration instance. func NewFacebookConfig(conf *oauth2.Config) *oa2.Config { return &oa2.Config{ ProviderName: "facebook", diff --git a/pkg/auth/elogin/oauth2/config.go b/pkg/auth/elogin/oauth2/config.go index 2a68aeb3..d3257eb2 100644 --- a/pkg/auth/elogin/oauth2/config.go +++ b/pkg/auth/elogin/oauth2/config.go @@ -12,61 +12,66 @@ import ( "github.com/geniusrabbit/blaze-api/pkg/auth/elogin/utils" ) -// DataExtractor provides a function to extract user data from oauth2 token +// DataExtractor extracts user data from an OAuth2 token. type DataExtractor func(ctx context.Context, token *oauth2.Token, oauth2conf *oauth2.Config) (*elogin.UserData, error) -// Config provides a configuration for oauth2 authentication +// Config holds the OAuth2 authentication configuration. type Config struct { - ProviderName string - OAuth2 *oauth2.Config - Extractor DataExtractor - StateCode string + ProviderName string // Name of the OAuth2 provider + OAuth2 *oauth2.Config // OAuth2 configuration + Extractor DataExtractor // Function to extract user data from token + StateCode string // State code for CSRF protection } -// Protocol returns the protocol name +// Protocol returns the authentication protocol name. func (c *Config) Protocol() string { return "oauth2" } -// Provider returns the provider name +// Provider returns the OAuth2 provider name. func (c *Config) Provider() string { return c.ProviderName } -// LoginURL returns the login url +// LoginURL generates the OAuth2 login URL with the provided parameters. func (c *Config) LoginURL(params []elogin.URLParam) string { state := utils.NewState(utils.Param{Key: "sc", Value: c.StateCode}) - // reauthorize - always has for permissions - // rerequest - for declined/revoked permissions - // reauthenticate - always as user to confirm password + + // OAuth2 auth type options: + // - rerequest: for declined/revoked permissions + // - reauthorize: always requires permissions + // - reauthenticate: always confirms password opts := make([]oauth2.AuthCodeOption, 0, 2) opts = append(opts, oauth2.SetAuthURLParam("auth_type", "rerequest")) + + // Process additional parameters for _, param := range params { if param.Key == "scope" { opts = append(opts, oauth2.SetAuthURLParam("scope", param.Value)) } state = state.Extend(param.Key, param.Value) } + return c.OAuth2.AuthCodeURL(state.Encode(), opts...) } -// OAuth2Config returns the oauth2 configuration +// OAuth2Config returns the underlying OAuth2 configuration. func (c *Config) OAuth2Config() *oauth2.Config { return c.OAuth2 } -// UserData returns the user data from the oauth2 token +// UserData exchanges the authorization code for a token and extracts user data. func (c *Config) UserData(ctx context.Context, values url.Values, params []elogin.URLParam) (*elogin.Token, *elogin.UserData, error) { code := values.Get("code") state := utils.DecodeState(values.Get("state")) scopes := c.OAuth2.Scopes - // Check state code if it is set + // Validate state code if configured if c.StateCode != "" && c.StateCode != state.Get("sc") { return nil, nil, elogin.ErrInvalidState } - // Extract scopes from the params + // Extract scopes from parameters for _, param := range params { if param.Key == "scope" { scopes = xtypes.Slice[string](strings.Split(strings.ReplaceAll(param.Value, " ", ","), ",")). @@ -77,12 +82,13 @@ func (c *Config) UserData(ctx context.Context, values url.Values, params []elogi } } - // Exchange code for token - oa2token, err := c.OAuth2.Exchange(ctx, code) //, opts...) + // Exchange authorization code for access token + oa2token, err := c.OAuth2.Exchange(ctx, code) if err != nil { return nil, nil, err } + // Create token object token := &elogin.Token{ TokenType: oa2token.TokenType, AccessToken: oa2token.AccessToken, @@ -90,11 +96,13 @@ func (c *Config) UserData(ctx context.Context, values url.Values, params []elogi ExpiresAt: oa2token.Expiry, Scopes: scopes, } + + // If no extractor is configured, return token only if c.Extractor == nil { return token, nil, nil } - // Extract user data if extractor is set + // Extract user data using the configured extractor data, err := c.Extractor(ctx, oa2token.WithExtra(map[string]any{"scope": scopes, "newToken": token}), c.OAuth2) if err != nil { return nil, nil, err diff --git a/pkg/auth/elogin/token.go b/pkg/auth/elogin/token.go index f309d7ce..a0509669 100644 --- a/pkg/auth/elogin/token.go +++ b/pkg/auth/elogin/token.go @@ -5,7 +5,7 @@ import ( "time" ) -// Token represents the token data +// Token represents OAuth token data with access and refresh tokens. type Token struct { TokenType string `json:"token_type,omitempty"` AccessToken string `json:"access_token"` @@ -14,12 +14,12 @@ type Token struct { Scopes []string `json:"scopes,omitempty"` } -// IsExpired checks if the token is expired +// IsExpired returns true if the token has expired based on the ExpiresAt time. func (tok *Token) IsExpired() bool { return tok.ExpiresAt.Before(time.Now()) } -// IsBearer checks if the token is a bearer token +// IsBearer returns true if the token type is "bearer" (case-insensitive). func (tok *Token) IsBearer() bool { return strings.EqualFold(tok.TokenType, "bearer") } diff --git a/pkg/auth/elogin/userdata.go b/pkg/auth/elogin/userdata.go index a55a87ea..e95fb2f6 100644 --- a/pkg/auth/elogin/userdata.go +++ b/pkg/auth/elogin/userdata.go @@ -4,18 +4,32 @@ import ( "golang.org/x/oauth2" ) -// UserData represents the user data +// UserData represents the user data retrieved from an OAuth2 provider. type UserData struct { - ID string `json:"id"` - Email string `json:"email"` + // ID is the unique identifier of the user + ID string `json:"id"` + + // Email is the user's email address + Email string `json:"email"` + + // FirstName is the user's first name FirstName string `json:"first_name"` - LastName string `json:"last_name"` - Username string `json:"username"` + + // LastName is the user's last name + LastName string `json:"last_name"` + + // Username is the user's username or handle + Username string `json:"username"` + + // AvatarURL is the URL to the user's avatar image AvatarURL string `json:"avatar_url"` - Link string `json:"link"` - // Ext is the extra data + // Link is the user's profile link or homepage URL + Link string `json:"link"` + + // Ext contains additional provider-specific user data Ext map[string]any `json:"ext,omitempty"` + // OAuth2conf is the OAuth2 configuration (excluded from JSON serialization) OAuth2conf *oauth2.Config `json:"-"` } diff --git a/pkg/auth/elogin/utils/state.go b/pkg/auth/elogin/utils/state.go index f4dd739c..31f7e05b 100644 --- a/pkg/auth/elogin/utils/state.go +++ b/pkg/auth/elogin/utils/state.go @@ -8,14 +8,22 @@ import ( "gopkg.in/mgo.v2/bson" ) +// State represents a collection of parameters. type State []Param +// NewState creates a new State from the given parameters. func NewState(params ...Param) State { return State(params) } -func (s State) Len() int { return len(s) } +// Len returns the length of the State (implements sort.Interface). +func (s State) Len() int { return len(s) } + +// Swap swaps two elements in the State (implements sort.Interface). func (s State) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// Less compares two elements for sorting (implements sort.Interface). +// Sorts by Key first, then by Value if Keys are equal. func (s State) Less(i, j int) bool { if s[i].Key == s[j].Key { return s[i].Value < s[j].Value @@ -23,6 +31,7 @@ func (s State) Less(i, j int) bool { return s[i].Key < s[j].Key } +// Has checks if a parameter with the given key exists in the State. func (s State) Has(key string) bool { for _, p := range s { if p.Key == key { @@ -32,6 +41,7 @@ func (s State) Has(key string) bool { return false } +// Get retrieves the value for a given key, returning an empty string if not found. func (s State) Get(key string) string { for _, p := range s { if p.Key == key { @@ -41,6 +51,7 @@ func (s State) Get(key string) string { return "" } +// Extend adds or updates a parameter in the State. func (s State) Extend(key, value string) State { for i, p := range s { if p.Key == key { @@ -51,6 +62,7 @@ func (s State) Extend(key, value string) State { return append(s, Param{Key: key, Value: value}) } +// Encode serializes the State to a base64-encoded BSON string. func (s State) Encode() string { sort.Sort(s) data := make(bson.D, 0, len(s)) @@ -61,6 +73,7 @@ func (s State) Encode() string { return base64.URLEncoding.EncodeToString(b) } +// DecodeState deserializes a base64-encoded BSON string back into a State. func DecodeState(s string) State { srcData, _ := base64.URLEncoding.DecodeString(s) var data bson.M diff --git a/pkg/auth/jwt/authorizer.go b/pkg/auth/jwt/authorizer.go index 54d9cf6d..b42005b9 100644 --- a/pkg/auth/jwt/authorizer.go +++ b/pkg/auth/jwt/authorizer.go @@ -7,16 +7,19 @@ import ( jwtmiddleware "github.com/auth0/go-jwt-middleware" "go.uber.org/zap" - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/pkg/auth/authutils" "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" + "github.com/geniusrabbit/blaze-api/repository/account/auth" + accountModels "github.com/geniusrabbit/blaze-api/repository/account/models" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" ) +// Authorizer handles JWT-based authorization for API requests. type Authorizer struct { provider *Provider jmid *jwtmiddleware.JWTMiddleware } +// NewAuthorizer creates a new JWT authorizer instance. func NewAuthorizer(jwtProvider *Provider) *Authorizer { return &Authorizer{ provider: jwtProvider, @@ -24,18 +27,25 @@ func NewAuthorizer(jwtProvider *Provider) *Authorizer { } } +// AuthorizerCode returns the identifier for this authorizer. func (au *Authorizer) AuthorizerCode() string { return "jwt" } -func (au *Authorizer) Authorize(w http.ResponseWriter, r *http.Request) (token string, usr *model.User, acc *model.Account, err error) { +// Authorize validates the JWT token from the request and retrieves associated user and account data. +func (au *Authorizer) Authorize(w http.ResponseWriter, r *http.Request) (token string, usr *userModels.User, acc *accountModels.Account, err error) { + ctx := r.Context() + + // Validate JWT token if err = au.jmid.CheckJWT(w, r); err != nil { - ctxlogger.Get(r.Context()).Debug("JWT authorization", zap.Error(err)) + ctxlogger.Get(ctx).Debug("JWT authorization", zap.Error(err)) return "", nil, nil, nil } - ctx := r.Context() + // Extract token from context jwtToken := ctx.Value(au.jmid.Options.UserProperty) + + // Parse token and fetch user/account data switch t := jwtToken.(type) { case nil: case *Token: @@ -46,10 +56,11 @@ func (au *Authorizer) Authorize(w http.ResponseWriter, r *http.Request) (token s return token, usr, acc, err } -func (au *Authorizer) authContextJWT(ctx context.Context, token *Token) (*model.User, *model.Account, error) { +// authContextJWT extracts user and account information from the JWT token. +func (au *Authorizer) authContextJWT(ctx context.Context, token *Token) (*userModels.User, *accountModels.Account, error) { jwtData, err := au.provider.ExtractTokenData(token) if err != nil { return nil, nil, err } - return authutils.UserAccountByID(ctx, jwtData.UserID, jwtData.AccountID, nil, nil) + return auth.UserAccountByID(ctx, jwtData.UserID, jwtData.AccountID, nil, nil) } diff --git a/pkg/auth/jwt/provider.go b/pkg/auth/jwt/provider.go index 7e0a1e65..6304e6c1 100644 --- a/pkg/auth/jwt/provider.go +++ b/pkg/auth/jwt/provider.go @@ -32,32 +32,26 @@ type ( // Token of JWT session Token = jwt.Token - // MapClaims describes the Claims type that uses the map[string]interface{} for JSON decoding - // This is the default claims type if you don't supply one + // MapClaims describes the Claims type that uses map[string]interface{} for JSON decoding MapClaims = jwt.MapClaims ) -// TokenData extracted from token +// TokenData contains extracted token information type TokenData struct { UserID uint64 AccountID uint64 - SocealAccountID uint64 + SocealAccountID uint64 // Note: typo - consider renaming to SocialAccountID ExpireAt int64 } -// Provider to JWT constructions +// Provider manages JWT token creation and validation type Provider struct { - // TokenLifetime defineds the valid time-period of token - TokenLifetime time.Duration - - // Secret of session generation - Secret string - - // MiddlewareOpts to get middelware procedure - MiddlewareOpts *jwtmiddleware.Options + TokenLifetime time.Duration // Valid time period for tokens + Secret string // Secret key for signing + MiddlewareOpts *jwtmiddleware.Options // Middleware configuration } -// NewDefaultProvider returns new provider +// NewDefaultProvider creates a new JWT provider with default settings func NewDefaultProvider(secret string, tokenLifetime time.Duration, isDebug bool) *Provider { return &Provider{ TokenLifetime: tokenLifetime, @@ -70,98 +64,101 @@ func NewDefaultProvider(secret string, tokenLifetime time.Duration, isDebug bool } } -// CreateToken new token for user ID +// CreateToken generates a new signed JWT token for the given user func (provider *Provider) CreateToken(userID, accountID, socialAccountID uint64) (string, time.Time, error) { - var ( - err error - lifetime = gocast.IfThen(provider.TokenLifetime > time.Minute, provider.TokenLifetime, time.Hour) - expireAt = time.Now().Add(lifetime) - ) - //Creating Access Token + lifetime := gocast.IfThen(provider.TokenLifetime > time.Minute, provider.TokenLifetime, time.Hour) + expireAt := time.Now().Add(lifetime) + + // Build token claims atClaims := jwt.MapClaims{ claimUserID: userID, claimExpiredAt: expireAt.Unix(), } + if accountID > 0 { atClaims[claimAccountID] = accountID } if socialAccountID > 0 { atClaims[claimSocialAccountID] = socialAccountID } + + // Sign and return token opt := provider.MiddlewareOptions() at := jwt.NewWithClaims(opt.SigningMethod, atClaims) token, err := at.SignedString([]byte(provider.Secret)) if err != nil { return "", expireAt, err } + return token, expireAt, nil } -// MiddlewareOptions returns the options of middelware +// MiddlewareOptions returns configured middleware options with defaults func (provider *Provider) MiddlewareOptions() *jwtmiddleware.Options { if provider.MiddlewareOpts == nil { provider.MiddlewareOpts = &jwtmiddleware.Options{} } + if provider.MiddlewareOpts.ValidationKeyGetter == nil { provider.MiddlewareOpts.ValidationKeyGetter = provider.validationKeyGetter } + if provider.MiddlewareOpts.SigningMethod == nil { - // When set, the middleware verifies that tokens are signed with the specific signing algorithm - // If the signing method is not constant the ValidationKeyGetter callback can be used to implement additional checks - // Important to avoid security issues described here: https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/ provider.MiddlewareOpts.SigningMethod = jwt.SigningMethodHS256 } + if provider.MiddlewareOpts.ErrorHandler == nil { provider.MiddlewareOpts.ErrorHandler = func(w http.ResponseWriter, r *http.Request, err string) {} } + return provider.MiddlewareOpts } -// Middleware returns middleware object with custom validation procedure +// Middleware returns a configured JWT middleware handler func (provider *Provider) Middleware() *jwtmiddleware.JWTMiddleware { return jwtmiddleware.New(*provider.MiddlewareOptions()) } -// ExtractTokenData into the token struct +// ExtractTokenData extracts and validates claims from a token func (provider *Provider) ExtractTokenData(token *Token) (*TokenData, error) { if token == nil || token.Claims == nil { return nil, errJWTInvalidToken } - claims := token.Claims.(MapClaims) - uid := gocast.Uint64(claims[claimUserID]) - acc := gocast.Uint64(claims[claimAccountID]) - sid := gocast.Uint64(claims[claimSocialAccountID]) - exp := gocast.Int64(claims[claimExpiredAt]) + claims := token.Claims.(MapClaims) data := &TokenData{ - UserID: uid, - AccountID: acc, - SocealAccountID: sid, - ExpireAt: exp, + UserID: gocast.Uint64(claims[claimUserID]), + AccountID: gocast.Uint64(claims[claimAccountID]), + SocealAccountID: gocast.Uint64(claims[claimSocialAccountID]), + ExpireAt: gocast.Int64(claims[claimExpiredAt]), } + // Validate expiration and user ID if data.ExpireAt < time.Now().Unix() { return nil, errJWTTokenIsExpired } if data.UserID <= 0 { return nil, jwt.ErrInvalidKey } + return data, nil } +// validationKeyGetter retrieves and validates the secret key for token verification func (provider *Provider) validationKeyGetter(token *Token) (any, error) { if token.Claims == nil { return nil, jwt.ErrInvalidKey } + claims := token.Claims.(MapClaims) - uid := claims[claimUserID] - // acc, _ := claims[claimAccountID] - exp := claims[claimExpiredAt] + exp := gocast.Int64(claims[claimExpiredAt]) + uid := gocast.Int64(claims[claimUserID]) - if gocast.Int64(exp) < time.Now().Unix() { + // Validate token claims + if exp < time.Now().Unix() { return nil, errJWTTokenIsExpired } - if gocast.Int64(uid) <= 0 { + if uid <= 0 { return nil, jwt.ErrInvalidKey } diff --git a/pkg/auth/middleware.go b/pkg/auth/middleware.go deleted file mode 100644 index b77f093e..00000000 --- a/pkg/auth/middleware.go +++ /dev/null @@ -1,61 +0,0 @@ -package auth - -import ( - "net/http" - - "go.uber.org/zap" - - "github.com/geniusrabbit/blaze-api/pkg/auth/authutils" - "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" - "github.com/geniusrabbit/blaze-api/pkg/context/session" - accountRepository "github.com/geniusrabbit/blaze-api/repository/account/repository" -) - -func Middelware(next http.Handler, authorizers ...Authorizer) http.Handler { - wr := NewAuthorizeWrapper(authorizers...) - accounts := accountRepository.New() - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - ctx := r.Context() - token, user, acc, err := wr.Authorize(w, r) - if err != nil { - ctxlogger.Get(ctx).Error("authorize", zap.Error(err)) - unauthorized(w) - return - } - if user == nil && acc == nil { - ctx = session.WithAnonymousUserAccount(ctx) - } else { - user, acc, err = authutils.CrossAccountConnect(ctx, r.Header.Get(session.CrossAuthHeader), user, acc) - if err != nil { - ctxlogger.Get(ctx).Error("cross account connect", zap.Error(err)) - unauthorized(w) - return - } - - // Check if user is a member of the account and load permissions - if acc != nil { - if user != nil && !accounts.IsMember(ctx, user.ID, acc.ID) { - ctxlogger.Get(ctx).Error("user is not a member of the account") - unauthorized(w) - return - } - err = accounts.LoadPermissions(ctx, acc, user) - if err != nil { - ctxlogger.Get(ctx).Error("load permissions", zap.Error(err)) - unauthorized(w) - return - } - } - - ctx = session.WithUserAccount(ctx, user, acc) - } - - next.ServeHTTP(w, r.WithContext(session.WithToken(ctx, token))) - }) -} - -func unauthorized(w http.ResponseWriter) { - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusUnauthorized) - _, _ = w.Write([]byte(`{"errors":[{"message":"Unauthorized","code":401}]}`)) -} diff --git a/pkg/auth/oauth2/authorizer.go b/pkg/auth/oauth2/authorizer.go index 296ee130..1c56e777 100644 --- a/pkg/auth/oauth2/authorizer.go +++ b/pkg/auth/oauth2/authorizer.go @@ -7,11 +7,12 @@ import ( "github.com/ory/fosite" "go.uber.org/zap" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/auth/oauth2/serverprovider" "github.com/geniusrabbit/blaze-api/pkg/auth/tokenextractor" "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" - userRepository "github.com/geniusrabbit/blaze-api/repository/user/repository" + accountModels "github.com/geniusrabbit/blaze-api/repository/account/models" + accountRepo "github.com/geniusrabbit/blaze-api/repository/account/repository" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" ) var ( @@ -32,13 +33,13 @@ func (au *Authorizer) AuthorizerCode() string { return "oauth2" } -func (au *Authorizer) Authorize(w http.ResponseWriter, r *http.Request) (string, *model.User, *model.Account, error) { +func (au *Authorizer) Authorize(w http.ResponseWriter, r *http.Request) (string, *userModels.User, *accountModels.Account, error) { var ( - userObj *model.User - accountObj *model.Account + userObj *userModels.User + accountObj *accountModels.Account ctx = r.Context() token, err = tokenextractor.DefaultExtractor(r) - users = userRepository.New() + accounts = accountRepo.NewAccountRepository() ) if err != nil { ctxlogger.Get(r.Context()).Error("token extraction", zap.Error(err)) @@ -59,7 +60,7 @@ func (au *Authorizer) Authorize(w http.ResponseWriter, r *http.Request) (string, return "", nil, nil, errAccessTokensOnlyAllows } session := accessReq.GetSession().(*serverprovider.Session) - userObj, accountObj, err = users.GetByToken(ctx, session.AccessToken) + userObj, accountObj, err = accounts.GetByToken(ctx, session.AccessToken) return token, userObj, accountObj, err } diff --git a/pkg/auth/oauth2/serverprovider/context.go b/pkg/auth/oauth2/serverprovider/context.go index 660ee8ed..305275f7 100644 --- a/pkg/auth/oauth2/serverprovider/context.go +++ b/pkg/auth/oauth2/serverprovider/context.go @@ -5,15 +5,15 @@ import ( "github.com/ory/fosite" - "github.com/geniusrabbit/blaze-api/model" + "github.com/geniusrabbit/blaze-api/repository/authclient" ) var ctxTarget = struct{ s string }{"oauth2:user"} type target struct { uid uint64 - clientObj *model.AuthClient - sessionObj *model.AuthSession + clientObj *authclient.AuthClient + sessionObj *authclient.AuthSession } // NewContext with additional functionality for oauth2 module @@ -39,22 +39,22 @@ func GetContextTargetUserID(ctx context.Context) uint64 { } // SetContextTargetClient puts user ID into the context to reuse it in future -func SetContextTargetClient(ctx context.Context, client *model.AuthClient) { +func SetContextTargetClient(ctx context.Context, client *authclient.AuthClient) { getContextTarget(ctx).clientObj = client } // GetContextTargetClient returns auth client object -func GetContextTargetClient(ctx context.Context) *model.AuthClient { +func GetContextTargetClient(ctx context.Context) *authclient.AuthClient { return getContextTarget(ctx).clientObj } // SetContextSession puts session model into the context -func SetContextSession(ctx context.Context, session *model.AuthSession) { +func SetContextSession(ctx context.Context, session *authclient.AuthSession) { getContextTarget(ctx).sessionObj = session } // GetContextSession returns session model object from context -func GetContextSession(ctx context.Context) *model.AuthSession { +func GetContextSession(ctx context.Context) *authclient.AuthSession { return getContextTarget(ctx).sessionObj } diff --git a/pkg/auth/oauth2/serverprovider/mocks/storage.go b/pkg/auth/oauth2/serverprovider/mocks/storage.go index 7ca8a1bc..d3ae6770 100644 --- a/pkg/auth/oauth2/serverprovider/mocks/storage.go +++ b/pkg/auth/oauth2/serverprovider/mocks/storage.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: storage.go +// +// Generated by this command: +// +// mockgen -source storage.go -package mocks -destination mocks/storage.go +// // Package mocks is a generated GoMock package. package mocks @@ -9,14 +14,15 @@ import ( reflect "reflect" time "time" - model "github.com/geniusrabbit/blaze-api/model" - gomock "github.com/golang/mock/gomock" + user "github.com/geniusrabbit/blaze-api/repository/user" + gomock "go.uber.org/mock/gomock" ) // Mockcacher is a mock of cacher interface. type Mockcacher struct { ctrl *gomock.Controller recorder *MockcacherMockRecorder + isgomock struct{} } // MockcacherMockRecorder is the mock recorder for Mockcacher. @@ -45,7 +51,7 @@ func (m *Mockcacher) Del(ctx context.Context, key string) error { } // Del indicates an expected call of Del. -func (mr *MockcacherMockRecorder) Del(ctx, key interface{}) *gomock.Call { +func (mr *MockcacherMockRecorder) Del(ctx, key any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Del", reflect.TypeOf((*Mockcacher)(nil).Del), ctx, key) } @@ -59,7 +65,7 @@ func (m *Mockcacher) Get(ctx context.Context, key string, target any) error { } // Get indicates an expected call of Get. -func (mr *MockcacherMockRecorder) Get(ctx, key, target interface{}) *gomock.Call { +func (mr *MockcacherMockRecorder) Get(ctx, key, target any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*Mockcacher)(nil).Get), ctx, key, target) } @@ -73,7 +79,7 @@ func (m *Mockcacher) Set(ctx context.Context, key string, value any, lifetime ti } // Set indicates an expected call of Set. -func (mr *MockcacherMockRecorder) Set(ctx, key, value, lifetime interface{}) *gomock.Call { +func (mr *MockcacherMockRecorder) Set(ctx, key, value, lifetime any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Set", reflect.TypeOf((*Mockcacher)(nil).Set), ctx, key, value, lifetime) } @@ -82,6 +88,7 @@ func (mr *MockcacherMockRecorder) Set(ctx, key, value, lifetime interface{}) *go type MockuserAccessor struct { ctrl *gomock.Controller recorder *MockuserAccessorMockRecorder + isgomock struct{} } // MockuserAccessorMockRecorder is the mock recorder for MockuserAccessor. @@ -102,16 +109,16 @@ func (m *MockuserAccessor) EXPECT() *MockuserAccessorMockRecorder { } // GetByPassword mocks base method. -func (m *MockuserAccessor) GetByPassword(ctx context.Context, email, password string) (*model.User, error) { +func (m *MockuserAccessor) GetByPassword(ctx context.Context, email, password string) (*user.User, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetByPassword", ctx, email, password) - ret0, _ := ret[0].(*model.User) + ret0, _ := ret[0].(*user.User) ret1, _ := ret[1].(error) return ret0, ret1 } // GetByPassword indicates an expected call of GetByPassword. -func (mr *MockuserAccessorMockRecorder) GetByPassword(ctx, email, password interface{}) *gomock.Call { +func (mr *MockuserAccessorMockRecorder) GetByPassword(ctx, email, password any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByPassword", reflect.TypeOf((*MockuserAccessor)(nil).GetByPassword), ctx, email, password) } diff --git a/pkg/auth/oauth2/serverprovider/storage.go b/pkg/auth/oauth2/serverprovider/storage.go index df94c8ae..344c9013 100644 --- a/pkg/auth/oauth2/serverprovider/storage.go +++ b/pkg/auth/oauth2/serverprovider/storage.go @@ -16,9 +16,10 @@ import ( "github.com/ory/fosite/handler/oauth2" "github.com/pkg/errors" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/cache" "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" + "github.com/geniusrabbit/blaze-api/repository/authclient" + "github.com/geniusrabbit/blaze-api/repository/user" ) type cacher interface { @@ -28,7 +29,7 @@ type cacher interface { } type userAccessor interface { - GetByPassword(ctx context.Context, email, password string) (*model.User, error) + GetByPassword(ctx context.Context, email, password string) (*user.User, error) } // DatabaseStorage implements fosite.Storage interface to control Oauth2 and OpenID access @@ -55,7 +56,7 @@ func NewDatabaseStorage(db *gorm.DB, userAccessor userAccessor, cache cacher, ca func (s *DatabaseStorage) GetClient(ctx context.Context, id string) (fosite.Client, error) { ctxlogger.Get(ctx).Debug("GetClient", zap.String("client_id", id)) var ( - clientObj model.AuthClient + clientObj authclient.AuthClient err = s.fromCacheOrSelect(ctx, s.clientCacheKey(id), &clientObj, id) ) if err == sql.ErrNoRows { @@ -185,7 +186,7 @@ func (s *DatabaseStorage) CreateRefreshTokenSession(ctx context.Context, signatu zap.String("refresh_signature", signature), zap.String("refresh_access_signature", accessSignature), ) - err := s.updateSessionCB(request.GetID(), func(auth *model.AuthSession) { + err := s.updateSessionCB(request.GetID(), func(auth *authclient.AuthSession) { auth.RefreshToken = null.StringFrom(signature) auth.RefreshTokenExpiresAt = request.GetSession().GetExpiresAt(fosite.RefreshToken) }) @@ -236,7 +237,7 @@ func (s *DatabaseStorage) CreateImplicitAccessTokenSession(ctx context.Context, // grant (see Implementation Note). func (s *DatabaseStorage) RevokeRefreshToken(ctx context.Context, requestID string) error { ctxlogger.Get(ctx).Debug("RevokeRefreshToken", zap.String("request_id", requestID)) - return s.updateSessionCB(requestID, func(auth *model.AuthSession) { + return s.updateSessionCB(requestID, func(auth *authclient.AuthSession) { auth.AccessTokenExpiresAt = time.Now() auth.RefreshTokenExpiresAt = time.Now() }) @@ -266,7 +267,7 @@ func (s *DatabaseStorage) RevokeRefreshTokenMaybeGracePeriod(ctx context.Context // token as well. func (s *DatabaseStorage) RevokeAccessToken(ctx context.Context, requestID string) error { ctxlogger.Get(ctx).Debug("RevokeAccessToken", zap.String("request_id", requestID)) - return s.updateSessionCB(requestID, func(auth *model.AuthSession) { + return s.updateSessionCB(requestID, func(auth *authclient.AuthSession) { auth.AccessTokenExpiresAt = time.Now() }) } @@ -300,7 +301,7 @@ func (s *DatabaseStorage) newSession(ctx context.Context, token string, request return fosite.ErrInvalidClient.WithHint("Check session user") } var ( - sessionObj = &model.AuthSession{ + sessionObj = &authclient.AuthSession{ Active: true, ClientID: client.GetID(), Username: session.GetUsername(), @@ -326,9 +327,9 @@ func (s *DatabaseStorage) newSession(ctx context.Context, token string, request return nil } -func (s *DatabaseStorage) updateSessionCB(requestID string, cb func(auth *model.AuthSession)) error { +func (s *DatabaseStorage) updateSessionCB(requestID string, cb func(auth *authclient.AuthSession)) error { var ( - sessionObj model.AuthSession + sessionObj authclient.AuthSession err = s.db.Find(&sessionObj, `request_id=?`, requestID).Error ) if errors.Is(err, gorm.ErrRecordNotFound) { @@ -341,9 +342,9 @@ func (s *DatabaseStorage) updateSessionCB(requestID string, cb func(auth *model. return s.db.Model(&sessionObj).Where(`request_id=?`, requestID).Updates(&sessionObj).Error } -func (s *DatabaseStorage) getAuthSession(ctx context.Context, code, fieldName string) (*model.AuthSession, error) { +func (s *DatabaseStorage) getAuthSession(ctx context.Context, code, fieldName string) (*authclient.AuthSession, error) { var ( - sessionObj model.AuthSession + sessionObj authclient.AuthSession err = s.fromCacheOrSelect(ctx, s.sessCacheKey(code), &sessionObj, fieldName+`=?`, code) ) if err != nil { @@ -373,7 +374,7 @@ func (s *DatabaseStorage) getSessionCode(ctx context.Context, code, fieldName st } func (s *DatabaseStorage) dropSession(ctx context.Context, code, fieldName string) error { - err := s.db.Model((*model.AuthSession)(nil)).Delete(fieldName+`=?`, code).Error + err := s.db.Model((*authclient.AuthSession)(nil)).Delete(fieldName+`=?`, code).Error if err == sql.ErrNoRows { return fosite.ErrNotFound } @@ -402,14 +403,14 @@ func (s *DatabaseStorage) invalidateSession(ctx context.Context, code, fieldName ctxlogger.Get(ctx).Error("incalidate session cache", zap.String(`cache_key`, cacheKey), zap.Error(err)) } - err = s.db.Model((*model.AuthSession)(nil)).Where(fieldName+`=? AND active=TRUE`, code).Update(`active`, true).Error + err = s.db.Model((*authclient.AuthSession)(nil)).Where(fieldName+`=? AND active=TRUE`, code).Update(`active`, true).Error if err == sql.ErrNoRows { return fosite.ErrNotFound } return err } -func (s *DatabaseStorage) authToSession(ctx context.Context, sessionObj *model.AuthSession) (_ fosite.Session, err error) { +func (s *DatabaseStorage) authToSession(ctx context.Context, sessionObj *authclient.AuthSession) (_ fosite.Session, err error) { if !sessionObj.Active { err = fosite.ErrInvalidatedAuthorizeCode } @@ -424,7 +425,7 @@ func (s *DatabaseStorage) authToSession(ctx context.Context, sessionObj *model.A ), err } -func (s *DatabaseStorage) toRequest(ctx context.Context, sessionObj *model.AuthSession) (*fosite.Request, error) { +func (s *DatabaseStorage) toRequest(ctx context.Context, sessionObj *authclient.AuthSession) (*fosite.Request, error) { session, authErr := s.authToSession(ctx, sessionObj) if session == nil { return nil, errors.Wrap(authErr, "auth session") diff --git a/pkg/auth/tokenextractor/default.go b/pkg/auth/tokenextractor/default.go index fdd8fb30..391f9795 100644 --- a/pkg/auth/tokenextractor/default.go +++ b/pkg/auth/tokenextractor/default.go @@ -8,6 +8,8 @@ import ( "github.com/geniusrabbit/blaze-api/pkg/auth/elogin/utils" ) +// DefaultExtractor is the default token extractor that looks for the token in the Authorization header and then in the state query parameter. +// Parse token from state query parameter is for the case when the token is passed in the state parameter during the e-login flow, which is used by the frontend to pass the token to the backend after successful login. func DefaultExtractor(r *http.Request) (string, error) { token := fosite.AccessTokenFromRequest(r) if token == "" { diff --git a/pkg/cache/memory/cache.go b/pkg/cache/memory/cache.go index eebd2a81..f664cd9d 100644 --- a/pkg/cache/memory/cache.go +++ b/pkg/cache/memory/cache.go @@ -54,9 +54,10 @@ func (c *Cache) TrySet(ctx context.Context, key string, value any, lifetime time // Get cached item func (c *Cache) Get(ctx context.Context, key string, target any) error { data, err := c.big.Get(key) - if err == nil { + switch err { + case nil: return json.Unmarshal(data, target) - } else if err == bigcache.ErrEntryNotFound { + case bigcache.ErrEntryNotFound: err = cache.ErrEntryNotFound } return err diff --git a/pkg/context/session/account.go b/pkg/context/session/account.go index f850f732..aa8db6d4 100644 --- a/pkg/context/session/account.go +++ b/pkg/context/session/account.go @@ -3,34 +3,35 @@ package session import ( "context" - // "github.com/geniusrabbit/blaze-api/repository/user" - - "github.com/geniusrabbit/blaze-api/model" + "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/pkg/permissions" + "github.com/geniusrabbit/blaze-api/repository/account" + accountCtx "github.com/geniusrabbit/blaze-api/repository/account/context" + "github.com/geniusrabbit/blaze-api/repository/user" + userContext "github.com/geniusrabbit/blaze-api/repository/user/context" // "github.com/grpc-ecosystem/go-grpc-middleware/util/metautils" // "google.golang.org/grpc/metadata" ) -var ( - ctxUserKey = &struct{ s string }{"account:user"} - ctxAccountKey = &struct{ s string }{"account:account"} -) - // Permission auth specific constants const ( - PermAuthCross = `auth.cross` + PermAuthCross = account.PermAuthCross AnonymousDefaultRole = `anonymous` ) // WithUserAccount puts to the context user and account models -func WithUserAccount(ctx context.Context, userObj *model.User, accountObj *model.Account) context.Context { +func WithUserAccount(ctx context.Context, userObj *user.User, accountObj *account.Account) context.Context { if accountObj == nil { pm := permissions.FromContext(ctx) role := pm.Role(ctx, AnonymousDefaultRole) - accountObj = &model.Account{Title: "", Permissions: role, Admins: []uint64{userObj.ID}} + accountObj = &account.Account{ + Title: "", + Permissions: role, + Admins: []uint64{userObj.ID}, + } } - ctx = context.WithValue(ctx, ctxUserKey, userObj) - ctx = context.WithValue(ctx, ctxAccountKey, accountObj) + ctx = userContext.WithSessionUser(ctx, userObj) + ctx = accountCtx.WithSessionAccount(ctx, accountObj) return ctx } @@ -39,8 +40,8 @@ func WithAnonymousUserAccount(ctx context.Context) context.Context { pm := permissions.FromContext(ctx) role := pm.Role(ctx, AnonymousDefaultRole) return WithUserAccount(ctx, - &model.User{Email: "", Approve: model.ApprovedApproveStatus}, - &model.Account{Title: "", Permissions: role}) + &user.User{Email: "", Approve: models.ApprovedApproveStatus}, + &account.Account{Title: "", Permissions: role}) } // WithUserAccountDevelop sets development objects into the context @@ -49,8 +50,8 @@ func WithUserAccountDevelop(ctx context.Context) context.Context { manager := permissions.NewTestManager(ctx) role := manager.Role(ctx, `test`) // INFO: Assume that there is no error because of this is the test manager ctx = WithUserAccount(ctx, - &model.User{ID: 1}, - &model.Account{ID: 1, Permissions: role, Admins: []uint64{1}}, + &user.User{ID: 1}, + &account.Account{ID: 1, Permissions: role, Admins: []uint64{1}}, ) // if changelog.MessageQueue(ctx) == nil { // ctx = changelog.WithMessageQueue(ctx) @@ -59,23 +60,23 @@ func WithUserAccountDevelop(ctx context.Context) context.Context { } // UserAccount returns user + account models -func UserAccount(ctx context.Context) (u *model.User, a *model.Account) { - if u, _ = ctx.Value(ctxUserKey).(*model.User); u == nil { - u = &model.Anonymous +func UserAccount(ctx context.Context) (u *user.User, a *account.Account) { + if u = userContext.SessionUser(ctx); u == nil { + u = &user.Anonymous } - if a, _ = ctx.Value(ctxAccountKey).(*model.Account); a == nil { - a = &model.Account{} + if a = accountCtx.SessionAccount(ctx); a == nil { + a = &account.Account{} } return u, a } // Account returns current account model -func Account(ctx context.Context) *model.Account { - return ctx.Value(ctxAccountKey).(*model.Account) +func Account(ctx context.Context) *account.Account { + return accountCtx.SessionAccount(ctx) } // User returns current user model // nolint:unused // temporary -func User(ctx context.Context) *model.User { - return ctx.Value(ctxUserKey).(*model.User) +func User(ctx context.Context) *user.User { + return userContext.SessionUser(ctx) } diff --git a/model/ordering.go b/pkg/models/ordering.go similarity index 98% rename from model/ordering.go rename to pkg/models/ordering.go index c65ee26a..280978d7 100644 --- a/model/ordering.go +++ b/pkg/models/ordering.go @@ -1,4 +1,4 @@ -package model +package models import ( "strings" diff --git a/model/status.go b/pkg/models/statuses.go similarity index 98% rename from model/status.go rename to pkg/models/statuses.go index 6301f816..38fcf0eb 100644 --- a/model/status.go +++ b/pkg/models/statuses.go @@ -1,4 +1,4 @@ -package model +package models // AvailableStatus type type AvailableStatus int diff --git a/pkg/permissions/loader.go b/pkg/permissions/loader.go index a23f46da..2198eb5c 100644 --- a/pkg/permissions/loader.go +++ b/pkg/permissions/loader.go @@ -11,8 +11,8 @@ import ( "go.uber.org/zap" "gorm.io/gorm" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" + rbacModels "github.com/geniusrabbit/blaze-api/repository/rbac/models" ) // DBRoleLoader provides roles from database @@ -23,8 +23,8 @@ type DBRoleLoader struct { // ListRoles returns all roles from database func (l *DBRoleLoader) ListRoles(ctx context.Context) []rbac.Role { var ( - links []*model.M2MRole - roles []*model.Role + links []*rbacModels.M2MRole + roles []*rbacModels.Role roleCache = make(map[uint64]rbac.Role, 10) query = l.conn.WithContext(ctx) ) @@ -49,7 +49,7 @@ func (l *DBRoleLoader) ListRoles(ctx context.Context) []rbac.Role { return xtypes.Map[uint64, rbac.Role](roleCache).Values() } -func roleByModel(role *model.Role, roles map[uint64]rbac.Role, links []*model.M2MRole) (rbac.Role, error) { +func roleByModel(role *rbacModels.Role, roles map[uint64]rbac.Role, links []*rbacModels.M2MRole) (rbac.Role, error) { roleList := make([]rbac.Role, 0, len(links)) for _, link := range links { if link.ParentRoleID != role.ID { diff --git a/pkg/permissions/manager_test.go b/pkg/permissions/manager_test.go index a589fcba..33c71031 100644 --- a/pkg/permissions/manager_test.go +++ b/pkg/permissions/manager_test.go @@ -7,7 +7,8 @@ import ( "github.com/demdxx/rbac" "github.com/stretchr/testify/assert" - "github.com/geniusrabbit/blaze-api/model" + rbacModels "github.com/geniusrabbit/blaze-api/repository/rbac/models" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" ) type TestObject struct{} @@ -16,21 +17,21 @@ func TestManager(t *testing.T) { ctx := context.TODO() mng := NewManager(nil, 0) - mng.RegisterObject(&model.Role{}, func(ctx context.Context, obj *model.Role, perm rbac.Permission) bool { return true }) + mng.RegisterObject(&rbacModels.Role{}, func(ctx context.Context, obj *rbacModels.Role, perm rbac.Permission) bool { return true }) - _ = mng.RegisterNewPermission(&model.Role{}, `view`) - _ = mng.RegisterNewPermission(&model.User{}, `view`) + _ = mng.RegisterNewPermission(&rbacModels.Role{}, `view`) + _ = mng.RegisterNewPermission(&userModels.User{}, `view`) perm1 := mng.Permission(`role.view`) - assert.True(t, perm1.CheckPermissions(ctx, &model.Role{}, `view`), `CheckPermissions`) + assert.True(t, perm1.CheckPermissions(ctx, &rbacModels.Role{}, `view`), `CheckPermissions`) perm2 := mng.Permission(`user.view`) - assert.True(t, perm2.CheckPermissions(ctx, &model.User{}, `view`), `CheckPermissions`) + assert.True(t, perm2.CheckPermissions(ctx, &userModels.User{}, `view`), `CheckPermissions`) - roleObj := &model.Role{ID: 10, Name: `role1`, PermissionPatterns: []string{`role.*`}} + roleObj := &rbacModels.Role{ID: 10, Name: `role1`, PermissionPatterns: []string{`role.*`}} role1, err := roleByModel(roleObj, map[uint64]rbac.Role{}, nil) assert.NoError(t, err, `permissionByModel:role1`) mng.RegisterRole(ctx, role1) - assert.True(t, role1.CheckPermissions(ctx, &model.Role{}, `view`), `CheckPermissions`) + assert.True(t, role1.CheckPermissions(ctx, &rbacModels.Role{}, `view`), `CheckPermissions`) } diff --git a/protocol/graphql/gqlgen.yml b/protocol/graphql/gqlgen.yml index 265f5a31..7d77cfae 100644 --- a/protocol/graphql/gqlgen.yml +++ b/protocol/graphql/gqlgen.yml @@ -3,7 +3,8 @@ # Where are all the schema files located? globs are supported eg src/**/*.graphqls schema: -- ./schemas/*.graphql + - ./schemas/*.graphql + - ../../repository/**/*.graphql skip_mod_tidy: true @@ -76,20 +77,20 @@ models: model: github.com/geniusrabbit/blaze-api/server/graphql/types.ID64 # Connectors UserConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.UserConnection + model: github.com/geniusrabbit/blaze-api/repository/user/delivery/graphql.UserConnection AccountConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.AccountConnection + model: github.com/geniusrabbit/blaze-api/repository/account/delivery/graphql.AccountConnection MemberConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.MemberConnection + model: github.com/geniusrabbit/blaze-api/repository/account/delivery/graphql.MemberConnection SocialAccountConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.SocialAccountConnection + model: github.com/geniusrabbit/blaze-api/repository/socialaccount/delivery/graphql.SocialAccountConnection RBACRoleConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.RBACRoleConnection + model: github.com/geniusrabbit/blaze-api/repository/rbac/delivery/graphql.RBACRoleConnection AuthClientConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.AuthClientConnection + model: github.com/geniusrabbit/blaze-api/repository/authclient/delivery/graphql.AuthClientConnection HistoryActionConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.HistoryActionConnection + model: github.com/geniusrabbit/blaze-api/repository/historylog/delivery/graphql.HistoryActionConnection OptionConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.OptionConnection + model: github.com/geniusrabbit/blaze-api/repository/option/delivery/graphql.OptionConnection DirectAccessTokenConnection: - model: github.com/geniusrabbit/blaze-api/server/graphql/connectors.DirectAccessTokenConnection + model: github.com/geniusrabbit/blaze-api/repository/directaccesstoken/delivery/graphql.DirectAccessTokenConnection diff --git a/protocol/graphql/schemas/auth_client.graphql b/protocol/graphql/schemas/auth_client.graphql deleted file mode 100644 index 4c1f5fd5..00000000 --- a/protocol/graphql/schemas/auth_client.graphql +++ /dev/null @@ -1,233 +0,0 @@ -""" -AuthClient object represents an OAuth 2.0 client -""" -type AuthClient { - """ - ClientID is the client ID which represents unique connection indentificator - """ - ID: ID! - - # Owner and creator of the auth client - accountID: ID64! - userID: ID64! - - """ - Title of the AuthClient as himan readable name - """ - title: String! - - """ - Secret is the client's secret. The secret will be included in the create request as cleartext, and then - never again. The secret is stored using BCrypt so it is impossible to recover it. Tell your users - that they need to write the secret down as it will not be made available again. - """ - secret: String! - - """ - RedirectURIs is an array of allowed redirect urls for the client, for example http://mydomain/oauth/callback . - """ - redirectURIs: [String!] - - """ - GrantTypes is an array of grant types the client is allowed to use. - - Pattern: client_credentials|authorization_code|implicit|refresh_token - """ - grantTypes: [String!] - - """ - ResponseTypes is an array of the OAuth 2.0 response type strings that the client can - use at the authorization endpoint. - - Pattern: id_token|code|token - """ - responseTypes: [String!] - - """ - Scope is a string containing a space-separated list of scope values (as - described in Section 3.3 of OAuth 2.0 [RFC6749]) that the client - can use when requesting access tokens. - - Pattern: ([a-zA-Z0-9\.\*]+\s?)+ - """ - scope: String! - - """ - Audience is a whitelist defining the audiences this client is allowed to request tokens for. An audience limits - the applicability of an OAuth 2.0 Access Token to, for example, certain API endpoints. The value is a list - of URLs. URLs MUST NOT contain whitespaces. - """ - audience: [String!] - - """ - SubjectType requested for responses to this Client. The subject_types_supported Discovery parameter contains a - list of the supported subject_type values for this server. Valid types include `pairwise` and `public`. - """ - subjectType: String! - - """ - AllowedCORSOrigins are one or more URLs (scheme://host[:port]) which are allowed to make CORS requests - to the /oauth/token endpoint. If this array is empty, the sever's CORS origin configuration (`CORS_ALLOWED_ORIGINS`) - will be used instead. If this array is set, the allowed origins are appended to the server's CORS origin configuration. - Be aware that environment variable `CORS_ENABLED` MUST be set to `true` for this to work. - """ - allowedCORSOrigins: [String!] - - """ - Public flag tells that the client is public - """ - public: Boolean! - - """ - ExpiresAt contins the time of expiration of the client - """ - expiresAt: Time! - - createdAt: Time! - updatedAt: Time! - deletedAt: Time -} - -type AuthClientEdge { - """ - A cursor for use in pagination. - """ - cursor: String! - - """ - The item at the end of the edge. - """ - node: AuthClient -} - -""" -AuthClientConnection implements collection accessor interface with pagination. -""" -type AuthClientConnection { - """ - The total number of campaigns - """ - totalCount: Int! - - """ - The edges for each of the AuthClient's lists - """ - edges: [AuthClientEdge!] - - """ - A list of the AuthClient's, as a convenience when edges are not needed. - """ - list: [AuthClient!] - - """ - Information for paginating this connection - """ - pageInfo: PageInfo! -} - -""" -AuthClientPayload wrapper to access of AuthClient oprtation results -""" -type AuthClientPayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationID: String! - - """ - AuthClient ID operation result - """ - authClientID: ID! - - """ - AuthClient object accessor - """ - authClient: AuthClient -} - -""" -SessionToken object represents an OAuth 2.0 / JWT session token -""" -type SessionToken { - token: String! - expiresAt: Time! - isAdmin: Boolean! - roles: [String!] -} - -############################################################################### -# Query -############################################################################### - -input AuthClientListFilter { - ID: [String!] - userID: [ID64!] - accountID: [ID64!] - public: Boolean -} - -input AuthClientListOrder { - ID: Ordering - userID: Ordering - accountID: Ordering - title: Ordering - public: Ordering - lastUpdate: Ordering -} - -############################################################################### -# Mutations -############################################################################### - -input AuthClientInput { - accountID: ID64 - userID: ID64 - title: String - secret: String - redirectURIs: [String!] - grantTypes: [String!] - responseTypes: [String!] - scope: String - audience: [String!] - subjectType: String! - allowedCORSOrigins: [String!] - public: Boolean - expiresAt: Time -} - -############################################################################### -# Query and Mutations -############################################################################### - -extend type Query { - """ - Get auth client object by ID - """ - authClient(id: ID!): AuthClientPayload! @hasPermissions(permissions: ["auth_client.view.*"]) - - """ - List of the auth client objects which can be filtered and ordered by some fields - """ - listAuthClients( - filter: AuthClientListFilter = null, - order: AuthClientListOrder = null, - page: Page = null - ): AuthClientConnection @hasPermissions(permissions: ["auth_client.list.*"]) -} - -extend type Mutation { - """ - Create the new auth client - """ - createAuthClient(input: AuthClientInput!): AuthClientPayload! @hasPermissions(permissions: ["auth_client.create.*"]) - - """ - Update auth client info - """ - updateAuthClient(id: ID!, input: AuthClientInput!): AuthClientPayload! @hasPermissions(permissions: ["auth_client.update.*"]) - - """ - Delete auth client - """ - deleteAuthClient(id: ID!, msg: String = null): AuthClientPayload! @hasPermissions(permissions: ["auth_client.delete.*"]) -} diff --git a/protocol/graphql/schemas/directives.graphql b/protocol/graphql/schemas/directives.graphql index fc8d0f26..ba904f7b 100644 --- a/protocol/graphql/schemas/directives.graphql +++ b/protocol/graphql/schemas/directives.graphql @@ -16,3 +16,33 @@ directive @cacheData( key: String fields: [String!] ) on FIELD_DEFINITION | FIELD + +# Validation directives + +## @length validates the length of a string or array. +directive @length( + min: Int! + max: Int! = 0 + trim: Boolean! = false + ornil: Boolean! = false +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR + +## @notempty validates that a string or array is not empty. +directive @notempty( + trim: Boolean! = false + ornil: Boolean! = false +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR + +## @regex validates a string against a regular expression. +directive @regex( + pattern: String! + trim: Boolean! = true + ornil: Boolean! = false +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR + +## @range validates that a number is within a specified range. +directive @range( + min: Float! + max: Float! = 0 + ornil: Boolean! = false +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR diff --git a/repository/account/auth/middleware.go b/repository/account/auth/middleware.go new file mode 100644 index 00000000..cd871cfc --- /dev/null +++ b/repository/account/auth/middleware.go @@ -0,0 +1,78 @@ +package auth + +import ( + "net/http" + + "go.uber.org/zap" + + "github.com/geniusrabbit/blaze-api/pkg/auth" + "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" + "github.com/geniusrabbit/blaze-api/pkg/context/session" + "github.com/geniusrabbit/blaze-api/repository/account/models" + accountRepository "github.com/geniusrabbit/blaze-api/repository/account/repository" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" +) + +// Authorizer is a type alias for the generic Authorizer with specific user and account types. +type Authorizer = auth.Authorizer[*userModels.User, *models.Account] + +// Middleware returns an HTTP handler that performs authorization checks on incoming requests. +// It validates tokens, handles cross-account connections, and loads user permissions. +func Middleware(next http.Handler, authorizers ...Authorizer) http.Handler { + authWrap := auth.NewAuthorizeWrapper(authorizers...) + accounts := accountRepository.NewAccountRepository() + members := accountRepository.NewMemberRepository() + + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + // Authorize the request and extract token, user, and account information + token, user, acc, err := authWrap.Authorize(w, r) + if err != nil { + ctxlogger.Get(ctx).Error("authorize", zap.Error(err)) + unauthorized(w) + return + } + + // Handle anonymous user if neither user nor account is present + if user == nil && acc == nil { + ctx = session.WithAnonymousUserAccount(ctx) + } else { + // Handle cross-account connection + user, acc, err = CrossAccountConnect(ctx, r.Header.Get(session.CrossAuthHeader), user, acc) + if err != nil { + ctxlogger.Get(ctx).Error("cross account connect", zap.Error(err)) + unauthorized(w) + return + } + + // Validate account membership and load permissions + if acc != nil { + if user != nil && !members.IsMember(ctx, user.ID, acc.ID) { + ctxlogger.Get(ctx).Error("user is not a member of the account") + unauthorized(w) + return + } + + err = accounts.LoadPermissions(ctx, acc, user) + if err != nil { + ctxlogger.Get(ctx).Error("load permissions", zap.Error(err)) + unauthorized(w) + return + } + } + + ctx = session.WithUserAccount(ctx, user, acc) + } + + // Pass the request to the next handler with updated context + next.ServeHTTP(w, r.WithContext(session.WithToken(ctx, token))) + }) +} + +// unauthorized writes an HTTP 401 Unauthorized response with a JSON error message. +func unauthorized(w http.ResponseWriter) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusUnauthorized) + _, _ = w.Write([]byte(`{"errors":[{"message":"Unauthorized","code":401}]}`)) +} diff --git a/repository/account/auth/utils.go b/repository/account/auth/utils.go new file mode 100644 index 00000000..4bfc0935 --- /dev/null +++ b/repository/account/auth/utils.go @@ -0,0 +1,85 @@ +package auth + +import ( + "context" + "errors" + + "github.com/geniusrabbit/blaze-api/pkg/context/session" + "github.com/geniusrabbit/blaze-api/repository/account/models" + accountRepository "github.com/geniusrabbit/blaze-api/repository/account/repository" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" + userRepository "github.com/geniusrabbit/blaze-api/repository/user/repository" +) + +var ( + // errAuthUserIsNotMemberOfAccount is returned when a user is not a member of the target account + errAuthUserIsNotMemberOfAccount = errors.New("user is not a member of the account") + // errNoCrossAuthPermission is returned when a user lacks cross-account authentication permissions + errNoCrossAuthPermission = errors.New("user don't have cross auth permissions") +) + +// UserAccountByID retrieves and validates a user and account by their IDs, ensuring proper permissions. +// It checks membership, cross-account permissions, and loads account permissions for the user. +func UserAccountByID(ctx context.Context, uID, accID uint64, preUser *userModels.User, prevAccount *models.Account) (*userModels.User, *models.Account, error) { + var ( + err error + users = userRepository.NewUserRepository() + accounts = accountRepository.NewAccountRepository() + members = accountRepository.NewMemberRepository() + account = prevAccount + userObj = preUser + ) + + // Fetch user if ID is provided and doesn't match the pre-loaded user + if uID > 0 && (preUser == nil || preUser.ID != uID) { + if userObj, err = users.Get(ctx, uID); err != nil { + return nil, nil, err + } + } + + // Fetch account if ID is provided and doesn't match the pre-loaded account + if accID > 0 && (prevAccount == nil || prevAccount.ID != accID) { + if account, err = accounts.Get(ctx, accID); err != nil { + return nil, nil, err + } + } + + // Validate permissions and load account data + if account != nil { + // Verify user is a member of the target account + if userObj != nil && !members.IsMember(ctx, userObj.ID, account.ID) { + return nil, nil, errAuthUserIsNotMemberOfAccount + } + + // Verify cross-account access permissions if switching accounts + if prevAccount != nil && prevAccount.ID != account.ID && + !prevAccount.CheckPermissions(ctx, account, session.PermAuthCross) { + return nil, nil, errNoCrossAuthPermission + } + + // Load account permissions for the user + err = accounts.LoadPermissions(ctx, account, userObj) + if err != nil { + return nil, nil, err + } + + // Extend account permissions from previous account if applicable + if prevAccount != nil { + account.ExtendPermissions(prevAccount.Permissions) + } + } + + return userObj, account, nil +} + +// CrossAccountConnect validates and connects to a cross-account context if specified via header. +// Returns the user and account objects with updated permissions. +func CrossAccountConnect(ctx context.Context, crossAccountID string, userObj *userModels.User, accountObj *models.Account) (*userModels.User, *models.Account, error) { + if crossAccountID != "" { + userID, accountID := session.ParseCrossAuthHeader(crossAccountID) + if userID > 0 || accountID > 0 { + return UserAccountByID(ctx, userID, accountID, userObj, accountObj) + } + } + return userObj, accountObj, nil +} diff --git a/repository/account/authorizer/devtoken_authorizer.go b/repository/account/authorizer/devtoken_authorizer.go new file mode 100644 index 00000000..9e66f4c7 --- /dev/null +++ b/repository/account/authorizer/devtoken_authorizer.go @@ -0,0 +1,69 @@ +package authorizer + +import ( + "net/http" + + "github.com/demdxx/gocast/v2" + "go.uber.org/zap" + + "github.com/geniusrabbit/blaze-api/pkg/auth/tokenextractor" + "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" + "github.com/geniusrabbit/blaze-api/repository/account/auth" + "github.com/geniusrabbit/blaze-api/repository/account/models" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" +) + +// DevTokenAuthorizer handles development token authentication. +type DevTokenAuthorizer struct { + options AuthOption + extractor TokenExtractor +} + +// NewDevTokenAuthorizer creates a new DevTokenAuthorizer with the given options. +func NewDevTokenAuthorizer(opts *AuthOption) *DevTokenAuthorizer { + return &DevTokenAuthorizer{ + options: gocast.IfThenExec(opts != nil, + func() AuthOption { return *opts }, + func() AuthOption { return AuthOption{} }), + extractor: tokenextractor.DefaultExtractor, + } +} + +// AuthorizerCode returns the authorizer identifier. +func (au *DevTokenAuthorizer) AuthorizerCode() string { + return "devtoken" +} + +// Authorize validates a development token from the request and returns the associated user and account. +func (au *DevTokenAuthorizer) Authorize(w http.ResponseWriter, r *http.Request) (string, *userModels.User, *models.Account, error) { + // Return early if dev token is not configured + if au.options.DevToken == "" { + return "", nil, nil, nil + } + + ctx := r.Context() + + // Extract token from request + token, err := au.extractor(r) + if err != nil { + ctxlogger.Get(ctx).Error("token extraction failed", zap.Error(err)) + return "", nil, nil, nil + } + + // Return early if no token provided + if token == "" { + return "", nil, nil, nil + } + + // Validate token matches configured dev token + if au.options.DevToken == token { + usr, acc, err := auth.UserAccountByID(ctx, au.options.DevUserID, au.options.DevAccountID, nil, nil) + if err != nil { + ctxlogger.Get(ctx).Error("failed to fetch user and account", zap.Error(err)) + return "", nil, nil, nil + } + return token, usr, acc, nil + } + + return "", nil, nil, nil +} diff --git a/repository/account/authorizer/directtoken_authorizer.go b/repository/account/authorizer/directtoken_authorizer.go new file mode 100644 index 00000000..58d89ba4 --- /dev/null +++ b/repository/account/authorizer/directtoken_authorizer.go @@ -0,0 +1,52 @@ +package authorizer + +import ( + "net/http" + + "go.uber.org/zap" + + "github.com/geniusrabbit/blaze-api/pkg/auth/tokenextractor" + "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" + accountModels "github.com/geniusrabbit/blaze-api/repository/account/models" + accountRepo "github.com/geniusrabbit/blaze-api/repository/account/repository" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" +) + +// DirectTokenAuthorizer implements authorization using direct token authentication. +type DirectTokenAuthorizer struct { + extractor TokenExtractor +} + +// NewDirectTokenAuthorizer creates a new instance of DirectTokenAuthorizer. +func NewDirectTokenAuthorizer() *DirectTokenAuthorizer { + return &DirectTokenAuthorizer{ + extractor: tokenextractor.DefaultExtractor, + } +} + +// AuthorizerCode returns the identifier code for this authorizer. +func (au *DirectTokenAuthorizer) AuthorizerCode() string { + return "directtoken" +} + +// Authorize validates the request by extracting and verifying the token, +// then retrieves the associated user and account information. +func (au *DirectTokenAuthorizer) Authorize(w http.ResponseWriter, r *http.Request) (string, *userModels.User, *accountModels.Account, error) { + ctx := r.Context() + + // Extract token from the request + token, err := au.extractor(r) + if err != nil { + ctxlogger.Get(r.Context()).Error("token extraction", zap.Error(err)) + return "", nil, nil, nil + } + + // Return early if no token is provided + if token == "" { + return "", nil, nil, nil + } + + // Retrieve user and account information by token + userObj, accountObj, err := accountRepo.NewAccountRepository().GetByToken(ctx, token) + return token, userObj, accountObj, err +} diff --git a/repository/account/authorizer/token.go b/repository/account/authorizer/token.go new file mode 100644 index 00000000..a8f1188c --- /dev/null +++ b/repository/account/authorizer/token.go @@ -0,0 +1,13 @@ +package authorizer + +import "net/http" + +// AuthOption to access to default user +type AuthOption struct { + DevToken string + DevUserID uint64 + DevAccountID uint64 +} + +// TokenExtractor defines a function type for extracting tokens from HTTP requests. +type TokenExtractor func(r *http.Request) (string, error) diff --git a/repository/account/context/permissions.go b/repository/account/context/permissions.go new file mode 100644 index 00000000..f312b05e --- /dev/null +++ b/repository/account/context/permissions.go @@ -0,0 +1,18 @@ +package context + +import ( + "context" + + "github.com/geniusrabbit/blaze-api/repository/account/models" +) + +// PermissionCheckAccountFromContext returns the original account for permission checks +// from the given context, or nil if not found. +func PermissionCheckAccountFromContext(ctx context.Context) *models.Account { + switch acc := ctx.Value(models.CtxPermissionCheckAccount).(type) { + case nil: + case *models.Account: + return acc + } + return nil +} diff --git a/repository/account/context/session.go b/repository/account/context/session.go new file mode 100644 index 00000000..8cd89878 --- /dev/null +++ b/repository/account/context/session.go @@ -0,0 +1,20 @@ +package context + +import ( + "context" + + "github.com/geniusrabbit/blaze-api/repository/account/models" +) + +var ctxAccountKey = &struct{ s string }{"account:account"} + +// WithSessionAccount puts to the context account model +func WithSessionAccount(ctx context.Context, accountObj *models.Account) context.Context { + return context.WithValue(ctx, ctxAccountKey, accountObj) +} + +// SessionAccount returns current account model +// nolint:unused // temporary +func SessionAccount(ctx context.Context) *models.Account { + return ctx.Value(ctxAccountKey).(*models.Account) +} diff --git a/protocol/graphql/schemas/account_base.graphql b/repository/account/delivery/graphql/account_base.graphql similarity index 63% rename from protocol/graphql/schemas/account_base.graphql rename to repository/account/delivery/graphql/account_base.graphql index 7ea691ce..b16c8178 100644 --- a/protocol/graphql/schemas/account_base.graphql +++ b/repository/account/delivery/graphql/account_base.graphql @@ -21,37 +21,37 @@ type Account { description: String! """ - logoURI is an URL string that references a logo for the client. + logoURI is an URL string that references a logo for the client. """ - logoURI: String! + logoURI: String! """ - policyURI is a URL string that points to a human-readable privacy policy document - that describes how the deployment organization collects, uses, - retains, and discloses personal data. + policyURI is a URL string that points to a human-readable privacy policy document + that describes how the deployment organization collects, uses, + retains, and discloses personal data. """ - policyURI: String! + policyURI: String! """ - termsOfServiceURI is a URL string that points to a human-readable terms of service - document for the client that describes a contractual relationship - between the end-user and the client that the end-user accepts when - authorizing the client. + termsOfServiceURI is a URL string that points to a human-readable terms of service + document for the client that describes a contractual relationship + between the end-user and the client that the end-user accepts when + authorizing the client. """ - termsOfServiceURI: String! + termsOfServiceURI: String! """ - clientURI is an URL string of a web page providing information about the client. - If present, the server SHOULD display this URL to the end-user in - a clickable fashion. + clientURI is an URL string of a web page providing information about the client. + If present, the server SHOULD display this URL to the end-user in + a clickable fashion. """ - clientURI: String! + clientURI: String! """ - contacts is a array of strings representing ways to contact people responsible - for this client, typically email addresses. + contacts is a array of strings representing ways to contact people responsible + for this client, typically email addresses. """ - contacts: [String!] + contacts: [String!] createdAt: Time! updatedAt: Time! @@ -114,6 +114,16 @@ type AccountPayload { account: Account } +""" +SessionToken object represents an OAuth 2.0 / JWT session token +""" +type SessionToken { + token: String! + expiresAt: Time! + isAdmin: Boolean! + roles: [String!] +} + ############################################################################### # Query ############################################################################### @@ -139,17 +149,17 @@ input AccountInput { status: ApproveStatus title: String description: String - logoURI: String - policyURI: String - termsOfServiceURI: String - clientURI: String - contacts: [String!] + logoURI: String + policyURI: String + termsOfServiceURI: String + clientURI: String + contacts: [String!] } input AccountCreateInput { - ownerID: ID64 - owner: UserInput - account: AccountInput! + ownerID: ID64 + owner: UserInput + account: AccountInput! password: String! } @@ -183,26 +193,31 @@ extend type Query { """ Current account from the session """ - currentAccount: AccountPayload! @hasPermissions(permissions: ["account.view.*"]) + currentAccount: AccountPayload! + @hasPermissions(permissions: ["account.view.*"]) """ Get account object by ID """ - account(id: ID64!): AccountPayload! @hasPermissions(permissions: ["account.view.*"]) + account(id: ID64!): AccountPayload! + @hasPermissions(permissions: ["account.view.*"]) """ List of the account objects which can be filtered and ordered by some fields """ listAccounts( - filter: AccountListFilter = null, - order: AccountListOrder = null, + filter: AccountListFilter = null + order: AccountListOrder = null page: Page = null ): AccountConnection @hasPermissions(permissions: ["account.list.*"]) """ List of the account roles/permissions """ - listAccountRolesAndPermissions(accountID: ID64!, order: RBACRoleListOrder = null): RBACRoleConnection @hasPermissions(permissions: ["account.view.*"]) + listAccountRolesAndPermissions( + accountID: ID64! + order: RBACRoleListOrder = null + ): RBACRoleConnection @hasPermissions(permissions: ["account.view.*"]) } extend type Mutation { @@ -224,20 +239,24 @@ extend type Mutation { """ Register the new account """ - registerAccount(input: AccountCreateInput!): AccountCreatePayload! @hasPermissions(permissions: ["account.register"]) + registerAccount(input: AccountCreateInput!): AccountCreatePayload! + @hasPermissions(permissions: ["account.register"]) """ Update account info """ - updateAccount(id: ID64!, input: AccountInput!): AccountPayload! @hasPermissions(permissions: ["account.update.*"]) + updateAccount(id: ID64!, input: AccountInput!): AccountPayload! + @hasPermissions(permissions: ["account.update.*"]) """ Approve account and leave the comment """ - approveAccount(id: ID64!, msg: String!): AccountPayload! @hasPermissions(permissions: ["account.approve.*"]) + approveAccount(id: ID64!, msg: String!): AccountPayload! + @hasPermissions(permissions: ["account.approve.*"]) """ Reject account and leave the comment """ - rejectAccount(id: ID64!, msg: String!): AccountPayload! @hasPermissions(permissions: ["account.reject.*"]) + rejectAccount(id: ID64!, msg: String!): AccountPayload! + @hasPermissions(permissions: ["account.reject.*"]) } diff --git a/protocol/graphql/schemas/account_member.graphql b/repository/account/delivery/graphql/account_member.graphql similarity index 100% rename from protocol/graphql/schemas/account_member.graphql rename to repository/account/delivery/graphql/account_member.graphql diff --git a/repository/account/delivery/graphql/auth_resolver.go b/repository/account/delivery/graphql/auth_resolver.go index 1e617635..5ddb8923 100644 --- a/repository/account/delivery/graphql/auth_resolver.go +++ b/repository/account/delivery/graphql/auth_resolver.go @@ -9,18 +9,17 @@ import ( lrbac "github.com/demdxx/rbac" "github.com/demdxx/xtypes" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/auth/jwt" "github.com/geniusrabbit/blaze-api/pkg/context/session" "github.com/geniusrabbit/blaze-api/pkg/permissions" "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/account" - accountrepo "github.com/geniusrabbit/blaze-api/repository/account/repository" - accountusecase "github.com/geniusrabbit/blaze-api/repository/account/usecase" + accountModels "github.com/geniusrabbit/blaze-api/repository/account/models" "github.com/geniusrabbit/blaze-api/repository/rbac" - userrepo "github.com/geniusrabbit/blaze-api/repository/user/repository" - "github.com/geniusrabbit/blaze-api/server/graphql/connectors" - "github.com/geniusrabbit/blaze-api/server/graphql/models" + rbacgql "github.com/geniusrabbit/blaze-api/repository/rbac/delivery/graphql" + "github.com/geniusrabbit/blaze-api/repository/user" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) var ( @@ -31,25 +30,25 @@ var ( // AuthResolver is the resolver for the Auth type type AuthResolver struct { provider *jwt.Provider - userRepo *userrepo.Repository - accountRepo *accountrepo.Repository + userRepo user.Repository + accountRepo account.Repository accountUsecase account.Usecase roleRepo rbac.Repository } // NewAuthResolver creates new resolver for the Auth type -func NewAuthResolver(provider *jwt.Provider, roleRepo rbac.Repository) *AuthResolver { +func NewAuthResolver(provider *jwt.Provider, userRepo user.Repository, accountRepo account.Repository, accountUsecase account.Usecase, roleRepo rbac.Repository) *AuthResolver { return &AuthResolver{ provider: provider, - userRepo: userrepo.New(), - accountRepo: accountrepo.New(), - accountUsecase: accountusecase.NewAccountUsecase(userrepo.New(), accountrepo.New()), + userRepo: userRepo, + accountRepo: accountRepo, + accountUsecase: accountUsecase, roleRepo: roleRepo, } } // Login is the resolver for the login field -func (r *AuthResolver) Login(ctx context.Context, login string, password string) (*models.SessionToken, error) { +func (r *AuthResolver) Login(ctx context.Context, login string, password string) (*gqlmodels.SessionToken, error) { accountID := uint64(0) user, err := r.userRepo.GetByPassword(ctx, login, password) if err != nil { @@ -73,7 +72,7 @@ func (r *AuthResolver) Login(ctx context.Context, login string, password string) if r, ok := account.Permissions.(lrbac.Role); ok { roles = append(roles, r) } - return &models.SessionToken{ + return &gqlmodels.SessionToken{ Token: token, ExpiresAt: expiresAt.UTC(), IsAdmin: account.IsAdminUser(user.GetID()), // Is current account admin @@ -87,7 +86,7 @@ func (r *AuthResolver) Logout(ctx context.Context) (bool, error) { } // SwitchAccount is the resolver for the switchAccount field -func (r *AuthResolver) SwitchAccount(ctx context.Context, id uint64) (*models.SessionToken, error) { +func (r *AuthResolver) SwitchAccount(ctx context.Context, id uint64) (*gqlmodels.SessionToken, error) { user := session.User(ctx) if user == nil { return nil, errUserIsNotAuthorized @@ -107,7 +106,7 @@ func (r *AuthResolver) SwitchAccount(ctx context.Context, id uint64) (*models.Se if r, ok := account.Permissions.(lrbac.Role); ok { roles = append(roles, r) } - return &models.SessionToken{ + return &gqlmodels.SessionToken{ Token: token, ExpiresAt: expiresAt, IsAdmin: account.IsAdminUser(user.GetID()), // Is current account admin @@ -116,13 +115,13 @@ func (r *AuthResolver) SwitchAccount(ctx context.Context, id uint64) (*models.Se } // CurrentSession is the resolver for the currentSession field -func (r *AuthResolver) CurrentSession(ctx context.Context) (*models.SessionToken, error) { +func (r *AuthResolver) CurrentSession(ctx context.Context) (*gqlmodels.SessionToken, error) { user, account, token := session.User(ctx), session.Account(ctx), session.Token(ctx) roles := append([]lrbac.Role{}, account.Permissions.ChildRoles()...) if r, ok := account.Permissions.(lrbac.Role); ok { roles = append(roles, r) } - return &models.SessionToken{ + return &gqlmodels.SessionToken{ Token: token, ExpiresAt: time.Now().Add(r.provider.TokenLifetime), IsAdmin: account.IsAdminUser(user.GetID()), // Is current account admin @@ -131,23 +130,23 @@ func (r *AuthResolver) CurrentSession(ctx context.Context) (*models.SessionToken } // ListRolesAndPermissions is the resolver for the listRolesAndPermissions field -func (r *AuthResolver) ListRolesAndPermissions(ctx context.Context, accountID uint64, order *models.RBACRoleListOrder) (*connectors.RBACRoleConnection, error) { +func (r *AuthResolver) ListRolesAndPermissions(ctx context.Context, accountID uint64, order *gqlmodels.RBACRoleListOrder) (*rbacgql.RBACRoleConnection, error) { var ( err error - account *model.Account + account *accountModels.Account permIDs []uint64 ) + + // If accountID is provided, load that account and check permissions, otherwise use current session account if accountID != 0 { - account, err = r.accountUsecase.Get(ctx, accountID) - if err != nil { + if account, err = r.accountUsecase.Get(ctx, accountID); err != nil { return nil, err } - } else { - account = session.Account(ctx) - if account == nil { - return nil, errUserIsNotAuthorized - } + } else if account = session.Account(ctx); account == nil { + return nil, errUserIsNotAuthorized } + + // Collect permission IDs from the account's permissions and child roles if account != nil && account.Permissions != nil { childRoles := append([]lrbac.Role{}, account.Permissions.ChildRoles()...) if r, ok := account.Permissions.(lrbac.Role); ok { @@ -162,10 +161,10 @@ func (r *AuthResolver) ListRolesAndPermissions(ctx context.Context, accountID ui } }).Filter(func(id uint64) bool { return id != 0 }) } - return connectors.NewRBACRoleConnectionByIDs(ctx, r.roleRepo, permIDs, order), nil + return rbacgql.NewRBACRoleConnectionByIDs(ctx, r.roleRepo, permIDs, order), nil } -func accountForUser(ctx context.Context, accountRepo account.Repository, user *model.User, accountID uint64) (*model.Account, error) { +func accountForUser(ctx context.Context, accountRepo account.Repository, user *userModels.User, accountID uint64) (*accountModels.Account, error) { accounts, err := accountRepo.FetchList(ctx, &account.Filter{ ID: gocast.IfThen(accountID > 0, []uint64{accountID}, nil), diff --git a/repository/account/delivery/graphql/base_resolver.go b/repository/account/delivery/graphql/base_resolver.go index 848d74e4..762d9cf2 100644 --- a/repository/account/delivery/graphql/base_resolver.go +++ b/repository/account/delivery/graphql/base_resolver.go @@ -7,17 +7,16 @@ import ( "go.uber.org/zap" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" "github.com/geniusrabbit/blaze-api/pkg/context/session" "github.com/geniusrabbit/blaze-api/pkg/messanger" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/pkg/requestid" "github.com/geniusrabbit/blaze-api/repository/account" - "github.com/geniusrabbit/blaze-api/repository/account/repository" - "github.com/geniusrabbit/blaze-api/repository/account/usecase" "github.com/geniusrabbit/blaze-api/repository/historylog" - userrepo "github.com/geniusrabbit/blaze-api/repository/user/repository" - "github.com/geniusrabbit/blaze-api/server/graphql/connectors" + "github.com/geniusrabbit/blaze-api/repository/user" + usergql "github.com/geniusrabbit/blaze-api/repository/user/delivery/graphql" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) @@ -27,15 +26,17 @@ var ( // QueryResolver implements GQL API methods type QueryResolver struct { - userRepo *userrepo.Repository + userRepo user.Repository accounts account.Usecase + members account.MemberUsecase } // NewQueryResolver returns new API resolver -func NewQueryResolver() *QueryResolver { +func NewQueryResolver(accounts account.Usecase, members account.MemberUsecase, userRepo user.Repository) *QueryResolver { return &QueryResolver{ - userRepo: userrepo.New(), - accounts: usecase.NewAccountUsecase(userrepo.New(), repository.New()), + userRepo: userRepo, + accounts: accounts, + members: members, } } @@ -45,7 +46,7 @@ func (r *QueryResolver) CurrentAccount(ctx context.Context) (*gqlmodels.AccountP return &gqlmodels.AccountPayload{ ClientMutationID: requestid.Get(ctx), AccountID: account.ID, - Account: gqlmodels.FromAccountModel(account), + Account: FromAccountModel(account), }, nil } @@ -58,7 +59,7 @@ func (r *QueryResolver) Account(ctx context.Context, id uint64) (*gqlmodels.Acco return &gqlmodels.AccountPayload{ ClientMutationID: requestid.Get(ctx), AccountID: id, - Account: gqlmodels.FromAccountModel(acc), + Account: FromAccountModel(acc), }, nil } @@ -73,15 +74,15 @@ func (r *QueryResolver) RegisterAccount(ctx context.Context, input *gqlmodels.Ac } var ( - userObj = input.Owner.Model(model.UndefinedApproveStatus) - accObj = input.Account.Model(model.UndefinedApproveStatus) + userObj = input.Owner.Model(pkgModels.UndefinedApproveStatus) + accObj = input.Account.Model(pkgModels.UndefinedApproveStatus) ) if input.OwnerID != nil && *input.OwnerID > 0 { if userObj != nil { userObj.ID = *input.OwnerID } else { - userObj = &model.User{ID: *input.OwnerID} + userObj = &userModels.User{ID: *input.OwnerID} } } @@ -107,8 +108,8 @@ func (r *QueryResolver) RegisterAccount(ctx context.Context, input *gqlmodels.Ac return &gqlmodels.AccountCreatePayload{ ClientMutationID: requestid.Get(ctx), - Account: gqlmodels.FromAccountModel(accObj), - Owner: gqlmodels.FromUserModel(userObj), + Account: FromAccountModel(accObj), + Owner: usergql.FromUserModel(userObj), }, nil } @@ -134,62 +135,62 @@ func (r *QueryResolver) createUpdateAccount(ctx context.Context, id uint64, inpu return &gqlmodels.AccountPayload{ ClientMutationID: requestid.Get(ctx), AccountID: id, - Account: gqlmodels.FromAccountModel(acc), + Account: FromAccountModel(acc), }, nil } // ApproveAccount is the resolver for the approveAccount field. func (r *QueryResolver) ApproveAccount(ctx context.Context, id uint64, msg string) (*gqlmodels.AccountPayload, error) { - return r.updateApproveStatus(ctx, id, model.ApprovedApproveStatus, msg) + return r.updateApproveStatus(ctx, id, pkgModels.ApprovedApproveStatus, msg) } // RejectAccount is the resolver for the rejectAccount field. func (r *QueryResolver) RejectAccount(ctx context.Context, id uint64, msg string) (*gqlmodels.AccountPayload, error) { - return r.updateApproveStatus(ctx, id, model.DisapprovedApproveStatus, msg) + return r.updateApproveStatus(ctx, id, pkgModels.DisapprovedApproveStatus, msg) } -func (r *QueryResolver) updateApproveStatus(ctx context.Context, id uint64, status model.ApproveStatus, msg string) (*gqlmodels.AccountPayload, error) { - acc, err := r.accounts.Get(ctx, uint64(id)) +func (r *QueryResolver) updateApproveStatus(ctx context.Context, id uint64, status pkgModels.ApproveStatus, msg string) (*gqlmodels.AccountPayload, error) { + acc, err := r.accounts.Get(ctx, id) if err != nil { return nil, err } acc.Approve = status saveCtx := historylog.WithMessage(ctx, msg) saveCtx = historylog.WithAction(saveCtx, strings.ToLower(status.String())) + + // Store the updated account if _, err = r.accounts.Store(saveCtx, acc); err != nil { return nil, err } - // Send message to the account owner - if true { - // Get account owner - members, err := r.accounts.FetchListMembers(ctx, - &account.MemberFilter{AccountID: []uint64{acc.ID}}, nil, nil) - if err != nil { - return nil, err - } + // Get account owner + members, err := r.members.FetchListMembers(ctx, + &account.MemberFilter{AccountID: []uint64{acc.ID}}, nil, nil) + if err != nil { + return nil, err + } - recipients := make([]string, 0, len(members)) - for _, member := range members { - if member.IsAdmin { - recipients = append(recipients, member.User.Email) - } + recipients := make([]string, 0, len(members)) + for _, member := range members { + if member.IsAdmin { + recipients = append(recipients, member.User.Email) } + } - // Send message to the account owner about the account creation (welcome message) - tmplName := "account." + strings.ToLower(status.String()) - err = messanger.Get(ctx).Send(ctx, tmplName, recipients, map[string]any{ - "id": id, - "account": acc, - "status": status, - }) - if err != nil { - ctxlogger.Get(ctx).Error("Failed to send message", - zap.String("template", tmplName), - zap.Error(err)) - return nil, err - } + // Send message to the account owner about the account creation (welcome message) + tmplName := "account." + strings.ToLower(status.String()) + err = messanger.Get(ctx).Send(ctx, tmplName, recipients, map[string]any{ + "id": id, + "account": acc, + "status": status, + }) + if err != nil { + ctxlogger.Get(ctx).Error("Failed to send message", + zap.String("template", tmplName), + zap.Error(err)) + return nil, err } + return &gqlmodels.AccountPayload{ ClientMutationID: requestid.Get(ctx), AccountID: id, @@ -202,6 +203,6 @@ func (r *QueryResolver) ListAccounts(ctx context.Context, filter *gqlmodels.AccountListFilter, order *gqlmodels.AccountListOrder, page *gqlmodels.Page, -) (*connectors.AccountConnection, error) { - return connectors.NewAccountConnection(ctx, r.accounts, filter, order, page), nil +) (*AccountConnection, error) { + return NewAccountConnection(ctx, r.accounts, filter, order, page), nil } diff --git a/repository/account/delivery/graphql/connectors.go b/repository/account/delivery/graphql/connectors.go new file mode 100644 index 00000000..f5e0956e --- /dev/null +++ b/repository/account/delivery/graphql/connectors.go @@ -0,0 +1,56 @@ +package graphql + +import ( + "context" + + "github.com/demdxx/gocast/v2" + + "github.com/geniusrabbit/blaze-api/repository/account" + "github.com/geniusrabbit/blaze-api/server/graphql/connectors" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" +) + +// AccountConnection implements collection accessor interface with pagination +type AccountConnection = connectors.CollectionConnection[gqlmodels.Account, gqlmodels.AccountEdge] + +// NewAccountConnection based on query object +func NewAccountConnection(ctx context.Context, accountsAccessor account.Usecase, filter *gqlmodels.AccountListFilter, order *gqlmodels.AccountListOrder, page *gqlmodels.Page) *AccountConnection { + return connectors.NewCollectionConnection(ctx, &connectors.DataAccessorFunc[gqlmodels.Account, gqlmodels.AccountEdge]{ + FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.Account, error) { + accounts, err := accountsAccessor.FetchList(ctx, filter.Filter(), order.Order(), page.Pagination()) + return FromAccountModelList(accounts), err + }, + CountDataFunc: func(ctx context.Context) (int64, error) { + return accountsAccessor.Count(ctx, filter.Filter()) + }, + ConvertToEdgeFunc: func(obj *gqlmodels.Account) *gqlmodels.AccountEdge { + return &gqlmodels.AccountEdge{ + Cursor: gocast.Str(obj.ID), + Node: obj, + } + }, + }, page) +} + +// MemberConnection implements collection accessor interface with pagination +type MemberConnection = connectors.CollectionConnection[gqlmodels.Member, gqlmodels.MemberEdge] + +// NewMemberConnection based on query object +func NewMemberConnection(ctx context.Context, membersAccessor account.MemberUsecase, filter *gqlmodels.MemberListFilter, order *gqlmodels.MemberListOrder, page *gqlmodels.Page) *MemberConnection { + return connectors.NewCollectionConnection(ctx, &connectors.DataAccessorFunc[gqlmodels.Member, gqlmodels.MemberEdge]{ + FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.Member, error) { + members, err := membersAccessor.FetchListMembers(ctx, + filter.Filter(), order.Order(), page.Pagination()) + return FromMemberModelList(ctx, members), err + }, + CountDataFunc: func(ctx context.Context) (int64, error) { + return membersAccessor.CountMembers(ctx, filter.Filter()) + }, + ConvertToEdgeFunc: func(obj *gqlmodels.Member) *gqlmodels.MemberEdge { + return &gqlmodels.MemberEdge{ + Cursor: gocast.Str(obj.ID), + Node: obj, + } + }, + }, page) +} diff --git a/repository/account/delivery/graphql/mapping.go b/repository/account/delivery/graphql/mapping.go new file mode 100644 index 00000000..814784b6 --- /dev/null +++ b/repository/account/delivery/graphql/mapping.go @@ -0,0 +1,62 @@ +package graphql + +import ( + "context" + + "github.com/demdxx/gocast/v2" + "github.com/demdxx/xtypes" + + "github.com/geniusrabbit/blaze-api/repository/account/models" + rbacgql "github.com/geniusrabbit/blaze-api/repository/rbac/delivery/graphql" + usergql "github.com/geniusrabbit/blaze-api/repository/user/delivery/graphql" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" +) + +// FromAccountModel to local graphql model +func FromAccountModel(acc *models.Account) *gqlmodels.Account { + if acc == nil { + return nil + } + return &gqlmodels.Account{ + ID: acc.ID, + Status: gqlmodels.ApproveStatusFrom(acc.Approve), + Title: acc.Title, + Description: acc.Description, + LogoURI: acc.LogoURI, + PolicyURI: acc.PolicyURI, + TermsOfServiceURI: acc.TermsOfServiceURI, + ClientURI: acc.ClientURI, + Contacts: acc.Contacts, + CreatedAt: acc.CreatedAt, + UpdatedAt: acc.UpdatedAt, + } +} + +// FromAccountModelList converts model list to local model list +func FromAccountModelList(list []*models.Account) []*gqlmodels.Account { + return xtypes.SliceApply(list, FromAccountModel) +} + +// FromMemberModel to local graphql model +func FromMemberModel(ctx context.Context, member *models.AccountMember) *gqlmodels.Member { + if member == nil { + return nil + } + return &gqlmodels.Member{ + ID: member.ID, + Account: FromAccountModel(gocast.Or(member.Account, &models.Account{ID: member.AccountID})), + User: usergql.FromUserModel(gocast.Or(member.User, &userModels.User{ID: member.UserID})), + IsAdmin: member.IsAdmin, + Status: gqlmodels.ApproveStatusFrom(member.Approve), + Roles: rbacgql.FromRBACRoleModelList(ctx, member.Roles), + CreatedAt: member.CreatedAt, + UpdatedAt: member.UpdatedAt, + } +} + +func FromMemberModelList(ctx context.Context, list []*models.AccountMember) []*gqlmodels.Member { + return xtypes.SliceApply(list, func(m *models.AccountMember) *gqlmodels.Member { + return FromMemberModel(ctx, m) + }) +} diff --git a/repository/account/delivery/graphql/member_relolver.go b/repository/account/delivery/graphql/member_relolver.go index 0256df47..a1ef5b77 100644 --- a/repository/account/delivery/graphql/member_relolver.go +++ b/repository/account/delivery/graphql/member_relolver.go @@ -6,52 +6,50 @@ import ( "github.com/geniusrabbit/blaze-api/pkg/requestid" "github.com/geniusrabbit/blaze-api/repository/account" - "github.com/geniusrabbit/blaze-api/repository/account/repository" - "github.com/geniusrabbit/blaze-api/repository/account/usecase" - userrepo "github.com/geniusrabbit/blaze-api/repository/user/repository" - "github.com/geniusrabbit/blaze-api/server/graphql/connectors" "github.com/geniusrabbit/blaze-api/server/graphql/models" ) type MemberQueryResolver struct { accounts account.Usecase + members account.MemberUsecase } -func NewMemberQueryResolver() *MemberQueryResolver { +func NewMemberQueryResolver(accounts account.Usecase, members account.MemberUsecase) *MemberQueryResolver { return &MemberQueryResolver{ - accounts: usecase.NewAccountUsecase(userrepo.New(), repository.New()), + accounts: accounts, + members: members, } } // Invite is the resolver for the inviteAccountMember field. func (r *MemberQueryResolver) Invite(ctx context.Context, accountID uint64, member models.InviteMemberInput) (*models.MemberPayload, error) { - accountMember, err := r.accounts.InviteMember(ctx, accountID, member.Email, member.AllRoles()...) + accountMember, err := r.members.InviteMember(ctx, accountID, member.Email, member.AllRoles()...) if err != nil { return nil, err } return &models.MemberPayload{ ClientMutationID: requestid.Get(ctx), MemberID: accountID, - Member: models.FromMemberModel(ctx, accountMember), + Member: FromMemberModel(ctx, accountMember), }, nil } // Update is the resolver for the updateAccountMember field. func (r *MemberQueryResolver) Update(ctx context.Context, memberID uint64, member models.MemberInput) (*models.MemberPayload, error) { - accountMember, err := r.accounts.SetMemberRoles(ctx, memberID, member.AllRoles()...) + accountMember, err := r.members.SetMemberRoles(ctx, memberID, member.AllRoles()...) if err != nil { return nil, err } return &models.MemberPayload{ ClientMutationID: requestid.Get(ctx), MemberID: memberID, - Member: models.FromMemberModel(ctx, accountMember), + Member: FromMemberModel(ctx, accountMember), }, nil } // Remove is the resolver for the removeAccountMember field. func (r *MemberQueryResolver) Remove(ctx context.Context, memberID uint64) (*models.MemberPayload, error) { - err := r.accounts.UnlinkAccountMember(ctx, memberID) + err := r.members.UnlinkAccountMember(ctx, memberID) if err != nil { return nil, err } @@ -72,6 +70,6 @@ func (r *MemberQueryResolver) Reject(ctx context.Context, memberID uint64, msg s } // List is the resolver for the listMembers field. -func (r *MemberQueryResolver) List(ctx context.Context, filter *models.MemberListFilter, order *models.MemberListOrder, page *models.Page) (*connectors.MemberConnection, error) { - return connectors.NewMemberConnection(ctx, r.accounts, filter, order, page), nil +func (r *MemberQueryResolver) List(ctx context.Context, filter *models.MemberListFilter, order *models.MemberListOrder, page *models.Page) (*MemberConnection, error) { + return NewMemberConnection(ctx, r.members, filter, order, page), nil } diff --git a/repository/account/init.go b/repository/account/init.go index 3549b222..1a6e9399 100644 --- a/repository/account/init.go +++ b/repository/account/init.go @@ -1,3 +1,9 @@ package account -const RoleAdmin = `admin` +const ( + // RoleAdmin is the admin role for accounts + RoleAdmin = `admin` + + // PermAuthCross is the permission for cross-account auth + PermAuthCross = `auth.cross` +) diff --git a/repository/account/mocks/repository.go b/repository/account/mocks/repository.go index e4af8d31..5ecb3de9 100644 --- a/repository/account/mocks/repository.go +++ b/repository/account/mocks/repository.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: repository.go +// +// Generated by this command: +// +// mockgen -source repository.go -package mocks -destination mocks/repository.go +// // Package mocks is a generated GoMock package. package mocks @@ -8,16 +13,15 @@ import ( context "context" reflect "reflect" - model "github.com/geniusrabbit/blaze-api/model" - repository "github.com/geniusrabbit/blaze-api/repository" account "github.com/geniusrabbit/blaze-api/repository/account" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockRepository is a mock of Repository interface. type MockRepository struct { ctrl *gomock.Controller recorder *MockRepositoryMockRecorder + isgomock struct{} } // MockRepositoryMockRecorder is the mock recorder for MockRepository. @@ -38,48 +42,38 @@ func (m *MockRepository) EXPECT() *MockRepositoryMockRecorder { } // Count mocks base method. -func (m *MockRepository) Count(ctx context.Context, filter *account.Filter) (int64, error) { +func (m *MockRepository) Count(ctx context.Context, opts ...account.QOption) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockRepositoryMockRecorder) Count(ctx, filter interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Count(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), ctx, filter) -} - -// CountMembers mocks base method. -func (m *MockRepository) CountMembers(ctx context.Context, filter *account.MemberFilter) (int64, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CountMembers", ctx, filter) - ret0, _ := ret[0].(int64) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// CountMembers indicates an expected call of CountMembers. -func (mr *MockRepositoryMockRecorder) CountMembers(ctx, filter interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountMembers", reflect.TypeOf((*MockRepository)(nil).CountMembers), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), varargs...) } // Create mocks base method. -func (m *MockRepository) Create(ctx context.Context, account *model.Account) (uint64, error) { +func (m *MockRepository) Create(ctx context.Context, arg1 *account.Account) (uint64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", ctx, account) + ret := m.ctrl.Call(m, "Create", ctx, arg1) ret0, _ := ret[0].(uint64) ret1, _ := ret[1].(error) return ret0, ret1 } // Create indicates an expected call of Create. -func (mr *MockRepositoryMockRecorder) Create(ctx, account interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Create(ctx, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockRepository)(nil).Create), ctx, account) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockRepository)(nil).Create), ctx, arg1) } // Delete mocks base method. @@ -91,73 +85,156 @@ func (m *MockRepository) Delete(ctx context.Context, id uint64) error { } // Delete indicates an expected call of Delete. -func (mr *MockRepositoryMockRecorder) Delete(ctx, id interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Delete(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRepository)(nil).Delete), ctx, id) } // FetchList mocks base method. -func (m *MockRepository) FetchList(ctx context.Context, filter *account.Filter, order *account.ListOrder, pagination *repository.Pagination) ([]*model.Account, error) { +func (m *MockRepository) FetchList(ctx context.Context, opts ...account.QOption) ([]*account.Account, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter, order, pagination) - ret0, _ := ret[0].([]*model.Account) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*account.Account) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockRepositoryMockRecorder) FetchList(ctx, filter, order, pagination interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) FetchList(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), ctx, filter, order, pagination) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), varargs...) } -// FetchListMembers mocks base method. -func (m *MockRepository) FetchListMembers(ctx context.Context, filter *account.MemberFilter, order *account.MemberListOrder, pagination *repository.Pagination) ([]*model.AccountMember, error) { +// Get mocks base method. +func (m *MockRepository) Get(ctx context.Context, id uint64) (*account.Account, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchListMembers", ctx, filter, order, pagination) - ret0, _ := ret[0].([]*model.AccountMember) + ret := m.ctrl.Call(m, "Get", ctx, id) + ret0, _ := ret[0].(*account.Account) ret1, _ := ret[1].(error) return ret0, ret1 } -// FetchListMembers indicates an expected call of FetchListMembers. -func (mr *MockRepositoryMockRecorder) FetchListMembers(ctx, filter, order, pagination interface{}) *gomock.Call { +// Get indicates an expected call of Get. +func (mr *MockRepositoryMockRecorder) Get(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchListMembers", reflect.TypeOf((*MockRepository)(nil).FetchListMembers), ctx, filter, order, pagination) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRepository)(nil).Get), ctx, id) } -// Get mocks base method. -func (m *MockRepository) Get(ctx context.Context, id uint64) (*model.Account, error) { +// GetByToken mocks base method. +func (m *MockRepository) GetByToken(ctx context.Context, token string) (*account.User, *account.Account, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, id) - ret0, _ := ret[0].(*model.Account) + ret := m.ctrl.Call(m, "GetByToken", ctx, token) + ret0, _ := ret[0].(*account.User) + ret1, _ := ret[1].(*account.Account) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetByToken indicates an expected call of GetByToken. +func (mr *MockRepositoryMockRecorder) GetByToken(ctx, token any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByToken", reflect.TypeOf((*MockRepository)(nil).GetByToken), ctx, token) +} + +// LoadPermissions mocks base method. +func (m *MockRepository) LoadPermissions(ctx context.Context, arg1 *account.Account, user *account.User) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "LoadPermissions", ctx, arg1, user) + ret0, _ := ret[0].(error) + return ret0 +} + +// LoadPermissions indicates an expected call of LoadPermissions. +func (mr *MockRepositoryMockRecorder) LoadPermissions(ctx, arg1, user any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadPermissions", reflect.TypeOf((*MockRepository)(nil).LoadPermissions), ctx, arg1, user) +} + +// Update mocks base method. +func (m *MockRepository) Update(ctx context.Context, id uint64, arg2 *account.Account) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Update", ctx, id, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// Update indicates an expected call of Update. +func (mr *MockRepositoryMockRecorder) Update(ctx, id, arg2 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockRepository)(nil).Update), ctx, id, arg2) +} + +// MockMemberRepository is a mock of MemberRepository interface. +type MockMemberRepository struct { + ctrl *gomock.Controller + recorder *MockMemberRepositoryMockRecorder + isgomock struct{} +} + +// MockMemberRepositoryMockRecorder is the mock recorder for MockMemberRepository. +type MockMemberRepositoryMockRecorder struct { + mock *MockMemberRepository +} + +// NewMockMemberRepository creates a new mock instance. +func NewMockMemberRepository(ctrl *gomock.Controller) *MockMemberRepository { + mock := &MockMemberRepository{ctrl: ctrl} + mock.recorder = &MockMemberRepositoryMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMemberRepository) EXPECT() *MockMemberRepositoryMockRecorder { + return m.recorder +} + +// CountMembers mocks base method. +func (m *MockMemberRepository) CountMembers(ctx context.Context, opts ...account.QOption) (int64, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CountMembers", varargs...) + ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } -// Get indicates an expected call of Get. -func (mr *MockRepositoryMockRecorder) Get(ctx, id interface{}) *gomock.Call { +// CountMembers indicates an expected call of CountMembers. +func (mr *MockMemberRepositoryMockRecorder) CountMembers(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRepository)(nil).Get), ctx, id) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountMembers", reflect.TypeOf((*MockMemberRepository)(nil).CountMembers), varargs...) } -// GetByTitle mocks base method. -func (m *MockRepository) GetByTitle(ctx context.Context, title string) (*model.Account, error) { +// FetchListMembers mocks base method. +func (m *MockMemberRepository) FetchListMembers(ctx context.Context, opts ...account.QOption) ([]*account.AccountMember, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetByTitle", ctx, title) - ret0, _ := ret[0].(*model.Account) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchListMembers", varargs...) + ret0, _ := ret[0].([]*account.AccountMember) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetByTitle indicates an expected call of GetByTitle. -func (mr *MockRepositoryMockRecorder) GetByTitle(ctx, title interface{}) *gomock.Call { +// FetchListMembers indicates an expected call of FetchListMembers. +func (mr *MockMemberRepositoryMockRecorder) FetchListMembers(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByTitle", reflect.TypeOf((*MockRepository)(nil).GetByTitle), ctx, title) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchListMembers", reflect.TypeOf((*MockMemberRepository)(nil).FetchListMembers), varargs...) } // IsAdmin mocks base method. -func (m *MockRepository) IsAdmin(ctx context.Context, userID, accountID uint64) bool { +func (m *MockMemberRepository) IsAdmin(ctx context.Context, userID, accountID uint64) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IsAdmin", ctx, userID, accountID) ret0, _ := ret[0].(bool) @@ -165,13 +242,13 @@ func (m *MockRepository) IsAdmin(ctx context.Context, userID, accountID uint64) } // IsAdmin indicates an expected call of IsAdmin. -func (mr *MockRepositoryMockRecorder) IsAdmin(ctx, userID, accountID interface{}) *gomock.Call { +func (mr *MockMemberRepositoryMockRecorder) IsAdmin(ctx, userID, accountID any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAdmin", reflect.TypeOf((*MockRepository)(nil).IsAdmin), ctx, userID, accountID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsAdmin", reflect.TypeOf((*MockMemberRepository)(nil).IsAdmin), ctx, userID, accountID) } // IsMember mocks base method. -func (m *MockRepository) IsMember(ctx context.Context, userID, accountID uint64) bool { +func (m *MockMemberRepository) IsMember(ctx context.Context, userID, accountID uint64) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IsMember", ctx, userID, accountID) ret0, _ := ret[0].(bool) @@ -179,15 +256,15 @@ func (m *MockRepository) IsMember(ctx context.Context, userID, accountID uint64) } // IsMember indicates an expected call of IsMember. -func (mr *MockRepositoryMockRecorder) IsMember(ctx, userID, accountID interface{}) *gomock.Call { +func (mr *MockMemberRepositoryMockRecorder) IsMember(ctx, userID, accountID any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsMember", reflect.TypeOf((*MockRepository)(nil).IsMember), ctx, userID, accountID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsMember", reflect.TypeOf((*MockMemberRepository)(nil).IsMember), ctx, userID, accountID) } // LinkMember mocks base method. -func (m *MockRepository) LinkMember(ctx context.Context, account *model.Account, isAdmin bool, members ...*model.User) error { +func (m *MockMemberRepository) LinkMember(ctx context.Context, arg1 *account.Account, isAdmin bool, members ...*account.User) error { m.ctrl.T.Helper() - varargs := []interface{}{ctx, account, isAdmin} + varargs := []any{ctx, arg1, isAdmin} for _, a := range members { varargs = append(varargs, a) } @@ -197,60 +274,46 @@ func (m *MockRepository) LinkMember(ctx context.Context, account *model.Account, } // LinkMember indicates an expected call of LinkMember. -func (mr *MockRepositoryMockRecorder) LinkMember(ctx, account, isAdmin interface{}, members ...interface{}) *gomock.Call { +func (mr *MockMemberRepositoryMockRecorder) LinkMember(ctx, arg1, isAdmin any, members ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, account, isAdmin}, members...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LinkMember", reflect.TypeOf((*MockRepository)(nil).LinkMember), varargs...) -} - -// LoadPermissions mocks base method. -func (m *MockRepository) LoadPermissions(ctx context.Context, account *model.Account, user *model.User) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "LoadPermissions", ctx, account, user) - ret0, _ := ret[0].(error) - return ret0 -} - -// LoadPermissions indicates an expected call of LoadPermissions. -func (mr *MockRepositoryMockRecorder) LoadPermissions(ctx, account, user interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadPermissions", reflect.TypeOf((*MockRepository)(nil).LoadPermissions), ctx, account, user) + varargs := append([]any{ctx, arg1, isAdmin}, members...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LinkMember", reflect.TypeOf((*MockMemberRepository)(nil).LinkMember), varargs...) } // Member mocks base method. -func (m *MockRepository) Member(ctx context.Context, userID, accountID uint64) (*model.AccountMember, error) { +func (m *MockMemberRepository) Member(ctx context.Context, userID, accountID uint64) (*account.AccountMember, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Member", ctx, userID, accountID) - ret0, _ := ret[0].(*model.AccountMember) + ret0, _ := ret[0].(*account.AccountMember) ret1, _ := ret[1].(error) return ret0, ret1 } // Member indicates an expected call of Member. -func (mr *MockRepositoryMockRecorder) Member(ctx, userID, accountID interface{}) *gomock.Call { +func (mr *MockMemberRepositoryMockRecorder) Member(ctx, userID, accountID any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Member", reflect.TypeOf((*MockRepository)(nil).Member), ctx, userID, accountID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Member", reflect.TypeOf((*MockMemberRepository)(nil).Member), ctx, userID, accountID) } // MemberByID mocks base method. -func (m *MockRepository) MemberByID(ctx context.Context, id uint64) (*model.AccountMember, error) { +func (m *MockMemberRepository) MemberByID(ctx context.Context, id uint64) (*account.AccountMember, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MemberByID", ctx, id) - ret0, _ := ret[0].(*model.AccountMember) + ret0, _ := ret[0].(*account.AccountMember) ret1, _ := ret[1].(error) return ret0, ret1 } // MemberByID indicates an expected call of MemberByID. -func (mr *MockRepositoryMockRecorder) MemberByID(ctx, id interface{}) *gomock.Call { +func (mr *MockMemberRepositoryMockRecorder) MemberByID(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MemberByID", reflect.TypeOf((*MockRepository)(nil).MemberByID), ctx, id) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MemberByID", reflect.TypeOf((*MockMemberRepository)(nil).MemberByID), ctx, id) } // SetMemberRoles mocks base method. -func (m *MockRepository) SetMemberRoles(ctx context.Context, account *model.Account, member *model.User, roles ...string) error { +func (m *MockMemberRepository) SetMemberRoles(ctx context.Context, arg1 *account.Account, member *account.User, roles ...string) error { m.ctrl.T.Helper() - varargs := []interface{}{ctx, account, member} + varargs := []any{ctx, arg1, member} for _, a := range roles { varargs = append(varargs, a) } @@ -260,16 +323,16 @@ func (m *MockRepository) SetMemberRoles(ctx context.Context, account *model.Acco } // SetMemberRoles indicates an expected call of SetMemberRoles. -func (mr *MockRepositoryMockRecorder) SetMemberRoles(ctx, account, member interface{}, roles ...interface{}) *gomock.Call { +func (mr *MockMemberRepositoryMockRecorder) SetMemberRoles(ctx, arg1, member any, roles ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, account, member}, roles...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetMemberRoles", reflect.TypeOf((*MockRepository)(nil).SetMemberRoles), varargs...) + varargs := append([]any{ctx, arg1, member}, roles...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetMemberRoles", reflect.TypeOf((*MockMemberRepository)(nil).SetMemberRoles), varargs...) } // UnlinkMember mocks base method. -func (m *MockRepository) UnlinkMember(ctx context.Context, account *model.Account, members ...*model.User) error { +func (m *MockMemberRepository) UnlinkMember(ctx context.Context, arg1 *account.Account, members ...*account.User) error { m.ctrl.T.Helper() - varargs := []interface{}{ctx, account} + varargs := []any{ctx, arg1} for _, a := range members { varargs = append(varargs, a) } @@ -279,22 +342,8 @@ func (m *MockRepository) UnlinkMember(ctx context.Context, account *model.Accoun } // UnlinkMember indicates an expected call of UnlinkMember. -func (mr *MockRepositoryMockRecorder) UnlinkMember(ctx, account interface{}, members ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, account}, members...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnlinkMember", reflect.TypeOf((*MockRepository)(nil).UnlinkMember), varargs...) -} - -// Update mocks base method. -func (m *MockRepository) Update(ctx context.Context, id uint64, account *model.Account) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Update", ctx, id, account) - ret0, _ := ret[0].(error) - return ret0 -} - -// Update indicates an expected call of Update. -func (mr *MockRepositoryMockRecorder) Update(ctx, id, account interface{}) *gomock.Call { +func (mr *MockMemberRepositoryMockRecorder) UnlinkMember(ctx, arg1 any, members ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockRepository)(nil).Update), ctx, id, account) + varargs := append([]any{ctx, arg1}, members...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnlinkMember", reflect.TypeOf((*MockMemberRepository)(nil).UnlinkMember), varargs...) } diff --git a/repository/account/mocks/usecase.go b/repository/account/mocks/usecase.go index 7b7292ac..2590daae 100644 --- a/repository/account/mocks/usecase.go +++ b/repository/account/mocks/usecase.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: usecase.go +// +// Generated by this command: +// +// mockgen -source usecase.go -package mocks -destination mocks/usecase.go +// // Package mocks is a generated GoMock package. package mocks @@ -8,16 +13,15 @@ import ( context "context" reflect "reflect" - model "github.com/geniusrabbit/blaze-api/model" - repository "github.com/geniusrabbit/blaze-api/repository" account "github.com/geniusrabbit/blaze-api/repository/account" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockUsecase is a mock of Usecase interface. type MockUsecase struct { ctrl *gomock.Controller recorder *MockUsecaseMockRecorder + isgomock struct{} } // MockUsecaseMockRecorder is the mock recorder for MockUsecase. @@ -38,33 +42,23 @@ func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder { } // Count mocks base method. -func (m *MockUsecase) Count(ctx context.Context, filter *account.Filter) (int64, error) { +func (m *MockUsecase) Count(ctx context.Context, opts ...account.QOption) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockUsecaseMockRecorder) Count(ctx, filter interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), ctx, filter) -} - -// CountMembers mocks base method. -func (m *MockUsecase) CountMembers(ctx context.Context, filter *account.MemberFilter) (int64, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CountMembers", ctx, filter) - ret0, _ := ret[0].(int64) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// CountMembers indicates an expected call of CountMembers. -func (mr *MockUsecaseMockRecorder) CountMembers(ctx, filter interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Count(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountMembers", reflect.TypeOf((*MockUsecase)(nil).CountMembers), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), varargs...) } // Delete mocks base method. @@ -76,95 +70,164 @@ func (m *MockUsecase) Delete(ctx context.Context, id uint64) error { } // Delete indicates an expected call of Delete. -func (mr *MockUsecaseMockRecorder) Delete(ctx, id interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Delete(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockUsecase)(nil).Delete), ctx, id) } // FetchList mocks base method. -func (m *MockUsecase) FetchList(ctx context.Context, filter *account.Filter, order *account.ListOrder, pagination *repository.Pagination) ([]*model.Account, error) { +func (m *MockUsecase) FetchList(ctx context.Context, opts ...account.QOption) ([]*account.Account, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter, order, pagination) - ret0, _ := ret[0].([]*model.Account) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*account.Account) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockUsecaseMockRecorder) FetchList(ctx, filter, order, pagination interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) FetchList(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), ctx, filter, order, pagination) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), varargs...) } -// FetchListMembers mocks base method. -func (m *MockUsecase) FetchListMembers(ctx context.Context, filter *account.MemberFilter, order *account.MemberListOrder, pagination *repository.Pagination) ([]*model.AccountMember, error) { +// Get mocks base method. +func (m *MockUsecase) Get(ctx context.Context, id uint64) (*account.Account, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchListMembers", ctx, filter, order, pagination) - ret0, _ := ret[0].([]*model.AccountMember) + ret := m.ctrl.Call(m, "Get", ctx, id) + ret0, _ := ret[0].(*account.Account) ret1, _ := ret[1].(error) return ret0, ret1 } -// FetchListMembers indicates an expected call of FetchListMembers. -func (mr *MockUsecaseMockRecorder) FetchListMembers(ctx, filter, order, pagination interface{}) *gomock.Call { +// Get indicates an expected call of Get. +func (mr *MockUsecaseMockRecorder) Get(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchListMembers", reflect.TypeOf((*MockUsecase)(nil).FetchListMembers), ctx, filter, order, pagination) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockUsecase)(nil).Get), ctx, id) } -// Get mocks base method. -func (m *MockUsecase) Get(ctx context.Context, id uint64) (*model.Account, error) { +// Register mocks base method. +func (m *MockUsecase) Register(ctx context.Context, ownerObj *account.User, accountObj *account.Account, password string) (uint64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, id) - ret0, _ := ret[0].(*model.Account) + ret := m.ctrl.Call(m, "Register", ctx, ownerObj, accountObj, password) + ret0, _ := ret[0].(uint64) ret1, _ := ret[1].(error) return ret0, ret1 } -// Get indicates an expected call of Get. -func (mr *MockUsecaseMockRecorder) Get(ctx, id interface{}) *gomock.Call { +// Register indicates an expected call of Register. +func (mr *MockUsecaseMockRecorder) Register(ctx, ownerObj, accountObj, password any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockUsecase)(nil).Get), ctx, id) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Register", reflect.TypeOf((*MockUsecase)(nil).Register), ctx, ownerObj, accountObj, password) +} + +// Store mocks base method. +func (m *MockUsecase) Store(ctx context.Context, arg1 *account.Account) (uint64, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Store", ctx, arg1) + ret0, _ := ret[0].(uint64) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Store indicates an expected call of Store. +func (mr *MockUsecaseMockRecorder) Store(ctx, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Store", reflect.TypeOf((*MockUsecase)(nil).Store), ctx, arg1) +} + +// MockMemberUsecase is a mock of MemberUsecase interface. +type MockMemberUsecase struct { + ctrl *gomock.Controller + recorder *MockMemberUsecaseMockRecorder + isgomock struct{} +} + +// MockMemberUsecaseMockRecorder is the mock recorder for MockMemberUsecase. +type MockMemberUsecaseMockRecorder struct { + mock *MockMemberUsecase +} + +// NewMockMemberUsecase creates a new mock instance. +func NewMockMemberUsecase(ctrl *gomock.Controller) *MockMemberUsecase { + mock := &MockMemberUsecase{ctrl: ctrl} + mock.recorder = &MockMemberUsecaseMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMemberUsecase) EXPECT() *MockMemberUsecaseMockRecorder { + return m.recorder +} + +// CountMembers mocks base method. +func (m *MockMemberUsecase) CountMembers(ctx context.Context, opts ...account.QOption) (int64, error) { + m.ctrl.T.Helper() + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CountMembers", varargs...) + ret0, _ := ret[0].(int64) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CountMembers indicates an expected call of CountMembers. +func (mr *MockMemberUsecaseMockRecorder) CountMembers(ctx any, opts ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountMembers", reflect.TypeOf((*MockMemberUsecase)(nil).CountMembers), varargs...) } -// GetByTitle mocks base method. -func (m *MockUsecase) GetByTitle(ctx context.Context, title string) (*model.Account, error) { +// FetchListMembers mocks base method. +func (m *MockMemberUsecase) FetchListMembers(ctx context.Context, opts ...account.QOption) ([]*account.AccountMember, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetByTitle", ctx, title) - ret0, _ := ret[0].(*model.Account) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchListMembers", varargs...) + ret0, _ := ret[0].([]*account.AccountMember) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetByTitle indicates an expected call of GetByTitle. -func (mr *MockUsecaseMockRecorder) GetByTitle(ctx, title interface{}) *gomock.Call { +// FetchListMembers indicates an expected call of FetchListMembers. +func (mr *MockMemberUsecaseMockRecorder) FetchListMembers(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByTitle", reflect.TypeOf((*MockUsecase)(nil).GetByTitle), ctx, title) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchListMembers", reflect.TypeOf((*MockMemberUsecase)(nil).FetchListMembers), varargs...) } // InviteMember mocks base method. -func (m *MockUsecase) InviteMember(ctx context.Context, accountID uint64, email string, roles ...string) (*model.AccountMember, error) { +func (m *MockMemberUsecase) InviteMember(ctx context.Context, accountID uint64, email string, roles ...string) (*account.AccountMember, error) { m.ctrl.T.Helper() - varargs := []interface{}{ctx, accountID, email} + varargs := []any{ctx, accountID, email} for _, a := range roles { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "InviteMember", varargs...) - ret0, _ := ret[0].(*model.AccountMember) + ret0, _ := ret[0].(*account.AccountMember) ret1, _ := ret[1].(error) return ret0, ret1 } // InviteMember indicates an expected call of InviteMember. -func (mr *MockUsecaseMockRecorder) InviteMember(ctx, accountID, email interface{}, roles ...interface{}) *gomock.Call { +func (mr *MockMemberUsecaseMockRecorder) InviteMember(ctx, accountID, email any, roles ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, accountID, email}, roles...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InviteMember", reflect.TypeOf((*MockUsecase)(nil).InviteMember), varargs...) + varargs := append([]any{ctx, accountID, email}, roles...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InviteMember", reflect.TypeOf((*MockMemberUsecase)(nil).InviteMember), varargs...) } // LinkMember mocks base method. -func (m *MockUsecase) LinkMember(ctx context.Context, account *model.Account, isAdmin bool, members ...*model.User) error { +func (m *MockMemberUsecase) LinkMember(ctx context.Context, arg1 *account.Account, isAdmin bool, members ...*account.User) error { m.ctrl.T.Helper() - varargs := []interface{}{ctx, account, isAdmin} + varargs := []any{ctx, arg1, isAdmin} for _, a := range members { varargs = append(varargs, a) } @@ -174,84 +237,54 @@ func (m *MockUsecase) LinkMember(ctx context.Context, account *model.Account, is } // LinkMember indicates an expected call of LinkMember. -func (mr *MockUsecaseMockRecorder) LinkMember(ctx, account, isAdmin interface{}, members ...interface{}) *gomock.Call { +func (mr *MockMemberUsecaseMockRecorder) LinkMember(ctx, arg1, isAdmin any, members ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, account, isAdmin}, members...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LinkMember", reflect.TypeOf((*MockUsecase)(nil).LinkMember), varargs...) -} - -// Register mocks base method. -func (m *MockUsecase) Register(ctx context.Context, ownerObj *model.User, accountObj *model.Account, password string) (uint64, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Register", ctx, ownerObj, accountObj, password) - ret0, _ := ret[0].(uint64) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Register indicates an expected call of Register. -func (mr *MockUsecaseMockRecorder) Register(ctx, ownerObj, accountObj, password interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Register", reflect.TypeOf((*MockUsecase)(nil).Register), ctx, ownerObj, accountObj, password) + varargs := append([]any{ctx, arg1, isAdmin}, members...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LinkMember", reflect.TypeOf((*MockMemberUsecase)(nil).LinkMember), varargs...) } // SetAccountMemeberRoles mocks base method. -func (m *MockUsecase) SetAccountMemeberRoles(ctx context.Context, accountID, userID uint64, roles ...string) (*model.AccountMember, error) { +func (m *MockMemberUsecase) SetAccountMemeberRoles(ctx context.Context, accountID, userID uint64, roles ...string) (*account.AccountMember, error) { m.ctrl.T.Helper() - varargs := []interface{}{ctx, accountID, userID} + varargs := []any{ctx, accountID, userID} for _, a := range roles { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "SetAccountMemeberRoles", varargs...) - ret0, _ := ret[0].(*model.AccountMember) + ret0, _ := ret[0].(*account.AccountMember) ret1, _ := ret[1].(error) return ret0, ret1 } // SetAccountMemeberRoles indicates an expected call of SetAccountMemeberRoles. -func (mr *MockUsecaseMockRecorder) SetAccountMemeberRoles(ctx, accountID, userID interface{}, roles ...interface{}) *gomock.Call { +func (mr *MockMemberUsecaseMockRecorder) SetAccountMemeberRoles(ctx, accountID, userID any, roles ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, accountID, userID}, roles...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAccountMemeberRoles", reflect.TypeOf((*MockUsecase)(nil).SetAccountMemeberRoles), varargs...) + varargs := append([]any{ctx, accountID, userID}, roles...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAccountMemeberRoles", reflect.TypeOf((*MockMemberUsecase)(nil).SetAccountMemeberRoles), varargs...) } // SetMemberRoles mocks base method. -func (m *MockUsecase) SetMemberRoles(ctx context.Context, memberID uint64, roles ...string) (*model.AccountMember, error) { +func (m *MockMemberUsecase) SetMemberRoles(ctx context.Context, memberID uint64, roles ...string) (*account.AccountMember, error) { m.ctrl.T.Helper() - varargs := []interface{}{ctx, memberID} + varargs := []any{ctx, memberID} for _, a := range roles { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "SetMemberRoles", varargs...) - ret0, _ := ret[0].(*model.AccountMember) + ret0, _ := ret[0].(*account.AccountMember) ret1, _ := ret[1].(error) return ret0, ret1 } // SetMemberRoles indicates an expected call of SetMemberRoles. -func (mr *MockUsecaseMockRecorder) SetMemberRoles(ctx, memberID interface{}, roles ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, memberID}, roles...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetMemberRoles", reflect.TypeOf((*MockUsecase)(nil).SetMemberRoles), varargs...) -} - -// Store mocks base method. -func (m *MockUsecase) Store(ctx context.Context, account *model.Account) (uint64, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Store", ctx, account) - ret0, _ := ret[0].(uint64) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Store indicates an expected call of Store. -func (mr *MockUsecaseMockRecorder) Store(ctx, account interface{}) *gomock.Call { +func (mr *MockMemberUsecaseMockRecorder) SetMemberRoles(ctx, memberID any, roles ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Store", reflect.TypeOf((*MockUsecase)(nil).Store), ctx, account) + varargs := append([]any{ctx, memberID}, roles...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetMemberRoles", reflect.TypeOf((*MockMemberUsecase)(nil).SetMemberRoles), varargs...) } // UnlinkAccountMember mocks base method. -func (m *MockUsecase) UnlinkAccountMember(ctx context.Context, memberID uint64) error { +func (m *MockMemberUsecase) UnlinkAccountMember(ctx context.Context, memberID uint64) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UnlinkAccountMember", ctx, memberID) ret0, _ := ret[0].(error) @@ -259,15 +292,15 @@ func (m *MockUsecase) UnlinkAccountMember(ctx context.Context, memberID uint64) } // UnlinkAccountMember indicates an expected call of UnlinkAccountMember. -func (mr *MockUsecaseMockRecorder) UnlinkAccountMember(ctx, memberID interface{}) *gomock.Call { +func (mr *MockMemberUsecaseMockRecorder) UnlinkAccountMember(ctx, memberID any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnlinkAccountMember", reflect.TypeOf((*MockUsecase)(nil).UnlinkAccountMember), ctx, memberID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnlinkAccountMember", reflect.TypeOf((*MockMemberUsecase)(nil).UnlinkAccountMember), ctx, memberID) } // UnlinkMember mocks base method. -func (m *MockUsecase) UnlinkMember(ctx context.Context, account *model.Account, members ...*model.User) error { +func (m *MockMemberUsecase) UnlinkMember(ctx context.Context, arg1 *account.Account, members ...*account.User) error { m.ctrl.T.Helper() - varargs := []interface{}{ctx, account} + varargs := []any{ctx, arg1} for _, a := range members { varargs = append(varargs, a) } @@ -277,8 +310,8 @@ func (m *MockUsecase) UnlinkMember(ctx context.Context, account *model.Account, } // UnlinkMember indicates an expected call of UnlinkMember. -func (mr *MockUsecaseMockRecorder) UnlinkMember(ctx, account interface{}, members ...interface{}) *gomock.Call { +func (mr *MockMemberUsecaseMockRecorder) UnlinkMember(ctx, arg1 any, members ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, account}, members...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnlinkMember", reflect.TypeOf((*MockUsecase)(nil).UnlinkMember), varargs...) + varargs := append([]any{ctx, arg1}, members...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnlinkMember", reflect.TypeOf((*MockMemberUsecase)(nil).UnlinkMember), varargs...) } diff --git a/repository/account/models.go b/repository/account/models.go index 9516288f..480b643a 100644 --- a/repository/account/models.go +++ b/repository/account/models.go @@ -1,33 +1,49 @@ package account import ( - "time" + "github.com/geniusrabbit/blaze-api/repository/account/models" + "github.com/geniusrabbit/blaze-api/repository/user" +) + +// import ( +// "time" + +// "github.com/geniusrabbit/blaze-api/model" +// ) + +// type AccountBase interface { +// IsNil() bool +// GetID() uint64 +// SetID(id uint64) + +// ExtendAdminUsers(ids ...uint64) +// SetPermissions(perm model.PermissionChecker) + +// GetApprove() model.ApproveStatus +// SetApprove(status model.ApproveStatus) + +// SetCreatedAt(createdAt time.Time) +// } + +// type Account[AccountT AccountBase] interface { +// AccountBase +// New() AccountT +// NewBasicAccount( +// id uint64, +// title string, +// approve model.ApproveStatus, +// perms model.PermissionChecker, +// admins []uint64, +// ) AccountT +// } - "github.com/geniusrabbit/blaze-api/model" +type ( + Account = models.Account + AccountMember = models.AccountMember + M2MAccountMemberRole = models.M2MAccountMemberRole + PermissionChecker = models.PermissionChecker + User = user.User ) -type AccountBase interface { - IsNil() bool - GetID() uint64 - SetID(id uint64) - - ExtendAdminUsers(ids ...uint64) - SetPermissions(perm model.PermissionChecker) - - GetApprove() model.ApproveStatus - SetApprove(status model.ApproveStatus) - - SetCreatedAt(createdAt time.Time) -} - -type Account[AccountT AccountBase] interface { - AccountBase - New() AccountT - NewBasicAccount( - id uint64, - title string, - approve model.ApproveStatus, - perms model.PermissionChecker, - admins []uint64, - ) AccountT -} +// CtxPermissionCheckAccount is the context key for account permission checks. +var CtxPermissionCheckAccount = models.CtxPermissionCheckAccount diff --git a/model/account_base.go b/repository/account/models/account_base.go similarity index 90% rename from model/account_base.go rename to repository/account/models/account_base.go index 5e94d920..2eeeb4f4 100644 --- a/model/account_base.go +++ b/repository/account/models/account_base.go @@ -1,4 +1,4 @@ -package model +package models import ( "context" @@ -8,12 +8,14 @@ import ( "github.com/demdxx/xtypes" "github.com/geniusrabbit/gosql/v2" "gorm.io/gorm" + + "github.com/geniusrabbit/blaze-api/pkg/models" ) // Account provides the information about the account type Account struct { - ID uint64 `json:"id" gorm:"primaryKey"` - Approve ApproveStatus `json:"approved" db:"approve_status" gorm:"column:approve_status" ` + ID uint64 `json:"id" gorm:"primaryKey"` + Approve models.ApproveStatus `json:"approved" db:"approve_status" gorm:"column:approve_status" ` Title string `json:"title"` Description string `json:"description"` @@ -54,6 +56,11 @@ func (acc *Account) TableName() string { return `account_base` } +// IsNil checks if the account is nil +func (acc *Account) IsNil() bool { + return acc == nil +} + // IsAnonymous account func (acc *Account) IsAnonymous() bool { return acc == nil || acc.ID == 0 @@ -85,7 +92,7 @@ func (acc *Account) CheckPermissions(ctx context.Context, resource any, patterns if acc == nil || acc.Permissions == nil { return false } - ctx = context.WithValue(ctx, ctxPermissionCheckAccount, acc) + ctx = context.WithValue(ctx, CtxPermissionCheckAccount, acc) return acc.Permissions.CheckPermissions(ctx, resource, patterns...) } @@ -94,7 +101,7 @@ func (acc *Account) CheckedPermissions(ctx context.Context, resource any, patter if acc == nil || acc.Permissions == nil { return nil } - ctx = context.WithValue(ctx, ctxPermissionCheckAccount, acc) + ctx = context.WithValue(ctx, CtxPermissionCheckAccount, acc) return acc.Permissions.CheckedPermissions(ctx, resource, patterns...) } diff --git a/model/account_member.go b/repository/account/models/account_member.go similarity index 66% rename from model/account_member.go rename to repository/account/models/account_member.go index 0a5dd5d1..b1dc9add 100644 --- a/model/account_member.go +++ b/repository/account/models/account_member.go @@ -1,9 +1,13 @@ -package model +package models import ( "time" "gorm.io/gorm" + + "github.com/geniusrabbit/blaze-api/pkg/models" + rbacModels "github.com/geniusrabbit/blaze-api/repository/rbac/models" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" ) // M2MAccountMemberRole m2m link between members and roles|permissions @@ -20,13 +24,13 @@ func (member *M2MAccountMemberRole) TableName() string { // AccountMember contains reference from user to account as memeber type AccountMember struct { - ID uint64 `db:"id" gorm:"primaryKey"` - Approve ApproveStatus `db:"approve_status" gorm:"column:approve_status"` + ID uint64 `db:"id" gorm:"primaryKey"` + Approve models.ApproveStatus `db:"approve_status" gorm:"column:approve_status"` - AccountID uint64 `db:"account_id"` - Account *Account `db:"-" gorm:"foreignKey:AccountID;references:ID"` - UserID uint64 `db:"user_id"` - User *User `db:"-" gorm:"foreignKey:UserID;references:ID"` + AccountID uint64 `db:"account_id"` + Account *Account `db:"-" gorm:"foreignKey:AccountID;references:ID"` + UserID uint64 `db:"user_id"` + User *userModels.User `db:"-" gorm:"foreignKey:UserID;references:ID"` // Superuser permissions for the current account // Despite of that optinion that better to use roles as the only way of permission issue @@ -36,7 +40,7 @@ type AccountMember struct { IsAdmin bool `db:"is_admin"` // Roles of the member - Roles []*Role `gorm:"many2many:m2m_account_member_role;foreignKey:ID;joinForeignKey:MemberID;references:ID;joinReferences:RoleID"` + Roles []*rbacModels.Role `gorm:"many2many:m2m_account_member_role;foreignKey:ID;joinForeignKey:MemberID;references:ID;joinReferences:RoleID"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` diff --git a/model/account_permission.go b/repository/account/models/account_permission.go similarity index 57% rename from model/account_permission.go rename to repository/account/models/account_permission.go index d6fe0b03..9e3fd974 100644 --- a/model/account_permission.go +++ b/repository/account/models/account_permission.go @@ -1,4 +1,4 @@ -package model +package models import ( "context" @@ -6,29 +6,29 @@ import ( "github.com/demdxx/rbac" ) -var ctxPermissionCheckAccount = &struct{ s string }{s: "permc:account"} - -// PermissionCheckAccountFromContext returns the original account for check -func PermissionCheckAccountFromContext(ctx context.Context) *Account { - switch acc := ctx.Value(ctxPermissionCheckAccount).(type) { - case nil: - case *Account: - return acc - } - return nil -} +// CtxPermissionCheckAccount is the context key used to store the account for permission checks. +var CtxPermissionCheckAccount = &struct{ s string }{s: "permc:account"} +// PermissionChecker describes the interface for checking permissions for account members. type PermissionChecker interface { + // CheckPermissions verifies if the given patterns are permitted for a resource in the context. CheckPermissions(ctx context.Context, resource any, patterns ...string) bool + // CheckedPermissions returns the permission object if patterns are permitted, nil otherwise. CheckedPermissions(ctx context.Context, resource any, patterns ...string) rbac.Permission + // ChildRoles returns all child roles associated with this permission checker. ChildRoles() []rbac.Role + // ChildPermissions returns all child permissions associated with this permission checker. ChildPermissions() []rbac.Permission + // Permissions returns all permissions matching the given patterns. Permissions(patterns ...string) []rbac.Permission + // HasPermission checks if any of the given permission patterns exist. HasPermission(patterns ...string) bool } +// groupPermissionChecker is a slice of PermissionChecker that aggregates multiple permission checkers. type groupPermissionChecker []PermissionChecker +// CheckPermissions checks if any group permits the resource with the given patterns. func (groups groupPermissionChecker) CheckPermissions(ctx context.Context, resource any, patterns ...string) bool { for _, group := range groups { if group.CheckPermissions(ctx, resource, patterns...) { @@ -38,21 +38,21 @@ func (groups groupPermissionChecker) CheckPermissions(ctx context.Context, resou return false } +// CheckedPermissions returns the first permission found across groups, or nil. func (groups groupPermissionChecker) CheckedPermissions(ctx context.Context, resource any, patterns ...string) rbac.Permission { for _, group := range groups { - if perm := group.CheckedPermissions(ctx, resource, patterns...); perm == nil { + if perm := group.CheckedPermissions(ctx, resource, patterns...); perm != nil { return perm } } return nil } +// ChildRoles aggregates child roles from all groups. func (groups groupPermissionChecker) ChildRoles() []rbac.Role { var roles []rbac.Role for _, group := range groups { - switch role := group.(type) { - case nil: - case rbac.Role: + if role, ok := group.(rbac.Role); ok { roles = append(roles, role) } roles = append(roles, group.ChildRoles()...) @@ -60,11 +60,11 @@ func (groups groupPermissionChecker) ChildRoles() []rbac.Role { return roles } +// ChildPermissions aggregates child permissions from all groups. func (groups groupPermissionChecker) ChildPermissions() []rbac.Permission { var perms []rbac.Permission for _, group := range groups { - switch perm := group.(type) { - case rbac.Permission: + if perm, ok := group.(rbac.Permission); ok { perms = append(perms, perm) } perms = append(perms, group.ChildPermissions()...) @@ -72,6 +72,7 @@ func (groups groupPermissionChecker) ChildPermissions() []rbac.Permission { return perms } +// Permissions aggregates permissions matching the patterns across all groups. func (groups groupPermissionChecker) Permissions(patterns ...string) []rbac.Permission { var perms []rbac.Permission for _, group := range groups { @@ -80,6 +81,7 @@ func (groups groupPermissionChecker) Permissions(patterns ...string) []rbac.Perm return perms } +// HasPermission checks if any group has the given permission patterns. func (groups groupPermissionChecker) HasPermission(patterns ...string) bool { for _, group := range groups { if group.HasPermission(patterns...) { diff --git a/repository/account/query.go b/repository/account/query.go index 38723240..7b084b65 100644 --- a/repository/account/query.go +++ b/repository/account/query.go @@ -1,10 +1,24 @@ package account import ( + "context" + "errors" + "github.com/guregu/null" "gorm.io/gorm" - "github.com/geniusrabbit/blaze-api/model" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" + "github.com/geniusrabbit/blaze-api/repository" + accountCtx "github.com/geniusrabbit/blaze-api/repository/account/context" + accountModels "github.com/geniusrabbit/blaze-api/repository/account/models" + userCtx "github.com/geniusrabbit/blaze-api/repository/user/context" +) + +// Sentinel errors returned by AdjustPermissions. +// Callers in the usecase layer wrap these with acl.ErrNoPermissions. +var ( + errListFilterTooWide = errors.New("list account (too wide filter)") + errMemberFilterTooWide = errors.New("member account for that account") ) // Filter of the objects list @@ -12,7 +26,7 @@ type Filter struct { ID []uint64 UserID []uint64 Title []string - Status []model.ApproveStatus + Status []pkgModels.ApproveStatus } func (fl *Filter) PrepareQuery(query *gorm.DB) *gorm.DB { @@ -24,7 +38,7 @@ func (fl *Filter) PrepareQuery(query *gorm.DB) *gorm.DB { } if len(fl.UserID) > 0 { query = query.Where(`id IN (SELECT account_id FROM `+ - (*model.AccountMember)(nil).TableName()+` WHERE user_id IN (?))`, fl.UserID) + (*accountModels.AccountMember)(nil).TableName()+` WHERE user_id IN (?))`, fl.UserID) } if len(fl.Title) > 0 { query = query.Where(`title IN (?)`, fl.Title) @@ -35,13 +49,27 @@ func (fl *Filter) PrepareQuery(query *gorm.DB) *gorm.DB { return query } +// AdjustPermissions narrows the filter to the current user's accounts. +// Cannot import pkg/acl or pkg/context/session due to an import cycle; +// uses the lower-level context sub-packages instead. +func (fl *Filter) AdjustPermissions(ctx context.Context) error { + usr := userCtx.SessionUser(ctx) + if len(fl.UserID) == 0 { + fl.UserID = []uint64{usr.ID} + } + if len(fl.UserID) != 1 || fl.UserID[0] != usr.ID { + return errListFilterTooWide + } + return nil +} + // ListOrder of the objects list type ListOrder struct { - ID model.Order - Title model.Order - Status model.Order - CreatedAt model.Order - UpdatedAt model.Order + ID pkgModels.Order + Title pkgModels.Order + Status pkgModels.Order + CreatedAt pkgModels.Order + UpdatedAt pkgModels.Order } func (ord *ListOrder) PrepareQuery(query *gorm.DB) *gorm.DB { @@ -62,7 +90,7 @@ type MemberFilter struct { AccountID []uint64 UserID []uint64 NotUserID []uint64 - Status []model.ApproveStatus + Status []pkgModels.ApproveStatus IsAdmin null.Bool } @@ -91,15 +119,27 @@ func (fl *MemberFilter) PrepareQuery(query *gorm.DB) *gorm.DB { return query } +// AdjustPermissions narrows the member filter to the current session account. +// Cannot import pkg/acl or pkg/context/session due to an import cycle; +// uses the lower-level context sub-packages instead. +func (fl *MemberFilter) AdjustPermissions(ctx context.Context) error { + accID := accountCtx.SessionAccount(ctx).ID + if l := len(fl.AccountID); l > 1 || (l == 1 && fl.AccountID[0] != accID) { + return errMemberFilterTooWide + } + fl.AccountID = []uint64{accID} + return nil +} + // MemberListOrder of the objects list type MemberListOrder struct { - ID model.Order - AccountID model.Order - UserID model.Order - Status model.Order - IsAdmin model.Order - CreatedAt model.Order - UpdatedAt model.Order + ID pkgModels.Order + AccountID pkgModels.Order + UserID pkgModels.Order + Status pkgModels.Order + IsAdmin pkgModels.Order + CreatedAt pkgModels.Order + UpdatedAt pkgModels.Order } func (ord *MemberListOrder) PrepareQuery(query *gorm.DB) *gorm.DB { @@ -115,3 +155,13 @@ func (ord *MemberListOrder) PrepareQuery(query *gorm.DB) *gorm.DB { query = ord.UpdatedAt.PrepareQuery(query, `updated_at`) return query } + +// Pagination of the objects list +type Pagination = repository.Pagination + +type ( + // QOption is the query option interface + QOption = repository.QOption + // ListOptions is the list of query options + ListOptions = repository.ListOptions +) diff --git a/repository/account/query/user.go b/repository/account/query/user.go new file mode 100644 index 00000000..8fbcd2b7 --- /dev/null +++ b/repository/account/query/user.go @@ -0,0 +1,56 @@ +package query + +import ( + "context" + "strings" + + "github.com/demdxx/xtypes" + "gorm.io/gorm" + + "github.com/geniusrabbit/blaze-api/pkg/context/session" + "github.com/geniusrabbit/blaze-api/repository/account/models" +) + +// UserExtFilter of the objects list with extended fields +type UserExtFilter struct { + AccountID []uint64 + UserID []uint64 + Emails []string + Roles []uint64 +} + +// AdjustPermissions adjusts the filter based on the current user's permissions. +func (fl *UserExtFilter) AdjustPermissions(ctx context.Context) error { + fl.AccountID = []uint64{session.Account(ctx).ID} + return nil +} + +// PrepareQuery returns the query with applied filters +func (fl *UserExtFilter) PrepareQuery(q *gorm.DB) *gorm.DB { + if fl == nil { + return q + } + if len(fl.Roles) > 0 { + qstr := `SELECT member_id FROM ` + + (*models.M2MAccountMemberRole)(nil).TableName() + ` WHERE role_id IN (?)` + if len(fl.AccountID) > 0 { + q = q.Where(`id IN (SELECT user_id FROM `+(*models.AccountMember)(nil).TableName()+ + ` WHERE account_id IN (?) OR id IN (`+qstr+`))`, fl.AccountID, fl.Roles) + } else { + q = q.Where(`id IN (SELECT user_id FROM `+(*models.AccountMember)(nil).TableName()+ + ` WHERE id IN (`+qstr+`))`, fl.Roles) + } + } else if len(fl.AccountID) > 0 { + q = q.Where(`id IN (SELECT user_id FROM `+ + (*models.AccountMember)(nil).TableName()+` WHERE account_id IN (?))`, fl.AccountID) + } + if len(fl.UserID) > 0 { + q = q.Where(`id IN (?)`, fl.UserID) + } + if len(fl.Emails) > 0 { + q = q.Where(`lower(email) IN (?)`, xtypes.SliceApply(fl.Emails, func(v string) string { + return strings.ToLower(v) + })) + } + return q +} diff --git a/repository/account/repository.go b/repository/account/repository.go index 53a3e830..5ec6163b 100644 --- a/repository/account/repository.go +++ b/repository/account/repository.go @@ -3,33 +3,35 @@ package account import ( "context" - - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" ) // Repository of access to the account // //go:generate mockgen -source $GOFILE -package mocks -destination mocks/repository.go type Repository interface { - Get(ctx context.Context, id uint64) (*model.Account, error) - GetByTitle(ctx context.Context, title string) (*model.Account, error) - FetchList(ctx context.Context, filter *Filter, order *ListOrder, pagination *repository.Pagination) ([]*model.Account, error) - Count(ctx context.Context, filter *Filter) (int64, error) - Create(ctx context.Context, account *model.Account) (uint64, error) - Update(ctx context.Context, id uint64, account *model.Account) error + Get(ctx context.Context, id uint64) (*Account, error) + FetchList(ctx context.Context, opts ...QOption) ([]*Account, error) + Count(ctx context.Context, opts ...QOption) (int64, error) + Create(ctx context.Context, account *Account) (uint64, error) + Update(ctx context.Context, id uint64, account *Account) error Delete(ctx context.Context, id uint64) error + LoadPermissions(ctx context.Context, account *Account, user *User) error + + // GetByToken returns the user and account objects linked to the token (external session ID) + GetByToken(ctx context.Context, token string) (*User, *Account, error) +} + +// MemberRepository of access to the account members +type MemberRepository interface { IsAdmin(ctx context.Context, userID, accountID uint64) bool IsMember(ctx context.Context, userID, accountID uint64) bool - FetchListMembers(ctx context.Context, filter *MemberFilter, order *MemberListOrder, pagination *repository.Pagination) ([]*model.AccountMember, error) - CountMembers(ctx context.Context, filter *MemberFilter) (int64, error) - Member(ctx context.Context, userID, accountID uint64) (*model.AccountMember, error) - MemberByID(ctx context.Context, id uint64) (*model.AccountMember, error) - LinkMember(ctx context.Context, account *model.Account, isAdmin bool, members ...*model.User) error - UnlinkMember(ctx context.Context, account *model.Account, members ...*model.User) error - SetMemberRoles(ctx context.Context, account *model.Account, member *model.User, roles ...string) error - - LoadPermissions(ctx context.Context, account *model.Account, user *model.User) error + FetchListMembers(ctx context.Context, opts ...QOption) ([]*AccountMember, error) + CountMembers(ctx context.Context, opts ...QOption) (int64, error) + Member(ctx context.Context, userID, accountID uint64) (*AccountMember, error) + MemberByID(ctx context.Context, id uint64) (*AccountMember, error) + LinkMember(ctx context.Context, account *Account, isAdmin bool, members ...*User) error + UnlinkMember(ctx context.Context, account *Account, members ...*User) error + SetMemberRoles(ctx context.Context, account *Account, member *User, roles ...string) error } diff --git a/repository/account/repository/account_repository.go b/repository/account/repository/account_repository.go index 001ef2b8..ecc6571c 100644 --- a/repository/account/repository/account_repository.go +++ b/repository/account/repository/account_repository.go @@ -8,308 +8,177 @@ import ( "time" "github.com/demdxx/rbac" - "github.com/demdxx/xtypes" - "github.com/guregu/null" "github.com/pkg/errors" "gorm.io/gorm" - "gorm.io/gorm/clause" - "github.com/geniusrabbit/blaze-api/model" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/account" - prbac "github.com/geniusrabbit/blaze-api/repository/rbac" - userbac "github.com/geniusrabbit/blaze-api/repository/rbac/usecase" + authclientModels "github.com/geniusrabbit/blaze-api/repository/authclient/models" ) -var ( - // ErrInvalidRoleList error in case of invalid role list - ErrInvalidRoleList = errors.New(`invalid role list, check your permissions`) - - // ErrAccountHaveToHaveAdmin error in case of no any admin in account - ErrAccountHaveToHaveAdmin = errors.New(`account must have at least one admin`) -) - -// Repository DAO which provides functionality of working with accounts +// Repository is a DAO which provides functionality for working with accounts. type Repository struct { repository.Repository - rbacUse prbac.Usecase } -// New account repository -func New() *Repository { - return &Repository{ - rbacUse: userbac.NewDefault(), - } +// NewAccountRepository creates and returns a new account repository instance. +func NewAccountRepository() *Repository { + return &Repository{} } -// Get returns account model by ID -func (r *Repository) Get(ctx context.Context, id uint64) (*model.Account, error) { - object := new(model.Account) +// Get retrieves an account model by its ID. +func (r *Repository) Get(ctx context.Context, id uint64) (*account.Account, error) { + object := new(account.Account) if err := r.Slave(ctx).Find(object, id).Error; err != nil { return nil, err } return object, nil } -// GetByTitle returns account model by title -func (r *Repository) GetByTitle(ctx context.Context, title string) (*model.Account, error) { - object := new(model.Account) - if err := r.Slave(ctx).Find(object, `title=?`, title).Error; err != nil { - return nil, err - } - return object, nil -} - -// LoadPermissions into account object -func (r *Repository) LoadPermissions(ctx context.Context, accountObj *model.Account, userObj *model.User) (err error) { +// LoadPermissions loads and assigns permissions into the account object based on user roles. +// If userObj is nil, returns public permissions; otherwise loads member-specific permissions. +func (r *Repository) LoadPermissions(ctx context.Context, accountObj *account.Account, userObj *account.User) error { if accountObj == nil || userObj == nil { + var err error accountObj.Permissions, err = r.PermissionManager(ctx).AsOneRole(ctx, false, nil) return err } + var ( - roles []uint64 - memeber = new(model.AccountMember) - query = r.Slave(ctx) + roles []uint64 + member = new(account.AccountMember) + query = r.Slave(ctx) ) - if err = query.Find(memeber, `account_id=? AND user_id=?`, accountObj.ID, userObj.ID).Error; err != nil { + + // Fetch the account member record for the given user and account. + if err := query.Find(member, `account_id=? AND user_id=?`, accountObj.ID, userObj.ID).Error; err != nil { return errors.WithStack(err) } - // If member is not found, we return without permissions - err = query.Table((*model.M2MAccountMemberRole)(nil).TableName()). - Where(`member_id=?`, memeber.ID).Select(`role_id`).Find(&roles).Error + // Retrieve all roles assigned to this member. + err := query.Table((*account.M2MAccountMemberRole)(nil).TableName()). + Where(`member_id=?`, member.ID).Select(`role_id`).Find(&roles).Error if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) && !errors.Is(err, sql.ErrNoRows) { - // `sql.ErrNoRows` in case of no any linked permissions return errors.WithStack(err) } - if memeber.IsAdmin { + + // Mark admin users and load permissions based on approval status. + if member.IsAdmin { accountObj.ExtendAdminUsers(userObj.ID) } + if !accountObj.Approve.IsRejected() && !userObj.Approve.IsRejected() { - accountObj.Permissions, err = r.PermissionManager(ctx).AsOneRole(ctx, memeber.IsAdmin, nil, roles...) + accountObj.Permissions, err = r.PermissionManager(ctx).AsOneRole(ctx, member.IsAdmin, nil, roles...) } else { + // For unapproved accounts, skip system and account roles. accountObj.Permissions, err = r.PermissionManager(ctx).AsOneRole(ctx, false, func(_ context.Context, r rbac.Role) bool { - // Skip system or account roles for not approved accounts return !strings.HasPrefix(r.Name(), "system:") || !strings.HasPrefix(r.Name(), "account:") }, roles...) } return err } -// FetchList returns list of accounts by filter -func (r *Repository) FetchList(ctx context.Context, filter *account.Filter, order *account.ListOrder, pagination *repository.Pagination) ([]*model.Account, error) { +// FetchList retrieves a list of accounts filtered, ordered, and paginated according to parameters. +func (r *Repository) FetchList(ctx context.Context, opts ...account.QOption) ([]*account.Account, error) { var ( - list []*model.Account - query = r.Slave(ctx).Model((*model.Account)(nil)) + list []*account.Account + query = r.Slave(ctx).Model((*account.Account)(nil)) ) - query = filter.PrepareQuery(query) - query = order.PrepareQuery(query) - query = pagination.PrepareQuery(query) + + query = account.ListOptions(opts).PrepareQuery(query) err := query.Find(&list).Error + + // Treat "no records found" as success with empty list. if errors.Is(err, gorm.ErrRecordNotFound) { err = nil } return list, err } -// Count returns count of accounts by filter -func (r *Repository) Count(ctx context.Context, filter *account.Filter) (int64, error) { +// Count returns the number of accounts matching the filter criteria. +func (r *Repository) Count(ctx context.Context, opts ...account.QOption) (int64, error) { var ( count int64 - query = r.Slave(ctx).Model((*model.Account)(nil)) - err = filter.PrepareQuery(query).Count(&count).Error + query = r.Slave(ctx).Model((*account.Account)(nil)) ) + query = account.ListOptions(opts).PrepareQuery(query) + err := query.Count(&count).Error return count, err } -// Create new object into database -func (r *Repository) Create(ctx context.Context, accountObj *model.Account) (uint64, error) { +// Create inserts a new account record into the database. +func (r *Repository) Create(ctx context.Context, accountObj *account.Account) (uint64, error) { accountObj.CreatedAt = time.Now() accountObj.UpdatedAt = accountObj.CreatedAt - accountObj.Approve = model.UndefinedApproveStatus + accountObj.Approve = pkgModels.UndefinedApproveStatus err := r.Master(ctx).Create(accountObj).Error return accountObj.ID, err } -// Update existing object in database -func (r *Repository) Update(ctx context.Context, id uint64, accountObj *model.Account) error { +// Update modifies an existing account record in the database. +func (r *Repository) Update(ctx context.Context, id uint64, accountObj *account.Account) error { obj := *accountObj obj.ID = id return r.Master(ctx).Updates(&obj).Error } -// Delete delites record by ID +// Delete removes an account record by its ID. func (r *Repository) Delete(ctx context.Context, id uint64) error { - return r.Master(ctx).Model((*model.Account)(nil)).Delete(`id=?`, id).Error -} - -// FetchListMembers returns the list of members from account -func (r *Repository) FetchListMembers(ctx context.Context, filter *account.MemberFilter, order *account.MemberListOrder, pagination *repository.Pagination) ([]*model.AccountMember, error) { - var ( - list []*model.AccountMember - query = r.Slave(ctx).Model((*model.AccountMember)(nil)) - ) - query = filter.PrepareQuery(query) - query = order.PrepareQuery(query) - query = pagination.PrepareQuery(query) - query = query.Preload(clause.Associations) - err := query.Find(&list).Error - return list, err + return r.Master(ctx).Model((*account.Account)(nil)).Delete(`id=?`, id).Error } -// CountMembers returns the count of members from account -func (r *Repository) CountMembers(ctx context.Context, filter *account.MemberFilter) (int64, error) { +// GetByToken retrieves the user and account objects associated with an authentication token. +func (r *Repository) GetByToken(ctx context.Context, token string) (*account.User, *account.Account, error) { var ( - count int64 - err = filter.PrepareQuery( - r.Slave(ctx).Model((*model.AccountMember)(nil)), - ).Count(&count).Error + err error + roles []uint64 + db = r.Slave(ctx) + userObj = new(account.User) + accObj = new(account.Account) + member = new(account.AccountMember) + // Query to find the account member linked to the given token via auth session. + memberRequest = `WITH auth_client AS (` + + ` SELECT user_id, account_id FROM ` + (*authclientModels.AuthClient)(nil).TableName() + ` WHERE id = (` + + ` SELECT client_id FROM ` + (*authclientModels.AuthSession)(nil).TableName() + ` WHERE deleted_at IS NULL AND access_token=?` + + ` )` + + `)` + + `SELECT am.* FROM ` + (*account.AccountMember)(nil).TableName() + ` AS am, auth_client AS ac` + + ` WHERE am.deleted_at IS NULL AND am.account_id=ac.account_id AND am.user_id=ac.user_id` ) - return count, err -} - -// Member returns the member object by account and user -func (r *Repository) Member(ctx context.Context, userID, accountID uint64) (*model.AccountMember, error) { - return r.memberByQuery(ctx, `account_id=? AND user_id=?`, accountID, userID) -} -// MemberByID returns the member object by ID -func (r *Repository) MemberByID(ctx context.Context, id uint64) (*model.AccountMember, error) { - return r.memberByQuery(ctx, `id=?`, id) -} - -func (r *Repository) memberByQuery(ctx context.Context, query ...any) (*model.AccountMember, error) { - var member model.AccountMember - err := r.Slave(ctx). - Preload(clause.Associations). - Find(&member, query...).Error - if errors.Is(err, gorm.ErrRecordNotFound) || member.ID == 0 { - return nil, nil - } - if err != nil { - return nil, err - } - return &member, err -} - -// IsMember check the user if linked to account -func (r *Repository) IsMember(ctx context.Context, userID, accountID uint64) bool { - count, _ := r.CountMembers(ctx, &account.MemberFilter{ - UserID: []uint64{userID}, - AccountID: []uint64{accountID}, - }) - return count > 0 -} - -// IsAdmin check the user if linked to account as admin -func (r *Repository) IsAdmin(ctx context.Context, userID, accountID uint64) bool { - if accountID == 0 || userID == 0 { - return false + // Fetch member record and associated user and account objects. + if err = db.Raw(memberRequest, token).Scan(member).Error; err != nil { + return nil, nil, errors.WithStack(err) } - var member model.AccountMember - err := r.Slave(ctx). - Find(&member, `account_id=? AND user_id=?`, accountID, userID).Error - if errors.Is(err, gorm.ErrRecordNotFound) || member.ID == 0 { - return false + if err = db.First(userObj, member.UserID).Error; err != nil { + return nil, nil, errors.WithStack(err) } - return err == nil && member.IsAdmin -} - -// LinkMember into account -func (r *Repository) LinkMember(ctx context.Context, accountObj *model.Account, isAdmin bool, members ...*model.User) error { - return r.Master(ctx).Transaction(func(tx *gorm.DB) error { - query := tx.Model((*model.AccountMember)(nil)).Clauses(clause.OnConflict{ - Columns: []clause.Column{{Name: "account_id"}, {Name: "user_id"}}, - DoUpdates: clause.AssignmentColumns([]string{"approve_status", "is_admin"}), - }) - for _, userObj := range members { - err := query.Create(&model.AccountMember{ - Approve: model.ApprovedApproveStatus, - AccountID: accountObj.ID, - UserID: userObj.ID, - IsAdmin: isAdmin, - }).Error - if err != nil { - return err - } - } - return nil - }) -} - -// UnlinkMember from the account -func (r *Repository) UnlinkMember(ctx context.Context, accountObj *model.Account, users ...*model.User) error { - ids := make([]uint64, 0, len(users)) - for _, user := range users { - ids = append(ids, user.ID) + if err = db.First(accObj, member.AccountID).Error; err != nil { + return nil, nil, errors.WithStack(err) } - return r.Master(ctx).Model((*model.AccountMember)(nil)).Delete(`id=ANY(?)`, ids).Error -} -// SetMemberRoles into account -func (r *Repository) SetMemberRoles(ctx context.Context, accountObj *model.Account, user *model.User, roles ...string) error { - var ( - listRoles []*model.Role - member, err = r.Member(ctx, user.ID, accountObj.ID) - ) - if err != nil { - return err + // Fetch all roles assigned to this member. + err = db.Model(&account.M2MAccountMemberRole{}). + Select("role_id").Where(`member_id=?`, member.ID).Scan(&roles).Error + if err != nil && err != gorm.ErrRecordNotFound { + return nil, nil, errors.WithStack(err) } - // Load roles for the member - if len(roles) > 0 { - if listRoles, err = r.rbacUse.FetchList(ctx, &prbac.Filter{Names: roles}, nil, nil); err != nil { - return err + // Load permissions if member has roles or is an admin. + if len(roles) > 0 || member.IsAdmin { + if accObj.Approve.IsApproved() && userObj.Approve.IsApproved() { + accObj.Permissions, err = r.PermissionManager(ctx).AsOneRole(ctx, member.IsAdmin, nil, roles...) + } else { + // Skip system roles for unapproved accounts. + accObj.Permissions, err = r.PermissionManager(ctx).AsOneRole(ctx, false, + func(_ context.Context, r rbac.Role) bool { + return !strings.HasPrefix(r.Name(), "system:") + }, roles...) } - if len(listRoles) != len(roles) { - return ErrInvalidRoleList - } - } - - // Prepare member roles - wasAdmin := member.IsAdmin - member.Roles = listRoles - member.IsAdmin = xtypes.Slice[string](roles).Has(func(v string) bool { return v == "admin" || v == "account:admin" }) - - // Check if we have at least one admin in account - if wasAdmin != member.IsAdmin && !member.IsAdmin { - cnt, err := r.CountMembers(ctx, &account.MemberFilter{ - AccountID: []uint64{accountObj.ID}, - NotUserID: []uint64{user.ID}, - IsAdmin: null.BoolFrom(true), - Status: []model.ApproveStatus{model.ApprovedApproveStatus}, - }) if err != nil { - return err - } - if cnt == 0 { - return ErrAccountHaveToHaveAdmin + return nil, nil, err } } - - // Transaction for updating member roles - return r.TransactionExec(ctx, func(ctx context.Context, tx *gorm.DB) error { - // Save member object state - err := tx.Omit(clause.Associations).Save(member).Error - if err != nil { - return err - } - roleIDs := xtypes.SliceApply(listRoles, func(v *model.Role) uint64 { return v.ID }) - // Remove roles for the member - err = tx.Model((*model.M2MAccountMemberRole)(nil)). - Where(`member_id=?`, member.ID). - Where(`role_id NOT IN (?)`, roleIDs). - Delete(&model.M2MAccountMemberRole{}).Error - if err != nil { - return err - } - // Save roles for the member - return tx.Save(xtypes.SliceApply(listRoles, func(v *model.Role) *model.M2MAccountMemberRole { - return &model.M2MAccountMemberRole{ - MemberID: member.ID, - RoleID: v.ID, - CreatedAt: time.Now(), - } - })).Error - }) + return userObj, accObj, nil } diff --git a/repository/account/repository/account_test.go b/repository/account/repository/account_test.go index 230c8088..a68fd3b2 100644 --- a/repository/account/repository/account_test.go +++ b/repository/account/repository/account_test.go @@ -7,9 +7,11 @@ import ( sqlmock "github.com/DATA-DOG/go-sqlmock" "github.com/stretchr/testify/suite" - "github.com/geniusrabbit/blaze-api/model" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/repository/account" + accountModels "github.com/geniusrabbit/blaze-api/repository/account/models" "github.com/geniusrabbit/blaze-api/repository/testsuite" + "github.com/geniusrabbit/blaze-api/repository/user" ) type testSuite struct { @@ -20,7 +22,7 @@ type testSuite struct { func (s *testSuite) SetupSuite() { s.DatabaseSuite.SetupSuite() - s.accountRepo = New() + s.accountRepo = NewAccountRepository() } func (s *testSuite) TestGet() { @@ -35,32 +37,19 @@ func (s *testSuite) TestGet() { s.Equal(uint64(1), account.ID) } -func (s *testSuite) TestGetByTitle() { - s.Mock.ExpectQuery("SELECT *"). - WithArgs("title1"). - WillReturnRows( - sqlmock.NewRows([]string{"id", "status", "title", "description", "created_at"}). - AddRow(1, 1, "title1", "description1", time.Now()), - ) - account, err := s.accountRepo.GetByTitle(s.Ctx, "title1") - s.NoError(err) - s.Equal(uint64(1), account.ID) - s.Equal("title1", account.Title) -} - func (s *testSuite) TestLoadPermissions() { - s.Mock.ExpectQuery(`SELECT \* FROM "?`+(*model.AccountMember)(nil).TableName()). + s.Mock.ExpectQuery(`SELECT \* FROM "?`+(*accountModels.AccountMember)(nil).TableName()). WithArgs(uint64(1), uint64(1)). WillReturnRows( sqlmock.NewRows([]string{"id", "status", "account_id", "user_id", "is_admin", "created_at"}). AddRow(1, 1, 1, 1, true, time.Now()), ) - s.Mock.ExpectQuery(`SELECT role_id FROM "?` + (*model.M2MAccountMemberRole)(nil).TableName()). + s.Mock.ExpectQuery(`SELECT role_id FROM "?` + (*accountModels.M2MAccountMemberRole)(nil).TableName()). WithArgs(uint64(1)). WillReturnRows(sqlmock.NewRows([]string{"role_id"})) - account := &model.Account{ID: 1, Approve: model.ApprovedApproveStatus} - user := &model.User{ID: 1, Approve: model.ApprovedApproveStatus} + account := &account.Account{ID: 1, Approve: pkgModels.ApprovedApproveStatus} + user := &user.User{ID: 1, Approve: pkgModels.ApprovedApproveStatus} err := s.accountRepo.LoadPermissions(s.Ctx, account, user) s.NoError(err) s.NotNil(account.Permissions) @@ -75,7 +64,7 @@ func (s *testSuite) TestFetchList() { AddRow(2, 1, "title2", "description2", time.Now()), ) accounts, err := s.accountRepo.FetchList(s.Ctx, &account.Filter{ - UserID: []uint64{1}, ID: []uint64{1, 2}}, nil, nil) + UserID: []uint64{1}, ID: []uint64{1, 2}}) s.NoError(err) s.Equal(2, len(accounts)) } @@ -99,7 +88,7 @@ func (s *testSuite) TestCreate() { WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(101)) id, err := s.accountRepo.Create( s.Ctx, - &model.Account{ + &accountModels.Account{ ID: 101, Title: "test", }) @@ -113,7 +102,7 @@ func (s *testSuite) TestUpdate() { WillReturnResult(sqlmock.NewResult(101, 1)) err := s.accountRepo.Update( s.Ctx, - 101, &model.Account{Title: "test"}) + 101, &accountModels.Account{Title: "test"}) s.NoError(err) } @@ -125,89 +114,6 @@ func (s *testSuite) TestDelete() { s.NoError(err) } -func (s *testSuite) TestFetchListMembers() { - s.Mock.ExpectQuery(`SELECT \* FROM "account_member"`). - WillReturnRows( - sqlmock.NewRows([]string{"id", "status", "user_id", "account_id", "created_at"}). - AddRow(1, 1, 101, 1, time.Now()). - AddRow(2, 1, 102, 1, time.Now()), - ) - s.Mock.ExpectQuery(`SELECT \* FROM "account_base"`). - WillReturnRows( - sqlmock.NewRows([]string{"id", "approve_status", "title", "description", "updated_at", "created_at"}). - AddRow(1, 1, "title", "desc", time.Now(), time.Now()), - ) - s.Mock.ExpectQuery(`SELECT \* FROM "m2m_account_member_role"`). - WillReturnRows( - sqlmock.NewRows([]string{"member_id", "role_id", "created_at"}). - AddRow(1, 1, time.Now()), - ) - s.Mock.ExpectQuery(`SELECT \* FROM "rbac_role"`). - WillReturnRows( - sqlmock.NewRows([]string{"id", "name", "created_at"}). - AddRow(1, `test`, time.Now()), - ) - s.Mock.ExpectQuery(`SELECT \* FROM "account_user"`). - WillReturnRows( - sqlmock.NewRows([]string{"id", "approve_status", "email", "created_at"}). - AddRow(101, 1, "mail@", time.Now()). - AddRow(102, 1, "mail@", time.Now()), - ) - members, err := s.accountRepo.FetchListMembers(s.Ctx, nil, nil, nil) - s.NoError(err) - s.Equal(2, len(members)) -} - -func (s *testSuite) TestIsMember() { - ctx := s.Ctx - s.Mock.ExpectQuery("SELECT"). - WithArgs(uint64(202), uint64(101)). - WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(uint64(1))) - account := &model.Account{ID: 202} - user := &model.User{ID: 101} - ok := s.accountRepo.IsMember(ctx, user.ID, account.ID) - s.True(ok) -} - -func (s *testSuite) TestIsAdmin() { - ctx := s.Ctx - s.Mock.ExpectQuery("SELECT"). - WithArgs(uint64(202), uint64(101)). - WillReturnRows(sqlmock.NewRows([]string{"id", "is_admin"}).AddRow(uint64(1), true)) - account := &model.Account{ID: 202} - user := &model.User{ID: 101} - ok := s.accountRepo.IsAdmin(ctx, user.ID, account.ID) - s.True(ok) -} - -func (s *testSuite) TestLinkMember() { - s.Mock.ExpectBegin() - // stmt := s.Mock.ExpectPrepare("INSERT INTO") - s.Mock.ExpectQuery("INSERT INTO"). - WithArgs(model.ApprovedApproveStatus, uint64(101), uint64(101), true, sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg()). - WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(101)) - s.Mock.ExpectQuery("INSERT INTO"). - WithArgs(model.ApprovedApproveStatus, uint64(101), uint64(102), true, sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg()). - WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(102)) - s.Mock.ExpectCommit() - - account := &model.Account{ID: 101, Title: "test"} - users := []*model.User{{ID: 101}, {ID: 102}} - err := s.accountRepo.LinkMember(s.Ctx, account, true, users...) - s.NoError(err) -} - -func (s *testSuite) TestUnlinkMember() { - ctx := s.Ctx - s.Mock.ExpectExec("UPDATE"). - WithArgs(sqlmock.AnyArg(), uint64(101), uint64(102)). - WillReturnResult(sqlmock.NewResult(101, 2)) - account := &model.Account{ID: 101, Title: "test"} - users := []*model.User{{ID: 101}, {ID: 102}} - err := s.accountRepo.UnlinkMember(ctx, account, users...) - s.NoError(err) -} - func TestAccountSuite(t *testing.T) { suite.Run(t, &testSuite{}) } diff --git a/repository/account/repository/member_repository.go b/repository/account/repository/member_repository.go new file mode 100644 index 00000000..ee37e836 --- /dev/null +++ b/repository/account/repository/member_repository.go @@ -0,0 +1,210 @@ +package repository + +import ( + "context" + "time" + + "github.com/demdxx/xtypes" + "github.com/guregu/null" + "github.com/pkg/errors" + "gorm.io/gorm" + "gorm.io/gorm/clause" + + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" + "github.com/geniusrabbit/blaze-api/repository" + "github.com/geniusrabbit/blaze-api/repository/account" + "github.com/geniusrabbit/blaze-api/repository/account/models" + prbac "github.com/geniusrabbit/blaze-api/repository/rbac" + userbac "github.com/geniusrabbit/blaze-api/repository/rbac/usecase" + "github.com/geniusrabbit/blaze-api/repository/user" +) + +var ( + // ErrInvalidRoleList error in case of invalid role list + ErrInvalidRoleList = errors.New(`invalid role list, check your permissions`) + + // ErrAccountHaveToHaveAdmin error in case of no any admin in account + ErrAccountHaveToHaveAdmin = errors.New(`account must have at least one admin`) +) + +// Repository DAO which provides functionality of working with accounts +type MemberRepository struct { + repository.Repository + rbacUse prbac.Usecase +} + +// NewMemberRepository account repository +func NewMemberRepository() *MemberRepository { + return &MemberRepository{ + rbacUse: userbac.NewDefault(), + } +} + +// FetchListMembers returns the list of members from account +func (r *MemberRepository) FetchListMembers(ctx context.Context, opts ...account.QOption) ([]*models.AccountMember, error) { + var ( + list []*models.AccountMember + query = r.Slave(ctx).Model((*models.AccountMember)(nil)) + ) + query = account.ListOptions(opts).PrepareQuery(query) + query = query.Preload(clause.Associations) + err := query.Find(&list).Error + return list, err +} + +// CountMembers returns the count of members from account +func (r *MemberRepository) CountMembers(ctx context.Context, opts ...account.QOption) (int64, error) { + var ( + count int64 + query = r.Slave(ctx).Model((*models.AccountMember)(nil)) + ) + query = account.ListOptions(opts).PrepareQuery(query) + err := query.Count(&count).Error + return count, err +} + +// Member returns the member object by account and user +func (r *MemberRepository) Member(ctx context.Context, userID, accountID uint64) (*models.AccountMember, error) { + return r.memberByQuery(ctx, `account_id=? AND user_id=?`, accountID, userID) +} + +// MemberByID returns the member object by ID +func (r *MemberRepository) MemberByID(ctx context.Context, id uint64) (*models.AccountMember, error) { + return r.memberByQuery(ctx, `id=?`, id) +} + +func (r *MemberRepository) memberByQuery(ctx context.Context, query ...any) (*models.AccountMember, error) { + var member models.AccountMember + err := r.Slave(ctx). + Preload(clause.Associations). + Find(&member, query...).Error + if errors.Is(err, gorm.ErrRecordNotFound) || member.ID == 0 { + return nil, nil + } + if err != nil { + return nil, err + } + return &member, err +} + +// IsMember check the user if linked to account +func (r *MemberRepository) IsMember(ctx context.Context, userID, accountID uint64) bool { + count, _ := r.CountMembers(ctx, &account.MemberFilter{ + UserID: []uint64{userID}, + AccountID: []uint64{accountID}, + }) + return count > 0 +} + +// IsAdmin check the user if linked to account as admin +func (r *MemberRepository) IsAdmin(ctx context.Context, userID, accountID uint64) bool { + if accountID == 0 || userID == 0 { + return false + } + var member models.AccountMember + err := r.Slave(ctx). + Find(&member, `account_id=? AND user_id=?`, accountID, userID).Error + if errors.Is(err, gorm.ErrRecordNotFound) || member.ID == 0 { + return false + } + return err == nil && member.IsAdmin +} + +// LinkMember into account +func (r *MemberRepository) LinkMember(ctx context.Context, accountObj *models.Account, isAdmin bool, members ...*user.User) error { + return r.Master(ctx).Transaction(func(tx *gorm.DB) error { + query := tx.Model((*models.AccountMember)(nil)).Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "account_id"}, {Name: "user_id"}}, + DoUpdates: clause.AssignmentColumns([]string{"approve_status", "is_admin"}), + }) + for _, userObj := range members { + err := query.Create(&models.AccountMember{ + Approve: pkgModels.ApprovedApproveStatus, + AccountID: accountObj.ID, + UserID: userObj.ID, + IsAdmin: isAdmin, + }).Error + if err != nil { + return err + } + } + return nil + }) +} + +// UnlinkMember from the account +func (r *MemberRepository) UnlinkMember(ctx context.Context, accountObj *models.Account, users ...*user.User) error { + ids := make([]uint64, 0, len(users)) + for _, user := range users { + ids = append(ids, user.ID) + } + return r.Master(ctx).Model((*models.AccountMember)(nil)).Delete(`id=ANY(?)`, ids).Error +} + +// SetMemberRoles into account +func (r *MemberRepository) SetMemberRoles(ctx context.Context, accountObj *models.Account, user *user.User, roles ...string) error { + var ( + listRoles []*prbac.Role + member, err = r.Member(ctx, user.ID, accountObj.ID) + ) + if err != nil { + return err + } + + // Load roles for the member + if len(roles) > 0 { + if listRoles, err = r.rbacUse.FetchList(ctx, &prbac.Filter{Names: roles}); err != nil { + return err + } + if len(listRoles) != len(roles) { + return ErrInvalidRoleList + } + } + + // Prepare member roles + wasAdmin := member.IsAdmin + member.Roles = listRoles + member.IsAdmin = xtypes.Slice[string](roles).Has(func(v string) bool { return v == "admin" || v == "account:admin" }) + + // Check if we have at least one admin in account + if wasAdmin != member.IsAdmin && !member.IsAdmin { + cnt, err := r.CountMembers(ctx, &account.MemberFilter{ + AccountID: []uint64{accountObj.ID}, + NotUserID: []uint64{user.ID}, + IsAdmin: null.BoolFrom(true), + Status: []pkgModels.ApproveStatus{pkgModels.ApprovedApproveStatus}, + }) + if err != nil { + return err + } + if cnt == 0 { + return ErrAccountHaveToHaveAdmin + } + } + + // Transaction for updating member roles + return r.TransactionExec(ctx, func(ctx context.Context, tx *gorm.DB) error { + // Save member object state + err := tx.Omit(clause.Associations).Save(member).Error + if err != nil { + return err + } + roleIDs := xtypes.SliceApply(listRoles, func(v *prbac.Role) uint64 { return v.ID }) + // Remove roles for the member + err = tx.Model((*models.M2MAccountMemberRole)(nil)). + Where(`member_id=?`, member.ID). + Where(`role_id NOT IN (?)`, roleIDs). + Delete(&models.M2MAccountMemberRole{}).Error + if err != nil { + return err + } + // Save roles for the member + return tx.Save(xtypes.SliceApply(listRoles, func(v *prbac.Role) *models.M2MAccountMemberRole { + return &models.M2MAccountMemberRole{ + MemberID: member.ID, + RoleID: v.ID, + CreatedAt: time.Now(), + } + })).Error + }) +} diff --git a/repository/account/repository/member_test.go b/repository/account/repository/member_test.go new file mode 100644 index 00000000..d244e473 --- /dev/null +++ b/repository/account/repository/member_test.go @@ -0,0 +1,113 @@ +package repository + +import ( + "testing" + "time" + + sqlmock "github.com/DATA-DOG/go-sqlmock" + "github.com/stretchr/testify/suite" + + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" + "github.com/geniusrabbit/blaze-api/repository/account" + accountModels "github.com/geniusrabbit/blaze-api/repository/account/models" + "github.com/geniusrabbit/blaze-api/repository/testsuite" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" +) + +type testMemberSuite struct { + testsuite.DatabaseSuite + + memberRepo account.MemberRepository +} + +func (s *testMemberSuite) SetupSuite() { + s.DatabaseSuite.SetupSuite() + s.memberRepo = NewMemberRepository() +} + +func (s *testMemberSuite) TestFetchListMembers() { + s.Mock.ExpectQuery(`SELECT \* FROM "account_member"`). + WillReturnRows( + sqlmock.NewRows([]string{"id", "status", "user_id", "account_id", "created_at"}). + AddRow(1, 1, 101, 1, time.Now()). + AddRow(2, 1, 102, 1, time.Now()), + ) + s.Mock.ExpectQuery(`SELECT \* FROM "account_base"`). + WillReturnRows( + sqlmock.NewRows([]string{"id", "approve_status", "title", "description", "updated_at", "created_at"}). + AddRow(1, 1, "title", "desc", time.Now(), time.Now()), + ) + s.Mock.ExpectQuery(`SELECT \* FROM "m2m_account_member_role"`). + WillReturnRows( + sqlmock.NewRows([]string{"member_id", "role_id", "created_at"}). + AddRow(1, 1, time.Now()), + ) + s.Mock.ExpectQuery(`SELECT \* FROM "rbac_role"`). + WillReturnRows( + sqlmock.NewRows([]string{"id", "name", "created_at"}). + AddRow(1, `test`, time.Now()), + ) + s.Mock.ExpectQuery(`SELECT \* FROM "account_user"`). + WillReturnRows( + sqlmock.NewRows([]string{"id", "approve_status", "email", "created_at"}). + AddRow(101, 1, "mail@", time.Now()). + AddRow(102, 1, "mail@", time.Now()), + ) + members, err := s.memberRepo.FetchListMembers(s.Ctx) + s.NoError(err) + s.Equal(2, len(members)) +} + +func (s *testMemberSuite) TestIsMember() { + ctx := s.Ctx + s.Mock.ExpectQuery("SELECT"). + WithArgs(uint64(202), uint64(101)). + WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(uint64(1))) + account := &accountModels.Account{ID: 202} + user := &userModels.User{ID: 101} + ok := s.memberRepo.IsMember(ctx, user.ID, account.ID) + s.True(ok) +} + +func (s *testMemberSuite) TestIsAdmin() { + ctx := s.Ctx + s.Mock.ExpectQuery("SELECT"). + WithArgs(uint64(202), uint64(101)). + WillReturnRows(sqlmock.NewRows([]string{"id", "is_admin"}).AddRow(uint64(1), true)) + account := &accountModels.Account{ID: 202} + user := &userModels.User{ID: 101} + ok := s.memberRepo.IsAdmin(ctx, user.ID, account.ID) + s.True(ok) +} + +func (s *testMemberSuite) TestLinkMember() { + s.Mock.ExpectBegin() + // stmt := s.Mock.ExpectPrepare("INSERT INTO") + s.Mock.ExpectQuery("INSERT INTO"). + WithArgs(pkgModels.ApprovedApproveStatus, uint64(101), uint64(101), true, sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg()). + WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(101)) + s.Mock.ExpectQuery("INSERT INTO"). + WithArgs(pkgModels.ApprovedApproveStatus, uint64(101), uint64(102), true, sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg()). + WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(102)) + s.Mock.ExpectCommit() + + account := &accountModels.Account{ID: 101, Title: "test"} + users := []*userModels.User{{ID: 101}, {ID: 102}} + err := s.memberRepo.LinkMember(s.Ctx, account, true, users...) + s.NoError(err) +} + +func (s *testMemberSuite) TestUnlinkMember() { + ctx := s.Ctx + s.Mock.ExpectExec("UPDATE"). + WithArgs(sqlmock.AnyArg(), uint64(101), uint64(102)). + WillReturnResult(sqlmock.NewResult(101, 2)) + account := &accountModels.Account{ID: 101, Title: "test"} + users := []*userModels.User{{ID: 101}, {ID: 102}} + err := s.memberRepo.UnlinkMember(ctx, account, users...) + s.NoError(err) +} + +func TestMemberSuite(t *testing.T) { + suite.Run(t, &testMemberSuite{}) +} diff --git a/repository/account/usecase.go b/repository/account/usecase.go index 20b5c9c3..bfcfd174 100644 --- a/repository/account/usecase.go +++ b/repository/account/usecase.go @@ -2,29 +2,28 @@ package account import ( "context" - - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" ) // Usecase of the account // //go:generate mockgen -source $GOFILE -package mocks -destination mocks/usecase.go type Usecase interface { - Get(ctx context.Context, id uint64) (*model.Account, error) - GetByTitle(ctx context.Context, title string) (*model.Account, error) - FetchList(ctx context.Context, filter *Filter, order *ListOrder, pagination *repository.Pagination) ([]*model.Account, error) - Count(ctx context.Context, filter *Filter) (int64, error) - Store(ctx context.Context, account *model.Account) (uint64, error) - Register(ctx context.Context, ownerObj *model.User, accountObj *model.Account, password string) (uint64, error) + Get(ctx context.Context, id uint64) (*Account, error) + FetchList(ctx context.Context, opts ...QOption) ([]*Account, error) + Count(ctx context.Context, opts ...QOption) (int64, error) + Store(ctx context.Context, account *Account) (uint64, error) + Register(ctx context.Context, ownerObj *User, accountObj *Account, password string) (uint64, error) Delete(ctx context.Context, id uint64) error +} - FetchListMembers(ctx context.Context, filter *MemberFilter, order *MemberListOrder, pagination *repository.Pagination) ([]*model.AccountMember, error) - CountMembers(ctx context.Context, filter *MemberFilter) (int64, error) - LinkMember(ctx context.Context, account *model.Account, isAdmin bool, members ...*model.User) error - UnlinkMember(ctx context.Context, account *model.Account, members ...*model.User) error +// MemberUsecase of the account members +type MemberUsecase interface { + FetchListMembers(ctx context.Context, opts ...QOption) ([]*AccountMember, error) + CountMembers(ctx context.Context, opts ...QOption) (int64, error) + LinkMember(ctx context.Context, account *Account, isAdmin bool, members ...*User) error + UnlinkMember(ctx context.Context, account *Account, members ...*User) error UnlinkAccountMember(ctx context.Context, memberID uint64) error - InviteMember(ctx context.Context, accountID uint64, email string, roles ...string) (*model.AccountMember, error) - SetAccountMemeberRoles(ctx context.Context, accountID, userID uint64, roles ...string) (*model.AccountMember, error) - SetMemberRoles(ctx context.Context, memberID uint64, roles ...string) (*model.AccountMember, error) + InviteMember(ctx context.Context, accountID uint64, email string, roles ...string) (*AccountMember, error) + SetAccountMemeberRoles(ctx context.Context, accountID, userID uint64, roles ...string) (*AccountMember, error) + SetMemberRoles(ctx context.Context, memberID uint64, roles ...string) (*AccountMember, error) } diff --git a/repository/account/usecase/account_test.go b/repository/account/usecase/account_test.go index 0eef43cf..0824ece9 100644 --- a/repository/account/usecase/account_test.go +++ b/repository/account/usecase/account_test.go @@ -6,13 +6,13 @@ import ( "errors" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "go.uber.org/mock/gomock" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/context/session" "github.com/geniusrabbit/blaze-api/repository/account" "github.com/geniusrabbit/blaze-api/repository/account/mocks" + accountModels "github.com/geniusrabbit/blaze-api/repository/account/models" usermocks "github.com/geniusrabbit/blaze-api/repository/user/mocks" ) @@ -23,6 +23,7 @@ type testSuite struct { userRepo *usermocks.MockRepository accountRepo *mocks.MockRepository + memberRepo *mocks.MockMemberRepository accountUsecase account.Usecase } @@ -31,32 +32,22 @@ func (s *testSuite) SetupSuite() { s.ctx = session.WithUserAccountDevelop(context.TODO()) s.userRepo = usermocks.NewMockRepository(ctrl) s.accountRepo = mocks.NewMockRepository(ctrl) - s.accountUsecase = NewAccountUsecase(s.userRepo, s.accountRepo) + s.memberRepo = mocks.NewMockMemberRepository(ctrl) + s.accountUsecase = NewAccountUsecase(s.userRepo, s.accountRepo, s.memberRepo) } func (s *testSuite) TestGet() { s.accountRepo.EXPECT().Get(s.ctx, uint64(2)). - Return(&model.Account{ID: 2}, nil) + Return(&accountModels.Account{ID: 2}, nil) account, err := s.accountUsecase.Get(s.ctx, 2) s.NoError(err) s.Equal(uint64(2), account.ID) } -func (s *testSuite) TestGetByTitle() { - const title = "title" - s.accountRepo.EXPECT().GetByTitle(s.ctx, title). - Return(&model.Account{ID: 2, Title: title}, nil) - - account, err := s.accountUsecase.GetByTitle(s.ctx, title) - s.NoError(err) - s.Equal(uint64(2), account.ID) - s.Equal(title, account.Title) -} - func (s *testSuite) TestGetCurrent() { s.accountRepo.EXPECT().Get(s.ctx, uint64(1)). - Return(&model.Account{ID: 1}, nil) + Return(&accountModels.Account{ID: 1}, nil) account, err := s.accountUsecase.Get(s.ctx, 1) s.NoError(err) @@ -74,11 +65,11 @@ func (s *testSuite) TestGetGetError() { func (s *testSuite) TestFetchList() { s.accountRepo.EXPECT(). - FetchList(s.ctx, gomock.AssignableToTypeOf(&account.Filter{}), nil, nil). - Return([]*model.Account{{ID: 1}, {ID: 2}}, nil) + FetchList(s.ctx, gomock.AssignableToTypeOf(&account.Filter{})). + Return([]*accountModels.Account{{ID: 1}, {ID: 2}}, nil) accounts, err := s.accountUsecase.FetchList(s.ctx, &account.Filter{ - UserID: []uint64{1}, ID: []uint64{1, 2}}, nil, nil) + UserID: []uint64{1}, ID: []uint64{1, 2}}) s.NoError(err) s.Equal(2, len(accounts)) } @@ -96,10 +87,10 @@ func (s *testSuite) TestCount() { func (s *testSuite) TestStore() { s.accountRepo.EXPECT(). - Create(s.ctx, gomock.AssignableToTypeOf(&model.Account{})). + Create(s.ctx, gomock.AssignableToTypeOf(&accountModels.Account{})). Return(uint64(101), nil) - id, err := s.accountUsecase.Store(s.ctx, &model.Account{ID: 0, Title: "test1"}) + id, err := s.accountUsecase.Store(s.ctx, &accountModels.Account{ID: 0, Title: "test1"}) s.NoError(err) s.Equal(id, uint64(101)) } @@ -107,17 +98,17 @@ func (s *testSuite) TestStore() { func (s *testSuite) TestUpdate() { s.accountRepo.EXPECT(). Update(gomock.AssignableToTypeOf(s.ctx), - uint64(101), gomock.AssignableToTypeOf(&model.Account{})). + uint64(101), gomock.AssignableToTypeOf(&accountModels.Account{})). Return(nil) - _, err := s.accountUsecase.Store(s.ctx, &model.Account{ID: 101, Title: "test-test"}) + _, err := s.accountUsecase.Store(s.ctx, &accountModels.Account{ID: 101, Title: "test-test"}) s.NoError(err) } func (s *testSuite) TestDelete() { s.accountRepo.EXPECT(). Get(gomock.AssignableToTypeOf(s.ctx), uint64(1)). - Return(&model.Account{ID: 1}, nil) + Return(&accountModels.Account{ID: 1}, nil) s.accountRepo.EXPECT(). Delete(gomock.AssignableToTypeOf(s.ctx), gomock.AssignableToTypeOf(uint64(1))). Return(nil) @@ -134,44 +125,6 @@ func (s *testSuite) TestDeleteNotFound() { s.EqualError(err, sql.ErrNoRows.Error()) } -func (s *testSuite) TestFetchListMembers() { - s.accountRepo.EXPECT(). - FetchListMembers(s.ctx, gomock.AssignableToTypeOf((*account.MemberFilter)(nil)), nil, nil). - Return([]*model.AccountMember{{ID: 1}, {ID: 2}}, nil) - - members, err := s.accountUsecase.FetchListMembers(s.ctx, - &account.MemberFilter{AccountID: []uint64{1}, UserID: []uint64{1, 2}}, - nil, nil, - ) - - s.NoError(err) - s.Equal(2, len(members)) -} - -func (s *testSuite) TestLinkMember() { - s.accountRepo.EXPECT(). - LinkMember(s.ctx, gomock.AssignableToTypeOf(&model.Account{}), - true, gomock.AssignableToTypeOf(&model.User{})). - Return(nil) - - account := &model.Account{ID: 1} - user := &model.User{ID: 101} - err := s.accountUsecase.LinkMember(s.ctx, account, true, user) - s.NoError(err) -} - -func (s *testSuite) TestUnlinkMember() { - s.accountRepo.EXPECT(). - UnlinkMember(s.ctx, gomock.AssignableToTypeOf(&model.Account{}), - gomock.AssignableToTypeOf(&model.User{})). - Return(nil) - - account := &model.Account{ID: 1} - user := &model.User{ID: 101} - err := s.accountUsecase.UnlinkMember(s.ctx, account, user) - s.NoError(err) -} - func TestAccountSuite(t *testing.T) { suite.Run(t, &testSuite{}) } diff --git a/repository/account/usecase/account_usecase.go b/repository/account/usecase/account_usecase.go index 63146b79..b5f8ab2d 100644 --- a/repository/account/usecase/account_usecase.go +++ b/repository/account/usecase/account_usecase.go @@ -4,16 +4,13 @@ package usecase import ( "context" "fmt" - "slices" "github.com/pkg/errors" "gorm.io/gorm" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/acl" "github.com/geniusrabbit/blaze-api/pkg/context/database" "github.com/geniusrabbit/blaze-api/pkg/context/session" - "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/account" "github.com/geniusrabbit/blaze-api/repository/historylog" "github.com/geniusrabbit/blaze-api/repository/user" @@ -25,18 +22,20 @@ var ErrOwnerRequired = errors.New("owner is required") type AccountUsecase struct { userRepo user.Repository accountRepo account.Repository + memberRepo account.MemberRepository } // NewAccountUsecase object controller -func NewAccountUsecase(userRepo user.Repository, accountRepo account.Repository) *AccountUsecase { +func NewAccountUsecase(userRepo user.Repository, accountRepo account.Repository, memberRepo account.MemberRepository) *AccountUsecase { return &AccountUsecase{ userRepo: userRepo, accountRepo: accountRepo, + memberRepo: memberRepo, } } // Get returns the group by ID if have access -func (a *AccountUsecase) Get(ctx context.Context, id uint64) (*model.Account, error) { +func (a *AccountUsecase) Get(ctx context.Context, id uint64) (*account.Account, error) { accountObj, err := a.accountRepo.Get(ctx, id) if err != nil { return nil, err @@ -47,54 +46,38 @@ func (a *AccountUsecase) Get(ctx context.Context, id uint64) (*model.Account, er return accountObj, nil } -// GetByTitle returns the account by title if have access -func (a *AccountUsecase) GetByTitle(ctx context.Context, title string) (*model.Account, error) { - _, currentAccount := session.UserAccount(ctx) - if currentAccount.Title == title { - return currentAccount, nil - } - accountObj, err := a.accountRepo.GetByTitle(ctx, title) - if err != nil { - return nil, err - } - if !acl.HaveAccessView(ctx, accountObj) { - return nil, errors.Wrap(acl.ErrNoPermissions, "view account") - } - return accountObj, nil -} - // FetchList of accounts by filter -func (a *AccountUsecase) FetchList(ctx context.Context, filter *account.Filter, order *account.ListOrder, pagination *repository.Pagination) ([]*model.Account, error) { - var err error +func (a *AccountUsecase) FetchList(ctx context.Context, opts ...account.QOption) ([]*account.Account, error) { if !acl.HaveAccessList(ctx, session.Account(ctx)) { return nil, errors.Wrap(acl.ErrNoPermissions, "list account") } // If not `system` access then filter by current user - if !acl.HaveAccessList(ctx, &model.Account{}) { - if filter, err = adjustListFilter(ctx, filter); err != nil { - return nil, err + if !acl.HaveAccessList(ctx, &account.Account{}) { + var err error + if opts, err = account.ListOptions(opts).WithPermissions(ctx, &account.Filter{}); err != nil { + return nil, errors.Wrap(acl.ErrNoPermissions, err.Error()) } } - return a.accountRepo.FetchList(ctx, filter, order, pagination) + return a.accountRepo.FetchList(ctx, opts...) } // Count of accounts by filter -func (a *AccountUsecase) Count(ctx context.Context, filter *account.Filter) (int64, error) { - var err error +func (a *AccountUsecase) Count(ctx context.Context, opts ...account.QOption) (int64, error) { if !acl.HaveAccessCount(ctx, session.Account(ctx)) { return 0, errors.Wrap(acl.ErrNoPermissions, "list account") } // If not `system` access then filter by current user - if !acl.HaveAccessCount(ctx, &model.Account{}) { - if filter, err = adjustListFilter(ctx, filter); err != nil { - return 0, err + if !acl.HaveAccessCount(ctx, &account.Account{}) { + var err error + if opts, err = account.ListOptions(opts).WithPermissions(ctx, &account.Filter{}); err != nil { + return 0, errors.Wrap(acl.ErrNoPermissions, err.Error()) } } - return a.accountRepo.Count(ctx, filter) + return a.accountRepo.Count(ctx, opts...) } // Store new object into database -func (a *AccountUsecase) Store(ctx context.Context, accountObj *model.Account) (uint64, error) { +func (a *AccountUsecase) Store(ctx context.Context, accountObj *account.Account) (uint64, error) { var err error if accountObj.ID == 0 { if !acl.HaveAccessCreate(ctx, accountObj) { @@ -114,7 +97,7 @@ func (a *AccountUsecase) Store(ctx context.Context, accountObj *model.Account) ( } // Register new account with owner if not exists -func (a *AccountUsecase) Register(ctx context.Context, ownerObj *model.User, accountObj *model.Account, password string) (uint64, error) { +func (a *AccountUsecase) Register(ctx context.Context, ownerObj *user.User, accountObj *account.Account, password string) (uint64, error) { if ownerObj == nil || (ownerObj.ID == 0 && ownerObj.Email == "") { return 0, errors.Wrap(ErrOwnerRequired, "invalid user data") } @@ -143,7 +126,7 @@ func (a *AccountUsecase) Register(ctx context.Context, ownerObj *model.User, acc } accountObj.ID = aid // Link the user to the account as owner (admin) - if err := a.accountRepo.LinkMember(txctx, accountObj, true, ownerObj); err != nil { + if err := a.memberRepo.LinkMember(txctx, accountObj, true, ownerObj); err != nil { return err } return nil @@ -162,143 +145,3 @@ func (a *AccountUsecase) Delete(ctx context.Context, id uint64) error { } return a.accountRepo.Delete(historylog.WithPK(ctx, id), id) } - -// FetchListMembers returns the list of members from account -func (a *AccountUsecase) FetchListMembers(ctx context.Context, filter *account.MemberFilter, order *account.MemberListOrder, pagination *repository.Pagination) (_ []*model.AccountMember, err error) { - if !acl.HaveAccessList(ctx, &model.AccountMember{}) { - if filter, err = adjustMemberListFilter(ctx, "list", filter); err != nil { - return nil, err - } - } - return a.accountRepo.FetchListMembers(ctx, filter, order, pagination) -} - -// CountMembers returns the count of members from account -func (a *AccountUsecase) CountMembers(ctx context.Context, filter *account.MemberFilter) (_ int64, err error) { - if !acl.HaveAccessCount(ctx, &model.AccountMember{}) { - if filter, err = adjustMemberListFilter(ctx, "count", filter); err != nil { - return 0, err - } - } - return a.accountRepo.CountMembers(ctx, filter) -} - -// LinkMember into account -func (a *AccountUsecase) LinkMember(ctx context.Context, accountObj *model.Account, isAdmin bool, members ...*model.User) error { - if !acl.HaveAccessView(ctx, accountObj) { - return errors.Wrap(acl.ErrNoPermissions, "view account") - } - if !acl.HaveAccessCreate(ctx, &model.AccountMember{}) { - return errors.Wrap(acl.ErrNoPermissions, "create member account") - } - return a.accountRepo.LinkMember(ctx, accountObj, isAdmin, members...) -} - -// UnlinkMember from the account -func (a *AccountUsecase) UnlinkMember(ctx context.Context, accountObj *model.Account, members ...*model.User) error { - if len(members) == 0 { - return nil - } - for _, member := range members { - if !acl.HaveAccessDelete(ctx, &model.AccountMember{AccountID: accountObj.ID, UserID: member.ID}) { - return errors.Wrap(acl.ErrNoPermissions, "delete member account") - } - } - return a.accountRepo.UnlinkMember(ctx, accountObj, members...) -} - -// UnlinkAccountMember from the account -func (a *AccountUsecase) UnlinkAccountMember(ctx context.Context, memberID uint64) error { - member, err := a.accountRepo.MemberByID(ctx, memberID) - if err != nil { - return err - } - return a.accountRepo.UnlinkMember(ctx, member.Account, member.User) -} - -// InviteMember into account by email -func (a *AccountUsecase) InviteMember(ctx context.Context, accountID uint64, email string, roles ...string) (*model.AccountMember, error) { - // Check permissions for the account object `invite` - if !acl.HaveObjectPermissions(ctx, &model.AccountMember{AccountID: accountID}, `invite`) { - return nil, errors.Wrap(acl.ErrNoPermissions, "invite member account") - } - // Get account by ID - account, err := a.Get(ctx, accountID) - if err != nil { - return nil, err - } - // Get user by email - usr, err := a.userRepo.GetByEmail(ctx, email) - if err != nil { - return nil, err - } - // Link the user to the account as member - if err = a.accountRepo.LinkMember(ctx, account, slices.Contains(roles, "admin"), usr); err != nil { - return nil, err - } - // Set roles for the member - if err = a.accountRepo.SetMemberRoles(ctx, account, usr, roles...); err != nil { - return nil, err - } - // Return the member object - member, err := a.accountRepo.Member(ctx, usr.ID, account.ID) - if err != nil { - return nil, err - } - // Check permissions for the member object `view` - if !acl.HaveAccessView(ctx, member) { - return nil, errors.Wrap(acl.ErrNoPermissions, "view member account") - } - return member, nil -} - -// SetAccountMemeberRoles into account -func (a *AccountUsecase) SetAccountMemeberRoles(ctx context.Context, accountID, userID uint64, roles ...string) (*model.AccountMember, error) { - memeber, err := a.accountRepo.Member(ctx, userID, accountID) - if err != nil { - return nil, err - } - if !acl.HaveObjectPermissions(ctx, memeber, `roles.set.*`) { - return nil, errors.Wrap(acl.ErrNoPermissions, "update member roles") - } - return memeber, a.accountRepo.SetMemberRoles(ctx, memeber.Account, memeber.User, roles...) -} - -// SetMemberRoles into account -func (a *AccountUsecase) SetMemberRoles(ctx context.Context, memberID uint64, roles ...string) (*model.AccountMember, error) { - memeber, err := a.accountRepo.MemberByID(ctx, memberID) - if err != nil { - return nil, err - } - if !acl.HaveObjectPermissions(ctx, memeber, `roles.set.*`) { - return nil, errors.Wrap(acl.ErrNoPermissions, "update member roles") - } - return memeber, a.accountRepo.SetMemberRoles(ctx, memeber.Account, memeber.User, roles...) -} - -func adjustListFilter(ctx context.Context, filter *account.Filter) (*account.Filter, error) { - usr := session.User(ctx) - if filter == nil { - return &account.Filter{UserID: []uint64{usr.ID}}, nil - } else if len(filter.UserID) == 0 { - filter.UserID = []uint64{usr.ID} - } - if len(filter.UserID) != 1 || filter.UserID[0] != usr.ID { - return nil, errors.Wrap(acl.ErrNoPermissions, "list account (too wide filter)") - } - return filter, nil -} - -func adjustMemberListFilter(ctx context.Context, action string, filter *account.MemberFilter) (*account.MemberFilter, error) { - if filter == nil { - filter = &account.MemberFilter{ - AccountID: []uint64{session.Account(ctx).ID}, - } - } else { - if l := len(filter.AccountID); l > 1 || (l == 1 && filter.AccountID[0] != session.Account(ctx).ID) { - return nil, errors.Wrap(acl.ErrNoPermissions, action+" member account for that account") - } - filter.AccountID = append(filter.AccountID[:0], session.Account(ctx).ID) - } - return filter, nil -} diff --git a/repository/account/usecase/member_test.go b/repository/account/usecase/member_test.go new file mode 100644 index 00000000..342bdd24 --- /dev/null +++ b/repository/account/usecase/member_test.go @@ -0,0 +1,77 @@ +package usecase + +import ( + "context" + "testing" + + "github.com/stretchr/testify/suite" + "go.uber.org/mock/gomock" + + "github.com/geniusrabbit/blaze-api/pkg/context/session" + "github.com/geniusrabbit/blaze-api/repository/account" + "github.com/geniusrabbit/blaze-api/repository/account/mocks" + accountModels "github.com/geniusrabbit/blaze-api/repository/account/models" + usermocks "github.com/geniusrabbit/blaze-api/repository/user/mocks" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" +) + +type testMemberSuite struct { + suite.Suite + + ctx context.Context + + userRepo *usermocks.MockRepository + accountRepo *mocks.MockRepository + memberRepo *mocks.MockMemberRepository + memberUsecase account.MemberUsecase +} + +func (s *testMemberSuite) SetupSuite() { + ctrl := gomock.NewController(s.T()) + s.ctx = session.WithUserAccountDevelop(context.TODO()) + s.userRepo = usermocks.NewMockRepository(ctrl) + s.accountRepo = mocks.NewMockRepository(ctrl) + s.memberRepo = mocks.NewMockMemberRepository(ctrl) + s.memberUsecase = NewMemberUsecase(s.userRepo, s.accountRepo, s.memberRepo) +} + +func (s *testMemberSuite) TestFetchListMembers() { + s.memberRepo.EXPECT(). + FetchListMembers(s.ctx, gomock.AssignableToTypeOf((*account.MemberFilter)(nil))). + Return([]*accountModels.AccountMember{{ID: 1}, {ID: 2}}, nil) + + members, err := s.memberUsecase.FetchListMembers(s.ctx, + &account.MemberFilter{AccountID: []uint64{1}, UserID: []uint64{1, 2}}, + ) + + s.NoError(err) + s.Equal(2, len(members)) +} + +func (s *testMemberSuite) TestLinkMember() { + s.memberRepo.EXPECT(). + LinkMember(s.ctx, gomock.AssignableToTypeOf(&accountModels.Account{}), + true, gomock.AssignableToTypeOf(&userModels.User{})). + Return(nil) + + account := &accountModels.Account{ID: 1} + user := &userModels.User{ID: 101} + err := s.memberUsecase.LinkMember(s.ctx, account, true, user) + s.NoError(err) +} + +func (s *testMemberSuite) TestUnlinkMember() { + s.memberRepo.EXPECT(). + UnlinkMember(s.ctx, gomock.AssignableToTypeOf(&accountModels.Account{}), + gomock.AssignableToTypeOf(&userModels.User{})). + Return(nil) + + account := &accountModels.Account{ID: 1} + user := &userModels.User{ID: 101} + err := s.memberUsecase.UnlinkMember(s.ctx, account, user) + s.NoError(err) +} + +func TestAccountMemberSuite(t *testing.T) { + suite.Run(t, &testMemberSuite{}) +} diff --git a/repository/account/usecase/member_usecase.go b/repository/account/usecase/member_usecase.go new file mode 100644 index 00000000..3cea8fad --- /dev/null +++ b/repository/account/usecase/member_usecase.go @@ -0,0 +1,141 @@ +package usecase + +import ( + "context" + "slices" + + "github.com/geniusrabbit/blaze-api/pkg/acl" + "github.com/geniusrabbit/blaze-api/repository/account" + accountModels "github.com/geniusrabbit/blaze-api/repository/account/models" + "github.com/geniusrabbit/blaze-api/repository/user" + "github.com/pkg/errors" +) + +// MemberUsecase provides bussiness logic for account members +type MemberUsecase struct { + userRepo user.Repository + accountRepo account.Repository + memberRepo account.MemberRepository +} + +// NewMemberUsecase object controller +func NewMemberUsecase(userRepo user.Repository, accountRepo account.Repository, memberRepo account.MemberRepository) *MemberUsecase { + return &MemberUsecase{ + userRepo: userRepo, + accountRepo: accountRepo, + memberRepo: memberRepo, + } +} + +// FetchListMembers returns the list of members from account +func (a *MemberUsecase) FetchListMembers(ctx context.Context, opts ...account.QOption) (_ []*account.AccountMember, err error) { + if !acl.HaveAccessList(ctx, &accountModels.AccountMember{}) { + if opts, err = account.ListOptions(opts).WithPermissions(ctx, &account.MemberFilter{}); err != nil { + return nil, errors.Wrap(acl.ErrNoPermissions, err.Error()) + } + } + return a.memberRepo.FetchListMembers(ctx, opts...) +} + +// CountMembers returns the count of members from account +func (a *MemberUsecase) CountMembers(ctx context.Context, opts ...account.QOption) (_ int64, err error) { + if !acl.HaveAccessCount(ctx, &accountModels.AccountMember{}) { + if opts, err = account.ListOptions(opts).WithPermissions(ctx, &account.MemberFilter{}); err != nil { + return 0, errors.Wrap(acl.ErrNoPermissions, err.Error()) + } + } + return a.memberRepo.CountMembers(ctx, opts...) +} + +// LinkMember into account +func (a *MemberUsecase) LinkMember(ctx context.Context, accountObj *account.Account, isAdmin bool, members ...*user.User) error { + if !acl.HaveAccessView(ctx, accountObj) { + return errors.Wrap(acl.ErrNoPermissions, "view account") + } + if !acl.HaveAccessCreate(ctx, &account.AccountMember{}) { + return errors.Wrap(acl.ErrNoPermissions, "create member account") + } + return a.memberRepo.LinkMember(ctx, accountObj, isAdmin, members...) +} + +// UnlinkMember from the account +func (a *MemberUsecase) UnlinkMember(ctx context.Context, accountObj *account.Account, members ...*user.User) error { + if len(members) == 0 { + return nil + } + for _, member := range members { + if !acl.HaveAccessDelete(ctx, &account.AccountMember{AccountID: accountObj.ID, UserID: member.ID}) { + return errors.Wrap(acl.ErrNoPermissions, "delete member account") + } + } + return a.memberRepo.UnlinkMember(ctx, accountObj, members...) +} + +// UnlinkAccountMember from the account +func (a *MemberUsecase) UnlinkAccountMember(ctx context.Context, memberID uint64) error { + member, err := a.memberRepo.MemberByID(ctx, memberID) + if err != nil { + return err + } + return a.memberRepo.UnlinkMember(ctx, member.Account, member.User) +} + +// InviteMember into account by email +func (a *MemberUsecase) InviteMember(ctx context.Context, accountID uint64, email string, roles ...string) (*account.AccountMember, error) { + // Check permissions for the account object `invite` + if !acl.HaveObjectPermissions(ctx, &account.AccountMember{AccountID: accountID}, `invite`) { + return nil, errors.Wrap(acl.ErrNoPermissions, "invite member account") + } + // Get account by ID + account, err := a.accountRepo.Get(ctx, accountID) + if err != nil { + return nil, err + } + // Get user by email + usr, err := a.userRepo.GetByEmail(ctx, email) + if err != nil { + return nil, err + } + // Link the user to the account as member + if err = a.memberRepo.LinkMember(ctx, account, slices.Contains(roles, "admin"), usr); err != nil { + return nil, err + } + // Set roles for the member + if err = a.memberRepo.SetMemberRoles(ctx, account, usr, roles...); err != nil { + return nil, err + } + // Return the member object + member, err := a.memberRepo.Member(ctx, usr.ID, account.ID) + if err != nil { + return nil, err + } + // Check permissions for the member object `view` + if !acl.HaveAccessView(ctx, member) { + return nil, errors.Wrap(acl.ErrNoPermissions, "view member account") + } + return member, nil +} + +// SetAccountMemeberRoles into account +func (a *MemberUsecase) SetAccountMemeberRoles(ctx context.Context, accountID, userID uint64, roles ...string) (*account.AccountMember, error) { + memeber, err := a.memberRepo.Member(ctx, userID, accountID) + if err != nil { + return nil, err + } + if !acl.HaveObjectPermissions(ctx, memeber, `roles.set.*`) { + return nil, errors.Wrap(acl.ErrNoPermissions, "update member roles") + } + return memeber, a.memberRepo.SetMemberRoles(ctx, memeber.Account, memeber.User, roles...) +} + +// SetMemberRoles into account +func (a *MemberUsecase) SetMemberRoles(ctx context.Context, memberID uint64, roles ...string) (*account.AccountMember, error) { + memeber, err := a.memberRepo.MemberByID(ctx, memberID) + if err != nil { + return nil, err + } + if !acl.HaveObjectPermissions(ctx, memeber, `roles.set.*`) { + return nil, errors.Wrap(acl.ErrNoPermissions, "update member roles") + } + return memeber, a.memberRepo.SetMemberRoles(ctx, memeber.Account, memeber.User, roles...) +} diff --git a/repository/authclient/delivery/graphql/auth_client.graphql b/repository/authclient/delivery/graphql/auth_client.graphql new file mode 100644 index 00000000..185f3420 --- /dev/null +++ b/repository/authclient/delivery/graphql/auth_client.graphql @@ -0,0 +1,355 @@ +""" +AuthClient object represents an OAuth 2.0 client +""" +type AuthClient { + """ + ClientID is the client ID which represents unique connection indentificator + """ + ID: ID! + + # Owner and creator of the auth client + accountID: ID64! + userID: ID64! + + """ + Title of the AuthClient as himan readable name + """ + title: String! + + """ + Secret is the client's secret. The secret will be included in the create request as cleartext, and then + never again. The secret is stored using BCrypt so it is impossible to recover it. Tell your users + that they need to write the secret down as it will not be made available again. + """ + secret: String! + + """ + RedirectURIs is an array of allowed redirect urls for the client, for example http://mydomain/oauth/callback . + """ + redirectURIs: [String!] + + """ + GrantTypes is an array of grant types the client is allowed to use. + + Pattern: client_credentials|authorization_code|implicit|refresh_token + """ + grantTypes: [String!] + + """ + ResponseTypes is an array of the OAuth 2.0 response type strings that the client can + use at the authorization endpoint. + + Pattern: id_token|code|token + """ + responseTypes: [String!] + + """ + Scope is a string containing a space-separated list of scope values (as + described in Section 3.3 of OAuth 2.0 [RFC6749]) that the client + can use when requesting access tokens. + + Pattern: ([a-zA-Z0-9\.\*]+\s?)+ + """ + scope: String! + + """ + Audience is a whitelist defining the audiences this client is allowed to request tokens for. An audience limits + the applicability of an OAuth 2.0 Access Token to, for example, certain API endpoints. The value is a list + of URLs. URLs MUST NOT contain whitespaces. + """ + audience: [String!] + + """ + SubjectType requested for responses to this Client. The subject_types_supported Discovery parameter contains a + list of the supported subject_type values for this server. Valid types include `pairwise` and `public`. + """ + subjectType: String! + + """ + AllowedCORSOrigins are one or more URLs (scheme://host[:port]) which are allowed to make CORS requests + to the /oauth/token endpoint. If this array is empty, the sever's CORS origin configuration (`CORS_ALLOWED_ORIGINS`) + will be used instead. If this array is set, the allowed origins are appended to the server's CORS origin configuration. + Be aware that environment variable `CORS_ENABLED` MUST be set to `true` for this to work. + """ + allowedCORSOrigins: [String!] + + """ + Public flag tells that the client is public + """ + public: Boolean! + + """ + ExpiresAt contins the time of expiration of the client + """ + expiresAt: Time! + + createdAt: Time! + updatedAt: Time! + deletedAt: Time +} + +type AuthClientEdge { + """ + A cursor for use in pagination. + """ + cursor: String! + + """ + The item at the end of the edge. + """ + node: AuthClient +} + +""" +AuthClientConnection implements collection accessor interface with pagination. +""" +type AuthClientConnection { + """ + The total number of campaigns + """ + totalCount: Int! + + """ + The edges for each of the AuthClient's lists + """ + edges: [AuthClientEdge!] + + """ + A list of the AuthClient's, as a convenience when edges are not needed. + """ + list: [AuthClient!] + + """ + Information for paginating this connection + """ + pageInfo: PageInfo! +} + +""" +AuthClientPayload wrapper to access of AuthClient oprtation results +""" +type AuthClientPayload { + """ + A unique identifier for the client performing the mutation. + """ + clientMutationID: String! + + """ + AuthClient ID operation result + """ + authClientID: ID! + + """ + AuthClient object accessor + """ + authClient: AuthClient +} + +############################################################################### +# Query +############################################################################### + +input AuthClientListFilter { + ID: [String!] + userID: [ID64!] + accountID: [ID64!] + public: Boolean +} + +input AuthClientListOrder { + ID: Ordering + userID: Ordering + accountID: Ordering + title: Ordering + public: Ordering + lastUpdate: Ordering +} + +############################################################################### +# Mutations +############################################################################### + +############################################################################### +# Input Types +############################################################################### + +""" +AuthClientCreateInput is used to create a new OAuth 2.0 client +""" +input AuthClientCreateInput { + """ + AccountID of the auth client owner + """ + accountID: ID64 @notempty + + """ + UserID of the auth client creator + """ + userID: ID64 @notempty + + """ + Title of the auth client as human readable name + """ + title: String @notempty(trim: true) + + """ + Secret for the OAuth 2.0 client + """ + secret: String @notempty(trim: true) + + """ + RedirectURIs allowed for this client + """ + redirectURIs: [String!] + + """ + GrantTypes allowed for this client + """ + grantTypes: [String!] + + """ + ResponseTypes allowed for this client + """ + responseTypes: [String!] + + """ + Scope string for the client + """ + scope: String + + """ + Audience whitelist for token requests + """ + audience: [String!] + + """ + SubjectType for responses to this client + """ + subjectType: String! + + """ + AllowedCORSOrigins for this client + """ + allowedCORSOrigins: [String!] + + """ + Public flag for the client + """ + public: Boolean + + """ + ExpiresAt time for the client + """ + expiresAt: Time +} + +""" +AuthClientUpdateInput is used to update an existing OAuth 2.0 client +""" +input AuthClientUpdateInput { + """ + AccountID of the auth client owner + """ + accountID: ID64 @notempty(ornil: true) + + """ + UserID of the auth client creator + """ + userID: ID64 @notempty(ornil: true) + + """ + Title of the auth client as human readable name + """ + title: String @notempty(trim: true, ornil: true) + + """ + Secret for the OAuth 2.0 client + """ + secret: String @notempty(trim: true, ornil: true) + + """ + RedirectURIs allowed for this client + """ + redirectURIs: [String!] @notempty(ornil: true) + + """ + GrantTypes allowed for this client + """ + grantTypes: [String!] @notempty(ornil: true) + + """ + ResponseTypes allowed for this client + """ + responseTypes: [String!] @notempty(ornil: true) + + """ + Scope string for the client + """ + scope: String @notempty(trim: true, ornil: true) + + """ + Audience whitelist for token requests + """ + audience: [String!] @notempty(ornil: true) + + """ + SubjectType for responses to this client + """ + subjectType: String @notempty(trim: true, ornil: true) + + """ + AllowedCORSOrigins for this client + """ + allowedCORSOrigins: [String!] @notempty(ornil: true) + + """ + Public flag for the client + """ + public: Boolean + + """ + ExpiresAt time for the client + """ + expiresAt: Time @notempty(ornil: true) +} + +############################################################################### +# Query and Mutations +############################################################################### + +extend type Query { + """ + Get auth client object by ID + """ + authClient(id: ID!): AuthClientPayload! + @hasPermissions(permissions: ["auth_client.view.*"]) + + """ + List of the auth client objects which can be filtered and ordered by some fields + """ + listAuthClients( + filter: AuthClientListFilter = null + order: [AuthClientListOrder] = null + page: Page = null + ): AuthClientConnection @hasPermissions(permissions: ["auth_client.list.*"]) +} + +extend type Mutation { + """ + Create the new auth client + """ + createAuthClient(input: AuthClientCreateInput!): AuthClientPayload! + @hasPermissions(permissions: ["auth_client.create.*"]) + + """ + Update auth client info + """ + updateAuthClient(id: ID!, input: AuthClientUpdateInput!): AuthClientPayload! + @hasPermissions(permissions: ["auth_client.update.*"]) + + """ + Delete auth client + """ + deleteAuthClient(id: ID!, msg: String = null): AuthClientPayload! + @hasPermissions(permissions: ["auth_client.delete.*"]) +} diff --git a/repository/authclient/delivery/graphql/connector.go b/repository/authclient/delivery/graphql/connector.go new file mode 100644 index 00000000..3f68b856 --- /dev/null +++ b/repository/authclient/delivery/graphql/connector.go @@ -0,0 +1,32 @@ +package graphql + +import ( + "context" + + "github.com/demdxx/gocast/v2" + "github.com/geniusrabbit/blaze-api/repository/authclient" + "github.com/geniusrabbit/blaze-api/server/graphql/connectors" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" +) + +// AuthClientConnection implements collection accessor interface with pagination +type AuthClientConnection = connectors.CollectionConnection[gqlmodels.AuthClient, gqlmodels.AuthClientEdge] + +// NewAuthClientConnection based on query object +func NewAuthClientConnection(ctx context.Context, authClientsAccessor authclient.Usecase, page *gqlmodels.Page) *AuthClientConnection { + return connectors.NewCollectionConnection(ctx, &connectors.DataAccessorFunc[gqlmodels.AuthClient, gqlmodels.AuthClientEdge]{ + FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.AuthClient, error) { + clients, err := authClientsAccessor.FetchList(ctx, page.Pagination()) + return FromAuthClientModelList(clients), err + }, + CountDataFunc: func(ctx context.Context) (int64, error) { + return authClientsAccessor.Count(ctx, nil) + }, + ConvertToEdgeFunc: func(obj *gqlmodels.AuthClient) *gqlmodels.AuthClientEdge { + return &gqlmodels.AuthClientEdge{ + Cursor: gocast.Str(obj.ID), + Node: obj, + } + }, + }, page) +} diff --git a/repository/authclient/delivery/graphql/mapping.go b/repository/authclient/delivery/graphql/mapping.go new file mode 100644 index 00000000..5367e7a7 --- /dev/null +++ b/repository/authclient/delivery/graphql/mapping.go @@ -0,0 +1,87 @@ +package graphql + +import ( + "time" + + "github.com/demdxx/gocast/v2" + "github.com/demdxx/xtypes" + + "github.com/geniusrabbit/blaze-api/repository/authclient/models" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" +) + +// FromAuthClientModel to local graphql model +func FromAuthClientModel(acc *models.AuthClient) *gqlmodels.AuthClient { + if acc == nil { + return nil + } + return &gqlmodels.AuthClient{ + ID: acc.ID, + AccountID: acc.AccountID, + UserID: acc.UserID, + Title: acc.Title, + Secret: acc.Secret, + RedirectURIs: acc.RedirectURIs, + GrantTypes: acc.GrantTypes, + ResponseTypes: acc.ResponseTypes, + Scope: acc.Scope, + Audience: acc.Audience, + SubjectType: acc.SubjectType, + AllowedCORSOrigins: acc.AllowedCORSOrigins, + Public: acc.Public, + CreatedAt: acc.CreatedAt, + UpdatedAt: acc.UpdatedAt, + DeletedAt: gqlmodels.DeletedAt(acc.DeletedAt), + } +} + +// FromAuthClientModelList converts model list to local model list +func FromAuthClientModelList(list []*models.AuthClient) []*gqlmodels.AuthClient { + return xtypes.SliceApply(list, FromAuthClientModel) +} + +// CreateFillModel fills adasset model from create input. +func CreateFillModel(inp *gqlmodels.AuthClientCreateInput, obj *models.AuthClient) *models.AuthClient { + obj.ID = "" + obj.UserID = gocast.PtrAsValue(inp.UserID, 0) + obj.AccountID = gocast.PtrAsValue(inp.AccountID, 0) + obj.Title = gocast.PtrAsValue(inp.Title, "") + obj.Secret = gocast.PtrAsValue(inp.Secret, "") + obj.RedirectURIs = inp.RedirectURIs + obj.GrantTypes = inp.GrantTypes + obj.ResponseTypes = inp.ResponseTypes + obj.Scope = gocast.PtrAsValue(inp.Scope, "") + obj.Audience = inp.Audience + obj.SubjectType = inp.SubjectType + obj.AllowedCORSOrigins = inp.AllowedCORSOrigins + obj.Public = gocast.PtrAsValue(inp.Public, false) + obj.ExpiresAt = gocast.PtrAsValue(inp.ExpiresAt, time.Time{}) + return obj +} + +// UpdateFillModel fills adasset model from update input. +func UpdateFillModel(inp *gqlmodels.AuthClientUpdateInput, obj *models.AuthClient) { + obj.UserID = gocast.PtrAsValue(inp.UserID, obj.UserID) + obj.AccountID = gocast.PtrAsValue(inp.AccountID, obj.AccountID) + obj.Title = gocast.PtrAsValue(inp.Title, obj.Title) + obj.Secret = gocast.PtrAsValue(inp.Secret, obj.Secret) + if inp.RedirectURIs != nil { + obj.RedirectURIs = inp.RedirectURIs + } + if inp.GrantTypes != nil { + obj.GrantTypes = inp.GrantTypes + } + if inp.ResponseTypes != nil { + obj.ResponseTypes = inp.ResponseTypes + } + obj.Scope = gocast.PtrAsValue(inp.Scope, obj.Scope) + if inp.Audience != nil { + obj.Audience = inp.Audience + } + obj.SubjectType = gocast.PtrAsValue(inp.SubjectType, obj.SubjectType) + if inp.AllowedCORSOrigins != nil { + obj.AllowedCORSOrigins = inp.AllowedCORSOrigins + } + obj.Public = gocast.PtrAsValue(inp.Public, obj.Public) + obj.ExpiresAt = gocast.PtrAsValue(inp.ExpiresAt, obj.ExpiresAt) +} diff --git a/repository/authclient/delivery/graphql/resolver.go b/repository/authclient/delivery/graphql/resolver.go index ea15ce32..36b6c837 100644 --- a/repository/authclient/delivery/graphql/resolver.go +++ b/repository/authclient/delivery/graphql/resolver.go @@ -2,16 +2,12 @@ package graphql import ( "context" - "time" - "github.com/demdxx/gocast/v2" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/requestid" "github.com/geniusrabbit/blaze-api/repository/authclient" - "github.com/geniusrabbit/blaze-api/repository/authclient/repository" - "github.com/geniusrabbit/blaze-api/repository/authclient/usecase" - "github.com/geniusrabbit/blaze-api/server/graphql/connectors" - "github.com/geniusrabbit/blaze-api/server/graphql/models" + "github.com/geniusrabbit/blaze-api/repository/authclient/models" + "github.com/geniusrabbit/blaze-api/repository/historylog" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) // QueryResolver implements GQL API methods @@ -20,50 +16,38 @@ type QueryResolver struct { } // NewQueryResolver returns new API resolver -func NewQueryResolver() *QueryResolver { - return &QueryResolver{ - authClients: usecase.NewAuthclientUsecase(repository.New()), - } +func NewQueryResolver(uc authclient.Usecase) *QueryResolver { + return &QueryResolver{authClients: uc} } // AuthClient is the resolver for the authClient field. -func (r *QueryResolver) AuthClient(ctx context.Context, id string) (*models.AuthClientPayload, error) { +func (r *QueryResolver) AuthClient(ctx context.Context, id string) (*gqlmodels.AuthClientPayload, error) { client, err := r.authClients.Get(ctx, id) if err != nil { return nil, err } - return &models.AuthClientPayload{ + return &gqlmodels.AuthClientPayload{ ClientMutationID: requestid.Get(ctx), AuthClientID: client.ID, - AuthClient: models.FromAuthClientModel(client), + AuthClient: FromAuthClientModel(client), }, nil } // ListAuthClients is the resolver for the listAuthClients field. func (r *QueryResolver) ListAuthClients(ctx context.Context, - filter *models.AuthClientListFilter, - order *models.AuthClientListOrder, - page *models.Page) (*connectors.AuthClientConnection, error) { - return connectors.NewAuthClientConnection(ctx, r.authClients, page), nil + filter *gqlmodels.AuthClientListFilter, + orders []*gqlmodels.AuthClientListOrder, + page *gqlmodels.Page, +) (*AuthClientConnection, error) { + return NewAuthClientConnection(ctx, r.authClients, page), nil } // CreateAuthClient is the resolver for the createAuthClient field. -func (r *QueryResolver) CreateAuthClient(ctx context.Context, input *models.AuthClientInput) (*models.AuthClientPayload, error) { - id, err := r.authClients.Create(ctx, &model.AuthClient{ - UserID: idFromPtr(input.UserID, 0), - AccountID: idFromPtr(input.AccountID, 0), - Title: gocast.PtrAsValue(input.Title, ""), - Secret: gocast.PtrAsValue(input.Secret, ""), - RedirectURIs: input.RedirectURIs, - GrantTypes: input.GrantTypes, - ResponseTypes: input.ResponseTypes, - Scope: gocast.PtrAsValue(input.Scope, ""), - Audience: input.Audience, - SubjectType: input.SubjectType, - AllowedCORSOrigins: input.AllowedCORSOrigins, - Public: gocast.PtrAsValue(input.Public, false), - ExpiresAt: gocast.PtrAsValue(input.ExpiresAt, time.Time{}), - }) +func (r *QueryResolver) CreateAuthClient(ctx context.Context, input *gqlmodels.AuthClientCreateInput) (*gqlmodels.AuthClientPayload, error) { + // Create and fill model from input + clientObj := CreateFillModel(input, &models.AuthClient{}) + + id, err := r.authClients.Create(ctx, clientObj, historylog.Message("GQL create authclient")) if err != nil { return nil, err } @@ -71,58 +55,39 @@ func (r *QueryResolver) CreateAuthClient(ctx context.Context, input *models.Auth if err != nil { return nil, err } - return &models.AuthClientPayload{ + return &gqlmodels.AuthClientPayload{ ClientMutationID: requestid.Get(ctx), AuthClientID: client.ID, - AuthClient: models.FromAuthClientModel(client), + AuthClient: FromAuthClientModel(client), }, nil } // UpdateAuthClient is the resolver for the updateAuthClient field. -func (r *QueryResolver) UpdateAuthClient(ctx context.Context, id string, input *models.AuthClientInput) (*models.AuthClientPayload, error) { - client, err := r.authClients.Get(ctx, id) +func (r *QueryResolver) UpdateAuthClient(ctx context.Context, id string, input *gqlmodels.AuthClientUpdateInput) (*gqlmodels.AuthClientPayload, error) { + clientObj, err := r.authClients.Get(ctx, id) if err != nil { return nil, err } // Update client fields - client.UserID = idFromPtr(input.UserID, client.UserID) - client.AccountID = idFromPtr(input.AccountID, client.AccountID) - client.Title = gocast.PtrAsValue(input.Title, client.Title) - client.Secret = gocast.PtrAsValue(input.Secret, client.Secret) - client.RedirectURIs = input.RedirectURIs - client.GrantTypes = input.GrantTypes - client.ResponseTypes = input.ResponseTypes - client.Scope = gocast.PtrAsValue(input.Scope, client.Scope) - client.Audience = input.Audience - client.SubjectType = input.SubjectType - client.AllowedCORSOrigins = input.AllowedCORSOrigins - client.Public = gocast.PtrAsValue(input.Public, client.Public) - client.ExpiresAt = gocast.PtrAsValue(input.ExpiresAt, client.ExpiresAt) + UpdateFillModel(input, clientObj) - if err = r.authClients.Update(ctx, id, client); err != nil { + if err = r.authClients.Update(ctx, id, clientObj, historylog.Message("GQL update authclient")); err != nil { return nil, err } - return &models.AuthClientPayload{ + return &gqlmodels.AuthClientPayload{ ClientMutationID: requestid.Get(ctx), - AuthClientID: client.ID, - AuthClient: models.FromAuthClientModel(client), + AuthClientID: id, + AuthClient: FromAuthClientModel(clientObj), }, nil } // DeleteAuthClient is the resolver for the deleteAuthClient field. -func (r *QueryResolver) DeleteAuthClient(ctx context.Context, id string, msg *string) (*models.AuthClientPayload, error) { - if err := r.authClients.Delete(ctx, id); err != nil { +func (r *QueryResolver) DeleteAuthClient(ctx context.Context, id string, msg *string) (*gqlmodels.AuthClientPayload, error) { + if err := r.authClients.Delete(ctx, id, historylog.Message("GQL delete authclient")); err != nil { return nil, err } - return &models.AuthClientPayload{ + return &gqlmodels.AuthClientPayload{ ClientMutationID: requestid.Get(ctx), AuthClientID: id, }, nil } - -func idFromPtr(id *uint64, def uint64) uint64 { - if id == nil { - return def - } - return uint64(*id) -} diff --git a/repository/authclient/mocks/repository.go b/repository/authclient/mocks/repository.go index 18b6ad9c..13604305 100644 --- a/repository/authclient/mocks/repository.go +++ b/repository/authclient/mocks/repository.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: repository.go +// +// Generated by this command: +// +// mockgen -source repository.go -package mocks -destination mocks/repository.go +// // Package mocks is a generated GoMock package. package mocks @@ -8,15 +13,15 @@ import ( context "context" reflect "reflect" - model "github.com/geniusrabbit/blaze-api/model" authclient "github.com/geniusrabbit/blaze-api/repository/authclient" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockRepository is a mock of Repository interface. type MockRepository struct { ctrl *gomock.Controller recorder *MockRepositoryMockRecorder + isgomock struct{} } // MockRepositoryMockRecorder is the mock recorder for MockRepository. @@ -37,89 +42,114 @@ func (m *MockRepository) EXPECT() *MockRepositoryMockRecorder { } // Count mocks base method. -func (m *MockRepository) Count(ctx context.Context, filter *authclient.Filter) (int64, error) { +func (m *MockRepository) Count(ctx context.Context, opts ...authclient.QOption) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockRepositoryMockRecorder) Count(ctx, filter interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Count(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), varargs...) } // Create mocks base method. -func (m *MockRepository) Create(ctx context.Context, authClient *model.AuthClient) (string, error) { +func (m *MockRepository) Create(ctx context.Context, authClient *authclient.AuthClient, opts ...authclient.QOption) (string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", ctx, authClient) + varargs := []any{ctx, authClient} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Create", varargs...) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 } // Create indicates an expected call of Create. -func (mr *MockRepositoryMockRecorder) Create(ctx, authClient interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Create(ctx, authClient any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockRepository)(nil).Create), ctx, authClient) + varargs := append([]any{ctx, authClient}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockRepository)(nil).Create), varargs...) } // Delete mocks base method. -func (m *MockRepository) Delete(ctx context.Context, id string) error { +func (m *MockRepository) Delete(ctx context.Context, id string, opts ...authclient.QOption) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Delete", ctx, id) + varargs := []any{ctx, id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Delete", varargs...) ret0, _ := ret[0].(error) return ret0 } // Delete indicates an expected call of Delete. -func (mr *MockRepositoryMockRecorder) Delete(ctx, id interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Delete(ctx, id any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRepository)(nil).Delete), ctx, id) + varargs := append([]any{ctx, id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRepository)(nil).Delete), varargs...) } // FetchList mocks base method. -func (m *MockRepository) FetchList(ctx context.Context, filter *authclient.Filter) ([]*model.AuthClient, error) { +func (m *MockRepository) FetchList(ctx context.Context, opts ...authclient.QOption) ([]*authclient.AuthClient, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter) - ret0, _ := ret[0].([]*model.AuthClient) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*authclient.AuthClient) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockRepositoryMockRecorder) FetchList(ctx, filter interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) FetchList(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), varargs...) } // Get mocks base method. -func (m *MockRepository) Get(ctx context.Context, id string) (*model.AuthClient, error) { +func (m *MockRepository) Get(ctx context.Context, id string) (*authclient.AuthClient, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Get", ctx, id) - ret0, _ := ret[0].(*model.AuthClient) + ret0, _ := ret[0].(*authclient.AuthClient) ret1, _ := ret[1].(error) return ret0, ret1 } // Get indicates an expected call of Get. -func (mr *MockRepositoryMockRecorder) Get(ctx, id interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Get(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRepository)(nil).Get), ctx, id) } // Update mocks base method. -func (m *MockRepository) Update(ctx context.Context, id string, authClient *model.AuthClient) error { +func (m *MockRepository) Update(ctx context.Context, id string, authClient *authclient.AuthClient, opts ...authclient.QOption) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Update", ctx, id, authClient) + varargs := []any{ctx, id, authClient} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Update", varargs...) ret0, _ := ret[0].(error) return ret0 } // Update indicates an expected call of Update. -func (mr *MockRepositoryMockRecorder) Update(ctx, id, authClient interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Update(ctx, id, authClient any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockRepository)(nil).Update), ctx, id, authClient) + varargs := append([]any{ctx, id, authClient}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockRepository)(nil).Update), varargs...) } diff --git a/repository/authclient/mocks/usecase.go b/repository/authclient/mocks/usecase.go index 24561b98..66a57a34 100644 --- a/repository/authclient/mocks/usecase.go +++ b/repository/authclient/mocks/usecase.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: usecase.go +// +// Generated by this command: +// +// mockgen -source usecase.go -package mocks -destination mocks/usecase.go +// // Package mocks is a generated GoMock package. package mocks @@ -8,15 +13,15 @@ import ( context "context" reflect "reflect" - model "github.com/geniusrabbit/blaze-api/model" authclient "github.com/geniusrabbit/blaze-api/repository/authclient" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockUsecase is a mock of Usecase interface. type MockUsecase struct { ctrl *gomock.Controller recorder *MockUsecaseMockRecorder + isgomock struct{} } // MockUsecaseMockRecorder is the mock recorder for MockUsecase. @@ -37,89 +42,114 @@ func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder { } // Count mocks base method. -func (m *MockUsecase) Count(ctx context.Context, filter *authclient.Filter) (int64, error) { +func (m *MockUsecase) Count(ctx context.Context, opts ...authclient.QOption) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockUsecaseMockRecorder) Count(ctx, filter interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Count(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), varargs...) } // Create mocks base method. -func (m *MockUsecase) Create(ctx context.Context, authClient *model.AuthClient) (string, error) { +func (m *MockUsecase) Create(ctx context.Context, authClient *authclient.AuthClient, opts ...authclient.QOption) (string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", ctx, authClient) + varargs := []any{ctx, authClient} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Create", varargs...) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 } // Create indicates an expected call of Create. -func (mr *MockUsecaseMockRecorder) Create(ctx, authClient interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Create(ctx, authClient any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockUsecase)(nil).Create), ctx, authClient) + varargs := append([]any{ctx, authClient}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockUsecase)(nil).Create), varargs...) } // Delete mocks base method. -func (m *MockUsecase) Delete(ctx context.Context, id string) error { +func (m *MockUsecase) Delete(ctx context.Context, id string, opts ...authclient.QOption) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Delete", ctx, id) + varargs := []any{ctx, id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Delete", varargs...) ret0, _ := ret[0].(error) return ret0 } // Delete indicates an expected call of Delete. -func (mr *MockUsecaseMockRecorder) Delete(ctx, id interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Delete(ctx, id any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockUsecase)(nil).Delete), ctx, id) + varargs := append([]any{ctx, id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockUsecase)(nil).Delete), varargs...) } // FetchList mocks base method. -func (m *MockUsecase) FetchList(ctx context.Context, filter *authclient.Filter) ([]*model.AuthClient, error) { +func (m *MockUsecase) FetchList(ctx context.Context, opts ...authclient.QOption) ([]*authclient.AuthClient, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter) - ret0, _ := ret[0].([]*model.AuthClient) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*authclient.AuthClient) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockUsecaseMockRecorder) FetchList(ctx, filter interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) FetchList(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), varargs...) } // Get mocks base method. -func (m *MockUsecase) Get(ctx context.Context, id string) (*model.AuthClient, error) { +func (m *MockUsecase) Get(ctx context.Context, id string) (*authclient.AuthClient, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Get", ctx, id) - ret0, _ := ret[0].(*model.AuthClient) + ret0, _ := ret[0].(*authclient.AuthClient) ret1, _ := ret[1].(error) return ret0, ret1 } // Get indicates an expected call of Get. -func (mr *MockUsecaseMockRecorder) Get(ctx, id interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Get(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockUsecase)(nil).Get), ctx, id) } // Update mocks base method. -func (m *MockUsecase) Update(ctx context.Context, id string, authClient *model.AuthClient) error { +func (m *MockUsecase) Update(ctx context.Context, id string, authClient *authclient.AuthClient, opts ...authclient.QOption) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Update", ctx, id, authClient) + varargs := []any{ctx, id, authClient} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Update", varargs...) ret0, _ := ret[0].(error) return ret0 } // Update indicates an expected call of Update. -func (mr *MockUsecaseMockRecorder) Update(ctx, id, authClient interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Update(ctx, id, authClient any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockUsecase)(nil).Update), ctx, id, authClient) + varargs := append([]any{ctx, id, authClient}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockUsecase)(nil).Update), varargs...) } diff --git a/repository/authclient/models.go b/repository/authclient/models.go new file mode 100644 index 00000000..54bb120f --- /dev/null +++ b/repository/authclient/models.go @@ -0,0 +1,8 @@ +package authclient + +import "github.com/geniusrabbit/blaze-api/repository/authclient/models" + +type ( + AuthClient = models.AuthClient + AuthSession = models.AuthSession +) diff --git a/model/auth_client.go b/repository/authclient/models/auth_client.go similarity index 89% rename from model/auth_client.go rename to repository/authclient/models/auth_client.go index 9e6c2016..7fff7d70 100644 --- a/model/auth_client.go +++ b/repository/authclient/models/auth_client.go @@ -1,4 +1,4 @@ -package model +package models import ( "time" @@ -85,3 +85,23 @@ func (m *AuthClient) OwnerAccountID() uint64 { func (m *AuthClient) RBACResourceName() string { return `auth_client` } + +// GetID returns the client ID +func (m AuthClient) GetID() string { + return m.ID +} + +// SetID sets the client ID +func (m *AuthClient) SetID(id string) { + m.ID = id +} + +// SetCreatedAt sets the created_at field +func (m *AuthClient) SetCreatedAt(t time.Time) { + m.CreatedAt = t +} + +// SetUpdatedAt sets the updated_at field +func (m *AuthClient) SetUpdatedAt(t time.Time) { + m.UpdatedAt = t +} diff --git a/model/auth_session.go b/repository/authclient/models/auth_session.go similarity index 99% rename from model/auth_session.go rename to repository/authclient/models/auth_session.go index cb6428af..6300ed34 100644 --- a/model/auth_session.go +++ b/repository/authclient/models/auth_session.go @@ -1,4 +1,4 @@ -package model +package models import ( "time" diff --git a/repository/authclient/query.go b/repository/authclient/query.go index a6749be7..e668437f 100644 --- a/repository/authclient/query.go +++ b/repository/authclient/query.go @@ -1,8 +1,29 @@ package authclient +import ( + "github.com/geniusrabbit/blaze-api/repository" + "gorm.io/gorm" +) + // Filter of the objects list type Filter struct { - ID []string - Page int - PageSize int + ID []string +} + +// PrepareQuery prepares the GORM query based on the filter fields. +func (f *Filter) PrepareQuery(q *gorm.DB) *gorm.DB { + if f == nil { + return q + } + if len(f.ID) > 0 { + q = q.Where(`id IN (?)`, f.ID) + } + return q } + +// Type aliases for common repository types. +type ( + Pagination = repository.Pagination + QOption = repository.QOption + ListOptions = repository.ListOptions +) diff --git a/repository/authclient/repository.go b/repository/authclient/repository.go index 8a0469eb..f21aee8b 100644 --- a/repository/authclient/repository.go +++ b/repository/authclient/repository.go @@ -1,20 +1,29 @@ -// Package account present full API functionality of the specific object +// Package authclient provides repository access for authentication client management. package authclient import ( "context" - - "github.com/geniusrabbit/blaze-api/model" ) -// Repository of access to the account +// Repository defines the interface for AuthClient data access operations. // //go:generate mockgen -source $GOFILE -package mocks -destination mocks/repository.go type Repository interface { - Get(ctx context.Context, id string) (*model.AuthClient, error) - FetchList(ctx context.Context, filter *Filter) ([]*model.AuthClient, error) - Count(ctx context.Context, filter *Filter) (int64, error) - Create(ctx context.Context, authClient *model.AuthClient) (string, error) - Update(ctx context.Context, id string, authClient *model.AuthClient) error - Delete(ctx context.Context, id string) error + // Get retrieves an AuthClient by ID. + Get(ctx context.Context, id string) (*AuthClient, error) + + // FetchList retrieves a list of AuthClients with optional query parameters. + FetchList(ctx context.Context, opts ...QOption) ([]*AuthClient, error) + + // Count returns the total number of AuthClients matching the query options. + Count(ctx context.Context, opts ...QOption) (int64, error) + + // Create adds a new AuthClient and returns its ID. + Create(ctx context.Context, authClient *AuthClient, opts ...QOption) (string, error) + + // Update modifies an existing AuthClient by ID. + Update(ctx context.Context, id string, authClient *AuthClient, opts ...QOption) error + + // Delete removes an AuthClient by ID. + Delete(ctx context.Context, id string, opts ...QOption) error } diff --git a/repository/authclient/repository/repository.go b/repository/authclient/repository/repository.go index a8dcf2e4..2a80ed62 100644 --- a/repository/authclient/repository/repository.go +++ b/repository/authclient/repository/repository.go @@ -3,90 +3,54 @@ package repository import ( "context" - "database/sql" "time" - "github.com/pkg/errors" - "gorm.io/gorm" - - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/authclient" + "github.com/geniusrabbit/blaze-api/repository/generated" + "github.com/geniusrabbit/blaze-api/repository/historylog" ) -// Repository DAO which provides functionality of working with RBAC roles +// Repository DAO which provides functionality of working with AuthClients. +// FetchList and Count are provided by the embedded generated.Repository. type Repository struct { - repository.Repository + generated.Repository[authclient.AuthClient, string] } -// New role repository -func New() *Repository { - return &Repository{} +// NewAuthclientRepository creates a new instance of the AuthClient repository +func NewAuthclientRepository() *Repository { + return &Repository{Repository: *generated.NewRepository[authclient.AuthClient, string]()} } -// Get returns RBAC role model by ID -func (r *Repository) Get(ctx context.Context, id string) (*model.AuthClient, error) { - object := new(model.AuthClient) +// Get returns AuthClient by ID. Uses Find (not First) to keep the original +// no-error-on-not-found behavior required by the authclient domain interface. +func (r *Repository) Get(ctx context.Context, id string) (*authclient.AuthClient, error) { + object := new(authclient.AuthClient) if err := r.Slave(ctx).Find(object, id).Error; err != nil { return nil, err } return object, nil } -// FetchList returns list of RBAC roles by filter -func (r *Repository) FetchList(ctx context.Context, filter *authclient.Filter) ([]*model.AuthClient, error) { - var ( - list []*model.AuthClient - query = r.Slave(ctx).Model((*model.AuthClient)(nil)) - ) - if filter != nil && len(filter.ID) > 0 { - query = query.Where(`id IN (?)`, filter.ID) - } - if filter.PageSize > 0 { - query = query.Limit(filter.PageSize).Offset(filter.PageSize * filter.Page) - } - err := query.Find(&list).Error - if errors.Is(err, gorm.ErrRecordNotFound) || errors.Is(err, sql.ErrNoRows) { - err = nil - } - return list, err -} - -// Count returns count of records by filter -func (r *Repository) Count(ctx context.Context, filter *authclient.Filter) (int64, error) { - var ( - count int64 - query = r.Slave(ctx).Model((*model.AuthClient)(nil)) - ) - if filter != nil && len(filter.ID) > 0 { - query = query.Where(`id IN (?)`, filter.ID) - } - err := query.Count(&count).Error - if errors.Is(err, gorm.ErrRecordNotFound) || errors.Is(err, sql.ErrNoRows) { - err = nil - } - return count, err -} - -// Create new object into database -func (r *Repository) Create(ctx context.Context, roleObj *model.AuthClient) (string, error) { +// Create adds a new AuthClient, auto-generating a UUID when the ID is empty. +func (r *Repository) Create(ctx context.Context, roleObj *authclient.AuthClient, opts ...authclient.QOption) (string, error) { if roleObj.ID == "" { roleObj.ID = newID() } roleObj.CreatedAt = time.Now() roleObj.UpdatedAt = roleObj.CreatedAt - err := r.Master(ctx).Create(roleObj).Error + db := authclient.ListOptions(opts).PrepareQuery(r.Master(historylog.WithPK(ctx, roleObj.ID))) + err := db.Create(roleObj).Error return roleObj.ID, err } -// Update existing object in database -func (r *Repository) Update(ctx context.Context, id string, roleObj *model.AuthClient) error { +// Update saves partial changes (non-zero fields only) to an existing AuthClient. +func (r *Repository) Update(ctx context.Context, id string, roleObj *authclient.AuthClient, opts ...authclient.QOption) error { obj := *roleObj obj.ID = id - return r.Master(ctx).Updates(&obj).Error + return authclient.ListOptions(opts).PrepareQuery(r.Master(ctx)).Updates(&obj).Error } -// Delete delites record by ID -func (r *Repository) Delete(ctx context.Context, id string) error { - return r.Master(ctx).Model((*model.AuthClient)(nil)).Delete(`id=?`, id).Error +// Delete removes an AuthClient by ID. +func (r *Repository) Delete(ctx context.Context, id string, opts ...authclient.QOption) error { + return r.Repository.Delete(historylog.WithPK(ctx, id), id, opts...) } diff --git a/repository/authclient/repository/repository_test.go b/repository/authclient/repository/repository_test.go index 22a13bea..281237bc 100644 --- a/repository/authclient/repository/repository_test.go +++ b/repository/authclient/repository/repository_test.go @@ -7,8 +7,9 @@ import ( sqlmock "github.com/DATA-DOG/go-sqlmock" "github.com/stretchr/testify/suite" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/repository/authclient" + "github.com/geniusrabbit/blaze-api/repository/authclient/models" + "github.com/geniusrabbit/blaze-api/repository/historylog" "github.com/geniusrabbit/blaze-api/repository/testsuite" ) @@ -20,7 +21,7 @@ type testSuite struct { func (s *testSuite) SetupSuite() { s.DatabaseSuite.SetupSuite() - s.authclientRepo = New() + s.authclientRepo = NewAuthclientRepository() } func (s *testSuite) TestGet() { @@ -37,14 +38,13 @@ func (s *testSuite) TestGet() { func (s *testSuite) TestFetchList() { s.Mock.ExpectQuery("SELECT *"). - WithArgs("1", "2", 100). + WithArgs("1", "2"). WillReturnRows( sqlmock.NewRows([]string{"id", "account_id", "user_id", "title", "secret", "created_at"}). AddRow("1", 1, 1, "title1", "secret", time.Now()). AddRow("2", 1, 1, "title2", "secret", time.Now()), ) - clients, err := s.authclientRepo.FetchList(s.Ctx, &authclient.Filter{ - ID: []string{"1", "2"}, PageSize: 100}) + clients, err := s.authclientRepo.FetchList(s.Ctx, &authclient.Filter{ID: []string{"1", "2"}}) s.NoError(err) s.Equal(2, len(clients)) } @@ -56,8 +56,7 @@ func (s *testSuite) TestCount() { sqlmock.NewRows([]string{"count"}). AddRow(2), ) - count, err := s.authclientRepo.Count(s.Ctx, &authclient.Filter{ - ID: []string{"1", "2"}, PageSize: 100}) + count, err := s.authclientRepo.Count(s.Ctx, &authclient.Filter{ID: []string{"1", "2"}}) s.NoError(err) s.Equal(int64(2), count) } @@ -66,14 +65,14 @@ func (s *testSuite) TestCreate() { s.Mock.ExpectExec("INSERT INTO"). WithArgs(sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg()). WillReturnResult(sqlmock.NewResult(0, 1)) - id, err := s.authclientRepo.Create( - s.Ctx, - &model.AuthClient{ - ID: "101", - Title: "test", - AccountID: 1, - UserID: 1, - }) + + obj := &models.AuthClient{ + ID: "101", + Title: "test", + AccountID: 1, + UserID: 1, + } + id, err := s.authclientRepo.Create(s.Ctx, obj, historylog.Message("create authclient")) s.NoError(err) s.Equal("101", id) } @@ -82,7 +81,7 @@ func (s *testSuite) TestUpdate() { s.Mock.ExpectExec("UPDATE"). WithArgs("test", sqlmock.AnyArg(), "101"). WillReturnResult(sqlmock.NewResult(0, 1)) - err := s.authclientRepo.Update(s.Ctx, "101", &model.AuthClient{Title: "test"}) + err := s.authclientRepo.Update(s.Ctx, "101", &models.AuthClient{Title: "test"}, historylog.Message("update authclient")) s.NoError(err) } @@ -90,7 +89,7 @@ func (s *testSuite) TestDelete() { s.Mock.ExpectExec("UPDATE"). WithArgs(sqlmock.AnyArg(), "101"). WillReturnResult(sqlmock.NewResult(0, 1)) - err := s.authclientRepo.Delete(s.Ctx, "101") + err := s.authclientRepo.Delete(s.Ctx, "101", historylog.Message("delete authclient")) s.NoError(err) } diff --git a/repository/authclient/usecase.go b/repository/authclient/usecase.go index 7434ca44..70e4d2f0 100644 --- a/repository/authclient/usecase.go +++ b/repository/authclient/usecase.go @@ -2,18 +2,27 @@ package authclient import ( "context" - - "github.com/geniusrabbit/blaze-api/model" ) -// Usecase of the AuthAclient +// Usecase defines the business logic operations for AuthClient management. // //go:generate mockgen -source $GOFILE -package mocks -destination mocks/usecase.go type Usecase interface { - Get(ctx context.Context, id string) (*model.AuthClient, error) - FetchList(ctx context.Context, filter *Filter) ([]*model.AuthClient, error) - Count(ctx context.Context, filter *Filter) (int64, error) - Create(ctx context.Context, authClient *model.AuthClient) (string, error) - Update(ctx context.Context, id string, authClient *model.AuthClient) error - Delete(ctx context.Context, id string) error + // Get retrieves a single AuthClient by ID. + Get(ctx context.Context, id string) (*AuthClient, error) + + // FetchList retrieves multiple AuthClients with optional query parameters. + FetchList(ctx context.Context, opts ...QOption) ([]*AuthClient, error) + + // Count returns the total number of AuthClients matching the query options. + Count(ctx context.Context, opts ...QOption) (int64, error) + + // Create adds a new AuthClient and records the change message. + Create(ctx context.Context, authClient *AuthClient, opts ...QOption) (string, error) + + // Update modifies an existing AuthClient by ID with a change message. + Update(ctx context.Context, id string, authClient *AuthClient, opts ...QOption) error + + // Delete removes an AuthClient by ID with a change message. + Delete(ctx context.Context, id string, opts ...QOption) error } diff --git a/repository/authclient/usecase/usecase.go b/repository/authclient/usecase/usecase.go index 80463bcc..a72b23e5 100644 --- a/repository/authclient/usecase/usecase.go +++ b/repository/authclient/usecase/usecase.go @@ -4,9 +4,9 @@ package usecase import ( "context" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/acl" "github.com/geniusrabbit/blaze-api/repository/authclient" + "github.com/geniusrabbit/blaze-api/repository/authclient/models" "github.com/geniusrabbit/blaze-api/repository/historylog" "github.com/pkg/errors" ) @@ -24,7 +24,7 @@ func NewAuthclientUsecase(repo authclient.Repository) *AuthclientUsecase { } // Get returns the group by ID if have access -func (a *AuthclientUsecase) Get(ctx context.Context, id string) (*model.AuthClient, error) { +func (a *AuthclientUsecase) Get(ctx context.Context, id string) (*models.AuthClient, error) { authclientObj, err := a.authclientRepo.Get(ctx, id) if err != nil { return nil, err @@ -36,17 +36,11 @@ func (a *AuthclientUsecase) Get(ctx context.Context, id string) (*model.AuthClie } // FetchList of accounts by filter -func (a *AuthclientUsecase) FetchList(ctx context.Context, filter *authclient.Filter) ([]*model.AuthClient, error) { - if filter == nil { - filter = &authclient.Filter{} - } - if filter.PageSize <= 0 { - filter.PageSize = 10 - } - if !acl.HaveAccessList(ctx, &model.AuthClient{}) { +func (a *AuthclientUsecase) FetchList(ctx context.Context, opts ...authclient.QOption) ([]*models.AuthClient, error) { + if !acl.HaveAccessList(ctx, &models.AuthClient{}) { return nil, errors.Wrap(acl.ErrNoPermissions, "list authclient") } - list, err := a.authclientRepo.FetchList(ctx, filter) + list, err := a.authclientRepo.FetchList(ctx, opts...) for _, link := range list { if !acl.HaveAccessList(ctx, link) { return nil, errors.Wrap(acl.ErrNoPermissions, "list authclient") @@ -56,36 +50,33 @@ func (a *AuthclientUsecase) FetchList(ctx context.Context, filter *authclient.Fi } // Count of accounts by filter -func (a *AuthclientUsecase) Count(ctx context.Context, filter *authclient.Filter) (int64, error) { - if filter == nil { - filter = &authclient.Filter{} - } - if !acl.HaveAccessList(ctx, &model.AuthClient{}) { +func (a *AuthclientUsecase) Count(ctx context.Context, opts ...authclient.QOption) (int64, error) { + if !acl.HaveAccessList(ctx, &models.AuthClient{}) { return 0, errors.Wrap(acl.ErrNoPermissions, "list authclient") } - return a.authclientRepo.Count(ctx, filter) + return a.authclientRepo.Count(ctx, opts...) } // Create new object in database -func (a *AuthclientUsecase) Create(ctx context.Context, authclientObj *model.AuthClient) (string, error) { +func (a *AuthclientUsecase) Create(ctx context.Context, authclientObj *models.AuthClient, opts ...authclient.QOption) (string, error) { var err error if !acl.HaveAccessCreate(ctx, authclientObj) { return "", errors.Wrap(acl.ErrNoPermissions, "create authclient") } - authclientObj.ID, err = a.authclientRepo.Create(ctx, authclientObj) + authclientObj.ID, err = a.authclientRepo.Create(ctx, authclientObj, opts...) return authclientObj.ID, err } // Update object in database -func (a *AuthclientUsecase) Update(ctx context.Context, id string, authclientObj *model.AuthClient) error { +func (a *AuthclientUsecase) Update(ctx context.Context, id string, authclientObj *models.AuthClient, opts ...authclient.QOption) error { if !acl.HaveAccessUpdate(ctx, authclientObj) { return errors.Wrap(acl.ErrNoPermissions, "update authclient") } - return a.authclientRepo.Update(historylog.WithPK(ctx, id), id, authclientObj) + return a.authclientRepo.Update(historylog.WithPK(ctx, id), id, authclientObj, opts...) } // Delete delites record by ID -func (a *AuthclientUsecase) Delete(ctx context.Context, id string) error { +func (a *AuthclientUsecase) Delete(ctx context.Context, id string, opts ...authclient.QOption) error { authclientObj, err := a.Get(ctx, id) if err != nil { return err @@ -93,5 +84,5 @@ func (a *AuthclientUsecase) Delete(ctx context.Context, id string) error { if !acl.HaveAccessDelete(ctx, authclientObj) { return errors.Wrap(acl.ErrNoPermissions, "delete authclient") } - return a.authclientRepo.Delete(historylog.WithPK(ctx, id), id) + return a.authclientRepo.Delete(historylog.WithPK(ctx, id), id, opts...) } diff --git a/repository/authclient/usecase/usecase_test.go b/repository/authclient/usecase/usecase_test.go index fa362615..147af41b 100644 --- a/repository/authclient/usecase/usecase_test.go +++ b/repository/authclient/usecase/usecase_test.go @@ -6,13 +6,14 @@ import ( "errors" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "go.uber.org/mock/gomock" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/context/session" "github.com/geniusrabbit/blaze-api/repository/authclient" "github.com/geniusrabbit/blaze-api/repository/authclient/mocks" + "github.com/geniusrabbit/blaze-api/repository/authclient/models" + "github.com/geniusrabbit/blaze-api/repository/historylog" ) type testSuite struct { @@ -33,7 +34,7 @@ func (s *testSuite) SetupSuite() { func (s *testSuite) TestGet() { s.authclientRepo.EXPECT().Get(s.ctx, "2"). - Return(&model.AuthClient{ID: "2"}, nil) + Return(&models.AuthClient{ID: "2"}, nil) role, err := s.authclientUsecase.Get(s.ctx, "2") s.NoError(err) @@ -52,10 +53,10 @@ func (s *testSuite) TestGetGetError() { func (s *testSuite) TestFetchList() { s.authclientRepo.EXPECT(). FetchList(s.ctx, gomock.AssignableToTypeOf(&authclient.Filter{})). - Return([]*model.AuthClient{{ID: "1"}, {ID: "2"}}, nil) + Return([]*models.AuthClient{{ID: "1"}, {ID: "2"}}, nil) - roles, err := s.authclientUsecase.FetchList(s.ctx, &authclient.Filter{ - ID: []string{"1", "2"}, PageSize: 100}) + roles, err := s.authclientUsecase.FetchList(s.ctx, + &authclient.Filter{ID: []string{"1", "2"}}) s.NoError(err) s.Equal(2, len(roles)) } @@ -65,17 +66,19 @@ func (s *testSuite) TestCount() { Count(s.ctx, gomock.AssignableToTypeOf(&authclient.Filter{})). Return(int64(2), nil) - count, err := s.authclientUsecase.Count(s.ctx, &authclient.Filter{ID: []string{"1", "2"}}) + count, err := s.authclientUsecase.Count(s.ctx, + &authclient.Filter{ID: []string{"1", "2"}}) s.NoError(err) s.Equal(int64(2), count) } func (s *testSuite) TestCreate() { s.authclientRepo.EXPECT(). - Create(s.ctx, gomock.AssignableToTypeOf(&model.AuthClient{})). + Create(s.ctx, gomock.AssignableToTypeOf(&models.AuthClient{}), historylog.Message("create authclient")). Return("101", nil) - id, err := s.authclientUsecase.Create(s.ctx, &model.AuthClient{ID: "", Title: "test1"}) + id, err := s.authclientUsecase.Create(s.ctx, + &models.AuthClient{ID: "", Title: "test1"}, historylog.Message("create authclient")) s.NoError(err) s.Equal(id, "101") } @@ -83,22 +86,24 @@ func (s *testSuite) TestCreate() { func (s *testSuite) TestUpdate() { s.authclientRepo.EXPECT(). Update(gomock.AssignableToTypeOf(s.ctx), - "101", gomock.AssignableToTypeOf(&model.AuthClient{})). + "101", gomock.AssignableToTypeOf(&models.AuthClient{}), historylog.Message("update authclient")). Return(nil) - err := s.authclientUsecase.Update(s.ctx, "101", &model.AuthClient{Title: "test-test"}) + err := s.authclientUsecase.Update(s.ctx, "101", + &models.AuthClient{Title: "test-test"}, historylog.Message("update authclient")) s.NoError(err) } func (s *testSuite) TestDelete() { + stype := gomock.AssignableToTypeOf("1") s.authclientRepo.EXPECT(). Get(gomock.AssignableToTypeOf(s.ctx), "1"). - Return(&model.AuthClient{ID: "1"}, nil) + Return(&models.AuthClient{ID: "1"}, nil) s.authclientRepo.EXPECT(). - Delete(gomock.AssignableToTypeOf(s.ctx), gomock.AssignableToTypeOf("101")). + Delete(gomock.AssignableToTypeOf(s.ctx), stype, gomock.AssignableToTypeOf(historylog.Message(""))). Return(nil) - err := s.authclientUsecase.Delete(s.ctx, "1") + err := s.authclientUsecase.Delete(s.ctx, "1", historylog.Message("delete authclient")) s.NoError(err) } @@ -106,7 +111,7 @@ func (s *testSuite) TestDeleteNotFound() { s.authclientRepo.EXPECT(). Get(s.ctx, "9999"). Return(nil, sql.ErrNoRows) - err := s.authclientUsecase.Delete(s.ctx, "9999") + err := s.authclientUsecase.Delete(s.ctx, "9999", historylog.Message("delete authclient")) s.EqualError(err, sql.ErrNoRows.Error()) } diff --git a/repository/directaccesstoken/delivery/graphql/connector.go b/repository/directaccesstoken/delivery/graphql/connector.go new file mode 100644 index 00000000..3a4f84f5 --- /dev/null +++ b/repository/directaccesstoken/delivery/graphql/connector.go @@ -0,0 +1,66 @@ +package graphql + +import ( + "context" + + "github.com/demdxx/gocast/v2" + + "github.com/geniusrabbit/blaze-api/repository/directaccesstoken" + "github.com/geniusrabbit/blaze-api/repository/directaccesstoken/models" + "github.com/geniusrabbit/blaze-api/server/graphql/connectors" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" +) + +// DirectAccessTokenConnection is a GraphQL collection connection for direct access tokens with pagination support. +type DirectAccessTokenConnection = connectors.CollectionConnection[gqlmodels.DirectAccessToken, gqlmodels.DirectAccessTokenEdge] + +// NewDirectAccessTokenConnection creates a new collection connection for direct access tokens based on the provided query parameters. +// +// Parameters: +// - ctx: context for the operation +// - directAccessTokenAccessor: usecase for accessing direct access token data +// - filter: GraphQL filter criteria +// - order: GraphQL sort order +// - page: pagination parameters +// - fnPrep: optional preparation function to transform tokens before returning +func NewDirectAccessTokenConnection( + ctx context.Context, + directAccessTokenAccessor directaccesstoken.Usecase, + filter *gqlmodels.DirectAccessTokenListFilter, + order *gqlmodels.DirectAccessTokenListOrder, + page *gqlmodels.Page, + fnPrep func(*models.DirectAccessToken) *models.DirectAccessToken, +) *DirectAccessTokenConnection { + return connectors.NewCollectionConnection( + ctx, + &connectors.DataAccessorFunc[gqlmodels.DirectAccessToken, gqlmodels.DirectAccessTokenEdge]{ + // FetchDataListFunc retrieves the list of direct access tokens with applied filters, ordering, and pagination. + FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.DirectAccessToken, error) { + directAccessTokens, err := directAccessTokenAccessor.FetchList( + ctx, + filter.Filter(), + order.Order(), + page.Pagination(), + ) + if fnPrep != nil { + for i, token := range directAccessTokens { + directAccessTokens[i] = fnPrep(token) + } + } + return gqlmodels.FromDirectAccessTokenModelList(directAccessTokens), err + }, + // CountDataFunc returns the total count of direct access tokens matching the filter criteria. + CountDataFunc: func(ctx context.Context) (int64, error) { + return directAccessTokenAccessor.Count(ctx, filter.Filter()) + }, + // ConvertToEdgeFunc transforms a token into a GraphQL edge with cursor and node information. + ConvertToEdgeFunc: func(obj *gqlmodels.DirectAccessToken) *gqlmodels.DirectAccessTokenEdge { + return &gqlmodels.DirectAccessTokenEdge{ + Cursor: gocast.Str(obj.ID), + Node: obj, + } + }, + }, + page, + ) +} diff --git a/protocol/graphql/schemas/directaccesstoken.graphql b/repository/directaccesstoken/delivery/graphql/directaccesstoken.graphql similarity index 100% rename from protocol/graphql/schemas/directaccesstoken.graphql rename to repository/directaccesstoken/delivery/graphql/directaccesstoken.graphql diff --git a/repository/directaccesstoken/delivery/graphql/resolver.go b/repository/directaccesstoken/delivery/graphql/resolver.go index 1234c49b..5d37c68e 100644 --- a/repository/directaccesstoken/delivery/graphql/resolver.go +++ b/repository/directaccesstoken/delivery/graphql/resolver.go @@ -7,35 +7,42 @@ import ( "time" "github.com/demdxx/gocast/v2" - "github.com/geniusrabbit/blaze-api/model" + "github.com/geniusrabbit/blaze-api/pkg/context/session" "github.com/geniusrabbit/blaze-api/pkg/requestid" - "github.com/geniusrabbit/blaze-api/repository/directaccesstoken/repository" - "github.com/geniusrabbit/blaze-api/repository/directaccesstoken/usecase" - "github.com/geniusrabbit/blaze-api/server/graphql/connectors" + "github.com/geniusrabbit/blaze-api/repository/directaccesstoken" + datModels "github.com/geniusrabbit/blaze-api/repository/directaccesstoken/models" "github.com/geniusrabbit/blaze-api/server/graphql/models" ) +// QueryResolver handles GraphQL queries for direct access tokens. type QueryResolver struct { - uc *usecase.Usecase + uc directaccesstoken.Usecase } -// NewQueryResolver creates a new resolver. -func NewQueryResolver() *QueryResolver { - return &QueryResolver{uc: usecase.New(repository.New())} +// NewQueryResolver creates a new QueryResolver instance. +func NewQueryResolver(uc directaccesstoken.Usecase) *QueryResolver { + return &QueryResolver{uc: uc} } -// Generate is the resolver for the generateDirectAccessToken field. +// Generate creates a new direct access token with the specified parameters. func (r *QueryResolver) Generate(ctx context.Context, userID *uint64, description string, expiresAt *time.Time) (*models.DirectAccessTokenPayload, error) { + // Initialize expiration time if nil if expiresAt == nil { expiresAt = &time.Time{} } + + // Set default expiration to 30 days if zero if expiresAt.IsZero() { *expiresAt = time.Now().Add(time.Hour * 24 * 30) } + + // Validate expiration is in the future if expiresAt.Before(time.Now()) { return nil, fmt.Errorf("expiresAt should be in future") } + + // Generate token using the usecase token, err := r.uc.Generate(ctx, gocast.IfThenExec(userID != nil, func() uint64 { return *userID }, func() uint64 { return 0 }), session.Account(ctx).ID, @@ -45,45 +52,52 @@ func (r *QueryResolver) Generate(ctx context.Context, userID *uint64, descriptio if err != nil { return nil, err } + return &models.DirectAccessTokenPayload{ ClientMutationID: requestid.Get(ctx), Token: models.FromDirectAccessToken(token), }, nil } -// Revoke is the resolver for the revokeDirectAccessToken field. +// Revoke revokes direct access tokens matching the provided filter. func (r *QueryResolver) Revoke(ctx context.Context, filter models.DirectAccessTokenListFilter) (*models.StatusResponse, error) { err := r.uc.Revoke(ctx, filter.Filter()) if err != nil { return nil, err } + return &models.StatusResponse{ ClientMutationID: requestid.Get(ctx), Status: "ok", - Message: &[]string{"token(s) revoked"}[0], + Message: gocast.Ptr("token(s) revoked"), }, nil } -// Get is the resolver for the getDirectAccessToken field. +// Get retrieves a direct access token by its ID. func (r *QueryResolver) Get(ctx context.Context, id uint64) (*models.DirectAccessTokenPayload, error) { token, err := r.uc.Get(ctx, id) if err != nil { return nil, err } + return &models.DirectAccessTokenPayload{ ClientMutationID: requestid.Get(ctx), Token: models.FromDirectAccessToken(token), }, nil } -// List is the resolver for the listDirectAccessTokens field. -func (r *QueryResolver) List(ctx context.Context, filter *models.DirectAccessTokenListFilter, order *models.DirectAccessTokenListOrder, page *models.Page) (*connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge], error) { - return connectors.NewDirectAccessTokenConnection(ctx, r.uc, filter, order, page, - func(dat *model.DirectAccessToken) *model.DirectAccessToken { +// List retrieves a paginated collection of direct access tokens with optional filtering and ordering. +// Tokens created within the last 5 minutes are returned as-is; older tokens have their values masked. +func (r *QueryResolver) List(ctx context.Context, filter *models.DirectAccessTokenListFilter, order *models.DirectAccessTokenListOrder, page *models.Page) (*DirectAccessTokenConnection, error) { + return NewDirectAccessTokenConnection(ctx, r.uc, filter, order, page, + func(dat *datModels.DirectAccessToken) *datModels.DirectAccessToken { + // Return token unmasked if recently created if dat.CreatedAt.After(time.Now().Add(-time.Minute * 5)) { return dat } - m := new(model.DirectAccessToken) + + // Mask token value for older tokens + m := new(datModels.DirectAccessToken) *m = *dat m.Token = strings.Repeat("*", len(m.Token)) return m diff --git a/repository/directaccesstoken/delivery/wrapper/httpwrapper.go b/repository/directaccesstoken/delivery/wrapper/httpwrapper.go index 74186649..41d1aa00 100644 --- a/repository/directaccesstoken/delivery/wrapper/httpwrapper.go +++ b/repository/directaccesstoken/delivery/wrapper/httpwrapper.go @@ -5,18 +5,20 @@ import ( "go.uber.org/zap" - "github.com/geniusrabbit/blaze-api/pkg/auth/authutils" "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" "github.com/geniusrabbit/blaze-api/pkg/context/session" + "github.com/geniusrabbit/blaze-api/repository/account/auth" accountRepository "github.com/geniusrabbit/blaze-api/repository/account/repository" directAccRepository "github.com/geniusrabbit/blaze-api/repository/directaccesstoken/repository" ) +// TokenSource defines where and how to extract a token from an HTTP request. type TokenSource struct { - Type string `json:"type"` // Type of the token source: `query`, `header` - Name string `json:"name"` // Name of the token source + Type string `json:"type"` // Type of token source: "query" or "header" + Name string `json:"name"` // Name of query parameter or header field } +// Extract retrieves the token value from the request based on the TokenSource configuration. func (ts TokenSource) Extract(r *http.Request) string { switch ts.Type { case "query": @@ -27,58 +29,65 @@ func (ts TokenSource) Extract(r *http.Request) string { return "" } +// HTTPWrapper is middleware that validates direct access tokens and injects user/account context. func HTTPWrapper(h http.Handler, sources ...TokenSource) http.Handler { + // Default to header-based token if no sources specified if len(sources) == 0 { sources = append(sources, TokenSource{Type: "header", Name: "D-Access-Token"}) } - actokens := directAccRepository.New() - accounts := accountRepository.New() + + actokens := directAccRepository.NewDirectAccessTokenRepository() + accounts := accountRepository.NewAccountRepository() + members := accountRepository.NewMemberRepository() + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { token := "" ctx := r.Context() - // Extract token + // Extract token from request for _, source := range sources { if token = source.Extract(r); token != "" { break } } - // Check token + // Validate token exists if token == "" { badRequest(w) return } - // Load direct token object + // Load token object from repository tokenObj, err := actokens.GetByToken(ctx, token) if err != nil { - ctxlogger.Get(ctx).Error(`Invalid token load`, zap.Error(err)) + ctxlogger.Get(ctx).Error("invalid token load", zap.Error(err)) unauthorized(w) return } - // Load user and account - user, acc, err := authutils.UserAccountByID(ctx, tokenObj.UserID.V, tokenObj.AccountID, nil, nil) + // Load associated user and account + user, acc, err := auth.UserAccountByID(ctx, tokenObj.UserID.V, tokenObj.AccountID, nil, nil) if err != nil { - ctxlogger.Get(ctx).Error(`Invalid user load`, zap.Error(err)) + ctxlogger.Get(ctx).Error("invalid user load", zap.Error(err)) unauthorized(w) return } - // Check if user and account not found + // Validate account found if acc == nil { - ctxlogger.Get(ctx).Info(`User and account not found`) + ctxlogger.Get(ctx).Info("user and account not found") unauthorized(w) return } - // Check if user is a member of the account and load permissions - if user != nil && !accounts.IsMember(ctx, user.ID, acc.ID) { + // Verify user is member of account + if user != nil && !members.IsMember(ctx, user.ID, acc.ID) { ctxlogger.Get(ctx).Error("user is not a member of the account") unauthorized(w) return } + + // Load user permissions for the account err = accounts.LoadPermissions(ctx, acc, user) if err != nil { ctxlogger.Get(ctx).Error("load permissions", zap.Error(err)) @@ -86,17 +95,20 @@ func HTTPWrapper(h http.Handler, sources ...TokenSource) http.Handler { return } + // Inject user and account into context ctx = session.WithUserAccount(ctx, user, acc) h.ServeHTTP(w, r.WithContext(session.WithToken(ctx, token))) }) } +// unauthorized responds with a 401 Unauthorized error. func unauthorized(w http.ResponseWriter) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusUnauthorized) _, _ = w.Write([]byte(`{"errors":[{"message":"Unauthorized","code":401}]}`)) } +// badRequest responds with a 400 Bad Request error. func badRequest(w http.ResponseWriter) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusBadRequest) diff --git a/repository/directaccesstoken/mocks/repository.go b/repository/directaccesstoken/mocks/repository.go index 7c5923c6..cae70c7f 100644 --- a/repository/directaccesstoken/mocks/repository.go +++ b/repository/directaccesstoken/mocks/repository.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: repository.go +// +// Generated by this command: +// +// mockgen -source repository.go -package mocks -destination mocks/repository.go +// // Package mocks is a generated GoMock package. package mocks @@ -9,16 +14,15 @@ import ( reflect "reflect" time "time" - model "github.com/geniusrabbit/blaze-api/model" - repository "github.com/geniusrabbit/blaze-api/repository" directaccesstoken "github.com/geniusrabbit/blaze-api/repository/directaccesstoken" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockRepository is a mock of Repository interface. type MockRepository struct { ctrl *gomock.Controller recorder *MockRepositoryMockRecorder + isgomock struct{} } // MockRepositoryMockRecorder is the mock recorder for MockRepository. @@ -39,90 +43,105 @@ func (m *MockRepository) EXPECT() *MockRepositoryMockRecorder { } // Count mocks base method. -func (m *MockRepository) Count(ctx context.Context, filter *directaccesstoken.Filter) (int64, error) { +func (m *MockRepository) Count(ctx context.Context, opts ...directaccesstoken.QOption) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockRepositoryMockRecorder) Count(ctx, filter interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Count(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), varargs...) } // FetchList mocks base method. -func (m *MockRepository) FetchList(ctx context.Context, filter *directaccesstoken.Filter, order *directaccesstoken.Order, page *repository.Pagination) ([]*model.DirectAccessToken, error) { +func (m *MockRepository) FetchList(ctx context.Context, opts ...directaccesstoken.QOption) ([]*directaccesstoken.DirectAccessToken, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter, order, page) - ret0, _ := ret[0].([]*model.DirectAccessToken) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*directaccesstoken.DirectAccessToken) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockRepositoryMockRecorder) FetchList(ctx, filter, order, page interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) FetchList(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), ctx, filter, order, page) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), varargs...) } // Generate mocks base method. -func (m *MockRepository) Generate(ctx context.Context, userID, accountID uint64, description string, expiresAt time.Time) (*model.DirectAccessToken, error) { +func (m *MockRepository) Generate(ctx context.Context, userID, accountID uint64, description string, expiresAt time.Time) (*directaccesstoken.DirectAccessToken, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Generate", ctx, userID, accountID, description, expiresAt) - ret0, _ := ret[0].(*model.DirectAccessToken) + ret0, _ := ret[0].(*directaccesstoken.DirectAccessToken) ret1, _ := ret[1].(error) return ret0, ret1 } // Generate indicates an expected call of Generate. -func (mr *MockRepositoryMockRecorder) Generate(ctx, userID, accountID, description, expiresAt interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Generate(ctx, userID, accountID, description, expiresAt any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Generate", reflect.TypeOf((*MockRepository)(nil).Generate), ctx, userID, accountID, description, expiresAt) } // Get mocks base method. -func (m *MockRepository) Get(ctx context.Context, id uint64) (*model.DirectAccessToken, error) { +func (m *MockRepository) Get(ctx context.Context, id uint64) (*directaccesstoken.DirectAccessToken, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Get", ctx, id) - ret0, _ := ret[0].(*model.DirectAccessToken) + ret0, _ := ret[0].(*directaccesstoken.DirectAccessToken) ret1, _ := ret[1].(error) return ret0, ret1 } // Get indicates an expected call of Get. -func (mr *MockRepositoryMockRecorder) Get(ctx, id interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Get(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRepository)(nil).Get), ctx, id) } // GetByToken mocks base method. -func (m *MockRepository) GetByToken(ctx context.Context, token string) (*model.DirectAccessToken, error) { +func (m *MockRepository) GetByToken(ctx context.Context, token string) (*directaccesstoken.DirectAccessToken, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetByToken", ctx, token) - ret0, _ := ret[0].(*model.DirectAccessToken) + ret0, _ := ret[0].(*directaccesstoken.DirectAccessToken) ret1, _ := ret[1].(error) return ret0, ret1 } // GetByToken indicates an expected call of GetByToken. -func (mr *MockRepositoryMockRecorder) GetByToken(ctx, token interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) GetByToken(ctx, token any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByToken", reflect.TypeOf((*MockRepository)(nil).GetByToken), ctx, token) } // Revoke mocks base method. -func (m *MockRepository) Revoke(ctx context.Context, filter *directaccesstoken.Filter) error { +func (m *MockRepository) Revoke(ctx context.Context, opts ...directaccesstoken.QOption) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Revoke", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Revoke", varargs...) ret0, _ := ret[0].(error) return ret0 } // Revoke indicates an expected call of Revoke. -func (mr *MockRepositoryMockRecorder) Revoke(ctx, filter interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Revoke(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Revoke", reflect.TypeOf((*MockRepository)(nil).Revoke), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Revoke", reflect.TypeOf((*MockRepository)(nil).Revoke), varargs...) } diff --git a/repository/directaccesstoken/mocks/usecase.go b/repository/directaccesstoken/mocks/usecase.go index 8f4c5dda..f52be797 100644 --- a/repository/directaccesstoken/mocks/usecase.go +++ b/repository/directaccesstoken/mocks/usecase.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: usecase.go +// +// Generated by this command: +// +// mockgen -source usecase.go -package mocks -destination mocks/usecase.go +// // Package mocks is a generated GoMock package. package mocks @@ -9,16 +14,15 @@ import ( reflect "reflect" time "time" - model "github.com/geniusrabbit/blaze-api/model" - repository "github.com/geniusrabbit/blaze-api/repository" directaccesstoken "github.com/geniusrabbit/blaze-api/repository/directaccesstoken" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockUsecase is a mock of Usecase interface. type MockUsecase struct { ctrl *gomock.Controller recorder *MockUsecaseMockRecorder + isgomock struct{} } // MockUsecaseMockRecorder is the mock recorder for MockUsecase. @@ -39,75 +43,90 @@ func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder { } // Count mocks base method. -func (m *MockUsecase) Count(ctx context.Context, filter *directaccesstoken.Filter) (int64, error) { +func (m *MockUsecase) Count(ctx context.Context, opts ...directaccesstoken.QOption) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockUsecaseMockRecorder) Count(ctx, filter interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Count(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), varargs...) } // FetchList mocks base method. -func (m *MockUsecase) FetchList(ctx context.Context, filter *directaccesstoken.Filter, order *directaccesstoken.Order, page *repository.Pagination) ([]*model.DirectAccessToken, error) { +func (m *MockUsecase) FetchList(ctx context.Context, opts ...directaccesstoken.QOption) ([]*directaccesstoken.DirectAccessToken, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter, order, page) - ret0, _ := ret[0].([]*model.DirectAccessToken) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*directaccesstoken.DirectAccessToken) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockUsecaseMockRecorder) FetchList(ctx, filter, order, page interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) FetchList(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), ctx, filter, order, page) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), varargs...) } // Generate mocks base method. -func (m *MockUsecase) Generate(ctx context.Context, userID, accountID uint64, description string, expiresAt time.Time) (*model.DirectAccessToken, error) { +func (m *MockUsecase) Generate(ctx context.Context, userID, accountID uint64, description string, expiresAt time.Time) (*directaccesstoken.DirectAccessToken, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Generate", ctx, userID, accountID, description, expiresAt) - ret0, _ := ret[0].(*model.DirectAccessToken) + ret0, _ := ret[0].(*directaccesstoken.DirectAccessToken) ret1, _ := ret[1].(error) return ret0, ret1 } // Generate indicates an expected call of Generate. -func (mr *MockUsecaseMockRecorder) Generate(ctx, userID, accountID, description, expiresAt interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Generate(ctx, userID, accountID, description, expiresAt any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Generate", reflect.TypeOf((*MockUsecase)(nil).Generate), ctx, userID, accountID, description, expiresAt) } // Get mocks base method. -func (m *MockUsecase) Get(ctx context.Context, id uint64) (*model.DirectAccessToken, error) { +func (m *MockUsecase) Get(ctx context.Context, id uint64) (*directaccesstoken.DirectAccessToken, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Get", ctx, id) - ret0, _ := ret[0].(*model.DirectAccessToken) + ret0, _ := ret[0].(*directaccesstoken.DirectAccessToken) ret1, _ := ret[1].(error) return ret0, ret1 } // Get indicates an expected call of Get. -func (mr *MockUsecaseMockRecorder) Get(ctx, id interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Get(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockUsecase)(nil).Get), ctx, id) } // Revoke mocks base method. -func (m *MockUsecase) Revoke(ctx context.Context, filter *directaccesstoken.Filter) error { +func (m *MockUsecase) Revoke(ctx context.Context, opts ...directaccesstoken.QOption) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Revoke", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Revoke", varargs...) ret0, _ := ret[0].(error) return ret0 } // Revoke indicates an expected call of Revoke. -func (mr *MockUsecaseMockRecorder) Revoke(ctx, filter interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Revoke(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Revoke", reflect.TypeOf((*MockUsecase)(nil).Revoke), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Revoke", reflect.TypeOf((*MockUsecase)(nil).Revoke), varargs...) } diff --git a/repository/directaccesstoken/models.go b/repository/directaccesstoken/models.go new file mode 100644 index 00000000..57dcf861 --- /dev/null +++ b/repository/directaccesstoken/models.go @@ -0,0 +1,5 @@ +package directaccesstoken + +import "github.com/geniusrabbit/blaze-api/repository/directaccesstoken/models" + +type DirectAccessToken = models.DirectAccessToken diff --git a/model/direct_access_token.go b/repository/directaccesstoken/models/direct_access_token.go similarity index 71% rename from model/direct_access_token.go rename to repository/directaccesstoken/models/direct_access_token.go index d9f31482..921c00e6 100644 --- a/model/direct_access_token.go +++ b/repository/directaccesstoken/models/direct_access_token.go @@ -1,10 +1,11 @@ -package model +package models import ( "database/sql" "time" ) +// DirectAccessToken represents a direct access token entity. type DirectAccessToken struct { ID uint64 `json:"id"` Token string `json:"token"` @@ -16,11 +17,12 @@ type DirectAccessToken struct { ExpiresAt time.Time `json:"expires_at"` } +// TableName specifies the database table name for DirectAccessToken. func (m *DirectAccessToken) TableName() string { return "direct_access_tokens" } -// RBACResourceName returns the name of the resource for the RBAC +// RBACResourceName returns the RBAC resource name for access control. func (m *DirectAccessToken) RBACResourceName() string { return "directaccesstoken" } diff --git a/repository/directaccesstoken/query.go b/repository/directaccesstoken/query.go index 0559750f..200d113f 100644 --- a/repository/directaccesstoken/query.go +++ b/repository/directaccesstoken/query.go @@ -1,21 +1,30 @@ package directaccesstoken import ( + "context" "time" - "github.com/geniusrabbit/blaze-api/model" "gorm.io/gorm" + + "github.com/geniusrabbit/blaze-api/pkg/context/session" + "github.com/geniusrabbit/blaze-api/pkg/models" + "github.com/geniusrabbit/blaze-api/repository" ) +// Order is an alias for models.Order +type Order = models.Order + +// Filter defines query filters for direct access tokens type Filter struct { - ID []uint64 - Token []string - UserID []uint64 - AccountID []uint64 - MinExpiresAt time.Time - MaxExpiresAt time.Time + ID []uint64 // Filter by token IDs + Token []string // Filter by token strings + UserID []uint64 // Filter by user IDs + AccountID []uint64 // Filter by account IDs + MinExpiresAt time.Time // Minimum expiration time + MaxExpiresAt time.Time // Maximum expiration time } +// PrepareQuery applies filter conditions to a GORM query func (fl *Filter) PrepareQuery(query *gorm.DB) *gorm.DB { if fl == nil { return query @@ -41,16 +50,18 @@ func (fl *Filter) PrepareQuery(query *gorm.DB) *gorm.DB { return query } -type Order struct { - ID model.Order - Token model.Order - UserID model.Order - AccountID model.Order - CreatedAt model.Order - ExpiresAt model.Order +// ListOrder defines sort order for query results +type ListOrder struct { + ID models.Order // Sort by ID + Token models.Order // Sort by token + UserID models.Order // Sort by user ID + AccountID models.Order // Sort by account ID + CreatedAt models.Order // Sort by creation time + ExpiresAt models.Order // Sort by expiration time } -func (ord *Order) PrepareQuery(query *gorm.DB) *gorm.DB { +// PrepareQuery applies sort order to a GORM query +func (ord *ListOrder) PrepareQuery(query *gorm.DB) *gorm.DB { if ord == nil { return query } @@ -62,3 +73,19 @@ func (ord *Order) PrepareQuery(query *gorm.DB) *gorm.DB { query = ord.ExpiresAt.PrepareQuery(query, "expires_at") return query } + +// AdjustPermissions scopes the filter to the current session account. +// It always overwrites AccountID to ensure results are restricted to the caller's account. +func (fl *Filter) AdjustPermissions(ctx context.Context) error { + fl.AccountID = []uint64{session.Account(ctx).ID} + return nil +} + +// Pagination is an alias for repository.Pagination +type Pagination = repository.Pagination + +// Type aliases for list options. +type ( + QOption = repository.QOption + ListOptions = repository.ListOptions +) diff --git a/repository/directaccesstoken/repository.go b/repository/directaccesstoken/repository.go index 1debbe27..96ad6784 100644 --- a/repository/directaccesstoken/repository.go +++ b/repository/directaccesstoken/repository.go @@ -3,17 +3,27 @@ package directaccesstoken import ( "context" "time" - - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" ) //go:generate mockgen -source $GOFILE -package mocks -destination mocks/repository.go + +// Repository defines the interface for managing direct access tokens. type Repository interface { - Get(ctx context.Context, id uint64) (*model.DirectAccessToken, error) - GetByToken(ctx context.Context, token string) (*model.DirectAccessToken, error) - FetchList(ctx context.Context, filter *Filter, order *Order, page *repository.Pagination) ([]*model.DirectAccessToken, error) - Count(ctx context.Context, filter *Filter) (int64, error) - Generate(ctx context.Context, userID, accountID uint64, description string, expiresAt time.Time) (*model.DirectAccessToken, error) - Revoke(ctx context.Context, filter *Filter) error + // Get retrieves a direct access token by its ID. + Get(ctx context.Context, id uint64) (*DirectAccessToken, error) + + // GetByToken retrieves a direct access token by its token string. + GetByToken(ctx context.Context, token string) (*DirectAccessToken, error) + + // FetchList retrieves a paginated list of direct access tokens matching the filter and order criteria. + FetchList(ctx context.Context, opts ...QOption) ([]*DirectAccessToken, error) + + // Count returns the total count of direct access tokens matching the filter criteria. + Count(ctx context.Context, opts ...QOption) (int64, error) + + // Generate creates and stores a new direct access token for the specified user and account. + Generate(ctx context.Context, userID, accountID uint64, description string, expiresAt time.Time) (*DirectAccessToken, error) + + // Revoke invalidates direct access tokens matching the filter criteria. + Revoke(ctx context.Context, opts ...QOption) error } diff --git a/repository/directaccesstoken/repository/repository.go b/repository/directaccesstoken/repository/repository.go index 0e6e3b6f..69bb3c22 100644 --- a/repository/directaccesstoken/repository/repository.go +++ b/repository/directaccesstoken/repository/repository.go @@ -5,23 +5,24 @@ import ( "database/sql" "time" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/directaccesstoken" + "github.com/geniusrabbit/blaze-api/repository/directaccesstoken/models" ) +// Repository handles direct access token database operations. type Repository struct { repository.Repository } -// New direct access token repository -func New() *Repository { +// NewDirectAccessTokenRepository creates and returns a new direct access token repository instance. +func NewDirectAccessTokenRepository() *Repository { return &Repository{} } -// Get returns direct access token model by ID -func (r *Repository) Get(ctx context.Context, id uint64) (*model.DirectAccessToken, error) { - object := new(model.DirectAccessToken) +// Get retrieves a non-expired direct access token by ID. +func (r *Repository) Get(ctx context.Context, id uint64) (*models.DirectAccessToken, error) { + object := new(models.DirectAccessToken) err := r.Slave(ctx).Model(object). Find(object, "id=? AND expires_at>NOW()", id).Error if err != nil { @@ -30,9 +31,9 @@ func (r *Repository) Get(ctx context.Context, id uint64) (*model.DirectAccessTok return object, nil } -// GetByToken returns direct access token model by Token -func (r *Repository) GetByToken(ctx context.Context, token string) (*model.DirectAccessToken, error) { - object := new(model.DirectAccessToken) +// GetByToken retrieves a non-expired direct access token by its token value. +func (r *Repository) GetByToken(ctx context.Context, token string) (*models.DirectAccessToken, error) { + object := new(models.DirectAccessToken) err := r.Slave(ctx).Model(object). Find(object, "token=? AND expires_at>NOW()", token).Error if err != nil { @@ -41,13 +42,11 @@ func (r *Repository) GetByToken(ctx context.Context, token string) (*model.Direc return object, nil } -// FetchList returns list of direct access tokens -func (r *Repository) FetchList(ctx context.Context, filter *directaccesstoken.Filter, order *directaccesstoken.Order, page *repository.Pagination) ([]*model.DirectAccessToken, error) { - objects := make([]*model.DirectAccessToken, 0) - query := r.Slave(ctx).Model(&model.DirectAccessToken{}) - query = filter.PrepareQuery(query) - query = order.PrepareQuery(query) - query = page.PrepareQuery(query) +// FetchList retrieves a paginated list of direct access tokens with optional filtering and ordering. +func (r *Repository) FetchList(ctx context.Context, opts ...directaccesstoken.QOption) ([]*models.DirectAccessToken, error) { + objects := make([]*models.DirectAccessToken, 0) + query := r.Slave(ctx).Model(&models.DirectAccessToken{}) + query = directaccesstoken.ListOptions(opts).PrepareQuery(query) err := query.Find(&objects).Error if err != nil { return nil, err @@ -55,11 +54,11 @@ func (r *Repository) FetchList(ctx context.Context, filter *directaccesstoken.Fi return objects, nil } -// Count returns count of direct access tokens -func (r *Repository) Count(ctx context.Context, filter *directaccesstoken.Filter) (int64, error) { +// Count returns the total number of direct access tokens matching the filter criteria. +func (r *Repository) Count(ctx context.Context, opts ...directaccesstoken.QOption) (int64, error) { var count int64 - query := r.Slave(ctx).Model(&model.DirectAccessToken{}) - query = filter.PrepareQuery(query) + query := r.Slave(ctx).Model(&models.DirectAccessToken{}) + query = directaccesstoken.ListOptions(opts).PrepareQuery(query) err := query.Count(&count).Error if err != nil { return 0, err @@ -67,14 +66,14 @@ func (r *Repository) Count(ctx context.Context, filter *directaccesstoken.Filter return count, nil } -// Generate creates a new direct access token -func (r *Repository) Generate(ctx context.Context, userID, accountID uint64, description string, expiresAt time.Time) (*model.DirectAccessToken, error) { +// Generate creates and stores a new direct access token with the specified parameters. +func (r *Repository) Generate(ctx context.Context, userID, accountID uint64, description string, expiresAt time.Time) (*models.DirectAccessToken, error) { token, err := directaccesstoken.GenerateToken(32) if err != nil { return nil, err } - object := &model.DirectAccessToken{ + object := &models.DirectAccessToken{ Token: token, Description: description, UserID: sql.Null[uint64]{V: userID, Valid: userID > 0}, @@ -90,9 +89,9 @@ func (r *Repository) Generate(ctx context.Context, userID, accountID uint64, des return object, nil } -// Revoke access tokens -func (r *Repository) Revoke(ctx context.Context, filter *directaccesstoken.Filter) error { - query := r.Master(ctx).Model(&model.DirectAccessToken{}) - query = filter.PrepareQuery(query) +// Revoke invalidates direct access tokens by setting their expiration to the past. +func (r *Repository) Revoke(ctx context.Context, opts ...directaccesstoken.QOption) error { + query := r.Master(ctx).Model(&models.DirectAccessToken{}) + query = directaccesstoken.ListOptions(opts).PrepareQuery(query) return query.UpdateColumn("expires_at", time.Now().Add(-time.Hour)).Error } diff --git a/repository/directaccesstoken/usecase.go b/repository/directaccesstoken/usecase.go index 9fdd0a56..ae80e267 100644 --- a/repository/directaccesstoken/usecase.go +++ b/repository/directaccesstoken/usecase.go @@ -3,16 +3,24 @@ package directaccesstoken import ( "context" "time" - - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" ) //go:generate mockgen -source $GOFILE -package mocks -destination mocks/usecase.go + +// Usecase defines the business logic operations for direct access tokens. type Usecase interface { - Get(ctx context.Context, id uint64) (*model.DirectAccessToken, error) - FetchList(ctx context.Context, filter *Filter, order *Order, page *repository.Pagination) ([]*model.DirectAccessToken, error) - Count(ctx context.Context, filter *Filter) (int64, error) - Generate(ctx context.Context, userID, accountID uint64, description string, expiresAt time.Time) (*model.DirectAccessToken, error) - Revoke(ctx context.Context, filter *Filter) error + // Get retrieves a direct access token by its ID. + Get(ctx context.Context, id uint64) (*DirectAccessToken, error) + + // FetchList retrieves a list of direct access tokens with optional filtering, ordering, and pagination. + FetchList(ctx context.Context, opts ...QOption) ([]*DirectAccessToken, error) + + // Count returns the total number of direct access tokens matching the query options. + Count(ctx context.Context, opts ...QOption) (int64, error) + + // Generate creates a new direct access token for the specified user and account. + Generate(ctx context.Context, userID, accountID uint64, description string, expiresAt time.Time) (*DirectAccessToken, error) + + // Revoke deactivates direct access tokens matching the query options. + Revoke(ctx context.Context, opts ...QOption) error } diff --git a/repository/directaccesstoken/usecase/usecase.go b/repository/directaccesstoken/usecase/usecase.go index 8f5c351d..7674a300 100644 --- a/repository/directaccesstoken/usecase/usecase.go +++ b/repository/directaccesstoken/usecase/usecase.go @@ -7,24 +7,24 @@ import ( "github.com/pkg/errors" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/acl" "github.com/geniusrabbit/blaze-api/pkg/context/session" - "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/directaccesstoken" + "github.com/geniusrabbit/blaze-api/repository/directaccesstoken/models" ) +// Usecase handles business logic for direct access tokens. type Usecase struct { repo directaccesstoken.Repository } -// New direct access token usecase +// New creates a new direct access token usecase instance. func New(repo directaccesstoken.Repository) *Usecase { return &Usecase{repo: repo} } -// Get direct access token by token -func (u *Usecase) Get(ctx context.Context, id uint64) (*model.DirectAccessToken, error) { +// Get retrieves a direct access token by ID with permission checks. +func (u *Usecase) Get(ctx context.Context, id uint64) (*models.DirectAccessToken, error) { accToken, err := u.repo.Get(ctx, id) if err != nil { return nil, err @@ -35,33 +35,33 @@ func (u *Usecase) Get(ctx context.Context, id uint64) (*model.DirectAccessToken, return accToken, nil } -// FetchList of direct access tokens -func (u *Usecase) FetchList(ctx context.Context, filter *directaccesstoken.Filter, order *directaccesstoken.Order, page *repository.Pagination) ([]*model.DirectAccessToken, error) { - if !acl.HaveAccessList(ctx, &model.DirectAccessToken{}) { +// FetchList retrieves a filtered and paginated list of direct access tokens. +func (u *Usecase) FetchList(ctx context.Context, opts ...directaccesstoken.QOption) ([]*models.DirectAccessToken, error) { + if !acl.HaveAccessList(ctx, &models.DirectAccessToken{}) { acc := session.Account(ctx) - if !acl.HaveAccessList(ctx, &model.DirectAccessToken{AccountID: acc.ID}) { + if !acl.HaveAccessList(ctx, &models.DirectAccessToken{AccountID: acc.ID}) { return nil, errors.Wrap(acl.ErrNoPermissions, "list access tokens") } - filter.AccountID = []uint64{acc.ID} + opts, _ = directaccesstoken.ListOptions(opts).WithPermissions(ctx, &directaccesstoken.Filter{}) } - return u.repo.FetchList(ctx, filter, order, page) + return u.repo.FetchList(ctx, opts...) } -// Count of direct access tokens -func (u *Usecase) Count(ctx context.Context, filter *directaccesstoken.Filter) (int64, error) { - if !acl.HaveAccessCount(ctx, &model.DirectAccessToken{}) { +// Count returns the total count of direct access tokens matching the filter. +func (u *Usecase) Count(ctx context.Context, opts ...directaccesstoken.QOption) (int64, error) { + if !acl.HaveAccessCount(ctx, &models.DirectAccessToken{}) { acc := session.Account(ctx) - if !acl.HaveAccessCount(ctx, &model.DirectAccessToken{AccountID: acc.ID}) { + if !acl.HaveAccessCount(ctx, &models.DirectAccessToken{AccountID: acc.ID}) { return 0, errors.Wrap(acl.ErrNoPermissions, "count access tokens") } - filter.AccountID = []uint64{acc.ID} + opts, _ = directaccesstoken.ListOptions(opts).WithPermissions(ctx, &directaccesstoken.Filter{}) } - return u.repo.Count(ctx, filter) + return u.repo.Count(ctx, opts...) } -// Generate access token -func (u *Usecase) Generate(ctx context.Context, userID, accountID uint64, description string, expiresAt time.Time) (*model.DirectAccessToken, error) { - if !acl.HaveAccessCreate(ctx, &model.DirectAccessToken{ +// Generate creates a new direct access token. +func (u *Usecase) Generate(ctx context.Context, userID, accountID uint64, description string, expiresAt time.Time) (*models.DirectAccessToken, error) { + if !acl.HaveAccessCreate(ctx, &models.DirectAccessToken{ UserID: sql.Null[uint64]{V: userID, Valid: userID > 0}, AccountID: accountID, }) { @@ -70,14 +70,14 @@ func (u *Usecase) Generate(ctx context.Context, userID, accountID uint64, descri return u.repo.Generate(ctx, userID, accountID, description, expiresAt) } -// Revoke access tokens -func (u *Usecase) Revoke(ctx context.Context, filter *directaccesstoken.Filter) error { - if !acl.HaveAccessDelete(ctx, &model.DirectAccessToken{}) { +// Revoke revokes direct access tokens matching the filter criteria. +func (u *Usecase) Revoke(ctx context.Context, opts ...directaccesstoken.QOption) error { + if !acl.HaveAccessDelete(ctx, &models.DirectAccessToken{}) { acc := session.Account(ctx) - if !acl.HaveAccessList(ctx, &model.DirectAccessToken{AccountID: acc.ID}) { + if !acl.HaveAccessList(ctx, &models.DirectAccessToken{AccountID: acc.ID}) { return errors.Wrap(acl.ErrNoPermissions, "revoke access tokens") } - filter.AccountID = []uint64{acc.ID} + opts, _ = directaccesstoken.ListOptions(opts).WithPermissions(ctx, &directaccesstoken.Filter{}) } - return u.repo.Revoke(ctx, filter) + return u.repo.Revoke(ctx, opts...) } diff --git a/repository/generated/model.go b/repository/generated/model.go index a63a0129..1d597cd9 100644 --- a/repository/generated/model.go +++ b/repository/generated/model.go @@ -3,99 +3,126 @@ package generated import ( "time" - "github.com/geniusrabbit/blaze-api/model" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" ) -// ModelIDGetter defines an interface for models that can return their ID -type ModelIDGetter[TID any] interface { +// Model is the compile-time constraint for types used with Repository[T, TID] and Usecase[T, TID]. +// T must expose its primary key via a value receiver so that T itself (not *T) satisfies the constraint. +type Model[TID comparable] interface { GetID() TID } -// getModelID extracts the ID from a model that implements ModelIDGetter -// Returns zero value if the model doesn't implement the interface -// -//go:inline -func getModelID[TID any](obj any) TID { - switch v := obj.(type) { - case ModelIDGetter[TID]: +// getModelID extracts the ID from obj by asserting it to Model[TID]. +// Returns zero value of TID if the assertion fails. +func getModelID[TID comparable](obj any) TID { + if v, ok := obj.(Model[TID]); ok { return v.GetID() } return *new(TID) } -// ModelIDFieldGetter defines an interface for models that can return their ID field name +// ModelIDFieldGetter defines an interface for models that can override the primary key column name. type ModelIDFieldGetter interface { GetIDField() string } -// getModelIDField extracts the ID field name from a model that implements ModelIDFieldGetter -// Returns empty string if the model doesn't implement the interface -// -//go:inline +// getModelIDField returns the primary key column name for obj. +// Defaults to "id" if the model does not implement ModelIDFieldGetter. func getModelIDField(obj any) string { - switch v := obj.(type) { - case ModelIDFieldGetter: + if v, ok := obj.(ModelIDFieldGetter); ok { return v.GetIDField() } return "id" } -// ModelIDSetter defines an interface for models that can set their ID +// ModelIDSetter defines an interface for models that can set their primary key. type ModelIDSetter[TID any] interface { SetID(id TID) } -// setModelID sets the ID on a model that implements ModelIDSetter -// -//go:inline +// setModelID sets the ID on obj by asserting it to ModelIDSetter[TID]. +// No-op if obj does not implement ModelIDSetter[TID]. func setModelID[TID any](obj any, id TID) { - switch v := obj.(type) { - case ModelIDSetter[TID]: + if v, ok := obj.(ModelIDSetter[TID]); ok { v.SetID(id) } } -// ModelCreateTimeSetter defines an interface for models that can set their creation time +// ModelCreateTimeSetter defines an interface for models that can set their creation time. type ModelCreateTimeSetter interface { SetCreatedAt(time.Time) } -// setModelCreatedAt sets the creation time on a model that implements ModelCreateTimeSetter -// -//go:inline +// setModelCreatedAt sets the creation time on obj. +// No-op if obj does not implement ModelCreateTimeSetter. func setModelCreatedAt(obj any, t time.Time) { - switch v := obj.(type) { - case ModelCreateTimeSetter: + if v, ok := obj.(ModelCreateTimeSetter); ok { v.SetCreatedAt(t) } } -// ModelUpdateTimeSetter defines an interface for models that can set their update time +// ModelUpdateTimeSetter defines an interface for models that can set their update time. type ModelUpdateTimeSetter interface { SetUpdatedAt(time.Time) } -// setModelUpdatedAt sets the update time on a model that implements ModelUpdateTimeSetter -// -//go:inline +// setModelUpdatedAt sets the update time on obj. +// No-op if obj does not implement ModelUpdateTimeSetter. func setModelUpdatedAt(obj any, t time.Time) { - switch v := obj.(type) { - case ModelUpdateTimeSetter: + if v, ok := obj.(ModelUpdateTimeSetter); ok { v.SetUpdatedAt(t) } } -// ModelApproveStatusSetter defines an interface for models that can set their approval status +// ModelApproveStatusSetter defines an interface for models that support an approval workflow. type ModelApproveStatusSetter interface { - SetApproveStatus(status model.ApproveStatus) + SetApproveStatus(status pkgModels.ApproveStatus) } -// setModelApproveStatus sets the approval status on a model that implements ModelApproveStatusSetter -// -//go:inline -func setModelApproveStatus(obj any, status model.ApproveStatus) { - switch v := obj.(type) { - case ModelApproveStatusSetter: +// setModelApproveStatus sets the approval status on obj. +// No-op if obj does not implement ModelApproveStatusSetter. +func setModelApproveStatus(obj any, status pkgModels.ApproveStatus) { + if v, ok := obj.(ModelApproveStatusSetter); ok { v.SetApproveStatus(status) } } + +// BaseModel is a convenience embed for domain models used with Repository[T, TID] and Usecase[T, TID]. +// It provides GetID (value receiver, satisfies Model[TID] constraint) and SetID implementations. +// +// Usage: +// +// type MyModel struct { +// generated.BaseModel[uint64] +// Name string +// } +type BaseModel[TID comparable] struct { + ID TID `gorm:"primaryKey" db:"id"` +} + +// GetID returns the model's primary key. +// Value receiver ensures MyModel (not *MyModel) satisfies the Model[TID] constraint. +func (m BaseModel[TID]) GetID() TID { return m.ID } + +// SetID sets the model's primary key. +func (m *BaseModel[TID]) SetID(id TID) { m.ID = id } + +// BaseTimestamps is a convenience embed providing SetCreatedAt and SetUpdatedAt. +// +// Usage: +// +// type MyModel struct { +// generated.BaseModel[uint64] +// generated.BaseTimestamps +// gorm.DeletedAt +// } +type BaseTimestamps struct { + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` +} + +// SetCreatedAt sets the creation timestamp. +func (m *BaseTimestamps) SetCreatedAt(t time.Time) { m.CreatedAt = t } + +// SetUpdatedAt sets the update timestamp. +func (m *BaseTimestamps) SetUpdatedAt(t time.Time) { m.UpdatedAt = t } diff --git a/repository/generated/model_test.go b/repository/generated/model_test.go new file mode 100644 index 00000000..0f9a601d --- /dev/null +++ b/repository/generated/model_test.go @@ -0,0 +1,209 @@ +package generated + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" +) + +// --------------------------------------------------------------------------- +// Helpers — minimal in-test models +// --------------------------------------------------------------------------- + +// idModel implements Model[uint64] (value receiver) + ModelIDSetter[uint64]. +type idModel struct { + ID uint64 +} + +func (m idModel) GetID() uint64 { return m.ID } +func (m *idModel) SetID(v uint64) { m.ID = v } + +// stringIDModel uses string as TID. +type stringIDModel struct { + ID string +} + +func (m stringIDModel) GetID() string { return m.ID } +func (m *stringIDModel) SetID(v string) { m.ID = v } + +// customFieldModel overrides the primary key column name. +type customFieldModel struct{} + +func (m customFieldModel) GetID() uint64 { return 0 } +func (m customFieldModel) GetIDField() string { return "custom_id" } + +// timestampModel implements both time setters. +type timestampModel struct { + Created time.Time + Updated time.Time +} + +func (m *timestampModel) SetCreatedAt(t time.Time) { m.Created = t } +func (m *timestampModel) SetUpdatedAt(t time.Time) { m.Updated = t } + +// approveModel implements ModelApproveStatusSetter. +type approveModel struct { + Status pkgModels.ApproveStatus +} + +func (m *approveModel) SetApproveStatus(s pkgModels.ApproveStatus) { m.Status = s } + +// plainModel implements none of the optional interfaces. +type plainModel struct{ Val int } + +// --------------------------------------------------------------------------- +// BaseModel +// --------------------------------------------------------------------------- + +func TestBaseModel_GetID(t *testing.T) { + m := BaseModel[uint64]{ID: 42} + assert.Equal(t, uint64(42), m.GetID()) +} + +func TestBaseModel_SetID(t *testing.T) { + m := BaseModel[uint64]{} + m.SetID(99) + assert.Equal(t, uint64(99), m.ID) +} + +func TestBaseModel_StringTID(t *testing.T) { + m := BaseModel[string]{ID: "abc"} + assert.Equal(t, "abc", m.GetID()) + m.SetID("xyz") + assert.Equal(t, "xyz", m.ID) +} + +// Value receiver satisfies Model[TID] — T (not *T) can be used as constraint. +func TestBaseModel_ValueReceiverSatisfiesConstraint(t *testing.T) { + var _ Model[uint64] = BaseModel[uint64]{} + var _ Model[string] = BaseModel[string]{} +} + +// --------------------------------------------------------------------------- +// BaseTimestamps +// --------------------------------------------------------------------------- + +func TestBaseTimestamps_SetCreatedAt(t *testing.T) { + m := &BaseTimestamps{} + ts := time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC) + m.SetCreatedAt(ts) + assert.Equal(t, ts, m.CreatedAt) +} + +func TestBaseTimestamps_SetUpdatedAt(t *testing.T) { + m := &BaseTimestamps{} + ts := time.Date(2024, 6, 1, 12, 0, 0, 0, time.UTC) + m.SetUpdatedAt(ts) + assert.Equal(t, ts, m.UpdatedAt) +} + +// --------------------------------------------------------------------------- +// getModelID +// --------------------------------------------------------------------------- + +func TestGetModelID_WithInterface(t *testing.T) { + m := &idModel{ID: 7} + assert.Equal(t, uint64(7), getModelID[uint64](m)) +} + +func TestGetModelID_ValueReceiver(t *testing.T) { + // value receiver: both T and *T satisfy Model[TID] + m := idModel{ID: 3} + assert.Equal(t, uint64(3), getModelID[uint64](m)) +} + +func TestGetModelID_StringID(t *testing.T) { + m := &stringIDModel{ID: "hello"} + assert.Equal(t, "hello", getModelID[string](m)) +} + +func TestGetModelID_NoInterface_ReturnsZero(t *testing.T) { + m := &plainModel{Val: 5} + assert.Equal(t, uint64(0), getModelID[uint64](m)) +} + +// --------------------------------------------------------------------------- +// setModelID +// --------------------------------------------------------------------------- + +func TestSetModelID_WithInterface(t *testing.T) { + m := &idModel{} + setModelID(m, uint64(55)) + assert.Equal(t, uint64(55), m.ID) +} + +func TestSetModelID_NoInterface_NoOp(t *testing.T) { + m := &plainModel{Val: 1} + // Must not panic; Val must remain unchanged. + setModelID(m, uint64(99)) + assert.Equal(t, 1, m.Val) +} + +// --------------------------------------------------------------------------- +// getModelIDField +// --------------------------------------------------------------------------- + +func TestGetModelIDField_Default(t *testing.T) { + assert.Equal(t, "id", getModelIDField(&plainModel{})) +} + +func TestGetModelIDField_Custom(t *testing.T) { + assert.Equal(t, "custom_id", getModelIDField(&customFieldModel{})) +} + +// --------------------------------------------------------------------------- +// setModelCreatedAt +// --------------------------------------------------------------------------- + +func TestSetModelCreatedAt_WithInterface(t *testing.T) { + m := ×tampModel{} + ts := time.Now() + setModelCreatedAt(m, ts) + assert.Equal(t, ts, m.Created) +} + +func TestSetModelCreatedAt_NoInterface_NoOp(t *testing.T) { + m := &plainModel{} + assert.NotPanics(t, func() { + setModelCreatedAt(m, time.Now()) + }) +} + +// --------------------------------------------------------------------------- +// setModelUpdatedAt +// --------------------------------------------------------------------------- + +func TestSetModelUpdatedAt_WithInterface(t *testing.T) { + m := ×tampModel{} + ts := time.Now() + setModelUpdatedAt(m, ts) + assert.Equal(t, ts, m.Updated) +} + +func TestSetModelUpdatedAt_NoInterface_NoOp(t *testing.T) { + m := &plainModel{} + assert.NotPanics(t, func() { + setModelUpdatedAt(m, time.Now()) + }) +} + +// --------------------------------------------------------------------------- +// setModelApproveStatus +// --------------------------------------------------------------------------- + +func TestSetModelApproveStatus_WithInterface(t *testing.T) { + m := &approveModel{} + setModelApproveStatus(m, pkgModels.ApprovedApproveStatus) + assert.Equal(t, pkgModels.ApprovedApproveStatus, m.Status) +} + +func TestSetModelApproveStatus_NoInterface_NoOp(t *testing.T) { + m := &plainModel{Val: 2} + assert.NotPanics(t, func() { + setModelApproveStatus(m, pkgModels.ApprovedApproveStatus) + }) + assert.Equal(t, 2, m.Val) +} diff --git a/repository/generated/repository_approver_db_gen.go b/repository/generated/repository_approver_db_gen.go index e015eedf..4daea362 100644 --- a/repository/generated/repository_approver_db_gen.go +++ b/repository/generated/repository_approver_db_gen.go @@ -3,7 +3,7 @@ package generated import ( "context" - "github.com/geniusrabbit/blaze-api/model" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/historylog" ) @@ -21,7 +21,7 @@ func (r *RepositoryApprover[T, TID]) Approve(ctx context.Context, id TID, messag historylog.WithMessage(ctx, message), ).Model((*T)(nil)). Where(r.IDName+"=?", id). - Update(r.StatusName, model.ApprovedApproveStatus).Error + Update(r.StatusName, pkgModels.ApprovedApproveStatus).Error } // Reject rejects an entity by ID @@ -30,5 +30,5 @@ func (r *RepositoryApprover[T, TID]) Reject(ctx context.Context, id TID, message historylog.WithMessage(ctx, message), ).Model((*T)(nil)). Where(r.IDName+"=?", id). - Update(r.StatusName, model.DisapprovedApproveStatus).Error + Update(r.StatusName, pkgModels.DisapprovedApproveStatus).Error } diff --git a/repository/generated/repository_db_gen.go b/repository/generated/repository_db_gen.go index 926e3658..d589f3ed 100644 --- a/repository/generated/repository_db_gen.go +++ b/repository/generated/repository_db_gen.go @@ -5,19 +5,17 @@ import ( "errors" "time" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/repository" - "github.com/geniusrabbit/blaze-api/repository/historylog" "gorm.io/gorm" ) -type Repository[T any, TID any] struct { +type Repository[T Model[TID], TID comparable] struct { repository.Repository idField string } // NewRepository creates a new repository instance -func NewRepository[T any, TID any]() *Repository[T, TID] { +func NewRepository[T Model[TID], TID comparable]() *Repository[T, TID] { return &Repository[T, TID]{idField: getModelIDField(new(T))} } @@ -53,30 +51,27 @@ func (r *Repository[T, TID]) Count(ctx context.Context, qops ...Option) (count i } // Create creates a new campaign -func (r *Repository[T, TID]) Create(ctx context.Context, obj *T, message string) (TID, error) { +func (r *Repository[T, TID]) Create(ctx context.Context, obj *T, opts ...Option) (TID, error) { setModelCreatedAt(obj, time.Now()) - setModelApproveStatus(obj, model.ApproveStatus(model.PendingApproveStatus)) - db := r.Master(historylog.WithMessage(ctx, message)) + db := Options(opts).PrepareQuery(r.Master(ctx)) err := db.Create(obj).Error return getModelID[TID](obj), err } // Update updates an existing campaign -func (r *Repository[T, TID]) Update(ctx context.Context, id TID, obj *T, message string) error { +func (r *Repository[T, TID]) Update(ctx context.Context, id TID, obj *T, opts ...Option) error { newObj := *obj setModelID(&newObj, id) setModelUpdatedAt(&newObj, time.Now()) - db := r.Master(historylog.WithMessage(ctx, message)) - if err := db.Save(&newObj).Error; err != nil { + db := Options(opts).PrepareQuery(r.Master(ctx)) + if err := db.Updates(&newObj).Error; err != nil { return err } return nil } // Delete deletes a campaign by ID -func (r *Repository[T, TID]) Delete(ctx context.Context, id TID, message string) error { +func (r *Repository[T, TID]) Delete(ctx context.Context, id TID, opts ...Option) error { obj := new(T) - return r.Master( - historylog.WithMessage(ctx, message), - ).Delete(obj, r.idField+`=?`, id).Error + return Options(opts).PrepareQuery(r.Master(ctx)).Delete(obj, r.idField+`=?`, id).Error } diff --git a/repository/generated/repository_iface.go b/repository/generated/repository_iface.go index dc26fc4b..db8ff036 100644 --- a/repository/generated/repository_iface.go +++ b/repository/generated/repository_iface.go @@ -12,21 +12,21 @@ type ( Options = repository.ListOptions ) -type RepositoryIface[T any, TID any] interface { +type RepositoryIface[T Model[TID], TID comparable] interface { Get(ctx context.Context, id TID, qops ...Option) (*T, error) FetchList(ctx context.Context, qops ...Option) ([]*T, error) Count(ctx context.Context, qops ...Option) (int64, error) - Create(ctx context.Context, obj *T, message string) (TID, error) - Update(ctx context.Context, id TID, obj *T, message string) error - Delete(ctx context.Context, id TID, message string) error + Create(ctx context.Context, obj *T, opts ...Option) (TID, error) + Update(ctx context.Context, id TID, obj *T, opts ...Option) error + Delete(ctx context.Context, id TID, opts ...Option) error } -type RepositoryApproveIface[TID any] interface { - Approve(ctx context.Context, id TID, message string) error - Reject(ctx context.Context, id TID, message string) error +type RepositoryApproveIface[TID comparable] interface { + Approve(ctx context.Context, id TID, opts ...Option) error + Reject(ctx context.Context, id TID, opts ...Option) error } -type RepositoryIfaceWithApprove[T any, TID any] interface { +type RepositoryIfaceWithApprove[T Model[TID], TID comparable] interface { RepositoryIface[T, TID] RepositoryApproveIface[TID] } diff --git a/repository/generated/usecase_appove_db_gen.go b/repository/generated/usecase_appove_db_gen.go index f0f588eb..330b827d 100644 --- a/repository/generated/usecase_appove_db_gen.go +++ b/repository/generated/usecase_appove_db_gen.go @@ -7,12 +7,12 @@ import ( ) // UsecaseApprover provides approve/reject usecase methods -type UsecaseApprover[T any, TID any] struct { +type UsecaseApprover[T Model[TID], TID comparable] struct { Repo RepositoryIfaceWithApprove[T, TID] } // Approve approves an entity by ID with ACL permission check -func (u *UsecaseApprover[T, TID]) Approve(ctx context.Context, id TID, message string) error { +func (u *UsecaseApprover[T, TID]) Approve(ctx context.Context, id TID, opts ...Option) error { // Fetch existing entity to check permissions existingObj, err := u.Repo.Get(ctx, id) if err != nil { @@ -23,11 +23,11 @@ func (u *UsecaseApprover[T, TID]) Approve(ctx context.Context, id TID, message s if !acl.HaveAccessApprove(ctx, existingObj) { return acl.ErrNoPermissions.WithMessage("approve") } - return u.Repo.Approve(ctx, id, message) + return u.Repo.Approve(ctx, id, opts...) } // Reject rejects an entity by ID with ACL permission check -func (u *UsecaseApprover[T, TID]) Reject(ctx context.Context, id TID, message string) error { +func (u *UsecaseApprover[T, TID]) Reject(ctx context.Context, id TID, opts ...Option) error { // Fetch existing entity to check permissions existingObj, err := u.Repo.Get(ctx, id) if err != nil { @@ -35,8 +35,8 @@ func (u *UsecaseApprover[T, TID]) Reject(ctx context.Context, id TID, message st } // Check if user has reject permissions for the existing entity - if !acl.HaveAccessApprove(ctx, existingObj) { + if !acl.HaveAccessReject(ctx, existingObj) { return acl.ErrNoPermissions.WithMessage("reject") } - return u.Repo.Reject(ctx, id, message) + return u.Repo.Reject(ctx, id, opts...) } diff --git a/repository/generated/usecase_db_gen.go b/repository/generated/usecase_db_gen.go index b7d34be9..231e1d00 100644 --- a/repository/generated/usecase_db_gen.go +++ b/repository/generated/usecase_db_gen.go @@ -4,12 +4,13 @@ import ( "context" "github.com/geniusrabbit/blaze-api/pkg/acl" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/go-faster/errors" ) // Usecase provides a generic business logic layer with ACL (Access Control List) support // for CRUD operations on entities of type T with ID type TID. -type Usecase[T any, TID any] struct { +type Usecase[T Model[TID], TID comparable] struct { Repo RepositoryIface[T, TID] // Repository interface for data access operations } @@ -60,18 +61,21 @@ func (u *Usecase[T, TID]) Count(ctx context.Context, qops ...Option) (int64, err } // Create creates a new entity with ACL permission check. +// Sets the initial approval status to Pending before delegating to the repository. // Returns the ID of the created entity if successful. -func (u *Usecase[T, TID]) Create(ctx context.Context, obj *T, message string) (id TID, err error) { +func (u *Usecase[T, TID]) Create(ctx context.Context, obj *T, opts ...Option) (id TID, err error) { // Check if user has create permissions for this entity if !acl.HaveAccessCreate(ctx, obj) { return id, acl.ErrNoPermissions.WithMessage("create") } - return u.Repo.Create(ctx, obj, message) + // New entities start in Pending status (no-op for models without approval workflow). + setModelApproveStatus(obj, pkgModels.PendingApproveStatus) + return u.Repo.Create(ctx, obj, opts...) } // Update modifies an existing entity with ACL permission check. // Fetches the existing entity first to verify update permissions. -func (u *Usecase[T, TID]) Update(ctx context.Context, id TID, obj *T, message string) error { +func (u *Usecase[T, TID]) Update(ctx context.Context, id TID, obj *T, opts ...Option) error { // Fetch existing entity to check permissions existingObj, err := u.Repo.Get(ctx, id) if err != nil { @@ -82,12 +86,12 @@ func (u *Usecase[T, TID]) Update(ctx context.Context, id TID, obj *T, message st if !acl.HaveAccessUpdate(ctx, existingObj) { return acl.ErrNoPermissions.WithMessage("update") } - return u.Repo.Update(ctx, id, obj, message) + return u.Repo.Update(ctx, id, obj, opts...) } // Delete removes an entity with ACL permission check. // Fetches the existing entity first to verify delete permissions. -func (u *Usecase[T, TID]) Delete(ctx context.Context, id TID, message string) error { +func (u *Usecase[T, TID]) Delete(ctx context.Context, id TID, opts ...Option) error { // Fetch existing entity to check permissions existingObj, err := u.Repo.Get(ctx, id) if err != nil { @@ -98,5 +102,5 @@ func (u *Usecase[T, TID]) Delete(ctx context.Context, id TID, message string) er if !acl.HaveAccessDelete(ctx, existingObj) { return acl.ErrNoPermissions.WithMessage("delete") } - return u.Repo.Delete(ctx, id, message) + return u.Repo.Delete(ctx, id, opts...) } diff --git a/repository/generated/usecase_iface.go b/repository/generated/usecase_iface.go index fe076121..9dff1529 100644 --- a/repository/generated/usecase_iface.go +++ b/repository/generated/usecase_iface.go @@ -2,16 +2,16 @@ package generated import "context" -type UsecaseIface[T any, TID any] interface { +type UsecaseIface[T Model[TID], TID comparable] interface { Get(ctx context.Context, id TID, qops ...Option) (*T, error) FetchList(ctx context.Context, qops ...Option) ([]*T, error) Count(ctx context.Context, qops ...Option) (int64, error) - Create(ctx context.Context, obj *T, message string) (TID, error) - Update(ctx context.Context, id TID, obj *T, message string) error - Delete(ctx context.Context, id TID, message string) error + Create(ctx context.Context, obj *T, opts ...Option) (TID, error) + Update(ctx context.Context, id TID, obj *T, opts ...Option) error + Delete(ctx context.Context, id TID, opts ...Option) error } -type UsecaseApproveIface[TID any] interface { - Approve(ctx context.Context, id TID, message string) error - Reject(ctx context.Context, id TID, message string) error +type UsecaseApproveIface[TID comparable] interface { + Approve(ctx context.Context, id TID, opts ...Option) error + Reject(ctx context.Context, id TID, opts ...Option) error } diff --git a/repository/historylog/delivery/graphql/connector.go b/repository/historylog/delivery/graphql/connector.go new file mode 100644 index 00000000..5b0e3869 --- /dev/null +++ b/repository/historylog/delivery/graphql/connector.go @@ -0,0 +1,33 @@ +package graphql + +import ( + "context" + + "github.com/demdxx/gocast/v2" + + "github.com/geniusrabbit/blaze-api/repository/historylog" + "github.com/geniusrabbit/blaze-api/server/graphql/connectors" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" +) + +// HistoryActionConnection implements collection accessor interface with pagination +type HistoryActionConnection = connectors.CollectionConnection[gqlmodels.HistoryAction, gqlmodels.HistoryActionEdge] + +// NewHistoryActionConnection based on query object +func NewHistoryActionConnection(ctx context.Context, historyActionsAccessor historylog.Usecase, filter *gqlmodels.HistoryActionListFilter, order *gqlmodels.HistoryActionListOrder, page *gqlmodels.Page) *HistoryActionConnection { + return connectors.NewCollectionConnection(ctx, &connectors.DataAccessorFunc[gqlmodels.HistoryAction, gqlmodels.HistoryActionEdge]{ + FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.HistoryAction, error) { + historyActions, err := historyActionsAccessor.FetchList(ctx, HistoryActionFilter(filter), HistoryActionOrder(order), page.Pagination()) + return FromHistoryActionModelList(historyActions), err + }, + CountDataFunc: func(ctx context.Context) (int64, error) { + return historyActionsAccessor.Count(ctx, HistoryActionFilter(filter)) + }, + ConvertToEdgeFunc: func(obj *gqlmodels.HistoryAction) *gqlmodels.HistoryActionEdge { + return &gqlmodels.HistoryActionEdge{ + Cursor: gocast.Str(obj.ID), + Node: obj, + } + }, + }, page) +} diff --git a/protocol/graphql/schemas/history.graphql b/repository/historylog/delivery/graphql/history.graphql similarity index 100% rename from protocol/graphql/schemas/history.graphql rename to repository/historylog/delivery/graphql/history.graphql diff --git a/repository/historylog/delivery/graphql/mapping.go b/repository/historylog/delivery/graphql/mapping.go new file mode 100644 index 00000000..a420dd49 --- /dev/null +++ b/repository/historylog/delivery/graphql/mapping.go @@ -0,0 +1,72 @@ +package graphql + +import ( + "github.com/demdxx/xtypes" + + "github.com/geniusrabbit/blaze-api/repository/historylog" + historylogModels "github.com/geniusrabbit/blaze-api/repository/historylog/models" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" + "github.com/geniusrabbit/blaze-api/server/graphql/types" +) + +// FromHistoryAction converts a historylogModels.HistoryAction to a gqlmodels.HistoryAction. +func FromHistoryAction(action *historylogModels.HistoryAction) *gqlmodels.HistoryAction { + if action == nil { + return nil + } + return &gqlmodels.HistoryAction{ + ID: action.ID, + RequestID: action.RequestID, + Name: action.Name, + Message: action.Message, + + UserID: action.UserID, + AccountID: action.AccountID, + + ObjectID: action.ObjectID, + ObjectIDs: action.ObjectIDs, + ObjectType: action.ObjectType, + Data: *types.MustNullableJSONFrom(&action.Data), + + ActionAt: action.ActionAt, + } +} + +// FromHistoryActionModelList converts a slice of historylogModels.HistoryAction to a slice of gqlmodels.HistoryAction. +func FromHistoryActionModelList(list []*historylogModels.HistoryAction) []*gqlmodels.HistoryAction { + return xtypes.SliceApply(list, FromHistoryAction) +} + +// HistoryActionFilter converts a GraphQL filter to a domain filter. +func HistoryActionFilter(filter *gqlmodels.HistoryActionListFilter) *historylog.Filter { + if filter == nil { + return nil + } + return &historylog.Filter{ + ID: filter.ID, + RequestID: filter.RequestID, + UserID: filter.UserID, + AccountID: filter.AccountID, + ObjectID: filter.ObjectID, + ObjectIDStr: filter.ObjectIDs, + ObjectType: filter.ObjectType, + } +} + +// HistoryActionOrder converts a GraphQL order to a domain order. +func HistoryActionOrder(order *gqlmodels.HistoryActionListOrder) *historylog.Order { + if order == nil { + return nil + } + return &historylog.Order{ + ID: order.ID.AsOrder(), + RequestID: order.RequestID.AsOrder(), + Name: order.Name.AsOrder(), + UserID: order.UserID.AsOrder(), + AccountID: order.AccountID.AsOrder(), + ObjectID: order.ObjectID.AsOrder(), + ObjectIDStr: order.ObjectIDs.AsOrder(), + ObjectType: order.ObjectType.AsOrder(), + ActionAt: order.ActionAt.AsOrder(), + } +} diff --git a/repository/historylog/delivery/graphql/resolver.go b/repository/historylog/delivery/graphql/resolver.go index 4259410c..4cd7ec7e 100644 --- a/repository/historylog/delivery/graphql/resolver.go +++ b/repository/historylog/delivery/graphql/resolver.go @@ -4,10 +4,7 @@ import ( "context" "github.com/geniusrabbit/blaze-api/repository/historylog" - "github.com/geniusrabbit/blaze-api/repository/historylog/repository" - "github.com/geniusrabbit/blaze-api/repository/historylog/usecase" - "github.com/geniusrabbit/blaze-api/server/graphql/connectors" - "github.com/geniusrabbit/blaze-api/server/graphql/models" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) // QueryResolver implements GQL API methods @@ -16,13 +13,11 @@ type QueryResolver struct { } // NewQueryResolver returns new API resolver -func NewQueryResolver() *QueryResolver { - return &QueryResolver{ - uc: usecase.NewUsecase(repository.New()), - } +func NewQueryResolver(uc historylog.Usecase) *QueryResolver { + return &QueryResolver{uc: uc} } // List changelogs is the resolver for the listChangelogs field. -func (r *QueryResolver) List(ctx context.Context, filter *models.HistoryActionListFilter, order *models.HistoryActionListOrder, page *models.Page) (*connectors.HistoryActionConnection, error) { - return connectors.NewHistoryActionConnection(ctx, r.uc, filter, order, page), nil +func (r *QueryResolver) List(ctx context.Context, filter *gqlmodels.HistoryActionListFilter, order *gqlmodels.HistoryActionListOrder, page *gqlmodels.Page) (*HistoryActionConnection, error) { + return NewHistoryActionConnection(ctx, r.uc, filter, order, page), nil } diff --git a/repository/historylog/middleware/gormlog/log.go b/repository/historylog/middleware/gormlog/log.go index 66270b1d..eda78af2 100644 --- a/repository/historylog/middleware/gormlog/log.go +++ b/repository/historylog/middleware/gormlog/log.go @@ -12,11 +12,11 @@ import ( "go.uber.org/zap" "gorm.io/gorm" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" "github.com/geniusrabbit/blaze-api/pkg/context/session" "github.com/geniusrabbit/blaze-api/pkg/requestid" "github.com/geniusrabbit/blaze-api/repository/historylog" + historylogModels "github.com/geniusrabbit/blaze-api/repository/historylog/models" ) // Register gorm callbacks for history log @@ -87,7 +87,7 @@ func Log(db *gorm.DB, name string) func(*gorm.DB) { } // Create history log - err := db.Create(&model.HistoryAction{ + err := db.Create(&historylogModels.HistoryAction{ ID: uuid.New(), RequestID: requestid.Get(ctx), Name: gocast.Or(historylog.ActionFromContext(ctx), name), diff --git a/repository/historylog/mocks/repository.go b/repository/historylog/mocks/repository.go index fee529ae..ea382ac4 100644 --- a/repository/historylog/mocks/repository.go +++ b/repository/historylog/mocks/repository.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: repository.go +// +// Generated by this command: +// +// mockgen -source repository.go -package mocks -destination mocks/repository.go +// // Package mocks is a generated GoMock package. package mocks @@ -8,16 +13,16 @@ import ( context "context" reflect "reflect" - model "github.com/geniusrabbit/blaze-api/model" - repository "github.com/geniusrabbit/blaze-api/repository" historylog "github.com/geniusrabbit/blaze-api/repository/historylog" - gomock "github.com/golang/mock/gomock" + models "github.com/geniusrabbit/blaze-api/repository/historylog/models" + gomock "go.uber.org/mock/gomock" ) // MockRepository is a mock of Repository interface. type MockRepository struct { ctrl *gomock.Controller recorder *MockRepositoryMockRecorder + isgomock struct{} } // MockRepositoryMockRecorder is the mock recorder for MockRepository. @@ -38,31 +43,41 @@ func (m *MockRepository) EXPECT() *MockRepositoryMockRecorder { } // Count mocks base method. -func (m *MockRepository) Count(ctx context.Context, filter *historylog.Filter) (int64, error) { +func (m *MockRepository) Count(ctx context.Context, opts ...historylog.QOption) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockRepositoryMockRecorder) Count(ctx, filter interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Count(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), varargs...) } // FetchList mocks base method. -func (m *MockRepository) FetchList(ctx context.Context, filter *historylog.Filter, order *historylog.Order, pagination *repository.Pagination) ([]*model.HistoryAction, error) { +func (m *MockRepository) FetchList(ctx context.Context, opts ...historylog.QOption) ([]*models.HistoryAction, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter, order, pagination) - ret0, _ := ret[0].([]*model.HistoryAction) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*models.HistoryAction) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockRepositoryMockRecorder) FetchList(ctx, filter, order, pagination interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) FetchList(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), ctx, filter, order, pagination) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), varargs...) } diff --git a/repository/historylog/mocks/usecase.go b/repository/historylog/mocks/usecase.go index 1e3f93a6..e89740c7 100644 --- a/repository/historylog/mocks/usecase.go +++ b/repository/historylog/mocks/usecase.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: usecase.go +// +// Generated by this command: +// +// mockgen -source usecase.go -package mocks -destination mocks/usecase.go +// // Package mocks is a generated GoMock package. package mocks @@ -8,16 +13,16 @@ import ( context "context" reflect "reflect" - model "github.com/geniusrabbit/blaze-api/model" - repository "github.com/geniusrabbit/blaze-api/repository" historylog "github.com/geniusrabbit/blaze-api/repository/historylog" - gomock "github.com/golang/mock/gomock" + models "github.com/geniusrabbit/blaze-api/repository/historylog/models" + gomock "go.uber.org/mock/gomock" ) // MockUsecase is a mock of Usecase interface. type MockUsecase struct { ctrl *gomock.Controller recorder *MockUsecaseMockRecorder + isgomock struct{} } // MockUsecaseMockRecorder is the mock recorder for MockUsecase. @@ -38,31 +43,41 @@ func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder { } // Count mocks base method. -func (m *MockUsecase) Count(ctx context.Context, filter *historylog.Filter) (int64, error) { +func (m *MockUsecase) Count(ctx context.Context, opts ...historylog.QOption) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockUsecaseMockRecorder) Count(ctx, filter interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Count(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), varargs...) } // FetchList mocks base method. -func (m *MockUsecase) FetchList(ctx context.Context, filter *historylog.Filter, order *historylog.Order, pagination *repository.Pagination) ([]*model.HistoryAction, error) { +func (m *MockUsecase) FetchList(ctx context.Context, opts ...historylog.QOption) ([]*models.HistoryAction, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter, order, pagination) - ret0, _ := ret[0].([]*model.HistoryAction) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*models.HistoryAction) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockUsecaseMockRecorder) FetchList(ctx, filter, order, pagination interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) FetchList(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), ctx, filter, order, pagination) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), varargs...) } diff --git a/repository/historylog/models.go b/repository/historylog/models.go new file mode 100644 index 00000000..a5df00e9 --- /dev/null +++ b/repository/historylog/models.go @@ -0,0 +1,5 @@ +package historylog + +import "github.com/geniusrabbit/blaze-api/repository/historylog/models" + +type HistoryAction = models.HistoryAction diff --git a/model/history_action.go b/repository/historylog/models/history_action.go similarity index 99% rename from model/history_action.go rename to repository/historylog/models/history_action.go index 905f21df..41f478c6 100644 --- a/model/history_action.go +++ b/repository/historylog/models/history_action.go @@ -1,4 +1,4 @@ -package model +package models import ( "encoding/json" diff --git a/repository/historylog/options.go b/repository/historylog/options.go new file mode 100644 index 00000000..dcec614e --- /dev/null +++ b/repository/historylog/options.go @@ -0,0 +1,23 @@ +package historylog + +import "gorm.io/gorm" + +// MessageOption is a QOption that injects a historylog message into the DB context. +// It implements repository.QOption via PrepareQuery. +type MessageOption struct { + Msg string +} + +// PrepareQuery adds the message to the gorm DB's context so historylog middleware +// can record it. +func (m *MessageOption) PrepareQuery(q *gorm.DB) *gorm.DB { + if m.Msg == "" { + return q + } + return q.WithContext(WithMessage(q.Statement.Context, m.Msg)) +} + +// Message returns a MessageOption carrying the given historylog message string. +func Message(msg string) *MessageOption { + return &MessageOption{Msg: msg} +} diff --git a/repository/historylog/query.go b/repository/historylog/query.go index 0a78ae66..47dd8269 100644 --- a/repository/historylog/query.go +++ b/repository/historylog/query.go @@ -1,24 +1,27 @@ package historylog import ( - "github.com/geniusrabbit/blaze-api/model" "github.com/google/uuid" "gorm.io/gorm" + + "github.com/geniusrabbit/blaze-api/repository" + "github.com/geniusrabbit/blaze-api/repository/option/models" ) -// Filter of the objects list +// Filter represents query filters for history log objects. type Filter struct { - ID []uuid.UUID - RequestID []string - Name []string - UserID []uint64 - AccountID []uint64 - ObjectID []uint64 - ObjectIDStr []string - ObjectType []string + ID []uuid.UUID // Filter by history log IDs + RequestID []string // Filter by request IDs + Name []string // Filter by names + UserID []uint64 // Filter by user IDs + AccountID []uint64 // Filter by account IDs + ObjectID []uint64 // Filter by numeric object IDs + ObjectIDStr []string // Filter by string object IDs + ObjectType []string // Filter by object types } -func (filter *Filter) Query(query *gorm.DB) *gorm.DB { +// PrepareQuery applies the filter conditions to a GORM query. +func (filter *Filter) PrepareQuery(query *gorm.DB) *gorm.DB { if filter == nil { return query } @@ -49,19 +52,21 @@ func (filter *Filter) Query(query *gorm.DB) *gorm.DB { return query } +// Order defines sorting options for history log queries. type Order struct { - ID model.Order - RequestID model.Order - Name model.Order - UserID model.Order - AccountID model.Order - ObjectID model.Order - ObjectIDStr model.Order - ObjectType model.Order - ActionAt model.Order + ID models.Order // Sort by ID + RequestID models.Order // Sort by request ID + Name models.Order // Sort by name + UserID models.Order // Sort by user ID + AccountID models.Order // Sort by account ID + ObjectID models.Order // Sort by numeric object ID + ObjectIDStr models.Order // Sort by string object ID + ObjectType models.Order // Sort by object type + ActionAt models.Order // Sort by action timestamp } -func (o *Order) Query(query *gorm.DB) *gorm.DB { +// PrepareQuery applies the sorting conditions to a GORM query. +func (o *Order) PrepareQuery(query *gorm.DB) *gorm.DB { if o == nil { return query } @@ -76,3 +81,10 @@ func (o *Order) Query(query *gorm.DB) *gorm.DB { query = o.ActionAt.PrepareQuery(query, `action_at`) return query } + +// Type aliases for common repository types. +type ( + Pagination = repository.Pagination + QOption = repository.QOption + ListOptions = repository.ListOptions +) diff --git a/repository/historylog/repository.go b/repository/historylog/repository.go index 830b80d7..4bab2c42 100644 --- a/repository/historylog/repository.go +++ b/repository/historylog/repository.go @@ -4,14 +4,13 @@ package historylog import ( "context" - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" + historylogModels "github.com/geniusrabbit/blaze-api/repository/historylog/models" ) -// Repository of access to the changelog +// Repository of the history actions log // //go:generate mockgen -source $GOFILE -package mocks -destination mocks/repository.go type Repository interface { - Count(ctx context.Context, filter *Filter) (int64, error) - FetchList(ctx context.Context, filter *Filter, order *Order, pagination *repository.Pagination) ([]*model.HistoryAction, error) + Count(ctx context.Context, opts ...QOption) (int64, error) + FetchList(ctx context.Context, opts ...QOption) ([]*historylogModels.HistoryAction, error) } diff --git a/repository/historylog/repository/repository.go b/repository/historylog/repository/repository.go index 40e791c0..1981eadb 100644 --- a/repository/historylog/repository/repository.go +++ b/repository/historylog/repository/repository.go @@ -7,9 +7,9 @@ import ( "github.com/pkg/errors" "gorm.io/gorm" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/historylog" + historylogModels "github.com/geniusrabbit/blaze-api/repository/historylog/models" ) // Repository DAO which provides functionality of working with changelogs @@ -23,22 +23,20 @@ func New() *Repository { } // Count returns count of history actions log by filter -func (r *Repository) Count(ctx context.Context, filter *historylog.Filter) (cnt int64, err error) { - query := r.Slave(ctx).Model((*model.HistoryAction)(nil)) - query = filter.Query(query) +func (r *Repository) Count(ctx context.Context, opts ...historylog.QOption) (cnt int64, err error) { + query := r.Slave(ctx).Model((*historylogModels.HistoryAction)(nil)) + query = historylog.ListOptions(opts).PrepareQuery(query) err = query.Count(&cnt).Error return cnt, err } // FetchList returns list of history actions log by filter -func (r *Repository) FetchList(ctx context.Context, filter *historylog.Filter, order *historylog.Order, pagination *repository.Pagination) ([]*model.HistoryAction, error) { +func (r *Repository) FetchList(ctx context.Context, opts ...historylog.QOption) ([]*historylogModels.HistoryAction, error) { var ( - list []*model.HistoryAction - query = r.Slave(ctx).Model((*model.HistoryAction)(nil)) + list []*historylogModels.HistoryAction + query = r.Slave(ctx).Model((*historylogModels.HistoryAction)(nil)) ) - query = filter.Query(query) - query = order.Query(query) - query = pagination.PrepareQuery(query) + query = historylog.ListOptions(opts).PrepareQuery(query) err := query.Find(&list).Error if errors.Is(err, gorm.ErrRecordNotFound) { err = nil diff --git a/repository/historylog/usecase.go b/repository/historylog/usecase.go index 60a4e96b..ac818786 100644 --- a/repository/historylog/usecase.go +++ b/repository/historylog/usecase.go @@ -3,14 +3,13 @@ package historylog import ( "context" - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" + historylogModels "github.com/geniusrabbit/blaze-api/repository/historylog/models" ) // Usecase of the changelog // //go:generate mockgen -source $GOFILE -package mocks -destination mocks/usecase.go type Usecase interface { - Count(ctx context.Context, filter *Filter) (int64, error) - FetchList(ctx context.Context, filter *Filter, order *Order, pagination *repository.Pagination) ([]*model.HistoryAction, error) + Count(ctx context.Context, opts ...QOption) (int64, error) + FetchList(ctx context.Context, opts ...QOption) ([]*historylogModels.HistoryAction, error) } diff --git a/repository/historylog/usecase/usecase.go b/repository/historylog/usecase/usecase.go index 250ea336..14aa1ec8 100644 --- a/repository/historylog/usecase/usecase.go +++ b/repository/historylog/usecase/usecase.go @@ -4,11 +4,11 @@ package usecase import ( "context" - "github.com/geniusrabbit/blaze-api/model" + "github.com/pkg/errors" + "github.com/geniusrabbit/blaze-api/pkg/acl" - "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/historylog" - "github.com/pkg/errors" + historylogModels "github.com/geniusrabbit/blaze-api/repository/historylog/models" ) // RoleUsecase provides bussiness logic for account access @@ -24,19 +24,19 @@ func NewUsecase(repo historylog.Repository) *HistoryUsecase { } // Count of roles by filter -func (a *HistoryUsecase) Count(ctx context.Context, filter *historylog.Filter) (int64, error) { - if !acl.HaveAccessList(ctx, &model.HistoryAction{}) { +func (a *HistoryUsecase) Count(ctx context.Context, opts ...historylog.QOption) (int64, error) { + if !acl.HaveAccessList(ctx, &historylogModels.HistoryAction{}) { return 0, errors.Wrap(acl.ErrNoPermissions, "list log items") } - return a.repo.Count(ctx, filter) + return a.repo.Count(ctx, opts...) } // FetchList of roles by filter -func (a *HistoryUsecase) FetchList(ctx context.Context, filter *historylog.Filter, order *historylog.Order, pagination *repository.Pagination) ([]*model.HistoryAction, error) { - if !acl.HaveAccessList(ctx, &model.HistoryAction{}) { +func (a *HistoryUsecase) FetchList(ctx context.Context, opts ...historylog.QOption) ([]*historylogModels.HistoryAction, error) { + if !acl.HaveAccessList(ctx, &historylogModels.HistoryAction{}) { return nil, errors.Wrap(acl.ErrNoPermissions, "list log items") } - list, err := a.repo.FetchList(ctx, filter, order, pagination) + list, err := a.repo.FetchList(ctx, opts...) for _, link := range list { if !acl.HaveAccessList(ctx, link) { return nil, errors.Wrap(acl.ErrNoPermissions, "list log items") diff --git a/repository/historylog/usecase/usecase_test.go b/repository/historylog/usecase/usecase_test.go index 3b159fe6..bd0defcb 100644 --- a/repository/historylog/usecase/usecase_test.go +++ b/repository/historylog/usecase/usecase_test.go @@ -4,15 +4,14 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/google/uuid" "github.com/stretchr/testify/suite" + "go.uber.org/mock/gomock" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/context/session" - "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/historylog" "github.com/geniusrabbit/blaze-api/repository/historylog/mocks" + historylogModels "github.com/geniusrabbit/blaze-api/repository/historylog/models" ) type testSuite struct { @@ -47,12 +46,12 @@ func (s *testSuite) TestFetchList() { FetchList(s.ctx, gomock.AssignableToTypeOf(&historylog.Filter{}), gomock.AssignableToTypeOf(&historylog.Order{}), - gomock.AssignableToTypeOf(&repository.Pagination{})). - Return([]*model.HistoryAction{{ID: uid1}, {ID: uid2}}, nil) + gomock.AssignableToTypeOf(&historylog.Pagination{})). + Return([]*historylogModels.HistoryAction{{ID: uid1}, {ID: uid2}}, nil) objs, err := s.testUsecase.FetchList(s.ctx, &historylog.Filter{ID: []uuid.UUID{uid1, uid2}}, - &historylog.Order{}, &repository.Pagination{Size: 100}) + &historylog.Order{}, &historylog.Pagination{Size: 100}) s.NoError(err) s.Equal(2, len(objs)) } diff --git a/repository/option/delivery/graphql/connector.go b/repository/option/delivery/graphql/connector.go new file mode 100644 index 00000000..95bbe1e9 --- /dev/null +++ b/repository/option/delivery/graphql/connector.go @@ -0,0 +1,33 @@ +package graphql + +import ( + "context" + + "github.com/demdxx/gocast/v2" + + "github.com/geniusrabbit/blaze-api/repository/option" + "github.com/geniusrabbit/blaze-api/server/graphql/connectors" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" +) + +// OptionConnection implements collection accessor interface with pagination +type OptionConnection = connectors.CollectionConnection[gqlmodels.Option, gqlmodels.OptionEdge] + +// NewOptionConnection based on query object +func NewOptionConnection(ctx context.Context, optionsAccessor option.Usecase, filter *gqlmodels.OptionListFilter, order *gqlmodels.OptionListOrder, page *gqlmodels.Page) *OptionConnection { + return connectors.NewCollectionConnection(ctx, &connectors.DataAccessorFunc[gqlmodels.Option, gqlmodels.OptionEdge]{ + FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.Option, error) { + options, err := optionsAccessor.FetchList(ctx, filter.Filter(), order.Order(), page.Pagination()) + return FromOptionModelList(options), err + }, + CountDataFunc: func(ctx context.Context) (int64, error) { + return optionsAccessor.Count(ctx, filter.Filter()) + }, + ConvertToEdgeFunc: func(obj *gqlmodels.Option) *gqlmodels.OptionEdge { + return &gqlmodels.OptionEdge{ + Cursor: gocast.Str(obj.Name), + Node: obj, + } + }, + }, page) +} diff --git a/repository/option/delivery/graphql/mapping.go b/repository/option/delivery/graphql/mapping.go new file mode 100644 index 00000000..3ec55f57 --- /dev/null +++ b/repository/option/delivery/graphql/mapping.go @@ -0,0 +1,54 @@ +package graphql + +import ( + "github.com/demdxx/xtypes" + + "github.com/geniusrabbit/blaze-api/repository/option/models" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" + "github.com/geniusrabbit/blaze-api/server/graphql/types" +) + +// FromOptionType converts a models.OptionType to a GraphQL gqlmodels.OptionType. +func FromOptionType(tp models.OptionType) gqlmodels.OptionType { + switch tp { + case models.UserOptionType: + return gqlmodels.OptionTypeUser + case models.AccountOptionType: + return gqlmodels.OptionTypeAccount + case models.SystemOptionType: + return gqlmodels.OptionTypeSystem + } + return gqlmodels.OptionTypeUndefined +} + +// ModelOptionType converts a gqlmodels.OptionType to a models.OptionType. +func ModelOptionType(tp gqlmodels.OptionType) models.OptionType { + switch tp { + case gqlmodels.OptionTypeUser: + return models.UserOptionType + case gqlmodels.OptionTypeAccount: + return models.AccountOptionType + case gqlmodels.OptionTypeSystem: + return models.SystemOptionType + } + return models.UndefinedOptionType +} + +// FromOption converts a models.Option to a gqlmodels.Option. +// Returns nil if the input option is nil. +func FromOption(opt *models.Option) *gqlmodels.Option { + if opt == nil { + return nil + } + return &gqlmodels.Option{ + Name: opt.Name, + Type: FromOptionType(opt.Type), + TargetID: opt.TargetID, + Value: types.MustNullableJSONFrom(opt.Value.Data), + } +} + +// FromOptionModelList converts a slice of models.Option to a slice of gqlmodels.Option. +func FromOptionModelList(opts []*models.Option) []*gqlmodels.Option { + return xtypes.SliceApply(opts, FromOption) +} diff --git a/protocol/graphql/schemas/options.graphql b/repository/option/delivery/graphql/options.graphql similarity index 100% rename from protocol/graphql/schemas/options.graphql rename to repository/option/delivery/graphql/options.graphql diff --git a/repository/option/delivery/graphql/resolver.go b/repository/option/delivery/graphql/resolver.go index 5c032a5d..10534f9e 100644 --- a/repository/option/delivery/graphql/resolver.go +++ b/repository/option/delivery/graphql/resolver.go @@ -5,11 +5,10 @@ import ( "github.com/geniusrabbit/gosql/v2" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/requestid" "github.com/geniusrabbit/blaze-api/repository/option" - "github.com/geniusrabbit/blaze-api/server/graphql/connectors" - "github.com/geniusrabbit/blaze-api/server/graphql/models" + "github.com/geniusrabbit/blaze-api/repository/option/models" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" "github.com/geniusrabbit/blaze-api/server/graphql/types" ) @@ -24,10 +23,10 @@ func NewQueryResolver(uc option.Usecase) *QueryResolver { } // Set Option is the resolver for the setOption field. -func (r *QueryResolver) Set(ctx context.Context, name string, value *types.NullableJSON, typeArg models.OptionType, targetID uint64) (*models.OptionPayload, error) { - opt := model.Option{ +func (r *QueryResolver) Set(ctx context.Context, name string, value *types.NullableJSON, typeArg gqlmodels.OptionType, targetID uint64) (*gqlmodels.OptionPayload, error) { + opt := models.Option{ Name: name, - Type: typeArg.ModelType(), + Type: ModelOptionType(typeArg), TargetID: targetID, } if value != nil { @@ -37,27 +36,27 @@ func (r *QueryResolver) Set(ctx context.Context, name string, value *types.Nulla if err != nil { return nil, err } - return &models.OptionPayload{ + return &gqlmodels.OptionPayload{ ClientMutationID: requestid.Get(ctx), Name: name, - Option: models.FromOption(&opt), + Option: FromOption(&opt), }, nil } // Get Option is the resolver for the option field. -func (r *QueryResolver) Get(ctx context.Context, name string, otype models.OptionType, targetID uint64) (*models.OptionPayload, error) { - opt, err := r.uc.Get(ctx, name, otype.ModelType(), targetID) +func (r *QueryResolver) Get(ctx context.Context, name string, otype gqlmodels.OptionType, targetID uint64) (*gqlmodels.OptionPayload, error) { + opt, err := r.uc.Get(ctx, name, ModelOptionType(otype), targetID) if err != nil { return nil, err } - return &models.OptionPayload{ + return &gqlmodels.OptionPayload{ ClientMutationID: requestid.Get(ctx), Name: name, - Option: models.FromOption(opt), + Option: FromOption(opt), }, nil } // List Options is the resolver for the listOptions field. -func (r *QueryResolver) List(ctx context.Context, filter *models.OptionListFilter, order *models.OptionListOrder, page *models.Page) (*connectors.OptionConnection, error) { - return connectors.NewOptionConnection(ctx, r.uc, filter, order, page), nil +func (r *QueryResolver) List(ctx context.Context, filter *gqlmodels.OptionListFilter, order *gqlmodels.OptionListOrder, page *gqlmodels.Page) (*OptionConnection, error) { + return NewOptionConnection(ctx, r.uc, filter, order, page), nil } diff --git a/repository/option/mocks/repository.go b/repository/option/mocks/repository.go index 10e0f982..930e68c8 100644 --- a/repository/option/mocks/repository.go +++ b/repository/option/mocks/repository.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: repository.go +// +// Generated by this command: +// +// mockgen -source repository.go -package mocks -destination mocks/repository.go +// // Package mocks is a generated GoMock package. package mocks @@ -8,16 +13,15 @@ import ( context "context" reflect "reflect" - model "github.com/geniusrabbit/blaze-api/model" - repository "github.com/geniusrabbit/blaze-api/repository" option "github.com/geniusrabbit/blaze-api/repository/option" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockRepository is a mock of Repository interface. type MockRepository struct { ctrl *gomock.Controller recorder *MockRepositoryMockRecorder + isgomock struct{} } // MockRepositoryMockRecorder is the mock recorder for MockRepository. @@ -38,22 +42,27 @@ func (m *MockRepository) EXPECT() *MockRepositoryMockRecorder { } // Count mocks base method. -func (m *MockRepository) Count(ctx context.Context, filter *option.Filter) (int64, error) { +func (m *MockRepository) Count(ctx context.Context, opts ...option.QOption) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockRepositoryMockRecorder) Count(ctx, filter interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Count(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), varargs...) } // Delete mocks base method. -func (m *MockRepository) Delete(ctx context.Context, name string, otype model.OptionType, targetID uint64) error { +func (m *MockRepository) Delete(ctx context.Context, name string, otype option.OptionType, targetID uint64) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delete", ctx, name, otype, targetID) ret0, _ := ret[0].(error) @@ -61,43 +70,48 @@ func (m *MockRepository) Delete(ctx context.Context, name string, otype model.Op } // Delete indicates an expected call of Delete. -func (mr *MockRepositoryMockRecorder) Delete(ctx, name, otype, targetID interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Delete(ctx, name, otype, targetID any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRepository)(nil).Delete), ctx, name, otype, targetID) } // FetchList mocks base method. -func (m *MockRepository) FetchList(ctx context.Context, filter *option.Filter, order *option.ListOrder, pagination *repository.Pagination) ([]*model.Option, error) { +func (m *MockRepository) FetchList(ctx context.Context, opts ...option.QOption) ([]*option.Option, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter, order, pagination) - ret0, _ := ret[0].([]*model.Option) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*option.Option) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockRepositoryMockRecorder) FetchList(ctx, filter, order, pagination interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) FetchList(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), ctx, filter, order, pagination) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), varargs...) } // Get mocks base method. -func (m *MockRepository) Get(ctx context.Context, name string, otype model.OptionType, targetID uint64) (*model.Option, error) { +func (m *MockRepository) Get(ctx context.Context, name string, otype option.OptionType, targetID uint64) (*option.Option, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Get", ctx, name, otype, targetID) - ret0, _ := ret[0].(*model.Option) + ret0, _ := ret[0].(*option.Option) ret1, _ := ret[1].(error) return ret0, ret1 } // Get indicates an expected call of Get. -func (mr *MockRepositoryMockRecorder) Get(ctx, name, otype, targetID interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Get(ctx, name, otype, targetID any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRepository)(nil).Get), ctx, name, otype, targetID) } // Set mocks base method. -func (m *MockRepository) Set(ctx context.Context, opt *model.Option) error { +func (m *MockRepository) Set(ctx context.Context, opt *option.Option) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Set", ctx, opt) ret0, _ := ret[0].(error) @@ -105,7 +119,7 @@ func (m *MockRepository) Set(ctx context.Context, opt *model.Option) error { } // Set indicates an expected call of Set. -func (mr *MockRepositoryMockRecorder) Set(ctx, opt interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Set(ctx, opt any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Set", reflect.TypeOf((*MockRepository)(nil).Set), ctx, opt) } diff --git a/repository/option/mocks/usecase.go b/repository/option/mocks/usecase.go index c7137187..c2fa2007 100644 --- a/repository/option/mocks/usecase.go +++ b/repository/option/mocks/usecase.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: usecase.go +// +// Generated by this command: +// +// mockgen -source usecase.go -package mocks -destination mocks/usecase.go +// // Package mocks is a generated GoMock package. package mocks @@ -8,16 +13,15 @@ import ( context "context" reflect "reflect" - model "github.com/geniusrabbit/blaze-api/model" - repository "github.com/geniusrabbit/blaze-api/repository" option "github.com/geniusrabbit/blaze-api/repository/option" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockUsecase is a mock of Usecase interface. type MockUsecase struct { ctrl *gomock.Controller recorder *MockUsecaseMockRecorder + isgomock struct{} } // MockUsecaseMockRecorder is the mock recorder for MockUsecase. @@ -38,22 +42,27 @@ func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder { } // Count mocks base method. -func (m *MockUsecase) Count(ctx context.Context, filter *option.Filter) (int64, error) { +func (m *MockUsecase) Count(ctx context.Context, opts ...option.QOption) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockUsecaseMockRecorder) Count(ctx, filter interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Count(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), varargs...) } // Delete mocks base method. -func (m *MockUsecase) Delete(ctx context.Context, name string, otype model.OptionType, targetID uint64) error { +func (m *MockUsecase) Delete(ctx context.Context, name string, otype option.OptionType, targetID uint64) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delete", ctx, name, otype, targetID) ret0, _ := ret[0].(error) @@ -61,43 +70,48 @@ func (m *MockUsecase) Delete(ctx context.Context, name string, otype model.Optio } // Delete indicates an expected call of Delete. -func (mr *MockUsecaseMockRecorder) Delete(ctx, name, otype, targetID interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Delete(ctx, name, otype, targetID any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockUsecase)(nil).Delete), ctx, name, otype, targetID) } // FetchList mocks base method. -func (m *MockUsecase) FetchList(ctx context.Context, filter *option.Filter, order *option.ListOrder, pagination *repository.Pagination) ([]*model.Option, error) { +func (m *MockUsecase) FetchList(ctx context.Context, opts ...option.QOption) ([]*option.Option, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter, order, pagination) - ret0, _ := ret[0].([]*model.Option) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*option.Option) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockUsecaseMockRecorder) FetchList(ctx, filter, order, pagination interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) FetchList(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), ctx, filter, order, pagination) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), varargs...) } // Get mocks base method. -func (m *MockUsecase) Get(ctx context.Context, name string, otype model.OptionType, targetID uint64) (*model.Option, error) { +func (m *MockUsecase) Get(ctx context.Context, name string, otype option.OptionType, targetID uint64) (*option.Option, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Get", ctx, name, otype, targetID) - ret0, _ := ret[0].(*model.Option) + ret0, _ := ret[0].(*option.Option) ret1, _ := ret[1].(error) return ret0, ret1 } // Get indicates an expected call of Get. -func (mr *MockUsecaseMockRecorder) Get(ctx, name, otype, targetID interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Get(ctx, name, otype, targetID any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockUsecase)(nil).Get), ctx, name, otype, targetID) } // Set mocks base method. -func (m *MockUsecase) Set(ctx context.Context, opt *model.Option) error { +func (m *MockUsecase) Set(ctx context.Context, opt *option.Option) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Set", ctx, opt) ret0, _ := ret[0].(error) @@ -105,13 +119,13 @@ func (m *MockUsecase) Set(ctx context.Context, opt *model.Option) error { } // Set indicates an expected call of Set. -func (mr *MockUsecaseMockRecorder) Set(ctx, opt interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Set(ctx, opt any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Set", reflect.TypeOf((*MockUsecase)(nil).Set), ctx, opt) } // SetOption mocks base method. -func (m *MockUsecase) SetOption(ctx context.Context, name string, otype model.OptionType, targetID uint64, value any) error { +func (m *MockUsecase) SetOption(ctx context.Context, name string, otype option.OptionType, targetID uint64, value any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetOption", ctx, name, otype, targetID, value) ret0, _ := ret[0].(error) @@ -119,7 +133,7 @@ func (m *MockUsecase) SetOption(ctx context.Context, name string, otype model.Op } // SetOption indicates an expected call of SetOption. -func (mr *MockUsecaseMockRecorder) SetOption(ctx, name, otype, targetID, value interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) SetOption(ctx, name, otype, targetID, value any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetOption", reflect.TypeOf((*MockUsecase)(nil).SetOption), ctx, name, otype, targetID, value) } diff --git a/repository/option/models.go b/repository/option/models.go new file mode 100644 index 00000000..58abacb2 --- /dev/null +++ b/repository/option/models.go @@ -0,0 +1,27 @@ +package option + +import "github.com/geniusrabbit/blaze-api/repository/option/models" + +type ( + // Option represents a single option in the system. + Option = models.Option + + // OptionType defines the type of the option, such as user, project, etc. + OptionType = models.OptionType + + // Order defines the sort direction. + Order = models.Order +) + +const ( + OrderUndefined = models.OrderUndefined + OrderAsc = models.OrderAsc + OrderDesc = models.OrderDesc +) + +const ( + UndefinedOptionType = models.UndefinedOptionType + UserOptionType = models.UserOptionType + AccountOptionType = models.AccountOptionType + SystemOptionType = models.SystemOptionType +) diff --git a/repository/option/models/option.go b/repository/option/models/option.go new file mode 100644 index 00000000..7c4e0909 --- /dev/null +++ b/repository/option/models/option.go @@ -0,0 +1,67 @@ +package models + +import ( + "time" + + "github.com/geniusrabbit/gosql/v2" + "gorm.io/gorm" + + "github.com/geniusrabbit/blaze-api/pkg/models" +) + +// Order is an alias for the Order type from the models package +type Order = models.Order + +// Order constants define the sort direction +const ( + OrderUndefined = models.OrderUndefined + OrderAsc = models.OrderAsc + OrderDesc = models.OrderDesc +) + +// OptionType defines the type of option +type OptionType string + +// OptionType constants represent different option categories +const ( + UndefinedOptionType OptionType = "undefined" + UserOptionType OptionType = "user" + AccountOptionType OptionType = "account" + SystemOptionType OptionType = "system" +) + +// Option represents a configuration option with associated metadata +type Option struct { + Type OptionType `json:"type"` // Type of option + TargetID uint64 `json:"target_id"` // ID of the target entity + Name string `json:"name"` // Option name + Value gosql.NullableJSON[any] `json:"value" gorm:"type:jsonb"` // JSON value + + CreatedAt time.Time `db:"created_at"` // Creation timestamp + UpdatedAt time.Time `db:"updated_at"` // Last update timestamp + DeletedAt gorm.DeletedAt `db:"deleted_at"` // Soft delete timestamp +} + +// TableName specifies the database table name for Option +func (o *Option) TableName() string { return "option" } + +// CreatorUserID returns the user ID if this option is a user option +func (o *Option) CreatorUserID() uint64 { + if o != nil && o.Type == UserOptionType { + return o.TargetID + } + return 0 +} + +// OwnerAccountID returns the account ID if this option is an account option +func (o *Option) OwnerAccountID() uint64 { + if o != nil && o.Type == AccountOptionType { + return o.TargetID + } + return 0 +} + +// RBACResourceName returns the RBAC resource name for authorization +func (o *Option) RBACResourceName() string { + return "option" +} diff --git a/repository/option/query.go b/repository/option/query.go index b4806123..363af285 100644 --- a/repository/option/query.go +++ b/repository/option/query.go @@ -3,13 +3,15 @@ package option import ( "bytes" - "github.com/geniusrabbit/blaze-api/model" "gorm.io/gorm" + + "github.com/geniusrabbit/blaze-api/repository" + optionModels "github.com/geniusrabbit/blaze-api/repository/option/models" ) // Filter of the objects list type Filter struct { - Type []model.OptionType + Type []optionModels.OptionType TargetID []uint64 Name []string NamePattern []string @@ -48,11 +50,11 @@ func (fl *Filter) PrepareQuery(q *gorm.DB) *gorm.DB { // ListOrder object with order values which is not NULL type ListOrder struct { - Name model.Order - Type model.Order - TargetID model.Order - CreatedAt model.Order - UpdatedAt model.Order + Name optionModels.Order + Type optionModels.Order + TargetID optionModels.Order + CreatedAt optionModels.Order + UpdatedAt optionModels.Order } // PrepareQuery returns the query with applied order @@ -66,3 +68,9 @@ func (ord *ListOrder) PrepareQuery(q *gorm.DB) *gorm.DB { } return q } + +type ( + Pagination = repository.Pagination + QOption = repository.QOption + ListOptions = repository.ListOptions +) diff --git a/repository/option/repository.go b/repository/option/repository.go index e45c77b6..7cdd67e2 100644 --- a/repository/option/repository.go +++ b/repository/option/repository.go @@ -1,20 +1,26 @@ -// Package option present full API functionality of the specific object +// Package option presents full API functionality of the specific object. package option import ( "context" - - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" ) -// Repository of access to the option +// Repository provides access to options with CRUD operations. // //go:generate mockgen -source $GOFILE -package mocks -destination mocks/repository.go type Repository interface { - Get(ctx context.Context, name string, otype model.OptionType, targetID uint64) (*model.Option, error) - FetchList(ctx context.Context, filter *Filter, order *ListOrder, pagination *repository.Pagination) ([]*model.Option, error) - Count(ctx context.Context, filter *Filter) (int64, error) - Set(ctx context.Context, opt *model.Option) error - Delete(ctx context.Context, name string, otype model.OptionType, targetID uint64) error + // Get retrieves a single option by name, type, and target ID. + Get(ctx context.Context, name string, otype OptionType, targetID uint64) (*Option, error) + + // FetchList retrieves a list of options with filtering, ordering, and pagination. + FetchList(ctx context.Context, opts ...QOption) ([]*Option, error) + + // Count returns the total number of options matching the filter. + Count(ctx context.Context, opts ...QOption) (int64, error) + + // Set creates or updates an option. + Set(ctx context.Context, opt *Option) error + + // Delete removes an option by name, type, and target ID. + Delete(ctx context.Context, name string, otype OptionType, targetID uint64) error } diff --git a/repository/option/repository/repository.go b/repository/option/repository/repository.go index 01b43029..6e985fbf 100644 --- a/repository/option/repository/repository.go +++ b/repository/option/repository/repository.go @@ -10,9 +10,9 @@ import ( "gorm.io/gorm" "gorm.io/gorm/clause" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/option" + "github.com/geniusrabbit/blaze-api/repository/option/models" ) // Repository DAO which provides functionality of working with RBAC song-tabulatures @@ -21,23 +21,23 @@ type Repository struct { defaultSystemOptions map[string]any } -// New role repository -func New(defSysOpts map[string]any) *Repository { +// NewOptionRepository creates a new option repository +func NewOptionRepository(defSysOpts map[string]any) *Repository { return &Repository{ defaultSystemOptions: defSysOpts, } } // Get returns option by ID -func (r *Repository) Get(ctx context.Context, name string, otype model.OptionType, targetID uint64) (*model.Option, error) { - object := &model.Option{Name: name, Type: otype, TargetID: targetID} +func (r *Repository) Get(ctx context.Context, name string, otype models.OptionType, targetID uint64) (*models.Option, error) { + object := &option.Option{Name: name, Type: otype, TargetID: targetID} res := r.Slave(ctx).Model(object). Where(`name=? AND type=? AND target_id=?`, name, otype, targetID).Find(object) if errors.Is(res.Error, gorm.ErrRecordNotFound) || errors.Is(res.Error, sql.ErrNoRows) || object.Value.Data == nil { - if otype == model.SystemOptionType && targetID == 0 && r.defaultSystemOptions != nil { + if otype == models.SystemOptionType && targetID == 0 && r.defaultSystemOptions != nil { object.Name = name - object.Type = model.SystemOptionType + object.Type = models.SystemOptionType object.TargetID = 0 if value, ok := r.defaultSystemOptions[name]; ok { @@ -56,14 +56,12 @@ func (r *Repository) Get(ctx context.Context, name string, otype model.OptionTyp } // FetchList returns list of -func (r *Repository) FetchList(ctx context.Context, filter *option.Filter, order *option.ListOrder, pagination *repository.Pagination) ([]*model.Option, error) { +func (r *Repository) FetchList(ctx context.Context, opts ...option.QOption) ([]*models.Option, error) { var ( - list []*model.Option - query = r.Slave(ctx).Model((*model.Option)(nil)) + list []*models.Option + query = r.Slave(ctx).Model((*models.Option)(nil)) ) - query = filter.PrepareQuery(query) - query = order.PrepareQuery(query) - query = pagination.PrepareQuery(query) + query = option.ListOptions(opts).PrepareQuery(query) err := query.Find(&list).Error if errors.Is(err, gorm.ErrRecordNotFound) || errors.Is(err, sql.ErrNoRows) { err = nil @@ -72,12 +70,12 @@ func (r *Repository) FetchList(ctx context.Context, filter *option.Filter, order } // Count returns count of records by filter -func (r *Repository) Count(ctx context.Context, filter *option.Filter) (int64, error) { +func (r *Repository) Count(ctx context.Context, opts ...option.QOption) (int64, error) { var ( count int64 - query = r.Slave(ctx).Model((*model.Option)(nil)) + query = r.Slave(ctx).Model((*models.Option)(nil)) ) - query = filter.PrepareQuery(query) + query = option.ListOptions(opts).PrepareQuery(query) err := query.Count(&count).Error if errors.Is(err, gorm.ErrRecordNotFound) || errors.Is(err, sql.ErrNoRows) { err = nil @@ -86,7 +84,7 @@ func (r *Repository) Count(ctx context.Context, filter *option.Filter) (int64, e } // Set new or update object in database -func (r *Repository) Set(ctx context.Context, obj *model.Option) error { +func (r *Repository) Set(ctx context.Context, obj *models.Option) error { if obj.CreatedAt.IsZero() { obj.CreatedAt = time.Now() } @@ -100,7 +98,7 @@ func (r *Repository) Set(ctx context.Context, obj *model.Option) error { } // Delete delites record by ID -func (r *Repository) Delete(ctx context.Context, name string, otype model.OptionType, targetID uint64) error { - return r.Master(ctx).Model((*model.Option)(nil)). +func (r *Repository) Delete(ctx context.Context, name string, otype models.OptionType, targetID uint64) error { + return r.Master(ctx).Model((*models.Option)(nil)). Delete(`type=? AND target_id=? AND name=?`, otype, targetID, name).Error } diff --git a/repository/option/repository/repository_test.go b/repository/option/repository/repository_test.go index 4076044c..20bb3626 100644 --- a/repository/option/repository/repository_test.go +++ b/repository/option/repository/repository_test.go @@ -9,15 +9,14 @@ import ( "github.com/stretchr/testify/suite" "gorm.io/gorm" - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/option" + "github.com/geniusrabbit/blaze-api/repository/option/models" "github.com/geniusrabbit/blaze-api/repository/testsuite" ) -var testOption = model.Option{ +var testOption = models.Option{ Name: "opt.name", - Type: model.UserOptionType, + Type: models.UserOptionType, TargetID: 1, Value: *gosql.MustNullableJSON[any](map[string]any{"val": 1}), } @@ -30,7 +29,7 @@ type testSuite struct { func (s *testSuite) SetupSuite() { s.DatabaseSuite.SetupSuite() - s.testRepo = New(map[string]any{ + s.testRepo = NewOptionRepository(map[string]any{ "opt.default": 1, }) } @@ -40,9 +39,9 @@ func (s *testSuite) TestGet() { WithArgs("opt.name", sqlmock.AnyArg(), sqlmock.AnyArg()). WillReturnRows( sqlmock.NewRows([]string{"type", "target_id", "name", "value", "created_at"}). - AddRow(model.UserOptionType, uint64(1), "opt.name", `{"val":1}`, time.Now()), + AddRow(models.UserOptionType, uint64(1), "opt.name", `{"val":1}`, time.Now()), ) - role, err := s.testRepo.Get(s.Ctx, "opt.name", model.UserOptionType, 1) + role, err := s.testRepo.Get(s.Ctx, "opt.name", models.UserOptionType, 1) s.NoError(err) s.Equal("opt.name", role.Name) } @@ -51,11 +50,11 @@ func (s *testSuite) TestGetDefault() { s.Mock.ExpectQuery("SELECT *"). WithArgs("opt.default", sqlmock.AnyArg(), sqlmock.AnyArg()). WillReturnError(gorm.ErrRecordNotFound) - role, err := s.testRepo.Get(s.Ctx, "opt.default", model.SystemOptionType, 0) + role, err := s.testRepo.Get(s.Ctx, "opt.default", models.SystemOptionType, 0) if s.NoError(err) { s.Equal("opt.default", role.Name) - s.Equal(model.SystemOptionType, role.Type) + s.Equal(models.SystemOptionType, role.Type) s.Equal(uint64(0), role.TargetID) if s.NotNil(role.Value.Data) { s.Equal(1, *role.Value.Data) @@ -68,13 +67,13 @@ func (s *testSuite) TestFetchList() { WithArgs("opt.name1", "opt.name2", 100). WillReturnRows( sqlmock.NewRows([]string{"type", "target_id", "name", "value", "created_at"}). - AddRow(model.UserOptionType, uint64(1), "opt.name1", `{"val":1}`, time.Now()). - AddRow(model.UserOptionType, uint64(2), "opt.name2", `{"val":2}`, time.Now()), + AddRow(models.UserOptionType, uint64(1), "opt.name1", `{"val":1}`, time.Now()). + AddRow(models.UserOptionType, uint64(2), "opt.name2", `{"val":2}`, time.Now()), ) list, err := s.testRepo.FetchList(s.Ctx, &option.Filter{Name: []string{"opt.name1", "opt.name2"}}, - &option.ListOrder{Name: model.OrderAsc}, - &repository.Pagination{Size: 100}) + &option.ListOrder{Name: models.OrderAsc}, + &option.Pagination{Size: 100}) s.NoError(err) s.Equal(2, len(list)) } @@ -93,7 +92,7 @@ func (s *testSuite) TestCount() { func (s *testSuite) TestSet() { s.Mock.ExpectExec("INSERT INTO"). - WithArgs(model.UserOptionType, uint64(1), "opt.name", `{"val":1}`, sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg()). + WithArgs(models.UserOptionType, uint64(1), "opt.name", `{"val":1}`, sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg()). WillReturnResult(sqlmock.NewResult(0, 1)) err := s.testRepo.Set(s.Ctx, &testOption) s.NoError(err) @@ -101,9 +100,9 @@ func (s *testSuite) TestSet() { func (s *testSuite) TestDelete() { s.Mock.ExpectExec("UPDATE"). - WithArgs(sqlmock.AnyArg(), model.UserOptionType, uint64(1), "opt.name"). + WithArgs(sqlmock.AnyArg(), models.UserOptionType, uint64(1), "opt.name"). WillReturnResult(sqlmock.NewResult(0, 1)) - err := s.testRepo.Delete(s.Ctx, "opt.name", model.UserOptionType, 1) + err := s.testRepo.Delete(s.Ctx, "opt.name", models.UserOptionType, 1) s.NoError(err) } diff --git a/repository/option/usecase.go b/repository/option/usecase.go index 4c0f48b0..ae3b921f 100644 --- a/repository/option/usecase.go +++ b/repository/option/usecase.go @@ -2,19 +2,27 @@ package option import ( "context" - - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" ) -// Usecase of the Option +// Usecase defines operations for managing options in the system. // //go:generate mockgen -source $GOFILE -package mocks -destination mocks/usecase.go type Usecase interface { - Get(ctx context.Context, name string, otype model.OptionType, targetID uint64) (*model.Option, error) - FetchList(ctx context.Context, filter *Filter, order *ListOrder, pagination *repository.Pagination) ([]*model.Option, error) - Count(ctx context.Context, filter *Filter) (int64, error) - Set(ctx context.Context, opt *model.Option) error - SetOption(ctx context.Context, name string, otype model.OptionType, targetID uint64, value any) error - Delete(ctx context.Context, name string, otype model.OptionType, targetID uint64) error + // Get retrieves a single option by name, type, and target ID. + Get(ctx context.Context, name string, otype OptionType, targetID uint64) (*Option, error) + + // FetchList retrieves a list of options filtered, ordered, and paginated according to the parameters. + FetchList(ctx context.Context, opts ...QOption) ([]*Option, error) + + // Count returns the total number of options matching the filter criteria. + Count(ctx context.Context, opts ...QOption) (int64, error) + + // Set stores or updates an option. + Set(ctx context.Context, opt *Option) error + + // SetOption stores or updates an option by name, type, target ID, and value. + SetOption(ctx context.Context, name string, otype OptionType, targetID uint64, value any) error + + // Delete removes an option by name, type, and target ID. + Delete(ctx context.Context, name string, otype OptionType, targetID uint64) error } diff --git a/repository/option/usecase/usecase.go b/repository/option/usecase/usecase.go index b44c3369..bdeb71ca 100644 --- a/repository/option/usecase/usecase.go +++ b/repository/option/usecase/usecase.go @@ -1,4 +1,4 @@ -// Package usecase account implementation +// Package usecase provides business logic for option management package usecase import ( @@ -6,32 +6,31 @@ import ( "github.com/pkg/errors" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/acl" "github.com/geniusrabbit/blaze-api/pkg/context/session" - "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/historylog" "github.com/geniusrabbit/blaze-api/repository/option" + "github.com/geniusrabbit/blaze-api/repository/option/models" ) -// Usecase provides bussiness logic for account access +// Usecase implements business logic for option access and management type Usecase struct { baseRepo option.Repository } -// NewUsecase object controller +// NewUsecase creates and returns a new Usecase instance func NewUsecase(repo option.Repository) *Usecase { return &Usecase{ baseRepo: repo, } } -// Get returns the group by ID if have access -func (a *Usecase) Get(ctx context.Context, name string, otype model.OptionType, targetID uint64) (*model.Option, error) { +// Get retrieves an option by name, type, and target ID with permission checks +func (a *Usecase) Get(ctx context.Context, name string, otype models.OptionType, targetID uint64) (*models.Option, error) { switch { - case otype == model.UserOptionType && targetID == 0: + case otype == models.UserOptionType && targetID == 0: targetID = session.User(ctx).ID - case otype == model.AccountOptionType && targetID == 0: + case otype == models.AccountOptionType && targetID == 0: targetID = session.Account(ctx).ID } targetObj, err := a.baseRepo.Get(ctx, name, otype, targetID) @@ -39,52 +38,50 @@ func (a *Usecase) Get(ctx context.Context, name string, otype model.OptionType, return nil, err } if !acl.HaveObjectPermissions(ctx, targetObj, acl.PermGet+`.*`) { - return nil, errors.Wrap(acl.ErrNoPermissions, "get") + return nil, acl.ErrNoPermissions.WithMessage("get") } return targetObj, nil } -// FetchList of accounts by filter -func (a *Usecase) FetchList(ctx context.Context, filter *option.Filter, order *option.ListOrder, pagination *repository.Pagination) ([]*model.Option, error) { - if !acl.HaveAccessList(ctx, &model.Option{}) { - return nil, errors.Wrap(acl.ErrNoPermissions, "list") +// FetchList retrieves a list of options filtered and ordered with permission checks +func (a *Usecase) FetchList(ctx context.Context, opts ...option.QOption) ([]*models.Option, error) { + if !acl.HaveAccessList(ctx, &models.Option{}) { + return nil, acl.ErrNoPermissions.WithMessage("list") } - list, err := a.baseRepo.FetchList(ctx, filter, order, pagination) + list, err := a.baseRepo.FetchList(ctx, opts...) for _, obj := range list { if !acl.HaveAccessList(ctx, obj) { - return nil, errors.Wrap(acl.ErrNoPermissions, "list") + return nil, acl.ErrNoPermissions.WithMessage("list") } } return list, err } -// Count of accounts by filter -func (a *Usecase) Count(ctx context.Context, filter *option.Filter) (int64, error) { - if !acl.HaveAccessList(ctx, &model.Option{}) { - return 0, errors.Wrap(acl.ErrNoPermissions, "list") +// Count returns the total count of options matching the filter with permission checks +func (a *Usecase) Count(ctx context.Context, opts ...option.QOption) (int64, error) { + if !acl.HaveAccessList(ctx, &models.Option{}) { + return 0, acl.ErrNoPermissions.WithMessage("list") } - return a.baseRepo.Count(ctx, filter) + return a.baseRepo.Count(ctx, opts...) } -// Create new object in database -func (a *Usecase) Set(ctx context.Context, targetObj *model.Option) error { - var err error +// Set creates or updates an option with permission checks +func (a *Usecase) Set(ctx context.Context, targetObj *models.Option) error { switch { - case targetObj.Type == model.UserOptionType && targetObj.TargetID == 0: + case targetObj.Type == models.UserOptionType && targetObj.TargetID == 0: targetObj.TargetID = session.User(ctx).ID - case targetObj.Type == model.AccountOptionType && targetObj.TargetID == 0: + case targetObj.Type == models.AccountOptionType && targetObj.TargetID == 0: targetObj.TargetID = session.Account(ctx).ID } if !acl.HaveObjectPermissions(ctx, targetObj, acl.PermSet+`.*`) { - return errors.Wrap(acl.ErrNoPermissions, "set") + return acl.ErrNoPermissions.WithMessage("set") } - err = a.baseRepo.Set(ctx, targetObj) - return err + return a.baseRepo.Set(ctx, targetObj) } -// SetOption sets option value by name, type and targetID -func (a *Usecase) SetOption(ctx context.Context, name string, otype model.OptionType, targetID uint64, value any) error { - obj := &model.Option{ +// SetOption sets an option value by name, type, and target ID +func (a *Usecase) SetOption(ctx context.Context, name string, otype models.OptionType, targetID uint64, value any) error { + obj := &models.Option{ Type: otype, TargetID: targetID, Name: name, @@ -95,14 +92,14 @@ func (a *Usecase) SetOption(ctx context.Context, name string, otype model.Option return a.baseRepo.Set(ctx, obj) } -// Delete delites record by ID -func (a *Usecase) Delete(ctx context.Context, name string, otype model.OptionType, targetID uint64) error { +// Delete removes an option with permission checks +func (a *Usecase) Delete(ctx context.Context, name string, otype models.OptionType, targetID uint64) error { targetObj, err := a.Get(ctx, name, otype, targetID) if err != nil { return err } if !acl.HaveAccessDelete(ctx, targetObj) { - return errors.Wrap(acl.ErrNoPermissions, "delete") + return acl.ErrNoPermissions.WithMessage("delete") } return a.baseRepo.Delete( historylog.WithPK(ctx, targetObj.Name), diff --git a/repository/option/usecase/usecase_test.go b/repository/option/usecase/usecase_test.go index 1e2a8464..a2e4bbe1 100644 --- a/repository/option/usecase/usecase_test.go +++ b/repository/option/usecase/usecase_test.go @@ -7,19 +7,18 @@ import ( "testing" "github.com/geniusrabbit/gosql/v2" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "go.uber.org/mock/gomock" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/context/session" - "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/option" "github.com/geniusrabbit/blaze-api/repository/option/mocks" + "github.com/geniusrabbit/blaze-api/repository/option/models" ) -var testOption = model.Option{ +var testOption = models.Option{ Name: "opt.name", - Type: model.UserOptionType, + Type: models.UserOptionType, TargetID: 1, Value: *gosql.MustNullableJSON[any](map[string]any{"val": 1}), } @@ -63,13 +62,13 @@ func (s *testSuite) TestFetchList() { FetchList(s.ctx, gomock.AssignableToTypeOf(&option.Filter{}), gomock.AssignableToTypeOf(&option.ListOrder{}), - gomock.AssignableToTypeOf(&repository.Pagination{})). - Return([]*model.Option{{Name: "opt.name1"}, {Name: "opt.name2"}}, nil) + gomock.AssignableToTypeOf(&option.Pagination{})). + Return([]*option.Option{{Name: "opt.name1"}, {Name: "opt.name2"}}, nil) roles, err := s.testUsecase.FetchList(s.ctx, &option.Filter{NamePattern: []string{"opt.%"}}, - &option.ListOrder{Name: model.OrderAsc}, - &repository.Pagination{Size: 100}) + &option.ListOrder{Name: models.OrderAsc}, + &option.Pagination{Size: 100}) s.NoError(err) s.Equal(2, len(roles)) } @@ -86,16 +85,16 @@ func (s *testSuite) TestCount() { func (s *testSuite) TestSet() { s.baseRepo.EXPECT(). - Set(s.ctx, gomock.AssignableToTypeOf(&model.Option{})). + Set(s.ctx, gomock.AssignableToTypeOf(&option.Option{})). Return(nil) - err := s.testUsecase.Set(s.ctx, &model.Option{Name: "test1"}) + err := s.testUsecase.Set(s.ctx, &option.Option{Name: "test1"}) s.NoError(err) } func (s *testSuite) TestSetOption() { s.baseRepo.EXPECT(). - Set(s.ctx, gomock.AssignableToTypeOf(&model.Option{})). + Set(s.ctx, gomock.AssignableToTypeOf(&option.Option{})). Return(nil) err := s.testUsecase.SetOption(s.ctx, diff --git a/repository/options.go b/repository/options.go index bd60bd0b..cf866fe9 100644 --- a/repository/options.go +++ b/repository/options.go @@ -1,12 +1,17 @@ package repository import ( + "context" "reflect" "github.com/demdxx/xtypes" "gorm.io/gorm" ) +type QueryPermissionAdjuster interface { + AdjustPermissions(ctx context.Context) error +} + // QOption prepare query type QOption interface { PrepareQuery(query *gorm.DB) *gorm.DB @@ -79,7 +84,9 @@ func (opts ListOptions) With(prep QOption) ListOptions { func (opts ListOptions) PrepareQuery(query *gorm.DB) *gorm.DB { for _, opt := range opts { - query = opt.PrepareQuery(query) + if opt != nil { + query = opt.PrepareQuery(query) + } } return query } @@ -100,3 +107,20 @@ func (opts ListOptions) PrepareAfterQuery(query *gorm.DB, idCol string, orderCol } return query } + +// WithPermissions finds the first QOption implementing QueryPermissionAdjuster and calls it. +// If no such option is found, appends defaultOpt and adjusts it. +// Returns the (possibly extended) opts slice and any adjustment error. +func (opts ListOptions) WithPermissions(ctx context.Context, defaultOpt QOption) (ListOptions, error) { + for _, opt := range opts { + if adj, ok := opt.(QueryPermissionAdjuster); ok { + return opts, adj.AdjustPermissions(ctx) + } + } + if adj, ok := defaultOpt.(QueryPermissionAdjuster); ok { + if err := adj.AdjustPermissions(ctx); err != nil { + return nil, err + } + } + return append(opts, defaultOpt), nil +} diff --git a/repository/rbac/delivery/graphql/connector.go b/repository/rbac/delivery/graphql/connector.go new file mode 100644 index 00000000..a67c3a41 --- /dev/null +++ b/repository/rbac/delivery/graphql/connector.go @@ -0,0 +1,59 @@ +package graphql + +import ( + "context" + + "github.com/demdxx/gocast/v2" + "github.com/geniusrabbit/blaze-api/repository/rbac" + "github.com/geniusrabbit/blaze-api/repository/rbac/models" + "github.com/geniusrabbit/blaze-api/server/graphql/connectors" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" +) + +// RBACRoleConnection implements collection accessor interface with pagination +type RBACRoleConnection = connectors.CollectionConnection[gqlmodels.RBACRole, gqlmodels.RBACRoleEdge] + +// NewRBACRoleConnection based on query object +func NewRBACRoleConnection(ctx context.Context, rolesAccessor rbac.Usecase, filter *gqlmodels.RBACRoleListFilter, order *gqlmodels.RBACRoleListOrder, page *gqlmodels.Page) *RBACRoleConnection { + return connectors.NewCollectionConnection(ctx, &connectors.DataAccessorFunc[gqlmodels.RBACRole, gqlmodels.RBACRoleEdge]{ + FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.RBACRole, error) { + roles, err := rolesAccessor.FetchList(ctx, + filter.Filter(), order.Order(), page.Pagination()) + return FromRBACRoleModelList(ctx, roles), err + }, + CountDataFunc: func(ctx context.Context) (int64, error) { + return rolesAccessor.Count(ctx, filter.Filter()) + }, + ConvertToEdgeFunc: func(obj *gqlmodels.RBACRole) *gqlmodels.RBACRoleEdge { + return &gqlmodels.RBACRoleEdge{ + Cursor: gocast.Str(obj.ID), + Node: obj, + } + }, + }, page) +} + +// NewRBACRoleConnectionByIDs based on query object +func NewRBACRoleConnectionByIDs(ctx context.Context, rolesPepo rbac.Repository, ids []uint64, order *gqlmodels.RBACRoleListOrder) *RBACRoleConnection { + return connectors.NewCollectionConnection(ctx, &connectors.DataAccessorFunc[gqlmodels.RBACRole, gqlmodels.RBACRoleEdge]{ + FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.RBACRole, error) { + var ( + roles []*models.Role + err error + ) + if len(ids) > 0 { + roles, err = rolesPepo.FetchList(ctx, &rbac.Filter{ID: ids}, order.Order()) + } + return FromRBACRoleModelList(ctx, roles), err + }, + CountDataFunc: func(ctx context.Context) (int64, error) { + return int64(len(ids)), nil + }, + ConvertToEdgeFunc: func(obj *gqlmodels.RBACRole) *gqlmodels.RBACRoleEdge { + return &gqlmodels.RBACRoleEdge{ + Cursor: gocast.Str(obj.ID), + Node: obj, + } + }, + }, nil) +} diff --git a/repository/rbac/delivery/graphql/mapping.go b/repository/rbac/delivery/graphql/mapping.go new file mode 100644 index 00000000..104c95c1 --- /dev/null +++ b/repository/rbac/delivery/graphql/mapping.go @@ -0,0 +1,87 @@ +package graphql + +import ( + "context" + "strings" + + "github.com/demdxx/gocast/v2" + mrbac "github.com/demdxx/rbac" + "github.com/demdxx/xtypes" + + "github.com/geniusrabbit/blaze-api/pkg/permissions" + "github.com/geniusrabbit/blaze-api/repository/rbac/models" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" + "github.com/geniusrabbit/blaze-api/server/graphql/types" +) + +func FromRBACPermissionModel(perm mrbac.Permission) *gqlmodels.RBACPermission { + type rname interface { + ResourceName() string + } + var ( + name = perm.Name() + objName string + access string + ) + if r, ok := perm.(rname); ok { + objName = r.ResourceName() + name = name[len(objName)+1:] + if strings.HasSuffix(name, `.owner`) || strings.HasSuffix(name, `.account`) || + strings.HasSuffix(name, `.all`) || strings.HasSuffix(name, `.system`) { + access = name[strings.LastIndex(name, `.`)+1:] + name = name[:len(name)-len(access)-1] + } + } + return &gqlmodels.RBACPermission{ + Fullname: perm.Name(), + Name: name, + Object: objName, + Access: access, + Description: gocast.Ptr(perm.Description()), + } +} + +// FromRBACPermissionModelList converts model list to local model list +func FromRBACPermissionModelList(perms []mrbac.Permission) []*gqlmodels.RBACPermission { + return xtypes.SliceApply(perms, FromRBACPermissionModel). + Sort(func(a, b *gqlmodels.RBACPermission) bool { + if a.Object < b.Object { + return true + } + if a.Object != b.Object { + return false + } + if a.Name < b.Name { + return true + } + return a.Name == b.Name && a.Access < b.Access + }) +} + +// FromRBACRoleModel to local graphql model +func FromRBACRoleModel(ctx context.Context, role *models.Role) *gqlmodels.RBACRole { + perms := permissions.FromContext(ctx).Permissions(role.PermissionPatterns...) + return &gqlmodels.RBACRole{ + ID: role.ID, + Name: role.Name, + Title: role.Title, + + Description: gocast.Ptr(role.Description), + + Context: types.MustNullableJSONFrom(role.Context.Data), + + Permissions: FromRBACPermissionModelList(perms), + PermissionPatterns: role.PermissionPatterns, + + CreatedAt: role.CreatedAt, + UpdatedAt: role.UpdatedAt, + DeletedAt: gqlmodels.DeletedAt(role.DeletedAt), + } +} + +// FromRBACRoleModelList converts model list to local model list +func FromRBACRoleModelList(ctx context.Context, list []*models.Role) []*gqlmodels.RBACRole { + return xtypes.SliceApply(list, func(val *models.Role) *gqlmodels.RBACRole { + return FromRBACRoleModel(ctx, val) + }) +} diff --git a/protocol/graphql/schemas/rbac.graphql b/repository/rbac/delivery/graphql/rbac.graphql similarity index 100% rename from protocol/graphql/schemas/rbac.graphql rename to repository/rbac/delivery/graphql/rbac.graphql diff --git a/repository/rbac/delivery/graphql/resolver.go b/repository/rbac/delivery/graphql/resolver.go index ae7f899b..74b41f53 100644 --- a/repository/rbac/delivery/graphql/resolver.go +++ b/repository/rbac/delivery/graphql/resolver.go @@ -9,15 +9,12 @@ import ( "github.com/pkg/errors" "go.uber.org/zap" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" "github.com/geniusrabbit/blaze-api/pkg/context/session" "github.com/geniusrabbit/blaze-api/pkg/permissions" "github.com/geniusrabbit/blaze-api/pkg/requestid" - rbacGen "github.com/geniusrabbit/blaze-api/repository/rbac" - "github.com/geniusrabbit/blaze-api/repository/rbac/repository" - "github.com/geniusrabbit/blaze-api/repository/rbac/usecase" - "github.com/geniusrabbit/blaze-api/server/graphql/connectors" + "github.com/geniusrabbit/blaze-api/repository/historylog" + "github.com/geniusrabbit/blaze-api/repository/rbac" gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) @@ -28,14 +25,12 @@ var ( // QueryResolver implements GQL API methods type QueryResolver struct { - roles rbacGen.Usecase + roles rbac.Usecase } // NewQueryResolver returns new API resolver -func NewQueryResolver() *QueryResolver { - return &QueryResolver{ - roles: usecase.New(repository.New()), - } +func NewQueryResolver(uc rbac.Usecase) *QueryResolver { + return &QueryResolver{roles: uc} } // Role is the resolver for the Role field. @@ -47,7 +42,7 @@ func (r *QueryResolver) Role(ctx context.Context, id uint64) (*gqlmodels.RBACRol return &gqlmodels.RBACRolePayload{ ClientMutationID: requestid.Get(ctx), RoleID: role.ID, - Role: gqlmodels.FromRBACRoleModel(ctx, role), + Role: FromRBACRoleModel(ctx, role), }, nil } @@ -109,13 +104,13 @@ func (r *QueryResolver) Check(ctx context.Context, name string, key, targetID, i } // ListRoles is the resolver for the listRoles field. -func (r *QueryResolver) ListRoles(ctx context.Context, filter *gqlmodels.RBACRoleListFilter, order *gqlmodels.RBACRoleListOrder, page *gqlmodels.Page) (*connectors.RBACRoleConnection, error) { - return connectors.NewRBACRoleConnection(ctx, r.roles, filter, order, page), nil +func (r *QueryResolver) ListRoles(ctx context.Context, filter *gqlmodels.RBACRoleListFilter, order *gqlmodels.RBACRoleListOrder, page *gqlmodels.Page) (*RBACRoleConnection, error) { + return NewRBACRoleConnection(ctx, r.roles, filter, order, page), nil } // CreateRole is the resolver for the createRole field. func (r *QueryResolver) CreateRole(ctx context.Context, input *gqlmodels.RBACRoleInput) (*gqlmodels.RBACRolePayload, error) { - roleObj := &model.Role{ + roleObj := &rbac.Role{ Name: gocast.PtrAsValue(input.Name, ""), Title: gocast.PtrAsValue(input.Title, ""), } @@ -135,7 +130,7 @@ func (r *QueryResolver) CreateRole(ctx context.Context, input *gqlmodels.RBACRol return &gqlmodels.RBACRolePayload{ ClientMutationID: requestid.Get(ctx), RoleID: id, - Role: gqlmodels.FromRBACRoleModel(ctx, roleObj), + Role: FromRBACRoleModel(ctx, roleObj), }, nil } @@ -159,13 +154,13 @@ func (r *QueryResolver) UpdateRole(ctx context.Context, id uint64, input *gqlmod return &gqlmodels.RBACRolePayload{ ClientMutationID: requestid.Get(ctx), RoleID: id, - Role: gqlmodels.FromRBACRoleModel(ctx, role), + Role: FromRBACRoleModel(ctx, role), }, nil } // DeleteRole is the resolver for the deleteRole field. func (r *QueryResolver) DeleteRole(ctx context.Context, id uint64, msg *string) (*gqlmodels.RBACRolePayload, error) { - err := r.roles.Delete(ctx, id) + err := r.roles.Delete(ctx, id, historylog.Message(gocast.PtrAsValue(msg, ""))) if err != nil { return nil, err } @@ -176,17 +171,17 @@ func (r *QueryResolver) DeleteRole(ctx context.Context, id uint64, msg *string) return &gqlmodels.RBACRolePayload{ ClientMutationID: requestid.Get(ctx), RoleID: id, - Role: gqlmodels.FromRBACRoleModel(ctx, role), + Role: FromRBACRoleModel(ctx, role), }, nil } // ListPermissions is the resolver for the listPermissions field. func (r *QueryResolver) ListPermissions(ctx context.Context, patterns []string) ([]*gqlmodels.RBACPermission, error) { list := permissions.FromContext(ctx).Permissions(patterns...) - return gqlmodels.FromRBACPermissionModelList(list), nil + return FromRBACPermissionModelList(list), nil } func (r *QueryResolver) ListMyPermissions(ctx context.Context, patterns []string) ([]*gqlmodels.RBACPermission, error) { list := session.Account(ctx).ListPermissions() - return gqlmodels.FromRBACPermissionModelList(list), nil + return FromRBACPermissionModelList(list), nil } diff --git a/repository/rbac/delivery/graphql/utils.go b/repository/rbac/delivery/graphql/utils.go index 2f25aab9..69d3815c 100644 --- a/repository/rbac/delivery/graphql/utils.go +++ b/repository/rbac/delivery/graphql/utils.go @@ -5,7 +5,8 @@ import ( "reflect" "github.com/demdxx/gocast/v2" - "github.com/geniusrabbit/blaze-api/model" + accountModels "github.com/geniusrabbit/blaze-api/repository/account/models" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" ) type ( @@ -17,14 +18,14 @@ type ( } ) -func ownedObject(ctx context.Context, obj any, user *model.User, acc *model.Account) any { +func ownedObject(ctx context.Context, obj any, user *userModels.User, acc *accountModels.Account) any { switch obj.(type) { case nil: return nil - case *model.Account, model.Account: - return &model.Account{ID: acc.ID, Admins: []uint64{user.ID}} - case *model.User, model.User: - return &model.User{ID: user.ID} + case *accountModels.Account, accountModels.Account: + return &accountModels.Account{ID: acc.ID, Admins: []uint64{user.ID}} + case *userModels.User, userModels.User: + return &userModels.User{ID: user.ID} } // Get object struct type value diff --git a/repository/rbac/mocks/repository.go b/repository/rbac/mocks/repository.go index 4339cb00..9066a044 100644 --- a/repository/rbac/mocks/repository.go +++ b/repository/rbac/mocks/repository.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: repository.go +// +// Generated by this command: +// +// mockgen -source repository.go -package mocks -destination mocks/repository.go +// // Package mocks is a generated GoMock package. package mocks @@ -8,16 +13,16 @@ import ( context "context" reflect "reflect" - model "github.com/geniusrabbit/blaze-api/model" - repository "github.com/geniusrabbit/blaze-api/repository" + generated "github.com/geniusrabbit/blaze-api/repository/generated" rbac "github.com/geniusrabbit/blaze-api/repository/rbac" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockRepository is a mock of Repository interface. type MockRepository struct { ctrl *gomock.Controller recorder *MockRepositoryMockRecorder + isgomock struct{} } // MockRepositoryMockRecorder is the mock recorder for MockRepository. @@ -38,104 +43,134 @@ func (m *MockRepository) EXPECT() *MockRepositoryMockRecorder { } // Count mocks base method. -func (m *MockRepository) Count(ctx context.Context, filter *rbac.Filter) (int64, error) { +func (m *MockRepository) Count(ctx context.Context, qops ...generated.Option) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range qops { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockRepositoryMockRecorder) Count(ctx, filter interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Count(ctx any, qops ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), ctx, filter) + varargs := append([]any{ctx}, qops...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), varargs...) } // Create mocks base method. -func (m *MockRepository) Create(ctx context.Context, role *model.Role) (uint64, error) { +func (m *MockRepository) Create(ctx context.Context, obj *rbac.Role, opts ...generated.Option) (uint64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", ctx, role) + varargs := []any{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Create", varargs...) ret0, _ := ret[0].(uint64) ret1, _ := ret[1].(error) return ret0, ret1 } // Create indicates an expected call of Create. -func (mr *MockRepositoryMockRecorder) Create(ctx, role interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Create(ctx, obj any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockRepository)(nil).Create), ctx, role) + varargs := append([]any{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockRepository)(nil).Create), varargs...) } // Delete mocks base method. -func (m *MockRepository) Delete(ctx context.Context, id uint64) error { +func (m *MockRepository) Delete(ctx context.Context, id uint64, opts ...generated.Option) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Delete", ctx, id) + varargs := []any{ctx, id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Delete", varargs...) ret0, _ := ret[0].(error) return ret0 } // Delete indicates an expected call of Delete. -func (mr *MockRepositoryMockRecorder) Delete(ctx, id interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Delete(ctx, id any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRepository)(nil).Delete), ctx, id) + varargs := append([]any{ctx, id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRepository)(nil).Delete), varargs...) } // FetchList mocks base method. -func (m *MockRepository) FetchList(ctx context.Context, filter *rbac.Filter, order *rbac.Order, pagination *repository.Pagination) ([]*model.Role, error) { +func (m *MockRepository) FetchList(ctx context.Context, qops ...generated.Option) ([]*rbac.Role, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter, order, pagination) - ret0, _ := ret[0].([]*model.Role) + varargs := []any{ctx} + for _, a := range qops { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*rbac.Role) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockRepositoryMockRecorder) FetchList(ctx, filter, order, pagination interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) FetchList(ctx any, qops ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), ctx, filter, order, pagination) + varargs := append([]any{ctx}, qops...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), varargs...) } // Get mocks base method. -func (m *MockRepository) Get(ctx context.Context, id uint64) (*model.Role, error) { +func (m *MockRepository) Get(ctx context.Context, id uint64, qops ...generated.Option) (*rbac.Role, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, id) - ret0, _ := ret[0].(*model.Role) + varargs := []any{ctx, id} + for _, a := range qops { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Get", varargs...) + ret0, _ := ret[0].(*rbac.Role) ret1, _ := ret[1].(error) return ret0, ret1 } // Get indicates an expected call of Get. -func (mr *MockRepositoryMockRecorder) Get(ctx, id interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Get(ctx, id any, qops ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRepository)(nil).Get), ctx, id) + varargs := append([]any{ctx, id}, qops...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRepository)(nil).Get), varargs...) } // GetByName mocks base method. -func (m *MockRepository) GetByName(ctx context.Context, name string) (*model.Role, error) { +func (m *MockRepository) GetByName(ctx context.Context, name string) (*rbac.Role, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetByName", ctx, name) - ret0, _ := ret[0].(*model.Role) + ret0, _ := ret[0].(*rbac.Role) ret1, _ := ret[1].(error) return ret0, ret1 } // GetByName indicates an expected call of GetByName. -func (mr *MockRepositoryMockRecorder) GetByName(ctx, name interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) GetByName(ctx, name any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByName", reflect.TypeOf((*MockRepository)(nil).GetByName), ctx, name) } // Update mocks base method. -func (m *MockRepository) Update(ctx context.Context, id uint64, role *model.Role) error { +func (m *MockRepository) Update(ctx context.Context, id uint64, obj *rbac.Role, opts ...generated.Option) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Update", ctx, id, role) + varargs := []any{ctx, id, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Update", varargs...) ret0, _ := ret[0].(error) return ret0 } // Update indicates an expected call of Update. -func (mr *MockRepositoryMockRecorder) Update(ctx, id, role interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Update(ctx, id, obj any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockRepository)(nil).Update), ctx, id, role) + varargs := append([]any{ctx, id, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockRepository)(nil).Update), varargs...) } diff --git a/repository/rbac/mocks/usecase.go b/repository/rbac/mocks/usecase.go index fe67732b..69194dc3 100644 --- a/repository/rbac/mocks/usecase.go +++ b/repository/rbac/mocks/usecase.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: usecase.go +// +// Generated by this command: +// +// mockgen -source usecase.go -package mocks -destination mocks/usecase.go +// // Package mocks is a generated GoMock package. package mocks @@ -8,16 +13,16 @@ import ( context "context" reflect "reflect" - model "github.com/geniusrabbit/blaze-api/model" - repository "github.com/geniusrabbit/blaze-api/repository" + generated "github.com/geniusrabbit/blaze-api/repository/generated" rbac "github.com/geniusrabbit/blaze-api/repository/rbac" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockUsecase is a mock of Usecase interface. type MockUsecase struct { ctrl *gomock.Controller recorder *MockUsecaseMockRecorder + isgomock struct{} } // MockUsecaseMockRecorder is the mock recorder for MockUsecase. @@ -38,104 +43,134 @@ func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder { } // Count mocks base method. -func (m *MockUsecase) Count(ctx context.Context, filter *rbac.Filter) (int64, error) { +func (m *MockUsecase) Count(ctx context.Context, qops ...generated.Option) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range qops { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockUsecaseMockRecorder) Count(ctx, filter interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Count(ctx any, qops ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), ctx, filter) + varargs := append([]any{ctx}, qops...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), varargs...) } // Create mocks base method. -func (m *MockUsecase) Create(ctx context.Context, role *model.Role) (uint64, error) { +func (m *MockUsecase) Create(ctx context.Context, obj *rbac.Role, opts ...generated.Option) (uint64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", ctx, role) + varargs := []any{ctx, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Create", varargs...) ret0, _ := ret[0].(uint64) ret1, _ := ret[1].(error) return ret0, ret1 } // Create indicates an expected call of Create. -func (mr *MockUsecaseMockRecorder) Create(ctx, role interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Create(ctx, obj any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockUsecase)(nil).Create), ctx, role) + varargs := append([]any{ctx, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockUsecase)(nil).Create), varargs...) } // Delete mocks base method. -func (m *MockUsecase) Delete(ctx context.Context, id uint64) error { +func (m *MockUsecase) Delete(ctx context.Context, id uint64, opts ...generated.Option) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Delete", ctx, id) + varargs := []any{ctx, id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Delete", varargs...) ret0, _ := ret[0].(error) return ret0 } // Delete indicates an expected call of Delete. -func (mr *MockUsecaseMockRecorder) Delete(ctx, id interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Delete(ctx, id any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockUsecase)(nil).Delete), ctx, id) + varargs := append([]any{ctx, id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockUsecase)(nil).Delete), varargs...) } // FetchList mocks base method. -func (m *MockUsecase) FetchList(ctx context.Context, filter *rbac.Filter, order *rbac.Order, pagination *repository.Pagination) ([]*model.Role, error) { +func (m *MockUsecase) FetchList(ctx context.Context, qops ...generated.Option) ([]*rbac.Role, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter, order, pagination) - ret0, _ := ret[0].([]*model.Role) + varargs := []any{ctx} + for _, a := range qops { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*rbac.Role) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockUsecaseMockRecorder) FetchList(ctx, filter, order, pagination interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) FetchList(ctx any, qops ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), ctx, filter, order, pagination) + varargs := append([]any{ctx}, qops...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), varargs...) } // Get mocks base method. -func (m *MockUsecase) Get(ctx context.Context, id uint64) (*model.Role, error) { +func (m *MockUsecase) Get(ctx context.Context, id uint64, qops ...generated.Option) (*rbac.Role, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, id) - ret0, _ := ret[0].(*model.Role) + varargs := []any{ctx, id} + for _, a := range qops { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Get", varargs...) + ret0, _ := ret[0].(*rbac.Role) ret1, _ := ret[1].(error) return ret0, ret1 } // Get indicates an expected call of Get. -func (mr *MockUsecaseMockRecorder) Get(ctx, id interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Get(ctx, id any, qops ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockUsecase)(nil).Get), ctx, id) + varargs := append([]any{ctx, id}, qops...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockUsecase)(nil).Get), varargs...) } // GetByName mocks base method. -func (m *MockUsecase) GetByName(ctx context.Context, title string) (*model.Role, error) { +func (m *MockUsecase) GetByName(ctx context.Context, title string) (*rbac.Role, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetByName", ctx, title) - ret0, _ := ret[0].(*model.Role) + ret0, _ := ret[0].(*rbac.Role) ret1, _ := ret[1].(error) return ret0, ret1 } // GetByName indicates an expected call of GetByName. -func (mr *MockUsecaseMockRecorder) GetByName(ctx, title interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) GetByName(ctx, title any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByName", reflect.TypeOf((*MockUsecase)(nil).GetByName), ctx, title) } // Update mocks base method. -func (m *MockUsecase) Update(ctx context.Context, id uint64, role *model.Role) error { +func (m *MockUsecase) Update(ctx context.Context, id uint64, obj *rbac.Role, opts ...generated.Option) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Update", ctx, id, role) + varargs := []any{ctx, id, obj} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Update", varargs...) ret0, _ := ret[0].(error) return ret0 } // Update indicates an expected call of Update. -func (mr *MockUsecaseMockRecorder) Update(ctx, id, role interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Update(ctx, id, obj any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockUsecase)(nil).Update), ctx, id, role) + varargs := append([]any{ctx, id, obj}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockUsecase)(nil).Update), varargs...) } diff --git a/repository/rbac/models.go b/repository/rbac/models.go new file mode 100644 index 00000000..6bf81246 --- /dev/null +++ b/repository/rbac/models.go @@ -0,0 +1,15 @@ +package rbac + +import "github.com/geniusrabbit/blaze-api/repository/rbac/models" + +type ( + Role = models.Role + M2MRole = models.M2MRole +) + +const ( + AccessLevelBasic = models.AccessLevelBasic + AccessLevelNoAnonymous = models.AccessLevelNoAnonymous + AccessLevelAccount = models.AccessLevelAccount + AccessLevelSystem = models.AccessLevelSystem +) diff --git a/repository/rbac/models/m2m_role.go b/repository/rbac/models/m2m_role.go new file mode 100644 index 00000000..2a9d12a9 --- /dev/null +++ b/repository/rbac/models/m2m_role.go @@ -0,0 +1,15 @@ +package models + +import "time" + +// M2MRole link parent and child role +type M2MRole struct { + ParentRoleID uint64 `db:"parent_role_id" gorm:"primaryKey"` + ChildRoleID uint64 `db:"child_role_id" gorm:"primaryKey"` + CreatedAt time.Time `db:"created_at"` +} + +// TableName of the model in the database +func (m2m *M2MRole) TableName() string { + return `m2m_rbac_role` +} diff --git a/model/rbac_role.go b/repository/rbac/models/role.go similarity index 82% rename from model/rbac_role.go rename to repository/rbac/models/role.go index ceb32408..9eb2db19 100644 --- a/model/rbac_role.go +++ b/repository/rbac/models/role.go @@ -1,4 +1,4 @@ -package model +package models import ( "time" @@ -15,18 +15,6 @@ const ( AccessLevelSystem = 3 ) -// M2MRole link parent and child role -type M2MRole struct { - ParentRoleID uint64 `db:"parent_role_id" gorm:"primaryKey"` - ChildRoleID uint64 `db:"child_role_id" gorm:"primaryKey"` - CreatedAt time.Time `db:"created_at"` -} - -// TableName of the model in the database -func (m2m *M2MRole) TableName() string { - return `m2m_rbac_role` -} - // Role base model type Role struct { ID uint64 `db:"id"` @@ -81,3 +69,23 @@ func (role *Role) ContextItem(name string) any { func (role *Role) ContextItemString(name string) string { return gocast.Str(role.ContextItem(name)) } + +// SetUpdatedAt sets the updated_at field +func (role *Role) SetUpdatedAt(t time.Time) { + role.UpdatedAt = t +} + +// GetID returns the role ID +func (role Role) GetID() uint64 { + return role.ID +} + +// SetID sets the role ID +func (role *Role) SetID(id uint64) { + role.ID = id +} + +// SetCreatedAt sets the created_at field +func (role *Role) SetCreatedAt(t time.Time) { + role.CreatedAt = t +} diff --git a/model/rbac_role_test.go b/repository/rbac/models/role_test.go similarity index 92% rename from model/rbac_role_test.go rename to repository/rbac/models/role_test.go index 11d12c48..9c03e3bf 100644 --- a/model/rbac_role_test.go +++ b/repository/rbac/models/role_test.go @@ -1,4 +1,4 @@ -package model +package models import ( "testing" diff --git a/repository/rbac/query.go b/repository/rbac/query.go index 8640512c..bfb6831e 100644 --- a/repository/rbac/query.go +++ b/repository/rbac/query.go @@ -1,8 +1,10 @@ package rbac import ( - "github.com/geniusrabbit/blaze-api/model" "gorm.io/gorm" + + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" + "github.com/geniusrabbit/blaze-api/repository" ) // Filter of the objects list @@ -36,12 +38,12 @@ func (fl *Filter) PrepareQuery(query *gorm.DB) *gorm.DB { // Order of the objects list type Order struct { - ID model.Order - Name model.Order - Title model.Order - AccessLevel model.Order - CreatedAt model.Order - UpdatedAt model.Order + ID pkgModels.Order + Name pkgModels.Order + Title pkgModels.Order + AccessLevel pkgModels.Order + CreatedAt pkgModels.Order + UpdatedAt pkgModels.Order } func (o *Order) PrepareQuery(query *gorm.DB) *gorm.DB { @@ -56,3 +58,8 @@ func (o *Order) PrepareQuery(query *gorm.DB) *gorm.DB { query = o.UpdatedAt.PrepareQuery(query, `updated_at`) return query } + +type ( + QOption = repository.QOption + ListOptions = repository.ListOptions +) diff --git a/repository/rbac/repository.go b/repository/rbac/repository.go index 22155b5d..0e4303dd 100644 --- a/repository/rbac/repository.go +++ b/repository/rbac/repository.go @@ -4,19 +4,13 @@ package rbac import ( "context" - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" + "github.com/geniusrabbit/blaze-api/repository/generated" ) // Repository of access to the account // //go:generate mockgen -source $GOFILE -package mocks -destination mocks/repository.go type Repository interface { - Get(ctx context.Context, id uint64) (*model.Role, error) - GetByName(ctx context.Context, name string) (*model.Role, error) - FetchList(ctx context.Context, filter *Filter, order *Order, pagination *repository.Pagination) ([]*model.Role, error) - Count(ctx context.Context, filter *Filter) (int64, error) - Create(ctx context.Context, role *model.Role) (uint64, error) - Update(ctx context.Context, id uint64, role *model.Role) error - Delete(ctx context.Context, id uint64) error + generated.RepositoryIface[Role, uint64] + GetByName(ctx context.Context, name string) (*Role, error) } diff --git a/repository/rbac/repository/role_repository.go b/repository/rbac/repository/role_repository.go index 3efabd8d..1fffea02 100644 --- a/repository/rbac/repository/role_repository.go +++ b/repository/rbac/repository/role_repository.go @@ -3,87 +3,28 @@ package repository import ( "context" - "time" - "github.com/pkg/errors" - "gorm.io/gorm" - - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" + "github.com/geniusrabbit/blaze-api/repository/generated" "github.com/geniusrabbit/blaze-api/repository/rbac" ) // Repository DAO which provides functionality of working with RBAC roles type Repository struct { - repository.Repository + generated.Repository[rbac.Role, uint64] } // New role repository func New() *Repository { - return &Repository{} -} - -// Get returns RBAC role model by ID -func (r *Repository) Get(ctx context.Context, id uint64) (*model.Role, error) { - object := new(model.Role) - if err := r.Slave(ctx).Find(object, id).Error; err != nil { - return nil, err + return &Repository{ + Repository: *generated.NewRepository[rbac.Role, uint64](), } - return object, nil } -// GetByName returns RBAC role model by title -func (r *Repository) GetByName(ctx context.Context, title string) (*model.Role, error) { - object := new(model.Role) - if err := r.Slave(ctx).Find(object, `name=?`, title).Error; err != nil { +// GetByName returns RBAC role model by name +func (r *Repository) GetByName(ctx context.Context, name string) (*rbac.Role, error) { + object := new(rbac.Role) + if err := r.Slave(ctx).Find(object, `name=?`, name).Error; err != nil { return nil, err } return object, nil } - -// FetchList returns list of RBAC roles by filter -func (r *Repository) FetchList(ctx context.Context, filter *rbac.Filter, order *rbac.Order, pagination *repository.Pagination) ([]*model.Role, error) { - var ( - list []*model.Role - query = r.Slave(ctx).Model((*model.Role)(nil)) - ) - query = filter.PrepareQuery(query) - query = order.PrepareQuery(query) - query = pagination.PrepareQuery(query) - err := query.Find(&list).Error - if errors.Is(err, gorm.ErrRecordNotFound) { - err = nil - } - return list, err -} - -// Count returns count of RBAC roles by filter -func (r *Repository) Count(ctx context.Context, filter *rbac.Filter) (int64, error) { - var ( - count int64 - query = r.Slave(ctx).Model((*model.Role)(nil)) - ) - query = filter.PrepareQuery(query) - err := query.Count(&count).Error - return count, err -} - -// Create new object into database -func (r *Repository) Create(ctx context.Context, roleObj *model.Role) (uint64, error) { - roleObj.CreatedAt = time.Now() - roleObj.UpdatedAt = roleObj.CreatedAt - err := r.Master(ctx).Create(roleObj).Error - return roleObj.ID, err -} - -// Update existing object in database -func (r *Repository) Update(ctx context.Context, id uint64, roleObj *model.Role) error { - obj := *roleObj - obj.ID = id - return r.Master(ctx).Updates(&obj).Error -} - -// Delete delites record by ID -func (r *Repository) Delete(ctx context.Context, id uint64) error { - return r.Master(ctx).Model((*model.Role)(nil)).Delete(`id=?`, id).Error -} diff --git a/repository/rbac/repository/role_test.go b/repository/rbac/repository/role_test.go index c1c3af47..c4b9a93e 100644 --- a/repository/rbac/repository/role_test.go +++ b/repository/rbac/repository/role_test.go @@ -7,8 +7,9 @@ import ( sqlmock "github.com/DATA-DOG/go-sqlmock" "github.com/stretchr/testify/suite" - "github.com/geniusrabbit/blaze-api/model" + "github.com/geniusrabbit/blaze-api/repository/historylog" "github.com/geniusrabbit/blaze-api/repository/rbac" + "github.com/geniusrabbit/blaze-api/repository/rbac/models" "github.com/geniusrabbit/blaze-api/repository/testsuite" ) @@ -25,7 +26,7 @@ func (s *testSuite) SetupSuite() { func (s *testSuite) TestGet() { s.Mock.ExpectQuery("SELECT *"). - WithArgs(1). + WithArgs(uint64(1), 1). WillReturnRows( sqlmock.NewRows([]string{"id", "status", "title", "description", "created_at"}). AddRow(1, 1, "title1", "description1", time.Now()), @@ -57,7 +58,7 @@ func (s *testSuite) TestFetchList() { AddRow(2, "role", "title2", "test2", time.Now()), ) roles, err := s.roleRepo.FetchList(s.Ctx, &rbac.Filter{ - ID: []uint64{1, 2}}, nil, nil) + ID: []uint64{1, 2}}) s.NoError(err) s.Equal(2, len(roles)) } @@ -74,13 +75,12 @@ func (s *testSuite) TestCreate() { s.Mock.ExpectQuery("INSERT INTO"). WithArgs(sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg(), sqlmock.AnyArg()). WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(101)) - id, err := s.roleRepo.Create( - s.Ctx, - &model.Role{ - ID: 101, - Name: "test", - Title: "test", - }) + testRole := &models.Role{ + ID: 101, + Name: "test", + Title: "test", + } + id, err := s.roleRepo.Create(s.Ctx, testRole, historylog.Message("create role")) s.NoError(err) s.Equal(uint64(101), id) } @@ -89,7 +89,7 @@ func (s *testSuite) TestUpdate() { s.Mock.ExpectExec("UPDATE"). WithArgs("test", sqlmock.AnyArg(), uint64(101)). WillReturnResult(sqlmock.NewResult(101, 1)) - err := s.roleRepo.Update(s.Ctx, 101, &model.Role{Title: "test"}) + err := s.roleRepo.Update(s.Ctx, 101, &models.Role{Title: "test"}, historylog.Message("update role")) s.NoError(err) } @@ -97,7 +97,7 @@ func (s *testSuite) TestDelete() { s.Mock.ExpectExec("UPDATE"). WithArgs(sqlmock.AnyArg(), uint64(101)). WillReturnResult(sqlmock.NewResult(101, 1)) - err := s.roleRepo.Delete(s.Ctx, 101) + err := s.roleRepo.Delete(s.Ctx, 101, historylog.Message("delete role")) s.NoError(err) } diff --git a/repository/rbac/usecase.go b/repository/rbac/usecase.go index 34508a35..92105588 100644 --- a/repository/rbac/usecase.go +++ b/repository/rbac/usecase.go @@ -3,19 +3,13 @@ package rbac import ( "context" - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" + "github.com/geniusrabbit/blaze-api/repository/generated" ) // Usecase of the account // //go:generate mockgen -source $GOFILE -package mocks -destination mocks/usecase.go type Usecase interface { - Get(ctx context.Context, id uint64) (*model.Role, error) - GetByName(ctx context.Context, title string) (*model.Role, error) - FetchList(ctx context.Context, filter *Filter, order *Order, pagination *repository.Pagination) ([]*model.Role, error) - Count(ctx context.Context, filter *Filter) (int64, error) - Create(ctx context.Context, role *model.Role) (uint64, error) - Update(ctx context.Context, id uint64, role *model.Role) error - Delete(ctx context.Context, id uint64) error + generated.UsecaseIface[Role, uint64] + GetByName(ctx context.Context, title string) (*Role, error) } diff --git a/repository/rbac/usecase/role_test.go b/repository/rbac/usecase/role_test.go index f0bdd93d..3c0ce6b3 100644 --- a/repository/rbac/usecase/role_test.go +++ b/repository/rbac/usecase/role_test.go @@ -6,13 +6,13 @@ import ( "errors" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "go.uber.org/mock/gomock" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/context/session" "github.com/geniusrabbit/blaze-api/repository/rbac" "github.com/geniusrabbit/blaze-api/repository/rbac/mocks" + rbacModels "github.com/geniusrabbit/blaze-api/repository/rbac/models" ) type testSuite struct { @@ -33,7 +33,7 @@ func (s *testSuite) SetupSuite() { func (s *testSuite) TestGet() { s.roleRepo.EXPECT().Get(s.ctx, uint64(2)). - Return(&model.Role{ID: 2}, nil) + Return(&rbacModels.Role{ID: 2}, nil) role, err := s.roleUsecase.Get(s.ctx, 2) s.NoError(err) @@ -43,7 +43,7 @@ func (s *testSuite) TestGet() { func (s *testSuite) TestGetByName() { const name = "test" s.roleRepo.EXPECT().GetByName(s.ctx, name). - Return(&model.Role{ID: 2, Name: name}, nil) + Return(&rbacModels.Role{ID: 2, Name: name}, nil) role, err := s.roleUsecase.GetByName(s.ctx, name) s.NoError(err) @@ -63,7 +63,7 @@ func (s *testSuite) TestGetGetError() { func (s *testSuite) TestFetchList() { s.roleRepo.EXPECT(). FetchList(s.ctx, gomock.AssignableToTypeOf(&rbac.Filter{}), nil, nil). - Return([]*model.Role{{ID: 1}, {ID: 2}}, nil) + Return([]*rbacModels.Role{{ID: 1}, {ID: 2}}, nil) roles, err := s.roleUsecase.FetchList(s.ctx, &rbac.Filter{ID: []uint64{1, 2}}, nil, nil) s.NoError(err) @@ -82,28 +82,31 @@ func (s *testSuite) TestCount() { func (s *testSuite) TestCreate() { s.roleRepo.EXPECT(). - Create(s.ctx, gomock.AssignableToTypeOf(&model.Role{})). + Create(s.ctx, gomock.AssignableToTypeOf(&rbacModels.Role{})). Return(uint64(101), nil) - id, err := s.roleUsecase.Create(s.ctx, &model.Role{ID: 0, Title: "test1"}) + id, err := s.roleUsecase.Create(s.ctx, &rbacModels.Role{ID: 0, Title: "test1"}) s.NoError(err) s.Equal(id, uint64(101)) } func (s *testSuite) TestUpdate() { + s.roleRepo.EXPECT(). + Get(gomock.AssignableToTypeOf(s.ctx), uint64(101)). + Return(&rbacModels.Role{ID: 101}, nil) s.roleRepo.EXPECT(). Update(gomock.AssignableToTypeOf(s.ctx), - uint64(101), gomock.AssignableToTypeOf(&model.Role{})). + uint64(101), gomock.AssignableToTypeOf(&rbacModels.Role{})). Return(nil) - err := s.roleUsecase.Update(s.ctx, 101, &model.Role{Title: "test-test"}) + err := s.roleUsecase.Update(s.ctx, 101, &rbacModels.Role{Title: "test-test"}) s.NoError(err) } func (s *testSuite) TestDelete() { s.roleRepo.EXPECT(). Get(gomock.AssignableToTypeOf(s.ctx), gomock.AssignableToTypeOf(uint64(101))). - Return(&model.Role{ID: 1}, nil) + Return(&rbacModels.Role{ID: 1}, nil) s.roleRepo.EXPECT(). Delete(gomock.AssignableToTypeOf(s.ctx), gomock.AssignableToTypeOf(uint64(101))). Return(nil) diff --git a/repository/rbac/usecase/role_usecase.go b/repository/rbac/usecase/role_usecase.go index c057f1ed..be3be386 100644 --- a/repository/rbac/usecase/role_usecase.go +++ b/repository/rbac/usecase/role_usecase.go @@ -1,51 +1,38 @@ -// Package usecase account implementation +// Package usecase provides business logic for RBAC role management package usecase import ( "context" - "github.com/geniusrabbit/blaze-api/model" + "github.com/pkg/errors" + "github.com/geniusrabbit/blaze-api/pkg/acl" "github.com/geniusrabbit/blaze-api/pkg/context/session" - "github.com/geniusrabbit/blaze-api/repository" - "github.com/geniusrabbit/blaze-api/repository/historylog" + "github.com/geniusrabbit/blaze-api/repository/generated" "github.com/geniusrabbit/blaze-api/repository/rbac" rbacrepo "github.com/geniusrabbit/blaze-api/repository/rbac/repository" - "github.com/pkg/errors" ) -// RoleUsecase provides bussiness logic for account access +// RoleUsecase provides business logic for role access control type RoleUsecase struct { - roleRepo rbac.Repository + generated.Usecase[rbac.Role, uint64] } -// New object usecase +// New creates a new RoleUsecase with the provided repository func New(repo rbac.Repository) *RoleUsecase { return &RoleUsecase{ - roleRepo: repo, + Usecase: generated.Usecase[rbac.Role, uint64]{Repo: repo}, } } -// NewDefault object usecase +// NewDefault creates a new RoleUsecase with default repository func NewDefault() *RoleUsecase { return New(rbacrepo.New()) } -// Get returns the group by ID if have access -func (a *RoleUsecase) Get(ctx context.Context, id uint64) (*model.Role, error) { - roleObj, err := a.roleRepo.Get(ctx, id) - if err != nil { - return nil, err - } - if !acl.HaveAccessView(ctx, roleObj) { - return nil, errors.Wrap(acl.ErrNoPermissions, "view role/permission") - } - return roleObj, nil -} - -// GetByName returns the role by name if have access -func (a *RoleUsecase) GetByName(ctx context.Context, name string) (*model.Role, error) { - roleObj, err := a.roleRepo.GetByName(ctx, name) +// GetByName retrieves a role by name with access control validation +func (a *RoleUsecase) GetByName(ctx context.Context, name string) (*rbac.Role, error) { + roleObj, err := a.Usecase.Repo.(rbac.Repository).GetByName(ctx, name) if err != nil { return nil, err } @@ -55,13 +42,13 @@ func (a *RoleUsecase) GetByName(ctx context.Context, name string) (*model.Role, return roleObj, nil } -// FetchList of roles by filter -func (a *RoleUsecase) FetchList(ctx context.Context, filter *rbac.Filter, order *rbac.Order, pagination *repository.Pagination) ([]*model.Role, error) { - if !acl.HaveAccessList(ctx, &model.Role{}) { +// FetchList retrieves a filtered list of roles with access control validation +func (a *RoleUsecase) FetchList(ctx context.Context, qops ...rbac.QOption) ([]*rbac.Role, error) { + if !acl.HaveAccessList(ctx, &rbac.Role{}) { return nil, errors.Wrap(acl.ErrNoPermissions, "list role/permission") } - filter = prepareFilter(ctx, filter, `list`) - list, err := a.roleRepo.FetchList(ctx, filter, order, pagination) + list, err := a.Usecase.Repo.(rbac.Repository). + FetchList(ctx, prepareQueryOptions(ctx, qops, `list`)...) for _, link := range list { if !acl.HaveAccessList(ctx, link) { return nil, errors.Wrap(acl.ErrNoPermissions, "list role/permission") @@ -70,46 +57,34 @@ func (a *RoleUsecase) FetchList(ctx context.Context, filter *rbac.Filter, order return list, err } -// Count of roles by filter -func (a *RoleUsecase) Count(ctx context.Context, filter *rbac.Filter) (int64, error) { - if !acl.HaveAccessList(ctx, &model.Role{}) { +// Count returns the count of roles matching the filter with access control +func (a *RoleUsecase) Count(ctx context.Context, qops ...rbac.QOption) (int64, error) { + if !acl.HaveAccessList(ctx, &rbac.Role{}) { return 0, errors.Wrap(acl.ErrNoPermissions, "list role/permission") } - return a.roleRepo.Count(ctx, prepareFilter(ctx, filter, `count`)) -} - -// Create new object in database -func (a *RoleUsecase) Create(ctx context.Context, roleObj *model.Role) (uint64, error) { - var err error - if !acl.HaveAccessCreate(ctx, roleObj) { - return 0, errors.Wrap(acl.ErrNoPermissions, "create role/permission") - } - roleObj.ID, err = a.roleRepo.Create(ctx, roleObj) - return roleObj.ID, err + return a.Usecase.Repo.(rbac.Repository).Count(ctx, prepareQueryOptions(ctx, qops, `count`)...) } -// Update object in database -func (a *RoleUsecase) Update(ctx context.Context, id uint64, roleObj *model.Role) error { - upRoleObj := *roleObj - upRoleObj.ID = id - if !acl.HaveAccessUpdate(ctx, upRoleObj) { - return errors.Wrap(acl.ErrNoPermissions, "update role/permission") - } - return a.roleRepo.Update(historylog.WithPK(ctx, id), id, &upRoleObj) -} - -// Delete delites record by ID -func (a *RoleUsecase) Delete(ctx context.Context, id uint64) error { - roleObj, err := a.roleRepo.Get(ctx, id) - if err != nil { - return err +func prepareQueryOptions(ctx context.Context, qops []rbac.QOption, accessName string) []rbac.QOption { + var filter *rbac.Filter + for _, ops := range qops { + if ops != nil { + if f, ok := ops.(*rbac.Filter); ok { + filter = f + break + } + } } - if !acl.HaveAccessDelete(ctx, roleObj) { - return errors.Wrap(acl.ErrNoPermissions, "delete role/permission") + if filter == nil { + filter = prepareFilter(ctx, filter, accessName) + qops = append(qops, filter) + } else { + prepareFilter(ctx, filter, accessName) } - return a.roleRepo.Delete(historylog.WithPK(ctx, id), id) + return qops } +// prepareFilter applies access-based filters to role queries based on user permissions func prepareFilter(ctx context.Context, filter *rbac.Filter, accessName string) *rbac.Filter { if acl.HasPermission(ctx, "role."+accessName+".all") { return filter @@ -118,11 +93,11 @@ func prepareFilter(ctx context.Context, filter *rbac.Filter, accessName string) filter = &rbac.Filter{} } if acl.HasPermission(ctx, "role."+accessName+".account") { - filter.MaxAccessLevel = model.AccessLevelAccount + filter.MaxAccessLevel = rbac.AccessLevelAccount } else if session.User(ctx).IsAnonymous() { - filter.MaxAccessLevel = model.AccessLevelBasic + filter.MaxAccessLevel = rbac.AccessLevelBasic } else { - filter.MaxAccessLevel = model.AccessLevelNoAnonymous + filter.MaxAccessLevel = rbac.AccessLevelNoAnonymous } return filter } diff --git a/protocol/graphql/schemas/account_social.graphql b/repository/socialaccount/delivery/graphql/account_social.graphql similarity index 100% rename from protocol/graphql/schemas/account_social.graphql rename to repository/socialaccount/delivery/graphql/account_social.graphql diff --git a/repository/socialaccount/delivery/graphql/connector.go b/repository/socialaccount/delivery/graphql/connector.go new file mode 100644 index 00000000..fe25fadc --- /dev/null +++ b/repository/socialaccount/delivery/graphql/connector.go @@ -0,0 +1,43 @@ +package graphql + +import ( + "context" + + "github.com/demdxx/gocast/v2" + + "github.com/geniusrabbit/blaze-api/repository/socialaccount" + "github.com/geniusrabbit/blaze-api/server/graphql/connectors" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" +) + +// SocialAccountConnection is a GraphQL connection type for paginated social account collections. +type SocialAccountConnection = connectors.CollectionConnection[gqlmodels.SocialAccount, gqlmodels.SocialAccountEdge] + +// NewSocialAccountConnection creates a new paginated connection for social accounts. +// It configures data fetching, counting, and edge conversion based on the provided filter, order, and page parameters. +func NewSocialAccountConnection( + ctx context.Context, + accountsAccessor socialaccount.Usecase, + filter *gqlmodels.SocialAccountListFilter, + order *gqlmodels.SocialAccountListOrder, + page *gqlmodels.Page, +) *SocialAccountConnection { + return connectors.NewCollectionConnection(ctx, &connectors.DataAccessorFunc[gqlmodels.SocialAccount, gqlmodels.SocialAccountEdge]{ + // FetchDataListFunc retrieves the paginated list of social accounts. + FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.SocialAccount, error) { + accounts, err := accountsAccessor.FetchList(ctx, filter.Filter(), order.Order(), page.Pagination()) + return FromSocialAccountModelList(accounts), err + }, + // CountDataFunc returns the total count of social accounts matching the filter. + CountDataFunc: func(ctx context.Context) (int64, error) { + return accountsAccessor.Count(ctx, filter.Filter()) + }, + // ConvertToEdgeFunc transforms a social account into a GraphQL edge with cursor. + ConvertToEdgeFunc: func(obj *gqlmodels.SocialAccount) *gqlmodels.SocialAccountEdge { + return &gqlmodels.SocialAccountEdge{ + Cursor: gocast.Str(obj.ID), + Node: obj, + } + }, + }, page) +} diff --git a/repository/socialaccount/delivery/graphql/mapping.go b/repository/socialaccount/delivery/graphql/mapping.go new file mode 100644 index 00000000..8e6c4bf8 --- /dev/null +++ b/repository/socialaccount/delivery/graphql/mapping.go @@ -0,0 +1,62 @@ +package graphql + +import ( + "github.com/demdxx/gocast/v2" + "github.com/demdxx/xtypes" + + "github.com/geniusrabbit/blaze-api/repository/socialaccount/models" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" + "github.com/geniusrabbit/blaze-api/server/graphql/types" +) + +// FromSocialAccountModel converts a domain AccountSocial model to a GraphQL SocialAccount model. +func FromSocialAccountModel(acc *models.AccountSocial) *gqlmodels.SocialAccount { + if acc == nil { + return nil + } + return &gqlmodels.SocialAccount{ + ID: acc.ID, + UserID: acc.UserID, + SocialID: acc.SocialID, + Provider: acc.Provider, + Username: acc.Username, + Email: acc.Email, + FirstName: acc.FirstName, + LastName: acc.LastName, + Avatar: acc.Avatar, + Link: acc.Link, + Data: *types.MustNullableJSONFrom(acc.Data.Data), + Sessions: FromSocialAccountSessionModelList(acc.Sessions), + CreatedAt: acc.CreatedAt, + UpdatedAt: acc.UpdatedAt, + DeletedAt: gqlmodels.DeletedAt(acc.DeletedAt), + } +} + +// FromSocialAccountModelList converts a slice of domain models to GraphQL models. +func FromSocialAccountModelList(list []*models.AccountSocial) []*gqlmodels.SocialAccount { + return xtypes.SliceApply(list, FromSocialAccountModel) +} + +// FromSocialAccountSessionModel converts a domain AccountSocialSession model to a GraphQL model. +func FromSocialAccountSessionModel(sess *models.AccountSocialSession) *gqlmodels.SocialAccountSession { + if sess == nil { + return nil + } + return &gqlmodels.SocialAccountSession{ + Name: sess.Name, + SocialAccountID: sess.AccountSocialID, + AccessToken: sess.AccessToken, + RefreshToken: sess.RefreshToken, + Scope: sess.Scopes, + ExpiresAt: gocast.IfThen(sess.ExpiresAt.Valid, &sess.ExpiresAt.Time, nil), + CreatedAt: sess.CreatedAt, + UpdatedAt: sess.UpdatedAt, + DeletedAt: gqlmodels.DeletedAt(sess.DeletedAt), + } +} + +// FromSocialAccountSessionModelList converts a slice of session models to GraphQL models. +func FromSocialAccountSessionModelList(list []*models.AccountSocialSession) []*gqlmodels.SocialAccountSession { + return xtypes.SliceApply(list, FromSocialAccountSessionModel) +} diff --git a/repository/socialaccount/delivery/graphql/resolver.go b/repository/socialaccount/delivery/graphql/resolver.go index b42ee9d8..75e3c723 100644 --- a/repository/socialaccount/delivery/graphql/resolver.go +++ b/repository/socialaccount/delivery/graphql/resolver.go @@ -7,63 +7,67 @@ import ( "github.com/geniusrabbit/blaze-api/pkg/context/session" "github.com/geniusrabbit/blaze-api/pkg/requestid" "github.com/geniusrabbit/blaze-api/repository/socialaccount" - "github.com/geniusrabbit/blaze-api/repository/socialaccount/repository" - "github.com/geniusrabbit/blaze-api/repository/socialaccount/usecase" - "github.com/geniusrabbit/blaze-api/server/graphql/connectors" - "github.com/geniusrabbit/blaze-api/server/graphql/models" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) -// QueryResolver for the social account +// QueryResolver handles GraphQL queries for social accounts. type QueryResolver struct { - accsounts socialaccount.Usecase + accounts socialaccount.Usecase } -// NewQueryResolver creates a new instance of the QueryResolver -func NewQueryResolver() *QueryResolver { - return &QueryResolver{ - accsounts: usecase.New( - repository.New(), - ), - } +// NewQueryResolver creates a new QueryResolver instance. +func NewQueryResolver(uc socialaccount.Usecase) *QueryResolver { + return &QueryResolver{accounts: uc} } -// Get Social Account by ID -func (r *QueryResolver) Get(ctx context.Context, id uint64) (*models.SocialAccountPayload, error) { - obj, err := r.accsounts.Get(ctx, id) +// Get retrieves a social account by ID. +func (r *QueryResolver) Get(ctx context.Context, id uint64) (*gqlmodels.SocialAccountPayload, error) { + obj, err := r.accounts.Get(ctx, id) if err != nil { return nil, err } - return &models.SocialAccountPayload{ + return &gqlmodels.SocialAccountPayload{ ClientMutationID: requestid.Get(ctx), - SocialAccountID: obj.ID, - SocialAccount: models.FromSocialAccountModel(obj), + SocialAccountID: id, + SocialAccount: FromSocialAccountModel(obj), }, nil } -// Current Social Accounts list -func (r *QueryResolver) ListCurrent(ctx context.Context, filter *models.SocialAccountListFilter, order *models.SocialAccountListOrder) (*connectors.SocialAccountConnection, error) { +// ListCurrent returns social accounts for the current authenticated user. +func (r *QueryResolver) ListCurrent( + ctx context.Context, + filter *gqlmodels.SocialAccountListFilter, + order *gqlmodels.SocialAccountListOrder, +) (*SocialAccountConnection, error) { if filter == nil { - filter = &models.SocialAccountListFilter{} + filter = &gqlmodels.SocialAccountListFilter{} } if len(filter.UserID) > 1 || (len(filter.UserID) == 1 && filter.UserID[0] != session.User(ctx).ID) { return nil, fmt.Errorf("filter by user id is not allowed for current user") } filter.UserID = append(filter.UserID[:0], session.User(ctx).ID) - return connectors.NewSocialAccountConnection(ctx, r.accsounts, filter, order, nil), nil + return NewSocialAccountConnection(ctx, r.accounts, filter, order, nil), nil } -// List Social Accounts -func (r *QueryResolver) List(ctx context.Context, filter *models.SocialAccountListFilter, order *models.SocialAccountListOrder, page *models.Page) (*connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge], error) { - return connectors.NewSocialAccountConnection(ctx, r.accsounts, filter, order, page), nil +// List returns paginated social accounts with optional filtering and ordering. +func (r *QueryResolver) List( + ctx context.Context, + filter *gqlmodels.SocialAccountListFilter, + order *gqlmodels.SocialAccountListOrder, + page *gqlmodels.Page, +) (*SocialAccountConnection, error) { + return NewSocialAccountConnection(ctx, r.accounts, filter, order, page), nil } -// Disconnect Social Account -func (r *QueryResolver) Disconnect(ctx context.Context, socialAccountID uint64) (*models.SocialAccountPayload, error) { - obj, err := r.accsounts.Disconnect(ctx, socialAccountID) +// Disconnect removes a social account association. +func (r *QueryResolver) Disconnect(ctx context.Context, socialAccountID uint64) (*gqlmodels.SocialAccountPayload, error) { + obj, err := r.accounts.Disconnect(ctx, socialAccountID) if err != nil { return nil, err } - return &models.SocialAccountPayload{ - SocialAccount: models.FromSocialAccountModel(obj), + return &gqlmodels.SocialAccountPayload{ + ClientMutationID: requestid.Get(ctx), + SocialAccountID: socialAccountID, + SocialAccount: FromSocialAccountModel(obj), }, nil } diff --git a/repository/socialaccount/models.go b/repository/socialaccount/models.go new file mode 100644 index 00000000..ed1c8bb1 --- /dev/null +++ b/repository/socialaccount/models.go @@ -0,0 +1,8 @@ +package socialaccount + +import "github.com/geniusrabbit/blaze-api/repository/socialaccount/models" + +type ( + AccountSocial = models.AccountSocial + AccountSocialSession = models.AccountSocialSession +) diff --git a/repository/socialaccount/models/account_social.go b/repository/socialaccount/models/account_social.go new file mode 100644 index 00000000..db358023 --- /dev/null +++ b/repository/socialaccount/models/account_social.go @@ -0,0 +1,56 @@ +package models + +import ( + "time" + + "github.com/geniusrabbit/gosql/v2" + "gorm.io/gorm" + + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" +) + +// AccountSocial represents a user's social network account connection. +type AccountSocial struct { + ID uint64 `db:"id" gorm:"primaryKey"` + UserID uint64 `db:"user_id"` + User *userModels.User `db:"-" gorm:"foreignKey:UserID"` + + // Social network credentials and profile information + SocialID string `db:"social_id"` // unique identifier from the social provider + Provider string `db:"provider"` // provider name (facebook, google, twitter, github, etc.) + Email string `db:"email"` + FirstName string `db:"first_name"` + LastName string `db:"last_name"` + Username string `db:"username"` + Avatar string `db:"avatar"` + Link string `db:"link"` // profile URL + + // Data stores additional provider-specific information as JSON + Data gosql.NullableJSON[map[string]any] `db:"data" gorm:"type:jsonb"` + + // Sessions contains active sessions linked to this social account + Sessions []*AccountSocialSession `db:"-" gorm:"foreignKey:AccountSocialID;references:ID"` + + // Timestamps for audit tracking + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` + DeletedAt gorm.DeletedAt `db:"deleted_at"` // soft delete +} + +// TableName returns the database table name for AccountSocial. +func (m *AccountSocial) TableName() string { + return `account_social` +} + +// RBACResourceName returns the RBAC resource identifier. +func (m *AccountSocial) RBACResourceName() string { + return `account_social` +} + +// CreatorUserID returns the ID of the account owner. +func (m *AccountSocial) CreatorUserID() uint64 { + if m == nil { + return 0 + } + return m.UserID +} diff --git a/repository/socialaccount/models/account_social_sessiong.go b/repository/socialaccount/models/account_social_sessiong.go new file mode 100644 index 00000000..8bb41233 --- /dev/null +++ b/repository/socialaccount/models/account_social_sessiong.go @@ -0,0 +1,49 @@ +package models + +import ( + "time" + + "github.com/geniusrabbit/gosql/v2" + "github.com/guregu/null" + "gorm.io/gorm" +) + +// AccountSocialSession represents a social account authentication session +// with OAuth tokens and scope information. +type AccountSocialSession struct { + // Name uniquely identifies the session to distinguish between different + // sessions with different scopes for the same social account. + Name string `db:"name" gorm:"primaryKey"` + + // AccountSocialID is the foreign key to the social account. + AccountSocialID uint64 `db:"account_social_id" gorm:"primaryKey;autoIncrement:false"` + + // TokenType specifies the OAuth token type (e.g., "Bearer"). + TokenType string `db:"token_type" json:"token_type,omitempty"` + + // AccessToken is the OAuth access token for API requests. + AccessToken string `db:"access_token" json:"access_token"` + + // RefreshToken is used to obtain a new access token when it expires. + RefreshToken string `db:"refresh_token" json:"refresh_token"` + + // Scopes are the OAuth permission scopes granted for this session. + Scopes gosql.NullableStringArray `db:"scopes" json:"scopes,omitempty" gorm:"type:text[]"` + + // CreatedAt is the session creation timestamp. + CreatedAt time.Time `db:"created_at" json:"created_at"` + + // UpdatedAt is the last update timestamp. + UpdatedAt time.Time `db:"updated_at" json:"updated_at"` + + // ExpiresAt is when the access token expires (nullable). + ExpiresAt null.Time `db:"expires_at" json:"expires_at,omitempty"` + + // DeletedAt is the soft delete timestamp. + DeletedAt gorm.DeletedAt `db:"deleted_at" json:"deleted_at,omitempty"` +} + +// TableName returns the database table name for AccountSocialSession. +func (m *AccountSocialSession) TableName() string { + return `account_social_session` +} diff --git a/repository/socialaccount/query.go b/repository/socialaccount/query.go index 335385e3..f0b1ef6f 100644 --- a/repository/socialaccount/query.go +++ b/repository/socialaccount/query.go @@ -1,8 +1,10 @@ package socialaccount import ( - "github.com/geniusrabbit/blaze-api/model" "gorm.io/gorm" + + "github.com/geniusrabbit/blaze-api/repository" + "github.com/geniusrabbit/blaze-api/repository/option/models" ) type Filter struct { @@ -36,13 +38,13 @@ func (f *Filter) PrepareQuery(q *gorm.DB) *gorm.DB { } type Order struct { - ID model.Order - UserID model.Order - Provider model.Order - Email model.Order - Username model.Order - FirstName model.Order - LastName model.Order + ID models.Order + UserID models.Order + Provider models.Order + Email models.Order + Username models.Order + FirstName models.Order + LastName models.Order } func (o *Order) PrepareQuery(q *gorm.DB) *gorm.DB { @@ -58,3 +60,10 @@ func (o *Order) PrepareQuery(q *gorm.DB) *gorm.DB { q = o.LastName.PrepareQuery(q, `last_name`) return q } + +// Type aliases for common repository types. +type ( + Pagination = repository.Pagination + QOption = repository.QOption + ListOptions = repository.ListOptions +) diff --git a/repository/socialaccount/repository.go b/repository/socialaccount/repository.go index 55bd6b38..df52c6c4 100644 --- a/repository/socialaccount/repository.go +++ b/repository/socialaccount/repository.go @@ -3,14 +3,29 @@ package socialaccount import ( "context" - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" + "github.com/geniusrabbit/blaze-api/repository/socialaccount/models" ) +// Repository defines the interface for managing social account data operations. +// It provides methods for retrieving, listing, counting, and managing social accounts +// and their associated sessions. type Repository interface { - Get(ctx context.Context, id uint64) (*model.AccountSocial, error) - FetchList(ctx context.Context, filter *Filter, order *Order, pagination *repository.Pagination) ([]*model.AccountSocial, error) - Count(ctx context.Context, filter *Filter) (int64, error) + // Get retrieves a social account by its unique identifier. + // Returns the social account if found, or an error if the operation fails. + Get(ctx context.Context, id uint64) (*models.AccountSocial, error) + + // FetchList retrieves a list of social accounts based on the provided query options. + // Returns a slice of social accounts or an error if the operation fails. + FetchList(ctx context.Context, opts ...QOption) ([]*models.AccountSocial, error) + + // Count returns the total number of social accounts matching the query options. + Count(ctx context.Context, opts ...QOption) (int64, error) + + // Disconnect removes the association of a social account by its unique identifier. + // Returns an error if the operation fails. Disconnect(ctx context.Context, id uint64) error - FetchSessionList(ctx context.Context, socialAccountID []uint64) ([]*model.AccountSocialSession, error) + + // FetchSessionList retrieves all sessions for the given social account IDs. + // Returns a slice of sessions or an error if the operation fails. + FetchSessionList(ctx context.Context, socialAccountID []uint64) ([]*models.AccountSocialSession, error) } diff --git a/repository/socialaccount/repository/repository.go b/repository/socialaccount/repository/repository.go index 93dab879..1fa7c1db 100644 --- a/repository/socialaccount/repository/repository.go +++ b/repository/socialaccount/repository/repository.go @@ -7,10 +7,10 @@ import ( "gorm.io/gorm" "gorm.io/gorm/clause" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/context/database" "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/socialaccount" + "github.com/geniusrabbit/blaze-api/repository/socialaccount/models" ) // Repository for social account @@ -18,14 +18,14 @@ type Repository struct { repository.Repository } -// New social account repository -func New() *Repository { +// NewSocaccRepository social account repository +func NewSocaccRepository() *Repository { return &Repository{} } // Get social account by ID -func (r *Repository) Get(ctx context.Context, id uint64) (*model.AccountSocial, error) { - object := &model.AccountSocial{} +func (r *Repository) Get(ctx context.Context, id uint64) (*models.AccountSocial, error) { + object := &models.AccountSocial{} res := r.Slave(ctx).Model(object). Preload(clause.Associations). Where(`id=?`, id).Find(object) @@ -36,14 +36,12 @@ func (r *Repository) Get(ctx context.Context, id uint64) (*model.AccountSocial, } // FetchList of social accounts -func (r *Repository) FetchList(ctx context.Context, filter *socialaccount.Filter, order *socialaccount.Order, pagination *repository.Pagination) ([]*model.AccountSocial, error) { +func (r *Repository) FetchList(ctx context.Context, opts ...socialaccount.QOption) ([]*models.AccountSocial, error) { var ( - list []*model.AccountSocial - query = r.Slave(ctx).Model((*model.AccountSocial)(nil)) + list []*models.AccountSocial + query = r.Slave(ctx).Model((*models.AccountSocial)(nil)) ) - query = filter.PrepareQuery(query) - query = order.PrepareQuery(query) - query = pagination.PrepareQuery(query) + query = socialaccount.ListOptions(opts).PrepareQuery(query) query = query.Preload(clause.Associations) err := query.Find(&list).Error if errors.Is(err, gorm.ErrRecordNotFound) { @@ -53,12 +51,12 @@ func (r *Repository) FetchList(ctx context.Context, filter *socialaccount.Filter } // Count of social accounts -func (r *Repository) Count(ctx context.Context, filter *socialaccount.Filter) (int64, error) { +func (r *Repository) Count(ctx context.Context, opts ...socialaccount.QOption) (int64, error) { var ( count int64 - query = r.Slave(ctx).Model((*model.AccountSocial)(nil)) + query = r.Slave(ctx).Model((*models.AccountSocial)(nil)) ) - query = filter.PrepareQuery(query) + query = socialaccount.ListOptions(opts).PrepareQuery(query) err := query.Count(&count).Error return count, err } @@ -66,10 +64,10 @@ func (r *Repository) Count(ctx context.Context, filter *socialaccount.Filter) (i // Disconnect social account by ID func (r *Repository) Disconnect(ctx context.Context, id uint64) error { return database.ContextTransactionExec(ctx, func(ctx context.Context, tx *gorm.DB) error { - if err := tx.Delete(&model.AccountSocialSession{}, `account_social_id=?`, id).Error; err != nil { + if err := tx.Delete(&models.AccountSocialSession{}, `account_social_id=?`, id).Error; err != nil { return err } - if err := tx.Delete(&model.AccountSocial{}, `id=?`, id).Error; err != nil { + if err := tx.Delete(&models.AccountSocial{}, `id=?`, id).Error; err != nil { return err } return nil @@ -77,10 +75,10 @@ func (r *Repository) Disconnect(ctx context.Context, id uint64) error { } // FetchSessionList of social account -func (r *Repository) FetchSessionList(ctx context.Context, socialAccountID []uint64) ([]*model.AccountSocialSession, error) { +func (r *Repository) FetchSessionList(ctx context.Context, socialAccountID []uint64) ([]*models.AccountSocialSession, error) { var ( - list []*model.AccountSocialSession - query = r.Slave(ctx).Model((*model.AccountSocialSession)(nil)) + list []*models.AccountSocialSession + query = r.Slave(ctx).Model((*models.AccountSocialSession)(nil)) ) if len(socialAccountID) > 0 { query = query.Where(`account_social_id IN (?)`, socialAccountID) diff --git a/repository/socialaccount/usecase.go b/repository/socialaccount/usecase.go index 40d1bd34..de38b312 100644 --- a/repository/socialaccount/usecase.go +++ b/repository/socialaccount/usecase.go @@ -3,14 +3,23 @@ package socialaccount import ( "context" - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" + "github.com/geniusrabbit/blaze-api/repository/socialaccount/models" ) +// Usecase defines the business logic operations for social accounts. type Usecase interface { - Get(ctx context.Context, id uint64) (*model.AccountSocial, error) - FetchList(ctx context.Context, filter *Filter, order *Order, page *repository.Pagination) ([]*model.AccountSocial, error) - Count(ctx context.Context, filter *Filter) (int64, error) - Disconnect(ctx context.Context, id uint64) (*model.AccountSocial, error) - FetchSessionList(ctx context.Context, socialAccountID []uint64) ([]*model.AccountSocialSession, error) + // Get retrieves a single social account by ID. + Get(ctx context.Context, id uint64) (*models.AccountSocial, error) + + // FetchList retrieves a list of social accounts with optional query parameters. + FetchList(ctx context.Context, opts ...QOption) ([]*models.AccountSocial, error) + + // Count returns the total number of social accounts matching the query options. + Count(ctx context.Context, opts ...QOption) (int64, error) + + // Disconnect removes a social account connection by ID. + Disconnect(ctx context.Context, id uint64) (*models.AccountSocial, error) + + // FetchSessionList retrieves sessions for the given social account IDs. + FetchSessionList(ctx context.Context, socialAccountID []uint64) ([]*models.AccountSocialSession, error) } diff --git a/repository/socialaccount/usecase/usecase.go b/repository/socialaccount/usecase/usecase.go index 0fec0397..dc6f1bd5 100644 --- a/repository/socialaccount/usecase/usecase.go +++ b/repository/socialaccount/usecase/usecase.go @@ -3,13 +3,10 @@ package usecase import ( "context" - "github.com/pkg/errors" - - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/acl" "github.com/geniusrabbit/blaze-api/pkg/context/session" - "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/socialaccount" + "github.com/geniusrabbit/blaze-api/repository/socialaccount/models" ) // Usecase for social account @@ -17,63 +14,61 @@ type Usecase struct { repo socialaccount.Repository } -func New(repo socialaccount.Repository) *Usecase { +func NewSocaccUsecase(repo socialaccount.Repository) *Usecase { return &Usecase{repo: repo} } // Get social account by ID -func (u *Usecase) Get(ctx context.Context, id uint64) (*model.AccountSocial, error) { +func (u *Usecase) Get(ctx context.Context, id uint64) (*models.AccountSocial, error) { obj, err := u.repo.Get(ctx, id) if err != nil { return nil, err } if !acl.HaveAccessView(ctx, obj) { - return nil, errors.Wrap(acl.ErrNoPermissions, "view social account") + return nil, acl.ErrNoPermissions.WithMessage("view social account") } return obj, nil } // FetchList of social accounts -func (u *Usecase) FetchList(ctx context.Context, filter *socialaccount.Filter, order *socialaccount.Order, page *repository.Pagination) ([]*model.AccountSocial, error) { - if !acl.HaveAccessList(ctx, &model.AccountSocial{}) { - if !acl.HaveAccessList(ctx, &model.AccountSocial{UserID: session.User(ctx).ID}) { - return nil, errors.Wrap(acl.ErrNoPermissions, "list social account") - } - if filter == nil { - filter = &socialaccount.Filter{} +func (u *Usecase) FetchList(ctx context.Context, opts ...socialaccount.QOption) ([]*models.AccountSocial, error) { + if !acl.HaveAccessList(ctx, &models.AccountSocial{}) { + if !acl.HaveAccessList(ctx, &models.AccountSocial{UserID: session.User(ctx).ID}) { + return nil, acl.ErrNoPermissions.WithMessage("list social account") } - filter.UserID = append(filter.UserID[:0], session.User(ctx).ID) + opts = append(opts, &socialaccount.Filter{ + UserID: []uint64{session.User(ctx).ID}, + }) } - return u.repo.FetchList(ctx, filter, order, page) + return u.repo.FetchList(ctx, opts...) } // Count social accounts -func (u *Usecase) Count(ctx context.Context, filter *socialaccount.Filter) (int64, error) { - if !acl.HaveAccessCount(ctx, &model.AccountSocial{}) { - if !acl.HaveAccessCount(ctx, &model.AccountSocial{UserID: session.User(ctx).ID}) { - return 0, errors.Wrap(acl.ErrNoPermissions, "count social account") - } - if filter == nil { - filter = &socialaccount.Filter{} +func (u *Usecase) Count(ctx context.Context, opts ...socialaccount.QOption) (int64, error) { + if !acl.HaveAccessCount(ctx, &models.AccountSocial{}) { + if !acl.HaveAccessCount(ctx, &models.AccountSocial{UserID: session.User(ctx).ID}) { + return 0, acl.ErrNoPermissions.WithMessage("count social account") } - filter.UserID = append(filter.UserID[:0], session.User(ctx).ID) + opts = append(opts, &socialaccount.Filter{ + UserID: []uint64{session.User(ctx).ID}, + }) } - return u.repo.Count(ctx, filter) + return u.repo.Count(ctx, opts...) } // Disconnect social account -func (u *Usecase) Disconnect(ctx context.Context, id uint64) (*model.AccountSocial, error) { +func (u *Usecase) Disconnect(ctx context.Context, id uint64) (*models.AccountSocial, error) { obj, err := u.Get(ctx, id) if err != nil { return nil, err } if !acl.HaveAccessDelete(ctx, obj) { - return nil, errors.Wrap(acl.ErrNoPermissions, "disconnect social account") + return nil, acl.ErrNoPermissions.WithMessage("disconnect social account") } return obj, u.repo.Disconnect(ctx, id) } // FetchSessionList of social accounts -func (u *Usecase) FetchSessionList(ctx context.Context, socialAccountID []uint64) ([]*model.AccountSocialSession, error) { +func (u *Usecase) FetchSessionList(ctx context.Context, socialAccountID []uint64) ([]*models.AccountSocialSession, error) { return u.repo.FetchSessionList(ctx, socialAccountID) } diff --git a/repository/socialauth/delivery/rest/oauth2wrapper.go b/repository/socialauth/delivery/rest/oauth2wrapper.go index 1de42d9d..6323bafc 100644 --- a/repository/socialauth/delivery/rest/oauth2wrapper.go +++ b/repository/socialauth/delivery/rest/oauth2wrapper.go @@ -14,18 +14,20 @@ import ( "go.uber.org/zap" "gorm.io/gorm" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/acl" "github.com/geniusrabbit/blaze-api/pkg/auth/elogin" "github.com/geniusrabbit/blaze-api/pkg/auth/elogin/utils" "github.com/geniusrabbit/blaze-api/pkg/auth/jwt" "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" "github.com/geniusrabbit/blaze-api/pkg/context/session" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/repository/account" accrepo "github.com/geniusrabbit/blaze-api/repository/account/repository" + socialAccountModels "github.com/geniusrabbit/blaze-api/repository/socialaccount/models" "github.com/geniusrabbit/blaze-api/repository/socialauth" "github.com/geniusrabbit/blaze-api/repository/socialauth/repository" "github.com/geniusrabbit/blaze-api/repository/socialauth/usecase" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" userrepo "github.com/geniusrabbit/blaze-api/repository/user/repository" ) @@ -52,7 +54,7 @@ func NewWrapper(auth elogin.AuthAccessor, options ...Option) *Oauth2Wrapper { opt(wr) } if wr.socialAuthUsecase == nil { - wr.socialAuthUsecase = usecase.New(userrepo.New(), repository.New()) + wr.socialAuthUsecase = usecase.New(userrepo.NewUserRepository(), repository.New()) } wr.wrapper = elogin.NewWrapper(auth, wr, wr, wr) return wr @@ -147,7 +149,7 @@ func (wr *Oauth2Wrapper) Success(w http.ResponseWriter, r *http.Request, token * } var ( - accSocial *model.AccountSocial + accSocial *socialAccountModels.AccountSocial expiresAt time.Time ctx = acl.WithNoPermCheck(r.Context()) state = utils.DecodeState(r.URL.Query().Get("state")) @@ -162,7 +164,7 @@ func (wr *Oauth2Wrapper) Success(w http.ResponseWriter, r *http.Request, token * Provider: []string{wr.Provider()}, RetrieveDeleted: true, }) - if err != nil && !(errors.Is(err, gorm.ErrRecordNotFound) || errors.Is(err, sql.ErrNoRows)) { + if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) && !errors.Is(err, sql.ErrNoRows) { wr.Error(w, r, err) return } @@ -194,9 +196,9 @@ func (wr *Oauth2Wrapper) Success(w http.ResponseWriter, r *http.Request, token * if sessToken == "" && wr.sessProvider != nil && session.User(ctx).IsAnonymous() { // Get preoritized user account accountID := uint64(0) - acclist, err := accrepo.New().FetchList(ctx, &account.Filter{ + acclist, err := accrepo.NewAccountRepository().FetchList(ctx, &account.Filter{ UserID: []uint64{accSocial.UserID}, - Status: []model.ApproveStatus{model.ApprovedApproveStatus, model.PendingApproveStatus}, + Status: []pkgModels.ApproveStatus{pkgModels.ApprovedApproveStatus, pkgModels.PendingApproveStatus}, }, nil, nil) if err == nil && len(acclist) > 0 { for _, acc := range acclist { @@ -237,19 +239,19 @@ func (wr *Oauth2Wrapper) Success(w http.ResponseWriter, r *http.Request, token * }) } -func (wr *Oauth2Wrapper) createSocialAccountAndUser(ctx context.Context, userData *elogin.UserData) (*model.AccountSocial, error) { +func (wr *Oauth2Wrapper) createSocialAccountAndUser(ctx context.Context, userData *elogin.UserData) (*socialAccountModels.AccountSocial, error) { user := session.User(ctx) // Create new user or connect to the existing one if user.IsAnonymous() { - user = &model.User{ + user = &userModels.User{ Email: userData.Email, - Approve: model.ApprovedApproveStatus, + Approve: pkgModels.ApprovedApproveStatus, } } // Connect user to the social account - socAcc := &model.AccountSocial{ + socAcc := &socialAccountModels.AccountSocial{ Provider: wr.Provider(), SocialID: userData.ID, Email: userData.Email, @@ -264,7 +266,7 @@ func (wr *Oauth2Wrapper) createSocialAccountAndUser(ctx context.Context, userDat return socAcc, err } -func (wr *Oauth2Wrapper) updateSocialAccount(ctx context.Context, socAcc *model.AccountSocial, userData *elogin.UserData) error { +func (wr *Oauth2Wrapper) updateSocialAccount(ctx context.Context, socAcc *socialAccountModels.AccountSocial, userData *elogin.UserData) error { socAcc.Email = gocast.Or(userData.Email, socAcc.Email) socAcc.FirstName = gocast.Or(userData.FirstName, socAcc.FirstName) socAcc.LastName = gocast.Or(userData.LastName, socAcc.LastName) diff --git a/repository/socialauth/delivery/rest/utils.go b/repository/socialauth/delivery/rest/utils.go index 7ef3d52a..a9fb5360 100644 --- a/repository/socialauth/delivery/rest/utils.go +++ b/repository/socialauth/delivery/rest/utils.go @@ -15,7 +15,7 @@ func urlSetQueryParams(sUrl string, params map[string]string) string { // Replace pattern params in URL by patter `{paramName}` for k, v := range params { if strings.Contains(sUrl, `{`+k+`}`) { - sUrl = strings.Replace(sUrl, `{`+k+`}`, v, -1) + sUrl = strings.ReplaceAll(sUrl, `{`+k+`}`, v) setted[k] = true } } diff --git a/repository/socialauth/repository.go b/repository/socialauth/repository.go index e56f2c85..c0d0883b 100644 --- a/repository/socialauth/repository.go +++ b/repository/socialauth/repository.go @@ -3,15 +3,15 @@ package socialauth import ( "context" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/auth/elogin" + socialAccountModels "github.com/geniusrabbit/blaze-api/repository/socialaccount/models" ) type Repository interface { - Get(ctx context.Context, id uint64) (*model.AccountSocial, error) - List(ctx context.Context, filter *Filter) ([]*model.AccountSocial, error) - Create(ctx context.Context, account *model.AccountSocial) (uint64, error) - Update(ctx context.Context, id uint64, account *model.AccountSocial) error + Get(ctx context.Context, id uint64) (*socialAccountModels.AccountSocial, error) + List(ctx context.Context, filter *Filter) ([]*socialAccountModels.AccountSocial, error) + Create(ctx context.Context, account *socialAccountModels.AccountSocial) (uint64, error) + Update(ctx context.Context, id uint64, account *socialAccountModels.AccountSocial) error Token(ctx context.Context, name string, accountSocialID uint64) (*elogin.Token, error) SetToken(ctx context.Context, name string, accountSocialID uint64, token *elogin.Token) error } diff --git a/repository/socialauth/repository/socialauth_repository.go b/repository/socialauth/repository/socialauth_repository.go index 1c12c78b..e6d2e5dd 100644 --- a/repository/socialauth/repository/socialauth_repository.go +++ b/repository/socialauth/repository/socialauth_repository.go @@ -7,10 +7,10 @@ import ( "github.com/guregu/null" "gorm.io/gorm" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/auth/elogin" "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/socialauth" + socialAccountModels "github.com/geniusrabbit/blaze-api/repository/socialaccount/models" ) type Repository struct { @@ -22,8 +22,8 @@ func New() *Repository { } // Get account by ID -func (r *Repository) Get(ctx context.Context, id uint64) (*model.AccountSocial, error) { - var account model.AccountSocial +func (r *Repository) Get(ctx context.Context, id uint64) (*socialAccountModels.AccountSocial, error) { + var account socialAccountModels.AccountSocial err := r.Slave(ctx).First(&account, id).Error if err != nil { return nil, err @@ -32,9 +32,9 @@ func (r *Repository) Get(ctx context.Context, id uint64) (*model.AccountSocial, } // List accounts by filter -func (r *Repository) List(ctx context.Context, filter *socialauth.Filter) ([]*model.AccountSocial, error) { - var list []*model.AccountSocial - query := r.Slave(ctx).Model((*model.AccountSocial)(nil)) +func (r *Repository) List(ctx context.Context, filter *socialauth.Filter) ([]*socialAccountModels.AccountSocial, error) { + var list []*socialAccountModels.AccountSocial + query := r.Slave(ctx).Model((*socialAccountModels.AccountSocial)(nil)) query = filter.PrepareQuery(query) err := query.Find(&list).Error if errors.Is(err, gorm.ErrRecordNotFound) { @@ -44,7 +44,7 @@ func (r *Repository) List(ctx context.Context, filter *socialauth.Filter) ([]*mo } // Create new account in the database -func (r *Repository) Create(ctx context.Context, account *model.AccountSocial) (uint64, error) { +func (r *Repository) Create(ctx context.Context, account *socialAccountModels.AccountSocial) (uint64, error) { err := r.Master(ctx).Create(account).Error if err != nil { return 0, err @@ -53,9 +53,9 @@ func (r *Repository) Create(ctx context.Context, account *model.AccountSocial) ( } // Update account in the database -func (r *Repository) Update(ctx context.Context, id uint64, account *model.AccountSocial) error { +func (r *Repository) Update(ctx context.Context, id uint64, account *socialAccountModels.AccountSocial) error { return r.Master(ctx). - Model((*model.AccountSocial)(nil)). + Model((*socialAccountModels.AccountSocial)(nil)). Where("id = ?", id). Unscoped(). Updates(account).Error @@ -64,8 +64,8 @@ func (r *Repository) Update(ctx context.Context, id uint64, account *model.Accou // Token returns the token by social account ID func (r *Repository) Token(ctx context.Context, name string, id uint64) (*elogin.Token, error) { var ( - sess model.AccountSocialSession - err = r.Slave(ctx).Model((*model.AccountSocialSession)(nil)). + sess socialAccountModels.AccountSocialSession + err = r.Slave(ctx).Model((*socialAccountModels.AccountSocialSession)(nil)). Where("account_social_id=? AND name=?", id, name). First(&sess).Error ) @@ -87,8 +87,8 @@ func (r *Repository) Token(ctx context.Context, name string, id uint64) (*elogin // SetToken saves the token to the social account func (r *Repository) SetToken(ctx context.Context, name string, id uint64, token *elogin.Token) error { var ( - oldSess model.AccountSocialSession - db = r.Master(ctx).Model((*model.AccountSocialSession)(nil)) + oldSess socialAccountModels.AccountSocialSession + db = r.Master(ctx).Model((*socialAccountModels.AccountSocialSession)(nil)) err = db.Unscoped().Find(&oldSess, "account_social_id=? AND name=?", id, name).Error ) if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { @@ -96,7 +96,7 @@ func (r *Repository) SetToken(ctx context.Context, name string, id uint64, token } return r.Master(ctx).Unscoped(). - Save(&model.AccountSocialSession{ + Save(&socialAccountModels.AccountSocialSession{ AccountSocialID: id, Name: name, TokenType: token.TokenType, diff --git a/repository/socialauth/usecase.go b/repository/socialauth/usecase.go index 82787c75..6e75ef00 100644 --- a/repository/socialauth/usecase.go +++ b/repository/socialauth/usecase.go @@ -3,17 +3,18 @@ package socialauth import ( "context" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/auth/elogin" + socialAccountModels "github.com/geniusrabbit/blaze-api/repository/socialaccount/models" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" ) // Usecase of the socialauth account which provides bussiness logic for socialauth access // and connection to the user account by social network type Usecase interface { - Get(ctx context.Context, id uint64) (*model.AccountSocial, error) - List(ctx context.Context, filter *Filter) ([]*model.AccountSocial, error) - Register(ctx context.Context, user *model.User, account *model.AccountSocial) (uint64, error) - Update(ctx context.Context, id uint64, account *model.AccountSocial) error + Get(ctx context.Context, id uint64) (*socialAccountModels.AccountSocial, error) + List(ctx context.Context, filter *Filter) ([]*socialAccountModels.AccountSocial, error) + Register(ctx context.Context, user *userModels.User, account *socialAccountModels.AccountSocial) (uint64, error) + Update(ctx context.Context, id uint64, account *socialAccountModels.AccountSocial) error Token(ctx context.Context, name string, accountSocialID uint64) (*elogin.Token, error) SetToken(ctx context.Context, name string, accountSocialID uint64, token *elogin.Token) error } diff --git a/repository/socialauth/usecase/socialauth_usecase.go b/repository/socialauth/usecase/socialauth_usecase.go index eaad8620..3fd35c6e 100644 --- a/repository/socialauth/usecase/socialauth_usecase.go +++ b/repository/socialauth/usecase/socialauth_usecase.go @@ -6,12 +6,13 @@ import ( "github.com/pkg/errors" "gorm.io/gorm" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/acl" "github.com/geniusrabbit/blaze-api/pkg/auth/elogin" "github.com/geniusrabbit/blaze-api/pkg/context/database" "github.com/geniusrabbit/blaze-api/repository/socialauth" + socialAccountModels "github.com/geniusrabbit/blaze-api/repository/socialaccount/models" "github.com/geniusrabbit/blaze-api/repository/user" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" ) var ErrLinkToExistsUser = errors.New("to connect social account to exists user, need to be authorized") @@ -29,23 +30,23 @@ func New(userRepo user.Repository, socAccountRepo socialauth.Repository) *Usecas } // Get social account by id -func (u *Usecase) Get(ctx context.Context, id uint64) (*model.AccountSocial, error) { - if !acl.HaveAccessView(ctx, &model.AccountSocial{}) { +func (u *Usecase) Get(ctx context.Context, id uint64) (*socialAccountModels.AccountSocial, error) { + if !acl.HaveAccessView(ctx, &socialAccountModels.AccountSocial{}) { return nil, errors.Wrap(acl.ErrNoPermissions, "get social account") } return u.socAccountRepo.Get(ctx, id) } // List social accounts by filter -func (u *Usecase) List(ctx context.Context, filter *socialauth.Filter) ([]*model.AccountSocial, error) { - if !acl.HaveAccessList(ctx, &model.AccountSocial{}) { +func (u *Usecase) List(ctx context.Context, filter *socialauth.Filter) ([]*socialAccountModels.AccountSocial, error) { + if !acl.HaveAccessList(ctx, &socialAccountModels.AccountSocial{}) { return nil, errors.Wrap(acl.ErrNoPermissions, "list social accounts") } return u.socAccountRepo.List(ctx, filter) } // Register new social account and link it to the user -func (u *Usecase) Register(ctx context.Context, ownerObj *model.User, accountObj *model.AccountSocial) (uint64, error) { +func (u *Usecase) Register(ctx context.Context, ownerObj *userModels.User, accountObj *socialAccountModels.AccountSocial) (uint64, error) { if !acl.HavePermissions(ctx, "account.register") { return 0, errors.Wrap(acl.ErrNoPermissions, "register/link social account") } @@ -81,7 +82,7 @@ func (u *Usecase) Register(ctx context.Context, ownerObj *model.User, accountObj } // Update social account by id -func (u *Usecase) Update(ctx context.Context, id uint64, account *model.AccountSocial) error { +func (u *Usecase) Update(ctx context.Context, id uint64, account *socialAccountModels.AccountSocial) error { if !acl.HaveAccessUpdate(ctx, account) { return errors.Wrap(acl.ErrNoPermissions, "update social account") } diff --git a/repository/user/context/session.go b/repository/user/context/session.go new file mode 100644 index 00000000..8f5a3991 --- /dev/null +++ b/repository/user/context/session.go @@ -0,0 +1,20 @@ +package context + +import ( + "context" + + "github.com/geniusrabbit/blaze-api/repository/user/models" +) + +var ctxUserKey = &struct{ s string }{"account:user"} + +// WithSessionUser puts to the context user model +func WithSessionUser(ctx context.Context, userObj *models.User) context.Context { + return context.WithValue(ctx, ctxUserKey, userObj) +} + +// SessionUser returns current user model +// nolint:unused // temporary +func SessionUser(ctx context.Context) *models.User { + return ctx.Value(ctxUserKey).(*models.User) +} diff --git a/repository/user/delivery/graphql/connector.go b/repository/user/delivery/graphql/connector.go new file mode 100644 index 00000000..654d1f6d --- /dev/null +++ b/repository/user/delivery/graphql/connector.go @@ -0,0 +1,32 @@ +package graphql + +import ( + "context" + + "github.com/demdxx/gocast/v2" + "github.com/geniusrabbit/blaze-api/repository/user" + "github.com/geniusrabbit/blaze-api/server/graphql/connectors" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" +) + +// UserConnection implements collection accessor interface with pagination +type UserConnection = connectors.CollectionConnection[gqlmodels.User, gqlmodels.UserEdge] + +// NewUserConnection based on query object +func NewUserConnection(ctx context.Context, usersAccessor user.Usecase, filter *gqlmodels.UserListFilter, order *gqlmodels.UserListOrder, page *gqlmodels.Page) *UserConnection { + return connectors.NewCollectionConnection(ctx, &connectors.DataAccessorFunc[gqlmodels.User, gqlmodels.UserEdge]{ + FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.User, error) { + users, err := usersAccessor.FetchList(ctx, filter.Filter(), order.Order(), page.Pagination()) + return FromUserModelList(users), err + }, + CountDataFunc: func(ctx context.Context) (int64, error) { + return usersAccessor.Count(ctx, filter.Filter()) + }, + ConvertToEdgeFunc: func(obj *gqlmodels.User) *gqlmodels.UserEdge { + return &gqlmodels.UserEdge{ + Cursor: gocast.Str(obj.ID), + Node: obj, + } + }, + }, page) +} diff --git a/repository/user/delivery/graphql/mapping.go b/repository/user/delivery/graphql/mapping.go new file mode 100644 index 00000000..f836f7a1 --- /dev/null +++ b/repository/user/delivery/graphql/mapping.go @@ -0,0 +1,27 @@ +package graphql + +import ( + "github.com/demdxx/xtypes" + + "github.com/geniusrabbit/blaze-api/repository/user" + gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" +) + +// FromUserModel to local graphql model +func FromUserModel(u *user.User) *gqlmodels.User { + if u == nil { + return nil + } + return &gqlmodels.User{ + ID: u.ID, + Username: u.Email, + Status: gqlmodels.ApproveStatusFrom(u.Approve), + CreatedAt: u.CreatedAt, + UpdatedAt: u.UpdatedAt, + } +} + +// FromUserModelList converts model list to local model list +func FromUserModelList(list []*user.User) []*gqlmodels.User { + return xtypes.SliceApply(list, FromUserModel) +} diff --git a/repository/user/delivery/graphql/resolver.go b/repository/user/delivery/graphql/resolver.go index f437db9e..bec0bad7 100644 --- a/repository/user/delivery/graphql/resolver.go +++ b/repository/user/delivery/graphql/resolver.go @@ -8,16 +8,13 @@ import ( "github.com/demdxx/sendmsg" "go.uber.org/zap" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" "github.com/geniusrabbit/blaze-api/pkg/context/session" "github.com/geniusrabbit/blaze-api/pkg/messanger" + "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/pkg/requestid" "github.com/geniusrabbit/blaze-api/repository/historylog" "github.com/geniusrabbit/blaze-api/repository/user" - "github.com/geniusrabbit/blaze-api/repository/user/repository" - "github.com/geniusrabbit/blaze-api/repository/user/usecase" - "github.com/geniusrabbit/blaze-api/server/graphql/connectors" gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) @@ -31,10 +28,8 @@ type QueryResolver struct { } // NewQueryResolver returns new API resolver -func NewQueryResolver() *QueryResolver { - return &QueryResolver{ - users: usecase.NewUserUsecase(repository.New()), - } +func NewQueryResolver(uc user.Usecase) *QueryResolver { + return &QueryResolver{users: uc} } // CurrentUser returns the current user info @@ -49,10 +44,10 @@ func (r *QueryResolver) CurrentUser(ctx context.Context) (*gqlmodels.UserPayload // CreateUser is the resolver for the createUser field. func (r *QueryResolver) CreateUser(ctx context.Context, input *gqlmodels.UserInput) (*gqlmodels.UserPayload, error) { - uid, err := r.users.Store(ctx, &model.User{ + uid, err := r.users.Create(ctx, &user.User{ Email: *input.Username, Approve: input.Status.ModelStatus(), - }, "") + }, "GQL create user") if err != nil { return nil, err } @@ -63,7 +58,7 @@ func (r *QueryResolver) CreateUser(ctx context.Context, input *gqlmodels.UserInp return &gqlmodels.UserPayload{ ClientMutationID: requestid.Get(ctx), UserID: user.ID, - User: gqlmodels.FromUserModel(user), + User: FromUserModel(user), }, nil } @@ -85,21 +80,21 @@ func (r *QueryResolver) UpdateUser(ctx context.Context, id uint64, input *gqlmod return &gqlmodels.UserPayload{ ClientMutationID: requestid.Get(ctx), UserID: user.ID, - User: gqlmodels.FromUserModel(user), + User: FromUserModel(user), }, nil } // ApproveUser is the resolver for the approveUser field. func (r *QueryResolver) ApproveUser(ctx context.Context, id uint64, msg *string) (*gqlmodels.UserPayload, error) { - return r.updateApproveStatus(ctx, id, model.ApprovedApproveStatus, msg) + return r.updateApproveStatus(ctx, id, models.ApprovedApproveStatus, msg) } // RejectUser is the resolver for the rejectUser field. func (r *QueryResolver) RejectUser(ctx context.Context, id uint64, msg *string) (*gqlmodels.UserPayload, error) { - return r.updateApproveStatus(ctx, id, model.DisapprovedApproveStatus, msg) + return r.updateApproveStatus(ctx, id, models.DisapprovedApproveStatus, msg) } -func (r *QueryResolver) updateApproveStatus(ctx context.Context, id uint64, status model.ApproveStatus, msg *string) (*gqlmodels.UserPayload, error) { +func (r *QueryResolver) updateApproveStatus(ctx context.Context, id uint64, status models.ApproveStatus, msg *string) (*gqlmodels.UserPayload, error) { user, err := r.users.Get(ctx, id) if err != nil { return nil, err @@ -128,7 +123,7 @@ func (r *QueryResolver) updateApproveStatus(ctx context.Context, id uint64, stat return &gqlmodels.UserPayload{ ClientMutationID: requestid.Get(ctx), UserID: id, - User: gqlmodels.FromUserModel(user), + User: FromUserModel(user), }, nil } @@ -201,7 +196,7 @@ func (r *QueryResolver) UpdateResetedUserPassword(ctx context.Context, token, em func (r *QueryResolver) User(ctx context.Context, id uint64, username string) (*gqlmodels.UserPayload, error) { var ( err error - user *model.User + user *user.User ) switch { case id > 0: @@ -223,11 +218,11 @@ func (r *QueryResolver) User(ctx context.Context, id uint64, username string) (* return &gqlmodels.UserPayload{ ClientMutationID: requestid.Get(ctx), UserID: user.ID, - User: gqlmodels.FromUserModel(user), + User: FromUserModel(user), }, nil } // ListUsers list by filter -func (r *QueryResolver) ListUsers(ctx context.Context, filter *gqlmodels.UserListFilter, order *gqlmodels.UserListOrder, page *gqlmodels.Page) (*connectors.UserConnection, error) { - return connectors.NewUserConnection(ctx, r.users, filter, order, page), nil +func (r *QueryResolver) ListUsers(ctx context.Context, filter *gqlmodels.UserListFilter, order *gqlmodels.UserListOrder, page *gqlmodels.Page) (*UserConnection, error) { + return NewUserConnection(ctx, r.users, filter, order, page), nil } diff --git a/protocol/graphql/schemas/account_users.graphql b/repository/user/delivery/graphql/user.graphql similarity index 100% rename from protocol/graphql/schemas/account_users.graphql rename to repository/user/delivery/graphql/user.graphql diff --git a/repository/user/mocks/repository.go b/repository/user/mocks/repository.go index b867df30..c12d2c25 100644 --- a/repository/user/mocks/repository.go +++ b/repository/user/mocks/repository.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: repository.go +// +// Generated by this command: +// +// mockgen -source repository.go -package mocks -destination mocks/repository.go +// // Package mocks is a generated GoMock package. package mocks @@ -8,16 +13,15 @@ import ( context "context" reflect "reflect" - model "github.com/geniusrabbit/blaze-api/model" - repository "github.com/geniusrabbit/blaze-api/repository" user "github.com/geniusrabbit/blaze-api/repository/user" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockRepository is a mock of Repository interface. type MockRepository struct { ctrl *gomock.Controller recorder *MockRepositoryMockRecorder + isgomock struct{} } // MockRepositoryMockRecorder is the mock recorder for MockRepository. @@ -38,46 +42,51 @@ func (m *MockRepository) EXPECT() *MockRepositoryMockRecorder { } // Count mocks base method. -func (m *MockRepository) Count(ctx context.Context, filter *user.ListFilter) (int64, error) { +func (m *MockRepository) Count(ctx context.Context, opts ...user.QOption) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockRepositoryMockRecorder) Count(ctx, filter interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Count(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockRepository)(nil).Count), varargs...) } // Create mocks base method. -func (m *MockRepository) Create(ctx context.Context, user *model.User, password string) (uint64, error) { +func (m *MockRepository) Create(ctx context.Context, arg1 *user.User, password string) (uint64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", ctx, user, password) + ret := m.ctrl.Call(m, "Create", ctx, arg1, password) ret0, _ := ret[0].(uint64) ret1, _ := ret[1].(error) return ret0, ret1 } // Create indicates an expected call of Create. -func (mr *MockRepositoryMockRecorder) Create(ctx, user, password interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Create(ctx, arg1, password any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockRepository)(nil).Create), ctx, user, password) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockRepository)(nil).Create), ctx, arg1, password) } // CreateResetPassword mocks base method. -func (m *MockRepository) CreateResetPassword(ctx context.Context, userID uint64) (*model.UserPasswordReset, error) { +func (m *MockRepository) CreateResetPassword(ctx context.Context, userID uint64) (*user.UserPasswordReset, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateResetPassword", ctx, userID) - ret0, _ := ret[0].(*model.UserPasswordReset) + ret0, _ := ret[0].(*user.UserPasswordReset) ret1, _ := ret[1].(error) return ret0, ret1 } // CreateResetPassword indicates an expected call of CreateResetPassword. -func (mr *MockRepositoryMockRecorder) CreateResetPassword(ctx, userID interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) CreateResetPassword(ctx, userID any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateResetPassword", reflect.TypeOf((*MockRepository)(nil).CreateResetPassword), ctx, userID) } @@ -91,7 +100,7 @@ func (m *MockRepository) Delete(ctx context.Context, id uint64) error { } // Delete indicates an expected call of Delete. -func (mr *MockRepositoryMockRecorder) Delete(ctx, id interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Delete(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRepository)(nil).Delete), ctx, id) } @@ -105,126 +114,115 @@ func (m *MockRepository) EliminateResetPassword(ctx context.Context, userID uint } // EliminateResetPassword indicates an expected call of EliminateResetPassword. -func (mr *MockRepositoryMockRecorder) EliminateResetPassword(ctx, userID interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) EliminateResetPassword(ctx, userID any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EliminateResetPassword", reflect.TypeOf((*MockRepository)(nil).EliminateResetPassword), ctx, userID) } // FetchList mocks base method. -func (m *MockRepository) FetchList(ctx context.Context, filter *user.ListFilter, order *user.ListOrder, page *repository.Pagination) ([]*model.User, error) { +func (m *MockRepository) FetchList(ctx context.Context, opts ...user.QOption) ([]*user.User, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter, order, page) - ret0, _ := ret[0].([]*model.User) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*user.User) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockRepositoryMockRecorder) FetchList(ctx, filter, order, page interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) FetchList(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), ctx, filter, order, page) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockRepository)(nil).FetchList), varargs...) } // Get mocks base method. -func (m *MockRepository) Get(ctx context.Context, id uint64) (*model.User, error) { +func (m *MockRepository) Get(ctx context.Context, id uint64) (*user.User, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Get", ctx, id) - ret0, _ := ret[0].(*model.User) + ret0, _ := ret[0].(*user.User) ret1, _ := ret[1].(error) return ret0, ret1 } // Get indicates an expected call of Get. -func (mr *MockRepositoryMockRecorder) Get(ctx, id interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Get(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRepository)(nil).Get), ctx, id) } // GetByEmail mocks base method. -func (m *MockRepository) GetByEmail(ctx context.Context, email string) (*model.User, error) { +func (m *MockRepository) GetByEmail(ctx context.Context, email string) (*user.User, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetByEmail", ctx, email) - ret0, _ := ret[0].(*model.User) + ret0, _ := ret[0].(*user.User) ret1, _ := ret[1].(error) return ret0, ret1 } // GetByEmail indicates an expected call of GetByEmail. -func (mr *MockRepositoryMockRecorder) GetByEmail(ctx, email interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) GetByEmail(ctx, email any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByEmail", reflect.TypeOf((*MockRepository)(nil).GetByEmail), ctx, email) } // GetByPassword mocks base method. -func (m *MockRepository) GetByPassword(ctx context.Context, email, password string) (*model.User, error) { +func (m *MockRepository) GetByPassword(ctx context.Context, email, password string) (*user.User, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetByPassword", ctx, email, password) - ret0, _ := ret[0].(*model.User) + ret0, _ := ret[0].(*user.User) ret1, _ := ret[1].(error) return ret0, ret1 } // GetByPassword indicates an expected call of GetByPassword. -func (mr *MockRepositoryMockRecorder) GetByPassword(ctx, email, password interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) GetByPassword(ctx, email, password any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByPassword", reflect.TypeOf((*MockRepository)(nil).GetByPassword), ctx, email, password) } -// GetByToken mocks base method. -func (m *MockRepository) GetByToken(ctx context.Context, token string) (*model.User, *model.Account, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetByToken", ctx, token) - ret0, _ := ret[0].(*model.User) - ret1, _ := ret[1].(*model.Account) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// GetByToken indicates an expected call of GetByToken. -func (mr *MockRepositoryMockRecorder) GetByToken(ctx, token interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByToken", reflect.TypeOf((*MockRepository)(nil).GetByToken), ctx, token) -} - // GetResetPassword mocks base method. -func (m *MockRepository) GetResetPassword(ctx context.Context, userID uint64, token string) (*model.UserPasswordReset, error) { +func (m *MockRepository) GetResetPassword(ctx context.Context, userID uint64, token string) (*user.UserPasswordReset, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetResetPassword", ctx, userID, token) - ret0, _ := ret[0].(*model.UserPasswordReset) + ret0, _ := ret[0].(*user.UserPasswordReset) ret1, _ := ret[1].(error) return ret0, ret1 } // GetResetPassword indicates an expected call of GetResetPassword. -func (mr *MockRepositoryMockRecorder) GetResetPassword(ctx, userID, token interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) GetResetPassword(ctx, userID, token any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetResetPassword", reflect.TypeOf((*MockRepository)(nil).GetResetPassword), ctx, userID, token) } // SetPassword mocks base method. -func (m *MockRepository) SetPassword(ctx context.Context, user *model.User, password string) error { +func (m *MockRepository) SetPassword(ctx context.Context, arg1 *user.User, password string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetPassword", ctx, user, password) + ret := m.ctrl.Call(m, "SetPassword", ctx, arg1, password) ret0, _ := ret[0].(error) return ret0 } // SetPassword indicates an expected call of SetPassword. -func (mr *MockRepositoryMockRecorder) SetPassword(ctx, user, password interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) SetPassword(ctx, arg1, password any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetPassword", reflect.TypeOf((*MockRepository)(nil).SetPassword), ctx, user, password) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetPassword", reflect.TypeOf((*MockRepository)(nil).SetPassword), ctx, arg1, password) } // Update mocks base method. -func (m *MockRepository) Update(ctx context.Context, user *model.User) error { +func (m *MockRepository) Update(ctx context.Context, arg1 *user.User) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Update", ctx, user) + ret := m.ctrl.Call(m, "Update", ctx, arg1) ret0, _ := ret[0].(error) return ret0 } // Update indicates an expected call of Update. -func (mr *MockRepositoryMockRecorder) Update(ctx, user interface{}) *gomock.Call { +func (mr *MockRepositoryMockRecorder) Update(ctx, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockRepository)(nil).Update), ctx, user) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockRepository)(nil).Update), ctx, arg1) } diff --git a/repository/user/mocks/usecase.go b/repository/user/mocks/usecase.go index dcb3f0e6..a5553dff 100644 --- a/repository/user/mocks/usecase.go +++ b/repository/user/mocks/usecase.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: usercase.go +// +// Generated by this command: +// +// mockgen -source usercase.go -package mocks -destination mocks/usecase.go +// // Package mocks is a generated GoMock package. package mocks @@ -8,16 +13,15 @@ import ( context "context" reflect "reflect" - model "github.com/geniusrabbit/blaze-api/model" - repository "github.com/geniusrabbit/blaze-api/repository" user "github.com/geniusrabbit/blaze-api/repository/user" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockUsecase is a mock of Usecase interface. type MockUsecase struct { ctrl *gomock.Controller recorder *MockUsecaseMockRecorder + isgomock struct{} } // MockUsecaseMockRecorder is the mock recorder for MockUsecase. @@ -38,18 +42,38 @@ func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder { } // Count mocks base method. -func (m *MockUsecase) Count(ctx context.Context, filter *user.ListFilter) (int64, error) { +func (m *MockUsecase) Count(ctx context.Context, opts ...user.QOption) (int64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Count", ctx, filter) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Count", varargs...) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Count indicates an expected call of Count. -func (mr *MockUsecaseMockRecorder) Count(ctx, filter interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Count(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), ctx, filter) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Count", reflect.TypeOf((*MockUsecase)(nil).Count), varargs...) +} + +// Create mocks base method. +func (m *MockUsecase) Create(ctx context.Context, arg1 *user.User, password string) (uint64, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Create", ctx, arg1, password) + ret0, _ := ret[0].(uint64) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Create indicates an expected call of Create. +func (mr *MockUsecaseMockRecorder) Create(ctx, arg1, password any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockUsecase)(nil).Create), ctx, arg1, password) } // Delete mocks base method. @@ -61,144 +85,118 @@ func (m *MockUsecase) Delete(ctx context.Context, id uint64) error { } // Delete indicates an expected call of Delete. -func (mr *MockUsecaseMockRecorder) Delete(ctx, id interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Delete(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockUsecase)(nil).Delete), ctx, id) } // FetchList mocks base method. -func (m *MockUsecase) FetchList(ctx context.Context, filter *user.ListFilter, order *user.ListOrder, page *repository.Pagination) ([]*model.User, error) { +func (m *MockUsecase) FetchList(ctx context.Context, opts ...user.QOption) ([]*user.User, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FetchList", ctx, filter, order, page) - ret0, _ := ret[0].([]*model.User) + varargs := []any{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FetchList", varargs...) + ret0, _ := ret[0].([]*user.User) ret1, _ := ret[1].(error) return ret0, ret1 } // FetchList indicates an expected call of FetchList. -func (mr *MockUsecaseMockRecorder) FetchList(ctx, filter, order, page interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) FetchList(ctx any, opts ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), ctx, filter, order, page) + varargs := append([]any{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchList", reflect.TypeOf((*MockUsecase)(nil).FetchList), varargs...) } // Get mocks base method. -func (m *MockUsecase) Get(ctx context.Context, id uint64) (*model.User, error) { +func (m *MockUsecase) Get(ctx context.Context, id uint64) (*user.User, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Get", ctx, id) - ret0, _ := ret[0].(*model.User) + ret0, _ := ret[0].(*user.User) ret1, _ := ret[1].(error) return ret0, ret1 } // Get indicates an expected call of Get. -func (mr *MockUsecaseMockRecorder) Get(ctx, id interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Get(ctx, id any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockUsecase)(nil).Get), ctx, id) } // GetByEmail mocks base method. -func (m *MockUsecase) GetByEmail(ctx context.Context, email string) (*model.User, error) { +func (m *MockUsecase) GetByEmail(ctx context.Context, email string) (*user.User, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetByEmail", ctx, email) - ret0, _ := ret[0].(*model.User) + ret0, _ := ret[0].(*user.User) ret1, _ := ret[1].(error) return ret0, ret1 } // GetByEmail indicates an expected call of GetByEmail. -func (mr *MockUsecaseMockRecorder) GetByEmail(ctx, email interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) GetByEmail(ctx, email any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByEmail", reflect.TypeOf((*MockUsecase)(nil).GetByEmail), ctx, email) } // GetByPassword mocks base method. -func (m *MockUsecase) GetByPassword(ctx context.Context, email, password string) (*model.User, error) { +func (m *MockUsecase) GetByPassword(ctx context.Context, email, password string) (*user.User, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetByPassword", ctx, email, password) - ret0, _ := ret[0].(*model.User) + ret0, _ := ret[0].(*user.User) ret1, _ := ret[1].(error) return ret0, ret1 } // GetByPassword indicates an expected call of GetByPassword. -func (mr *MockUsecaseMockRecorder) GetByPassword(ctx, email, password interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) GetByPassword(ctx, email, password any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByPassword", reflect.TypeOf((*MockUsecase)(nil).GetByPassword), ctx, email, password) } -// GetByToken mocks base method. -func (m *MockUsecase) GetByToken(ctx context.Context, token string) (*model.User, *model.Account, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetByToken", ctx, token) - ret0, _ := ret[0].(*model.User) - ret1, _ := ret[1].(*model.Account) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// GetByToken indicates an expected call of GetByToken. -func (mr *MockUsecaseMockRecorder) GetByToken(ctx, token interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByToken", reflect.TypeOf((*MockUsecase)(nil).GetByToken), ctx, token) -} - // ResetPassword mocks base method. -func (m *MockUsecase) ResetPassword(ctx context.Context, email string) (*model.UserPasswordReset, *model.User, error) { +func (m *MockUsecase) ResetPassword(ctx context.Context, email string) (*user.UserPasswordReset, *user.User, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ResetPassword", ctx, email) - ret0, _ := ret[0].(*model.UserPasswordReset) - ret1, _ := ret[1].(*model.User) + ret0, _ := ret[0].(*user.UserPasswordReset) + ret1, _ := ret[1].(*user.User) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } // ResetPassword indicates an expected call of ResetPassword. -func (mr *MockUsecaseMockRecorder) ResetPassword(ctx, email interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) ResetPassword(ctx, email any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResetPassword", reflect.TypeOf((*MockUsecase)(nil).ResetPassword), ctx, email) } // SetPassword mocks base method. -func (m *MockUsecase) SetPassword(ctx context.Context, user *model.User, password string) error { +func (m *MockUsecase) SetPassword(ctx context.Context, arg1 *user.User, password string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetPassword", ctx, user, password) + ret := m.ctrl.Call(m, "SetPassword", ctx, arg1, password) ret0, _ := ret[0].(error) return ret0 } // SetPassword indicates an expected call of SetPassword. -func (mr *MockUsecaseMockRecorder) SetPassword(ctx, user, password interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetPassword", reflect.TypeOf((*MockUsecase)(nil).SetPassword), ctx, user, password) -} - -// Store mocks base method. -func (m *MockUsecase) Store(ctx context.Context, user *model.User, password string) (uint64, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Store", ctx, user, password) - ret0, _ := ret[0].(uint64) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Store indicates an expected call of Store. -func (mr *MockUsecaseMockRecorder) Store(ctx, user, password interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) SetPassword(ctx, arg1, password any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Store", reflect.TypeOf((*MockUsecase)(nil).Store), ctx, user, password) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetPassword", reflect.TypeOf((*MockUsecase)(nil).SetPassword), ctx, arg1, password) } // Update mocks base method. -func (m *MockUsecase) Update(ctx context.Context, user *model.User) error { +func (m *MockUsecase) Update(ctx context.Context, arg1 *user.User) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Update", ctx, user) + ret := m.ctrl.Call(m, "Update", ctx, arg1) ret0, _ := ret[0].(error) return ret0 } // Update indicates an expected call of Update. -func (mr *MockUsecaseMockRecorder) Update(ctx, user interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) Update(ctx, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockUsecase)(nil).Update), ctx, user) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockUsecase)(nil).Update), ctx, arg1) } // UpdatePassword mocks base method. @@ -210,7 +208,7 @@ func (m *MockUsecase) UpdatePassword(ctx context.Context, token, email, password } // UpdatePassword indicates an expected call of UpdatePassword. -func (mr *MockUsecaseMockRecorder) UpdatePassword(ctx, token, email, password interface{}) *gomock.Call { +func (mr *MockUsecaseMockRecorder) UpdatePassword(ctx, token, email, password any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdatePassword", reflect.TypeOf((*MockUsecase)(nil).UpdatePassword), ctx, token, email, password) } diff --git a/repository/user/models.go b/repository/user/models.go new file mode 100644 index 00000000..d0f0eb9b --- /dev/null +++ b/repository/user/models.go @@ -0,0 +1,14 @@ +package user + +import "github.com/geniusrabbit/blaze-api/repository/user/models" + +type ( + // User is the main user model + User = models.User + + // UserPasswordReset is the model for password reset tokens + UserPasswordReset = models.UserPasswordReset +) + +// Anonymous user object +var Anonymous = User{ID: 0} diff --git a/model/account_user.go b/repository/user/models/user.go similarity index 64% rename from model/account_user.go rename to repository/user/models/user.go index 9b2d36f8..463552fe 100644 --- a/model/account_user.go +++ b/repository/user/models/user.go @@ -1,9 +1,11 @@ -package model +package models import ( "time" "gorm.io/gorm" + + "github.com/geniusrabbit/blaze-api/pkg/models" ) // Anonymous user object @@ -11,18 +13,20 @@ var Anonymous = User{ID: 0} // User direct defenition type User struct { - ID uint64 `json:"id" gorm:"primaryKey"` - Email string `json:"email"` - Password string `json:"password"` + ID uint64 `json:"id" gorm:"primaryKey"` + Email string `json:"email"` + + Password string `json:"password"` + RequiredPasswordReset bool `json:"required_password_reset"` - Approve ApproveStatus `gorm:"column:approve_status" db:"approve_status" json:"approve_status"` + Approve models.ApproveStatus `gorm:"column:approve_status" db:"approve_status" json:"approve_status"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"deleted_at"` } -// GetID returns user id +// GetID returns user ID func (u *User) GetID() uint64 { if u == nil { return 0 @@ -30,6 +34,11 @@ func (u *User) GetID() uint64 { return u.ID } +// IsNil checks if the user is nil +func (u *User) IsNil() bool { + return u == nil +} + // TableName returns the name in database func (u *User) TableName() string { return "account_user" diff --git a/model/account_user_reset_password.go b/repository/user/models/user_password_reset.go similarity index 96% rename from model/account_user_reset_password.go rename to repository/user/models/user_password_reset.go index c0f247cd..bfbe9e4c 100644 --- a/model/account_user_reset_password.go +++ b/repository/user/models/user_password_reset.go @@ -1,4 +1,4 @@ -package model +package models import ( "time" diff --git a/repository/user/password.go b/repository/user/password/password.go similarity index 98% rename from repository/user/password.go rename to repository/user/password/password.go index 80dc28a3..4ab5d955 100644 --- a/repository/user/password.go +++ b/repository/user/password/password.go @@ -1,4 +1,4 @@ -package user +package password import ( "golang.org/x/crypto/bcrypt" diff --git a/repository/user/password_test.go b/repository/user/password/password_test.go similarity index 95% rename from repository/user/password_test.go rename to repository/user/password/password_test.go index 1e817047..1a1c3717 100644 --- a/repository/user/password_test.go +++ b/repository/user/password/password_test.go @@ -1,4 +1,4 @@ -package user +package password import ( "testing" diff --git a/repository/user/repository/utils.go b/repository/user/password/rest_token.go similarity index 69% rename from repository/user/repository/utils.go rename to repository/user/password/rest_token.go index cade1196..485d39a4 100644 --- a/repository/user/repository/utils.go +++ b/repository/user/password/rest_token.go @@ -1,4 +1,4 @@ -package repository +package password import ( "bytes" @@ -7,7 +7,8 @@ import ( const tokenAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-$@" -func generateResetToken(size int) string { +// GenerateResetToken generates a random token for password reset +func GenerateResetToken(size int) string { var randomString bytes.Buffer for i := 0; i < size; i++ { randomString.WriteByte(tokenAlphabet[rand.Intn(len(tokenAlphabet))]) diff --git a/repository/user/query.go b/repository/user/query.go index 4e3f8fb7..d42aa53a 100644 --- a/repository/user/query.go +++ b/repository/user/query.go @@ -6,15 +6,17 @@ import ( "github.com/demdxx/xtypes" "gorm.io/gorm" - "github.com/geniusrabbit/blaze-api/model" + "github.com/geniusrabbit/blaze-api/pkg/models" + "github.com/geniusrabbit/blaze-api/repository" ) +// Order Ascending or Descending for query fields +type Order = models.Order + // ListFilter object with filtered values which is not NULL type ListFilter struct { - AccountID []uint64 - UserID []uint64 - Emails []string - Roles []uint64 + UserID []uint64 + Emails []string } // PrepareQuery returns the query with applied filters @@ -22,48 +24,44 @@ func (fl *ListFilter) PrepareQuery(q *gorm.DB) *gorm.DB { if fl == nil { return q } - if len(fl.Roles) > 0 { - qstr := `SELECT member_id FROM ` + - (*model.M2MAccountMemberRole)(nil).TableName() + ` WHERE role_id IN (?)` - if len(fl.AccountID) > 0 { - q = q.Where(`id IN (SELECT user_id FROM `+(*model.AccountMember)(nil).TableName()+ - ` WHERE account_id IN (?) OR id IN (`+qstr+`))`, fl.AccountID, fl.Roles) - } else { - q = q.Where(`id IN (SELECT user_id FROM `+(*model.AccountMember)(nil).TableName()+ - ` WHERE id IN (`+qstr+`))`, fl.Roles) - } - } else if len(fl.AccountID) > 0 { - q = q.Where(`id IN (SELECT user_id FROM `+ - (*model.AccountMember)(nil).TableName()+` WHERE account_id IN (?))`, fl.AccountID) - } if len(fl.UserID) > 0 { q = q.Where(`id IN (?)`, fl.UserID) } if len(fl.Emails) > 0 { - q = q.Where(`lower(email) IN (?)`, xtypes.SliceApply(fl.Emails, func(v string) string { - return strings.ToLower(v) - })) + q = q.Where(`lower(email) IN (?)`, xtypes.SliceApply(fl.Emails, strings.ToLower)) } return q } // ListOrder object with order values which is not NULL type ListOrder struct { - ID model.Order - Email model.Order - Status model.Order - CreatedAt model.Order - UpdatedAt model.Order + ID Order + Email Order + Status Order + CreatedAt Order + UpdatedAt Order } // PrepareQuery returns the query with applied order func (ord *ListOrder) PrepareQuery(q *gorm.DB) *gorm.DB { - if ord != nil { - q = ord.ID.PrepareQuery(q, "id") - q = ord.Email.PrepareQuery(q, "email") - q = ord.Status.PrepareQuery(q, "approve_status") - q = ord.CreatedAt.PrepareQuery(q, "created_at") - q = ord.UpdatedAt.PrepareQuery(q, "updated_at") + if ord == nil { + return q } + q = ord.ID.PrepareQuery(q, "id") + q = ord.Email.PrepareQuery(q, "email") + q = ord.Status.PrepareQuery(q, "approve_status") + q = ord.CreatedAt.PrepareQuery(q, "created_at") + q = ord.UpdatedAt.PrepareQuery(q, "updated_at") return q } + +type ( + // Pagination is the pagination object + Pagination = repository.Pagination + + // QOption is the query option interface + QOption = repository.QOption + + // ListOptions is the list options struct + ListOptions = repository.ListOptions +) diff --git a/repository/user/repository.go b/repository/user/repository.go index 900922b5..87f495d7 100644 --- a/repository/user/repository.go +++ b/repository/user/repository.go @@ -3,27 +3,25 @@ package user import ( "context" - - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" ) // Repository describes basic user methods // //go:generate mockgen -source $GOFILE -package mocks -destination mocks/repository.go type Repository interface { - Get(ctx context.Context, id uint64) (*model.User, error) - GetByEmail(ctx context.Context, email string) (*model.User, error) - GetByPassword(ctx context.Context, email, password string) (*model.User, error) - GetByToken(ctx context.Context, token string) (*model.User, *model.Account, error) - FetchList(ctx context.Context, filter *ListFilter, order *ListOrder, page *repository.Pagination) ([]*model.User, error) - Count(ctx context.Context, filter *ListFilter) (int64, error) - Create(ctx context.Context, user *model.User, password string) (uint64, error) - Update(ctx context.Context, user *model.User) error + Get(ctx context.Context, id uint64) (*User, error) + GetByEmail(ctx context.Context, email string) (*User, error) + GetByPassword(ctx context.Context, email, password string) (*User, error) + FetchList(ctx context.Context, opts ...QOption) ([]*User, error) + Count(ctx context.Context, opts ...QOption) (int64, error) + + Create(ctx context.Context, user *User, password string) (uint64, error) + Update(ctx context.Context, user *User) error Delete(ctx context.Context, id uint64) error - SetPassword(ctx context.Context, user *model.User, password string) error - CreateResetPassword(ctx context.Context, userID uint64) (*model.UserPasswordReset, error) - GetResetPassword(ctx context.Context, userID uint64, token string) (*model.UserPasswordReset, error) + SetPassword(ctx context.Context, user *User, password string) error + + CreateResetPassword(ctx context.Context, userID uint64) (*UserPasswordReset, error) + GetResetPassword(ctx context.Context, userID uint64, token string) (*UserPasswordReset, error) EliminateResetPassword(ctx context.Context, userID uint64) error } diff --git a/repository/user/repository/password.go b/repository/user/repository/password.go index 0936b6fd..30a1f2b4 100644 --- a/repository/user/repository/password.go +++ b/repository/user/repository/password.go @@ -5,11 +5,11 @@ import ( "go.uber.org/zap" - "github.com/geniusrabbit/blaze-api/repository/user" + "github.com/geniusrabbit/blaze-api/repository/user/password" ) func (r *Repository) hashAndSalt(pwd []byte) string { - hash, err := user.PasswordHash(pwd) + hash, err := password.PasswordHash(pwd) if err != nil { zap.L().Error("GenerateFromPassword", zap.Error(err)) } @@ -17,7 +17,7 @@ func (r *Repository) hashAndSalt(pwd []byte) string { } func (r *Repository) comparePasswords(hashedPwd string, plainPwd []byte) bool { - err := user.ComparePasswords(hashedPwd, plainPwd) + err := password.ComparePasswords(hashedPwd, plainPwd) if err != nil { zap.L().Error("CompareHashAndPassword", zap.Error(err)) return false diff --git a/repository/user/repository/user_repository.go b/repository/user/repository/user_repository.go index cad13b13..4da0eda5 100644 --- a/repository/user/repository/user_repository.go +++ b/repository/user/repository/user_repository.go @@ -7,13 +7,14 @@ import ( "strings" "time" - "github.com/demdxx/rbac" "github.com/pkg/errors" "gorm.io/gorm" - "github.com/geniusrabbit/blaze-api/model" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/user" + "github.com/geniusrabbit/blaze-api/repository/user/models" + "github.com/geniusrabbit/blaze-api/repository/user/password" ) // Errors list... @@ -27,14 +28,14 @@ type Repository struct { repository.Repository } -// New repository accessor to work with users and profiles -func New() *Repository { +// NewUserRepository repository accessor to work with users and profiles +func NewUserRepository() *Repository { return &Repository{} } // Get one object by ID -func (r *Repository) Get(ctx context.Context, id uint64) (*model.User, error) { - object := new(model.User) +func (r *Repository) Get(ctx context.Context, id uint64) (*models.User, error) { + object := new(models.User) if err := r.Slave(ctx).First(object, id).Error; err != nil { return nil, err } @@ -42,8 +43,8 @@ func (r *Repository) Get(ctx context.Context, id uint64) (*model.User, error) { } // GetByEmail one object by Email -func (r *Repository) GetByEmail(ctx context.Context, email string) (*model.User, error) { - object := new(model.User) +func (r *Repository) GetByEmail(ctx context.Context, email string) (*models.User, error) { + object := new(models.User) if err := r.Slave(ctx).First(object, `lower(email)=?`, strings.ToLower(email)).Error; err != nil { if errors.Is(err, gorm.ErrRecordNotFound) || errors.Is(err, sql.ErrNoRows) { return nil, nil @@ -54,7 +55,7 @@ func (r *Repository) GetByEmail(ctx context.Context, email string) (*model.User, } // GetByPassword user returns user object by password -func (r *Repository) GetByPassword(ctx context.Context, email, password string) (*model.User, error) { +func (r *Repository) GetByPassword(ctx context.Context, email, password string) (*models.User, error) { object, err := r.GetByEmail(ctx, email) if err != nil { return nil, err @@ -65,62 +66,13 @@ func (r *Repository) GetByPassword(ctx context.Context, email, password string) return object, nil } -// GetByToken returns the user object linked to the token (external session ID) -func (r *Repository) GetByToken(ctx context.Context, token string) (*model.User, *model.Account, error) { - var ( - err error - roles []uint64 - db = r.Slave(ctx) - userObj = new(model.User) - account = new(model.Account) - memeber = new(model.AccountMember) - memberRequest = `WITH auth_client AS (` + - ` SELECT user_id, account_id FROM ` + (*model.AuthClient)(nil).TableName() + ` WHERE id = (` + - ` SELECT client_id FROM ` + (*model.AuthSession)(nil).TableName() + ` WHERE deleted_at IS NULL AND access_token=?` + - ` )` + - `)` + - `SELECT am.* FROM ` + (*model.AccountMember)(nil).TableName() + ` AS am, auth_client AS ac` + - ` WHERE am.deleted_at IS NULL AND am.account_id=ac.account_id AND am.user_id=ac.user_id` - ) - if err = db.Raw(memberRequest, token).Scan(memeber).Error; err != nil { - return nil, nil, errors.WithStack(err) - } - if err = db.First(userObj, memeber.UserID).Error; err != nil { - return nil, nil, errors.WithStack(err) - } - if err = db.First(account, memeber.AccountID).Error; err != nil { - return nil, nil, errors.WithStack(err) - } - err = db.Model(&model.M2MAccountMemberRole{}). - Select("role_id").Where(`member_id=?`, memeber.ID).Scan(&roles).Error - if err != nil && err != gorm.ErrRecordNotFound { - // `sql.ErrNoRows` in case of no any linked permissions - return nil, nil, errors.WithStack(err) - } - if len(roles) > 0 || memeber.IsAdmin { - if account.Approve.IsApproved() && userObj.Approve.IsApproved() { - account.Permissions, err = r.PermissionManager(ctx).AsOneRole(ctx, memeber.IsAdmin, nil, roles...) - } else { - account.Permissions, err = r.PermissionManager(ctx).AsOneRole(ctx, false, func(_ context.Context, r rbac.Role) bool { - return !strings.HasPrefix(r.Name(), "system:") - }, roles...) - } - if err != nil { - return nil, nil, err - } - } - return userObj, account, nil -} - // FetchList of users by filter -func (r *Repository) FetchList(ctx context.Context, filter *user.ListFilter, order *user.ListOrder, page *repository.Pagination) ([]*model.User, error) { +func (r *Repository) FetchList(ctx context.Context, opts ...user.QOption) ([]*models.User, error) { var ( - list []*model.User - query = r.Slave(ctx).Model((*model.User)(nil)) + list []*models.User + query = r.Slave(ctx).Model((*models.User)(nil)) ) - query = filter.PrepareQuery(query) - query = order.PrepareQuery(query) - query = page.PrepareQuery(query) + query = user.ListOptions(opts).PrepareQuery(query) err := query.Find(&list).Error if errors.Is(err, gorm.ErrRecordNotFound) { err = nil @@ -129,12 +81,12 @@ func (r *Repository) FetchList(ctx context.Context, filter *user.ListFilter, ord } // Count of users by filter -func (r *Repository) Count(ctx context.Context, filter *user.ListFilter) (int64, error) { +func (r *Repository) Count(ctx context.Context, opts ...user.QOption) (int64, error) { var ( count int64 - query = r.Slave(ctx).Model((*model.User)(nil)) + query = r.Slave(ctx).Model((*models.User)(nil)) ) - query = filter.PrepareQuery(query) + query = user.ListOptions(opts).PrepareQuery(query) err := query.Count(&count).Error if errors.Is(err, gorm.ErrRecordNotFound) { err = nil @@ -143,17 +95,17 @@ func (r *Repository) Count(ctx context.Context, filter *user.ListFilter) (int64, } // SetPassword to the user -func (r *Repository) SetPassword(ctx context.Context, userObj *model.User, password string) error { +func (r *Repository) SetPassword(ctx context.Context, userObj *models.User, password string) error { userObj.Password = r.hashAndSalt([]byte(password)) return r.Update(ctx, userObj) } // CreateResetPassword creates new reset password token -func (r *Repository) CreateResetPassword(ctx context.Context, userID uint64) (*model.UserPasswordReset, error) { +func (r *Repository) CreateResetPassword(ctx context.Context, userID uint64) (*models.UserPasswordReset, error) { var ( - token = generateResetToken(128) + token = password.GenerateResetToken(128) expires = time.Now().Add(time.Hour * 1) - reset = &model.UserPasswordReset{ + reset = &models.UserPasswordReset{ UserID: userID, Token: token, CreatedAt: time.Now(), @@ -167,8 +119,8 @@ func (r *Repository) CreateResetPassword(ctx context.Context, userID uint64) (*m } // GetResetPassword returns reset password token -func (r *Repository) GetResetPassword(ctx context.Context, userID uint64, token string) (*model.UserPasswordReset, error) { - reset := new(model.UserPasswordReset) +func (r *Repository) GetResetPassword(ctx context.Context, userID uint64, token string) (*models.UserPasswordReset, error) { + reset := new(models.UserPasswordReset) if err := r.Slave(ctx).First(reset, `token=? AND user_id=?`, token, userID).Error; err != nil { return nil, err } @@ -177,11 +129,11 @@ func (r *Repository) GetResetPassword(ctx context.Context, userID uint64, token // EliminateResetPassword removes reset password token func (r *Repository) EliminateResetPassword(ctx context.Context, userID uint64) error { - return r.Master(ctx).Delete(&model.UserPasswordReset{}, `user_id=?`, userID).Error + return r.Master(ctx).Delete(&models.UserPasswordReset{}, `user_id=?`, userID).Error } // Create new user object to database -func (r *Repository) Create(ctx context.Context, userObj *model.User, password string) (uint64, error) { +func (r *Repository) Create(ctx context.Context, userObj *models.User, password string) (uint64, error) { if password != "" { userObj.Password = r.hashAndSalt([]byte(password)) } else { @@ -189,13 +141,13 @@ func (r *Repository) Create(ctx context.Context, userObj *model.User, password s } userObj.CreatedAt = time.Now() userObj.UpdatedAt = userObj.CreatedAt - userObj.Approve = model.UndefinedApproveStatus + userObj.Approve = pkgModels.UndefinedApproveStatus err := r.Master(ctx).Create(userObj).Error return userObj.ID, err } // Update existing object in database -func (r *Repository) Update(ctx context.Context, userObj *model.User) error { +func (r *Repository) Update(ctx context.Context, userObj *models.User) error { if userObj.ID == 0 { return ErrInvalidUserObject } @@ -204,7 +156,7 @@ func (r *Repository) Update(ctx context.Context, userObj *model.User) error { // Delete delites record by ID func (r *Repository) Delete(ctx context.Context, id uint64) error { - res := r.Master(ctx).Delete(&model.User{}, id) + res := r.Master(ctx).Delete(&models.User{}, id) if res.Error != nil { return res.Error } else if res.RowsAffected == 0 { diff --git a/repository/user/repository/user_test.go b/repository/user/repository/user_test.go index 0d76e929..c2a3bc5d 100644 --- a/repository/user/repository/user_test.go +++ b/repository/user/repository/user_test.go @@ -7,16 +7,14 @@ import ( sqlmock "github.com/DATA-DOG/go-sqlmock" "github.com/stretchr/testify/suite" - "github.com/geniusrabbit/blaze-api/model" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/testsuite" "github.com/geniusrabbit/blaze-api/repository/user" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" + "github.com/geniusrabbit/blaze-api/repository/user/password" ) -// make pwgen PASSWORD=test -// go run cmd/pwgen/main.go test -// PwSalt: 1111111 -// PwCost: 12 // Password: test // PassHash: $2a$12$mbz/OdK.Pal.AwOz13RxX.PDqkthADBr.B4UMXerY4QbQeqAiJGma const ( @@ -32,9 +30,9 @@ type testSuite struct { func (s *testSuite) SetupSuite() { s.DatabaseSuite.SetupSuite() - s.userRepo = New() + s.userRepo = NewUserRepository() - user.SetSalt([]byte("1111111"), 1) + password.SetSalt([]byte("1111111"), 1) } func (s *testSuite) TestGet() { @@ -64,15 +62,15 @@ func (s *testSuite) TestGetByEmail() { func (s *testSuite) TestFetchList() { s.Mock.ExpectQuery("SELECT *"). - WithArgs(1, 1, 2, 100). + WithArgs(1, 2, 100). WillReturnRows( sqlmock.NewRows([]string{"id", "status", "email", "password", "created_at"}). AddRow(1, 1, "email1", defaultPasswordHash, time.Now()). AddRow(2, 1, "email2", defaultPasswordHash, time.Now()), ) users, err := s.userRepo.FetchList(s.Ctx, - &user.ListFilter{AccountID: []uint64{1}, UserID: []uint64{1, 2}}, - &user.ListOrder{ID: model.OrderAsc}, + &user.ListFilter{UserID: []uint64{1, 2}}, + &user.ListOrder{ID: pkgModels.OrderAsc}, &repository.Pagination{Size: 100}) s.Assert().NoError(err) s.Assert().Equal(2, len(users)) @@ -80,13 +78,13 @@ func (s *testSuite) TestFetchList() { func (s *testSuite) TestCount() { s.Mock.ExpectQuery("SELECT count"). - WithArgs(1, 1, 2). + WithArgs(1, 2). WillReturnRows( sqlmock.NewRows([]string{"count"}). AddRow(2), ) count, err := s.userRepo.Count(s.Ctx, - &user.ListFilter{AccountID: []uint64{1}, UserID: []uint64{1, 2}}) + &user.ListFilter{UserID: []uint64{1, 2}}) s.Assert().NoError(err) s.Assert().Equal(int64(2), count) } @@ -104,44 +102,44 @@ func (s *testSuite) TestGetByPassword() { s.Assert().Equal(uint64(1), user.ID) } -func (s *testSuite) TestGetByToken() { - tocken := "jBQpj4CbcJRZjznk00mjpgxvLc2QwErx" - s.Mock.ExpectQuery(`WITH auth_client AS \(`). - WithArgs(tocken). - WillReturnRows( - sqlmock.NewRows([]string{"id", "status", "user_id", "account_id", "is_admin", "created_at", "updated_at"}). - AddRow(1, 1, 1, 1, 0, time.Now(), time.Now()), - ) - s.Mock.ExpectQuery(`SELECT \* FROM "`+(*model.User)(nil).TableName()+`"`). - WithArgs(uint64(1), 1). - WillReturnRows( - sqlmock.NewRows([]string{"id", "status", "email", "password", "created_at"}). - AddRow(1, 1, "email1", defaultPasswordHash, time.Now()), - ) - s.Mock.ExpectQuery(`SELECT \* FROM "`+(*model.Account)(nil).TableName()+`"`). - WithArgs(uint64(1), 1). - WillReturnRows( - sqlmock.NewRows([]string{"id", "status", "title", "description", "created_at"}). - AddRow(1, 1, "title1", "description1", time.Now()), - ) - s.Mock.ExpectQuery(`SELECT "role_id" FROM `). - WithArgs(uint64(1)). - WillReturnRows(sqlmock.NewRows([]string{"role_id"})) - - user, account, err := s.userRepo.GetByToken(s.Ctx, tocken) - - s.Assert().NoError(err) - s.Assert().Equal(uint64(1), user.ID) - s.Assert().Equal(uint64(1), account.ID) -} +// func (s *testSuite) TestGetByToken() { +// tocken := "jBQpj4CbcJRZjznk00mjpgxvLc2QwErx" +// s.Mock.ExpectQuery(`WITH auth_client AS \(`). +// WithArgs(tocken). +// WillReturnRows( +// sqlmock.NewRows([]string{"id", "status", "user_id", "account_id", "is_admin", "created_at", "updated_at"}). +// AddRow(1, 1, 1, 1, 0, time.Now(), time.Now()), +// ) +// s.Mock.ExpectQuery(`SELECT \* FROM "`+(*userModels.User)(nil).TableName()+`"`). +// WithArgs(uint64(1), 1). +// WillReturnRows( +// sqlmock.NewRows([]string{"id", "status", "email", "password", "created_at"}). +// AddRow(1, 1, "email1", defaultPasswordHash, time.Now()), +// ) +// s.Mock.ExpectQuery(`SELECT \* FROM "`+(*accountModels.Account)(nil).TableName()+`"`). +// WithArgs(uint64(1), 1). +// WillReturnRows( +// sqlmock.NewRows([]string{"id", "status", "title", "description", "created_at"}). +// AddRow(1, 1, "title1", "description1", time.Now()), +// ) +// s.Mock.ExpectQuery(`SELECT "role_id" FROM `). +// WithArgs(uint64(1)). +// WillReturnRows(sqlmock.NewRows([]string{"role_id"})) + +// user, account, err := s.userRepo.GetByToken(s.Ctx, tocken) + +// s.Assert().NoError(err) +// s.Assert().Equal(uint64(1), user.ID) +// s.Assert().Equal(uint64(1), account.ID) +// } func (s *testSuite) TestCreate() { s.Mock.ExpectQuery("INSERT INTO"). - WithArgs("test", sqlmock.AnyArg(), model.UndefinedApproveStatus, sqlmock.AnyArg(), sqlmock.AnyArg(), nil, uint(101)). + WithArgs("test", sqlmock.AnyArg(), false, pkgModels.UndefinedApproveStatus, sqlmock.AnyArg(), sqlmock.AnyArg(), nil, uint(101)). WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(101)) id, err := s.userRepo.Create( s.Ctx, - &model.User{ID: 101, Email: "test"}, + &userModels.User{ID: 101, Email: "test"}, "password") s.Assert().NoError(err) s.Assert().Equal(uint64(101), id) @@ -149,11 +147,11 @@ func (s *testSuite) TestCreate() { func (s *testSuite) TestUpdate() { s.Mock.ExpectExec("UPDATE"). - WithArgs("test", sqlmock.AnyArg(), model.UndefinedApproveStatus, sqlmock.AnyArg(), sqlmock.AnyArg(), nil, uint64(101)). + WithArgs("test", sqlmock.AnyArg(), false, pkgModels.UndefinedApproveStatus, sqlmock.AnyArg(), sqlmock.AnyArg(), nil, uint64(101)). WillReturnResult(sqlmock.NewResult(101, 1)) err := s.userRepo.Update( s.Ctx, - &model.User{ + &userModels.User{ ID: 101, Email: "test", }) diff --git a/repository/user/usecase/user_test.go b/repository/user/usecase/user_test.go index 02d5ff1b..84922655 100644 --- a/repository/user/usecase/user_test.go +++ b/repository/user/usecase/user_test.go @@ -6,21 +6,19 @@ import ( "errors" "testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "go.uber.org/mock/gomock" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/context/session" - "github.com/geniusrabbit/blaze-api/repository" "github.com/geniusrabbit/blaze-api/repository/user" "github.com/geniusrabbit/blaze-api/repository/user/mocks" + userModels "github.com/geniusrabbit/blaze-api/repository/user/models" ) type userTestSuite struct { suite.Suite - ctx context.Context - + ctx context.Context userRepo *mocks.MockRepository userUsecase user.Usecase } @@ -34,7 +32,7 @@ func (s *userTestSuite) SetupSuite() { func (s *userTestSuite) TestGet() { s.userRepo.EXPECT().Get(s.ctx, uint64(2)). - Return(&model.User{ID: 2}, nil) + Return(&userModels.User{ID: 2}, nil) user, err := s.userUsecase.Get(s.ctx, 2) s.Assert().NoError(err) @@ -44,7 +42,7 @@ func (s *userTestSuite) TestGet() { func (s *userTestSuite) TestGetByEmail() { const email = "test@mail.com" s.userRepo.EXPECT().GetByEmail(s.ctx, email). - Return(&model.User{ID: 2, Email: email}, nil) + Return(&userModels.User{ID: 2, Email: email}, nil) user, err := s.userUsecase.GetByEmail(s.ctx, email) s.Assert().NoError(err) @@ -54,7 +52,7 @@ func (s *userTestSuite) TestGetByEmail() { func (s *userTestSuite) TestGetCurrent() { // s.userRepo.EXPECT().Get(s.ctx, uint64(1)). - // Return(&model.User{ID: 1}, nil) + // Return(&userModels.User{ID: 1}, nil) user, err := s.userUsecase.Get(s.ctx, 1) s.Assert().NoError(err) @@ -72,73 +70,69 @@ func (s *userTestSuite) TestGetGetError() { func (s *userTestSuite) TestGetByPassword() { s.userRepo.EXPECT().GetByPassword(s.ctx, "test@mail.com", "password"). - Return(&model.User{ID: 1}, nil) + Return(&userModels.User{ID: 1}, nil) user, err := s.userUsecase.GetByPassword(s.ctx, "test@mail.com", "password") s.Assert().NoError(err) s.Assert().Equal(uint64(1), user.ID) } -func (s *userTestSuite) TestGetByToken() { - s.userRepo.EXPECT().GetByToken(s.ctx, "token"). - Return(&model.User{ID: 1}, &model.Account{ID: 1}, nil) +// func (s *userTestSuite) TestGetByToken() { +// s.userRepo.EXPECT().GetByToken(s.ctx, "token"). +// Return(&userModels.User{ID: 1}, &model.Account{ID: 1}, nil) - user, account, err := s.userUsecase.GetByToken(s.ctx, "token") - s.Assert().NoError(err) - s.Assert().Equal(uint64(1), user.ID) - s.Assert().Equal(uint64(1), account.ID) -} +// user, account, err := s.userUsecase.GetByToken(s.ctx, "token") +// s.Assert().NoError(err) +// s.Assert().Equal(uint64(1), user.ID) +// s.Assert().Equal(uint64(1), account.ID) +// } func (s *userTestSuite) TestFetchList() { s.userRepo.EXPECT(). - FetchList(s.ctx, &user.ListFilter{AccountID: []uint64{1}}, - gomock.AssignableToTypeOf(&user.ListOrder{}), - gomock.AssignableToTypeOf(&repository.Pagination{})). - Return([]*model.User{{ID: 1}, {ID: 2}}, nil) + FetchList(s.ctx, &user.ListFilter{}, nil, nil). + Return([]*userModels.User{{ID: 1}, {ID: 2}}, nil) - users, err := s.userUsecase.FetchList(s.ctx, &user.ListFilter{AccountID: []uint64{1}}, nil, nil) + users, err := s.userUsecase.FetchList(s.ctx, &user.ListFilter{}, nil, nil) s.Assert().NoError(err) s.Assert().Equal(2, len(users)) } func (s *userTestSuite) TestCount() { s.userRepo.EXPECT(). - Count(s.ctx, &user.ListFilter{AccountID: []uint64{1}}). + Count(s.ctx, &user.ListFilter{}). Return(int64(2), nil) - count, err := s.userUsecase.Count(s.ctx, &user.ListFilter{AccountID: []uint64{1}}) + count, err := s.userUsecase.Count(s.ctx, &user.ListFilter{}) s.Assert().NoError(err) s.Assert().Equal(int64(2), count) } func (s *userTestSuite) TestFetchList_CurrentUser() { s.userRepo.EXPECT(). - FetchList(s.ctx, &user.ListFilter{AccountID: []uint64{1}}, - gomock.AssignableToTypeOf(&user.ListOrder{}), - gomock.AssignableToTypeOf(&repository.Pagination{})). - Return([]*model.User{{ID: 1}, {ID: 2}}, nil) + FetchList(s.ctx, &user.ListFilter{}, nil, nil). + Return([]*userModels.User{{ID: 1}, {ID: 2}}, nil) - users, err := s.userUsecase.FetchList(s.ctx, &user.ListFilter{AccountID: []uint64{1}}, nil, nil) + users, err := s.userUsecase.FetchList(s.ctx, &user.ListFilter{}, nil, nil) s.Assert().NoError(err) s.Assert().Equal(2, len(users)) } func (s *userTestSuite) TestCreate() { s.userRepo.EXPECT(). - Create(s.ctx, gomock.AssignableToTypeOf(&model.User{}), "password"). + Create(s.ctx, gomock.AssignableToTypeOf(&userModels.User{}), "password"). Return(uint64(101), nil) - id, err := s.userUsecase.Store(s.ctx, &model.User{Email: "test@mail.com"}, "password") + id, err := s.userUsecase.Create(s.ctx, &userModels.User{Email: "test@mail.com"}, "password") s.Assert().NoError(err) s.Assert().Equal(id, uint64(101)) } func (s *userTestSuite) TestUpdate() { s.userRepo.EXPECT(). - Update(gomock.AssignableToTypeOf(s.ctx), gomock.AssignableToTypeOf(&model.User{})). + Update(gomock.AssignableToTypeOf(s.ctx), gomock.AssignableToTypeOf(&userModels.User{})). Return(nil) - err := s.userUsecase.Update(s.ctx, &model.User{ID: 101, Email: "test@mail.com"}) + err := s.userUsecase.Update(s.ctx, &userModels.User{ID: 101, Email: "test@mail.com"}) s.Assert().NoError(err) } diff --git a/repository/user/usecase/user_usecase.go b/repository/user/usecase/user_usecase.go index c6ebb93c..779b5cb3 100644 --- a/repository/user/usecase/user_usecase.go +++ b/repository/user/usecase/user_usecase.go @@ -10,7 +10,6 @@ import ( "go.uber.org/zap" "gorm.io/gorm" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/acl" "github.com/geniusrabbit/blaze-api/pkg/context/ctxlogger" "github.com/geniusrabbit/blaze-api/pkg/context/session" @@ -32,7 +31,7 @@ func NewUserUsecase(repo user.Repository) *UserUsecase { } // Get returns the group by ID if have access -func (a *UserUsecase) Get(ctx context.Context, id uint64) (*model.User, error) { +func (a *UserUsecase) Get(ctx context.Context, id uint64) (*user.User, error) { currentUser, _ := session.UserAccount(ctx) if currentUser.ID == id { if !acl.HaveAccessView(ctx, currentUser) { @@ -51,7 +50,7 @@ func (a *UserUsecase) Get(ctx context.Context, id uint64) (*model.User, error) { } // GetByEmail returns the group by Email if have access -func (a *UserUsecase) GetByEmail(ctx context.Context, email string) (*model.User, error) { +func (a *UserUsecase) GetByEmail(ctx context.Context, email string) (*user.User, error) { currentUser, _ := session.UserAccount(ctx) if currentUser.Email == email { if !acl.HaveAccessView(ctx, currentUser) { @@ -70,45 +69,38 @@ func (a *UserUsecase) GetByEmail(ctx context.Context, email string) (*model.User } // GetByPassword returns user by email + password -func (a *UserUsecase) GetByPassword(ctx context.Context, email, password string) (*model.User, error) { +func (a *UserUsecase) GetByPassword(ctx context.Context, email, password string) (*user.User, error) { return a.userRepo.GetByPassword(ctx, email, password) } -// GetByToken returns user + account by session token -func (a *UserUsecase) GetByToken(ctx context.Context, token string) (*model.User, *model.Account, error) { - return a.userRepo.GetByToken(ctx, token) -} - // FetchList of users by filter -func (a *UserUsecase) FetchList(ctx context.Context, filter *user.ListFilter, order *user.ListOrder, page *repository.Pagination) ([]*model.User, error) { - if !acl.HaveAccessList(ctx, &model.User{}) { +func (a *UserUsecase) FetchList(ctx context.Context, opts ...user.QOption) ([]*user.User, error) { + if !acl.HaveAccessList(ctx, &user.User{}) { if !acl.HaveAccessList(ctx, session.User(ctx)) { return nil, acl.ErrNoPermissions } - if filter == nil { - filter = &user.ListFilter{} + if err := adjustFetchListPermissions(ctx, opts...); err != nil { + return nil, err } - filter.AccountID = []uint64{session.Account(ctx).ID} } - return a.userRepo.FetchList(ctx, filter, order, page) + return a.userRepo.FetchList(ctx, opts...) } // Count of users by filter -func (a *UserUsecase) Count(ctx context.Context, filter *user.ListFilter) (int64, error) { - if !acl.HaveAccessCount(ctx, &model.User{}) { +func (a *UserUsecase) Count(ctx context.Context, opts ...user.QOption) (int64, error) { + if !acl.HaveAccessCount(ctx, &user.User{}) { if !acl.HaveAccessCount(ctx, session.User(ctx)) { return 0, acl.ErrNoPermissions } - if filter == nil { - filter = &user.ListFilter{} + if err := adjustFetchListPermissions(ctx, opts...); err != nil { + return 0, err } - filter.AccountID = []uint64{session.Account(ctx).ID} } - return a.userRepo.Count(ctx, filter) + return a.userRepo.Count(ctx, opts...) } // SetPassword for the exists user -func (a *UserUsecase) SetPassword(ctx context.Context, userObj *model.User, password string) error { +func (a *UserUsecase) SetPassword(ctx context.Context, userObj *user.User, password string) error { if !acl.HaveObjectPermissions(ctx, userObj, `password.set.*`) { return errors.Wrap(acl.ErrNoPermissions, `set password`) } @@ -116,7 +108,7 @@ func (a *UserUsecase) SetPassword(ctx context.Context, userObj *model.User, pass } // ResetPassword for the exists user -func (a *UserUsecase) ResetPassword(ctx context.Context, email string) (*model.UserPasswordReset, *model.User, error) { +func (a *UserUsecase) ResetPassword(ctx context.Context, email string) (*user.UserPasswordReset, *user.User, error) { user, err := a.userRepo.GetByEmail(ctx, email) if err != nil { if err == sql.ErrNoRows || err == gorm.ErrRecordNotFound { @@ -168,25 +160,16 @@ func (a *UserUsecase) UpdatePassword(ctx context.Context, token, email, password return nil } -// Store new object into database -func (a *UserUsecase) Store(ctx context.Context, userObj *model.User, password string) (uint64, error) { - var err error - if userObj.ID == 0 && !acl.HaveAccessCreate(ctx, userObj) { - return 0, acl.ErrNoPermissions - } - if userObj.ID != 0 && !acl.HaveAccessUpdate(ctx, userObj) { +// Create new object into database +func (a *UserUsecase) Create(ctx context.Context, userObj *user.User, password string) (uint64, error) { + if !acl.HaveAccessCreate(ctx, userObj) { return 0, acl.ErrNoPermissions } - if userObj.ID == 0 { - userObj.ID, err = a.userRepo.Create(ctx, userObj, password) - } else { - err = a.userRepo.Update(ctx, userObj) - } - return userObj.ID, err + return a.userRepo.Create(ctx, userObj, password) } // Update existing object in database -func (a *UserUsecase) Update(ctx context.Context, userObj *model.User) error { +func (a *UserUsecase) Update(ctx context.Context, userObj *user.User) error { if !acl.HaveAccessUpdate(ctx, userObj) { return acl.ErrNoPermissions } @@ -205,10 +188,26 @@ func (a *UserUsecase) Delete(ctx context.Context, id uint64) error { return a.userRepo.Delete(historylog.WithPK(ctx, id), id) } -func (a *UserUsecase) getUserByID(ctx context.Context, id uint64) (*model.User, error) { +func (a *UserUsecase) getUserByID(ctx context.Context, id uint64) (*user.User, error) { currentUser := session.User(ctx) if currentUser.ID == id { return currentUser, nil } return nil, sql.ErrNoRows } + +func adjustFetchListPermissions(ctx context.Context, opts ...user.QOption) error { + adjusted := false + for _, opt := range opts { + if adjuster, ok := opt.(repository.QueryPermissionAdjuster); ok { + if err := adjuster.AdjustPermissions(ctx); err != nil { + return err + } + adjusted = true + } + } + if !adjusted { + return acl.ErrNoPermissions + } + return nil +} diff --git a/repository/user/usercase.go b/repository/user/usercase.go index 71a0a80b..c6366500 100644 --- a/repository/user/usercase.go +++ b/repository/user/usercase.go @@ -2,26 +2,23 @@ package user import ( "context" - - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository" ) // Usecase describes basic user methods // //go:generate mockgen -source $GOFILE -package mocks -destination mocks/usecase.go type Usecase interface { - Get(ctx context.Context, id uint64) (*model.User, error) - GetByEmail(ctx context.Context, email string) (*model.User, error) - GetByPassword(ctx context.Context, email, password string) (*model.User, error) - GetByToken(ctx context.Context, token string) (*model.User, *model.Account, error) - FetchList(ctx context.Context, filter *ListFilter, order *ListOrder, page *repository.Pagination) ([]*model.User, error) - Count(ctx context.Context, filter *ListFilter) (int64, error) - Store(ctx context.Context, user *model.User, password string) (uint64, error) - Update(ctx context.Context, user *model.User) error + Get(ctx context.Context, id uint64) (*User, error) + GetByEmail(ctx context.Context, email string) (*User, error) + GetByPassword(ctx context.Context, email, password string) (*User, error) + FetchList(ctx context.Context, opts ...QOption) ([]*User, error) + Count(ctx context.Context, opts ...QOption) (int64, error) + + Create(ctx context.Context, user *User, password string) (uint64, error) + Update(ctx context.Context, user *User) error Delete(ctx context.Context, id uint64) error - SetPassword(ctx context.Context, user *model.User, password string) error - ResetPassword(ctx context.Context, email string) (*model.UserPasswordReset, *model.User, error) + SetPassword(ctx context.Context, user *User, password string) error + ResetPassword(ctx context.Context, email string) (*UserPasswordReset, *User, error) UpdatePassword(ctx context.Context, token, email, password string) error } diff --git a/server/graphql/connectors/account.go b/server/graphql/connectors/account.go index 9de1954f..e705fb91 100644 --- a/server/graphql/connectors/account.go +++ b/server/graphql/connectors/account.go @@ -1,31 +1,9 @@ package connectors import ( - "context" - - "github.com/demdxx/gocast/v2" - "github.com/geniusrabbit/blaze-api/repository/account" gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) // AccountConnection implements collection accessor interface with pagination type AccountConnection = CollectionConnection[gqlmodels.Account, gqlmodels.AccountEdge] -// NewAccountConnection based on query object -func NewAccountConnection(ctx context.Context, accountsAccessor account.Usecase, filter *gqlmodels.AccountListFilter, order *gqlmodels.AccountListOrder, page *gqlmodels.Page) *AccountConnection { - return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.Account, gqlmodels.AccountEdge]{ - FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.Account, error) { - accounts, err := accountsAccessor.FetchList(ctx, filter.Filter(), order.Order(), page.Pagination()) - return gqlmodels.FromAccountModelList(accounts), err - }, - CountDataFunc: func(ctx context.Context) (int64, error) { - return accountsAccessor.Count(ctx, filter.Filter()) - }, - ConvertToEdgeFunc: func(obj *gqlmodels.Account) *gqlmodels.AccountEdge { - return &gqlmodels.AccountEdge{ - Cursor: gocast.Str(obj.ID), - Node: obj, - } - }, - }, page) -} diff --git a/server/graphql/connectors/auth_client.go b/server/graphql/connectors/auth_client.go index 9cd5e396..c2c9e6c8 100644 --- a/server/graphql/connectors/auth_client.go +++ b/server/graphql/connectors/auth_client.go @@ -1,31 +1,31 @@ package connectors -import ( - "context" +// import ( +// "context" - "github.com/demdxx/gocast/v2" - "github.com/geniusrabbit/blaze-api/repository/authclient" - gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" -) +// "github.com/demdxx/gocast/v2" +// "github.com/geniusrabbit/blaze-api/repository/authclient" +// gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" +// ) -// AuthClientConnection implements collection accessor interface with pagination -type AuthClientConnection = CollectionConnection[gqlmodels.AuthClient, gqlmodels.AuthClientEdge] +// // AuthClientConnection implements collection accessor interface with pagination +// type AuthClientConnection = CollectionConnection[gqlmodels.AuthClient, gqlmodels.AuthClientEdge] -// NewAuthClientConnection based on query object -func NewAuthClientConnection(ctx context.Context, authClientsAccessor authclient.Usecase, page *gqlmodels.Page) *AuthClientConnection { - return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.AuthClient, gqlmodels.AuthClientEdge]{ - FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.AuthClient, error) { - clients, err := authClientsAccessor.FetchList(ctx, nil) - return gqlmodels.FromAuthClientModelList(clients), err - }, - CountDataFunc: func(ctx context.Context) (int64, error) { - return authClientsAccessor.Count(ctx, nil) - }, - ConvertToEdgeFunc: func(obj *gqlmodels.AuthClient) *gqlmodels.AuthClientEdge { - return &gqlmodels.AuthClientEdge{ - Cursor: gocast.Str(obj.ID), - Node: obj, - } - }, - }, page) -} +// // NewAuthClientConnection based on query object +// func NewAuthClientConnection(ctx context.Context, authClientsAccessor authclient.Usecase, page *gqlmodels.Page) *AuthClientConnection { +// return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.AuthClient, gqlmodels.AuthClientEdge]{ +// FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.AuthClient, error) { +// clients, err := authClientsAccessor.FetchList(ctx, nil) +// return gqlmodels.FromAuthClientModelList(clients), err +// }, +// CountDataFunc: func(ctx context.Context) (int64, error) { +// return authClientsAccessor.Count(ctx, nil) +// }, +// ConvertToEdgeFunc: func(obj *gqlmodels.AuthClient) *gqlmodels.AuthClientEdge { +// return &gqlmodels.AuthClientEdge{ +// Cursor: gocast.Str(obj.ID), +// Node: obj, +// } +// }, +// }, page) +// } diff --git a/server/graphql/connectors/direct_access_token.go b/server/graphql/connectors/direct_access_token.go index 1562fae4..be232fba 100644 --- a/server/graphql/connectors/direct_access_token.go +++ b/server/graphql/connectors/direct_access_token.go @@ -1,37 +1,37 @@ package connectors -import ( - "context" +// import ( +// "context" - "github.com/demdxx/gocast/v2" - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository/directaccesstoken" - gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" -) +// "github.com/demdxx/gocast/v2" +// "github.com/geniusrabbit/blaze-api/model" +// "github.com/geniusrabbit/blaze-api/repository/directaccesstoken" +// gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" +// ) -// DirectAccessTokenConnection implements collection accessor interface with pagination -type DirectAccessTokenConnection = CollectionConnection[gqlmodels.DirectAccessToken, gqlmodels.DirectAccessTokenEdge] +// // DirectAccessTokenConnection implements collection accessor interface with pagination +// type DirectAccessTokenConnection = CollectionConnection[gqlmodels.DirectAccessToken, gqlmodels.DirectAccessTokenEdge] -// NewDirectAccessTokenConnection based on query object -func NewDirectAccessTokenConnection(ctx context.Context, directAccessTokenAccessor directaccesstoken.Usecase, filter *gqlmodels.DirectAccessTokenListFilter, order *gqlmodels.DirectAccessTokenListOrder, page *gqlmodels.Page, fnPrep func(*model.DirectAccessToken) *model.DirectAccessToken) *DirectAccessTokenConnection { - return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.DirectAccessToken, gqlmodels.DirectAccessTokenEdge]{ - FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.DirectAccessToken, error) { - directAccessTokens, err := directAccessTokenAccessor.FetchList(ctx, filter.Filter(), order.Order(), page.Pagination()) - if fnPrep != nil { - for i, token := range directAccessTokens { - directAccessTokens[i] = fnPrep(token) - } - } - return gqlmodels.FromDirectAccessTokenModelList(directAccessTokens), err - }, - CountDataFunc: func(ctx context.Context) (int64, error) { - return directAccessTokenAccessor.Count(ctx, filter.Filter()) - }, - ConvertToEdgeFunc: func(obj *gqlmodels.DirectAccessToken) *gqlmodels.DirectAccessTokenEdge { - return &gqlmodels.DirectAccessTokenEdge{ - Cursor: gocast.Str(obj.ID), - Node: obj, - } - }, - }, page) -} +// // NewDirectAccessTokenConnection based on query object +// func NewDirectAccessTokenConnection(ctx context.Context, directAccessTokenAccessor directaccesstoken.Usecase, filter *gqlmodels.DirectAccessTokenListFilter, order *gqlmodels.DirectAccessTokenListOrder, page *gqlmodels.Page, fnPrep func(*model.DirectAccessToken) *model.DirectAccessToken) *DirectAccessTokenConnection { +// return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.DirectAccessToken, gqlmodels.DirectAccessTokenEdge]{ +// FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.DirectAccessToken, error) { +// directAccessTokens, err := directAccessTokenAccessor.FetchList(ctx, filter.Filter(), order.Order(), page.Pagination()) +// if fnPrep != nil { +// for i, token := range directAccessTokens { +// directAccessTokens[i] = fnPrep(token) +// } +// } +// return gqlmodels.FromDirectAccessTokenModelList(directAccessTokens), err +// }, +// CountDataFunc: func(ctx context.Context) (int64, error) { +// return directAccessTokenAccessor.Count(ctx, filter.Filter()) +// }, +// ConvertToEdgeFunc: func(obj *gqlmodels.DirectAccessToken) *gqlmodels.DirectAccessTokenEdge { +// return &gqlmodels.DirectAccessTokenEdge{ +// Cursor: gocast.Str(obj.ID), +// Node: obj, +// } +// }, +// }, page) +// } diff --git a/server/graphql/connectors/history_action.go b/server/graphql/connectors/history_action.go index d43823b9..974362c1 100644 --- a/server/graphql/connectors/history_action.go +++ b/server/graphql/connectors/history_action.go @@ -1,31 +1,9 @@ package connectors import ( - "context" - - "github.com/demdxx/gocast/v2" - "github.com/geniusrabbit/blaze-api/repository/historylog" gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) // HistoryActionConnection implements collection accessor interface with pagination type HistoryActionConnection = CollectionConnection[gqlmodels.HistoryAction, gqlmodels.HistoryActionEdge] -// NewHistoryActionConnection based on query object -func NewHistoryActionConnection(ctx context.Context, historyActionsAccessor historylog.Usecase, filter *gqlmodels.HistoryActionListFilter, order *gqlmodels.HistoryActionListOrder, page *gqlmodels.Page) *HistoryActionConnection { - return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.HistoryAction, gqlmodels.HistoryActionEdge]{ - FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.HistoryAction, error) { - historyActions, err := historyActionsAccessor.FetchList(ctx, filter.Filter(), order.Order(), page.Pagination()) - return gqlmodels.FromHistoryActionModelList(historyActions), err - }, - CountDataFunc: func(ctx context.Context) (int64, error) { - return historyActionsAccessor.Count(ctx, filter.Filter()) - }, - ConvertToEdgeFunc: func(obj *gqlmodels.HistoryAction) *gqlmodels.HistoryActionEdge { - return &gqlmodels.HistoryActionEdge{ - Cursor: gocast.Str(obj.ID), - Node: obj, - } - }, - }, page) -} diff --git a/server/graphql/connectors/member.go b/server/graphql/connectors/member.go index 19836459..87320b9a 100644 --- a/server/graphql/connectors/member.go +++ b/server/graphql/connectors/member.go @@ -1,32 +1,8 @@ package connectors import ( - "context" - - "github.com/demdxx/gocast/v2" - "github.com/geniusrabbit/blaze-api/repository/account" gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) // MemberConnection implements collection accessor interface with pagination type MemberConnection = CollectionConnection[gqlmodels.Member, gqlmodels.MemberEdge] - -// NewMemberConnection based on query object -func NewMemberConnection(ctx context.Context, accountsAccessor account.Usecase, filter *gqlmodels.MemberListFilter, order *gqlmodels.MemberListOrder, page *gqlmodels.Page) *MemberConnection { - return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.Member, gqlmodels.MemberEdge]{ - FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.Member, error) { - members, err := accountsAccessor.FetchListMembers(ctx, - filter.Filter(), order.Order(), page.Pagination()) - return gqlmodels.FromMemberModelList(ctx, members), err - }, - CountDataFunc: func(ctx context.Context) (int64, error) { - return accountsAccessor.CountMembers(ctx, filter.Filter()) - }, - ConvertToEdgeFunc: func(obj *gqlmodels.Member) *gqlmodels.MemberEdge { - return &gqlmodels.MemberEdge{ - Cursor: gocast.Str(obj.ID), - Node: obj, - } - }, - }, page) -} diff --git a/server/graphql/connectors/option.go b/server/graphql/connectors/option.go index 9e2ce2d7..fdc9a9c6 100644 --- a/server/graphql/connectors/option.go +++ b/server/graphql/connectors/option.go @@ -1,32 +1,9 @@ package connectors import ( - "context" - - "github.com/demdxx/gocast/v2" - - "github.com/geniusrabbit/blaze-api/repository/option" gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) // OptionConnection implements collection accessor interface with pagination type OptionConnection = CollectionConnection[gqlmodels.Option, gqlmodels.OptionEdge] -// NewOptionConnection based on query object -func NewOptionConnection(ctx context.Context, optionsAccessor option.Usecase, filter *gqlmodels.OptionListFilter, order *gqlmodels.OptionListOrder, page *gqlmodels.Page) *OptionConnection { - return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.Option, gqlmodels.OptionEdge]{ - FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.Option, error) { - options, err := optionsAccessor.FetchList(ctx, filter.Filter(), order.Order(), page.Pagination()) - return gqlmodels.FromOptionModelList(options), err - }, - CountDataFunc: func(ctx context.Context) (int64, error) { - return optionsAccessor.Count(ctx, filter.Filter()) - }, - ConvertToEdgeFunc: func(obj *gqlmodels.Option) *gqlmodels.OptionEdge { - return &gqlmodels.OptionEdge{ - Cursor: gocast.Str(obj.Name), - Node: obj, - } - }, - }, page) -} diff --git a/server/graphql/connectors/rbac_role.go b/server/graphql/connectors/rbac_role.go index 7b20e1c8..f62e8186 100644 --- a/server/graphql/connectors/rbac_role.go +++ b/server/graphql/connectors/rbac_role.go @@ -1,57 +1,52 @@ package connectors import ( - "context" - - "github.com/demdxx/gocast/v2" - "github.com/geniusrabbit/blaze-api/model" - "github.com/geniusrabbit/blaze-api/repository/rbac" gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) // RBACRoleConnection implements collection accessor interface with pagination type RBACRoleConnection = CollectionConnection[gqlmodels.RBACRole, gqlmodels.RBACRoleEdge] -// NewRBACRoleConnection based on query object -func NewRBACRoleConnection(ctx context.Context, rolesAccessor rbac.Usecase, filter *gqlmodels.RBACRoleListFilter, order *gqlmodels.RBACRoleListOrder, page *gqlmodels.Page) *RBACRoleConnection { - return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.RBACRole, gqlmodels.RBACRoleEdge]{ - FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.RBACRole, error) { - roles, err := rolesAccessor.FetchList(ctx, filter.Filter(), order.Order(), page.Pagination()) - return gqlmodels.FromRBACRoleModelList(ctx, roles), err - }, - CountDataFunc: func(ctx context.Context) (int64, error) { - return rolesAccessor.Count(ctx, filter.Filter()) - }, - ConvertToEdgeFunc: func(obj *gqlmodels.RBACRole) *gqlmodels.RBACRoleEdge { - return &gqlmodels.RBACRoleEdge{ - Cursor: gocast.Str(obj.ID), - Node: obj, - } - }, - }, page) -} +// // NewRBACRoleConnection based on query object +// func NewRBACRoleConnection(ctx context.Context, rolesAccessor rbac.Usecase, filter *gqlmodels.RBACRoleListFilter, order *gqlmodels.RBACRoleListOrder, page *gqlmodels.Page) *RBACRoleConnection { +// return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.RBACRole, gqlmodels.RBACRoleEdge]{ +// FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.RBACRole, error) { +// roles, err := rolesAccessor.FetchList(ctx, filter.Filter(), order.Order(), page.Pagination()) +// return gqlmodels.FromRBACRoleModelList(ctx, roles), err +// }, +// CountDataFunc: func(ctx context.Context) (int64, error) { +// return rolesAccessor.Count(ctx, filter.Filter()) +// }, +// ConvertToEdgeFunc: func(obj *gqlmodels.RBACRole) *gqlmodels.RBACRoleEdge { +// return &gqlmodels.RBACRoleEdge{ +// Cursor: gocast.Str(obj.ID), +// Node: obj, +// } +// }, +// }, page) +// } -// NewRBACRoleConnectionByIDs based on query object -func NewRBACRoleConnectionByIDs(ctx context.Context, rolesPepo rbac.Repository, ids []uint64, order *gqlmodels.RBACRoleListOrder) *RBACRoleConnection { - return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.RBACRole, gqlmodels.RBACRoleEdge]{ - FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.RBACRole, error) { - var ( - roles []*model.Role - err error - ) - if len(ids) > 0 { - roles, err = rolesPepo.FetchList(ctx, &rbac.Filter{ID: ids}, order.Order(), nil) - } - return gqlmodels.FromRBACRoleModelList(ctx, roles), err - }, - CountDataFunc: func(ctx context.Context) (int64, error) { - return int64(len(ids)), nil - }, - ConvertToEdgeFunc: func(obj *gqlmodels.RBACRole) *gqlmodels.RBACRoleEdge { - return &gqlmodels.RBACRoleEdge{ - Cursor: gocast.Str(obj.ID), - Node: obj, - } - }, - }, nil) -} +// // NewRBACRoleConnectionByIDs based on query object +// func NewRBACRoleConnectionByIDs(ctx context.Context, rolesPepo rbac.Repository, ids []uint64, order *gqlmodels.RBACRoleListOrder) *RBACRoleConnection { +// return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.RBACRole, gqlmodels.RBACRoleEdge]{ +// FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.RBACRole, error) { +// var ( +// roles []*model.Role +// err error +// ) +// if len(ids) > 0 { +// roles, err = rolesPepo.FetchList(ctx, &rbac.Filter{ID: ids}, order.Order(), nil) +// } +// return gqlmodels.FromRBACRoleModelList(ctx, roles), err +// }, +// CountDataFunc: func(ctx context.Context) (int64, error) { +// return int64(len(ids)), nil +// }, +// ConvertToEdgeFunc: func(obj *gqlmodels.RBACRole) *gqlmodels.RBACRoleEdge { +// return &gqlmodels.RBACRoleEdge{ +// Cursor: gocast.Str(obj.ID), +// Node: obj, +// } +// }, +// }, nil) +// } diff --git a/server/graphql/connectors/socialaccount.go b/server/graphql/connectors/socialaccount.go index ee7d350e..ce51e27b 100644 --- a/server/graphql/connectors/socialaccount.go +++ b/server/graphql/connectors/socialaccount.go @@ -1,31 +1,9 @@ package connectors import ( - "context" - - "github.com/demdxx/gocast/v2" - "github.com/geniusrabbit/blaze-api/repository/socialaccount" gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) // SocialAccountConnection implements collection accessor interface with pagination type SocialAccountConnection = CollectionConnection[gqlmodels.SocialAccount, gqlmodels.SocialAccountEdge] -// NewSocialAccountConnection based on query object -func NewSocialAccountConnection(ctx context.Context, accountsAccessor socialaccount.Usecase, filter *gqlmodels.SocialAccountListFilter, order *gqlmodels.SocialAccountListOrder, page *gqlmodels.Page) *SocialAccountConnection { - return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.SocialAccount, gqlmodels.SocialAccountEdge]{ - FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.SocialAccount, error) { - accounts, err := accountsAccessor.FetchList(ctx, filter.Filter(), order.Order(), page.Pagination()) - return gqlmodels.FromSocialAccountModelList(accounts), err - }, - CountDataFunc: func(ctx context.Context) (int64, error) { - return accountsAccessor.Count(ctx, filter.Filter()) - }, - ConvertToEdgeFunc: func(obj *gqlmodels.SocialAccount) *gqlmodels.SocialAccountEdge { - return &gqlmodels.SocialAccountEdge{ - Cursor: gocast.Str(obj.ID), - Node: obj, - } - }, - }, page) -} diff --git a/server/graphql/connectors/user.go b/server/graphql/connectors/user.go index f4cca578..ec1772a7 100644 --- a/server/graphql/connectors/user.go +++ b/server/graphql/connectors/user.go @@ -1,31 +1,9 @@ package connectors import ( - "context" - - "github.com/demdxx/gocast/v2" - "github.com/geniusrabbit/blaze-api/repository/user" gqlmodels "github.com/geniusrabbit/blaze-api/server/graphql/models" ) // UserConnection implements collection accessor interface with pagination type UserConnection = CollectionConnection[gqlmodels.User, gqlmodels.UserEdge] -// NewUserConnection based on query object -func NewUserConnection(ctx context.Context, usersAccessor user.Usecase, filter *gqlmodels.UserListFilter, order *gqlmodels.UserListOrder, page *gqlmodels.Page) *UserConnection { - return NewCollectionConnection(ctx, &DataAccessorFunc[gqlmodels.User, gqlmodels.UserEdge]{ - FetchDataListFunc: func(ctx context.Context) ([]*gqlmodels.User, error) { - users, err := usersAccessor.FetchList(ctx, filter.Filter(), order.Order(), page.Pagination()) - return gqlmodels.FromUserModelList(users), err - }, - CountDataFunc: func(ctx context.Context) (int64, error) { - return usersAccessor.Count(ctx, filter.Filter()) - }, - ConvertToEdgeFunc: func(obj *gqlmodels.User) *gqlmodels.UserEdge { - return &gqlmodels.UserEdge{ - Cursor: gocast.Str(obj.ID), - Node: obj, - } - }, - }, page) -} diff --git a/server/graphql/directives/cache.go b/server/graphql/directives/cache.go index ee14df13..5d9040cd 100644 --- a/server/graphql/directives/cache.go +++ b/server/graphql/directives/cache.go @@ -98,7 +98,7 @@ func getCacheKey(opCtx *graphql.OperationContext, fc *graphql.FieldContext, obj opName = "op" } - objName := "unknown" + var objName string if fc != nil { // fc.Object is like "Query", "Video", etc. objName = fc.Object + "." + fc.Field.Name @@ -129,10 +129,10 @@ func getCacheKey(opCtx *graphql.OperationContext, fc *graphql.FieldContext, obj if objMap == nil { objMap = gocast.Map[string, any](obj, `json`) } - if v, _ = objMap[newField]; v == nil { + if v = objMap[newField]; v == nil { newField2 := strings.ToLower(newField) if newField2 != newField { - v, _ = objMap[newField2] + v = objMap[newField2] } } } diff --git a/server/graphql/directives/has_permissions.go b/server/graphql/directives/has_permissions.go index 436cb8c6..a2b83f15 100644 --- a/server/graphql/directives/has_permissions.go +++ b/server/graphql/directives/has_permissions.go @@ -9,9 +9,10 @@ import ( "github.com/demdxx/gocast/v2" "github.com/pkg/errors" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/pkg/context/session" "github.com/geniusrabbit/blaze-api/pkg/permissions" + "github.com/geniusrabbit/blaze-api/repository/account" + "github.com/geniusrabbit/blaze-api/repository/user" ) var ( @@ -60,14 +61,14 @@ func HasPermissions(ctx context.Context, obj any, next graphql.Resolver, perms [ // here we need to check that object belongs to the user or have manager access // as it's the basic level of access to any object -func ownedObject(ctx context.Context, obj any, user *model.User, acc *model.Account) any { +func ownedObject(ctx context.Context, obj any, usr *user.User, acc *account.Account) any { switch obj.(type) { case nil: return nil - case *model.Account, model.Account: - return &model.Account{ID: acc.ID, Admins: []uint64{user.ID}} - case *model.User, model.User: - return &model.User{ID: user.ID} + case *account.Account, account.Account: + return &account.Account{ID: acc.ID, Admins: []uint64{usr.ID}} + case *user.User, user.User: + return &user.User{ID: usr.ID} } // Get object struct type value @@ -92,11 +93,11 @@ func ownedObject(ctx context.Context, obj any, user *model.User, acc *model.Acco // Set user owner ID if setter, ok := newObj.(userOwnerSetter); ok { - setter.SetUserOwnerID(user.ID) + setter.SetUserOwnerID(usr.ID) } else { - _ = gocast.SetStructFieldValue(ctx, newObj, `UserID`, user.ID) - _ = gocast.SetStructFieldValue(ctx, newObj, `OwnerID`, user.ID) - _ = gocast.SetStructFieldValue(ctx, newObj, `OwnerUserID`, user.ID) + _ = gocast.SetStructFieldValue(ctx, newObj, `UserID`, usr.ID) + _ = gocast.SetStructFieldValue(ctx, newObj, `OwnerID`, usr.ID) + _ = gocast.SetStructFieldValue(ctx, newObj, `OwnerUserID`, usr.ID) } return newObj } diff --git a/server/graphql/generated/exec.go b/server/graphql/generated/exec.go index 80898e30..a0f8a29d 100644 --- a/server/graphql/generated/exec.go +++ b/server/graphql/generated/exec.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "strconv" - "sync" "sync/atomic" "time" @@ -26,20 +25,10 @@ import ( // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - schema: cfg.Schema, - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } + return &executableSchema{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity} } -type Config struct { - Schema *ast.Schema - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} +type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot] type ResolverRoot interface { Mutation() MutationResolver @@ -51,6 +40,10 @@ type DirectiveRoot struct { Auth func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) CacheData func(ctx context.Context, obj any, next graphql.Resolver, ttl int, key *string, fields []string) (res any, err error) HasPermissions func(ctx context.Context, obj any, next graphql.Resolver, permissions []string) (res any, err error) + Length func(ctx context.Context, obj any, next graphql.Resolver, min int, max int, trim bool, ornil bool) (res any, err error) + Notempty func(ctx context.Context, obj any, next graphql.Resolver, trim bool, ornil bool) (res any, err error) + Range func(ctx context.Context, obj any, next graphql.Resolver, min float64, max float64, ornil bool) (res any, err error) + Regex func(ctx context.Context, obj any, next graphql.Resolver, pattern string, trim bool, ornil bool) (res any, err error) SkipNoPermissions func(ctx context.Context, obj any, next graphql.Resolver, permissions []string) (res any, err error) } @@ -225,7 +218,7 @@ type ComplexityRoot struct { ApproveAccount func(childComplexity int, id uint64, msg string) int ApproveAccountMember func(childComplexity int, memberID uint64, msg string) int ApproveUser func(childComplexity int, id uint64, msg *string) int - CreateAuthClient func(childComplexity int, input models.AuthClientInput) int + CreateAuthClient func(childComplexity int, input models.AuthClientCreateInput) int CreateRole func(childComplexity int, input models.RBACRoleInput) int CreateUser func(childComplexity int, input models.UserInput) int DeleteAuthClient func(childComplexity int, id string, msg *string) int @@ -247,7 +240,7 @@ type ComplexityRoot struct { SwitchAccount func(childComplexity int, id uint64) int UpdateAccount func(childComplexity int, id uint64, input models.AccountInput) int UpdateAccountMember func(childComplexity int, memberID uint64, member models.MemberInput) int - UpdateAuthClient func(childComplexity int, id string, input models.AuthClientInput) int + UpdateAuthClient func(childComplexity int, id string, input models.AuthClientUpdateInput) int UpdateRole func(childComplexity int, id uint64, input models.RBACRoleInput) int UpdateUser func(childComplexity int, id uint64, input models.UserInput) int UpdateUserPassword func(childComplexity int, token string, email string, password string) int @@ -317,7 +310,7 @@ type ComplexityRoot struct { GetDirectAccessToken func(childComplexity int, id uint64) int ListAccountRolesAndPermissions func(childComplexity int, accountID uint64, order *models.RBACRoleListOrder) int ListAccounts func(childComplexity int, filter *models.AccountListFilter, order *models.AccountListOrder, page *models.Page) int - ListAuthClients func(childComplexity int, filter *models.AuthClientListFilter, order *models.AuthClientListOrder, page *models.Page) int + ListAuthClients func(childComplexity int, filter *models.AuthClientListFilter, order []*models.AuthClientListOrder, page *models.Page) int ListDirectAccessTokens func(childComplexity int, filter *models.DirectAccessTokenListFilter, order *models.DirectAccessTokenListOrder, page *models.Page) int ListHistory func(childComplexity int, filter *models.HistoryActionListFilter, order *models.HistoryActionListOrder, page *models.Page) int ListMembers func(childComplexity int, filter *models.MemberListFilter, order *models.MemberListOrder, page *models.Page) int @@ -466,6 +459,12 @@ type ComplexityRoot struct { type MutationResolver interface { Poke(ctx context.Context) (string, error) + CreateUser(ctx context.Context, input models.UserInput) (*models.UserPayload, error) + UpdateUser(ctx context.Context, id uint64, input models.UserInput) (*models.UserPayload, error) + ApproveUser(ctx context.Context, id uint64, msg *string) (*models.UserPayload, error) + RejectUser(ctx context.Context, id uint64, msg *string) (*models.UserPayload, error) + ResetUserPassword(ctx context.Context, email string) (*models.StatusResponse, error) + UpdateUserPassword(ctx context.Context, token string, email string, password string) (*models.StatusResponse, error) Login(ctx context.Context, login string, password string) (*models.SessionToken, error) Logout(ctx context.Context) (bool, error) SwitchAccount(ctx context.Context, id uint64) (*models.SessionToken, error) @@ -478,15 +477,8 @@ type MutationResolver interface { RemoveAccountMember(ctx context.Context, memberID uint64) (*models.MemberPayload, error) ApproveAccountMember(ctx context.Context, memberID uint64, msg string) (*models.MemberPayload, error) RejectAccountMember(ctx context.Context, memberID uint64, msg string) (*models.MemberPayload, error) - DisconnectSocialAccount(ctx context.Context, id uint64) (*models.SocialAccountPayload, error) - CreateUser(ctx context.Context, input models.UserInput) (*models.UserPayload, error) - UpdateUser(ctx context.Context, id uint64, input models.UserInput) (*models.UserPayload, error) - ApproveUser(ctx context.Context, id uint64, msg *string) (*models.UserPayload, error) - RejectUser(ctx context.Context, id uint64, msg *string) (*models.UserPayload, error) - ResetUserPassword(ctx context.Context, email string) (*models.StatusResponse, error) - UpdateUserPassword(ctx context.Context, token string, email string, password string) (*models.StatusResponse, error) - CreateAuthClient(ctx context.Context, input models.AuthClientInput) (*models.AuthClientPayload, error) - UpdateAuthClient(ctx context.Context, id string, input models.AuthClientInput) (*models.AuthClientPayload, error) + CreateAuthClient(ctx context.Context, input models.AuthClientCreateInput) (*models.AuthClientPayload, error) + UpdateAuthClient(ctx context.Context, id string, input models.AuthClientUpdateInput) (*models.AuthClientPayload, error) DeleteAuthClient(ctx context.Context, id string, msg *string) (*models.AuthClientPayload, error) GenerateDirectAccessToken(ctx context.Context, userID *uint64, description string, expiresAt *time.Time) (*models.DirectAccessTokenPayload, error) RevokeDirectAccessToken(ctx context.Context, filter models.DirectAccessTokenListFilter) (*models.StatusResponse, error) @@ -494,23 +486,21 @@ type MutationResolver interface { CreateRole(ctx context.Context, input models.RBACRoleInput) (*models.RBACRolePayload, error) UpdateRole(ctx context.Context, id uint64, input models.RBACRoleInput) (*models.RBACRolePayload, error) DeleteRole(ctx context.Context, id uint64, msg *string) (*models.RBACRolePayload, error) + DisconnectSocialAccount(ctx context.Context, id uint64) (*models.SocialAccountPayload, error) } type QueryResolver interface { ServiceVersion(ctx context.Context) (string, error) + CurrentUser(ctx context.Context) (*models.UserPayload, error) + User(ctx context.Context, id uint64, username string) (*models.UserPayload, error) + ListUsers(ctx context.Context, filter *models.UserListFilter, order *models.UserListOrder, page *models.Page) (*connectors.CollectionConnection[models.User, models.UserEdge], error) CurrentSession(ctx context.Context) (*models.SessionToken, error) CurrentAccount(ctx context.Context) (*models.AccountPayload, error) Account(ctx context.Context, id uint64) (*models.AccountPayload, error) ListAccounts(ctx context.Context, filter *models.AccountListFilter, order *models.AccountListOrder, page *models.Page) (*connectors.CollectionConnection[models.Account, models.AccountEdge], error) ListAccountRolesAndPermissions(ctx context.Context, accountID uint64, order *models.RBACRoleListOrder) (*connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge], error) ListMembers(ctx context.Context, filter *models.MemberListFilter, order *models.MemberListOrder, page *models.Page) (*connectors.CollectionConnection[models.Member, models.MemberEdge], error) - SocialAccount(ctx context.Context, id uint64) (*models.SocialAccountPayload, error) - CurrentSocialAccounts(ctx context.Context, filter *models.SocialAccountListFilter, order *models.SocialAccountListOrder) (*connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge], error) - ListSocialAccounts(ctx context.Context, filter *models.SocialAccountListFilter, order *models.SocialAccountListOrder, page *models.Page) (*connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge], error) - CurrentUser(ctx context.Context) (*models.UserPayload, error) - User(ctx context.Context, id uint64, username string) (*models.UserPayload, error) - ListUsers(ctx context.Context, filter *models.UserListFilter, order *models.UserListOrder, page *models.Page) (*connectors.CollectionConnection[models.User, models.UserEdge], error) AuthClient(ctx context.Context, id string) (*models.AuthClientPayload, error) - ListAuthClients(ctx context.Context, filter *models.AuthClientListFilter, order *models.AuthClientListOrder, page *models.Page) (*connectors.CollectionConnection[models.AuthClient, models.AuthClientEdge], error) + ListAuthClients(ctx context.Context, filter *models.AuthClientListFilter, order []*models.AuthClientListOrder, page *models.Page) (*connectors.CollectionConnection[models.AuthClient, models.AuthClientEdge], error) GetDirectAccessToken(ctx context.Context, id uint64) (*models.DirectAccessTokenPayload, error) ListDirectAccessTokens(ctx context.Context, filter *models.DirectAccessTokenListFilter, order *models.DirectAccessTokenListOrder, page *models.Page) (*connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge], error) ListHistory(ctx context.Context, filter *models.HistoryActionListFilter, order *models.HistoryActionListOrder, page *models.Page) (*connectors.CollectionConnection[models.HistoryAction, models.HistoryActionEdge], error) @@ -521,668 +511,666 @@ type QueryResolver interface { ListRoles(ctx context.Context, filter *models.RBACRoleListFilter, order *models.RBACRoleListOrder, page *models.Page) (*connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge], error) ListPermissions(ctx context.Context, patterns []string) ([]*models.RBACPermission, error) ListMyPermissions(ctx context.Context, patterns []string) ([]*models.RBACPermission, error) + SocialAccount(ctx context.Context, id uint64) (*models.SocialAccountPayload, error) + CurrentSocialAccounts(ctx context.Context, filter *models.SocialAccountListFilter, order *models.SocialAccountListOrder) (*connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge], error) + ListSocialAccounts(ctx context.Context, filter *models.SocialAccountListFilter, order *models.SocialAccountListOrder, page *models.Page) (*connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge], error) } -type executableSchema struct { - schema *ast.Schema - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} +type executableSchema graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot] func (e *executableSchema) Schema() *ast.Schema { - if e.schema != nil { - return e.schema + if e.SchemaData != nil { + return e.SchemaData } return parsedSchema } func (e *executableSchema) Complexity(ctx context.Context, typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) { - ec := executionContext{nil, e, 0, 0, nil} + ec := newExecutionContext(nil, e, nil) _ = ec switch typeName + "." + field { case "Account.clientURI": - if e.complexity.Account.ClientURI == nil { + if e.ComplexityRoot.Account.ClientURI == nil { break } - return e.complexity.Account.ClientURI(childComplexity), true + return e.ComplexityRoot.Account.ClientURI(childComplexity), true case "Account.contacts": - if e.complexity.Account.Contacts == nil { + if e.ComplexityRoot.Account.Contacts == nil { break } - return e.complexity.Account.Contacts(childComplexity), true + return e.ComplexityRoot.Account.Contacts(childComplexity), true case "Account.createdAt": - if e.complexity.Account.CreatedAt == nil { + if e.ComplexityRoot.Account.CreatedAt == nil { break } - return e.complexity.Account.CreatedAt(childComplexity), true + return e.ComplexityRoot.Account.CreatedAt(childComplexity), true case "Account.description": - if e.complexity.Account.Description == nil { + if e.ComplexityRoot.Account.Description == nil { break } - return e.complexity.Account.Description(childComplexity), true + return e.ComplexityRoot.Account.Description(childComplexity), true case "Account.ID": - if e.complexity.Account.ID == nil { + if e.ComplexityRoot.Account.ID == nil { break } - return e.complexity.Account.ID(childComplexity), true + return e.ComplexityRoot.Account.ID(childComplexity), true case "Account.logoURI": - if e.complexity.Account.LogoURI == nil { + if e.ComplexityRoot.Account.LogoURI == nil { break } - return e.complexity.Account.LogoURI(childComplexity), true + return e.ComplexityRoot.Account.LogoURI(childComplexity), true case "Account.policyURI": - if e.complexity.Account.PolicyURI == nil { + if e.ComplexityRoot.Account.PolicyURI == nil { break } - return e.complexity.Account.PolicyURI(childComplexity), true + return e.ComplexityRoot.Account.PolicyURI(childComplexity), true case "Account.status": - if e.complexity.Account.Status == nil { + if e.ComplexityRoot.Account.Status == nil { break } - return e.complexity.Account.Status(childComplexity), true + return e.ComplexityRoot.Account.Status(childComplexity), true case "Account.statusMessage": - if e.complexity.Account.StatusMessage == nil { + if e.ComplexityRoot.Account.StatusMessage == nil { break } - return e.complexity.Account.StatusMessage(childComplexity), true + return e.ComplexityRoot.Account.StatusMessage(childComplexity), true case "Account.termsOfServiceURI": - if e.complexity.Account.TermsOfServiceURI == nil { + if e.ComplexityRoot.Account.TermsOfServiceURI == nil { break } - return e.complexity.Account.TermsOfServiceURI(childComplexity), true + return e.ComplexityRoot.Account.TermsOfServiceURI(childComplexity), true case "Account.title": - if e.complexity.Account.Title == nil { + if e.ComplexityRoot.Account.Title == nil { break } - return e.complexity.Account.Title(childComplexity), true + return e.ComplexityRoot.Account.Title(childComplexity), true case "Account.updatedAt": - if e.complexity.Account.UpdatedAt == nil { + if e.ComplexityRoot.Account.UpdatedAt == nil { break } - return e.complexity.Account.UpdatedAt(childComplexity), true + return e.ComplexityRoot.Account.UpdatedAt(childComplexity), true case "AccountConnection.edges": - if e.complexity.AccountConnection.Edges == nil { + if e.ComplexityRoot.AccountConnection.Edges == nil { break } - return e.complexity.AccountConnection.Edges(childComplexity), true + return e.ComplexityRoot.AccountConnection.Edges(childComplexity), true case "AccountConnection.list": - if e.complexity.AccountConnection.List == nil { + if e.ComplexityRoot.AccountConnection.List == nil { break } - return e.complexity.AccountConnection.List(childComplexity), true + return e.ComplexityRoot.AccountConnection.List(childComplexity), true case "AccountConnection.pageInfo": - if e.complexity.AccountConnection.PageInfo == nil { + if e.ComplexityRoot.AccountConnection.PageInfo == nil { break } - return e.complexity.AccountConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.AccountConnection.PageInfo(childComplexity), true case "AccountConnection.totalCount": - if e.complexity.AccountConnection.TotalCount == nil { + if e.ComplexityRoot.AccountConnection.TotalCount == nil { break } - return e.complexity.AccountConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.AccountConnection.TotalCount(childComplexity), true case "AccountCreatePayload.account": - if e.complexity.AccountCreatePayload.Account == nil { + if e.ComplexityRoot.AccountCreatePayload.Account == nil { break } - return e.complexity.AccountCreatePayload.Account(childComplexity), true + return e.ComplexityRoot.AccountCreatePayload.Account(childComplexity), true case "AccountCreatePayload.clientMutationID": - if e.complexity.AccountCreatePayload.ClientMutationID == nil { + if e.ComplexityRoot.AccountCreatePayload.ClientMutationID == nil { break } - return e.complexity.AccountCreatePayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.AccountCreatePayload.ClientMutationID(childComplexity), true case "AccountCreatePayload.owner": - if e.complexity.AccountCreatePayload.Owner == nil { + if e.ComplexityRoot.AccountCreatePayload.Owner == nil { break } - return e.complexity.AccountCreatePayload.Owner(childComplexity), true + return e.ComplexityRoot.AccountCreatePayload.Owner(childComplexity), true case "AccountEdge.cursor": - if e.complexity.AccountEdge.Cursor == nil { + if e.ComplexityRoot.AccountEdge.Cursor == nil { break } - return e.complexity.AccountEdge.Cursor(childComplexity), true + return e.ComplexityRoot.AccountEdge.Cursor(childComplexity), true case "AccountEdge.node": - if e.complexity.AccountEdge.Node == nil { + if e.ComplexityRoot.AccountEdge.Node == nil { break } - return e.complexity.AccountEdge.Node(childComplexity), true + return e.ComplexityRoot.AccountEdge.Node(childComplexity), true case "AccountPayload.account": - if e.complexity.AccountPayload.Account == nil { + if e.ComplexityRoot.AccountPayload.Account == nil { break } - return e.complexity.AccountPayload.Account(childComplexity), true + return e.ComplexityRoot.AccountPayload.Account(childComplexity), true case "AccountPayload.accountID": - if e.complexity.AccountPayload.AccountID == nil { + if e.ComplexityRoot.AccountPayload.AccountID == nil { break } - return e.complexity.AccountPayload.AccountID(childComplexity), true + return e.ComplexityRoot.AccountPayload.AccountID(childComplexity), true case "AccountPayload.clientMutationID": - if e.complexity.AccountPayload.ClientMutationID == nil { + if e.ComplexityRoot.AccountPayload.ClientMutationID == nil { break } - return e.complexity.AccountPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.AccountPayload.ClientMutationID(childComplexity), true case "AuthClient.accountID": - if e.complexity.AuthClient.AccountID == nil { + if e.ComplexityRoot.AuthClient.AccountID == nil { break } - return e.complexity.AuthClient.AccountID(childComplexity), true + return e.ComplexityRoot.AuthClient.AccountID(childComplexity), true case "AuthClient.allowedCORSOrigins": - if e.complexity.AuthClient.AllowedCORSOrigins == nil { + if e.ComplexityRoot.AuthClient.AllowedCORSOrigins == nil { break } - return e.complexity.AuthClient.AllowedCORSOrigins(childComplexity), true + return e.ComplexityRoot.AuthClient.AllowedCORSOrigins(childComplexity), true case "AuthClient.audience": - if e.complexity.AuthClient.Audience == nil { + if e.ComplexityRoot.AuthClient.Audience == nil { break } - return e.complexity.AuthClient.Audience(childComplexity), true + return e.ComplexityRoot.AuthClient.Audience(childComplexity), true case "AuthClient.createdAt": - if e.complexity.AuthClient.CreatedAt == nil { + if e.ComplexityRoot.AuthClient.CreatedAt == nil { break } - return e.complexity.AuthClient.CreatedAt(childComplexity), true + return e.ComplexityRoot.AuthClient.CreatedAt(childComplexity), true case "AuthClient.deletedAt": - if e.complexity.AuthClient.DeletedAt == nil { + if e.ComplexityRoot.AuthClient.DeletedAt == nil { break } - return e.complexity.AuthClient.DeletedAt(childComplexity), true + return e.ComplexityRoot.AuthClient.DeletedAt(childComplexity), true case "AuthClient.expiresAt": - if e.complexity.AuthClient.ExpiresAt == nil { + if e.ComplexityRoot.AuthClient.ExpiresAt == nil { break } - return e.complexity.AuthClient.ExpiresAt(childComplexity), true + return e.ComplexityRoot.AuthClient.ExpiresAt(childComplexity), true case "AuthClient.grantTypes": - if e.complexity.AuthClient.GrantTypes == nil { + if e.ComplexityRoot.AuthClient.GrantTypes == nil { break } - return e.complexity.AuthClient.GrantTypes(childComplexity), true + return e.ComplexityRoot.AuthClient.GrantTypes(childComplexity), true case "AuthClient.ID": - if e.complexity.AuthClient.ID == nil { + if e.ComplexityRoot.AuthClient.ID == nil { break } - return e.complexity.AuthClient.ID(childComplexity), true + return e.ComplexityRoot.AuthClient.ID(childComplexity), true case "AuthClient.public": - if e.complexity.AuthClient.Public == nil { + if e.ComplexityRoot.AuthClient.Public == nil { break } - return e.complexity.AuthClient.Public(childComplexity), true + return e.ComplexityRoot.AuthClient.Public(childComplexity), true case "AuthClient.redirectURIs": - if e.complexity.AuthClient.RedirectURIs == nil { + if e.ComplexityRoot.AuthClient.RedirectURIs == nil { break } - return e.complexity.AuthClient.RedirectURIs(childComplexity), true + return e.ComplexityRoot.AuthClient.RedirectURIs(childComplexity), true case "AuthClient.responseTypes": - if e.complexity.AuthClient.ResponseTypes == nil { + if e.ComplexityRoot.AuthClient.ResponseTypes == nil { break } - return e.complexity.AuthClient.ResponseTypes(childComplexity), true + return e.ComplexityRoot.AuthClient.ResponseTypes(childComplexity), true case "AuthClient.scope": - if e.complexity.AuthClient.Scope == nil { + if e.ComplexityRoot.AuthClient.Scope == nil { break } - return e.complexity.AuthClient.Scope(childComplexity), true + return e.ComplexityRoot.AuthClient.Scope(childComplexity), true case "AuthClient.secret": - if e.complexity.AuthClient.Secret == nil { + if e.ComplexityRoot.AuthClient.Secret == nil { break } - return e.complexity.AuthClient.Secret(childComplexity), true + return e.ComplexityRoot.AuthClient.Secret(childComplexity), true case "AuthClient.subjectType": - if e.complexity.AuthClient.SubjectType == nil { + if e.ComplexityRoot.AuthClient.SubjectType == nil { break } - return e.complexity.AuthClient.SubjectType(childComplexity), true + return e.ComplexityRoot.AuthClient.SubjectType(childComplexity), true case "AuthClient.title": - if e.complexity.AuthClient.Title == nil { + if e.ComplexityRoot.AuthClient.Title == nil { break } - return e.complexity.AuthClient.Title(childComplexity), true + return e.ComplexityRoot.AuthClient.Title(childComplexity), true case "AuthClient.updatedAt": - if e.complexity.AuthClient.UpdatedAt == nil { + if e.ComplexityRoot.AuthClient.UpdatedAt == nil { break } - return e.complexity.AuthClient.UpdatedAt(childComplexity), true + return e.ComplexityRoot.AuthClient.UpdatedAt(childComplexity), true case "AuthClient.userID": - if e.complexity.AuthClient.UserID == nil { + if e.ComplexityRoot.AuthClient.UserID == nil { break } - return e.complexity.AuthClient.UserID(childComplexity), true + return e.ComplexityRoot.AuthClient.UserID(childComplexity), true case "AuthClientConnection.edges": - if e.complexity.AuthClientConnection.Edges == nil { + if e.ComplexityRoot.AuthClientConnection.Edges == nil { break } - return e.complexity.AuthClientConnection.Edges(childComplexity), true + return e.ComplexityRoot.AuthClientConnection.Edges(childComplexity), true case "AuthClientConnection.list": - if e.complexity.AuthClientConnection.List == nil { + if e.ComplexityRoot.AuthClientConnection.List == nil { break } - return e.complexity.AuthClientConnection.List(childComplexity), true + return e.ComplexityRoot.AuthClientConnection.List(childComplexity), true case "AuthClientConnection.pageInfo": - if e.complexity.AuthClientConnection.PageInfo == nil { + if e.ComplexityRoot.AuthClientConnection.PageInfo == nil { break } - return e.complexity.AuthClientConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.AuthClientConnection.PageInfo(childComplexity), true case "AuthClientConnection.totalCount": - if e.complexity.AuthClientConnection.TotalCount == nil { + if e.ComplexityRoot.AuthClientConnection.TotalCount == nil { break } - return e.complexity.AuthClientConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.AuthClientConnection.TotalCount(childComplexity), true case "AuthClientEdge.cursor": - if e.complexity.AuthClientEdge.Cursor == nil { + if e.ComplexityRoot.AuthClientEdge.Cursor == nil { break } - return e.complexity.AuthClientEdge.Cursor(childComplexity), true + return e.ComplexityRoot.AuthClientEdge.Cursor(childComplexity), true case "AuthClientEdge.node": - if e.complexity.AuthClientEdge.Node == nil { + if e.ComplexityRoot.AuthClientEdge.Node == nil { break } - return e.complexity.AuthClientEdge.Node(childComplexity), true + return e.ComplexityRoot.AuthClientEdge.Node(childComplexity), true case "AuthClientPayload.authClient": - if e.complexity.AuthClientPayload.AuthClient == nil { + if e.ComplexityRoot.AuthClientPayload.AuthClient == nil { break } - return e.complexity.AuthClientPayload.AuthClient(childComplexity), true + return e.ComplexityRoot.AuthClientPayload.AuthClient(childComplexity), true case "AuthClientPayload.authClientID": - if e.complexity.AuthClientPayload.AuthClientID == nil { + if e.ComplexityRoot.AuthClientPayload.AuthClientID == nil { break } - return e.complexity.AuthClientPayload.AuthClientID(childComplexity), true + return e.ComplexityRoot.AuthClientPayload.AuthClientID(childComplexity), true case "AuthClientPayload.clientMutationID": - if e.complexity.AuthClientPayload.ClientMutationID == nil { + if e.ComplexityRoot.AuthClientPayload.ClientMutationID == nil { break } - return e.complexity.AuthClientPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.AuthClientPayload.ClientMutationID(childComplexity), true case "DirectAccessToken.accountID": - if e.complexity.DirectAccessToken.AccountID == nil { + if e.ComplexityRoot.DirectAccessToken.AccountID == nil { break } - return e.complexity.DirectAccessToken.AccountID(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.AccountID(childComplexity), true case "DirectAccessToken.createdAt": - if e.complexity.DirectAccessToken.CreatedAt == nil { + if e.ComplexityRoot.DirectAccessToken.CreatedAt == nil { break } - return e.complexity.DirectAccessToken.CreatedAt(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.CreatedAt(childComplexity), true case "DirectAccessToken.description": - if e.complexity.DirectAccessToken.Description == nil { + if e.ComplexityRoot.DirectAccessToken.Description == nil { break } - return e.complexity.DirectAccessToken.Description(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.Description(childComplexity), true case "DirectAccessToken.expiresAt": - if e.complexity.DirectAccessToken.ExpiresAt == nil { + if e.ComplexityRoot.DirectAccessToken.ExpiresAt == nil { break } - return e.complexity.DirectAccessToken.ExpiresAt(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.ExpiresAt(childComplexity), true case "DirectAccessToken.ID": - if e.complexity.DirectAccessToken.ID == nil { + if e.ComplexityRoot.DirectAccessToken.ID == nil { break } - return e.complexity.DirectAccessToken.ID(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.ID(childComplexity), true case "DirectAccessToken.token": - if e.complexity.DirectAccessToken.Token == nil { + if e.ComplexityRoot.DirectAccessToken.Token == nil { break } - return e.complexity.DirectAccessToken.Token(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.Token(childComplexity), true case "DirectAccessToken.userID": - if e.complexity.DirectAccessToken.UserID == nil { + if e.ComplexityRoot.DirectAccessToken.UserID == nil { break } - return e.complexity.DirectAccessToken.UserID(childComplexity), true + return e.ComplexityRoot.DirectAccessToken.UserID(childComplexity), true case "DirectAccessTokenConnection.edges": - if e.complexity.DirectAccessTokenConnection.Edges == nil { + if e.ComplexityRoot.DirectAccessTokenConnection.Edges == nil { break } - return e.complexity.DirectAccessTokenConnection.Edges(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenConnection.Edges(childComplexity), true case "DirectAccessTokenConnection.list": - if e.complexity.DirectAccessTokenConnection.List == nil { + if e.ComplexityRoot.DirectAccessTokenConnection.List == nil { break } - return e.complexity.DirectAccessTokenConnection.List(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenConnection.List(childComplexity), true case "DirectAccessTokenConnection.pageInfo": - if e.complexity.DirectAccessTokenConnection.PageInfo == nil { + if e.ComplexityRoot.DirectAccessTokenConnection.PageInfo == nil { break } - return e.complexity.DirectAccessTokenConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenConnection.PageInfo(childComplexity), true case "DirectAccessTokenConnection.totalCount": - if e.complexity.DirectAccessTokenConnection.TotalCount == nil { + if e.ComplexityRoot.DirectAccessTokenConnection.TotalCount == nil { break } - return e.complexity.DirectAccessTokenConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenConnection.TotalCount(childComplexity), true case "DirectAccessTokenEdge.cursor": - if e.complexity.DirectAccessTokenEdge.Cursor == nil { + if e.ComplexityRoot.DirectAccessTokenEdge.Cursor == nil { break } - return e.complexity.DirectAccessTokenEdge.Cursor(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenEdge.Cursor(childComplexity), true case "DirectAccessTokenEdge.node": - if e.complexity.DirectAccessTokenEdge.Node == nil { + if e.ComplexityRoot.DirectAccessTokenEdge.Node == nil { break } - return e.complexity.DirectAccessTokenEdge.Node(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenEdge.Node(childComplexity), true case "DirectAccessTokenPayload.clientMutationID": - if e.complexity.DirectAccessTokenPayload.ClientMutationID == nil { + if e.ComplexityRoot.DirectAccessTokenPayload.ClientMutationID == nil { break } - return e.complexity.DirectAccessTokenPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenPayload.ClientMutationID(childComplexity), true case "DirectAccessTokenPayload.token": - if e.complexity.DirectAccessTokenPayload.Token == nil { + if e.ComplexityRoot.DirectAccessTokenPayload.Token == nil { break } - return e.complexity.DirectAccessTokenPayload.Token(childComplexity), true + return e.ComplexityRoot.DirectAccessTokenPayload.Token(childComplexity), true case "HistoryAction.accountID": - if e.complexity.HistoryAction.AccountID == nil { + if e.ComplexityRoot.HistoryAction.AccountID == nil { break } - return e.complexity.HistoryAction.AccountID(childComplexity), true + return e.ComplexityRoot.HistoryAction.AccountID(childComplexity), true case "HistoryAction.actionAt": - if e.complexity.HistoryAction.ActionAt == nil { + if e.ComplexityRoot.HistoryAction.ActionAt == nil { break } - return e.complexity.HistoryAction.ActionAt(childComplexity), true + return e.ComplexityRoot.HistoryAction.ActionAt(childComplexity), true case "HistoryAction.data": - if e.complexity.HistoryAction.Data == nil { + if e.ComplexityRoot.HistoryAction.Data == nil { break } - return e.complexity.HistoryAction.Data(childComplexity), true + return e.ComplexityRoot.HistoryAction.Data(childComplexity), true case "HistoryAction.ID": - if e.complexity.HistoryAction.ID == nil { + if e.ComplexityRoot.HistoryAction.ID == nil { break } - return e.complexity.HistoryAction.ID(childComplexity), true + return e.ComplexityRoot.HistoryAction.ID(childComplexity), true case "HistoryAction.message": - if e.complexity.HistoryAction.Message == nil { + if e.ComplexityRoot.HistoryAction.Message == nil { break } - return e.complexity.HistoryAction.Message(childComplexity), true + return e.ComplexityRoot.HistoryAction.Message(childComplexity), true case "HistoryAction.name": - if e.complexity.HistoryAction.Name == nil { + if e.ComplexityRoot.HistoryAction.Name == nil { break } - return e.complexity.HistoryAction.Name(childComplexity), true + return e.ComplexityRoot.HistoryAction.Name(childComplexity), true case "HistoryAction.objectID": - if e.complexity.HistoryAction.ObjectID == nil { + if e.ComplexityRoot.HistoryAction.ObjectID == nil { break } - return e.complexity.HistoryAction.ObjectID(childComplexity), true + return e.ComplexityRoot.HistoryAction.ObjectID(childComplexity), true case "HistoryAction.objectIDs": - if e.complexity.HistoryAction.ObjectIDs == nil { + if e.ComplexityRoot.HistoryAction.ObjectIDs == nil { break } - return e.complexity.HistoryAction.ObjectIDs(childComplexity), true + return e.ComplexityRoot.HistoryAction.ObjectIDs(childComplexity), true case "HistoryAction.objectType": - if e.complexity.HistoryAction.ObjectType == nil { + if e.ComplexityRoot.HistoryAction.ObjectType == nil { break } - return e.complexity.HistoryAction.ObjectType(childComplexity), true + return e.ComplexityRoot.HistoryAction.ObjectType(childComplexity), true case "HistoryAction.RequestID": - if e.complexity.HistoryAction.RequestID == nil { + if e.ComplexityRoot.HistoryAction.RequestID == nil { break } - return e.complexity.HistoryAction.RequestID(childComplexity), true + return e.ComplexityRoot.HistoryAction.RequestID(childComplexity), true case "HistoryAction.userID": - if e.complexity.HistoryAction.UserID == nil { + if e.ComplexityRoot.HistoryAction.UserID == nil { break } - return e.complexity.HistoryAction.UserID(childComplexity), true + return e.ComplexityRoot.HistoryAction.UserID(childComplexity), true case "HistoryActionConnection.edges": - if e.complexity.HistoryActionConnection.Edges == nil { + if e.ComplexityRoot.HistoryActionConnection.Edges == nil { break } - return e.complexity.HistoryActionConnection.Edges(childComplexity), true + return e.ComplexityRoot.HistoryActionConnection.Edges(childComplexity), true case "HistoryActionConnection.list": - if e.complexity.HistoryActionConnection.List == nil { + if e.ComplexityRoot.HistoryActionConnection.List == nil { break } - return e.complexity.HistoryActionConnection.List(childComplexity), true + return e.ComplexityRoot.HistoryActionConnection.List(childComplexity), true case "HistoryActionConnection.pageInfo": - if e.complexity.HistoryActionConnection.PageInfo == nil { + if e.ComplexityRoot.HistoryActionConnection.PageInfo == nil { break } - return e.complexity.HistoryActionConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.HistoryActionConnection.PageInfo(childComplexity), true case "HistoryActionConnection.totalCount": - if e.complexity.HistoryActionConnection.TotalCount == nil { + if e.ComplexityRoot.HistoryActionConnection.TotalCount == nil { break } - return e.complexity.HistoryActionConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.HistoryActionConnection.TotalCount(childComplexity), true case "HistoryActionEdge.cursor": - if e.complexity.HistoryActionEdge.Cursor == nil { + if e.ComplexityRoot.HistoryActionEdge.Cursor == nil { break } - return e.complexity.HistoryActionEdge.Cursor(childComplexity), true + return e.ComplexityRoot.HistoryActionEdge.Cursor(childComplexity), true case "HistoryActionEdge.node": - if e.complexity.HistoryActionEdge.Node == nil { + if e.ComplexityRoot.HistoryActionEdge.Node == nil { break } - return e.complexity.HistoryActionEdge.Node(childComplexity), true + return e.ComplexityRoot.HistoryActionEdge.Node(childComplexity), true case "HistoryActionPayload.action": - if e.complexity.HistoryActionPayload.Action == nil { + if e.ComplexityRoot.HistoryActionPayload.Action == nil { break } - return e.complexity.HistoryActionPayload.Action(childComplexity), true + return e.ComplexityRoot.HistoryActionPayload.Action(childComplexity), true case "HistoryActionPayload.actionID": - if e.complexity.HistoryActionPayload.ActionID == nil { + if e.ComplexityRoot.HistoryActionPayload.ActionID == nil { break } - return e.complexity.HistoryActionPayload.ActionID(childComplexity), true + return e.ComplexityRoot.HistoryActionPayload.ActionID(childComplexity), true case "HistoryActionPayload.clientMutationId": - if e.complexity.HistoryActionPayload.ClientMutationID == nil { + if e.ComplexityRoot.HistoryActionPayload.ClientMutationID == nil { break } - return e.complexity.HistoryActionPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.HistoryActionPayload.ClientMutationID(childComplexity), true case "Member.account": - if e.complexity.Member.Account == nil { + if e.ComplexityRoot.Member.Account == nil { break } - return e.complexity.Member.Account(childComplexity), true + return e.ComplexityRoot.Member.Account(childComplexity), true case "Member.createdAt": - if e.complexity.Member.CreatedAt == nil { + if e.ComplexityRoot.Member.CreatedAt == nil { break } - return e.complexity.Member.CreatedAt(childComplexity), true + return e.ComplexityRoot.Member.CreatedAt(childComplexity), true case "Member.deletedAt": - if e.complexity.Member.DeletedAt == nil { + if e.ComplexityRoot.Member.DeletedAt == nil { break } - return e.complexity.Member.DeletedAt(childComplexity), true + return e.ComplexityRoot.Member.DeletedAt(childComplexity), true case "Member.ID": - if e.complexity.Member.ID == nil { + if e.ComplexityRoot.Member.ID == nil { break } - return e.complexity.Member.ID(childComplexity), true + return e.ComplexityRoot.Member.ID(childComplexity), true case "Member.isAdmin": - if e.complexity.Member.IsAdmin == nil { + if e.ComplexityRoot.Member.IsAdmin == nil { break } - return e.complexity.Member.IsAdmin(childComplexity), true + return e.ComplexityRoot.Member.IsAdmin(childComplexity), true case "Member.roles": - if e.complexity.Member.Roles == nil { + if e.ComplexityRoot.Member.Roles == nil { break } - return e.complexity.Member.Roles(childComplexity), true + return e.ComplexityRoot.Member.Roles(childComplexity), true case "Member.status": - if e.complexity.Member.Status == nil { + if e.ComplexityRoot.Member.Status == nil { break } - return e.complexity.Member.Status(childComplexity), true + return e.ComplexityRoot.Member.Status(childComplexity), true case "Member.updatedAt": - if e.complexity.Member.UpdatedAt == nil { + if e.ComplexityRoot.Member.UpdatedAt == nil { break } - return e.complexity.Member.UpdatedAt(childComplexity), true + return e.ComplexityRoot.Member.UpdatedAt(childComplexity), true case "Member.user": - if e.complexity.Member.User == nil { + if e.ComplexityRoot.Member.User == nil { break } - return e.complexity.Member.User(childComplexity), true + return e.ComplexityRoot.Member.User(childComplexity), true case "MemberConnection.edges": - if e.complexity.MemberConnection.Edges == nil { + if e.ComplexityRoot.MemberConnection.Edges == nil { break } - return e.complexity.MemberConnection.Edges(childComplexity), true + return e.ComplexityRoot.MemberConnection.Edges(childComplexity), true case "MemberConnection.list": - if e.complexity.MemberConnection.List == nil { + if e.ComplexityRoot.MemberConnection.List == nil { break } - return e.complexity.MemberConnection.List(childComplexity), true + return e.ComplexityRoot.MemberConnection.List(childComplexity), true case "MemberConnection.pageInfo": - if e.complexity.MemberConnection.PageInfo == nil { + if e.ComplexityRoot.MemberConnection.PageInfo == nil { break } - return e.complexity.MemberConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.MemberConnection.PageInfo(childComplexity), true case "MemberConnection.totalCount": - if e.complexity.MemberConnection.TotalCount == nil { + if e.ComplexityRoot.MemberConnection.TotalCount == nil { break } - return e.complexity.MemberConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.MemberConnection.TotalCount(childComplexity), true case "MemberEdge.cursor": - if e.complexity.MemberEdge.Cursor == nil { + if e.ComplexityRoot.MemberEdge.Cursor == nil { break } - return e.complexity.MemberEdge.Cursor(childComplexity), true + return e.ComplexityRoot.MemberEdge.Cursor(childComplexity), true case "MemberEdge.node": - if e.complexity.MemberEdge.Node == nil { + if e.ComplexityRoot.MemberEdge.Node == nil { break } - return e.complexity.MemberEdge.Node(childComplexity), true + return e.ComplexityRoot.MemberEdge.Node(childComplexity), true case "MemberPayload.clientMutationID": - if e.complexity.MemberPayload.ClientMutationID == nil { + if e.ComplexityRoot.MemberPayload.ClientMutationID == nil { break } - return e.complexity.MemberPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.MemberPayload.ClientMutationID(childComplexity), true case "MemberPayload.member": - if e.complexity.MemberPayload.Member == nil { + if e.ComplexityRoot.MemberPayload.Member == nil { break } - return e.complexity.MemberPayload.Member(childComplexity), true + return e.ComplexityRoot.MemberPayload.Member(childComplexity), true case "MemberPayload.memberID": - if e.complexity.MemberPayload.MemberID == nil { + if e.ComplexityRoot.MemberPayload.MemberID == nil { break } - return e.complexity.MemberPayload.MemberID(childComplexity), true + return e.ComplexityRoot.MemberPayload.MemberID(childComplexity), true case "Mutation.approveAccount": - if e.complexity.Mutation.ApproveAccount == nil { + if e.ComplexityRoot.Mutation.ApproveAccount == nil { break } @@ -1191,9 +1179,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.ApproveAccount(childComplexity, args["id"].(uint64), args["msg"].(string)), true + return e.ComplexityRoot.Mutation.ApproveAccount(childComplexity, args["id"].(uint64), args["msg"].(string)), true case "Mutation.approveAccountMember": - if e.complexity.Mutation.ApproveAccountMember == nil { + if e.ComplexityRoot.Mutation.ApproveAccountMember == nil { break } @@ -1202,9 +1190,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.ApproveAccountMember(childComplexity, args["memberID"].(uint64), args["msg"].(string)), true + return e.ComplexityRoot.Mutation.ApproveAccountMember(childComplexity, args["memberID"].(uint64), args["msg"].(string)), true case "Mutation.approveUser": - if e.complexity.Mutation.ApproveUser == nil { + if e.ComplexityRoot.Mutation.ApproveUser == nil { break } @@ -1213,9 +1201,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.ApproveUser(childComplexity, args["id"].(uint64), args["msg"].(*string)), true + return e.ComplexityRoot.Mutation.ApproveUser(childComplexity, args["id"].(uint64), args["msg"].(*string)), true case "Mutation.createAuthClient": - if e.complexity.Mutation.CreateAuthClient == nil { + if e.ComplexityRoot.Mutation.CreateAuthClient == nil { break } @@ -1224,9 +1212,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.CreateAuthClient(childComplexity, args["input"].(models.AuthClientInput)), true + return e.ComplexityRoot.Mutation.CreateAuthClient(childComplexity, args["input"].(models.AuthClientCreateInput)), true case "Mutation.createRole": - if e.complexity.Mutation.CreateRole == nil { + if e.ComplexityRoot.Mutation.CreateRole == nil { break } @@ -1235,9 +1223,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.CreateRole(childComplexity, args["input"].(models.RBACRoleInput)), true + return e.ComplexityRoot.Mutation.CreateRole(childComplexity, args["input"].(models.RBACRoleInput)), true case "Mutation.createUser": - if e.complexity.Mutation.CreateUser == nil { + if e.ComplexityRoot.Mutation.CreateUser == nil { break } @@ -1246,9 +1234,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.CreateUser(childComplexity, args["input"].(models.UserInput)), true + return e.ComplexityRoot.Mutation.CreateUser(childComplexity, args["input"].(models.UserInput)), true case "Mutation.deleteAuthClient": - if e.complexity.Mutation.DeleteAuthClient == nil { + if e.ComplexityRoot.Mutation.DeleteAuthClient == nil { break } @@ -1257,9 +1245,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.DeleteAuthClient(childComplexity, args["id"].(string), args["msg"].(*string)), true + return e.ComplexityRoot.Mutation.DeleteAuthClient(childComplexity, args["id"].(string), args["msg"].(*string)), true case "Mutation.deleteRole": - if e.complexity.Mutation.DeleteRole == nil { + if e.ComplexityRoot.Mutation.DeleteRole == nil { break } @@ -1268,9 +1256,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.DeleteRole(childComplexity, args["id"].(uint64), args["msg"].(*string)), true + return e.ComplexityRoot.Mutation.DeleteRole(childComplexity, args["id"].(uint64), args["msg"].(*string)), true case "Mutation.disconnectSocialAccount": - if e.complexity.Mutation.DisconnectSocialAccount == nil { + if e.ComplexityRoot.Mutation.DisconnectSocialAccount == nil { break } @@ -1279,9 +1267,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.DisconnectSocialAccount(childComplexity, args["id"].(uint64)), true + return e.ComplexityRoot.Mutation.DisconnectSocialAccount(childComplexity, args["id"].(uint64)), true case "Mutation.generateDirectAccessToken": - if e.complexity.Mutation.GenerateDirectAccessToken == nil { + if e.ComplexityRoot.Mutation.GenerateDirectAccessToken == nil { break } @@ -1290,9 +1278,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.GenerateDirectAccessToken(childComplexity, args["userID"].(*uint64), args["description"].(string), args["expiresAt"].(*time.Time)), true + return e.ComplexityRoot.Mutation.GenerateDirectAccessToken(childComplexity, args["userID"].(*uint64), args["description"].(string), args["expiresAt"].(*time.Time)), true case "Mutation.inviteAccountMember": - if e.complexity.Mutation.InviteAccountMember == nil { + if e.ComplexityRoot.Mutation.InviteAccountMember == nil { break } @@ -1301,9 +1289,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.InviteAccountMember(childComplexity, args["accountID"].(uint64), args["member"].(models.InviteMemberInput)), true + return e.ComplexityRoot.Mutation.InviteAccountMember(childComplexity, args["accountID"].(uint64), args["member"].(models.InviteMemberInput)), true case "Mutation.login": - if e.complexity.Mutation.Login == nil { + if e.ComplexityRoot.Mutation.Login == nil { break } @@ -1312,21 +1300,21 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.Login(childComplexity, args["login"].(string), args["password"].(string)), true + return e.ComplexityRoot.Mutation.Login(childComplexity, args["login"].(string), args["password"].(string)), true case "Mutation.logout": - if e.complexity.Mutation.Logout == nil { + if e.ComplexityRoot.Mutation.Logout == nil { break } - return e.complexity.Mutation.Logout(childComplexity), true + return e.ComplexityRoot.Mutation.Logout(childComplexity), true case "Mutation.poke": - if e.complexity.Mutation.Poke == nil { + if e.ComplexityRoot.Mutation.Poke == nil { break } - return e.complexity.Mutation.Poke(childComplexity), true + return e.ComplexityRoot.Mutation.Poke(childComplexity), true case "Mutation.registerAccount": - if e.complexity.Mutation.RegisterAccount == nil { + if e.ComplexityRoot.Mutation.RegisterAccount == nil { break } @@ -1335,9 +1323,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.RegisterAccount(childComplexity, args["input"].(models.AccountCreateInput)), true + return e.ComplexityRoot.Mutation.RegisterAccount(childComplexity, args["input"].(models.AccountCreateInput)), true case "Mutation.rejectAccount": - if e.complexity.Mutation.RejectAccount == nil { + if e.ComplexityRoot.Mutation.RejectAccount == nil { break } @@ -1346,9 +1334,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.RejectAccount(childComplexity, args["id"].(uint64), args["msg"].(string)), true + return e.ComplexityRoot.Mutation.RejectAccount(childComplexity, args["id"].(uint64), args["msg"].(string)), true case "Mutation.rejectAccountMember": - if e.complexity.Mutation.RejectAccountMember == nil { + if e.ComplexityRoot.Mutation.RejectAccountMember == nil { break } @@ -1357,9 +1345,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.RejectAccountMember(childComplexity, args["memberID"].(uint64), args["msg"].(string)), true + return e.ComplexityRoot.Mutation.RejectAccountMember(childComplexity, args["memberID"].(uint64), args["msg"].(string)), true case "Mutation.rejectUser": - if e.complexity.Mutation.RejectUser == nil { + if e.ComplexityRoot.Mutation.RejectUser == nil { break } @@ -1368,9 +1356,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.RejectUser(childComplexity, args["id"].(uint64), args["msg"].(*string)), true + return e.ComplexityRoot.Mutation.RejectUser(childComplexity, args["id"].(uint64), args["msg"].(*string)), true case "Mutation.removeAccountMember": - if e.complexity.Mutation.RemoveAccountMember == nil { + if e.ComplexityRoot.Mutation.RemoveAccountMember == nil { break } @@ -1379,9 +1367,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.RemoveAccountMember(childComplexity, args["memberID"].(uint64)), true + return e.ComplexityRoot.Mutation.RemoveAccountMember(childComplexity, args["memberID"].(uint64)), true case "Mutation.resetUserPassword": - if e.complexity.Mutation.ResetUserPassword == nil { + if e.ComplexityRoot.Mutation.ResetUserPassword == nil { break } @@ -1390,9 +1378,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.ResetUserPassword(childComplexity, args["email"].(string)), true + return e.ComplexityRoot.Mutation.ResetUserPassword(childComplexity, args["email"].(string)), true case "Mutation.revokeDirectAccessToken": - if e.complexity.Mutation.RevokeDirectAccessToken == nil { + if e.ComplexityRoot.Mutation.RevokeDirectAccessToken == nil { break } @@ -1401,9 +1389,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.RevokeDirectAccessToken(childComplexity, args["filter"].(models.DirectAccessTokenListFilter)), true + return e.ComplexityRoot.Mutation.RevokeDirectAccessToken(childComplexity, args["filter"].(models.DirectAccessTokenListFilter)), true case "Mutation.setOption": - if e.complexity.Mutation.SetOption == nil { + if e.ComplexityRoot.Mutation.SetOption == nil { break } @@ -1412,9 +1400,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.SetOption(childComplexity, args["name"].(string), args["value"].(*types.NullableJSON), args["type"].(models.OptionType), args["targetID"].(uint64)), true + return e.ComplexityRoot.Mutation.SetOption(childComplexity, args["name"].(string), args["value"].(*types.NullableJSON), args["type"].(models.OptionType), args["targetID"].(uint64)), true case "Mutation.switchAccount": - if e.complexity.Mutation.SwitchAccount == nil { + if e.ComplexityRoot.Mutation.SwitchAccount == nil { break } @@ -1423,9 +1411,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.SwitchAccount(childComplexity, args["id"].(uint64)), true + return e.ComplexityRoot.Mutation.SwitchAccount(childComplexity, args["id"].(uint64)), true case "Mutation.updateAccount": - if e.complexity.Mutation.UpdateAccount == nil { + if e.ComplexityRoot.Mutation.UpdateAccount == nil { break } @@ -1434,9 +1422,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.UpdateAccount(childComplexity, args["id"].(uint64), args["input"].(models.AccountInput)), true + return e.ComplexityRoot.Mutation.UpdateAccount(childComplexity, args["id"].(uint64), args["input"].(models.AccountInput)), true case "Mutation.updateAccountMember": - if e.complexity.Mutation.UpdateAccountMember == nil { + if e.ComplexityRoot.Mutation.UpdateAccountMember == nil { break } @@ -1445,9 +1433,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.UpdateAccountMember(childComplexity, args["memberID"].(uint64), args["member"].(models.MemberInput)), true + return e.ComplexityRoot.Mutation.UpdateAccountMember(childComplexity, args["memberID"].(uint64), args["member"].(models.MemberInput)), true case "Mutation.updateAuthClient": - if e.complexity.Mutation.UpdateAuthClient == nil { + if e.ComplexityRoot.Mutation.UpdateAuthClient == nil { break } @@ -1456,9 +1444,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.UpdateAuthClient(childComplexity, args["id"].(string), args["input"].(models.AuthClientInput)), true + return e.ComplexityRoot.Mutation.UpdateAuthClient(childComplexity, args["id"].(string), args["input"].(models.AuthClientUpdateInput)), true case "Mutation.updateRole": - if e.complexity.Mutation.UpdateRole == nil { + if e.ComplexityRoot.Mutation.UpdateRole == nil { break } @@ -1467,9 +1455,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.UpdateRole(childComplexity, args["id"].(uint64), args["input"].(models.RBACRoleInput)), true + return e.ComplexityRoot.Mutation.UpdateRole(childComplexity, args["id"].(uint64), args["input"].(models.RBACRoleInput)), true case "Mutation.updateUser": - if e.complexity.Mutation.UpdateUser == nil { + if e.ComplexityRoot.Mutation.UpdateUser == nil { break } @@ -1478,9 +1466,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.UpdateUser(childComplexity, args["id"].(uint64), args["input"].(models.UserInput)), true + return e.ComplexityRoot.Mutation.UpdateUser(childComplexity, args["id"].(uint64), args["input"].(models.UserInput)), true case "Mutation.updateUserPassword": - if e.complexity.Mutation.UpdateUserPassword == nil { + if e.ComplexityRoot.Mutation.UpdateUserPassword == nil { break } @@ -1489,209 +1477,209 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Mutation.UpdateUserPassword(childComplexity, args["token"].(string), args["email"].(string), args["password"].(string)), true + return e.ComplexityRoot.Mutation.UpdateUserPassword(childComplexity, args["token"].(string), args["email"].(string), args["password"].(string)), true case "Option.name": - if e.complexity.Option.Name == nil { + if e.ComplexityRoot.Option.Name == nil { break } - return e.complexity.Option.Name(childComplexity), true + return e.ComplexityRoot.Option.Name(childComplexity), true case "Option.targetID": - if e.complexity.Option.TargetID == nil { + if e.ComplexityRoot.Option.TargetID == nil { break } - return e.complexity.Option.TargetID(childComplexity), true + return e.ComplexityRoot.Option.TargetID(childComplexity), true case "Option.type": - if e.complexity.Option.Type == nil { + if e.ComplexityRoot.Option.Type == nil { break } - return e.complexity.Option.Type(childComplexity), true + return e.ComplexityRoot.Option.Type(childComplexity), true case "Option.value": - if e.complexity.Option.Value == nil { + if e.ComplexityRoot.Option.Value == nil { break } - return e.complexity.Option.Value(childComplexity), true + return e.ComplexityRoot.Option.Value(childComplexity), true case "OptionConnection.edges": - if e.complexity.OptionConnection.Edges == nil { + if e.ComplexityRoot.OptionConnection.Edges == nil { break } - return e.complexity.OptionConnection.Edges(childComplexity), true + return e.ComplexityRoot.OptionConnection.Edges(childComplexity), true case "OptionConnection.list": - if e.complexity.OptionConnection.List == nil { + if e.ComplexityRoot.OptionConnection.List == nil { break } - return e.complexity.OptionConnection.List(childComplexity), true + return e.ComplexityRoot.OptionConnection.List(childComplexity), true case "OptionConnection.pageInfo": - if e.complexity.OptionConnection.PageInfo == nil { + if e.ComplexityRoot.OptionConnection.PageInfo == nil { break } - return e.complexity.OptionConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.OptionConnection.PageInfo(childComplexity), true case "OptionConnection.totalCount": - if e.complexity.OptionConnection.TotalCount == nil { + if e.ComplexityRoot.OptionConnection.TotalCount == nil { break } - return e.complexity.OptionConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.OptionConnection.TotalCount(childComplexity), true case "OptionEdge.cursor": - if e.complexity.OptionEdge.Cursor == nil { + if e.ComplexityRoot.OptionEdge.Cursor == nil { break } - return e.complexity.OptionEdge.Cursor(childComplexity), true + return e.ComplexityRoot.OptionEdge.Cursor(childComplexity), true case "OptionEdge.node": - if e.complexity.OptionEdge.Node == nil { + if e.ComplexityRoot.OptionEdge.Node == nil { break } - return e.complexity.OptionEdge.Node(childComplexity), true + return e.ComplexityRoot.OptionEdge.Node(childComplexity), true case "OptionPayload.clientMutationId": - if e.complexity.OptionPayload.ClientMutationID == nil { + if e.ComplexityRoot.OptionPayload.ClientMutationID == nil { break } - return e.complexity.OptionPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.OptionPayload.ClientMutationID(childComplexity), true case "OptionPayload.name": - if e.complexity.OptionPayload.Name == nil { + if e.ComplexityRoot.OptionPayload.Name == nil { break } - return e.complexity.OptionPayload.Name(childComplexity), true + return e.ComplexityRoot.OptionPayload.Name(childComplexity), true case "OptionPayload.option": - if e.complexity.OptionPayload.Option == nil { + if e.ComplexityRoot.OptionPayload.Option == nil { break } - return e.complexity.OptionPayload.Option(childComplexity), true + return e.ComplexityRoot.OptionPayload.Option(childComplexity), true case "PageInfo.count": - if e.complexity.PageInfo.Count == nil { + if e.ComplexityRoot.PageInfo.Count == nil { break } - return e.complexity.PageInfo.Count(childComplexity), true + return e.ComplexityRoot.PageInfo.Count(childComplexity), true case "PageInfo.endCursor": - if e.complexity.PageInfo.EndCursor == nil { + if e.ComplexityRoot.PageInfo.EndCursor == nil { break } - return e.complexity.PageInfo.EndCursor(childComplexity), true + return e.ComplexityRoot.PageInfo.EndCursor(childComplexity), true case "PageInfo.hasNextPage": - if e.complexity.PageInfo.HasNextPage == nil { + if e.ComplexityRoot.PageInfo.HasNextPage == nil { break } - return e.complexity.PageInfo.HasNextPage(childComplexity), true + return e.ComplexityRoot.PageInfo.HasNextPage(childComplexity), true case "PageInfo.hasPreviousPage": - if e.complexity.PageInfo.HasPreviousPage == nil { + if e.ComplexityRoot.PageInfo.HasPreviousPage == nil { break } - return e.complexity.PageInfo.HasPreviousPage(childComplexity), true + return e.ComplexityRoot.PageInfo.HasPreviousPage(childComplexity), true case "PageInfo.page": - if e.complexity.PageInfo.Page == nil { + if e.ComplexityRoot.PageInfo.Page == nil { break } - return e.complexity.PageInfo.Page(childComplexity), true + return e.ComplexityRoot.PageInfo.Page(childComplexity), true case "PageInfo.startCursor": - if e.complexity.PageInfo.StartCursor == nil { + if e.ComplexityRoot.PageInfo.StartCursor == nil { break } - return e.complexity.PageInfo.StartCursor(childComplexity), true + return e.ComplexityRoot.PageInfo.StartCursor(childComplexity), true case "PageInfo.total": - if e.complexity.PageInfo.Total == nil { + if e.ComplexityRoot.PageInfo.Total == nil { break } - return e.complexity.PageInfo.Total(childComplexity), true + return e.ComplexityRoot.PageInfo.Total(childComplexity), true case "Profile.about": - if e.complexity.Profile.About == nil { + if e.ComplexityRoot.Profile.About == nil { break } - return e.complexity.Profile.About(childComplexity), true + return e.ComplexityRoot.Profile.About(childComplexity), true case "Profile.companyName": - if e.complexity.Profile.CompanyName == nil { + if e.ComplexityRoot.Profile.CompanyName == nil { break } - return e.complexity.Profile.CompanyName(childComplexity), true + return e.ComplexityRoot.Profile.CompanyName(childComplexity), true case "Profile.createdAt": - if e.complexity.Profile.CreatedAt == nil { + if e.ComplexityRoot.Profile.CreatedAt == nil { break } - return e.complexity.Profile.CreatedAt(childComplexity), true + return e.ComplexityRoot.Profile.CreatedAt(childComplexity), true case "Profile.email": - if e.complexity.Profile.Email == nil { + if e.ComplexityRoot.Profile.Email == nil { break } - return e.complexity.Profile.Email(childComplexity), true + return e.ComplexityRoot.Profile.Email(childComplexity), true case "Profile.firstName": - if e.complexity.Profile.FirstName == nil { + if e.ComplexityRoot.Profile.FirstName == nil { break } - return e.complexity.Profile.FirstName(childComplexity), true + return e.ComplexityRoot.Profile.FirstName(childComplexity), true case "Profile.ID": - if e.complexity.Profile.ID == nil { + if e.ComplexityRoot.Profile.ID == nil { break } - return e.complexity.Profile.ID(childComplexity), true + return e.ComplexityRoot.Profile.ID(childComplexity), true case "Profile.lastName": - if e.complexity.Profile.LastName == nil { + if e.ComplexityRoot.Profile.LastName == nil { break } - return e.complexity.Profile.LastName(childComplexity), true + return e.ComplexityRoot.Profile.LastName(childComplexity), true case "Profile.messgangers": - if e.complexity.Profile.Messgangers == nil { + if e.ComplexityRoot.Profile.Messgangers == nil { break } - return e.complexity.Profile.Messgangers(childComplexity), true + return e.ComplexityRoot.Profile.Messgangers(childComplexity), true case "Profile.updatedAt": - if e.complexity.Profile.UpdatedAt == nil { + if e.ComplexityRoot.Profile.UpdatedAt == nil { break } - return e.complexity.Profile.UpdatedAt(childComplexity), true + return e.ComplexityRoot.Profile.UpdatedAt(childComplexity), true case "Profile.user": - if e.complexity.Profile.User == nil { + if e.ComplexityRoot.Profile.User == nil { break } - return e.complexity.Profile.User(childComplexity), true + return e.ComplexityRoot.Profile.User(childComplexity), true case "ProfileMessanger.address": - if e.complexity.ProfileMessanger.Address == nil { + if e.ComplexityRoot.ProfileMessanger.Address == nil { break } - return e.complexity.ProfileMessanger.Address(childComplexity), true + return e.ComplexityRoot.ProfileMessanger.Address(childComplexity), true case "ProfileMessanger.mtype": - if e.complexity.ProfileMessanger.Mtype == nil { + if e.ComplexityRoot.ProfileMessanger.Mtype == nil { break } - return e.complexity.ProfileMessanger.Mtype(childComplexity), true + return e.ComplexityRoot.ProfileMessanger.Mtype(childComplexity), true case "Query.account": - if e.complexity.Query.Account == nil { + if e.ComplexityRoot.Query.Account == nil { break } @@ -1700,9 +1688,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.Account(childComplexity, args["id"].(uint64)), true + return e.ComplexityRoot.Query.Account(childComplexity, args["id"].(uint64)), true case "Query.authClient": - if e.complexity.Query.AuthClient == nil { + if e.ComplexityRoot.Query.AuthClient == nil { break } @@ -1711,9 +1699,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.AuthClient(childComplexity, args["id"].(string)), true + return e.ComplexityRoot.Query.AuthClient(childComplexity, args["id"].(string)), true case "Query.checkPermission": - if e.complexity.Query.CheckPermission == nil { + if e.ComplexityRoot.Query.CheckPermission == nil { break } @@ -1722,21 +1710,21 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.CheckPermission(childComplexity, args["name"].(string), args["key"].(*string), args["targetID"].(*string), args["idKey"].(*string)), true + return e.ComplexityRoot.Query.CheckPermission(childComplexity, args["name"].(string), args["key"].(*string), args["targetID"].(*string), args["idKey"].(*string)), true case "Query.currentAccount": - if e.complexity.Query.CurrentAccount == nil { + if e.ComplexityRoot.Query.CurrentAccount == nil { break } - return e.complexity.Query.CurrentAccount(childComplexity), true + return e.ComplexityRoot.Query.CurrentAccount(childComplexity), true case "Query.currentSession": - if e.complexity.Query.CurrentSession == nil { + if e.ComplexityRoot.Query.CurrentSession == nil { break } - return e.complexity.Query.CurrentSession(childComplexity), true + return e.ComplexityRoot.Query.CurrentSession(childComplexity), true case "Query.currentSocialAccounts": - if e.complexity.Query.CurrentSocialAccounts == nil { + if e.ComplexityRoot.Query.CurrentSocialAccounts == nil { break } @@ -1745,15 +1733,15 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.CurrentSocialAccounts(childComplexity, args["filter"].(*models.SocialAccountListFilter), args["order"].(*models.SocialAccountListOrder)), true + return e.ComplexityRoot.Query.CurrentSocialAccounts(childComplexity, args["filter"].(*models.SocialAccountListFilter), args["order"].(*models.SocialAccountListOrder)), true case "Query.currentUser": - if e.complexity.Query.CurrentUser == nil { + if e.ComplexityRoot.Query.CurrentUser == nil { break } - return e.complexity.Query.CurrentUser(childComplexity), true + return e.ComplexityRoot.Query.CurrentUser(childComplexity), true case "Query.getDirectAccessToken": - if e.complexity.Query.GetDirectAccessToken == nil { + if e.ComplexityRoot.Query.GetDirectAccessToken == nil { break } @@ -1762,9 +1750,10 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.GetDirectAccessToken(childComplexity, args["id"].(uint64)), true + return e.ComplexityRoot.Query.GetDirectAccessToken(childComplexity, args["id"].(uint64)), true + case "Query.listAccountRolesAndPermissions": - if e.complexity.Query.ListAccountRolesAndPermissions == nil { + if e.ComplexityRoot.Query.ListAccountRolesAndPermissions == nil { break } @@ -1773,9 +1762,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListAccountRolesAndPermissions(childComplexity, args["accountID"].(uint64), args["order"].(*models.RBACRoleListOrder)), true + return e.ComplexityRoot.Query.ListAccountRolesAndPermissions(childComplexity, args["accountID"].(uint64), args["order"].(*models.RBACRoleListOrder)), true case "Query.listAccounts": - if e.complexity.Query.ListAccounts == nil { + if e.ComplexityRoot.Query.ListAccounts == nil { break } @@ -1784,9 +1773,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListAccounts(childComplexity, args["filter"].(*models.AccountListFilter), args["order"].(*models.AccountListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListAccounts(childComplexity, args["filter"].(*models.AccountListFilter), args["order"].(*models.AccountListOrder), args["page"].(*models.Page)), true case "Query.listAuthClients": - if e.complexity.Query.ListAuthClients == nil { + if e.ComplexityRoot.Query.ListAuthClients == nil { break } @@ -1795,9 +1784,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListAuthClients(childComplexity, args["filter"].(*models.AuthClientListFilter), args["order"].(*models.AuthClientListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListAuthClients(childComplexity, args["filter"].(*models.AuthClientListFilter), args["order"].([]*models.AuthClientListOrder), args["page"].(*models.Page)), true case "Query.listDirectAccessTokens": - if e.complexity.Query.ListDirectAccessTokens == nil { + if e.ComplexityRoot.Query.ListDirectAccessTokens == nil { break } @@ -1806,9 +1795,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListDirectAccessTokens(childComplexity, args["filter"].(*models.DirectAccessTokenListFilter), args["order"].(*models.DirectAccessTokenListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListDirectAccessTokens(childComplexity, args["filter"].(*models.DirectAccessTokenListFilter), args["order"].(*models.DirectAccessTokenListOrder), args["page"].(*models.Page)), true case "Query.listHistory": - if e.complexity.Query.ListHistory == nil { + if e.ComplexityRoot.Query.ListHistory == nil { break } @@ -1817,9 +1806,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListHistory(childComplexity, args["filter"].(*models.HistoryActionListFilter), args["order"].(*models.HistoryActionListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListHistory(childComplexity, args["filter"].(*models.HistoryActionListFilter), args["order"].(*models.HistoryActionListOrder), args["page"].(*models.Page)), true case "Query.listMembers": - if e.complexity.Query.ListMembers == nil { + if e.ComplexityRoot.Query.ListMembers == nil { break } @@ -1828,9 +1817,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListMembers(childComplexity, args["filter"].(*models.MemberListFilter), args["order"].(*models.MemberListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListMembers(childComplexity, args["filter"].(*models.MemberListFilter), args["order"].(*models.MemberListOrder), args["page"].(*models.Page)), true case "Query.listMyPermissions": - if e.complexity.Query.ListMyPermissions == nil { + if e.ComplexityRoot.Query.ListMyPermissions == nil { break } @@ -1839,9 +1828,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListMyPermissions(childComplexity, args["patterns"].([]string)), true + return e.ComplexityRoot.Query.ListMyPermissions(childComplexity, args["patterns"].([]string)), true case "Query.listOptions": - if e.complexity.Query.ListOptions == nil { + if e.ComplexityRoot.Query.ListOptions == nil { break } @@ -1850,9 +1839,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListOptions(childComplexity, args["filter"].(*models.OptionListFilter), args["order"].(*models.OptionListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListOptions(childComplexity, args["filter"].(*models.OptionListFilter), args["order"].(*models.OptionListOrder), args["page"].(*models.Page)), true case "Query.listPermissions": - if e.complexity.Query.ListPermissions == nil { + if e.ComplexityRoot.Query.ListPermissions == nil { break } @@ -1861,9 +1850,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListPermissions(childComplexity, args["patterns"].([]string)), true + return e.ComplexityRoot.Query.ListPermissions(childComplexity, args["patterns"].([]string)), true case "Query.listRoles": - if e.complexity.Query.ListRoles == nil { + if e.ComplexityRoot.Query.ListRoles == nil { break } @@ -1872,9 +1861,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListRoles(childComplexity, args["filter"].(*models.RBACRoleListFilter), args["order"].(*models.RBACRoleListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListRoles(childComplexity, args["filter"].(*models.RBACRoleListFilter), args["order"].(*models.RBACRoleListOrder), args["page"].(*models.Page)), true case "Query.listSocialAccounts": - if e.complexity.Query.ListSocialAccounts == nil { + if e.ComplexityRoot.Query.ListSocialAccounts == nil { break } @@ -1883,9 +1872,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListSocialAccounts(childComplexity, args["filter"].(*models.SocialAccountListFilter), args["order"].(*models.SocialAccountListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListSocialAccounts(childComplexity, args["filter"].(*models.SocialAccountListFilter), args["order"].(*models.SocialAccountListOrder), args["page"].(*models.Page)), true case "Query.listUsers": - if e.complexity.Query.ListUsers == nil { + if e.ComplexityRoot.Query.ListUsers == nil { break } @@ -1894,9 +1883,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.ListUsers(childComplexity, args["filter"].(*models.UserListFilter), args["order"].(*models.UserListOrder), args["page"].(*models.Page)), true + return e.ComplexityRoot.Query.ListUsers(childComplexity, args["filter"].(*models.UserListFilter), args["order"].(*models.UserListOrder), args["page"].(*models.Page)), true case "Query.option": - if e.complexity.Query.Option == nil { + if e.ComplexityRoot.Query.Option == nil { break } @@ -1905,9 +1894,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.Option(childComplexity, args["name"].(string), args["type"].(models.OptionType), args["targetID"].(uint64)), true + return e.ComplexityRoot.Query.Option(childComplexity, args["name"].(string), args["type"].(models.OptionType), args["targetID"].(uint64)), true case "Query.role": - if e.complexity.Query.Role == nil { + if e.ComplexityRoot.Query.Role == nil { break } @@ -1916,15 +1905,15 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.Role(childComplexity, args["id"].(uint64)), true + return e.ComplexityRoot.Query.Role(childComplexity, args["id"].(uint64)), true case "Query.serviceVersion": - if e.complexity.Query.ServiceVersion == nil { + if e.ComplexityRoot.Query.ServiceVersion == nil { break } - return e.complexity.Query.ServiceVersion(childComplexity), true + return e.ComplexityRoot.Query.ServiceVersion(childComplexity), true case "Query.socialAccount": - if e.complexity.Query.SocialAccount == nil { + if e.ComplexityRoot.Query.SocialAccount == nil { break } @@ -1933,9 +1922,9 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.SocialAccount(childComplexity, args["id"].(uint64)), true + return e.ComplexityRoot.Query.SocialAccount(childComplexity, args["id"].(uint64)), true case "Query.user": - if e.complexity.Query.User == nil { + if e.ComplexityRoot.Query.User == nil { break } @@ -1944,509 +1933,509 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return 0, false } - return e.complexity.Query.User(childComplexity, args["id"].(uint64), args["username"].(string)), true + return e.ComplexityRoot.Query.User(childComplexity, args["id"].(uint64), args["username"].(string)), true case "RBACPermission.access": - if e.complexity.RBACPermission.Access == nil { + if e.ComplexityRoot.RBACPermission.Access == nil { break } - return e.complexity.RBACPermission.Access(childComplexity), true + return e.ComplexityRoot.RBACPermission.Access(childComplexity), true case "RBACPermission.description": - if e.complexity.RBACPermission.Description == nil { + if e.ComplexityRoot.RBACPermission.Description == nil { break } - return e.complexity.RBACPermission.Description(childComplexity), true + return e.ComplexityRoot.RBACPermission.Description(childComplexity), true case "RBACPermission.fullname": - if e.complexity.RBACPermission.Fullname == nil { + if e.ComplexityRoot.RBACPermission.Fullname == nil { break } - return e.complexity.RBACPermission.Fullname(childComplexity), true + return e.ComplexityRoot.RBACPermission.Fullname(childComplexity), true case "RBACPermission.name": - if e.complexity.RBACPermission.Name == nil { + if e.ComplexityRoot.RBACPermission.Name == nil { break } - return e.complexity.RBACPermission.Name(childComplexity), true + return e.ComplexityRoot.RBACPermission.Name(childComplexity), true case "RBACPermission.object": - if e.complexity.RBACPermission.Object == nil { + if e.ComplexityRoot.RBACPermission.Object == nil { break } - return e.complexity.RBACPermission.Object(childComplexity), true + return e.ComplexityRoot.RBACPermission.Object(childComplexity), true case "RBACRole.childRoles": - if e.complexity.RBACRole.ChildRoles == nil { + if e.ComplexityRoot.RBACRole.ChildRoles == nil { break } - return e.complexity.RBACRole.ChildRoles(childComplexity), true + return e.ComplexityRoot.RBACRole.ChildRoles(childComplexity), true case "RBACRole.context": - if e.complexity.RBACRole.Context == nil { + if e.ComplexityRoot.RBACRole.Context == nil { break } - return e.complexity.RBACRole.Context(childComplexity), true + return e.ComplexityRoot.RBACRole.Context(childComplexity), true case "RBACRole.createdAt": - if e.complexity.RBACRole.CreatedAt == nil { + if e.ComplexityRoot.RBACRole.CreatedAt == nil { break } - return e.complexity.RBACRole.CreatedAt(childComplexity), true + return e.ComplexityRoot.RBACRole.CreatedAt(childComplexity), true case "RBACRole.deletedAt": - if e.complexity.RBACRole.DeletedAt == nil { + if e.ComplexityRoot.RBACRole.DeletedAt == nil { break } - return e.complexity.RBACRole.DeletedAt(childComplexity), true + return e.ComplexityRoot.RBACRole.DeletedAt(childComplexity), true case "RBACRole.description": - if e.complexity.RBACRole.Description == nil { + if e.ComplexityRoot.RBACRole.Description == nil { break } - return e.complexity.RBACRole.Description(childComplexity), true + return e.ComplexityRoot.RBACRole.Description(childComplexity), true case "RBACRole.ID": - if e.complexity.RBACRole.ID == nil { + if e.ComplexityRoot.RBACRole.ID == nil { break } - return e.complexity.RBACRole.ID(childComplexity), true + return e.ComplexityRoot.RBACRole.ID(childComplexity), true case "RBACRole.name": - if e.complexity.RBACRole.Name == nil { + if e.ComplexityRoot.RBACRole.Name == nil { break } - return e.complexity.RBACRole.Name(childComplexity), true + return e.ComplexityRoot.RBACRole.Name(childComplexity), true case "RBACRole.permissionPatterns": - if e.complexity.RBACRole.PermissionPatterns == nil { + if e.ComplexityRoot.RBACRole.PermissionPatterns == nil { break } - return e.complexity.RBACRole.PermissionPatterns(childComplexity), true + return e.ComplexityRoot.RBACRole.PermissionPatterns(childComplexity), true case "RBACRole.permissions": - if e.complexity.RBACRole.Permissions == nil { + if e.ComplexityRoot.RBACRole.Permissions == nil { break } - return e.complexity.RBACRole.Permissions(childComplexity), true + return e.ComplexityRoot.RBACRole.Permissions(childComplexity), true case "RBACRole.title": - if e.complexity.RBACRole.Title == nil { + if e.ComplexityRoot.RBACRole.Title == nil { break } - return e.complexity.RBACRole.Title(childComplexity), true + return e.ComplexityRoot.RBACRole.Title(childComplexity), true case "RBACRole.updatedAt": - if e.complexity.RBACRole.UpdatedAt == nil { + if e.ComplexityRoot.RBACRole.UpdatedAt == nil { break } - return e.complexity.RBACRole.UpdatedAt(childComplexity), true + return e.ComplexityRoot.RBACRole.UpdatedAt(childComplexity), true case "RBACRoleConnection.edges": - if e.complexity.RBACRoleConnection.Edges == nil { + if e.ComplexityRoot.RBACRoleConnection.Edges == nil { break } - return e.complexity.RBACRoleConnection.Edges(childComplexity), true + return e.ComplexityRoot.RBACRoleConnection.Edges(childComplexity), true case "RBACRoleConnection.list": - if e.complexity.RBACRoleConnection.List == nil { + if e.ComplexityRoot.RBACRoleConnection.List == nil { break } - return e.complexity.RBACRoleConnection.List(childComplexity), true + return e.ComplexityRoot.RBACRoleConnection.List(childComplexity), true case "RBACRoleConnection.pageInfo": - if e.complexity.RBACRoleConnection.PageInfo == nil { + if e.ComplexityRoot.RBACRoleConnection.PageInfo == nil { break } - return e.complexity.RBACRoleConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.RBACRoleConnection.PageInfo(childComplexity), true case "RBACRoleConnection.totalCount": - if e.complexity.RBACRoleConnection.TotalCount == nil { + if e.ComplexityRoot.RBACRoleConnection.TotalCount == nil { break } - return e.complexity.RBACRoleConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.RBACRoleConnection.TotalCount(childComplexity), true case "RBACRoleEdge.cursor": - if e.complexity.RBACRoleEdge.Cursor == nil { + if e.ComplexityRoot.RBACRoleEdge.Cursor == nil { break } - return e.complexity.RBACRoleEdge.Cursor(childComplexity), true + return e.ComplexityRoot.RBACRoleEdge.Cursor(childComplexity), true case "RBACRoleEdge.node": - if e.complexity.RBACRoleEdge.Node == nil { + if e.ComplexityRoot.RBACRoleEdge.Node == nil { break } - return e.complexity.RBACRoleEdge.Node(childComplexity), true + return e.ComplexityRoot.RBACRoleEdge.Node(childComplexity), true case "RBACRolePayload.clientMutationID": - if e.complexity.RBACRolePayload.ClientMutationID == nil { + if e.ComplexityRoot.RBACRolePayload.ClientMutationID == nil { break } - return e.complexity.RBACRolePayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.RBACRolePayload.ClientMutationID(childComplexity), true case "RBACRolePayload.role": - if e.complexity.RBACRolePayload.Role == nil { + if e.ComplexityRoot.RBACRolePayload.Role == nil { break } - return e.complexity.RBACRolePayload.Role(childComplexity), true + return e.ComplexityRoot.RBACRolePayload.Role(childComplexity), true case "RBACRolePayload.roleID": - if e.complexity.RBACRolePayload.RoleID == nil { + if e.ComplexityRoot.RBACRolePayload.RoleID == nil { break } - return e.complexity.RBACRolePayload.RoleID(childComplexity), true + return e.ComplexityRoot.RBACRolePayload.RoleID(childComplexity), true case "SessionToken.expiresAt": - if e.complexity.SessionToken.ExpiresAt == nil { + if e.ComplexityRoot.SessionToken.ExpiresAt == nil { break } - return e.complexity.SessionToken.ExpiresAt(childComplexity), true + return e.ComplexityRoot.SessionToken.ExpiresAt(childComplexity), true case "SessionToken.isAdmin": - if e.complexity.SessionToken.IsAdmin == nil { + if e.ComplexityRoot.SessionToken.IsAdmin == nil { break } - return e.complexity.SessionToken.IsAdmin(childComplexity), true + return e.ComplexityRoot.SessionToken.IsAdmin(childComplexity), true case "SessionToken.roles": - if e.complexity.SessionToken.Roles == nil { + if e.ComplexityRoot.SessionToken.Roles == nil { break } - return e.complexity.SessionToken.Roles(childComplexity), true + return e.ComplexityRoot.SessionToken.Roles(childComplexity), true case "SessionToken.token": - if e.complexity.SessionToken.Token == nil { + if e.ComplexityRoot.SessionToken.Token == nil { break } - return e.complexity.SessionToken.Token(childComplexity), true + return e.ComplexityRoot.SessionToken.Token(childComplexity), true case "SocialAccount.avatar": - if e.complexity.SocialAccount.Avatar == nil { + if e.ComplexityRoot.SocialAccount.Avatar == nil { break } - return e.complexity.SocialAccount.Avatar(childComplexity), true + return e.ComplexityRoot.SocialAccount.Avatar(childComplexity), true case "SocialAccount.createdAt": - if e.complexity.SocialAccount.CreatedAt == nil { + if e.ComplexityRoot.SocialAccount.CreatedAt == nil { break } - return e.complexity.SocialAccount.CreatedAt(childComplexity), true + return e.ComplexityRoot.SocialAccount.CreatedAt(childComplexity), true case "SocialAccount.data": - if e.complexity.SocialAccount.Data == nil { + if e.ComplexityRoot.SocialAccount.Data == nil { break } - return e.complexity.SocialAccount.Data(childComplexity), true + return e.ComplexityRoot.SocialAccount.Data(childComplexity), true case "SocialAccount.deletedAt": - if e.complexity.SocialAccount.DeletedAt == nil { + if e.ComplexityRoot.SocialAccount.DeletedAt == nil { break } - return e.complexity.SocialAccount.DeletedAt(childComplexity), true + return e.ComplexityRoot.SocialAccount.DeletedAt(childComplexity), true case "SocialAccount.email": - if e.complexity.SocialAccount.Email == nil { + if e.ComplexityRoot.SocialAccount.Email == nil { break } - return e.complexity.SocialAccount.Email(childComplexity), true + return e.ComplexityRoot.SocialAccount.Email(childComplexity), true case "SocialAccount.firstName": - if e.complexity.SocialAccount.FirstName == nil { + if e.ComplexityRoot.SocialAccount.FirstName == nil { break } - return e.complexity.SocialAccount.FirstName(childComplexity), true + return e.ComplexityRoot.SocialAccount.FirstName(childComplexity), true case "SocialAccount.ID": - if e.complexity.SocialAccount.ID == nil { + if e.ComplexityRoot.SocialAccount.ID == nil { break } - return e.complexity.SocialAccount.ID(childComplexity), true + return e.ComplexityRoot.SocialAccount.ID(childComplexity), true case "SocialAccount.lastName": - if e.complexity.SocialAccount.LastName == nil { + if e.ComplexityRoot.SocialAccount.LastName == nil { break } - return e.complexity.SocialAccount.LastName(childComplexity), true + return e.ComplexityRoot.SocialAccount.LastName(childComplexity), true case "SocialAccount.link": - if e.complexity.SocialAccount.Link == nil { + if e.ComplexityRoot.SocialAccount.Link == nil { break } - return e.complexity.SocialAccount.Link(childComplexity), true + return e.ComplexityRoot.SocialAccount.Link(childComplexity), true case "SocialAccount.provider": - if e.complexity.SocialAccount.Provider == nil { + if e.ComplexityRoot.SocialAccount.Provider == nil { break } - return e.complexity.SocialAccount.Provider(childComplexity), true + return e.ComplexityRoot.SocialAccount.Provider(childComplexity), true case "SocialAccount.sessions": - if e.complexity.SocialAccount.Sessions == nil { + if e.ComplexityRoot.SocialAccount.Sessions == nil { break } - return e.complexity.SocialAccount.Sessions(childComplexity), true + return e.ComplexityRoot.SocialAccount.Sessions(childComplexity), true case "SocialAccount.socialID": - if e.complexity.SocialAccount.SocialID == nil { + if e.ComplexityRoot.SocialAccount.SocialID == nil { break } - return e.complexity.SocialAccount.SocialID(childComplexity), true + return e.ComplexityRoot.SocialAccount.SocialID(childComplexity), true case "SocialAccount.updatedAt": - if e.complexity.SocialAccount.UpdatedAt == nil { + if e.ComplexityRoot.SocialAccount.UpdatedAt == nil { break } - return e.complexity.SocialAccount.UpdatedAt(childComplexity), true + return e.ComplexityRoot.SocialAccount.UpdatedAt(childComplexity), true case "SocialAccount.userID": - if e.complexity.SocialAccount.UserID == nil { + if e.ComplexityRoot.SocialAccount.UserID == nil { break } - return e.complexity.SocialAccount.UserID(childComplexity), true + return e.ComplexityRoot.SocialAccount.UserID(childComplexity), true case "SocialAccount.username": - if e.complexity.SocialAccount.Username == nil { + if e.ComplexityRoot.SocialAccount.Username == nil { break } - return e.complexity.SocialAccount.Username(childComplexity), true + return e.ComplexityRoot.SocialAccount.Username(childComplexity), true case "SocialAccountConnection.edges": - if e.complexity.SocialAccountConnection.Edges == nil { + if e.ComplexityRoot.SocialAccountConnection.Edges == nil { break } - return e.complexity.SocialAccountConnection.Edges(childComplexity), true + return e.ComplexityRoot.SocialAccountConnection.Edges(childComplexity), true case "SocialAccountConnection.list": - if e.complexity.SocialAccountConnection.List == nil { + if e.ComplexityRoot.SocialAccountConnection.List == nil { break } - return e.complexity.SocialAccountConnection.List(childComplexity), true + return e.ComplexityRoot.SocialAccountConnection.List(childComplexity), true case "SocialAccountConnection.pageInfo": - if e.complexity.SocialAccountConnection.PageInfo == nil { + if e.ComplexityRoot.SocialAccountConnection.PageInfo == nil { break } - return e.complexity.SocialAccountConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.SocialAccountConnection.PageInfo(childComplexity), true case "SocialAccountConnection.totalCount": - if e.complexity.SocialAccountConnection.TotalCount == nil { + if e.ComplexityRoot.SocialAccountConnection.TotalCount == nil { break } - return e.complexity.SocialAccountConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.SocialAccountConnection.TotalCount(childComplexity), true case "SocialAccountEdge.cursor": - if e.complexity.SocialAccountEdge.Cursor == nil { + if e.ComplexityRoot.SocialAccountEdge.Cursor == nil { break } - return e.complexity.SocialAccountEdge.Cursor(childComplexity), true + return e.ComplexityRoot.SocialAccountEdge.Cursor(childComplexity), true case "SocialAccountEdge.node": - if e.complexity.SocialAccountEdge.Node == nil { + if e.ComplexityRoot.SocialAccountEdge.Node == nil { break } - return e.complexity.SocialAccountEdge.Node(childComplexity), true + return e.ComplexityRoot.SocialAccountEdge.Node(childComplexity), true case "SocialAccountPayload.clientMutationID": - if e.complexity.SocialAccountPayload.ClientMutationID == nil { + if e.ComplexityRoot.SocialAccountPayload.ClientMutationID == nil { break } - return e.complexity.SocialAccountPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.SocialAccountPayload.ClientMutationID(childComplexity), true case "SocialAccountPayload.socialAccount": - if e.complexity.SocialAccountPayload.SocialAccount == nil { + if e.ComplexityRoot.SocialAccountPayload.SocialAccount == nil { break } - return e.complexity.SocialAccountPayload.SocialAccount(childComplexity), true + return e.ComplexityRoot.SocialAccountPayload.SocialAccount(childComplexity), true case "SocialAccountPayload.socialAccountID": - if e.complexity.SocialAccountPayload.SocialAccountID == nil { + if e.ComplexityRoot.SocialAccountPayload.SocialAccountID == nil { break } - return e.complexity.SocialAccountPayload.SocialAccountID(childComplexity), true + return e.ComplexityRoot.SocialAccountPayload.SocialAccountID(childComplexity), true case "SocialAccountSession.accessToken": - if e.complexity.SocialAccountSession.AccessToken == nil { + if e.ComplexityRoot.SocialAccountSession.AccessToken == nil { break } - return e.complexity.SocialAccountSession.AccessToken(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.AccessToken(childComplexity), true case "SocialAccountSession.createdAt": - if e.complexity.SocialAccountSession.CreatedAt == nil { + if e.ComplexityRoot.SocialAccountSession.CreatedAt == nil { break } - return e.complexity.SocialAccountSession.CreatedAt(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.CreatedAt(childComplexity), true case "SocialAccountSession.deletedAt": - if e.complexity.SocialAccountSession.DeletedAt == nil { + if e.ComplexityRoot.SocialAccountSession.DeletedAt == nil { break } - return e.complexity.SocialAccountSession.DeletedAt(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.DeletedAt(childComplexity), true case "SocialAccountSession.expiresAt": - if e.complexity.SocialAccountSession.ExpiresAt == nil { + if e.ComplexityRoot.SocialAccountSession.ExpiresAt == nil { break } - return e.complexity.SocialAccountSession.ExpiresAt(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.ExpiresAt(childComplexity), true case "SocialAccountSession.name": - if e.complexity.SocialAccountSession.Name == nil { + if e.ComplexityRoot.SocialAccountSession.Name == nil { break } - return e.complexity.SocialAccountSession.Name(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.Name(childComplexity), true case "SocialAccountSession.refreshToken": - if e.complexity.SocialAccountSession.RefreshToken == nil { + if e.ComplexityRoot.SocialAccountSession.RefreshToken == nil { break } - return e.complexity.SocialAccountSession.RefreshToken(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.RefreshToken(childComplexity), true case "SocialAccountSession.scope": - if e.complexity.SocialAccountSession.Scope == nil { + if e.ComplexityRoot.SocialAccountSession.Scope == nil { break } - return e.complexity.SocialAccountSession.Scope(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.Scope(childComplexity), true case "SocialAccountSession.socialAccountID": - if e.complexity.SocialAccountSession.SocialAccountID == nil { + if e.ComplexityRoot.SocialAccountSession.SocialAccountID == nil { break } - return e.complexity.SocialAccountSession.SocialAccountID(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.SocialAccountID(childComplexity), true case "SocialAccountSession.tokenType": - if e.complexity.SocialAccountSession.TokenType == nil { + if e.ComplexityRoot.SocialAccountSession.TokenType == nil { break } - return e.complexity.SocialAccountSession.TokenType(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.TokenType(childComplexity), true case "SocialAccountSession.updatedAt": - if e.complexity.SocialAccountSession.UpdatedAt == nil { + if e.ComplexityRoot.SocialAccountSession.UpdatedAt == nil { break } - return e.complexity.SocialAccountSession.UpdatedAt(childComplexity), true + return e.ComplexityRoot.SocialAccountSession.UpdatedAt(childComplexity), true case "StatusResponse.clientMutationID": - if e.complexity.StatusResponse.ClientMutationID == nil { + if e.ComplexityRoot.StatusResponse.ClientMutationID == nil { break } - return e.complexity.StatusResponse.ClientMutationID(childComplexity), true + return e.ComplexityRoot.StatusResponse.ClientMutationID(childComplexity), true case "StatusResponse.message": - if e.complexity.StatusResponse.Message == nil { + if e.ComplexityRoot.StatusResponse.Message == nil { break } - return e.complexity.StatusResponse.Message(childComplexity), true + return e.ComplexityRoot.StatusResponse.Message(childComplexity), true case "StatusResponse.status": - if e.complexity.StatusResponse.Status == nil { + if e.ComplexityRoot.StatusResponse.Status == nil { break } - return e.complexity.StatusResponse.Status(childComplexity), true + return e.ComplexityRoot.StatusResponse.Status(childComplexity), true case "User.createdAt": - if e.complexity.User.CreatedAt == nil { + if e.ComplexityRoot.User.CreatedAt == nil { break } - return e.complexity.User.CreatedAt(childComplexity), true + return e.ComplexityRoot.User.CreatedAt(childComplexity), true case "User.ID": - if e.complexity.User.ID == nil { + if e.ComplexityRoot.User.ID == nil { break } - return e.complexity.User.ID(childComplexity), true + return e.ComplexityRoot.User.ID(childComplexity), true case "User.status": - if e.complexity.User.Status == nil { + if e.ComplexityRoot.User.Status == nil { break } - return e.complexity.User.Status(childComplexity), true + return e.ComplexityRoot.User.Status(childComplexity), true case "User.statusMessage": - if e.complexity.User.StatusMessage == nil { + if e.ComplexityRoot.User.StatusMessage == nil { break } - return e.complexity.User.StatusMessage(childComplexity), true + return e.ComplexityRoot.User.StatusMessage(childComplexity), true case "User.updatedAt": - if e.complexity.User.UpdatedAt == nil { + if e.ComplexityRoot.User.UpdatedAt == nil { break } - return e.complexity.User.UpdatedAt(childComplexity), true + return e.ComplexityRoot.User.UpdatedAt(childComplexity), true case "User.username": - if e.complexity.User.Username == nil { + if e.ComplexityRoot.User.Username == nil { break } - return e.complexity.User.Username(childComplexity), true + return e.ComplexityRoot.User.Username(childComplexity), true case "UserConnection.edges": - if e.complexity.UserConnection.Edges == nil { + if e.ComplexityRoot.UserConnection.Edges == nil { break } - return e.complexity.UserConnection.Edges(childComplexity), true + return e.ComplexityRoot.UserConnection.Edges(childComplexity), true case "UserConnection.list": - if e.complexity.UserConnection.List == nil { + if e.ComplexityRoot.UserConnection.List == nil { break } - return e.complexity.UserConnection.List(childComplexity), true + return e.ComplexityRoot.UserConnection.List(childComplexity), true case "UserConnection.pageInfo": - if e.complexity.UserConnection.PageInfo == nil { + if e.ComplexityRoot.UserConnection.PageInfo == nil { break } - return e.complexity.UserConnection.PageInfo(childComplexity), true + return e.ComplexityRoot.UserConnection.PageInfo(childComplexity), true case "UserConnection.totalCount": - if e.complexity.UserConnection.TotalCount == nil { + if e.ComplexityRoot.UserConnection.TotalCount == nil { break } - return e.complexity.UserConnection.TotalCount(childComplexity), true + return e.ComplexityRoot.UserConnection.TotalCount(childComplexity), true case "UserEdge.cursor": - if e.complexity.UserEdge.Cursor == nil { + if e.ComplexityRoot.UserEdge.Cursor == nil { break } - return e.complexity.UserEdge.Cursor(childComplexity), true + return e.ComplexityRoot.UserEdge.Cursor(childComplexity), true case "UserEdge.node": - if e.complexity.UserEdge.Node == nil { + if e.ComplexityRoot.UserEdge.Node == nil { break } - return e.complexity.UserEdge.Node(childComplexity), true + return e.ComplexityRoot.UserEdge.Node(childComplexity), true case "UserPayload.clientMutationID": - if e.complexity.UserPayload.ClientMutationID == nil { + if e.ComplexityRoot.UserPayload.ClientMutationID == nil { break } - return e.complexity.UserPayload.ClientMutationID(childComplexity), true + return e.ComplexityRoot.UserPayload.ClientMutationID(childComplexity), true case "UserPayload.user": - if e.complexity.UserPayload.User == nil { + if e.ComplexityRoot.UserPayload.User == nil { break } - return e.complexity.UserPayload.User(childComplexity), true + return e.ComplexityRoot.UserPayload.User(childComplexity), true case "UserPayload.userID": - if e.complexity.UserPayload.UserID == nil { + if e.ComplexityRoot.UserPayload.UserID == nil { break } - return e.complexity.UserPayload.UserID(childComplexity), true + return e.ComplexityRoot.UserPayload.UserID(childComplexity), true } return 0, false @@ -2454,15 +2443,16 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { opCtx := graphql.GetOperationContext(ctx) - ec := executionContext{opCtx, e, 0, 0, make(chan graphql.DeferredResult)} + ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult)) inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputAccountCreateInput, ec.unmarshalInputAccountInput, ec.unmarshalInputAccountListFilter, ec.unmarshalInputAccountListOrder, - ec.unmarshalInputAuthClientInput, + ec.unmarshalInputAuthClientCreateInput, ec.unmarshalInputAuthClientListFilter, ec.unmarshalInputAuthClientListOrder, + ec.unmarshalInputAuthClientUpdateInput, ec.unmarshalInputDirectAccessTokenListFilter, ec.unmarshalInputDirectAccessTokenListOrder, ec.unmarshalInputHistoryActionListFilter, @@ -2495,9 +2485,9 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) data = ec._Query(ctx, opCtx.Operation.SelectionSet) } else { - if atomic.LoadInt32(&ec.pendingDeferred) > 0 { - result := <-ec.deferredResults - atomic.AddInt32(&ec.pendingDeferred, -1) + if atomic.LoadInt32(&ec.PendingDeferred) > 0 { + result := <-ec.DeferredResults + atomic.AddInt32(&ec.PendingDeferred, -1) data = result.Result response.Path = result.Path response.Label = result.Label @@ -2509,8 +2499,8 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { var buf bytes.Buffer data.MarshalGQL(&buf) response.Data = buf.Bytes() - if atomic.LoadInt32(&ec.deferred) > 0 { - hasNext := atomic.LoadInt32(&ec.pendingDeferred) > 0 + if atomic.LoadInt32(&ec.Deferred) > 0 { + hasNext := atomic.LoadInt32(&ec.PendingDeferred) > 0 response.HasNext = &hasNext } @@ -2538,107 +2528,55 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { } type executionContext struct { - *graphql.OperationContext - *executableSchema - deferred int32 - pendingDeferred int32 - deferredResults chan graphql.DeferredResult -} - -func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { - atomic.AddInt32(&ec.pendingDeferred, 1) - go func() { - ctx := graphql.WithFreshResponseContext(dg.Context) - dg.FieldSet.Dispatch(ctx) - ds := graphql.DeferredResult{ - Path: dg.Path, - Label: dg.Label, - Result: dg.FieldSet, - Errors: graphql.GetErrors(ctx), - } - // null fields should bubble up - if dg.FieldSet.Invalids > 0 { - ds.Result = graphql.Null - } - ec.deferredResults <- ds - }() -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapSchema(ec.Schema()), nil + *graphql.ExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot] } -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") +func newExecutionContext( + opCtx *graphql.OperationContext, + execSchema *executableSchema, + deferredResults chan graphql.DeferredResult, +) executionContext { + return executionContext{ + ExecutionContextState: graphql.NewExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot]( + opCtx, + (*graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot])(execSchema), + parsedSchema, + deferredResults, + ), } - return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } var sources = []*ast.Source{ - {Name: "../../../protocol/graphql/schemas/account_base.graphql", Input: `""" -Account is a company account that can be used to login to the system. + {Name: "../../../protocol/graphql/schemas/account_users.graphql", Input: ` """ -type Account { - """ - The primary key of the Account - """ - ID: ID64! - - """ - Status of Account active - """ - status: ApproveStatus! - - """ - Message which defined during user approve/rejection process - """ - statusMessage: String - - title: String! - description: String! - - """ - logoURI is an URL string that references a logo for the client. - """ - logoURI: String! - +User represents a user object of the system +""" +type User { """ - policyURI is a URL string that points to a human-readable privacy policy document - that describes how the deployment organization collects, uses, - retains, and discloses personal data. + The primary key of the user """ - policyURI: String! + ID: ID64! """ - termsOfServiceURI is a URL string that points to a human-readable terms of service - document for the client that describes a contractual relationship - between the end-user and the client that the end-user accepts when - authorizing the client. + Unical user name """ - termsOfServiceURI: String! + username: String! """ - clientURI is an URL string of a web page providing information about the client. - If present, the server SHOULD display this URL to the end-user in - a clickable fashion. + Status of user active """ - clientURI: String! + status: ApproveStatus! """ - contacts is a array of strings representing ways to contact people responsible - for this client, typically email addresses. + Message which defined during user approve/rejection process """ - contacts: [String!] + statusMessage: String createdAt: Time! updatedAt: Time! } -type AccountEdge { +type UserEdge { """ A cursor for use in pagination. """ @@ -2647,27 +2585,27 @@ type AccountEdge { """ The item at the end of the edge. """ - node: Account + node: User } """ -AccountConnection implements collection accessor interface with pagination. +UserConnection implements collection accessor interface with pagination. """ -type AccountConnection { +type UserConnection { """ The total number of campaigns """ totalCount: Int! """ - The edges for each of the account's lists + The edges for each of the users's lists """ - edges: [AccountEdge!] + edges: [UserEdge!] """ - A list of the accounts, as a convenience when edges are not needed. + A list of the users, as a convenience when edges are not needed. """ - list: [Account!] + list: [User!] """ Information for paginating this connection @@ -2676,583 +2614,703 @@ type AccountConnection { } """ -AccountPayload wrapper to access of Account oprtation results +UserPayload wrapper to access of user oprtation results """ -type AccountPayload { +type UserPayload { """ A unique identifier for the client performing the mutation. """ clientMutationID: String! """ - Account ID operation result + User ID operation result """ - accountID: ID64! + userID: ID64! """ - Account object accessor + User object accessor """ - account: Account + user: User } ############################################################################### # Query ############################################################################### -input AccountListFilter { +""" +UserListFilter implements filter for user list query +""" +input UserListFilter { ID: [ID64!] - UserID: [ID64!] - title: [String!] - status: [ApproveStatus!] + accountID: [ID64!] + emails: [String!] + roles: [ID64!] } -input AccountListOrder { - ID: Ordering - title: Ordering - status: Ordering +""" +UserListOrder implements order for user list query +""" +input UserListOrder { + ID: Ordering + email: Ordering + username: Ordering + status: Ordering + registrationDate: Ordering + country: Ordering + manager: Ordering + createdAt: Ordering + updatedAt: Ordering } ############################################################################### # Mutations ############################################################################### -input AccountInput { +input UserInput { + username: String status: ApproveStatus - title: String - description: String - logoURI: String - policyURI: String - termsOfServiceURI: String - clientURI: String - contacts: [String!] } -input AccountCreateInput { - ownerID: ID64 - owner: UserInput - account: AccountInput! - password: String! -} +type Profile { + ID: ID64! + user: User! + firstName: String! + lastName: String! + companyName: String! + about: String! + email: String! + messgangers: [ProfileMessanger!] -type AccountCreatePayload { - """ - A unique identifier for the client performing the mutation. - """ - clientMutationID: String! + createdAt: Time! + updatedAt: Time! +} - """ - The account object - """ - account: Account! +enum MessangerType { + SKYPE + AIM + ICQ + WHATSAPP + TELEGRAM + VIBER + PHONE +} - """ - The user object - """ - owner: User! +type ProfileMessanger { + mtype: MessangerType! + address: String! } ############################################################################### -# Query declarations +# Query ############################################################################### extend type Query { """ - Current session from the token - """ - currentSession: SessionToken! @hasPermissions(permissions: ["account.view.*"]) - - """ - Current account from the session + Current user from the session """ - currentAccount: AccountPayload! @hasPermissions(permissions: ["account.view.*"]) + currentUser: UserPayload! @hasPermissions(permissions: ["user.view.*"]) """ - Get account object by ID + Get user object by ID or username """ - account(id: ID64!): AccountPayload! @hasPermissions(permissions: ["account.view.*"]) + user( + id: ID64! = 0, + username: String! = "" + ): UserPayload! @hasPermissions(permissions: ["user.view.*"]) """ - List of the account objects which can be filtered and ordered by some fields + List of the user objects which can be filtered and ordered by some fields """ - listAccounts( - filter: AccountListFilter = null, - order: AccountListOrder = null, + listUsers( + filter: UserListFilter = null, + order: UserListOrder = null, page: Page = null - ): AccountConnection @hasPermissions(permissions: ["account.list.*"]) - - """ - List of the account roles/permissions - """ - listAccountRolesAndPermissions(accountID: ID64!, order: RBACRoleListOrder = null): RBACRoleConnection @hasPermissions(permissions: ["account.view.*"]) + ): UserConnection @hasPermissions(permissions: ["user.list.*"]) } extend type Mutation { """ - Login to the system and get the token as JWT session - """ - login(login: String!, password: String!): SessionToken! - - """ - Logout from the system + Create the new user """ - logout: Boolean! + createUser(input: UserInput!): UserPayload! @hasPermissions(permissions: ["user.create.*"]) """ - Switch the account by ID + Update user info """ - switchAccount(id: ID64!): SessionToken! + updateUser(id: ID64!, input: UserInput!): UserPayload! @hasPermissions(permissions: ["user.update.*"]) """ - Register the new account + Approve user and leave the comment """ - registerAccount(input: AccountCreateInput!): AccountCreatePayload! @hasPermissions(permissions: ["account.register"]) + approveUser(id: ID64!, msg: String): UserPayload! @hasPermissions(permissions: ["user.approve.*"]) """ - Update account info + Reject user and leave the comment """ - updateAccount(id: ID64!, input: AccountInput!): AccountPayload! @hasPermissions(permissions: ["account.update.*"]) + rejectUser(id: ID64!, msg: String): UserPayload! @hasPermissions(permissions: ["user.reject.*"]) """ - Approve account and leave the comment + Reset password of the particular user in case if user forgot it """ - approveAccount(id: ID64!, msg: String!): AccountPayload! @hasPermissions(permissions: ["account.approve.*"]) + resetUserPassword(email: String!): StatusResponse! @hasPermissions(permissions: ["user.password.reset.*"]) """ - Reject account and leave the comment + Update password of the particular user """ - rejectAccount(id: ID64!, msg: String!): AccountPayload! @hasPermissions(permissions: ["account.reject.*"]) + updateUserPassword(token: String!, email: String!, password: String!): StatusResponse! @hasPermissions(permissions: ["user.password.reset.*"]) } `, BuiltIn: false}, - {Name: "../../../protocol/graphql/schemas/account_member.graphql", Input: `""" -Account Member represents a member of the account + {Name: "../../../protocol/graphql/schemas/constants.graphql", Input: ` """ -type Member { +The list of statuses that shows is object approved or not +""" +enum ApproveStatus { """ - The primary key of the Member + Pending status of the just inited objects """ - ID: ID64! + PENDING """ - Status of Member active + Approved status of object could be obtained from the some authorized user who have permissions """ - status: ApproveStatus! + APPROVED """ - User object accessor + Rejected status of object could be obtained from the some authorized user who have permissions """ - user: User! + REJECTED +} +""" +The list of statuses that shows is particular object active or paused +""" +enum ActiveStatus { """ - Account object accessor + All object by default have to be paused """ - account: Account! + PAUSED """ - Is the user an admin of the account + Status of the active object """ - isAdmin: Boolean! + ACTIVE +} +""" +The list of statuses that shows is particular object is available +""" +enum AvailableStatus { """ - Roles of the member - """ - roles: [RBACRole!] + All object by default have to be undefined + """ + UNDEFINED - createdAt: Time! - updatedAt: Time! - deletedAt: Time + """ + Status of the available object + """ + AVAILABLE + + """ + Status of the unavailable object + """ + UNAVAILABLE } -type MemberEdge { +""" +Constants of the order of data +""" +enum Ordering { """ - A cursor for use in pagination. + Ascending ordering of data """ - cursor: String! + ASC """ - The item at the end of the edge. + Descending ordering of data """ - node: Member + DESC } -type MemberConnection { +""" +Constants of the response status +""" +enum ResponseStatus { """ - The total number of campaigns + Success status of the response """ - totalCount: Int! + SUCCESS """ - The edges for each of the members's lists + Error status of the response """ - edges: [MemberEdge!] + ERROR +} +`, BuiltIn: false}, + {Name: "../../../protocol/graphql/schemas/directives.graphql", Input: `"Prevents access to a field if the user is not authenticated" +directive @auth on FIELD_DEFINITION | FIELD + +"Prevents access to a field/method if the user doesnt have the matching permissions" +directive @hasPermissions(permissions: [String!]!) on FIELD_DEFINITION | FIELD + +"Prevents access to a field/method if the user doesnt have the matching permissions" +directive @acl(permissions: [String!]!) on FIELD_DEFINITION | FIELD + +"Prevents access to a field/method if the user doesnt have the matching permissions" +directive @skipNoPermissions(permissions: [String!]) on FIELD_DEFINITION | FIELD +"Caches the result of a field/method for a specified time to live (ttl) in seconds" +directive @cacheData( + ttl: Int! + key: String + fields: [String!] +) on FIELD_DEFINITION | FIELD + +# Validation directives + +## @length validates the length of a string or array. +directive @length( + min: Int! + max: Int! = 0 + trim: Boolean! = false + ornil: Boolean! = false +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR + +## @notempty validates that a string or array is not empty. +directive @notempty( + trim: Boolean! = false + ornil: Boolean! = false +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR + +## @regex validates a string against a regular expression. +directive @regex( + pattern: String! + trim: Boolean! = true + ornil: Boolean! = false +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR + +## @range validates that a number is within a specified range. +directive @range( + min: Float! + max: Float! = 0 + ornil: Boolean! = false +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR +`, BuiltIn: false}, + {Name: "../../../protocol/graphql/schemas/pagination.graphql", Input: ` +# @link https://developer.github.com/v4/object/pageinfo/ + +""" +Information for paginating +""" +type PageInfo { """ - A list of the members, as a convenience when edges are not needed. + When paginating backwards, the cursor to continue. """ - list: [Member!] + startCursor: String! """ - Information for paginating this connection + When paginating forwards, the cursor to continue. """ - pageInfo: PageInfo! + endCursor: String! + + """ + When paginating backwards, are there more items? + """ + hasPreviousPage: Boolean! + + """ + When paginating forwards, are there more items? + """ + hasNextPage: Boolean! + + """ + Total number of pages available + """ + total: Int! + + """ + Current page number + """ + page: Int! + + """ + Number of pages + """ + count: Int! } -type MemberPayload { +""" +Information for paginating +""" +input Page { """ - A unique identifier for the client performing the mutation. + Start after the cursor ID """ - clientMutationID: String! + after: String """ - Member ID operation result + Start after some records """ - memberID: ID64! + offset: Int """ - Member object accessor + Page number to start at (0-based), defaults to 0 (0, 1, 2, etc.) """ - member: Member + startPage: Int + + """ + Maximum number of items to return + """ + size: Int } +`, BuiltIn: false}, + {Name: "../../../protocol/graphql/schemas/schema.graphql", Input: `# https://github.com/prisma/graphql-import +# Pagination https://graphql.org/learn/pagination/#pagination-and-edges -############################################################################### -# Query -############################################################################### +scalar Time +scalar TimeDuration +scalar DateTime +scalar Map +scalar JSON +scalar NullableJSON +scalar UUID +scalar ID64 -input MemberListFilter { - ID: [ID64!] - status: [ApproveStatus!] - userID: [ID64!] - accountID: [ID64!] - isAdmin: Boolean +schema { + query: Query + mutation: Mutation } -input MemberListOrder { - ID: Ordering - status: Ordering - userID: Ordering - accountID: Ordering - isAdmin: Ordering - createdAt: Ordering - updatedAt: Ordering +type Query { + serviceVersion: String! } -input InviteMemberInput { +type Mutation { + poke: String! +} +`, BuiltIn: false}, + {Name: "../../../protocol/graphql/schemas/status.graphql", Input: `""" +Simple response type for the API +""" +type StatusResponse { """ - The email of the member to invite + Unique identifier for the client performing the mutation """ - email: String! + clientMutationID: String! """ - The roles to assign to the member + The status of the response """ - roles: [String!]! + status: ResponseStatus! """ - Is the user an admin of the account + The message of the response """ - isAdmin: Boolean! = false + message: String } +`, BuiltIn: false}, + {Name: "../../../repository/account/delivery/graphql/account_base.graphql", Input: `""" +Account is a company account that can be used to login to the system. +""" +type Account { + """ + The primary key of the Account + """ + ID: ID64! -input MemberInput { """ - The roles to assign to the member + Status of Account active """ - roles: [String!]! + status: ApproveStatus! """ - Is the user an admin of the account + Message which defined during user approve/rejection process """ - isAdmin: Boolean! = false -} + statusMessage: String -############################################################################### -# Query declarations -############################################################################### + title: String! + description: String! -extend type Query { - listMembers( - """ - The filter to apply to the list - """ - filter: MemberListFilter = null, + """ + logoURI is an URL string that references a logo for the client. + """ + logoURI: String! - """ - The order to apply to the list - """ - order: MemberListOrder = null, + """ + policyURI is a URL string that points to a human-readable privacy policy document + that describes how the deployment organization collects, uses, + retains, and discloses personal data. + """ + policyURI: String! - """ - The pagination to apply to the list - """ - page: Page = null - ): MemberConnection @acl(permissions: ["account.member.list.*"]) + """ + termsOfServiceURI is a URL string that points to a human-readable terms of service + document for the client that describes a contractual relationship + between the end-user and the client that the end-user accepts when + authorizing the client. + """ + termsOfServiceURI: String! + + """ + clientURI is an URL string of a web page providing information about the client. + If present, the server SHOULD display this URL to the end-user in + a clickable fashion. + """ + clientURI: String! + + """ + contacts is a array of strings representing ways to contact people responsible + for this client, typically email addresses. + """ + contacts: [String!] + + createdAt: Time! + updatedAt: Time! } -extend type Mutation { +type AccountEdge { """ - Invite a new member to the account + A cursor for use in pagination. """ - inviteAccountMember( - """ - The account ID to invite the member to - """ - accountID: ID64!, + cursor: String! - """ - The new member to invite to the account - """ - member: InviteMemberInput! - ): MemberPayload! @acl(permissions: ["account.member.invite.*"]) + """ + The item at the end of the edge. + """ + node: Account +} +""" +AccountConnection implements collection accessor interface with pagination. +""" +type AccountConnection { """ - Update the member data + The total number of campaigns """ - updateAccountMember( - """ - The member ID to update - """ - memberID: ID64!, + totalCount: Int! - """ - The new member data to update - """ - member: MemberInput! - ): MemberPayload! @acl(permissions: ["account.member.update.*"]) + """ + The edges for each of the account's lists + """ + edges: [AccountEdge!] """ - Remove the member from the account + A list of the accounts, as a convenience when edges are not needed. """ - removeAccountMember( - """ - The member ID to remove - """ - memberID: ID64! - ): MemberPayload! @acl(permissions: ["account.member.delete.*"]) + list: [Account!] """ - Approve the member to join the account + Information for paginating this connection """ - approveAccountMember( - """ - The member ID to approve - """ - memberID: ID64! + pageInfo: PageInfo! +} - """ - Reason message for the approval - """ - msg: String! = "" - ): MemberPayload! @acl(permissions: ["account.member.approve.*"]) +""" +AccountPayload wrapper to access of Account oprtation results +""" +type AccountPayload { + """ + A unique identifier for the client performing the mutation. + """ + clientMutationID: String! """ - Reject the member to join the account + Account ID operation result """ - rejectAccountMember( - """ - The member ID to reject - """ - memberID: ID64! + accountID: ID64! - """ - Reason message for the rejection - """ - msg: String! = "" - ): MemberPayload! @acl(permissions: ["account.member.reject.*"]) -} -`, BuiltIn: false}, - {Name: "../../../protocol/graphql/schemas/account_social.graphql", Input: `type SocialAccountSession { """ - The unique name of the session to destinguish between different sessions with different scopes + Account object accessor """ - name: String! - socialAccountID: ID64! + account: Account +} - tokenType: String! - accessToken: String! - refreshToken: String! - scope: [String!] +""" +SessionToken object represents an OAuth 2.0 / JWT session token +""" +type SessionToken { + token: String! + expiresAt: Time! + isAdmin: Boolean! + roles: [String!] +} - createdAt: Time! - updatedAt: Time! - expiresAt: Time - deletedAt: Time +############################################################################### +# Query +############################################################################### + +input AccountListFilter { + ID: [ID64!] + UserID: [ID64!] + title: [String!] + status: [ApproveStatus!] } -type SocialAccount { - ID: ID64! - userID: ID64! +input AccountListOrder { + ID: Ordering + title: Ordering + status: Ordering +} - socialID: String! - provider: String! - email: String! - username: String! +############################################################################### +# Mutations +############################################################################### - firstName: String! - lastName: String! - avatar: String! - link: String! +input AccountInput { + status: ApproveStatus + title: String + description: String + logoURI: String + policyURI: String + termsOfServiceURI: String + clientURI: String + contacts: [String!] +} - data: NullableJSON! +input AccountCreateInput { + ownerID: ID64 + owner: UserInput + account: AccountInput! + password: String! +} +type AccountCreatePayload { """ - Social Account session object accessor + A unique identifier for the client performing the mutation. """ - sessions: [SocialAccountSession!] - - createdAt: Time! - updatedAt: Time! - deletedAt: Time -} + clientMutationID: String! -type SocialAccountEdge { """ - A cursor for use in pagination. + The account object """ - cursor: String! + account: Account! """ - The item at the end of the edge. + The user object """ - node: SocialAccount + owner: User! } -""" -SocialAccountConnection implements collection accessor interface with pagination -""" -type SocialAccountConnection { +############################################################################### +# Query declarations +############################################################################### + +extend type Query { """ - The total number of records + Current session from the token """ - totalCount: Int! + currentSession: SessionToken! @hasPermissions(permissions: ["account.view.*"]) """ - The edges for each of the social account's lists + Current account from the session """ - edges: [SocialAccountEdge!] + currentAccount: AccountPayload! + @hasPermissions(permissions: ["account.view.*"]) """ - A list of the social accounts, as a convenience when edges are not needed. + Get account object by ID """ - list: [SocialAccount!] + account(id: ID64!): AccountPayload! + @hasPermissions(permissions: ["account.view.*"]) """ - Information for paginating this connection + List of the account objects which can be filtered and ordered by some fields """ - pageInfo: PageInfo! -} + listAccounts( + filter: AccountListFilter = null + order: AccountListOrder = null + page: Page = null + ): AccountConnection @hasPermissions(permissions: ["account.list.*"]) -""" -SocialAccountPayload wrapper to access of SocialAccount oprtation results -""" -type SocialAccountPayload { """ - A unique identifier for the client performing the mutation. + List of the account roles/permissions """ - clientMutationID: String! + listAccountRolesAndPermissions( + accountID: ID64! + order: RBACRoleListOrder = null + ): RBACRoleConnection @hasPermissions(permissions: ["account.view.*"]) +} +extend type Mutation { """ - Social Account ID operation result + Login to the system and get the token as JWT session """ - socialAccountID: ID64! + login(login: String!, password: String!): SessionToken! """ - Social Account object accessor + Logout from the system """ - socialAccount: SocialAccount -} - -############################################################################### -# Query -############################################################################### - -input SocialAccountListFilter { - ID: [ID64!] - userID: [ID64!] - provider: [String!] - username: [String!] - email: [String!] -} + logout: Boolean! -input SocialAccountListOrder { - ID: Ordering - userID: Ordering - provider: Ordering - email: Ordering - username: Ordering - firstName: Ordering - lastName: Ordering -} + """ + Switch the account by ID + """ + switchAccount(id: ID64!): SessionToken! -extend type Query { """ - Get a social account by its unique identifier + Register the new account """ - socialAccount( - """ - The unique identifier of the social account - """ - id: ID64! - ): SocialAccountPayload! @hasPermissions(permissions: ["account_social.view.*"]) + registerAccount(input: AccountCreateInput!): AccountCreatePayload! + @hasPermissions(permissions: ["account.register"]) """ - Get the current user's social accounts + Update account info """ - currentSocialAccounts( - filter: SocialAccountListFilter = null, - order: SocialAccountListOrder = null - ): SocialAccountConnection! @hasPermissions(permissions: ["account_social.list.*"]) + updateAccount(id: ID64!, input: AccountInput!): AccountPayload! + @hasPermissions(permissions: ["account.update.*"]) """ - List all social accounts + Approve account and leave the comment """ - listSocialAccounts( - filter: SocialAccountListFilter = null, - order: SocialAccountListOrder = null, - page: Page = null - ): SocialAccountConnection! @hasPermissions(permissions: ["account_social.list.*"]) -} + approveAccount(id: ID64!, msg: String!): AccountPayload! + @hasPermissions(permissions: ["account.approve.*"]) -extend type Mutation { """ - Disconnect a social account + Reject account and leave the comment """ - disconnectSocialAccount( - """ - The unique identifier of the social account to disconnect - """ - id: ID64! - ): SocialAccountPayload! @hasPermissions(permissions: ["account_social.disconnect.*"]) + rejectAccount(id: ID64!, msg: String!): AccountPayload! + @hasPermissions(permissions: ["account.reject.*"]) } `, BuiltIn: false}, - {Name: "../../../protocol/graphql/schemas/account_users.graphql", Input: ` -""" -User represents a user object of the system + {Name: "../../../repository/account/delivery/graphql/account_member.graphql", Input: `""" +Account Member represents a member of the account """ -type User { +type Member { """ - The primary key of the user + The primary key of the Member """ - ID: ID64! + ID: ID64! """ - Unical user name + Status of Member active """ - username: String! + status: ApproveStatus! """ - Status of user active + User object accessor """ - status: ApproveStatus! + user: User! """ - Message which defined during user approve/rejection process + Account object accessor """ - statusMessage: String + account: Account! + + """ + Is the user an admin of the account + """ + isAdmin: Boolean! + + """ + Roles of the member + """ + roles: [RBACRole!] createdAt: Time! updatedAt: Time! + deletedAt: Time } -type UserEdge { +type MemberEdge { """ A cursor for use in pagination. """ @@ -3261,27 +3319,24 @@ type UserEdge { """ The item at the end of the edge. """ - node: User + node: Member } -""" -UserConnection implements collection accessor interface with pagination. -""" -type UserConnection { +type MemberConnection { """ The total number of campaigns """ totalCount: Int! """ - The edges for each of the users's lists + The edges for each of the members's lists """ - edges: [UserEdge!] + edges: [MemberEdge!] """ - A list of the users, as a convenience when edges are not needed. + A list of the members, as a convenience when edges are not needed. """ - list: [User!] + list: [Member!] """ Information for paginating this connection @@ -3289,241 +3344,257 @@ type UserConnection { pageInfo: PageInfo! } -""" -UserPayload wrapper to access of user oprtation results -""" -type UserPayload { +type MemberPayload { """ A unique identifier for the client performing the mutation. """ clientMutationID: String! """ - User ID operation result - """ - userID: ID64! - - """ - User object accessor + Member ID operation result """ - user: User -} - -############################################################################### -# Query -############################################################################### - -""" -UserListFilter implements filter for user list query -""" -input UserListFilter { - ID: [ID64!] - accountID: [ID64!] - emails: [String!] - roles: [ID64!] -} - -""" -UserListOrder implements order for user list query -""" -input UserListOrder { - ID: Ordering - email: Ordering - username: Ordering - status: Ordering - registrationDate: Ordering - country: Ordering - manager: Ordering - createdAt: Ordering - updatedAt: Ordering -} - -############################################################################### -# Mutations -############################################################################### - -input UserInput { - username: String - status: ApproveStatus -} - -type Profile { - ID: ID64! - user: User! - firstName: String! - lastName: String! - companyName: String! - about: String! - email: String! - messgangers: [ProfileMessanger!] - - createdAt: Time! - updatedAt: Time! -} - -enum MessangerType { - SKYPE - AIM - ICQ - WHATSAPP - TELEGRAM - VIBER - PHONE -} - -type ProfileMessanger { - mtype: MessangerType! - address: String! + memberID: ID64! + + """ + Member object accessor + """ + member: Member } ############################################################################### # Query ############################################################################### -extend type Query { +input MemberListFilter { + ID: [ID64!] + status: [ApproveStatus!] + userID: [ID64!] + accountID: [ID64!] + isAdmin: Boolean +} + +input MemberListOrder { + ID: Ordering + status: Ordering + userID: Ordering + accountID: Ordering + isAdmin: Ordering + createdAt: Ordering + updatedAt: Ordering +} + +input InviteMemberInput { """ - Current user from the session + The email of the member to invite """ - currentUser: UserPayload! @hasPermissions(permissions: ["user.view.*"]) + email: String! """ - Get user object by ID or username + The roles to assign to the member """ - user( - id: ID64! = 0, - username: String! = "" - ): UserPayload! @hasPermissions(permissions: ["user.view.*"]) + roles: [String!]! """ - List of the user objects which can be filtered and ordered by some fields + Is the user an admin of the account """ - listUsers( - filter: UserListFilter = null, - order: UserListOrder = null, - page: Page = null - ): UserConnection @hasPermissions(permissions: ["user.list.*"]) + isAdmin: Boolean! = false } -extend type Mutation { +input MemberInput { """ - Create the new user + The roles to assign to the member """ - createUser(input: UserInput!): UserPayload! @hasPermissions(permissions: ["user.create.*"]) + roles: [String!]! """ - Update user info + Is the user an admin of the account """ - updateUser(id: ID64!, input: UserInput!): UserPayload! @hasPermissions(permissions: ["user.update.*"]) + isAdmin: Boolean! = false +} + +############################################################################### +# Query declarations +############################################################################### + +extend type Query { + listMembers( + """ + The filter to apply to the list + """ + filter: MemberListFilter = null, + + """ + The order to apply to the list + """ + order: MemberListOrder = null, + """ + The pagination to apply to the list + """ + page: Page = null + ): MemberConnection @acl(permissions: ["account.member.list.*"]) +} + +extend type Mutation { """ - Approve user and leave the comment + Invite a new member to the account """ - approveUser(id: ID64!, msg: String): UserPayload! @hasPermissions(permissions: ["user.approve.*"]) + inviteAccountMember( + """ + The account ID to invite the member to + """ + accountID: ID64!, + + """ + The new member to invite to the account + """ + member: InviteMemberInput! + ): MemberPayload! @acl(permissions: ["account.member.invite.*"]) """ - Reject user and leave the comment + Update the member data """ - rejectUser(id: ID64!, msg: String): UserPayload! @hasPermissions(permissions: ["user.reject.*"]) + updateAccountMember( + """ + The member ID to update + """ + memberID: ID64!, + + """ + The new member data to update + """ + member: MemberInput! + ): MemberPayload! @acl(permissions: ["account.member.update.*"]) """ - Reset password of the particular user in case if user forgot it + Remove the member from the account """ - resetUserPassword(email: String!): StatusResponse! @hasPermissions(permissions: ["user.password.reset.*"]) + removeAccountMember( + """ + The member ID to remove + """ + memberID: ID64! + ): MemberPayload! @acl(permissions: ["account.member.delete.*"]) """ - Update password of the particular user + Approve the member to join the account """ - updateUserPassword(token: String!, email: String!, password: String!): StatusResponse! @hasPermissions(permissions: ["user.password.reset.*"]) + approveAccountMember( + """ + The member ID to approve + """ + memberID: ID64! + + """ + Reason message for the approval + """ + msg: String! = "" + ): MemberPayload! @acl(permissions: ["account.member.approve.*"]) + + """ + Reject the member to join the account + """ + rejectAccountMember( + """ + The member ID to reject + """ + memberID: ID64! + + """ + Reason message for the rejection + """ + msg: String! = "" + ): MemberPayload! @acl(permissions: ["account.member.reject.*"]) } `, BuiltIn: false}, - {Name: "../../../protocol/graphql/schemas/auth_client.graphql", Input: `""" + {Name: "../../../repository/authclient/delivery/graphql/auth_client.graphql", Input: `""" AuthClient object represents an OAuth 2.0 client """ type AuthClient { """ ClientID is the client ID which represents unique connection indentificator """ - ID: ID! + ID: ID! - # Owner and creator of the auth client - accountID: ID64! - userID: ID64! + # Owner and creator of the auth client + accountID: ID64! + userID: ID64! """ - Title of the AuthClient as himan readable name + Title of the AuthClient as himan readable name """ - title: String! + title: String! """ - Secret is the client's secret. The secret will be included in the create request as cleartext, and then - never again. The secret is stored using BCrypt so it is impossible to recover it. Tell your users - that they need to write the secret down as it will not be made available again. + Secret is the client's secret. The secret will be included in the create request as cleartext, and then + never again. The secret is stored using BCrypt so it is impossible to recover it. Tell your users + that they need to write the secret down as it will not be made available again. """ - secret: String! + secret: String! """ - RedirectURIs is an array of allowed redirect urls for the client, for example http://mydomain/oauth/callback . + RedirectURIs is an array of allowed redirect urls for the client, for example http://mydomain/oauth/callback . """ - redirectURIs: [String!] + redirectURIs: [String!] """ - GrantTypes is an array of grant types the client is allowed to use. + GrantTypes is an array of grant types the client is allowed to use. - Pattern: client_credentials|authorization_code|implicit|refresh_token + Pattern: client_credentials|authorization_code|implicit|refresh_token """ - grantTypes: [String!] + grantTypes: [String!] """ - ResponseTypes is an array of the OAuth 2.0 response type strings that the client can - use at the authorization endpoint. - - Pattern: id_token|code|token + ResponseTypes is an array of the OAuth 2.0 response type strings that the client can + use at the authorization endpoint. + + Pattern: id_token|code|token """ - responseTypes: [String!] + responseTypes: [String!] """ - Scope is a string containing a space-separated list of scope values (as - described in Section 3.3 of OAuth 2.0 [RFC6749]) that the client - can use when requesting access tokens. - - Pattern: ([a-zA-Z0-9\.\*]+\s?)+ + Scope is a string containing a space-separated list of scope values (as + described in Section 3.3 of OAuth 2.0 [RFC6749]) that the client + can use when requesting access tokens. + + Pattern: ([a-zA-Z0-9\.\*]+\s?)+ """ - scope: String! + scope: String! """ - Audience is a whitelist defining the audiences this client is allowed to request tokens for. An audience limits - the applicability of an OAuth 2.0 Access Token to, for example, certain API endpoints. The value is a list - of URLs. URLs MUST NOT contain whitespaces. + Audience is a whitelist defining the audiences this client is allowed to request tokens for. An audience limits + the applicability of an OAuth 2.0 Access Token to, for example, certain API endpoints. The value is a list + of URLs. URLs MUST NOT contain whitespaces. """ - audience: [String!] + audience: [String!] """ - SubjectType requested for responses to this Client. The subject_types_supported Discovery parameter contains a - list of the supported subject_type values for this server. Valid types include ` + "`" + `pairwise` + "`" + ` and ` + "`" + `public` + "`" + `. + SubjectType requested for responses to this Client. The subject_types_supported Discovery parameter contains a + list of the supported subject_type values for this server. Valid types include ` + "`" + `pairwise` + "`" + ` and ` + "`" + `public` + "`" + `. """ - subjectType: String! + subjectType: String! """ - AllowedCORSOrigins are one or more URLs (scheme://host[:port]) which are allowed to make CORS requests - to the /oauth/token endpoint. If this array is empty, the sever's CORS origin configuration (` + "`" + `CORS_ALLOWED_ORIGINS` + "`" + `) - will be used instead. If this array is set, the allowed origins are appended to the server's CORS origin configuration. - Be aware that environment variable ` + "`" + `CORS_ENABLED` + "`" + ` MUST be set to ` + "`" + `true` + "`" + ` for this to work. + AllowedCORSOrigins are one or more URLs (scheme://host[:port]) which are allowed to make CORS requests + to the /oauth/token endpoint. If this array is empty, the sever's CORS origin configuration (` + "`" + `CORS_ALLOWED_ORIGINS` + "`" + `) + will be used instead. If this array is set, the allowed origins are appended to the server's CORS origin configuration. + Be aware that environment variable ` + "`" + `CORS_ENABLED` + "`" + ` MUST be set to ` + "`" + `true` + "`" + ` for this to work. """ - allowedCORSOrigins: [String!] + allowedCORSOrigins: [String!] """ - Public flag tells that the client is public + Public flag tells that the client is public """ - public: Boolean! + public: Boolean! """ - ExpiresAt contins the time of expiration of the client + ExpiresAt contins the time of expiration of the client """ - expiresAt: Time! + expiresAt: Time! createdAt: Time! updatedAt: Time! - deletedAt: Time + deletedAt: Time } type AuthClientEdge { @@ -3583,16 +3654,6 @@ type AuthClientPayload { authClient: AuthClient } -""" -SessionToken object represents an OAuth 2.0 / JWT session token -""" -type SessionToken { - token: String! - expiresAt: Time! - isAdmin: Boolean! - roles: [String!] -} - ############################################################################### # Query ############################################################################### @@ -3605,158 +3666,204 @@ input AuthClientListFilter { } input AuthClientListOrder { - ID: Ordering - userID: Ordering - accountID: Ordering - title: Ordering - public: Ordering - lastUpdate: Ordering + ID: Ordering + userID: Ordering + accountID: Ordering + title: Ordering + public: Ordering + lastUpdate: Ordering } ############################################################################### # Mutations ############################################################################### -input AuthClientInput { - accountID: ID64 - userID: ID64 - title: String - secret: String - redirectURIs: [String!] - grantTypes: [String!] - responseTypes: [String!] - scope: String - audience: [String!] - subjectType: String! - allowedCORSOrigins: [String!] - public: Boolean - expiresAt: Time -} - ############################################################################### -# Query and Mutations +# Input Types ############################################################################### -extend type Query { +""" +AuthClientCreateInput is used to create a new OAuth 2.0 client +""" +input AuthClientCreateInput { """ - Get auth client object by ID + AccountID of the auth client owner """ - authClient(id: ID!): AuthClientPayload! @hasPermissions(permissions: ["auth_client.view.*"]) + accountID: ID64 @notempty """ - List of the auth client objects which can be filtered and ordered by some fields + UserID of the auth client creator """ - listAuthClients( - filter: AuthClientListFilter = null, - order: AuthClientListOrder = null, - page: Page = null - ): AuthClientConnection @hasPermissions(permissions: ["auth_client.list.*"]) -} + userID: ID64 @notempty -extend type Mutation { """ - Create the new auth client + Title of the auth client as human readable name """ - createAuthClient(input: AuthClientInput!): AuthClientPayload! @hasPermissions(permissions: ["auth_client.create.*"]) + title: String @notempty(trim: true) """ - Update auth client info + Secret for the OAuth 2.0 client """ - updateAuthClient(id: ID!, input: AuthClientInput!): AuthClientPayload! @hasPermissions(permissions: ["auth_client.update.*"]) + secret: String @notempty(trim: true) """ - Delete auth client + RedirectURIs allowed for this client """ - deleteAuthClient(id: ID!, msg: String = null): AuthClientPayload! @hasPermissions(permissions: ["auth_client.delete.*"]) -} -`, BuiltIn: false}, - {Name: "../../../protocol/graphql/schemas/constants.graphql", Input: ` -""" -The list of statuses that shows is object approved or not -""" -enum ApproveStatus { + redirectURIs: [String!] + """ - Pending status of the just inited objects + GrantTypes allowed for this client """ - PENDING + grantTypes: [String!] """ - Approved status of object could be obtained from the some authorized user who have permissions + ResponseTypes allowed for this client """ - APPROVED + responseTypes: [String!] """ - Rejected status of object could be obtained from the some authorized user who have permissions + Scope string for the client """ - REJECTED -} + scope: String -""" -The list of statuses that shows is particular object active or paused -""" -enum ActiveStatus { """ - All object by default have to be paused + Audience whitelist for token requests """ - PAUSED + audience: [String!] """ - Status of the active object + SubjectType for responses to this client """ - ACTIVE + subjectType: String! + + """ + AllowedCORSOrigins for this client + """ + allowedCORSOrigins: [String!] + + """ + Public flag for the client + """ + public: Boolean + + """ + ExpiresAt time for the client + """ + expiresAt: Time } """ -The list of statuses that shows is particular object is available +AuthClientUpdateInput is used to update an existing OAuth 2.0 client """ -enum AvailableStatus { +input AuthClientUpdateInput { """ - All object by default have to be undefined + AccountID of the auth client owner """ - UNDEFINED + accountID: ID64 @notempty(ornil: true) """ - Status of the available object + UserID of the auth client creator """ - AVAILABLE + userID: ID64 @notempty(ornil: true) + + """ + Title of the auth client as human readable name + """ + title: String @notempty(trim: true, ornil: true) + + """ + Secret for the OAuth 2.0 client + """ + secret: String @notempty(trim: true, ornil: true) + + """ + RedirectURIs allowed for this client + """ + redirectURIs: [String!] @notempty(ornil: true) + + """ + GrantTypes allowed for this client + """ + grantTypes: [String!] @notempty(ornil: true) + + """ + ResponseTypes allowed for this client + """ + responseTypes: [String!] @notempty(ornil: true) + + """ + Scope string for the client + """ + scope: String @notempty(trim: true, ornil: true) + + """ + Audience whitelist for token requests + """ + audience: [String!] @notempty(ornil: true) + + """ + SubjectType for responses to this client + """ + subjectType: String @notempty(trim: true, ornil: true) + + """ + AllowedCORSOrigins for this client + """ + allowedCORSOrigins: [String!] @notempty(ornil: true) + + """ + Public flag for the client + """ + public: Boolean """ - Status of the unavailable object + ExpiresAt time for the client """ - UNAVAILABLE + expiresAt: Time @notempty(ornil: true) } -""" -Constants of the order of data -""" -enum Ordering { +############################################################################### +# Query and Mutations +############################################################################### + +extend type Query { """ - Ascending ordering of data + Get auth client object by ID """ - ASC + authClient(id: ID!): AuthClientPayload! + @hasPermissions(permissions: ["auth_client.view.*"]) """ - Descending ordering of data + List of the auth client objects which can be filtered and ordered by some fields """ - DESC + listAuthClients( + filter: AuthClientListFilter = null + order: [AuthClientListOrder] = null + page: Page = null + ): AuthClientConnection @hasPermissions(permissions: ["auth_client.list.*"]) } -""" -Constants of the response status -""" -enum ResponseStatus { +extend type Mutation { """ - Success status of the response + Create the new auth client """ - SUCCESS + createAuthClient(input: AuthClientCreateInput!): AuthClientPayload! + @hasPermissions(permissions: ["auth_client.create.*"]) """ - Error status of the response + Update auth client info """ - ERROR + updateAuthClient(id: ID!, input: AuthClientUpdateInput!): AuthClientPayload! + @hasPermissions(permissions: ["auth_client.update.*"]) + + """ + Delete auth client + """ + deleteAuthClient(id: ID!, msg: String = null): AuthClientPayload! + @hasPermissions(permissions: ["auth_client.delete.*"]) } `, BuiltIn: false}, - {Name: "../../../protocol/graphql/schemas/directaccesstoken.graphql", Input: `type DirectAccessToken { + {Name: "../../../repository/directaccesstoken/delivery/graphql/directaccesstoken.graphql", Input: `type DirectAccessToken { ID: ID64! token: String! description: String! @@ -3883,26 +3990,7 @@ extend type Mutation { ): StatusResponse @hasPermissions(permissions: ["directaccesstoken.delete.*"]) } `, BuiltIn: false}, - {Name: "../../../protocol/graphql/schemas/directives.graphql", Input: `"Prevents access to a field if the user is not authenticated" -directive @auth on FIELD_DEFINITION | FIELD - -"Prevents access to a field/method if the user doesnt have the matching permissions" -directive @hasPermissions(permissions: [String!]!) on FIELD_DEFINITION | FIELD - -"Prevents access to a field/method if the user doesnt have the matching permissions" -directive @acl(permissions: [String!]!) on FIELD_DEFINITION | FIELD - -"Prevents access to a field/method if the user doesnt have the matching permissions" -directive @skipNoPermissions(permissions: [String!]) on FIELD_DEFINITION | FIELD - -"Caches the result of a field/method for a specified time to live (ttl) in seconds" -directive @cacheData( - ttl: Int! - key: String - fields: [String!] -) on FIELD_DEFINITION | FIELD -`, BuiltIn: false}, - {Name: "../../../protocol/graphql/schemas/history.graphql", Input: `""" + {Name: "../../../repository/historylog/delivery/graphql/history.graphql", Input: `""" HistoryAction is the model for history actions. """ type HistoryAction { @@ -4056,7 +4144,7 @@ extend type Query { ): HistoryActionConnection @hasPermissions(permissions: ["history_log.list.*"]) } `, BuiltIn: false}, - {Name: "../../../protocol/graphql/schemas/options.graphql", Input: `enum OptionType { + {Name: "../../../repository/option/delivery/graphql/options.graphql", Input: `enum OptionType { UNDEFINED, USER, ACCOUNT, @@ -4168,75 +4256,7 @@ extend type Mutation { setOption(name: String!, value: NullableJSON, type: OptionType! = USER, targetID: ID64! = 0): OptionPayload! @hasPermissions(permissions: ["option.set.*"]) } `, BuiltIn: false}, - {Name: "../../../protocol/graphql/schemas/pagination.graphql", Input: ` -# @link https://developer.github.com/v4/object/pageinfo/ - -""" -Information for paginating -""" -type PageInfo { - """ - When paginating backwards, the cursor to continue. - """ - startCursor: String! - - """ - When paginating forwards, the cursor to continue. - """ - endCursor: String! - - """ - When paginating backwards, are there more items? - """ - hasPreviousPage: Boolean! - - """ - When paginating forwards, are there more items? - """ - hasNextPage: Boolean! - - """ - Total number of pages available - """ - total: Int! - - """ - Current page number - """ - page: Int! - - """ - Number of pages - """ - count: Int! -} - -""" -Information for paginating -""" -input Page { - """ - Start after the cursor ID - """ - after: String - - """ - Start after some records - """ - offset: Int - - """ - Page number to start at (0-based), defaults to 0 (0, 1, 2, etc.) - """ - startPage: Int - - """ - Maximum number of items to return - """ - size: Int -} -`, BuiltIn: false}, - {Name: "../../../protocol/graphql/schemas/rbac.graphql", Input: `type RBACPermission { + {Name: "../../../repository/rbac/delivery/graphql/rbac.graphql", Input: `type RBACPermission { name: String! object: String! access: String! @@ -4415,49 +4435,168 @@ extend type Mutation { deleteRole(id: ID64!, msg: String = null): RBACRolePayload! @hasPermissions(permissions: ["role.delete.*"]) } `, BuiltIn: false}, - {Name: "../../../protocol/graphql/schemas/schema.graphql", Input: `# https://github.com/prisma/graphql-import -# Pagination https://graphql.org/learn/pagination/#pagination-and-edges + {Name: "../../../repository/socialaccount/delivery/graphql/account_social.graphql", Input: `type SocialAccountSession { + """ + The unique name of the session to destinguish between different sessions with different scopes + """ + name: String! + socialAccountID: ID64! -scalar Time -scalar TimeDuration -scalar DateTime -scalar Map -scalar JSON -scalar NullableJSON -scalar UUID -scalar ID64 + tokenType: String! + accessToken: String! + refreshToken: String! + scope: [String!] -schema { - query: Query - mutation: Mutation + createdAt: Time! + updatedAt: Time! + expiresAt: Time + deletedAt: Time } -type Query { - serviceVersion: String! +type SocialAccount { + ID: ID64! + userID: ID64! + + socialID: String! + provider: String! + email: String! + username: String! + + firstName: String! + lastName: String! + avatar: String! + link: String! + + data: NullableJSON! + + """ + Social Account session object accessor + """ + sessions: [SocialAccountSession!] + + createdAt: Time! + updatedAt: Time! + deletedAt: Time +} + +type SocialAccountEdge { + """ + A cursor for use in pagination. + """ + cursor: String! + + """ + The item at the end of the edge. + """ + node: SocialAccount +} + +""" +SocialAccountConnection implements collection accessor interface with pagination +""" +type SocialAccountConnection { + """ + The total number of records + """ + totalCount: Int! + + """ + The edges for each of the social account's lists + """ + edges: [SocialAccountEdge!] + + """ + A list of the social accounts, as a convenience when edges are not needed. + """ + list: [SocialAccount!] + + """ + Information for paginating this connection + """ + pageInfo: PageInfo! +} + +""" +SocialAccountPayload wrapper to access of SocialAccount oprtation results +""" +type SocialAccountPayload { + """ + A unique identifier for the client performing the mutation. + """ + clientMutationID: String! + + """ + Social Account ID operation result + """ + socialAccountID: ID64! + + """ + Social Account object accessor + """ + socialAccount: SocialAccount +} + +############################################################################### +# Query +############################################################################### + +input SocialAccountListFilter { + ID: [ID64!] + userID: [ID64!] + provider: [String!] + username: [String!] + email: [String!] +} + +input SocialAccountListOrder { + ID: Ordering + userID: Ordering + provider: Ordering + email: Ordering + username: Ordering + firstName: Ordering + lastName: Ordering } -type Mutation { - poke: String! -} -`, BuiltIn: false}, - {Name: "../../../protocol/graphql/schemas/status.graphql", Input: `""" -Simple response type for the API -""" -type StatusResponse { +extend type Query { + """ + Get a social account by its unique identifier + """ + socialAccount( + """ + The unique identifier of the social account + """ + id: ID64! + ): SocialAccountPayload! @hasPermissions(permissions: ["account_social.view.*"]) + """ - Unique identifier for the client performing the mutation + Get the current user's social accounts """ - clientMutationID: String! + currentSocialAccounts( + filter: SocialAccountListFilter = null, + order: SocialAccountListOrder = null + ): SocialAccountConnection! @hasPermissions(permissions: ["account_social.list.*"]) """ - The status of the response + List all social accounts """ - status: ResponseStatus! + listSocialAccounts( + filter: SocialAccountListFilter = null, + order: SocialAccountListOrder = null, + page: Page = null + ): SocialAccountConnection! @hasPermissions(permissions: ["account_social.list.*"]) +} +extend type Mutation { """ - The message of the response + Disconnect a social account """ - message: String + disconnectSocialAccount( + """ + The unique identifier of the social account to disconnect + """ + id: ID64! + ): SocialAccountPayload! @hasPermissions(permissions: ["account_social.disconnect.*"]) } `, BuiltIn: false}, } @@ -4510,6 +4649,90 @@ func (ec *executionContext) dir_hasPermissions_args(ctx context.Context, rawArgs return args, nil } +func (ec *executionContext) dir_length_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "min", ec.unmarshalNInt2int) + if err != nil { + return nil, err + } + args["min"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "max", ec.unmarshalNInt2int) + if err != nil { + return nil, err + } + args["max"] = arg1 + arg2, err := graphql.ProcessArgField(ctx, rawArgs, "trim", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["trim"] = arg2 + arg3, err := graphql.ProcessArgField(ctx, rawArgs, "ornil", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["ornil"] = arg3 + return args, nil +} + +func (ec *executionContext) dir_notempty_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "trim", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["trim"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "ornil", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["ornil"] = arg1 + return args, nil +} + +func (ec *executionContext) dir_range_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "min", ec.unmarshalNFloat2float64) + if err != nil { + return nil, err + } + args["min"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "max", ec.unmarshalNFloat2float64) + if err != nil { + return nil, err + } + args["max"] = arg1 + arg2, err := graphql.ProcessArgField(ctx, rawArgs, "ornil", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["ornil"] = arg2 + return args, nil +} + +func (ec *executionContext) dir_regex_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "pattern", ec.unmarshalNString2string) + if err != nil { + return nil, err + } + args["pattern"] = arg0 + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "trim", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["trim"] = arg1 + arg2, err := graphql.ProcessArgField(ctx, rawArgs, "ornil", ec.unmarshalNBoolean2bool) + if err != nil { + return nil, err + } + args["ornil"] = arg2 + return args, nil +} + func (ec *executionContext) dir_skipNoPermissions_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -4572,7 +4795,7 @@ func (ec *executionContext) field_Mutation_approveUser_args(ctx context.Context, func (ec *executionContext) field_Mutation_createAuthClient_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNAuthClientInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientInput) + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNAuthClientCreateInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientCreateInput) if err != nil { return nil, err } @@ -4867,7 +5090,7 @@ func (ec *executionContext) field_Mutation_updateAuthClient_args(ctx context.Con return nil, err } args["id"] = arg0 - arg1, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNAuthClientInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientInput) + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNAuthClientUpdateInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientUpdateInput) if err != nil { return nil, err } @@ -5059,7 +5282,7 @@ func (ec *executionContext) field_Query_listAuthClients_args(ctx context.Context return nil, err } args["filter"] = arg0 - arg1, err := graphql.ProcessArgField(ctx, rawArgs, "order", ec.unmarshalOAuthClientListOrder2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientListOrder) + arg1, err := graphql.ProcessArgField(ctx, rawArgs, "order", ec.unmarshalOAuthClientListOrder2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientListOrder) if err != nil { return nil, err } @@ -5361,18 +5584,18 @@ func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj any, next } n := next next = func(ctx context.Context) (any, error) { - if ec.directives.Acl == nil { + if ec.Directives.Acl == nil { return nil, errors.New("directive acl is not implemented") } - return ec.directives.Acl(ctx, obj, n, args["permissions"].([]string)) + return ec.Directives.Acl(ctx, obj, n, args["permissions"].([]string)) } case "auth": n := next next = func(ctx context.Context) (any, error) { - if ec.directives.Auth == nil { + if ec.Directives.Auth == nil { return nil, errors.New("directive auth is not implemented") } - return ec.directives.Auth(ctx, obj, n) + return ec.Directives.Auth(ctx, obj, n) } case "cacheData": rawArgs := d.ArgumentMap(ec.Variables) @@ -5383,10 +5606,10 @@ func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj any, next } n := next next = func(ctx context.Context) (any, error) { - if ec.directives.CacheData == nil { + if ec.Directives.CacheData == nil { return nil, errors.New("directive cacheData is not implemented") } - return ec.directives.CacheData(ctx, obj, n, args["ttl"].(int), args["key"].(*string), args["fields"].([]string)) + return ec.Directives.CacheData(ctx, obj, n, args["ttl"].(int), args["key"].(*string), args["fields"].([]string)) } case "hasPermissions": rawArgs := d.ArgumentMap(ec.Variables) @@ -5397,10 +5620,10 @@ func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj any, next } n := next next = func(ctx context.Context) (any, error) { - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { return nil, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, obj, n, args["permissions"].([]string)) + return ec.Directives.HasPermissions(ctx, obj, n, args["permissions"].([]string)) } case "skipNoPermissions": rawArgs := d.ArgumentMap(ec.Variables) @@ -5411,10 +5634,10 @@ func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj any, next } n := next next = func(ctx context.Context) (any, error) { - if ec.directives.SkipNoPermissions == nil { + if ec.Directives.SkipNoPermissions == nil { return nil, errors.New("directive skipNoPermissions is not implemented") } - return ec.directives.SkipNoPermissions(ctx, obj, n, args["permissions"].([]string)) + return ec.Directives.SkipNoPermissions(ctx, obj, n, args["permissions"].([]string)) } } } @@ -9205,7 +9428,7 @@ func (ec *executionContext) _Mutation_poke(ctx context.Context, field graphql.Co field, ec.fieldContext_Mutation_poke, func(ctx context.Context) (any, error) { - return ec.resolvers.Mutation().Poke(ctx) + return ec.Resolvers.Mutation().Poke(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) @@ -9229,26 +9452,42 @@ func (ec *executionContext) fieldContext_Mutation_poke(_ context.Context, field return fc, nil } -func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_createUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_login, + ec.fieldContext_Mutation_createUser, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().Login(ctx, fc.Args["login"].(string), fc.Args["password"].(string)) + return ec.Resolvers.Mutation().CreateUser(ctx, fc.Args["input"].(models.UserInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.create.*"}) + if err != nil { + var zeroVal *models.UserPayload + return zeroVal, err + } + if ec.Directives.HasPermissions == nil { + var zeroVal *models.UserPayload + return zeroVal, errors.New("directive hasPermissions is not implemented") + } + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) + } + + next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNSessionToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSessionToken, + ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9256,16 +9495,14 @@ func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, fie IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "token": - return ec.fieldContext_SessionToken_token(ctx, field) - case "expiresAt": - return ec.fieldContext_SessionToken_expiresAt(ctx, field) - case "isAdmin": - return ec.fieldContext_SessionToken_isAdmin(ctx, field) - case "roles": - return ec.fieldContext_SessionToken_roles(ctx, field) + case "clientMutationID": + return ec.fieldContext_UserPayload_clientMutationID(ctx, field) + case "userID": + return ec.fieldContext_UserPayload_userID(ctx, field) + case "user": + return ec.fieldContext_UserPayload_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SessionToken", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) }, } defer func() { @@ -9275,64 +9512,49 @@ func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, fie } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_login_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_logout, + ec.fieldContext_Mutation_updateUser, func(ctx context.Context) (any, error) { - return ec.resolvers.Mutation().Logout(ctx) + fc := graphql.GetFieldContext(ctx) + return ec.Resolvers.Mutation().UpdateUser(ctx, fc.Args["id"].(uint64), fc.Args["input"].(models.UserInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - return ec._fieldMiddleware(ctx, nil, next) - }, - ec.marshalNBoolean2bool, - true, - true, - ) -} + directive0 := next -func (ec *executionContext) fieldContext_Mutation_logout(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} + directive1 := func(ctx context.Context) (any, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.update.*"}) + if err != nil { + var zeroVal *models.UserPayload + return zeroVal, err + } + if ec.Directives.HasPermissions == nil { + var zeroVal *models.UserPayload + return zeroVal, errors.New("directive hasPermissions is not implemented") + } + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) + } -func (ec *executionContext) _Mutation_switchAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Mutation_switchAccount, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().SwitchAccount(ctx, fc.Args["id"].(uint64)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNSessionToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSessionToken, + ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_switchAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9340,16 +9562,14 @@ func (ec *executionContext) fieldContext_Mutation_switchAccount(ctx context.Cont IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "token": - return ec.fieldContext_SessionToken_token(ctx, field) - case "expiresAt": - return ec.fieldContext_SessionToken_expiresAt(ctx, field) - case "isAdmin": - return ec.fieldContext_SessionToken_isAdmin(ctx, field) - case "roles": - return ec.fieldContext_SessionToken_roles(ctx, field) + case "clientMutationID": + return ec.fieldContext_UserPayload_clientMutationID(ctx, field) + case "userID": + return ec.fieldContext_UserPayload_userID(ctx, field) + case "user": + return ec.fieldContext_UserPayload_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SessionToken", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) }, } defer func() { @@ -9359,49 +9579,49 @@ func (ec *executionContext) fieldContext_Mutation_switchAccount(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_switchAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_registerAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_approveUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_registerAccount, + ec.fieldContext_Mutation_approveUser, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().RegisterAccount(ctx, fc.Args["input"].(models.AccountCreateInput)) + return ec.Resolvers.Mutation().ApproveUser(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.register"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.approve.*"}) if err != nil { - var zeroVal *models.AccountCreatePayload + var zeroVal *models.UserPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.AccountCreatePayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.UserPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNAccountCreatePayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountCreatePayload, + ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_registerAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_approveUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9410,13 +9630,13 @@ func (ec *executionContext) fieldContext_Mutation_registerAccount(ctx context.Co Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_AccountCreatePayload_clientMutationID(ctx, field) - case "account": - return ec.fieldContext_AccountCreatePayload_account(ctx, field) - case "owner": - return ec.fieldContext_AccountCreatePayload_owner(ctx, field) + return ec.fieldContext_UserPayload_clientMutationID(ctx, field) + case "userID": + return ec.fieldContext_UserPayload_userID(ctx, field) + case "user": + return ec.fieldContext_UserPayload_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AccountCreatePayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) }, } defer func() { @@ -9426,49 +9646,49 @@ func (ec *executionContext) fieldContext_Mutation_registerAccount(ctx context.Co } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_registerAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_approveUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_rejectUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_updateAccount, + ec.fieldContext_Mutation_rejectUser, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().UpdateAccount(ctx, fc.Args["id"].(uint64), fc.Args["input"].(models.AccountInput)) + return ec.Resolvers.Mutation().RejectUser(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.update.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.reject.*"}) if err != nil { - var zeroVal *models.AccountPayload + var zeroVal *models.UserPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.AccountPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.UserPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, + ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_updateAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_rejectUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9477,13 +9697,13 @@ func (ec *executionContext) fieldContext_Mutation_updateAccount(ctx context.Cont Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) - case "accountID": - return ec.fieldContext_AccountPayload_accountID(ctx, field) - case "account": - return ec.fieldContext_AccountPayload_account(ctx, field) + return ec.fieldContext_UserPayload_clientMutationID(ctx, field) + case "userID": + return ec.fieldContext_UserPayload_userID(ctx, field) + case "user": + return ec.fieldContext_UserPayload_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) }, } defer func() { @@ -9493,49 +9713,49 @@ func (ec *executionContext) fieldContext_Mutation_updateAccount(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_rejectUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_approveAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_resetUserPassword(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_approveAccount, + ec.fieldContext_Mutation_resetUserPassword, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().ApproveAccount(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(string)) + return ec.Resolvers.Mutation().ResetUserPassword(ctx, fc.Args["email"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.approve.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.password.reset.*"}) if err != nil { - var zeroVal *models.AccountPayload + var zeroVal *models.StatusResponse return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.AccountPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.StatusResponse return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, + ec.marshalNStatusResponse2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐStatusResponse, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_approveAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_resetUserPassword(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9544,13 +9764,13 @@ func (ec *executionContext) fieldContext_Mutation_approveAccount(ctx context.Con Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) - case "accountID": - return ec.fieldContext_AccountPayload_accountID(ctx, field) - case "account": - return ec.fieldContext_AccountPayload_account(ctx, field) + return ec.fieldContext_StatusResponse_clientMutationID(ctx, field) + case "status": + return ec.fieldContext_StatusResponse_status(ctx, field) + case "message": + return ec.fieldContext_StatusResponse_message(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type StatusResponse", field.Name) }, } defer func() { @@ -9560,49 +9780,49 @@ func (ec *executionContext) fieldContext_Mutation_approveAccount(ctx context.Con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_approveAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_resetUserPassword_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_rejectAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateUserPassword(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_rejectAccount, + ec.fieldContext_Mutation_updateUserPassword, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().RejectAccount(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(string)) + return ec.Resolvers.Mutation().UpdateUserPassword(ctx, fc.Args["token"].(string), fc.Args["email"].(string), fc.Args["password"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.reject.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.password.reset.*"}) if err != nil { - var zeroVal *models.AccountPayload + var zeroVal *models.StatusResponse return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.AccountPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.StatusResponse return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, + ec.marshalNStatusResponse2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐStatusResponse, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_rejectAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateUserPassword(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9611,13 +9831,13 @@ func (ec *executionContext) fieldContext_Mutation_rejectAccount(ctx context.Cont Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) - case "accountID": - return ec.fieldContext_AccountPayload_accountID(ctx, field) - case "account": - return ec.fieldContext_AccountPayload_account(ctx, field) + return ec.fieldContext_StatusResponse_clientMutationID(ctx, field) + case "status": + return ec.fieldContext_StatusResponse_status(ctx, field) + case "message": + return ec.fieldContext_StatusResponse_message(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type StatusResponse", field.Name) }, } defer func() { @@ -9627,49 +9847,33 @@ func (ec *executionContext) fieldContext_Mutation_rejectAccount(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_rejectAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateUserPassword_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_inviteAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_inviteAccountMember, + ec.fieldContext_Mutation_login, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().InviteAccountMember(ctx, fc.Args["accountID"].(uint64), fc.Args["member"].(models.InviteMemberInput)) + return ec.Resolvers.Mutation().Login(ctx, fc.Args["login"].(string), fc.Args["password"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.invite.*"}) - if err != nil { - var zeroVal *models.MemberPayload - return zeroVal, err - } - if ec.directives.Acl == nil { - var zeroVal *models.MemberPayload - return zeroVal, errors.New("directive acl is not implemented") - } - return ec.directives.Acl(ctx, nil, directive0, permissions) - } - - next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, + ec.marshalNSessionToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSessionToken, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_inviteAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9677,14 +9881,16 @@ func (ec *executionContext) fieldContext_Mutation_inviteAccountMember(ctx contex IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "clientMutationID": - return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) - case "memberID": - return ec.fieldContext_MemberPayload_memberID(ctx, field) - case "member": - return ec.fieldContext_MemberPayload_member(ctx, field) + case "token": + return ec.fieldContext_SessionToken_token(ctx, field) + case "expiresAt": + return ec.fieldContext_SessionToken_expiresAt(ctx, field) + case "isAdmin": + return ec.fieldContext_SessionToken_isAdmin(ctx, field) + case "roles": + return ec.fieldContext_SessionToken_roles(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SessionToken", field.Name) }, } defer func() { @@ -9694,116 +9900,64 @@ func (ec *executionContext) fieldContext_Mutation_inviteAccountMember(ctx contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_inviteAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_login_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_updateAccountMember, + ec.fieldContext_Mutation_logout, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().UpdateAccountMember(ctx, fc.Args["memberID"].(uint64), fc.Args["member"].(models.MemberInput)) + return ec.Resolvers.Mutation().Logout(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.update.*"}) - if err != nil { - var zeroVal *models.MemberPayload - return zeroVal, err - } - if ec.directives.Acl == nil { - var zeroVal *models.MemberPayload - return zeroVal, errors.New("directive acl is not implemented") - } - return ec.directives.Acl(ctx, nil, directive0, permissions) - } - - next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, + ec.marshalNBoolean2bool, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_updateAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_logout(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "clientMutationID": - return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) - case "memberID": - return ec.fieldContext_MemberPayload_memberID(ctx, field) - case "member": - return ec.fieldContext_MemberPayload_member(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_removeAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_switchAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_removeAccountMember, + ec.fieldContext_Mutation_switchAccount, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().RemoveAccountMember(ctx, fc.Args["memberID"].(uint64)) + return ec.Resolvers.Mutation().SwitchAccount(ctx, fc.Args["id"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.delete.*"}) - if err != nil { - var zeroVal *models.MemberPayload - return zeroVal, err - } - if ec.directives.Acl == nil { - var zeroVal *models.MemberPayload - return zeroVal, errors.New("directive acl is not implemented") - } - return ec.directives.Acl(ctx, nil, directive0, permissions) - } - - next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, + ec.marshalNSessionToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSessionToken, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_removeAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_switchAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9811,14 +9965,16 @@ func (ec *executionContext) fieldContext_Mutation_removeAccountMember(ctx contex IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "clientMutationID": - return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) - case "memberID": - return ec.fieldContext_MemberPayload_memberID(ctx, field) - case "member": - return ec.fieldContext_MemberPayload_member(ctx, field) + case "token": + return ec.fieldContext_SessionToken_token(ctx, field) + case "expiresAt": + return ec.fieldContext_SessionToken_expiresAt(ctx, field) + case "isAdmin": + return ec.fieldContext_SessionToken_isAdmin(ctx, field) + case "roles": + return ec.fieldContext_SessionToken_roles(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SessionToken", field.Name) }, } defer func() { @@ -9828,49 +9984,49 @@ func (ec *executionContext) fieldContext_Mutation_removeAccountMember(ctx contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_removeAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_switchAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_approveAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_registerAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_approveAccountMember, + ec.fieldContext_Mutation_registerAccount, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().ApproveAccountMember(ctx, fc.Args["memberID"].(uint64), fc.Args["msg"].(string)) + return ec.Resolvers.Mutation().RegisterAccount(ctx, fc.Args["input"].(models.AccountCreateInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.approve.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.register"}) if err != nil { - var zeroVal *models.MemberPayload + var zeroVal *models.AccountCreatePayload return zeroVal, err } - if ec.directives.Acl == nil { - var zeroVal *models.MemberPayload - return zeroVal, errors.New("directive acl is not implemented") + if ec.Directives.HasPermissions == nil { + var zeroVal *models.AccountCreatePayload + return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.Acl(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, + ec.marshalNAccountCreatePayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountCreatePayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_approveAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_registerAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9879,13 +10035,13 @@ func (ec *executionContext) fieldContext_Mutation_approveAccountMember(ctx conte Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) - case "memberID": - return ec.fieldContext_MemberPayload_memberID(ctx, field) - case "member": - return ec.fieldContext_MemberPayload_member(ctx, field) + return ec.fieldContext_AccountCreatePayload_clientMutationID(ctx, field) + case "account": + return ec.fieldContext_AccountCreatePayload_account(ctx, field) + case "owner": + return ec.fieldContext_AccountCreatePayload_owner(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountCreatePayload", field.Name) }, } defer func() { @@ -9895,49 +10051,49 @@ func (ec *executionContext) fieldContext_Mutation_approveAccountMember(ctx conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_approveAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_registerAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_rejectAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_rejectAccountMember, + ec.fieldContext_Mutation_updateAccount, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().RejectAccountMember(ctx, fc.Args["memberID"].(uint64), fc.Args["msg"].(string)) + return ec.Resolvers.Mutation().UpdateAccount(ctx, fc.Args["id"].(uint64), fc.Args["input"].(models.AccountInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.reject.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.update.*"}) if err != nil { - var zeroVal *models.MemberPayload + var zeroVal *models.AccountPayload return zeroVal, err } - if ec.directives.Acl == nil { - var zeroVal *models.MemberPayload - return zeroVal, errors.New("directive acl is not implemented") + if ec.Directives.HasPermissions == nil { + var zeroVal *models.AccountPayload + return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.Acl(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, + ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_rejectAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -9946,13 +10102,13 @@ func (ec *executionContext) fieldContext_Mutation_rejectAccountMember(ctx contex Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) - case "memberID": - return ec.fieldContext_MemberPayload_memberID(ctx, field) - case "member": - return ec.fieldContext_MemberPayload_member(ctx, field) + return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) + case "accountID": + return ec.fieldContext_AccountPayload_accountID(ctx, field) + case "account": + return ec.fieldContext_AccountPayload_account(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) }, } defer func() { @@ -9962,49 +10118,49 @@ func (ec *executionContext) fieldContext_Mutation_rejectAccountMember(ctx contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_rejectAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_disconnectSocialAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_approveAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_disconnectSocialAccount, + ec.fieldContext_Mutation_approveAccount, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().DisconnectSocialAccount(ctx, fc.Args["id"].(uint64)) + return ec.Resolvers.Mutation().ApproveAccount(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.disconnect.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.approve.*"}) if err != nil { - var zeroVal *models.SocialAccountPayload + var zeroVal *models.AccountPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.SocialAccountPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.AccountPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNSocialAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountPayload, + ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_disconnectSocialAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_approveAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10013,13 +10169,13 @@ func (ec *executionContext) fieldContext_Mutation_disconnectSocialAccount(ctx co Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_SocialAccountPayload_clientMutationID(ctx, field) - case "socialAccountID": - return ec.fieldContext_SocialAccountPayload_socialAccountID(ctx, field) - case "socialAccount": - return ec.fieldContext_SocialAccountPayload_socialAccount(ctx, field) + return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) + case "accountID": + return ec.fieldContext_AccountPayload_accountID(ctx, field) + case "account": + return ec.fieldContext_AccountPayload_account(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SocialAccountPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) }, } defer func() { @@ -10029,49 +10185,49 @@ func (ec *executionContext) fieldContext_Mutation_disconnectSocialAccount(ctx co } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_disconnectSocialAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_approveAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_createUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_rejectAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_createUser, + ec.fieldContext_Mutation_rejectAccount, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().CreateUser(ctx, fc.Args["input"].(models.UserInput)) + return ec.Resolvers.Mutation().RejectAccount(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.create.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.reject.*"}) if err != nil { - var zeroVal *models.UserPayload + var zeroVal *models.AccountPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.UserPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.AccountPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, + ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_rejectAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10080,13 +10236,13 @@ func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_UserPayload_clientMutationID(ctx, field) - case "userID": - return ec.fieldContext_UserPayload_userID(ctx, field) - case "user": - return ec.fieldContext_UserPayload_user(ctx, field) + return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) + case "accountID": + return ec.fieldContext_AccountPayload_accountID(ctx, field) + case "account": + return ec.fieldContext_AccountPayload_account(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) }, } defer func() { @@ -10096,49 +10252,49 @@ func (ec *executionContext) fieldContext_Mutation_createUser(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_rejectAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_inviteAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_updateUser, + ec.fieldContext_Mutation_inviteAccountMember, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().UpdateUser(ctx, fc.Args["id"].(uint64), fc.Args["input"].(models.UserInput)) + return ec.Resolvers.Mutation().InviteAccountMember(ctx, fc.Args["accountID"].(uint64), fc.Args["member"].(models.InviteMemberInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.update.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.invite.*"}) if err != nil { - var zeroVal *models.UserPayload + var zeroVal *models.MemberPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.UserPayload - return zeroVal, errors.New("directive hasPermissions is not implemented") + if ec.Directives.Acl == nil { + var zeroVal *models.MemberPayload + return zeroVal, errors.New("directive acl is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.Acl(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, + ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_inviteAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10147,13 +10303,13 @@ func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_UserPayload_clientMutationID(ctx, field) - case "userID": - return ec.fieldContext_UserPayload_userID(ctx, field) - case "user": - return ec.fieldContext_UserPayload_user(ctx, field) + return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) + case "memberID": + return ec.fieldContext_MemberPayload_memberID(ctx, field) + case "member": + return ec.fieldContext_MemberPayload_member(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) }, } defer func() { @@ -10163,49 +10319,49 @@ func (ec *executionContext) fieldContext_Mutation_updateUser(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_inviteAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_approveUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_approveUser, + ec.fieldContext_Mutation_updateAccountMember, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().ApproveUser(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(*string)) + return ec.Resolvers.Mutation().UpdateAccountMember(ctx, fc.Args["memberID"].(uint64), fc.Args["member"].(models.MemberInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.approve.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.update.*"}) if err != nil { - var zeroVal *models.UserPayload + var zeroVal *models.MemberPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.UserPayload - return zeroVal, errors.New("directive hasPermissions is not implemented") + if ec.Directives.Acl == nil { + var zeroVal *models.MemberPayload + return zeroVal, errors.New("directive acl is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.Acl(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, + ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_approveUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10214,13 +10370,13 @@ func (ec *executionContext) fieldContext_Mutation_approveUser(ctx context.Contex Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_UserPayload_clientMutationID(ctx, field) - case "userID": - return ec.fieldContext_UserPayload_userID(ctx, field) - case "user": - return ec.fieldContext_UserPayload_user(ctx, field) + return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) + case "memberID": + return ec.fieldContext_MemberPayload_memberID(ctx, field) + case "member": + return ec.fieldContext_MemberPayload_member(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) }, } defer func() { @@ -10230,49 +10386,49 @@ func (ec *executionContext) fieldContext_Mutation_approveUser(ctx context.Contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_approveUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_rejectUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_removeAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_rejectUser, + ec.fieldContext_Mutation_removeAccountMember, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().RejectUser(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(*string)) + return ec.Resolvers.Mutation().RemoveAccountMember(ctx, fc.Args["memberID"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.reject.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.delete.*"}) if err != nil { - var zeroVal *models.UserPayload + var zeroVal *models.MemberPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.UserPayload - return zeroVal, errors.New("directive hasPermissions is not implemented") + if ec.Directives.Acl == nil { + var zeroVal *models.MemberPayload + return zeroVal, errors.New("directive acl is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.Acl(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, + ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_rejectUser(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_removeAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10281,13 +10437,13 @@ func (ec *executionContext) fieldContext_Mutation_rejectUser(ctx context.Context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_UserPayload_clientMutationID(ctx, field) - case "userID": - return ec.fieldContext_UserPayload_userID(ctx, field) - case "user": - return ec.fieldContext_UserPayload_user(ctx, field) + return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) + case "memberID": + return ec.fieldContext_MemberPayload_memberID(ctx, field) + case "member": + return ec.fieldContext_MemberPayload_member(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) }, } defer func() { @@ -10297,49 +10453,49 @@ func (ec *executionContext) fieldContext_Mutation_rejectUser(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_rejectUser_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_removeAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_resetUserPassword(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_approveAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_resetUserPassword, + ec.fieldContext_Mutation_approveAccountMember, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().ResetUserPassword(ctx, fc.Args["email"].(string)) + return ec.Resolvers.Mutation().ApproveAccountMember(ctx, fc.Args["memberID"].(uint64), fc.Args["msg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.password.reset.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.approve.*"}) if err != nil { - var zeroVal *models.StatusResponse + var zeroVal *models.MemberPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.StatusResponse - return zeroVal, errors.New("directive hasPermissions is not implemented") + if ec.Directives.Acl == nil { + var zeroVal *models.MemberPayload + return zeroVal, errors.New("directive acl is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.Acl(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNStatusResponse2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐStatusResponse, + ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_resetUserPassword(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_approveAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10348,13 +10504,13 @@ func (ec *executionContext) fieldContext_Mutation_resetUserPassword(ctx context. Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_StatusResponse_clientMutationID(ctx, field) - case "status": - return ec.fieldContext_StatusResponse_status(ctx, field) - case "message": - return ec.fieldContext_StatusResponse_message(ctx, field) + return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) + case "memberID": + return ec.fieldContext_MemberPayload_memberID(ctx, field) + case "member": + return ec.fieldContext_MemberPayload_member(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type StatusResponse", field.Name) + return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) }, } defer func() { @@ -10364,49 +10520,49 @@ func (ec *executionContext) fieldContext_Mutation_resetUserPassword(ctx context. } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_resetUserPassword_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_approveAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateUserPassword(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_rejectAccountMember(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_updateUserPassword, + ec.fieldContext_Mutation_rejectAccountMember, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().UpdateUserPassword(ctx, fc.Args["token"].(string), fc.Args["email"].(string), fc.Args["password"].(string)) + return ec.Resolvers.Mutation().RejectAccountMember(ctx, fc.Args["memberID"].(uint64), fc.Args["msg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.password.reset.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.reject.*"}) if err != nil { - var zeroVal *models.StatusResponse + var zeroVal *models.MemberPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.StatusResponse - return zeroVal, errors.New("directive hasPermissions is not implemented") + if ec.Directives.Acl == nil { + var zeroVal *models.MemberPayload + return zeroVal, errors.New("directive acl is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.Acl(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNStatusResponse2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐStatusResponse, + ec.marshalNMemberPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_updateUserPassword(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_rejectAccountMember(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10415,13 +10571,13 @@ func (ec *executionContext) fieldContext_Mutation_updateUserPassword(ctx context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_StatusResponse_clientMutationID(ctx, field) - case "status": - return ec.fieldContext_StatusResponse_status(ctx, field) - case "message": - return ec.fieldContext_StatusResponse_message(ctx, field) + return ec.fieldContext_MemberPayload_clientMutationID(ctx, field) + case "memberID": + return ec.fieldContext_MemberPayload_memberID(ctx, field) + case "member": + return ec.fieldContext_MemberPayload_member(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type StatusResponse", field.Name) + return nil, fmt.Errorf("no field named %q was found under type MemberPayload", field.Name) }, } defer func() { @@ -10431,7 +10587,7 @@ func (ec *executionContext) fieldContext_Mutation_updateUserPassword(ctx context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateUserPassword_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_rejectAccountMember_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -10446,7 +10602,7 @@ func (ec *executionContext) _Mutation_createAuthClient(ctx context.Context, fiel ec.fieldContext_Mutation_createAuthClient, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().CreateAuthClient(ctx, fc.Args["input"].(models.AuthClientInput)) + return ec.Resolvers.Mutation().CreateAuthClient(ctx, fc.Args["input"].(models.AuthClientCreateInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -10457,11 +10613,11 @@ func (ec *executionContext) _Mutation_createAuthClient(ctx context.Context, fiel var zeroVal *models.AuthClientPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.AuthClientPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10513,7 +10669,7 @@ func (ec *executionContext) _Mutation_updateAuthClient(ctx context.Context, fiel ec.fieldContext_Mutation_updateAuthClient, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().UpdateAuthClient(ctx, fc.Args["id"].(string), fc.Args["input"].(models.AuthClientInput)) + return ec.Resolvers.Mutation().UpdateAuthClient(ctx, fc.Args["id"].(string), fc.Args["input"].(models.AuthClientUpdateInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -10524,11 +10680,11 @@ func (ec *executionContext) _Mutation_updateAuthClient(ctx context.Context, fiel var zeroVal *models.AuthClientPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.AuthClientPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10580,7 +10736,7 @@ func (ec *executionContext) _Mutation_deleteAuthClient(ctx context.Context, fiel ec.fieldContext_Mutation_deleteAuthClient, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().DeleteAuthClient(ctx, fc.Args["id"].(string), fc.Args["msg"].(*string)) + return ec.Resolvers.Mutation().DeleteAuthClient(ctx, fc.Args["id"].(string), fc.Args["msg"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -10591,11 +10747,11 @@ func (ec *executionContext) _Mutation_deleteAuthClient(ctx context.Context, fiel var zeroVal *models.AuthClientPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.AuthClientPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10647,7 +10803,7 @@ func (ec *executionContext) _Mutation_generateDirectAccessToken(ctx context.Cont ec.fieldContext_Mutation_generateDirectAccessToken, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().GenerateDirectAccessToken(ctx, fc.Args["userID"].(*uint64), fc.Args["description"].(string), fc.Args["expiresAt"].(*time.Time)) + return ec.Resolvers.Mutation().GenerateDirectAccessToken(ctx, fc.Args["userID"].(*uint64), fc.Args["description"].(string), fc.Args["expiresAt"].(*time.Time)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -10658,11 +10814,11 @@ func (ec *executionContext) _Mutation_generateDirectAccessToken(ctx context.Cont var zeroVal *models.DirectAccessTokenPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.DirectAccessTokenPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10712,7 +10868,7 @@ func (ec *executionContext) _Mutation_revokeDirectAccessToken(ctx context.Contex ec.fieldContext_Mutation_revokeDirectAccessToken, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().RevokeDirectAccessToken(ctx, fc.Args["filter"].(models.DirectAccessTokenListFilter)) + return ec.Resolvers.Mutation().RevokeDirectAccessToken(ctx, fc.Args["filter"].(models.DirectAccessTokenListFilter)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -10723,11 +10879,11 @@ func (ec *executionContext) _Mutation_revokeDirectAccessToken(ctx context.Contex var zeroVal *models.StatusResponse return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.StatusResponse return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10779,7 +10935,7 @@ func (ec *executionContext) _Mutation_setOption(ctx context.Context, field graph ec.fieldContext_Mutation_setOption, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().SetOption(ctx, fc.Args["name"].(string), fc.Args["value"].(*types.NullableJSON), fc.Args["type"].(models.OptionType), fc.Args["targetID"].(uint64)) + return ec.Resolvers.Mutation().SetOption(ctx, fc.Args["name"].(string), fc.Args["value"].(*types.NullableJSON), fc.Args["type"].(models.OptionType), fc.Args["targetID"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -10790,11 +10946,11 @@ func (ec *executionContext) _Mutation_setOption(ctx context.Context, field graph var zeroVal *models.OptionPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.OptionPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10821,7 +10977,74 @@ func (ec *executionContext) fieldContext_Mutation_setOption(ctx context.Context, case "option": return ec.fieldContext_OptionPayload_option(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type OptionPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type OptionPayload", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_setOption_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_createRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Mutation_createRole, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.Resolvers.Mutation().CreateRole(ctx, fc.Args["input"].(models.RBACRoleInput)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"role.create.*"}) + if err != nil { + var zeroVal *models.RBACRolePayload + return zeroVal, err + } + if ec.Directives.HasPermissions == nil { + var zeroVal *models.RBACRolePayload + return zeroVal, errors.New("directive hasPermissions is not implemented") + } + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) + } + + next = directive1 + return ec._fieldMiddleware(ctx, nil, next) + }, + ec.marshalNRBACRolePayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACRolePayload, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Mutation_createRole(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "clientMutationID": + return ec.fieldContext_RBACRolePayload_clientMutationID(ctx, field) + case "roleID": + return ec.fieldContext_RBACRolePayload_roleID(ctx, field) + case "role": + return ec.fieldContext_RBACRolePayload_role(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RBACRolePayload", field.Name) }, } defer func() { @@ -10831,37 +11054,37 @@ func (ec *executionContext) fieldContext_Mutation_setOption(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_setOption_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_createRole_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_createRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_updateRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_createRole, + ec.fieldContext_Mutation_updateRole, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().CreateRole(ctx, fc.Args["input"].(models.RBACRoleInput)) + return ec.Resolvers.Mutation().UpdateRole(ctx, fc.Args["id"].(uint64), fc.Args["input"].(models.RBACRoleInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"role.create.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"role.update.*"}) if err != nil { var zeroVal *models.RBACRolePayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.RBACRolePayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10873,7 +11096,7 @@ func (ec *executionContext) _Mutation_createRole(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_Mutation_createRole(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_updateRole(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10898,37 +11121,37 @@ func (ec *executionContext) fieldContext_Mutation_createRole(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createRole_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_updateRole_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_updateRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_deleteRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_updateRole, + ec.fieldContext_Mutation_deleteRole, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().UpdateRole(ctx, fc.Args["id"].(uint64), fc.Args["input"].(models.RBACRoleInput)) + return ec.Resolvers.Mutation().DeleteRole(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"role.update.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"role.delete.*"}) if err != nil { var zeroVal *models.RBACRolePayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.RBACRolePayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -10940,7 +11163,7 @@ func (ec *executionContext) _Mutation_updateRole(ctx context.Context, field grap ) } -func (ec *executionContext) fieldContext_Mutation_updateRole(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_deleteRole(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -10965,49 +11188,49 @@ func (ec *executionContext) fieldContext_Mutation_updateRole(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateRole_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_deleteRole_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_deleteRole(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_disconnectSocialAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Mutation_deleteRole, + ec.fieldContext_Mutation_disconnectSocialAccount, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Mutation().DeleteRole(ctx, fc.Args["id"].(uint64), fc.Args["msg"].(*string)) + return ec.Resolvers.Mutation().DisconnectSocialAccount(ctx, fc.Args["id"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"role.delete.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.disconnect.*"}) if err != nil { - var zeroVal *models.RBACRolePayload + var zeroVal *models.SocialAccountPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.RBACRolePayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.SocialAccountPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNRBACRolePayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACRolePayload, + ec.marshalNSocialAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountPayload, true, true, ) } -func (ec *executionContext) fieldContext_Mutation_deleteRole(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_disconnectSocialAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -11016,13 +11239,13 @@ func (ec *executionContext) fieldContext_Mutation_deleteRole(ctx context.Context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "clientMutationID": - return ec.fieldContext_RBACRolePayload_clientMutationID(ctx, field) - case "roleID": - return ec.fieldContext_RBACRolePayload_roleID(ctx, field) - case "role": - return ec.fieldContext_RBACRolePayload_role(ctx, field) + return ec.fieldContext_SocialAccountPayload_clientMutationID(ctx, field) + case "socialAccountID": + return ec.fieldContext_SocialAccountPayload_socialAccountID(ctx, field) + case "socialAccount": + return ec.fieldContext_SocialAccountPayload_socialAccount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type RBACRolePayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SocialAccountPayload", field.Name) }, } defer func() { @@ -11032,7 +11255,7 @@ func (ec *executionContext) fieldContext_Mutation_deleteRole(ctx context.Context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteRole_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_disconnectSocialAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -12110,7 +12333,7 @@ func (ec *executionContext) _Query_serviceVersion(ctx context.Context, field gra field, ec.fieldContext_Query_serviceVersion, func(ctx context.Context) (any, error) { - return ec.resolvers.Query().ServiceVersion(ctx) + return ec.Resolvers.Query().ServiceVersion(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) @@ -12134,290 +12357,97 @@ func (ec *executionContext) fieldContext_Query_serviceVersion(_ context.Context, return fc, nil } -func (ec *executionContext) _Query_currentSession(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Query_currentSession, - func(ctx context.Context) (any, error) { - return ec.resolvers.Query().CurrentSession(ctx) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) - if err != nil { - var zeroVal *models.SessionToken - return zeroVal, err - } - if ec.directives.HasPermissions == nil { - var zeroVal *models.SessionToken - return zeroVal, errors.New("directive hasPermissions is not implemented") - } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) - } - - next = directive1 - return ec._fieldMiddleware(ctx, nil, next) - }, - ec.marshalNSessionToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSessionToken, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_Query_currentSession(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "token": - return ec.fieldContext_SessionToken_token(ctx, field) - case "expiresAt": - return ec.fieldContext_SessionToken_expiresAt(ctx, field) - case "isAdmin": - return ec.fieldContext_SessionToken_isAdmin(ctx, field) - case "roles": - return ec.fieldContext_SessionToken_roles(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type SessionToken", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_currentAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Query_currentAccount, - func(ctx context.Context) (any, error) { - return ec.resolvers.Query().CurrentAccount(ctx) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) - if err != nil { - var zeroVal *models.AccountPayload - return zeroVal, err - } - if ec.directives.HasPermissions == nil { - var zeroVal *models.AccountPayload - return zeroVal, errors.New("directive hasPermissions is not implemented") - } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) - } - - next = directive1 - return ec._fieldMiddleware(ctx, nil, next) - }, - ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, - true, - true, - ) -} - -func (ec *executionContext) fieldContext_Query_currentAccount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "clientMutationID": - return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) - case "accountID": - return ec.fieldContext_AccountPayload_accountID(ctx, field) - case "account": - return ec.fieldContext_AccountPayload_account(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_account(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_currentUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_account, + ec.fieldContext_Query_currentUser, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Account(ctx, fc.Args["id"].(uint64)) + return ec.Resolvers.Query().CurrentUser(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.view.*"}) if err != nil { - var zeroVal *models.AccountPayload + var zeroVal *models.UserPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.AccountPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.UserPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, - true, + ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, true, - ) -} - -func (ec *executionContext) fieldContext_Query_account(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "clientMutationID": - return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) - case "accountID": - return ec.fieldContext_AccountPayload_accountID(ctx, field) - case "account": - return ec.fieldContext_AccountPayload_account(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_account_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_listAccounts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - ec.fieldContext_Query_listAccounts, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListAccounts(ctx, fc.Args["filter"].(*models.AccountListFilter), fc.Args["order"].(*models.AccountListOrder), fc.Args["page"].(*models.Page)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.list.*"}) - if err != nil { - var zeroVal *connectors.CollectionConnection[models.Account, models.AccountEdge] - return zeroVal, err - } - if ec.directives.HasPermissions == nil { - var zeroVal *connectors.CollectionConnection[models.Account, models.AccountEdge] - return zeroVal, errors.New("directive hasPermissions is not implemented") - } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) - } - - next = directive1 - return ec._fieldMiddleware(ctx, nil, next) - }, - ec.marshalOAccountConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, true, - false, ) } -func (ec *executionContext) fieldContext_Query_listAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "totalCount": - return ec.fieldContext_AccountConnection_totalCount(ctx, field) - case "edges": - return ec.fieldContext_AccountConnection_edges(ctx, field) - case "list": - return ec.fieldContext_AccountConnection_list(ctx, field) - case "pageInfo": - return ec.fieldContext_AccountConnection_pageInfo(ctx, field) +func (ec *executionContext) fieldContext_Query_currentUser(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "clientMutationID": + return ec.fieldContext_UserPayload_clientMutationID(ctx, field) + case "userID": + return ec.fieldContext_UserPayload_userID(ctx, field) + case "user": + return ec.fieldContext_UserPayload_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type AccountConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listAccounts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_listAccountRolesAndPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_listAccountRolesAndPermissions, + ec.fieldContext_Query_user, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListAccountRolesAndPermissions(ctx, fc.Args["accountID"].(uint64), fc.Args["order"].(*models.RBACRoleListOrder)) + return ec.Resolvers.Query().User(ctx, fc.Args["id"].(uint64), fc.Args["username"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.view.*"}) if err != nil { - var zeroVal *connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge] + var zeroVal *models.UserPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge] + if ec.Directives.HasPermissions == nil { + var zeroVal *models.UserPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalORBACRoleConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Query_listAccountRolesAndPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12425,16 +12455,14 @@ func (ec *executionContext) fieldContext_Query_listAccountRolesAndPermissions(ct IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "totalCount": - return ec.fieldContext_RBACRoleConnection_totalCount(ctx, field) - case "edges": - return ec.fieldContext_RBACRoleConnection_edges(ctx, field) - case "list": - return ec.fieldContext_RBACRoleConnection_list(ctx, field) - case "pageInfo": - return ec.fieldContext_RBACRoleConnection_pageInfo(ctx, field) + case "clientMutationID": + return ec.fieldContext_UserPayload_clientMutationID(ctx, field) + case "userID": + return ec.fieldContext_UserPayload_userID(ctx, field) + case "user": + return ec.fieldContext_UserPayload_user(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type RBACRoleConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) }, } defer func() { @@ -12444,49 +12472,49 @@ func (ec *executionContext) fieldContext_Query_listAccountRolesAndPermissions(ct } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listAccountRolesAndPermissions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_user_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_listMembers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_listUsers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_listMembers, + ec.fieldContext_Query_listUsers, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListMembers(ctx, fc.Args["filter"].(*models.MemberListFilter), fc.Args["order"].(*models.MemberListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListUsers(ctx, fc.Args["filter"].(*models.UserListFilter), fc.Args["order"].(*models.UserListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.list.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.list.*"}) if err != nil { - var zeroVal *connectors.CollectionConnection[models.Member, models.MemberEdge] + var zeroVal *connectors.CollectionConnection[models.User, models.UserEdge] return zeroVal, err } - if ec.directives.Acl == nil { - var zeroVal *connectors.CollectionConnection[models.Member, models.MemberEdge] - return zeroVal, errors.New("directive acl is not implemented") + if ec.Directives.HasPermissions == nil { + var zeroVal *connectors.CollectionConnection[models.User, models.UserEdge] + return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.Acl(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalOMemberConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + ec.marshalOUserConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, true, false, ) } -func (ec *executionContext) fieldContext_Query_listMembers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_listUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12495,15 +12523,15 @@ func (ec *executionContext) fieldContext_Query_listMembers(ctx context.Context, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "totalCount": - return ec.fieldContext_MemberConnection_totalCount(ctx, field) + return ec.fieldContext_UserConnection_totalCount(ctx, field) case "edges": - return ec.fieldContext_MemberConnection_edges(ctx, field) + return ec.fieldContext_UserConnection_edges(ctx, field) case "list": - return ec.fieldContext_MemberConnection_list(ctx, field) + return ec.fieldContext_UserConnection_list(ctx, field) case "pageInfo": - return ec.fieldContext_MemberConnection_pageInfo(ctx, field) + return ec.fieldContext_UserConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type MemberConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) }, } defer func() { @@ -12513,49 +12541,48 @@ func (ec *executionContext) fieldContext_Query_listMembers(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listMembers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_listUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_socialAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_currentSession(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_socialAccount, + ec.fieldContext_Query_currentSession, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().SocialAccount(ctx, fc.Args["id"].(uint64)) + return ec.Resolvers.Query().CurrentSession(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.view.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) if err != nil { - var zeroVal *models.SocialAccountPayload + var zeroVal *models.SessionToken return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.SocialAccountPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *models.SessionToken return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNSocialAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountPayload, + ec.marshalNSessionToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSessionToken, true, true, ) } -func (ec *executionContext) fieldContext_Query_socialAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_currentSession(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12563,66 +12590,56 @@ func (ec *executionContext) fieldContext_Query_socialAccount(ctx context.Context IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "clientMutationID": - return ec.fieldContext_SocialAccountPayload_clientMutationID(ctx, field) - case "socialAccountID": - return ec.fieldContext_SocialAccountPayload_socialAccountID(ctx, field) - case "socialAccount": - return ec.fieldContext_SocialAccountPayload_socialAccount(ctx, field) + case "token": + return ec.fieldContext_SessionToken_token(ctx, field) + case "expiresAt": + return ec.fieldContext_SessionToken_expiresAt(ctx, field) + case "isAdmin": + return ec.fieldContext_SessionToken_isAdmin(ctx, field) + case "roles": + return ec.fieldContext_SessionToken_roles(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SocialAccountPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SessionToken", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_socialAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_currentSocialAccounts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_currentAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_currentSocialAccounts, + ec.fieldContext_Query_currentAccount, func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().CurrentSocialAccounts(ctx, fc.Args["filter"].(*models.SocialAccountListFilter), fc.Args["order"].(*models.SocialAccountListOrder)) + return ec.Resolvers.Query().CurrentAccount(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.list.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) if err != nil { - var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] + var zeroVal *models.AccountPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] + if ec.Directives.HasPermissions == nil { + var zeroVal *models.AccountPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNSocialAccountConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, true, true, ) } -func (ec *executionContext) fieldContext_Query_currentSocialAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_currentAccount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12630,68 +12647,55 @@ func (ec *executionContext) fieldContext_Query_currentSocialAccounts(ctx context IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "totalCount": - return ec.fieldContext_SocialAccountConnection_totalCount(ctx, field) - case "edges": - return ec.fieldContext_SocialAccountConnection_edges(ctx, field) - case "list": - return ec.fieldContext_SocialAccountConnection_list(ctx, field) - case "pageInfo": - return ec.fieldContext_SocialAccountConnection_pageInfo(ctx, field) + case "clientMutationID": + return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) + case "accountID": + return ec.fieldContext_AccountPayload_accountID(ctx, field) + case "account": + return ec.fieldContext_AccountPayload_account(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SocialAccountConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_currentSocialAccounts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_listSocialAccounts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_account(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_listSocialAccounts, + ec.fieldContext_Query_account, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListSocialAccounts(ctx, fc.Args["filter"].(*models.SocialAccountListFilter), fc.Args["order"].(*models.SocialAccountListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().Account(ctx, fc.Args["id"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.list.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) if err != nil { - var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] + var zeroVal *models.AccountPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] + if ec.Directives.HasPermissions == nil { + var zeroVal *models.AccountPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNSocialAccountConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + ec.marshalNAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountPayload, true, true, ) } -func (ec *executionContext) fieldContext_Query_listSocialAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_account(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12699,16 +12703,14 @@ func (ec *executionContext) fieldContext_Query_listSocialAccounts(ctx context.Co IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "totalCount": - return ec.fieldContext_SocialAccountConnection_totalCount(ctx, field) - case "edges": - return ec.fieldContext_SocialAccountConnection_edges(ctx, field) - case "list": - return ec.fieldContext_SocialAccountConnection_list(ctx, field) - case "pageInfo": - return ec.fieldContext_SocialAccountConnection_pageInfo(ctx, field) + case "clientMutationID": + return ec.fieldContext_AccountPayload_clientMutationID(ctx, field) + case "accountID": + return ec.fieldContext_AccountPayload_accountID(ctx, field) + case "account": + return ec.fieldContext_AccountPayload_account(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type SocialAccountConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountPayload", field.Name) }, } defer func() { @@ -12718,48 +12720,49 @@ func (ec *executionContext) fieldContext_Query_listSocialAccounts(ctx context.Co } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listSocialAccounts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_account_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_currentUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_listAccounts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_currentUser, + ec.fieldContext_Query_listAccounts, func(ctx context.Context) (any, error) { - return ec.resolvers.Query().CurrentUser(ctx) + fc := graphql.GetFieldContext(ctx) + return ec.Resolvers.Query().ListAccounts(ctx, fc.Args["filter"].(*models.AccountListFilter), fc.Args["order"].(*models.AccountListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.view.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.list.*"}) if err != nil { - var zeroVal *models.UserPayload + var zeroVal *connectors.CollectionConnection[models.Account, models.AccountEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.UserPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *connectors.CollectionConnection[models.Account, models.AccountEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, - true, + ec.marshalOAccountConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, true, + false, ) } -func (ec *executionContext) fieldContext_Query_currentUser(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_listAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12767,55 +12770,68 @@ func (ec *executionContext) fieldContext_Query_currentUser(_ context.Context, fi IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "clientMutationID": - return ec.fieldContext_UserPayload_clientMutationID(ctx, field) - case "userID": - return ec.fieldContext_UserPayload_userID(ctx, field) - case "user": - return ec.fieldContext_UserPayload_user(ctx, field) + case "totalCount": + return ec.fieldContext_AccountConnection_totalCount(ctx, field) + case "edges": + return ec.fieldContext_AccountConnection_edges(ctx, field) + case "list": + return ec.fieldContext_AccountConnection_list(ctx, field) + case "pageInfo": + return ec.fieldContext_AccountConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type AccountConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_listAccounts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_listAccountRolesAndPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_user, + ec.fieldContext_Query_listAccountRolesAndPermissions, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().User(ctx, fc.Args["id"].(uint64), fc.Args["username"].(string)) + return ec.Resolvers.Query().ListAccountRolesAndPermissions(ctx, fc.Args["accountID"].(uint64), fc.Args["order"].(*models.RBACRoleListOrder)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.view.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.view.*"}) if err != nil { - var zeroVal *models.UserPayload + var zeroVal *connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *models.UserPayload + if ec.Directives.HasPermissions == nil { + var zeroVal *connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalNUserPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserPayload, - true, + ec.marshalORBACRoleConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, true, + false, ) } -func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_listAccountRolesAndPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12823,14 +12839,16 @@ func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field g IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "clientMutationID": - return ec.fieldContext_UserPayload_clientMutationID(ctx, field) - case "userID": - return ec.fieldContext_UserPayload_userID(ctx, field) - case "user": - return ec.fieldContext_UserPayload_user(ctx, field) + case "totalCount": + return ec.fieldContext_RBACRoleConnection_totalCount(ctx, field) + case "edges": + return ec.fieldContext_RBACRoleConnection_edges(ctx, field) + case "list": + return ec.fieldContext_RBACRoleConnection_list(ctx, field) + case "pageInfo": + return ec.fieldContext_RBACRoleConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserPayload", field.Name) + return nil, fmt.Errorf("no field named %q was found under type RBACRoleConnection", field.Name) }, } defer func() { @@ -12840,49 +12858,49 @@ func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field g } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_user_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_listAccountRolesAndPermissions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_listUsers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_listMembers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_listUsers, + ec.fieldContext_Query_listMembers, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListUsers(ctx, fc.Args["filter"].(*models.UserListFilter), fc.Args["order"].(*models.UserListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListMembers(ctx, fc.Args["filter"].(*models.MemberListFilter), fc.Args["order"].(*models.MemberListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"user.list.*"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account.member.list.*"}) if err != nil { - var zeroVal *connectors.CollectionConnection[models.User, models.UserEdge] + var zeroVal *connectors.CollectionConnection[models.Member, models.MemberEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal *connectors.CollectionConnection[models.User, models.UserEdge] - return zeroVal, errors.New("directive hasPermissions is not implemented") + if ec.Directives.Acl == nil { + var zeroVal *connectors.CollectionConnection[models.Member, models.MemberEdge] + return zeroVal, errors.New("directive acl is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.Acl(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalOUserConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + ec.marshalOMemberConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, true, false, ) } -func (ec *executionContext) fieldContext_Query_listUsers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_listMembers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -12891,15 +12909,15 @@ func (ec *executionContext) fieldContext_Query_listUsers(ctx context.Context, fi Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "totalCount": - return ec.fieldContext_UserConnection_totalCount(ctx, field) + return ec.fieldContext_MemberConnection_totalCount(ctx, field) case "edges": - return ec.fieldContext_UserConnection_edges(ctx, field) + return ec.fieldContext_MemberConnection_edges(ctx, field) case "list": - return ec.fieldContext_UserConnection_list(ctx, field) + return ec.fieldContext_MemberConnection_list(ctx, field) case "pageInfo": - return ec.fieldContext_UserConnection_pageInfo(ctx, field) + return ec.fieldContext_MemberConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type MemberConnection", field.Name) }, } defer func() { @@ -12909,7 +12927,7 @@ func (ec *executionContext) fieldContext_Query_listUsers(ctx context.Context, fi } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listUsers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_listMembers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -12924,7 +12942,7 @@ func (ec *executionContext) _Query_authClient(ctx context.Context, field graphql ec.fieldContext_Query_authClient, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().AuthClient(ctx, fc.Args["id"].(string)) + return ec.Resolvers.Query().AuthClient(ctx, fc.Args["id"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -12935,11 +12953,11 @@ func (ec *executionContext) _Query_authClient(ctx context.Context, field graphql var zeroVal *models.AuthClientPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.AuthClientPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -12991,7 +13009,7 @@ func (ec *executionContext) _Query_listAuthClients(ctx context.Context, field gr ec.fieldContext_Query_listAuthClients, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListAuthClients(ctx, fc.Args["filter"].(*models.AuthClientListFilter), fc.Args["order"].(*models.AuthClientListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListAuthClients(ctx, fc.Args["filter"].(*models.AuthClientListFilter), fc.Args["order"].([]*models.AuthClientListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13002,11 +13020,11 @@ func (ec *executionContext) _Query_listAuthClients(ctx context.Context, field gr var zeroVal *connectors.CollectionConnection[models.AuthClient, models.AuthClientEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *connectors.CollectionConnection[models.AuthClient, models.AuthClientEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13060,7 +13078,7 @@ func (ec *executionContext) _Query_getDirectAccessToken(ctx context.Context, fie ec.fieldContext_Query_getDirectAccessToken, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().GetDirectAccessToken(ctx, fc.Args["id"].(uint64)) + return ec.Resolvers.Query().GetDirectAccessToken(ctx, fc.Args["id"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13071,11 +13089,11 @@ func (ec *executionContext) _Query_getDirectAccessToken(ctx context.Context, fie var zeroVal *models.DirectAccessTokenPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.DirectAccessTokenPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13125,7 +13143,7 @@ func (ec *executionContext) _Query_listDirectAccessTokens(ctx context.Context, f ec.fieldContext_Query_listDirectAccessTokens, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListDirectAccessTokens(ctx, fc.Args["filter"].(*models.DirectAccessTokenListFilter), fc.Args["order"].(*models.DirectAccessTokenListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListDirectAccessTokens(ctx, fc.Args["filter"].(*models.DirectAccessTokenListFilter), fc.Args["order"].(*models.DirectAccessTokenListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13136,11 +13154,11 @@ func (ec *executionContext) _Query_listDirectAccessTokens(ctx context.Context, f var zeroVal *connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *connectors.CollectionConnection[models.DirectAccessToken, models.DirectAccessTokenEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13194,7 +13212,7 @@ func (ec *executionContext) _Query_listHistory(ctx context.Context, field graphq ec.fieldContext_Query_listHistory, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListHistory(ctx, fc.Args["filter"].(*models.HistoryActionListFilter), fc.Args["order"].(*models.HistoryActionListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListHistory(ctx, fc.Args["filter"].(*models.HistoryActionListFilter), fc.Args["order"].(*models.HistoryActionListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13205,11 +13223,11 @@ func (ec *executionContext) _Query_listHistory(ctx context.Context, field graphq var zeroVal *connectors.CollectionConnection[models.HistoryAction, models.HistoryActionEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *connectors.CollectionConnection[models.HistoryAction, models.HistoryActionEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13263,7 +13281,7 @@ func (ec *executionContext) _Query_option(ctx context.Context, field graphql.Col ec.fieldContext_Query_option, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Option(ctx, fc.Args["name"].(string), fc.Args["type"].(models.OptionType), fc.Args["targetID"].(uint64)) + return ec.Resolvers.Query().Option(ctx, fc.Args["name"].(string), fc.Args["type"].(models.OptionType), fc.Args["targetID"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13274,11 +13292,11 @@ func (ec *executionContext) _Query_option(ctx context.Context, field graphql.Col var zeroVal *models.OptionPayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.OptionPayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13330,7 +13348,7 @@ func (ec *executionContext) _Query_listOptions(ctx context.Context, field graphq ec.fieldContext_Query_listOptions, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListOptions(ctx, fc.Args["filter"].(*models.OptionListFilter), fc.Args["order"].(*models.OptionListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListOptions(ctx, fc.Args["filter"].(*models.OptionListFilter), fc.Args["order"].(*models.OptionListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13341,11 +13359,11 @@ func (ec *executionContext) _Query_listOptions(ctx context.Context, field graphq var zeroVal *connectors.CollectionConnection[models.Option, models.OptionEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *connectors.CollectionConnection[models.Option, models.OptionEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13399,7 +13417,7 @@ func (ec *executionContext) _Query_role(ctx context.Context, field graphql.Colle ec.fieldContext_Query_role, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().Role(ctx, fc.Args["id"].(uint64)) + return ec.Resolvers.Query().Role(ctx, fc.Args["id"].(uint64)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13410,11 +13428,11 @@ func (ec *executionContext) _Query_role(ctx context.Context, field graphql.Colle var zeroVal *models.RBACRolePayload return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *models.RBACRolePayload return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13466,7 +13484,7 @@ func (ec *executionContext) _Query_checkPermission(ctx context.Context, field gr ec.fieldContext_Query_checkPermission, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().CheckPermission(ctx, fc.Args["name"].(string), fc.Args["key"].(*string), fc.Args["targetID"].(*string), fc.Args["idKey"].(*string)) + return ec.Resolvers.Query().CheckPermission(ctx, fc.Args["name"].(string), fc.Args["key"].(*string), fc.Args["targetID"].(*string), fc.Args["idKey"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13477,11 +13495,11 @@ func (ec *executionContext) _Query_checkPermission(ctx context.Context, field gr var zeroVal *string return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *string return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13525,7 +13543,7 @@ func (ec *executionContext) _Query_listRoles(ctx context.Context, field graphql. ec.fieldContext_Query_listRoles, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListRoles(ctx, fc.Args["filter"].(*models.RBACRoleListFilter), fc.Args["order"].(*models.RBACRoleListOrder), fc.Args["page"].(*models.Page)) + return ec.Resolvers.Query().ListRoles(ctx, fc.Args["filter"].(*models.RBACRoleListFilter), fc.Args["order"].(*models.RBACRoleListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next @@ -13536,11 +13554,11 @@ func (ec *executionContext) _Query_listRoles(ctx context.Context, field graphql. var zeroVal *connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { + if ec.Directives.HasPermissions == nil { var zeroVal *connectors.CollectionConnection[models.RBACRole, models.RBACRoleEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 @@ -13560,16 +13578,225 @@ func (ec *executionContext) fieldContext_Query_listRoles(ctx context.Context, fi IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "totalCount": - return ec.fieldContext_RBACRoleConnection_totalCount(ctx, field) - case "edges": - return ec.fieldContext_RBACRoleConnection_edges(ctx, field) - case "list": - return ec.fieldContext_RBACRoleConnection_list(ctx, field) - case "pageInfo": - return ec.fieldContext_RBACRoleConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_RBACRoleConnection_totalCount(ctx, field) + case "edges": + return ec.fieldContext_RBACRoleConnection_edges(ctx, field) + case "list": + return ec.fieldContext_RBACRoleConnection_list(ctx, field) + case "pageInfo": + return ec.fieldContext_RBACRoleConnection_pageInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RBACRoleConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_listRoles_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_listPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Query_listPermissions, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.Resolvers.Query().ListPermissions(ctx, fc.Args["patterns"].([]string)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"permission.list"}) + if err != nil { + var zeroVal []*models.RBACPermission + return zeroVal, err + } + if ec.Directives.HasPermissions == nil { + var zeroVal []*models.RBACPermission + return zeroVal, errors.New("directive hasPermissions is not implemented") + } + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) + } + + next = directive1 + return ec._fieldMiddleware(ctx, nil, next) + }, + ec.marshalORBACPermission2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACPermissionᚄ, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Query_listPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_RBACPermission_name(ctx, field) + case "object": + return ec.fieldContext_RBACPermission_object(ctx, field) + case "access": + return ec.fieldContext_RBACPermission_access(ctx, field) + case "fullname": + return ec.fieldContext_RBACPermission_fullname(ctx, field) + case "description": + return ec.fieldContext_RBACPermission_description(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RBACPermission", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_listPermissions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_listMyPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Query_listMyPermissions, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.Resolvers.Query().ListMyPermissions(ctx, fc.Args["patterns"].([]string)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"permission.list"}) + if err != nil { + var zeroVal []*models.RBACPermission + return zeroVal, err + } + if ec.Directives.HasPermissions == nil { + var zeroVal []*models.RBACPermission + return zeroVal, errors.New("directive hasPermissions is not implemented") + } + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) + } + + next = directive1 + return ec._fieldMiddleware(ctx, nil, next) + }, + ec.marshalORBACPermission2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACPermissionᚄ, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Query_listMyPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_RBACPermission_name(ctx, field) + case "object": + return ec.fieldContext_RBACPermission_object(ctx, field) + case "access": + return ec.fieldContext_RBACPermission_access(ctx, field) + case "fullname": + return ec.fieldContext_RBACPermission_fullname(ctx, field) + case "description": + return ec.fieldContext_RBACPermission_description(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type RBACPermission", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_listMyPermissions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_socialAccount(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Query_socialAccount, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.Resolvers.Query().SocialAccount(ctx, fc.Args["id"].(uint64)) + }, + func(ctx context.Context, next graphql.Resolver) graphql.Resolver { + directive0 := next + + directive1 := func(ctx context.Context) (any, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.view.*"}) + if err != nil { + var zeroVal *models.SocialAccountPayload + return zeroVal, err + } + if ec.Directives.HasPermissions == nil { + var zeroVal *models.SocialAccountPayload + return zeroVal, errors.New("directive hasPermissions is not implemented") + } + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) + } + + next = directive1 + return ec._fieldMiddleware(ctx, nil, next) + }, + ec.marshalNSocialAccountPayload2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountPayload, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Query_socialAccount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "clientMutationID": + return ec.fieldContext_SocialAccountPayload_clientMutationID(ctx, field) + case "socialAccountID": + return ec.fieldContext_SocialAccountPayload_socialAccountID(ctx, field) + case "socialAccount": + return ec.fieldContext_SocialAccountPayload_socialAccount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type RBACRoleConnection", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SocialAccountPayload", field.Name) }, } defer func() { @@ -13579,49 +13806,49 @@ func (ec *executionContext) fieldContext_Query_listRoles(ctx context.Context, fi } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listRoles_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_socialAccount_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_listPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_currentSocialAccounts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_listPermissions, + ec.fieldContext_Query_currentSocialAccounts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListPermissions(ctx, fc.Args["patterns"].([]string)) + return ec.Resolvers.Query().CurrentSocialAccounts(ctx, fc.Args["filter"].(*models.SocialAccountListFilter), fc.Args["order"].(*models.SocialAccountListOrder)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"permission.list"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.list.*"}) if err != nil { - var zeroVal []*models.RBACPermission + var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal []*models.RBACPermission + if ec.Directives.HasPermissions == nil { + var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalORBACPermission2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACPermissionᚄ, + ec.marshalNSocialAccountConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Query_listPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_currentSocialAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -13629,18 +13856,16 @@ func (ec *executionContext) fieldContext_Query_listPermissions(ctx context.Conte IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "name": - return ec.fieldContext_RBACPermission_name(ctx, field) - case "object": - return ec.fieldContext_RBACPermission_object(ctx, field) - case "access": - return ec.fieldContext_RBACPermission_access(ctx, field) - case "fullname": - return ec.fieldContext_RBACPermission_fullname(ctx, field) - case "description": - return ec.fieldContext_RBACPermission_description(ctx, field) + case "totalCount": + return ec.fieldContext_SocialAccountConnection_totalCount(ctx, field) + case "edges": + return ec.fieldContext_SocialAccountConnection_edges(ctx, field) + case "list": + return ec.fieldContext_SocialAccountConnection_list(ctx, field) + case "pageInfo": + return ec.fieldContext_SocialAccountConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type RBACPermission", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SocialAccountConnection", field.Name) }, } defer func() { @@ -13650,49 +13875,49 @@ func (ec *executionContext) fieldContext_Query_listPermissions(ctx context.Conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listPermissions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_currentSocialAccounts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_listMyPermissions(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_listSocialAccounts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, - ec.fieldContext_Query_listMyPermissions, + ec.fieldContext_Query_listSocialAccounts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.resolvers.Query().ListMyPermissions(ctx, fc.Args["patterns"].([]string)) + return ec.Resolvers.Query().ListSocialAccounts(ctx, fc.Args["filter"].(*models.SocialAccountListFilter), fc.Args["order"].(*models.SocialAccountListOrder), fc.Args["page"].(*models.Page)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { - permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"permission.list"}) + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []any{"account_social.list.*"}) if err != nil { - var zeroVal []*models.RBACPermission + var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] return zeroVal, err } - if ec.directives.HasPermissions == nil { - var zeroVal []*models.RBACPermission + if ec.Directives.HasPermissions == nil { + var zeroVal *connectors.CollectionConnection[models.SocialAccount, models.SocialAccountEdge] return zeroVal, errors.New("directive hasPermissions is not implemented") } - return ec.directives.HasPermissions(ctx, nil, directive0, permissions) + return ec.Directives.HasPermissions(ctx, nil, directive0, permissions) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, - ec.marshalORBACPermission2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACPermissionᚄ, + ec.marshalNSocialAccountConnection2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋconnectorsᚐCollectionConnection, + true, true, - false, ) } -func (ec *executionContext) fieldContext_Query_listMyPermissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_listSocialAccounts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -13700,18 +13925,16 @@ func (ec *executionContext) fieldContext_Query_listMyPermissions(ctx context.Con IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "name": - return ec.fieldContext_RBACPermission_name(ctx, field) - case "object": - return ec.fieldContext_RBACPermission_object(ctx, field) - case "access": - return ec.fieldContext_RBACPermission_access(ctx, field) - case "fullname": - return ec.fieldContext_RBACPermission_fullname(ctx, field) - case "description": - return ec.fieldContext_RBACPermission_description(ctx, field) + case "totalCount": + return ec.fieldContext_SocialAccountConnection_totalCount(ctx, field) + case "edges": + return ec.fieldContext_SocialAccountConnection_edges(ctx, field) + case "list": + return ec.fieldContext_SocialAccountConnection_list(ctx, field) + case "pageInfo": + return ec.fieldContext_SocialAccountConnection_pageInfo(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type RBACPermission", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SocialAccountConnection", field.Name) }, } defer func() { @@ -13721,7 +13944,7 @@ func (ec *executionContext) fieldContext_Query_listMyPermissions(ctx context.Con } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_listMyPermissions_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_listSocialAccounts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -13736,7 +13959,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col ec.fieldContext_Query___type, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) - return ec.introspectType(fc.Args["name"].(string)) + return ec.IntrospectType(fc.Args["name"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) @@ -13802,7 +14025,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C field, ec.fieldContext_Query___schema, func(ctx context.Context) (any, error) { - return ec.introspectSchema() + return ec.IntrospectSchema() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) @@ -18200,145 +18423,472 @@ func (ec *executionContext) fieldContext___Type_isOneOf(_ context.Context, field return nil, errors.New("field of type Boolean does not have child fields") }, } - return fc, nil + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputAccountCreateInput(ctx context.Context, obj any) (models.AccountCreateInput, error) { + var it models.AccountCreateInput + if obj == nil { + return it, nil + } + + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"ownerID", "owner", "account", "password"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "ownerID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerID")) + data, err := ec.unmarshalOID642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.OwnerID = data + case "owner": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("owner")) + data, err := ec.unmarshalOUserInput2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserInput(ctx, v) + if err != nil { + return it, err + } + it.Owner = data + case "account": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("account")) + data, err := ec.unmarshalNAccountInput2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountInput(ctx, v) + if err != nil { + return it, err + } + it.Account = data + case "password": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Password = data + } + } + return it, nil +} + +func (ec *executionContext) unmarshalInputAccountInput(ctx context.Context, obj any) (models.AccountInput, error) { + var it models.AccountInput + if obj == nil { + return it, nil + } + + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"status", "title", "description", "logoURI", "policyURI", "termsOfServiceURI", "clientURI", "contacts"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "status": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) + data, err := ec.unmarshalOApproveStatus2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐApproveStatus(ctx, v) + if err != nil { + return it, err + } + it.Status = data + case "title": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Title = data + case "description": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Description = data + case "logoURI": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("logoURI")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.LogoURI = data + case "policyURI": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("policyURI")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PolicyURI = data + case "termsOfServiceURI": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("termsOfServiceURI")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TermsOfServiceURI = data + case "clientURI": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clientURI")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ClientURI = data + case "contacts": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("contacts")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Contacts = data + } + } + return it, nil +} + +func (ec *executionContext) unmarshalInputAccountListFilter(ctx context.Context, obj any) (models.AccountListFilter, error) { + var it models.AccountListFilter + if obj == nil { + return it, nil + } + + asMap := map[string]any{} + for k, v := range obj.(map[string]any) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"ID", "UserID", "title", "status"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "ID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ID")) + data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "UserID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("UserID")) + data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) + if err != nil { + return it, err + } + it.UserID = data + case "title": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.Title = data + case "status": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) + data, err := ec.unmarshalOApproveStatus2ᚕgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐApproveStatusᚄ(ctx, v) + if err != nil { + return it, err + } + it.Status = data + } + } + return it, nil } -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** +func (ec *executionContext) unmarshalInputAccountListOrder(ctx context.Context, obj any) (models.AccountListOrder, error) { + var it models.AccountListOrder + if obj == nil { + return it, nil + } -func (ec *executionContext) unmarshalInputAccountCreateInput(ctx context.Context, obj any) (models.AccountCreateInput, error) { - var it models.AccountCreateInput asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } - fieldsInOrder := [...]string{"ownerID", "owner", "account", "password"} + fieldsInOrder := [...]string{"ID", "title", "status"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "ownerID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerID")) - data, err := ec.unmarshalOID642ᚖuint64(ctx, v) - if err != nil { - return it, err - } - it.OwnerID = data - case "owner": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("owner")) - data, err := ec.unmarshalOUserInput2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserInput(ctx, v) + case "ID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ID")) + data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) if err != nil { return it, err } - it.Owner = data - case "account": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("account")) - data, err := ec.unmarshalNAccountInput2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountInput(ctx, v) + it.ID = data + case "title": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) + data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) if err != nil { return it, err } - it.Account = data - case "password": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) - data, err := ec.unmarshalNString2string(ctx, v) + it.Title = data + case "status": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) + data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) if err != nil { return it, err } - it.Password = data + it.Status = data } } - return it, nil } -func (ec *executionContext) unmarshalInputAccountInput(ctx context.Context, obj any) (models.AccountInput, error) { - var it models.AccountInput +func (ec *executionContext) unmarshalInputAuthClientCreateInput(ctx context.Context, obj any) (models.AuthClientCreateInput, error) { + var it models.AuthClientCreateInput + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } - fieldsInOrder := [...]string{"status", "title", "description", "logoURI", "policyURI", "termsOfServiceURI", "clientURI", "contacts"} + fieldsInOrder := [...]string{"accountID", "userID", "title", "secret", "redirectURIs", "grantTypes", "responseTypes", "scope", "audience", "subjectType", "allowedCORSOrigins", "public", "expiresAt"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "status": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - data, err := ec.unmarshalOApproveStatus2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐApproveStatus(ctx, v) + case "accountID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountID")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOID642ᚖuint64(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *uint64 + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*uint64); ok { + it.AccountID = data + } else if tmp == nil { + it.AccountID = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *uint64`, tmp) + return it, graphql.ErrorOnPath(ctx, err) + } + case "userID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOID642ᚖuint64(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *uint64 + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) + if err != nil { + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*uint64); ok { + it.UserID = data + } else if tmp == nil { + it.UserID = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *uint64`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.Status = data case "title": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) + if err != nil { + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*string); ok { + it.Title = data + } else if tmp == nil { + it.Title = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) + } + case "secret": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secret")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) + if err != nil { + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*string); ok { + it.Secret = data + } else if tmp == nil { + it.Secret = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) + } + case "redirectURIs": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("redirectURIs")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Title = data - case "description": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.RedirectURIs = data + case "grantTypes": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("grantTypes")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Description = data - case "logoURI": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("logoURI")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.GrantTypes = data + case "responseTypes": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("responseTypes")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.LogoURI = data - case "policyURI": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("policyURI")) + it.ResponseTypes = data + case "scope": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("scope")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PolicyURI = data - case "termsOfServiceURI": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("termsOfServiceURI")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.Scope = data + case "audience": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("audience")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.TermsOfServiceURI = data - case "clientURI": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clientURI")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + it.Audience = data + case "subjectType": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subjectType")) + data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - it.ClientURI = data - case "contacts": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("contacts")) + it.SubjectType = data + case "allowedCORSOrigins": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("allowedCORSOrigins")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.Contacts = data + it.AllowedCORSOrigins = data + case "public": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.Public = data + case "expiresAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("expiresAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.ExpiresAt = data } } - return it, nil } -func (ec *executionContext) unmarshalInputAccountListFilter(ctx context.Context, obj any) (models.AccountListFilter, error) { - var it models.AccountListFilter +func (ec *executionContext) unmarshalInputAuthClientListFilter(ctx context.Context, obj any) (models.AuthClientListFilter, error) { + var it models.AuthClientListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } - fieldsInOrder := [...]string{"ID", "UserID", "title", "status"} + fieldsInOrder := [...]string{"ID", "userID", "accountID", "public"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -18347,46 +18897,49 @@ func (ec *executionContext) unmarshalInputAccountListFilter(ctx context.Context, switch k { case "ID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ID")) - data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } it.ID = data - case "UserID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("UserID")) + case "userID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } it.UserID = data - case "title": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + case "accountID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountID")) + data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) if err != nil { return it, err } - it.Title = data - case "status": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - data, err := ec.unmarshalOApproveStatus2ᚕgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐApproveStatusᚄ(ctx, v) + it.AccountID = data + case "public": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.Status = data + it.Public = data } } - return it, nil } -func (ec *executionContext) unmarshalInputAccountListOrder(ctx context.Context, obj any) (models.AccountListOrder, error) { - var it models.AccountListOrder +func (ec *executionContext) unmarshalInputAuthClientListOrder(ctx context.Context, obj any) (models.AuthClientListOrder, error) { + var it models.AuthClientListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } - fieldsInOrder := [...]string{"ID", "title", "status"} + fieldsInOrder := [...]string{"ID", "userID", "accountID", "title", "public", "lastUpdate"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -18399,7 +18952,21 @@ func (ec *executionContext) unmarshalInputAccountListOrder(ctx context.Context, if err != nil { return it, err } - it.ID = data + it.ID = data + case "userID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) + data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + if err != nil { + return it, err + } + it.UserID = data + case "accountID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountID")) + data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + if err != nil { + return it, err + } + it.AccountID = data case "title": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) @@ -18407,21 +18974,31 @@ func (ec *executionContext) unmarshalInputAccountListOrder(ctx context.Context, return it, err } it.Title = data - case "status": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) + case "public": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) if err != nil { return it, err } - it.Status = data + it.Public = data + case "lastUpdate": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastUpdate")) + data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + if err != nil { + return it, err + } + it.LastUpdate = data } } - return it, nil } -func (ec *executionContext) unmarshalInputAuthClientInput(ctx context.Context, obj any) (models.AuthClientInput, error) { - var it models.AuthClientInput +func (ec *executionContext) unmarshalInputAuthClientUpdateInput(ctx context.Context, obj any) (models.AuthClientUpdateInput, error) { + var it models.AuthClientUpdateInput + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -18436,213 +19013,430 @@ func (ec *executionContext) unmarshalInputAuthClientInput(ctx context.Context, o switch k { case "accountID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountID")) - data, err := ec.unmarshalOID642ᚖuint64(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOID642ᚖuint64(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *uint64 + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*uint64); ok { + it.AccountID = data + } else if tmp == nil { + it.AccountID = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *uint64`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.AccountID = data case "userID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) - data, err := ec.unmarshalOID642ᚖuint64(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOID642ᚖuint64(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *uint64 + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *uint64 + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*uint64); ok { + it.UserID = data + } else if tmp == nil { + it.UserID = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *uint64`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.UserID = data case "title": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*string); ok { + it.Title = data + } else if tmp == nil { + it.Title = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.Title = data case "secret": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("secret")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*string); ok { + it.Secret = data + } else if tmp == nil { + it.Secret = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.Secret = data case "redirectURIs": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("redirectURIs")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚕstringᚄ(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal []string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal []string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal []string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.([]string); ok { + it.RedirectURIs = data + } else if tmp == nil { + it.RedirectURIs = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be []string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.RedirectURIs = data case "grantTypes": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("grantTypes")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚕstringᚄ(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal []string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal []string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal []string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.([]string); ok { + it.GrantTypes = data + } else if tmp == nil { + it.GrantTypes = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be []string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.GrantTypes = data case "responseTypes": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("responseTypes")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.ResponseTypes = data - case "scope": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("scope")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚕstringᚄ(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal []string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal []string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal []string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) } - it.Scope = data - case "audience": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("audience")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) } - it.Audience = data - case "subjectType": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subjectType")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err + if data, ok := tmp.([]string); ok { + it.ResponseTypes = data + } else if tmp == nil { + it.ResponseTypes = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be []string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.SubjectType = data - case "allowedCORSOrigins": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("allowedCORSOrigins")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err + case "scope": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("scope")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) } - it.AllowedCORSOrigins = data - case "public": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) } - it.Public = data - case "expiresAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("expiresAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err + if data, ok := tmp.(*string); ok { + it.Scope = data + } else if tmp == nil { + it.Scope = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.ExpiresAt = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputAuthClientListFilter(ctx context.Context, obj any) (models.AuthClientListFilter, error) { - var it models.AuthClientListFilter - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } + case "audience": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("audience")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚕstringᚄ(ctx, v) } - fieldsInOrder := [...]string{"ID", "userID", "accountID", "public"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "ID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ID")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal []string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal []string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal []string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) } - it.ID = data - case "userID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) - data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) } - it.UserID = data - case "accountID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountID")) - data, err := ec.unmarshalOID642ᚕuint64ᚄ(ctx, v) - if err != nil { - return it, err + if data, ok := tmp.([]string); ok { + it.Audience = data + } else if tmp == nil { + it.Audience = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be []string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.AccountID = data - case "public": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err + case "subjectType": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subjectType")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) } - it.Public = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputAuthClientListOrder(ctx context.Context, obj any) (models.AuthClientListOrder, error) { - var it models.AuthClientListOrder - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } - fieldsInOrder := [...]string{"ID", "userID", "accountID", "title", "public", "lastUpdate"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "ID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ID")) - data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) } - it.ID = data - case "userID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userID")) - data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) - if err != nil { - return it, err + if data, ok := tmp.(*string); ok { + it.SubjectType = data + } else if tmp == nil { + it.SubjectType = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.UserID = data - case "accountID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("accountID")) - data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) - if err != nil { - return it, err + case "allowedCORSOrigins": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("allowedCORSOrigins")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚕstringᚄ(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal []string + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal []string + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal []string + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) } - it.AccountID = data - case "title": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) - data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.([]string); ok { + it.AllowedCORSOrigins = data + } else if tmp == nil { + it.AllowedCORSOrigins = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be []string`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.Title = data case "public": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("public")) - data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } it.Public = data - case "lastUpdate": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastUpdate")) - data, err := ec.unmarshalOOrdering2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOrdering(ctx, v) + case "expiresAt": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("expiresAt")) + directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) } + + directive1 := func(ctx context.Context) (any, error) { + trim, err := ec.unmarshalNBoolean2bool(ctx, false) + if err != nil { + var zeroVal *time.Time + return zeroVal, err + } + ornil, err := ec.unmarshalNBoolean2bool(ctx, true) + if err != nil { + var zeroVal *time.Time + return zeroVal, err + } + if ec.Directives.Notempty == nil { + var zeroVal *time.Time + return zeroVal, errors.New("directive notempty is not implemented") + } + return ec.Directives.Notempty(ctx, obj, directive0, trim, ornil) + } + + tmp, err := directive1(ctx) if err != nil { - return it, err + return it, graphql.ErrorOnPath(ctx, err) + } + if data, ok := tmp.(*time.Time); ok { + it.ExpiresAt = data + } else if tmp == nil { + it.ExpiresAt = nil + } else { + err := fmt.Errorf(`unexpected type %T from directive, should be *time.Time`, tmp) + return it, graphql.ErrorOnPath(ctx, err) } - it.LastUpdate = data } } - return it, nil } func (ec *executionContext) unmarshalInputDirectAccessTokenListFilter(ctx context.Context, obj any) (models.DirectAccessTokenListFilter, error) { var it models.DirectAccessTokenListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -18699,12 +19493,15 @@ func (ec *executionContext) unmarshalInputDirectAccessTokenListFilter(ctx contex it.MaxExpiresAt = data } } - return it, nil } func (ec *executionContext) unmarshalInputDirectAccessTokenListOrder(ctx context.Context, obj any) (models.DirectAccessTokenListOrder, error) { var it models.DirectAccessTokenListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -18761,12 +19558,15 @@ func (ec *executionContext) unmarshalInputDirectAccessTokenListOrder(ctx context it.ExpiresAt = data } } - return it, nil } func (ec *executionContext) unmarshalInputHistoryActionListFilter(ctx context.Context, obj any) (models.HistoryActionListFilter, error) { var it models.HistoryActionListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -18837,12 +19637,15 @@ func (ec *executionContext) unmarshalInputHistoryActionListFilter(ctx context.Co it.ObjectIDs = data } } - return it, nil } func (ec *executionContext) unmarshalInputHistoryActionListOrder(ctx context.Context, obj any) (models.HistoryActionListOrder, error) { var it models.HistoryActionListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -18920,12 +19723,15 @@ func (ec *executionContext) unmarshalInputHistoryActionListOrder(ctx context.Con it.ActionAt = data } } - return it, nil } func (ec *executionContext) unmarshalInputInviteMemberInput(ctx context.Context, obj any) (models.InviteMemberInput, error) { var it models.InviteMemberInput + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -18965,12 +19771,15 @@ func (ec *executionContext) unmarshalInputInviteMemberInput(ctx context.Context, it.IsAdmin = data } } - return it, nil } func (ec *executionContext) unmarshalInputMemberInput(ctx context.Context, obj any) (models.MemberInput, error) { var it models.MemberInput + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19003,12 +19812,15 @@ func (ec *executionContext) unmarshalInputMemberInput(ctx context.Context, obj a it.IsAdmin = data } } - return it, nil } func (ec *executionContext) unmarshalInputMemberListFilter(ctx context.Context, obj any) (models.MemberListFilter, error) { var it models.MemberListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19058,12 +19870,15 @@ func (ec *executionContext) unmarshalInputMemberListFilter(ctx context.Context, it.IsAdmin = data } } - return it, nil } func (ec *executionContext) unmarshalInputMemberListOrder(ctx context.Context, obj any) (models.MemberListOrder, error) { var it models.MemberListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19127,12 +19942,15 @@ func (ec *executionContext) unmarshalInputMemberListOrder(ctx context.Context, o it.UpdatedAt = data } } - return it, nil } func (ec *executionContext) unmarshalInputOptionListFilter(ctx context.Context, obj any) (models.OptionListFilter, error) { var it models.OptionListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19175,12 +19993,15 @@ func (ec *executionContext) unmarshalInputOptionListFilter(ctx context.Context, it.NamePattern = data } } - return it, nil } func (ec *executionContext) unmarshalInputOptionListOrder(ctx context.Context, obj any) (models.OptionListOrder, error) { var it models.OptionListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19223,12 +20044,15 @@ func (ec *executionContext) unmarshalInputOptionListOrder(ctx context.Context, o it.Value = data } } - return it, nil } func (ec *executionContext) unmarshalInputPage(ctx context.Context, obj any) (models.Page, error) { var it models.Page + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19271,12 +20095,15 @@ func (ec *executionContext) unmarshalInputPage(ctx context.Context, obj any) (mo it.Size = data } } - return it, nil } func (ec *executionContext) unmarshalInputRBACRoleInput(ctx context.Context, obj any) (models.RBACRoleInput, error) { var it models.RBACRoleInput + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19319,12 +20146,15 @@ func (ec *executionContext) unmarshalInputRBACRoleInput(ctx context.Context, obj it.Permissions = data } } - return it, nil } func (ec *executionContext) unmarshalInputRBACRoleListFilter(ctx context.Context, obj any) (models.RBACRoleListFilter, error) { var it models.RBACRoleListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19353,12 +20183,15 @@ func (ec *executionContext) unmarshalInputRBACRoleListFilter(ctx context.Context it.Name = data } } - return it, nil } func (ec *executionContext) unmarshalInputRBACRoleListOrder(ctx context.Context, obj any) (models.RBACRoleListOrder, error) { var it models.RBACRoleListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19394,12 +20227,15 @@ func (ec *executionContext) unmarshalInputRBACRoleListOrder(ctx context.Context, it.Title = data } } - return it, nil } func (ec *executionContext) unmarshalInputSocialAccountListFilter(ctx context.Context, obj any) (models.SocialAccountListFilter, error) { var it models.SocialAccountListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19449,12 +20285,15 @@ func (ec *executionContext) unmarshalInputSocialAccountListFilter(ctx context.Co it.Email = data } } - return it, nil } func (ec *executionContext) unmarshalInputSocialAccountListOrder(ctx context.Context, obj any) (models.SocialAccountListOrder, error) { var it models.SocialAccountListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19518,12 +20357,15 @@ func (ec *executionContext) unmarshalInputSocialAccountListOrder(ctx context.Con it.LastName = data } } - return it, nil } func (ec *executionContext) unmarshalInputUserInput(ctx context.Context, obj any) (models.UserInput, error) { var it models.UserInput + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19552,12 +20394,15 @@ func (ec *executionContext) unmarshalInputUserInput(ctx context.Context, obj any it.Status = data } } - return it, nil } func (ec *executionContext) unmarshalInputUserListFilter(ctx context.Context, obj any) (models.UserListFilter, error) { var it models.UserListFilter + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19600,12 +20445,15 @@ func (ec *executionContext) unmarshalInputUserListFilter(ctx context.Context, ob it.Roles = data } } - return it, nil } func (ec *executionContext) unmarshalInputUserListOrder(ctx context.Context, obj any) (models.UserListOrder, error) { var it models.UserListOrder + if obj == nil { + return it, nil + } + asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v @@ -19683,7 +20531,6 @@ func (ec *executionContext) unmarshalInputUserListOrder(ctx context.Context, obj it.UpdatedAt = data } } - return it, nil } @@ -19769,10 +20616,10 @@ func (ec *executionContext) _Account(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -19817,10 +20664,10 @@ func (ec *executionContext) _AccountConnection(ctx context.Context, sel ast.Sele return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -19866,10 +20713,10 @@ func (ec *executionContext) _AccountCreatePayload(ctx context.Context, sel ast.S return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -19907,10 +20754,10 @@ func (ec *executionContext) _AccountEdge(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -19953,10 +20800,10 @@ func (ec *executionContext) _AccountPayload(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20054,10 +20901,10 @@ func (ec *executionContext) _AuthClient(ctx context.Context, sel ast.SelectionSe return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20102,10 +20949,10 @@ func (ec *executionContext) _AuthClientConnection(ctx context.Context, sel ast.S return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20143,10 +20990,10 @@ func (ec *executionContext) _AuthClientEdge(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20189,10 +21036,10 @@ func (ec *executionContext) _AuthClientPayload(ctx context.Context, sel ast.Sele return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20255,10 +21102,10 @@ func (ec *executionContext) _DirectAccessToken(ctx context.Context, sel ast.Sele return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20303,10 +21150,10 @@ func (ec *executionContext) _DirectAccessTokenConnection(ctx context.Context, se return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20344,10 +21191,10 @@ func (ec *executionContext) _DirectAccessTokenEdge(ctx context.Context, sel ast. return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20385,10 +21232,10 @@ func (ec *executionContext) _DirectAccessTokenPayload(ctx context.Context, sel a return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20474,10 +21321,10 @@ func (ec *executionContext) _HistoryAction(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20522,10 +21369,10 @@ func (ec *executionContext) _HistoryActionConnection(ctx context.Context, sel as return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20566,10 +21413,10 @@ func (ec *executionContext) _HistoryActionEdge(ctx context.Context, sel ast.Sele return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20612,10 +21459,10 @@ func (ec *executionContext) _HistoryActionPayload(ctx context.Context, sel ast.S return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20685,10 +21532,10 @@ func (ec *executionContext) _Member(ctx context.Context, sel ast.SelectionSet, o return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20733,10 +21580,10 @@ func (ec *executionContext) _MemberConnection(ctx context.Context, sel ast.Selec return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20774,10 +21621,10 @@ func (ec *executionContext) _MemberEdge(ctx context.Context, sel ast.SelectionSe return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20820,10 +21667,10 @@ func (ec *executionContext) _MemberPayload(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -20860,135 +21707,128 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } - case "login": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_login(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "logout": + case "createUser": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_logout(ctx, field) + return ec._Mutation_createUser(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "switchAccount": + case "updateUser": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_switchAccount(ctx, field) + return ec._Mutation_updateUser(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "registerAccount": + case "approveUser": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_registerAccount(ctx, field) + return ec._Mutation_approveUser(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "updateAccount": + case "rejectUser": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateAccount(ctx, field) + return ec._Mutation_rejectUser(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "approveAccount": + case "resetUserPassword": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_approveAccount(ctx, field) + return ec._Mutation_resetUserPassword(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "rejectAccount": + case "updateUserPassword": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_rejectAccount(ctx, field) + return ec._Mutation_updateUserPassword(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "inviteAccountMember": + case "login": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_inviteAccountMember(ctx, field) + return ec._Mutation_login(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "updateAccountMember": + case "logout": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateAccountMember(ctx, field) + return ec._Mutation_logout(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "removeAccountMember": + case "switchAccount": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_removeAccountMember(ctx, field) + return ec._Mutation_switchAccount(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "approveAccountMember": + case "registerAccount": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_approveAccountMember(ctx, field) + return ec._Mutation_registerAccount(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "rejectAccountMember": + case "updateAccount": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_rejectAccountMember(ctx, field) + return ec._Mutation_updateAccount(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "disconnectSocialAccount": + case "approveAccount": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_disconnectSocialAccount(ctx, field) + return ec._Mutation_approveAccount(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "createUser": + case "rejectAccount": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_createUser(ctx, field) + return ec._Mutation_rejectAccount(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "updateUser": + case "inviteAccountMember": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateUser(ctx, field) + return ec._Mutation_inviteAccountMember(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "approveUser": + case "updateAccountMember": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_approveUser(ctx, field) + return ec._Mutation_updateAccountMember(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "rejectUser": + case "removeAccountMember": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_rejectUser(ctx, field) + return ec._Mutation_removeAccountMember(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "resetUserPassword": + case "approveAccountMember": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_resetUserPassword(ctx, field) + return ec._Mutation_approveAccountMember(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "updateUserPassword": + case "rejectAccountMember": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateUserPassword(ctx, field) + return ec._Mutation_rejectAccountMember(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ @@ -21050,6 +21890,13 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } + case "disconnectSocialAccount": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_disconnectSocialAccount(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -21059,10 +21906,10 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21110,10 +21957,10 @@ func (ec *executionContext) _Option(ctx context.Context, sel ast.SelectionSet, o return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21164,10 +22011,10 @@ func (ec *executionContext) _OptionConnection(ctx context.Context, sel ast.Selec return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21208,10 +22055,10 @@ func (ec *executionContext) _OptionEdge(ctx context.Context, sel ast.SelectionSe return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21254,10 +22101,10 @@ func (ec *executionContext) _OptionPayload(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21323,10 +22170,10 @@ func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21404,10 +22251,10 @@ func (ec *executionContext) _Profile(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21448,10 +22295,10 @@ func (ec *executionContext) _ProfileMessanger(ctx context.Context, sel ast.Selec return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -21468,42 +22315,20 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", - }) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "serviceVersion": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_serviceVersion(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } + }) - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "currentSession": + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ + Object: field.Name, + Field: field, + }) + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "serviceVersion": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -21512,7 +22337,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_currentSession(ctx, field) + res = ec._Query_serviceVersion(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -21525,7 +22350,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "currentAccount": + case "currentUser": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -21534,7 +22359,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_currentAccount(ctx, field) + res = ec._Query_currentUser(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -21547,7 +22372,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "account": + case "user": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -21556,7 +22381,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_account(ctx, field) + res = ec._Query_user(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -21569,45 +22394,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "listAccounts": - field := field - - innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_listAccounts(ctx, field) - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "listAccountRolesAndPermissions": - field := field - - innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_listAccountRolesAndPermissions(ctx, field) - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "listMembers": + case "listUsers": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { @@ -21616,7 +22403,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_listMembers(ctx, field) + res = ec._Query_listUsers(ctx, field) return res } @@ -21626,7 +22413,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "socialAccount": + case "currentSession": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -21635,7 +22422,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_socialAccount(ctx, field) + res = ec._Query_currentSession(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -21648,7 +22435,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "currentSocialAccounts": + case "currentAccount": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -21657,7 +22444,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_currentSocialAccounts(ctx, field) + res = ec._Query_currentAccount(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -21670,7 +22457,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "listSocialAccounts": + case "account": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -21679,7 +22466,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_listSocialAccounts(ctx, field) + res = ec._Query_account(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -21692,19 +22479,16 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "currentUser": + case "listAccounts": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_currentUser(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_listAccounts(ctx, field) return res } @@ -21714,19 +22498,16 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "user": + case "listAccountRolesAndPermissions": field := field - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_user(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_listAccountRolesAndPermissions(ctx, field) return res } @@ -21736,7 +22517,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "listUsers": + case "listMembers": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { @@ -21745,7 +22526,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_listUsers(ctx, field) + res = ec._Query_listMembers(ctx, field) return res } @@ -21991,6 +22772,72 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "socialAccount": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_socialAccount(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "currentSocialAccounts": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_currentSocialAccounts(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "listSocialAccounts": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_listSocialAccounts(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { @@ -22009,10 +22856,10 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22065,10 +22912,10 @@ func (ec *executionContext) _RBACPermission(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22136,10 +22983,10 @@ func (ec *executionContext) _RBACRole(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22184,10 +23031,10 @@ func (ec *executionContext) _RBACRoleConnection(ctx context.Context, sel ast.Sel return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22225,10 +23072,10 @@ func (ec *executionContext) _RBACRoleEdge(ctx context.Context, sel ast.Selection return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22271,10 +23118,10 @@ func (ec *executionContext) _RBACRolePayload(ctx context.Context, sel ast.Select return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22322,10 +23169,10 @@ func (ec *executionContext) _SessionToken(ctx context.Context, sel ast.Selection return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22425,10 +23272,10 @@ func (ec *executionContext) _SocialAccount(ctx context.Context, sel ast.Selectio return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22473,10 +23320,10 @@ func (ec *executionContext) _SocialAccountConnection(ctx context.Context, sel as return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22514,10 +23361,10 @@ func (ec *executionContext) _SocialAccountEdge(ctx context.Context, sel ast.Sele return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22560,10 +23407,10 @@ func (ec *executionContext) _SocialAccountPayload(ctx context.Context, sel ast.S return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22635,10 +23482,10 @@ func (ec *executionContext) _SocialAccountSession(ctx context.Context, sel ast.S return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22681,10 +23528,10 @@ func (ec *executionContext) _StatusResponse(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22742,10 +23589,10 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22790,10 +23637,10 @@ func (ec *executionContext) _UserConnection(ctx context.Context, sel ast.Selecti return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22831,10 +23678,10 @@ func (ec *executionContext) _UserEdge(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22877,10 +23724,10 @@ func (ec *executionContext) _UserPayload(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22933,10 +23780,10 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -22981,10 +23828,10 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -23039,10 +23886,10 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -23094,10 +23941,10 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -23149,10 +23996,10 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -23208,10 +24055,10 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o return graphql.Null } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ + ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, @@ -23309,6 +24156,11 @@ func (ec *executionContext) marshalNAuthClient2ᚖgithubᚗcomᚋgeniusrabbitᚋ return ec._AuthClient(ctx, sel, v) } +func (ec *executionContext) unmarshalNAuthClientCreateInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientCreateInput(ctx context.Context, v any) (models.AuthClientCreateInput, error) { + res, err := ec.unmarshalInputAuthClientCreateInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalNAuthClientEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientEdge(ctx context.Context, sel ast.SelectionSet, v *models.AuthClientEdge) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -23319,11 +24171,6 @@ func (ec *executionContext) marshalNAuthClientEdge2ᚖgithubᚗcomᚋgeniusrabbi return ec._AuthClientEdge(ctx, sel, v) } -func (ec *executionContext) unmarshalNAuthClientInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientInput(ctx context.Context, v any) (models.AuthClientInput, error) { - res, err := ec.unmarshalInputAuthClientInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) marshalNAuthClientPayload2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientPayload(ctx context.Context, sel ast.SelectionSet, v models.AuthClientPayload) graphql.Marshaler { return ec._AuthClientPayload(ctx, sel, &v) } @@ -23338,6 +24185,11 @@ func (ec *executionContext) marshalNAuthClientPayload2ᚖgithubᚗcomᚋgeniusra return ec._AuthClientPayload(ctx, sel, v) } +func (ec *executionContext) unmarshalNAuthClientUpdateInput2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientUpdateInput(ctx context.Context, v any) (models.AuthClientUpdateInput, error) { + res, err := ec.unmarshalInputAuthClientUpdateInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v any) (bool, error) { res, err := graphql.UnmarshalBoolean(v) return res, graphql.ErrorOnPath(ctx, err) @@ -23379,6 +24231,22 @@ func (ec *executionContext) unmarshalNDirectAccessTokenListFilter2githubᚗcom return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v any) (float64, error) { + res, err := graphql.UnmarshalFloatContext(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { + _ = sel + res := graphql.MarshalFloatContext(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + } + return graphql.WrapContextMarshaler(ctx, res) +} + func (ec *executionContext) marshalNHistoryAction2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐHistoryAction(ctx context.Context, sel ast.SelectionSet, v *models.HistoryAction) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -23512,39 +24380,11 @@ func (ec *executionContext) marshalNNullableJSON2githubᚗcomᚋgeniusrabbitᚋb } func (ec *executionContext) marshalNOption2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOptionᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.Option) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNOption2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOption(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNOption2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOption(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -23566,39 +24406,11 @@ func (ec *executionContext) marshalNOption2ᚖgithubᚗcomᚋgeniusrabbitᚋblaz } func (ec *executionContext) marshalNOptionEdge2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOptionEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.OptionEdge) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNOptionEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOptionEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNOptionEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOptionEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -23930,39 +24742,11 @@ func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24005,39 +24789,11 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx conte } func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24061,39 +24817,11 @@ func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlg } func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24109,39 +24837,11 @@ func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24182,39 +24882,11 @@ func (ec *executionContext) marshalOAccount2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋ if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNAccount2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccount(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNAccount2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccount(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24243,39 +24915,11 @@ func (ec *executionContext) marshalOAccountEdge2ᚕᚖgithubᚗcomᚋgeniusrabbi if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNAccountEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNAccountEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAccountEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24324,39 +24968,11 @@ func (ec *executionContext) marshalOApproveStatus2ᚕgithubᚗcomᚋgeniusrabbit if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNApproveStatus2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐApproveStatus(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNApproveStatus2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐApproveStatus(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24387,39 +25003,11 @@ func (ec *executionContext) marshalOAuthClient2ᚕᚖgithubᚗcomᚋgeniusrabbit if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNAuthClient2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClient(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNAuthClient2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClient(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24448,39 +25036,11 @@ func (ec *executionContext) marshalOAuthClientEdge2ᚕᚖgithubᚗcomᚋgeniusra if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNAuthClientEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNAuthClientEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24499,6 +25059,24 @@ func (ec *executionContext) unmarshalOAuthClientListFilter2ᚖgithubᚗcomᚋgen return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalOAuthClientListOrder2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientListOrder(ctx context.Context, v any) ([]*models.AuthClientListOrder, error) { + if v == nil { + return nil, nil + } + var vSlice []any + vSlice = graphql.CoerceList(v) + var err error + res := make([]*models.AuthClientListOrder, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalOAuthClientListOrder2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientListOrder(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + func (ec *executionContext) unmarshalOAuthClientListOrder2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐAuthClientListOrder(ctx context.Context, v any) (*models.AuthClientListOrder, error) { if v == nil { return nil, nil @@ -24541,39 +25119,11 @@ func (ec *executionContext) marshalODirectAccessToken2ᚕᚖgithubᚗcomᚋgeniu if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNDirectAccessToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐDirectAccessToken(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNDirectAccessToken2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐDirectAccessToken(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24602,39 +25152,11 @@ func (ec *executionContext) marshalODirectAccessTokenEdge2ᚕᚖgithubᚗcomᚋg if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNDirectAccessTokenEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐDirectAccessTokenEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNDirectAccessTokenEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐDirectAccessTokenEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24672,39 +25194,11 @@ func (ec *executionContext) marshalOHistoryAction2ᚕᚖgithubᚗcomᚋgeniusrab if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNHistoryAction2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐHistoryAction(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNHistoryAction2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐHistoryAction(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24726,39 +25220,11 @@ func (ec *executionContext) marshalOHistoryActionEdge2ᚕᚖgithubᚗcomᚋgeniu if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNHistoryActionEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐHistoryActionEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNHistoryActionEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐHistoryActionEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24861,39 +25327,11 @@ func (ec *executionContext) marshalOMember2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋb if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNMember2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMember(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNMember2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMember(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -24922,39 +25360,11 @@ func (ec *executionContext) marshalOMemberEdge2ᚕᚖgithubᚗcomᚋgeniusrabbit if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNMemberEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNMemberEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐMemberEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25049,39 +25459,11 @@ func (ec *executionContext) marshalOOptionType2ᚕgithubᚗcomᚋgeniusrabbitᚋ if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNOptionType2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOptionType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNOptionType2githubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐOptionType(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25120,39 +25502,11 @@ func (ec *executionContext) marshalOProfileMessanger2ᚕᚖgithubᚗcomᚋgenius if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNProfileMessanger2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐProfileMessanger(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNProfileMessanger2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐProfileMessanger(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25167,39 +25521,11 @@ func (ec *executionContext) marshalORBACPermission2ᚕᚖgithubᚗcomᚋgeniusra if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNRBACPermission2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACPermission(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNRBACPermission2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACPermission(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25214,39 +25540,11 @@ func (ec *executionContext) marshalORBACRole2ᚕᚖgithubᚗcomᚋgeniusrabbit if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNRBACRole2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACRole(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNRBACRole2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACRole(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25275,39 +25573,11 @@ func (ec *executionContext) marshalORBACRoleEdge2ᚕᚖgithubᚗcomᚋgeniusrabb if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNRBACRoleEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACRoleEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNRBACRoleEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐRBACRoleEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25338,39 +25608,11 @@ func (ec *executionContext) marshalOSocialAccount2ᚕᚖgithubᚗcomᚋgeniusrab if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNSocialAccount2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccount(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNSocialAccount2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccount(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25392,39 +25634,11 @@ func (ec *executionContext) marshalOSocialAccountEdge2ᚕᚖgithubᚗcomᚋgeniu if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNSocialAccountEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNSocialAccountEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25455,39 +25669,11 @@ func (ec *executionContext) marshalOSocialAccountSession2ᚕᚖgithubᚗcomᚋge if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNSocialAccountSession2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountSession(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNSocialAccountSession2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐSocialAccountSession(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25617,39 +25803,11 @@ func (ec *executionContext) marshalOUser2ᚕᚖgithubᚗcomᚋgeniusrabbitᚋbla if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNUser2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUser(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNUser2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUser(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25678,39 +25836,11 @@ func (ec *executionContext) marshalOUserEdge2ᚕᚖgithubᚗcomᚋgeniusrabbit if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNUserEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserEdge(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalNUserEdge2ᚖgithubᚗcomᚋgeniusrabbitᚋblazeᚑapiᚋserverᚋgraphqlᚋmodelsᚐUserEdge(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25749,39 +25879,11 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25796,39 +25898,11 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25843,39 +25917,11 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { @@ -25897,39 +25943,11 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen if v == nil { return graphql.Null } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() + ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { + fc := graphql.GetFieldContext(ctx) + fc.Result = &v[i] + return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + }) for _, e := range ret { if e == graphql.Null { diff --git a/server/graphql/models/account_convertor.go b/server/graphql/models/account_convertor.go index 0d7bbdab..bc9fe902 100644 --- a/server/graphql/models/account_convertor.go +++ b/server/graphql/models/account_convertor.go @@ -3,12 +3,12 @@ package models import ( "github.com/demdxx/xtypes" - "github.com/geniusrabbit/blaze-api/model" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/repository/account" ) // FromAccountModel to local graphql model -func FromAccountModel(acc *model.Account) *Account { +func FromAccountModel(acc *account.Account) *Account { if acc == nil { return nil } @@ -28,7 +28,7 @@ func FromAccountModel(acc *model.Account) *Account { } // FromAccountModelList converts model list to local model list -func FromAccountModelList(list []*model.Account) []*Account { +func FromAccountModelList(list []*account.Account) []*Account { return xtypes.SliceApply(list, FromAccountModel) } @@ -41,24 +41,24 @@ func (fl *AccountListFilter) Filter() *account.Filter { ID: fl.ID, UserID: fl.UserID, Title: fl.Title, - Status: xtypes.SliceApply(fl.Status, func(st ApproveStatus) model.ApproveStatus { + Status: xtypes.SliceApply(fl.Status, func(st ApproveStatus) pkgModels.ApproveStatus { return st.ModelStatus() }), } } // Model converts local graphql model to model -func (acc *AccountInput) Model(appStatus ...model.ApproveStatus) *model.Account { +func (acc *AccountInput) Model(appStatus ...pkgModels.ApproveStatus) *account.Account { if acc == nil { return nil } - var status model.ApproveStatus + var status pkgModels.ApproveStatus if len(appStatus) == 0 { status = acc.Status.ModelStatus() } else { status = appStatus[0] } - return &model.Account{ + return &account.Account{ Approve: status, Title: s4ptr(acc.Title), Description: s4ptr(acc.Description), @@ -76,9 +76,9 @@ func (ord *AccountListOrder) Order() *account.ListOrder { } return &account.ListOrder{ // UserID: ord.UserID.AsOrder(), - ID: ord.ID.AsOrder(), - Title: ord.Title.AsOrder(), - Status: ord.Status.AsOrder(), + ID: pkgModels.Order(ord.ID.AsOrder()), + Title: pkgModels.Order(ord.Title.AsOrder()), + Status: pkgModels.Order(ord.Status.AsOrder()), // CreatedAt: ord.CreatedAt.AsOrder(), // UpdatedAt: ord.UpdatedAt.AsOrder(), } diff --git a/server/graphql/models/authclient_convertor.go b/server/graphql/models/authclient_convertor.go index a2c36d72..113ba9f2 100644 --- a/server/graphql/models/authclient_convertor.go +++ b/server/graphql/models/authclient_convertor.go @@ -2,11 +2,11 @@ package models import ( "github.com/demdxx/xtypes" - "github.com/geniusrabbit/blaze-api/model" + "github.com/geniusrabbit/blaze-api/repository/authclient" ) // FromAuthClientModel to local graphql model -func FromAuthClientModel(acc *model.AuthClient) *AuthClient { +func FromAuthClientModel(acc *authclient.AuthClient) *AuthClient { if acc == nil { return nil } @@ -31,6 +31,6 @@ func FromAuthClientModel(acc *model.AuthClient) *AuthClient { } // FromAuthClientModelList converts model list to local model list -func FromAuthClientModelList(list []*model.AuthClient) []*AuthClient { +func FromAuthClientModelList(list []*authclient.AuthClient) []*AuthClient { return xtypes.SliceApply(list, FromAuthClientModel) } diff --git a/server/graphql/models/directaccesstoken_convertor.go b/server/graphql/models/directaccesstoken_convertor.go index 698b89f0..e659ec50 100644 --- a/server/graphql/models/directaccesstoken_convertor.go +++ b/server/graphql/models/directaccesstoken_convertor.go @@ -6,11 +6,11 @@ import ( "github.com/demdxx/gocast/v2" "github.com/demdxx/xtypes" - "github.com/geniusrabbit/blaze-api/model" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/repository/directaccesstoken" ) -func FromDirectAccessToken(token *model.DirectAccessToken) *DirectAccessToken { +func FromDirectAccessToken(token *directaccesstoken.DirectAccessToken) *DirectAccessToken { if token == nil { return nil } @@ -25,8 +25,8 @@ func FromDirectAccessToken(token *model.DirectAccessToken) *DirectAccessToken { } } -func FromDirectAccessTokenModelList(list []*model.DirectAccessToken) []*DirectAccessToken { - return xtypes.SliceApply(list, func(m *model.DirectAccessToken) *DirectAccessToken { +func FromDirectAccessTokenModelList(list []*directaccesstoken.DirectAccessToken) []*DirectAccessToken { + return xtypes.SliceApply(list, func(m *directaccesstoken.DirectAccessToken) *DirectAccessToken { return FromDirectAccessToken(m) }) } @@ -47,16 +47,16 @@ func (fl *DirectAccessTokenListFilter) Filter() *directaccesstoken.Filter { } } -func (ord *DirectAccessTokenListOrder) Order() *directaccesstoken.Order { +func (ord *DirectAccessTokenListOrder) Order() *directaccesstoken.ListOrder { if ord == nil { return nil } - return &directaccesstoken.Order{ - ID: ord.ID.AsOrder(), - Token: ord.Token.AsOrder(), - UserID: ord.UserID.AsOrder(), - AccountID: ord.AccountID.AsOrder(), - ExpiresAt: ord.ExpiresAt.AsOrder(), - CreatedAt: ord.CreatedAt.AsOrder(), + return &directaccesstoken.ListOrder{ + ID: pkgModels.Order(ord.ID.AsOrder()), + Token: pkgModels.Order(ord.Token.AsOrder()), + UserID: pkgModels.Order(ord.UserID.AsOrder()), + AccountID: pkgModels.Order(ord.AccountID.AsOrder()), + ExpiresAt: pkgModels.Order(ord.ExpiresAt.AsOrder()), + CreatedAt: pkgModels.Order(ord.CreatedAt.AsOrder()), } } diff --git a/server/graphql/models/generated.go b/server/graphql/models/generated.go index c62b07ef..aba96f56 100644 --- a/server/graphql/models/generated.go +++ b/server/graphql/models/generated.go @@ -152,6 +152,36 @@ type AuthClient struct { DeletedAt *time.Time `json:"deletedAt,omitempty"` } +// AuthClientCreateInput is used to create a new OAuth 2.0 client +type AuthClientCreateInput struct { + // AccountID of the auth client owner + AccountID *uint64 `json:"accountID,omitempty"` + // UserID of the auth client creator + UserID *uint64 `json:"userID,omitempty"` + // Title of the auth client as human readable name + Title *string `json:"title,omitempty"` + // Secret for the OAuth 2.0 client + Secret *string `json:"secret,omitempty"` + // RedirectURIs allowed for this client + RedirectURIs []string `json:"redirectURIs,omitempty"` + // GrantTypes allowed for this client + GrantTypes []string `json:"grantTypes,omitempty"` + // ResponseTypes allowed for this client + ResponseTypes []string `json:"responseTypes,omitempty"` + // Scope string for the client + Scope *string `json:"scope,omitempty"` + // Audience whitelist for token requests + Audience []string `json:"audience,omitempty"` + // SubjectType for responses to this client + SubjectType string `json:"subjectType"` + // AllowedCORSOrigins for this client + AllowedCORSOrigins []string `json:"allowedCORSOrigins,omitempty"` + // Public flag for the client + Public *bool `json:"public,omitempty"` + // ExpiresAt time for the client + ExpiresAt *time.Time `json:"expiresAt,omitempty"` +} + type AuthClientEdge struct { // A cursor for use in pagination. Cursor string `json:"cursor"` @@ -159,22 +189,6 @@ type AuthClientEdge struct { Node *AuthClient `json:"node,omitempty"` } -type AuthClientInput struct { - AccountID *uint64 `json:"accountID,omitempty"` - UserID *uint64 `json:"userID,omitempty"` - Title *string `json:"title,omitempty"` - Secret *string `json:"secret,omitempty"` - RedirectURIs []string `json:"redirectURIs,omitempty"` - GrantTypes []string `json:"grantTypes,omitempty"` - ResponseTypes []string `json:"responseTypes,omitempty"` - Scope *string `json:"scope,omitempty"` - Audience []string `json:"audience,omitempty"` - SubjectType string `json:"subjectType"` - AllowedCORSOrigins []string `json:"allowedCORSOrigins,omitempty"` - Public *bool `json:"public,omitempty"` - ExpiresAt *time.Time `json:"expiresAt,omitempty"` -} - type AuthClientListFilter struct { ID []string `json:"ID,omitempty"` UserID []uint64 `json:"userID,omitempty"` @@ -201,6 +215,36 @@ type AuthClientPayload struct { AuthClient *AuthClient `json:"authClient,omitempty"` } +// AuthClientUpdateInput is used to update an existing OAuth 2.0 client +type AuthClientUpdateInput struct { + // AccountID of the auth client owner + AccountID *uint64 `json:"accountID,omitempty"` + // UserID of the auth client creator + UserID *uint64 `json:"userID,omitempty"` + // Title of the auth client as human readable name + Title *string `json:"title,omitempty"` + // Secret for the OAuth 2.0 client + Secret *string `json:"secret,omitempty"` + // RedirectURIs allowed for this client + RedirectURIs []string `json:"redirectURIs,omitempty"` + // GrantTypes allowed for this client + GrantTypes []string `json:"grantTypes,omitempty"` + // ResponseTypes allowed for this client + ResponseTypes []string `json:"responseTypes,omitempty"` + // Scope string for the client + Scope *string `json:"scope,omitempty"` + // Audience whitelist for token requests + Audience []string `json:"audience,omitempty"` + // SubjectType for responses to this client + SubjectType *string `json:"subjectType,omitempty"` + // AllowedCORSOrigins for this client + AllowedCORSOrigins []string `json:"allowedCORSOrigins,omitempty"` + // Public flag for the client + Public *bool `json:"public,omitempty"` + // ExpiresAt time for the client + ExpiresAt *time.Time `json:"expiresAt,omitempty"` +} + type DirectAccessToken struct { ID uint64 `json:"ID"` Token string `json:"token"` diff --git a/server/graphql/models/historyaction_convertor.go b/server/graphql/models/historyaction_convertor.go index 0d8a1574..cc65a453 100644 --- a/server/graphql/models/historyaction_convertor.go +++ b/server/graphql/models/historyaction_convertor.go @@ -2,13 +2,12 @@ package models import ( "github.com/demdxx/xtypes" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/repository/historylog" "github.com/geniusrabbit/blaze-api/server/graphql/types" ) // FromHistoryAction converts HistoryAction to HistoryAction -func FromHistoryAction(action *model.HistoryAction) *HistoryAction { +func FromHistoryAction(action *historylog.HistoryAction) *HistoryAction { if action == nil { return nil } @@ -31,7 +30,7 @@ func FromHistoryAction(action *model.HistoryAction) *HistoryAction { } // FromHistoryActionModelList converts list of HistoryAction to list of HistoryAction -func FromHistoryActionModelList(list []*model.HistoryAction) []*HistoryAction { +func FromHistoryActionModelList(list []*historylog.HistoryAction) []*HistoryAction { return xtypes.SliceApply(list, FromHistoryAction) } diff --git a/server/graphql/models/member_converter.go b/server/graphql/models/member_converter.go index b2e1f963..1bfdce7e 100644 --- a/server/graphql/models/member_converter.go +++ b/server/graphql/models/member_converter.go @@ -5,20 +5,21 @@ import ( "github.com/demdxx/gocast/v2" "github.com/demdxx/xtypes" - "github.com/geniusrabbit/blaze-api/model" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/repository/account" + "github.com/geniusrabbit/blaze-api/repository/user" "github.com/guregu/null" ) // FromMemberModel to local graphql model -func FromMemberModel(ctx context.Context, member *model.AccountMember) *Member { +func FromMemberModel(ctx context.Context, member *account.AccountMember) *Member { if member == nil { return nil } return &Member{ ID: member.ID, - Account: FromAccountModel(gocast.Or(member.Account, &model.Account{ID: member.AccountID})), - User: FromUserModel(gocast.Or(member.User, &model.User{ID: member.UserID})), + Account: FromAccountModel(gocast.Or(member.Account, &account.Account{ID: member.AccountID})), + User: FromUserModel(gocast.Or(member.User, &user.User{ID: member.UserID})), IsAdmin: member.IsAdmin, Status: ApproveStatusFrom(member.Approve), Roles: FromRBACRoleModelList(ctx, member.Roles), @@ -27,8 +28,8 @@ func FromMemberModel(ctx context.Context, member *model.AccountMember) *Member { } } -func FromMemberModelList(ctx context.Context, list []*model.AccountMember) []*Member { - return xtypes.SliceApply(list, func(m *model.AccountMember) *Member { +func FromMemberModelList(ctx context.Context, list []*account.AccountMember) []*Member { + return xtypes.SliceApply(list, func(m *account.AccountMember) *Member { return FromMemberModel(ctx, m) }) } @@ -50,13 +51,13 @@ func (ord *MemberListOrder) Order() *account.MemberListOrder { return nil } return &account.MemberListOrder{ - ID: ord.ID.AsOrder(), - AccountID: ord.AccountID.AsOrder(), - UserID: ord.UserID.AsOrder(), - Status: ord.Status.AsOrder(), - IsAdmin: ord.IsAdmin.AsOrder(), - CreatedAt: ord.CreatedAt.AsOrder(), - UpdatedAt: ord.UpdatedAt.AsOrder(), + ID: pkgModels.Order(ord.ID.AsOrder()), + AccountID: pkgModels.Order(ord.AccountID.AsOrder()), + UserID: pkgModels.Order(ord.UserID.AsOrder()), + Status: pkgModels.Order(ord.Status.AsOrder()), + IsAdmin: pkgModels.Order(ord.IsAdmin.AsOrder()), + CreatedAt: pkgModels.Order(ord.CreatedAt.AsOrder()), + UpdatedAt: pkgModels.Order(ord.UpdatedAt.AsOrder()), } } diff --git a/server/graphql/models/option_converter.go b/server/graphql/models/option_converter.go index adbaa6b4..b1e88c2e 100644 --- a/server/graphql/models/option_converter.go +++ b/server/graphql/models/option_converter.go @@ -3,33 +3,32 @@ package models import ( "github.com/demdxx/xtypes" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/repository/option" "github.com/geniusrabbit/blaze-api/server/graphql/types" ) -func FromOptionType(tp model.OptionType) OptionType { +func FromOptionType(tp option.OptionType) OptionType { switch tp { - case model.UserOptionType: + case option.UserOptionType: return OptionTypeUser - case model.AccountOptionType: + case option.AccountOptionType: return OptionTypeAccount - case model.SystemOptionType: + case option.SystemOptionType: return OptionTypeSystem } return OptionTypeUndefined } -func (tp OptionType) ModelType() model.OptionType { +func (tp OptionType) ModelType() option.OptionType { switch tp { case OptionTypeUser: - return model.UserOptionType + return option.UserOptionType case OptionTypeAccount: - return model.AccountOptionType + return option.AccountOptionType case OptionTypeSystem: - return model.SystemOptionType + return option.SystemOptionType } - return model.UndefinedOptionType + return option.UndefinedOptionType } func (fl *OptionListFilter) Filter() *option.Filter { @@ -37,7 +36,7 @@ func (fl *OptionListFilter) Filter() *option.Filter { return nil } return &option.Filter{ - Type: xtypes.SliceApply(fl.Type, func(tp OptionType) model.OptionType { return tp.ModelType() }), + Type: xtypes.SliceApply(fl.Type, func(tp OptionType) option.OptionType { return tp.ModelType() }), TargetID: fl.TargetID, Name: fl.Name, NamePattern: fl.NamePattern, @@ -54,7 +53,7 @@ func (ol *OptionListOrder) Order() *option.ListOrder { } } -func FromOption(opt *model.Option) *Option { +func FromOption(opt *option.Option) *Option { if opt == nil { return nil } @@ -66,6 +65,6 @@ func FromOption(opt *model.Option) *Option { } } -func FromOptionModelList(opts []*model.Option) []*Option { +func FromOptionModelList(opts []*option.Option) []*Option { return xtypes.SliceApply(opts, FromOption) } diff --git a/server/graphql/models/order.go b/server/graphql/models/order.go index 620ab81d..58fd1202 100644 --- a/server/graphql/models/order.go +++ b/server/graphql/models/order.go @@ -3,7 +3,7 @@ package models import ( "fmt" - "github.com/geniusrabbit/blaze-api/model" + "github.com/geniusrabbit/blaze-api/pkg/models" ) func (order *Ordering) Int8() int8 { @@ -18,15 +18,15 @@ func (order *Ordering) Int8() int8 { return 0 } -func (order *Ordering) AsOrder() model.Order { +func (order *Ordering) AsOrder() models.Order { if order != nil { fmt.Println("order: ", *order) switch *order { case OrderingAsc: - return model.OrderAsc + return models.OrderAsc case OrderingDesc: - return model.OrderDesc + return models.OrderDesc } } - return model.OrderUndefined + return models.OrderUndefined } diff --git a/server/graphql/models/rbac_converter.go b/server/graphql/models/rbac_converter.go index 39848920..d00fb75d 100644 --- a/server/graphql/models/rbac_converter.go +++ b/server/graphql/models/rbac_converter.go @@ -7,7 +7,7 @@ import ( mrbac "github.com/demdxx/rbac" "github.com/demdxx/xtypes" - "github.com/geniusrabbit/blaze-api/model" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/pkg/permissions" "github.com/geniusrabbit/blaze-api/repository/rbac" "github.com/geniusrabbit/blaze-api/server/graphql/types" @@ -58,7 +58,7 @@ func FromRBACPermissionModelList(perms []mrbac.Permission) []*RBACPermission { } // FromRBACRoleModel to local graphql model -func FromRBACRoleModel(ctx context.Context, role *model.Role) *RBACRole { +func FromRBACRoleModel(ctx context.Context, role *rbac.Role) *RBACRole { perms := permissions.FromContext(ctx).Permissions(role.PermissionPatterns...) return &RBACRole{ ID: role.ID, @@ -79,8 +79,8 @@ func FromRBACRoleModel(ctx context.Context, role *model.Role) *RBACRole { } // FromRBACRoleModelList converts model list to local model list -func FromRBACRoleModelList(ctx context.Context, list []*model.Role) []*RBACRole { - return xtypes.SliceApply(list, func(val *model.Role) *RBACRole { +func FromRBACRoleModelList(ctx context.Context, list []*rbac.Role) []*RBACRole { + return xtypes.SliceApply(list, func(val *rbac.Role) *RBACRole { return FromRBACRoleModel(ctx, val) }) } @@ -100,8 +100,8 @@ func (ol *RBACRoleListOrder) Order() *rbac.Order { return nil } return &rbac.Order{ - ID: ol.ID.AsOrder(), - Name: ol.Name.AsOrder(), - Title: ol.Title.AsOrder(), + ID: pkgModels.Order(ol.ID.AsOrder()), + Name: pkgModels.Order(ol.Name.AsOrder()), + Title: pkgModels.Order(ol.Title.AsOrder()), } } diff --git a/server/graphql/models/socialaccount_convertor.go b/server/graphql/models/socialaccount_convertor.go index 061b8cdd..e63da286 100644 --- a/server/graphql/models/socialaccount_convertor.go +++ b/server/graphql/models/socialaccount_convertor.go @@ -4,12 +4,11 @@ import ( "github.com/demdxx/gocast/v2" "github.com/demdxx/xtypes" - "github.com/geniusrabbit/blaze-api/model" "github.com/geniusrabbit/blaze-api/repository/socialaccount" "github.com/geniusrabbit/blaze-api/server/graphql/types" ) -func FromSocialAccountModel(acc *model.AccountSocial) *SocialAccount { +func FromSocialAccountModel(acc *socialaccount.AccountSocial) *SocialAccount { if acc == nil { return nil } @@ -35,11 +34,11 @@ func FromSocialAccountModel(acc *model.AccountSocial) *SocialAccount { } } -func FromSocialAccountModelList(list []*model.AccountSocial) []*SocialAccount { +func FromSocialAccountModelList(list []*socialaccount.AccountSocial) []*SocialAccount { return xtypes.SliceApply(list, FromSocialAccountModel) } -func FromSocialAccountSessionModel(sess *model.AccountSocialSession) *SocialAccountSession { +func FromSocialAccountSessionModel(sess *socialaccount.AccountSocialSession) *SocialAccountSession { if sess == nil { return nil } @@ -58,7 +57,7 @@ func FromSocialAccountSessionModel(sess *model.AccountSocialSession) *SocialAcco } } -func FromSocialAccountSessionModelList(list []*model.AccountSocialSession) []*SocialAccountSession { +func FromSocialAccountSessionModelList(list []*socialaccount.AccountSocialSession) []*SocialAccountSession { return xtypes.SliceApply(list, FromSocialAccountSessionModel) } diff --git a/server/graphql/models/status.go b/server/graphql/models/status.go index 83d1bec4..b9efbfdb 100644 --- a/server/graphql/models/status.go +++ b/server/graphql/models/status.go @@ -1,74 +1,52 @@ package models -import "github.com/geniusrabbit/blaze-api/model" - -// // StatusFrom model value -// func StatusFrom(status model.ActiveStatus) ActiveStatus { -// switch status { -// case model.ActiveStatus: -// return ActiveStatusActive -// case model.PausedStatus: -// return ActiveStatusPaused -// } -// return ActiveStatusPaused -// } - -// // Value model status -// func (status ActiveStatus) Value() model.Status { -// switch status { -// case ActiveStatusActive: -// return model.ActiveStatus -// case ActiveStatusPaused: -// return model.PausedStatus -// } -// return model.PausedStatus -// } +import pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" // ModelStatus returns status type from models -func (status *ApproveStatus) ModelStatus() model.ApproveStatus { +func (status *ApproveStatus) ModelStatus() pkgModels.ApproveStatus { if status == nil { - return model.UndefinedApproveStatus + return pkgModels.UndefinedApproveStatus } switch *status { case ApproveStatusApproved: - return model.ApprovedApproveStatus + return pkgModels.ApprovedApproveStatus case ApproveStatusRejected: - return model.DisapprovedApproveStatus + return pkgModels.DisapprovedApproveStatus } - return model.UndefinedApproveStatus + return pkgModels.UndefinedApproveStatus } // ModelStatus returns status type from models -func (status *AvailableStatus) ModelStatus() model.AvailableStatus { +func (status *AvailableStatus) ModelStatus() pkgModels.AvailableStatus { if status == nil { - return model.UndefinedAvailableStatus + return pkgModels.UndefinedAvailableStatus } switch *status { case AvailableStatusAvailable: - return model.AvailableAvailableStatus + return pkgModels.AvailableAvailableStatus case AvailableStatusUnavailable: - return model.UnavailableAvailableStatus + return pkgModels.UnavailableAvailableStatus } - return model.UndefinedAvailableStatus + return pkgModels.UndefinedAvailableStatus } // AvailableStatusFrom model value -func AvailableStatusFrom(status model.AvailableStatus) AvailableStatus { +func AvailableStatusFrom(status pkgModels.AvailableStatus) AvailableStatus { switch status { - case model.AvailableAvailableStatus: + case pkgModels.AvailableAvailableStatus: return AvailableStatusAvailable - case model.UnavailableAvailableStatus: + case pkgModels.UnavailableAvailableStatus: return AvailableStatusUnavailable } return AvailableStatusUndefined } // ApproveStatusFrom model value -func ApproveStatusFrom(status model.ApproveStatus) ApproveStatus { +func ApproveStatusFrom(status pkgModels.ApproveStatus) ApproveStatus { switch status { - case model.ApprovedApproveStatus: + case pkgModels.ApprovedApproveStatus: return ApproveStatusApproved - case model.DisapprovedApproveStatus: + case pkgModels.DisapprovedApproveStatus: return ApproveStatusRejected } return ApproveStatusPending diff --git a/server/graphql/models/user_convertor.go b/server/graphql/models/user_convertor.go index de372368..1f3a0bd3 100644 --- a/server/graphql/models/user_convertor.go +++ b/server/graphql/models/user_convertor.go @@ -3,12 +3,12 @@ package models import ( "github.com/demdxx/xtypes" - "github.com/geniusrabbit/blaze-api/model" + pkgModels "github.com/geniusrabbit/blaze-api/pkg/models" "github.com/geniusrabbit/blaze-api/repository/user" ) // FromUserModel to local graphql model -func FromUserModel(u *model.User) *User { +func FromUserModel(u *user.User) *User { if u == nil { return nil } @@ -22,7 +22,7 @@ func FromUserModel(u *model.User) *User { } // FromUserModelList converts model list to local model list -func FromUserModelList(list []*model.User) []*User { +func FromUserModelList(list []*user.User) []*User { return xtypes.SliceApply(list, FromUserModel) } @@ -32,10 +32,8 @@ func (fl *UserListFilter) Filter() *user.ListFilter { return nil } return &user.ListFilter{ - UserID: fl.ID, - AccountID: fl.AccountID, - Emails: fl.Emails, - Roles: fl.Roles, + UserID: fl.ID, + Emails: fl.Emails, } } @@ -53,17 +51,17 @@ func (ord *UserListOrder) Order() *user.ListOrder { } } -func (usr *UserInput) Model(appStatus ...model.ApproveStatus) *model.User { +func (usr *UserInput) Model(appStatus ...pkgModels.ApproveStatus) *user.User { if usr == nil { return nil } - var status model.ApproveStatus + var status pkgModels.ApproveStatus if len(appStatus) == 0 { status = usr.Status.ModelStatus() } else { status = appStatus[0] } - return &model.User{ + return &user.User{ Email: s4ptr(usr.Username), Approve: status, } diff --git a/server/graphql/resolvers/account_base.resolvers.go b/server/graphql/resolvers/account_base.resolvers.go index a40b85e0..18f7c006 100644 --- a/server/graphql/resolvers/account_base.resolvers.go +++ b/server/graphql/resolvers/account_base.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/server/graphql/resolvers/account_member.resolvers.go b/server/graphql/resolvers/account_member.resolvers.go index 386f0df4..5e335715 100644 --- a/server/graphql/resolvers/account_member.resolvers.go +++ b/server/graphql/resolvers/account_member.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/server/graphql/resolvers/account_social.resolvers.go b/server/graphql/resolvers/account_social.resolvers.go index aeb63845..419756d3 100644 --- a/server/graphql/resolvers/account_social.resolvers.go +++ b/server/graphql/resolvers/account_social.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/server/graphql/resolvers/account_users.resolvers.go b/server/graphql/resolvers/account_users.resolvers.go index 12942d6c..62a9a54a 100644 --- a/server/graphql/resolvers/account_users.resolvers.go +++ b/server/graphql/resolvers/account_users.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/server/graphql/resolvers/auth_client.resolvers.go b/server/graphql/resolvers/auth_client.resolvers.go index 675f3b21..e3ddddf8 100644 --- a/server/graphql/resolvers/auth_client.resolvers.go +++ b/server/graphql/resolvers/auth_client.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" @@ -13,12 +13,12 @@ import ( ) // CreateAuthClient is the resolver for the createAuthClient field. -func (r *mutationResolver) CreateAuthClient(ctx context.Context, input models.AuthClientInput) (*models.AuthClientPayload, error) { +func (r *mutationResolver) CreateAuthClient(ctx context.Context, input models.AuthClientCreateInput) (*models.AuthClientPayload, error) { return r.authclients.CreateAuthClient(ctx, &input) } // UpdateAuthClient is the resolver for the updateAuthClient field. -func (r *mutationResolver) UpdateAuthClient(ctx context.Context, id string, input models.AuthClientInput) (*models.AuthClientPayload, error) { +func (r *mutationResolver) UpdateAuthClient(ctx context.Context, id string, input models.AuthClientUpdateInput) (*models.AuthClientPayload, error) { return r.authclients.UpdateAuthClient(ctx, id, &input) } @@ -33,6 +33,6 @@ func (r *queryResolver) AuthClient(ctx context.Context, id string) (*models.Auth } // ListAuthClients is the resolver for the listAuthClients field. -func (r *queryResolver) ListAuthClients(ctx context.Context, filter *models.AuthClientListFilter, order *models.AuthClientListOrder, page *models.Page) (*connectors.CollectionConnection[models.AuthClient, models.AuthClientEdge], error) { +func (r *queryResolver) ListAuthClients(ctx context.Context, filter *models.AuthClientListFilter, order []*models.AuthClientListOrder, page *models.Page) (*connectors.CollectionConnection[models.AuthClient, models.AuthClientEdge], error) { return r.authclients.ListAuthClients(ctx, filter, order, page) } diff --git a/server/graphql/resolvers/directaccesstoken.resolvers.go b/server/graphql/resolvers/directaccesstoken.resolvers.go index 7da49a29..77501bd1 100644 --- a/server/graphql/resolvers/directaccesstoken.resolvers.go +++ b/server/graphql/resolvers/directaccesstoken.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/server/graphql/resolvers/history.resolvers.go b/server/graphql/resolvers/history.resolvers.go index cacc92d2..c249c576 100644 --- a/server/graphql/resolvers/history.resolvers.go +++ b/server/graphql/resolvers/history.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/server/graphql/resolvers/options.resolvers.go b/server/graphql/resolvers/options.resolvers.go index 38981d1a..53acb873 100644 --- a/server/graphql/resolvers/options.resolvers.go +++ b/server/graphql/resolvers/options.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/server/graphql/resolvers/rbac.resolvers.go b/server/graphql/resolvers/rbac.resolvers.go index d52dfc0d..c2dac9da 100644 --- a/server/graphql/resolvers/rbac.resolvers.go +++ b/server/graphql/resolvers/rbac.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/server/graphql/resolvers/resolver.go b/server/graphql/resolvers/resolver.go index bc8c28be..1432d4d2 100644 --- a/server/graphql/resolvers/resolver.go +++ b/server/graphql/resolvers/resolver.go @@ -3,15 +3,28 @@ package resolvers import ( "github.com/geniusrabbit/blaze-api/pkg/auth/jwt" account_graphql "github.com/geniusrabbit/blaze-api/repository/account/delivery/graphql" + accountrepo "github.com/geniusrabbit/blaze-api/repository/account/repository" + accountusecase "github.com/geniusrabbit/blaze-api/repository/account/usecase" authclient_graphql "github.com/geniusrabbit/blaze-api/repository/authclient/delivery/graphql" + authclientrepo "github.com/geniusrabbit/blaze-api/repository/authclient/repository" + authclientusecase "github.com/geniusrabbit/blaze-api/repository/authclient/usecase" directaccesstoken_graphql "github.com/geniusrabbit/blaze-api/repository/directaccesstoken/delivery/graphql" + datokenrepo "github.com/geniusrabbit/blaze-api/repository/directaccesstoken/repository" + datokenusecase "github.com/geniusrabbit/blaze-api/repository/directaccesstoken/usecase" historylog_graphql "github.com/geniusrabbit/blaze-api/repository/historylog/delivery/graphql" + historylogrepo "github.com/geniusrabbit/blaze-api/repository/historylog/repository" + historylogusecase "github.com/geniusrabbit/blaze-api/repository/historylog/usecase" "github.com/geniusrabbit/blaze-api/repository/option" option_graphql "github.com/geniusrabbit/blaze-api/repository/option/delivery/graphql" rbac_graphql "github.com/geniusrabbit/blaze-api/repository/rbac/delivery/graphql" - rbac "github.com/geniusrabbit/blaze-api/repository/rbac/repository" + rbacrepo "github.com/geniusrabbit/blaze-api/repository/rbac/repository" + rbacusecase "github.com/geniusrabbit/blaze-api/repository/rbac/usecase" socialaccount_graphql "github.com/geniusrabbit/blaze-api/repository/socialaccount/delivery/graphql" + socaccrepo "github.com/geniusrabbit/blaze-api/repository/socialaccount/repository" + socaccusecase "github.com/geniusrabbit/blaze-api/repository/socialaccount/usecase" user_graphql "github.com/geniusrabbit/blaze-api/repository/user/delivery/graphql" + userrepo "github.com/geniusrabbit/blaze-api/repository/user/repository" + userusecase "github.com/geniusrabbit/blaze-api/repository/user/usecase" ) // This file will not be regenerated automatically. @@ -32,16 +45,24 @@ type Resolver struct { } func NewResolver(provider *jwt.Provider, options option.Usecase) *Resolver { + userRepoInst := userrepo.NewUserRepository() + accountRepoInst := accountrepo.NewAccountRepository() + memberRepoInst := accountrepo.NewMemberRepository() + rbacRepoInst := rbacrepo.New() + + accountUsecaseInst := accountusecase.NewAccountUsecase(userRepoInst, accountRepoInst, memberRepoInst) + memberUsecaseInst := accountusecase.NewMemberUsecase(userRepoInst, accountRepoInst, memberRepoInst) + return &Resolver{ - users: user_graphql.NewQueryResolver(), - accAuth: account_graphql.NewAuthResolver(provider, rbac.New()), - accounts: account_graphql.NewQueryResolver(), - members: account_graphql.NewMemberQueryResolver(), - socAccounts: socialaccount_graphql.NewQueryResolver(), - roles: rbac_graphql.NewQueryResolver(), - authclients: authclient_graphql.NewQueryResolver(), - historylogs: historylog_graphql.NewQueryResolver(), + users: user_graphql.NewQueryResolver(userusecase.NewUserUsecase(userRepoInst)), + accAuth: account_graphql.NewAuthResolver(provider, userRepoInst, accountRepoInst, accountUsecaseInst, rbacRepoInst), + accounts: account_graphql.NewQueryResolver(accountUsecaseInst, memberUsecaseInst, userRepoInst), + members: account_graphql.NewMemberQueryResolver(accountUsecaseInst, memberUsecaseInst), + socAccounts: socialaccount_graphql.NewQueryResolver(socaccusecase.NewSocaccUsecase(socaccrepo.NewSocaccRepository())), + roles: rbac_graphql.NewQueryResolver(rbacusecase.New(rbacRepoInst)), + authclients: authclient_graphql.NewQueryResolver(authclientusecase.NewAuthclientUsecase(authclientrepo.NewAuthclientRepository())), + historylogs: historylog_graphql.NewQueryResolver(historylogusecase.NewUsecase(historylogrepo.New())), options: option_graphql.NewQueryResolver(options), - directaccesstoken: directaccesstoken_graphql.NewQueryResolver(), + directaccesstoken: directaccesstoken_graphql.NewQueryResolver(datokenusecase.New(datokenrepo.NewDirectAccessTokenRepository())), } } diff --git a/server/graphql/resolvers/schema.resolvers.go b/server/graphql/resolvers/schema.resolvers.go index 6f8c02e4..a0d97e1e 100644 --- a/server/graphql/resolvers/schema.resolvers.go +++ b/server/graphql/resolvers/schema.resolvers.go @@ -3,7 +3,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.86 +// Code generated by github.com/99designs/gqlgen version v0.17.88 import ( "context" diff --git a/server/graphql/types/json.go b/server/graphql/types/json.go index 29638f75..3430089a 100644 --- a/server/graphql/types/json.go +++ b/server/graphql/types/json.go @@ -1,7 +1,7 @@ package types import ( - "fmt" + "encoding/json" "io" "github.com/geniusrabbit/gosql/v2" @@ -43,14 +43,24 @@ func (j JSON) MarshalGQL(w io.Writer) { _, _ = w.Write(data) } -// UnmarshalGQL implements method of interface graphql.Unmarshaler +// UnmarshalGQL implements method of interface graphql.Unmarshaler. +// gqlgen passes already-parsed values (map[string]any, []any, primitives) +// when variables are used, and strings/bytes when inlined as literals. func (j *JSON) UnmarshalGQL(v any) error { switch v := v.(type) { case []byte: return j.goJSON().UnmarshalJSON(v) case string: return j.goJSON().UnmarshalJSON([]byte(v)) + case nil: + j.goJSON().Data = nil + return nil default: - return fmt.Errorf("%T is not a supported as a duration", v) + // Already-parsed value from variables (map[string]any, []any, bool, float64, …) + data, err := json.Marshal(v) + if err != nil { + return err + } + return j.goJSON().UnmarshalJSON(data) } } diff --git a/server/graphql/types/nullable_json.go b/server/graphql/types/nullable_json.go index b802c3a3..0beed3aa 100644 --- a/server/graphql/types/nullable_json.go +++ b/server/graphql/types/nullable_json.go @@ -1,7 +1,7 @@ package types import ( - "fmt" + "encoding/json" "io" "github.com/geniusrabbit/gosql/v2" @@ -55,14 +55,24 @@ func (j NullableJSON) MarshalGQL(w io.Writer) { _, _ = w.Write(data) } -// UnmarshalGQL implements method of interface graphql.Unmarshaler +// UnmarshalGQL implements method of interface graphql.Unmarshaler. +// gqlgen passes already-parsed values (map[string]any, []any, primitives) +// when variables are used, and strings/bytes when inlined as literals. func (j *NullableJSON) UnmarshalGQL(v any) error { switch v := v.(type) { case []byte: return j.goJSON().UnmarshalJSON(v) case string: return j.goJSON().UnmarshalJSON([]byte(v)) + case nil: + j.goJSON().Data = nil + return nil default: - return fmt.Errorf("%T is not a supported as a duration", v) + // Already-parsed value from variables (map[string]any, []any, bool, float64, …) + data, err := json.Marshal(v) + if err != nil { + return err + } + return j.goJSON().UnmarshalJSON(data) } }