Files
zitadel/backend/v3/storage/database/operators_enumer.go
T
f5ce288ea5 feat(domain): define user repositories (#11059)
This pull request introduces a new set of domain models and repositories
for managing users within the new v3 structure. The goal is to establish
a clean, robust, and extensible foundation for user management.

### Summary

This PR accomplishes the following:

- **Polymorphic User Model**: Introduces a `User` model in user.go that
can represent either a `Human` or a `Machine` user. This provides a
unified way to handle different user types while allowing for specific
attributes and logic for each.
- **Repository Pattern**: Implements the repository pattern for
accessing and manipulating user data. This decouples the business logic
from the data storage implementation. The main repository interfaces
(`UserRepository`, `HumanUserRepository`, `MachineUserRepository`) are
now defined in `backend/v3/domain/user_repository.go`.
- **Comprehensive User Models**: The user.go file now also defines the
domain models for associated user data, including `UserMetadata`,
`IdentityProviderLink`, `Passkey`, `PersonalAccessToken`, and
`MachineKey`.
- **Generic Verification and Check System**: Introduces verification.go
and check.go to provide a standardized way of handling various
verification flows (e.g., email verification, OTP checks).
- **Generated Code**: Adds new generated files for enums
(`humangender_enumer.go`, `machinekeytype_enumer.go`,
`passkeytype_enumer.go`, `personalaccesstokentype_enumer.go`,
`userstate_enumer.go`, `usertype_enumer.go`) and mocks for the new
repositories.
- **Session Domain Refactoring**: Updates the session domain
(`backend/v3/domain/session*.go`) to align with the new user model
structure.

This foundational work paves the way for migrating user management logic
to the new `v3` backend, with a more maintainable and testable
architecture.

part of #10224

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Marco A. <[email protected]>
2025-11-25 11:54:32 +01:00

270 lines
9.1 KiB
Go

// Code generated by "enumer -type NumberOperation,TextOperation,BytesOperation -linecomment -output ./operators_enumer.go"; DO NOT EDIT.
package database
import (
"fmt"
"strings"
)
const _NumberOperationName = "=<><<=>>="
var _NumberOperationIndex = [...]uint8{0, 1, 3, 4, 6, 7, 9}
const _NumberOperationLowerName = "=<><<=>>="
func (i NumberOperation) String() string {
i -= 1
if i >= NumberOperation(len(_NumberOperationIndex)-1) {
return fmt.Sprintf("NumberOperation(%d)", i+1)
}
return _NumberOperationName[_NumberOperationIndex[i]:_NumberOperationIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _NumberOperationNoOp() {
var x [1]struct{}
_ = x[NumberOperationEqual-(1)]
_ = x[NumberOperationNotEqual-(2)]
_ = x[NumberOperationLessThan-(3)]
_ = x[NumberOperationAtLeast-(4)]
_ = x[NumberOperationGreaterThan-(5)]
_ = x[NumberOperationAtMost-(6)]
}
var _NumberOperationValues = []NumberOperation{NumberOperationEqual, NumberOperationNotEqual, NumberOperationLessThan, NumberOperationAtLeast, NumberOperationGreaterThan, NumberOperationAtMost}
var _NumberOperationNameToValueMap = map[string]NumberOperation{
_NumberOperationName[0:1]: NumberOperationEqual,
_NumberOperationLowerName[0:1]: NumberOperationEqual,
_NumberOperationName[1:3]: NumberOperationNotEqual,
_NumberOperationLowerName[1:3]: NumberOperationNotEqual,
_NumberOperationName[3:4]: NumberOperationLessThan,
_NumberOperationLowerName[3:4]: NumberOperationLessThan,
_NumberOperationName[4:6]: NumberOperationAtLeast,
_NumberOperationLowerName[4:6]: NumberOperationAtLeast,
_NumberOperationName[6:7]: NumberOperationGreaterThan,
_NumberOperationLowerName[6:7]: NumberOperationGreaterThan,
_NumberOperationName[7:9]: NumberOperationAtMost,
_NumberOperationLowerName[7:9]: NumberOperationAtMost,
}
var _NumberOperationNames = []string{
_NumberOperationName[0:1],
_NumberOperationName[1:3],
_NumberOperationName[3:4],
_NumberOperationName[4:6],
_NumberOperationName[6:7],
_NumberOperationName[7:9],
}
// NumberOperationString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func NumberOperationString(s string) (NumberOperation, error) {
if val, ok := _NumberOperationNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _NumberOperationNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to NumberOperation values", s)
}
// NumberOperationValues returns all values of the enum
func NumberOperationValues() []NumberOperation {
return _NumberOperationValues
}
// NumberOperationStrings returns a slice of all String values of the enum
func NumberOperationStrings() []string {
strs := make([]string, len(_NumberOperationNames))
copy(strs, _NumberOperationNames)
return strs
}
// IsANumberOperation returns "true" if the value is listed in the enum definition. "false" otherwise
func (i NumberOperation) IsANumberOperation() bool {
for _, v := range _NumberOperationValues {
if i == v {
return true
}
}
return false
}
const _TextOperationName = "=<>LIKELIKELIKELIKELIKELIKE=<>"
var _TextOperationIndex = [...]uint8{0, 1, 3, 7, 11, 15, 19, 23, 27, 28, 30}
const _TextOperationLowerName = "=<>likelikelikelikelikelike=<>"
func (i TextOperation) String() string {
i -= 1
if i >= TextOperation(len(_TextOperationIndex)-1) {
return fmt.Sprintf("TextOperation(%d)", i+1)
}
return _TextOperationName[_TextOperationIndex[i]:_TextOperationIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _TextOperationNoOp() {
var x [1]struct{}
_ = x[TextOperationEqual-(1)]
_ = x[TextOperationNotEqual-(2)]
_ = x[TextOperationStartsWith-(3)]
_ = x[TextOperationContains-(4)]
_ = x[TextOperationEndsWith-(5)]
_ = x[TextOperationContainsIgnoreCase-(6)]
_ = x[TextOperationEndsWithIgnoreCase-(7)]
_ = x[TextOperationStartsWithIgnoreCase-(8)]
_ = x[TextOperationEqualIgnoreCase-(9)]
_ = x[TextOperationNotEqualIgnoreCase-(10)]
}
var _TextOperationValues = []TextOperation{TextOperationEqual, TextOperationNotEqual, TextOperationStartsWith, TextOperationContains, TextOperationEndsWith, TextOperationContainsIgnoreCase, TextOperationEndsWithIgnoreCase, TextOperationStartsWithIgnoreCase, TextOperationEqualIgnoreCase, TextOperationNotEqualIgnoreCase}
var _TextOperationNameToValueMap = map[string]TextOperation{
_TextOperationName[0:1]: TextOperationEqual,
_TextOperationLowerName[0:1]: TextOperationEqual,
_TextOperationName[1:3]: TextOperationNotEqual,
_TextOperationLowerName[1:3]: TextOperationNotEqual,
_TextOperationName[3:7]: TextOperationStartsWith,
_TextOperationLowerName[3:7]: TextOperationStartsWith,
_TextOperationName[7:11]: TextOperationContains,
_TextOperationLowerName[7:11]: TextOperationContains,
_TextOperationName[11:15]: TextOperationEndsWith,
_TextOperationLowerName[11:15]: TextOperationEndsWith,
_TextOperationName[15:19]: TextOperationContainsIgnoreCase,
_TextOperationLowerName[15:19]: TextOperationContainsIgnoreCase,
_TextOperationName[19:23]: TextOperationEndsWithIgnoreCase,
_TextOperationLowerName[19:23]: TextOperationEndsWithIgnoreCase,
_TextOperationName[23:27]: TextOperationStartsWithIgnoreCase,
_TextOperationLowerName[23:27]: TextOperationStartsWithIgnoreCase,
_TextOperationName[27:28]: TextOperationEqualIgnoreCase,
_TextOperationLowerName[27:28]: TextOperationEqualIgnoreCase,
_TextOperationName[28:30]: TextOperationNotEqualIgnoreCase,
_TextOperationLowerName[28:30]: TextOperationNotEqualIgnoreCase,
}
var _TextOperationNames = []string{
_TextOperationName[0:1],
_TextOperationName[1:3],
_TextOperationName[3:7],
_TextOperationName[7:11],
_TextOperationName[11:15],
_TextOperationName[15:19],
_TextOperationName[19:23],
_TextOperationName[23:27],
_TextOperationName[27:28],
_TextOperationName[28:30],
}
// TextOperationString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func TextOperationString(s string) (TextOperation, error) {
if val, ok := _TextOperationNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _TextOperationNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to TextOperation values", s)
}
// TextOperationValues returns all values of the enum
func TextOperationValues() []TextOperation {
return _TextOperationValues
}
// TextOperationStrings returns a slice of all String values of the enum
func TextOperationStrings() []string {
strs := make([]string, len(_TextOperationNames))
copy(strs, _TextOperationNames)
return strs
}
// IsATextOperation returns "true" if the value is listed in the enum definition. "false" otherwise
func (i TextOperation) IsATextOperation() bool {
for _, v := range _TextOperationValues {
if i == v {
return true
}
}
return false
}
const _BytesOperationName = "=<>"
var _BytesOperationIndex = [...]uint8{0, 1, 3}
const _BytesOperationLowerName = "=<>"
func (i BytesOperation) String() string {
i -= 1
if i >= BytesOperation(len(_BytesOperationIndex)-1) {
return fmt.Sprintf("BytesOperation(%d)", i+1)
}
return _BytesOperationName[_BytesOperationIndex[i]:_BytesOperationIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _BytesOperationNoOp() {
var x [1]struct{}
_ = x[BytesOperationEqual-(1)]
_ = x[BytesOperationNotEqual-(2)]
}
var _BytesOperationValues = []BytesOperation{BytesOperationEqual, BytesOperationNotEqual}
var _BytesOperationNameToValueMap = map[string]BytesOperation{
_BytesOperationName[0:1]: BytesOperationEqual,
_BytesOperationLowerName[0:1]: BytesOperationEqual,
_BytesOperationName[1:3]: BytesOperationNotEqual,
_BytesOperationLowerName[1:3]: BytesOperationNotEqual,
}
var _BytesOperationNames = []string{
_BytesOperationName[0:1],
_BytesOperationName[1:3],
}
// BytesOperationString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func BytesOperationString(s string) (BytesOperation, error) {
if val, ok := _BytesOperationNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _BytesOperationNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to BytesOperation values", s)
}
// BytesOperationValues returns all values of the enum
func BytesOperationValues() []BytesOperation {
return _BytesOperationValues
}
// BytesOperationStrings returns a slice of all String values of the enum
func BytesOperationStrings() []string {
strs := make([]string, len(_BytesOperationNames))
copy(strs, _BytesOperationNames)
return strs
}
// IsABytesOperation returns "true" if the value is listed in the enum definition. "false" otherwise
func (i BytesOperation) IsABytesOperation() bool {
for _, v := range _BytesOperationValues {
if i == v {
return true
}
}
return false
}