Documentation
¶
Index ¶
- Constants
- type CreateObjectTypeSpec
- type ForeignKeySpec
- type ListObjectTypesSpecV1
- type ListObjectTypesSpecV2
- type Model
- type MySQLRepository
- func (repo MySQLRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo MySQLRepository) DeleteByTypeId(ctx context.Context, typeId string) error
- func (repo MySQLRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo MySQLRepository) GetByTypeId(ctx context.Context, typeId string) (Model, error)
- func (repo MySQLRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
- func (repo MySQLRepository) UpdateByTypeId(ctx context.Context, typeId string, model Model) error
- type ObjectType
- func (objectType ObjectType) GetCreatedAt() time.Time
- func (objectType ObjectType) GetDefinition() string
- func (objectType ObjectType) GetDeletedAt() *time.Time
- func (objectType ObjectType) GetID() int64
- func (objectType ObjectType) GetTypeId() string
- func (objectType ObjectType) GetUpdatedAt() time.Time
- func (objectType *ObjectType) SetDefinition(newDefinition string)
- func (objectType ObjectType) ToObjectTypeSpec() (*ObjectTypeSpec, error)
- type ObjectTypeListParamParser
- type ObjectTypeRepository
- type ObjectTypeService
- func (svc ObjectTypeService) Create(ctx context.Context, spec CreateObjectTypeSpec) (*ObjectTypeSpec, *wookie.Token, error)
- func (svc ObjectTypeService) DeleteByTypeId(ctx context.Context, typeId string) (*wookie.Token, error)
- func (svc ObjectTypeService) GetByTypeId(ctx context.Context, typeId string) (*ObjectTypeSpec, error)
- func (svc ObjectTypeService) List(ctx context.Context, listParams service.ListParams) ([]ObjectTypeSpec, *service.Cursor, *service.Cursor, error)
- func (svc ObjectTypeService) Routes() ([]service.Route, error)
- func (svc ObjectTypeService) UpdateByTypeId(ctx context.Context, typeId string, spec UpdateObjectTypeSpec) (*ObjectTypeSpec, *wookie.Token, error)
- type ObjectTypeSpec
- type PostgresRepository
- func (repo PostgresRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo PostgresRepository) DeleteByTypeId(ctx context.Context, typeId string) error
- func (repo PostgresRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo PostgresRepository) GetByTypeId(ctx context.Context, typeId string) (Model, error)
- func (repo PostgresRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
- func (repo PostgresRepository) UpdateByTypeId(ctx context.Context, typeId string, model Model) error
- type RelationRule
- type SQLiteRepository
- func (repo SQLiteRepository) Create(ctx context.Context, model Model) (int64, error)
- func (repo SQLiteRepository) DeleteByTypeId(ctx context.Context, typeId string) error
- func (repo SQLiteRepository) GetById(ctx context.Context, id int64) (Model, error)
- func (repo SQLiteRepository) GetByTypeId(ctx context.Context, typeId string) (Model, error)
- func (repo SQLiteRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
- func (repo SQLiteRepository) UpdateByTypeId(ctx context.Context, typeId string, model Model) error
- type Service
- type Source
- type UpdateObjectTypeSpec
Constants ¶
View Source
const ( ObjectTypeFeature = "feature" ObjectTypePermission = "permission" ObjectTypePricingTier = "pricing-tier" ObjectTypeRole = "role" ObjectTypeTenant = "tenant" ObjectTypeUser = "user" InheritIfAllOf = "allOf" InheritIfAnyOf = "anyOf" InheritIfNoneOf = "noneOf" )
View Source
const PrimarySortKey = "typeId"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateObjectTypeSpec ¶ added in v0.57.0
type CreateObjectTypeSpec struct {
Type string `json:"type" validate:"required,valid_object_type"`
Source *Source `json:"source,omitempty"`
Relations map[string]RelationRule `json:"relations" validate:"required,dive"` // NOTE: map key = name of relation
}
func (CreateObjectTypeSpec) ToObjectType ¶ added in v0.57.0
func (spec CreateObjectTypeSpec) ToObjectType() (*ObjectType, error)
type ForeignKeySpec ¶
type ListObjectTypesSpecV1 ¶ added in v0.57.0
type ListObjectTypesSpecV1 []ObjectTypeSpec
type ListObjectTypesSpecV2 ¶ added in v0.57.0
type ListObjectTypesSpecV2 struct {
Results []ObjectTypeSpec `json:"results"`
PrevCursor *service.Cursor `json:"prevCursor,omitempty"`
NextCursor *service.Cursor `json:"nextCursor,omitempty"`
}
type MySQLRepository ¶
type MySQLRepository struct {
database.SQLRepository
}
func NewMySQLRepository ¶
func NewMySQLRepository(db *database.MySQL) *MySQLRepository
func (MySQLRepository) DeleteByTypeId ¶
func (repo MySQLRepository) DeleteByTypeId(ctx context.Context, typeId string) error
func (MySQLRepository) GetByTypeId ¶
func (MySQLRepository) UpdateByTypeId ¶
type ObjectType ¶
type ObjectType struct {
ID int64 `mysql:"id" postgres:"id" sqlite:"id"`
TypeId string `mysql:"typeId" postgres:"type_id" sqlite:"typeId"`
Definition string `mysql:"definition" postgres:"definition" sqlite:"definition"`
CreatedAt time.Time `mysql:"createdAt" postgres:"created_at" sqlite:"createdAt"`
UpdatedAt time.Time `mysql:"updatedAt" postgres:"updated_at" sqlite:"updatedAt"`
DeletedAt *time.Time `mysql:"deletedAt" postgres:"deleted_at" sqlite:"deletedAt"`
}
func (ObjectType) GetCreatedAt ¶ added in v0.8.0
func (objectType ObjectType) GetCreatedAt() time.Time
func (ObjectType) GetDefinition ¶ added in v0.8.0
func (objectType ObjectType) GetDefinition() string
func (ObjectType) GetDeletedAt ¶ added in v0.8.0
func (objectType ObjectType) GetDeletedAt() *time.Time
func (ObjectType) GetID ¶ added in v0.8.0
func (objectType ObjectType) GetID() int64
func (ObjectType) GetTypeId ¶ added in v0.8.0
func (objectType ObjectType) GetTypeId() string
func (ObjectType) GetUpdatedAt ¶ added in v0.8.0
func (objectType ObjectType) GetUpdatedAt() time.Time
func (*ObjectType) SetDefinition ¶ added in v0.8.0
func (objectType *ObjectType) SetDefinition(newDefinition string)
func (ObjectType) ToObjectTypeSpec ¶
func (objectType ObjectType) ToObjectTypeSpec() (*ObjectTypeSpec, error)
type ObjectTypeListParamParser ¶
type ObjectTypeListParamParser struct{}
func (ObjectTypeListParamParser) GetDefaultSortBy ¶
func (parser ObjectTypeListParamParser) GetDefaultSortBy() string
func (ObjectTypeListParamParser) GetSupportedSortBys ¶
func (parser ObjectTypeListParamParser) GetSupportedSortBys() []string
func (ObjectTypeListParamParser) ParseValue ¶
func (parser ObjectTypeListParamParser) ParseValue(val string, sortBy string) (interface{}, error)
type ObjectTypeRepository ¶
type ObjectTypeRepository interface {
Create(ctx context.Context, objectType Model) (int64, error)
GetById(ctx context.Context, id int64) (Model, error)
GetByTypeId(ctx context.Context, typeId string) (Model, error)
List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
UpdateByTypeId(ctx context.Context, typeId string, objectType Model) error
DeleteByTypeId(ctx context.Context, typeId string) error
}
func NewRepository ¶
func NewRepository(db database.Database) (ObjectTypeRepository, error)
type ObjectTypeService ¶
type ObjectTypeService struct {
service.BaseService
// contains filtered or unexported fields
}
func NewService ¶
func NewService(env service.Env, repository ObjectTypeRepository) *ObjectTypeService
func (ObjectTypeService) Create ¶
func (svc ObjectTypeService) Create(ctx context.Context, spec CreateObjectTypeSpec) (*ObjectTypeSpec, *wookie.Token, error)
func (ObjectTypeService) DeleteByTypeId ¶
func (ObjectTypeService) GetByTypeId ¶
func (svc ObjectTypeService) GetByTypeId(ctx context.Context, typeId string) (*ObjectTypeSpec, error)
func (ObjectTypeService) List ¶
func (svc ObjectTypeService) List(ctx context.Context, listParams service.ListParams) ([]ObjectTypeSpec, *service.Cursor, *service.Cursor, error)
func (ObjectTypeService) Routes ¶ added in v0.8.0
func (svc ObjectTypeService) Routes() ([]service.Route, error)
func (ObjectTypeService) UpdateByTypeId ¶
func (svc ObjectTypeService) UpdateByTypeId(ctx context.Context, typeId string, spec UpdateObjectTypeSpec) (*ObjectTypeSpec, *wookie.Token, error)
type ObjectTypeSpec ¶
type PostgresRepository ¶ added in v0.4.0
type PostgresRepository struct {
database.SQLRepository
}
func NewPostgresRepository ¶ added in v0.4.0
func NewPostgresRepository(db *database.Postgres) *PostgresRepository
func (PostgresRepository) DeleteByTypeId ¶ added in v0.4.0
func (repo PostgresRepository) DeleteByTypeId(ctx context.Context, typeId string) error
func (PostgresRepository) GetByTypeId ¶ added in v0.4.0
func (PostgresRepository) UpdateByTypeId ¶ added in v0.4.0
type RelationRule ¶
type RelationRule struct {
InheritIf string `json:"inheritIf,omitempty" validate:"required_with=Rules OfType WithRelation,valid_inheritif"`
Rules []RelationRule `json:"rules,omitempty" validate:"required_if_oneof=InheritIf anyOf allOf noneOf,omitempty,min=1,dive"` // Required if InheritIf is "anyOf", "allOf", or "noneOf", empty otherwise
OfType string `json:"ofType,omitempty" validate:"required_with=WithRelation,valid_relation"`
WithRelation string `json:"withRelation,omitempty" validate:"required_with=OfType,valid_relation"`
}
RelationRule type represents the rule or set of rules that imply a particular relation if met
type SQLiteRepository ¶ added in v0.11.0
type SQLiteRepository struct {
database.SQLRepository
}
func NewSQLiteRepository ¶ added in v0.11.0
func NewSQLiteRepository(db *database.SQLite) *SQLiteRepository
func (SQLiteRepository) DeleteByTypeId ¶ added in v0.11.0
func (repo SQLiteRepository) DeleteByTypeId(ctx context.Context, typeId string) error
func (SQLiteRepository) GetByTypeId ¶ added in v0.11.0
func (SQLiteRepository) UpdateByTypeId ¶ added in v0.11.0
type Service ¶ added in v0.39.0
type Service interface {
Create(ctx context.Context, spec CreateObjectTypeSpec) (*ObjectTypeSpec, *wookie.Token, error)
GetByTypeId(ctx context.Context, typeId string) (*ObjectTypeSpec, error)
List(ctx context.Context, listParams service.ListParams) ([]ObjectTypeSpec, *service.Cursor, *service.Cursor, error)
UpdateByTypeId(ctx context.Context, typeId string, spec UpdateObjectTypeSpec) (*ObjectTypeSpec, *wookie.Token, error)
DeleteByTypeId(ctx context.Context, typeId string) (*wookie.Token, error)
}
type Source ¶
type Source struct {
DatabaseType string `json:"dbType" validate:"required"`
DatabaseName string `json:"dbName" validate:"required"`
Table string `json:"table" validate:"required"`
PrimaryKey []string `json:"primaryKey" validate:"min=1"`
ForeignKeys []ForeignKeySpec `json:"foreignKeys,omitempty"`
}
type UpdateObjectTypeSpec ¶ added in v0.57.0
type UpdateObjectTypeSpec struct {
Type string `json:"type"` // NOTE: used internally for updates, but value from request is ignored
Source *Source `json:"source,omitempty"`
Relations map[string]RelationRule `json:"relations" validate:"required,dive"` // NOTE: map key = name of relation
}
func (*UpdateObjectTypeSpec) ToObjectType ¶ added in v0.57.0
func (spec *UpdateObjectTypeSpec) ToObjectType(typeId string) (*ObjectType, error)
Click to show internal directories.
Click to hide internal directories.