core/subscriptions/subscriptions.go
Alex Dunmow 917eee13a2 feat: add menus, subscriptions, public users, and plugin bridge to SDK
New capability interfaces:
- menus.Menus: menu/nav access (GetMenuByName, GetMenuItems)
- subscriptions.Subscriptions: tier/plan access (GetUserTierLevel, GetTierBySlug, ListActivePlans)
- auth.PublicUsers: public user profiles (GetByUsername, GetByID)
- plugin.PluginBridge: inter-plugin service registry with typed GetServiceAs[T] helper

All added to ServiceDeps for plugin consumption.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-01 12:36:13 +08:00

45 lines
977 B
Go

package subscriptions
import (
"context"
"time"
"github.com/google/uuid"
)
// Subscriptions provides subscription tier and billing plan access for plugins.
type Subscriptions interface {
GetUserTierLevel(ctx context.Context, userID uuid.UUID) (*TierLevel, error)
GetTierBySlug(ctx context.Context, slug string) (*Tier, error)
ListActivePlans(ctx context.Context, tierID uuid.UUID) ([]Plan, error)
}
// TierLevel is the resolved tier for a user.
type TierLevel struct {
Level int
Features []byte
}
// Tier is a subscription tier definition.
type Tier struct {
ID uuid.UUID
Name string
Slug string
Level int
Description string
Features []byte
IsDefault bool
Position int
}
// Plan is an active billing plan within a tier.
type Plan struct {
ID uuid.UUID
TierID uuid.UUID
BillingInterval string
Amount int32
Currency string
IsActive bool
CreatedAt time.Time
}