All checks were successful
CI/CD / detect-changes (pull_request) Successful in 18s
CI/CD / test-frontend (pull_request) Successful in 5s
CI/CD / test-go-pg (pull_request) Successful in 2m42s
CI/CD / test-sqlite (pull_request) Successful in 2m59s
CI/CD / build-and-deploy (pull_request) Successful in 1m24s
Add realtime pub/sub: Starlark realtime.publish() module gated by new realtime.publish permission, WS room protocol (room.subscribe/ room.unsubscribe intercepted in readPump with 100-room cap), and SDK sw.realtime.subscribe() with auto room join/leave and reconnect recovery. Migrate 5 bare confirm() calls to sw.confirm() with destructive styling in tasks, schedules, notes (×2), and editor packages. Add admin permissions UI: per-permission grant/revoke drawer, Grant All bulk action, pending_review/suspended status badges, disabled enable toggle when pending. Closes v0.4.7 permissions UI gap. 8 new Go tests, all passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
67 lines
2.5 KiB
Go
67 lines
2.5 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// ── Package Status Constants ─────────────────
|
|
|
|
const (
|
|
// PackageStatusActive means the package is running normally.
|
|
PackageStatusActive = "active"
|
|
|
|
// PackageStatusPendingReview means the package declared permissions
|
|
// that require admin approval before activation.
|
|
PackageStatusPendingReview = "pending_review"
|
|
|
|
// PackageStatusSuspended means an admin has suspended the package.
|
|
PackageStatusSuspended = "suspended"
|
|
)
|
|
|
|
// ValidPackageStatuses is the set of valid package status values.
|
|
var ValidPackageStatuses = map[string]bool{
|
|
PackageStatusActive: true,
|
|
PackageStatusPendingReview: true,
|
|
PackageStatusSuspended: true,
|
|
}
|
|
|
|
// ── Extension Permission Constants ───────────
|
|
|
|
const (
|
|
ExtPermSecretsRead = "secrets.read"
|
|
ExtPermNotificationsSend = "notifications.send"
|
|
ExtPermDBRead = "db.read"
|
|
ExtPermDBWrite = "db.write"
|
|
ExtPermAPIHTTP = "api.http"
|
|
ExtPermFormValidate = "forms.validate" // v0.29.3: form validation hooks
|
|
ExtPermWorkflowAccess = "workflow.access" // v0.30.2: workflow definition + stage data access
|
|
ExtPermConnectionsRead = "connections.read" // v0.38.1: extension connection resolution
|
|
ExtPermTriggersRegister = "triggers.register" // v0.2.2: event/webhook trigger registration
|
|
ExtPermRealtimePublish = "realtime.publish" // v0.5.0: publish events to realtime channels
|
|
)
|
|
|
|
// ValidExtensionPermissions is the set of recognized permission keys.
|
|
var ValidExtensionPermissions = map[string]bool{
|
|
ExtPermSecretsRead: true,
|
|
ExtPermNotificationsSend: true,
|
|
ExtPermDBRead: true,
|
|
ExtPermDBWrite: true,
|
|
ExtPermAPIHTTP: true,
|
|
ExtPermFormValidate: true,
|
|
ExtPermWorkflowAccess: true,
|
|
ExtPermConnectionsRead: true,
|
|
ExtPermTriggersRegister: true,
|
|
ExtPermRealtimePublish: true,
|
|
}
|
|
|
|
// ── Extension Permission Model ───────────────
|
|
|
|
// ExtensionPermission represents a declared/granted capability for a package.
|
|
type ExtensionPermission struct {
|
|
ID string `json:"id" db:"id"`
|
|
PackageID string `json:"package_id" db:"package_id"`
|
|
Permission string `json:"permission" db:"permission"`
|
|
Granted bool `json:"granted" db:"granted"`
|
|
GrantedBy *string `json:"granted_by,omitempty" db:"granted_by"`
|
|
GrantedAt *time.Time `json:"granted_at,omitempty" db:"granted_at"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
}
|