Compare commits
No commits in common. "62c25a7b3a32387e140450e18647904ab35c5491" and "d270bc8582f605a1814e350daee9088e80ad9ce4" have entirely different histories.
62c25a7b3a
...
d270bc8582
@ -1,42 +0,0 @@
|
|||||||
package badges
|
|
||||||
|
|
||||||
import "encoding/json"
|
|
||||||
|
|
||||||
// BadgeRule defines a condition for automatic badge assignment.
|
|
||||||
type BadgeRule struct {
|
|
||||||
Field string `json:"field"`
|
|
||||||
Operator string `json:"operator"` // eq, neq, gt, gte, lt, lte, contains, exists, true, false
|
|
||||||
Value any `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// BadgeDefinition defines a badge with auto-computation rules.
|
|
||||||
type BadgeDefinition struct {
|
|
||||||
Key string `json:"key"`
|
|
||||||
Label string `json:"label"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
Icon string `json:"icon"`
|
|
||||||
Rules []BadgeRule `json:"rules"`
|
|
||||||
RulesMode string `json:"rules_mode"` // "and" or "or"
|
|
||||||
ManualOnly bool `json:"manual_only"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParseDefinitions extracts badge definitions from a data table schema JSON.
|
|
||||||
func ParseDefinitions(schemaJSON []byte) []BadgeDefinition {
|
|
||||||
var schema map[string]any
|
|
||||||
if err := json.Unmarshal(schemaJSON, &schema); err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
badgesRaw, ok := schema["badges"]
|
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
raw, err := json.Marshal(badgesRaw)
|
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
var definitions []BadgeDefinition
|
|
||||||
if err := json.Unmarshal(raw, &definitions); err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return definitions
|
|
||||||
}
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
package plugin
|
|
||||||
|
|
||||||
import (
|
|
||||||
"git.dev.alexdunmow.com/block/core/rbac"
|
|
||||||
)
|
|
||||||
|
|
||||||
// CoreServiceBindings provides pre-built CMS service bindings that plugins
|
|
||||||
// can include in their ServiceRegistration with custom RBAC role mappings.
|
|
||||||
// The CMS constructs the actual service handlers — plugins just specify which
|
|
||||||
// services to mount and what roles apply.
|
|
||||||
type CoreServiceBindings interface {
|
|
||||||
Bind(serviceName string, methodRoles map[string]rbac.Role) (ConnectServiceBinding, error)
|
|
||||||
}
|
|
||||||
@ -46,12 +46,6 @@ type ServiceDeps struct {
|
|||||||
// Plugin interop
|
// Plugin interop
|
||||||
Bridge PluginBridge
|
Bridge PluginBridge
|
||||||
|
|
||||||
// Core RPC services — pre-built bindings for CMS-provided services
|
|
||||||
CoreServiceBindings CoreServiceBindings
|
|
||||||
ReviewSubmitter ReviewSubmitter
|
|
||||||
BadgeRefresher BadgeRefresher
|
|
||||||
SettingsUpdater settings.Updater
|
|
||||||
|
|
||||||
// Extension points — typed as narrow interfaces where possible
|
// Extension points — typed as narrow interfaces where possible
|
||||||
JobRunner JobRunner
|
JobRunner JobRunner
|
||||||
EmbeddingService EmbeddingService
|
EmbeddingService EmbeddingService
|
||||||
@ -87,10 +81,3 @@ type RAGResult struct {
|
|||||||
Score float64
|
Score float64
|
||||||
Metadata map[string]string
|
Metadata map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
// BadgeRefresher recomputes badges for a data table row.
|
|
||||||
// The CMS handles loading the table schema, aggregating ratings,
|
|
||||||
// evaluating badge rules, and persisting the updated badge list.
|
|
||||||
type BadgeRefresher interface {
|
|
||||||
RefreshBadges(ctx context.Context, tableID, rowID uuid.UUID) error
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,23 +0,0 @@
|
|||||||
package plugin
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ReviewSubmitter allows plugins to submit community reviews programmatically
|
|
||||||
// without importing CMS proto types.
|
|
||||||
type ReviewSubmitter interface {
|
|
||||||
SubmitReview(ctx context.Context, params SubmitReviewParams) (reviewID string, err error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SubmitReviewParams contains the fields needed to submit a community review.
|
|
||||||
type SubmitReviewParams struct {
|
|
||||||
TableID uuid.UUID
|
|
||||||
RowID uuid.UUID
|
|
||||||
OverallRating int32
|
|
||||||
ReviewText string
|
|
||||||
Ratings map[string]any
|
|
||||||
Photos []string
|
|
||||||
}
|
|
||||||
@ -8,11 +8,6 @@ type Settings interface {
|
|||||||
GetPluginSettings(ctx context.Context, pluginName string) (map[string]any, error)
|
GetPluginSettings(ctx context.Context, pluginName string) (map[string]any, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updater allows plugins to modify site settings.
|
|
||||||
type Updater interface {
|
|
||||||
UpdateSiteSetting(ctx context.Context, key string, value any) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetStringOr returns a string value from a map, or defaultVal if not found/wrong type.
|
// GetStringOr returns a string value from a map, or defaultVal if not found/wrong type.
|
||||||
func GetStringOr(m map[string]any, key, defaultVal string) string {
|
func GetStringOr(m map[string]any, key, defaultVal string) string {
|
||||||
if v, ok := m[key].(string); ok {
|
if v, ok := m[key].(string); ok {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user