Documentation
¶
Overview ¶
Package resources owns learning-resource publications and configurable taxonomy. Files, academic references and moderation are supplied through ports.
Index ¶
- Constants
- Variables
- func ValidateAttributes(c Category, values map[string]Value, filter bool) error
- func ValidateCategory(c CategoryWrite) error
- type AccessFailure
- type Associations
- type Authority
- type Capabilities
- type Catalog
- type Category
- type CategoryPage
- type CategoryWrite
- type Command
- type Config
- type Consent
- type Coverage
- type CoverageRule
- type Decision
- type Dependencies
- type Directory
- type DirectoryPage
- type DirectoryWrite
- type DiscoveryDocument
- type DiscoveryPage
- type DiscoverySource
- type DiscoveryTarget
- type DraftWrite
- type Entitlement
- type Envelope
- 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 Membership
- type Metadata
- type Moderation
- type NameCatalog
- type Names
- type Option
- type Origin
- type OutboxReader
- type Package
- type PackagePart
- type PackageRecord
- type PackageRequest
- type Page
- type Principal
- type Publication
- type PurchaseSource
- type Record
- type Reference
- type References
- 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) AnonymizeOwner(ctx context.Context, p Principal, id string) error
- 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) Consume(ctx context.Context, event Envelope) 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) DiscoveryCurrent(ctx context.Context, p Principal, ids []string) ([]DiscoveryDocument, 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) GetCoverage(ctx context.Context, p Principal, id string) (Coverage, 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) InspectComplaint(ctx context.Context, p Principal, versionID string) (Inspection, 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) MyReferences(ctx context.Context, p Principal, ids []string) (References, 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) PutCoverage(ctx context.Context, p Principal, id, key string, in Coverage) (Coverage, 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) ReadCategories(ctx context.Context, p Principal, limit int, after string, disabled bool) (CategoryPage, 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) UnlockEligibility(ctx context.Context, p Principal, id string) (UnlockDecision, error)
- func (s *Service) UpdateDraft(ctx context.Context, p Principal, id, key string, in DraftWrite) (Resource, error)
- type StateChange
- type Terms
- type Transaction
- type UnlockDecision
- type UploadProfile
- type Value
- type Version
- type VersionRecord
Constants ¶
const OutboxChannel = "resources_outbox"
Variables ¶
var ( ErrRateLimited = errors.New("rate_limited") 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 AccessFailure ¶
type AccessFailure struct {
Reason string `json:"access_reason"`
Missing []string `json:"missing_conditions,omitempty"`
RuleVersion string `json:"rule_version,omitempty"`
}
AccessFailure reports only known policy facts. It never guesses an entitlement failure when the qualification or rights provider is unavailable.
func (*AccessFailure) Error ¶
func (e *AccessFailure) Error() string
func (*AccessFailure) Unwrap ¶
func (e *AccessFailure) Unwrap() error
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 Coverage ¶
type Coverage struct {
PlanID string `json:"plan_id"`
Revision int64 `json:"revision"`
Rules []CoverageRule `json:"rules"`
}
type CoverageRule ¶
type CoverageRule struct {
SchoolID string `json:"school_id"`
DirectoryID string `json:"directory_id,omitempty"`
CategoryID string `json:"category_id,omitempty"`
}
Coverage rules are a union; dimensions within each rule are an intersection. Directory matching is exact, so moving a child never silently broadens a plan.
type Dependencies ¶
type Dependencies struct {
Authority Authority
Catalog Catalog
Files Files
Moderation Moderation
}
type DirectoryPage ¶
type DirectoryWrite ¶
type DiscoveryDocument ¶
type DiscoveryDocument struct {
Target DiscoveryTarget `json:"target"`
Revision int64 `json:"revision"`
Title string `json:"title"`
SchoolID string `json:"school_id"`
Visible bool `json:"visible"`
CourseID string `json:"course_id,omitempty"`
TeacherIDs []string `json:"teacher_ids,omitempty"`
At time.Time `json:"at"`
}
type DiscoveryPage ¶
type DiscoveryPage struct {
Items []DiscoveryDocument
Next string
}
type DiscoverySource ¶
type DiscoverySource interface {
DiscoverySnapshot(context.Context, string, int) (DiscoveryPage, error)
}
DiscoverySource is for trusted rebuild jobs, not an unauthenticated HTTP route.
type DiscoveryTarget ¶
type DiscoveryTarget struct {
Source string `json:"source"`
ID string `json:"id"`
Kind string `json:"kind"`
}
DiscoveryDocument is the public search projection. It deliberately has no body, identity, evidence, origin, payment or rating fields.
type DraftWrite ¶
type Entitlement ¶
type Envelope ¶
type Envelope struct {
DataContentType string `json:"datacontenttype,omitempty"`
SpecVersion string `json:"specversion"`
ID string `json:"id"`
Source string `json:"source"`
Type string `json:"type"`
Subject string `json:"subject"`
Time time.Time `json:"time"`
Data json.RawMessage `json:"data"`
}
Envelope carries either a discovery document or the minimal business revision. Consumers select a payload type using Type; no private persistence model is sent.
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 Membership ¶
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 NameCatalog ¶
type NameCatalog interface {
ReferenceNames(context.Context, []string) (References, error)
}
NameCatalog is a minimal module port, called only after local ownership checks.
type OutboxReader ¶
type OutboxReader interface {
PendingOutbox(context.Context, int, []string) ([]Envelope, error)
ConfirmOutbox(context.Context, string) error
}
OutboxReader is a trusted relay port. The relay serializes each source/subject and confirms only after every subscribed consumer durably accepts the event. Exclude up to 1000 subjects currently backing off or awaiting manual handling.
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 PurchaseSource ¶
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 References ¶
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 {
ResourceTitle string `json:"resource_title,omitempty"`
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 {
AvailableMethods []string `json:"available_methods,omitempty"`
UnlockReason string `json:"unlock_reason,omitempty"`
MissingConditions []string `json:"missing_conditions,omitempty"`
RuleVersion string `json:"rule_version,omitempty"`
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) AnonymizeOwner ¶
Public resource DTOs carry no uploader identity. Keep an irreversible owner marker for future projections while preserving copyright attribution/files.
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) Consume ¶
Consume is a trusted relay boundary. Authentication of the producer belongs to backend. Unknown fields are rejected to keep commercial data out of this store.
func (*Service) CreateDraft ¶
func (*Service) CreatePackage ¶
func (*Service) CreateRequest ¶
func (*Service) Directories ¶
func (*Service) DiscoveryCurrent ¶
func (s *Service) DiscoveryCurrent(ctx context.Context, p Principal, ids []string) ([]DiscoveryDocument, error)
DiscoveryCurrent returns only published metadata permitted by the requester's current discovery policy. Ownership or management access does not expose drafts.
func (*Service) DownloadPackage ¶
func (*Service) DownloadReviewFile ¶
func (*Service) GetCoverage ¶
func (*Service) GetPackage ¶
func (*Service) InspectComplaint ¶
func (s *Service) InspectComplaint(ctx context.Context, p Principal, versionID string) (Inspection, error)
InspectComplaint returns only target routing metadata. The caller must have login-only request access; no title, description, file or content is returned. A persisted complaint may still refer to a historical version after an update.
func (*Service) InspectReview ¶
func (*Service) MyReferences ¶
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) PutCoverage ¶
func (*Service) PutDirectory ¶
func (*Service) ReadCategories ¶
func (s *Service) ReadCategories(ctx context.Context, p Principal, limit int, after string, disabled bool) (CategoryPage, error)
ReadCategories is the user-facing taxonomy read boundary. Scoped configuration access remains independent of campus qualification.
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) UnlockEligibility ¶
func (*Service) UpdateDraft ¶
type StateChange ¶
type Transaction ¶
type Transaction interface {
Coverage(string) (Coverage, error)
SaveCoverage(Coverage) error
Purchase(string) (PurchaseSource, error)
SavePurchase(PurchaseSource) error
Membership(string, string) (Membership, error)
SaveMembership(Membership) error
Inbox(string) (bool, error)
SaveInbox(string) error
Envelope(Envelope) error
Rights(string, string, string, string, string, time.Time) (Entitlement, error)
DiscoveryCurrent([]string) ([]DiscoveryDocument, error)
CloseOwner(Principal, string) error
OwnedReferences(Principal, []string) ([]string, error)
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 UnlockDecision ¶
type UploadProfile ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package accountquery provides the module-owned account investigation port.
|
Package accountquery provides the module-owned account investigation port. |
|
Package auditquery defines the sanitized, authorized audit repository port.
|
Package auditquery defines the sanitized, authorized audit repository port. |
|
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. |