Documentation
¶
Overview ¶
Package resources owns learning-resource publications and configurable taxonomy. Files, academic references, moderation and entitlements are supplied through ports.
Index ¶
- Variables
- func ValidateAttributes(c Category, values map[string]Value, filter bool) error
- func ValidateCategory(c CategoryWrite) error
- type Associations
- type Authority
- type Capabilities
- type Catalog
- type Category
- type CategoryPage
- type CategoryWrite
- type Command
- type Config
- type Consent
- type Decision
- type Dependencies
- type Directory
- type DirectoryPage
- type DirectoryWrite
- type DraftWrite
- type Entitlement
- type Entitlements
- type Event
- type Field
- type File
- type FileEvidence
- type FileLink
- type Files
- type Filter
- type Grant
- type GrantPage
- type GrantRecord
- type GrantWrite
- type Inspection
- type Job
- type Metadata
- type Moderation
- type Names
- type Option
- type Origin
- type Package
- type PackagePart
- type PackageRecord
- type PackageRequest
- type Page
- type Principal
- type Publication
- type Record
- type Replay
- type Repository
- type Request
- type RequestPage
- type RequestReceipt
- type RequestRecord
- type RequestStatus
- type Resource
- type ReviewSubmission
- type Selection
- type Service
- func (s *Service) ApplyContentDecision(ctx context.Context, p Principal, in Decision) (Resource, error)
- func (s *Service) ApplyDecision(ctx context.Context, p Principal, id, key string, in Decision) (Resource, error)
- func (s *Service) AttachFile(ctx context.Context, p Principal, id, key string, in FileLink) (Resource, error)
- func (s *Service) AuthorizeFile(ctx context.Context, p Principal, versionID, mediaVersionID, action string) error
- func (s *Service) Capabilities() Capabilities
- func (s *Service) Categories(ctx context.Context, limit int, after string, includeDisabled bool) (CategoryPage, error)
- func (s *Service) CreateDraft(ctx context.Context, p Principal, key string, in DraftWrite) (Resource, error)
- func (s *Service) CreatePackage(ctx context.Context, p Principal, key string, in PackageRequest) (Package, error)
- func (s *Service) CreateRequest(ctx context.Context, p Principal, id, key string, in Request) (RequestReceipt, error)
- func (s *Service) Directories(ctx context.Context, p Principal, school, course, parent string, n int, ...) (DirectoryPage, error)
- func (s *Service) Download(ctx context.Context, p Principal, id string, w io.Writer) (File, error)
- func (s *Service) DownloadPackage(ctx context.Context, p Principal, id string, part int, w io.Writer) error
- func (s *Service) DownloadReviewFile(ctx context.Context, p Principal, versionID string, w io.Writer) error
- func (s *Service) Get(ctx context.Context, p Principal, id string) (Resource, error)
- func (s *Service) GetPackage(ctx context.Context, p Principal, id string) (PackageRecord, error)
- func (s *Service) Grants(ctx context.Context, p Principal, id string, n int, after string) (GrantPage, error)
- func (s *Service) InspectReview(ctx context.Context, p Principal, versionID string) (Inspection, error)
- func (s *Service) List(ctx context.Context, p Principal, f Filter, mine, admin bool) (Page, error)
- func (s *Service) ProcessOne(ctx context.Context, worker string) (bool, error)
- func (s *Service) PutCategory(ctx context.Context, p Principal, id, key string, input CategoryWrite) (Category, error)
- func (s *Service) PutDirectory(ctx context.Context, p Principal, id, key string, in DirectoryWrite) (Directory, error)
- func (s *Service) PutGrant(ctx context.Context, p Principal, id, grantID, key string, in GrantWrite) (Grant, error)
- func (s *Service) RequestStatus(ctx context.Context, p Principal, id string) (RequestReceipt, error)
- func (s *Service) Requests(ctx context.Context, p Principal, n int, after string) (RequestPage, error)
- func (s *Service) RetryPending(ctx context.Context, p Principal, id, key string, in Command) (Resource, error)
- func (s *Service) RetryRequest(ctx context.Context, p Principal, id, key string) (RequestReceipt, error)
- func (s *Service) ReviewResource(ctx context.Context, p Principal, versionID string) (Resource, error)
- func (s *Service) SetState(ctx context.Context, p Principal, id, key string, in StateChange) (Resource, error)
- func (s *Service) Submit(ctx context.Context, p Principal, id, key string, in Command) (Resource, error)
- func (s *Service) UpdateDraft(ctx context.Context, p Principal, id, key string, in DraftWrite) (Resource, error)
- type StateChange
- type Terms
- type Transaction
- type UploadProfile
- type Value
- type Version
- type VersionRecord
Constants ¶
This section is empty.
Variables ¶
var ( ErrInput = errors.New("resources_invalid_input") ErrUnauthenticated = errors.New("resources_authentication_required") ErrDenied = errors.New("resources_permission_denied") ErrNotFound = errors.New("resources_not_found") ErrConflict = errors.New("resources_conflict") ErrCapacity = errors.New("resources_capacity_exceeded") )
Functions ¶
func ValidateAttributes ¶
func ValidateCategory ¶
func ValidateCategory(c CategoryWrite) error
ValidateCategory checks the configurable schema, never a category name or ID.
Types ¶
type Associations ¶
type Authority ¶
Authority supplies current action eligibility and administration scope. Upload and download decisions include the configured campus/phone facts. Missing facts return unavailable; a permission grant cannot silently stand in for a fact.
type Capabilities ¶
type Capabilities struct {
UploadProfiles []UploadProfile `json:"upload_profiles"`
Terms Terms `json:"terms"`
AllowedTypes []string `json:"allowed_types"`
MaxFileSize int64 `json:"max_file_size"`
MaxPackageBytes int64 `json:"max_package_bytes"`
MaxPackageFiles int `json:"max_package_files"`
PurchaseAvailable bool `json:"purchase_available"`
}
type CategoryPage ¶
type CategoryWrite ¶
type Config ¶
type Config struct {
UploadProfiles []UploadProfile
Clock func() time.Time
Terms Terms
AllowedTypes []string
MaxFileSize, MaxPackageBytes int64
MaxPackageFiles, MaxPackageParts, MaxDirectoryDepth, MaxRecords, MaxOperations, MaxJobs int
OperationTimeout, PackageTTL, Lease time.Duration
MaxAttempts int
}
type Dependencies ¶
type Dependencies struct {
Authority Authority
Catalog Catalog
Files Files
Moderation Moderation
Entitlements Entitlements
}
type DirectoryPage ¶
type DirectoryWrite ¶
type DraftWrite ¶
type Entitlement ¶
type Entitlements ¶
type Field ¶
type Field struct {
Key string `json:"key"`
Names Names `json:"names"`
Kind string `json:"kind"`
Required bool `json:"required"`
Filterable bool `json:"filterable"`
Groupable bool `json:"groupable"`
Min *int64 `json:"min,omitempty"`
Max *int64 `json:"max,omitempty"`
MaxLength int `json:"max_length,omitempty"`
Options []Option `json:"options,omitempty"`
}
type FileEvidence ¶
type Files ¶
type Files interface {
Inspect(context.Context, Principal, string) (FileEvidence, error)
Publish(context.Context, Publication) (reference string, ready bool, err error)
Release(context.Context, string, string) error
Download(context.Context, Principal, string, io.Writer) error
Archive(context.Context, Principal, []Selection, io.Writer) error
ReviewDownload(context.Context, Principal, string, string, io.Writer) error
}
type GrantRecord ¶
type GrantWrite ¶
type Inspection ¶
type Inspection struct {
ResourceID, VersionID, SchoolID, Owner, Title, Description, State string
Revision int64
Visible bool
}
Inspection is the minimal current content state for the moderation router. The account must have the current school-scoped moderation permission.
type Metadata ¶
type Metadata struct {
Title string `json:"title"`
Description string `json:"description"`
Tags []string `json:"tags"`
CategoryID string `json:"category_id"`
CategoryRevision int64 `json:"category_revision"`
Attributes map[string]Value `json:"attributes"`
Associations Associations `json:"associations"`
Access string `json:"access"`
Origin Origin `json:"origin"`
DirectoryID string `json:"directory_id,omitempty"`
}
type Moderation ¶
type Package ¶
type Package struct {
ID string `json:"id"`
Parts []PackagePart `json:"parts"`
ExpiresAt time.Time `json:"expires_at"`
}
type PackagePart ¶
type PackageRecord ¶
type PackageRequest ¶
type Publication ¶
type Record ¶
type Record struct {
ID string
Owner Principal
SchoolID string
Revision int64
State string
ActiveID string
ProposalID string
NextVersion int64
CreatedAt time.Time
}
Record and VersionRecord are private repository/port models, never HTTP DTOs.
type Replay ¶
type Replay struct {
Key, Digest string
Result json.RawMessage
}
type Repository ¶
type RequestPage ¶
type RequestPage struct {
Items []RequestReceipt `json:"items"`
NextCursor string `json:"next_cursor"`
}
type RequestReceipt ¶
type RequestReceipt struct {
TaskID string `json:"task_id,omitempty"`
ResourceID string `json:"resource_id,omitempty"`
Kind string `json:"kind,omitempty"`
DecisionReason string `json:"decision_reason,omitempty"`
CanAppeal bool `json:"can_appeal"`
ID string `json:"id"`
State string `json:"state"`
CreatedAt time.Time `json:"created_at"`
}
type RequestRecord ¶
type RequestStatus ¶
type Resource ¶
type Resource struct {
ID string `json:"id"`
Revision int64 `json:"revision"`
State string `json:"state"`
Current *Version `json:"current,omitempty"`
Proposal *Version `json:"proposal,omitempty"`
DownloadAllowed bool `json:"download_allowed"`
AccessReason string `json:"access_reason"`
Owned bool `json:"owned"`
}
type ReviewSubmission ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func New ¶
func New(repo Repository, deps Dependencies, cfg Config) (*Service, error)
func (*Service) ApplyContentDecision ¶
func (s *Service) ApplyContentDecision(ctx context.Context, p Principal, in Decision) (Resource, error)
ApplyContentDecision is the moderation delivery boundary. A single durable replay key covers both initial review and later state changes, so a retry after an ambiguous response does not reinterpret a now-published version.
func (*Service) ApplyDecision ¶
func (*Service) AttachFile ¶
func (*Service) AuthorizeFile ¶
func (s *Service) AuthorizeFile(ctx context.Context, p Principal, versionID, mediaVersionID, action string) error
AuthorizeFile is used by the media adapter before every file action. Reference ownership comes from the persisted resources version; clients cannot supply it.
func (*Service) Capabilities ¶
func (s *Service) Capabilities() Capabilities
func (*Service) Categories ¶
func (*Service) CreateDraft ¶
func (*Service) CreatePackage ¶
func (*Service) CreateRequest ¶
func (*Service) Directories ¶
func (*Service) DownloadPackage ¶
func (*Service) DownloadReviewFile ¶
func (*Service) GetPackage ¶
func (*Service) InspectReview ¶
func (*Service) ProcessOne ¶
ProcessOne claims one recoverable operation. The host owns concurrency and shutdown; a cancelled attempt remains leased until it can safely be reclaimed.
func (*Service) PutCategory ¶
func (*Service) PutDirectory ¶
func (*Service) RequestStatus ¶
func (s *Service) RequestStatus(ctx context.Context, p Principal, id string) (RequestReceipt, error)
RequestStatus returns only the submitting user's receipt and safe decision text. Private reporter evidence remains in the moderation task and is never copied.
func (*Service) Requests ¶
func (s *Service) Requests(ctx context.Context, p Principal, n int, after string) (RequestPage, error)
Requests is a bounded owner-only receipt listing. Detail refresh performs the current moderation lookup without issuing one external call per list row.
func (*Service) RetryPending ¶
func (s *Service) RetryPending(ctx context.Context, p Principal, id, key string, in Command) (Resource, error)
RetryPending resumes exhausted operations without changing their idempotency keys. Providers must return the earlier result after an ambiguous timeout.
func (*Service) RetryRequest ¶
func (*Service) ReviewResource ¶
func (*Service) UpdateDraft ¶
type StateChange ¶
type Transaction ¶
type Transaction interface {
Lock(string) error
Category(string, int64) (Category, error)
SaveCategory(Category) error
Categories(int, string, bool) ([]Category, error)
Record(string) (Record, error)
SaveRecord(Record) error
Version(string) (VersionRecord, error)
SaveVersion(VersionRecord) error
List(Filter) ([]Record, error)
Counts() (records, operations, jobs int, err error)
Replay(string) (Replay, error)
SaveReplay(Replay) error
Grant(string, string) (GrantRecord, error)
GrantByID(string) (GrantRecord, error)
Grants(string, int, string) ([]GrantRecord, error)
SaveGrant(GrantRecord) error
Directory(string) (Directory, error)
SaveDirectory(Directory) error
Directories(string, string, string, int, string) ([]Directory, error)
Package(string) (PackageRecord, error)
SavePackage(PackageRecord) error
Request(string) (RequestRecord, error)
Requests(Principal, int, string) ([]RequestRecord, error)
SaveRequest(RequestRecord) error
Job(string) (Job, error)
SaveJob(Job) error
Event(Event) error
}
type UploadProfile ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package contracts supplies the same OpenAPI document used to generate clients.
|
Package contracts supplies the same OpenAPI document used to generate clients. |
|
Package httpapi translates bounded resource requests and stable errors.
|
Package httpapi translates bounded resource requests and stable errors. |
|
Package postgres owns the resources schema and data access identity.
|
Package postgres owns the resources schema and data access identity. |
|
Package sdk provides primitives to interact with the openapi HTTP API.
|
Package sdk provides primitives to interact with the openapi HTTP API. |