Documentation
¶
Index ¶
- Variables
- func AddEdgeToGraph(data json.RawMessage, predicate, objectID, subjectID string) (json.RawMessage, error)
- func BuildResourceGraph(data json.RawMessage, refProps []ReferencePropertyDef, ...) (json.RawMessage, error)
- func EdgeValue(graphData, ldContext json.RawMessage, propertyName string) string
- func EdgeValues(graphData, ldContext json.RawMessage, propertyName string) []string
- func ExtractAndStripReferences(data json.RawMessage, refProps []ReferencePropertyDef) (json.RawMessage, []repositories.Triple, error)
- func ExtractEdgesNode(graphData json.RawMessage) json.RawMessage
- func ExtractEntityNode(graphData json.RawMessage) json.RawMessage
- func ExtractReferenceTriples(data json.RawMessage, refProps []ReferencePropertyDef) ([]repositories.Triple, error)
- func ExtractResourceFields(r *entities.Resource) (map[string]any, error)
- func ExtractTriplesFromData(refProps []ReferencePropertyDef, data json.RawMessage, subjectID string) []repositories.Triple
- func FlattenGraph(graphData, ldContext json.RawMessage) json.RawMessage
- func Module(cfg config.Config, registry *PresetRegistry) fx.Option
- func ProvideAuthenticationService(params struct{ ... }) authapp.AuthenticationService
- func ProvideAuthorizationChecker(db *gorm.DB) (*authcasbin.CasbinAuthorizationChecker, error)
- func ProvideOAuthProviderRegistry(params struct{ ... }) authapp.OAuthProviderRegistry
- func ProvideSessionManager(params struct{ ... }) session.SessionManager
- func RemoveEdgeFromGraph(data json.RawMessage, predicate, objectID string) (json.RawMessage, error)
- func ReservedResourceTypeSlugs() map[string]bool
- func SeedAdminPolicies(checker *authcasbin.CasbinAuthorizationChecker) error
- func StringField(m map[string]any, key string) string
- func SubscribeResourceHandlers(d *domain.EventDispatcher, eventStore domain.EventStore, ...) error
- func SubscribeResourceTypeHandlers(d *domain.EventDispatcher, repo repositories.ResourceTypeRepository, ...) error
- func SubscribeTripleHandlers(d *domain.EventDispatcher, tripleRepo repositories.TripleRepository, ...) error
- func SyncAccessMapToCasbin(checker *authcasbin.CasbinAuthorizationChecker, ...) error
- func WireResourceWriter(writer *lazyResourceWriter, svc ResourceService) error
- type BehaviorFactory
- type BehaviorInfo
- type BehaviorMetaRegistry
- type BehaviorServices
- type CreateResourceCommand
- type CreateResourceTypeCommand
- type DeleteResourceCommand
- type DeleteResourceTypeCommand
- type FileService
- type GrantPermissionCommand
- type InstallPresetResult
- type MountedHandler
- type PresetDefinition
- type PresetHTTPHandler
- type PresetHTTPHandlers
- type PresetRegistry
- func (r *PresetRegistry) Add(def PresetDefinition) error
- func (r *PresetRegistry) Behaviors(services BehaviorServices) (ResourceBehaviorRegistry, error)
- func (r *PresetRegistry) BehaviorsMeta() BehaviorMetaRegistry
- func (r *PresetRegistry) Get(name string) (PresetDefinition, bool)
- func (r *PresetRegistry) Handlers(services BehaviorServices) ([]MountedHandler, error)
- func (r *PresetRegistry) List() []PresetDefinition
- func (r *PresetRegistry) MustAdd(def PresetDefinition)
- type PresetResourceType
- type PresetSidebarConfig
- type ReferencePropertyDef
- type ResourceBehaviorRegistry
- type ResourcePermissionService
- type ResourceService
- type ResourceTypeService
- type ResourceWriter
- type RevokePermissionCommand
- type SortOptions
- type UpdateResourceCommand
- type UpdateResourceTypeCommand
- type UploadParams
- type UploadResult
Constants ¶
This section is empty.
Variables ¶
var ErrForbidden = errors.New("forbidden")
ErrForbidden is returned when the caller lacks required permissions.
var ErrValidation = errors.New("validation error")
ErrValidation is returned for client-side validation failures (bad input).
var ODRLActions = map[string]string{ "read": authentities.ActionRead, "modify": authentities.ActionModify, "delete": authentities.ActionDelete, }
ODRLActions maps short action names used in the API to ODRL IRIs.
Functions ¶
func AddEdgeToGraph ¶
func AddEdgeToGraph( data json.RawMessage, predicate, objectID, subjectID string, ) (json.RawMessage, error)
AddEdgeToGraph adds a relationship edge to a JSON-LD @graph document. Multi-valued predicates accumulate into an array. Re-adding an edge that already exists with the same (predicate, object) pair is a no-op — this lets the Triple.Created projection replay edges already materialized in Resource.Created's @graph body without duplicating them. If no edges node exists, one is created. If no @graph exists, the data is wrapped as an entity node with a new edges node. Returns an error if the edges node contains a value of an unexpected shape (not nil, not a map with @id, not a slice of such maps), since silently overwriting would destroy data that the caller cannot see.
func BuildResourceGraph ¶
func BuildResourceGraph( data json.RawMessage, refProps []ReferencePropertyDef, resourceID, typeName string, ldContext json.RawMessage, ) (json.RawMessage, error)
BuildResourceGraph takes flat input data and separates it into a JSON-LD @graph with an entity node (intrinsic properties) and an edges node (resource references). Reference properties are identified by x-resource-type markers in the schema. The edges node uses JSON-LD {"@id": "..."} format for object references.
func EdgeValue ¶
func EdgeValue(graphData, ldContext json.RawMessage, propertyName string) string
EdgeValue reads a specific reference property value from a JSON-LD @graph's edges node. The propertyName is the original schema property name (e.g., "courseId"). It resolves the property to its predicate IRI using the document's @context, then looks up that predicate in the edges node and unwraps the {"@id": "..."} value. Falls back to reading from flat data for legacy format.
For multi-valued reference properties (where the edge is stored as an array of refs), this returns the first @id. Use EdgeValues to read every entry.
func EdgeValues ¶
func EdgeValues(graphData, ldContext json.RawMessage, propertyName string) []string
EdgeValues reads every reference value for the given property from a JSON-LD @graph's edges node. Returns a single-element slice for the scalar-edge case and one entry per ref for the array-edge case (which BuildResourceGraph emits when the schema declares x-resource-type on an array property).
Falls back to reading the property directly for legacy flat data. Returns an empty slice when the property is absent.
func ExtractAndStripReferences ¶
func ExtractAndStripReferences( data json.RawMessage, refProps []ReferencePropertyDef, ) (json.RawMessage, []repositories.Triple, error)
ExtractAndStripReferences extracts reference property values from data as triples and removes the reference keys from the data. Returns the stripped data and the extracted triples (with subject left empty — caller sets it).
Prefer ExtractReferenceTriples when the caller doesn't need the stripped data — it avoids the unmarshal/marshal round-trip that this function performs solely to produce the stripped output.
func ExtractEdgesNode ¶
func ExtractEdgesNode(graphData json.RawMessage) json.RawMessage
ExtractEdgesNode extracts the edges node (relationship references) from a JSON-LD @graph. Returns nil if no edges node exists or if the data is in legacy flat format.
func ExtractEntityNode ¶
func ExtractEntityNode(graphData json.RawMessage) json.RawMessage
ExtractEntityNode extracts the intrinsic entity node from a JSON-LD @graph document. Falls back to returning the input as-is if it has no @graph key (legacy flat format).
func ExtractReferenceTriples ¶
func ExtractReferenceTriples( data json.RawMessage, refProps []ReferencePropertyDef, ) ([]repositories.Triple, error)
ExtractReferenceTriples decodes data and pulls out reference property values as triples without modifying or re-marshaling the data. Use this in callers that already pass the original data (refs intact) into BuildResourceGraph and only need the triples for event sourcing — the stripped output that ExtractAndStripReferences produces would just be discarded.
Returned triples have empty Subject; the caller sets it.
func ExtractResourceFields ¶
ExtractResourceFields parses intrinsic properties from a Resource's JSON-LD data.
func ExtractTriplesFromData ¶
func ExtractTriplesFromData( refProps []ReferencePropertyDef, data json.RawMessage, subjectID string, ) []repositories.Triple
ExtractTriplesFromData produces concrete triples from resource data using reference property definitions. Supports both @graph format and legacy flat format. Each non-empty reference property value becomes a triple.
func FlattenGraph ¶
func FlattenGraph(graphData, ldContext json.RawMessage) json.RawMessage
FlattenGraph converts a @graph document back to flat JSON by merging the entity node and edges node into a single object. Edge values are converted from {"@id": "..."} to their original property names using the resource type's ldContext for reverse-mapping. Falls back to returning data as-is if not in @graph format.
func Module ¶
func Module(cfg config.Config, registry *PresetRegistry) fx.Option
Module provides all application dependencies. It accepts a Config parameter that must be provided by the calling application.
func ProvideAuthenticationService ¶
func ProvideAuthenticationService(params struct {
fx.In
Registry authapp.OAuthProviderRegistry
Agents authrepos.AgentRepository
Credentials authrepos.CredentialRepository
Sessions authrepos.AuthSessionRepository
Accounts authrepos.AccountRepository
AuthzChecker *authcasbin.CasbinAuthorizationChecker
}) authapp.AuthenticationService
func ProvideAuthorizationChecker ¶
func ProvideAuthorizationChecker(db *gorm.DB) (*authcasbin.CasbinAuthorizationChecker, error)
func ProvideSessionManager ¶
func RemoveEdgeFromGraph ¶
func RemoveEdgeFromGraph( data json.RawMessage, predicate, objectID string, ) (json.RawMessage, error)
RemoveEdgeFromGraph removes a specific relationship edge from a JSON-LD @graph document. For multi-valued predicates (arrays), only the matching objectID is removed. If the edges node becomes empty (only @id remains), it is removed from the @graph array.
func ReservedResourceTypeSlugs ¶
ReservedResourceTypeSlugs returns the set of slugs that cannot be used as resource type identifiers because they conflict with API route prefixes or are reserved for dedicated domain entities (auth).
func SeedAdminPolicies ¶
func SeedAdminPolicies(checker *authcasbin.CasbinAuthorizationChecker) error
SeedAdminPolicies ensures admin and owner roles have wildcard access. Idempotent — safe to call on every startup.
func StringField ¶
StringField extracts a string value from a map, returning "" if missing.
func SubscribeResourceHandlers ¶
func SubscribeResourceHandlers( d *domain.EventDispatcher, eventStore domain.EventStore, repo repositories.ResourceRepository, projMgr repositories.ProjectionManager, logger entities.Logger, ) error
SubscribeResourceHandlers exports the subscription for tests.
func SubscribeResourceTypeHandlers ¶
func SubscribeResourceTypeHandlers( d *domain.EventDispatcher, repo repositories.ResourceTypeRepository, projMgr repositories.ProjectionManager, logger entities.Logger, ) error
SubscribeResourceTypeHandlers exports the subscription for tests.
func SubscribeTripleHandlers ¶
func SubscribeTripleHandlers( d *domain.EventDispatcher, tripleRepo repositories.TripleRepository, logger entities.Logger, ) error
SubscribeTripleHandlers exports the subscription for tests.
func SyncAccessMapToCasbin ¶
func SyncAccessMapToCasbin( checker *authcasbin.CasbinAuthorizationChecker, newMap, oldMap entities.AccessMap, ) error
SyncAccessMapToCasbin clears stale role policies and re-adds from the new access map. oldAccessMap may be nil (on startup). It preserves admin and owner wildcard policies.
func WireResourceWriter ¶
func WireResourceWriter(writer *lazyResourceWriter, svc ResourceService) error
WireResourceWriter installs the real ResourceService into the lazy writer proxy after both have been constructed by Fx.
Fx guarantees that lazyResourceWriter and ResourceService are available before this invoke runs (parameter-level dependency ordering), but it does NOT impose ordering relative to other fx.Invoke calls that also depend on ResourceService. Any startup invoke that may call ResourceService.Create, Update, or Delete — and thus trigger behavior hooks that use BehaviorServices.Writer — MUST be registered after WireResourceWriter in application/module.go. Today the only such invoke is ensureBuiltInResourceTypes, and the module registers WireResourceWriter first; adding a new hook-triggering invoke earlier would silently regress this contract.
Returns an error on nil svc, self-target, or double-set so Fx aborts startup loudly instead of silently installing a broken proxy.
Types ¶
type BehaviorFactory ¶
type BehaviorFactory func(services BehaviorServices) entities.ResourceBehavior
BehaviorFactory constructs a ResourceBehavior given the available application services. Factories are invoked once at startup, after the Fx container is wired, allowing behaviors to close over real repositories and loggers. A factory must not return nil — that is treated as a programmer error and fails startup.
func StaticBehavior ¶
func StaticBehavior(b entities.ResourceBehavior) BehaviorFactory
StaticBehavior wraps a pre-constructed ResourceBehavior in a BehaviorFactory. Use this for behaviors that have no service dependencies, so presets can declare them inline without writing a factory function. Panics if b is nil.
type BehaviorInfo ¶
type BehaviorInfo struct {
Slug string `json:"slug"`
DisplayName string `json:"displayName"`
Description string `json:"description"`
Enabled bool `json:"enabled"`
Manageable bool `json:"manageable"`
}
BehaviorInfo describes a behavior's state for a resource type within the caller's account context.
type BehaviorMetaRegistry ¶
type BehaviorMetaRegistry map[string]entities.BehaviorMeta
BehaviorMetaRegistry maps resource type slugs to their behavior metadata. Used by services to expose available behaviors and enforce manageability.
func ProvideBehaviorMetaRegistry ¶
func ProvideBehaviorMetaRegistry(registry *PresetRegistry) BehaviorMetaRegistry
ProvideBehaviorMetaRegistry builds the metadata registry from all presets.
type BehaviorServices ¶
type BehaviorServices struct {
Resources repositories.ResourceRepository
Triples repositories.TripleRepository
ResourceTypes repositories.ResourceTypeRepository
Logger entities.Logger
// Writer lets behaviors create, update, or delete other resources through
// the full ResourceService pipeline. See lazyResourceWriter for the
// cycle-breaking rationale behind how this is wired.
Writer ResourceWriter
}
BehaviorServices bundles application services that ResourceBehavior factories may depend on. All fields are required when constructed by ProvideResourceBehaviorRegistry; tests that build BehaviorServices directly must supply real or fake implementations for any field their behavior touches.
type CreateResourceCommand ¶
type CreateResourceCommand struct {
TypeSlug string
Data json.RawMessage
}
type CreateResourceTypeCommand ¶
type CreateResourceTypeCommand struct {
Name string
Slug string
Description string
Context json.RawMessage
Schema json.RawMessage
}
type DeleteResourceCommand ¶
type DeleteResourceCommand struct {
ID string
}
type DeleteResourceTypeCommand ¶
type DeleteResourceTypeCommand struct {
ID string
}
type FileService ¶
type FileService = services.FileService
FileService is the application-layer alias for the domain FileService interface.
type GrantPermissionCommand ¶
type GrantPermissionCommand struct {
ResourceID string `json:"resource_id"`
AgentID string `json:"agent_id"`
Actions json.RawMessage `json:"actions"` // JSON array: ["read","modify","delete"]
}
type InstallPresetResult ¶
type InstallPresetResult struct {
Created []string `json:"created"`
Updated []string `json:"updated,omitempty"`
Skipped []string `json:"skipped"`
Seeded map[string]int `json:"seeded,omitempty"` // slug -> count of fixtures created
}
InstallPresetResult reports which types were created, updated, or skipped.
type MountedHandler ¶
type MountedHandler struct {
Method string
Path string
Protected bool
Handler http.HandlerFunc
Source string
}
MountedHandler is a fully-resolved preset HTTP route, ready to mount on the HTTP router. Source names the preset that contributed it, surfaced in collision errors and startup logs.
type PresetDefinition ¶
type PresetDefinition struct {
Name string
Description string
Types []PresetResourceType
Behaviors map[string]BehaviorFactory // slug -> factory invoked at startup with services
BehaviorMeta map[string]entities.BehaviorMeta // slug -> metadata for UI/config
Screens fs.FS // optional embedded screen components
Sidebar *PresetSidebarConfig // optional sidebar defaults
Handlers []PresetHTTPHandler // optional HTTP routes mounted under /api
AutoInstall bool // if true, types are auto-created at startup
}
PresetDefinition defines a named preset package that bundles resource types, behaviors, screen components, sidebar configuration, and HTTP routes.
func (PresetDefinition) ScreenManifest ¶
func (d PresetDefinition) ScreenManifest() map[string][]string
ScreenManifest walks the Screens FS and returns a map of typeSlug to screen filenames. Returns nil if Screens is nil or contains no .mjs files. Only files at exactly one level of nesting (<typeSlug>/<ScreenName>.mjs) are included; deeper paths are ignored.
type PresetHTTPHandler ¶
type PresetHTTPHandler struct {
Method string // GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD
Path string // relative to /api, e.g. "/leads/upload"
Factory func(BehaviorServices) http.HandlerFunc
Protected bool // true => mount behind auth middleware
}
PresetHTTPHandler describes one HTTP route contributed by a preset. The Factory is invoked once at server start with the same BehaviorServices that behavior factories receive, so handlers can close over real repositories without depending on Fx directly.
Path is relative to /api: a preset declaring Path "/leads/upload" mounts at /api/leads/upload. Protected selects the auth-gated group; public handlers land on the bare /api group and run without auth middleware.
type PresetHTTPHandlers ¶
type PresetHTTPHandlers []MountedHandler
PresetHTTPHandlers is a distinct nominal type for the Fx-provided list of resolved preset routes — keeps it from being confused with any other []MountedHandler that might enter the graph later.
func ProvidePresetHTTPHandlers ¶
func ProvidePresetHTTPHandlers( registry *PresetRegistry, resources repositories.ResourceRepository, triples repositories.TripleRepository, resourceTypes repositories.ResourceTypeRepository, logger entities.Logger, writer *lazyResourceWriter, ) (PresetHTTPHandlers, error)
ProvidePresetHTTPHandlers resolves preset-contributed HTTP routes against the same BehaviorServices that behavior factories receive, so handlers and behaviors share a single application-services view.
type PresetRegistry ¶
type PresetRegistry struct {
// contains filtered or unexported fields
}
PresetRegistry holds all registered presets. Preset packages call Add() to register.
func NewPresetRegistry ¶
func NewPresetRegistry() *PresetRegistry
NewPresetRegistry creates an empty registry.
func (*PresetRegistry) Add ¶
func (r *PresetRegistry) Add(def PresetDefinition) error
Add registers a preset. Returns an error if the definition is invalid. If a preset with the same name already exists, it is replaced.
func (*PresetRegistry) Behaviors ¶
func (r *PresetRegistry) Behaviors(services BehaviorServices) (ResourceBehaviorRegistry, error)
Behaviors returns a merged ResourceBehaviorRegistry from all registered presets, invoking each preset's BehaviorFactory exactly once with the supplied services. Presets are processed in alphabetical order; if multiple presets declare a behavior for the same slug, the last preset alphabetically wins and a warning is logged (when services.Logger is non-nil). Returns an error if any factory is nil or returns a nil ResourceBehavior — Add() rejects nil factories at registration time, so the nil-factory branch here is defense in depth.
func (*PresetRegistry) BehaviorsMeta ¶
func (r *PresetRegistry) BehaviorsMeta() BehaviorMetaRegistry
BehaviorsMeta returns a merged BehaviorMetaRegistry from all registered presets. Same merge semantics as Behaviors(): alphabetical order, last wins.
func (*PresetRegistry) Get ¶
func (r *PresetRegistry) Get(name string) (PresetDefinition, bool)
Get returns a preset by name. The returned value is a deep copy safe to mutate.
func (*PresetRegistry) Handlers ¶
func (r *PresetRegistry) Handlers(services BehaviorServices) ([]MountedHandler, error)
Handlers returns all preset-contributed HTTP routes, with each Factory invoked once with the supplied services. Ordering is alphabetical by preset name, preserving each preset's declared handler order. Returns an error if any factory is nil or returns nil, or if two presets declare the same "METHOD /path" — startup fails so the conflict can't go unnoticed.
func (*PresetRegistry) List ¶
func (r *PresetRegistry) List() []PresetDefinition
List returns all registered presets sorted by name. Returned values are deep copies.
func (*PresetRegistry) MustAdd ¶
func (r *PresetRegistry) MustAdd(def PresetDefinition)
MustAdd registers a preset and panics if the definition is invalid. Use for init-time registration of known-good preset data.
type PresetResourceType ¶
type PresetResourceType struct {
Name string
Slug string
Description string
Context json.RawMessage
Schema json.RawMessage
Fixtures []json.RawMessage // optional seed data created on install
}
PresetResourceType defines a single resource type within a preset.
func NewPresetType ¶
func NewPresetType(name, slug, desc, ctx, schema string) PresetResourceType
NewPresetType is a helper to create a PresetResourceType from raw strings.
type PresetSidebarConfig ¶
type PresetSidebarConfig struct {
HiddenSlugs []string // resource type slugs hidden by default
MenuGroups map[string]string // slug -> parent slug for sidebar nesting
}
PresetSidebarConfig holds default sidebar settings applied when a preset is installed.
type ReferencePropertyDef ¶
type ReferencePropertyDef struct {
PropertyName string // e.g. "invoiceId"
PredicateIRI string // e.g. "https://schema.org/object"
TargetType string // e.g. "invoice"
DisplayProperty string // e.g. "name" — property on the target resource shown in lists
}
ReferencePropertyDef describes a JSON Schema property that references another resource.
func ExtractReferenceProperties ¶
func ExtractReferenceProperties( schema json.RawMessage, ldContext json.RawMessage, ) []ReferencePropertyDef
ExtractReferenceProperties parses a JSON Schema and JSON-LD context to find properties that reference other resources (marked with x-resource-type) and their predicate IRIs.
type ResourceBehaviorRegistry ¶
type ResourceBehaviorRegistry map[string]entities.ResourceBehavior
ResourceBehaviorRegistry maps resource type slugs to their custom behaviors. Types without a registered behavior use DefaultBehavior (no-op).
func ProvideResourceBehaviorRegistry ¶
func ProvideResourceBehaviorRegistry( registry *PresetRegistry, resources repositories.ResourceRepository, triples repositories.TripleRepository, resourceTypes repositories.ResourceTypeRepository, logger entities.Logger, writer *lazyResourceWriter, ) (ResourceBehaviorRegistry, error)
ProvideResourceBehaviorRegistry builds the behavior registry from all registered presets, invoking each factory with the supplied services. Fails startup if any injected dependency is nil or any factory returns nil. The writer parameter is an unwired *lazyResourceWriter — see that type for the cycle-breaking rationale.
type ResourcePermissionService ¶
type ResourcePermissionService interface {
Grant(ctx context.Context, cmd GrantPermissionCommand) error
Revoke(ctx context.Context, cmd RevokePermissionCommand) error
ListForResource(ctx context.Context, resourceID string) ([]*entities.ResourcePermission, error)
}
func ProvideResourcePermissionService ¶
func ProvideResourcePermissionService(params struct {
fx.In
PermRepo repositories.ResourcePermissionRepository
ResourceRepo repositories.ResourceRepository
AccountRepo authrepos.AccountRepository
Logger entities.Logger
}) ResourcePermissionService
type ResourceService ¶
type ResourceService interface {
Create(ctx context.Context, cmd CreateResourceCommand) (*entities.Resource, error)
GetByID(ctx context.Context, id string) (*entities.Resource, error)
// GetFlat returns a single resource as a flat projection row (camelCase keys),
// including denormalized _display columns for x-resource-type references.
// Used by detail views so the frontend can render reference names without a
// client-side ID→name lookup cache. Returns an error for types with no
// projection table; caller should fall back to GetByID.
GetFlat(ctx context.Context, typeSlug, id string) (map[string]any, error)
List(ctx context.Context, typeSlug, cursor string, limit int, sort repositories.SortOptions) (
repositories.PaginatedResponse[*entities.Resource], error)
ListFlat(ctx context.Context, typeSlug, cursor string, limit int, sort repositories.SortOptions) (
repositories.PaginatedResponse[map[string]any], error)
ListByField(ctx context.Context, typeSlug, fieldName, fieldValue string) (
repositories.PaginatedResponse[*entities.Resource], error)
ListWithFilters(ctx context.Context, typeSlug string, filters []repositories.FilterCondition,
cursor string, limit int, sort repositories.SortOptions) (
repositories.PaginatedResponse[*entities.Resource], error)
ListFlatWithFilters(ctx context.Context, typeSlug string, filters []repositories.FilterCondition,
cursor string, limit int, sort repositories.SortOptions) (
repositories.PaginatedResponse[map[string]any], error)
Update(ctx context.Context, cmd UpdateResourceCommand) (*entities.Resource, error)
Delete(ctx context.Context, cmd DeleteResourceCommand) error
}
func NewResourceServiceForTest ¶
func NewResourceServiceForTest( repo repositories.ResourceRepository, typeRepo repositories.ResourceTypeRepository, tripleRepo repositories.TripleRepository, eventStore domain.EventStore, dispatcher *domain.EventDispatcher, logger entities.Logger, behaviors ResourceBehaviorRegistry, ) ResourceService
NewResourceServiceForTest creates a ResourceService without fx wiring. Pass nil for behaviors to use DefaultBehavior for all types.
func NewResourceServiceForTestWithSettings ¶
func NewResourceServiceForTestWithSettings( repo repositories.ResourceRepository, typeRepo repositories.ResourceTypeRepository, tripleRepo repositories.TripleRepository, eventStore domain.EventStore, dispatcher *domain.EventDispatcher, logger entities.Logger, behaviors ResourceBehaviorRegistry, behaviorMeta BehaviorMetaRegistry, behaviorSettings repositories.BehaviorSettingsRepository, ) ResourceService
NewResourceServiceForTestWithSettings creates a ResourceService with behavior settings support for tests that need account-scoped behavior config.
func ProvideResourceService ¶
func ProvideResourceService(params struct {
fx.In
Repo repositories.ResourceRepository
TypeRepo repositories.ResourceTypeRepository
TripleRepo repositories.TripleRepository
PermRepo repositories.ResourcePermissionRepository
AccountRepo authrepos.AccountRepository
EventStore domain.EventStore
Dispatcher *domain.EventDispatcher
Logger entities.Logger
Behaviors ResourceBehaviorRegistry
BehaviorMeta BehaviorMetaRegistry
BehaviorSettings repositories.BehaviorSettingsRepository
}) ResourceService
type ResourceTypeService ¶
type ResourceTypeService interface {
Create(ctx context.Context, cmd CreateResourceTypeCommand) (*entities.ResourceType, error)
GetByID(ctx context.Context, id string) (*entities.ResourceType, error)
GetBySlug(ctx context.Context, slug string) (*entities.ResourceType, error)
List(ctx context.Context, cursor string, limit int) (
repositories.PaginatedResponse[*entities.ResourceType], error)
Update(ctx context.Context, cmd UpdateResourceTypeCommand) (*entities.ResourceType, error)
Delete(ctx context.Context, cmd DeleteResourceTypeCommand) error
ListPresets() []PresetDefinition
InstallPreset(ctx context.Context, presetName string, update bool) (*InstallPresetResult, error)
ListBehaviors(ctx context.Context, typeSlug string) ([]BehaviorInfo, error)
SetBehaviors(ctx context.Context, typeSlug string, slugs []string) error
}
func NewResourceTypeServiceForTest ¶
func NewResourceTypeServiceForTest( repo repositories.ResourceTypeRepository, projMgr repositories.ProjectionManager, eventStore domain.EventStore, dispatcher *domain.EventDispatcher, registry *PresetRegistry, logger entities.Logger, resourceSvc ResourceService, ) ResourceTypeService
NewResourceTypeServiceForTest creates a ResourceTypeService without fx wiring.
func ProvideResourceTypeService ¶
func ProvideResourceTypeService(params struct {
fx.In
Repo repositories.ResourceTypeRepository
ProjMgr repositories.ProjectionManager
EventStore domain.EventStore
Dispatcher *domain.EventDispatcher
Registry *PresetRegistry
Logger entities.Logger
ResourceSvc ResourceService
Behaviors ResourceBehaviorRegistry
BehaviorMeta BehaviorMetaRegistry
BehaviorSettings repositories.BehaviorSettingsRepository
AccountRepo authrepos.AccountRepository
}) ResourceTypeService
type ResourceWriter ¶
type ResourceWriter interface {
Create(ctx context.Context, cmd CreateResourceCommand) (*entities.Resource, error)
Update(ctx context.Context, cmd UpdateResourceCommand) (*entities.Resource, error)
Delete(ctx context.Context, cmd DeleteResourceCommand) error
}
ResourceWriter is the subset of ResourceService that behaviors need to create, update, and delete other resources from inside a hook. It intentionally omits queries — use BehaviorServices.Resources for reads.
Write methods go through the full ResourceService pipeline: schema validation, JSON-LD graph assembly, triple extraction, event recording, and UnitOfWork commit, including nested behavior dispatch on the affected resources.
type RevokePermissionCommand ¶
type SortOptions ¶
type SortOptions = repositories.SortOptions
SortOptions re-exports for integration test convenience.
type UpdateResourceCommand ¶
type UpdateResourceCommand struct {
ID string
Data json.RawMessage
}
type UpdateResourceTypeCommand ¶
type UpdateResourceTypeCommand struct {
ID string
Name string
Slug string
Description string
Context json.RawMessage
Schema json.RawMessage
Status string
}
type UploadParams ¶
type UploadParams = services.UploadParams
UploadParams is the application-layer alias for the domain UploadParams type.
type UploadResult ¶
type UploadResult = services.UploadResult
UploadResult is the application-layer alias for the domain UploadResult type.
Source Files
¶
- auth_providers.go
- builtin_resource_types.go
- casbin_sync.go
- event_handlers.go
- file_service.go
- module.go
- preset_http_handlers.go
- preset_registry.go
- providers.go
- resource_behaviors.go
- resource_commands.go
- resource_helpers.go
- resource_permission_service.go
- resource_service.go
- resource_type_commands.go
- resource_type_service.go
- testing.go
- triple_extraction.go
- triple_handler.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package presets provides functions to register all built-in presets and create a fully populated registry.
|
Package presets provides functions to register all built-in presets and create a fully populated registry. |
|
core
Package core provides the built-in Person and Organization resource types with their associated behaviors.
|
Package core provides the built-in Person and Organization resource types with their associated behaviors. |
|
ecommerce
Package ecommerce provides resource types for e-commerce: products, offers, reviews, and services.
|
Package ecommerce provides resource types for e-commerce: products, offers, reviews, and services. |
|
events
Package events provides resource types for event management.
|
Package events provides resource types for event management. |
|
knowledge
Package knowledge provides SKOS-based resource types for knowledge organization.
|
Package knowledge provides SKOS-based resource types for knowledge organization. |
|
tasks
Package tasks provides resource types for task and project management.
|
Package tasks provides resource types for task and project management. |
|
website
Package website provides resource types for website structure and content.
|
Package website provides resource types for website structure and content. |