Documentation
¶
Overview ¶
package resource provides a set of types and functions for working with resources.
Index ¶
- Variables
- func AddResources[Resource Resourcer](c *Collection, scope accesstypes.PermissionScope, rSet *ResourceSet[Resource]) error
- func CloneRequest(r *http.Request) (*http.Request, error)
- func CommitTimestamp(_ context.Context, _ TxnBuffer) (any, error)
- func CommitTimestampPtr(_ context.Context, _ TxnBuffer) (any, error)
- func DefaultFalse(_ context.Context, _ TxnBuffer) (any, error)
- func DefaultTrue(_ context.Context, _ TxnBuffer) (any, error)
- func Operations(r *http.Request, pattern string, opts ...Option) iter.Seq2[*Operation, error]
- func PatchsetCompare(a, b PatchSetComparer) bool
- func ProcessEvent(processName string) string
- func UserEvent(ctx context.Context) string
- func UserProcessEvent(ctx context.Context, processName string) string
- type Collection
- func (s *Collection) AddMethodResource(scope accesstypes.PermissionScope, permission accesstypes.Permission, ...) error
- func (s *Collection) AddResource(scope accesstypes.PermissionScope, permission accesstypes.Permission, ...) error
- func (s *Collection) IsResourceImmutable(scope accesstypes.PermissionScope, res accesstypes.Resource) bool
- func (s *Collection) List() map[accesstypes.Permission][]accesstypes.Resource
- func (s *Collection) ResourceExists(r accesstypes.Resource) bool
- func (s *Collection) Resources() []accesstypes.Resource
- func (s *Collection) Scope(resource accesstypes.Resource) accesstypes.PermissionScope
- func (c *Collection) TypescriptData() TypescriptData
- type Columns
- type CommitBuffer
- type Condition
- type ConditionNode
- type Config
- type Configurer
- type DBType
- type DataChangeEvent
- type Decoder
- func (d *Decoder[Resource, Request]) Decode(request *http.Request, userPermissions UserPermissions, ...) (*PatchSet[Resource], error)
- func (d *Decoder[Resource, Request]) DecodeOperation(oper *Operation, userPermissions UserPermissions) (*PatchSet[Resource], error)
- func (d *Decoder[Resource, Request]) DecodeOperationWithoutPermissions(oper *Operation) (*PatchSet[Resource], error)
- func (d *Decoder[Resource, Request]) DecodeWithoutPermissions(request *http.Request) (*PatchSet[Resource], error)
- func (d *Decoder[Resource, Request]) WithValidator(v ValidatorFunc) *Decoder[Resource, Request]
- type DiffElem
- type DomainFromCtx
- type DomainFromReq
- type ExpressionNode
- type FieldDefaultFunc
- type FieldInfo
- type GroupNode
- type Ident
- func (i Ident[T]) Equal(v ...T) QueryClause
- func (i Ident[T]) GreaterThan(v T) QueryClause
- func (i Ident[T]) GreaterThanEq(v T) QueryClause
- func (i Ident[T]) IsNotNull() QueryClause
- func (i Ident[T]) IsNull() QueryClause
- func (i Ident[T]) LessThan(v T) QueryClause
- func (i Ident[T]) LessThanEq(v T) QueryClause
- func (i Ident[T]) NotEqual(v ...T) QueryClause
- type KeyPart
- type KeySet
- type Lexer
- type Link
- type LogicalOpNode
- type LogicalOperator
- type NullLink
- type Operation
- type OperationType
- type Option
- type Parser
- type PartialQueryClause
- type PatchSet
- func (p *PatchSet[Resource]) Data() map[accesstypes.Field]any
- func (p *PatchSet[Resource]) Diff(old any) (map[accesstypes.Field]DiffElem, error)
- func (p *PatchSet[Resource]) EnableUserPermissionEnforcement(rSet *ResourceSet[Resource], userPermissions UserPermissions, ...) *PatchSet[Resource]
- func (p *PatchSet[Resource]) Fields() []accesstypes.Field
- func (p *PatchSet[Resource]) Get(field accesstypes.Field) any
- func (p *PatchSet[Resource]) HasKey() bool
- func (p *PatchSet[Resource]) IsSet(field accesstypes.Field) bool
- func (p *PatchSet[Resource]) Key(field accesstypes.Field) any
- func (p *PatchSet[Resource]) Len() int
- func (p *PatchSet[Resource]) PatchType() PatchType
- func (p *PatchSet[Resource]) PrimaryKey() KeySet
- func (p *PatchSet[Resource]) RegisterDefaultCreateFunc(field accesstypes.Field, fn FieldDefaultFunc)
- func (p *PatchSet[Resource]) RegisterDefaultUpdateFunc(field accesstypes.Field, fn FieldDefaultFunc)
- func (p *PatchSet[Resource]) Resolve() (map[string]any, error)
- func (p *PatchSet[Resource]) Resource() accesstypes.Resource
- func (p *PatchSet[Resource]) Set(field accesstypes.Field, value any) *PatchSet[Resource]
- func (p *PatchSet[Resource]) SetKey(field accesstypes.Field, value any) *PatchSet[Resource]
- func (p *PatchSet[Resource]) SetPatchType(t PatchType) *PatchSet[Resource]
- func (p *PatchSet[Resource]) SpannerApply(ctx context.Context, committer SpannerCommitter, eventSource ...string) error
- func (p *PatchSet[Resource]) SpannerBuffer(ctx context.Context, txn TxnBuffer, eventSource ...string) error
- func (p *PatchSet[Resource]) SpannerBufferInsertOrUpdate(ctx context.Context, txn TxnBuffer, eventSource ...string) error
- func (p *PatchSet[Resource]) SpannerInsertOrUpdate(ctx context.Context, s *spanner.Client, eventSource ...string) error
- type PatchSetComparer
- type PatchType
- type PostgreSQLGenerator
- type PostgresStatement
- type QueryClause
- type QueryDecoder
- type QueryParam
- type QuerySet
- func (q *QuerySet[Resource]) AddField(field accesstypes.Field) *QuerySet[Resource]
- func (q *QuerySet[Resource]) Columns() (Columns, error)
- func (q *QuerySet[Resource]) EnableUserPermissionEnforcement(rSet *ResourceSet[Resource], userPermissions UserPermissions, ...) *QuerySet[Resource]
- func (q *QuerySet[Resource]) Fields() []accesstypes.Field
- func (q *QuerySet[Resource]) Key(field accesstypes.Field) any
- func (q *QuerySet[Resource]) KeySet() KeySet
- func (q *QuerySet[Resource]) Len() int
- func (q *QuerySet[Resource]) PostgresStmt() (*PostgresStatement, error)
- func (q *QuerySet[Resource]) RequiredPermission() accesstypes.Permission
- func (q *QuerySet[Resource]) Resource() accesstypes.Resource
- func (q *QuerySet[Resource]) ReturnAccessableFields(b bool) *QuerySet[Resource]
- func (q *QuerySet[Resource]) SetFilterAst(ast ExpressionNode)
- func (q *QuerySet[Resource]) SetKey(field accesstypes.Field, value any)
- func (q *QuerySet[Resource]) SetSearchParam(search *Search)
- func (q *QuerySet[Resource]) SetSortFields(sortFields []SortField)
- func (q *QuerySet[Resource]) SetWhereClause(qc QueryClause)
- func (q *QuerySet[Resource]) SpannerList(ctx context.Context, db spxapi.Querier) iter.Seq2[*Resource, error]
- func (q *QuerySet[Resource]) SpannerRead(ctx context.Context, db spxapi.Querier) (*Resource, error)
- func (q *QuerySet[Resource]) SpannerStmt() (*SpannerStatement, error)
- type RPCDecoder
- type RequestFieldMapper
- type ResourceMetadata
- type ResourceSet
- func (r *ResourceSet[Resource]) BaseResource() accesstypes.Resource
- func (r *ResourceSet[Resource]) ImmutableFields() map[accesstypes.Tag]struct{}
- func (r *ResourceSet[Resource]) PermissionRequired(fieldName accesstypes.Field, perm accesstypes.Permission) bool
- func (r *ResourceSet[Resource]) Permissions() []accesstypes.Permission
- func (r *ResourceSet[Resource]) Resource(fieldName accesstypes.Field) accesstypes.Resource
- func (r *ResourceSet[Resource]) ResourceMetadata() *ResourceMetadata[Resource]
- func (r *ResourceSet[Resource]) TagPermissions() accesstypes.TagPermissions
- type Resourcer
- type RunnerFunc
- type SQLDialect
- type Search
- type SearchKey
- type SearchKeys
- type SearchType
- type SortDirection
- type SortField
- type SpannerBuffer
- type SpannerCommitter
- type SpannerGenerator
- type SpannerStatement
- type Statement
- type StructDecoder
- type Token
- type TokenType
- type TxnBuffer
- type TxnFuncRunner
- type TxnRunner
- type TypescriptData
- type UserFromCtx
- type UserFromReq
- type UserPermissions
- type ValidatorFunc
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedNodeType = errors.New("unsupported AST node type for SQL generation")
ErrUnsupportedNodeType indicates an AST node type that the SQL generator cannot handle.
var ErrUnsupportedOperator = errors.New("unsupported operator for SQL generation")
ErrUnsupportedOperator indicates a condition operator that the SQL generator cannot handle.
Functions ¶
func AddResources ¶ added in v0.0.3
func AddResources[Resource Resourcer](c *Collection, scope accesstypes.PermissionScope, rSet *ResourceSet[Resource]) error
func CommitTimestamp ¶ added in v0.1.10
func CommitTimestampPtr ¶ added in v0.1.10
func Operations ¶ added in v0.0.3
func PatchsetCompare ¶ added in v0.0.3
func PatchsetCompare(a, b PatchSetComparer) bool
func ProcessEvent ¶ added in v0.0.3
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
func NewCollection ¶
func NewCollection() *Collection
func (*Collection) AddMethodResource ¶ added in v0.1.0
func (s *Collection) AddMethodResource(scope accesstypes.PermissionScope, permission accesstypes.Permission, res accesstypes.Resource) error
func (*Collection) AddResource ¶
func (s *Collection) AddResource(scope accesstypes.PermissionScope, permission accesstypes.Permission, res accesstypes.Resource) error
func (*Collection) IsResourceImmutable ¶
func (s *Collection) IsResourceImmutable(scope accesstypes.PermissionScope, res accesstypes.Resource) bool
func (*Collection) List ¶
func (s *Collection) List() map[accesstypes.Permission][]accesstypes.Resource
func (*Collection) ResourceExists ¶ added in v0.1.7
func (s *Collection) ResourceExists(r accesstypes.Resource) bool
func (*Collection) Resources ¶ added in v0.0.10
func (s *Collection) Resources() []accesstypes.Resource
func (*Collection) Scope ¶
func (s *Collection) Scope(resource accesstypes.Resource) accesstypes.PermissionScope
func (*Collection) TypescriptData ¶ added in v0.0.10
func (c *Collection) TypescriptData() TypescriptData
type CommitBuffer ¶ added in v0.0.21
type CommitBuffer struct {
// contains filtered or unexported fields
}
func NewCommitBuffer ¶ added in v0.0.21
func NewCommitBuffer(db TxnFuncRunner, eventSource string, autoCommitSize int) *CommitBuffer
NewCommitBuffer returns a CommitBuffer that flushes the buffer when it reaches autoCommitSize, committing the content in a single transaction. A autoCommitSize of 0 means that the buffer will never be flushed automatically. The buffer can be flushed manually by calling Commit(). Commit() must be called before discarding CommitBuffer to ensure all buffered mutations are committed.
func (*CommitBuffer) Buffer ¶ added in v0.0.21
func (cb *CommitBuffer) Buffer(ctx context.Context, ps ...SpannerBuffer) error
type Condition ¶ added in v0.1.12
type Condition struct {
Field string
Operator string
Value any // For eq, ne, gt, lt, gte, lte
Values []any // For in, notin
IsNullOp bool // For isnull, isnotnull
}
Condition represents a single condition (e.g., name:eq:John).
type ConditionNode ¶ added in v0.1.12
type ConditionNode struct {
Condition Condition
}
ConditionNode represents a simple condition in the AST.
func (*ConditionNode) String ¶ added in v0.1.12
func (cn *ConditionNode) String() string
String returns a string representation of the ConditionNode.
type Config ¶ added in v0.0.3
func (Config) SetChangeTrackingTable ¶ added in v0.0.3
func (Config) SetTrackChanges ¶ added in v0.0.3
type Configurer ¶ added in v0.0.3
type Configurer interface {
Config() Config
}
type DataChangeEvent ¶ added in v0.0.3
type Decoder ¶ added in v0.0.3
Decoder is a struct that can be used for decoding http requests and validating those requests
func NewDecoder ¶ added in v0.0.3
func NewDecoder[Resource Resourcer, Request any](rSet *ResourceSet[Resource]) (*Decoder[Resource, Request], error)
func (*Decoder[Resource, Request]) Decode ¶ added in v0.0.3
func (d *Decoder[Resource, Request]) Decode(request *http.Request, userPermissions UserPermissions, requiredPermission accesstypes.Permission) (*PatchSet[Resource], error)
func (*Decoder[Resource, Request]) DecodeOperation ¶ added in v0.0.17
func (d *Decoder[Resource, Request]) DecodeOperation(oper *Operation, userPermissions UserPermissions) (*PatchSet[Resource], error)
func (*Decoder[Resource, Request]) DecodeOperationWithoutPermissions ¶ added in v0.0.17
func (*Decoder[Resource, Request]) DecodeWithoutPermissions ¶ added in v0.0.17
func (*Decoder[Resource, Request]) WithValidator ¶ added in v0.0.3
func (d *Decoder[Resource, Request]) WithValidator(v ValidatorFunc) *Decoder[Resource, Request]
type DomainFromCtx ¶ added in v0.0.3
type DomainFromCtx func(context.Context) accesstypes.Domain
type DomainFromReq ¶ added in v0.0.3
type DomainFromReq func(*http.Request) accesstypes.Domain
type ExpressionNode ¶ added in v0.1.12
type ExpressionNode interface {
// String returns a string representation of the node (for debugging/testing).
String() string
}
ExpressionNode represents a node in the filter AST.
type FieldDefaultFunc ¶ added in v0.1.5
type GroupNode ¶ added in v0.1.12
type GroupNode struct {
Expression ExpressionNode
}
GroupNode represents a parenthesized group of expressions in the AST.
type Ident ¶ added in v0.0.19
type Ident[T comparable] struct { // contains filtered or unexported fields }
func NewIdent ¶ added in v0.0.19
func NewIdent[T comparable](column string, px PartialQueryClause, indexed bool) Ident[T]
func (Ident[T]) Equal ¶ added in v0.0.19
func (i Ident[T]) Equal(v ...T) QueryClause
func (Ident[T]) GreaterThan ¶ added in v0.0.19
func (i Ident[T]) GreaterThan(v T) QueryClause
func (Ident[T]) GreaterThanEq ¶ added in v0.0.19
func (i Ident[T]) GreaterThanEq(v T) QueryClause
func (Ident[T]) IsNotNull ¶ added in v0.1.12
func (i Ident[T]) IsNotNull() QueryClause
func (Ident[T]) IsNull ¶ added in v0.1.12
func (i Ident[T]) IsNull() QueryClause
func (Ident[T]) LessThan ¶ added in v0.0.19
func (i Ident[T]) LessThan(v T) QueryClause
func (Ident[T]) LessThanEq ¶ added in v0.0.19
func (i Ident[T]) LessThanEq(v T) QueryClause
func (Ident[T]) NotEqual ¶ added in v0.0.19
func (i Ident[T]) NotEqual(v ...T) QueryClause
type KeyPart ¶
type KeyPart struct {
Key accesstypes.Field
Value any
}
type KeySet ¶
type KeySet struct {
// contains filtered or unexported fields
}
KeySet is an object that represents a single or composite primary key and its value.
type Lexer ¶ added in v0.1.12
type Lexer struct {
// contains filtered or unexported fields
}
Lexer parses the filter producing tokens
type Link ¶ added in v0.0.11
type Link struct {
ID ccc.UUID `json:"id"`
Resource string `json:"resource"`
Text string `json:"text"`
}
func (*Link) DecodeSpanner ¶ added in v0.0.11
func (Link) EncodeSpanner ¶ added in v0.0.11
func (Link) MarshalJSON ¶ added in v0.0.11
func (*Link) UnmarshalJSON ¶ added in v0.0.11
type LogicalOpNode ¶ added in v0.1.12
type LogicalOpNode struct {
Left ExpressionNode
Operator LogicalOperator
Right ExpressionNode
}
LogicalOpNode represents a logical operation (AND/OR) in the AST.
func (*LogicalOpNode) String ¶ added in v0.1.12
func (ln *LogicalOpNode) String() string
String returns a string representation of the LogicalOpNode.
type LogicalOperator ¶ added in v0.1.12
type LogicalOperator string
LogicalOperator defines the type of logical operator (AND, OR).
const ( OperatorAnd LogicalOperator = "AND" OperatorOr LogicalOperator = "OR" )
type NullLink ¶ added in v0.0.11
func (*NullLink) DecodeSpanner ¶ added in v0.0.11
func (NullLink) EncodeSpanner ¶ added in v0.0.11
func (NullLink) MarshalJSON ¶ added in v0.0.11
func (*NullLink) UnmarshalJSON ¶ added in v0.0.11
type Operation ¶ added in v0.0.3
type Operation struct {
Type OperationType
Req *http.Request
}
type OperationType ¶ added in v0.0.3
type OperationType string
const ( OperationCreate OperationType = "add" OperationUpdate OperationType = "patch" OperationDelete OperationType = "remove" )
type Option ¶ added in v0.0.12
type Option func(opt options) options
func RequireCreatePath ¶ added in v0.0.12
func RequireCreatePath() Option
type Parser ¶ added in v0.1.12
type Parser struct {
// contains filtered or unexported fields
}
Parser builds an AST from tokens.
func (*Parser) Parse ¶ added in v0.1.12
func (p *Parser) Parse() (ExpressionNode, error)
Parse is the main entry point for parsing the filter string.
type PartialQueryClause ¶ added in v0.0.19
type PartialQueryClause struct {
// contains filtered or unexported fields
}
func NewPartialQueryClause ¶ added in v0.0.19
func NewPartialQueryClause() PartialQueryClause
func (PartialQueryClause) Group ¶ added in v0.0.19
func (p PartialQueryClause) Group(qc QueryClause) QueryClause
type PatchSet ¶
type PatchSet[Resource Resourcer] struct { // contains filtered or unexported fields }
func NewPatchSet ¶
func NewPatchSet[Resource Resourcer](rMeta *ResourceMetadata[Resource]) *PatchSet[Resource]
func (*PatchSet[Resource]) Diff ¶ added in v0.0.3
Diff returns a map of fields that have changed between old and patchSet.
func (*PatchSet[Resource]) EnableUserPermissionEnforcement ¶ added in v0.0.17
func (p *PatchSet[Resource]) EnableUserPermissionEnforcement(rSet *ResourceSet[Resource], userPermissions UserPermissions, requiredPermission accesstypes.Permission) *PatchSet[Resource]
func (*PatchSet[Resource]) Fields ¶
func (p *PatchSet[Resource]) Fields() []accesstypes.Field
func (*PatchSet[Resource]) IsSet ¶ added in v0.0.3
func (p *PatchSet[Resource]) IsSet(field accesstypes.Field) bool
func (*PatchSet[Resource]) PrimaryKey ¶ added in v0.0.3
func (*PatchSet[Resource]) RegisterDefaultCreateFunc ¶ added in v0.1.10
func (p *PatchSet[Resource]) RegisterDefaultCreateFunc(field accesstypes.Field, fn FieldDefaultFunc)
func (*PatchSet[Resource]) RegisterDefaultUpdateFunc ¶ added in v0.1.10
func (p *PatchSet[Resource]) RegisterDefaultUpdateFunc(field accesstypes.Field, fn FieldDefaultFunc)
func (*PatchSet[Resource]) Resolve ¶ added in v0.0.3
Resolve returns a map with the keys set to the database struct tags found on databaseType, and the values set to the values in patchSet.
func (*PatchSet[Resource]) Resource ¶ added in v0.0.3
func (p *PatchSet[Resource]) Resource() accesstypes.Resource
func (*PatchSet[Resource]) Set ¶
func (p *PatchSet[Resource]) Set(field accesstypes.Field, value any) *PatchSet[Resource]
func (*PatchSet[Resource]) SetKey ¶
func (p *PatchSet[Resource]) SetKey(field accesstypes.Field, value any) *PatchSet[Resource]
func (*PatchSet[Resource]) SetPatchType ¶ added in v0.0.3
func (*PatchSet[Resource]) SpannerApply ¶ added in v0.0.6
func (*PatchSet[Resource]) SpannerBuffer ¶ added in v0.0.3
func (*PatchSet[Resource]) SpannerBufferInsertOrUpdate ¶ added in v0.0.3
type PatchSetComparer ¶ added in v0.0.3
type PatchSetComparer interface {
Data() map[accesstypes.Field]any
Fields() []accesstypes.Field
PatchType() PatchType
PrimaryKey() KeySet
}
type PostgreSQLGenerator ¶ added in v0.1.12
type PostgreSQLGenerator struct {
// contains filtered or unexported fields
}
PostgreSQLGenerator is a SQL generator for PostgreSQL.
func NewPostgreSQLGenerator ¶ added in v0.1.12
func NewPostgreSQLGenerator() *PostgreSQLGenerator
NewPostgreSQLGenerator creates a new PostgreSQLGenerator.
func (*PostgreSQLGenerator) GenerateSQL ¶ added in v0.1.12
func (g *PostgreSQLGenerator) GenerateSQL(node ExpressionNode) (sqlStr string, params []any, err error)
GenerateSQL generates SQL for the given node.
type PostgresStatement ¶ added in v0.1.12
type QueryClause ¶ added in v0.0.19
type QueryClause struct {
// contains filtered or unexported fields
}
func (QueryClause) And ¶ added in v0.0.19
func (x QueryClause) And() PartialQueryClause
func (QueryClause) Or ¶ added in v0.0.19
func (x QueryClause) Or() PartialQueryClause
func (QueryClause) Validate ¶ added in v0.1.15
func (qc QueryClause) Validate() error
Validate checks if the query clause has at least one indexed field.
type QueryDecoder ¶ added in v0.0.3
type QueryDecoder[Resource Resourcer, Request any] struct { // contains filtered or unexported fields }
QueryDecoder is a struct that returns columns that a given user has access to view
func NewQueryDecoder ¶ added in v0.0.3
func NewQueryDecoder[Resource Resourcer, Request any](resSet *ResourceSet[Resource]) (*QueryDecoder[Resource, Request], error)
func (*QueryDecoder[Resource, Request]) Decode ¶ added in v0.0.3
func (d *QueryDecoder[Resource, Request]) Decode(request *http.Request, userPermissions UserPermissions) (*QuerySet[Resource], error)
func (*QueryDecoder[Resource, Request]) DecodeWithoutPermissions ¶ added in v0.0.17
func (d *QueryDecoder[Resource, Request]) DecodeWithoutPermissions(request *http.Request) (*QuerySet[Resource], error)
type QueryParam ¶ added in v0.1.12
QueryParam holds a single query parameter's name and value.
type QuerySet ¶
type QuerySet[Resource Resourcer] struct { // contains filtered or unexported fields }
func NewQuerySet ¶
func NewQuerySet[Resource Resourcer](rMeta *ResourceMetadata[Resource]) *QuerySet[Resource]
func (*QuerySet[Resource]) AddField ¶
func (q *QuerySet[Resource]) AddField(field accesstypes.Field) *QuerySet[Resource]
func (*QuerySet[Resource]) Columns ¶ added in v0.0.3
Columns returns the database struct tags for the fields in databaseType that the user has access to view.
func (*QuerySet[Resource]) EnableUserPermissionEnforcement ¶ added in v0.0.17
func (q *QuerySet[Resource]) EnableUserPermissionEnforcement(rSet *ResourceSet[Resource], userPermissions UserPermissions, requiredPermission accesstypes.Permission) *QuerySet[Resource]
func (*QuerySet[Resource]) Fields ¶
func (q *QuerySet[Resource]) Fields() []accesstypes.Field
func (*QuerySet[Resource]) Key ¶ added in v0.0.3
func (q *QuerySet[Resource]) Key(field accesstypes.Field) any
func (*QuerySet[Resource]) PostgresStmt ¶ added in v0.0.3
func (q *QuerySet[Resource]) PostgresStmt() (*PostgresStatement, error)
func (*QuerySet[Resource]) RequiredPermission ¶ added in v0.0.17
func (q *QuerySet[Resource]) RequiredPermission() accesstypes.Permission
func (*QuerySet[Resource]) Resource ¶ added in v0.0.3
func (q *QuerySet[Resource]) Resource() accesstypes.Resource
func (*QuerySet[Resource]) ReturnAccessableFields ¶ added in v0.0.17
func (*QuerySet[Resource]) SetFilterAst ¶ added in v0.1.13
func (q *QuerySet[Resource]) SetFilterAst(ast ExpressionNode)
func (*QuerySet[Resource]) SetKey ¶ added in v0.0.3
func (q *QuerySet[Resource]) SetKey(field accesstypes.Field, value any)
func (*QuerySet[Resource]) SetSearchParam ¶ added in v0.0.13
func (*QuerySet[Resource]) SetSortFields ¶ added in v0.1.13
func (*QuerySet[Resource]) SetWhereClause ¶ added in v0.0.19
func (q *QuerySet[Resource]) SetWhereClause(qc QueryClause)
func (*QuerySet[Resource]) SpannerList ¶ added in v0.0.3
func (*QuerySet[Resource]) SpannerRead ¶ added in v0.0.3
func (*QuerySet[Resource]) SpannerStmt ¶ added in v0.0.3
func (q *QuerySet[Resource]) SpannerStmt() (*SpannerStatement, error)
type RPCDecoder ¶ added in v0.1.0
type RPCDecoder[Request any] struct { // contains filtered or unexported fields }
func NewRPCDecoder ¶ added in v0.1.0
func NewRPCDecoder[Request any](userPermissions func(*http.Request) UserPermissions, methodName accesstypes.Resource, perm accesstypes.Permission) (*RPCDecoder[Request], error)
func (*RPCDecoder[Request]) Decode ¶ added in v0.1.0
func (r *RPCDecoder[Request]) Decode(request *http.Request) (*Request, error)
func (*RPCDecoder[Request]) WithValidator ¶ added in v0.1.0
func (s *RPCDecoder[Request]) WithValidator(v ValidatorFunc) *RPCDecoder[Request]
type RequestFieldMapper ¶ added in v0.0.17
type RequestFieldMapper struct {
// contains filtered or unexported fields
}
func NewRequestFieldMapper ¶ added in v0.0.17
func NewRequestFieldMapper(v any) (*RequestFieldMapper, error)
func (*RequestFieldMapper) Fields ¶ added in v0.0.17
func (f *RequestFieldMapper) Fields() []accesstypes.Field
func (*RequestFieldMapper) Len ¶ added in v0.0.17
func (f *RequestFieldMapper) Len() int
func (*RequestFieldMapper) StructFieldName ¶ added in v0.0.17
func (f *RequestFieldMapper) StructFieldName(jsonTag string) (accesstypes.Field, bool)
type ResourceMetadata ¶ added in v0.0.3
type ResourceMetadata[Resource Resourcer] struct { // contains filtered or unexported fields }
func NewResourceMetadata ¶ added in v0.0.3
func NewResourceMetadata[Resource Resourcer]() *ResourceMetadata[Resource]
func (*ResourceMetadata[Resource]) Fields ¶ added in v0.0.17
func (r *ResourceMetadata[Resource]) Fields() []accesstypes.Field
func (*ResourceMetadata[Resource]) Len ¶ added in v0.0.17
func (r *ResourceMetadata[Resource]) Len() int
type ResourceSet ¶
type ResourceSet[Resource Resourcer] struct { // contains filtered or unexported fields }
func NewResourceSet ¶
func NewResourceSet[Resource Resourcer, Request any](permissions ...accesstypes.Permission) (*ResourceSet[Resource], error)
func (*ResourceSet[Resource]) BaseResource ¶
func (r *ResourceSet[Resource]) BaseResource() accesstypes.Resource
func (*ResourceSet[Resource]) ImmutableFields ¶
func (r *ResourceSet[Resource]) ImmutableFields() map[accesstypes.Tag]struct{}
func (*ResourceSet[Resource]) PermissionRequired ¶
func (r *ResourceSet[Resource]) PermissionRequired(fieldName accesstypes.Field, perm accesstypes.Permission) bool
func (*ResourceSet[Resource]) Permissions ¶
func (r *ResourceSet[Resource]) Permissions() []accesstypes.Permission
func (*ResourceSet[Resource]) Resource ¶
func (r *ResourceSet[Resource]) Resource(fieldName accesstypes.Field) accesstypes.Resource
func (*ResourceSet[Resource]) ResourceMetadata ¶ added in v0.0.3
func (r *ResourceSet[Resource]) ResourceMetadata() *ResourceMetadata[Resource]
func (*ResourceSet[Resource]) TagPermissions ¶
func (r *ResourceSet[Resource]) TagPermissions() accesstypes.TagPermissions
type Resourcer ¶
type Resourcer interface {
Resource() accesstypes.Resource
DefaultConfig() Config
}
type RunnerFunc ¶ added in v0.0.21
RunnerFunc is a function that converts a TxnFuncRunner into a TxnRunner
type SQLDialect ¶ added in v0.1.12
type SQLDialect int
SQLDialect defines the type of SQL dialect to generate.
const ( PostgreSQL SQLDialect = iota Spanner )
type SearchKeys ¶ added in v0.0.13
type SearchKeys struct {
// contains filtered or unexported fields
}
func NewSearchKeys ¶ added in v0.0.13
func NewSearchKeys[Req any](res Resourcer) *SearchKeys
type SearchType ¶ added in v0.0.13
type SearchType string
const ( SubString SearchType = "substring" FullText SearchType = "fulltext" Ngram SearchType = "ngram" )
type SortDirection ¶ added in v0.1.13
type SortDirection string
SortDirection defines the sort direction for a field.
const ( SortAscending SortDirection = "asc" SortDescending SortDirection = "desc" )
type SortField ¶ added in v0.1.13
type SortField struct {
Field string
Direction SortDirection
}
SortField represents a field to sort by, including the field name and sort direction.
type SpannerBuffer ¶ added in v0.0.18
type SpannerBuffer interface {
SpannerBuffer(ctx context.Context, txn TxnBuffer, eventSource ...string) error
}
SpannerBuffer is an interface implemented by *PatchSet that buffers its mutations in the *spanner.ReadWriteTransaction provided by TxnBuffer
type SpannerCommitter ¶ added in v0.0.21
type SpannerCommitter interface {
ReadWriteTransaction(ctx context.Context, f func(context.Context, *spanner.ReadWriteTransaction) error) (commitTimestamp time.Time, err error)
}
SpannerCommitter is an interface implemented by *spanner.Client and is used by PatchSet to allow mocking of *spanner.Client
type SpannerGenerator ¶ added in v0.1.12
type SpannerGenerator struct {
// contains filtered or unexported fields
}
SpannerGenerator is a SQL generator for Spanner.
func NewSpannerGenerator ¶ added in v0.1.12
func NewSpannerGenerator() *SpannerGenerator
NewSpannerGenerator creates a new SpannerGenerator.
func (*SpannerGenerator) GenerateSQL ¶ added in v0.1.12
func (g *SpannerGenerator) GenerateSQL(node ExpressionNode) (sqlStr string, params map[string]any, err error)
GenerateSQL generates SQL for the given node and returns named parameters.
type SpannerStatement ¶ added in v0.1.12
type StructDecoder ¶ added in v0.0.3
type StructDecoder[Request any] struct { // contains filtered or unexported fields }
StructDecoder is a struct that can be used for decoding http requests and validating those requests
func NewStructDecoder ¶ added in v0.0.3
func NewStructDecoder[Request any]() (*StructDecoder[Request], error)
func (*StructDecoder[Request]) Decode ¶ added in v0.0.3
func (s *StructDecoder[Request]) Decode(request *http.Request) (*Request, error)
func (*StructDecoder[Request]) WithValidator ¶ added in v0.0.3
func (s *StructDecoder[Request]) WithValidator(v ValidatorFunc) *StructDecoder[Request]
type TokenType ¶ added in v0.1.12
type TokenType int
TokenType defines the types of tokens in the filter string.
type TxnBuffer ¶ added in v0.0.21
TxnBuffer is an interface implemented by *spanner.ReadWriteTransaction, and is used by PatchSet to allow mocking of *spanner.ReadWriteTransaction
type TxnFuncRunner ¶ added in v0.0.21
type TxnFuncRunner interface {
ExecuteFunc(ctx context.Context, runnerFn func(ctx context.Context, txn TxnBuffer) error) error
}
TxnFuncRunner will have its ExecuteFunc() method called inside the *spanner.ReadWriteTransaction provided by TxnBuffer
type TxnRunner ¶ added in v0.0.21
TxnRunner will have its Execute() method called inside the *spanner.ReadWriteTransaction provided by TxnBuffer
type TypescriptData ¶ added in v0.0.10
type TypescriptData struct {
Permissions []accesstypes.Permission
ResourcePermissions []accesstypes.Permission
Resources []accesstypes.Resource
RPCMethods []accesstypes.Resource
ResourceTags map[accesstypes.Resource][]accesstypes.Tag
ResourcePermissionMap permissionMap
Domains []accesstypes.PermissionScope
}
type UserFromCtx ¶ added in v0.0.3
type UserFromCtx func(context.Context) accesstypes.User
type UserFromReq ¶ added in v0.0.3
type UserFromReq func(*http.Request) accesstypes.User
type UserPermissions ¶ added in v0.0.17
type UserPermissions interface {
Check(ctx context.Context, perm accesstypes.Permission, resources ...accesstypes.Resource) (ok bool, missing []accesstypes.Resource, err error)
Domain() accesstypes.Domain
User() accesstypes.User
}
UserPermissions is an interface that provides methods to check user permissions and retrieve user information, and is used in the PatchSet and QuerySet types to enforce user permissions on resources.
type ValidatorFunc ¶ added in v0.0.3
type ValidatorFunc interface {
Struct(s interface{}) error
StructPartial(s interface{}, fields ...string) error
}
ValidatorFunc is a function that validates s It returns an error if the validation fails
Source Files
¶
- buffering.go
- clone.go
- collection.go
- config.go
- decoder.go
- dml.go
- eventsource.go
- fieldmapper.go
- fieldset.go
- filterparser.go
- keyset.go
- link.go
- patchset.go
- query_decoder.go
- querybuilder.go
- queryset.go
- request.go
- resource_iface.go
- resourceset.go
- rpc_decoder.go
- search.go
- searchkeys.go
- sqlgenerator.go
- struct_decoder.go
- tokentype_string.go
- types.go
Directories
¶
| Path | Synopsis |
|---|---|
|
package generation provides the ability to generate resource, handler, and typescript permissions and metadata code from a resource file.
|
package generation provides the ability to generate resource, handler, and typescript permissions and metadata code from a resource file. |