domain

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Anonymous = User{UserBase: userModels.UserBase{ID: 0}}

Anonymous is the example anonymous session user placeholder.

Functions

func AccountToGraphQL

func AccountToGraphQL(acc *Account) *exmodels.Account

AccountToGraphQL maps example domain Account to extended GraphQL Account.

func UserListFilterMapper

func UserListFilterMapper(fl *exmodels.UserListFilter) user.QOption

UserListFilterMapper converts extended user list filter to domain query option.

func UserListOrderMapper

func UserListOrderMapper(ord *exmodels.UserListOrder) user.QOption

UserListOrderMapper converts extended user list order to domain query option.

func UserToGraphQL

func UserToGraphQL(u *User) *exmodels.User

UserToGraphQL maps example domain User to base GraphQL User.

func UserToGraphQLPtr

func UserToGraphQLPtr(u *User) *exmodels.User

UserToGraphQLPtr maps example domain User to base GraphQL User pointer (account/member payloads).

Types

type Account

type Account struct {
	accountModels.AccountBase
	AccountProfile
}

Account is the bundled default for example/api: Base + consumer profile trait.

func AccountFromProfile

func AccountFromProfile(approve pkgModels.ApproveStatus, title, description, logoURI, policyURI, tosURI, clientURI string, contacts []string) *Account

AccountFromProfile builds account from profile/base fields.

func AccountStub

func AccountStub(id uint64) *Account

AccountStub returns account with only ID set (ACL/GraphQL placeholders).

func AccountStubWithAdmins

func AccountStubWithAdmins(id uint64, adminUserIDs ...uint64) *Account

AccountStubWithAdmins returns account stub with admin user IDs.

func FillAccountFromCreateInput

func FillAccountFromCreateInput(dest *Account, input *exmodels.AccountCreateInput, appStatus ...pkgModels.ApproveStatus) *Account

FillAccountFromCreateInput copies account create input into domain Account.

func FillAccountFromInputWithStatus

func FillAccountFromInputWithStatus(dest *Account, inp *exmodels.AccountUpdateInput, appStatus ...pkgModels.ApproveStatus) *Account

FillAccountFromInputWithStatus is a helper for wiring account repos that need an approve-status override. Used internally by account graphql wiring.

func FillAccountFromUpdateInput

func FillAccountFromUpdateInput(dest *Account, input *exmodels.AccountUpdateInput, appStatus ...pkgModels.ApproveStatus) *Account

FillAccountFromUpdateInput applies account update input to a domain Account.

func (*Account) NewWithIDs

func (a *Account) NewWithIDs(id uint64, adminUserIDs ...uint64) account.Model

NewWithIDs returns a new account instance with ID and admin user IDs set.

func (*Account) RBACResourceName

func (a *Account) RBACResourceName() string

RBACResourceName is nil-safe.

func (*Account) TableName

func (a *Account) TableName() string

TableName is nil-safe.

type AccountGraphQLMappers

AccountGraphQLMappers is the 2-param consumer alias for example/api. It pins the 4 concrete types (create input, update input, filter, order) so callers need only supply T (domain account) and TGQLAccount (GraphQL account type).

type AccountGraphQLMappersImpl

type AccountGraphQLMappersImpl struct{}

AccountGraphQLMappersImpl implements AccountGraphQLMappers for example/api. All methods delegate to the free functions in domain/graphql.go. Instantiate with AccountGraphQLMappersImpl{} — stateless.

func (AccountGraphQLMappersImpl) FromCreateInput

FromCreateInput builds a new domain Account from a create-account account input.

func (AccountGraphQLMappersImpl) FromFilter

FromFilter converts the extended GraphQL account list filter to a domain QOption.

func (AccountGraphQLMappersImpl) FromOrder

FromOrder converts the extended GraphQL account list order to a domain QOption.

func (AccountGraphQLMappersImpl) FromUpdateInput

FromUpdateInput merges an update mutation input into an existing domain Account. AccountUpdateInput carries only the approval status; profile edits use a separate mutation.

func (AccountGraphQLMappersImpl) New

New creates a new empty domain Account.

func (AccountGraphQLMappersImpl) NewPayload

func (AccountGraphQLMappersImpl) NewPayload(clientMutationID string, accountID uint64, account *exmodels.Account) *exmodels.AccountPayload

NewPayload builds account payload from parts.

func (AccountGraphQLMappersImpl) ToGQL

ToGQL maps a domain Account to the extended GraphQL Account model.

type AccountMember

type AccountMember = account.Member[*User, *Account]

AccountMember is the bundled member type for example/api.

type AccountProfile

type AccountProfile struct {
	Title       string `json:"title"`
	Description string `json:"description"`

	LogoURI string `json:"logo_uri" gorm:"column:logo_uri"`

	PolicyURI         string `json:"policy_uri" gorm:"column:policy_uri"`
	TermsOfServiceURI string `json:"tos_uri" gorm:"column:tos_uri"`
	ClientURI         string `json:"client_uri" gorm:"column:client_uri"`

	Contacts gosql.NullableStringArray `json:"contacts" gorm:"column:contacts;type:text[]"`
}

AccountProfile is example/api profile metadata (consumer-defined per project).

func (*AccountProfile) ApplyProfile

func (p *AccountProfile) ApplyProfile(title, description, logoURI, policyURI, tosURI, clientURI string, contacts []string)

ApplyProfile sets profile fields from input values.

func (*AccountProfile) GetClientURI

func (p *AccountProfile) GetClientURI() string

GetClientURI returns client URI.

func (*AccountProfile) GetContacts

func (p *AccountProfile) GetContacts() []string

GetContacts returns contact list.

func (*AccountProfile) GetDescription

func (p *AccountProfile) GetDescription() string

GetDescription returns account description.

func (*AccountProfile) GetLogoURI

func (p *AccountProfile) GetLogoURI() string

GetLogoURI returns logo URI.

func (*AccountProfile) GetPolicyURI

func (p *AccountProfile) GetPolicyURI() string

GetPolicyURI returns policy URI.

func (*AccountProfile) GetTermsOfServiceURI

func (p *AccountProfile) GetTermsOfServiceURI() string

GetTermsOfServiceURI returns terms of service URI.

func (*AccountProfile) GetTitle

func (p *AccountProfile) GetTitle() string

GetTitle returns account title.

type User

User is the example consumer user model (Base + Email + Password traits).

func UserFromCreateInput

func UserFromCreateInput(input *exmodels.UserCreateInput, appStatus ...pkgModels.ApproveStatus) *User

UserFromCreateInput builds a new domain User from GraphQL create input.

func UserFromUpdateInput

func UserFromUpdateInput(input *exmodels.UserUpdateInput, dest *User, appStatus ...pkgModels.ApproveStatus) *User

FillUserFromInput merges GraphQL update input into an existing domain User.

func (*User) NewWithID

func (u *User) NewWithID(id uint64) user.Model

type UserGraphQLMappers

UserGraphQLMappers is the 2-param consumer alias for example/api. It pins the 5 concrete types (create input, update input, payload, filter, order) so callers need only supply T (domain user) and TGQLUser (GraphQL user type).

m := domain.UserGraphQLMappersImpl{}
resolver := resolvers.NewUserResolver[*domain.User](uc, m)

type UserGraphQLMappersImpl

type UserGraphQLMappersImpl struct{}

UserGraphQLMappersImpl implements UserGraphQLMappers for example/api. All methods delegate to the free functions in domain/graphql.go. Instantiate with UserGraphQLMappersImpl{} — stateless.

func (UserGraphQLMappersImpl) FromCreateInput

func (UserGraphQLMappersImpl) FromCreateInput(inp *exmodels.UserCreateInput) *User

FromCreateInput builds a new domain User from a create mutation input.

func (UserGraphQLMappersImpl) FromFilter

FromFilter converts the extended GraphQL user list filter to a domain QOption.

func (UserGraphQLMappersImpl) FromOrder

FromOrder converts the extended GraphQL user list order to a domain QOption.

func (UserGraphQLMappersImpl) FromUpdateInput

func (UserGraphQLMappersImpl) FromUpdateInput(inp *exmodels.UserUpdateInput, dest *User) *User

FromUpdateInput merges an update mutation input into an existing domain User.

func (UserGraphQLMappersImpl) New

New creates a new empty domain User.

func (UserGraphQLMappersImpl) NewPayload

func (UserGraphQLMappersImpl) NewPayload(clientMutationID string, userID uint64, u *exmodels.User) *exmodels.UserPayload

NewPayload wraps a GQL User in the mutation payload type.

func (UserGraphQLMappersImpl) ToAccountGQL

func (UserGraphQLMappersImpl) ToAccountGQL(u *User) *exmodels.User

ToAccountGQL converts a domain User to the account-facing GQL user type.

func (UserGraphQLMappersImpl) ToGQL

ToGQL maps a domain User to the base GraphQL User model.

Jump to

Keyboard shortcuts

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