Documentation
¶
Index ¶
- Constants
- type Access
- type AccessCapabilities
- type CapabilitiesRequest
- type Collection
- type Computed
- type Config
- type Context
- type Decision
- type DecisionKind
- type DistinctRequest
- type Engine
- func (engine *Engine) Capabilities(ctx context.Context, request CapabilitiesRequest) (result AccessCapabilities, err error)
- func (engine *Engine) CopyLocale(ctx context.Context, collectionName, documentID string, ...) (document store.Document, err error)
- func (engine *Engine) Distinct(ctx context.Context, request DistinctRequest) (result store.DistinctPage, err error)
- func (engine *Engine) Execute(ctx context.Context, request Request) (result Result, err error)
- func (engine *Engine) ExecuteBatch(ctx context.Context, requests []Request) (results []Result, err error)
- func (engine *Engine) ForceUnlockAuth(ctx context.Context, collectionName, documentID string, actor *store.Document, ...) (err error)
- func (engine *Engine) MutateJoin(ctx context.Context, request JoinMutationRequest) (result JoinMutationResult, err error)
- func (engine *Engine) ResolveFilteredSelection(ctx context.Context, request FilteredSelectionRequest) (result FilteredSelectionResult, err error)
- func (engine *Engine) Restore(ctx context.Context, collectionName, documentID string, ...) (Result, error)
- func (engine *Engine) RestorePopulated(ctx context.Context, collectionName, documentID string, ...) (result Result, err error)
- func (engine *Engine) Version(ctx context.Context, collectionName, documentID string, revision int, ...) (store.Version, error)
- func (engine *Engine) Versions(ctx context.Context, collectionName, documentID string, actor *store.Document, ...) (versions []store.Version, err error)
- type Error
- type FieldAccess
- type FieldCapabilities
- type FieldRules
- type FilteredSelectionItem
- type FilteredSelectionRequest
- type FilteredSelectionResult
- type Hook
- type Hooks
- type JoinMutationRequest
- type JoinMutationResult
- type Kind
- type LocalizationOptions
- type OperationCapabilities
- type PermanentDelete
- type PluginValidator
- type Request
- type Result
- type TransactionMutation
- type TransactionResource
Constants ¶
const MaxBatchDocuments = store.MaxListWindowDocuments
const ( // MaxDocumentReferences bounds the relationship and upload work admitted by // one document mutation. The limit lives in the operation engine so local // calls, jobs, REST, GraphQL, and future transports cannot bypass it. MaxDocumentReferences = 512 )
const MaxValidationIssues = 128
MaxValidationIssues bounds error-envelope construction for malformed nested documents. Validation stops once the cap is reached because the mutation is already inadmissible and collecting more paths only consumes resources.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessCapabilities ¶
type AccessCapabilities struct {
Operations OperationCapabilities
Fields map[string]FieldCapabilities
}
type CapabilitiesRequest ¶
type CapabilitiesRequest struct {
Collection string
ID string
Data store.Values
Actor *store.Document
ActorCollection schema.CollectionSlug
TrashOnly bool
Locale string
FallbackLocales []schema.LocaleCode
DisableFallback bool
AllLocales bool
}
CapabilitiesRequest evaluates non-secret operation and field access for an actor. Data is a prospective create/update snapshot. TrashOnly evaluates a deleted document for restore and permanent-delete actions.
type Collection ¶
type Config ¶
type Config struct {
Collections []Collection
Store store.Store
AllowIDOnCreate bool
MaxDepth int
PluginValidators map[string]PluginValidator
DispatchAfterCommit func(Context, Hook) error
BeginPermanentDeleteFence func(context.Context, []PermanentDelete) func(bool)
CleanupPermanentDeletes func(context.Context, []PermanentDelete) error
ValidateUploadImport func(context.Context, schema.Collection, store.Values) error
RootAfterError []Hook
Localization *schema.LocalizationSettings
}
type Context ¶
type Context struct {
Context context.Context
Operation Kind
Collection schema.Collection
ID string
Actor *store.Document
ActorCollection schema.CollectionSlug
Data store.Values
Value store.Value
SiblingData store.Values
Document *store.Document
Original *store.Document
FieldPath string
RuntimePath string
Error error
Locale schema.LocaleCode
AllLocales bool
Locales []schema.LocaleCode
}
type Decision ¶
type Decision struct {
Kind DecisionKind
Access *query.Node
}
type DecisionKind ¶
type DecisionKind string
const ( Allow DecisionKind = "allow" Deny DecisionKind = "deny" Where DecisionKind = "where" )
type DistinctRequest ¶
type DistinctRequest struct {
Collection string
Field query.Path
Filter query.Expression
Page int
Limit int
Actor *store.Document
ActorCollection schema.CollectionSlug
Draft *bool
TrashOnly bool
Locale string
FallbackLocales []schema.LocaleCode
DisableFallback bool
}
DistinctRequest describes one access-checked local distinct read. The field itself remains deliberately limited by store.ValidateDistinctRequest.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) Capabilities ¶
func (engine *Engine) Capabilities(ctx context.Context, request CapabilitiesRequest) (result AccessCapabilities, err error)
Capabilities evaluates access without running validation, hooks, mutations, or commits. Filtered decisions remain predicates on store reads so a document-specific true result has the same authorization semantics as the corresponding operation.
func (*Engine) CopyLocale ¶
func (engine *Engine) CopyLocale(ctx context.Context, collectionName, documentID string, source, target schema.LocaleCode, expectedRevision int, actor *store.Document, authorizationOptions ...LocalizationOptions) (document store.Document, err error)
CopyLocale copies readable localized values from one exact locale into a different locale through the lifecycle appropriate to the current status. Copying into a published document is itself a live edit, so it requires both update and publish access and runs publish hooks atomically.
func (*Engine) Distinct ¶
func (engine *Engine) Distinct(ctx context.Context, request DistinctRequest) (result store.DistinctPage, err error)
Distinct reads unique scalar values through the collection read rule and a single atomic adapter query. It is intentionally separate from Execute: the initial contract is a Local API query, not a new document lifecycle or general aggregation operation.
func (*Engine) ExecuteBatch ¶
func (engine *Engine) ExecuteBatch(ctx context.Context, requests []Request) (results []Result, err error)
ExecuteBatch runs ordinary operations in one transaction. Every item uses the same access, validation, hook, version, and redaction pipeline as Execute.
func (*Engine) ForceUnlockAuth ¶
func (engine *Engine) ForceUnlockAuth(ctx context.Context, collectionName, documentID string, actor *store.Document, actorCollection schema.CollectionSlug) (err error)
ForceUnlockAuth clears an auth document's private login lockout state in the same transaction that evaluates and applies its update access predicate. Unlike ordinary CRUD, an omitted update rule fails closed for this privileged account-management action.
func (*Engine) MutateJoin ¶
func (engine *Engine) MutateJoin(ctx context.Context, request JoinMutationRequest) (result JoinMutationResult, err error)
MutateJoin applies inverse relation deltas through ordinary target updates in one transaction. Target access, field access, validation, hooks, versions, and after-commit dispatch remain owned by Execute.
func (*Engine) ResolveFilteredSelection ¶
func (engine *Engine) ResolveFilteredSelection(ctx context.Context, request FilteredSelectionRequest) (result FilteredSelectionResult, err error)
ResolveFilteredSelection freezes one bounded, read-visible ID set and its exact per-document capabilities without running hooks or mutations.
func (*Engine) RestorePopulated ¶
func (engine *Engine) RestorePopulated(ctx context.Context, collectionName, documentID string, revision, expectedRevision int, draft bool, actor *store.Document, populations []query.Population, outputFields []query.Path, localeOptions ...LocalizationOptions) (result Result, err error)
RestorePopulated restores a revision and applies a bounded relationship population plan to the returned document in the update transaction.
type Error ¶
type Error struct {
Code string
Status int
Message string
Issues []schema.Issue
Cause error
// Committed reports that the durable transaction succeeded before a later
// after-commit effect failed. Callers that stage external resources must not
// roll those resources back when this is true.
Committed bool
// CommitAttempted reports that Commit was sent but its durable outcome could
// not be proven. External resources must be retained and reconciled instead
// of rolled back when this is true.
CommitAttempted bool
}
type FieldAccess ¶
type FieldCapabilities ¶
type FieldRules ¶
type FieldRules struct {
Create FieldAccess
Read FieldAccess
Update FieldAccess
}
type FilteredSelectionItem ¶
type FilteredSelectionItem struct {
ID string
Capabilities AccessCapabilities
}
type FilteredSelectionRequest ¶
type FilteredSelectionRequest struct {
Collection string
Filter query.Expression
Actor *store.Document
ActorCollection schema.CollectionSlug
TrashOnly bool
Locale string
FallbackLocales []schema.LocaleCode
DisableFallback bool
AllLocales bool
}
type FilteredSelectionResult ¶
type FilteredSelectionResult struct {
Items []FilteredSelectionItem
}
type JoinMutationRequest ¶
type JoinMutationRequest struct {
Collection string
ID string
Field string
Additions []string
Removals []string
Actor *store.Document
ActorCollection schema.CollectionSlug
Locale string
FallbackLocales []schema.LocaleCode
DisableFallback bool
AllLocales bool
}
JoinMutationRequest describes explicit inverse-relation changes. Additions and removals are deltas because a rendered join can be a limited subset of all matching target documents.
type JoinMutationResult ¶
JoinMutationResult reports the refreshed source document and applied deltas.
type Kind ¶
type Kind string
const ( Create Kind = "create" Duplicate Kind = "duplicate" Admin Kind = "admin" Read Kind = "read" ReadVersions Kind = "read-versions" Update Kind = "update" Delete Kind = "delete" RestoreDeleted Kind = "restore-deleted" DeletePermanent Kind = "delete-permanent" Publish Kind = "publish" Unpublish Kind = "unpublish" Unlock Kind = "unlock" )
type LocalizationOptions ¶
type LocalizationOptions struct {
Locale string
FallbackLocales []schema.LocaleCode
DisableFallback bool
AllLocales bool
// ActorCollection identifies the exact auth collection that owns Actor on
// specialized version and locale operations.
ActorCollection schema.CollectionSlug
}
LocalizationOptions selects the locale projection for version reads.
type OperationCapabilities ¶
type PermanentDelete ¶
type PermanentDelete struct {
Collection schema.Collection
DocumentID string
Original store.Document
}
PermanentDelete identifies one document whose durable deletion must be fenced with lifecycle-sensitive in-process state such as preview grants.
type Request ¶
type Request struct {
Operation Kind
Collection string
ID string
Data store.Values
Filter query.Expression
Actor *store.Document
ActorCollection schema.CollectionSlug
Page int
Limit int
IndexWindow *store.IndexWindow
Sort []query.Sort
Select []query.Path
Populate []query.Population
// OutputFields limits computed and inverse-join resolution. Nil preserves
// the local API's historical behavior of resolving every output field; a
// non-nil empty slice resolves none. This is deliberately separate from
// Select because computed resolvers may depend on unprojected stored data.
OutputFields []query.Path
// Draft overrides versioned read visibility or selects the status written
// by create/update. Nil preserves the caller's existing behavior.
Draft *bool
ExpectedRevision int
Status *store.Status
ImportID string
ImportCreatedAt time.Time
ImportUpdatedAt time.Time
TrashOnly bool
StoragePrepared bool
// ValidateUploadObjects re-adopts existing upload keys. The engine locks and
// verifies every final key inside the write transaction before committing
// metadata that can make those objects live again.
ValidateUploadObjects bool
LocalizationPrepared bool
// SkipFieldAccess is reserved for framework-owned initialization that must
// author the first administrator before an actor exists. Collection access,
// validation, hooks, and the transaction remain active.
SkipFieldAccess bool
TransactionMutation TransactionMutation
// TransactionResource binds one framework-owned external resource to the
// true outer transaction. Commit retains it, a definite rollback cleans it
// up, and an unknown commit outcome retains it for reconciliation rather
// than risking a dangling durable row.
TransactionResource *TransactionResource
Locale string
FallbackLocales []schema.LocaleCode
DisableFallback bool
AllLocales bool
// contains filtered or unexported fields
}
type TransactionMutation ¶
type TransactionMutation func(context.Context, store.Transaction, schema.Collection, store.Document) error
type TransactionResource ¶
type TransactionResource struct {
Commit func()
Rollback func(context.Context) error
Unknown func()
// contains filtered or unexported fields
}
TransactionResource coordinates an external resource whose durable system cannot participate in the document-store transaction.
func (*TransactionResource) Claimed ¶
func (resource *TransactionResource) Claimed() bool
Claimed reports whether the operation engine attached the resource to a document transaction. Once claimed, only the true outer transaction may finalize it; callers must not perform eager fallback cleanup.