Documentation
¶
Overview ¶
Package inspect is an Arandu module that takes an operator into somebody's account without signing them out of their own, lets them act there as the account's owner, brings them back, and holds the visit to a deadline. Everything is recorded in arandu-activitylog under the operator's name.
module.go -> registration, routes, handlers, the guard and the migration config.go -> what the application passes in model.go -> the inspection policy.go -> who may go into which account service.go -> going in, coming back, the deadline, the history
The bar that tells the operator whose account they are in is drawn by the application's layout from hesape's view.Inspection, which every page built with view.New answers; its button posts to the route named inspect.leave, which this module registers.
Index ¶
- Constants
- Variables
- type Config
- type Flag
- type HistoryQuery
- type InspectPolicy
- type InspectService
- func (s *InspectService) Find(ctx context.Context, actor security.Subject, id string) (*Inspection, error)
- func (s *InspectService) History(ctx context.Context, actor security.Subject, q HistoryQuery) ([]*Inspection, int, error)
- func (s *InspectService) Lapsed(ctx context.Context, current security.Subject) (bool, error)
- func (s *InspectService) Leave(ctx context.Context, current security.Subject, reason string) (security.Subject, *Inspection, error)
- func (s *InspectService) OpenNow(ctx context.Context, actor security.Subject) ([]*Inspection, error)
- func (s *InspectService) Start(ctx context.Context, actor security.Subject, targetID string) (security.Subject, *Inspection, error)
- type Inspection
- type InspectionCollection
- func (c InspectionCollection) Contains(key any) bool
- func (c InspectionCollection) Except(keys ...any) InspectionCollection
- func (c InspectionCollection) Find(key any) *Inspection
- func (c InspectionCollection) FindOrFail(key any) (*Inspection, error)
- func (c InspectionCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (InspectionCollection, error)
- func (c InspectionCollection) Load(ctx context.Context, g auth.Grant, relations ...string) error
- func (c InspectionCollection) LoadCount(ctx context.Context, g auth.Grant, relations ...string) error
- func (c InspectionCollection) LoadMissing(ctx context.Context, g auth.Grant, relations ...string) error
- func (c InspectionCollection) ModelKeys() []any
- func (c InspectionCollection) Only(keys ...any) InspectionCollection
- func (c InspectionCollection) Pluck(column string) []any
- func (c InspectionCollection) Rows() model.Rows
- func (c InspectionCollection) ToArray() []map[string]any
- func (c InspectionCollection) Unique() InspectionCollection
- type InspectionQuery
- func (q *InspectionQuery) AddSelect(columns ...any) *InspectionQuery
- func (q *InspectionQuery) Avg(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *InspectionQuery) Base() *model.Builder
- func (q *InspectionQuery) Chunk(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *InspectionQuery) Clone() *InspectionQuery
- func (q *InspectionQuery) Count(ctx context.Context, g auth.Grant, columns ...any) (int64, error)
- func (q *InspectionQuery) Create(ctx context.Context, g auth.Grant, attributes map[string]any) (*Inspection, error)
- func (q *InspectionQuery) Cursor(ctx context.Context, g auth.Grant) iter.Seq2[*Inspection, error]
- func (q *InspectionQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, ...) (InspectionCollection, *pagination.CursorPage, error)
- func (q *InspectionQuery) Decrement(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *InspectionQuery) Delete(ctx context.Context, g auth.Grant) (int64, error)
- func (q *InspectionQuery) DoesntExist(ctx context.Context, g auth.Grant) (bool, error)
- func (q *InspectionQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *InspectionQuery
- func (q *InspectionQuery) Each(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *InspectionQuery) Exists(ctx context.Context, g auth.Grant) (bool, error)
- func (q *InspectionQuery) Find(ctx context.Context, g auth.Grant, id any, columns ...any) (*Inspection, error)
- func (q *InspectionQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (InspectionCollection, error)
- func (q *InspectionQuery) FindOrFail(ctx context.Context, g auth.Grant, id any, columns ...any) (*Inspection, error)
- func (q *InspectionQuery) FindOrNew(ctx context.Context, g auth.Grant, id any, columns ...any) (*Inspection, error)
- func (q *InspectionQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*Inspection, error)
- func (q *InspectionQuery) FirstOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Inspection, error)
- func (q *InspectionQuery) FirstOrFail(ctx context.Context, g auth.Grant, columns ...any) (*Inspection, error)
- func (q *InspectionQuery) FirstOrNew(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Inspection, error)
- func (q *InspectionQuery) FirstWhere(ctx context.Context, g auth.Grant, column any, args ...any) (*Inspection, error)
- func (q *InspectionQuery) ForPage(page, perPage int) *InspectionQuery
- func (q *InspectionQuery) ForceCreate(ctx context.Context, g auth.Grant, attributes map[string]any) (*Inspection, error)
- func (q *InspectionQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (InspectionCollection, error)
- func (q *InspectionQuery) GroupBy(groups ...any) *InspectionQuery
- func (q *InspectionQuery) Has(relation, operator string, count int, boolean string, ...) *InspectionQuery
- func (q *InspectionQuery) Increment(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *InspectionQuery) Insert(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *InspectionQuery) InsertOrIgnore(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *InspectionQuery) Join(table any, first any, args ...any) *InspectionQuery
- func (q *InspectionQuery) Latest(column ...string) *InspectionQuery
- func (q *InspectionQuery) Limit(value int) *InspectionQuery
- func (q *InspectionQuery) Max(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *InspectionQuery) Min(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *InspectionQuery) New() (*Inspection, error)
- func (q *InspectionQuery) Offset(value int) *InspectionQuery
- func (q *InspectionQuery) Oldest(column ...string) *InspectionQuery
- func (q *InspectionQuery) OrDoesntHave(relation string) *InspectionQuery
- func (q *InspectionQuery) OrHas(relation, operator string, count int) *InspectionQuery
- func (q *InspectionQuery) OrWhere(column any, args ...any) *InspectionQuery
- func (q *InspectionQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *InspectionQuery
- func (q *InspectionQuery) OrWhereHas(relation string, callback func(*query.Builder)) *InspectionQuery
- func (q *InspectionQuery) OrWhereNot(column any, args ...any) *InspectionQuery
- func (q *InspectionQuery) OrWhereRelation(relation string, column any, args ...any) *InspectionQuery
- func (q *InspectionQuery) OrderBy(column any, direction ...string) *InspectionQuery
- func (q *InspectionQuery) OrderByDesc(column any) *InspectionQuery
- func (q *InspectionQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (InspectionCollection, *pagination.LengthAwarePage, error)
- func (q *InspectionQuery) Pluck(ctx context.Context, g auth.Grant, column string) ([]any, error)
- func (q *InspectionQuery) Select(columns ...any) *InspectionQuery
- func (q *InspectionQuery) SelectRaw(expression string, bindings ...any) *InspectionQuery
- func (q *InspectionQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (InspectionCollection, *pagination.Page, error)
- func (q *InspectionQuery) Sole(ctx context.Context, g auth.Grant, columns ...any) (*Inspection, error)
- func (q *InspectionQuery) SoleValue(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *InspectionQuery) Sum(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *InspectionQuery) Touch(ctx context.Context, g auth.Grant, column ...string) (int64, error)
- func (q *InspectionQuery) Update(ctx context.Context, g auth.Grant, values map[string]any) (int64, error)
- func (q *InspectionQuery) UpdateOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Inspection, error)
- func (q *InspectionQuery) Upsert(ctx context.Context, g auth.Grant, values []map[string]any, ...) (int64, error)
- func (q *InspectionQuery) Value(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *InspectionQuery) ValueOrFail(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *InspectionQuery) Where(column any, args ...any) *InspectionQuery
- func (q *InspectionQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *InspectionQuery
- func (q *InspectionQuery) WhereBetween(column any, from, to any) *InspectionQuery
- func (q *InspectionQuery) WhereColumn(first any, args ...any) *InspectionQuery
- func (q *InspectionQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *InspectionQuery
- func (q *InspectionQuery) WhereExists(callback func(*query.Builder)) *InspectionQuery
- func (q *InspectionQuery) WhereHas(relation string, callback func(*query.Builder)) *InspectionQuery
- func (q *InspectionQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *InspectionQuery
- func (q *InspectionQuery) WhereIn(column any, values []any) *InspectionQuery
- func (q *InspectionQuery) WhereKey(id any) *InspectionQuery
- func (q *InspectionQuery) WhereNot(column any, args ...any) *InspectionQuery
- func (q *InspectionQuery) WhereNotExists(callback func(*query.Builder)) *InspectionQuery
- func (q *InspectionQuery) WhereNotIn(column any, values []any) *InspectionQuery
- func (q *InspectionQuery) WhereNotNull(columns ...any) *InspectionQuery
- func (q *InspectionQuery) WhereNull(columns ...any) *InspectionQuery
- func (q *InspectionQuery) WhereRelation(relation string, column any, args ...any) *InspectionQuery
- func (q *InspectionQuery) With(relations ...string) *InspectionQuery
- func (q *InspectionQuery) WithAvg(relation, column string) *InspectionQuery
- func (q *InspectionQuery) WithCount(relations ...string) *InspectionQuery
- func (q *InspectionQuery) WithExists(relation string) *InspectionQuery
- func (q *InspectionQuery) WithMax(relation, column string) *InspectionQuery
- func (q *InspectionQuery) WithMin(relation, column string) *InspectionQuery
- func (q *InspectionQuery) WithSum(relation, column string) *InspectionQuery
- func (q *InspectionQuery) Without(relations ...string) *InspectionQuery
- func (q *InspectionQuery) WithoutGlobalScope(identifier string) *InspectionQuery
- func (q *InspectionQuery) WithoutGlobalScopes(identifiers ...string) *InspectionQuery
- type Module
- type Status
- type Targets
- type TargetsFunc
Constants ¶
const ( // DefaultPrefix is where the routes are mounted when Config leaves Prefix // empty. DefaultPrefix = "/inspect" // DefaultTTL is how long an inspection lasts before it lapses. DefaultTTL = time.Hour // MaxTTL is the longest an inspection may be configured to last. MaxTTL = 12 * time.Hour // DefaultUserType is the kind the activity log names an account by. DefaultUserType = "user" // LogName is the activity log the package's own entries go in. LogName = "inspect" )
const ( // EndLeft is the operator going back to their own account. EndLeft = "left" // EndExpired is the deadline passing. EndExpired = "expired" )
The reasons an inspection ends.
const ( // InspectStart is an operator going into somebody's account. InspectStart security.Action = "inspect.start" // InspectLeave is the operator going back to their own account. InspectLeave security.Action = "inspect.leave" // InspectHistory is reading who went into which account, and when. InspectHistory security.Action = "inspect.history" )
The actions of the package. Constants rather than strings at the call site: a typo in an action name would silently authorize nothing, or worse, everything.
const OperatorRole = "inspect.operator"
OperatorRole is the role that may go into other people's accounts and read the history. The application gives it through arandu-permission, which fills the Subject's roles.
Variables ¶
var ( // ErrOperatorAccount is an operator going into another operator's // account. ErrOperatorAccount = fmt.Errorf("inspect: an operator's account is not inspected: %w", security.ErrForbidden) // ErrNotInspecting is a leave asked by somebody who is in no account but // their own. ErrNotInspecting = fmt.Errorf("inspect: nobody is inside another account here: %w", security.ErrForbidden) )
The refusals of an inspection the policy cannot see, because they are about the account and not the inspection. Each wraps ErrForbidden.
var ErrNotFound = fmt.Errorf("inspect: record not found: %w", model.ErrModelNotFound)
ErrNotFound is a record the caller may not see or that does not exist. It wraps model.ErrModelNotFound, which the router answers with 404.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Prefix is the path the routes are mounted under. Empty means
// DefaultPrefix.
Prefix string
// Targets loads the account an operator goes into. Required.
Targets Targets
// Activity is arandu-activitylog's logger. Required: going in, coming
// back and the deadline passing are entries, and everything done inside
// the account is recorded under the operator's name by the log itself.
Activity *activitylog.Logger
// Landing is where the operator lands inside the account, and Return
// where they land back in their own. Empty means "/".
Landing string
Return string
// TTL is how long an inspection lasts. Zero means DefaultTTL; above
// MaxTTL is refused.
TTL time.Duration
// UserType is the kind the activity log names accounts by, the one the
// application's own entries use. Empty means DefaultUserType.
UserType string
}
Config is everything the module needs from the application.
type Flag ¶
type Flag bool
Flag is a yes-or-no stored as 0 or 1, which every engine reads the same.
type HistoryQuery ¶
HistoryQuery narrows the history. Page counts from one.
type InspectPolicy ¶
type InspectPolicy struct{}
InspectPolicy is the only authority over who goes into whose account.
It denies unless a rule below allows. An operator goes into accounts of their own tenant and reads its history; whoever an inspection names as its operator ends it. Whether the account itself may be gone into -- another operator's, the operator's own -- is the service's refusal, because the policy sees the inspection and not the account.
type InspectService ¶
type InspectService struct {
// contains filtered or unexported fields
}
InspectService is the package's use cases. It owns the database handle; every exported method asks the policy before it reads or writes.
func NewInspectService ¶
func NewInspectService(db *data.DB) *InspectService
NewInspectService returns the use cases over a database handle. New wires the rest.
func (*InspectService) Find ¶
func (s *InspectService) Find(ctx context.Context, actor security.Subject, id string) (*Inspection, error)
Find answers one inspection, for an operator.
func (*InspectService) History ¶
func (s *InspectService) History(ctx context.Context, actor security.Subject, q HistoryQuery) ([]*Inspection, int, error)
History is a page of inspections, newest first, and how many there are.
func (*InspectService) Lapsed ¶
Lapsed reports whether the inspection the current subject is in has passed its deadline, or no longer exists as open. A subject that is in no inspection has nothing lapsed.
func (*InspectService) Leave ¶
func (s *InspectService) Leave(ctx context.Context, current security.Subject, reason string) (security.Subject, *Inspection, error)
Leave takes the operator inside an account back to their own: the answer is the operator's own subject, for the session, and the inspection it closed. reason is EndLeft or EndExpired.
func (*InspectService) OpenNow ¶
func (s *InspectService) OpenNow(ctx context.Context, actor security.Subject) ([]*Inspection, error)
OpenNow lists the inspections under way: who is inside which account right now, and until when.
func (*InspectService) Start ¶
func (s *InspectService) Start(ctx context.Context, actor security.Subject, targetID string) (security.Subject, *Inspection, error)
Start takes an operator into somebody's account: the answer is the subject the session carries from then on -- the account's owner, with the operator kept as the one acting, able to change it -- and the inspection that records the visit.
The operator may not go into their own account, into another operator's, or anywhere from inside an account already.
type Inspection ¶
type Inspection struct {
model.Model
ID string `db:"id"`
TenantID string `db:"tenant_id"`
// ActorID is the operator; TargetID the account they went into.
ActorID string `db:"actor_id"`
TargetID string `db:"target_id"`
// Acting says the operator could change the account, and not only look.
Acting Flag `db:"acting"`
// Status is open while the operator is inside, closed once they left or
// the deadline passed. ClosedAt and EndReason mean something only once it
// is closed.
Status Status `db:"status"`
StartedAt time.Time `db:"started_at"`
ExpiresAt time.Time `db:"expires_at"`
ClosedAt time.Time `db:"closed_at"`
EndReason string `db:"end_reason"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
Inspection is one time an operator went into somebody's account: who, whose account, whether they could change it, when it began, when it lapses, and how it ended.
It is the package's own record of the visit, kept so the session can be held to a deadline and so the list of who went where can be read without reading the whole activity log. What the operator did inside the account is in the activity log, under their name, and not here.
func (Inspection) Expired ¶
func (i Inspection) Expired(now time.Time) bool
Expired reports whether the deadline has passed at now.
func (*Inspection) Fresh ¶
func (row *Inspection) Fresh(ctx context.Context, g auth.Grant, with ...string) (*Inspection, error)
Fresh reads the row again, as a new Inspection; it shadows the untyped one the embedded model promotes.
func (*Inspection) Replicate ¶
func (row *Inspection) Replicate(except ...string) (*Inspection, error)
Replicate returns an unsaved copy of the row without its key; it shadows the untyped one the embedded model promotes.
type InspectionCollection ¶
type InspectionCollection []*Inspection
InspectionCollection is rows of Inspection, as a query returns them.
func InspectionCollectionOf ¶
func InspectionCollectionOf(rows model.Rows) InspectionCollection
InspectionCollectionOf converts rows of the table of Inspection. A nil input is a nil collection.
func (InspectionCollection) Contains ¶
func (c InspectionCollection) Contains(key any) bool
func (InspectionCollection) Except ¶
func (c InspectionCollection) Except(keys ...any) InspectionCollection
func (InspectionCollection) Find ¶
func (c InspectionCollection) Find(key any) *Inspection
func (InspectionCollection) FindOrFail ¶
func (c InspectionCollection) FindOrFail(key any) (*Inspection, error)
func (InspectionCollection) Fresh ¶
func (c InspectionCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (InspectionCollection, error)
func (InspectionCollection) LoadMissing ¶
func (InspectionCollection) ModelKeys ¶
func (c InspectionCollection) ModelKeys() []any
func (InspectionCollection) Only ¶
func (c InspectionCollection) Only(keys ...any) InspectionCollection
func (InspectionCollection) Pluck ¶
func (c InspectionCollection) Pluck(column string) []any
func (InspectionCollection) Rows ¶
func (c InspectionCollection) Rows() model.Rows
Rows converts the collection back to the core's rows.
func (InspectionCollection) ToArray ¶
func (c InspectionCollection) ToArray() []map[string]any
func (InspectionCollection) Unique ¶
func (c InspectionCollection) Unique() InspectionCollection
type InspectionQuery ¶
type InspectionQuery struct {
// contains filtered or unexported fields
}
InspectionQuery is a query on the table of Inspection.
The methods that build return the query, so they chain. The methods that run take a context and an auth.Grant, and return Inspection rows or a value; there is no way to run one without a Grant.
func Inspections ¶
func Inspections(db model.DB) *InspectionQuery
Inspections starts a query on the table of Inspection, through db.
Global scopes are on and, unless the table is Global, every statement is filtered by the tenant of the Grant its terminal takes.
func (*InspectionQuery) AddSelect ¶
func (q *InspectionQuery) AddSelect(columns ...any) *InspectionQuery
func (*InspectionQuery) Base ¶
func (q *InspectionQuery) Base() *model.Builder
Base returns the core builder the query forwards to. It is for code in this package -- a local scope in the custom block of model.go -- and for the factory, which builds rows through it.
func (*InspectionQuery) Clone ¶
func (q *InspectionQuery) Clone() *InspectionQuery
Clone returns an independent copy of the query.
func (*InspectionQuery) Create ¶
func (q *InspectionQuery) Create(ctx context.Context, g auth.Grant, attributes map[string]any) (*Inspection, error)
func (*InspectionQuery) Cursor ¶
func (q *InspectionQuery) Cursor(ctx context.Context, g auth.Grant) iter.Seq2[*Inspection, error]
func (*InspectionQuery) CursorPaginate ¶
func (q *InspectionQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, opts pagination.Options, columns ...any) (InspectionCollection, *pagination.CursorPage, error)
func (*InspectionQuery) DoesntExist ¶
func (*InspectionQuery) DoesntHave ¶
func (q *InspectionQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *InspectionQuery
func (*InspectionQuery) Find ¶
func (q *InspectionQuery) Find(ctx context.Context, g auth.Grant, id any, columns ...any) (*Inspection, error)
func (*InspectionQuery) FindMany ¶
func (q *InspectionQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (InspectionCollection, error)
func (*InspectionQuery) FindOrFail ¶
func (q *InspectionQuery) FindOrFail(ctx context.Context, g auth.Grant, id any, columns ...any) (*Inspection, error)
func (*InspectionQuery) FindOrNew ¶
func (q *InspectionQuery) FindOrNew(ctx context.Context, g auth.Grant, id any, columns ...any) (*Inspection, error)
func (*InspectionQuery) First ¶
func (q *InspectionQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*Inspection, error)
First returns the first row, or nil and no error when there is none.
func (*InspectionQuery) FirstOrCreate ¶
func (q *InspectionQuery) FirstOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Inspection, error)
func (*InspectionQuery) FirstOrFail ¶
func (q *InspectionQuery) FirstOrFail(ctx context.Context, g auth.Grant, columns ...any) (*Inspection, error)
func (*InspectionQuery) FirstOrNew ¶
func (q *InspectionQuery) FirstOrNew(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Inspection, error)
func (*InspectionQuery) FirstWhere ¶
func (q *InspectionQuery) FirstWhere(ctx context.Context, g auth.Grant, column any, args ...any) (*Inspection, error)
func (*InspectionQuery) ForPage ¶
func (q *InspectionQuery) ForPage(page, perPage int) *InspectionQuery
func (*InspectionQuery) ForceCreate ¶
func (q *InspectionQuery) ForceCreate(ctx context.Context, g auth.Grant, attributes map[string]any) (*Inspection, error)
func (*InspectionQuery) Get ¶
func (q *InspectionQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (InspectionCollection, error)
Get runs the query and returns the rows.
func (*InspectionQuery) GroupBy ¶
func (q *InspectionQuery) GroupBy(groups ...any) *InspectionQuery
func (*InspectionQuery) Has ¶
func (q *InspectionQuery) Has(relation, operator string, count int, boolean string, callback func(*query.Builder)) *InspectionQuery
func (*InspectionQuery) InsertOrIgnore ¶
func (*InspectionQuery) Join ¶
func (q *InspectionQuery) Join(table any, first any, args ...any) *InspectionQuery
func (*InspectionQuery) Latest ¶
func (q *InspectionQuery) Latest(column ...string) *InspectionQuery
func (*InspectionQuery) Limit ¶
func (q *InspectionQuery) Limit(value int) *InspectionQuery
func (*InspectionQuery) New ¶
func (q *InspectionQuery) New() (*Inspection, error)
New returns an empty Inspection on the query's connection, not yet saved, filled with what WithAttributes recorded on the query.
func (*InspectionQuery) Offset ¶
func (q *InspectionQuery) Offset(value int) *InspectionQuery
func (*InspectionQuery) Oldest ¶
func (q *InspectionQuery) Oldest(column ...string) *InspectionQuery
func (*InspectionQuery) OrDoesntHave ¶
func (q *InspectionQuery) OrDoesntHave(relation string) *InspectionQuery
func (*InspectionQuery) OrHas ¶
func (q *InspectionQuery) OrHas(relation, operator string, count int) *InspectionQuery
func (*InspectionQuery) OrWhere ¶
func (q *InspectionQuery) OrWhere(column any, args ...any) *InspectionQuery
OrWhere adds an or-where clause; a func(*InspectionQuery) in place of the column adds a group.
func (*InspectionQuery) OrWhereDoesntHave ¶
func (q *InspectionQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *InspectionQuery
func (*InspectionQuery) OrWhereHas ¶
func (q *InspectionQuery) OrWhereHas(relation string, callback func(*query.Builder)) *InspectionQuery
func (*InspectionQuery) OrWhereNot ¶
func (q *InspectionQuery) OrWhereNot(column any, args ...any) *InspectionQuery
OrWhereNot adds an or-joined negated where clause, or a negated group.
func (*InspectionQuery) OrWhereRelation ¶
func (q *InspectionQuery) OrWhereRelation(relation string, column any, args ...any) *InspectionQuery
func (*InspectionQuery) OrderBy ¶
func (q *InspectionQuery) OrderBy(column any, direction ...string) *InspectionQuery
func (*InspectionQuery) OrderByDesc ¶
func (q *InspectionQuery) OrderByDesc(column any) *InspectionQuery
func (*InspectionQuery) Paginate ¶
func (q *InspectionQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (InspectionCollection, *pagination.LengthAwarePage, error)
func (*InspectionQuery) Select ¶
func (q *InspectionQuery) Select(columns ...any) *InspectionQuery
func (*InspectionQuery) SelectRaw ¶
func (q *InspectionQuery) SelectRaw(expression string, bindings ...any) *InspectionQuery
func (*InspectionQuery) SimplePaginate ¶
func (q *InspectionQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (InspectionCollection, *pagination.Page, error)
func (*InspectionQuery) Sole ¶
func (q *InspectionQuery) Sole(ctx context.Context, g auth.Grant, columns ...any) (*Inspection, error)
func (*InspectionQuery) UpdateOrCreate ¶
func (q *InspectionQuery) UpdateOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Inspection, error)
func (*InspectionQuery) ValueOrFail ¶
func (*InspectionQuery) Where ¶
func (q *InspectionQuery) Where(column any, args ...any) *InspectionQuery
Where adds a where clause; a func(*InspectionQuery) in place of the column adds a group.
func (*InspectionQuery) WhereBelongsTo ¶
func (q *InspectionQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *InspectionQuery
func (*InspectionQuery) WhereBetween ¶
func (q *InspectionQuery) WhereBetween(column any, from, to any) *InspectionQuery
func (*InspectionQuery) WhereColumn ¶
func (q *InspectionQuery) WhereColumn(first any, args ...any) *InspectionQuery
func (*InspectionQuery) WhereDoesntHave ¶
func (q *InspectionQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *InspectionQuery
func (*InspectionQuery) WhereExists ¶
func (q *InspectionQuery) WhereExists(callback func(*query.Builder)) *InspectionQuery
func (*InspectionQuery) WhereHas ¶
func (q *InspectionQuery) WhereHas(relation string, callback func(*query.Builder)) *InspectionQuery
func (*InspectionQuery) WhereHasCount ¶
func (q *InspectionQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *InspectionQuery
func (*InspectionQuery) WhereIn ¶
func (q *InspectionQuery) WhereIn(column any, values []any) *InspectionQuery
func (*InspectionQuery) WhereKey ¶
func (q *InspectionQuery) WhereKey(id any) *InspectionQuery
func (*InspectionQuery) WhereNot ¶
func (q *InspectionQuery) WhereNot(column any, args ...any) *InspectionQuery
WhereNot adds a negated where clause, or a negated group.
func (*InspectionQuery) WhereNotExists ¶
func (q *InspectionQuery) WhereNotExists(callback func(*query.Builder)) *InspectionQuery
func (*InspectionQuery) WhereNotIn ¶
func (q *InspectionQuery) WhereNotIn(column any, values []any) *InspectionQuery
func (*InspectionQuery) WhereNotNull ¶
func (q *InspectionQuery) WhereNotNull(columns ...any) *InspectionQuery
func (*InspectionQuery) WhereNull ¶
func (q *InspectionQuery) WhereNull(columns ...any) *InspectionQuery
func (*InspectionQuery) WhereRelation ¶
func (q *InspectionQuery) WhereRelation(relation string, column any, args ...any) *InspectionQuery
func (*InspectionQuery) With ¶
func (q *InspectionQuery) With(relations ...string) *InspectionQuery
func (*InspectionQuery) WithAvg ¶
func (q *InspectionQuery) WithAvg(relation, column string) *InspectionQuery
func (*InspectionQuery) WithCount ¶
func (q *InspectionQuery) WithCount(relations ...string) *InspectionQuery
func (*InspectionQuery) WithExists ¶
func (q *InspectionQuery) WithExists(relation string) *InspectionQuery
func (*InspectionQuery) WithMax ¶
func (q *InspectionQuery) WithMax(relation, column string) *InspectionQuery
func (*InspectionQuery) WithMin ¶
func (q *InspectionQuery) WithMin(relation, column string) *InspectionQuery
func (*InspectionQuery) WithSum ¶
func (q *InspectionQuery) WithSum(relation, column string) *InspectionQuery
func (*InspectionQuery) Without ¶
func (q *InspectionQuery) Without(relations ...string) *InspectionQuery
func (*InspectionQuery) WithoutGlobalScope ¶
func (q *InspectionQuery) WithoutGlobalScope(identifier string) *InspectionQuery
func (*InspectionQuery) WithoutGlobalScopes ¶
func (q *InspectionQuery) WithoutGlobalScopes(identifiers ...string) *InspectionQuery
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module is what the application registers.
func (*Module) Guard ¶
Guard ends an inspection whose deadline passed: the next request of the operator inside the account is taken back to their own, and the end is recorded. The application mounts it after RequireAuth on the routes an operator can reach from inside an account -- its panel, usually:
panel := r.Group("/painel", middleware.RequireAuth(sessions), inspectModule.Guard())
func (*Module) Migrations ¶
func (m *Module) Migrations() []foundation.Migration
Migrations declares the schema this module owns.
func (*Module) Routes ¶
Routes registers the module's routes, behind RequireAuth.
inspect.leave is the name hesape's view.New links the way back by, so the bar every page draws posts here without the application spelling the path.
func (*Module) Service ¶
func (m *Module) Service() *InspectService
Service is the use cases, for an application that calls them from its own code. Every method asks the policy.
type Targets ¶
type Targets interface {
Target(ctx context.Context, tenant, userID string) (security.Subject, error)
}
Targets is the application's answer to "who is this account": the subject its owner signs in as -- identifier, tenant, roles, actions -- so the operator inside the account is exactly what the owner is. The package keeps no users of its own.
type TargetsFunc ¶
TargetsFunc is a function that answers Targets.